opt_elements = array( 'contenu' => true ); } protected function fetch_data(){ global $lang; if(!$this->id) return false; // les infos générales... $rqt = "select * from cms_articles where id_article ='".$this->id."'"; $res = mysql_query($rqt); if(mysql_num_rows($res)){ $row = mysql_fetch_object($res); $this->num_type = $row->article_num_type; $this->title = $row->article_title; $this->resume = $row->article_resume; $this->contenu = $row->article_contenu; $this->publication_state = $row->article_publication_state; $this->start_date = $row->article_start_date; $this->end_date = $row->article_end_date; $this->num_parent = $row->num_section; $this->create_date = $row->article_creation_date; } if(strpos($this->start_date,"0000-00-00")!== false){ $this->start_date = ""; } if(strpos($this->end_date,"0000-00-00")!== false){ $this->end_date = ""; } $this->get_descriptors(); $this->get_fields_type(); } public function save(){ if($this->id){ $save = "update "; $clause = "where id_article = '".$this->id."'"; }else{ $save = "insert into "; $clause = ""; } $save.= "cms_articles set article_title = '".addslashes($this->title)."', article_resume = '".addslashes($this->resume)."', article_contenu = '".addslashes($this->contenu)."', article_publication_state ='".addslashes($this->publication_state)."', article_start_date = '".addslashes($this->start_date)."', article_end_date = '".addslashes($this->end_date)."', num_section = '".addslashes($this->num_parent)."', article_num_type = '".$this->num_type."' ". (!$this->id ? ",article_creation_date=sysdate() " :"")." $clause"; mysql_query($save); if(!$this->id) $this->id = mysql_insert_id(); //au tour des descripteurs... //on commence par tout retirer... $del = "delete from cms_articles_descriptors where num_article = '".$this->id."'"; mysql_query($del); for($i=0 ; $idescriptors) ; $i++){ $rqt = "insert into cms_articles_descriptors set num_article = '".$this->id."', num_noeud = '".$this->descriptors[$i]."',article_descriptor_order='".$i."'"; mysql_query($rqt); } //et maintenant le logo... $this->save_logo(); //enfin les éléments du type de contenu $type_fields = new cms_editorial_parametres_perso($this->num_type); $type_fields->rec_fields_perso($this->id,$this->type); $this->maj_indexation(); } public function get_parent_selector(){ $opts.=$this->_recurse_parent_select(); return $opts; } protected function _recurse_parent_select($parent=0,$lvl=0){ global $charset; global $msg; $opts = ""; $rqt = "select id_section, section_title from cms_sections where section_num_parent = '".$parent."'"; $res = mysql_query($rqt); if(mysql_num_rows($res)){ while($row = mysql_fetch_object($res)){ $opts.=" "; $opts.=$this->_recurse_parent_select($row->id_section,$lvl+1); } } return $opts; } public function update_parent_section($num_section){ $this->num_section = $num_section; $update = "update cms_articles set num_section ='".$num_section."' where id_article = '".$this->id."'"; mysql_query($update); } protected function is_deletable(){ return true; } public function format_datas(){ $parent = new cms_section($this->num_parent); return array( 'id' => $this->id, 'parent' => $parent->format_datas(false,false), 'title' => $this->title, 'resume' => $this->resume, 'logo' => array( 'small_vign' => $this->logo->get_vign_url("small_vign"), 'vign' =>$this->logo->get_vign_url("vign"), 'large' =>$this->logo->get_vign_url("large") ), 'publication_state' => $this->publication_state, 'start_date' => format_date($this->start_date), 'end_date' => format_date($this->end_date), 'descriptors' => $this->descriptors, 'content' => $this->contenu, 'type' => $this->type_content, 'fields_type' => $this->fields_type, 'create_date' => $this->create_date ); } public static function get_format_data_structure(){ return cms_editorial::get_format_data_structure("article"); } }