public static function getDebugInfo()
 {
     $enabled = self::$enabled && session_getUserNick() == pref_getDebugUser();
     smarty_assign('debug_enabled', $enabled);
     if ($enabled) {
         smarty_assign('debug_messages', self::$debugInfo);
         smarty_assign('debug_runningTimeMillis', self::getRunningTimeInMillis());
         smarty_assign('debug_ormQueryLog', ORM::get_query_log());
     }
 }
 public static function runAllModules($lexems, $definitions)
 {
     $adsModules = pref_getServerPreference('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) {
                 smarty_assign('adsProvider', $adsModule);
                 smarty_assign('adsProviderParams', $result);
                 break;
             }
         }
     }
 }
Example #3
0
function smarty_displayPageWithSkin($templateName)
{
    $skin = session_getSkin();
    smarty_assign('contentTemplateName', "{$skin}/{$templateName}");
    smarty_display();
}
                } else {
                    // Create a new lexem.
                    $lexem = Lexem::create($lexemName, 'T', '1', '');
                    $lexem->save();
                    $lexem->regenerateParadigm();
                    LexemDefinitionMap::associate($lexem->id, $definition->id);
                    log_userLog("Created lexem {$lexem->id} ({$lexem->form})");
                }
            }
        }
        FlashMessage::add('Definiția a fost trimisă. Un moderator o va examina în scurt timp. Vă mulțumim!', 'info');
        util_redirect('contribuie');
    }
} else {
    smarty_assign('sourceId', session_getDefaultContribSourceId());
}
smarty_assign('contribSources', Model::factory('Source')->where('canContribute', true)->order_by_asc('displayOrder')->find_many());
smarty_assign('page_title', 'Contribuie cu definiții');
smarty_assign('suggestNoBanner', true);
smarty_displayCommonPageWithSkin('contribuie.ihtml');
/**************************************************************************/
function deleteEmptyElements(&$v)
{
    $result = array();
    foreach ($v as $elem) {
        if (!empty($elem)) {
            $result[] = $elem;
        }
    }
    return $result;
}
Example #5
0
<?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');
        $lexems[] = $l;
        $paradigms[] = $paradigm;
    }
    smarty_assign('modelsToDisplay', $modelsToDisplay);
    smarty_assign('lexems', $lexems);
    smarty_assign('paradigms', $paradigms);
} else {
    smarty_assign('selectedLocVersion', $locVersions[0]->name);
    // LocVersion::changeDatabase($locVersion);
}
$modelTypes = ModelType::loadCanonical();
$models = FlexModel::loadByType($modelType ? $modelType : $modelTypes[0]->code);
smarty_assign('page_title', 'Modele de flexiune');
smarty_assign('locVersions', $locVersions);
smarty_assign('modelTypes', $modelTypes);
smarty_assign('models', $models);
smarty_displayCommonPageWithSkin('modele-flexiune.ihtml');
/*************************************************************************/
/**
 * Load the forms to display for a model when a lexem already exists. This code is specific to each LOC version.
 */
