XOOPS
2.6.0
Main Page
Related Pages
Classes
Files
Examples
File List
File Members
search.php
Go to the documentation of this file.
1
<?php
2
/*
3
You may not change or alter any portion of this comment or credits
4
of supporting developers from this source code or any supporting source code
5
which is considered copyrighted (c) material of the original comment or credit authors.
6
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
*/
11
19
class
SearchSearchForm
extends
Xoops\Form\ThemeForm
20
{
26
public
function
__construct
($obj = null)
27
{
28
}
29
30
public
function
getSearchFrom
(
$andor
,
$queries
,
$mids
,
$mid
)
31
{
32
$xoops
=
Xoops::getInstance
();
33
$search
=
Search::getInstance
();
34
// create form
35
parent::__construct(
_MD_SEARCH
,
'search'
,
'index.php'
,
'get'
);
36
37
// create form elements
38
$this->
addElement
(
new
Xoops
\Form\Text(
_MD_SEARCH_KEYWORDS
,
'query'
, 30, 255, htmlspecialchars(stripslashes($this->
queryArrayToString
(
$queries
)), ENT_QUOTES)),
true
);
39
$type_select =
new
Xoops\Form\Select
(
_MD_SEARCH_TYPE
,
'andor'
,
$andor
);
40
$type_select->addOptionArray(array(
41
'AND'
=>
_MD_SEARCH_ALL
,
'OR'
=>
_MD_SEARCH_ANY
//, 'exact' => _MD_SEARCH_EXACT
42
));
43
$this->
addElement
($type_select);
44
if
(!empty(
$mids
)) {
45
$mods_checkbox =
new
Xoops\Form\Checkbox
(
_MD_SEARCH_SEARCHIN
,
'mids[]'
,
$mids
);
46
}
else
{
47
$mods_checkbox =
new
Xoops\Form\Checkbox
(
_MD_SEARCH_SEARCHIN
,
'mids[]'
,
$mid
);
48
}
49
if
(empty(
$modules
)) {
50
$gperm_handler
=
$xoops
->getHandlerGroupperm();
51
$available_modules
=
$gperm_handler
->getItemIds(
'module_read'
,
$xoops
->getUserGroups());
52
$available_plugins
= \Xoops\Module\Plugin::getPlugins(
'search'
);
53
54
//todo, would be nice to have the module ids availabe also
55
$criteria
=
new
CriteriaCompo
();
56
$criteria
->add(
new
Criteria
(
'dirname'
,
"('"
. implode(
"','"
, array_keys(
$available_plugins
)) .
"')"
,
'IN'
));
57
if
(isset(
$available_modules
) && !empty(
$available_modules
)) {
58
$criteria
->add(
new
Criteria
(
'mid'
,
'('
. implode(
','
,
$available_modules
) .
')'
,
'IN'
));
59
}
60
$module_handler
=
$xoops
->getHandlerModule();
61
$mods_checkbox->addOptionArray(
$module_handler
->getNameList(
$criteria
));
62
}
else
{
63
/* @var $module XoopsModule */
64
$module_array
= array();
65
foreach
(
$modules
as
$mid
=>
$module
) {
66
$module_array
[
$mid
] =
$module
->getVar(
'name'
);
67
}
68
$mods_checkbox->addOptionArray(
$module_array
);
69
}
70
$this->
addElement
($mods_checkbox);
71
if
(
$search
->getConfig(
'keyword_min'
) > 0) {
72
$this->
addElement
(
new
Xoops
\Form\Label(
_MD_SEARCH_SEARCHRULE
, sprintf(
_MD_SEARCH_KEYIGNORE
,
$search
->getConfig(
'keyword_min'
))));
73
}
74
$this->
addElement
(
new
Xoops
\Form\Hidden(
'action'
,
'results'
));
75
$this->
addElement
(
new
Xoops
\Form\Token(
'id'
));
76
$this->
addElement
(
new
Xoops
\Form\Button(
''
,
'submit'
,
_MD_SEARCH
,
'submit'
));
77
return
$this;
78
}
79
88
private
function
queryArrayToString
(
$queries
)
89
{
90
$query
=
''
;
91
foreach
(
$queries
as $term) {
92
if
(
false
=== strpos($term,
' '
)) {
93
$query
.= $term .
' '
;
94
}
else
{
95
$query
.=
'"'
. $term .
'" '
;
96
}
97
}
98
$query
= trim(
$query
);
99
return
$query
;
100
}
101
}
$mid
$mid
Definition:
index.php:39
$module_array
if(!empty($available_plugins)) $module_array[0]
Definition:
main.php:62
SearchSearchForm
Definition:
search.php:19
_MD_SEARCH_ALL
const _MD_SEARCH_ALL
Definition:
main.php:26
_MD_SEARCH_SEARCHIN
const _MD_SEARCH_SEARCHIN
Definition:
main.php:33
Xoops\getInstance
static getInstance()
Definition:
Xoops.php:160
Xoops\Form\Form\addElement
addElement(Element $formElement, $required=false)
Definition:
Form.php:206
$query
$query
Definition:
index.php:37
Xoops\Form\Checkbox
Definition:
Checkbox.php:27
SearchSearchForm\getSearchFrom
getSearchFrom($andor, $queries, $mids, $mid)
Definition:
search.php:30
$xoops
$xoops
Definition:
search.php:29
$queries
$queries
Definition:
index.php:44
SearchSearchForm\__construct
__construct($obj=null)
Definition:
search.php:26
_MD_SEARCH_KEYIGNORE
const _MD_SEARCH_KEYIGNORE
Definition:
main.php:35
$search
$search
Definition:
index.php:28
$gperm_handler
$gperm_handler
Definition:
xoops_smilies.php:75
Xoops\Form\ThemeForm
Definition:
ThemeForm.php:27
Xoops
$available_modules
$available_modules
Definition:
index.php:65
_MD_SEARCH_SEARCHRULE
const _MD_SEARCH_SEARCHRULE
Definition:
main.php:36
$module
$module
Definition:
main.php:52
_MD_SEARCH_TYPE
const _MD_SEARCH_TYPE
Definition:
main.php:32
_MD_SEARCH_KEYWORDS
const _MD_SEARCH_KEYWORDS
Definition:
main.php:31
_MD_SEARCH
const _MD_SEARCH
Definition:
main.php:19
$available_plugins
$available_plugins
Definition:
main.php:56
$modules
$modules
Definition:
userinfo.php:185
$criteria
$criteria
Definition:
page_configsite.php:52
$andor
$andor
Definition:
index.php:38
$module_handler
$module_handler
Definition:
main.php:55
$mids
$mids
Definition:
index.php:42
Xoops\Module\Helper\HelperAbstract\getInstance
static getInstance()
Definition:
HelperAbstract.php:61
CriteriaCompo
Definition:
criteria.php:22
Criteria
Definition:
criteria.php:29
_MD_SEARCH_ANY
const _MD_SEARCH_ANY
Definition:
main.php:25
Xoops\Form\Select
Definition:
Select.php:26
SearchSearchForm\queryArrayToString
queryArrayToString($queries)
Definition:
search.php:88
usr64
htdocs
modules
search
class
form
search.php
Generated on Fri May 22 2015 03:07:04 for XOOPS by
1.8.9.1