Example #1
0
function fu_generate_slugs_pages($rewriteExistingSlugs = false, $addHtmlExt = true, $lowercaseTranslit = false)
{
    // Reset slugs
    if ($rewriteExistingSlugs) {
        fu_reset_slugs('pages');
    }
    $countUpdated = 0;
    // Process items
    while (($items = fu_get_pages_to_process()) && $countUpdated < AUTO_TRANSLITERATOR_ITEMS_LIMIT) {
        foreach ($items as $item) {
            // Get unique slug
            $slugTranslitted = fu_translit($item['aux_page_name']);
            $slug = $addHtmlExt ? $slugTranslitted . '.html' : $slugTranslitted;
            if ($lowercaseTranslit) {
                $slug = strtolower($slug);
            }
            $i = 0;
            while (fu_slug_exists($slug)) {
                $slug = $addHtmlExt ? $slugTranslitted . '_' . ++$i . '.html' : $slugTranslitted . '_' . ++$i;
            }
            // Update slug
            $sql = "UPDATE " . AUX_PAGES_TABLE . "\n          SET\n            uri='{$slug}'\n          WHERE aux_page_ID='{$item['aux_page_ID']}'\n          LIMIT 1";
            $result = db_query($sql);
            $countUpdated++;
        }
    }
    return $countUpdated;
}
Example #2
0
function fu_generate_product($productID, $sef)
{
    if ($productID && $sef) {
        $slug = strtolower(fu_translit($sef) . '.html');
        $sql = '
        UPDATE ' . PRODUCTS_TABLE . '
        SET
        uri="' . $slug . '"
        WHERE productID="' . $productID . '"';
        db_query($sql);
    }
}