$articleid = isset($params['articleid']) ? $params['articleid'] : -1; $cache_id = 'nd' . md5(serialize($params)); $compile_id = 'nd' . $articleid; $template = 'detail' . $this->GetPreference('current_detail_template'); if (isset($params['detailtemplate'])) { $template = 'detail' . $params['detailtemplate']; } if ($id == '_preview_' && isset($_SESSION['news_preview']) && isset($params['preview'])) { // see if our data matches. if (md5(serialize($_SESSION['news_preview'])) == $params['preview']) { $fname = TMP_CACHE_LOCATION . '/' . $_SESSION['news_preview']['fname']; if (file_exists($fname) && md5_file($fname) == $_SESSION['news_preview']['checksum']) { $data = unserialize(file_get_contents($fname)); if (is_array($data)) { // get passed data into a standard format. $article = new news_article(); $article->set_linkdata($id, $params); news_ops::fill_article_from_formparams($article, $data, FALSE, FALSE); $compile_id = 'news_preview_' . time(); $preview = TRUE; } } } } if ($preview || !$smarty->isCached($this->GetDatabaseResource($template), $cache_id, $compile_id)) { // not cached... have to do to the work. if (isset($params['articleid']) && $params['articleid'] == -1) { $article = news_ops::get_latest_article(); } else { if (isset($params['articleid']) && (int) $params['articleid'] > 0) { $show_expired = $this->GetPreference('expired_viewable', 1);
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; }