<?php

require_once "../phplib/util.php";
$form = util_getRequestParameter('form');
$locVersion = util_getRequestParameter('locVersion');
$locVersions = pref_getLocVersions();
if ($locVersion && $form) {
    LocVersion::changeDatabase($locVersion);
    $form = StringUtil::cleanupQuery($form);
    smarty_assign('page_title', 'Verificare LOC: ' . $form);
    $ifs = loadLoc($form);
    $lexems = array();
    $inflections = array();
    foreach ($ifs as $if) {
        $lexems[] = Lexem::get_by_id($if->lexemId);
        $inflections[] = Inflection::get_by_id($if->inflectionId);
    }
    smarty_assign('form', $form);
    smarty_assign('selectedLocVersion', $locVersion);
    smarty_assign('ifs', $ifs);
    smarty_assign('lexems', $lexems);
    smarty_assign('inflections', $inflections);
} else {
    smarty_assign('selectedLocVersion', $locVersions[1]->name);
    smarty_assign('page_title', 'Căutare formă flexionară în LOC ' . $form);
}
setlocale(LC_ALL, "ro_RO.utf8");
smarty_assign('locVersions', $locVersions);
smarty_displayCommonPageWithSkin('scrabble-flexiune.ihtml');
function loadLoc($cuv)
{
Пример #2
0
    $lexem = Lexem::get_by_id($lexemId);
    if ($lexem) {
        $lexems = array($lexem);
        $cuv = $lexem->formNoAccent;
    } else {
        $lexems = array();
        $cuv = NULL;
    }
}
if ($lexemId) {
    SmartyWrap::assign('paradigmLink', util_getWwwRoot() . "lexem/{$cuv}/{$lexemId}/paradigma");
} else {
    SmartyWrap::assign('paradigmLink', util_getWwwRoot() . "definitie/{$cuv}/paradigma");
}
if ($cuv) {
    $cuv = StringUtil::cleanupQuery($cuv);
}
// Normal search
if ($searchType == SEARCH_INFLECTED) {
    $lexems = Lexem::searchInflectedForms($cuv, $hasDiacritics);
    if (count($lexems) == 0) {
        $cuv_old = StringUtil::tryOldOrthography($cuv);
        $lexems = Lexem::searchInflectedForms($cuv_old, $hasDiacritics);
    }
}
// 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)) {
    $conjugations = false;
    $declensions = false;
Пример #3
0
// Abbreviation is not delimited by spaces
assertAbbreviations("AGNUS DEI", "AGNUS DEI", "AGNUS DEI", 32);
assertEquals('@MÁRE^2,@ $mări,$ s.f.', AdminStringUtil::migrateFormatChars('@MÁRE^2@, $mări$, s.f.'));
assertEquals('@$%spaced% text$@', AdminStringUtil::migrateFormatChars('@$ % spaced % text $@'));
assertEquals('40\\% dolomite', AdminStringUtil::migrateFormatChars('40\\% dolomite'));
assertEquals('40 %dolomite%', AdminStringUtil::migrateFormatChars('40% dolomite%'));
assertEquals('cățel', AdminStringUtil::internalizeWordName("C~A,t'EL"));
assertEquals('ă', AdminStringUtil::internalizeWordName("~~A~~!@#\$%^&*()123456790"));
assertEquals('casă', AdminStringUtil::removeAccents('cásă'));
assertEquals('mama', StringUtil::cleanupQuery("'mama'"));
assertEquals('mama', StringUtil::cleanupQuery('"mama"'));
assertEquals('aăbcdef', StringUtil::cleanupQuery("aăbc<mamă foo bar>def"));
assertEquals('AĂBCDEF', StringUtil::cleanupQuery("AĂBC<MAMĂ FOO BAR>DEF"));
assertEquals('a~abcdef', StringUtil::cleanupQuery("a~abc<mam~a foo bar>def"));
assertEquals('a~ABcdef', StringUtil::cleanupQuery("a~ABc<mam~a foo bar>def"));
assertEquals('1234', StringUtil::cleanupQuery('12&qweasd;34'));
assert(StringUtil::hasDiacritics('mamă'));
assert(!StringUtil::hasDiacritics('mama'));
$def = Model::factory('Definition')->create();
$def->sourceId = 1;
$def->internalRep = 'abcd';
assertEquals('abcd', AdminStringUtil::extractLexicon($def));
$def->internalRep = 'wxyz';
assertEquals('wxyz', AdminStringUtil::extractLexicon($def));
$def->internalRep = 'mamă';
assertEquals('mamă', AdminStringUtil::extractLexicon($def));
assert(StringUtil::hasRegexp('asd[0-9]'));
assert(!StringUtil::hasRegexp('ăâîșț'));
assert(StringUtil::hasRegexp('cop?l'));
assertEquals("like 'cop%l'", StringUtil::dexRegexpToMysqlRegexp('cop*l'));
assertEquals("like 'cop_l'", StringUtil::dexRegexpToMysqlRegexp('cop?l'));
$name = util_getRequestParameter('name');
$status = util_getRequestIntParameter('status');
$nick = util_getRequestParameter('nick');
$sourceId = util_getRequestIntParameter('source');
$yr1 = util_getRequestIntParameter('yr1');
$mo1 = util_getRequestIntParameter('mo1');
$da1 = util_getRequestIntParameter('da1');
$yr2 = util_getRequestIntParameter('yr2');
$mo2 = util_getRequestIntParameter('mo2');
$da2 = util_getRequestIntParameter('da2');
$searchButton = util_getRequestParameter('searchButton');
$ip = $_SERVER['REMOTE_ADDR'];
// Execute query and display results
// Convert wildcards to mysql format
if ($searchButton) {
    $name = StringUtil::cleanupQuery($name);
    $arr = StringUtil::analyzeQuery($name);
    $hasDiacritics = $arr[0];
    $hasRegexp = $arr[1];
    $isAllDigits = $arr[2];
    $field = $hasDiacritics ? 'formNoAccent' : 'formUtf8General';
    $userId = '';
    if ($nick) {
        $user = User::get_by_nick($nick);
        if ($user) {
            $userId = $user->id;
        }
    }
    $beginTime = mktime(0, 0, 0, $mo1, $da1, $yr1);
    $endTime = mktime(23, 59, 59, $mo2, $da2, $yr2);
    // Query the database and output the results
Пример #5
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");
}