From: <vo...@us...> - 2012-01-09 10:53:51
|
Revision: 8688 http://xoops.svn.sourceforge.net/xoops/?rev=8688&view=rev Author: voltan1 Date: 2012-01-09 10:53:40 +0000 (Mon, 09 Jan 2012) Log Message: ----------- Add archive page Modified Paths: -------------- XoopsModules/fmcontent/branches/news/class/story.php XoopsModules/fmcontent/branches/news/language/arabic/main.php XoopsModules/fmcontent/branches/news/language/arabic/modinfo.php XoopsModules/fmcontent/branches/news/language/english/main.php XoopsModules/fmcontent/branches/news/language/english/modinfo.php XoopsModules/fmcontent/branches/news/language/persian/main.php XoopsModules/fmcontent/branches/news/language/persian/modinfo.php XoopsModules/fmcontent/branches/news/xoops_version.php Added Paths: ----------- XoopsModules/fmcontent/branches/news/archive.php XoopsModules/fmcontent/branches/news/templates/news_archive.html Added: XoopsModules/fmcontent/branches/news/archive.php =================================================================== --- XoopsModules/fmcontent/branches/news/archive.php (rev 0) +++ XoopsModules/fmcontent/branches/news/archive.php 2012-01-09 10:53:40 UTC (rev 8688) @@ -0,0 +1,125 @@ +<?php +/* + You may not change or alter any portion of this comment or credits + of supporting developers from this source code or any supporting source code + which is considered copyrighted (c) material of the original comment or credit authors. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/** + * News index file + * + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license http://www.fsf.org/copyleft/gpl.html GNU public license + * @author Andricq Nicolas (AKA MusS) + * @version $Id$ + */ + +require dirname(__FILE__) . '/header.php'; +if (!isset($NewsModule)) exit('Module not found'); + +include_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/calendar.php'; + +// Initialize content handler +$story_handler = xoops_getmodulehandler ( 'story', 'news' ); +$topic_handler = xoops_getmodulehandler ( 'topic', 'news' ); +$file_handler = xoops_getmodulehandler('file', 'news'); + +// Include content template +$xoopsOption ['template_main'] = 'news_archive.html'; + +// include Xoops header +include XOOPS_ROOT_PATH . '/header.php'; + +// Add Stylesheet +$xoTheme->addStylesheet ( XOOPS_URL . '/modules/' . $NewsModule->getVar ( 'dirname' ) . '/css/style.css' ); + +$lastyear = 0; +$lastmonth = 0; + +$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' ); + +$pgtitle = ''; +if($fromyear && $frommonth) { + $pgtitle = sprintf(" - %d - %d", $fromyear, $frommonth); +} + +$dateformat='m'; + +$xoopsTpl->assign('xoops_pagetitle', _NEWS_MD_ARCHIVE . $pgtitle . ' - ' . $xoopsModule->name('s')); + +$useroffset = ''; +if(is_object($xoopsUser)) { + $timezone = $xoopsUser->timezone(); + if(isset($timezone)){ + $useroffset = $xoopsUser->timezone(); + } else { + $useroffset = $xoopsConfig['default_TZ']; + } +} + +$result = $story_handler->News_GetArchiveMonth($NewsModule); +$years = array(); +$months = array(); +$i = 0; + +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)) { + $this_year = intval($datetime[1]); + $this_month = intval($datetime[2]); + if (empty($lastyear)) { + $lastyear = $this_year; + } + if ($lastmonth == 0) { + $lastmonth = $this_month; + $months[$lastmonth]['string'] = $months_arr[$lastmonth]; + $months[$lastmonth]['number'] = $lastmonth; + } + if ($lastyear != $this_year) { + $years[$i]['number'] = $lastyear; + $years[$i]['months'] = $months; + $months = array(); + $lastmonth = 0; + $lastyear = $this_year; + $i++; + } + if ($lastmonth != $this_month) { + $lastmonth = $this_month; + $months[$lastmonth]['string'] = $months_arr[$lastmonth]; + $months[$lastmonth]['number'] = $lastmonth; + } + } +} + + $years[$i]['number'] = $this_year; + $years[$i]['months'] = $months; + $xoopsTpl->assign('years', $years); + $xoopsTpl->assign('module', $NewsModule->getVar ( 'dirname' )); + + +if ($fromyear != 0 && $frommonth != 0) { + // must adjust the selected time to server timestamp + $timeoffset = $useroffset - $xoopsConfig['server_TZ']; + $monthstart = mktime(0 - $timeoffset, 0, 0, $frommonth, 1, $fromyear); + $monthend = mktime(23 - $timeoffset, 59, 59, $frommonth + 1, 0, $fromyear); + $monthend = ($monthend > time()) ? time() : $monthend; + + $topics = $topic_handler->getall (); + $archive = $story_handler->News_GetArchive($NewsModule , $monthstart, $monthend , $topics); + $xoopsTpl->assign('archive', $archive); + $xoopsTpl->assign('show_articles', true); +} else { + $xoopsTpl->assign('show_articles', false); +} + + +// include Xoops footer +include XOOPS_ROOT_PATH . '/footer.php'; +?> \ No newline at end of file Modified: XoopsModules/fmcontent/branches/news/class/story.php =================================================================== --- XoopsModules/fmcontent/branches/news/class/story.php 2012-01-09 08:00:51 UTC (rev 8687) +++ XoopsModules/fmcontent/branches/news/class/story.php 2012-01-09 10:53:40 UTC (rev 8688) @@ -846,7 +846,7 @@ * * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @author Hervé Thouzard (ttp://www.instant-zero.com) + * @author Hervé Thouzard (http://www.instant-zero.com) */ function News_UpdateHits($story_id) { @@ -1027,7 +1027,7 @@ * Returns the number of published news per topic * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) - * @author Hervé Thouzard (ttp://www.instant-zero.com) + * @author Hervé Thouzard (http://www.instant-zero.com) */ function News_GetNewsCountByTopic() { @@ -1039,6 +1039,55 @@ } return $ret; } + + /** + * Get archive month + * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ + * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) + * @author Hervé Thouzard (http://www.instant-zero.com) + */ + function News_GetArchiveMonth($NewsModule) { + $sql = "SELECT `story_publish` FROM ".$this->db->prefix('news_story')." WHERE ( story_status = 1 ) AND ( story_topic != 0 ) AND ( story_modid = " . $NewsModule->getVar ( 'mid' ) . " ) AND ( story_publish > 0 AND story_publish <= " . time() . " ) AND ( story_expire = 0 OR story_expire <= " . time() . " ) ORDER BY story_publish DESC"; + $result = $this->db->query($sql); + return $result; + } + + /** + * Get archive + */ + function News_GetArchive($NewsModule, $publish_start, $publish_end ,$topics) { + $ret = array(); + $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'); + $criteria->setSort ( 'story_publish' ); + $criteria->setOrder ( 'DESC' ); + $obj = $this->getObjects ( $criteria, false ); + if ($obj) { + foreach ( $obj as $root ) { + $tab = array (); + $tab = $root->toArray (); + foreach ( array_keys ( $topics ) as $i ) { + $list [$i] ['topic_title'] = $topics [$i]->getVar ( "topic_title" ); + $list [$i] ['topic_id'] = $topics [$i]->getVar ( "topic_id" ); + $list [$i] ['topic_alias'] =$topics [$i]->getVar ( "topic_alias" ); + } + $tab ['topic'] = $list [$root->getVar ( 'story_topic' )] ['topic_title']; + $tab ['topic_alias'] = $list [$root->getVar ( 'story_topic' )] ['topic_alias']; + $tab ['topicurl'] = NewsUtils::News_TopicUrl ( $NewsModule->getVar ( 'dirname' ), array('topic_id'=>$list [$root->getVar ( 'story_topic' )] ['topic_id'], 'topic_alias'=>$list [$root->getVar ( 'story_topic' )] ['topic_alias'] )); + $tab ['url'] = NewsUtils::News_Url ( $NewsModule->getVar ( 'dirname' ), $tab ); + $tab ['story_publish'] = formatTimestamp ( $root->getVar ( 'story_publish' ), _MEDIUMDATESTRING ); + $tab ['imageurl'] = XOOPS_URL . xoops_getModuleOption ( 'img_dir', $NewsModule->getVar ( 'dirname' ) ) . '/medium/' . $root->getVar ( 'story_img' ); + $tab ['thumburl'] = XOOPS_URL . xoops_getModuleOption ( 'img_dir', $NewsModule->getVar ( 'dirname' ) ) . '/thumb/' . $root->getVar ( 'story_img' ); + $ret [] = $tab; + } + } + return $ret; + } } ?> \ No newline at end of file Modified: XoopsModules/fmcontent/branches/news/language/arabic/main.php =================================================================== --- XoopsModules/fmcontent/branches/news/language/arabic/main.php 2012-01-09 08:00:51 UTC (rev 8687) +++ XoopsModules/fmcontent/branches/news/language/arabic/main.php 2012-01-09 10:53:40 UTC (rev 8688) @@ -85,5 +85,12 @@ define("_NEWS_MD_TOPIC_NAME", "العنوان"); define("_NEWS_MD_TOPIC_DESC", "شرح"); define("_NEWS_MD_TOPIC_IMG", "صورة"); +// Archive + define("_NEWS_MD_ARCHIVE", "News Archive"); + define("_NEWS_MD_ARCHIVE_ARTICLES", "Articles"); + define("_NEWS_MD_ARCHIVE_VIEW", "Hits"); + define("_NEWS_MD_ARCHIVE_DATE", "Date"); + define("_NEWS_MD_ARCHIVE_TOPIC", "Topic"); + define("_NEWS_MD_ARCHIVE_TOTAL", "Total Stores"); } ?> \ No newline at end of file Modified: XoopsModules/fmcontent/branches/news/language/arabic/modinfo.php =================================================================== --- XoopsModules/fmcontent/branches/news/language/arabic/modinfo.php 2012-01-09 08:00:51 UTC (rev 8687) +++ XoopsModules/fmcontent/branches/news/language/arabic/modinfo.php 2012-01-09 10:53:40 UTC (rev 8688) @@ -32,6 +32,7 @@ define("_NEWS_MI_HELP", "دلیل"); define("_NEWS_MI_SUBMIT", "ارسال"); define('_NEWS_MI_FILE', 'ملف'); + define('_NEWS_MI_ARCHIVE', 'Archive'); // Block define("_NEWS_MI_BLOCK_PAGE", "الصفحة"); define("_NEWS_MI_BLOCK_LIST", "الفهرسة"); Modified: XoopsModules/fmcontent/branches/news/language/english/main.php =================================================================== --- XoopsModules/fmcontent/branches/news/language/english/main.php 2012-01-09 08:00:51 UTC (rev 8687) +++ XoopsModules/fmcontent/branches/news/language/english/main.php 2012-01-09 10:53:40 UTC (rev 8688) @@ -80,10 +80,17 @@ define("_NEWS_MD_BOOKMARK_TO_GOOLGEBUZZ", "Bookmark to Google Buzz"); define("_NEWS_MD_BOOKMARK_TO_GOOLGEREADER", "Bookmark to Google Reader"); define("_NEWS_MD_BOOKMARK_TO_GOOLGEBOOKMARKS", "Bookmark to Google Bookmarks"); -// topic +// Topic define("_NEWS_MD_TOPIC_ID", "ID"); define("_NEWS_MD_TOPIC_NAME", "Title"); define("_NEWS_MD_TOPIC_DESC", "Description"); - define("_NEWS_MD_TOPIC_IMG", "image"); + define("_NEWS_MD_TOPIC_IMG", "image"); +// Archive + define("_NEWS_MD_ARCHIVE", "News Archive"); + define("_NEWS_MD_ARCHIVE_ARTICLES", "Articles"); + define("_NEWS_MD_ARCHIVE_VIEW", "Hits"); + define("_NEWS_MD_ARCHIVE_DATE", "Date"); + define("_NEWS_MD_ARCHIVE_TOPIC", "Topic"); + define("_NEWS_MD_ARCHIVE_TOTAL", "Total Stores"); } ?> \ No newline at end of file Modified: XoopsModules/fmcontent/branches/news/language/english/modinfo.php =================================================================== --- XoopsModules/fmcontent/branches/news/language/english/modinfo.php 2012-01-09 08:00:51 UTC (rev 8687) +++ XoopsModules/fmcontent/branches/news/language/english/modinfo.php 2012-01-09 10:53:40 UTC (rev 8688) @@ -31,7 +31,8 @@ define('_NEWS_MI_ABOUT', 'About'); define('_NEWS_MI_HELP', 'Help'); define('_NEWS_MI_SUBMIT', 'Submit'); - define('_NEWS_MI_FILE', 'File'); + define('_NEWS_MI_FILE', 'File'); + define('_NEWS_MI_ARCHIVE', 'Archive'); // Block define('_NEWS_MI_BLOCK_PAGE', 'Article page'); define('_NEWS_MI_BLOCK_LIST', 'Article list'); Modified: XoopsModules/fmcontent/branches/news/language/persian/main.php =================================================================== --- XoopsModules/fmcontent/branches/news/language/persian/main.php 2012-01-09 08:00:51 UTC (rev 8687) +++ XoopsModules/fmcontent/branches/news/language/persian/main.php 2012-01-09 10:53:40 UTC (rev 8688) @@ -85,5 +85,12 @@ define("_NEWS_MD_TOPIC_NAME", "عنوان"); define("_NEWS_MD_TOPIC_DESC", "توضیحات"); define("_NEWS_MD_TOPIC_IMG", "تصویر"); +// Archive + define("_NEWS_MD_ARCHIVE", "News Archive"); + define("_NEWS_MD_ARCHIVE_ARTICLES", "Articles"); + define("_NEWS_MD_ARCHIVE_VIEW", "Hits"); + define("_NEWS_MD_ARCHIVE_DATE", "Date"); + define("_NEWS_MD_ARCHIVE_TOPIC", "Topic"); + define("_NEWS_MD_ARCHIVE_TOTAL", "Total Stores"); } ?> \ No newline at end of file Modified: XoopsModules/fmcontent/branches/news/language/persian/modinfo.php =================================================================== --- XoopsModules/fmcontent/branches/news/language/persian/modinfo.php 2012-01-09 08:00:51 UTC (rev 8687) +++ XoopsModules/fmcontent/branches/news/language/persian/modinfo.php 2012-01-09 10:53:40 UTC (rev 8688) @@ -31,7 +31,8 @@ define("_NEWS_MI_ABOUT", "درباره"); define("_NEWS_MI_HELP", "راهنما"); define("_NEWS_MI_SUBMIT", "ارسال"); - define('_NEWS_MI_FILE', 'فایل'); + define('_NEWS_MI_FILE', 'فایل'); + define('_NEWS_MI_ARCHIVE', 'Archive'); // Block define("_NEWS_MI_BLOCK_PAGE", "صفحه"); define("_NEWS_MI_BLOCK_LIST", "فهرست"); Added: XoopsModules/fmcontent/branches/news/templates/news_archive.html =================================================================== --- XoopsModules/fmcontent/branches/news/templates/news_archive.html (rev 0) +++ XoopsModules/fmcontent/branches/news/templates/news_archive.html 2012-01-09 10:53:40 UTC (rev 8688) @@ -0,0 +1,39 @@ +<div class="news-archive"> + <div class="pad2 marg2"> + <table> + <tr> + <th><{$smarty.const._NEWS_MD_ARCHIVE}></th> + </tr> + <{foreach item=year from=$years}> + <{foreach item=month from=$year.months}> + <tr class="even"> + <td><a title="<{$month.string}> <{$year.number}>" href="<{$xoops_url}>/modules/<{$module}>/archive.php?year=<{$year.number}>&month=<{$month.number}>"><{$month.string}> <{$year.number}></a></td> + </tr> + <{/foreach}> + <{/foreach}> + </table> + </div> + + <{if $show_articles == true}> + <div class="pad2 marg2"> + <table> + <tr> + <th><{$smarty.const._NEWS_MD_ARCHIVE_ARTICLES}></th> + <th class="center"><{$smarty.const._NEWS_MD_ARCHIVE_VIEW}></th> + <th class="center"><{$smarty.const._NEWS_MD_ARCHIVE_DATE}></th> + <th class="center"><{$smarty.const._NEWS_MD_ARCHIVE_TOPIC}></th> + </tr> + <{foreach item=archive from=$archive}> + <tr class="<{cycle values="even,odd"}>"> + <td><a title="<{$archive.story_title}>" href="<{$archive.url}>"><{$archive.story_title}></a></td> + <td class="center"><{$archive.story_hits}></td> + <td class="center"><{$archive.story_publish}></td> + <td class="center"><a title="<{$archive.topic}>" href="<{$archive.topicurl}>" ><{$archive.topic}></a></td> + </tr> + <{/foreach}> + </table> + </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}> + +</div> \ No newline at end of file Modified: XoopsModules/fmcontent/branches/news/xoops_version.php =================================================================== --- XoopsModules/fmcontent/branches/news/xoops_version.php 2012-01-09 08:00:51 UTC (rev 8687) +++ XoopsModules/fmcontent/branches/news/xoops_version.php 2012-01-09 10:53:40 UTC (rev 8688) @@ -95,6 +95,7 @@ $modversion['templates'][] = array('file' => 'news_bookmarkme.html', 'description' => ''); $modversion['templates'][] = array('file' => 'news_header.html', 'description' => ''); $modversion['templates'][] = array('file' => 'news_topic.html', 'description' => ''); +$modversion['templates'][] = array('file' => 'news_archive.html', 'description' => ''); // Menu $modversion['sub'][] = array( @@ -103,6 +104,9 @@ $modversion['sub'][] = array( 'name' => _NEWS_MI_TOPIC, 'url' => 'topic.php'); +$modversion['sub'][] = array( + 'name' => _NEWS_MI_ARCHIVE, + 'url' => 'archive.php'); // Blocks $modversion['blocks'][] = array( This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |