Пример #1
0
function tep_count_articles_in_topic($topic_id, $include_inactive = false)
{
    $articles_count = 0;
    if ($include_inactive == true) {
        $articles_query = tep_db_query("select count(*) as total from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_TO_TOPICS . " a2t where (a.articles_date_available IS NULL or to_days(a.articles_date_available) <= to_days(now())) and a.articles_id = a2t.articles_id and a2t.topics_id = '" . (int) $topic_id . "'");
    } else {
        $articles_query = tep_db_query("select count(*) as total from " . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_TO_TOPICS . " a2t where (a.articles_date_available IS NULL or to_days(a.articles_date_available) <= to_days(now())) and a.articles_id = a2t.articles_id and a.articles_status = '1' and a2t.topics_id = '" . (int) $topic_id . "'");
    }
    $articles = tep_db_fetch_array($articles_query);
    $articles_count += $articles['total'];
    $child_topics_query = tep_db_query("select topics_id from " . TABLE_TOPICS . " where parent_id = '" . (int) $topic_id . "'");
    if (tep_db_num_rows($child_topics_query)) {
        while ($child_topics = tep_db_fetch_array($child_topics_query)) {
            $articles_count += tep_count_articles_in_topic($child_topics['topics_id'], $include_inactive);
        }
    }
    return $articles_count;
}
Пример #2
0
function tep_show_topic($counter)
{
    global $tree, $topics_string, $tPath_array;
    $topic_string = '';
    for ($i = 0; $i < $tree[$counter]['level']; $i++) {
        $topics_string .= "&nbsp;&nbsp;";
    }
    $topics_string .= '<a href="';
    if ($tree[$counter]['parent'] == 0) {
        $tPath_new = 'tPath=' . $counter;
    } else {
        $tPath_new = 'tPath=' . $tree[$counter]['path'];
    }
    $topics_string .= tep_href_link(FILENAME_ARTICLES, $tPath_new) . '">';
    if (isset($tPath_array) && in_array($counter, $tPath_array)) {
        $topics_string .= '<b>';
    }
    // display topic name
    if (tep_has_topic_subtopics($counter)) {
        $topics_string .= tep_image(DIR_WS_ICONS . 'pointer_blue.gif', '');
    } else {
        $topics_string .= tep_image(DIR_WS_ICONS . 'pointer_blue_light.gif', '');
    }
    $topics_string .= $tree[$counter]['name'];
    if (isset($tPath_array) && in_array($counter, $tPath_array)) {
        $topics_string .= '</b>';
    }
    $topics_string .= '</a>';
    if (SHOW_ARTICLE_COUNTS == 'true') {
        $articles_in_topic = tep_count_articles_in_topic($counter);
        if ($articles_in_topic > 0) {
            $topics_string .= '&nbsp;(' . $articles_in_topic . ')';
        }
    }
    $topics_string .= '<br>';
    if ($tree[$counter]['next_id'] != false) {
        tep_show_topic($tree[$counter]['next_id']);
    }
}