/** * Class constructor * */ public function __construct() { parent::__construct('configSaveForm'); $language = OW::getLanguage(); $configs = OW::getConfig()->getValues('googlelocation'); $element = new TextField('api_key'); $element->setValue($configs['api_key']); $validator = new StringValidator(0, 40); $validator->setErrorMessage($language->text('googlelocation', 'api_key_too_long')); $element->addValidator($validator); $this->addElement($element); $options = array(GOOGLELOCATION_BOL_LocationService::DISTANCE_UNITS_MILES => $language->text('googlelocation', 'miles'), GOOGLELOCATION_BOL_LocationService::DISTANCE_UNITS_KM => $language->text('googlelocation', 'kms')); $distanseUnits = new Selectbox('distanse_units'); $distanseUnits->setOptions($options); $distanseUnits->setValue(GOOGLELOCATION_BOL_LocationService::getInstance()->getDistanseUnits()); $distanseUnits->setHasInvitation(false); $this->addElement($distanseUnits); $restrictions = new Selectbox('country_restriction'); $restrictions->setValue(!empty($configs['country_restriction']) ? $configs['country_restriction'] : null); $restrictions->setOptions($this->countryList); $restrictions->setInvitation(OW::getLanguage()->text('googlelocation', 'no_country_restriction')); $this->addElement($restrictions); $autofill = OW::getConfig()->getValue('googlelocation', 'auto_fill_location_on_search'); $autoFillLocationOnSearch = new CheckboxField('auto_fill_location_on_search'); $autoFillLocationOnSearch->setValue(empty($autofill) || $autofill == '0' ? false : $autofill); $this->addElement($autoFillLocationOnSearch); // submit $submit = new Submit('save'); $submit->setValue($language->text('base', 'edit_button')); $this->addElement($submit); }
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); } }
public function __construct() { parent::__construct('insertLink'); // title $titleField = new TextField('title'); $titleField->setRequired(true)->setHasInvitation(true)->setInvitation(OW::getLanguage()->text('base', 'ws_link_text_label')); $sValidator = new StringValidator(self::MIN_TITLE_LENGTH, self::MAX_TITLE_LENGTH); $sValidator->setErrorMessage(OW::getLanguage()->text('base', 'chars_limit_exceeded', array('limit' => self::MAX_TITLE_LENGTH))); $titleField->addValidator($sValidator); $this->addElement($titleField); // link $linkField = new TextField('link'); $linkField->setRequired(true)->setHasInvitation(true)->setInvitation(OW::getLanguage()->text('base', 'ws_link_url_label')); $sValidator = new StringValidator(self::MIN_LINK_LENGTH, self::MAX_LINK_LENGTH); $sValidator->setErrorMessage(OW::getLanguage()->text('base', 'chars_limit_exceeded', array('limit' => self::MAX_LINK_LENGTH))); $linkField->addValidator($sValidator); $linkField->addValidator(new UrlValidator()); $this->addElement($linkField); // submit $submit = new Submit('submit'); $submit->setValue(OW::getLanguage()->text('base', 'ws_insert_label')); $this->addElement($submit); }
/** * 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 edit group form * * @param string $action * @return Form */ private function generateEditGroupForm($action) { $form = new Form('edit-group-form'); $form->setAction($action); $lang = OW::getLanguage(); $groupName = new TextField('group-name'); $groupName->setRequired(true); $sValidator = new StringValidator(1, 255); $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 255))); $groupName->addValidator($sValidator); $form->addElement($groupName); $description = new Textarea('description'); $description->setRequired(true); $sValidator = new StringValidator(1, 50000); $sValidator->setErrorMessage($lang->text('forum', 'chars_limit_exceeded', array('limit' => 50000))); $description->addValidator($sValidator); $form->addElement($description); $groupId = new HiddenField('group-id'); $groupId->setRequired(true); $form->addElement($groupId); $isPrivate = new CheckboxField('is-private'); $form->addElement($isPrivate); $roles = new CheckboxGroup('roles'); $authService = BOL_AuthorizationService::getInstance(); $roleList = $authService->getRoleList(); $options = array(); foreach ($roleList as $role) { $options[$role->id] = $authService->getRoleLabel($role->name); } $roles->addOptions($options); $roles->setColumnCount(2); $form->addElement($roles); $submit = new Submit('save'); $submit->setValue($lang->text('forum', 'edit_group_btn')); $form->addElement($submit); $form->setAjax(true); return $form; }
/** * 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; }
/** * Constructor. * * @param string $name */ public function __construct($name, array $buttons = null, $init = true) { parent::__construct($name); $this->service = BOL_TextFormatService::getInstance(); $this->init = (bool) $init; if (!empty($buttons)) { $buttons = array_unique(array_merge($buttons, array(BOL_TextFormatService::WS_BTN_BOLD, BOL_TextFormatService::WS_BTN_ITALIC, BOL_TextFormatService::WS_BTN_UNDERLINE, BOL_TextFormatService::WS_BTN_LINK, BOL_TextFormatService::WS_BTN_ORDERED_LIST, BOL_TextFormatService::WS_BTN_UNORDERED_LIST))); } else { $buttons = array(BOL_TextFormatService::WS_BTN_BOLD, BOL_TextFormatService::WS_BTN_ITALIC, BOL_TextFormatService::WS_BTN_UNDERLINE, BOL_TextFormatService::WS_BTN_LINK, BOL_TextFormatService::WS_BTN_ORDERED_LIST, BOL_TextFormatService::WS_BTN_UNORDERED_LIST); } $this->buttons = $this->processButtons($buttons); $this->size = self::SIZE_M; if (OW::getRequest()->isMobileUserAgent()) { $this->textarea = new Textarea($name); } $stringValidator = new StringValidator(0, 50000); $stringValidator->setErrorMessage(OW::getLanguage()->text('base', 'text_is_too_long', array('max_symbols_count' => 50000))); $this->addValidator($stringValidator); }
/** * 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; }
/** * Class constructor * */ public function __construct(MAILBOX_CMP_NewMessage $component = null) { $language = OW::getLanguage(); parent::__construct('mailbox-new-message-form'); $this->setId('mailbox-new-message-form'); $this->setAjax(true); $this->setAjaxResetOnSuccess(false); $this->setAction(OW::getRouter()->urlFor('MAILBOX_CTRL_Ajax', 'newMessage')); $this->setEmptyElementsErrorMessage(''); $this->setEnctype('multipart/form-data'); $subject = new TextField('subject'); // $subject->setHasInvitation(true); // $subject->setInvitation($language->text('mailbox', 'subject')); $subject->addAttribute('placeholder', $language->text('mailbox', 'subject')); $requiredValidator = new RequiredValidator(); $requiredValidator->setErrorMessage($language->text('mailbox', 'subject_is_required')); $subject->addValidator($requiredValidator); $validatorSubject = new StringValidator(1, 2048); $validatorSubject->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => 2048))); $subject->addValidator($validatorSubject); $this->addElement($subject); $validator = new StringValidator(1, MAILBOX_BOL_AjaxService::MAX_MESSAGE_TEXT_LENGTH); $validator->setErrorMessage($language->text('mailbox', 'message_too_long_error', array('maxLength' => MAILBOX_BOL_AjaxService::MAX_MESSAGE_TEXT_LENGTH))); $textarea = OW::getClassInstance("MAILBOX_CLASS_Textarea", "message"); /* @var $textarea MAILBOX_CLASS_Textarea */ $textarea->addValidator($validator); $textarea->setCustomBodyClass("mailbox"); // $textarea->setHasInvitation(true); // $textarea->setInvitation($language->text('mailbox', 'message_invitation')); $textarea->addAttribute('placeholder', $language->text('mailbox', 'message_invitation')); $requiredValidator = new RequiredValidator(); $requiredValidator->setErrorMessage($language->text('mailbox', 'chat_message_empty')); $textarea->addValidator($requiredValidator); $this->addElement($textarea); $user = OW::getClassInstance("MAILBOX_CLASS_UserField", "opponentId"); /* @var $user MAILBOX_CLASS_UserField */ // $user->setHasInvitation(true); // $user->setInvitation($language->text('mailbox', 'to')); $requiredValidator = new RequiredValidator(); $requiredValidator->setErrorMessage($language->text('mailbox', 'recipient_is_required')); $user->addValidator($requiredValidator); $this->addElement($user); if (OW::getSession()->isKeySet('mailbox.new_message_form_attachments_uid')) { $uidValue = OW::getSession()->get('mailbox.new_message_form_attachments_uid'); } else { $uidValue = UTIL_HtmlTag::generateAutoId('mailbox_new_message'); OW::getSession()->set('mailbox.new_message_form_attachments_uid', $uidValue); } $uid = new HiddenField('uid'); $uid->setValue($uidValue); $this->addElement($uid); $configs = OW::getConfig()->getValues('mailbox'); if (!empty($configs['enable_attachments']) && !empty($component)) { $attachmentCmp = new BASE_CLASS_FileAttachment('mailbox', $uidValue); $attachmentCmp->setInputSelector('#newMessageWindowAttachmentsBtn'); $component->addComponent('attachments', $attachmentCmp); } $submit = new Submit("send"); $submit->setValue($language->text('mailbox', 'send_button')); $this->addElement($submit); if (!OW::getRequest()->isAjax()) { $this->initStatic(); } }
/** * 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; }