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


PHP Source::get_by_shortName方法代码示例

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


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

示例1: getSqlStatement

 private static function getSqlStatement($manual)
 {
     /*
      *                      nick            source (short)     createDate              1:ratio (3-> 33%, 4 -> 25%)
      */
     $bulk = array(array(null, "MDN '00", " = '2007-09-15'", null), array(null, 'Petro-Sedim', null, null), array(null, 'GTA', null, null), array(null, 'DCR2', null, null), array(null, 'DOR', null, null), array('raduborza', 'DOOM 2', " > '2013-01-01'", 4), array(null, 'DRAM', null, null), array('siveco', null, null, null), array('RACAI', null, null, null));
     $conditions = array();
     foreach ($bulk as $tuple) {
         $parts = array();
         if ($tuple[0]) {
             $user = User::get_by_nick($tuple[0]);
             $parts[] = "(userId = {$user->id})";
         }
         if ($tuple[1]) {
             $src = Source::get_by_shortName($tuple[1]);
             $parts[] = "(sourceId = {$src->id})";
         }
         if ($tuple[2]) {
             $parts[] = "(left(from_unixtime(createDate), 10)" . $tuple[2] . ")";
         }
         if ($tuple[3]) {
             $parts[] = "(Definition.id%{$tuple[3]}!=0)";
         }
         $conditions[] = '(' . implode(' and ', $parts) . ')';
     }
     $clause = '(' . implode(' or ', $conditions) . ')';
     if ($manual) {
         $clause = "not {$clause}";
     }
     $statusClause = util_isModerator(PRIV_VIEW_HIDDEN) ? sprintf("status in (%d,%d)", ST_ACTIVE, ST_HIDDEN) : sprintf("status = %d", ST_ACTIVE);
     $query = "select nick, count(*) as NumDefinitions, sum(length(internalRep)) as NumChars, max(createDate) as Timestamp \n    from Definition, User \n    where userId = User.id \n    and {$statusClause}\n    and {$clause} group by nick";
     return $query;
 }
开发者ID:Jobava,项目名称:mirror-dexonline,代码行数:33,代码来源:TopEntry.php

示例2: getSqlStatement

 private static function getSqlStatement($manual)
 {
     $bulk = array(array(null, Source::get_by_shortName('MDN'), '2007-09-15'), array(null, Source::get_by_shortName('Petro-Sedim'), null), array(null, Source::get_by_shortName('GTA'), null), array(null, Source::get_by_shortName('DCR2'), null), array(null, Source::get_by_shortName('DOR'), null), array(User::get_by_nick('siveco'), null, null), array(User::get_by_nick('RACAI'), null, null));
     $conditions = array();
     foreach ($bulk as $tuple) {
         $parts = array();
         if ($tuple[0]) {
             $parts[] = "(userId = {$tuple[0]->id})";
         }
         if ($tuple[1]) {
             $parts[] = "(sourceId = {$tuple[1]->id})";
         }
         if ($tuple[2]) {
             $parts[] = "(left(from_unixtime(createDate), 10) = '{$tuple[2]}')";
         }
         $conditions[] = '(' . implode(' and ', $parts) . ')';
     }
     $clause = '(' . implode(' or ', $conditions) . ')';
     if ($manual) {
         $clause = "not {$clause}";
     }
     $statusClause = util_isModerator(PRIV_VIEW_HIDDEN) ? sprintf("status in (%d,%d)", ST_ACTIVE, ST_HIDDEN) : sprintf("status = %d", ST_ACTIVE);
     $query = "select nick, count(*) as NumDefinitions, sum(length(internalRep)) as NumChars, max(createDate) as Timestamp \n    from Definition, User \n    where userId = User.id \n    and {$statusClause}\n    and {$clause} group by nick";
     return $query;
 }
开发者ID:nastasie-octavian,项目名称:DEXonline,代码行数:25,代码来源:TopEntry.php

