1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8//this script may only be included - so its better to die if called directly.
9if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
10	header("location: index.php");
11	exit;
12}
13
14/**
15 * @return array
16 */
17function module_websearch_info()
18{
19	return [
20		'name' => tra('websearch'),
21		'description' => tra('Displays a simple form to perform a web search with choice on multiple search engines.'),
22		'prefs' => [],
23		'params' => [
24					'title' => [
25						'name' => tra('title'),
26						'description' => tra('Direction for menu: horiz or vert (default vert)'),
27						'default' => 'false',
28						'filter' => 'text',
29						'options' => [
30							['text' => '', 'value' => ''],
31							['text' => tra('True'), 'value' => 'true'],
32							['text' => tra('False'), 'value' => 'false']
33						]
34					],]
35	];
36}
37
38/**
39 * @param $mod_reference
40 * @param $module_params
41 */
42function module_websearch($mod_reference, $module_params)
43{
44	$url_page_info_engines = "https://doc.tiki.org/web_search_engines";
45	$engines = [
46		"Google" => "https://www.google.com/search?q=",
47		"Google Images" => "https://www.google.com/images?q=",
48		"Bing" => "https://www.bing.com/search?q=",
49		"Bing Images" => "https://www.bing.com/images?q=",
50		"Yahoo" => "https://search.yahoo.com/search?p=",
51		"Yahoo Images" => "https://images.search.yahoo.com/search/images?p=",
52		"Searx" => "https://searx.me/?q=",
53				"Searx Images" => "https://searx.me/?&category_images=on&q=",
54		"Qwant" => "https://www.qwant.com/?q=",
55				"Qwant Images" => "https://www.qwant.com/?t=images&q=",
56		"Startpage" => "https://www.startpage.com/do/asearch?&query=",
57				"Startpage Images" => "https://www.startpage.com/do/asearch?cat=pics&query=",
58		"Ask" => "https://www.ask.com/web?q=",
59				"Ask Videos" => "https://www.ask.com/youtube?q=",
60		"Duckduckgo" => "https://duckduckgo.com/?q=",
61				"Duckduckgo Images" => "https://duckduckgo.com/?iax=images&ia=images&q=",
62		"Pickanews" => "https://www.pickanews.com/find?q=",
63				"SearchEncrypt" => "https://www.searchencrypt.com/search?eq=",
64				"Swisscows" => "https://swisscows.ch/?query=",
65				"Gigablast" => "http://www.gigablast.com/search?q=",
66	];
67		ksort($engines);
68		$smarty = TikiLib::lib('smarty');
69		$smarty->assign('url_page_info_engines', $url_page_info_engines);
70	$smarty->assign('engines', $engines);
71}
72