Example #1
0
    $rows = 0;
    if (isset($_POST['search'])) {
        $search = smn_db_prepare_input($_POST['search']);
        $categories_query = smn_db_query("select cd.categories_description, c.category_head_title_tag, c.category_head_desc_tag, c.category_head_keywords_tag, c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.store_id = '" . $store_id . "' and c.store_id = '" . $store_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int) $languages_id . "' and cd.categories_name like '%" . smn_db_input($search) . "%' order by c.sort_order, cd.categories_name");
    } else {
        $categories_query = smn_db_query("select cd.categories_description, c.category_head_title_tag, c.category_head_desc_tag, c.category_head_keywords_tag, c.categories_id, cd.categories_name, c.categories_image, c.parent_id, c.sort_order, c.date_added, c.last_modified from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where cd.store_id = '" . $store_id . "' and c.store_id = '" . $store_id . "' and c.parent_id = '" . (int) $current_category_id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int) $languages_id . "' order by c.sort_order, cd.categories_name");
    }
    while ($categories = smn_db_fetch_array($categories_query)) {
        $categories_count++;
        $rows++;
        // Get parent_id for subcategories if search
        if (isset($_POST['search'])) {
            $cPath = $categories['parent_id'];
        }
        if ((!isset($_GET['cID']) && !isset($_GET['pID']) || isset($_GET['cID']) && $_GET['cID'] == $categories['categories_id']) && !isset($cInfo) && substr($action, 0, 3) != 'new') {
            $category_childs = array('childs_count' => smn_childs_in_category_count($categories['categories_id']));
            $category_products = array('products_count' => smn_products_in_category_count($categories['categories_id']));
            $cInfo_array = array_merge($categories, $category_childs, $category_products);
            $cInfo = new objectInfo($cInfo_array);
        }
        if (isset($cInfo) && is_object($cInfo) && $categories['categories_id'] == $cInfo->categories_id) {
            echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . smn_href_link(FILENAME_CATEGORIES, smn_get_path($categories['categories_id'])) . '\'">' . "\n";
        } else {
            echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . smn_href_link(FILENAME_CATEGORIES, 'cPath=' . $cPath . '&cID=' . $categories['categories_id']) . '\'">' . "\n";
        }
        ?>
                <td class="dataTableContent"><?php 
        echo '<a href="' . smn_href_link(FILENAME_CATEGORIES, smn_get_path($categories['categories_id'])) . '">' . smn_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . '</a>&nbsp;<b>' . $categories['categories_name'] . '</b>';
        ?>
</td>
                <td class="dataTableContent" align="center">&nbsp;</td>
Example #2
0
function smn_childs_in_category_count($categories_id)
{
    global $store_id;
    $categories_count = 0;
    $categories_query = smn_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int) $categories_id . "' and store_id = '" . $store_id . "'");
    while ($categories = smn_db_fetch_array($categories_query)) {
        $categories_count++;
        $categories_count += smn_childs_in_category_count($categories['categories_id']);
    }
    return $categories_count;
}