示例3: foreach

        }
    }
    // Delete lexems
    foreach ($deleteMap as $lId => $value) {
        if ($value == 2) {
            // Checked and confirmed
            $l = Lexem::get_by_id($lId);
            $l->delete();
        }
    }
    // Now save the ones that can be saved and present errors for the others
    foreach ($lexemMap as $id => $l) {
        if (!array_key_exists($id, $errorMap) && !array_key_exists($id, $deleteMap)) {
            $l->save();
            $lm = $l->getFirstLexemModel();
            $lm->save();
            $lm->regenerateParadigm();
        }
    }
}
$deSource = Source::get_by_shortName('DE');
$lexems = Model::factory('Lexem')->table_alias('l')->select('l.*')->distinct()->join('LexemModel', 'l.id = lm.lexemId', 'lm')->join('LexemDefinitionMap', 'l.id = ldm.lexemId', 'ldm')->join('Definition', 'ldm.definitionId = d.id', 'd')->where('d.status', Definition::ST_ACTIVE)->where('d.sourceId', $deSource->id)->where('lm.isLoc', 0)->where_like('l.formNoAccent', "{$prefix}%")->where('l.verifSp', 0)->where_not_equal('lm.modelType', 'SP')->order_by_asc('l.formNoAccent')->limit(100)->find_many();
foreach ($lexems as $l) {
    $l->restrP = strpos($l->restriction, 'P') !== false;
    $l->restrS = strpos($l->restriction, 'S') !== false;
}
RecentLink::createOrUpdate('Marcare substantive proprii');
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::assign('lexems', $lexems);
SmartyWrap::assign('prefix', $prefix);
SmartyWrap::displayAdminPage('admin/properNouns.tpl');
开发者ID:florinp,项目名称:dexonline,代码行数:31,代码来源:properNouns.php

示例4: file

<?php

