}
}
$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');
<?php

require_once "../phplib/util.php";
util_assertModerator(PRIV_EDIT);
util_assertNotMirror();
$id = util_getRequestIntParameter('id');
$def = Definition::get_by_id($id);
$recordSet = db_execute("SELECT old.Version AS OldVersion, new.Version AS NewVersion, old.ModDate AS OldDate, new.ModDate AS NewDate, old.UserId AS OldUserId, new.UserId AS NewUserId, oldUser.nick AS OldUserNick, newUser.nick AS NewUserNick, old.Status AS OldStatus, new.Status AS NewStatus, old.SourceId AS OldSourceId, new.SourceId AS NewSourceId, oldSource.shortName AS OldSourceName, newSource.shortName AS NewSourceName, old.Lexicon AS OldLexicon, new.Lexicon as NewLexicon, old.ModUserId AS OldModUserId, new.ModUserId AS NewModUserId, oldModUser.nick AS OldModUserNick, newModUser.nick AS NewModUserNick, old.InternalRep AS OldInternalRep, new.InternalRep AS NewInternalRep FROM history_Definition AS old LEFT JOIN User AS oldUser ON old.UserId = oldUser.id LEFT JOIN User AS oldModUser ON old.ModUserId = oldModUser.id LEFT JOIN Source AS oldSource ON old.SourceId = oldSource.id, history_Definition AS new LEFT JOIN User AS newUser ON new.UserId = newUser.id LEFT JOIN User AS newModUser ON new.ModUserId = newModUser.id LEFT JOIN Source AS newSource ON new.SourceId = newSource.id WHERE old.Id = new.Id AND old.Action = new.Action AND new.Version = old.Version + 1 AND old.NewDate = new.ModDate AND old.Action = 'UPDATE' AND old.Id = '{$id}' ORDER BY old.Version DESC");
$changeSets = array();
$diffs = array();
$statuses = util_getAllStatuses();
foreach ($recordSet as $row) {
    $changeSet = $row;
    $changeSet['changesCount'] = 0;
    if ($row['OldUserId'] !== $row['NewUserId']) {
        $changeSet['changesCount']++;
    }
    if ($row['OldSourceId'] !== $row['NewSourceId']) {
        $changeSet['changesCount']++;
    }
    if ($row['OldStatus'] !== $row['NewStatus']) {
        $changeSet['OldStatusName'] = $statuses[$row['OldStatus']];
        $changeSet['NewStatusName'] = $statuses[$row['NewStatus']];
        $changeSet['changesCount']++;
    }
    if ($row['OldLexicon'] !== $row['NewLexicon']) {
        $changeSet['changesCount']++;
    }
    if ($row['OldModUserId'] !== $row['NewModUserId']) {
        $changeSet['changesCount']++;
    }
<?php

require_once "../../phplib/util.php";
util_assertModerator(PRIV_EDIT);
util_assertNotMirror();
RecentLink::createOrUpdate('Definiții nemoderate');
$sourceId = 0;
$sourceUrlName = util_getRequestParameter('source');
if ($sourceUrlName) {
    $source = $sourceUrlName ? Source::get_by_urlName($sourceUrlName) : null;
    $sourceId = $source ? $source->id : 0;
    SmartyWrap::assign('src_selected', $sourceId);
}
$ip = $_SERVER['REMOTE_ADDR'];
$defs = Definition::searchModerator('*', '', $sourceId, ST_PENDING, 0, 0, time(), 1, 500);
$searchResults = SearchResult::mapDefinitionArray($defs);
FileCache::putModeratorQueryResults($ip, $searchResults);
SmartyWrap::assign('searchResults', $searchResults);
SmartyWrap::assign('sectionTitle', 'Definiții nemoderate');
SmartyWrap::assign('sectionCount', count($searchResults));
SmartyWrap::assign('allStatuses', util_getAllStatuses());
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::displayAdminPage('admin/definitionList.ihtml');
                        $lm->regenerateParadigm();
                    }
                }
            }
        }
    }
    util_redirect("placeAccents.php");
}
$chars = array();
$searchResults = array();
$lexems = Model::factory('Lexem')->raw_query("select * from Lexem where form not rlike '\\'' and not noAccent order by rand() limit 10")->find_many();
foreach ($lexems as $l) {
    $charArray = array();
    $form = mb_strtoupper($l->form);
    $len = mb_strlen($form);
    for ($i = 0; $i < $len; $i++) {
        $c = StringUtil::getCharAt($form, $i);
        $charArray[] = ctype_space($c) ? '&nbsp;' : $c;
    }
    $chars[$l->id] = $charArray;
    $definitions = Definition::loadByLexemId($l->id);
    $searchResults[$l->id] = SearchResult::mapDefinitionArray($definitions);
}
RecentLink::createOrUpdate('Plasare accente');
SmartyWrap::assign('sectionTitle', 'Plasare accente');
SmartyWrap::assign('lexems', $lexems);
SmartyWrap::assign('chars', $chars);
SmartyWrap::assign('searchResults', $searchResults);
SmartyWrap::assign("allStatuses", util_getAllStatuses());
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::displayAdminPage('admin/placeAccents.ihtml');
                    $lexem->save();
                    $lexem->regenerateParadigm();
                }
            }
        }
    }
    util_redirect("placeAccents.php");
}
$chars = array();
$searchResults = array();
$lexems = Model::factory('Lexem')->raw_query("select * from Lexem where form not rlike '\\'' and not noAccent order by rand() limit 10", null)->find_many();
foreach ($lexems as $l) {
    $charArray = array();
    $form = mb_strtoupper($l->form);
    $len = mb_strlen($form);
    for ($i = 0; $i < $len; $i++) {
        $c = StringUtil::getCharAt($form, $i);
        $charArray[] = ctype_space($c) ? '&nbsp;' : $c;
    }
    $chars[$l->id] = $charArray;
    $definitions = Definition::loadByLexemId($l->id);
    $searchResults[$l->id] = SearchResult::mapDefinitionArray($definitions);
}
RecentLink::createOrUpdate('Plasare accente');
smarty_assign('sectionTitle', 'Plasare accente');
smarty_assign('lexems', $lexems);
smarty_assign('chars', $chars);
smarty_assign('searchResults', $searchResults);
smarty_assign("allStatuses", util_getAllStatuses());
smarty_assign('recentLinks', RecentLink::loadForUser());
smarty_displayWithoutSkin('flex/placeAccents.ihtml');