Home > php教程 > php手册 > body text

xzn_html_tree(1.0) 可折叠大纲

WBOY
Release: 2016-06-21 09:11:57
Original
1083 people have browsed it

/** 可折叠大纲
* 类名 Tree
* 存放位置 xzn/html/tree.php
*/

/** 节点类
* 用于在树中保存相关参数
*
* @param $id    节点号
* @param $text  节点标题
* @param $value 节点参数,一般为url
* @param $image 节点图片
*/
class TreeNode {
  var $id;
  var $text;
  var $value;
  var $image;
  function TreeNode($id,$text,$value,$image) {
    $this->id = $id;
    $this->text = $text;
    $this->value = $value;
    $this->image = $image;
  }
}

/** 树类
* 用于保存和输出可折叠大纲
* 可折叠大纲使用FrontPage 2000的JavaScript脚本
*
* 方法
* set()
* 设置节点,节点编号采用1.2.3.4或1-2-3-4的形式。
* 无层次限制。输入次序不限。
* @param $id    节点号
* @param $text  节点标题
* @param $value 节点参数,一般为url
* @param $image 节点图片
*
* display()
* 向页面输出可折叠大纲
*
* 属性
* @public $node 数组,用于保存节点
* @public $jspath 脚本outline.js存放位置
*/
class Tree {
  var $node;
  var $jspath;
  function set($id,$text,$value="",$image="plus.gif") {
    $d = split("[.-]",$id);
    $e = "";
    for($i=0;$i      $e .= "[".$d][$i]."]";
    $n = new TreeNode($id,$text,$value,$image);
    eval("\$p=&\$this->node$e;");
    $p[node] = $n;
  }
  function display() {
    echo ''."\n";
    echo ''."\n";
    echo ''."\n";
    echo ''."\n";
    ksort($this->node);
    reset($this->node);
    while(list($key,$value) = each($this->node)) {
      $this->next($value,0);
    }
    echo "
\n";
  }
  function next($node,$level) {
    if(! is_array($node))
      return;
    if(isset($node[node])) {
//      echo $level.",".$node[node]->id.",".$node[node]->text.",".$node[node]->value.",".$node[node]->image."\n";
      echo ''."\n";
      echo 'xzn_html_tree(1.0) 可折叠大纲'."\n";
      echo '';
      if(empty($node[node]->value))
        echo $node[node]->text."\n";
      else
        echo ''.$node[node]->text."\n";
      echo ''."\n";
    }
    if(count($node) == 1) {
      echo "\n
\n";
      return;
    }
    ksort($node);
    reset($node);
    while(list($key,$value) = each($node)) {
      $this->next($value,$level+1);
    }
    echo " \n\n";
  }
}
?>



Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template