NewsDisplay.php

Go to the documentation of this file.
00001 <?php
00003 // {{{ license
00004 
00005 // +----------------------------------------------------------------------+
00006 // | FastFrame Application Framework                                      |
00007 // +----------------------------------------------------------------------+
00008 // | Copyright (c) 2002-2006 The Codejanitor Group                        |
00009 // +----------------------------------------------------------------------+
00010 // | This source file is subject to the GNU Lesser Public License (LGPL), |
00011 // | that is bundled with this package in the file LICENSE, and is        |
00012 // | available at through the world-wide-web at                           |
00013 // | http://www.fsf.org/copyleft/lesser.html                              |
00014 // | If you did not receive a copy of the LGPL and are unable to          |
00015 // | obtain it through the world-wide-web, you can get it by writing the  |
00016 // | Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
00017 // | MA 02111-1307, USA.                                                  |
00018 // +----------------------------------------------------------------------+
00019 // | Authors: Jason Rust <jrust@codejanitor.com>                          |
00020 // | Authors: Greg Gilbert <ggilbert@codejanitor.com>                     |
00021 // +----------------------------------------------------------------------+
00022 
00023 // }}}
00024 // {{{ requires
00025 
00026 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action/Display.php';
00027 
00028 // }}}
00029 // {{{ class FF_Action_Display_News 
00030 
00041 // }}}
00042 class FF_Action_Display_News extends FF_Action {
00043     // {{{ run()
00044 
00052     function run()
00053     {
00054         $this->o_output->setPageName($this->getPluralText());
00055         $o_result =& $this->o_model->getNewsArticles((FF_Auth::checkAuth() && $this->o_perms->hasPerm('can_view_protected_news')));
00056         if ($o_result->numRows() == 0) {
00057             $this->o_output->o_tpl->append('page_explanation', '<span style="font-style: italic;">' . 
00058                     sprintf(_('There are no %s to display'), $this->getPluralText()) . 
00059                     '</span>');
00060         }
00061         else {
00062             require_once 'HTML/BBCodeParser.php';
00063             $o_bbCodeParser =& new HTML_BBCodeParser(array('filters' => 'Basic,Email,Links'));
00064             $o_widget =& new FF_Smarty('news');
00065             $s_count = 0;
00066             if (FF_Request::getParam('showAll', 'g', false)) {
00067                 $s_limit = $o_result->numRows();
00068             }
00069             else {
00070                 $s_limit = $this->o_registry->getConfigParam('alumni/news_limit');
00071             }
00072 
00073             while (($a_row = $o_result->fetchRow(DB_FETCHMODE_DEFAULT, $s_count)) &&
00074                     $s_count < $s_limit) {
00075                 $s_count++;
00076                 $this->o_model->reset();
00077                 $this->o_model->importFromArray($a_row);
00078                 $o_widget->append('news_items', array(
00079                             'T_news_id' => $this->o_model->getId(),
00080                             'T_news_title' => $this->o_model->getTitle(),
00081                             'T_news_create_date' => $this->o_model->getFormattedCreateDate(),
00082                             'T_news_content' => nl2br($o_bbCodeParser->qparse(htmlspecialchars($this->o_model->getContent())))));
00083             }
00084 
00085             $this->o_output->o_tpl->append('content_middle', $o_widget->fetch());
00086             if ($o_result->numRows() > $s_count) {
00087                 $this->o_output->o_tpl->append('content_middle', 
00088                         '<div style="text-align: center;">' . 
00089                         $this->o_output->link(
00090                             FastFrame::selfURL(array('showAll' => 1)), 
00091                             sprintf(_('View All %s'), $this->getPluralText())) .
00092                         '</div>');
00093             }
00094         }
00095 
00096         return $this->o_nextAction;
00097     }
00098 
00099     // }}}
00100     // {{{ getPluralText()
00101 
00108     function getPluralText()
00109     {
00110         return _('News Articles');
00111     }
00112 
00113     // }}}
00114 }
00115 ?>

Generated on Fri Jun 23 11:38:17 2006 for FastFrame by  doxygen 1.4.4