Ejemplo n.º 1
0
 public static function runAllModules($lexems, $definitions)
 {
     $adsModules = Config::get('global.adsModulesH');
     if ($adsModules) {
         foreach ($adsModules as $adsModule) {
             require_once util_getRootPath() . "phplib/ads/{$adsModule}/{$adsModule}AdsModule.php";
             $className = ucfirst($adsModule) . 'AdsModule';
             $module = new $className();
             $result = $module->run(empty($lexems) ? null : $lexems, empty($definitions) ? null : $definitions);
             if ($result) {
                 SmartyWrap::assign('adsProvider', $adsModule);
                 SmartyWrap::assign('adsProviderParams', $result);
                 break;
             }
         }
     }
 }
Ejemplo n.º 2
0
$submitButton = util_getRequestParameter('submitButton');
if ($deleteId) {
    $mt = MeaningTag::get_by_id($deleteId);
    $mtms = MeaningTagMap::get_all_by_meaningTagId($mt->id);
    if (count($mtms)) {
        FlashMessage::add("Nu pot șterge eticheta «{$mt->value}», deoarece unele sensuri o folosesc.", 'error');
    } else {
        $mt->delete();
        FlashMessage::add("Am șters eticheta «{$mt->value}».", 'info');
    }
    util_redirect('etichete-sensuri');
}
if ($submitButton) {
    util_assertModerator(PRIV_ADMIN);
    $values = explode(',', $value);
    foreach ($values as $value) {
        $value = trim($value);
        if ($value && !MeaningTag::get_by_value($value)) {
            $mt = Model::factory('MeaningTag')->create();
            $mt->value = $value;
            $mt->save();
        }
    }
    FlashMessage::add('Etichetele au fost salvate.', 'info');
    util_redirect('etichete-sensuri');
}
$meaningTags = Model::factory('MeaningTag')->order_by_asc('value')->find_many();
SmartyWrap::assign('meaningTags', $meaningTags);
SmartyWrap::assign('page_title', 'Etichete pentru sensuri');
SmartyWrap::display('etichete-sensuri.ihtml');
Ejemplo n.º 3
0
<?php

require_once "../phplib/util.php";
$user = session_getUser();
if (!$user) {
    util_redirect('auth/login');
}
SmartyWrap::assign('bookmarks', UserWordBookmarkDisplayObject::getByUser($user->id));
SmartyWrap::display('cuvinte-favorite.tpl');
Ejemplo n.º 4
0
    // Exercise the fields we'll need later in the view.
    // TODO: this code replicates code from search.php
    $hasUnrecommendedForms = false;
    foreach ($filtered_lexems as $l) {
        foreach ($l->getLexemModels() as $lm) {
            $lm->getModelType();
            $lm->getSourceNames();
            $map = $lm->loadInflectedFormMap();
            $lm->addLocInfo();
            foreach ($map as $ifs) {
                foreach ($ifs as $if) {
                    $hasUnrecommendedForms |= !$if->recommended;
                }
            }
        }
    }
    SmartyWrap::assign('hasUnrecommendedForms', $hasUnrecommendedForms);
    SmartyWrap::assign('lexems', $filtered_lexems);
    SmartyWrap::assign('showParadigm', true);
    SmartyWrap::assign('locParadigm', session_user_prefers(Preferences::LOC_PARADIGM));
    SmartyWrap::assign('onlyParadigm', !$ajax);
} else {
    FlashMessage::add("Niciun rezultat pentru {$cuv}.");
    SmartyWrap::assign('page_title', "Eroare");
}
if ($ajax) {
    SmartyWrap::displayWithoutSkin('bits/multiParadigm.ihtml');
} else {
    SmartyWrap::addCss('paradigm');
    SmartyWrap::display('search.ihtml');
}
Ejemplo n.º 5
0
// $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');
Ejemplo n.º 6
0
        if (isset($_POST['hiddenText'])) {
            if ($_POST['hiddenText'] == '') {
                return '';
            } else {
                $search = array();
                $replace = array();
                $buffer = $_POST['hiddenText'];
                foreach ($_POST as $key => $value) {
                    if (is_numeric($key)) {
                        $search[] = '/@@' . $key . '@@/i';
                        $replace[] = $value;
                    }
                }
                return preg_replace($search, $replace, $buffer);
            }
        } else {
            return '';
        }
    }
}
if (strstr($_SERVER['SCRIPT_NAME'], 'diacritice.php')) {
    $obj = new DiacriticsFixer();
    if (isset($_POST['text']) && $_POST['text'] != '') {
        SmartyWrap::assign('textarea', '<div id="textInput">' . $obj->fix($_POST['text']) . '</div>');
        SmartyWrap::assign('hiddenText', '<input type="hidden" name="hiddenText" value="' . $obj->getHiddenText() . '">');
    } else {
        SmartyWrap::assign('textarea', '<textarea name="text" id="textInput" placeholder="introduceți textul aici">' . $obj->replaceDiacritics() . '</textarea>');
        SmartyWrap::assign('hiddenText', '<input type="hidden" name="hiddenText" value="">');
    }
    SmartyWrap::display('diacritics_fix/diacritics_fix.tpl');
}
<?php

