[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
[phpBB Debug] PHP Warning: in file [ROOT]/includes/crs/crs_misc_functions.php on line 37: mime_content_type(): Empty filename or path
Zen Cart 源代码 site_map.php

Zen Cart 源代码 site_map.php




下载文件

文件名: site_map.php
文件类型: PHP文件
文件大小: 3.18 KiB
MD5: e943497473ea5d10dfb8f9f4dfccb0a5

site_map.php - 关闭高亮
  1. <?php
  2. /**
  3.  * site_map.php
  4.  *
  5.  * @package general
  6.  * @copyright Copyright 2003-2005 Zen Cart Development Team
  7.  * @copyright Portions Copyright 2003 osCommerce
  8.  * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
  9.  * @version $Id: site_map.php 3041 2006-02-15 21:56:45Z wilt $
  10.  */
  11. if (!defined('IS_ADMIN_FLAG')) {
  12.   die('Illegal Access');
  13. }
  14. /**
  15.  * site_map.php
  16.  *
  17.  * @package general
  18.  */
  19.  class zen_SiteMapTree {
  20.    var $root_category_id = 0,
  21.        $max_level = 0,
  22.        $data = array(),
  23.        $root_start_string = '',
  24.        $root_end_string = '',
  25.        $parent_start_string = '',
  26.        $parent_end_string = '',
  27.        $parent_group_start_string = "\n<ul>",
  28.        $parent_group_end_string = "</ul>\n",
  29.        $child_start_string = '<li>',
  30.        $child_end_string = "</li>\n",
  31.        $spacer_string = '',
  32.        $spacer_multiplier = 1;
  33.  
  34.    function zen_SiteMapTree($load_from_database = true) {
  35.      global $languages_id, $db;
  36.   $this->data = array();
  37.  $categories_query = "select c.categories_id, cd.categories_name, c.parent_id
  38.                      from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd
  39.                      where c.categories_id = cd.categories_id
  40.                      and cd.language_id = '" . (int)$_SESSION['languages_id'] . "'
  41.                      and c.categories_status != '0'
  42.                      order by c.parent_id, c.sort_order, cd.categories_name";
  43.          $categories = $db->Execute($categories_query);
  44.          while (!$categories->EOF) {
  45.            $this->data[$categories->fields['parent_id']][$categories->fields['categories_id']] = array('name' => $categories->fields['categories_name'], 'count' => 0);
  46.            $categories->MoveNext();
  47.          }
  48.    }
  49.  
  50.    function buildBranch($parent_id, $level = 0, $parent_link = '') {
  51.     $result = $this->parent_group_start_string;
  52.  
  53.     if (isset($this->data[$parent_id])) {
  54.       foreach ($this->data[$parent_id] as $category_id => $category) {
  55.         $category_link = $parent_link . $category_id;
  56.         $result .= $this->child_start_string;
  57.         if (isset($this->data[$category_id])) {
  58.           $result .= $this->parent_start_string;
  59.         }
  60.  
  61.         if ($level == 0) {
  62.           $result .= $this->root_start_string;
  63.         }
  64.         $result .= str_repeat($this->spacer_string, $this->spacer_multiplier * $level) . '<a href="' . zen_href_link(FILENAME_DEFAULT, 'cPath=' . $category_link) . '">';
  65.         $result .= $category['name'];
  66.         $result .= '</a>';
  67.  
  68.         if ($level == 0) {
  69.           $result .= $this->root_end_string;
  70.         }
  71.  
  72.         if (isset($this->data[$category_id])) {
  73.           $result .= $this->parent_end_string;
  74.         }
  75.  
  76. //        $result .= $this->child_end_string;
  77.  
  78.        if (isset($this->data[$category_id]) && (($this->max_level == '0') || ($this->max_level > $level+1))) {
  79.          $result .= $this->buildBranch($category_id, $level+1, $category_link . '_');
  80.        }
  81.        $result .= $this->child_end_string;
  82.  
  83.      }
  84.    }
  85.  
  86.     $result .= $this->parent_group_end_string;
  87.  
  88.     return $result;
  89.   }
  90.    function buildTree() {
  91.      return $this->buildBranch($this->root_category_id);
  92.    }
  93.  }
  94. ?>