diff --git a/lib/zin/wg/globalsearch/js/v1.js b/lib/zin/wg/globalsearch/js/v1.js new file mode 100644 index 0000000000..a2a5ff13a4 --- /dev/null +++ b/lib/zin/wg/globalsearch/js/v1.js @@ -0,0 +1,4 @@ +window.globalSearch = function(key, searchValue) +{ + openUrl(globalSearchUrl + searchValue + '&type=' + key); +} diff --git a/lib/zin/wg/globalsearch/v1.php b/lib/zin/wg/globalsearch/v1.php index 6367ac67da..a1c7015be3 100644 --- a/lib/zin/wg/globalsearch/v1.php +++ b/lib/zin/wg/globalsearch/v1.php @@ -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( diff --git a/module/index/ui/index.html.php b/module/index/ui/index.html.php index 97ddadbe12..cd4a65c4f3 100644 --- a/module/index/ui/index.html.php +++ b/module/index/ui/index.html.php @@ -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'),