Example #1
0
 /**
  * Create structure for templates
  * 
  * @param SJB_NewsArticle $article
  * @return array:
  */
 public static function createTemplateStructureForNewsArticle($article)
 {
     $articleInfo = parent::getObjectInfo($article);
     if (is_null(self::$uploadFileManager)) {
         self::$uploadFileManager = new SJB_UploadFileManager();
     }
     foreach ($article->getProperties() as $property) {
         if ($property->isComplex()) {
             $isPropertyEmpty = true;
             $properties = $property->type->complex->getProperties();
             $properties = is_array($properties) ? $properties : array();
             foreach ($properties as $subProperty) {
                 if (!empty($articleInfo['user_defined'][$property->getID()][$subProperty->getID()]) && is_array($articleInfo['user_defined'][$property->getID()][$subProperty->getID()])) {
                     foreach ($articleInfo['user_defined'][$property->getID()][$subProperty->getID()] as $subValue) {
                         if (!empty($subValue)) {
                             $isPropertyEmpty = false;
                         }
                     }
                 }
             }
             if ($isPropertyEmpty) {
                 $articleInfo['user_defined'][$property->getID()] = '';
             }
         }
     }
     $structure = array('sid' => $articleInfo['system']['id'], 'id' => $articleInfo['system']['id'], 'date' => $articleInfo['system']['date'], 'expiration_date' => $articleInfo['system']['expiration_date'], 'active' => $articleInfo['system']['active'], 'image_link' => self::$uploadFileManager->getUploadedFileLink($articleInfo['system']['image']));
     if (!empty($articleInfo['system']['subuser_sid'])) {
         $structure['subuser'] = SJB_UserManager::getUserInfoBySID($articleInfo['system']['subuser_sid']);
     }
     $structure['METADATA'] = array('date' => array('type' => 'date'), 'expiration_date' => array('type' => 'date'));
     $structure = array_merge($structure, $articleInfo['user_defined']);
     $structure['METADATA'] = array_merge($structure['METADATA'], parent::getObjectMetaData($article));
     return array_merge($structure, $articleInfo['user_defined']);
 }