parameters= array(); $this->parameters['nb_max_elements'] = $cms_module_common_datasource_rss_limit+0; return parent::save_form(); } public function get_form(){ $form = parent::get_form(); $form.= "
"; return $form; } /* * Récupération des données de la source... */ public function get_datas(){ //on commence par récupérer l'identifiant retourné par le sélecteur... if($this->parameters['selector'] != ""){ for($i=0 ; $iselectors) ; $i++){ if($this->selectors[$i]['name'] == $this->parameters['selector']){ $selector = new $this->parameters['selector']($this->selectors[$i]['id']); break; } } @ini_set("zend.ze1_compatibility_mode", "0"); $rss = new domDocument(); $information = array(); $loaded = $rss->load($selector->get_value()); if($loaded){ //les infos sur le flux... $channel = $rss->getElementsByTagName("channel")->item(0); $elements = array( 'title', 'description', 'generator', 'link' ); $informations = $this->get_informations($channel,$elements,1); //on va lire les infos des items... $informations['items'] =array(); $items = $rss->getElementsByTagName("item"); $elements = array( 'title', 'description', 'link', 'guid', 'date', 'creator', 'subject', 'format', 'language', ); for($i=0 ; $i<$items->length ; $i++){ if($this->parameters['nb_max_elements']==0 || $i < $this->parameters['nb_max_elements']){ $informations['items'][]=$this->get_informations($items->item($i),$elements,false); } } } @ini_set("zend.ze1_compatibility_mode", "1"); return $informations; } return false; } protected function get_informations($node,$elements,$first_only=false){ global $charset; $informations = array(); foreach($elements as $element){ $items = $node->getElementsByTagName($element); if($items->length == 1 || $first_only){ $informations[$element] = $this->charset_normalize($items->item(0)->nodeValue,"utf-8"); }else{ for($i=0 ; $i<$items->length ; $i++){ $informations[$element][] = $this->charset_normalize($items->item($i)->nodeValue,"utf-8"); } } } return $informations; } public function get_format_data_structure(){ return array( array( 'var' => "title", 'desc' => $this->msg['cms_module_common_datasource_rss_title_desc'] ), array( 'var' => "description", 'desc' => $this->msg['cms_module_common_datasource_rss_description_desc'] ), array( 'var' => "generator", 'desc' => $this->msg['cms_module_common_datasource_rss_generator_desc'] ), array( 'var' => "link", 'desc' => $this->msg['cms_module_common_datasource_rss_link_desc'] ), array( 'var' => "items", 'desc' => $this->msg['cms_module_common_datasource_rss_items_desc'], 'children' => array( array( 'var' => "items[i].title", "desc" => $this->msg['cms_module_common_datasource_rss_item_title_desc'] ), array( 'var' => "items[i].description", "desc" => $this->msg['cms_module_common_datasource_rss_item_description_desc'] ), array( 'var' => "items[i].link", "desc" => $this->msg['cms_module_common_datasource_rss_item_link_desc'] ), array( 'var' => "items[i].guid", "desc" => $this->msg['cms_module_common_datasource_rss_item_guid_desc'] ), array( 'var' => "items[i].date", "desc" => $this->msg['cms_module_common_datasource_rss_item_date_desc'] ), array( 'var' => "items[i].creator", "desc" => $this->msg['cms_module_common_datasource_rss_item_creator_desc'] ), array( 'var' => "items[i].subject", "desc" => $this->msg['cms_module_common_datasource_rss_item_subject_desc'] ), array( 'var' => "items[i].format", "desc" => $this->msg['cms_module_common_datasource_rss_item_format_desc'] ), array( 'var' => "items[i].language", "desc" => $this->msg['cms_module_common_datasource_rss_item_language_desc'] ) ) ), ); } }