Esempio n. 1
0
 /**
  * Generates move topic form.
  *
  * @param string $actionUrl
  * @param $groupSelect
  * @param $topicDto
  * @return Form
  */
 private function generateMoveTopicForm($actionUrl, $groupSelect, $topicDto)
 {
     $form = new Form('move-topic-form');
     $form->setAction($actionUrl);
     $topicIdField = new HiddenField('topic-id');
     $topicIdField->setValue($topicDto->id);
     $form->addElement($topicIdField);
     $group = new ForumSelectBox('group-id');
     $group->setOptions($groupSelect);
     $group->setValue($topicDto->groupId);
     $group->addAttribute("style", "width: 300px;");
     $group->setRequired(true);
     $form->addElement($group);
     $submit = new Submit('save');
     $submit->setValue(OW::getLanguage()->text('forum', 'move_topic_btn'));
     $form->addElement($submit);
     $form->setAjax(true);
     return $form;
 }
Esempio n. 2
0
 /**
  * Generates Add Topic Form.
  *
  * @param array $groupSelect
  * @param int $groupId
  * @return Form
  */
 private function generateForm($groupSelect, $groupId, $isHidden)
 {
     $form = new Form('add-topic-form');
     $form->setEnctype("multipart/form-data");
     $lang = OW::getLanguage();
     $title = new TextField('title');
     $title->setRequired(true);
     $sValidator = new StringValidator(1, 255);
     $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 255)));
     $title->addValidator($sValidator);
     $form->addElement($title);
     if ($isHidden) {
         $group = new HiddenField('group');
         $group->setValue($groupId);
     } else {
         $group = new ForumSelectBox('group');
         $group->setOptions($groupSelect);
         if ($groupId) {
             $group->setValue($groupId);
         }
         $group->setRequired(true);
         $group->addValidator(new IntValidator());
     }
     $form->addElement($group);
     $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML);
     $text = new WysiwygTextarea('text', $btnSet);
     $text->setRequired(true);
     $sValidator = new StringValidator(1, 50000);
     $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 50000)));
     $text->addValidator($sValidator);
     $form->addElement($text);
     $subscribe = new CheckboxField('subscribe');
     $subscribe->setLabel($lang->text('forum', 'subscribe'));
     $subscribe->setValue(true);
     $form->addElement($subscribe);
     $post = new Submit('post');
     $post->setValue($lang->text('forum', 'add_post_btn'));
     $form->addElement($post);
     $attachmentField = new MultiFileField('attachments', 5);
     $form->addElement($attachmentField);
     $this->addForm($form);
     return $form;
 }