public function __construct() { parent::__construct(); $language = OW::getLanguage(); $serviceLang = BOL_LanguageService::getInstance(); $addSectionForm = new Form('qst_add_section_form'); $addSectionForm->setAjax(); $addSectionForm->setAjaxResetOnSuccess(true); $addSectionForm->setAction(OW::getRouter()->urlFor("ADMIN_CTRL_Questions", "ajaxResponder")); $input = new HiddenField('command'); $input->setValue('addSection'); $addSectionForm->addElement($input); $qstSectionName = new TextField('section_name'); $qstSectionName->addAttribute('class', 'ow_text'); $qstSectionName->addAttribute('style', 'width: auto;'); $qstSectionName->setRequired(); $qstSectionName->setLabel($language->text('admin', 'questions_new_section_label')); $addSectionForm->addElement($qstSectionName); $this->addForm($addSectionForm); $addSectionForm->bindJsFunction('success', ' function (result) { if ( result.result ) { OW.info(result.message); } else { OW.error(result.message); } window.location.reload(); } '); }
public function __construct() { parent::__construct(); $language = OW::getLanguage(); $form = new Form("change-user-password"); $form->setId("change-user-password"); $oldPassword = new PasswordField('oldPassword'); $oldPassword->setLabel($language->text('base', 'change_password_old_password')); $oldPassword->addValidator(new OldPasswordValidator()); $oldPassword->setRequired(); $form->addElement($oldPassword); $newPassword = new PasswordField('password'); $newPassword->setLabel($language->text('base', 'change_password_new_password')); $newPassword->setRequired(); $newPassword->addValidator(new NewPasswordValidator()); $form->addElement($newPassword); $repeatPassword = new PasswordField('repeatPassword'); $repeatPassword->setLabel($language->text('base', 'change_password_repeat_password')); $repeatPassword->setRequired(); $form->addElement($repeatPassword); $submit = new Submit("change"); $submit->setLabel($language->text('base', 'change_password_submit')); $form->setAjax(true); $form->setAjaxResetOnSuccess(false); $form->addElement($submit); if (OW::getRequest()->isAjax()) { $result = false; if ($form->isValid($_POST)) { $data = $form->getValues(); BOL_UserService::getInstance()->updatePassword(OW::getUser()->getId(), $data['password']); $result = true; } echo json_encode(array('result' => $result)); exit; } else { $messageError = $language->text('base', 'change_password_error'); $messageSuccess = $language->text('base', 'change_password_success'); $form->bindJsFunction(FORM::BIND_SUCCESS, "function( json )\n {\n \tif( json.result )\n \t{\n \t var floatbox = OW.getActiveFloatBox();\n\n if ( floatbox )\n {\n floatbox.close();\n }\n\n \t OW.info(" . json_encode($messageSuccess) . ");\n }\n else\n {\n OW.error(" . json_encode($messageError) . ");\n }\n\n } "); $this->addForm($form); $language->addKeyForJs('base', 'join_error_password_not_valid'); $language->addKeyForJs('base', 'join_error_password_too_short'); $language->addKeyForJs('base', 'join_error_password_too_long'); //include js $onLoadJs = " window.changePassword = new OW_BaseFieldValidators( " . json_encode(array('formName' => $form->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Join", "ajaxResponder"), 'passwordMaxLength' => UTIL_Validator::PASSWORD_MAX_LENGTH, 'passwordMinLength' => UTIL_Validator::PASSWORD_MIN_LENGTH)) . ",\n " . UTIL_Validator::EMAIL_PATTERN . ", " . UTIL_Validator::USER_NAME_PATTERN . " ); "; $onLoadJs .= " window.oldPassword = new OW_ChangePassword( " . json_encode(array('formName' => $form->getName(), 'responderUrl' => OW::getRouter()->urlFor("BASE_CTRL_Edit", "ajaxResponder"))) . " ); "; OW::getDocument()->addOnloadScript($onLoadJs); $jsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl(); OW::getDocument()->addScript($jsDir . "base_field_validators.js"); OW::getDocument()->addScript($jsDir . "change_password.js"); } }
/** * Constructor. * * @param array $itemsList */ public function __construct($langId) { parent::__construct(); $this->service = BOL_LanguageService::getInstance(); if (empty($langId)) { $this->setVisible(false); return; } $languageDto = $this->service->findById($langId); if ($languageDto === null) { $this->setVisible(false); return; } $language = OW::getLanguage(); $form = new Form('lang_edit'); $form->setAjax(); $form->setAction(OW::getRouter()->urlFor('ADMIN_CTRL_Languages', 'langEditFormResponder')); $form->setAjaxResetOnSuccess(false); $labelTextField = new TextField('label'); $labelTextField->setLabel($language->text('admin', 'clone_form_lbl_label')); $labelTextField->setDescription($language->text('admin', 'clone_form_descr_label')); $labelTextField->setRequired(); $labelTextField->setValue($languageDto->getLabel()); $form->addElement($labelTextField); $tagTextField = new TextField('tag'); $tagTextField->setLabel($language->text('admin', 'clone_form_lbl_tag')); $tagTextField->setDescription($language->text('admin', 'clone_form_descr_tag')); $tagTextField->setRequired(); $tagTextField->setValue($languageDto->getTag()); if ($languageDto->getTag() == 'en') { $tagTextField->addAttribute('disabled', 'disabled'); } $form->addElement($tagTextField); $rtl = new CheckboxField('rtl'); $rtl->setLabel($language->text('admin', 'lang_edit_form_rtl_label')); $rtl->setDescription($language->text('admin', 'lang_edit_form_rtl_desc')); $rtl->setValue((bool) $languageDto->getRtl()); $form->addElement($rtl); $hiddenField = new HiddenField('langId'); $hiddenField->setValue($languageDto->getId()); $form->addElement($hiddenField); $submit = new Submit('submit'); $submit->setValue($language->text('admin', 'btn_label_edit')); $form->addElement($submit); $form->bindJsFunction(Form::BIND_SUCCESS, "function(data){if(data.result){OW.info(data.message);setTimeout(function(){window.location.reload();}, 1000);}else{OW.error(data.message);}}"); $this->addForm($form); }
public function index(array $params = array()) { $config = OW::getConfig(); $configs = $config->getValues('antibruteforce'); $form = new Form('settings'); $form->setAjax(); $form->setAjaxResetOnSuccess(false); $form->setAction(OW::getRouter()->urlForRoute('antibruteforce.admin')); $form->bindJsFunction(Form::BIND_SUCCESS, 'function(data){if(data.result){OW.info("Settings successfuly saved");}else{OW.error("Parser error");}}'); $auth = new CheckboxField('auth'); $auth->setValue($configs['authentication']); $form->addElement($auth); $reg = new CheckboxField('reg'); $reg->setValue($configs['registration']); $form->addElement($reg); $tryCount = new TextField('tryCount'); $tryCount->setRequired(); $tryCount->addValidator(new IntValidator(1)); $tryCount->setValue($configs['try_count']); $form->addElement($tryCount); $expTime = new TextField('expTime'); $expTime->setRequired(); $expTime->setValue($configs['expire_time']); $expTime->addValidator(new IntValidator(1)); $form->addElement($expTime); $title = new TextField('title'); $title->setRequired(); $title->setValue($configs['lock_title']); $form->addElement($title); $desc = new Textarea('desc'); $desc->setValue($configs['lock_desc']); $form->addElement($desc); $submit = new Submit('save'); $form->addElement($submit); $this->addForm($form); if (OW::getRequest()->isAjax()) { if ($form->isValid($_POST)) { $config->saveConfig('antibruteforce', 'authentication', $form->getElement('auth')->getValue()); $config->saveConfig('antibruteforce', 'registration', $form->getElement('reg')->getValue()); $config->saveConfig('antibruteforce', 'try_count', $form->getElement('tryCount')->getValue()); $config->saveConfig('antibruteforce', 'expire_time', $form->getElement('expTime')->getValue()); $config->saveConfig('antibruteforce', 'lock_title', strip_tags($form->getElement('title')->getValue())); $config->saveConfig('antibruteforce', 'lock_desc', strip_tags($form->getElement('desc')->getValue())); exit(json_encode(array('result' => true))); } } }
/** * @return Constructor. */ public function __construct() { parent::__construct(); $form = new Form('set_suspend_message'); $form->setAjax(true); $form->setAjaxResetOnSuccess(true); $textarea = new Textarea('message'); $textarea->setRequired(); $form->addElement($textarea); $submit = new Submit('submit'); $submit->setLabel(OW::getLanguage()->text('base', 'submit')); $form->addElement($submit); // $form->bindJsFunction(Form::BIND_SUBMIT, ' function(e) { // return false; } // // '); $this->addForm($form); $this->bindJs($form); }
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); }
public function onBeforeRender() { parent::onBeforeRender(); $language = OW::getLanguage(); $form = new Form('inite-friends'); $emailList = new TagsInputField('emailList'); $emailList->setRequired(); $emailList->setDelimiterChars(array(',', ' ')); $emailList->setInvitation($language->text('contactimporter', 'email_field_inv_message')); $emailList->setJsRegexp('/^(([^<>()[\\]\\.,;:\\s@\\"]+(\\.[^<>()[\\]\\.,;:\\s@\\"]+)*)|(\\".+\\"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))$/'); $form->addElement($emailList); $text = new Textarea('text'); $text->setValue($language->text('contactimporter', 'email_invite_field_default_text')); $text->setHasInvitation(true); $form->addElement($text); $submit = new Submit('submit'); $form->addElement($submit); $form->setAction(OW::getRouter()->urlFor('CONTACTIMPORTER_CTRL_Email', 'send')); $form->setAjax(); $form->setAjaxResetOnSuccess(false); $form->bindJsFunction(Form::BIND_SUCCESS, "\n function(data){ \n if( data.success ){\n OW.info(data.message);\n owForms['inite-friends'].resetForm();\n window.ciMailFloatBox.close();\n }\n else{\n OW.error(data.message);\n }\n }"); $this->addForm($form); }
public function slugs() { $language = OW::getLanguage(); if (OW::getRequest()->isAjax() && OW::getRequest()->isPost()) { if (isset($_POST['plugins']) && is_array($_POST['plugins'])) { OW::getConfig()->saveConfig('oaseo', OASEO_BOL_Service::CNF_SLUG_PLUGINS, json_encode($_POST['plugins'])); } if (isset($_POST['redirect'])) { OW::getConfig()->saveConfig('oaseo', OASEO_BOL_Service::CNF_SLUG_OLD_URLS_ENABLE, (bool) $_POST['redirect']); } if (isset($_POST['words'])) { OW::getConfig()->saveConfig('oaseo', OASEO_BOL_Service::CNF_SLUG_FILTER_COMMON_WORDS, json_encode(array_map('mb_strtolower', array_map('trim', explode(',', $_POST['words']))))); } exit(json_encode(array('message' => $language->text('oaseo', 'slugs_submit_message')))); } $data = $this->service->getSlugData(); $pluginKeys = array_keys($data); $event = new BASE_CLASS_EventCollector('admin.add_auth_labels'); OW::getEventManager()->trigger($event); $labelData = $event->getData(); $dataLabels = empty($labelData) ? array() : call_user_func_array('array_merge', $labelData); $finalData = array(); foreach ($dataLabels as $pluginKey => $pluginInfo) { if (in_array($pluginKey, $pluginKeys)) { $finalData[$pluginKey] = $pluginInfo['label']; } } $form = new Form('slugs_form'); $form->setAjax(); $form->setAjaxResetOnSuccess(false); $form->bindJsFunction(Form::BIND_SUCCESS, "function(data){OW.info(data.message);}"); $plugins = new CheckboxGroup('plugins'); $plugins->setLabel($language->text('oaseo', 'slug_plugins_label')); $plugins->setDescription($language->text('oaseo', 'slug_plugins_desc')); $plugins->setOptions($finalData); $plugins->setValue(json_decode(OW::getConfig()->getValue('oaseo', OASEO_BOL_Service::CNF_SLUG_PLUGINS), true)); $form->addElement($plugins); $redirect = new CheckboxField('redirect'); $redirect->setLabel($language->text('oaseo', 'slug_redirect_label')); $redirect->setDescription($language->text('oaseo', 'slug_redirect_desc')); $redirect->setValue(OW::getConfig()->getValue('oaseo', OASEO_BOL_Service::CNF_SLUG_OLD_URLS_ENABLE)); $form->addElement($redirect); $words = new Textarea('words'); $words->setLabel($language->text('oaseo', 'slug_words_label')); $words->setDescription($language->text('oaseo', 'slug_words_desc')); $wordsList = json_decode(OW::getConfig()->getValue('oaseo', OASEO_BOL_Service::CNF_SLUG_FILTER_COMMON_WORDS)); if (is_array($wordsList)) { $valString = implode(', ', $wordsList); } else { $valString = ''; } $words->setValue($valString); $form->addElement($words); $submit = new Submit('submit'); $submit->setValue(OW::getLanguage()->text('admin', 'save_btn_label')); $form->addElement($submit); $this->addForm($form); }
/** * * @param string $name * @return Form */ public function getUserSettingsForm() { $form = new Form('im_user_settings_form'); $form->setAjax(true); $form->setAction(OW::getRouter()->urlFor('AJAXIM_CTRL_Action', 'processUserSettingsForm')); $form->setAjaxResetOnSuccess(false); $form->bindJsFunction(Form::BIND_SUCCESS, "function(data){\n OW_InstantChat_App.setSoundEnabled(data.im_soundEnabled);\n }"); $findContact = new ImSearchField('im_find_contact'); $findContact->setHasInvitation(true); $findContact->setInvitation(OW::getLanguage()->text('ajaxim', 'find_contact')); $form->addElement($findContact); $enableSound = new CheckboxField('im_enable_sound'); $user_preference_enable_sound = BOL_PreferenceService::getInstance()->getPreferenceValue('ajaxim_user_settings_enable_sound', OW::getUser()->getId()); $enableSound->setValue($user_preference_enable_sound); $enableSound->setLabel(OW::getLanguage()->text('ajaxim', 'enable_sound_label')); $form->addElement($enableSound); $userIdHidden = new HiddenField('user_id'); $form->addElement($userIdHidden); return $form; }
/** * * @param string $name * @return Form */ private function getManageForm($name) { if ($this->banners === null) { $banners = $this->adsService->findAllBanners(); $bannerInfo = array(); foreach ($banners as $banner) { /* @var $banner ADS_BOL_Banner */ $this->banners[$banner->getId()] = $banner->getLabel(); } } $form = new Form($name); $form->setAjax(true); $form->setAction(OW::getRouter()->urlFor('ADS_CTRL_Admin', 'processBannerForm')); $form->setAjaxResetOnSuccess(false); $form->bindJsFunction(Form::BIND_SUCCESS, "function(data){OW.info(data.message);window.adsForm.close();\$('#'+data.id).html(data.html);}"); $multiCheckbox = new CheckboxGroup('banners'); $multiCheckbox->setOptions($this->banners === null ? array() : $this->banners); $form->addElement($multiCheckbox); $submit = new Submit('submit'); $submit->setValue(OW::getLanguage()->text('ads', 'banner_position_submit_label')); $form->addElement($submit); $pluginHidden = new HiddenField('plugin_key'); $form->addElement($pluginHidden); return $form; }
/** * @return Constructor. */ public function __construct($metaData, $uri, $frontend = true) { parent::__construct(); $this->metaService = OASEO_BOL_Service::getInstance(); $language = OW::getLanguage(); $uriArray = parse_url($uri); $uri = !empty($uriArray['path']) ? $uriArray['path'] : ''; // need to get uri if url provided if (substr($uri, 0, 7) == 'http://') { $uri = substr($uri, strlen(OW_URL_HOME)); } elseif (UTIL_String::removeFirstAndLastSlashes(substr($uri, 0, strlen(OW_URL_HOME) - 7)) == UTIL_String::removeFirstAndLastSlashes(substr(OW_URL_HOME, 7))) { $uri = UTIL_String::removeFirstAndLastSlashes(substr($uri, strlen(OW_URL_HOME) - 7)); } else { $uri = trim($uri); } $metaData['routeData'] = $this->metaService->getRouteData($uri); $dispatchAttrs = $this->metaService->getDispatchParamsForUri($uri); if ($dispatchAttrs === false) { $this->assign('no_compile', true); return; } $entry = $this->metaService->getEntryForDispatchParams($dispatchAttrs); if ($entry !== null) { $metaArr = json_decode($entry->getMeta(), true); if (isset($metaArr['title'])) { $titleString = $metaArr['title']; } if (isset($metaArr['keywords'])) { $keywords = $metaArr['keywords']; } if (isset($metaArr['desc'])) { $descString = $metaArr['desc']; } } if (!isset($titleString)) { $titleString = $metaData['title']; } if (!isset($keywords)) { $keywords = explode(',', $metaData['keywords']); $keywords = array_map('trim', $keywords); } if (!isset($descString)) { $descString = $metaData['desc']; } $form = new Form('meta_edit'); $form->setAction(OW::getRouter()->urlFor('OASEO_CTRL_Base', 'updateMeta')); $form->setAjax(); $form->setAjaxResetOnSuccess(false); $this->addForm($form); $title = new TextField('title'); $title->setLabel($language->text('oaseo', 'meta_edit_form_title_label')); $title->setDescription($language->text('oaseo', 'meta_edit_form_title_fr_desc')); $title->setValue($titleString); $form->addElement($title); $keyword = new OA_CCLASS_TagsField('keywords'); $keyword->setLabel($language->text('oaseo', 'meta_edit_form_keyword_label')); $keyword->setDescription($language->text('oaseo', 'meta_edit_form_keyword_fr_desc')); $keyword->setValue($keywords); $form->addElement($keyword); $desc = new Textarea('desc'); $desc->setLabel($language->text('oaseo', 'meta_edit_form_desc_label')); $desc->setDescription($language->text('oaseo', 'meta_edit_form_desc_fr_desc')); $desc->setValue($descString); $form->addElement($desc); $hidTitle = new HiddenField('hidTitle'); $hidTitle->setValue($titleString); $form->addElement($hidTitle); $hidKeyword = new HiddenField('hidKeywords'); $hidKeyword->setValue(implode('+|+', $keywords)); $form->addElement($hidKeyword); $hidDesc = new HiddenField('hidDesc'); $hidDesc->setValue($descString); $form->addElement($hidDesc); if (!empty($metaData['routeData']) && $uri && $dispatchAttrs['controller'] != 'BASE_CTRL_StaticDocument') { $this->assign('urlAvail', true); $urlField = new OASEO_UrlField('url'); $urlField->setValue($metaData['routeData']['path']); $urlField->setLabel($language->text('oaseo', 'meta_edit_form_url_label')); $urlField->setDescription($language->text('oaseo', 'meta_edit_form_url_desc')); $form->addElement($urlField); $routeName = new HiddenField('routeName'); $routeName->setValue($metaData['routeData']['name']); $form->addElement($routeName); } $uriEl = new HiddenField('uri'); $uriEl->setValue($uri); $form->addElement($uriEl); $submit = new Submit('submit'); $submit->setValue($language->text('oaseo', 'meta_edit_form_submit_label')); $form->addElement($submit); $id = uniqid(); $this->assign('id', $id); $this->assign('frontend', $frontend); $form->bindJsFunction('success', "function(data){if(data.status){OW.info(data.msg);window.oaseoFB.close();}else{OW.error(data.msg);}}"); if ($frontend) { OW::getDocument()->addOnloadScript("\$('#aoseo_button_{$id}').click(\n function(){\n window.oaseoFB = new OA_FloatBox({\n \$title: '{$language->text('oaseo', 'meta_edit_form_cmp_title')}',\n \$contents: \$('#oaseo_edit_form_{$id}'),\n width: 900,\n icon_class: 'ow_ic_gear'\n });\n }\n );"); } }