PHP Classes

File: treemenu.php

Recommend this page to a friend!
  Classes of lalevee   treemenu1.2   treemenu.php   Download  
File: treemenu.php
Role: ???
Content type: text/plain
Description: HTML tree menu
Class: treemenu1.2
Author: By
Last change:
Date: 22 years ago
Size: 3,678 bytes
 

Contents

Class file image Download
<?php /* ** treemenu.php class version 1.0 12/24/99 Sword_Su@263.net ** version 1.2 04/15/01 raymond.lalevee@libertysurf.fr ** */ class submenu { var $classname = "submenu"; /* for serialize */ var $urls = array(); var $desps = array(); var $id; var $attr = array('ON_bgcolor' => '#34ABC0','ON_fontcolor' => 'White', 'ON_align' => 'center', 'OFF_bgcolor' => '#34ABBB','OFF_fontcolor' => 'White', 'OFF_align' => 'center', 'ELT_align' => 'center' ); function submenu($id,$parm) { /* constructor */ if (!empty($parm)) { while (list($k,$v) = each($parm)) { $this->attr[$k] = $v; } } $this->id=$id; } function add($url, $desp) { array_push($this->urls,$url); array_push($this->desps,$desp); } function open() { echo '<table width="15%" border="0" align="center">'; for ($i=0;$i<=count($this->urls);$i++) { if ($i == 0) { echo '<tr><th align='.$this->attr['ON_align'].' bgcolor='.$this->attr['ON_bgcolor'].'><font color='.$this->attr['ON_fontcolor'].'>'; echo $this->desps[0]; echo '</font></th></tr>'; } else { echo '<tr><td align='.$this->attr['ELT_align'].'><font size="-1">'; echo '<a href="'.$this->urls[$i].'">'.$this->desps[$i].'</a>'; echo '</font></td></tr>'; } } echo '</table>'; } function close() { echo '<table width="15%" border="0" align="center">'; echo '<tr><th align='.$this->attr['OFF_align'].' bgcolor='.$this->attr['OFF_bgcolor'].'><font color='.$this->attr['OFF_fontcolor'].'>'; echo '<a href="?action=open&id='.$this->id.'">'.$this->desps[0].'</a>'; echo '</font></th></tr>'; echo '</table>'; } } class menu { var $classname = "menu"; /* for serialize */ var $submenus = array(); function menu() { $this->id=2; } function add($submenu) { array_push($this->submenus,$submenu); } function show() { for ($i=0;$i<count($this->submenus);$i++) { /* Use this line code if you have problem parsing if ($this->submenus[$i]->id == $this->id) { */ if ($this->submenus[$i]->id == (string)$this->id) { $this->submenus[$i]->open(); } else { $this->submenus[$i]->close(); } } } } $sm_1=new submenu('1',array('ON_bgcolor' => 'red', 'OFF_bgcolor' => 'yellow', 'OFF_fontcolor' => 'red', 'ELT_align' => 'left')); $sm_1->add('','FLEURISTE'); $sm_1->add('http://www.whu.edu.cn','choix1'); $sm_1->add('http://www.whnet.edu.cn','choix2'); $sm_1->add('http://www.pku.edu.cn','choix3'); $sm_1->add('http://www.tsinghua.edu.cn','choix4'); $sm_2=new submenu('2',array('ON_bgcolor' => 'red', 'OFF_bgcolor' => 'blue', 'OFF_fontcolor' => 'red')); $sm_2->add('','EXECUTANT'); $sm_2->add('http://www.whu.edu.cn','choix1'); $sm_2->add('http://www.whnet.edu.cn','choix2'); $sm_2->add('http://www.pku.edu.cn','choix3'); $sm_2->add('http://www.tsinghua.edu.cn','choix4'); $sm_2->add('http://www.tsinghua.edu.cn','choix5'); $sm_2->add('http://www.tsinghua.edu.cn','choix6'); $sm_3=new submenu('3',array('ON_bgcolor' => 'red', 'OFF_bgcolor' => 'green','ELT_align' => 'right')); $sm_3->add('','COMMANDES'); $sm_3->add('http://www.whu.edu.cn','choice one'); $sm_3->add('http://www.whnet.edu.cn','choice two'); $sm_3->add('http://www.pku.edu.cn','choice three'); $sm_3->add('http://www.tsinghua.edu.cn','choice four'); $m_1=new menu; $m_1->add($sm_1); $m_1->add($sm_2); $m_1->add($sm_3); if ($action=='') { $m_1->show(); } if ($action=='open') { $m_1->id=$id; $m_1->show(); } ?>