require_once "../../phplib/util.php";
util_assertModerator(PRIV_EDIT);
util_assertNotMirror();
RecentLink::createOrUpdate('Lexeme neasociate');
$lexems = Lexem::loadUnassociated();
SmartyWrap::assign('lexems', $lexems);
SmartyWrap::assign('sectionTitle', 'Lexeme neasociate');
SmartyWrap::assign('sectionCount', count($lexems));
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::displayAdminPage('admin/lexemList.ihtml');
Ejemplo n.º 8
0
    $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']++;
    }
    if ($row['OldInternalRep'] !== $row['NewInternalRep']) {
        $changeSet['diff'] = LDiff::htmlDiff($row['OldInternalRep'], $row['NewInternalRep']);
        $changeSet['changesCount']++;
    }
    if ($changeSet['changesCount'] > 0) {
        $changeSets[] = $changeSet;
    }
}
SmartyWrap::assign('def', $def);
SmartyWrap::assign('changeSets', $changeSets);
SmartyWrap::display('istoria-definitiei.tpl');
Ejemplo n.º 9
0
<?php

require_once "../../phplib/util.php";
ini_set('max_execution_time', '3600');
util_assertModerator(PRIV_LOC);
util_assertNotMirror();
DebugInfo::disable();
$modelType = util_getRequestParameter('modelType');
$modelNumber = util_getRequestParameter('modelNumber');
$deleteButton = util_getRequestParameter('deleteButton');
$model = Model::factory('FlexModel')->where('modelType', $modelType)->where('number', $modelNumber)->find_one();
$lexemModels = LexemModel::loadByCanonicalModel($modelType, $modelNumber);
if ($deleteButton) {
    foreach ($lexemModels as $lm) {
        $lm->modelType = 'T';
        $lm->modelNumber = '1';
        $lm->restriction = '';
        $lm->save();
        $lm->regenerateParadigm();
    }
    $model->delete();
    util_redirect('../admin/index.php');
}
RecentLink::createOrUpdate("Ștergere model: {$model}");
SmartyWrap::assign('modelType', $modelType);
SmartyWrap::assign('modelNumber', $modelNumber);
SmartyWrap::assign('lexemModels', $lexemModels);
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::displayAdminPage('admin/deleteModel.tpl');
Ejemplo n.º 10
0
                    SmartyWrap::assign('def', $def);
                    SmartyWrap::assign('lexemIds', $lexemIds);
                    SmartyWrap::assign('user', userCache_get($def->userId));
                    SmartyWrap::displayWithoutSkin('xml/update3Definitions.tpl');
                }
                print "</Definitions>\n";
            } else {
                if ($export == 'lexems') {
                    $lexemDbResult = db_execute("select * from Lexem where modDate >= '{$timestamp}' order by modDate, id");
                    print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
                    print "<Lexems>\n";
                    print "<NumResults>" . $lexemDbResult->rowCount() . "</NumResults>\n";
                    foreach ($lexemDbResult as $dbRow) {
                        $lexem = Model::factory('Lexem')->create($dbRow);
                        SmartyWrap::assign('lexem', $lexem);
                        SmartyWrap::displayWithoutSkin('xml/update3Lexems.tpl');
                    }
                    print "</Lexems>\n";
                }
            }
        }
    }
}
/****************************************************************************/
function userCache_init()
{
    $GLOBALS['USER'] = array();
}
function userCache_get($key)
{
    if (array_key_exists($key, $GLOBALS['USER'])) {
Ejemplo n.º 11
0
    $where[] = "structStatus = {$structStatus}";
}
// Process the $nick argument
if ($nick) {
    $user = User::get_by_nick($nick);
    if ($user) {
        $joins['definition'] = true;
        $where[] = "userId = {$user->id}";
    }
}
// Assemble the query
$query = Model::factory('Lexem')->table_alias('l')->select('l.*')->distinct()->order_by_asc('formNoAccent')->limit(10000);
// ... and joins
foreach ($joins as $join => $ignored) {
    switch ($join) {
        case 'definition':
            $query = $query->join('LexemDefinitionMap', 'l.id = ldm.lexemId', 'ldm')->join('Definition', 'ldm.definitionId = d.id', 'd');
            break;
        case 'lexemModel':
            $query = $query->join('LexemModel', 'l.id = lm.lexemId', 'lm');
    }
}
// ... and where clauses
foreach ($where as $clause) {
    $query = $query->where_raw("({$clause})");
}
$lexems = $query->find_many();
SmartyWrap::assign('lexems', $lexems);
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::displayAdminPage('admin/lexemSearch.tpl');
Ejemplo n.º 12
0
                    }
                }
            }
        }
    }
    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');
