title_fields = array_merge(array( "title" => $this->msg['cms_module_timeline_datasource_articles_title'] ), $this->get_perso_fields('text', 'small_text')); /** Le champs résumé + les champs de type text large unique **/ $this->resume_fields = array_merge(array( "resume" => $this->msg['cms_module_timeline_datasource_articles_resume'] ), $this->get_perso_fields('text', 'text')); /** Le champs résumé + les champs de type text large unique **/ $this->image_fields = array_merge(array( "logo" => $this->msg['cms_module_timeline_datasource_articles_logo'] ), $this->get_perso_fields('url', 'text')); $this->date_fields = array_merge(array( "start_date" => $this->msg['cms_module_timeline_datasource_articles_start_date'], "end_date" => $this->msg['cms_module_timeline_datasource_articles_end_date'], "create_date" => $this->msg['cms_module_timeline_datasource_articles_create_date'] ), $this->get_perso_fields('date_box', 'date')); } protected function get_full_values($ids){ $events = array(); foreach($ids as $id){ $article = new cms_article($id); $event = []; if(!empty($this->parameters['timeline_fields'])){ foreach($this->parameters['timeline_fields'] as $field_name => $field_value){ if (!empty($field_value)) { if (strpos($field_value, 'c_perso') !== false) { $field_value = explode('c_perso_', $field_value)[1]; $event[$field_name] = $this->get_cp_value($field_value, $id); } else if ($field_value == 'logo') { $event[$field_name] = $article->logo->get_vign_url('vign'); } else { $event[$field_name] = $article->{$field_value}; } } } } $events[] = $event; } return $events; } protected function get_perso_fields($type, $datatype){ $data = array(); $query = 'select name, titre, idchamp, num_type, editorial_type_element from cms_editorial_custom join cms_editorial_types on cms_editorial_custom.num_type = cms_editorial_types.id_editorial_type where cms_editorial_custom.datatype = "'.$datatype.'" and cms_editorial_custom.type="'.$type.'" and cms_editorial_types.editorial_type_element in ("article", "article_generic")'; $result = pmb_mysql_query($query); if(pmb_mysql_num_rows($result)){ while($row = pmb_mysql_fetch_assoc($result)){ $data['c_perso_'.$row['name']] = $row['titre']; $num_type = $row['num_type']; if ($row['editorial_type_element'] == 'article_generic') { $num_type = 0; } if (!isset($this->cp_persos_by_type[$num_type])) { $this->cp_persos_by_type[$num_type] = array(); } $this->cp_persos_by_type[$num_type][] = 'c_perso_'.$row['name']; } } return $data; } public function get_form(){ $form = parent::get_form(); $form.= ' '; return $form; } }