Exemple #1
0
 /**
  * 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);
 }
 private function assertRdfOutputForCase($case)
 {
     if (isset($case['exportcontroller']['syntax']) && $case['exportcontroller']['syntax'] === 'turtle') {
         $serializer = new TurtleSerializer();
     } else {
         $serializer = new RDFXMLSerializer();
     }
     $exportController = new ExportController($serializer);
     $exportController->enableBacklinks($case['exportcontroller']['parameters']['backlinks']);
     ob_start();
     if (isset($case['exportcontroller']['print-pages'])) {
         $exportController->printPages($case['exportcontroller']['print-pages'], (int) $case['exportcontroller']['parameters']['recursion'], $case['exportcontroller']['parameters']['revisiondate']);
     }
     if (isset($case['exportcontroller']['wiki-info'])) {
         $exportController->printWikiInfo();
     }
     $output = ob_get_clean();
     if ($this->debug) {
         print_r($output);
     }
     if (isset($case['assert-output']['to-contain'])) {
         $this->stringValidator->assertThatStringContains($case['assert-output']['to-contain'], $output, $case['about']);
     }
     if (isset($case['assert-output']['not-contain'])) {
         $this->stringValidator->assertThatStringNotContains($case['assert-output']['not-contain'], $output, $case['about']);
     }
 }
 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);
     }
 }
 function validate()
 {
     $this->_helpId = trim($this->_request->getValue("helpId"));
     $val = new StringValidator();
     if (!$val->validate($this->_helpId)) {
         $this->_view = new AdminSimpleErrorView();
         $this->_view->setValue("error", "Incorrect identifier.");
         return false;
     }
     return true;
 }
 function validate()
 {
     $this->_searchTerms = $this->_request->getValue("searchTerms");
     // if the search terms are not correct, let's return an error message
     $val = new StringValidator();
     if (!$val->validate($this->_searchTerms)) {
         $this->_view = new SummaryView("summaryerror");
         $this->_view->setErrorMessage($this->_locale->tr("error_incorrect_search_terms"));
         return false;
     }
     return true;
 }
 function validate()
 {
     $this->_host = $this->_request->getValue("hostIp");
     $val = new StringValidator();
     if (!$val->validate($this->_host)) {
         $this->_view = new AdminErrorView($this->_blogInfo);
         $this->_view->setMessage("The host address is not correct.");
         $this->setCommonData();
         return false;
     }
     return true;
 }
Exemple #7
0
 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);
     }
 }
 function validate()
 {
     $this->_userNameHash = $this->_request->getValue("b");
     $this->_requestHash = $this->_request->getValue("a");
     // check that the parameters are there...
     $val = new StringValidator();
     if (!$val->validate($this->_userNameHash) || !$val->validate($this->_requestHash)) {
         $this->_view = new SummaryView("summaryerror");
         $this->_view->setErrorMessage($this->_locale->tr("error_incorrect_request"));
         return false;
     }
     return true;
 }
 /**
  * @covers StringValidator::setPatternValid
  * @todo Implement testSetPatternValid().
  */
 public function testSetRequiredValid()
 {
     $errorMsg = "The input is required";
     $this->object->setRequireValid($errorMsg);
     $testValue = "";
     $result = $this->object->validate($testValue);
     $this->assertEquals($result[0], $errorMsg);
     $this->object->setRequireValid();
     $testValue = "";
     $errorMsg = "ERROR!";
     $result = $this->object->validate($testValue);
     $this->assertEquals($result[0], $errorMsg);
 }
 private function assertOutputForCase($case, $text)
 {
     if (!isset($case['expected-output']) || !isset($case['expected-output']['to-contain'])) {
         return;
     }
     $this->stringValidator->assertThatStringContains($case['expected-output']['to-contain'], $text, $case['about']);
 }
Exemple #11
0
 public function __construct($minLength = 0, $maxLength = null)
 {
     if (func_num_args() == 1) {
         $maxLength = $minLength;
     }
     parent::__construct($minLength, $maxLength, 's');
 }
 private function assertParserOutputForCase($case)
 {
     if (!isset($case['expected-output']) || !isset($case['expected-output']['to-contain'])) {
         return;
     }
     $subject = DIWikiPage::newFromText($case['subject'], isset($case['namespace']) ? constant($case['namespace']) : NS_MAIN);
     $parserOutput = UtilityFactory::getInstance()->newPageReader()->getEditInfo($subject->getTitle())->output;
     $this->stringValidator->assertThatStringContains($case['expected-output']['to-contain'], $parserOutput->getText(), $case['about']);
 }
 private function assertOutputForCase($case, $text)
 {
     if (isset($case['assert-output']['to-contain'])) {
         $this->stringValidator->assertThatStringContains($case['assert-output']['to-contain'], $text, $case['about']);
     }
     if (isset($case['assert-output']['not-contain'])) {
         $this->stringValidator->assertThatStringNotContains($case['assert-output']['not-contain'], $text, $case['about']);
     }
 }
 function validate()
 {
     $this->_pluginEnabled = $this->_request->getValue("pluginEnabled");
     $this->_pluginEnabled = $this->_pluginEnabled != "";
     $this->_maxBackupFiles = $this->_request->getValue("maxBackupFiles");
     if ($this->_maxBackupFiles <= 0 || !ctype_digit($this->_maxBackupFiles)) {
         $this->_view = new PluginTemplateEditorConfigView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("templateeditor_error_maxbackupfiles"));
         $this->setCommonData();
         return false;
     }
     $this->_allowedExtension = $this->_request->getValue("allowedExtension");
     $val = new StringValidator();
     if (!$val->validate($this->_allowedExtension)) {
         $this->_view = new PluginTemplateEditorConfigView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("templateeditor_error_allowedextension"));
         $this->setCommonData();
         return false;
     }
     return true;
 }
 public function validateValue(Validatable $validateable)
 {
     $response = parent::validateValue($validateable);
     if ($response != null) {
         return $response;
     }
     if (strlen($validateable->getValue()) > $this->maximum) {
         $response = new ValidationResponse($this->getKeyName());
         $response->addValue('maxLength', $this->maximum);
         return $response;
     }
 }
 public function validateValue(Validatable $validateable)
 {
     $response = parent::validateValue($validateable);
     if ($response != null) {
         return $response;
     }
     if (preg_match("/" . $this->pattern . "/", $validateable->getValue()) != 1) {
         $response = new ValidationResponse($this->getKeyName(), $validateable->getValue());
         $response->addValue('expression', $this->pattern);
         return $response;
     }
 }
Exemple #17
0
 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);
 }
Exemple #18
0
 /**
  * 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);
 }
Exemple #19
0
 public function validate($input)
 {
     $pre = parent::validate($input);
     if ($pre !== true) {
         return $pre;
     }
     if ($input[2] !== '/' || $input[5] !== '/') {
         return self::$ERROR_WRONG_SEPARATOR;
     }
     list($day, $month, $year) = explode('/', $input);
     if ($day <= 0 || $day > 31 || $month <= 0 || $month > 12 || $year <= 0 || $year >= 3000) {
         return self::$ERROR_NOT_VALID;
     }
     return true;
 }
Exemple #20
0
 public function validate($value)
 {
     $parentValidation = parent::validate($value);
     if ($parentValidation === true) {
         if (filter_var($value, FILTER_VALIDATE_EMAIL) === false) {
             return self::$ERROR_SYNTAX_INVALID;
         }
         $host = substr($value, strpos($value, '@') + 1);
         if ($this->options['checkMX'] && !$this->checkMX($host)) {
             return self::$ERROR_HOST_VALID;
         }
         if ($this->options['checkHost'] && $this->checkHost($host)) {
             return self::$ERROR_HOST_VALID;
         }
         return true;
     } else {
         return $parentValidation;
     }
 }
 function validate()
 {
     $this->_debug = false;
     $this->_hostname = $this->_request->getValue("hostname");
     $this->_username = $this->_request->getValue("username");
     $this->_password = $this->_request->getValue("password");
     $this->_dbname = $this->_request->getValue("dbname");
     $this->_prefix = $this->_request->getValue("prefix");
     $this->_profile = $this->_request->getValue("profile");
     $val = new StringValidator();
     if (!$val->validate($this->_hostname) || !$val->validate($this->_username) || !$val->validate($this->_password) || !$val->validate($this->_dbname) || !$val->validate($this->_profile)) {
         $this->_view = new AdminErrorView($this->_blogInfo);
         $this->_view->setMessage("There was an error:  either your inputted hostname, usernae, password, dbname, or profile were invalid.  Please try again.");
         $this->setCommonData();
         return false;
     }
     return true;
 }
 public function __construct(\Happymeal\Port\Adaptor\Data\XML\Schema\String $tdo, \Happymeal\Port\Adaptor\Data\ValidationHandler $handler)
 {
     parent::__construct($tdo, $handler);
 }
Exemple #23
0
 /**
  * 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;
 }
Exemple #24
0
 /**
  * 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;
 }
Exemple #25
0
 /**
  * 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);
 }
Exemple #26
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;
 }
 /**
  * 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;
 }
 /**
  * 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();
     }
 }