public function show(MyTpl $tpl) { if (outputErrMsg()) { return; } global $setting, $news_cat, $cat_idx; $tpl->Set_Variable('template', $setting['gen']['template']); $tpl->Set_Variable('web_title', $setting['web']['title']); $tpl->Set_Variable('web_url', $setting['web']['url']); $tpl->Set_Variable('web_email', $setting['web']['email']); $tpl->Set_Variable('rss_link', $setting['rewrite']['enable'] ? "rss.xml" : "rss.php?cat=" . $cat_idx); $tpl->Set_Variable('page_keywords', $setting['web']['keyword']); $tpl->Set_Variable('page_description', $setting['web']['description']); $tpl->Set_Variable('charset', $setting['gen']['charset']); $tpl->Set_Variable('last_modify', date("Y-m-d H:i:s")); $this->pushAddedContent($tpl, "start", "end"); $max_count = count($news_cat); for ($i = 0; $i < $max_count; $i++) { if ($news_cat[$i]['cat_layer'] == 1 && $news_cat[$i]['web_id'] == $setting['info']['web']['web_id']) { if (($news_cat[$i]['cat_show'] & 1) != 1) { continue; } if (empty($news_cat[$i]['cat_link'])) { $news_cat[$i]['cat_link'] = getUrl("list", $news_cat[$i]['cat_idx'], 1, $setting['info']['web']['web_id']); } $tpl->Set_Loop('news_cat', $news_cat[$i]); } } if (count(ob_list_handlers()) == 0 && !headers_sent()) { ob_start(); } echo $tpl->Get_Content('$db, $setting', $setting['gen']['minify']); unset($tpl); }
public static function api_rss($id = 0, $mode = "cat") { global $setting, $db; $cat_id = ""; if ($mode == "cat") { if ($cat_info = getParaInfo("news_cat", "cat_id", $id)) { $web_info = getSubSetting($cat_info['web_id']); $cat_id = $id; } else { $web_info = getSubSetting($setting['info']['web']['web_id']); } } else { $web_info = getSubSetting($id); } $charset_tag = '<?xml version="1.0" encoding="' . $setting['gen']['charset'] . '"?>' . "\n"; $tpl_info = array("idx" => "rss", "style" => "../plugin/" . basename(realpath(dirname(__FILE__))) . "/tpl/", "path" => ROOT_PATH . "/" . $setting['path']['template']); $tpl = new MyTpl(); $tpl->init($tpl_info); $tpl->Set_Variable('web_title', $setting['web']['title']); $tpl->Set_Variable('web_url', $setting['web']['url']); $tpl->Set_Variable('web_email', $setting['web']['email']); $tpl->Set_Variable('page_keywords', $setting['web']['keyword']); $tpl->Set_Variable('page_description', $setting['web']['description']); $tpl->Set_Variable('charset_tag', $charset_tag); $tpl->Set_Variable('cat_txt', $cat_txt); $tpl->Set_Variable('now', date("r")); $condition = array(); if (!empty($cat_id)) { $condition[] = array("cat_id", "n=", $cat_id); } $db->select(array(array("name" => $web_info['db']['name'] . "." . $web_info['db']['pre'] . "news_show", "idx" => "a", "col" => "*", "condition" => $condition), array("name" => $setting['db']['pre'] . "news_cat", "idx" => "b", "col" => "cat_name", "join" => "cat_id")), array(), array("limit" => $setting['list']['rss'])); while ($record = $db->GetRS()) { $record['link'] = getUrl("read", array($record['news_id'], $record['cat_idx']), 1, $record['web_id']); $record['add_date'] = date("r", strtotime($record['add_date'])); $tpl->Set_Loop("record", $record); } $db->Free(); header('Content-Type: application/rss+xml; charset=' . $setting['gen']['charset']); return $tpl->Get_Content('$db, $setting'); }