get_storages_list(); $this->fetch_datas(); } protected function fetch_datas(){ $query = "select * from storages order by storage_name"; $result = pmb_mysql_query($query); $this->defined_list = array(); if(pmb_mysql_num_rows($result)){ while($row = pmb_mysql_fetch_object($result)){ $this->defined_list[] = array( 'id' => $row->id_storage, 'name' => $row->storage_name, 'class' => $row->storage_class, 'params' => unserialize($row->storage_params) ); } } } protected function get_storages_list(){ global $class_path; global $charset,$msg; $xml = new DOMDocument(); if(file_exists($class_path."/storages/storages_subst.xml")){ $file = $class_path."/storages/storages_subst.xml"; }else{ $file = $class_path."/storages/storages.xml"; } $xml->load($file); $storages = $xml->getElementsByTagName("storage"); for($i=0 ; $i<$storages->length ; $i++){ $storage = array(); $storage['class'] = ($charset != "utf-8" ? utf8_decode($storages->item($i)->getAttribute('class')) : $storages->item($i)->getAttribute('class')); $storage['label'] = ($charset != "utf-8" ? utf8_decode($storages->item($i)->nodeValue) : $storages->item($i)->nodeValue); if(substr($storage['label'],0,4) == "msg:"){ $storage['label'] = $msg[substr($storage['label'],4)]; } $this->list[] = $storage; } } public function get_item_form($id=0){ global $charset,$msg; $form = "

".htmlentities($msg['storage_form_title'],ENT_QUOTES,$charset)."

 
"; $id+=0; $form.="
"; return $form; } public static function get_storage_class($id){ global $base_path,$include_path,$class_path; $query = "select storage_class from storages where id_storage = ".($id*1); $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ $row = pmb_mysql_fetch_object($result); require_once($class_path."/storages/".$row->storage_class.".class.php"); $obj = new $row->storage_class($id); return $obj; } return false; } public function get_form($type,$id){ global $charset,$msg; $form = "

".htmlentities($msg['storage_form_title'],ENT_QUOTES,$charset)."

 
"; $id+=0; $row =array(); if($id){ $query ="select * from storages where storage_object_type = '".$type."' and storage_num_object = '".$id."'"; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ $row = pmb_mysql_fetch_assoc($result); } } $form.="
"; if($row['storage_class']){ $form.= $this->get_params_form($row['storage_class'],$row['storage_params']); } $form.= "
 
"; return $form; } public function save_form($type,$id){ global $storage_method,$storage_params; $id+=0; $row =array(); if($id){ $query ="select * from storages where storage_object_type = '".$type."' and storage_num_object = '".$id."'"; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ $row = pmb_mysql_fetch_assoc($result); } } if($row['id_storage']){ $query = "update storages set "; $clause =" where id_storage = ".$row['id_storage']; }else{ $query = "insert into storages set "; $clause= ""; } if($storage_method){ $query.= "storage_object_type = '".$type."', storage_num_object = '".$id."',storage_class = '".$storage_method."', storage_params = '".addslashes(serialize($storage_params))."'"; }else if ($row['id_storage']){ $query ="delete from storages"; } pmb_mysql_query($query.$clause); } public function get_params_form($class_name,$params=array()){ global $base_path,$include_path,$class_path; $exists = false; foreach($this->list as $storage){ if($class_name == $storage['class']){ $exists =true; break; } } if($exists){ require_once($class_path."/storages/".$class_name.".class.php"); $storage = new $class_name($params); return $storage->get_params_form(); } return ""; } }