Ejemplo n.º 1
0
 /**
  * Returns a xml-based representation of a single news.
  * Return format:
  *    <news>
  *        <title></title>
  *        <systemid></systemid>
  *        <intro></intro>
  *        <text></text>
  *        <image></image>
  *        <categories></categories>
  *        <startdate></startdate>
  *        <enddate></enddate>
  *        <archivedate></archivedate>
  *    </news>
  *
  * @return string
  * @xml
  */
 protected function actionNewsDetails()
 {
     $strReturn = "";
     $objNews = new class_module_news_news($this->getSystemid());
     $arrCats = class_module_news_category::getNewsMember($objNews->getSystemid());
     array_walk($arrCats, function (class_module_news_category &$objValue) {
         $objValue = $objValue->getSystemid();
     });
     if ($objNews->rightView()) {
         $strReturn .= " <news>\n";
         $strReturn .= "   <title>" . xmlSafeString($objNews->getStrTitle()) . "</title>";
         $strReturn .= "   <systemid>" . $objNews->getSystemid() . "</systemid>";
         $strReturn .= "   <intro>" . xmlSafeString($objNews->getStrIntro()) . "</intro>";
         $strReturn .= "   <text>" . xmlSafeString($objNews->getStrText()) . "</text>";
         $strReturn .= "   <image>" . xmlSafeString($objNews->getStrImage()) . "</image>";
         $strReturn .= "   <categories>" . xmlSafeString(implode(",", $arrCats)) . "</categories>";
         $strReturn .= "   <startdate>" . xmlSafeString($objNews->getObjStartDate() != null ? $objNews->getObjStartDate()->getTimeInOldStyle() : "") . "</startdate>";
         $strReturn .= "   <enddate>" . xmlSafeString($objNews->getObjEndDate() != null ? $objNews->getObjEndDate()->getTimeInOldStyle() : "") . "</enddate>";
         $strReturn .= "   <archivedate>" . xmlSafeString($objNews->getObjDateSpecial() != null ? $objNews->getObjDateSpecial()->getTimeInOldStyle() : "") . "</archivedate>";
         $strReturn .= " </news>\n";
     } else {
         $strReturn = "<error>" . $this->getLang("commons_error_permissions") . "</error>";
     }
     return $strReturn;
 }