public function __construct($interlocutorId) { $language = OW::getLanguage(); parent::__construct('mailbox-create-conversation-form'); $this->setAction(OW::getRouter()->urlFor('MAILBOX_CTRL_Mailbox', 'sendMessageAjaxResponder', array('userId' => $interlocutorId))); $this->setId('mailbox-create-conversation-form'); $this->setEnctype('multipart/form-data'); $this->setAjax(); $this->setAjaxResetOnSuccess(false); $hidden = new HiddenField('userId'); $hidden->setValue($interlocutorId); $this->addElement($hidden); //thickbox $validatorSubject = new StringValidator(0, 2048); $validatorSubject->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 2048))); $subject = new TextField('subject'); $subject->setLabel($language->text('mailbox', 'subject'))->addAttribute('class', 'ow_text'); $subject->addValidator($validatorSubject); $subject->setRequired(true); $this->addElement($subject); $validatorTextarea = new StringValidator(0, 24000); $validatorTextarea->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 24000))); $message = new WysiwygTextarea('message', array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO), false); $message->setLabel($language->text('mailbox', 'text'))->addAttribute('class', 'ow_text'); $message->addAttribute('rows', '10'); $message->addValidator($validatorTextarea); $message->setRequired(true); $this->addElement($message); if (OW::getConfig()->getValue('mailbox', 'enable_attachments')) { $multiUpload = new MAILBOX_CLASS_AjaxFileUpload('attachments'); $multiUpload->setId('attachments'); $this->addElement($multiUpload); } $captcha = new MailboxCaptchaField('captcha'); $captcha->addValidator(new MailboxCaptchaValidator($captcha->getId())); $LastSendStamp = BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_create_conversation_stamp', OW::getUser()->getId()); $this->displayCapcha = BOL_PreferenceService::getInstance()->getPreferenceValue('mailbox_create_conversation_display_capcha', OW::getUser()->getId()); if (!$this->displayCapcha && $LastSendStamp + self::DISPLAY_CAPTCHA_TIMEOUT > time()) { BOL_PreferenceService::getInstance()->savePreferenceValue('mailbox_create_conversation_display_capcha', true, OW::getUser()->getId()); $this->displayCapcha = true; } $captcha->addAttribute('disabled', 'disabled'); $this->addElement($captcha); $submit = new Submit('send'); $submit->setValue($language->text('mailbox', 'send_button')); $submit->addAttribute('class', 'ow_button ow_ic_mail'); $this->addElement($submit); if (!OW::getRequest()->isAjax()) { $messageError = $language->text('mailbox', 'create_conversation_fail_message'); $messageSuccess = $language->text('mailbox', 'create_conversation_message'); $js = " owForms['mailbox-create-conversation-form'].bind( 'success',\n function( json )\n {\n var from = \$('#mailbox-create-conversation-form');\n var captcha = from.find('input[name=captcha]');\n\n if ( json.result == 'permission_denied' )\n {\n if ( json.message != undefined )\n {\n OW.error(json.message);\n }\n else\n {\n OW.error(" . json_encode(OW::getLanguage()->text('mailbox', 'write_permission_denied')) . ");\n }\n }\n else if ( json.result == 'display_captcha' )\n \t{\n window." . $captcha->jsObjectName . ".refresh();\n\n if ( captcha.attr('disabled') != 'disabled' )\n {\n owForms['mailbox-create-conversation-form'].getElement('captcha').showError(" . json_encode(OW::getLanguage()->text('base', 'form_validator_captcha_error_message')) . ");\n }\n else\n {\n captcha.removeAttr('disabled');\n }\n\n from.find('tr.captcha').show();\n from.find('tr.mailbox_conversation').hide();\n }\n else if ( json.result == true )\n \t{\n \t window.mailbox_send_message_floatbox.close();\n \$('#attach_file_inputs').hide();\n\n captcha.attr('disabled','disabled');\n from.find('tr.captcha').hide();\n owForms['mailbox-create-conversation-form'].resetForm();\n window." . $captcha->jsObjectName . ".refresh();\n\n \t OW.info('{$messageSuccess}');\n from.find('tr.captcha').hide();\n from.find('tr.mailbox_conversation').show();\n }\n else\n {\n OW.error('{$messageError}');\n }\n\n \$('#mailbox-create-conversation-form input[name=userId]').val(" . $interlocutorId . ");\n\n \t} ); "; OW::getDocument()->addOnloadScript($js); } }
public function __construct($name, $senderId, $context = MCOMPOSE_BOL_Service::CONTEXT_USER, $initJs = true, $inPopup = true) { parent::__construct($name); $language = OW::getLanguage(); $this->userId = $senderId; $this->context = $context; $this->setAction(OW::getRouter()->urlFor('MCOMPOSE_CTRL_Compose', 'send', array('userId' => $senderId, 'formName' => $this->getName()))); $this->setMethod(self::METHOD_POST); $this->setId($this->getName()); $this->setEnctype('multipart/form-data'); $this->setAjax(); $this->setAjaxResetOnSuccess(false); $to = new MCOMPOSE_CLASS_UserSelectField('recipients', OW::getLanguage()->text('mcompose', 'selector_invitation_label')); $to->setRequired(); $this->addElement($to); //thickbox $validatorSubject = new StringValidator(0, 2048); $validatorSubject->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 2048))); $subject = new TextField('subject'); $subject->setInvitation('Subject'); $subject->setHasInvitation(true); $subject->setLabel($language->text('mailbox', 'subject'))->addAttribute('class', 'ow_text'); $subject->addValidator($validatorSubject); $subject->setRequired(true); $this->addElement($subject); $validatorTextarea = new StringValidator(0, 24000); $validatorTextarea->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 24000))); $message = new WysiwygTextarea('message', array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO), true); $message->setLabel($language->text('mailbox', 'text'))->addAttribute('class', 'ow_text'); $message->setSize(300); $message->addValidator($validatorTextarea); $message->setRequired(true); $this->addElement($message); if (OW::getConfig()->getValue('mailbox', 'enable_attachments')) { $multiUpload = new MAILBOX_CLASS_AjaxFileUpload('attachments'); //$multiUpload->setId('attachments'); $this->addElement($multiUpload); } // Captcha $captcha = new MailboxCaptchaField('captcha'); $captcha->addValidator(new MailboxCaptchaValidator($captcha->getId())); $captcha->addAttribute('disabled', 'disabled'); $this->addElement($captcha); $submit = new Submit('send'); $submit->setValue($language->text('mailbox', 'send_button')); $submit->addAttribute('class', 'ow_button ow_ic_mail'); $this->addElement($submit); if ($initJs) { $js = "owForms['" . $this->getName() . "'].bind( 'success',\n function( json )\n {\n var _complete = function(){ \n if ( _scope.floatBox ) _scope.floatBox.close();\n };\n\n var form = \$('#" . $this->getName() . "');\n var captcha = form.find('input[name=captcha]');\n\n if ( json.result == 'permission_denied' )\n {\n if ( json.message )\n {\n OW.error(json.message);\n }\n else\n {\n OW.error(" . json_encode(OW::getLanguage()->text('mailbox', 'write_permission_denied')) . ");\n }\n \n _complete();\n }\n else if ( json.result == 'display_captcha' )\n \t{\n window." . $captcha->jsObjectName . ".refresh();\n\n if ( captcha.attr('disabled') != 'disabled' )\n {\n owForms['" . $this->getName() . "'].getElement('captcha').showError(" . json_encode(OW::getLanguage()->text('base', 'form_validator_captcha_error_message')) . ");\n }\n else\n {\n captcha.removeAttr('disabled');\n }\n\n form.find('tr.captcha').show();\n form.find('tr.mailbox_conversation').hide();\n }\n else if ( json.result == true )\n \t{\n captcha.attr('disabled','disabled');\n form.find('tr.captcha').hide();\n window." . $captcha->jsObjectName . ".refresh();\n\n form.find('tr.captcha').hide();\n form.find('tr.mailbox_conversation').show();\n\n owForms['" . $this->getName() . "'].resetForm();\n form.find('textarea[name=message]').get(0).htmlareaRefresh();\n\n if ( json.error )\n OW.error(json.error);\n\n if ( json.warning )\n OW.warning(json.warning);\n\n if ( json.message )\n OW.info(json.message);\n \n _complete();\n }\n else if ( json.error )\n {\n OW.error(json.error);\n \n _complete();\n }\n\n }); "; OW::getDocument()->addOnloadScript($js); } }
/** * Class constructor */ public function __construct() { parent::__construct('edit-goal-form'); $this->setAction(OW::getRouter()->urlFor('OCSFUNDRAISING_CTRL_Admin', 'editGoal')); $this->setEnctype(Form::ENCTYPE_MULTYPART_FORMDATA); $lang = OW::getLanguage(); $id = new HiddenField('goalId'); $this->addElement($id); $name = new TextField('name'); $name->setRequired(true); $name->setLabel($lang->text('ocsfundraising', 'name')); $this->addElement($name); $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML); $desc = new WysiwygTextarea('description', $btnSet); $desc->setRequired(true); $sValidator = new StringValidator(1, 50000); $desc->addValidator($sValidator); $desc->setLabel($lang->text('ocsfundraising', 'description')); $this->addElement($desc); $category = new Selectbox('category'); $category->setLabel($lang->text('ocsfundraising', 'category')); $list = OCSFUNDRAISING_BOL_Service::getInstance()->getCategoryList(); if ($list) { foreach ($list as $cat) { $category->addOption($cat->id, $lang->text('ocsfundraising', 'category_' . $cat->id)); } } $this->addElement($category); $target = new TextField('target'); $target->setRequired(true); $target->setLabel($lang->text('ocsfundraising', 'target_amount')); $this->addElement($target); $current = new TextField('current'); $current->setRequired(true); $current->setLabel($lang->text('ocsfundraising', 'current_amount')); $this->addElement($current); $min = new TextField('min'); $min->setLabel($lang->text('ocsfundraising', 'min_amount')); $this->addElement($min); $end = new DateField('end'); $end->setMinYear(date('Y')); $end->setMaxYear(date('Y') + 2); $end->setLabel($lang->text('ocsfundraising', 'end_date')); $this->addElement($end); $imageField = new FileField('image'); $imageField->setLabel($lang->text('ocsfundraising', 'image_label')); $this->addElement($imageField); $submit = new Submit('update'); $submit->setLabel($lang->text('base', 'save')); $this->addElement($submit); }
public function __construct($userId) { parent::__construct(); $form = new Form("send_message_form"); $form->setAjax(true); $form->setAjaxResetOnSuccess(true); $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_AjaxSendMessageToEmail', 'sendMessage')); $user = new HiddenField("userId"); $user->setValue($userId); $form->addElement($user); $subject = new TextField('subject'); $subject->setInvitation(OW::getLanguage()->text('base', 'subject')); $subject->setRequired(true); $form->addElement($subject); $textarea = new WysiwygTextarea("message"); $textarea->setInvitation(OW::getLanguage()->text('base', 'message_invitation')); $requiredValidator = new WyswygRequiredValidator(); $requiredValidator->setErrorMessage(OW::getLanguage()->text('base', 'message_empty')); $textarea->addValidator($requiredValidator); $form->addElement($textarea); $submit = new Submit('send'); $submit->setLabel(OW::getLanguage()->text('base', 'send')); $form->addElement($submit); $form->bindJsFunction(Form::BIND_SUCCESS, ' function ( data ) { if ( data.result ) { OW.info(data.message); } else { OW.error(data.message); } if ( OW.getActiveFloatBox() ) { OW.getActiveFloatBox().close(); } } '); $this->addForm($form); }
/** * Class constructor * */ public function __construct() { $language = OW::getLanguage(); parent::__construct('mailbox-add-message-form'); $this->setId('mailbox-add-message-form'); $this->setEnctype('multipart/form-data'); $validator = new StringValidator(0, 24000); $validator->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 24000))); $textarea = new WysiwygTextarea('message', array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO), false); $textarea->addValidator($validator); $textarea->setHasInvitation(true); $textarea->setInvitation($language->text('mailbox', 'write_here')); $textarea->setRequired(true); $this->addElement($textarea); OW::getDocument()->addOnloadScript("\$('#{$textarea->getId()}').focus(function(){this.htmlarea();this.htmlareaFocus();});"); $configs = OW::getConfig()->getValues('mailbox'); if (!empty($configs['enable_attachments'])) { $multiUpload = new MultiFileField('attachments', 5); $this->addElement($multiUpload); } $submit = new Submit("add"); $submit->setValue($language->text('mailbox', 'add_button')); $this->addElement($submit); }
/** * Generates add post form. * * @param int $topicId * @param string $uid * @return Form */ private function generateAddPostForm($topicId, $uid) { $form = new Form('add-post-form'); $form->setEnctype('multipart/form-data'); $lang = OW::getLanguage(); $addPostUrl = OW::getRouter()->urlForRoute('add-post', array('topicId' => $topicId, 'uid' => $uid)); $form->setAction($addPostUrl); $topicIdField = new HiddenField('topic'); $topicIdField->setValue($topicId); $form->addElement($topicIdField); $attachmentUid = new HiddenField('attachmentUid'); $attachmentUid->setValue($uid); $attachmentUid->setRequired(true); $form->addElement($attachmentUid); $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML); $postText = new WysiwygTextarea('text', $btnSet); $postText->setRequired(true); $sValidator = new StringValidator(1, 50000); $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 50000))); $postText->addValidator($sValidator); $form->addElement($postText); $submit = new Submit('submit'); $submit->setValue($lang->text('forum', 'add_post_btn')); $form->addElement($submit); return $form; }
/** * 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; }
/** * Generates edit topic form. * * @param $topicDto * @param $postDto * @param $uid * @return Form */ private function generateEditTopicForm($topicDto, $postDto, $uid) { $form = new Form('edit-topic-form'); $form->setEnctype('multipart/form-data'); $lang = OW::getLanguage(); $topicIdField = new HiddenField('topic-id'); $topicIdField->setValue($topicDto->id); $form->addElement($topicIdField); $postIdField = new HiddenField('post-id'); $postIdField->setValue($postDto->id); $form->addElement($postIdField); $attachmentUid = new HiddenField('attachmentUid'); $attachmentUid->setValue($uid); $attachmentUid->setRequired(true); $form->addElement($attachmentUid); $topicTitleField = new TextField('title'); $topicTitleField->setValue($topicDto->title); $topicTitleField->setRequired(true); $sValidator = new StringValidator(1, 255); $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 255))); $topicTitleField->addValidator($sValidator); $form->addElement($topicTitleField); $btnSet = array(BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_VIDEO, BOL_TextFormatService::WS_BTN_HTML); $postText = new WysiwygTextarea('text', $btnSet); $postText->setValue($postDto->text); $postText->setRequired(true); $sValidator = new StringValidator(1, 50000); $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 50000))); $postText->addValidator($sValidator); $form->addElement($postText); $submit = new Submit('save'); $submit->setValue($lang->text('base', 'edit_button')); $form->addElement($submit); return $form; }