Exemplo n.º 1
0
 /**
  * Generates a rss-node-structure from the passed log-node-structure
  * @param string $objLogRootNode
  * @return SimpleXMLElement
  */
 public function generateRssNodesFromLogContent($strLogRootNode)
 {
     $objFeedRootNode = new SimpleXMLElement("<rss version=\"2.0\"></rss>");
     $objChannel = $objFeedRootNode->addChild("channel");
     $objChannel->addChild("title", $this->objConfig->getStrFeedTitle());
     $objChannel->addChild("description", $this->objConfig->getStrFeedDescription());
     $objChannel->addChild("link", $this->objConfig->getStrSvnUrl());
     $objChannel->addChild("pubDate", date("r", time()));
     //build a xml-tree out of the passed svn-log-content
     libxml_use_internal_errors();
     $objSimpleXmlElement = simplexml_load_string($strLogRootNode);
     $arrParseErrors = libxml_get_errors();
     libxml_clear_errors();
     if (count($arrParseErrors) > 0) {
         throw new Svn2RssException("Error parsing xml-based svn log content.\nErrors:\n" . implode("\n", $arrParseErrors));
     }
     foreach ($objSimpleXmlElement->logentry as $objOneLogEntry) {
         $arrObjAttributes = $objOneLogEntry->attributes();
         $objRssItemNode = $objChannel->addChild("item");
         //prepare log-message
         $strDescription = $objOneLogEntry->msg . "";
         //include changed files?
         if ($this->objConfig->getBitFeedWithChangedFiles()) {
             $strDescription .= "\n\n";
             foreach ($objOneLogEntry->paths->path as $objOnePath) {
                 $objPathAttributes = $objOnePath->attributes();
                 $strDescription .= $objPathAttributes->action . " " . $objOnePath . "\n";
             }
         }
         $strDescription = html_entity_decode($strDescription, ENT_COMPAT, "UTF-8");
         $strDetailsLink = SVN2RSS_WEB_ROOT . "?feed=" . $this->objConfig->getStrConfigSetName() . "&revision=" . $arrObjAttributes->revision;
         //but: encode &, <, >
         $strDescription = nl2br($this->xmlSafeString($strDescription));
         $strDetailsLink = $this->xmlSafeString($strDetailsLink);
         //title, description, logdate
         $objRssItemNode->addChild("title", $arrObjAttributes->revision . " by " . $objOneLogEntry->author);
         $objDescNode = $objRssItemNode->addChild("description", $strDescription);
         //$objRssItemNode->addChild("pubDate", $objOneLogEntry->date."");
         $objRssItemNode->addChild("pubDate", date("r", strtotime($objOneLogEntry->date)) . "");
         $objGuidNode = $objRssItemNode->addChild("guid", $arrObjAttributes->revision . "");
         $objGuidNode->addAttribute("isPermaLink", "false");
         $objRssItemNode->addChild("link", $strDetailsLink);
     }
     return $objFeedRootNode;
 }