Authored by whb

添加分页

... ... @@ -131,7 +131,11 @@ class Controller_Admin_Activity extends Controller_Admin_Base
*/
public function plantopicAction()
{
$this->_view['topics'] = Facade_Activity::getActivityTopic();
$limit = 15;
$total = Facade_Activity::getActivityTopicTotal();
$pagination = new Lib_Helper_Pagination($total, $limit);
$this->_view['topics'] = Facade_Activity::getActivityTopicList($pagination->getOffset(), $limit);
$this->_view['pagination'] = $pagination->getPagination();
}
/**
... ...
... ... @@ -15,7 +15,7 @@ class Controller_Admin_News extends Controller_Admin_Base
$total = Facade_News::getTotal($conditions);
$pagination = new Lib_Helper_Pagination($total,$limit);
$pagination->setParames($url_args);
$list = Facade_News::getList($conditions, $pagination->getOffset(),$limit);
$list = Facade_News::getList($conditions, $pagination->getOffset(), $limit);
foreach ($list as $k => $v)
{
$list[$k]['content'] = str_replace(array("\n","\r","\t"),'', Util_StringHelper::substr_cn(strip_tags($v['content']),30));
... ...
... ... @@ -155,6 +155,28 @@ class Facade_Activity
}
/**
* 获取活动主题列表
*
* @param int $offset
* @param int $limit
* @return array
*/
public static function getActivityTopicList($offset, $limit)
{
return self::service()->getActivityTopicList($offset, $limit);
}
/**
* 获取活动主题总数
*
* @return int
*/
public static function getActivityTopicTotal()
{
return self::service()->getActivityTopicTotal();
}
/**
* 增加活动主题
*
* @param int $title
... ...
... ... @@ -224,7 +224,30 @@ class Service_Activity extends Lib_Service
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getActivityTopic');
}
/**
* 获取活动主题列表
*
* @param int $offset
* @param int $limit
* @return array
*/
public function getActivityTopicList($offset, $limit)
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getActivityTopicList',
array('offset'=> intval($offset), 'limit'=> intval($limit)));
}
/**
* 获取活动主题总数
*
* @return int
*/
public function getActivityTopicTotal()
{
return self::service(self::ROUTER)->tag(self::$_tag)->fetchOne('getActivityTopicTotal');
}
/**
* 删除活动主题
*
... ...
... ... @@ -33,6 +33,12 @@
<select id="getActivityTopic">
SELECT * FROM tbl_activity_topic ORDER BY start_time DESC
</select>
<select id="getActivityTopicList">
SELECT * FROM tbl_activity_topic ORDER BY start_time DESC LIMIT :offset, :limit
</select>
<select id="getActivityTopicTotal">
SELECT COUNT(*) FROM tbl_activity_topic
</select>
<select id="setActivityTopic">
INSERT INTO tbl_activity_topic(title, place,start_time, end_time,create_time)VALUES(:title, :place, :start_time,:end_time, UNIX_TIMESTAMP())
</select>
... ...
... ... @@ -31,6 +31,10 @@
</tr>
<?php endforeach;?>
</table>
<?php $this->_component('Common_Pagination',array(
'pagination' => $this->view->pagination,'show_count' =>true,
));?>
<div id="form_pan" admin="" style="display:none;">
<table class="table table-bordered">
<tbody>
... ...