当前位置: 首页>>代码示例>>PHP>>正文


PHP StringUtil::analyzeQuery方法代码示例

本文整理汇总了PHP中StringUtil::analyzeQuery方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtil::analyzeQuery方法的具体用法?PHP StringUtil::analyzeQuery怎么用?PHP StringUtil::analyzeQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StringUtil的用法示例。


在下文中一共展示了StringUtil::analyzeQuery方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: define

<?php

require_once "../phplib/util.php";
define('TYPE_SHOW_ONLY_VERBS', 'conjugare');
define('TYPE_SHOW_NO_VERBS', 'declinare');
$cuv = util_getRequestParameter('cuv');
$lexemId = util_getRequestParameter('lexemId');
$ajax = util_getRequestParameter('ajax');
$type = util_getRequestParameter('type');
$searchType = SEARCH_INFLECTED;
$arr = StringUtil::analyzeQuery($cuv);
$hasDiacritics = session_user_prefers(Preferences::FORCE_DIACRITICS) || $arr[0];
// LexemId search
if ($lexemId) {
    $searchType = SEARCH_LEXEM_ID;
    SmartyWrap::assign('lexemId', $lexemId);
    if (!StringUtil::validateAlphabet($lexemId, '0123456789')) {
        $lexemId = '';
    }
    $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 {
开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:31,代码来源:paradigm.php

示例2: util_assertNotMirror

util_assertNotMirror();
$form = util_getRequestParameter('form');
$sourceId = util_getRequestParameter('source');
$loc = util_getRequestParameter('loc');
$paradigm = util_getRequestParameter('paradigm');
$structStatus = util_getRequestParameter('structStatus');
$nick = util_getRequestParameter('nick');
$searchButton = util_getRequestParameter('searchButton');
if (!$searchButton) {
    util_redirect('index.php');
}
$where = array();
$joins = array();
// Process the $form argument
$form = StringUtil::cleanupQuery($form);
list($hasDiacritics, $hasRegexp, $ignored) = StringUtil::analyzeQuery($form);
$field = $hasDiacritics ? 'formNoAccent' : 'formUtf8General';
if ($hasRegexp) {
    $fieldValue = StringUtil::dexRegexpToMysqlRegexp($form);
} else {
    $fieldValue = "= '{$form}'";
}
$where[] = "{$field} {$fieldValue}";
// Process the $sourceId argument
if ($sourceId) {
    $joins['definition'] = true;
    $where[] = "sourceId = {$sourceId}";
}
// Process the $loc argument
switch ($loc) {
    case 0:
开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:31,代码来源:lexemSearch.php

示例3: util_getRequestIntParameter

$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
    $defs = Definition::searchModerator($name, $hasDiacritics, $sourceId, $status, $userId, $beginTime, $endTime);
开发者ID:nastasie-octavian,项目名称:DEXonline,代码行数:31,代码来源:definitionLookup.php

示例4: assertEquals

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'));
assertEquals("rlike '^(cop[a-z]l)\$'", StringUtil::dexRegexpToMysqlRegexp('cop[a-z]l'));
assertEquals("rlike '^(cop[^a-z]l)\$'", StringUtil::dexRegexpToMysqlRegexp('cop[^a-z]l'));
assertEquals("rlike '^(cop[â-z]l)\$'", StringUtil::dexRegexpToMysqlRegexp('cop[â-z]l'));
assertEquals("rlike '^(cop[â-z]l.*)\$'", StringUtil::dexRegexpToMysqlRegexp('cop[â-z]l*'));
assertEqualArrays(array(0, 0, 0), StringUtil::analyzeQuery('mama'));
assertEqualArrays(array(1, 0, 0), StringUtil::analyzeQuery('mamă'));
assertEqualArrays(array(0, 1, 0), StringUtil::analyzeQuery('cop?l'));
assertEqualArrays(array(0, 1, 0), StringUtil::analyzeQuery('cop[c-g]l'));
assertEqualArrays(array(1, 1, 0), StringUtil::analyzeQuery('căț[c-g]l'));
assertEqualArrays(array(0, 0, 1), StringUtil::analyzeQuery('1234567'));
assertEquals('&#x25;&#x7e;&#x24;&#x40;&#x27;', AdminStringUtil::xmlizeRequired('\\%\\~\\$\\@\\\''));
assertEquals('&lt;&gt;&amp;', AdminStringUtil::xmlizeRequired('<>&'));
$t = FlexStringUtil::extractTransforms('arde', 'arzând', 0);
assertEquals(4, count($t));
assertEquals('d', $t[0]->transfFrom);
assertEquals('z', $t[0]->transfTo);
assertEquals('e', $t[1]->transfFrom);
assertEquals('', $t[1]->transfTo);
assertEquals('', $t[2]->transfFrom);
assertEquals('ând', $t[2]->transfTo);
assertEquals(UNKNOWN_ACCENT_SHIFT, $t[3]);
$t = FlexStringUtil::extractTransforms('frumos', 'frumoasă', 0);
assertEquals(3, count($t));
assertEquals('o', $t[0]->transfFrom);
assertEquals('oa', $t[0]->transfTo);
开发者ID:nastasie-octavian,项目名称:DEXonline,代码行数:31,代码来源:test.php

示例5: lookup

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");
}
开发者ID:florinp,项目名称:dexonline,代码行数:28,代码来源:dict-server.php

示例6: header

<?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);
?>

开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:24,代码来源:searchComplete.php


注:本文中的StringUtil::analyzeQuery方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。