v1.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace zin;
  3. class globalSearch extends wg
  4. {
  5. public static function getPageJS()
  6. {
  7. return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js');
  8. }
  9. protected function build()
  10. {
  11. global $config, $lang;
  12. if($config->systemMode == 'light') unset($lang->searchObjects['program'], $lang->searchObjects['charter']);
  13. unset($lang->searchObjects['all']);
  14. $searchItems = array();
  15. $searchItems[] = array('key' => 'search', 'text' => $lang->searchAB . ' {0}');
  16. foreach($lang->searchObjects as $key => $module) $searchItems[] = array('key' => $key, 'text' => $module . ' #{0}');
  17. $searchItemsEncoded = json_encode($searchItems);
  18. pageJS(<<<JS
  19. window.getSearchItems = () => JSON.parse(`{$searchItemsEncoded}`);
  20. JS
  21. );
  22. return zui::globalSearch
  23. (
  24. set::_id('globalSearch'),
  25. set::_class('w-44'),
  26. set::items($searchItems),
  27. set::searchHint($lang->searchAB),
  28. set::popPlacement('top-start'),
  29. set::popWidth(240),
  30. set::searchBox(array('circle' => true, 'prefixClass' => 'text-primary opacity-100', 'className' => 'size-md')),
  31. set::getSearchType(jsRaw('window.getGlobalSearchType')),
  32. set::onSearch(jsRaw('window.handleGlobalSearch')),
  33. inherit($this)
  34. );
  35. }
  36. }