static function registerOutputFilters() { if (session_user_prefers(Preferences::CEDILLA_BELOW)) { self::$theSmarty->registerFilter('output', array('StringUtil', 'replace_st')); } if (session_user_prefers(Preferences::OLD_ORTHOGRAPHY)) { self::$theSmarty->registerFilter('output', array('StringUtil', 'replace_ai')); } }
// Exercise the fields we'll need later in the view. // TODO: this code replicates code from search.php $hasUnrecommendedForms = false; foreach ($filtered_lexems as $l) { foreach ($l->getLexemModels() as $lm) { $lm->getModelType(); $lm->getSourceNames(); $map = $lm->loadInflectedFormMap(); $lm->addLocInfo(); foreach ($map as $ifs) { foreach ($ifs as $if) { $hasUnrecommendedForms |= !$if->recommended; } } } } SmartyWrap::assign('hasUnrecommendedForms', $hasUnrecommendedForms); SmartyWrap::assign('lexems', $filtered_lexems); SmartyWrap::assign('showParadigm', true); SmartyWrap::assign('locParadigm', session_user_prefers(Preferences::LOC_PARADIGM)); SmartyWrap::assign('onlyParadigm', !$ajax); } else { FlashMessage::add("Niciun rezultat pentru {$cuv}."); SmartyWrap::assign('page_title', "Eroare"); } if ($ajax) { SmartyWrap::displayWithoutSkin('bits/multiParadigm.ihtml'); } else { SmartyWrap::addCss('paradigm'); SmartyWrap::display('search.ihtml'); }
$cuv = StringUtil::cleanupQuery($cuv); } util_redirectToFriendlyUrl($cuv, $sourceUrlName, $text, $showParadigm, $xml); $searchType = SEARCH_INFLECTED; $hasDiacritics = session_user_prefers('FORCE_DIACRITICS'); $exclude_unofficial = session_user_prefers('EXCLUDE_UNOFFICIAL'); $hasRegexp = FALSE; $isAllDigits = FALSE; $showParadigm = $showParadigm || session_user_prefers('SHOW_PARADIGM'); $paradigmLink = $_SERVER['REQUEST_URI'] . ($showParadigm ? '' : '/paradigma'); $source = $sourceUrlName ? Source::get_by_urlName($sourceUrlName) : null; $sourceId = $source ? $source->id : null; if ($cuv) { smarty_assign('cuv', $cuv); $arr = StringUtil::analyzeQuery($cuv); $hasDiacritics = session_user_prefers('FORCE_DIACRITICS') || $arr[0]; $hasRegexp = $arr[1]; $isAllDigits = $arr[2]; } if ($isAllDigits) { $d = Definition::get_by_id($cuv); if ($d) { util_redirect(util_getWwwRoot() . "definitie/{$d->lexicon}/{$d->id}" . ($xml ? '/xml' : '')); } } if ($text) { $searchType = SEARCH_FULL_TEXT; if (Lock::exists(LOCK_FULL_TEXT_INDEX)) { smarty_assign('lockExists', true); $definitions = array(); } else {
<?php require_once "../../phplib/util.php"; header("Content-Type: application/json"); $acEnable = Config::get("search.acEnable"); $acMinChars = Config::get("search.acMinChars"); $acLimit = Config::get("search.acLimit"); $search = util_getRequestParameter('term'); if (!$acEnable || strlen($search) < $acMinChars) { return print json_encode(array()); } $hasDiacritics = session_user_prefers(Preferences::FORCE_DIACRITICS) || StringUtil::hasDiacritics($search); $search_results = Lexem::searchLike("{$search}%", $hasDiacritics, true, $acLimit); $clean_results = array_map(function ($rec) { return $rec['formNoAccent']; }, $search_results); return print json_encode($clean_results); ?>
function smarty_register_outputfilters() { if (session_user_prefers('CEDILLA_BELOW')) { smarty_registerOutputFilter($GLOBALS['smarty_theSmarty'], 'smarty_filter_display_st_cedilla_below'); } if (session_user_prefers('OLD_ORTHOGRAPHY')) { smarty_registerOutputFilter($GLOBALS['smarty_theSmarty'], 'smarty_filter_display_old_orthography'); } }
<?php require_once "../phplib/util.php"; header("Content-Type: application/json"); $acEnable = Config::get("search.acEnable"); $acMinChars = Config::get("search.acMinChars"); $acLimit = Config::get("search.acLimit"); $search = $_REQUEST["term"]; if (!$acEnable || strlen($search) < $acMinChars) { return print json_encode(array()); } $arr = StringUtil::analyzeQuery($search); $hasDiacritics = session_user_prefers(Preferences::FORCE_DIACRITICS) || $arr[0]; $sql_like = sprintf("%s%%", $search); $search_results = Lexem::searchLike($sql_like, $hasDiacritics, true, $acLimit); $clean_results = array_map(function ($lexem) use($hasDiacritics) { if ($hasDiacritics) { return $lexem->formNoAccent; } else { return $lexem->formUtf8General; } }, $search_results); return print json_encode($clean_results); ?>