* zin: refactor globalSearch.
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
window.globalSearch = function(key, searchValue)
|
||||
{
|
||||
openUrl(globalSearchUrl + searchValue + '&type=' + key);
|
||||
}
|
||||
@@ -8,12 +8,22 @@ class globalSearch extends wg
|
||||
'commonSearchText?: string',
|
||||
'commonSearchUrl: string',
|
||||
'searchItems: array',
|
||||
'searchFunc: callable'
|
||||
);
|
||||
|
||||
public static function getPageJS(): string|false
|
||||
{
|
||||
return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
|
||||
}
|
||||
|
||||
protected function build(): array
|
||||
{
|
||||
global $lang;
|
||||
$this->setDefaultProps(array('commonSearchText' => $lang->searchAB));
|
||||
$this->setDefaultProps(array(
|
||||
'commonSearchText' => $lang->searchAB,
|
||||
'commonSearchUrl' => 'all',
|
||||
'searchFunc' => jsRaw('window.globalSearch'),
|
||||
));
|
||||
|
||||
$input = inputGroup
|
||||
(
|
||||
@@ -32,7 +42,7 @@ class globalSearch extends wg
|
||||
$input->setProp('data-zin-id', $input->gid);
|
||||
$props = array_merge
|
||||
(
|
||||
$this->props->pick(array('commonSearchText', 'commonSearchUrl', 'searchItems')),
|
||||
$this->props->pick(array('commonSearchText', 'commonSearchKey', 'searchItems', 'searchFunc')),
|
||||
array('_to' => "[data-zin-id='{$input->gid}']")
|
||||
);
|
||||
return array(
|
||||
|
||||
@@ -80,12 +80,13 @@ div
|
||||
$canSearch = hasPriv('search', 'index');
|
||||
if($canSearch)
|
||||
{
|
||||
$searchUrl = createLink('search', 'index') . ($config->requestType == 'GET' ? '&' : '?') . 'words={searchValue}';
|
||||
$searchUrl = createLink('search', 'index') . ($config->requestType == 'GET' ? '&' : '?') . 'words=';
|
||||
jsVar('window.globalSearchUrl', $searchUrl);
|
||||
$searchItems = array();
|
||||
foreach($lang->searchObjects as $key => $module)
|
||||
{
|
||||
if($key == 'all') continue;
|
||||
$searchItems[] = array('key' => $key, 'text' => $module, 'url' => $searchUrl . "&type={$key}");
|
||||
$searchItems[] = array('key' => $key, 'text' => $module);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,11 +101,7 @@ div
|
||||
toolbar
|
||||
(
|
||||
setID('appsToolbar'),
|
||||
$canSearch ? globalSearch
|
||||
(
|
||||
set::commonSearchUrl($searchUrl),
|
||||
set::searchItems($searchItems)
|
||||
) : null,
|
||||
$canSearch ? globalSearch(set::searchItems($searchItems)) : null,
|
||||
item
|
||||
(
|
||||
set::class('ghost btn-zentao'),
|
||||
|
||||
Reference in New Issue
Block a user