/**
  * Searches the definition
  * @access protected
  * @return void
  * */
 protected function doSearch()
 {
     $q = str_replace("'", "\\'", $this->query);
     $where = "lexicon like '{$q}%'";
     if (strlen($q) >= 3) {
         $where = " lexicon like '%{$q}%'";
     }
     $where .= " order by lexicon = '{$q}', lexicon, id limit 20";
     $definitions = Model::factory('Definition')->raw_query("select * from Definition where {$where}", null)->find_many();
     $result = '';
     foreach ($definitions as $definition) {
         $source = Source::get_by_id($definition->sourceId);
         $result .= ($result == '' ? '' : "\n") . $definition->lexicon . " - " . substr($definition->internalRep, 0, 80) . ' (' . $source->shortName . ') [{' . $definition->id . '}]';
     }
     return $result;
 }
<?php

require_once "../phplib/util.php";
$submitButton = util_getRequestParameter('submitButton');
if ($submitButton) {
    util_assertModerator(PRIV_ADMIN);
    $order = 1;
    $ids = util_getRequestParameter("ids");
    foreach ($ids as $id) {
        $src = Source::get_by_id($id);
        $src->displayOrder = $order++;
        $src->save();
    }
    FlashMessage::add('Ordinea a fost salvată.', 'info');
    util_redirect('surse');
}
$sources = util_isModerator(PRIV_VIEW_HIDDEN) ? Model::factory('Source')->order_by_asc('displayOrder')->find_many() : Model::factory('Source')->where_not_equal('isOfficial', SOURCE_TYPE_HIDDEN)->order_by_asc('displayOrder')->find_many();
smarty_assign('sources', $sources);
smarty_assign('page_title', 'Surse');
smarty_displayCommonPageWithSkin('surse.ihtml');
<?php

require_once "../../phplib/util.php";
$lexemId = util_getRequestParameter('lexemId');
$defs = Definition::loadByLexemId($lexemId);
$results = array();
foreach ($defs as $def) {
    $htmlRep = str_replace("\n", ' ', $def->htmlRep);
    $source = Source::get_by_id($def->sourceId);
    $results[] = array('id' => $def->id, 'shortName' => $source->shortName, 'status' => $def->getStatusName(), 'htmlRep' => $htmlRep);
}
SmartyWrap::assign('results', $results);
SmartyWrap::displayWithoutSkin('ajax/getDefinitionsForLexem.tpl');
<?php

require_once "../../phplib/util.php";
util_hideEmptyRequestParameters();
util_assertModerator(PRIV_LOC);
util_assertNotMirror();
$sourceId = util_getRequestParameter('source');
$nick = util_getRequestParameter('nick');
$loc = util_getRequestParameter('loc');
$source = Source::get_by_id($sourceId);
switch ($loc) {
    case 0:
        $srcClause = " and not l.isLoc";
        smarty_assign('sectionTitle', "Lexeme din {$source->shortName} neincluse în LOC");
        break;
    case 1:
        $srcClause = " and l.isLoc";
        smarty_assign('sectionTitle', "Lexeme din {$source->shortName} incluse în LOC");
        break;
    case 2:
        $srcClause = "";
        smarty_assign('sectionTitle', "Lexeme din {$source->shortName}");
        break;
    default:
        exit;
}
$nickClause = '';
if ($nick) {
    $user = User::get_by_nick($nick);
    if ($user) {
        $nickClause = "and d.userId = {$user->id}";
<?php

require_once "../phplib/util.php";
util_assertModerator(PRIV_ADMIN);
$sourceId = util_getRequestParameter('id');
$submitButton = util_getRequestParameter('submitButton');
$src = $sourceId ? Source::get_by_id($sourceId) : Model::factory('Source')->create();
if ($submitButton) {
    $src->name = util_getRequestParameter("name");
    $src->shortName = util_getRequestParameter("shortName");
    $src->urlName = util_getRequestParameter("urlName");
    $src->author = util_getRequestParameter("author");
    $src->publisher = util_getRequestParameter("publisher");
    $src->year = util_getRequestParameter("year");
    $src->link = util_getRequestParameter("link");
    $src->isActive = util_getRequestParameterWithDefault("isActive", 0);
    $src->isOfficial = util_getRequestParameterWithDefault("isOfficial", 0);
    $src->canContribute = util_getRequestParameterWithDefault("canContribute", 0);
    $src->canModerate = util_getRequestParameterWithDefault("canModerate", 0);
    $src->canDistribute = util_getRequestParameterWithDefault("canDistribute", 0);
    $src->defCount = util_getRequestIntParameter("defCount");
    if (validate($src)) {
        // For new sources, set displayOrder to the highest available + 1
        if (!$sourceId) {
            $src->displayOrder = Model::factory('Source')->count() + 1;
        }
        $src->updatePercentComplete();
        $src->save();
        FlashMessage::add('Modificările au fost salvate', 'info');
        util_redirect("editare-sursa?id={$src->id}");
    }
            $l = Lexem::get_by_id($ldm->lexemId);
            $otherLdms = LexemDefinitionMap::get_all_by_lexemId($l->id);
            if (!$l->isLoc && !count($otherLdms)) {
                $l->delete();
            }
        }
    } else {
        db_execute("delete from LexemDefinitionMap where definitionId = {$definitionId}");
        foreach ($ldms as $ldm) {
            $ldm->save();
        }
    }
    log_userLog("Edited definition {$definition->id} ({$definition->lexicon})");
    util_redirect('definitionEdit.php?definitionId=' . $definitionId);
}
$source = Source::get_by_id($definition->sourceId);
if (!$refreshButton && !$acceptButton && !$moveButton) {
    // If a button was pressed, then this is a POST request and the URL
    // does not contain the definition ID.
    RecentLink::createOrUpdate(sprintf("Definiție: %s (%s)", $definition->lexicon, $source->shortName));
}
smarty_assign('def', $definition);
smarty_assign('source', $source);
smarty_assign('user', User::get_by_id($definition->userId));
smarty_assign('comment', $comment);
smarty_assign('commentUser', $commentUser);
smarty_assign('lexems', $lexems);
smarty_assign('typos', Typo::get_all_by_definitionId($definition->id));
smarty_assign('homonyms', loadSetHomonyms($lexems));
smarty_assign("allStatuses", util_getAllStatuses());
smarty_assign("allModeratorSources", Model::factory('Source')->where('canModerate', true)->order_by_asc('displayOrder')->find_many());
Exemple #7
0
 public static function getSimilarSource($sourceId)
 {
     $ss = Model::factory('SimilarSource')->select('similarSource')->where('sourceId', $sourceId)->find_one();
     return $ss ? Source::get_by_id($ss->similarSource) : null;
 }