index 445a42a92eed0ce79fe7230a0bc07039197c63d6..daf4f5bf0d408dc64e83b5f2f5e5cbbdbe3d654c 100644 (file)
function sieve_if($elements,$object_id,$parent)
{
$this->parent = $parent;
+ $this->object_id = $object_id;
/* Possible address parts we can select */
$this->address_parts = array(
"gt" => _("greater than"),
"ne" => _("not equal"));
- $this->object_id = $object_id;
- if($elements!=NULL){
- $this->elements = $elements;
- $this->_parsed = $this->_parse($elements['ELEMENTS'],1);
+ /* Skip parsing if this element is new */
+ if($elements != NULL){
+
+ /* Remove comments from tests */
+ $tmp = array();
+ foreach($elements['ELEMENTS'] as $ele){
+ if($ele['class'] != "comment"){
+ $tmp[] = $ele;
+ }
+ }
+ $elements['ELEMENTS'] = $tmp;
+
+ if($elements!=NULL){
+ $this->elements = $elements;
+ $this->_parsed = $this->_parse($elements['ELEMENTS'],1);
+ }
}
}
$parsed = $this->_parsed;
}
+ if($parsed == NULL) {
+ return(array(_("Can't save empty tests.")));
+ }
+
/* Walk through all elements */
foreach($parsed as $key => $data){
$parsed = $this->_parsed;
}
- if(!is_array($parsed)) return;
+ if(!is_array($parsed)) {
+ return;
+ }
/* Walk through all elements */
foreach($parsed as $key => $data){
if(!isset($match_types[$mt])){
$parsed[$key]['LastError'] = _("Invalid match type given.");
}
+ if($mt == ":regex"){
+ $this->parent->add_require("regex");
+ }
+ if($mt == ":count"){
+ $this->parent->add_require("comparator-i;ascii-numeric");
+ }
$parsed[$key]['Match_type'] = $mt;
}
$tmp2 = split(",",$vls);
foreach($tmp2 as $val){
- $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\"";
+ $tmp[] = trim($val);
+
+ if(preg_match("/\"/",$val)){
+ $parsed[$key]['LastError'] = _("Invalid character found in address attribute. Quotes are not allowed here.");
+ }
}
$parsed[$key]['Key_List'] = $tmp;
}
$tmp2 = split(",",$vls);
foreach($tmp2 as $val){
- $tmp[] = "\"".trim(preg_replace("/\"/","",$val))."\"";
+ $tmp[] = trim($val);
+ if(preg_match("/\"/",$val)){
+ $parsed[$key]['LastError'] = _("Invalid character found in value attribute. Quotes are not allowed here.");
+ }
}
$parsed[$key]['Value_List'] = $tmp;
}
$Match_types = array( ":over" => _("greater than") ,
":under" => _("lower than"));
- $Units = array( "M" => _("Megabyte") ,
- "K" => _("Kilobyte"));
+ $Units = array( "M" => _("Megabyte"),
+ "K" => _("Kilobyte"),
+ "" => _("Bytes"));
/* Toggle Inverse ? */
if(isset($_POST['toggle_inverse_'.$element_id])){
$smarty = get_smarty();
$smarty->assign("ID", $this->object_id);
- /* Only display navigation elements if necessary */
- if($this->TYPE == "if"){
- $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
- }else{
- $object_container = $smarty->fetch(get_template_path("templates/object_container_clear.tpl",TRUE,dirname(__FILE__)));
- }
+ /* Get navigation element container */
+ $object_container = $smarty->fetch(get_template_path("templates/object_container.tpl",TRUE,dirname(__FILE__)));
$smarty->assign("Name", $name);
$smarty->assign("Contents", $this->get_as_html());
$smarty->assign("ID" , $element_id);
$str = $smarty->fetch(get_template_path("templates/element_address.tpl",TRUE,dirname(__FILE__)));
$ret .= $str;
- echo htmlentities($str);
break;
}
$Match_types = array( ":over" => _("greater than") ,
":under" => _("lower than"));
- $Units = array( "M" => _("Megabyte") ,
- "K" => _("Kilobyte"));
+ $Units = array( "M" => _("Megabyte"),
+ "K" => _("Kilobyte"),
+ "" => _("Bytes"));
$Match_type = $data['Match_type'];
$Value = preg_replace("/[^0-9]/","",$data['Value_List'][0]);
$smarty->assign("DisplayAdd",TRUE);
$smarty->assign("DisplayDel",FALSE);
$cont_tmp = $smarty->fetch(get_template_path("templates/object_test_container.tpl",TRUE,dirname(__FILE__)));
- $cont_tmp = preg_replace("/%%OBJECT_CONTENT%%/",_("Click here to add a new test"),$cont_tmp);
+ $cont_tmp = preg_replace("/%%OBJECT_CONTENT%%/","<b>"._("Click here to add a new test")."</b>",$cont_tmp);
$smarty->assign("Inverse",$Inverse);
$smarty->assign("Contents",$cont_tmp.$Contents);