|
From: <al...@us...> - 2008-10-20 13:31:53
|
Revision: 734
http://sciret.svn.sourceforge.net/sciret/?rev=734&view=rev
Author: alpeb
Date: 2008-10-20 13:31:41 +0000 (Mon, 20 Oct 2008)
Log Message:
-----------
added ability to browse expired articles in the main view
Modified Paths:
--------------
trunk/classes/Library.php
trunk/models/Article.php
trunk/templates/MainView.tpl
trunk/views/MainView.php
Modified: trunk/classes/Library.php
===================================================================
--- trunk/classes/Library.php 2008-10-17 23:59:05 UTC (rev 733)
+++ trunk/classes/Library.php 2008-10-20 13:31:41 UTC (rev 734)
@@ -64,6 +64,14 @@
}
}
+ if (!in_array('viewexpired', array_keys($vars))) {
+ if (isset($_GET['viewexpired'])) {
+ $vars['viewexpired'] = $_GET['viewexpired'];
+ } else {
+ $vars['viewexpired'] = 0;
+ }
+ }
+
if (!in_array('tableSort', array_keys($vars)) && isset($_GET['tableSort'])) {
$vars['tableSort'] = $_GET['tableSort'];
}
Modified: trunk/models/Article.php
===================================================================
--- trunk/models/Article.php 2008-10-17 23:59:05 UTC (rev 733)
+++ trunk/models/Article.php 2008-10-20 13:31:41 UTC (rev 734)
@@ -218,6 +218,15 @@
}
}
+ public function isExpired()
+ {
+ if ($this->expDate == '0000-00-00') {
+ return false;
+ }
+
+ return ($this->expDate <= date('Y-m-d'));
+ }
+
function setExpDate($expDate)
{
$this->expDate = $expDate;
Modified: trunk/templates/MainView.tpl
===================================================================
--- trunk/templates/MainView.tpl 2008-10-17 23:59:05 UTC (rev 733)
+++ trunk/templates/MainView.tpl 2008-10-20 13:31:41 UTC (rev 734)
@@ -64,9 +64,7 @@
<div class="title_content" style="position:relative">
<span>
{navigationTitle}
- <!-- BEGIN browsingDraftsUnpublished_block -->
- [l](Showing drafts and unpublished too)[/l]
- <!-- END browsingDraftsUnpublished_block -->
+ {showing}
<a href="javascript:void(0)" onclick="addFavorite('location')"><img id="favoriteStarImg" src="images/star.png" alt="[l]Add location to favorites[/l]" title="[l]Add location to favorites[/l]" style="display:{favoriteLocationStarImgDisplay}" /><img id="unFavoriteStarImg" src="images/star_crossed.png" alt="[l]Remove location from favorites[/l]" title="[l]Remove location from favorites[/l]" style="display:{unFavoriteLocationStarImgDisplay}" /><img id="favoriteProgressImg" src="images/progress.gif" style="display:none" /></a>
</span>
<span style="position:absolute; right:0; top:7px">
@@ -90,6 +88,14 @@
<br />
<a href="{hideDraftsUnpublishedLink}" style="font-weight:bold; font-size:10px">[l]Hide drafts and unpublished articles[/l]</a>
<!-- END hideDraftsUnpublishedLink_block -->
+ <!-- BEGIN viewExpiredLink_block -->
+ <br />
+ <a href="{viewExpiredLink}" style="font-weight:bold; font-size:10px">[l]View expired articles[/l]</a>
+ <!-- END viewExpiredLink_block -->
+ <!-- BEGIN hideExpiredLink_block -->
+ <br />
+ <a href="{hideExpiredLink}" style="font-weight:bold; font-size:10px">[l]Hide expired articles[/l]</a>
+ <!-- END hideExpiredLink_block -->
</p>
<p class="view_right">[l]Sort by:[/l]
<span class="button_gray"><a href="{sortByDateLink}">[l]Date[/l]</a>{sortByDateArrow}</span>
Modified: trunk/views/MainView.php
===================================================================
--- trunk/views/MainView.php 2008-10-17 23:59:05 UTC (rev 733)
+++ trunk/views/MainView.php 2008-10-20 13:31:41 UTC (rev 734)
@@ -48,6 +48,14 @@
$_GET['viewall'] = 0;
}
+ if (!$this->user->isAnonymous()
+ && isset($_GET['viewexpired']) && $_GET['viewexpired'] == 1)
+ {
+ $_GET['viewexpired'] = 1;
+ } else {
+ $_GET['viewexpired'] = 0;
+ }
+
$this->tpl->set_var('checked_all', (!isset($_GET['set']) || $_GET['set'] == 'all')? 'checked="true"' : '');
$this->tpl->set_var('checked_articles', (isset($_GET['set']) && $_GET['set'] == 'articles')? 'checked="true"' : '');
$this->tpl->set_var('checked_bookmarks', (isset($_GET['set']) && $_GET['set'] == 'bookmarks')? 'checked="true"' : '');
@@ -66,8 +74,9 @@
$this->tpl->set_block('main', 'viewBookmarksLink_block', 'viewBookmarksLink');
$this->tpl->set_block('main', 'viewDraftsUnpublishedLink_block', 'viewDraftsUnpublishedLink');
$this->tpl->set_block('main', 'hideDraftsUnpublishedLink_block', 'hideDraftsUnpublishedLink');
+ $this->tpl->set_block('main', 'viewExpiredLink_block', 'viewExpiredLink');
+ $this->tpl->set_block('main', 'hideExpiredLink_block', 'hideExpiredLink');
$this->tpl->set_block('main', 'requestCat_block', 'requestCat');
- $this->tpl->set_block('main', 'browsingDraftsUnpublished_block', 'browsingDraftsUnpublished');
$this->tpl->set_block('articles_block', 'status_block', 'status');
$this->tpl->set_block('articles_block', 'question_block', 'question');
@@ -84,6 +93,8 @@
'viewBookmarksLink' => Library::getLink(array('view' => 'MainView', 'set' => 'bookmarks')),
'viewDraftsUnpublishedLink' => Library::getLink(array('view' => 'MainView', 'viewall' => '1')),
'hideDraftsUnpublishedLink' => Library::getLink(array('view' => 'MainView', 'viewall' => '0')),
+ 'viewExpiredLink' => Library::getLink(array('view' => 'MainView', 'viewexpired' => '1')),
+ 'hideExpiredLink' => Library::getLink(array('view' => 'MainView', 'viewexpired' => '0')),
'sortByDateLink' => Library::getLink(array('view' => 'MainView', 'sort' => 'created_'.($order == 'created' && $direction == 'desc'? 'asc' : 'desc'))),
'sortByViewsLink' => Library::getLink(array('view' => 'MainView', 'sort' => 'views_'.($order == 'views' && $direction == 'desc'? 'asc' : 'desc'))),
'rssLink' => Library::getLink(array('view' => 'Rss', 'catId' => $catId, 'items' => 10)),
@@ -137,10 +148,10 @@
$this->tpl->parse('viewBookmarksLink', 'viewBookmarksLink_block');
}
+ $showing = array();
if ($_GET['viewall']) {
- $this->tpl->parse('browsingDraftsUnpublished', 'browsingDraftsUnpublished_block');
- } else {
- $this->tpl->set_var('browsingDraftsUnpublished', '');
+ $showing[] = $this->user->lang('drafts');
+ $showing[] = $this->user->lang('unpublished');
}
if (!$this->user->isAnonymous()) {
@@ -158,7 +169,31 @@
));
}
+ if ($_GET['viewexpired']) {
+ $showing[] = $this->user->lang('expired');
+ }
+ if (!$this->user->isAnonymous()) {
+ if (isset($_GET['viewexpired']) && $_GET['viewexpired'] == 1) {
+ $this->tpl->parse('hideExpiredLink', 'hideExpiredLink_block');
+ $this->tpl->set_var('viewExpiredLink', '');
+ } else {
+ $this->tpl->parse('viewExpiredLink', 'viewExpiredLink_block');
+ $this->tpl->set_var('hideExpiredLink', '');
+ }
+ } else {
+ $this->tpl->set_var(array(
+ 'viewExpiredLink' => '',
+ 'hideExpiredLink' => '',
+ ));
+ }
+
+ if ($showing) {
+ $showing = implode(', ', $showing);
+ $this->tpl->set_var('showing', ' - ' . $this->user->lang('Showing %s', $showing));
+ }
+
+
// ** CATEGORIES **
$articleGateway = new ArticleGateway;
$categoryGateway = new CategoryGateway;
@@ -200,7 +235,7 @@
$this->user->getPreference('articlesPerPage'),
isset($_GET['set'])? $_GET['set'] : 'all',
isset($_GET['sort'])? $_GET['sort'] : false,
- false,
+ $_GET['viewexpired'],
$_GET['viewall']);
$this->tpl->set_var('numArts', $articles->getNumItems());
$firstIteration = true;
@@ -238,6 +273,10 @@
if ($article->isDraft()) {
$status[] = $this->user->lang('draft');
}
+ if ($article->isExpired()) {
+ $status[] = $this->user->lang('expired');
+ }
+
if ($status) {
$status = implode(', ', $status);
$this->tpl->set_var('status', $status);
@@ -263,19 +302,19 @@
}
$this->tpl->set_var('paginationLinks', $this->getPaginationLinks( 'MainView',
$articles->getNumItems(),
- isset($_GET['offset'])? (int)$_GET['offset'] : 0,
- false,
- false,
- false,
- false,
- '',
- '',
- '',
- '',
- 0,
- '',
- 'anywhere',
- 'created',
+ isset($_GET['offset'])? (int)$_GET['offset'] : 0,
+ false,
+ false,
+ false,
+ false,
+ '',
+ '',
+ '',
+ '',
+ 0,
+ '',
+ 'anywhere',
+ 'created',
'desc',
$catId));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|