function getExistingForms($lexemId, $locVersion)
{
    if ($locVersion >= '5.0') {
        return InflectedForm::loadByLexemIdMapByInflectionRank($lexemId);
    } else {
        return InflectedForm::loadByLexemIdMapByInflectionId($lexemId);
    }
}
function getNewForms($lexem, $locVersion)
{
<?php

require_once "../../phplib/util.php";
util_assertModerator(PRIV_WOTD);
util_assertNotMirror();
RecentLink::createOrUpdate('Word of the Day - Imagini');
smarty_assign('sectionTitle', 'Imagini pentru cuvântul zilei');
smarty_displayWithoutSkin('admin/wotdImages.ihtml');
<?php

require_once "../phplib/util.php";
require_once "../phplib/userPreferences.php";
util_assertNotLoggedIn();
$sendButton = util_getRequestParameter('send');
if ($sendButton) {
    $userPrefs = util_getRequestCheckboxArray('userPrefs', ',');
    $skin = util_getRequestParameter('skin');
    session_setAnonymousPrefs($userPrefs);
    if (session_isValidSkin($skin)) {
        session_setSkin($skin);
    }
    FlashMessage::add('Preferințele au fost salvate.', 'info');
    util_redirect('preferinte');
} else {
    $userPrefs = session_getAnonymousPrefs();
    $skin = session_getSkin();
}
foreach (preg_split('/,/', $userPrefs) as $pref) {
    if (isset($userPreferencesSet[$pref])) {
        $userPreferencesSet[$pref]['checked'] = true;
    }
}
smarty_assign('userPrefs', $userPreferencesSet);
smarty_assign('skin', $skin);
smarty_assign('availableSkins', pref_getServerPreference('skins'));
smarty_assign('page_title', 'Preferințe');
smarty_displayCommonPageWithSkin('preferinte.ihtml');
smarty_assign('inflections', $inflections);
smarty_assign('inflectionMap', Inflection::mapById($inflections));
smarty_assign('modelType', $modelType);
smarty_assign('modelNumber', $modelNumber);
smarty_assign('newModelNumber', $newModelNumber);
smarty_assign('exponent', $exponent);
smarty_assign('newExponent', $newExponent);
smarty_assign('description', $model->description);
smarty_assign('newDescription', $newDescription);
smarty_assign('participleNumber', $participleNumber);
smarty_assign('newParticipleNumber', $newParticipleNumber);
smarty_assign('newForms', $newForms);
smarty_assign('inputValues', $inputValues);
smarty_assign('recentLinks', RecentLink::loadForUser());
smarty_assign('wasPreviewed', $previewButton);
smarty_assign('errorMessage', $errorMessage);
smarty_displayWithoutSkin('flex/editModel.ihtml');
/****************************************************************************/
/**
 * $a, $b: arrays of ($form, $isLoc, $recommended) tuples. Only compares the forms.
 */
function equalArrays($a, $b)
{
    if (count($a) != count($b)) {
        return false;
    }
    foreach ($a as $key => $tuple) {
        if ($a[$key]['form'] != $b[$key]['form']) {
            return false;
        }
    }
$skin = util_getRequestParameter('skin');
$user = session_getUser();
if (!$user) {
    util_redirect('auth/login');
}
if ($sendButton) {
    $user->detailsVisible = $detailsVisible ? 1 : 0;
    $user->preferences = $userPrefs;
    if (session_isValidSkin($skin)) {
        $user->skin = $skin;
    }
    $user->save();
    session_setVariable('user', $user);
    FlashMessage::add('Informațiile au fost salvate.', 'info');
} else {
    $detailsVisible = $user->detailsVisible;
    $skin = session_getSkin();
    $userPrefs = $user->preferences;
}
foreach (preg_split('/,/', $userPrefs) as $pref) {
    if (isset($userPreferencesSet[$pref])) {
        $userPreferencesSet[$pref]['checked'] = true;
    }
}
smarty_assign('detailsVisible', $detailsVisible);
smarty_assign('userPrefs', $userPreferencesSet);
smarty_assign('skin', $skin);
smarty_assign('availableSkins', pref_getServerPreference('skins'));
smarty_assign('privilegeNames', $PRIV_NAMES);
smarty_assign('page_title', 'Contul meu');
smarty_displayCommonPageWithSkin('auth/contul-meu.ihtml');
Example #11
0
    WordOfTheDay::updateTodaysWord();
    $wotd = WordOfTheDay::get_by_displayDate($mysqlDate);
}
$archive = WordOfTheDay::getArchiveWotD(date('Y', $timestamp), date('m', $timestamp));
$defId = WordOfTheDayRel::getRefId($wotd->id);
$def = Definition::get_by_id($defId);
$searchResults = SearchResult::mapDefinitionArray(array($def));
setlocale(LC_ALL, 'ro_RO');
$roDate = strftime("%e %B %Y", $timestamp);
$pageTitle = sprintf("Cuvântul zilei: %s (%s)", $def->lexicon, $roDate);
if ($mysqlDate > WOTD_BIG_BANG) {
    smarty_assign('prevday', date('Y/m/d', $timestamp - 86400));
}
if ($mysqlDate < $today) {
    smarty_assign('nextday', date('Y/m/d', $timestamp + 86400));
}
smarty_assign('imageUrl', $wotd->getImageUrl());
smarty_assign('timestamp', $timestamp);
smarty_assign('archive', $archive);
smarty_assign('mysqlDate', $mysqlDate);
smarty_assign('page_title', $pageTitle);
smarty_assign('page_keywords', "Cuvântul zilei, {$def->lexicon}, dexonline, DEX online, {$pageTitle}");
smarty_assign('page_description', "{$pageTitle} de la dexonline");
smarty_assign('searchResult', array_pop($searchResults));
if ($type == 'url') {
    smarty_assign('today', $today);
    smarty_assign('title', $def->lexicon);
    smarty_displayWithoutSkin('common/bits/wotdurl.ihtml');
} else {
    smarty_displayCommonPageWithSkin('wotd.ihtml');
}
                // Compress the directory
                OS::executeAndAssert("zip -r0 compressed.zip *");
                // Move the resulting file to another temp location so it lives a little longer
                $outputFile = tempnam('/tmp', 'compress_');
                @unlink($outputFile);
                rename("{$workDir}/compressed.zip", $outputFile);
                OS::executeAndAssert("rm -rf {$workDir}");
                header('Content-disposition: attachment; filename=comprimate.zip');
                header('Content-Type: application/zip');
                readfile($outputFile);
                exit;
            }
        }
    }
}
smarty_assign('sectionTitle', 'Comprimare imagini');
smarty_displayWithoutSkin('admin/wotdCompressImages.ihtml');
/**************************************************************************/
function recursiveScan($path, $logFile)
{
    global $IGNORED_DIRS, $EXTENSIONS, $beforeBytes, $afterBytes;
    $files = scandir($path);
    foreach ($files as $file) {
        if (in_array($file, $IGNORED_DIRS)) {
            continue;
        }
        $full = "{$path}/{$file}";
        if (is_dir($full)) {
            recursiveScan($full, $logFile);
        } else {
            $extension = pathinfo(strtolower($full), PATHINFO_EXTENSION);
Example #13
0
<?php

require_once "../phplib/util.php";
require_once "../phplib/ads/adsModule.php";
// Display a custom ad 50% of the times
if (rand(0, 99) < 50) {
    AdsModule::runAllModules(null, null);
}
smarty_assign('page_title', 'Dicționar explicativ al limbii române');
smarty_assign('onHomePage', '1');
smarty_assign('letters', preg_split('//u', 'aăâbcdefghiîjklmnopqrsștțuvwxyz'));
smarty_assign('words_total', util_formatNumber(Definition::getWordCount(), 0));
smarty_assign('words_last_month', util_formatNumber(Definition::getWordCountLastMonth(), 0));
/* WotD part */
$wotd = WordOfTheDay::getTodaysWord();
if (!$wotd) {
    WordOfTheDay::updateTodaysWord();
    $wotd = WordOfTheDay::getTodaysWord();
}
$wotd->ensureThumbnail();
$defId = WordOfTheDayRel::getRefId($wotd->id);
$def = Model::factory('Definition')->where('id', $defId)->where('status', ST_ACTIVE)->find_one();
smarty_assign('thumbUrl', $wotd->getThumbUrl());
smarty_assign('title', $def->lexicon);
smarty_assign('today', date('Y/m/d'));
smarty_displayPageWithSkin('index.ihtml');
<?php

require_once "../../phplib/util.php";
util_assertModerator(PRIV_EDIT);
util_assertNotMirror();
RecentLink::createOrUpdate('Lexeme cu comentarii');
smarty_assign('sectionTitle', 'Lexeme cu comentarii');
smarty_assign('recentLinks', RecentLink::loadForUser());
smarty_assign('lexems', Model::factory('Lexem')->where_not_equal('comment', '')->order_by_asc('formNoAccent')->find_many());
smarty_displayWithoutSkin('flex/viewLexemsWithComments.ihtml');
    $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'] = htmlDiff($row['OldInternalRep'], $row['NewInternalRep']);
        $changeSet['changesCount']++;
    }
    if ($changeSet['changesCount'] > 0) {
        $changeSets[] = $changeSet;
    }
}
smarty_assign('page_title', 'Istoria definiției ' . $def->lexicon);
smarty_assign('def', $def);
smarty_assign('changeSets', $changeSets);
smarty_displayCommonPageWithSkin('istoria-definitiei.ihtml');
            }
        }
    } else {
        $openidNick = $loginType == 1 ? $data['fullname'] : ($loginType == 2 ? $data['nickname'] : $nick);
        $user = User::get_by_nick($openidNick);
        if ($user) {
            FlashMessage::add('Acest nume de utilizator este deja luat.');
        } else {
            if (mb_strlen($openidNick) < 3 || mb_strlen($openidNick) > 20) {
                FlashMessage::add('Numele de utilizator trebuie să aibă între 3 și 20 de caractere.');
            } else {
                if (!preg_match("/^([-a-z0-9_. ]|ă|â|î|ș|ț|Ă|Â|Î|Ș|Ț)+\$/i", $openidNick)) {
                    FlashMessage::add('Numele de utilizator poate conține doar litere, cifre, spații și simbolurile . - _');
                } else {
                    if (!preg_match("/[a-z]|ă|â|î|ș|ț|Ă|Â|Î|Ș|Ț/i", $openidNick)) {
                        FlashMessage::add('Numele de utilizator trebuie să conțină cel puțin o literă.');
                    } else {
                        $data['nickname'] = $openidNick;
                        session_login(null, $data);
                    }
                }
            }
        }
    }
}
smarty_assign('page_title', 'Autentificare cu OpenID');
smarty_assign('suggestHiddenSearchForm', true);
smarty_assign('data', $data);
smarty_assign('randString', $randString);
smarty_assign('loginType', $loginType);
smarty_displayCommonPageWithSkin('auth/chooseIdentity.ihtml');
                print sprintf("<span style=\"color: green\">%s: %s</span>\n", $newLocVersion, substr($line, 2));
            }
        }
    }
    print "</pre>\n";
    util_deleteFile($file1);
    util_deleteFile($file2);
    exit;
}
if ($locVersion) {
    header('Content-type: text/plain; charset=UTF-8');
    writeLexems($locVersion, 'php://output');
    exit;
}
setlocale(LC_ALL, "ro_RO.utf8");
smarty_assign('locVersions', pref_getLocVersions());
smarty_displayCommonPageWithSkin('scrabble-loc.ihtml');
function writeLexems($locVersion, $fileName)
{
    LocVersion::changeDatabase($locVersion);
    $dbResult = db_execute(DB_QUERY, PDO::FETCH_ASSOC);
    $handle = fopen($fileName, 'w');
    foreach ($dbResult as $row) {
        $l = Model::factory('Lexem')->create($row);
        fprintf($handle, AdminStringUtil::padRight(mb_strtoupper($l->form), 20));
        fprintf($handle, AdminStringUtil::padRight($l->modelType, 4));
        fprintf($handle, AdminStringUtil::padRight($l->modelNumber, 8));
        fprintf($handle, $l->restriction . "\n");
    }
    fclose($handle);
}
Example #18
0
$provider = util_getRequestParameter('provider');
// Display a banner for this provider
$go = util_getRequestParameter('go');
// Track a click and redirect to this provider
$clickurl = util_getRequestParameter('clickurl');
// Sent to us by OpenX; when displaying a banner, we have to link to this URL
if ($go) {
    $provider = $go;
    $go = true;
}
require_once "../phplib/ads/{$provider}/{$provider}AdsModule.php";
if ($provider == 'diverta') {
    $bookId = util_getRequestParameter('bookId');
    $book = DivertaBook::get_by_id($bookId);
    if (!$book) {
        exit;
    }
    if ($go) {
        $book->clicks++;
        $book->save();
        util_redirect($book->url);
    }
    $book->impressions++;
    $book->save();
    smarty_assign('book', $book);
    smarty_assign('hasImage', file_exists(util_getRootPath() . "wwwbase/img/diverta/thumb/{$book->sku}.jpg"));
}
smarty_assign('clickurl', str_replace('__', '&', $clickurl));
$output = smarty_fetch("ads/{$provider}.ihtml");
$output = addslashes(str_replace("\n", ' ', $output));
print "document.write(\"{$output}\");";
Example #19
0
    if (!is_null($conjugations) || !is_null($declensions)) {
        $page_keywords .= ", paradigmă {$cuv}";
        $page_description .= ', paradigme';
    }
    $page_keywords .= ", dexonline, DEX online";
    $page_description .= " pentru {$cuv}";
    $page_title = '';
    if (count($sourceList)) {
        $page_description .= " din dicționarele: " . implode(", ", $sourceList);
        if (count($sourceList) == 1) {
            $page_title = ' ' . $sourceList[0];
        }
    }
    $page_title .= $showParadigm ? ' si paradigme' : '';
    smarty_assign('page_title', "{$cuv} - definitie{$page_title}");
    smarty_assign('page_keywords', $page_keywords);
    smarty_assign('page_description', $page_description);
}
// Ads
AdsModule::runAllModules(empty($lexems) ? null : $lexems, empty($definitions) ? null : $definitions);
smarty_assign('text', $text);
smarty_assign('searchType', $searchType);
smarty_assign('showParadigm', $showParadigm);
smarty_assign('paradigmLink', $paradigmLink);
smarty_assign('advancedSearch', $text || $sourceId);
if (!$xml) {
    smarty_displayCommonPageWithSkin('search.ihtml');
} else {
    header('Content-type: text/xml');
    smarty_displayWithoutSkin('common/searchXML.ihtml');
}
$listAll = array();
$content = "";
$messageAlert = array();
$blackList = array();
foreach ($rezultate as $iter) {
    # Skip dexonline.ro from results
    #if(stripos($iter->url, "dexonline.ro") == true)
    #	continue;
    $components = parse_url($iter->url);
    if (StringUtil::endsWith($components['host'], 'dexonline.ro')) {
        continue;
    }
    $listAll[] = $iter->url;
    # Search for "licenta GPL" or "dexonline.ro" in resulted page
    $content = @file_get_contents($iter->url);
    $poslink = stripos($content, "dexonline.ro");
    $posGPL = stripos($content, "GPL");
    if ($poslink === false && $posGPL === false) {
        $blackList[] = $iter->url;
        $messageAlert[] = "Licenta GPL sau link catre dexonline.ro negasite in site-ul {$iter->url} ";
    } else {
        $messageAlert[] = "A fost gasita o mentiune catre licenta GPL sau un link catre dexonline.ro in site-ul {$iter->url} ";
    }
}
smarty_assign('page_title', 'Site Clones');
smarty_assign('definition', $definition);
smarty_assign('listAll', $listAll);
smarty_assign('alert', $messageAlert);
# Print Blacklist items if any
smarty_assign("blackList", $blackList);
smarty_displayCommonPageWithSkin("siteClones.ihtml");
            }
        }
    }
    // 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();
            $l->regenerateParadigm();
        }
    }
}
$deSource = Source::get_by_shortName('DE');
$lexems = Model::factory('Lexem')->distinct()->select('Lexem.*')->join('LexemDefinitionMap', 'Lexem.id = lexemId')->join('Definition', 'definitionId = Definition.id')->where('status', 0)->where('sourceId', $deSource->id)->where('isLoc', 0)->where_like('formNoAccent', "{$prefix}%")->where('verifSp', 0)->where_not_equal('modelType', 'SP')->order_by_asc('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');
smarty_assign('sectionTitle', 'Marcare substantive proprii');
smarty_assign('recentLinks', RecentLink::loadForUser());
smarty_assign('lexems', $lexems);
smarty_assign('prefix', $prefix);
smarty_displayWithoutSkin('admin/properNouns.ihtml');
Example #22
0
<?php

