コード例 #1
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>
                <td class="dataTableContent" align="right"><?php 
コード例 #2
0
ファイル: general.php プロジェクト: stanislauslive/StanMarket
function smn_products_in_category_count($categories_id, $include_deactivated = false)
{
    global $store_id;
    $products_count = 0;
    if ($include_deactivated) {
        $products_query = smn_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where  p.store_id = '" . $store_id . "'  and p2c.store_id = '" . $store_id . "' and p.products_id = p2c.products_id and p2c.categories_id = '" . (int) $categories_id . "'");
    } else {
        $products_query = smn_db_query("select count(*) as total from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c where  p.store_id = '" . $store_id . "'  and p2c.store_id = '" . $store_id . "' and p.products_id = p2c.products_id and p.products_status = '1' and p2c.categories_id = '" . (int) $categories_id . "'");
    }
    $products = smn_db_fetch_array($products_query);
    $products_count += $products['total'];
    $childs_query = smn_db_query("select categories_id from " . TABLE_CATEGORIES . " where parent_id = '" . (int) $categories_id . "' and store_id = '" . $store_id . "'");
    if (smn_db_num_rows($childs_query)) {
        while ($childs = smn_db_fetch_array($childs_query)) {
            $products_count += smn_products_in_category_count($childs['categories_id'], $include_deactivated);
        }
    }
    return $products_count;
}