예제 #1
0
 public static function changeDatabase($versionName)
 {
     $lvs = pref_getLocVersions();
     if ($versionName == $lvs[0]->name || !$versionName) {
         $dbInfo = db_splitDsn();
         $dbName = $dbInfo['database'];
     } else {
         $lv = new LocVersion();
         $lv->name = $versionName;
         $dbName = pref_getLocPrefix() . $lv->getDbName();
     }
     db_changeDatabase($dbName);
 }
<?php

require_once "../phplib/util.php";
$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)
{
예제 #3
0
                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);
}
<?php

require_once "../phplib/util.php";
$lvs = array_reverse(pref_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 = pref_getLocPrefix();
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");
}
if (!$lvToFreeze->freezeTimestamp) {
    die("ERROR: Version {$lvToFreeze->name} should have a freeze date\n");