Permalink
Browse files

update

  • Loading branch information...
1 parent 82b799a commit a63ade507713d6e4abbf2afa352ce39b15ef6b26 @williamjxj committed Dec 7, 2012
Showing with 118 additions and 35 deletions.
  1. +5 −0 f1.php
  2. +39 −13 f12Class.php
  3. +61 −12 f1Class.php
  4. +3 −3 templates/1/category_contents.tpl.html
  5. +10 −7 templates/1/item_contents.tpl.html
View
5 f1.php 100644 → 100755
@@ -33,12 +33,14 @@
exit ;
}
elseif (isset($_GET['cate_id'])) {
+ if (isset($_SESSION[PACKAGE]['cate_item'])) unset($_SESSION[PACKAGE]['cate_item']);
$list = $obj -> get_category_contents($_GET['cate_id']);
// $obj -> __p($list);
$obj -> assign('list', $list);
$obj -> assign('cc_template', $tdir1 . 'category_contents.tpl.html');
}
elseif (isset($_GET['iid'])) {
+ if (isset($_SESSION[PACKAGE]['cate_item'])) unset($_SESSION[PACKAGE]['cate_item']);
$list = $obj -> get_item_contents($_GET['iid']);
$obj -> assign('list', $list);
$obj -> assign('ic_template', $tdir1 . 'item_contents.tpl.html');
@@ -113,6 +115,9 @@
die("Error, no http request at: [" . __FILE__ . '], line ' . __LINE__);
}
+$pagination = $obj -> draw();
+$obj -> assign("pagination", $pagination);
+
$obj -> assign('_th', $obj -> get_header_label($header));
$obj -> assign('_tf', $obj -> get_footer_label($footer));
View
52 f12Class.php 100644 → 100755
@@ -103,9 +103,7 @@ function draw()
$queryURL .= '&' . $key . '=' . $value;
}
}
- //foreach($_SESSION[PACKAGE][SEARCH] as $k=$v) {
- // $queryURL .= '&' . $k . '=' . urlencode($v);
- //}
+
if (($total_pages) > 1) {
if ($current_page != 1) {
$links[] = '<a href="?page=1' . $queryURL . '">&laquo;&laquo; 首页 </a>';
@@ -132,6 +130,37 @@ function draw()
}
}
+ function draw_cate_item()
+ {
+ $current_page = isset($_SESSION[PACKAGE]['cate_item']['page']) ? $_SESSION[PACKAGE]['cate_item']['page'] : 1;
+ $total_pages = isset($_SESSION[PACKAGE]['cate_item']['total_pages']) ? $_SESSION[PACKAGE]['cate_item']['total_pages'] : 1;
+ $links = array();
+ if (($total_pages) > 1) {
+ if ($current_page != 1) {
+ $links[] = '<a href="?page=1">&laquo;&laquo; 首页 </a>';
+ $links[] = '<a href="?page=' . ($current_page - 1) . '">&laquo; 前页</a>';
+ }
+
+ for ($j = ($current_page - 4); $j < ($current_page + 4); $j++) {
+ if ($j < 1)
+ continue;
+ if ($j > $total_pages)
+ break;
+ if ($current_page == $j) {
+ $links[] = '<a href="javascript:;">' . $j . '</a>';
+ } else {
+ $links[] = '<a href="?page=' . $j . '">' . $j . '</a>';
+ }
+ }
+
+ if ($current_page < $total_pages) {
+ $links[] = '<a href="?page=' . ($current_page + 1) . '"> 下页 &raquo; </a>';
+ $links[] = '<a href="?page=' . ($total_pages) . '"> 末页 &raquo;&raquo; </a>';
+ }
+ return $links;
+ }
+ }
+
//还有用,网友在查。
function get_key_related($q) {
$sql = "select rid, rk, kurl from key_related where keyword like '%" . mysql_real_escape_string($q) . "%' order by rand() limit 0, " . TAB_LIST;
@@ -147,33 +176,30 @@ function get_content_1($cid) {
$sql = "select * from contents where cid=" . $cid;
$res = mysql_query($sql);
$row = mysql_fetch_assoc($res);
- //if(mysql_num_rows($res)>0) $_SESSION[PACKAGE][SEARCH]['title']=htmlspecialchars($row['title']);
- // $this->__p($_SESSION);
mysql_free_result($res);
return $row;
}
- //应该没有用了。
function select_contents_by_page() {
//计算共有多少页?
- $total_pages = isset($_SESSION[PACKAGE][SEARCH]['total_pages']) ? $_SESSION[PACKAGE][SEARCH]['total_pages'] : 1;
+ $total_pages = isset($_SESSION[PACKAGE]['cate_item']['total_pages']) ? $_SESSION[PACKAGE]['cate_item']['total_pages'] : 1;
$page = isset($_GET['page']) ? $_GET['page'] : 1;
if ($page > $total_pages)
$page = $total_pages;
if ($page < 1)
$page = 1;
- $_SESSION[PACKAGE][SEARCH]['page'] = $page;
+ $_SESSION[PACKAGE]['cate_item']['page'] = $page;
- //当前从第几条记录开始显示?
+ //当前从第几条记录开始显示?
$row_no = ((int)$page - 1) * ROWS_PER_PAGE;
//生成新的查询语句.
- if (preg_match("/limit/i", $_SESSION[PACKAGE][SEARCH]['sql']))
- $_SESSION[PACKAGE][SEARCH]['sql'] = preg_replace("/limit.*$/i", '', $_SESSION[PACKAGE][SEARCH]['sql']);
+ if (preg_match("/limit/i", $_SESSION[PACKAGE]['cate_item']['sql']))
+ $_SESSION[PACKAGE]['cate_item']['sql'] = preg_replace("/limit.*$/i", '', $_SESSION[PACKAGE]['cate_item']['sql']);
- $sql = $_SESSION[PACKAGE][SEARCH]['sql'];
+ $sql = $_SESSION[PACKAGE]['cate_item']['sql'];
$sql .= " limit " . $row_no . "," . ROWS_PER_PAGE;
- $_SESSION[PACKAGE][SEARCH]['sql'] = $sql;
+ $_SESSION[PACKAGE]['cate_item']['sql'] = $sql;
$ary = array();
$res = mysql_query($sql);
View
73 f1Class.php 100644 → 100755
@@ -137,10 +137,27 @@ public function get_news_label($footer) {
return $this -> _get_label($footer);
}
- function get_category_contents($cate_id) {
+ function get_category_contents($cate_id)
+ {
$sql = "select cid, title, url, pubdate, author, source, clicks, tags, likes, fandui, guanzhu, pinglun,
category, cate_id, item, iid, created
from contents where language='" . $this -> lang . "' and cate_id=$cate_id order by cid desc limit 0,".ROWS_PER_PAGE;
+
+ if(!isset($_SESSION[PACKAGE]['cate_item']) || empty($_SESSION[PACKAGE]['cate_item']['total_pages'])) {
+ $total = $this->get_category_count($cate_id);
+ $total_pages = ceil($total / ROWS_PER_PAGE);
+ $_SESSION[PACKAGE]['cate_item']['total'] = $total;
+ $_SESSION[PACKAGE]['cate_item']['total_pages'] = $total_pages;
+
+ $_SESSION[PACKAGE]['cate_item']['page'] = 1;
+ $_SESSION[PACKAGE]['cate_item']['sql'] = $sql;
+ }
+ elseif(isset($_GET['page']))
+ $_SESSION[PACKAGE]['cate_item']['page'] = $_GET['page'];
+
+ $this->__p($_SESSION[PACKAGE]);
+ exit;
+
$res = $this -> mdb2 -> queryAll($sql, '', MDB2_FETCHMODE_ASSOC);
if (PEAR::isError($res))
die($res -> getMessage());
@@ -152,16 +169,20 @@ function get_category_contents($cate_id) {
return $res;
}
- function assemble_sitemap($sm) {
- $info = array();
- if (preg_match("/English/i", $this -> lang)) {
- $info['title'] = $sm[1];
- $info['content'] = "Currently this model is under developing, will be ready shortly.<br>\n";
- } else {
- $info['title'] = $sm[0];
- $info['content'] = "目前该分类还处在开发阶段,很快就会有内容呈现。谢谢关注。<br>\n";
- }
- return $info;
+ function get_category_count($cate_id) {
+ $sql = "select count(*) from contents where cate_id =" . $cate_id;
+ $res = mysql_query($sql);
+ $row = mysql_fetch_row($res);
+ mysql_free_result($res);
+ return $row[0];
+ }
+
+ function get_item_count($iid) {
+ $sql = "select count(*) from items where iid=" . $iid;
+ $res = mysql_query($sql);
+ $row = mysql_fetch_row($res);
+ mysql_free_result($res);
+ return $row[0];
}
//////////////// Items ////////////////
@@ -180,11 +201,27 @@ function get_items($cate_id = 0) {
return $res;
}
- function get_item_contents($iid) {
+ function get_item_contents($iid)
+ {
$sql = "select cid, title, url, pubdate, author, source, clicks, tags, likes, fandui, guanzhu, pinglun,
category, cate_id, item, iid, created
from contents where language='" . $this -> lang . "' and iid=$iid order by iid desc limit 0, ".ROWS_PER_PAGE;
+ if(!isset($_SESSION[PACKAGE]['cate_item']) || empty($_SESSION[PACKAGE]['cate_item']['total_pages'])) {
+ $total = $this->get_category_count($cate_id);
+ $total_pages = ceil($total / ROWS_PER_PAGE);
+ $_SESSION[PACKAGE]['cate_item']['total'] = $total;
+ $_SESSION[PACKAGE]['cate_item']['total_pages'] = $total_pages;
+
+ $_SESSION[PACKAGE]['cate_item']['page'] = 1;
+ $_SESSION[PACKAGE]['cate_item']['sql'] = $sql;
+ }
+ elseif(isset($_GET['page']))
+ $_SESSION[PACKAGE]['cate_item']['page'] = $_GET['page'];
+
+ $this->__p($_SESSION[PACKAGE]);
+ exit;
+
$res = $this -> mdb2 -> queryAll($sql, '', MDB2_FETCHMODE_ASSOC);
if (PEAR::isError($res))
die($res -> getMessage());
@@ -193,6 +230,18 @@ function get_item_contents($iid) {
return $res;
}
+
+ function assemble_sitemap($sm) {
+ $info = array();
+ if (preg_match("/English/i", $this -> lang)) {
+ $info['title'] = $sm[1];
+ $info['content'] = "Currently this model is under developing, will be ready shortly.<br>\n";
+ } else {
+ $info['title'] = $sm[0];
+ $info['content'] = "目前该分类还处在开发阶段,很快就会有内容呈现。谢谢关注。<br>\n";
+ }
+ return $info;
+ }
// NO USE.
function get_item_list($cate_id)
{
@@ -14,7 +14,7 @@
<tr>
<th>序号</th>
<th>标题</th>
- <th>时间</th>
+ <th>日期</th>
<th>归类</th>
<th>阅览次数</th>
<th>赞成</th>
@@ -27,13 +27,13 @@
<tr>
<td><span class="badge badge-warning">{$count++}</span></td>
<td><a href="{$config.f7.s}?cid={$l.cid}">{$l.title}</a></td>
- <td>{$l.pubdate|default:'N/A'|date_format:"%Y-%m-%d %H:%M"}</td>
+ <td>{$l.pubdate|default:'N/A'|date_format:"%Y-%m-%d"}</td>
<td><a href="{$config.f1.s}?iid={$l.iid}">{$l.item}</a></td>
<td>{$l.clicks}</td>
<td>{$l.likes}</td>
<td>{$l.guanzhu}</td>
<td>{$l.pinglun}</td>
- <td>{$l.created|date_format:"%Y-%m-%d %H:%M"}}</td>
+ <td>{$l.created|date_format:"%Y-%m-%d %H:%M"}</td>
<td><a class="talk" href="{$config.f7.s}?cid={$l.cid}#Tab3"><i class="icon-comment"></i>我要PK</a>&nbsp;&nbsp; <i class="icon-list"></i><a class="talk
fancybox.ajax" href="{$config.f1.s}?js_get_content=1&cid={$l.cid}">预览</a> </td>
</tr>
@@ -14,22 +14,25 @@
<tr>
<th>序号</th>
<th>标题</th>
- <th>时间</th>
+ <th>日期</th>
<th>阅览次数</th>
- <th>关注度</th>
+ <th>赞成</th>
+ <th>反对</th>
<th>总评论</th>
+ <th>归档时间</th>
<th>选项</th>
</tr>
{foreach $list as $l}
<tr>
<td><span class="badge badge-warning">{$count++}</span></td>
<td><a href="{$config.f7.s}?cid={$l.cid}">{$l.title}</a></td>
- <td>{$l.pubdate|default:'N/A'|date_format:"%Y-%m-%d %H:%M"}</td>
+ <td>{$l.pubdate|default:'N/A'|date_format:"%Y-%m-%d"}</td>
<td>{$l.clicks}</td>
+ <td>{$l.likes}</td>
<td>{$l.guanzhu}</td>
<td>{$l.pinglun}</td>
- <td><a class="talk" href="{$config.f7.s}?cid={$l.cid}#Tab3"><i class="icon-comment"></i>我要PK</a>&nbsp;&nbsp; <i class="icon-list"></i><a class="talk
- fancybox.ajax" href="{$config.f1.s}?js_get_content=1&cid={$l.cid}">预览</a> </td>
+ <td>{$l.created|date_format:"%Y-%m-%d %H:%M"}</td>
+ <td><a class="talk" href="{$config.f7.s}?cid={$l.cid}#Tab3"><i class="icon-comment"></i>我要PK</a>&nbsp;&nbsp; <i class="icon-list"></i> <a class="talk fancybox.ajax" href="{$config.f1.s}?js_get_content=1&cid={$l.cid}">预览</a> </td>
</tr>
{/foreach}
</table>
@@ -38,8 +41,8 @@
<script type="text/javascript">
$(function() {
$('a.talk').fancybox({
- maxWidth : 1000,
- maxHeight : 800,
+ maxWidth : 1400,
+ maxHeight : 1200,
fitToView : false,
width : '85%',
height : '85%',

0 comments on commit a63ade5

Please sign in to comment.