Ejemplo n.º 13
0
$token = util_getRequestParameter('token');
$identity = util_getRequestParameter('identity');
$pt = PasswordToken::get_by_token($token);
$data = FileCache::get($identity);
if (!$pt) {
    FlashMessage::add('Ați introdus un cod de recuperare incorect.');
} else {
    if ($pt->createDate < time() - 24 * 3600) {
        FlashMessage::add('Codul de recuperare introdus a expirat.');
    } else {
        if (!$data) {
            FlashMessage::add('Ați introdus o identitate incorectă.');
        } else {
            $user = User::get_by_id($pt->userId);
            if (!$user) {
                FlashMessage::add('Ați introdus un cod de recuperare incorect.');
            } else {
                if ($user->identity) {
                    FlashMessage::add('Acest cont a fost deja revendicat de o identitate OpenID.');
                } else {
                    FlashMessage::add('Contul dumneavoastră a fost recuperat și unificat cu identitatea OpenID.', 'info');
                    session_login($user, $data);
                }
            }
        }
    }
}
SmartyWrap::assign('page_title', 'Recuperarea parolei');
SmartyWrap::assign('suggestHiddenSearchForm', true);
SmartyWrap::display('auth/passwordRecoveryWrongData.ihtml');
Ejemplo n.º 14
0
<?php

require_once "../phplib/util.php";
$type = util_getRequestParameter('t');
if ($type == 'rss') {
    $articles = WikiArticle::getRss();
    $results = array();
    foreach ($articles as $a) {
        $results[] = array('title' => $a->title, 'description' => $a->htmlContents, 'pubDate' => date('D, d M Y H:i:s', $a->modDate) . ' EEST', 'link' => sprintf("http://%s/articol/%s", $_SERVER['HTTP_HOST'], $a->getUrlTitle()));
    }
    header("Content-type: application/rss+xml");
    SmartyWrap::assign('rss_title', 'Articole lingvistice - dexonline');
    SmartyWrap::assign('rss_link', 'http://' . $_SERVER['HTTP_HOST'] . '/rss/articole/');
    SmartyWrap::assign('rss_description', 'Articole pe teme lingvistice de la dexonline');
    SmartyWrap::assign('rss_pubDate', date('D, d M Y H:i:s') . ' EEST');
    SmartyWrap::assign('results', $results);
    SmartyWrap::displayWithoutSkin('xml/rss.tpl');
    exit;
}
SmartyWrap::assign('wikiTitles', WikiArticle::loadAllTitles());
SmartyWrap::display('articole.tpl');
Ejemplo n.º 15
0
<?php

