function dumpAbbrevs($fileName)
{
    log_scriptLog("dumping abbreviations");
    $raw_abbrevs = AdminStringUtil::loadRawAbbreviations();
    $sources = array();
    $sections = array();
    foreach ($raw_abbrevs as $name => $raw_section) {
        if ($name == "sources") {
            // the index of sources
            foreach ($raw_section as $id => $source) {
                $sources[$id] = preg_split('/, */', $source);
            }
        } else {
            // a single source
            $section = array();
            foreach ($raw_section as $short => $long) {
                $abbrev_info = array('short' => $short, 'long' => $long, 'ambiguous' => false);
                if (substr($short, 0, 1) == "*") {
                    $abbrev_info['short'] = substr($short, 1);
                    $abbrev_info['ambiguous'] = true;
                }
                $section[] = $abbrev_info;
            }
            $sections[$name] = $section;
        }
    }
    smarty_assign('sources', $sources);
    smarty_assign('sections', $sections);
    $xml = smarty_fetch('xmldump/abbrev.ihtml');
    file_put_contents($fileName, gzencode($xml));
}
Exemple #2
0
$timestamp = util_getRequestIntParameter('timestamp');
$version = util_getRequestParameterWithDefault('version', '3.0');
if ($export && util_isDesktopBrowser() && !session_getUser()) {
    SmartyWrap::display('bits/updateError.tpl');
    exit;
}
if ($export == 'sources') {
    SmartyWrap::assign('sources', Model::factory('Source')->find_many());
    SmartyWrap::displayWithoutSkin('xml/update3Sources.tpl');
} else {
    if ($export == 'inflections') {
        SmartyWrap::assign('inflections', Model::factory('Inflection')->order_by_asc('id')->find_many());
        SmartyWrap::displayWithoutSkin('xml/update3Inflections.tpl');
    } else {
        if ($export == 'abbrev') {
            SmartyWrap::assign('abbrev', AdminStringUtil::loadRawAbbreviations());
            SmartyWrap::displayWithoutSkin('xml/update3Abbrev.tpl');
        } else {
            if ($export == 'definitions') {
                userCache_init();
                $statusClause = $timestamp ? '' : ' and status = 0';
                $defDbResult = db_execute("select * from Definition where modDate >= '{$timestamp}' and sourceId in (select id from Source where canDistribute) " . "{$statusClause} order by modDate, id", PDO::FETCH_ASSOC);
                //
                $lexemDbResult = db_execute("select Definition.id, lexemId from Definition force index(modDate), LexemDefinitionMap " . "where Definition.id = definitionId and Definition.modDate >= {$timestamp} " . "and sourceId in (select id from Source where canDistribute) " . "{$statusClause} order by Definition.modDate, Definition.id", PDO::FETCH_NUM);
                $currentLexem = $lexemDbResult->fetch();
                print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
                print "<Definitions>\n";
                print "  <NumResults>" . $defDbResult->rowCount() . "</NumResults>\n";
                foreach ($defDbResult as $dbRow) {
                    $def = Model::factory('Definition')->create($dbRow);
                    $def->internalRep = AdminStringUtil::xmlizeRequired($def->internalRep);