/** * Set a Feed element * * @access public * @see http://essfeed.org/index.php/ESS_structure * @param String name of the feed tag. * @param String content of the feed tag. * @return void */ private function setRootElement($elementName, $content) { $CDATA = array('description'); if (is_string($content) && !in_array($elementName, $CDATA)) { $content = FeedValidator::xml_entities($content, $this->CHARSET); } $this->roots[$elementName] = $content; }
/** * Creates a single node as xml format * * @access private * @param String name of the tag * @param Mixed tag value as string or array of nested tags in 'tagName' => 'tagValue' format * @param Array Attributes(if any) in 'attrName' => 'attrValue' format * @return String formatted XML tag */ private function makeNode($tagName, $tagContent, $attributes = NULL) { $CDATA = array('description'); // Names of the tags to be displayed with <[CDATA[...]]>. $nodeText = ''; $attrText = ''; if (is_array($attributes)) { foreach ($attributes as $key => $value) { if (strlen($value) > 0) { $attrText .= " {$key}=\"{$value}\" "; } } } $nodeText .= $this->t(2) . (in_array($tagName, $CDATA) ? "<{$tagName}{$attrText}>" . self::LN . $this->t(3) . "<![CDATA[" . self::LN : "<{$tagName}{$attrText}>"); if (is_array($tagContent)) { if (isset($value) || $value == 0) { $nodeText .= $this->t(4) . $this->makeNode($key, self::REPLACE_ACCENT ? FeedValidator::xml_entities(FeedValidator::noAccent($value, self::CHARSET), self::CHARSET) : $value); } } else { if (in_array($tagName, $CDATA) || $tagName == 'published' || $tagName == 'updated' || $tagName == 'value') { $nodeText .= $tagContent; } else { if ($tagName == 'start') { $nodeText .= self::getISODate($tagContent); } else { if ($tagName == 'link' || $tagName == 'uri') { $nodeText .= htmlspecialchars($tagContent, ENT_QUOTES, self::CHARSET, FALSE); } else { $nodeText .= FeedValidator::xml_entities(FeedValidator::noAccent($tagContent, self::CHARSET), self::CHARSET); } } } } $nodeText .= in_array($tagName, $CDATA) ? self::LN . $this->t(3) . "]]>" . self::LN . $this->t(3) . "</{$tagName}>" : "</{$tagName}>"; return $nodeText . self::LN; }