require_once __DIR__ . '/../phplib/util.php';
$lines = file('/tmp/scriban.txt');
$scribanSrc = Source::get_by_shortName('scriban');
foreach ($lines as $line) {
    $line = mb_strtolower(trim($line));
    if ($line) {
        $symbol = $line[0] == '!' ? '!' : '*';
        $line = str_replace(array('ş', 'ţ', '*', '!'), array('ș', 'ț', '', ''), $line);
        if (ctype_digit($line[0]) && !ctype_digit($line)) {
            $number = $line[0];
            $line = substr($line, 1);
        } else {
            $number = 0;
        }
        $query = Model::factory('Definition')->where('sourceId', $scribanSrc->id)->where('status', 0);
        if (ctype_digit($line)) {
            $query = $query->where('id', $line);
        } else {
            if ($number) {
                $query = $query->where_raw("lexicon = '{$line}' and (internalRep rlike '^@{$number}) ' or internalRep rlike '^@\\*{$number}) ')");
            } else {
                $query = $query->where('lexicon', $line);
            }
        }
        $defs = $query->find_many();
        if (count($defs) != 1) {
            printf("Am găsit %d definiții pentru [%s]\n", count($defs), $line);
        } else {
            if (strpos(substr($defs[0]->internalRep, 0, 10), $symbol) !== false) {
开发者ID:florinp,项目名称:dexonline,代码行数:31,代码来源:addScribanAsterisk.php

示例5: handleLexemActions

function handleLexemActions()
{
    $lexemId = util_getRequestParameter('lexemId');
    $lexem = Lexem::get_by_id($lexemId);
    $associateDefinitionId = util_getRequestParameter('associateDefinitionId');
    if ($associateDefinitionId) {
        LexemDefinitionMap::associate($lexem->id, $associateDefinitionId);
        util_redirect("lexemEdit.php?lexemId={$lexem->id}");
    }
    $dissociateDefinitionId = util_getRequestParameter('dissociateDefinitionId');
    if ($dissociateDefinitionId) {
        LexemDefinitionMap::dissociate($lexem->id, $dissociateDefinitionId);
        util_redirect("lexemEdit.php?lexemId={$lexem->id}");
    }
    $createDefinition = util_getRequestParameter('createDefinition');
    $miniDefTarget = util_getRequestParameter('miniDefTarget');
    if ($createDefinition) {
        $def = Model::factory('Definition')->create();
        $def->userId = session_getUserId();
        $def->sourceId = Source::get_by_shortName('Neoficial')->id;
        $def->lexicon = $lexem->formNoAccent;
        $def->internalRep = '@' . mb_strtoupper(AdminStringUtil::internalize($lexem->form, false)) . '@ v. @' . $miniDefTarget . '.@';
        $def->htmlRep = AdminStringUtil::htmlize($def->internalRep, $def->sourceId);
        $def->status = Definition::ST_ACTIVE;
        $def->save();
        LexemDefinitionMap::associate($lexem->id, $def->id);
        util_redirect("lexemEdit.php?lexemId={$lexem->id}");
    }
    $deleteLexem = util_getRequestParameter('deleteLexem');
    if ($deleteLexem) {
        $homonyms = Model::factory('Lexem')->where('formNoAccent', $lexem->formNoAccent)->where_not_equal('id', $lexem->id)->find_many();
        $lexem->delete();
        SmartyWrap::assign('lexem', $lexem);
        SmartyWrap::assign('homonyms', $homonyms);
        SmartyWrap::displayAdminPage('admin/lexemDeleted.tpl');
        exit;
    }
    $cloneLexem = util_getRequestParameter('cloneLexem');
    if ($cloneLexem) {
        $newLexem = $lexem->cloneLexem();
        log_userLog("Cloned lexem {$lexem->id} ({$lexem->form}), new id is {$newLexem->id}");
        util_redirect("lexemEdit.php?lexemId={$newLexem->id}");
    }
    $mergeLexem = util_getRequestParameter('mergeLexem');
    $mergeLexemId = util_getRequestParameter('mergeLexemId');
    if ($mergeLexem) {
        $other = Lexem::get_by_id($mergeLexemId);
        if ($lexem->form != $other->form) {
            FlashMessage::add('Nu pot unifica lexemele deoarece accentele diferă. Rezolvați diferența și încercați din nou.');
            util_redirect("lexemEdit.php?lexemId={$lexem->id}");
        }
        $defs = Definition::loadByLexemId($lexem->id);
        foreach ($defs as $def) {
            LexemDefinitionMap::associate($other->id, $def->id);
        }
        // Add lexem models from $lexem to $other if the form is the same. Exclude T-type models.
        $displayOrder = count($other->getLexemModels());
        foreach ($lexem->getLexemModels() as $lm) {
            if ($lm->modelType != 'T' && !$other->hasModel($lm->modelType, $lm->modelNumber)) {
                $lm->lexemId = $other->id;
                $lm->displayOrder = ++$displayOrder;
                $lm->save();
            }
        }
        // Add meanings from $lexem to $other and renumber their displayOrder and breadcrumb
        // displayOrders are generated sequentially regardless of level.
        // Breadcrumbs follow levels so only their first part changes.
        $counter = Model::factory('Meaning')->where('lexemId', $other->id)->count();
        $numRoots = Model::factory('Meaning')->where('lexemId', $other->id)->where('parentId', 0)->count();
        $meanings = Model::factory('Meaning')->where('lexemId', $lexem->id)->order_by_asc('displayOrder')->find_many();
        foreach ($meanings as $m) {
            $m->lexemId = $other->id;
            $m->displayOrder = ++$counter;
            $parts = explode('.', $m->breadcrumb, 2);
            $parts[0] += $numRoots;
            $m->breadcrumb = implode('.', $parts);
            $m->save();
        }
        // Add images and image tags from $lexem to $other
        $visuals = Visual::get_all_by_lexemeId($lexem->id);
        foreach ($visuals as $v) {
            $v->lexemeId = $other->id;
            $v->save();
        }
        $visualTags = VisualTag::get_all_by_lexemeId($lexem->id);
        foreach ($visualTags as $vt) {
            $vt->lexemeId = $other->id;
            $vt->save();
        }
        $lexem->delete();
        util_redirect("lexemEdit.php?lexemId={$other->id}");
    }
}
开发者ID:florinp,项目名称:dexonline,代码行数:93,代码来源:lexemEdit.php

示例6: util_redirect

$lexem = Lexem::get_by_id($lexemId);
$oldModelType = $lexem->modelType;
$oldModelNumber = $lexem->modelNumber;
if ($associateDefinitionId) {
    LexemDefinitionMap::associate($lexem->id, $associateDefinitionId);
    util_redirect("lexemEdit.php?lexemId={$lexem->id}");
}
if ($dissociateDefinitionId) {
    LexemDefinitionMap::dissociate($lexem->id, $dissociateDefinitionId);
    util_redirect("lexemEdit.php?lexemId={$lexem->id}");
}
if ($createDefinition) {
    $def = Model::factory('Definition')->create();
    $def->displayed = 0;
    $def->userId = session_getUserId();
    $def->sourceId = Source::get_by_shortName('Neoficial')->id;
    $def->lexicon = $lexem->formNoAccent;
    $def->internalRep = '@' . mb_strtoupper(AdminStringUtil::internalize($lexem->form, false)) . '@ v. @' . $miniDefTarget . '.@';
    $def->htmlRep = AdminStringUtil::htmlize($def->internalRep, $def->sourceId);
    $def->status = ST_ACTIVE;
    $def->save();
    LexemDefinitionMap::associate($lexem->id, $def->id);
    util_redirect("lexemEdit.php?lexemId={$lexem->id}");
    exit;
}
if ($deleteLexem) {
    $homonyms = Model::factory('Lexem')->where('formNoAccent', $lexem->formNoAccent)->where_not_equal('id', $lexem->id)->find_many();
    $lexem->delete();
    smarty_assign('lexem', $lexem);
    smarty_assign('homonyms', $homonyms);
    smarty_displayWithoutSkin('admin/lexemDeleted.ihtml');
开发者ID:nastasie-octavian,项目名称:DEXonline,代码行数:31,代码来源:lexemEdit.php


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