register_hook('SEARCH_QUERY_PAGELOOKUP', 'AFTER', $this, 'searchPage', array()); } /** * Modify the returned pages * The {@link callLinkWiz} of inc/Ajax.php do * just a page search with {@link ft_pageLookup()} * https://www.dokuwiki.org/search * @param Doku_Event $event * @param $params * The path are initialized in {@link init_paths} * @return void */ function searchPage(Doku_Event $event, $params) { global $INPUT; /** * linkwiz is the editor toolbar action * qsearch is the search button */ $postCall = $INPUT->post->str('call'); if (!(in_array($postCall, ["linkwiz", "qsearch", action_plugin_combo_search::CALL]))) { return; } if (PluginUtility::getConfValue(self::CONF_ENABLE_ENHANCED_LINK_WIZARD, 1) === 0) { return; } $sqlite = Sqlite::createOrGetSqlite(); if ($sqlite === null) { return; } $searchTerm = $event->data["id"]; // yes id is the search term if (strlen($searchTerm) < 3) { return; } $pattern = "*$searchTerm*"; $patterns = [$pattern, $pattern, $pattern, $pattern]; $searchTerm = <<createRequest() ->setQueryParametrized($searchTerm, $patterns); try { $rows = $request ->execute() ->getRows(); } catch (ExceptionCombo $e) { LogUtility::msg("Error while trying to retrieve a list of page", LogUtility::LVL_MSG_ERROR, self::CANONICAL); } finally { $request->close(); } foreach ($rows as $row) { $event->result[$row["id"]] = $row["title"]; } } }