xref: /plugin/statistics/SearchEngines.php (revision e357e0dc146ce72be1e61c3a8843707a04f43bc6)
12d987c80SAndreas Gohr<?php
22d987c80SAndreas Gohr
32d987c80SAndreas Gohrnamespace dokuwiki\plugin\statistics;
42d987c80SAndreas Gohr
52d987c80SAndreas Gohr/**
62d987c80SAndreas Gohr * Defines regular expressions for the most common search engines
72d987c80SAndreas Gohr */
82d987c80SAndreas Gohrclass SearchEngines
92d987c80SAndreas Gohr{
10*e357e0dcSAndreas Gohr (aider)    /** @var array Search engine definitions with regex patterns and metadata */
11*e357e0dcSAndreas Gohr (aider)    protected array $searchEngines = [
12*e357e0dcSAndreas Gohr (aider)        'google' => [
13*e357e0dcSAndreas Gohr (aider)            'name' => 'Google',
14*e357e0dcSAndreas Gohr (aider)            'url' => 'http://www.google.com',
15*e357e0dcSAndreas Gohr (aider)            'regex' => '^(\w+\.)*google(\.co)?\.([a-z]{2,5})$',
16*e357e0dcSAndreas Gohr (aider)            'params' => ['q']
17*e357e0dcSAndreas Gohr (aider)        ],
18*e357e0dcSAndreas Gohr (aider)        'bing' => [
19*e357e0dcSAndreas Gohr (aider)            'name' => 'Bing',
20*e357e0dcSAndreas Gohr (aider)            'url' => 'http://www.bing.com',
21*e357e0dcSAndreas Gohr (aider)            'regex' => '^(\w+\.)*bing(\.co)?\.([a-z]{2,5})$',
22*e357e0dcSAndreas Gohr (aider)            'params' => ['q']
23*e357e0dcSAndreas Gohr (aider)        ],
24*e357e0dcSAndreas Gohr (aider)        'yandex' => [
25*e357e0dcSAndreas Gohr (aider)            'name' => 'Яндекс (Yandex)',
26*e357e0dcSAndreas Gohr (aider)            'url' => 'http://www.yandex.ru',
27*e357e0dcSAndreas Gohr (aider)            'regex' => '^(\w+\.)*yandex(\.co)?\.([a-z]{2,5})$',
28*e357e0dcSAndreas Gohr (aider)            'params' => ['query']
29*e357e0dcSAndreas Gohr (aider)        ],
30*e357e0dcSAndreas Gohr (aider)        'yahoo' => [
31*e357e0dcSAndreas Gohr (aider)            'name' => 'Yahoo!',
32*e357e0dcSAndreas Gohr (aider)            'url' => 'http://www.yahoo.com',
33*e357e0dcSAndreas Gohr (aider)            'regex' => '^(\w+\.)*yahoo\.com$',
34*e357e0dcSAndreas Gohr (aider)            'params' => ['p']
35*e357e0dcSAndreas Gohr (aider)        ],
36*e357e0dcSAndreas Gohr (aider)        'naver' => [
37*e357e0dcSAndreas Gohr (aider)            'name' => '네이버 (Naver)',
38*e357e0dcSAndreas Gohr (aider)            'url' => 'http://www.naver.com',
39*e357e0dcSAndreas Gohr (aider)            'regex' => '^search\.naver\.com$',
40*e357e0dcSAndreas Gohr (aider)            'params' => ['query']
41*e357e0dcSAndreas Gohr (aider)        ],
42*e357e0dcSAndreas Gohr (aider)        'baidu' => [
43*e357e0dcSAndreas Gohr (aider)            'name' => '百度 (Baidu)',
44*e357e0dcSAndreas Gohr (aider)            'url' => 'http://www.baidu.com',
45*e357e0dcSAndreas Gohr (aider)            'regex' => '^(\w+\.)*baidu\.com$',
46*e357e0dcSAndreas Gohr (aider)            'params' => ['wd', 'word', 'kw']
47*e357e0dcSAndreas Gohr (aider)        ],
48*e357e0dcSAndreas Gohr (aider)        'ask' => [
49*e357e0dcSAndreas Gohr (aider)            'name' => 'Ask',
50*e357e0dcSAndreas Gohr (aider)            'url' => 'http://www.ask.com',
51*e357e0dcSAndreas Gohr (aider)            'regex' => '^(\w+\.)*ask\.com$',
52*e357e0dcSAndreas Gohr (aider)            'params' => ['ask', 'q', 'searchfor']
53*e357e0dcSAndreas Gohr (aider)        ],
54*e357e0dcSAndreas Gohr (aider)        'ask_search_results' => [
55*e357e0dcSAndreas Gohr (aider)            'name' => 'Ask',
56*e357e0dcSAndreas Gohr (aider)            'url' => 'http://www.ask.com',
57*e357e0dcSAndreas Gohr (aider)            'regex' => '^(\w+\.)*search-results\.com$',
58*e357e0dcSAndreas Gohr (aider)            'params' => ['ask', 'q', 'searchfor']
59*e357e0dcSAndreas Gohr (aider)        ],
60*e357e0dcSAndreas Gohr (aider)        'babylon' => [
61*e357e0dcSAndreas Gohr (aider)            'name' => 'Babylon',
62*e357e0dcSAndreas Gohr (aider)            'url' => 'http://search.babylon.com',
63*e357e0dcSAndreas Gohr (aider)            'regex' => '^search\.babylon\.com$',
64*e357e0dcSAndreas Gohr (aider)            'params' => ['q']
65*e357e0dcSAndreas Gohr (aider)        ],
66*e357e0dcSAndreas Gohr (aider)        'aol' => [
67*e357e0dcSAndreas Gohr (aider)            'name' => 'AOL Search',
68*e357e0dcSAndreas Gohr (aider)            'url' => 'http://search.aol.com',
69*e357e0dcSAndreas Gohr (aider)            'regex' => '^(\w+\.)*(aol)?((search|recherches?|images|suche|alicesuche)\.)aol(\.co)?\.([a-z]{2,5})$',
70*e357e0dcSAndreas Gohr (aider)            'params' => ['query', 'q']
71*e357e0dcSAndreas Gohr (aider)        ],
72*e357e0dcSAndreas Gohr (aider)        'duckduckgo' => [
73*e357e0dcSAndreas Gohr (aider)            'name' => 'DuckDuckGo',
74*e357e0dcSAndreas Gohr (aider)            'url' => 'http://duckduckgo.com',
75*e357e0dcSAndreas Gohr (aider)            'regex' => '^duckduckgo\.com$',
76*e357e0dcSAndreas Gohr (aider)            'params' => ['q']
77*e357e0dcSAndreas Gohr (aider)        ],
78*e357e0dcSAndreas Gohr (aider)        'google_avg' => [
79*e357e0dcSAndreas Gohr (aider)            'name' => 'Google',
80*e357e0dcSAndreas Gohr (aider)            'url' => 'http://www.google.com',
81*e357e0dcSAndreas Gohr (aider)            'regex' => '^search\.avg\.com$',
82*e357e0dcSAndreas Gohr (aider)            'params' => ['q']
83*e357e0dcSAndreas Gohr (aider)        ]
842d987c80SAndreas Gohr    ];
852d987c80SAndreas Gohr
862d987c80SAndreas Gohr    public function __construct()
872d987c80SAndreas Gohr    {
88*e357e0dcSAndreas Gohr (aider)        // Add the internal DokuWiki search engine
89*e357e0dcSAndreas Gohr (aider)        $this->searchEngines['dokuwiki'] = [
90*e357e0dcSAndreas Gohr (aider)            'name' => 'DokuWiki Internal Search',
91*e357e0dcSAndreas Gohr (aider)            'url' => wl(),
92*e357e0dcSAndreas Gohr (aider)            'regex' => '',
93*e357e0dcSAndreas Gohr (aider)            'params' => ['q']
94*e357e0dcSAndreas Gohr (aider)        ];
952d987c80SAndreas Gohr    }
962d987c80SAndreas Gohr
972d987c80SAndreas Gohr}
98