id = $id+0;
parent::__construct();
}
protected function fetch_datas(){
if($this->id){
//on commence par aller chercher ses infos
$query = " select id_cadre_content, cadre_content_hash, cadre_content_num_cadre, cadre_content_data from cms_cadre_content where id_cadre_content = ".$this->id;
$result = mysql_query($query);
if(mysql_num_rows($result)){
$row = mysql_fetch_object($result);
$this->id = $row->id_cadre_content+0;
$this->hash = $row->cadre_content_hash;
$this->cadre_parent = $row->cadre_content_num_cadre+0;
$this->unserialize($row->cadre_content_data);
}
}
}
public function save_form(){
$this->get_hash();
if($this->id){
$query = "update cms_cadre_content set";
$clause = " where id_cadre_content=".$this->id;
}else{
$query = "insert into cms_cadre_content set";
$clause = "";
}
$query.= "
cadre_content_hash = '".$this->hash."',
cadre_content_type = 'view',
cadre_content_object = '".$this->class_name."',".
($this->cadre_parent ? "cadre_content_num_cadre = ".$this->cadre_parent."," : "")."
cadre_content_data = '".addslashes($this->serialize())."'
".$clause;
$result = mysql_query($query);
if($result){
if(!$this->id){
$this->id = mysql_insert_id();
}
//on supprime les anciennes vues...
$query = "delete from cms_cadre_content where id_cadre_content != ".$this->id." and cadre_content_type='view' and cadre_content_num_cadre = ".$this->cadre_parent;
mysql_query($query);
return true;
}
return false;
}
public function set_cadre_parent($id){
$this->cadre_parent = $id+0;
}
/*
* Méthode de suppression
*/
public function delete(){
if($this->id){
//on commence par éliminer les sous-éléments associé (sait-on jamais...)
$query = "select id_cadre_content,cadre_content_object from cms_cadre_content where cadre_content_num_cadre_content = ".$this->id;
$result = mysql_query($query);
if(mysql_num_rows($result)){
while($row = mysql_fetch_object($result)){
$sub_elem = new $row->cadre_content_object($row->id_cadre_content);
$success = $sub_elem->delete();
if(!$success){
//TODO verbose mode
return false;
}
}
}
//on est tout seul, éliminons-nous !
$query = "delete from cms_cadre_content where id_cadre_content = ".$this->id;
$result = mysql_query($query);
if($result){
$this->delete_hash();
return true;
}else{
return false;
}
}
}
public function get_form(){
return "";
}
public function render($datas){
return "";
}
public function get_headers(){
global $lang;
$headers = array();
if($this->use_jquery){
$headers[] = "";
$headers[] = "";
}
if($this->use_dojo){
$headers[] = "";
$headers[]= "
";
$headers[]= "";
$headers[]= "
";
}
return $headers;
}
public function set_module_class_name($module_class_name){
$this->module_class_name = $module_class_name;
$this->fetch_managed_datas();
}
protected function fetch_managed_datas(){
parent::fetch_managed_datas("views");
}
protected function get_exported_datas(){
$infos = parent::get_exported_datas();
$infos['type'] = "view";
return $infos;
}
public function get_format_data_structure(){
return array();
}
}