require_once "../phplib/util.php";
$content = util_getRequestParameter('c');
switch ($content) {
    case 'abrev':
        $title = 'Abrevieri';
        break;
    case 'adminHelp':
        $title = 'Mini-manual de moderare';
        break;
    case 'loc':
        $title = 'Legendă LOC';
        break;
    default:
        exit;
}
smarty_assign('title', "{$title} | DEX online");
smarty_assign('content', $content);
smarty_register_outputfilters();
$GLOBALS['smarty_theSmarty']->display('common/static.ihtml');
Example #23
0
        $messages[$date] = sprintf("Definiția '%s' are imaginea asociată '%s', dar fișierul nu există", $def->lexicon, $wotds[0]->image);
        continue;
    }
    if ($firstProblem == $d) {
        $firstProblem++;
    }
}
if ($messages) {
    switch ($firstProblem) {
        case 0:
            $subject = 'ACUM';
            break;
        case 1:
            $subject = 'ASTĂZI';
            break;
        case 2:
            $subject = 'cel târziu mâine';
            break;
        default:
            $subject = sprintf("în %s zile", $firstProblem - 1);
    }
    $subject = 'Cuvântul zilei: acțiune necesară ' . $subject;
    smarty_assign('numDays', NUM_DAYS);
    smarty_assign('messages', $messages);
    $body = smarty_fetch('email/checkWotd.ihtml');
    if ($sendEmail) {
        mail($MAIL_TO, $subject, $body, implode("\n", $MAIL_HEADERS));
    } else {
        print "Subiect: {$subject}\n\n{$body}\n";
    }
}
$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}";
    }
}
$query = "select l.* from Lexem l, LexemDefinitionMap ldm, Definition d where l.id = ldm.lexemId and ldm.definitionId = d.id and d.status = 0 and d.sourceId = {$sourceId} " . "{$nickClause} {$srcClause} order by l.formNoAccent";
$lexemDbResult = db_execute($query);
smarty_assign('recentLinks', RecentLink::loadForUser());
smarty_assign('lexemDbResult', $lexemDbResult);
smarty_displayWithoutSkin('admin/lexemListDbResult.ihtml');
Example #25
0
$FOLDER = util_getRootPath() . '/wwwbase/download/xmldump';
$URL = 'http://dexonline.ro/download/xmldump';
if (count($_GET) == 0) {
    util_redirect("http://wiki.dexonline.ro/wiki/Update4Instructions");
}
$lastDump = getLastDumpDate($TODAY, $FOLDER);
smarty_assign('lastDump', $lastDump);
smarty_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
    smarty_assign('serveFullDump', true);
    $lastClientUpdate = $lastDump;
}
smarty_assign('diffs', getDiffsBetween($lastClientUpdate, $TODAY, $FOLDER));
header('Content-type: text/xml');
print smarty_fetch('common/update4.ihtml');
/**************************************************************************/
// Do not return a dump for today, in case it is still being built
function getLastDumpDate($today, $folder)
{
    $files = scandir($folder, 1);
    // descending
    foreach ($files as $file) {
        $matches = array();
        if (preg_match('/^(\\d\\d\\d\\d-\\d\\d-\\d\\d)-abbrevs.xml.gz$/', $file, $matches)) {
            $candidate = $matches[1];
            if ($candidate < $today && file_exists("{$folder}/{$candidate}-abbrevs.xml.gz") && file_exists("{$folder}/{$candidate}-definitions.xml.gz") && file_exists("{$folder}/{$candidate}-inflections.xml.gz") && file_exists("{$folder}/{$candidate}-ldm.xml.gz") && file_exists("{$folder}/{$candidate}-lexems.xml.gz") && file_exists("{$folder}/{$candidate}-sources.xml.gz")) {
                return $candidate;
            }
Example #26
0
                    smarty_assign('def', $def);
                    smarty_assign('lexemIds', $lexemIds);
                    smarty_assign('user', userCache_get($def->userId));
                    smarty_displayWithoutSkin('common/update3Definitions.ihtml');
                }
                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);
                        smarty_assign('ifs', InflectedForm::loadByLexemId($lexem->id));
                        smarty_assign('lexem', $lexem);
                        smarty_displayWithoutSkin('common/update3Lexems.ihtml');
                    }
                    print "</Lexems>\n";
                }
            }
        }
    }
}
/****************************************************************************/
function userCache_init()
{
    $GLOBALS['USER'] = array();
}
function userCache_get($key)
{
$form = util_getRequestParameter('form');
$locVersion = util_getRequestParameter('locVersion');
$locVersions = pref_getLocVersions();
if ($locVersion && $form) {
    LocVersion::changeDatabase($locVersion);
    $form = StringUtil::cleanupQuery($form);
    smarty_assign('page_title', 'Verificare LOC: ' . $form);
    $ifs = loadLoc($form);
    $lexems = array();
    $inflections = array();
    foreach ($ifs as $if) {
        $lexems[] = Lexem::get_by_id($if->lexemId);
        $inflections[] = Inflection::get_by_id($if->inflectionId);
    }
    smarty_assign('form', $form);
    smarty_assign('selectedLocVersion', $locVersion);
    smarty_assign('ifs', $ifs);
    smarty_assign('lexems', $lexems);
    smarty_assign('inflections', $inflections);
} else {
    smarty_assign('selectedLocVersion', $locVersions[1]->name);
    smarty_assign('page_title', 'Căutare formă flexionară în LOC ' . $form);
}
setlocale(LC_ALL, "ro_RO.utf8");
smarty_assign('locVersions', $locVersions);
smarty_displayCommonPageWithSkin('scrabble-flexiune.ihtml');
function loadLoc($cuv)
{
    $field = StringUtil::hasDiacritics($cuv) ? 'formNoAccent' : 'formUtf8General';
    return Model::factory('InflectedForm')->raw_query("select distinct I.* from InflectedForm I, Lexem L, Model M, ModelDescription MD, ModelType MT " . "where I.lexemId = L.id and L.modelType = MT.code and MT.canonical = M.modelType and L.modelNumber = M.number and M.id = MD.modelId " . "and I.inflectionId = MD.inflectionId and I.variant = MD.variant and MD.applOrder = 0 " . "and I.{$field} = '{$cuv}' and L.isLoc and MD.isLoc order by L.formNoAccent", null)->find_many();
}
<?php

require_once "../../phplib/util.php";
util_assertModerator(PRIV_EDIT);
util_assertNotMirror();
RecentLink::createOrUpdate('Lexeme ambigue');
$lexems = Model::factory('Lexem')->raw_query("select * from Lexem where description = '' group by form having count(*) > 1", null)->find_many();
smarty_assign('sectionTitle', 'Lexeme ambigue (cu nume și descriere identice)');
smarty_assign('recentLinks', RecentLink::loadForUser());
smarty_assign('lexems', $lexems);
smarty_displayWithoutSkin('admin/lexemList.ihtml');
    }
}
$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');
Example #30
0
        smarty_assign('page_title', "{$declensionText}: {$cuv}");
        smarty_assign('declensionText', "{$declensionText}: {$cuv}");
    }
    $sourceNamesArr = array();
    foreach ($lexems as $l) {
        $sourceNamesArr[] = LexemSources::getNamesOfSources($l->source);
    }
    // This paragraph replicates code from paradigm.php
    $hasUnrecommendedForms = false;
    foreach ($ifMaps as $ifMap) {
        foreach ($ifMap as $rank => $ifs) {
            foreach ($ifs as $if) {
                $hasUnrecommendedForms |= !$if->recommended;
            }
        }
    }
    smarty_assign('hasUnrecommendedForms', $hasUnrecommendedForms);
    smarty_assign('sourceNamesArr', $sourceNamesArr);
    smarty_assign('lexems', $filtered_lexems);
    smarty_assign('ifMaps', $ifMaps);
    smarty_assign('showParadigm', true);
    smarty_assign('onlyParadigm', !$ajax);
} else {
    FlashMessage::add("Niciun rezultat pentru {$cuv}.");
    smarty_assign('page_title', "Eroare");
}
if ($ajax) {
    smarty_displayWithoutSkin('common/bits/multiParadigm.ihtml');
} else {
    smarty_displayCommonPageWithSkin('search.ihtml');
}