00001 <?php
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 require_once FASTFRAME_ROOT . 'lib/FastFrame/Action/Form.php';
00026
00027
00028
00029
00040
00041 class FF_Action_Form_News extends FF_Action_Form {
00042
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
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
00080
00087 function getSingularText()
00088 {
00089 return _('News Article');
00090 }
00091
00092
00093
00094
00102 function getPluralText()
00103 {
00104 return _('News Articles');
00105 }
00106
00107
00108
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:
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
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
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 ?>