summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/classes
diff options
context:
space:
mode:
authorartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-05-29 08:47:18 +0000
committerartem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-05-29 08:47:18 +0000
commit0990cdce6c98be640a3c70bea413ac1f44865016 (patch)
tree97a9c36f69226f682f7326b668ee99b07ca6c684 /frontends/php/include/classes
parent3442ec61fa38eea4e68a3edea4ea3225ff78c8a0 (diff)
downloadzabbix-0990cdce6c98be640a3c70bea413ac1f44865016.tar.gz
zabbix-0990cdce6c98be640a3c70bea413ac1f44865016.tar.xz
zabbix-0990cdce6c98be640a3c70bea413ac1f44865016.zip
- changed IT Services interface (Artem)
- added class CTree - added Javascript class for Cookies management git-svn-id: svn://svn.zabbix.com/trunk@4188 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/classes')
-rw-r--r--frontends/php/include/classes/cbutton.inc.php25
-rw-r--r--frontends/php/include/classes/ccheckbox.inc.php24
-rw-r--r--frontends/php/include/classes/cformtable.inc.php121
-rw-r--r--frontends/php/include/classes/cpumenu.inc.php136
-rw-r--r--frontends/php/include/classes/ctable.inc.php113
-rw-r--r--frontends/php/include/classes/ctree.inc.php251
6 files changed, 459 insertions, 211 deletions
diff --git a/frontends/php/include/classes/cbutton.inc.php b/frontends/php/include/classes/cbutton.inc.php
index cf737cf9..30d6def4 100644
--- a/frontends/php/include/classes/cbutton.inc.php
+++ b/frontends/php/include/classes/cbutton.inc.php
@@ -19,11 +19,9 @@
**/
?>
<?php
- class CButton extends CTag
- {
+ class CButton extends CTag{
/* public */
- function CButton($name="button", $caption="", $action=NULL, $accesskey=NULL)
- {
+ function CButton($name="button", $caption="", $action=NULL, $accesskey=NULL){
parent::CTag('input','no');
$this->tag_body_start = '';
$this->options['type'] = 'submit';
@@ -33,26 +31,29 @@
$this->SetAction($action);
$this->SetAccessKey($accesskey);
}
- function SetAction($value=null)
- {
+
+ function SetAction($value=null){
$this->AddAction('onClick', $value);
}
- function SetTitle($value='button title')
- {
+
+ function SetTitle($value='button title'){
$this->AddOption('title', $value);
}
- function SetAccessKey($value='B')
- {
+
+ function SetAccessKey($value='B'){
if(isset($value))
if(!isset($this->options['title']))
$this->SetTitle($this->options['value'].' [Alt+'.$value.']');
return $this->AddOption('accessKey', $value);
}
+
+ function SetType($type="button"){
+ $this->AddOption('type',$type);
+ }
}
- class CButtonCancel extends CButton
- {
+ class CButtonCancel extends CButton{
function CButtonCancel($vars=NULL,$action=NULL){
parent::CButton('cancel',S_CANCEL);
$this->options['type'] = 'button';
diff --git a/frontends/php/include/classes/ccheckbox.inc.php b/frontends/php/include/classes/ccheckbox.inc.php
index 84bf8eb3..d59e11a7 100644
--- a/frontends/php/include/classes/ccheckbox.inc.php
+++ b/frontends/php/include/classes/ccheckbox.inc.php
@@ -98,30 +98,24 @@
?>
<script language="JavaScript" type="text/javascript">
<!--
- function visibility_status_changeds(value, obj_name, replace_to)
- {
+ function visibility_status_changeds(value, obj_name, replace_to){
var obj = document.getElementsByName(obj_name);
if(obj.length <= 0) throw "Can't find objects with name [" + obj_name +"]";
- for(i = obj.length-1; i>=0; i--)
- {
- if(replace_to && replace_to != "")
- {
- if(obj[i].originalObject)
- {
+ for(i = obj.length-1; i>=0; i--){
+ if(replace_to && replace_to != ""){
+ if(obj[i].originalObject){
var old_obj = obj[i].originalObject;
old_obj.originalObject = obj[i];
obj[i].parentNode.replaceChild(old_obj, obj[i]);
}
- else if(!value)
- {
+ else if(!value){
var new_obj = null;
try {
new_obj = document.createElement("<a name='" + obj[i].name + "'>");
}
- catch(err)
- {
+ catch(err){
new_obj = document.createElement("a");
new_obj.name = obj[i].name;
}
@@ -133,13 +127,11 @@
new_obj.originalObject = obj[i];
obj[i].parentNode.replaceChild(new_obj, obj[i]);
}
- else
- {
+ else{
throw "Missed originalObject for restoring";
}
}
- else
- {
+ else{
value = value ? 'visible' : 'hidden';
obj[i].style.visibility = value;
}
diff --git a/frontends/php/include/classes/cformtable.inc.php b/frontends/php/include/classes/cformtable.inc.php
index 4f888c81..9a51d8d4 100644
--- a/frontends/php/include/classes/cformtable.inc.php
+++ b/frontends/php/include/classes/cformtable.inc.php
@@ -30,21 +30,19 @@
var $center_items = array();
var $bottom_items = array();*/
/* public */
- function CFormTable($title=null, $action=null, $method=null, $enctype=null, $form_variable=null)
- {
+ function CFormTable($title=null, $action=null, $method=null, $enctype=null, $form_variable=null){
global $_REQUEST;
$this->top_items = array();
$this->center_items = array();
$this->bottom_items = array();
+ $this->tableclass = 'formtable';
- if( null == $method )
- {
+ if( null == $method ){
$method = 'get';
}
- if( null == $form_variable )
- {
+ if( null == $form_variable ){
$form_variable = 'form';
}
@@ -63,8 +61,8 @@
$this->bottom_items = new CCol(SPACE,'form_row_last');
$this->bottom_items->SetColSpan(2);
}
- function SetAction($value)
- {
+
+ function SetAction($value){
if(is_string($value))
return parent::SetAction($value);
@@ -73,39 +71,36 @@
else
return $this->error("Incorrect value for SetAction [$value]");
}
- function SetName($value)
- {
- if(!is_string($value))
- {
+
+ function SetName($value){
+ if(!is_string($value)){
return $this->error("Incorrect value for SetAlign [$value]");
}
return $this->AddOption('name',$value);
}
- function SetAlign($value)
- {
- if(!is_string($value))
- {
+
+ function SetAlign($value){
+ if(!is_string($value)){
return $this->error("Incorrect value for SetAlign [$value]");
}
return $this->align = $value;
}
- function SetTitle($value=NULL)
- {
- if(is_null($value))
- {
+
+ function SetTitle($value=NULL){
+ if(is_null($value)){
unset($this->title);
return 0;
}
-/* elseif(!is_string($value))
- {
+/*
+ elseif(!is_string($value)){
return $this->error("Incorrect value for SetTitle [$value]");
}
$this->title = nbsp($value);
- */
+*/
$this->title = unpack_object($value);
}
- function SetHelp($value=NULL)
- {
+
+ function SetHelp($value=NULL){
if(is_null($value)) {
$this->help = new CHelp();
} elseif(strtolower(get_class($value)) == 'chelp') {
@@ -114,38 +109,48 @@
$this->help = new CHelp($value);
if($this->GetName()==NULL)
$this->SetName($value);
- } else
- {
+ } else {
return $this->error("Incorrect value for SetHelp [$value]");
}
return 0;
}
- function AddVar($name, $value)
- {
+
+ function AddVar($name, $value){
$this->AddItemToTopRow(new CVar($name, $value));
}
- function AddItemToTopRow($value)
- {
+
+ function AddItemToTopRow($value){
array_push($this->top_items, $value);
}
- function AddRow($item1, $item2=NULL, $class=NULL)
- {
- if(is_string($item1))
- $item1=nbsp($item1);
-
- if(empty($item1)) $item1 = SPACE;
- if(empty($item2)) $item2 = SPACE;
-
- $row = new CRow(array(
- new CCol($item1,'form_row_l'),
- new CCol($item2,'form_row_r')
- ),
- $class
- );
- array_push($this->center_items, $row);
+
+ function AddRow($item1, $item2=NULL, $class=NULL){
+ if(strtolower(get_class($item1)) == 'crow'){
+
+ } elseif(strtolower(get_class($item1)) == 'ctable'){
+ $td = new CCol($item1,'form_row_c');
+ $td->SetColSpan(2);
+
+ $item1 = new CRow($td);
+
+ } else{
+ if(is_string($item1)){
+ $item1=nbsp($item1);
+ }
+
+ if(empty($item1)) $item1 = SPACE;
+ if(empty($item2)) $item2 = SPACE;
+
+ $item1 = new CRow(array(
+ new CCol($item1,'form_row_l'),
+ new CCol($item2,'form_row_r')
+ ),
+ $class);
+ }
+
+ array_push($this->center_items, $item1);
}
- function AddSpanRow($value, $class=NULL)
- {
+
+ function AddSpanRow($value, $class=NULL){
if(is_string($value))
$item1=nbsp($value);
@@ -156,16 +161,23 @@
$col->SetColSpan(2);
array_push($this->center_items,new CRow($col));
}
- function AddItemToBottomRow($value)
- {
+
+
+ function AddItemToBottomRow($value){
$this->bottom_items->AddItem($value);
}
+
+ function SetTableClass($class){
+ if(is_string($class)){
+ $this->tableclass = $class;
+ }
+ }
+
/* protected */
- function BodyToString()
- {
+ function BodyToString(){
parent::BodyToString();
- $tbl = new CTable(NULL,'formtable');
+ $tbl = new CTable(NULL,$this->tableclass);
$tbl->SetOddRowClass('form_odd_row');
$tbl->SetEvenRowClass('form_even_row');
@@ -174,7 +186,8 @@
$tbl->SetAlign($this->align);
# add first row
$col = new CCol(NULL,'form_row_first');
- $col->SetColSpan(2);
+ $col->SetColSpan(2);
+
if(isset($this->help)) $col->AddItem($this->help);
if(isset($this->title)) $col->AddItem($this->title);
foreach($this->top_items as $item) $col->AddItem($item);
diff --git a/frontends/php/include/classes/cpumenu.inc.php b/frontends/php/include/classes/cpumenu.inc.php
index 95cb104e..ef583ea6 100644
--- a/frontends/php/include/classes/cpumenu.inc.php
+++ b/frontends/php/include/classes/cpumenu.inc.php
@@ -1,69 +1,67 @@
-<?php
-/*
-** ZABBIX
-** Copyright (C) 2000-2005 SIA Zabbix
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**/
-?>
-<?php
- class CPUMenu
- {
-/* private */
- /*
- var $items = array();
- var $width;
- */
-/* public */
- function CPUMenu($items=array(), $width=null)
- {
- $this->InsertJavaScript();
- /*********************** ITEM ARRAY ***********************
- ITEM: array(name, url, param, css, submenu1, submenu2, ... , submenuN)
-
- name: text
- url: text (url for href perameter)
- param: array(tw => t_val, sb => s_val)
- tw: target parameter
- t_val: one of '_blank', '_parent', '_self', '_top'
- sb: text for statusbar)
- s_val: text
- css: array(outer => cssarray, inner => cssarray)
- outer -> style for outer div element
- inner -> style for inner link element with text
- cssarray -> array(normal, mouseover, mousedown)
- submen1-N: list of subitems
- **********************************************************/
- $this->items = $items;
- $this->width = $width;
- }
-
- function GetOnActionJS()
- {
- if(count($this->items) <= 0) return NULL;
-
- return 'return show_popup_menu(event,'.zbx_jsvalue($this->items).','.zbx_jsvalue($this->width).');';
- }
-
- function InsertJavaScript()
- {
- if(defined('CPUMENU_INSERTJAVASCRIPT_INSERTED')) return;
- define('CPUMENU_INSERTJAVASCRIPT_INSERTED', 1);
-?>
-<script language="JavaScript" type="text/javascript" src="js/menu.js"></script>
-<?php
- }
- }
-?>
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ class CPUMenu
+ {
+/* private */
+ /*
+ var $items = array();
+ var $width;
+ */
+/* public */
+ function CPUMenu($items=array(), $width=null)
+ {
+ $this->InsertJavaScript();
+ /*********************** ITEM ARRAY ***********************
+ ITEM: array(name, url, param, css, submenu1, submenu2, ... , submenuN)
+
+ name: text
+ url: text (url for href perameter)
+ param: array(tw => t_val, sb => s_val)
+ tw: target parameter
+ t_val: one of '_blank', '_parent', '_self', '_top'
+ sb: text for statusbar)
+ s_val: text
+ css: array(outer => cssarray, inner => cssarray)
+ outer -> style for outer div element
+ inner -> style for inner link element with text
+ cssarray -> array(normal, mouseover, mousedown)
+ submen1-N: list of subitems
+ **********************************************************/
+ $this->items = $items;
+ $this->width = $width;
+ }
+
+ function GetOnActionJS()
+ {
+ if(count($this->items) <= 0) return NULL;
+
+ return 'return show_popup_menu(event,'.zbx_jsvalue($this->items).','.zbx_jsvalue($this->width).');';
+ }
+
+ function InsertJavaScript()
+ {
+ if(defined('CPUMENU_INSERTJAVASCRIPT_INSERTED')) return;
+ define('CPUMENU_INSERTJAVASCRIPT_INSERTED', 1);
+ echo '<script language="JavaScript" type="text/javascript" src="js/menu.js"></script>';
+ }
+ }
+?>
diff --git a/frontends/php/include/classes/ctable.inc.php b/frontends/php/include/classes/ctable.inc.php
index 5001ec30..c54420e7 100644
--- a/frontends/php/include/classes/ctable.inc.php
+++ b/frontends/php/include/classes/ctable.inc.php
@@ -19,51 +19,49 @@
**/
?>
<?php
- class CCol extends CTag
- {
+ class CCol extends CTag{
/* public */
- function CCol($item=NULL,$class=NULL)
- {
+ function CCol($item=NULL,$class=NULL){
parent::CTag("td","yes");
$this->AddItem($item);
$this->SetClass($class);
}
- function SetAlign($value)
- {
+
+ function SetAlign($value){
return $this->options['align'] = $value;
}
- function SetRowSpan($value)
- {
+
+ function SetRowSpan($value){
return $this->options['rowspan'] = strval($value);
}
- function SetColSpan($value)
- {
+
+ function SetColSpan($value){
return $this->options['colspan'] =strval($value);
}
+
+ function SetWidth($value){
+ if(is_string($value))$this->AddOption('width',$value);
+ }
}
- class CRow extends CTag
- {
+ class CRow extends CTag{
/* public */
- function CRow($item=NULL,$class=NULL)
- {
+ function CRow($item=NULL,$class=NULL){
parent::CTag("tr","yes");
$this->AddItem($item);
$this->SetClass($class);
}
- function SetAlign($value)
- {
+
+ function SetAlign($value){
return $this->options['align'] = $value;
}
- function AddItem($item)
- {
+
+ function AddItem($item){
if(strtolower(get_class($item))=='ccol') {
parent::AddItem($item);
}
- elseif(is_array($item))
- {
- foreach($item as $el)
- {
+ elseif(is_array($item)){
+ foreach($item as $el){
if(strtolower(get_class($el))=='ccol') {
parent::AddItem($el);
} elseif(!is_null($el)) {
@@ -71,15 +69,17 @@
}
}
}
- elseif(!is_null($item))
- {
+ elseif(!is_null($item)){
parent::AddItem('<td>'.unpack_object($item).'</td>');
}
}
+
+ function SetWidth($value){
+ if(is_string($value))$this->AddOption('width',$value);
+ }
}
- class CTable extends CTag
- {
+ class CTable extends CTag{
/* protected *//*
var $oddRowClass;
var $evenRowClass;
@@ -91,8 +91,7 @@
var $footerClass;
var $message;*/
/* public */
- function CTable($message=NULL,$class=NULL)
- {
+ function CTable($message=NULL,$class=NULL){
parent::CTag("table","yes");
$this->SetClass($class);
@@ -109,29 +108,28 @@
$this->message = $message;
}
- function SetOddRowClass($value=NULL)
- {
+
+ function SetOddRowClass($value=NULL){
$this->oddRowClass = $value;
}
- function SetEvenRowClass($value=NULL)
- {
+
+ function SetEvenRowClass($value=NULL){
$this->evenRowClass = $value;
}
- function SetAlign($value)
- {
+
+ function SetAlign($value){
return $this->options['align'] = $value;
}
- function SetCellPadding($value)
- {
+
+ function SetCellPadding($value){
return $this->options['cellpadding'] = strval($value);
}
- function SetCellSpacing($value)
- {
+
+ function SetCellSpacing($value){
return $this->options['cellspacing'] = strval($value);
}
- function PrepareRow($item,$rowClass=NULL)
- {
+ function PrepareRow($item,$rowClass=NULL){
if(is_null($item)) return NULL;
if(strtolower(get_class($item))=='ccol') {
@@ -144,20 +142,18 @@
if(isset($rowClass))
$item->SetClass($rowClass);
}
- else
- {
+ else{
$item = new CRow($item,$rowClass);
}
- if(!isset($item->options['class']))
- {
+ if(!isset($item->options['class'])){
$item->SetClass(($this->rownum % 2) ?
$this->oddRowClass:
$this->evenRowClass);
}/**/
return $item->ToString();
}
- function SetHeader($value=NULL,$class=NULL)
- {
+
+ function SetHeader($value=NULL,$class=NULL){
if(is_null($class)) $class = $this->headerClass;
if(strtolower(get_class($value))=='crow') {
@@ -168,40 +164,37 @@
$this->colnum = $value->ItemsCount();
$this->header = $value->ToString();
}
- function SetFooter($value=NULL,$class=NULL)
- {
+
+ function SetFooter($value=NULL,$class=NULL){
if(is_null($class)) $class = $this->footerClass;
$this->footer = $this->PrepareRow($value,$class);;
}
- function AddRow($item,$rowClass=NULL)
- {
+
+ function AddRow($item,$rowClass=NULL){
$item = $this->AddItem($this->PrepareRow($item,$rowClass));
++$this->rownum;
return $item;
}
- function ShowRow($item,$rowClass=NULL)
- {
+
+ function ShowRow($item,$rowClass=NULL){
echo $this->PrepareRow($item,$rowClass);
++$this->rownum;
}
/* protected */
- function GetNumRows()
- {
+ function GetNumRows(){
return $this->rownum;
}
- function StartToString()
- {
+ function StartToString(){
$ret = parent::StartToString();
$ret .= $this->header;
return $ret;
}
- function EndToString()
- {
+
+ function EndToString(){
$ret = "";
- if($this->rownum == 0 && isset($this->message))
- {
+ if($this->rownum == 0 && isset($this->message)) {
$ret = $this->PrepareRow(new CCol($this->message,'message'));
}
$ret .= $this->footer;
diff --git a/frontends/php/include/classes/ctree.inc.php b/frontends/php/include/classes/ctree.inc.php
new file mode 100644
index 00000000..9b2412be
--- /dev/null
+++ b/frontends/php/include/classes/ctree.inc.php
@@ -0,0 +1,251 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+
+class CTree{
+
+/*public*/
+var $tree='';
+var $fields='';
+var $treename='';
+
+/*private*/
+var $size=0;
+var $maxlevel=0;
+
+
+/*public*/
+function CTree($value=array(),$fields=array()){
+// parent::CTable();
+ $this->tree = $value;
+ $this->fields = $fields;
+ $this->treename = $this->fields['caption'];
+
+ $this->size = count($value);
+ unset($value);
+ unset($fields);
+
+ if(!$this->CheckTree()){
+ $this->Destroy();
+ return false;
+ } else {
+ $this->CountDepth();
+ }
+}
+
+function GetTree(){
+ return $this->tree;
+}
+
+/*private*/
+function MakeHeaders(){
+ $c=0;
+ $tr = new CRow();
+ $tr->AddItem($this->fields['caption']);
+ $tr->SetClass('treeheader');
+ unset($this->fields['caption']);
+ foreach($this->fields as $id => $caption){
+ $tr->AddItem($caption);
+ $fields[$c] = $id;
+ $c++;
+ }
+ $this->fields = $fields;
+return $tr;
+}
+
+function SimpleHTML(){
+ $table = new CTableInfo('','tabletree');
+
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(0);
+
+ $table->oddRowClass = 'odd_row';
+ $table->evenRowClass = 'even_row';
+ $table->headerClass = 'header';
+ $table->footerClass = 'footer';
+
+ $table->AddOption('border','0');
+ $table->AddRow($this->MakeHeaders());
+// $table->AddRow();
+ foreach($this->tree as $id => $rows){
+ $table->AddRow($this->MakeSHTMLRow($id));
+ }
+return $table->ToString();
+}
+
+
+function MakeSHTMLRow($id){
+ $table = new CTable();
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(0);
+ $table->AddOption('width','200');
+
+ $tr = $this->MakeSImgStr($id);
+
+ $td = new CCol($this->tree[$id]['caption']);
+ $td->SetAlign('left');
+
+
+ $tr->AddItem($td);
+ $table->AddRow($tr);
+
+ $tr = new CRow();
+ $tr->AddItem($table);
+ $tr->AddOption('id',$id);
+// $tr->AddOption('ntype',$this->tree[$id]['childs']);
+ $tr->AddOption('style',($this->tree[$id]['parentid'] != '0')?('display: none;'):(''));
+
+ foreach($this->fields as $key => $value){
+// $tr->AddItem('&nbsp;&nbsp;');
+ $td = new CCol($this->tree[$id][$value]);
+// $td->SetAlign('left');
+ $tr->AddItem($td);
+ }
+return $tr;
+}
+
+function MakeSImgStr($id){
+ $tr = new CRow();
+ $tr->AddOption('height',18);
+ $count=(isset($this->tree[$id]['nodeimg']))?(strlen($this->tree[$id]['nodeimg'])):(0);
+ for($i=0; $i<$count; $i++){
+ switch($this->tree[$id]['nodeimg'][$i]){
+ case 'O':
+ $img= new CImg('images/general/tree/O.gif','o','22','18');
+ break;
+ case 'I':
+ $img= new CImg('images/general/tree/I.gif','i','22','18');
+ break;
+ case 'L':
+ if($this->tree[$id]['nodetype'] == 2){
+ $img= new CImg('images/general/tree/Yc.gif','y','22','18');
+ $img->AddOption('OnClick','javascript: tree.closeSNodeX('.$id.',this);');
+ $img->AddOption('id',$id.'I');
+ $img->SetClass('imgnode');
+
+ } else {
+ $img= new CImg('images/general/tree/L.gif','l','22','18');
+ }
+ break;
+ case 'T':
+ if($this->tree[$id]['nodetype'] == 2){
+ $img= new CImg('images/general/tree/Xc.gif','x','22','18');
+ $img->AddOption('OnClick','javascript: tree.closeSNodeX('.$id.',this);');
+ $img->AddOption('id',$id.'I');
+ $img->SetClass('imgnode');
+ } else {
+ $img= new CImg('images/general/tree/T.gif','t','22','18');
+ }
+ break;
+ }
+ $td = new CCol($img,'tdtree');
+ $tr->AddItem($td);
+ }
+// echo $txt.' '.$this->tree[$id]['Name'].'<br />';
+return $tr;
+}
+
+function CountDepth(){
+ foreach($this->tree as $id => $rows){
+
+ if($id == '0'){
+ continue;
+ }
+ $parentid = $this->tree[$id]['parentid'];
+
+ $this->tree[$id]['nodeimg'] = $this->GetImg($id,(isset($this->tree[$parentid]['nodeimg']))?($this->tree[$parentid]['nodeimg']):(''));
+ //$this->tree[$parentid]['childs'] = ($this->tree[$parentid]['childs']+$this->tree[$id]['childs']+1);
+
+ $this->tree[$parentid]['nodetype'] = 2;
+
+ $this->tree[$id]['Level'] = (isset($this->tree[$parentid]['Level']))?($this->tree[$parentid]['Level']+1):(1);
+
+ ($this->maxlevel>$this->tree[$id]['Level'])?(''):($this->maxlevel = $this->tree[$id]['Level']);
+ }
+
+}
+
+
+function CreateJS(){
+global $page;
+ $js = '
+ <script src="js/tree.js" type="text/javascript"></script>
+ <script src="js/cookies.js" type="text/javascript"></script>
+ <script type="text/javascript">
+ var treenode = new Array(0);
+ var tree_name = "tree_'.$this->getUserAlias().'_'.$page["file"].'";
+ ';
+
+ foreach($this->tree as $id => $rows){
+ $parentid = $rows['parentid'];
+ $this->tree[$parentid]['nodelist'].=$id.'.';
+ }
+
+ foreach($this->tree as $id => $rows){
+ if($rows['nodetype'] == '2'){
+ $js .= 'treenode['.$id.'] = { status: \'close\', nodelist : \''.$rows['nodelist'].'\', parentid : \''.$rows['parentid'].'\'};';
+ }
+ }
+return $js.'window.onload = function(){tree.init()};
+</script>';
+}
+
+function GetImg($id,$img){
+ $img=str_replace('T','I',$img);
+ $img=str_replace('L','O',$img);
+ $ch = 'L';
+
+ $childs = $this->tree[$this->tree[$id]['parentid']]['childnodes'];
+ $childs_last = count($this->tree[$this->tree[$id]['parentid']]['childnodes'])-1;
+
+ if(isset($childs[$childs_last]) && ($childs[$childs_last] != $id)){
+ $ch='T';
+ }
+ $img.=$ch;
+return $img;
+}
+
+function CheckTree(){
+ if(!is_array($this->tree)){
+ return false;
+ }
+ foreach($this->tree as $id => $cell){
+ $this->tree[$id]['nodetype'] = 0;
+
+ $parentid=$cell['parentid'];
+ $this->tree[$parentid]['childnodes'][] = $id;
+
+ $this->tree[$id]['nodelist'] = '';
+// echo $id.BR;
+ }
+
+return true;
+}
+
+function Destroy(){
+ unset($this->tree);
+}
+
+function getUserAlias(){
+global $USER_DETAILS;
+return $USER_DETAILS["alias"];
+}
+}
+
+?> \ No newline at end of file