*/ protected $_main = array ( 'mandatory' => array ( 'title' => null, 'link' => null, 'description' => null), 'optionnal' => array ( 'language' => null, 'copyright' => null, 'managingEditor' => null, 'webMaster' => null, 'pubDate' => null, 'lastBuildDate' => null, 'category' => null, 'generator' => null, 'docs' => null, 'cloud' => array ( 'mandatory' => array ( '_domain' => null, '_port' => null, '_path' => null, '_registerProcedure' => null, '_protocol' => null ) ), 'ttl' => null, 'image' => array ( 'mandatory' => array ( 'image' => null, 'url' => null, 'link' => null ), 'optionnal' => array ( 'height' => null, 'width' => null, 'description' => null ) ), 'rating' => null, 'textInput' => array ( 'mandatory' => array ( 'title' => null, 'description' => null, 'name' => null, 'link' => null ) ), 'skipHours' => null, 'skipDays' => null)); /** * Array containing the XSL stylesheets links */ private $_xsl = array (); /** * Class constructor * * @param array * @return void */ function __construct ($attributes = array()) { $this->_xml_base_node_name = 'rss'; $this->_xml_base_node_name_attributes = array ( 'version' => '2.0'); $this->_xml_main_node_name = 'channel'; parent::__construct ($attributes); $this->set ('language', $this->_lang); } /** * Generate the content and send it * Errors are managed * @return boolean true if generation is ok, else false */ final public function output () { $this->_headSent = false; $this->_httpHeaders['Content-Type'] = 'application/rss+xml; charset=' . $this->_charset; $this->sendHttpHeaders (); $this->_outputXmlHeader (); $this->_headSent = true; // $this->_outputOptionals(); $this->_deleteOptionnalEmptyNodes (); print $this->_xml_dom->saveXML(); if ($this->hasErrors ()) { echo $this->getFormatedErrorMsg (); } return true; } final public function outputErrors() { if (!$this->_headSent) { if ($this->_sendHttpHeader) { header('Content-Type: text/xml;charset='.$this->_charset); } echo '_charset .'"?>'; } echo ''; if ($this->hasErrors()) { echo $this->getFormatedErrorMsg(); } else { echo 'Unknow Error'; } echo ''; } /** * Format error messages * @return string formated errors */ protected function getFormatedErrorMsg(){ $errors = ''; foreach ($GLOBALS['gJCoord']->errorMessages as $e) { // FIXME : Pourquoi utiliser htmlentities() ? $errors .= ''.htmlentities($e[2], ENT_NOQUOTES, $this->_charset). ''. "\n"; } return $errors; } public function addOptionals($content) { if (is_array($content)) { $this->_optionals = $content; } } public function addXSLStyleSheet($src, $params=array ()) { if (!isset($this->_xsl[$src])){ $this->_xsl[$src] = $params; } } public function addItem ($item) { $this->_item_list[] = new jRSSItem ( $this->_xml_dom, $this->_xml_main_node, $item); } protected function _outputXmlHeader() { // XSL stylesheet foreach ($this->_xsl as $src => $params) { //the extra params we may found in there. $more = ''; foreach ($params as $param_name => $param_value) { $more .= $param_name.'="'. htmlspecialchars($param_value).'" '; } echo ' '; } } protected function _outputOptionals() { if (is_array($this->_optionals)) { foreach ($this->_optionals as $name => $value) { echo '<'. $name .'>'. $value .'', "\n"; } } } } class jRSSItem extends jXMLFeedItem { /** * elements in */ protected $_item = array ( 'mandatory' => array ( 'title' => null, 'description' => null), 'optionnal' => array ( 'link' => null, 'author' => null, 'category' => array ( 'optionnal' => array ( '_domain' => null)), 'comments' => null, 'enclosure' => array ( 'optionnal' => array ( '_url' => null, '_length' => null, '_type' => null)), 'guid' => array ( 'optionnal' => array ( '_isPermaLink' => null)), 'docs' => null, 'pubDate' => null, 'source' => array ( 'optionnal' => array ( '_url' => null)))); function __construct ( $DOMDocument, $parentNode, $dataArray) { $this->_xml_item_node = 'item'; parent::__construct ( $DOMDocument, $parentNode, $dataArray); } } ?>