Exemple #1
0
function format_cat_translation_table($cat)
{
    global $AVAILABLE_LANGS;
    //$sql = "SELECT categories.category_id, categories.category_name, lang, cat_name_translations.category_name AS NAME FROM categories LEFT JOIN cat_name_translations ON categories.category_id = cat_name_translations.category_id WHERE lang is NULL";
    foreach ($AVAILABLE_LANGS as $key => $val) {
        $sql = "SELECT categories.category_id, categories.category_name, lang FROM cat_name_translations, categories WHERE categories.category_id=cat_name_translations.category_id AND categories.category_id='{$cat}' AND lang='{$key}' ";
        //echo $sql;
        $result = mysql_query($sql) or die(mysql_error());
        //$row = mysql_fetch_row($result);
        if (mysql_num_rows($result) == 0) {
            $cat_row = get_category($cat);
            $sql = "REPLACE INTO `cat_name_translations` (`category_id`, `lang`, `category_name`) VALUES ('" . $cat . "', '" . $key . "', '" . addslashes($cat_row['category_name']) . "')";
            //echo "<b>$sql</b>";
            mysql_query($sql) or die(mysql_error() . $sql);
            // echo "$sql<br>";
        }
    }
    $search_set = get_search_set($cat, $cat);
    $sql = "update categories set search_set='{$search_set}' where category_id='{$cat}'";
    mysql_query($sql) or die(mysql_error() . $sql);
    $query = "SELECT * FROM categories WHERE parent_category_id='{$cat}' ";
    $result = mysql_query($query) or die(mysql_error() . $query);
    while ($row = mysql_fetch_array($result)) {
        format_cat_translation_table($row['category_id']);
    }
}
if ($action == 'del') {
    $_REQUEST['cat'] = getCatParent($_REQUEST['category_id']);
    // so that we come back to parent..
    if (($obj_count = del_cat_recursive($_REQUEST['category_id'])) < 0) {
        $obj_count = -$obj_count;
        echo "<br><font color='red'><b>Error:</b></font> Cannot delete this category: It looks like you have " . $obj_count . " record(s) in this category! <a href='" . $_SERVER['PHP_SELF'] . "?action=del&category_id=" . $_REQUEST['category_id'] . "&confirm=yes'>Click Here to delete anyway.</a></br>";
    }
    if ($_REQUEST['save'] != '' && CACHE_ENABLED == 'YES') {
        $CACHE_ENABLED = 'NO';
        include '../include/codegen_functions.php';
        update_category_cache(0);
        $CACHE_ENABLED = 'YES';
    }
}
if ($_REQUEST['action'] == 'process') {
    format_cat_translation_table(0);
    if ($_REQUEST['save'] != '' && CACHE_ENABLED == 'YES') {
        $CACHE_ENABLED = 'NO';
        include '../include/codegen_functions.php';
        update_category_cache(0);
        $CACHE_ENABLED = 'YES';
    }
}
echo "<div align='left'><h3><a href=" . htmlentities($_SERVER['PHP_SELF']) . ">Root Category</a> -&gt; " . getPath($_REQUEST['cat'], $_SERVER['PHP_SELF'], $_SESSION[form_id]) . " ";
if ($_REQUEST['cat'] != 0) {
    $MODE = "ADMIN";
    ?>
<a onClick="return confirmLink(this, 'Delete this category, are you sure? (This will also delete all sub-categories in this category)') " href="<?php 
    echo htmlentities($_SERVER['PHP_SELF']);
    ?>
?action=del&category_id=<?php