Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
williamjxj committed Dec 7, 2012
1 parent 82b799a commit a63ade5
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 35 deletions.
5 changes: 5 additions & 0 deletions f1.php
100644 → 100755
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@
exit ; exit ;
} }
elseif (isset($_GET['cate_id'])) { elseif (isset($_GET['cate_id'])) {
if (isset($_SESSION[PACKAGE]['cate_item'])) unset($_SESSION[PACKAGE]['cate_item']);
$list = $obj -> get_category_contents($_GET['cate_id']); $list = $obj -> get_category_contents($_GET['cate_id']);
// $obj -> __p($list); // $obj -> __p($list);
$obj -> assign('list', $list); $obj -> assign('list', $list);
$obj -> assign('cc_template', $tdir1 . 'category_contents.tpl.html'); $obj -> assign('cc_template', $tdir1 . 'category_contents.tpl.html');
} }
elseif (isset($_GET['iid'])) { elseif (isset($_GET['iid'])) {
if (isset($_SESSION[PACKAGE]['cate_item'])) unset($_SESSION[PACKAGE]['cate_item']);
$list = $obj -> get_item_contents($_GET['iid']); $list = $obj -> get_item_contents($_GET['iid']);
$obj -> assign('list', $list); $obj -> assign('list', $list);
$obj -> assign('ic_template', $tdir1 . 'item_contents.tpl.html'); $obj -> assign('ic_template', $tdir1 . 'item_contents.tpl.html');
Expand Down Expand Up @@ -113,6 +115,9 @@
die("Error, no http request at: [" . __FILE__ . '], line ' . __LINE__); 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('_th', $obj -> get_header_label($header));
$obj -> assign('_tf', $obj -> get_footer_label($footer)); $obj -> assign('_tf', $obj -> get_footer_label($footer));


Expand Down
52 changes: 39 additions & 13 deletions f12Class.php
100644 → 100755
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ function draw()
$queryURL .= '&' . $key . '=' . $value; $queryURL .= '&' . $key . '=' . $value;
} }
} }
//foreach($_SESSION[PACKAGE][SEARCH] as $k=$v) {
// $queryURL .= '&' . $k . '=' . urlencode($v);
//}
if (($total_pages) > 1) { if (($total_pages) > 1) {
if ($current_page != 1) { if ($current_page != 1) {
$links[] = '<a href="?page=1' . $queryURL . '">&laquo;&laquo; 首页 </a>'; $links[] = '<a href="?page=1' . $queryURL . '">&laquo;&laquo; 首页 </a>';
Expand All @@ -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) { 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; $sql = "select rid, rk, kurl from key_related where keyword like '%" . mysql_real_escape_string($q) . "%' order by rand() limit 0, " . TAB_LIST;
Expand All @@ -147,33 +176,30 @@ function get_content_1($cid) {
$sql = "select * from contents where cid=" . $cid; $sql = "select * from contents where cid=" . $cid;
$res = mysql_query($sql); $res = mysql_query($sql);
$row = mysql_fetch_assoc($res); $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); mysql_free_result($res);
return $row; return $row;
} }


//应该没有用了。
function select_contents_by_page() { 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; $page = isset($_GET['page']) ? $_GET['page'] : 1;
if ($page > $total_pages) if ($page > $total_pages)
$page = $total_pages; $page = $total_pages;
if ($page < 1) if ($page < 1)
$page = 1; $page = 1;
$_SESSION[PACKAGE][SEARCH]['page'] = $page; $_SESSION[PACKAGE]['cate_item']['page'] = $page;


//当前从第几条记录开始显示? //当前从第几条记录开始显示?
$row_no = ((int)$page - 1) * ROWS_PER_PAGE; $row_no = ((int)$page - 1) * ROWS_PER_PAGE;


//生成新的查询语句. //生成新的查询语句.
if (preg_match("/limit/i", $_SESSION[PACKAGE][SEARCH]['sql'])) if (preg_match("/limit/i", $_SESSION[PACKAGE]['cate_item']['sql']))
$_SESSION[PACKAGE][SEARCH]['sql'] = preg_replace("/limit.*$/i", '', $_SESSION[PACKAGE][SEARCH]['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; $sql .= " limit " . $row_no . "," . ROWS_PER_PAGE;
$_SESSION[PACKAGE][SEARCH]['sql'] = $sql; $_SESSION[PACKAGE]['cate_item']['sql'] = $sql;


$ary = array(); $ary = array();
$res = mysql_query($sql); $res = mysql_query($sql);
Expand Down
73 changes: 61 additions & 12 deletions f1Class.php
100644 → 100755
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -137,10 +137,27 @@ public function get_news_label($footer) {
return $this -> _get_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, $sql = "select cid, title, url, pubdate, author, source, clicks, tags, likes, fandui, guanzhu, pinglun,
category, cate_id, item, iid, created 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; 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); $res = $this -> mdb2 -> queryAll($sql, '', MDB2_FETCHMODE_ASSOC);
if (PEAR::isError($res)) if (PEAR::isError($res))
die($res -> getMessage()); die($res -> getMessage());
Expand All @@ -152,16 +169,20 @@ function get_category_contents($cate_id) {
return $res; return $res;
} }


function assemble_sitemap($sm) { function get_category_count($cate_id) {
$info = array(); $sql = "select count(*) from contents where cate_id =" . $cate_id;
if (preg_match("/English/i", $this -> lang)) { $res = mysql_query($sql);
$info['title'] = $sm[1]; $row = mysql_fetch_row($res);
$info['content'] = "Currently this model is under developing, will be ready shortly.<br>\n"; mysql_free_result($res);
} else { return $row[0];
$info['title'] = $sm[0]; }
$info['content'] = "目前该分类还处在开发阶段,很快就会有内容呈现。谢谢关注。<br>\n";
} function get_item_count($iid) {
return $info; $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 //////////////// //////////////// Items ////////////////
Expand All @@ -180,11 +201,27 @@ function get_items($cate_id = 0) {
return $res; 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, $sql = "select cid, title, url, pubdate, author, source, clicks, tags, likes, fandui, guanzhu, pinglun,
category, cate_id, item, iid, created category, cate_id, item, iid, created
from contents where language='" . $this -> lang . "' and iid=$iid order by iid desc limit 0, ".ROWS_PER_PAGE; 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); $res = $this -> mdb2 -> queryAll($sql, '', MDB2_FETCHMODE_ASSOC);
if (PEAR::isError($res)) if (PEAR::isError($res))
die($res -> getMessage()); die($res -> getMessage());
Expand All @@ -193,6 +230,18 @@ function get_item_contents($iid) {
return $res; 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. // NO USE.
function get_item_list($cate_id) function get_item_list($cate_id)
{ {
Expand Down
6 changes: 3 additions & 3 deletions templates/1/category_contents.tpl.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<tr> <tr>
<th>序号</th> <th>序号</th>
<th>标题</th> <th>标题</th>
<th>时间</th> <th>日期</th>
<th>归类</th> <th>归类</th>
<th>阅览次数</th> <th>阅览次数</th>
<th>赞成</th> <th>赞成</th>
Expand All @@ -27,13 +27,13 @@
<tr> <tr>
<td><span class="badge badge-warning">{$count++}</span></td> <td><span class="badge badge-warning">{$count++}</span></td>
<td><a href="{$config.f7.s}?cid={$l.cid}">{$l.title}</a></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><a href="{$config.f1.s}?iid={$l.iid}">{$l.item}</a></td>
<td>{$l.clicks}</td> <td>{$l.clicks}</td>
<td>{$l.likes}</td> <td>{$l.likes}</td>
<td>{$l.guanzhu}</td> <td>{$l.guanzhu}</td>
<td>{$l.pinglun}</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 <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> fancybox.ajax" href="{$config.f1.s}?js_get_content=1&cid={$l.cid}">预览</a> </td>
</tr> </tr>
Expand Down
17 changes: 10 additions & 7 deletions templates/1/item_contents.tpl.html
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,22 +14,25 @@
<tr> <tr>
<th>序号</th> <th>序号</th>
<th>标题</th> <th>标题</th>
<th>时间</th> <th>日期</th>
<th>阅览次数</th> <th>阅览次数</th>
<th>关注度</th> <th>赞成</th>
<th>反对</th>
<th>总评论</th> <th>总评论</th>
<th>归档时间</th>
<th>选项</th> <th>选项</th>
</tr> </tr>
{foreach $list as $l} {foreach $list as $l}
<tr> <tr>
<td><span class="badge badge-warning">{$count++}</span></td> <td><span class="badge badge-warning">{$count++}</span></td>
<td><a href="{$config.f7.s}?cid={$l.cid}">{$l.title}</a></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.clicks}</td>
<td>{$l.likes}</td>
<td>{$l.guanzhu}</td> <td>{$l.guanzhu}</td>
<td>{$l.pinglun}</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 <td>{$l.created|date_format:"%Y-%m-%d %H:%M"}</td>
fancybox.ajax" href="{$config.f1.s}?js_get_content=1&cid={$l.cid}">预览</a> </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> </tr>
{/foreach} {/foreach}
</table> </table>
Expand All @@ -38,8 +41,8 @@
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
$('a.talk').fancybox({ $('a.talk').fancybox({
maxWidth : 1000, maxWidth : 1400,
maxHeight : 800, maxHeight : 1200,
fitToView : false, fitToView : false,
width : '85%', width : '85%',
height : '85%', height : '85%',
Expand Down

0 comments on commit a63ade5

Please sign in to comment.