NewsForm.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 // +----------------------------------------------------------------------+
00021 
00022 // }}}
00023 // {{{ requires
00024 
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action/Form.php';
00026 
00027 // }}}
00028 // {{{ class FF_Action_Form_News
00029 
00040 // }}}
00041 class FF_Action_Form_News extends FF_Action_Form {
00042     // {{{ renderAdditionalLinks()
00043 
00050     function renderAdditionalLinks()
00051     {
00052         $this->o_output->o_tpl->append('page_links', $this->o_output->link(
00053                     FastFrame::selfURL(array('actionId' => ACTION_LIST)),
00054                     sprintf(_('Return to %s List'), $this->getSingularText())));
00055     }
00056 
00057     // }}}
00058     // {{{ createFormElements()
00059 
00067     function createFormElements()
00068     {
00069         $this->o_form->addElement('hidden', 'actionId');
00070         $this->o_form->addElement('hidden', 'objectId');
00071         $this->o_form->addElement('submit', 'submitbutton');
00072         $this->o_form->addElement('text', 'title', null, array('maxlength' => 200, 'size' => 30, 'style' => 'width: 100%;'));
00073         $this->o_form->addElement('textarea', 'content', null, array('cols' => 60, 'rows' => 10, 'style' => 'width: 100%;'));
00074         $this->o_form->addElement('checkbox', 'requires_auth');
00075         $this->o_form->addRule('title', _('Title cannot be blank.'), 'required', null, 'client');
00076     }
00077 
00078     // }}}
00079     // {{{ getSingularText()
00080 
00087     function getSingularText()
00088     {
00089         return _('News Article');
00090     }
00091 
00092     // }}}
00093     // {{{ getPluralText()
00094 
00102     function getPluralText()
00103     {
00104         return _('News Articles');
00105     }
00106 
00107     // }}}
00108     // {{{ getTableData()
00109 
00118     function getTableData()
00119     {
00120         $a_headers = array();
00121         $a_headers[] = array(
00122             'title' => '* ' . _('Title'),
00123                         'titleStyle' => 'style="font-weight: bold;"',
00124             'data' => $this->o_renderer->elementToHtml('title'), 
00125         );
00126         $a_headers[] = array(
00127             'title' => '* ' . _('Must be Approved to View?'),
00128                         'titleStyle' => 'style="font-weight: bold;"',
00129             'data' => $this->o_renderer->elementToHtml('requires_auth'), 
00130         );
00131         $tmp_help = nl2br(_('The following tags can be used to format the text:
00132 [b]<b>bold text</b>[/b]
00133 [i]<i>italic text</i>[/i]
00134 [u]<u>underlined text</u>[/u]
00135 [url]<u>http://www.example.com</u>[/url]
00136 [email=bob@example.com]<u>Email Bob</u>[/email]'));
00137         $a_headers[] = array(
00138             'title' => sprintf(_('Content %s'), $this->o_output->getHelpLink($tmp_help)),
00139             'data' => $this->o_renderer->elementToHtml('content'), 
00140         );
00141         return $a_headers;
00142     }
00143 
00144     // }}}
00145     // {{{ getFormDefaults()
00146 
00154     function getFormDefaults()
00155     {
00156         $a_fields = array();
00157         $a_fields['objectId'] = $this->o_model->getId();
00158         $a_fields['title'] = $this->o_model->getTitle();
00159         $a_fields['content'] = $this->o_model->getContent();
00160         $a_fields['requires_auth'] = $this->o_model->getRequiresAuth();
00161         return $a_fields;
00162     }
00163 
00164     // }}}
00165     // {{{ checkPerms()
00166 
00173     function checkPerms()
00174     {
00175         if ($this->o_perms->hasPerm('can_edit_news')) {
00176             return true;
00177         }
00178         else {
00179             $this->o_nextAction->setNextActionId(ACTION_PROBLEM);
00180             $this->o_output->setMessage(_('You do not have permission to edit news.'), FASTFRAME_ERROR_MESSAGE);
00181             return false;
00182         }
00183     }
00184 
00185     // }}}
00186 }
00187 ?>

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