public static function changeDatabase($versionName) { $lvs = Config::getLocVersions(); if ($versionName == $lvs[0]->name || !$versionName) { $dbInfo = db_splitDsn(); $dbName = $dbInfo['database']; } else { $lv = new LocVersion(); $lv->name = $versionName; $dbName = Config::get('global.mysql_loc_prefix') . $lv->getDbName(); } db_changeDatabase($dbName); }
<?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');
function run() { $this->cleanup(); // Write forms log_scriptLog('** dumping ' . $this->getName()); foreach (Config::getLocVersions() as $v) { if (!$v->freezeTimestamp || $this->allVersions) { log_scriptLog("* dumping version {$v->name}"); LocVersion::changeDatabase($v->name); $txtFile = $this->getTxtFileName($v); $zipFile = $this->getZipFileName($v); $ftpFile = $this->getFtpFileName($v); $this->writeForms($txtFile); $this->postProcess($txtFile); $this->zipAndShip($txtFile, $zipFile, $ftpFile); } } // Write diffs foreach (Config::getLocVersions() as $i => $v1) { foreach (Config::getLocVersions() as $j => $v2) { if ($i > $j && (!$v2->freezeTimestamp || $this->allVersions)) { log_scriptLog("* computing diffs between {$v1->name} and {$v2->name}"); $this->downloadAndUnzip($v1); $this->downloadAndUnzip($v2); $txt1 = $this->getTxtFileName($v1); $txt2 = $this->getTxtFileName($v2); $diffTxt = $this->getTxtDiffFileName($v1, $v2); $diffZip = $this->getZipDiffFileName($v1, $v2); $diffFtp = $this->getFtpDiffFileName($v1, $v2); OS::executeAndAssert("diff {$txt1} {$txt2} | grep '[<>]' > {$diffTxt} || true"); $this->zipAndShip($diffTxt, $diffZip, $diffFtp); } } } $this->cleanup(); }
<?php require_once __DIR__ . '/../phplib/util.php'; print "Acest script nu a fost adus la zi după introducerea tabelei LexemModel.\n"; print "Aduceți-l la zi înainte de a-l rula.\n"; exit; $lvs = array_reverse(Config::getLocVersions()); if (count($lvs) < 2) { die("ERROR: You need at least two LOC versions in dex.conf: " . "one that indicates the version to be frozen and " . "one to indicate the next current version.\n"); } $locDbPrefix = Config::get('global.mysql_loc_prefix'); if (!$locDbPrefix) { die("ERROR: You forgot to define mysql_loc_prefix in dex.conf.\n"); } // Assert that all the already frozen versions exist. for ($i = 0; $i < count($lvs) - 2; $i++) { print "Asserting that version {$lvs[$i]->name} exists.\n"; $dbName = $locDbPrefix . $lvs[$i]->getDbName(); if (!databaseExists($dbName)) { die("ERROR: Database {$dbName} for version {$lvs[$i]->name} " . "does not exist.\n"); } if (!$lvs[$i]->freezeTimestamp) { die("ERROR: Version {$lvs[$i]->name} should have a freeze date\n"); } } // Assert that the next-to-last version does not yet exist. $lvToFreeze = $lvs[count($lvs) - 2]; print "Asserting that version {$lvToFreeze->name} does not exist.\n"; $dbName = $locDbPrefix . $lvToFreeze->getDbName(); if (databaseExists($dbName)) { die("ERROR: Database {$dbName} for version {$lvToFreeze->name} " . "should not exist.\n");