Beispiel #1
0
function vam_count_articles_in_topic($topic_id, $include_inactive = false)
{
    $articles_count = 0;
    if ($include_inactive == true) {
        $articles_query = vamDBquery("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 = vamDBquery("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 = vam_db_fetch_array($articles_query, true);
    $articles_count += $articles['total'];
    $child_topics_query = vamDBquery("select topics_id from " . TABLE_TOPICS . " where parent_id = '" . (int) $topic_id . "'");
    if (vam_db_num_rows($child_topics_query, true)) {
        while ($child_topics = vam_db_fetch_array($child_topics_query, true)) {
            $articles_count += vam_count_articles_in_topic($child_topics['topics_id'], $include_inactive);
        }
    }
    return $articles_count;
}
Beispiel #2
0
 function vam_show_topic($counter)
 {
     global $tree, $topics_string, $tPath_array;
     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'];
     }
     $SEF_parameter_cat = '';
     if (SEARCH_ENGINE_FRIENDLY_URLS == 'true') {
         $SEF_parameter_cat = '&category=' . vam_cleanName($tree[$counter]['name']);
     }
     $topics_string .= vam_href_link(FILENAME_ARTICLES, $tPath_new . $SEF_parameter_cat) . '">';
     if (isset($tPath_array) && in_array($counter, $tPath_array)) {
         $topics_string .= '<b>';
     }
     // display topic name
     $topics_string .= $tree[$counter]['name'];
     if (isset($tPath_array) && in_array($counter, $tPath_array)) {
         $topics_string .= '</b>';
     }
     if (vam_has_topic_subtopics($counter)) {
         $topics_string .= ' -&gt;';
     }
     $topics_string .= '</a>';
     if (SHOW_ARTICLE_COUNTS == 'true') {
         $articles_in_topic = vam_count_articles_in_topic($counter);
         if ($articles_in_topic > 0) {
             $topics_string .= '&nbsp;(' . $articles_in_topic . ')';
         }
     }
     $topics_string .= '<br />' . "\n";
     if ($tree[$counter]['next_id'] != false) {
         vam_show_topic($tree[$counter]['next_id']);
     }
 }