diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-05-12 14:23:12 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-05-12 14:23:12 +0000 |
| commit | 4182bc6afb20b00fa27a54c67056bb98a58a49bb (patch) | |
| tree | 5cab17d23e387cc3b6e8c92e4c928ac5e1111b76 /frontends/php/include/classes | |
| parent | 6a6ac0772b8215bffc5fe8b02fc1033dbf273f41 (diff) | |
| download | zabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.tar.gz zabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.tar.xz zabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.zip | |
- speed improvement for Overview screens (Eugene)
- developed 'net.if.total[*]' parameter (Eugene)
- fixed new map link adding (Eugene)
- fixed host group adding (Eugene)
- fixed map displaying (Eugene)
- fixed 'No permissions' for 'Latest data','Triggers','Alarms' screens (Eugene)
- fixed permision deletion (Eugene)
- fixed 'get_map_by_sysmapid' function calls(Eugene)
- improved php code execution speed (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2825 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/classes')
18 files changed, 353 insertions, 789 deletions
diff --git a/frontends/php/include/classes/cbutton.inc.php b/frontends/php/include/classes/cbutton.inc.php index 139d3499..0c33caaf 100644 --- a/frontends/php/include/classes/cbutton.inc.php +++ b/frontends/php/include/classes/cbutton.inc.php @@ -24,70 +24,37 @@ /* public */ function CButton($name="button", $caption="", $action=NULL, $accesskey=NULL) { - parent::CTag("input","no"); - $this->tag_body_start = ""; - $this->AddOption("type","submit"); -// $this->AddOption("type","button"); - $this->SetClass("button"); + parent::CTag('input','no'); + $this->tag_body_start = ''; + $this->options['type'] = 'submit'; + $this->options['value'] = $caption; +// $this->options["type"] = "button"; + $this->options['class'] = 'button'; $this->SetName($name); - $this->SetCaption($caption); $this->SetAction($action); $this->SetAccessKey($accesskey); } function SetAction($value='submit()', $event='onClick') { - if(is_null($value)) - return 1; - if(!is_string($value)) - return $this->error("Incorrect value for SetAction [$value]"); - if(!is_string($event)) - return $this->error("Incorrect event for SetAction [$event]"); - return $this->AddOption($event,$value); + $this->options[$event] = $value; } function SetTitle($value='button title') { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetTitle [$value]"); - } - return $this->AddOption("title",$value); + $this->options['title'] = $value; } function SetAccessKey($value='B') { - if(is_null($value)) - return 0; - elseif(!is_string($value)) - { - return $this->error("Incorrect value for SetAccessKey [$value]"); - } - - if($this->GetOption('title')==NULL) - $this->SetTitle($this->GetOption('value')." [Alt+$value]"); + if(!isset($this->options['title'])) + $this->SetTitle($this->options['value'].' [Alt+$value]'); - return $this->AddOption("accessKey",$value); - } - function SetName($value='button') - { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetName [$value]"); - } - return $this->AddOption("name",$value); - } - function SetCaption($value="") - { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetCaption [$value]"); - } - return $this->AddOption("value",$value); + return $this->options['accessKey'] = $value; } } class CButtonCancel extends CButton { function CButtonCancel($vars=NULL){ - parent::CButton("cancel",S_CANCEL); + parent::CButton('cancel',S_CANCEL); $this->SetVars($vars); } function SetVars($value=NULL){ diff --git a/frontends/php/include/classes/ccheckbox.inc.php b/frontends/php/include/classes/ccheckbox.inc.php index 69a856e2..83ac51a6 100644 --- a/frontends/php/include/classes/ccheckbox.inc.php +++ b/frontends/php/include/classes/ccheckbox.inc.php @@ -22,66 +22,27 @@ class CCheckBox extends CTag { /* public */ - function CCheckBox($name='checkbox',$checked='no',$caption=NULL,$action=NULL,$value='yes') + function CCheckBox($name='checkbox',$checked='no',$action=NULL,$value='yes') { - parent::CTag("input","no"); - $this->tag_body_start = ""; - $this->AddOption('type','checkbox'); - $this->AddOption('value','yes'); - $this->SetName($name); - $this->SetCaption($caption); + parent::CTag('input','no'); + $this->tag_body_start = ''; + $this->options['type'] = 'checkbox'; + $this->options['value'] = $value; + $this->options['name'] = $name; + $this->options['onClick'] = $action; $this->SetChecked($checked); - $this->SetAction($action); - $this->SetValue($value); - } - function SetName($value='checkbox') - { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetName [$value]"); - } - return $this->AddOption("name",$value); - } - function SetCaption($value=NULL) - { - if(is_null($value)) - return 0; - elseif(is_string($value)) - return $this->AddItem(nbsp($value)); - return $this->error("Incorrect value for SetCaption [$value]"); - } - function SetValue($value=NULL) - { - if(is_null($value)) - return $this->DelOption("value"); - elseif(is_string($value) || is_numeric($value)) - return $this->AddOption('value',$value); - return $this->error("Incorrect value for SetValue [$value]"); } function SetChecked($value="yes") { - if(is_null($value)){ - return 0; - }elseif((is_string($value)&& - ($value=="yes" || $value=="checked" || $value=="on") || $value=="1") - || (is_int($value)&&$value<>0)){ - return $this->AddOption("checked","checked"); - }elseif((is_string($value)&& - ($value=="no" || $value=="unchecked" || $value=="off" || $value=="0")) - || (is_int($value)&&$value==0)){ - return $this->DelOption("checked"); - } - return $this->error("Incorrect value for SetChacked [$value]"); + if((is_string($value)&& ($value=="yes" || $value=="checked" || $value=="on") || $value=="1") + || (is_int($value)&&$value<>0)) + return $this->options['checked'] = 'checked'; + + $this->DelOption("checked"); } function SetAction($value='submit()', $event='onClick') { - if(is_null($value)) - return 1; - if(!is_string($value)) - return $this->error("Incorrect value for SetAction [$value]"); - if(!is_string($event)) - return $this->error("Incorrect event for SetAction [$event]"); - return $this->AddOption($event,$value); + $this->options[$event] = $value; } } ?> diff --git a/frontends/php/include/classes/ccombobox.inc.php b/frontends/php/include/classes/ccombobox.inc.php index ea579803..ee390332 100644 --- a/frontends/php/include/classes/ccombobox.inc.php +++ b/frontends/php/include/classes/ccombobox.inc.php @@ -26,90 +26,55 @@ { parent::CTag('option','yes'); $this->tag_body_start = ""; - $this->SetCaption($caption); - $this->SetValue($value); + $this->options['value'] = $value; + + $this->AddItem($caption); + $this->SetSelected($selected); $this->SetEnabled($enabled); } function SetValue($value) { - return parent::AddOption('value',$value); + return $this->options['value'] = $value; } function GetValue() { - return parent::GetOption('value'); + return $this->GetOption('value'); } function SetCaption($value=NULL) { - if(is_null($value)) - return 0; - elseif(is_string($value)){ - parent::AddItem(nbsp($value)); - return 0; - } - return $this->error("Incorrect value for SetCaption [$value]"); + $this->AddItem(nbsp($value)); } function SetSelected($value='yes') { - if(is_null($value)) - return $this->DelOption('selected'); - elseif((is_string($value) && ($value == 'yes' || $value == "selected" || $value=='on')) + if((is_string($value) && ($value == 'yes' || $value == "selected" || $value=='on')) || (is_int($value) && $value<>0)) - return $this->AddOption('selected','selected'); - elseif((is_string($value) && ($value == 'no' || $value=='off')) - || (is_int($value) && $value==0)) - return $this->DelOption('selected'); - return $this->error("Incorrect value for SetSelected [$value]"); + return $this->options['selected'] = 'selected'; + + $this->DelOption('selected'); } } class CComboBox extends CTag { /* private */ - var $caption; var $value; /* public */ function CComboBox($name='combobox',$value=NULL,$action=NULL) { - parent::CTag("select","yes"); - $this->tag_end = ""; - $this->SetClass("biginput"); - $this->SetName($name); - $this->SetValue($value); - $this->AddOption("size",1); + parent::CTag('select','yes'); + $this->tag_end = ''; + $this->options['class'] = 'biginput'; + $this->options['name'] = $name; + $this->value = $value; + $this->options['size'] = 1; $this->SetAction($action); } function SetAction($value='submit()', $event='onChange') { - if(is_null($value)) - return 1; - if(!is_string($value)) - return $this->error("Incorrect value for SetAction [$value]"); - if(!is_string($event)) - return $this->error("Incorrect event for SetAction [$event]"); - return $this->AddOption($event,$value); - } - function SetName($value='combobox') - { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetName [$value]"); - } - return $this->AddOption("name",$value); - } - function SetCaption($value=NULL) - { - if(is_null($value)) - unset($this->caption); - elseif(is_string($value)) - $this->caption = $value; - else - { - return $this->error("Incorrect value for SetCaption [$value]"); - } - return 0; + $this->AddOption($event,$value); } function SetValue($value=NULL) { @@ -119,30 +84,31 @@ { // if($enabled=='no') return; /* disable item method 1 */ - $cmbItem = new CComboItem($value,$caption,$selected,$enabled); - return parent::AddItem($cmbItem); - } - - function SetSelectedByValue(&$item) - { - if(!is_null($this->value)) + if(is_null($selected)) { $selected = 'no'; - if($item->GetValue() == $this->value) $selected = 'yes'; - $item->SetSelected($selected); + if($value == $this->value || (is_array($this->value) && in_array($value, $this->value))) + $selected = 'yes'; } + + parent::AddItem(new CComboItem($value,$caption,$selected,$enabled)); } + } - function ShowTagItem(&$item) + class CListBox extends CComboBox + { +/* public */ + function CListBox($name='combobox',$value=NULL,$size=5,$action=NULL) { - $this->SetSelectedByValue($item); - parent::ShowTagItem($item); + parent::CComboBox($name,NULL,$action); + $this->options['multiple'] = 'multiple'; + $this->options['size'] = $size; + $this->SetValue($value); } - function Show() + function SetSize($value) { - if(isset($this->caption)) - echo $this->caption." "; - parent::Show(); + $this->options['size'] = $value; } } + ?> diff --git a/frontends/php/include/classes/cflash.inc.php b/frontends/php/include/classes/cflash.inc.php index fa8886a7..0254443a 100644 --- a/frontends/php/include/classes/cflash.inc.php +++ b/frontends/php/include/classes/cflash.inc.php @@ -19,84 +19,62 @@ **/ ?> <?php - class CFlashEmbed extends CTag + /* private */ class CFlashEmbed extends CTag { function CFlashEmbed($src=NULL, $width = NULL, $height = NULL) { - parent::CTag("embed"); - $this->AddOption("allowScriptAccess","sameDomain"); - $this->AddOption("type","application/x-shockwave-flash"); - $this->AddOption("pluginspage","http://www.macromedia.com/go/getflashplayer"); - $this->AddOption("align","middle"); - $this->AddOption("quality","high"); + parent::CTag('embed'); + $this->options['allowScriptAccess'] = 'sameDomain'; + $this->options['type'] = 'application/x-shockwave-flash'; + $this->options['pluginspage'] = 'http://www.macromedia.com/go/getflashplayer'; + $this->options['align'] = 'middle'; + $this->options['quality'] = 'high'; - $this->SetWidth($width); - $this->SetHeight($height); - $this->SetSrc($src); + $this->options['width'] = $width; + $this->options['height'] = $height; + $this->options['src'] = $src; } function SetWidth($value) { - if(is_null($value)) - return $this->DelOption("width"); - if(!is_numeric($value)) - return $this->error("Incorrect value for SetWidth [$value]"); - - $this->AddOption("width",$value); + $this->options['width'] = $value; } function SetHeight($value) { - if(is_null($value)) - return $this->DelOption("height"); - if(!is_numeric($value)) - return $this->error("Incorrect value for SetHeight [$value]"); - - $this->AddOption("height",$value); + $this->options['height'] = $value; } function SetSrc($value) { - if(is_null($value)) - return $this->DelOption("src"); - if(!is_string($value)) - return $this->error("Incorrect value for SetSrc[$value]"); - - $this->AddOption("src",$value); + $this->options['src'] = $value; } } - class CParam extends CTag + /* private */ class CParam extends CTag { function CParam($name,$value) { parent::CTag("param","no"); - - $this->SetName($name); - $this->SetValue($value); - } - function SetName($value) - { - $this->AddOption("name",$value); - } - function SetValue($value) - { - $this->AddOption("value",$value); + $this->options['name'] = $name; + $this->options['value'] = $value; } } - class CFlash extends CTag + /* public */ class CFlash extends CTag { - var $timetype; + var $SrcParam; + var $EmbededFlash; + function CFlash($src=NULL, $width = NULL, $height = NULL) { parent::CTag("object",'yes'); - $this->AddOption("classid","clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"); - $this->AddOption("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"); - $this->AddOption("align","middle"); + $this->options['classid'] = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'; + $this->options['codebase'] = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'; + $this->options['align'] = 'middle'; $this->AddItem(new CParam("allowScriptAccess","sameDomain")); $this->AddItem(new CParam("quality","high")); - $this->items["src"] = new CParam("movie",$src); - $this->items["embeded"] = new CFlashEmbed(); + $this->SrcParam = new CParam("movie",$src); + $this->EmbededFlash = new CFlashEmbed(); $this->SetWidth($width); $this->SetHeight($height); @@ -104,33 +82,25 @@ } function SetWidth($value) { - if(is_null($value)) - return $this->DelOption("width"); - if(!is_numeric($value)) - return $this->error("Incorrect value for SetWidth [$value]"); - - $this->AddOption("width",$value); - $this->items["embeded"]->SetWidth($value); + $this->options['width'] = $value; + $this->EmbededFlash->options['width'] = $value; } function SetHeight($value) { - if(is_null($value)) - return $this->DelOption("height"); - if(!is_numeric($value)) - return $this->error("Incorrect value for SetHeight [$value]"); - - $this->AddOption("height",$value); - $this->items["embeded"]->SetHeight($value); + $this->options['height'] = $value; + $this->EmbededFlash->options['height'] = $value; } function SetSrc($value) { - if(is_null($value)) - return $this->DelOption("src"); - if(!is_string($value)) - return $this->error("Incorrect value for SetSrc[$value]"); - - $this->items["src"]->SetValue($value); - $this->items["embeded"]->SetSrc($value); + $this->SrcParam->options['value'] = $value; + $this->EmbededFlash->options['src'] = $value; + } + function BodyToString() + { + $ret = parent::BodyToString(); + $ret .= $this->SrcParam->ToString(); + $ret .= $this->EmbededFlash->ToString(); + return $ret; } } ?> diff --git a/frontends/php/include/classes/cflashclock.mod.php b/frontends/php/include/classes/cflashclock.mod.php index b5e4cdab..dbfef8d3 100644 --- a/frontends/php/include/classes/cflashclock.mod.php +++ b/frontends/php/include/classes/cflashclock.mod.php @@ -41,11 +41,12 @@ $this->timetype = $value; } - function Show() + function BodyToString() { if($this->timetype == TIME_TYPE_SERVER) $this->SetSrc($this->src."×tamp=".time()); - parent::Show(); + + return parent::BodyToString(); } } ?> diff --git a/frontends/php/include/classes/cform.inc.php b/frontends/php/include/classes/cform.inc.php index 2d2e8103..e83679dd 100644 --- a/frontends/php/include/classes/cform.inc.php +++ b/frontends/php/include/classes/cform.inc.php @@ -31,11 +31,7 @@ } function SetMethod($value='post') { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetMethod [$value]"); - } - return $this->AddOption("method",$value); + return $this->options['method'] = $value; } function SetAction($value=NULL) { @@ -43,17 +39,13 @@ if(is_null($value)) { - if(isset($page["file"])) + if(isset($page['file'])) { - return $this->AddOption("action",$page["file"]); + return $this->options['action'] = $page['file']; } return 1; } - elseif(!is_string($value)) - { - return $this->error("Incorrect value for SetAction [$value]"); - } - return $this->AddOption("action",$value); + return $this->options['action'] = $value; } function SetEnctype($value=NULL) { diff --git a/frontends/php/include/classes/cformtable.inc.php b/frontends/php/include/classes/cformtable.inc.php index 170dc881..fb5640ed 100644 --- a/frontends/php/include/classes/cformtable.inc.php +++ b/frontends/php/include/classes/cformtable.inc.php @@ -40,7 +40,7 @@ $this->SetHelp(); $frm_link = new CLink(); - $frm_link->SetName("formtable"); +// $frm_link->SetName("formtable"); $this->AddItemToTopRow($frm_link); $this->AddVar("form",get_request("form",1)); @@ -59,6 +59,14 @@ else return $this->error("Incorrect value for SetAction [$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)) @@ -128,19 +136,17 @@ $this->bottom_items->AddItem($value); } /* protected */ - function ShowTagBody() + function BodyToString() { - parent::ShowTagBody(); + parent::BodyToString(); $tbl = new CTable(NULL,'formtable'); + $tbl->SetOddRowClass('form_odd_row'); $tbl->SetEvenRowClass('form_even_row'); $tbl->SetCellSpacing(0); $tbl->SetCellPadding(1); $tbl->SetAlign($this->align); -# add center rows - foreach($this->center_items as $item) - $tbl->AddRow($item); # add first row $col = new CCol(NULL,'form_row_first'); $col->SetColSpan(2); @@ -150,7 +156,11 @@ $tbl->SetHeader($col); # add last row $tbl->SetFooter($this->bottom_items); - $tbl->Show(); +# add center rows + foreach($this->center_items as $item) + $tbl->AddRow($item); + + return $tbl->ToString(); } } ?> diff --git a/frontends/php/include/classes/chelp.inc.php b/frontends/php/include/classes/chelp.inc.php index 79055781..310c3286 100644 --- a/frontends/php/include/classes/chelp.inc.php +++ b/frontends/php/include/classes/chelp.inc.php @@ -24,8 +24,9 @@ /* public */ function CHelp($url="index.php") { - parent::CLink(new CImg("images/general/help.gif",'?'), "http://www.zabbix.com/manual/v1.1/$url"); - $this->AddOption("style","float:right"); + parent::CLink(new CImg('images/general/help.gif','?'), 'http://www.zabbix.com/manual/v1.1/'.$url); + $this->options['style'] = 'float:right'; + $this->options['target'] = '_blank'; } } ?> diff --git a/frontends/php/include/classes/clink.inc.php b/frontends/php/include/classes/clink.inc.php index cc160b45..8435092f 100644 --- a/frontends/php/include/classes/clink.inc.php +++ b/frontends/php/include/classes/clink.inc.php @@ -38,40 +38,24 @@ function SetAction($value=NULL) { if(is_null($value)) - { - return $this->AddOption("action",$page["file"]); - } - elseif(!is_string($value)) - { - return $this->error("Incorrect value for SetAction [$value]"); - } - return $this->AddOption("onClick",$value); + return $this->options['action'] = $page['file']; + + return $this->options['onClick'] = $value; } function SetUrl($value) { - if(is_null($value)) - { - return $this->DelOption("href"); - } - elseif(!is_string($value)) - { - return $this->error("Incorrect value for SetUrl [$value]"); - } - - $this->AddOption("href",$value); + $this->options['href'] = $value; } function SetTarget($value=NULL) { if(is_null($value)) { - return $this->DelOption("target"); + unset($this->options['target']); } - elseif(!is_string($value)) + else { - return $this->error("Incorrect value for SetTarget [$value]"); + $this->options['target'] = $value; } - - $this->AddOption("target",$value); } } ?> diff --git a/frontends/php/include/classes/clistbox.inc.php b/frontends/php/include/classes/clistbox.inc.php index bec590f7..311535b7 100644 --- a/frontends/php/include/classes/clistbox.inc.php +++ b/frontends/php/include/classes/clistbox.inc.php @@ -19,40 +19,7 @@ **/ ?> <?php - class CListBox extends CComboBox - { -/* public */ - function CListBox($name='combobox',$value=NULL,$size=5,$action=NULL) - { - parent::CComboBox($name,NULL,$action); - $this->AddOption("multiple","multiple"); - $this->SetSize($size); - $this->SetValue($value); - } - function SetSize($value) - { - if(is_null($value)) - return $this->DelOption("size"); - if(!is_numeric($value)) - return $this->error("Incorrect value for SetSize [$value]"); - $this->AddOption("size",$value); - } - function SetSelectedByValue(&$item) - { - if(!is_null($this->value)) - { - if(is_array($this->value)) - { - $selected = 'no'; - if(in_array($item->GetValue(),$this->value)) $selected = 'yes'; - return $item->SetSelected($selected); - } - else - { - return parent::SetSelectedByValue($item); - } - } - return false; - } - } +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +// TODO REMOVE THIS FILE FROM CVS !!! +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ?> diff --git a/frontends/php/include/classes/cpassbox.inc.php b/frontends/php/include/classes/cpassbox.inc.php index 2f51a9ee..12a198cb 100644 --- a/frontends/php/include/classes/cpassbox.inc.php +++ b/frontends/php/include/classes/cpassbox.inc.php @@ -19,13 +19,9 @@ **/ ?> <?php - class CPassBox extends CTextBox - { -/* public */ - function CPassBox($name="password",$value="",$size=20,$caption=NULL) - { - parent::CTextBox($name,$value,$size,$caption); - $this->AddOption("type","password"); - } - } + +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +// TODO REMOVE THIS FILE FROM CVS +// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + ?> diff --git a/frontends/php/include/classes/ctable.inc.php b/frontends/php/include/classes/ctable.inc.php index 69b10f71..d13c991d 100644 --- a/frontends/php/include/classes/ctable.inc.php +++ b/frontends/php/include/classes/ctable.inc.php @@ -30,27 +30,15 @@ } function SetAlign($value) { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetAlign [$value]"); - } - return $this->AddOption("align",$value); + return $this->options['align'] = $value; } function SetRowSpan($value) { - if(!is_int($value) && !is_numeric($value)) - { - return $this->error("Incorrect value for SetRowSpan [$value]"); - } - return $this->AddOption("rowspan",strval($value)); + return $this->options['rowspan'] = strval($value); } function SetColSpan($value) { - if(!is_int($value) && !is_numeric($value)) - { - return $this->error("Incorrect value for SetColSpan[$value]"); - } - return $this->AddOption("colspan",strval($value)); + return $this->options['colspan'] =strval($value); } } @@ -65,35 +53,30 @@ } function SetAlign($value) { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetAlign [$value]"); - } - return $this->AddOption("align",$value); + return $this->options['align'] = $value; } function AddItem($item=NULL) { - if(is_null($item)) - return 0; - elseif(is_a($item,'ccol')) + if(is_a($item,'ccol')) { - return parent::AddItem($item); + parent::AddItem($item); } elseif(is_array($item)) { - $ret = 0; foreach($item as $el) { if(is_a($el,'ccol')) { - $ret |= parent::AddItem($el); + parent::AddItem($el); } elseif(!is_null($el)) { - $ret |= parent::AddItem(new CCol($el)); + parent::AddItem('<td>'.unpack_object($el).'</td>'); } } - return $ret; } - return parent::AddItem(new CCol($item)); + elseif(!is_null($item)) + { + parent::AddItem('<td>'.unpack_object($item).'</td>'); + } } } @@ -103,7 +86,11 @@ var $oddRowClass; var $evenRowClass; var $header; + var $headerClass; + var $colnum; var $footer; + var $footerClass; + var $curr_row_class; /* public */ function CTable($message=NULL,$class=NULL) { @@ -113,153 +100,109 @@ $this->oddRowClass = NULL; $this->evenRowClass = NULL; - $this->header = NULL; - $this->footer = NULL;; - } - function SetHeader($value=NULL,$class=NULL) - { - if(is_null($value)){ - $this->header = NULL; - }elseif(is_a($value,'crow')) - { - if(isset($class)) - $value->SetClass($class); - $this->header = $value; - }else{ - $this->header = new CRow($value,$class); - } - return true; - } - function SetFooter($value=NULL,$class=NULL) - { - if(is_null($value)){ - $this->footer = NULL; - }elseif(is_a($value,'ccol')) - { - if(isset($this->header) && $value->GetOption('colspan')==NULL) - $value->SetColSpan(count($this->header->items)); - $this->footer = new CRow($value,$class); - }elseif(is_a($value,'crow')) - { - if(isset($class)) - $value->SetClass($class); - $this->footer = $value; - }else{ - $this->footer = new CRow($value,$class); - } + $this->curr_row_class = NULL; + + $this->header = ''; + $this->headerClass = NULL; + $this->footer = ''; + $this->footerClass = NULL; + $this->colnum = 0; } function SetOddRowClass($value=NULL) { - if(!is_string($value) && !is_null($value)) - { - return $this->error("Incorrect value for SetOddRowClass [$value]"); - } $this->oddRowClass = $value; } function SetEvenRowClass($value=NULL) { - if(!is_string($value) && !is_null($value)) - { - return $this->error("Incorrect value for SetEvenRowClass [$value]"); - } $this->evenRowClass = $value; } function SetAlign($value) { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetAlign [$value]"); - } - return $this->AddOption("align",$value); + return $this->options['align'] = $value; } function SetCellPadding($value) { - if(!is_int($value) && !is_numeric($value)) - { - return $this->error("Incorrect value for SetCellpadding [$value]"); - } - return $this->AddOption("cellpadding",strval($value)); + return $this->options['cellpadding'] = strval($value); } function SetCellSpacing($value) { - if(!is_int($value) && !is_numeric($value)) - { - return $this->error("Incorrect value for SetCellSpacing [$value]"); - } - return $this->AddOption("cellspacing",strval($value)); + return $this->options['cellspacing'] = strval($value); } - function AddRow($item,$rowClass=NULL) + + function PrepareRow($item,$rowClass=NULL) { - if(is_null($item)){ - return 0; - }elseif(is_a($item,'ccol')) + if(is_null($item)) return NULL; + + if(is_a($item,'ccol')) { - if(isset($this->header) && $item->GetOption('colspan')==NULL) - $item->SetColSpan(count($this->header->items)); + if(isset($this->header) && !isset($item->options['colspan'])) + $item->options['colspan'] = $this->colnum; - return $this->AddItem(new CRow($item,$rowClass)); - }elseif(is_a($item,'crow')) + $item = new CRow($item,$rowClass); + } + elseif(is_a($item,'crow')) { if(isset($rowClass)) - $item->SetClass($rowClass); + $item->options['class'] = $rowClass; + } + else + { + $item = new CRow($item,$rowClass); + } + if(!isset($item->options['class'])) + { + $this->curr_row_class = ($this->curr_row_class == $this->evenRowClass) ? + $this->oddRowClass: + $this->evenRowClass; + $item->options['class'] = $this->curr_row_class; + }/**/ + return $item->ToString(); + } + function SetHeader($value=NULL,$class=NULL) + { + if(is_null($class)) $class = $this->headerClass; - return $this->AddItem($item); + if(is_a($value,'crow')) + { + if(isset($class)) $value->SetClass($class); }else{ - return $this->AddItem(new CRow($item,$rowClass)); + $value = new CRow($value,$class); } + $this->colnum = $value->ItemsCount(); + $this->header = $value->ToString(); } -/* protected */ - function ShowHeader() + function SetFooter($value=NULL,$class=NULL) { - if(isset($this->header)) - $this->header->Show(); - } + if(is_null($class)) $class = $this->footerClass; - function GetNumRows() + $this->footer = $this->PrepareRow($value,$class);; + } + function AddRow($item,$rowClass=NULL) { - return $this->GetItemsCount(); + return $this->AddItem($this->PrepareRow($item,$rowClass)); } - - function ShowTagBody() + function ShowRow($item,$rowClass=NULL) { - $this->ShowHeader(); - - if(count($this->items)==0) - { - if(isset($this->message)) - $this->AddRow(new CCol($this->message,'message'),$this->evenRowClass); - } - - parent::ShowTagBody(); - - if(is_a($this->footer,'crow')) - $this->footer->Show(); + echo $this->PrepareRow($item,$rowClass); } - function AddItem($value) +/* protected */ + function GetNumRows() { - $cname="crow"; - if(!is_a($value,$cname)) - { - return $this->error("Incorrect value for AddItem [$value]"); - } - - if($value->GetOption('class')==NULL) - { - $value->SetClass( - ((count($this->items)+1)%2==1) ? - $this->evenRowClass : $this->oddRowClass - ); - } + return $this->ItemsCount(); + } - return parent::AddItem($value); + function StartToString() + { + $ret = parent::StartToString(); + $ret .= $this->header; + return $ret; } -/* function Show() + function EndToString() { - ob_start(); - parent::Show(); - ob_end_flush(); + $ret = $this->footer; + $ret .= parent::EndToString(); + return $ret; } -*/ } ?> diff --git a/frontends/php/include/classes/ctableinfo.inc.php b/frontends/php/include/classes/ctableinfo.inc.php index 4826eeba..34d35ddf 100644 --- a/frontends/php/include/classes/ctableinfo.inc.php +++ b/frontends/php/include/classes/ctableinfo.inc.php @@ -22,65 +22,15 @@ class CTableInfo extends CTable { /* public */ - var $sortby; - function CTableInfo($message='...',$class='tableinfo') { parent::CTable($message,$class); - $this->SetOddRowClass('odd_row'); - $this->SetEvenRowClass('even_row'); - $this->SetCellSpacing(1); - $this->SetCellPadding(3); - - $this->sortby = null; - } - function SetHeader($value=NULL,$class='header') - { - parent::SetHeader($value,$class); - } - function SetFooter($value=NULL,$class='footer') - { - parent::SetFooter($value,$class); - } - function SortBy($value = NULL) - { - if(!is_numeric($value) && !is_null($value)) - { - return $this->error("Incorrect value for SortBy [$value]"); - } - $this->sortby = $value; - } - function ShowHeader() - { - if(isset($this->header)) - { - // create a copy of real header - $header = $this->header; - - if(!is_null($this->sortby)) - { - $i = 1; - foreach($header->items as $id => $col) - { - $sort = new CSpan(); - $down = "_off"; - $up = "_off"; - - if(($i-$this->sortby) == 0) $down = ""; - if(($i+$this->sortby) == 0) $up = ""; - - $sort->AddItem(array( - new CImg("images/general/sortup$up.gif"), - new CImg("images/general/sortdown$down.gif"), - SPACE)); - $sort->AddOption("style","float:left"); - - $header->items[$id]->AddItem($sort); - $i++; - } - } - $header->Show(); - } + $this->oddRowClass = 'odd_row'; + $this->evenRowClass = 'even_row'; + $this->options['cellpadding'] = 3; + $this->options['cellspacing'] = 1; + $this->headerClass = 'header'; + $this->footerClass = 'footer'; } } ?> diff --git a/frontends/php/include/classes/ctag.inc.php b/frontends/php/include/classes/ctag.inc.php index a6e2ce3b..7b37e14d 100644 --- a/frontends/php/include/classes/ctag.inc.php +++ b/frontends/php/include/classes/ctag.inc.php @@ -19,230 +19,162 @@ **/ ?> <?php + function unpack_object(&$item) + { + $res = ""; + + if(is_object($item)) + { + $res = $item->ToString(); + } + elseif(is_array($item)) + { + foreach($item as $i) + $res .= unpack_object($i); // Attention, recursion !!! + } + elseif(!is_null($item)) + { + $res = strval($item); + } + return $res; + } + class CTag { /* private */ - var $name; + var $tagname; var $options = array(); var $paired; /* protected */ var $items = array(); - var $items_max_count; var $tag_body_start; var $tag_body_end; var $tag_start; var $tag_end; - function fnc($c) - { - $ret = '<tr>'; - foreach($c as $cc) - $ret .= '<td>'.$cc.'</td>'; - $ret .= '</tr>'; - return $ret; - } - /* public */ - function CTag($name=NULL, $paired='no', $body=NULL) + function CTag($tagname=NULL, $paired='no', $body=NULL) { - $this->SetTagName($name); - $this->SetPaired($paired); - - $this->items_max_count = 0; + if(!is_string($tagname)) + { + return $this->error('Incorrect tagname for CTag ['.$tagname.']'); + } + $this->tagname = $tagname; + $this->paired = $paired; - $this->tag_start=$this->tag_end=$this->tag_body_start=$this->tag_body_end= ""; + $this->tag_start = $this->tag_end = $this->tag_body_start = $this->tag_body_end = ''; if(is_null($body)) { - $this->tag_end = "\n"; - $this->tag_body_start = "\n"; - } else { + $this->tag_end = $this->tag_body_start = "\n"; + } + else + { CTag::AddItem($body); } } - function SetMaxLength($value) - { - if(!is_int($value)) - return $this->error("Incorrect value for SetMaxLength [$value]"); + function ShowStart() { echo $this->StartToString(); } + function ShowBody() { echo $this->BodyToString(); } + function ShowEnd() { echo $this->EndToString(); } + function Show() { echo $this->ToString(); } - $this->items_max_count = $value; - return 0; + function StartToString() + { + $res = $this->tag_start.'<'.$this->tagname; + foreach($this->options as $key => $value) + $res .= ' '.$key.'="'.$value.'"'; + $res .= ($this->paired=='yes') ? '>' : '/>'; + return $res; } - function Show() + function BodyToString() { - $this->ShowTagStart(); - $this->ShowTagBody(); - $this->ShowTagEnd(); + $res = $this->tag_body_start; + foreach($this->items as $item) + $res .= $item; + return $res; } - function SetTagName($value=NULL) - { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetTagName [$value]"); - } - $this->name=$value; - return 0; + function EndToString() + { + $res = ($this->paired=='yes') ? $this->tag_body_end.'</'.$this->tagname.'>' : ''; + $res .= $this->tag_end; + return $res; } - function SetName($value=NULL) + function ToString() { - if(is_null($value)) - return $this->DelOption("name");; - - if(!is_string($value)) - { - return $this->error("Incorrect value for SetClass [$value]"); - } - return $this->AddOption("name",$value); + $res = $this->StartToString(); + $res .= $this->BodyToString(); + $res .= $this->EndToString(); + return $res; } - function GetName() + function SetName($value) { - return $this->GetOption("name"); + $this->options['name'] = $value; } - function SetClass($value) + function GetName() { - if(is_null($value)) - return 0; - - if(!is_string($value)) - { - return $this->error("Incorrect value for SetClass [$value]"); - } - return $this->AddOption("class",$value); + if(isset($this->options['name'])) + return $this->options['name']; + return NULL; } - function SetPaired($value='no') + function SetClass($value) { - if($value == 'no') $this->paired=$value; - elseif($value == 'yes') $this->paired=$value; - else - { - return $this->error("Incorrect value for SetPaired [$value]"); - } - return 0; + return $this->options['class'] = $value; } function DelOption($name) { - if(!is_string($name)) - { - return $this->error("Incorrect value for DelOption [$value]"); - } unset($this->options[$name]); - return 0; } function &GetOption($name) { $ret = NULL; - if(is_string($name)) - if(isset($this->options[$name])) - $ret =& $this->options[$name]; + if(isset($this->options[$name])) + $ret =& $this->options[$name]; return $ret; } function AddOption($name, $value) { - if(!is_string($name)) - { - return $this->error("Incorrect name for AddOption [$name]"); - } - if(!is_string($value) && !is_int($value) && !is_float($value)) - { - return $this->error("Incorrect value for AddOption [$name] [$value]"); - } - $this->options[$name] = htmlspecialchars(strval($value)); - return 0; } function CleanItems() { $this->items = array(); } - function GetItemsCount() + function ItemsCount() { return count($this->items); } function AddItem($value) { - if(is_null($value)) - { - return 1; - } - elseif(is_array($value)) + if(is_array($value)) { foreach($value as $item) { - if($this->items_max_count > 0) - if(count($this->items) >= $this->items_max_count) - return $this->error("Maximal tag lenght '".$this->items_max_count."' is achived"); - array_push($this->items,$item); + array_push($this->items,unpack_object($item)); } } - else + elseif(!is_null($value)) { - if($this->items_max_count > 0) - if(count($this->items) >= $this->items_max_count) - return $this->error("Maximal tag lenght '".$this->items_max_count."' is achived"); - - array_push($this->items,$value); + array_push($this->items,unpack_object($value)); } - return 0; } -/* protected */ - function ShowTagStart() + function SetEnabled($value='yes') { - echo $this->tag_start; - echo "<".$this->name; - foreach($this->options as $key => $value) + if((is_string($value) && ($value == 'yes' || $value == 'enabled' || $value=='on') || $value=='1') + || (is_int($value) && $value<>0)) { - echo " $key=\"$value\""; + unset($this->options['disabled']); } - - if($this->paired=='yes') - echo ">"; - else - echo "/>"; - - echo $this->tag_body_start; - } - function ShowTagItem(&$item) - { - if(is_null($item)) return; - elseif(is_object($item))$item->Show(); - elseif(is_array($item)) { - foreach($item as $i) $this->ShowTagItem($i); // Attention, recursion !!! - } else echo strval($item); - } - function ShowTagBody() - { - foreach($this->items as $item) - $this->ShowTagItem($item); - } - function ShowTagEnd() - { - echo $this->tag_body_end; - - if($this->paired=='yes') + elseif((is_string($value) && ($value == 'no' || $value == 'disabled' || $value=='off') || $value=='0') + || (is_int($value) && $value==0)) { - echo "</".$this->name.">"; - echo $this->tag_end; + $this->options['disabled'] = 'disabled'; } } - function SetEnabled($value='yes') - { - if(is_null($value)) - return 0; - elseif((is_string($value) && - ($value == 'yes' || $value == 'enabled' || $value=='on') || $value=='1') - || (is_int($value) && $value<>0)) - return $this->DelOption('disabled'); - elseif((is_string($value) && - ($value == 'no' || $value == 'disabled' || $value=='off') || $value=='0') - || (is_int($value) && $value==0)) - return $this->AddOption('disabled','disabled'); - return $this->error("Incorrect value for SetEnabled [$value]"); - } function error($value) { - error("class(".get_class($this).") - ".$value); + error('class('.get_class($this).') - '.$value); return 1; } diff --git a/frontends/php/include/classes/ctextarea.inc.php b/frontends/php/include/classes/ctextarea.inc.php index 5ea51f70..af5b0127 100644 --- a/frontends/php/include/classes/ctextarea.inc.php +++ b/frontends/php/include/classes/ctextarea.inc.php @@ -21,82 +21,38 @@ <?php class CTextArea extends CTag { -/* private */ - var $caption; /* public */ - function CTextArea($name='textarea',$value="",$cols=77,$rows=7,$caption=NULL,$readonly='no') + function CTextArea($name='textarea',$value="",$cols=77,$rows=7,$readonly='no') { parent::CTag("textarea","yes"); - $this->SetClass("biginput"); - $this->AddOption('wrap','soft'); - $this->SetName($name); - $this->SetCols($cols); - $this->SetRows($rows); - $this->SetCaption($caption); - $this->SetValue($value); + $this->options['class'] = 'biginput'; + $this->options['wrap'] = 'soft'; + $this->options['name'] = $name; + $this->options['rows'] = $rows; + $this->options['cols'] = $cols; $this->SetReadonly($readonly); - } - function Show() - { - if(isset($this->caption)) - echo $this->caption." "; - parent::Show(); - } - function SetName($value='textarea') - { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetName [$value]"); - } - return $this->AddOption("name",$value); - } - function SetCaption($value=NULL) - { - if(is_null($value)) - unset($this->caption); - elseif(is_string($value)) - $this->caption = $value; - else - { - return $this->error("Incorrect value for SetCaption [$value]"); - } - return 0; + + $this->AddItem($value); } function SetReadonly($value='yes') { - if(is_string($value)) - { - if($value=='no') - return $this->DelOption("readonly"); - elseif($value=='yes') - return $this->AddOption("readonly",'readonly'); - } - return $this->error("Incorrect value for SetReadonly [$value]"); + if($value=='yes') + return $this->options['readonly'] = 'readonly'; + + $this->DelOption("readonly"); } function SetValue($value="") { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetValue [$value]"); - } return $this->AddItem($value); } function SetRows($value) { - if(!is_numeric($value)) - { - return $this->error("Incorrect value for SetRows [$value]"); - } - return $this->AddOption("rows",strval($value)); + return $this->options['rows'] = $value; } function SetCols($value) { - if(!is_numeric($value)) - { - return $this->error("Incorrect value for SetCols [$value]"); - } - return $this->AddOption("cols",strval($value)); + return $this->options['cols'] = $value; } } diff --git a/frontends/php/include/classes/ctextbox.inc.php b/frontends/php/include/classes/ctextbox.inc.php index 6345b342..b8faf48a 100644 --- a/frontends/php/include/classes/ctextbox.inc.php +++ b/frontends/php/include/classes/ctextbox.inc.php @@ -24,73 +24,41 @@ /* private */ var $caption; /* public */ - function CTextBox($name='textbox',$value="",$size=20,$caption=NULL,$readonly="no") + function CTextBox($name='textbox',$value="",$size=20,$readonly="no") { - parent::CTag("input","no"); - $this->SetClass("biginput"); - $this->SetName($name); - $this->SetSize($size); - $this->SetCaption($caption); - $this->SetValue($value); + parent::CTag('input','no'); + $this->options['class'] = 'biginput'; + $this->options['name'] = $name; + $this->options['size'] = $size; + $this->options['value'] = $value; $this->SetReadonly($readonly); } - function Show() - { - if(isset($this->caption)) - echo $this->caption." "; - parent::Show(); - } function SetReadonly($value='yes') { - if(is_string($value)) - { - if($value=='no') - return $this->DelOption("readonly"); - elseif($value=='yes') - return $this->AddOption("readonly",'readonly'); - } - return $this->error("Incorrect value for SetReadonly [$value]"); - } - function SetName($value='textbox') - { - if(!is_string($value)) - { - return $this->error("Incorrect value for SetName [$value]"); - } - return $this->AddOption("name",$value); - } - function SetCaption($value=NULL) - { - if(is_null($value)) - unset($this->caption); - elseif(is_string($value)) - $this->caption = $value; - else - { - return $this->error("Incorrect value for SetCaption [$value]"); - } - return 0; + if($value=='yes') + return $this->options['readonly'] = 'readonly'; + + $this->DelOption('readonly'); } function SetValue($value=NULL) { - if(is_null($value)) $value=""; - - if(is_numeric($value)) $value = strval($value); - - if(is_string($value)) - { - return $this->AddOption("value",$value); - } - return $this->error("Incorrect value for SetValue [$value]"); + $this->options['value'] = $value; } function SetSize($value) { - if(!is_numeric($value)) - { - return $this->error("Incorrect value for SetSize [$value]"); - } - return $this->AddOption("size",strval($value)); + $this->options['size'] = $value; } } + + class CPassBox extends CTextBox + { +/* public */ + function CPassBox($name='password',$value='',$size=20) + { + parent::CTextBox($name,$value,$size); + $this->options['type'] = 'password'; + } + } + ?> diff --git a/frontends/php/include/classes/cvar.inc.php b/frontends/php/include/classes/cvar.inc.php index fc823ce8..52dd4f8f 100644 --- a/frontends/php/include/classes/cvar.inc.php +++ b/frontends/php/include/classes/cvar.inc.php @@ -24,14 +24,14 @@ /* public */ function CVar($name="",$value="0") { - parent::CTag("input","no"); - $this->AddOption("type","hidden"); - $this->SetName($name); - $this->SetValue($value); + parent::CTag('input','no'); + $this->options['type'] = 'hidden'; + $this->options['name'] = $name; + $this->options['value'] = $value; } function SetValue($value) { - return $this->AddOption("value",$value); + $this->options['value'] = $value; } } ?> diff --git a/frontends/php/include/classes/graph.inc.php b/frontends/php/include/classes/graph.inc.php index 5b029bed..bf841bd0 100644 --- a/frontends/php/include/classes/graph.inc.php +++ b/frontends/php/include/classes/graph.inc.php @@ -818,8 +818,8 @@ // $this->im = imagecreate($this->sizeX+$this->shiftX+61,$this->sizeY+2*$this->shiftY+40); - Header( "Content-type: text/html"); -/* +// Header( "Content-type: text/html"); +//* Header( "Content-type: image/png"); Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT"); /**/ |
