示例#1
0
        $news_categories_query = tep_db_query("select nc.news_categories_id, nc.sort_order, nc.news_categories_name, nc.parent_id, nc.date_added, nc.icon from " . TABLE_NEWS_CATEGORIES . " nc where nc.news_categories_name like '%" . tep_db_input($search) . "%' order by nc.sort_order, nc.news_categories_name");
    } else {
        $news_categories_query = tep_db_query("select nc.news_categories_id, nc.sort_order, nc.news_categories_name, nc.parent_id, nc.date_added, nc.icon from " . TABLE_NEWS_CATEGORIES . " nc where nc.parent_id = '" . (int) $current_news_categories_id . "' order by nc.sort_order, nc.news_categories_name");
    }
    while ($news_categories = tep_db_fetch_array($news_categories_query)) {
        $news_categories_count++;
        $rows++;
        // Get parent_id for subnews if search
        if (isset($HTTP_GET_VARS['search'])) {
            $cPath = $news_categories['parent_id'];
        }
        if ((!isset($HTTP_GET_VARS['cID']) && !isset($HTTP_GET_VARS['nID']) || isset($HTTP_GET_VARS['cID']) && $HTTP_GET_VARS['cID'] == $news_categories['news_categories_id']) && !isset($cInfo) && substr($action, 0, 3) != 'new') {
            //get category con
            $news_categories_childs = array('childs_count' => tep_childs_in_news_categories_count($news_categories['news_categories_id']));
            //lay cac news thuoc category
            $news = array('news_count' => tep_news_in_news_categories_count($news_categories['news_categories_id']));
            $cInfo_array = array_merge($news_categories, $news_categories_childs, $news);
            $cInfo = new objectInfo($cInfo_array);
        }
        if (isset($cInfo) && is_object($cInfo) && $news_categories['news_categories_id'] == $cInfo->news_categories_id) {
            echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWS, tep_get_news_categories_path($news_categories['news_categories_id'])) . '\'">' . "\n";
        } else {
            echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_NEWS, 'cPath=' . $cPath . '&cID=' . $news_categories['news_categories_id']) . '\'">' . "\n";
        }
        ?>
                <td class="dataTableContent"><?php 
        echo '<a href="' . tep_href_link(FILENAME_NEWS, tep_get_news_categories_path($news_categories['news_categories_id'])) . '">' . tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . '</a>&nbsp;<b>' . $news_categories['news_categories_name'] . '</b>';
        ?>
</td>
                <td class="dataTableContent" align="center">&nbsp;</td>
                <td class="dataTableContent" align="right"><?php 
示例#2
0
function tep_news_in_news_categories_count($categories_id, $include_deactivated = false)
{
    $products_count = 0;
    if ($include_deactivated) {
        $products_query = tep_db_query("select count(*) as total from " . TABLE_NEWS . " n where n.news_categories_id = '" . (int) $categories_id . "'");
    } else {
        $products_query = tep_db_query("select count(*) as total from " . TABLE_NEWS . " n where n.news_status = '1' and n.news_categories_id = '" . (int) $categories_id . "'");
    }
    $products = tep_db_fetch_array($products_query);
    $products_count += $products['total'];
    $childs_query = tep_db_query("select news_categories_id from " . TABLE_NEWS_CATEGORIES . " where parent_id = '" . (int) $categories_id . "'");
    if (tep_db_num_rows($childs_query)) {
        while ($childs = tep_db_fetch_array($childs_query)) {
            $products_count += tep_news_in_news_categories_count($childs['news_categories_id'], $include_deactivated);
        }
    }
    return $products_count;
}