|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Xooghost\Plugin; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Xooghost module |
|
7
|
|
|
* |
|
8
|
|
|
* You may not change or alter any portion of this comment or credits |
|
9
|
|
|
* of supporting developers from this source code or any supporting source code |
|
10
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
|
11
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
16
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
17
|
|
|
* @package Xooghost |
|
18
|
|
|
* @since 2.6.0 |
|
19
|
|
|
* @author Laurent JEN (Aka DuGris) |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Class XooghostSearchPlugin |
|
24
|
|
|
*/ |
|
25
|
|
|
class SearchPlugin extends \Xoops\Module\Plugin\PluginAbstract implements \SearchPluginInterface |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* @param $queries |
|
29
|
|
|
* @param $andor |
|
30
|
|
|
* @param $limit |
|
31
|
|
|
* @param $start |
|
32
|
|
|
* @param $uid |
|
33
|
|
|
* |
|
34
|
|
|
* @return array |
|
35
|
|
|
*/ |
|
36
|
|
|
public function search($queries, $andor, $limit, $start, $uid) |
|
37
|
|
|
{ |
|
38
|
|
|
$searchstring = ''; |
|
|
|
|
|
|
39
|
|
|
$ret = []; |
|
40
|
|
|
|
|
41
|
|
|
$criteria = new \CriteriaCompo(); |
|
42
|
|
|
|
|
43
|
|
|
$criteria->setLimit($limit); |
|
44
|
|
|
$criteria->setStart($start); |
|
45
|
|
|
$criteria->setSort('xooghost_published'); |
|
46
|
|
|
$criteria->setOrder('DESC'); |
|
47
|
|
|
|
|
48
|
|
|
$criteria->add(new \Criteria('xooghost_online', 1)); |
|
49
|
|
|
$criteria->add(new \Criteria('xooghost_published', 0, '>')); |
|
50
|
|
|
$criteria->add(new \Criteria('xooghost_published', time(), '<=')); |
|
51
|
|
|
|
|
52
|
|
|
if (is_array($queries) && $count = count($queries)) { |
|
|
|
|
|
|
53
|
|
|
foreach ($queries as $k => $v) { |
|
54
|
|
|
$criteria_content = new \CriteriaCompo(); |
|
55
|
|
|
$criteria_content->add(new \Criteria('xooghost_title', '%' . $v . '%', 'LIKE'), 'OR'); |
|
56
|
|
|
$criteria_content->add(new \Criteria('xooghost_content', '%' . $v . '%', 'LIKE'), 'OR'); |
|
57
|
|
|
$criteria_content->add(new \Criteria('xooghost_description', '%' . $v . '%', 'LIKE'), 'OR'); |
|
58
|
|
|
$criteria_content->add(new \Criteria('xooghost_keywords', '%' . $v . '%', 'LIKE'), 'OR'); |
|
59
|
|
|
$criteria->add($criteria_content, $andor); |
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
if (0 != $uid) { |
|
64
|
|
|
$criteria->add(new \Criteria('xooghost_uid', $uid)); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$helper = \XoopsModules\Xooghost\Helper::getInstance(); |
|
68
|
|
|
$pageHandler = $helper->getHandler('Page'); |
|
69
|
|
|
|
|
70
|
|
|
$pages = $pageHandler->getObjects($criteria, true, false); |
|
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
$k = 0; |
|
73
|
|
|
foreach ($pages as $page) { |
|
74
|
|
|
$ret[$k]['image'] = 'assets/icons/logo_small.png'; |
|
75
|
|
|
$ret[$k]['link'] = $page['xooghost_url']; |
|
76
|
|
|
$ret[$k]['title'] = $page['xooghost_title']; |
|
77
|
|
|
$ret[$k]['time'] = $page['xooghost_time']; |
|
78
|
|
|
$ret[$k]['uid'] = $page['xooghost_uid']; |
|
79
|
|
|
$ret[$k]['content'] = $page['xooghost_content']; |
|
80
|
|
|
++$k; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
return $ret; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|