require_once "../phplib/util.php";
$user = session_getUser();
if (!$user) {
    util_redirect('auth/login');
}
SmartyWrap::assign('page_title', 'Cuvinte favorite');
SmartyWrap::assign('bookmarks', UserWordBookmarkDisplayObject::getByUser($user->id));
SmartyWrap::display('cuvinte-favorite.ihtml');
Ejemplo n.º 16
0
    }
    // 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');
Ejemplo n.º 17
0
    }
}
$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");
}
SmartyWrap::assign('search', $search);
SmartyWrap::assign('replace', $replace);
SmartyWrap::assign('sourceId', $sourceId);
SmartyWrap::assign('searchResults', $searchResults);
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::displayAdminPage('admin/bulkReplace.tpl');
Ejemplo n.º 18
0
<?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');
Ejemplo n.º 19
0
$wordCount = Definition::getWordCount();
$wordCountRough = $wordCount - $wordCount % 10000;
SmartyWrap::assign('page_title', 'Dicționar explicativ al limbii române');
SmartyWrap::assign('onHomePage', '1');
SmartyWrap::assign('letters', preg_split('//u', 'aăâbcdefghiîjklmnopqrsștțuvwxyz'));
SmartyWrap::assign('words_total', util_formatNumber($wordCount, 0));
SmartyWrap::assign('words_rough', util_formatNumber($wordCountRough, 0));
SmartyWrap::assign('words_last_month', util_formatNumber(Definition::getWordCountLastMonth(), 0));
SmartyWrap::assign('widgets', $widgets);
SmartyWrap::assign('numEnabledWidgets', $numEnabledWidgets);
/* WotD part */
$wotd = WordOfTheDay::getTodaysWord();
if (!$wotd) {
    WordOfTheDay::updateTodaysWord();
    $wotd = WordOfTheDay::getTodaysWord();
}
$defId = WordOfTheDayRel::getRefId($wotd->id);
$def = Model::factory('Definition')->where('id', $defId)->where('status', ST_ACTIVE)->find_one();
SmartyWrap::assign('thumbUrl', $wotd->getThumbUrl());
SmartyWrap::assign('title', $def->lexicon);
SmartyWrap::assign('today', date('Y/m/d'));
/* WotM part */
$wotm = WordOfTheMonth::getCurrentWotM();
$def = Model::factory('Definition')->where('id', $wotm->definitionId)->where('status', ST_ACTIVE)->find_one();
SmartyWrap::assign('thumbUrlM', $wotm->getThumbUrl());
SmartyWrap::assign('articol', $wotm->article);
SmartyWrap::assign('titleM', $def->lexicon);
SmartyWrap::assign('todayM', date('Y/m'));
$page = Config::get('global.aprilFoolsDay') ? 'index-afd.ihtml' : 'index.ihtml';
SmartyWrap::displayPageWithSkin($page);
Ejemplo n.º 20
0
if (count($_GET) == 0) {
    util_redirect("http://wiki.dexonline.ro/wiki/Protocol_de_exportare_a_datelor");
}
$lastDump = getLastDumpDate($TODAY, $REMOTE_FOLDER);
SmartyWrap::assign('lastDump', $lastDump);
SmartyWrap::assign('url', $URL);
$lastClientUpdate = util_getRequestParameterWithDefault('last', '0');
if ($lastClientUpdate == '0') {
    // Dump the freshest full dump we have
    // TODO: return an error if there is no full dump
    SmartyWrap::assign('serveFullDump', true);
    $lastClientUpdate = $lastDump;
}
SmartyWrap::assign('diffs', getDiffsBetween($lastClientUpdate, $TODAY, $REMOTE_FOLDER));
header('Content-type: text/xml');
print SmartyWrap::fetch('xml/update4.tpl');
/**************************************************************************/
// Do not return a dump for today, in case it is still being built
function getLastDumpDate($today, $folder)
{
    global $STATIC_FILES;
    // Group existing files by date, excluding the diff files
    $map = array();
    foreach ($STATIC_FILES as $file) {
        $matches = array();
        if (preg_match(":^{$folder}/(\\d\\d\\d\\d-\\d\\d-\\d\\d)-[a-z]+.xml.gz:", $file, $matches)) {
            $date = $matches[1];
            if ($date < $today) {
                if (array_key_exists($date, $map)) {
                    $map[$date]++;
                } else {
$data['identity'] = $provider;
if (isset($data['name'])) {
    $data['fullname'] = $data['name'];
}
$user = User::get_by_identity_openidConnectSub($provider, $data['sub']);
if (!$user && $oidc->getPlainOpenid()) {
    // This may be the first time the user logs in after the migration from
    // OpenID 2.0 to OpenID Connect.
    $user = User::get_by_identity($oidc->getPlainOpenid());
    if ($user) {
        $user->identity = null;
        // session_login will overwrite it
    }
}
if ($user) {
    session_login($user, $data);
} else {
    // First time logging in, must claim an existing account or create a new one
    // TODO this duplicates code in revenireOpenid.php
    $user = isset($data['email']) ? User::get_by_email($data['email']) : null;
    $loginType = $user ? 0 : (isset($data['fullname']) ? 1 : (isset($data['nickname']) ? 2 : 3));
    // Store the identity in a temporary file. Don't print it in the form, because then it can be faked on the next page.
    $randString = util_randomCapitalLetterString(20);
    FileCache::put($randString, $data);
    SmartyWrap::assign('page_title', 'Autentificare cu OpenID');
    SmartyWrap::assign('suggestHiddenSearchForm', true);
    SmartyWrap::assign('data', $data);
    SmartyWrap::assign('randString', $randString);
    SmartyWrap::assign('loginType', $loginType);
    SmartyWrap::display('auth/chooseIdentity.ihtml');
}
Ejemplo n.º 22
0
<?php

require_once "../phplib/util.php";
$type = util_getRequestParameter('t');
if ($type == 'rss') {
    $articles = WikiArticle::getRss();
    $results = array();
    foreach ($articles as $a) {
        $results[] = array('title' => $a->title, 'description' => $a->htmlContents, 'pubDate' => date('D, d M Y H:i:s', $a->modDate) . ' EEST', 'link' => sprintf("http://%s/articol/%s", $_SERVER['HTTP_HOST'], $a->getUrlTitle()));
    }
    header("Content-type: application/rss+xml");
    SmartyWrap::assign('rss_title', 'Articole lingvistice - DEX online');
    SmartyWrap::assign('rss_link', 'http://' . $_SERVER['HTTP_HOST'] . '/rss/articole/');
    SmartyWrap::assign('rss_description', 'Articole pe teme lingvistice de la DEX online');
    SmartyWrap::assign('rss_pubDate', date('D, d M Y H:i:s') . ' EEST');
    SmartyWrap::assign('results', $results);
    SmartyWrap::displayWithoutSkin('rss.ixml');
    exit;
}
SmartyWrap::assign('page_title', 'Articole lingvistice');
SmartyWrap::assign('wikiTitles', WikiArticle::loadAllTitles());
SmartyWrap::display('articole.ihtml');
Ejemplo n.º 23
0
<?php

require_once "../../phplib/util.php";
util_assertModerator(PRIV_EDIT);
util_assertNotMirror();
RecentLink::createOrUpdate('Greșeli de tipar');
$sourceClause = '';
$sourceId = 0;
$sourceUrlName = util_getRequestParameter('source');
if ($sourceUrlName) {
    $source = $sourceUrlName ? Source::get_by_urlName($sourceUrlName) : null;
    $sourceId = $source ? $source->id : 0;
    $sourceClause = $source ? "sourceId = {$sourceId} and " : '';
    SmartyWrap::assign('src_selected', $sourceId);
}
$defs = Model::factory('Definition')->raw_query("select * from Definition where {$sourceClause} id in (select definitionId from Typo) order by lexicon")->find_many();
SmartyWrap::assign('searchResults', SearchResult::mapDefinitionArray($defs));
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::displayAdminPage('admin/viewTypos.tpl');
Ejemplo n.º 24
0
if (count($_GET) == 0) {
    util_redirect("http://wiki.dexonline.ro/wiki/Protocol_de_exportare_a_datelor");
}
$lastDump = getLastDumpDate($TODAY, $REMOTE_FOLDER);
SmartyWrap::assign('lastDump', $lastDump);
SmartyWrap::assign('url', $URL);
$lastClientUpdate = util_getRequestParameterWithDefault('last', '0');
if ($lastClientUpdate == '0') {
    // Dump the freshest full dump we have
    // TODO: return an error if there is no full dump
    SmartyWrap::assign('serveFullDump', true);
    $lastClientUpdate = $lastDump;
}
SmartyWrap::assign('diffs', getDiffsBetween($lastClientUpdate, $TODAY, $REMOTE_FOLDER));
header('Content-type: text/xml');
print SmartyWrap::fetch('update4.ihtml');
/**************************************************************************/
// Do not return a dump for today, in case it is still being built
function getLastDumpDate($today, $folder)
{
    global $STATIC_FILES;
    // Group existing files by date, excluding the diff files
    $map = array();
    foreach ($STATIC_FILES as $file) {
        $matches = array();
        if (preg_match(":^{$folder}/(\\d\\d\\d\\d-\\d\\d-\\d\\d)-[a-z]+.xml.gz:", $file, $matches)) {
            $date = $matches[1];
            if ($date < $today) {
                if (array_key_exists($date, $map)) {
                    $map[$date]++;
                } else {
Ejemplo n.º 25
0
$user->email = StringUtil::scrambleEmail($user->email);
// Find the rank of this user by number of words and number of characters
$topWords = TopEntry::getTopData(CRIT_WORDS, SORT_DESC, true);
$numUsers = count($topWords);
$rankWords = 0;
while ($rankWords < $numUsers && $topWords[$rankWords]->userNick != $nick) {
    $rankWords++;
}
$userData['rank_words'] = $rankWords + 1;
if ($rankWords < $numUsers) {
    $topEntry = $topWords[$rankWords];
    $userData['last_submission'] = $topEntry->timestamp;
    $userData['num_words'] = $topEntry->numDefinitions;
    $userData['num_chars'] = $topEntry->numChars;
}
$topChars = TopEntry::getTopData(CRIT_CHARS, SORT_DESC, true);
$numUsers = count($topChars);
$rankChars = 0;
while ($rankChars < $numUsers && $topChars[$rankChars]->userNick != $nick) {
    $rankChars++;
}
$userData['rank_chars'] = $rankChars + 1;
SmartyWrap::assign('medals', Medal::loadForUser($user));
if (util_isModerator(PRIV_ADMIN)) {
    // Admins can grant/revoke medals
    SmartyWrap::assign('allMedals', Medal::$DATA);
}
SmartyWrap::assign('user', $user);
SmartyWrap::assign('userData', $userData);
SmartyWrap::display('user.tpl');
Ejemplo n.º 26
0
            $pm = ParticipleModel::loadByVerbModel($modelNumber);
            $clonePm = Model::factory('ParticipleModel')->create();
            $clonePm->verbModel = $newModelNumber;
            $clonePm->adjectiveModel = $pm->adjectiveModel;
            $clonePm->save();
        }
        // Migrate the selected lexems.
        if ($chooseLexems && $lexemModelIds) {
            foreach ($lexemModelIds as $lexemModelId) {
                $lm = LexemModel::get_by_id($lexemModelId);
                $lm->modelNumber = $newModelNumber;
                $lm->save();
                // It is not necessary to regenerate the paradigm for now, since
                // the inflected forms are identical.
            }
        }
        util_redirect('../admin/index.php');
        exit;
    }
} else {
    $newModelNumber = $modelNumber . ".1";
}
$lexemModels = LexemModel::loadByCanonicalModel($modelType, $modelNumber);
SmartyWrap::assign('modelType', $modelType);
SmartyWrap::assign('modelNumber', $modelNumber);
SmartyWrap::assign('newModelNumber', $newModelNumber);
SmartyWrap::assign('lexemModels', $lexemModels);
SmartyWrap::assign('errorMessage', $errorMessages);
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::displayAdminPage('admin/cloneModel.tpl');
Ejemplo n.º 27
0
<?php

require_once "../phplib/util.php";
$form = util_getRequestParameter('form');
$locVersion = util_getRequestParameter('locVersion');
$locVersions = Config::getLocVersions();
if (!util_isModerator(PRIV_LOC)) {
    $locVersions = array_slice($locVersions, 1);
    // remove the version in progress
}
if ($locVersion && $form) {
    LocVersion::changeDatabase($locVersion);
    $form = StringUtil::cleanupQuery($form);
    $field = StringUtil::hasDiacritics($form) ? 'formNoAccent' : 'formUtf8General';
    $data = Model::factory('InflectedForm')->table_alias('I')->select('I.form', 'inflectedForm')->select('L.formNoAccent', 'lexemFormNoAccent')->select('L.form', 'lexemForm')->select('LM.modelType', 'modelType')->select('LM.modelNumber', 'modelNumber')->select('LM.restriction', 'restriction')->select('Infl.description', 'inflection')->join('LexemModel', 'I.lexemModelId = LM.id', 'LM')->join('Lexem', 'LM.lexemId = L.id', 'L')->join('ModelType', 'LM.modelType = MT.code', 'MT')->join('Model', 'MT.canonical = M.modelType and LM.modelNumber = M.number', 'M')->join('ModelDescription', 'M.id = MD.modelId and I.variant = MD.variant and I.inflectionId = MD.inflectionId', 'MD')->join('Inflection', 'I.inflectionId = Infl.id', 'Infl')->where('MD.applOrder', 0)->where("I.{$field}", $form)->where('LM.isLoc', 1)->where('MD.isLoc', 1)->order_by_asc('LM.lexemId')->find_array();
    SmartyWrap::assign('page_title', 'Verificare LOC: ' . $form);
    SmartyWrap::assign('form', $form);
    SmartyWrap::assign('selectedLocVersion', $locVersion);
    SmartyWrap::assign('data', $data);
} else {
    SmartyWrap::assign('selectedLocVersion', $locVersions[0]->name);
    SmartyWrap::assign('page_title', 'Căutare formă flexionară în LOC ' . $form);
}
SmartyWrap::addJs('modelDropdown');
SmartyWrap::assign('suggestHiddenSearchForm', true);
SmartyWrap::assign('page_title', 'Scrabble');
SmartyWrap::assign('locVersions', $locVersions);
SmartyWrap::display('scrabble.ihtml');
Ejemplo n.º 28
0
// Always use the first of the month
$timestamp = $date ? strtotime($date) : time();
$mysqlDate = date("Y-m-01", $timestamp);
if ($mysqlDate < WOTM_BIG_BANG || $mysqlDate > $today && !util_isModerator(PRIV_ADMIN)) {
    util_redirect(util_getWwwRoot() . 'cuvantul-lunii');
}
$wotm = WordOfTheMonth::getWotM($mysqlDate);
$def = Definition::get_by_id($wotm->definitionId);
if ($type == 'url') {
    SmartyWrap::assign('today', $today);
    SmartyWrap::assign('title', $def->lexicon);
    SmartyWrap::displayWithoutSkin('bits/wotmurl.tpl');
    exit;
}
$searchResults = SearchResult::mapDefinitionArray(array($def));
$cYear = date('Y', $timestamp);
$cMonth = date('n', $timestamp);
$nextTS = mktime(0, 0, 0, $cMonth + 1, 1, $cYear);
$prevTS = mktime(0, 0, 0, $cMonth - 1, 1, $cYear);
if ($mysqlDate > WOTM_BIG_BANG) {
    SmartyWrap::assign('prevmon', date('Y/m', $prevTS));
}
if ($mysqlDate < $today || util_isModerator(PRIV_ADMIN)) {
    SmartyWrap::assign('nextmon', date('Y/m', $nextTS));
}
SmartyWrap::assign('imageUrl', $wotm->getImageUrl());
SmartyWrap::assign('artist', $wotm->getArtist());
SmartyWrap::assign('timestamp', $timestamp);
SmartyWrap::assign('searchResult', array_pop($searchResults));
SmartyWrap::display('wotm.tpl');
Ejemplo n.º 29
0
    $v = Visual::get_by_path($fileName);
    if (!$v) {
        $v = Visual::createFromFile($fileName);
    }
    util_redirect("?id={$v->id}");
}
$v = Visual::get_by_id($id);
if ($saveButton) {
    $v->lexemeId = $lexemId;
    $v->revised = $revised;
    $v->save();
    util_redirect("?id={$v->id}");
}
if ($addTagButton) {
    $vt = Model::factory('VisualTag')->create();
    $vt->imageId = $v->id;
    $vt->lexemeId = $tagLexemId;
    $vt->label = $tagLabel;
    $vt->textXCoord = $textXCoord;
    $vt->textYCoord = $textYCoord;
    $vt->imgXCoord = $imgXCoord;
    $vt->imgYCoord = $imgYCoord;
    $vt->save();
    util_redirect("?id={$v->id}");
}
SmartyWrap::assign('visual', $v);
SmartyWrap::assign('lexem', Lexem::get_by_id($v->lexemeId));
SmartyWrap::addCss('jqueryui-smoothness', 'jcrop', 'select2', 'jqgrid', 'jqueryui', 'gallery');
SmartyWrap::addJs('jquery', 'jqueryui', 'jcrop', 'visualTag', 'select2', 'select2Dev', 'jqgrid', 'gallery');
SmartyWrap::displayAdminPage('admin/visualTag.tpl');
Ejemplo n.º 30
0
        $s = substr($s, 0, $m['position']) . " {$MARKER} " . substr($s, $m['position'], $m['length']) . " {$MARKER} " . substr($s, $m['position'] + $m['length']);
    }
    $s = AdminStringUtil::htmlize($s, $def->sourceId);
    // Split the definition into n ambiguities and n+1 bits of text between the ambiguities
    $text = array();
    $ambiguities = array();
    while (($p = strpos($s, $MARKER)) !== false) {
        $chunk = trim(substr($s, 0, $p));
        $s = trim(substr($s, $p + strlen($MARKER)));
        if (count($text) == count($ambiguities)) {
            $text[] = $chunk;
        } else {
            $ambiguities[] = $chunk;
        }
    }
    $text[] = trim($s);
    SmartyWrap::assign('text', $text);
    SmartyWrap::assign('ambiguities', $ambiguities);
}
SmartyWrap::assign('def', $def);
SmartyWrap::assign('recentLinks', RecentLink::loadForUser());
SmartyWrap::assign('sectionTitle', 'Examinare abrevieri');
SmartyWrap::addJs('jquery');
SmartyWrap::displayAdminPage('admin/randomAbbrevReview.ihtml');
/**
 * Sort matches from last to first
 */
function positionCmp($a, $b)
{
    return $b['position'] - $a['position'];
}