Example #1
0
 private static function &get_article_from_row($row, $get_fields = 'PUBLIC')
 {
     if (!is_array($row)) {
         return;
     }
     $article = new news_article();
     foreach ($row as $key => $value) {
         switch ($key) {
             case 'news_id':
                 $article->id = $value;
                 break;
             case 'news_category_id':
                 $article->category_id = $value;
                 break;
             case 'news_title':
                 $article->title = $value;
                 break;
             case 'news_data':
                 $article->content = $value;
                 break;
             case 'news_date':
                 $article->postdate = $value;
                 break;
             case 'summary':
                 $article->summary = $value;
             case 'start_time':
                 $article->startdate = $value;
                 break;
             case 'end_time':
                 $article->enddate = $value;
                 break;
             case 'status':
                 $article->status = $value;
                 break;
             case 'create_date':
                 $article->create_date = $value;
                 break;
             case 'modified_date':
                 $article->modified_date = $value;
                 break;
             case 'author_id':
                 $article->author_id = $value;
                 break;
             case 'news_extra':
                 $article->extra = $value;
                 break;
             case 'news_url':
                 $article->news_url = $value;
                 break;
         }
     }
     if ($get_fields && $get_fields != 'NONE' && $article->id) {
         self::preloadFieldData($article->id);
         $fields = self::get_fields($article->id);
         if (count($fields)) {
             foreach ($fields as $field) {
                 $article->set_field($field);
             }
         }
     }
     return $article;
 }
 private static function &get_article_from_row($row, $get_fields = 'PUBLIC')
 {
     if (!is_array($row)) {
         return;
     }
     $article = new news_article();
     foreach ($row as $key => $value) {
         switch ($key) {
             case 'news_id':
                 $article->id = $value;
                 break;
             case 'news_category_id':
                 $article->category_id = $value;
                 break;
             case 'news_title':
                 $article->title = $value;
                 break;
             case 'news_data':
                 $article->content = $value;
                 break;
             case 'news_date':
                 $article->postdate = $value;
                 break;
             case 'summary':
                 $article->summary = $value;
             case 'start_time':
                 $article->startdate = $value;
                 break;
             case 'end_time':
                 $article->enddate = $value;
                 break;
             case 'status':
                 $article->status = $value;
                 break;
             case 'create_date':
                 $article->create_date = $value;
                 break;
             case 'modified_date':
                 $article->modified_date = $value;
                 break;
             case 'author_id':
                 $article->author_id = $value;
                 break;
             case 'news_extra':
                 $article->extra = $value;
                 break;
             case 'news_url':
                 $article->news_url = $value;
                 break;
         }
     }
     if ($get_fields && $get_fields != 'NONE' && $article->id) {
         // get the fields.
         $fields = self::get_category_names_by_id();
         $query = 'SELECT A.value,B.id,B.name,B.type FROM ' . cms_db_prefix() . 'module_news_fieldvals A, ' . cms_db_prefix() . 'module_news_fielddefs B 
               WHERE A.fielddef_id = B.id AND A.news_id = ?';
         $qparms = array($article->id);
         if ($get_fields == 'PUBLIC') {
             $query .= ' AND B.public = 1';
         }
         $query .= ' ORDER BY B.item_order';
         $db = cmsms()->GetDb();
         $dbr = $db->GetArray($query, $qparms);
         if (is_array($dbr)) {
             foreach ($dbr as $row) {
                 $field = self::get_field_from_row($row);
                 $article->set_field($field);
             }
         }
     }
     return $article;
 }