summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-01-06 15:24:33 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-01-06 15:24:33 +0000
commit7a1590d2ea50d61eb7f695d6371a48e609117e50 (patch)
tree066605dd07f91ff67ce51d30ffa0e60f1999e550 /frontends/php
parent5199d6f9a9f2d3829780e8b5a70b286cbfbcb40c (diff)
downloadzabbix-7a1590d2ea50d61eb7f695d6371a48e609117e50.tar.gz
zabbix-7a1590d2ea50d61eb7f695d6371a48e609117e50.tar.xz
zabbix-7a1590d2ea50d61eb7f695d6371a48e609117e50.zip
Frontend improvements.
git-svn-id: svn://svn.zabbix.com/trunk@2494 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/hosts.php21
-rw-r--r--frontends/php/include/classes/table.inc.php22
-rw-r--r--frontends/php/items.php24
-rw-r--r--frontends/php/overview.php17
-rw-r--r--frontends/php/tr_status.php12
-rw-r--r--frontends/php/triggers.php17
6 files changed, 61 insertions, 52 deletions
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php
index eb888746..a1eb11f8 100644
--- a/frontends/php/hosts.php
+++ b/frontends/php/hosts.php
@@ -473,9 +473,9 @@
?>
<?php
- table_begin();
- table_header(array(S_ID,S_HOST,S_IP,S_PORT,S_STATUS,S_AVAILABILITY,S_ERROR,S_ACTIONS));
- echo "<form method=\"get\" action=\"hosts.php\">";
+ $table = new Ctable(S_NO_HOSTS_DEFINED);
+ $table->setHeader(array(S_ID,S_HOST,S_IP,S_PORT,S_STATUS,S_AVAILABILITY,S_ERROR,S_ACTIONS));
+ $table->setAfterHeader("<form method=\"get\" action=\"hosts.php\">");
if(isset($_REQUEST["groupid"]))
{
@@ -487,7 +487,6 @@
}
$result=DBselect($sql);
- $col=0;
while($row=DBfetch($result))
{
if(!check_right("Host","R",$row["hostid"]))
@@ -574,7 +573,7 @@
{
$actions=S_CHANGE;
}
- table_row(array(
+ $table->addRow(array(
$id,
$host,
$ip,
@@ -582,16 +581,10 @@
$status,
$available,
$error,
- $actions
- ),$col++);
- }
- if(DBnum_rows($result)==0)
- {
- echo "<TR BGCOLOR=#EEEEEE>";
- echo "<TD COLSPAN=8 ALIGN=CENTER>".S_NO_HOSTS_DEFINED."</TD>";
- echo "<TR>";
+ $actions));
}
- table_end();
+ $table->show();
+
show_form_begin();
echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"Activate selected\" onClick=\"return Confirm('".S_ACTIVATE_SELECTED_HOSTS_Q."');\">";
echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"Disable selected\" onClick=\"return Confirm('".S_DISABLE_SELECTED_HOSTS_Q."');\">";
diff --git a/frontends/php/include/classes/table.inc.php b/frontends/php/include/classes/table.inc.php
index 7572b30b..c35802fd 100644
--- a/frontends/php/include/classes/table.inc.php
+++ b/frontends/php/include/classes/table.inc.php
@@ -21,15 +21,27 @@
<?php
class Ctable
{
- var $rows;
- var $header;
+ var $rows=array();
+ var $header=array();
var $msg_empty;
+ var $after_header_html;
+ var $before_footer_html;
function Ctable($msg_empty="...")
{
- $this->rows=array();
- $this->header=array();
$this->msg_empty=$msg_empty;
+ $this->after_header_html="";
+ $this->before_footer_html="";
+ }
+
+ function setAfterHeader($html)
+ {
+ $this->after_header_html = $html;
+ }
+
+ function setBeforeFooter($html)
+ {
+ $this->before_footer_html = $html;
}
function addRow($row)
@@ -92,6 +104,7 @@
function show()
{
$this->showHeader();
+ echo $this->after_header_html."\n";
while (list($num,$row) = each($this->rows))
{
$this->showRow($row,$num);
@@ -100,6 +113,7 @@
{
echo "<tr bgcolor=#eeeeee><td colspan=".count($this->header)." align=center>".$this->msg_empty."</td></tr>\n";
}
+ echo $this->before_footer_html."\n";
$this->showFooter();
}
}
diff --git a/frontends/php/items.php b/frontends/php/items.php
index 3010f1d4..3bb890c1 100644
--- a/frontends/php/items.php
+++ b/frontends/php/items.php
@@ -243,10 +243,13 @@
if(isset($_REQUEST["hostid"]))
{
- table_begin();
- table_header(array(S_ID,S_KEY,S_DESCRIPTION,nbsp(S_UPDATE_INTERVAL),S_HISTORY,S_TRENDS,S_TYPE,S_STATUS,S_ERROR));
- echo "<form method=\"get\" action=\"items.php\">";
- echo "<input class=\"biginput\" name=\"hostid\" type=hidden value=".$_REQUEST["hostid"]." size=8>";
+ $table = new Ctable();
+ $table->setHeader(array(S_ID,S_KEY,S_DESCRIPTION,nbsp(S_UPDATE_INTERVAL),S_HISTORY,S_TRENDS,S_TYPE,S_STATUS,S_ERROR));
+ $h="<form method=\"get\" action=\"items.php\">";
+ $h=$h."<input class=\"biginput\" name=\"hostid\" type=hidden value=".$_REQUEST["hostid"]." size=8>";
+
+ $table->setAfterHeader($h);
+
$result=DBselect("select h.host,i.key_,i.itemid,i.description,h.port,i.delay,i.history,i.lastvalue,i.lastclock,i.status,i.nextcheck,h.hostid,i.type,i.trends,i.error from hosts h,items i where h.hostid=i.hostid and h.hostid=".$_REQUEST["hostid"]." order by h.host,i.key_,i.description");
$col=0;
while($row=DBfetch($result))
@@ -316,7 +319,7 @@
{
$error=array("value"=>$row["error"],"class"=>"on");
}
- table_row(array(
+ $table->AddRow(array(
$input,
$key,
$row["description"],
@@ -326,26 +329,23 @@
$type,
$status,
$error
- ),$col++);
+ ));
}
- table_end();
+ $table->show();
$h="<input class=\"button\" type=\"submit\" name=\"register\" value=\"Activate selected\" onClick=\"return Confirm('".S_ACTIVATE_SELECTED_ITEMS_Q."');\">";
$h=$h."<input class=\"button\" type=\"submit\" name=\"register\" value=\"Disable selected\" onClick=\"return Confirm('".S_DISABLE_SELECTED_ITEMS_Q."');\">";
$h=$h."<input class=\"button\" type=\"submit\" name=\"register\" value=\"Delete selected\" onClick=\"return Confirm('".S_DELETE_SELECTED_ITEMS_Q."');\">";
+ $h=$h."</form>";
show_table_header($h);
}
- else
- {
-// echo "<center>Select Host</center>";
- }
}
?>
<?php
-// if(isset($_REQUEST["register"])&&(in_array($_REQUEST["register"],array("Create Item","change"))))
+ if(isset($_REQUEST["register"])&&(in_array($_REQUEST["register"],array("Create Item","change"))))
{
$result=DBselect("select count(*) as cnt from hosts");
$row=DBfetch($result);
diff --git a/frontends/php/overview.php b/frontends/php/overview.php
index b7a3a6c7..4846003d 100644
--- a/frontends/php/overview.php
+++ b/frontends/php/overview.php
@@ -104,7 +104,7 @@
if(isset($_REQUEST["groupid"])&&isset($_REQUEST["type"])&&($_REQUEST["type"]==SHOW_DATA))
{
- table_begin();
+ $table = new Ctable();
$header=array("&nbsp;");
$hosts=array();
$sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host";
@@ -114,9 +114,8 @@
$header=array_merge($header,array($row["host"]));
$hosts=array_merge($hosts,array($row["hostid"]));
}
- table_header($header);
+ $table->setHeader($header);
- $col=0;
if(isset($_REQUEST["sort"]))
{
switch ($_REQUEST["sort"])
@@ -177,13 +176,13 @@
$rows=array_merge($rows,array($value));
}
- table_row($rows, $col++);
+ $table->addRow($rows);
}
- table_end();
+ $table->show();
}
else if(isset($_REQUEST["groupid"])&&isset($_REQUEST["type"])&&($_REQUEST["type"]==SHOW_TRIGGERS))
{
- table_begin();
+ $table = new Ctable();
$header=array("&nbsp;");
$hosts=array();
$sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg,functions f,triggers t where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and t.triggerid=f.triggerid and f.itemid=i.itemid group by h.hostid,h.host order by h.host";
@@ -193,7 +192,7 @@
$header=array_merge($header,array($row["host"]));
$hosts=array_merge($hosts,array($row["hostid"]));
}
- table_header($header);
+ $table->setHeader($header);
$col=0;
if(isset($_REQUEST["sort"]))
@@ -249,9 +248,9 @@
$rows=array_merge($rows,array($value));
}
- table_row($rows, $col++);
+ $table->addRow($rows);
}
- table_end();
+ $table->show();
}
else
{
diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php
index 2e366cd9..29f99cd2 100644
--- a/frontends/php/tr_status.php
+++ b/frontends/php/tr_status.php
@@ -414,7 +414,7 @@
// show_table_header("<A HREF=\"tr_status.php?onlytrue=$onlytrue&noactions=$noactions&compact=$compact&fullscreen=1&sort=$sort\">".S_TRIGGERS_BIG." $time</A>");
}
- table_begin();
+ $table = new Ctable();
$header=array();
echo "<TR ALIGN=CENTER BGCOLOR=\"#CCCCCC\">";
@@ -475,7 +475,7 @@
$header=array_merge($header,array(S_ACTIONS));
}
$header=array_merge($header,array(S_COMMENTS));
- table_header($header);
+ $table->setHeader($header);
unset($header);
if(isset($_REQUEST["hostid"]))
@@ -515,6 +515,7 @@
{
$result=DBselect("select distinct t.triggerid,t.status,t.description,t.expression,t.priority,t.lastchange,t.comments,t.url,t.value from triggers t,hosts h,items i,functions f".$groupname." where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and t.status=0 and t.description $select_cond and i.status in (0,2) and h.status=".HOST_STATUS_MONITORED." $cond $groupcond $sort");
}
+
$col=0;
while($row=DBfetch($result))
{
@@ -600,16 +601,17 @@
$comments="<A HREF=\"tr_comments.php?triggerid=".$row["triggerid"]."\">".S_ADD."</a>";
}
- table_row(array(
+ $table->addRow(array(
$description,
$value,
$priority,
$lastchange,
$actions,
$comments
- ),$col++);
+ ));
+ $col++;
}
- table_end();
+ $table->show();
show_table_header(S_TOTAL.":$col");
?>
diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php
index 9de9dd66..c515b4c0 100644
--- a/frontends/php/triggers.php
+++ b/frontends/php/triggers.php
@@ -220,13 +220,13 @@
if(isset($_REQUEST["hostid"])&&!isset($_REQUEST["triggerid"]))
{
- table_begin();
- table_header(array(S_ID,S_NAME,S_EXPRESSION, S_SEVERITY, S_STATUS, S_ERROR, S_ACTIONS));
- echo "<form method=\"get\" action=\"triggers.php\">";
- echo "<input class=\"biginput\" name=\"hostid\" type=hidden value=".$_REQUEST["hostid"]." size=8>";
+ $table = new Ctable();
+ $table->setHeader(array(S_ID,S_NAME,S_EXPRESSION, S_SEVERITY, S_STATUS, S_ERROR, S_ACTIONS));
+ $h="<form method=\"get\" action=\"triggers.php\">";
+ $h=$h."<input class=\"biginput\" name=\"hostid\" type=hidden value=".$_REQUEST["hostid"]." size=8>";
+ $table->setAfterHeader($h);
$result=DBselect("select distinct h.hostid,h.host,t.triggerid,t.expression,t.description,t.status,t.value,t.priority,t.error from triggers t,hosts h,items i,functions f where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and h.hostid=".$_REQUEST["hostid"]." order by h.host,t.description");
- $col=0;
while($row=DBfetch($result))
{
if(check_right_on_trigger("R",$row["triggerid"]) == 0)
@@ -294,7 +294,7 @@
// {
// $actions=$actions."<A HREF=\"actions.php?triggerid=".$row["triggerid"]."\">".S_ACTIONS."</A>";
// }
- table_row(array(
+ $table->addRow(array(
$id,
$description,
explode_exp($row["expression"],1),
@@ -302,9 +302,10 @@
$status,
$row["error"],
$actions
- ),$col++);
+ ));
}
- table_end();
+ $table->show();
+
show_form_begin();
echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"enable selected\" onClick=\"return Confirm('".S_ENABLE_SELECTED_TRIGGERS_Q."');\">";
echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"disable selected\" onClick=\"return Confirm('Disable selected triggers?');\">";