Private GIT

Skip to content
Snippets Groups Projects
Commit 2b9179f8 authored by loiclau's avatar loiclau
Browse files

* fix style graph template

parent f0441da3
No related branches found
No related tags found
No related merge requests found
......@@ -45,7 +45,9 @@ function testExistence($name = null)
if (isset($form)) {
$id = $form->getSubmitValue('graph_id');
}
$res = $pearDB->query("SELECT graph_id, name FROM giv_graphs_template WHERE name = '".htmlentities($name, ENT_QUOTES, "UTF-8")."'");
$query = "SELECT graph_id, name FROM giv_graphs_template WHERE name = '" .
htmlentities($name, ENT_QUOTES, "UTF-8") . "'";
$res = $pearDB->query($query);
$graph = $res->fetchRow();
/*
* Modif case
......@@ -84,7 +86,9 @@ function multipleGraphTemplateInDB($graphs = array(), $nbrDup = array())
$val = null;
foreach ($row as $key2 => $value2) {
$key2 == "name" ? ($name = $value2 = $value2 . "_" . $i) : null;
$val ? $val .= ($value2!=null?(", '".$value2."'"):", NULL") : $val .= ($value2!=null?("'".$value2."'"):"NULL");
$val
? $val .= ($value2 != null ? (", '" . $value2 . "'") : ", NULL")
: $val .= ($value2 != null ? ("'" . $value2 . "'") : "NULL");
}
if (testExistence($name)) {
$val ? $rq = "INSERT INTO giv_graphs_template VALUES (" . $val . ")" : $rq = null;
......@@ -100,7 +104,8 @@ function defaultOreonGraph()
$rq = "SELECT DISTINCT graph_id FROM giv_graphs_template WHERE default_tpl1 = '1'";
$res = $pearDB->query($rq);
if (!$res->rowCount()) {
$rq = "UPDATE giv_graphs_template SET default_tpl1 = '1' WHERE graph_id = (SELECT MIN(graph_id) FROM giv_graphs_template)";
$rq = "UPDATE giv_graphs_template SET default_tpl1 = '1' " .
"WHERE graph_id = (SELECT MIN(graph_id) FROM giv_graphs_template)";
$pearDB->query($rq);
}
}
......@@ -137,22 +142,45 @@ function insertGraphTemplate()
noDefaultOreonGraph();
}
$rq = "INSERT INTO `giv_graphs_template` ( `graph_id` , `name` , " .
"`vertical_label` , `width` , `height` , `base` , `lower_limit`, `upper_limit` , `size_to_max`, `default_tpl1` , `split_component` , `scaled`, `stacked` , `comment`) ";
"`vertical_label` , `width` , `height` , `base` , `lower_limit`, `upper_limit` , `size_to_max`, " .
"`default_tpl1` , `split_component` , `scaled`, `stacked` , `comment`) ";
$rq .= "VALUES (";
$rq .= "NULL, ";
isset($ret["name"]) && $ret["name"] != null ? $rq .= "'".htmlentities($ret["name"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, ";
isset($ret["vertical_label"]) && $ret["vertical_label"] != null ? $rq .= "'".htmlentities($ret["vertical_label"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, ";
isset($ret["width"]) && $ret["width"] != null ? $rq .= "'".htmlentities($ret["width"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, ";
isset($ret["height"]) && $ret["height"] != null ? $rq .= "'".htmlentities($ret["height"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, ";
isset($ret["base"]) && $ret["base"] != null ? $rq .= "'".htmlentities($ret["base"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, ";
isset($ret["lower_limit"]) && $ret["lower_limit"] != null ? $rq .= "'".$ret["lower_limit"]."', ": $rq .= "NULL, ";
isset($ret["upper_limit"]) && $ret["upper_limit"] != null ? $rq .= "'".$ret["upper_limit"]."', ": $rq .= "NULL, ";
isset($ret["size_to_max"]) && $ret["size_to_max"] != null ? $rq .= "'".$ret["size_to_max"]."', ": $rq .= "0, ";
isset($ret["default_tpl1"]) && $ret["default_tpl1"] != null ? $rq .= "'".$ret["default_tpl1"]."', ": $rq .= "NULL, ";
isset($ret["name"]) && $ret["name"] != null
? $rq .= "'" . htmlentities($ret["name"], ENT_QUOTES, "UTF-8") . "', "
: $rq .= "NULL, ";
isset($ret["vertical_label"]) && $ret["vertical_label"] != null
? $rq .= "'" . htmlentities($ret["vertical_label"], ENT_QUOTES, "UTF-8") . "', "
: $rq .= "NULL, ";
isset($ret["width"]) && $ret["width"] != null
? $rq .= "'" . htmlentities($ret["width"], ENT_QUOTES, "UTF-8") . "', "
: $rq .= "NULL, ";
isset($ret["height"]) && $ret["height"] != null
? $rq .= "'" . htmlentities($ret["height"], ENT_QUOTES, "UTF-8") . "', "
: $rq .= "NULL, ";
isset($ret["base"]) && $ret["base"] != null
? $rq .= "'" . htmlentities($ret["base"], ENT_QUOTES, "UTF-8") . "', "
: $rq .= "NULL, ";
isset($ret["lower_limit"]) && $ret["lower_limit"] != null
? $rq .= "'" . $ret["lower_limit"] . "', "
: $rq .= "NULL, ";
isset($ret["upper_limit"]) && $ret["upper_limit"] != null
? $rq .= "'" . $ret["upper_limit"] . "', "
: $rq .= "NULL, ";
isset($ret["size_to_max"]) && $ret["size_to_max"] != null
? $rq .= "'" . $ret["size_to_max"] . "', "
: $rq .= "0, ";
isset($ret["default_tpl1"]) && $ret["default_tpl1"] != null
? $rq .= "'" . $ret["default_tpl1"] . "', "
: $rq .= "NULL, ";
$rq .= "NULL, "; // Column split chart (removed options)
isset($ret["scaled"]) && $ret["scaled"] != null ? $rq .= "'" . $ret["scaled"] . "', " : $rq .= "'0', ";
isset($ret["stacked"]) && $ret["stacked"] != null ? $rq .= "'".htmlentities($ret["stacked"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, ";
isset($ret["comment"]) && $ret["comment"] != null ? $rq .= "'".htmlentities($ret["comment"], ENT_QUOTES, "UTF-8")."'": $rq .= "NULL";
isset($ret["stacked"]) && $ret["stacked"] != null
? $rq .= "'" . htmlentities($ret["stacked"], ENT_QUOTES, "UTF-8") . "', "
: $rq .= "NULL, ";
isset($ret["comment"]) && $ret["comment"] != null
? $rq .= "'" . htmlentities($ret["comment"], ENT_QUOTES, "UTF-8") . "'"
: $rq .= "NULL";
$rq .= ")";
$pearDB->query($rq);
defaultOreonGraph();
......@@ -175,9 +203,13 @@ function updateGraphTemplate($graph_id = null)
}
$rq = "UPDATE giv_graphs_template ";
$rq .= "SET name = ";
isset($ret["name"]) && $ret["name"] != null ? $rq .= "'".htmlentities($ret["name"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, ";
isset($ret["name"]) && $ret["name"] != null
? $rq .= "'" . htmlentities($ret["name"], ENT_QUOTES, "UTF-8") . "', "
: $rq .= "NULL, ";
$rq .= "vertical_label = ";
isset($ret["vertical_label"]) && $ret["vertical_label"] != null ? $rq .= "'".htmlentities($ret["vertical_label"], ENT_QUOTES, "UTF-8")."', ": $rq .= "NULL, ";
isset($ret["vertical_label"]) && $ret["vertical_label"] != null
? $rq .= "'" . htmlentities($ret["vertical_label"], ENT_QUOTES, "UTF-8") . "', "
: $rq .= "NULL, ";
$rq .= "width = ";
isset($ret["width"]) && $ret["width"] != null ? $rq .= "'" . $ret["width"] . "', " : $rq .= "NULL, ";
$rq .= "height = ";
......@@ -185,21 +217,35 @@ function updateGraphTemplate($graph_id = null)
$rq .= "base = ";
isset($ret["base"]) && $ret["base"] != null ? $rq .= "'" . $ret["base"] . "', " : $rq .= "NULL, ";
$rq .= "lower_limit = ";
isset($ret["lower_limit"]) && $ret["lower_limit"] != null ? $rq .= "'".$ret["lower_limit"]."', ": $rq .= "NULL, ";
isset($ret["lower_limit"]) && $ret["lower_limit"] != null
? $rq .= "'" . $ret["lower_limit"] . "', "
: $rq .= "NULL, ";
$rq .= "upper_limit = ";
isset($ret["upper_limit"]) && $ret["upper_limit"] != null ? $rq .= "'".$ret["upper_limit"]."', ": $rq .= "NULL, ";
isset($ret["upper_limit"]) && $ret["upper_limit"] != null
? $rq .= "'" . $ret["upper_limit"] . "', "
: $rq .= "NULL, ";
$rq .= "size_to_max = ";
isset($ret["size_to_max"]) && $ret["size_to_max"] != null ? $rq .= "'".$ret["size_to_max"]."', ": $rq .= "0, ";
isset($ret["size_to_max"]) && $ret["size_to_max"] != null
? $rq .= "'" . $ret["size_to_max"] . "', "
: $rq .= "0, ";
$rq .= "default_tpl1 = ";
isset($ret["default_tpl1"]) && $ret["default_tpl1"] != null ? $rq .= "'".$ret["default_tpl1"]."', ": $rq .= "NULL, ";
isset($ret["default_tpl1"]) && $ret["default_tpl1"] != null
? $rq .= "'" . $ret["default_tpl1"] . "', "
: $rq .= "NULL, ";
$rq .= "split_component = ";
isset($ret["split_component"]) && $ret["split_component"] != null ? $rq .= "'".$ret["split_component"]."', ": $rq .= "NULL, ";
isset($ret["split_component"]) && $ret["split_component"] != null
? $rq .= "'" . $ret["split_component"] . "', "
: $rq .= "NULL, ";
$rq .= "scaled = ";
isset($ret["scaled"]) && $ret["scaled"] != null ? $rq .= "'" . $ret["scaled"] . "', " : $rq .= "'0', ";
$rq .= "stacked = ";
isset($ret["stacked"]) && $ret["stacked"] != null ? $rq .= "'".$ret["stacked"]."', ": $rq .= "NULL, ";
isset($ret["stacked"]) && $ret["stacked"] != null
? $rq .= "'" . $ret["stacked"] . "', "
: $rq .= "NULL, ";
$rq .= "comment = ";
isset($ret["comment"]) && $ret["comment"] != null ? $rq .= "'".htmlentities($ret["comment"], ENT_QUOTES, "UTF-8")."' ": $rq .= "NULL ";
isset($ret["comment"]) && $ret["comment"] != null
? $rq .= "'" . htmlentities($ret["comment"], ENT_QUOTES, "UTF-8") . "' "
: $rq .= "NULL ";
$rq .= "WHERE graph_id = '" . $graph_id . "'";
$pearDB->query($rq);
defaultOreonGraph();
......
......@@ -92,14 +92,19 @@ $form->addElement('text', 'vertical_label', _("Vertical Label"), $attrsText);
$form->addElement('text', 'width', _("Width"), $attrsText2);
$form->addElement('text', 'height', _("Height"), $attrsText2);
$form->addElement('text', 'lower_limit', _("Lower Limit"), $attrsText2);
$form->addElement('text', 'upper_limit', _("Upper Limit"), array('id' => 'upperLimitTxt',
'size' => '6'));
$form->addElement('checkbox', 'size_to_max', _("Size to max"), '', array('id' => 'sizeToMax',
'onClick' => 'sizeToMaxx();'));
$form->addElement('text', 'upper_limit', _("Upper Limit"), array(
'id' => 'upperLimitTxt',
'size' => '6'
));
$form->addElement('checkbox', 'size_to_max', _("Size to max"), '', array(
'id' => 'sizeToMax',
'onClick' => 'sizeToMaxx();'
));
$form->addElement('text', 'ds_name', _("Data Source Name"), $attrsText);
$form->addElement('select', 'base', _("Base"), array("1000" => "1000", "1024" => "1024"));
$periods = array( "10800"=>_("Last 3 Hours"),
$periods = array(
"10800" => _("Last 3 Hours"),
"21600" => _("Last 6 Hours"),
"43200" => _("Last 12 Hours"),
"86400" => _("Last 24 Hours"),
......@@ -113,16 +118,19 @@ $periods = array( "10800"=>_("Last 3 Hours"),
"5184000" => _("Last 2 Months"),
"10368000" => _("Last 4 Months"),
"15552000" => _("Last 6 Months"),
"31104000"=>_("Last Year"));
"31104000" => _("Last Year")
);
$sel = $form->addElement('select', 'period', _("Graph Period"), $periods);
$steps = array( "0"=>_("No Step"),
$steps = array(
"0" => _("No Step"),
"2" => "2",
"6" => "6",
"10" => "10",
"20" => "20",
"50" => "50",
"100"=>"100");
"100" => "100"
);
$sel = $form->addElement('select', 'step', _("Recovery Step"), $steps);
......@@ -162,7 +170,12 @@ $tpl = initSmartyTpl($path, $tpl);
# Just watch
if ($o == "w") {
$form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&graph_id=".$graph_id."'"));
$form->addElement(
"button",
"change",
_("Modify"),
array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&graph_id=" . $graph_id . "'")
);
$form->setDefaults($graph);
$form->freeze();
} elseif ($o == "c") {
......@@ -209,7 +222,15 @@ $tpl->assign('colorJS', "
hcolor = bckcolor.substr(1,6);
}
}
Modalbox.show('./include/common/javascript/color_picker_mb.php?name='+name, { title: '" . _('Pick a color') . "', width: width, height: height , afterLoad: function(){cp_init(t, hcolor);} });
Modalbox.show(
'./include/common/javascript/color_picker_mb.php?name='+name,
{
title: '" . _('Pick a color') . "',
width: width,
height: height ,
afterLoad: function(){cp_init(t, hcolor);}
}
);
}
</script>
");
......@@ -227,7 +248,12 @@ if ($form->validate()) {
updateGraphTemplateInDB($graphObj->getValue());
}
$o = "w";
$form->addElement("button", "change", _("Modify"), array("onClick"=>"javascript:window.location.href='?p=".$p."&o=c&graph_id=".$graphObj->getValue()."'"));
$form->addElement(
"button",
"change",
_("Modify"),
array("onClick" => "javascript:window.location.href='?p=" . $p . "&o=c&graph_id=" . $graphObj->getValue() . "'")
);
$form->freeze();
$valid = true;
}
......
......@@ -68,7 +68,8 @@ $tpl->assign("headerMenu_base", _("Base"));
$tpl->assign("headerMenu_options", _("Options"));
#List
$rq = "SELECT graph_id, name, default_tpl1, vertical_label, base, split_component FROM giv_graphs_template gg $SearchTool ORDER BY name LIMIT ".$num * $limit.", ".$limit;
$rq = "SELECT graph_id, name, default_tpl1, vertical_label, base, split_component " .
"FROM giv_graphs_template gg $SearchTool ORDER BY name LIMIT " . $num * $limit . ", " . $limit;
$res = $pearDB->query($rq);
$form = new HTML_QuickForm('select_form', 'POST', "?p=" . $p);
......@@ -82,15 +83,20 @@ $style = "one";
$elemArr = array();
for ($i = 0; $graph = $res->fetchRow(); $i++) {
$selectedElements = $form->addElement('checkbox', "select[" . $graph['graph_id'] . "]");
$moptions = "<input onKeypress=\"if(event.keyCode > 31 && (event.keyCode < 45 || event.keyCode > 57)) event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[".$graph['graph_id']."]'></input>";
$elemArr[$i] = array("MenuClass"=>"list_".$style,
$moptions = "<input onKeypress=\"if(event.keyCode > 31 && (event.keyCode < 45 || event.keyCode > 57)) " .
"event.returnValue = false; if(event.which > 31 && (event.which < 45 || event.which > 57)) return false;" .
"\" maxlength=\"3\" size=\"3\" value='1' style=\"margin-bottom:0px;\" name='dupNbr[" .
$graph['graph_id'] . "]' />";
$elemArr[$i] = array(
"MenuClass" => "list_" . $style,
"RowMenu_select" => $selectedElements->toHtml(),
"RowMenu_name" => $graph["name"],
"RowMenu_link" => "?p=" . $p . "&o=c&graph_id=" . $graph['graph_id'],
"RowMenu_desc" => $graph["vertical_label"],
"RowMenu_base" => $graph["base"],
"RowMenu_split_component" => $graph["split_component"] ? _("Yes") : _("No"),
"RowMenu_options"=>$moptions);
"RowMenu_options" => $moptions
);
$style != "two" ? $style = "two" : $style = "one";
}
$tpl->assign("elemArr", $elemArr);
......@@ -98,7 +104,10 @@ $tpl->assign("elemArr", $elemArr);
/*
* Different messages we put in the template
*/
$tpl->assign('msg', array ("addL"=>"?p=".$p."&o=a", "addT"=>_("Add"), "delConfirm"=>_("Do you confirm the deletion ?")));
$tpl->assign(
'msg',
array("addL" => "?p=" . $p . "&o=a", "addT" => _("Add"), "delConfirm" => _("Do you confirm the deletion ?"))
);
/*
* Toolbar select
......@@ -112,28 +121,46 @@ function setO(_i) {
<?php
$attrs1 = array(
'onchange' => "javascript: " .
"if (this.form.elements['o1'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" .
"if (this.form.elements['o1'].selectedIndex == 1 && confirm('" .
_("Do you confirm the duplication ?") . "')) {" .
" setO(this.form.elements['o1'].value); submit();} " .
"else if (this.form.elements['o1'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" .
"else if (this.form.elements['o1'].selectedIndex == 2 && confirm('" .
_("Do you confirm the deletion ?") . "')) {" .
" setO(this.form.elements['o1'].value); submit();} " .
"else if (this.form.elements['o1'].selectedIndex == 3) {" .
" setO(this.form.elements['o1'].value); submit();} " .
"");
$form->addElement('select', 'o1', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs1);
""
);
$form->addElement(
'select',
'o1',
null,
array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")),
$attrs1
);
$form->setDefaults(array('o1' => null));
$o1 = $form->getElement('o1');
$o1->setValue(null);
$attrs = array(
'onchange' => "javascript: " .
"if (this.form.elements['o2'].selectedIndex == 1 && confirm('"._("Do you confirm the duplication ?")."')) {" .
"if (this.form.elements['o2'].selectedIndex == 1 && confirm('" .
_("Do you confirm the duplication ?") . "')) {" .
" setO(this.form.elements['o2'].value); submit();} " .
"else if (this.form.elements['o2'].selectedIndex == 2 && confirm('"._("Do you confirm the deletion ?")."')) {" .
"else if (this.form.elements['o2'].selectedIndex == 2 && confirm('" .
_("Do you confirm the deletion ?") . "')) {" .
" setO(this.form.elements['o2'].value); submit();} " .
"else if (this.form.elements['o2'].selectedIndex == 3) {" .
" setO(this.form.elements['o2'].value); submit();} " .
"");
$form->addElement('select', 'o2', null, array(null=>_("More actions..."), "m"=>_("Duplicate"), "d"=>_("Delete")), $attrs);
""
);
$form->addElement(
'select',
'o2',
null,
array(null => _("More actions..."), "m" => _("Duplicate"), "d" => _("Delete")),
$attrs
);
$form->setDefaults(array('o2' => null));
$o2 = $form->getElement('o2');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment