public function __construct() { parent::__construct('hint-form'); $this->setAjax(TRUE); $this->setAction(OW::getRouter()->urlForRoute('profileprogressbar.admin_hint')); $this->setAjaxResetOnSuccess(FALSE); $this->bindJsFunction('success', 'function(data) { $("#profile-progressbar").tipTip({content: data.content}); OW.info("Settings successfully saved"); }'); $checkBox = new CheckboxField('show-hint'); if ((bool) OW::getConfig()->getValue('profileprogressbar', 'show_hint')) { $checkBox->addAttribute('checked', 'checked'); } $checkBox->setLabel(OW::getLanguage()->text('profileprogressbar', 'show_hint_label')); $checkBox->setDescription(OW::getLanguage()->text('profileprogressbar', 'show_hint_desc')); $this->addElement($checkBox); $hintText = new WysiwygTextarea('hint-text'); $hintText->setRequired(); $hintText->setSize(WysiwygTextarea::SIZE_L); $hintText->setValue(OW::getLanguage()->text('profileprogressbar', 'hint_text')); $hintText->setLabel(OW::getLanguage()->text('profileprogressbar', 'hint_label')); $hintText->setDescription(OW::getLanguage()->text('profileprogressbar', 'hint_desc')); $this->addElement($hintText); $submit = new Submit('save'); $submit->setValue('Save'); $this->addElement($submit); }
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(Post $post, $tags = array()) { parent::__construct('save'); $this->service = PostService::getInstance(); $this->post = $post; $this->setMethod('post'); $titleTextField = new TextField('title'); $this->addElement($titleTextField->setLabel(OW::getLanguage()->text('blogs', 'save_form_lbl_title'))->setValue($post->getTitle())->setRequired(true)); $buttons = array(BOL_TextFormatService::WS_BTN_BOLD, BOL_TextFormatService::WS_BTN_ITALIC, BOL_TextFormatService::WS_BTN_UNDERLINE, BOL_TextFormatService::WS_BTN_IMAGE, BOL_TextFormatService::WS_BTN_LINK, BOL_TextFormatService::WS_BTN_ORDERED_LIST, BOL_TextFormatService::WS_BTN_UNORDERED_LIST, BOL_TextFormatService::WS_BTN_MORE, BOL_TextFormatService::WS_BTN_SWITCH_HTML, BOL_TextFormatService::WS_BTN_HTML, BOL_TextFormatService::WS_BTN_VIDEO); $postTextArea = new WysiwygTextarea('post', $buttons); $postTextArea->setSize(WysiwygTextarea::SIZE_L); $postTextArea->setLabel(OW::getLanguage()->text('blogs', 'save_form_lbl_post')); $postTextArea->setValue($post->getPost()); $postTextArea->setRequired(true); $this->addElement($postTextArea); $draftSubmit = new Submit('draft'); $draftSubmit->addAttribute('onclick', "\$('#save_post_command').attr('value', 'draft');"); if ($post->getId() != null && !$post->isDraft()) { $text = OW::getLanguage()->text('blogs', 'change_status_draft'); } else { $text = OW::getLanguage()->text('blogs', 'sava_draft'); } $this->addElement($draftSubmit->setValue($text)); if ($post->getId() != null && !$post->isDraft()) { $text = OW::getLanguage()->text('blogs', 'update'); } else { $text = OW::getLanguage()->text('blogs', 'save_publish'); } $publishSubmit = new Submit('publish'); $publishSubmit->addAttribute('onclick', "\$('#save_post_command').attr('value', 'publish');"); $this->addElement($publishSubmit->setValue($text)); $tagService = BOL_TagService::getInstance(); $tags = array(); if (intval($this->post->getId()) > 0) { $arr = $tagService->findEntityTags($this->post->getId(), 'blog-post'); foreach (!empty($arr) ? $arr : array() as $dto) { $tags[] = $dto->getLabel(); } } $tf = new TagsInputField('tf'); $tf->setLabel(OW::getLanguage()->text('blogs', 'tags_field_label')); $tf->setValue($tags); $this->addElement($tf); }