コード例 #1
0
 public static function display()
 {
     if (isset($_POST['submit_edit_forum'])) {
         if (\PFBC\Form::isValid($_POST['submit_edit_forum'])) {
             new EditForumFormProcess();
         }
         Framework\Url\Header::redirect();
     }
     $oForumModel = new ForumModel();
     $oForumData = $oForumModel->getForum((new Http())->get('forum_id'), 0, 1);
     $oCategoriesData = $oForumModel->getCategory();
     $aCategoriesName = array();
     foreach ($oCategoriesData as $oId) {
         $aCategoriesName[$oId->categoryId] = $oId->title;
     }
     unset($oForumModel, $oCategoriesData);
     $sTitlePattern = Config::getInstance()->values['module.setting']['url_title.pattern'];
     $oForm = new \PFBC\Form('form_edit_forum', '100%');
     $oForm->configure(array('action' => ''));
     $oForm->addElement(new \PFBC\Element\Hidden('submit_edit_forum', 'form_edit_forum'));
     $oForm->addElement(new \PFBC\Element\Token('edit_forum'));
     $oForm->addElement(new \PFBC\Element\Select(t('Category Name:'), 'category_id', $aCategoriesName, array('value' => $oForumData->categoryId, 'required' => 1)));
     $oForm->addElement(new \PFBC\Element\Textbox(t('Forum Name:'), 'name', array('value' => $oForumData->name, 'id' => 'str_name', 'onblur' => 'CValid(this.value,this.id,2,60)', 'pattern' => $sTitlePattern, 'required' => 1, 'validation' => new \PFBC\Validation\RegExp($sTitlePattern))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_name"></span>'));
     $oForm->addElement(new \PFBC\Element\Textarea(t('Description:'), 'description', array('value' => $oForumData->description, 'id' => 'str_description', 'required' => 1, 'onblur' => 'CValid(this.value,this.id,4,255)', 'validation' => new \PFBC\Validation\Str(4, 255))));
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<span class="input_error str_description"></span>'));
     $oForm->addElement(new \PFBC\Element\Button());
     $oForm->addElement(new \PFBC\Element\HTMLExternal('<script src="' . PH7_URL_STATIC . PH7_JS . 'validate.js"></script>'));
     $oForm->render();
 }
コード例 #2
0
 public function __construct()
 {
     parent::__construct();
     $oForumModel = new ForumModel();
     $sMessage = $this->httpRequest->post('message', Http::ONLY_XSS_CLEAN);
     $sCurrentTime = $this->dateTime->get()->dateTime('Y-m-d H:i:s');
     $iTimeDelay = (int) DbConfig::getSetting('timeDelaySendForumTopic');
     $iProfileId = (int) $this->session->get('member_id');
     $iForumId = $this->httpRequest->get('forum_id', 'int');
     if (!$oForumModel->checkWaitTopic($iProfileId, $iTimeDelay, $sCurrentTime)) {
         \PFBC\Form::setError('form_msg', Form::waitWriteMsg($iTimeDelay));
     } elseif ($oForumModel->isDuplicateTopic($iProfileId, $sMessage)) {
         \PFBC\Form::setError('form_msg', Form::duplicateContentMsg());
     } else {
         $oForumModel->addTopic($iProfileId, $iForumId, $this->httpRequest->post('title'), $sMessage, $sCurrentTime);
         Header::redirect(Uri::get('forum', 'forum', 'post', $this->httpRequest->get('forum_name') . ',' . $iForumId . ',' . $this->httpRequest->post('title') . ',' . Db::getInstance()->lastInsertId()), t('Your message has been added successfully!'));
     }
     unset($oForumModel);
 }