}
}
$defs = Model::factory('Definition')->where_raw("status = 0 {$sourceClause} and binary internalRep like '%{$search}%'")->order_by_asc('id')->limit($MAX_AFFECTED)->find_many();
$searchResults = SearchResult::mapDefinitionArray($defs);
foreach ($defs as $def) {
    $def->internalRep = str_replace($search, $replace, $def->internalRep);
    $ambiguousMatches = array();
    $def->internalRep = AdminStringUtil::internalizeDefinition($def->internalRep, $def->sourceId, $ambiguousMatches);
    $def->htmlRep = AdminStringUtil::htmlize($def->internalRep, $def->sourceId);
    // Complete or un-complete the abbreviation review
    if (!count($ambiguousMatches) && $def->abbrevReview == ABBREV_AMBIGUOUS) {
        $def->abbrevReview = ABBREV_REVIEW_COMPLETE;
    } else {
        if (count($ambiguousMatches) && $def->abbrevReview == ABBREV_REVIEW_COMPLETE) {
            $def->abbrevReview = ABBREV_AMBIGUOUS;
        }
    }
    if ($realRun) {
        $def->save();
    }
}
if ($realRun) {
    util_redirect("index.php");
}
smarty_assign('search', $search);
smarty_assign('replace', $replace);
smarty_assign('sourceId', $sourceId);
smarty_assign('searchResults', $searchResults);
smarty_assign('allStatuses', util_getAllStatuses());
smarty_assign('recentLinks', RecentLink::loadForUser());
smarty_displayWithoutSkin('admin/bulkReplace.ihtml');
Esempio n. 2
0
$lexems = Model::factory('Lexem')->table_alias('l')->select('l.*')->join('LexemModel', 'lm.lexemId = l.id', 'lm')->where('lm.modelType', 'T')->where_like('l.reverse', "{$reverseSuffix}%")->order_by_asc('l.formNoAccent')->limit(20)->find_many();
// $lmMatrix[$i][$j] = lexem model (with inflected forms) for lexem $i and model $j
$lmMatrix = array();
foreach ($lexems as $l) {
    $lm = $l->getFirstLexemModel();
    $lmArray = array();
    foreach ($models as $m) {
        // Force a reload
        $lm = LexemModel::get_by_id($lm->id);
        $lm->modelType = $m->modelType;
        $lm->modelNumber = $m->number;
        $lm->generateInflectedFormMap();
        $lmArray[] = $lm;
    }
    $lmMatrix[] = $lmArray;
}
// Load the definitions for each lexem
$searchResults = array();
foreach ($lexems as $l) {
    $definitions = Definition::loadByLexemId($l->id);
    $searchResults[] = SearchResult::mapDefinitionArray($definitions);
}
SmartyWrap::assign('suffix', $suffix);
SmartyWrap::assign('lexems', $lexems);
SmartyWrap::assign('models', $models);
SmartyWrap::assign('modelTypes', $modelTypes);
SmartyWrap::assign('searchResults', $searchResults);
SmartyWrap::assign('lmMatrix', $lmMatrix);
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::addCss('paradigm');
SmartyWrap::displayAdminPage('admin/bulkLabel.tpl');