clsParsedItem(); $this->tablename = GetTablePrefix()."SearchConfig"; $this->id_field = "SearchConfigId"; $this->NoResourceId=1; $this->TagPrefix="searchfield"; if($id) $this->LoadFromDatabase($id); } function LoadFromDatabase($Id) { global $Errors; if(!isset($Id)) { $Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase"); return false; } $sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ".$this->IdField()." = '%s'",$Id); $result = $this->adodbConnection->Execute($sql); if ($result === false) { $Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"LoadFromDatabase"); return false; } $data = $result->fields; $this->SetFromArray($data); $this->Clean(); return true; } function GetWhereClause($verb,$value) { //$value = $this->adodbConnection->qstr(stripslashes($value)); $where = ""; if(strlen($this->Get("ForeignField"))>0) { $field = $this->Get("ForeignField"); } else $field = $this->Get("FieldName"); switch($verb) { case "is": if(strlen($this->Get("IsWhere"))) { $where = str_replace("{Value}",$value,$this->Get("IsWhere")); } else $where = $field." = '".$value."'"; break; case "isnot": if(strlen($this->Get("IsNotWhere"))) { $where = str_replace("{Value}",$value,$this->Get("IsNotWhere")); } else $where = $field." != '".$value."'"; break; case "contains": if(strlen($this->Get("ContainsWhere"))) { $where = str_replace("{Value}",$value,$this->Get("ContainsWhere")); } else $where = $field." LIKE '%".$value."%'"; break; case "notcontains": if(strlen($this->Get("NotContainsWhere"))) { $where = str_replace("{Value}",$value,$this->Get("NotContainsWhere")); } else $where = $field." NOT LIKE '%".$value."%'"; break; } return $where; } function ParseObject($element) { global $objConfig, $objSession, $objUsers, $objCatList, $var_list_update, $var_list, $bb_var_list_update, $m_var_list_update,$FormValues; $extra_attribs = ExtraAttributes($element->attributes); if(strtolower($element->name)==$this->TagPrefix) { $field = strtolower($element->attributes["_field"]); switch($field) { case "name": $ret = $this->Get("FieldName"); break; case "lang_name": $ret = language($this->Get("DisplayName")); break; case "id": $ret = $this->Get("SearchConfigId"); break; case "header": $hdr = $this->Get("ConfigHeader"); if(strlen($hdr)) $ret = language($hdr); break; case "table": $ret = $this->Get("TableName"); break; case "simple": $ret = (int)$this->Get("SimpleSearch"); if($ret) { if(strlen($element->attributes["_text"])) $ret = language($element->attributes["_text"]); if(strlen($element->attributes["_plaintext"])) $ret = $element->attributes["_plaintext"]; } break; case "advanced": $ret = (int)$this->Get("AdvancedSearch"); if($ret) { if(strlen($element->attributes["_text"])) $ret = language($element->attributes["_text"]); if(strlen($element->attributes["_plaintext"])) $ret = $element->attributes["_plaintext"]; } break; case "verb_select": $datatype = $this->Get("FieldType"); switch($datatype) { case "text": $fieldname = "verb[".$this->Get("FieldName")."]"; $ret = ""; break; case "boolean": $ret = ""; break; } break; case "form_input": $datatype = $this->Get("FieldType"); $name = $this->Get("FieldName"); switch($datatype) { case "text": $ret = ""; break; case "boolean": $ret = "
"; print_r($f); echo ""; $f->Set("SimpleSearch",(int)$SimpleSearch); $f->Set("AdvancedSearch",(int)$AdvancedSearch); $f->Set("Priority",(int)$Priority); $f->Update(); return $f; } function &AddSearchField($Table,$FieldName,$Module,$Simple,$Adv,$Description,$DisplayName,$ConfigHeader,$DisplayOrder=0, $Priority=0,$FieldType="text",$JoinClause=NULL,$IsWhere=NULL,$IsNotWhere=NULL,$ContainsWhere=NULL,$NotContainsWhere=NULL,$CustomId=0, $ForeignField = NULL) { $f = new clsSearchConfig(); if($DisplayOrder==0) $DisplayOrder = $this->GetNextDisplayOrder($Module); $f->Set(Array("TableName","ModuleName","SimpleSearch","AdvancedSearch","Description","DisplayName","ConfigHeader", "DisplayOrder","Priority","FieldType","FieldName", "ForeignField"), Array($Table,$Module,$Simple,$Adv,$Description,$DisplayName,$ConfigHeader,$DisplayOrder,$Priority,$FieldType,$FieldName, $ForeignField)); $f->Set("CustomFieldId",$CustomId); if(strlen($JoinClause)) $f->Set("JoinClause",$JoinClause); if(strlen($IsWhere)) $f->Set("IsWhere",$IsWhere); if(strlen($IsNotWhere)) $f->Set("IsNotWhere",$IsNotWhere); if(strlen($ContainsWhere)) $f->Set("ContainsWhere",$ContainsWhere); if(strlen($NotContainsWhere)) $f->Set("NotContainsWhere",$NotContainsWhere); $f->Create(); return $f; } function GetHeadingList() { $res = array(); foreach($this->Items as $i) { $header = $i->Get("ConfigHeader"); $res[$header]=1; } reset($res); return array_keys($res); } function GetHeadingItems($heading) { $res = array(); foreach($this->Items as $i) { if($i->Get("ConfigHeader")==$heading) array_push($res,$i); } return $res; } } ?>