// If 2 or more lexems have identical forms, only add a definition URL for the first one
        addUrl('http://dexonline.ro/definitie/' . urlencode($rowB[1]));
    }
    if ($rowB[0] && ($rowB[1] == $rowA[1] || $rowB[1] == $rowC[1])) {
        // Only add a link to the lexem if it has homonyms. Otherwise, its page is identical to the definition page.
        addUrl("http://dexonline.ro/lexem/{$rowB[1]}/{$rowB[0]}");
    }
}
// Now process the last row
if ($rowC[1] == $rowB[1]) {
    addUrl("http://dexonline.ro/lexem/{$rowC[1]}/{$rowC[0]}");
} else {
    addUrl('http://dexonline.ro/definitie/' . urlencode($rowC[1]));
}
closeCurrentFile();
generateIndexFile();
log_scriptLog('generateSitemap.php completed');
/*************************************************************************/
function addUrl($url)
{
    global $g_curFile;
    global $g_curFileSize;
    global $g_curFileUrl;
    if ($g_curFileSize >= FILE_SIZE_LIMIT || $g_curFileUrl >= FILE_URL_LIMIT) {
        closeCurrentFile();
        openNewFile();
    }
    $output = "<url><loc>{$url}</loc></url>\n";
    $g_curFileSize += strlen($output);
    $g_curFileUrl++;
    fwrite($g_curFile, $output);
Example #2
0
function generateCategory($parentId = 0, $subCategsRows = array())
{
    global $db;
    global $pathBuilder;
    $sql = CMD_SEL_CATEGORIES;
    $params = array($parentId);
    $rows =& $db->getAll($sql, $params, DB_FETCHMODE_OBJECT);
    if (PEAR::isError($rows)) {
        print $rows->getMessage() . "\n";
        return;
    }
    print "Generate for " . $parentId . "...\n";
    // Сгенерировать блок - "путь к категории"
    $pathBuilder->build($parentId);
    FileUtils::mkDirRecursive(OUTPUT_DIR . "/" . $pathBuilder->pathFile);
    if ($parentId == 0) {
        $indexRows =& $db->getAll(CMD_SEL_FIRSTCATEGORIES, array(), DB_FETCHMODE_OBJECT);
        if (PEAR::isError($indexRows)) {
            print $rows->getMessage() . "\n";
            return;
        }
        generateIndexFile($indexRows);
    } else {
        if (sizeof($rows) > 0) {
            generateRubricatorFile($rows, $parentId, $pathBuilder->pathFile);
        } else {
            generateCatalogFiles($parentId, $pathBuilder->pathFile, $subCategsRows);
        }
        /*
        // Сгенерировать блок - "список категорий"
        saveContents(OUTPUT_DIR . "/" . $pathBuilder->pathFile . "/categs.html",
        	getCategoriesCode($rows));
        */
    }
    // Обработка дочерних разделов
    foreach ($rows as $row) {
        generateCategory($row->id, $rows);
    }
}