|
From: <vo...@us...> - 2012-02-29 12:11:44
|
Revision: 9079
http://xoops.svn.sourceforge.net/xoops/?rev=9079&view=rev
Author: voltan1
Date: 2012-02-29 12:11:33 +0000 (Wed, 29 Feb 2012)
Log Message:
-----------
Improve archive page
Modified Paths:
--------------
XoopsModules/fmcontent/branches/news/archive.php
XoopsModules/fmcontent/branches/news/class/story.php
XoopsModules/fmcontent/branches/news/templates/news_archive.html
Modified: XoopsModules/fmcontent/branches/news/archive.php
===================================================================
--- XoopsModules/fmcontent/branches/news/archive.php 2012-02-29 10:44:03 UTC (rev 9078)
+++ XoopsModules/fmcontent/branches/news/archive.php 2012-02-29 12:11:33 UTC (rev 9079)
@@ -22,7 +22,7 @@
if (!isset($NewsModule)) exit('Module not found');
include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/calendar.php';
-
+ include_once XOOPS_ROOT_PATH . "/class/pagenav.php";
// Initialize content handler
$story_handler = xoops_getmodulehandler ( 'story', 'news' );
$topic_handler = xoops_getmodulehandler ( 'topic', 'news' );
@@ -42,8 +42,10 @@
$months_arr = array(1 => _CAL_JANUARY, 2 => _CAL_FEBRUARY, 3 => _CAL_MARCH, 4 => _CAL_APRIL, 5 => _CAL_MAY, 6 => _CAL_JUNE, 7 => _CAL_JULY, 8 => _CAL_AUGUST, 9 => _CAL_SEPTEMBER, 10 => _CAL_OCTOBER, 11 => _CAL_NOVEMBER, 12 => _CAL_DECEMBER);
-$fromyear = NewsUtils::News_CleanVars ( $_REQUEST, 'year', 0, 'int' );
-$frommonth = NewsUtils::News_CleanVars ( $_REQUEST, 'month', 0, 'int' );
+$fromyear = NewsUtils::News_CleanVars ( $_GET, 'year', 0, 'int' );
+$frommonth = NewsUtils::News_CleanVars ( $_GET, 'month', 0, 'int' );
+$start = NewsUtils::News_CleanVars ( $_GET, 'start', 0, 'int' );
+$limit = NewsUtils::News_CleanVars ( $_GET, 'limit', 50, 'int' );
$pgtitle = '';
if($fromyear && $frommonth) {
@@ -71,7 +73,7 @@
while (list($time) = $xoopsDB->fetchRow($result)) {
$time = formatTimestamp($time, 'mysql', $useroffset);
- if (preg_match("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $time, $datetime)) {
+ if (preg_match("/([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})/", $time, $datetime)) {
$this_year = intval($datetime[1]);
$this_month = intval($datetime[2]);
if (empty($lastyear)) {
@@ -112,8 +114,18 @@
$monthend = ($monthend > time()) ? time() : $monthend;
$topics = $topic_handler->getall ();
- $archive = $story_handler->News_GetArchive($NewsModule , $monthstart, $monthend , $topics);
+ $archive = $story_handler->News_GetArchive($NewsModule , $monthstart, $monthend , $topics , $limit , $start);
+ $numrows = $story_handler->News_GetArchiveCount($NewsModule, $publish_start, $publish_end ,$topics);
+
+ if ($numrows > $limit) {
+ $pagenav = new XoopsPageNav ( $numrows, $limit, $start, 'start', 'year=' . $fromyear . '&month=' . $frommonth . '&limit=' . $limit );
+ $pagenav = $pagenav->renderNav ( 4 );
+ } else {
+ $pagenav = '';
+ }
+
$xoopsTpl->assign('archive', $archive);
+ $xoopsTpl->assign('pagenav', $pagenav);
$xoopsTpl->assign('show_articles', true);
} else {
$xoopsTpl->assign('show_articles', false);
Modified: XoopsModules/fmcontent/branches/news/class/story.php
===================================================================
--- XoopsModules/fmcontent/branches/news/class/story.php 2012-02-29 10:44:03 UTC (rev 9078)
+++ XoopsModules/fmcontent/branches/news/class/story.php 2012-02-29 12:11:33 UTC (rev 9079)
@@ -1061,7 +1061,7 @@
/**
* Get archive
*/
- function News_GetArchive($NewsModule, $publish_start, $publish_end ,$topics) {
+ function News_GetArchive($NewsModule, $publish_start, $publish_end ,$topics ,$limit ,$start) {
$ret = array();
$criteria = new CriteriaCompo ();
$criteria->add ( new Criteria ( 'story_modid', $NewsModule->getVar ( 'mid' ) ) );
@@ -1072,6 +1072,8 @@
$criteria->add ( new Criteria ( 'story_expire', time() , '>' ) ,'OR');
$criteria->setSort ( 'story_publish' );
$criteria->setOrder ( 'DESC' );
+ $criteria->setLimit ( $limit );
+ $criteria->setStart ( $start );
$obj = $this->getObjects ( $criteria, false );
if ($obj) {
foreach ( $obj as $root ) {
@@ -1096,6 +1098,20 @@
}
/**
+ * Get archive count
+ */
+ function News_GetArchiveCount($NewsModule, $publish_start, $publish_end ,$topics) {
+ $criteria = new CriteriaCompo ();
+ $criteria->add ( new Criteria ( 'story_modid', $NewsModule->getVar ( 'mid' ) ) );
+ $criteria->add ( new Criteria ( 'story_status', '1' ) );
+ $criteria->add ( new Criteria ( 'story_publish', $publish_start , '>' ));
+ $criteria->add ( new Criteria ( 'story_publish', $publish_end , '<=' ));
+ $criteria->add ( new Criteria ( 'story_expire', 0 ));
+ $criteria->add ( new Criteria ( 'story_expire', time() , '>' ) ,'OR');
+ return $this->getCount ( $criteria );
+ }
+
+ /**
* News Prune Count
*/
function News_PruneCount($NewsModule,$timestamp,$expired,$topiclist) {
Modified: XoopsModules/fmcontent/branches/news/templates/news_archive.html
===================================================================
--- XoopsModules/fmcontent/branches/news/templates/news_archive.html 2012-02-29 10:44:03 UTC (rev 9078)
+++ XoopsModules/fmcontent/branches/news/templates/news_archive.html 2012-02-29 12:11:33 UTC (rev 9079)
@@ -33,6 +33,7 @@
<{/foreach}>
</table>
</div>
+ <div class="pagenave"><{$pagenav}></div>
<div class="marg2 pad2 center"><a title="<{$smarty.const._NEWS_MD_ARCHIVE_TOTAL}>" href="<{$xoops_url}>/modules/<{$module}>/archive.php"><{$smarty.const._NEWS_MD_ARCHIVE_TOTAL}></a></div>
<{/if}>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|