Example #1
0
function tep_articles_in_topic_count($topics_id, $include_deactivated = false)
{
    $articles_count = 0;
    if ($include_deactivated) {
        $articles_query = tep_db_query("select count(*) as total from " . TABLE_ARTICLES . " p, " . TABLE_ARTICLES_TO_TOPICS . " p2c where p.articles_id = p2c.articles_id and p2c.topics_id = '" . (int) $topics_id . "'");
    } else {
        $articles_query = tep_db_query("select count(*) as total from " . TABLE_ARTICLES . " p, " . TABLE_ARTICLES_TO_TOPICS . " p2c where p.articles_id = p2c.articles_id and p.articles_status = '1' and p2c.topics_id = '" . (int) $topics_id . "'");
    }
    $articles = tep_db_fetch_array($articles_query);
    $articles_count += $articles['total'];
    $childs_query = tep_db_query("select topics_id from " . TABLE_TOPICS . " where parent_id = '" . (int) $topics_id . "'");
    if (tep_db_num_rows($childs_query)) {
        while ($childs = tep_db_fetch_array($childs_query)) {
            $articles_count += tep_articles_in_topic_count($childs['topics_id'], $include_deactivated);
        }
    }
    return $articles_count;
}
Example #2
0
    if (isset($_GET['search'])) {
        $search = tep_db_prepare_input($_GET['search']);
        $topics_query = tep_db_query("select t.topics_id, td.topics_name, t.parent_id, t.sort_order, t.date_added, t.last_modified from " . TABLE_TOPICS . " t, " . TABLE_TOPICS_DESCRIPTION . " td where t.topics_id = td.topics_id and td.language_id = '" . (int) $languages_id . "' and td.topics_name like '%" . tep_db_input($search) . "%' order by t.sort_order, td.topics_name");
    } else {
        $topics_query = tep_db_query("select t.topics_id, td.topics_name, t.parent_id, t.sort_order, t.date_added, t.last_modified from " . TABLE_TOPICS . " t, " . TABLE_TOPICS_DESCRIPTION . " td where t.parent_id = '" . (int) $current_topic_id . "' and t.topics_id = td.topics_id and td.language_id = '" . (int) $languages_id . "' order by t.sort_order, td.topics_name");
    }
    while ($topics = tep_db_fetch_array($topics_query)) {
        $topics_count++;
        $rows++;
        // Get parent_id for subtopics if search
        if (isset($_GET['search'])) {
            $tPath = $topics['parent_id'];
        }
        if ((!isset($_GET['tID']) && !isset($_GET['aID']) || isset($_GET['tID']) && $_GET['tID'] == $topics['topics_id']) && !isset($tInfo) && substr($action, 0, 3) != 'new') {
            $topic_childs = array('childs_count' => tep_childs_in_topic_count($topics['topics_id']));
            $topic_articles = array('articles_count' => tep_articles_in_topic_count($topics['topics_id']));
            $tInfo_array = array_merge($topics, $topic_childs, $topic_articles);
            $tInfo = new objectInfo($tInfo_array);
        }
        if (isset($tInfo) && is_object($tInfo) && $topics['topics_id'] == $tInfo->topics_id) {
            echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_ARTICLES, tep_get_topic_path($topics['topics_id'])) . '\'">' . "\n";
        } else {
            echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_ARTICLES, 'tPath=' . $tPath . '&amp;tID=' . $topics['topics_id']) . '\'">' . "\n";
        }
        ?>
                <td class="dataTableContent"><?php 
        echo '<a href="' . tep_href_link(FILENAME_ARTICLES, tep_get_topic_path($topics['topics_id'])) . '">' . tep_image(DIR_WS_ICONS . 'folder.gif', ICON_FOLDER) . '</a>&nbsp;<b>' . $topics['topics_name'] . '</b>';
        ?>
</td>
                <td class="dataTableContent" align="center">&nbsp;</td>
                <td class="dataTableContent" align="right"><?php