[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/includes/boxes/ -> articles.php (source)

   1  <?php
   2  /*

   3  $Id: articles.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13  // Most of this file is changed or moved to BTS - Basic Template System - format.

  14  
  15    function tep_show_topic($counter) {
  16      global $tree, $topics_string, $tPath_array;
  17  
  18      for ($i=0; $i<$tree[$counter]['level']; $i++) {
  19        $topics_string .= "&nbsp;&nbsp;";
  20      }
  21  
  22      $topics_string .= '<a href="';
  23  
  24      if ($tree[$counter]['parent'] == 0) {
  25        $tPath_new = 'tPath=' . $counter;
  26      } else {
  27        $tPath_new = 'tPath=' . $tree[$counter]['path'];
  28      }
  29  
  30      $topics_string .= tep_href_link(FILENAME_ARTICLES, $tPath_new) . '">';
  31  
  32      if (isset($tPath_array) && in_array($counter, $tPath_array)) {
  33        $topics_string .= '<b>';
  34      }
  35  
  36  // display topic name

  37      $topics_string .= $tree[$counter]['name'];
  38  
  39      if (isset($tPath_array) && in_array($counter, $tPath_array)) {
  40        $topics_string .= '</b>';
  41      }
  42  
  43      if (tep_has_topic_subtopics($counter)) {
  44        $topics_string .= ' -&gt;';
  45      }
  46  
  47      $topics_string .= '</a>';
  48  
  49      if (SHOW_ARTICLE_COUNTS == 'true') {
  50        $articles_in_topic = tep_count_articles_in_topic($counter);
  51        if ($articles_in_topic > 0) {
  52          $topics_string .= '&nbsp;(' . $articles_in_topic . ')';
  53        }
  54      }
  55  
  56      $topics_string .= '<br>';
  57  
  58      if ($tree[$counter]['next_id'] != false) {
  59        tep_show_topic($tree[$counter]['next_id']);
  60      }
  61    }
  62  ?>
  63  <!-- topics //-->
  64  <?php
  65    $boxHeading = BOX_HEADING_ARTICLES;
  66    $corner_left = 'square';
  67    $corner_right = 'square';
  68    $box_base_name = 'articles'; // for easy unique box template setup (added BTSv1.2)

  69  
  70  //  $box_id = $box_base_name . 'Box';  // for CSS styling paulm (editted BTSv1.2)

  71  
  72  
  73  //  $info_box_contents = array();

  74  //  $info_box_contents[] = array('text' => BOX_HEADING_ARTICLES);

  75  
  76  //  new infoBoxHeading($info_box_contents, true, false);

  77  
  78    $topics_string = '';
  79    $tree = array();
  80  
  81    $topics_query = tep_db_query("select t.topics_id, td.topics_name, t.parent_id from " . TABLE_TOPICS . " t, " . TABLE_TOPICS_DESCRIPTION . " td where t.parent_id = '0' and t.topics_id = td.topics_id and td.language_id = '" . (int)$languages_id . "' order by sort_order, td.topics_name");
  82    while ($topics = tep_db_fetch_array($topics_query))  {
  83      $tree[$topics['topics_id']] = array('name' => $topics['topics_name'],
  84                                          'parent' => $topics['parent_id'],
  85                                          'level' => 0,
  86                                          'path' => $topics['topics_id'],
  87                                          'next_id' => false);
  88  
  89      if (isset($parent_id)) {
  90        $tree[$parent_id]['next_id'] = $topics['topics_id'];
  91      }
  92  
  93      $parent_id = $topics['topics_id'];
  94  
  95      if (!isset($first_topic_element)) {
  96        $first_topic_element = $topics['topics_id'];
  97      }
  98    }
  99  
 100    //------------------------

 101    if (tep_not_null($tPath)) {
 102      $new_path = '';
 103      reset($tPath_array);
 104      while (list($key, $value) = each($tPath_array)) {
 105        unset($parent_id);
 106        unset($first_id);
 107        $topics_query = tep_db_query("select t.topics_id, td.topics_name, t.parent_id from " . TABLE_TOPICS . " t, " . TABLE_TOPICS_DESCRIPTION . " td where t.parent_id = '" . (int)$value . "' and t.topics_id = td.topics_id and td.language_id = '" . (int)$languages_id . "' order by sort_order, td.topics_name");
 108        if (tep_db_num_rows($topics_query)) {
 109          $new_path .= $value;
 110          while ($row = tep_db_fetch_array($topics_query)) {
 111            $tree[$row['topics_id']] = array('name' => $row['topics_name'],
 112                                             'parent' => $row['parent_id'],
 113                                             'level' => $key+1,
 114                                             'path' => $new_path . '_' . $row['topics_id'],
 115                                             'next_id' => false);
 116  
 117            if (isset($parent_id)) {
 118              $tree[$parent_id]['next_id'] = $row['topics_id'];
 119            }
 120  
 121            $parent_id = $row['topics_id'];
 122  
 123            if (!isset($first_id)) {
 124              $first_id = $row['topics_id'];
 125            }
 126  
 127            $last_id = $row['topics_id'];
 128          }
 129          $tree[$last_id]['next_id'] = $tree[$value]['next_id'];
 130          $tree[$value]['next_id'] = $first_id;
 131          $new_path .= '_';
 132        } else {
 133          break;
 134        }
 135      }
 136    }
 137    tep_show_topic($first_topic_element);
 138  
 139    $info_box_contents = array();
 140    $new_articles_string = '';
 141    $all_articles_string = '';
 142  
 143    if (DISPLAY_NEW_ARTICLES=='true') {
 144      if (SHOW_ARTICLE_COUNTS == 'true') {
 145        $articles_new_query = tep_db_query("select a.articles_id from (" . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_TO_TOPICS . " a2t) left join " . TABLE_TOPICS_DESCRIPTION . " td on (a2t.topics_id = td.topics_id) left join " . TABLE_AUTHORS . " au on (a.authors_id = au.authors_id), " . TABLE_ARTICLES_DESCRIPTION . " ad 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 a.articles_id = ad.articles_id and ad.language_id = '" . (int)$languages_id . "' and td.language_id = '" . (int)$languages_id . "' and a.articles_date_added > SUBDATE(now( ), INTERVAL '" . NEW_ARTICLES_DAYS_DISPLAY . "' DAY)");
 146        $articles_new_count = ' (' . tep_db_num_rows($articles_new_query) . ')';
 147      } else {
 148        $articles_new_count = '';
 149      }
 150  
 151      if (strstr($_SERVER['PHP_SELF'],FILENAME_ARTICLES_NEW) or strstr($PHP_SELF,FILENAME_ARTICLES_NEW)) {
 152        $new_articles_string = '<b>';
 153      }
 154  
 155      $new_articles_string .= '<a href="' . tep_href_link(FILENAME_ARTICLES_NEW, '', 'NONSSL') . '">' . BOX_NEW_ARTICLES . '</a>';
 156  
 157      if (strstr($_SERVER['PHP_SELF'],FILENAME_ARTICLES_NEW) or strstr($PHP_SELF,FILENAME_ARTICLES_NEW)) {
 158        $new_articles_string .= '</b>';
 159      }
 160  
 161      $new_articles_string .= $articles_new_count . '<br>';
 162  
 163    }
 164  
 165    if (DISPLAY_ALL_ARTICLES=='true') {
 166      if (SHOW_ARTICLE_COUNTS == 'true') {
 167        $articles_all_query = tep_db_query("select a.articles_id from (" . TABLE_ARTICLES . " a, " . TABLE_ARTICLES_TO_TOPICS . " a2t) left join " . TABLE_TOPICS_DESCRIPTION . " td on (a2t.topics_id = td.topics_id) left join " . TABLE_AUTHORS . " au on (a.authors_id = au.authors_id), " . TABLE_ARTICLES_DESCRIPTION . " ad 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 a.articles_id = ad.articles_id and ad.language_id = '" . (int)$languages_id . "' and td.language_id = '" . (int)$languages_id . "'");
 168        $articles_all_count = ' (' . tep_db_num_rows($articles_all_query) . ')';
 169      } else {
 170        $articles_all_count = '';
 171      }
 172  
 173      if ($topic_depth == 'top') {
 174        $all_articles_string = '<b>';
 175      }
 176  
 177      $all_articles_string .= '<a href="' . tep_href_link(FILENAME_ARTICLES, '', 'NONSSL') . '">' . BOX_ALL_ARTICLES . '</a>';
 178  
 179      if ($topic_depth == 'top') {
 180        $all_articles_string .= '</b>';
 181      }
 182  
 183      $all_articles_string .= $articles_all_count . '<br>';
 184  
 185    }
 186  
 187    $boxContent = $new_articles_string . $all_articles_string . $topics_string;
 188  
 189  //  new infoBox($info_box_contents);

 190  
 191  include (bts_select('boxes', $box_base_name)); // BTS 1.5

 192  ?>
 193  <!-- topics_eof //-->


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7