<?php
/*
* Copyright 2008 Blandware (http://www.blandware.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Actions for news.
*
* @package AtleapLite
* @author Roman Puchkovskiy
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
// ~ DAO functions
/**
* Loads news items from DB.
*
* @param array $queryInfo optional query info
* @see loadObjects()
* @return array objects
*/
function loadNewsItems($queryInfo = array()) {
$queryInfo['fields']['layout'] = 'newsItem';
$queryInfo['fields']['language'] = getCurrentLanguage();
$queryInfo['fields']['published'] = 1;
$queryInfo['where'] = "('" . getNowDate() . "' BETWEEN publication_date AND expiration_date)";
return loadObjects('page', getPageDescriptor(), null, $queryInfo);
}
// ~ Actions
/**
* Displays a news archive.
*/
function showNewsArchive()
{
global $smarty, $perPage, $pagerDelta, $bottomLinks;
$queryInfo = buildDefaultQueryInfo();
$queryInfo['orderBy'] = 'publication_date desc';
$partial = loadNewsItems($queryInfo);
$total = $partial['total'];
$newsItems = $partial['rows'];
$fullName = RW_PREFIX . NEWS_ARCHIVE_PREFIX . RW_POSTFIX;
list($dir, $name) = splitFullName($fullName);
$name .= '?' . PAGE_ID_VAR . '=%d';
$pager = getPager(array('totalItems' => $total, 'fileName' => $name,
'path' => $dir, 'append' => false));
exportPagerData($pager, $smarty, $newsItems);
$smarty->assign('template', 'news/showArchive.tpl');
$smarty->assign('title', getMessage('newsItem.archive.title'));
$smarty->setAdminLayout(false);
// $smarty->initGrid('newsArchiveFilters', getNewsItemDescriptor(), $_GET['action']);
setSystemMenuItemBold('showNewsArchive');
}
?>