Example #1
0
            if (!count($lexems)) {
                FlashMessage::add("Niciun rezultat relevant pentru „{$cuv}”.");
            }
        }
    }
    if (count($lexems) == 1 && $cuv != $lexems[0]->formNoAccent) {
        // Convenience redirect when there is only one correct form. We want all pages to be canonical
        $sourcePart = $source ? "-{$source->urlName}" : '';
        session_setVariable('redirect', true);
        session_setVariable('init_word', $cuv);
        util_redirect(util_getWwwRoot() . "definitie{$sourcePart}/{$lexems[0]->formNoAccent}" . ($xml ? '/xml' : ''));
    }
    smarty_assign('lexems', $lexems);
    if ($searchType == SEARCH_INFLECTED) {
        // For successful searches, load the definitions, inflections and linguistic articles
        $definitions = Definition::loadForLexems($lexems, $sourceId, $cuv, $exclude_unofficial);
        smarty_assign('wikiArticles', WikiArticle::loadForLexems($lexems));
    }
    if (isset($definitions)) {
        $searchResults = SearchResult::mapDefinitionArray($definitions);
    }
}
$conjugations = NULL;
$declensions = NULL;
if ($searchType == SEARCH_INFLECTED || $searchType == SEARCH_LEXEM_ID || $searchType == SEARCH_FULL_TEXT || $searchType == SEARCH_MULTIWORD) {
    smarty_assign('results', $searchResults);
    // Maps lexems to arrays of inflected forms (some lexems may lack inflections)
    // Also compute the text of the link to the paradigm div,
    // which can be 'conjugări', 'declinări' or both
    if (!empty($lexems)) {
        $ifMaps = array();
Example #2
0
function lookup($sourceId, $cuv, $fd)
{
    if (!source_exists($sourceId)) {
        socket_write($fd, "550 invalid database, use SHOW DB for a list\r\n");
        return;
    }
    if ($sourceId == '*' || $sourceId == '!') {
        $sourceId = 0;
    }
    $cuv = StringUtil::cleanupQuery($cuv);
    $arr = StringUtil::analyzeQuery($cuv);
    $field = $arr[0] ? 'formNoAccent' : 'formUtf8General';
    $lexems = db_find(new Lexem(), "{$field} = '{$cuv}' order by formNoAccent");
    $definitions = Definition::loadForLexems($lexems, $sourceId, $cuv);
    $searchResults = SearchResult::mapDefinitionArray($definitions);
    if (!count($definitions)) {
        socket_write($fd, "552 no match\r\n");
        return;
    }
    socket_write($fd, "150 " . count($definitions) . " definition(s) found\r\n");
    foreach ($searchResults as $sr) {
        $def = pretty_print($sr->definition->internalRep);
        socket_write($fd, "151 \"" . $cuv . "\" " . $sr->source->id . " \"" . $sr->source->name . "\"\r\n");
        socket_write($fd, "{$cuv}\r\n{$def}");
        socket_write($fd, ".\r\n");
    }
    socket_write($fd, "250 ok\r\n");
}