/**
  * 	@access	public
  * 	@see	http://essfeed.org/index.php/ESS_structure
  * 	@param	Array	Array of data that represent the first elements of the feed.
  *
  * 	@return void;
  */
 function __construct($data_ = NULL, $CHARSET = 'UTF-8', $REPLACE_ACCENT = FALSE)
 {
     $this->CHARSET = $CHARSET;
     // Defines the document encoding Charset (Default UTF-8).
     $this->REPLACE_ACCENT = $REPLACE_ACCENT;
     // Defines if the ASCI accent have to be remplaced (Default FALSE).
     $this->rootDTD = EssDTD::getRootDTD();
     $this->feedDTD = EssDTD::getFeedDTD();
     foreach ($this->feedDTD as $key => $value) {
         $this->elements[$key] = array();
     }
     if ($data_ != NULL && count($data_) > 0) {
         foreach ($this->rootDTD as $elementName => $mandatory) {
             if ($mandatory == TRUE && strlen($data_[$elementName]) <= 0) {
                 throw new Exception("Error: Event element " . $elementName . " is mandatory.", 1);
             }
         }
         foreach ($data_ as $tagTest => $value) {
             $isFound = FALSE;
             if (in_array(strtolower($tagTest), $this->rootDTD)) {
                 $isFound = TRUE;
             }
             if ($isFound == FALSE) {
                 throw new Exception("Error: Event XML element < " . $tagTest . " > is not specified in ESS Feed DTD.");
             }
         }
         foreach ($data_ as $tag => $value) {
             if ($tag != 'tag') {
                 $this->roots[$tag] = $value;
             } else {
                 if (is_array($value)) {
                     $this->roots[$tag] = $value;
                 } else {
                     throw new Exception("Error: Element < tag > must be of 'Array' type.");
                 }
             }
         }
     }
 }
 public static function get_categories_types()
 {
     $cat_ = EssDTD::getFeedDTD();
     return @count($cat_) > 0 ? $cat_['categories']['types'] : NULL;
 }
 /**
  * FeedWriter Class Constructor
  *
  * @access 	public
  * @param  	String 	[OPTIONAL] 2 chars language (ISO 3166-1) definition for the current feed.
  * @param  	Array 	[OPTIONAL] array of event's feed tags definition.
  * @return 	void
  */
 function __construct($lang = 'en', $data_ = NULL)
 {
     if (function_exists('set_error_handler')) {
         set_error_handler(array('FeedWriter', 'error_handler'));
     }
     $channelDTD = EssDTD::getChannelDTD();
     // DTD Array of Channel first XML child elements.
     $this->lang = strlen($lang) == 2 ? strtolower($lang) : $this->lang;
     $this->setGenerator('ess:php:generator:version:' . self::LIBRARY_VERSION);
     $mandatoryRequiredCount = 0;
     $mandatoryCount = 0;
     if ($data_ != NULL) {
         if (count($data_) > 0) {
             foreach ($data_ as $key => $el) {
                 switch ($key) {
                     case 'title':
                         $this->setTitle($el);
                         if ($channelDTD[$key] == TRUE) {
                             $mandatoryCount++;
                         }
                         break;
                     case 'link':
                         $this->setLink($el);
                         if ($channelDTD[$key] == TRUE) {
                             $mandatoryCount++;
                         }
                         $mandatoryCount++;
                         break;
                         // + element ID
                     // + element ID
                     case 'published':
                         $this->setPublished($el);
                         if ($channelDTD[$key] == TRUE) {
                             $mandatoryCount++;
                         }
                         break;
                     case 'updated':
                         $this->setUpdated($el);
                         if ($channelDTD[$key] == TRUE) {
                             $mandatoryCount++;
                         }
                         break;
                     case 'generator':
                         $this->setGenerator($el);
                         if ($channelDTD[$key] == TRUE) {
                             $mandatoryCount++;
                         }
                         break;
                     case 'rights':
                         $this->setRights($el);
                         if ($channelDTD[$key] == TRUE) {
                             $mandatoryCount++;
                         }
                         break;
                     default:
                         throw new Exception("Error: XML Channel element < " . $key . " > is not defined within ESS DTD.");
                         break;
                 }
             }
             foreach ($channelDTD as $kk => $val) {
                 if ($val == TRUE && $kk != 'feed') {
                     $mandatoryRequiredCount++;
                 }
             }
             if ($mandatoryRequiredCount != $mandatoryCount || $mandatoryCount == 0) {
                 $out = '';
                 foreach ($channelDTD as $key => $m) {
                     if ($m == TRUE) {
                         $out .= "< {$key} >, ";
                     }
                 }
                 throw new Exception("Error: All XML Channel's mandatory elements are required: " . $out);
             }
         }
     }
 }