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();
            } ');
    }
Example #2
0
 public function __construct(BASE_CommentsParams $params, $id, $formName)
 {
     parent::__construct();
     $language = OW::getLanguage();
     $form = new Form($formName);
     $textArea = new Textarea('commentText');
     $textArea->setHasInvitation(true);
     $textArea->setInvitation($language->text('base', 'comment_form_element_invitation_text'));
     $form->addElement($textArea);
     $hiddenEls = array('entityType' => $params->getEntityType(), 'entityId' => $params->getEntityId(), 'displayType' => $params->getDisplayType(), 'pluginKey' => $params->getPluginKey(), 'ownerId' => $params->getOwnerId(), 'cid' => $id, 'commentCountOnPage' => $params->getCommentCountOnPage(), 'isMobile' => 1);
     foreach ($hiddenEls as $name => $value) {
         $el = new HiddenField($name);
         $el->setValue($value);
         $form->addElement($el);
     }
     $submit = new Submit('comment-submit');
     $submit->setValue($language->text('base', 'comment_add_submit_label'));
     $form->addElement($submit);
     $form->setAjax(true);
     $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment'));
     //        $form->bindJsFunction(Form::BIND_SUBMIT, "function(){ $('#comments-" . $id . " .comments-preloader').show();}");
     //        $form->bindJsFunction(Form::BIND_SUCCESS, "function(){ $('#comments-" . $id . " .comments-preloader').hide();}");
     $this->addForm($form);
     OW::getDocument()->addOnloadScript("window.owCommentCmps['{$id}'].initForm('" . $textArea->getId() . "', '" . $submit->getId() . "');");
     $this->assign('form', true);
     $this->assign('id', $id);
 }
Example #3
0
 public function __construct($entityType, $entityId, $displayType, $pluginKey, $ownerId, $commentCountOnPage, $id, $cmpContextId, $formName)
 {
     parent::__construct();
     $language = OW::getLanguage();
     //comment form init
     $form = new Form($formName);
     $textArea = new Textarea('commentText');
     $form->addElement($textArea);
     $entityTypeField = new HiddenField('entityType');
     $form->addElement($entityTypeField);
     $entityIdField = new HiddenField('entityId');
     $form->addElement($entityIdField);
     $displayTypeField = new HiddenField('displayType');
     $form->addElement($displayTypeField);
     $pluginKeyField = new HiddenField('pluginKey');
     $form->addElement($pluginKeyField);
     $ownerIdField = new HiddenField('ownerId');
     $form->addElement($ownerIdField);
     $attch = new HiddenField('attch');
     $form->addElement($attch);
     $cid = new HiddenField('cid');
     $form->addElement($cid);
     $commentsOnPageField = new HiddenField('commentCountOnPage');
     $form->addElement($commentsOnPageField);
     $submit = new Submit('comment-submit');
     $submit->setValue($language->text('base', 'comment_add_submit_label'));
     $form->addElement($submit);
     $form->getElement('entityType')->setValue($entityType);
     $form->getElement('entityId')->setValue($entityId);
     $form->getElement('displayType')->setValue($displayType);
     $form->getElement('pluginKey')->setValue($pluginKey);
     $form->getElement('ownerId')->setValue($ownerId);
     $form->getElement('cid')->setValue($id);
     $form->getElement('commentCountOnPage')->setValue($commentCountOnPage);
     $form->setAjax(true);
     $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment'));
     $form->bindJsFunction(Form::BIND_SUBMIT, "function(){ \$('#comments-" . $id . " .comments-preloader').show();}");
     $form->bindJsFunction(Form::BIND_SUCCESS, "function(){ \$('#comments-" . $id . " .comments-preloader').hide();}");
     $this->addForm($form);
     if (BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed()) {
         $attachmentCmp = new BASE_CLASS_Attachment($id);
         $this->addComponent('attachment', $attachmentCmp);
     }
     OW::getDocument()->addOnloadScript("owCommentCmps['{$id}'].initForm('" . $form->getElement('commentText')->getId() . "', '" . $form->getElement('attch')->getId() . "');");
     $this->assign('form', true);
     $this->assign('id', $id);
     if (OW::getUser()->isAuthenticated()) {
         $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
         $this->assign('currentUserInfo', $currentUserInfo[OW::getUser()->getId()]);
     }
 }
Example #4
0
 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->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');
         $js = " owForms['" . $form->getName() . "'].bind( 'success',\n            function( json )\n            {\n            \tif( json.result == true )\n            \t{\n            \t    \$('#TB_closeWindowButton').click();\n            \t    OW.info('{$messageSuccess}');\n                }\n                else\n                {\n                    OW.error('{$messageError}');\n                }\n\n            } ); ";
         OW::getDocument()->addOnloadScript($js);
         $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");
     }
 }
Example #5
0
 /**
  * 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);
 }
Example #6
0
 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);
 }
Example #8
0
    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);
    }
Example #9
0
 /**
  * @param integer $userId
  */
 public function __construct($userId)
 {
     parent::__construct();
     $user = BOL_UserService::getInstance()->findUserById((int) $userId);
     if (!OW::getUser()->isAuthorized('base') || $user === null) {
         $this->setVisible(false);
         return;
     }
     $aService = BOL_AuthorizationService::getInstance();
     $roleList = $aService->findNonGuestRoleList();
     $form = new Form('give-role');
     $form->setAjax(true);
     $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_User', 'updateUserRoles'));
     $hidden = new HiddenField('userId');
     $form->addElement($hidden->setValue($userId));
     $userRoles = $aService->findUserRoleList($user->getId());
     $userRolesIdList = array();
     foreach ($userRoles as $role) {
         $userRolesIdList[] = $role->getId();
     }
     $tplRoleList = array();
     /* @var $role BOL_AuthorizationRole */
     foreach ($roleList as $role) {
         $field = new CheckboxField('roles[' . $role->getId() . ']');
         $field->setLabel(OW::getLanguage()->text('base', 'authorization_role_' . $role->getName()));
         $field->setValue(in_array($role->getId(), $userRolesIdList));
         if (in_array($role->getId(), $userRolesIdList) && $role->getSortOrder() == 1) {
             $field->addAttribute('disabled', 'disabled');
         }
         $form->addElement($field);
         $tplRoleList[$role->sortOrder] = $role;
     }
     ksort($tplRoleList);
     $form->addElement(new Submit('submit'));
     OW::getDocument()->addOnloadScript("owForms['{$form->getName()}'].bind('success', function(data){\n                if( data.result ){\n                    if( data.result == 'success' ){\n                         window.baseChangeUserRoleFB.close();\n                         window.location.reload();\n                         //OW.info(data.message);\n                    }\n                    else if( data.result == 'error'){\n                        OW.error(data.message);\n                    }\n                }\n\t\t})");
     $this->addForm($form);
     $this->assign('list', $tplRoleList);
 }
Example #10
0
 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);
 }
Example #11
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;
 }
Example #12
0
 /**
  * Generates move topic form.
  *
  * @param string $actionUrl
  * @param $groupSelect
  * @param $topicDto
  * @return Form
  */
 private function generateMoveTopicForm($actionUrl, $groupSelect, $topicDto)
 {
     $form = new Form('move-topic-form');
     $form->setAction($actionUrl);
     $topicIdField = new HiddenField('topic-id');
     $topicIdField->setValue($topicDto->id);
     $form->addElement($topicIdField);
     $group = new ForumSelectBox('group-id');
     $group->setOptions($groupSelect);
     $group->setValue($topicDto->groupId);
     $group->addAttribute("style", "width: 300px;");
     $group->setRequired(true);
     $form->addElement($group);
     $submit = new Submit('save');
     $submit->setValue(OW::getLanguage()->text('forum', 'move_topic_btn'));
     $form->addElement($submit);
     $form->setAjax(true);
     return $form;
 }
Example #13
0
 public function passwordProtection()
 {
     $language = OW::getLanguage();
     $form = new Form('password_protection');
     $form->setAjax(true);
     $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_BaseDocument', 'passwordProtection'));
     $form->setAjaxDataType(Form::AJAX_DATA_TYPE_SCRIPT);
     $password = new PasswordField('password');
     $form->addElement($password);
     $submit = new Submit('submit');
     $submit->setValue(OW::getLanguage()->text('base', 'password_protection_submit_label'));
     $form->addElement($submit);
     $this->addForm($form);
     if (OW::getRequest()->isAjax() && $form->isValid($_POST)) {
         $data = $form->getValues();
         $password = OW::getConfig()->getValue('base', 'guests_can_view_password');
         $cryptedPassword = crypt($data['password'], OW_PASSWORD_SALT);
         if (!empty($data['password']) && $cryptedPassword === $password) {
             setcookie('base_password_protection', UTIL_String::getRandomString(), time() + 86400 * 30, '/');
             echo "OW.info('" . OW::getLanguage()->text('base', 'password_protection_success_message') . "');window.location.reload();";
         } else {
             echo "OW.error('" . OW::getLanguage()->text('base', 'password_protection_error_message') . "');";
         }
         exit;
     }
     OW::getDocument()->setHeading($language->text('base', 'password_protection_text'));
     OW::getDocument()->getMasterPage()->setTemplate(OW::getThemeManager()->getMasterPageTemplate('mobile_blank'));
 }
Example #14
0
 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);
 }
Example #15
0
 public function __construct($entityType, $entityId, $displayType, $pluginKey, $ownerId, $commentCountOnPage, $id, $cmpContextId, $formName)
 {
     parent::__construct();
     $language = OW::getLanguage();
     //comment form init
     $form = new Form($formName);
     $textArea = new Textarea('commentText');
     $form->addElement($textArea);
     $entityTypeField = new HiddenField('entityType');
     $form->addElement($entityTypeField);
     $entityIdField = new HiddenField('entityId');
     $form->addElement($entityIdField);
     $displayTypeField = new HiddenField('displayType');
     $form->addElement($displayTypeField);
     $pluginKeyField = new HiddenField('pluginKey');
     $form->addElement($pluginKeyField);
     $ownerIdField = new HiddenField('ownerId');
     $form->addElement($ownerIdField);
     $attch = new HiddenField('attch');
     $form->addElement($attch);
     $cid = new HiddenField('cid');
     $form->addElement($cid);
     $commentsOnPageField = new HiddenField('commentCountOnPage');
     $form->addElement($commentsOnPageField);
     $submit = new Submit('comment-submit');
     $submit->setValue($language->text('base', 'comment_add_submit_label'));
     $form->addElement($submit);
     $form->getElement('entityType')->setValue($entityType);
     $form->getElement('entityId')->setValue($entityId);
     $form->getElement('displayType')->setValue($displayType);
     $form->getElement('pluginKey')->setValue($pluginKey);
     $form->getElement('ownerId')->setValue($ownerId);
     $form->getElement('commentCountOnPage')->setValue($commentCountOnPage);
     $form->setAjax(true);
     $form->setAction(OW::getRouter()->urlFor('BASE_CTRL_Comments', 'addComment'));
     $form->bindJsFunction(Form::BIND_SUBMIT, "function(){ \$('#comments-" . $id . " .comments-preloader').show();}");
     $form->bindJsFunction(Form::BIND_SUCCESS, "function(){ \$('#comments-" . $id . " .comments-preloader').hide();}");
     $this->addForm($form);
     $attachmentsId = null;
     if (BOL_TextFormatService::getInstance()->isCommentsRichMediaAllowed()) {
         $attachmentsId = $this->initAttachments();
         $attControlUniq = uniqid('attpControl');
         $js = UTIL_JsGenerator::newInstance()->newObject(array('ATTP.CORE.ObjectRegistry', $attControlUniq), 'ATTP.AttachmentsControl', array($cmpContextId, array('attachmentId' => $attachmentsId, 'attachmentInputId' => $attch->getId(), 'inputId' => $textArea->getId(), 'formName' => $form->getName())));
         ATTACHMENTS_Plugin::getInstance()->addJs($js);
     }
     OW::getDocument()->addOnloadScript("owCommentCmps['{$id}'].initForm('" . $form->getElement('commentText')->getId() . "', '" . $form->getElement('attch')->getId() . "');");
     OW::getDocument()->addOnloadScript(UTIL_JsGenerator::composeJsString('
         owForms[{$formName}].bind("success", function(data) {
             var attachId = {$attcachmentId};
             if ( attachId && ATTP.CORE.ObjectRegistry[attachId] )
             {
                 ATTP.CORE.ObjectRegistry[attachId].reset();
             }
         });
     ', array('formName' => $form->getName(), 'attcachmentId' => $attachmentsId)));
     $this->assign('form', true);
     $this->assign('id', $id);
     if (OW::getUser()->isAuthenticated()) {
         $currentUserInfo = BOL_AvatarService::getInstance()->getDataForUserAvatars(array(OW::getUser()->getId()));
         $this->assign('currentUserInfo', $currentUserInfo[OW::getUser()->getId()]);
     }
 }
Example #16
0
 /**
  * @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        );");
     }
 }
Example #17
0
 public function view(array $params = array())
 {
     OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('photo')->getStaticCssUrl() . 'admin.css');
     OW::getDocument()->addOnloadScript(';window.photoAdmin.init();');
     $form = new Form('view-mode');
     $form->setAjax(TRUE);
     $form->bindJsFunction('success', 'function(data)
     {
         if ( data && data.result )
         {
             OW.info(data.msg);
         }
     }');
     if (OW::getRequest()->isPost()) {
         OW::getConfig()->saveConfig('photo', 'photo_list_view_classic', (bool) $_POST['photo-list-mode']);
         OW::getConfig()->saveConfig('photo', 'album_list_view_classic', (bool) $_POST['album-list-mode']);
         OW::getConfig()->saveConfig('photo', 'photo_view_classic', (bool) $_POST['photo-view-mode']);
         exit(json_encode(array('result' => true, 'msg' => OW::getLanguage()->text('photo', 'settings_updated'))));
     }
     $photoListMode = new HiddenField('photo-list-mode');
     $photoListMode->setValue(OW::getConfig()->getValue('photo', 'photo_list_view_classic'));
     $form->addElement($photoListMode);
     $albumListMode = new HiddenField('album-list-mode');
     $albumListMode->setValue(OW::getConfig()->getValue('photo', 'album_list_view_classic'));
     $form->addElement($albumListMode);
     $photoViewMode = new HiddenField('photo-view-mode');
     $photoViewMode->setValue(OW::getConfig()->getValue('photo', 'photo_view_classic'));
     $form->addElement($photoViewMode);
     $submit = new Submit('save');
     $submit->addAttribute('class', 'ow_ic_save ow_positive');
     $submit->setValue(OW::getLanguage()->text('photo', 'btn_edit'));
     $form->addElement($submit);
     $this->addForm($form);
 }
Example #18
0
 /**
  *
  * @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;
 }
Example #19
0
 public function __construct($pluginKey, $entityType, $entityId)
 {
     // remove newfeeds cookie if has
     setcookie('ynsocialpublisher_feed_data_' . $entityId, '', -1, '/');
     parent::__construct();
     $userId = OW::getUser()->getId();
     $language = OW::getLanguage();
     $service = YNSOCIALPUBLISHER_BOL_Service::getInstance();
     $core = YNSOCIALPUBLISHER_CLASS_Core::getInstance();
     // user setting
     $userSetting = $service->getUsersetting($userId, $pluginKey);
     $this->assign('userSetting', $userSetting);
     // avatar
     $avatar = BOL_AvatarService::getInstance()->getAvatarUrl($userId);
     if (empty($avatar)) {
         $avatar = BOL_AvatarService::getInstance()->getDefaultAvatarUrl();
     }
     $this->assign('avatar', $avatar);
     // default status
     $defaultStatus = $core->getDefaultStatus($pluginKey, $entityType, $entityId);
     $this->assign('defaultStatus', $defaultStatus);
     // entity url
     $url = $core->getUrl($pluginKey, $entityType, $entityId);
     $this->assign('url', $url);
     // title
     $title = $core->getTitle($pluginKey, $entityType, $entityId);
     $this->assign('title', $title);
     // -- connect each provider to get data
     // callbackUrl
     $callbackUrl = OW::getRouter()->urlForRoute('ynsocialbridge-connects');
     $coreBridge = new YNSOCIALBRIDGE_CLASS_Core();
     $arrObjServices = array();
     foreach (array('facebook', 'twitter', 'linkedin') as $serviceName) {
         $profile = null;
         $connect_url = "";
         $access_token = "";
         $scope = '';
         $objService = array();
         //check enable API
         $clientConfig = YNSOCIALBRIDGE_BOL_ApisettingService::getInstance()->getConfig($serviceName);
         if ($clientConfig) {
             $obj = $coreBridge->getInstance($serviceName);
             $values = array('service' => $serviceName, 'userId' => OW::getUser()->getId());
             //$tokenDto = $obj -> getToken($values);
             //print_r($_SESSION['socialbridge_session'][$serviceName]);die;
             $disconnect_url = OW::getRouter()->urlForRoute('ynsocialbridge-disconnect') . "?service=" . $serviceName;
             if (!empty($_SESSION['socialbridge_session'][$serviceName]['access_token'])) {
                 if ($serviceName == 'facebook') {
                     $access_token = $_SESSION['socialbridge_session'][$serviceName]['access_token'];
                     //check permission
                     $me = $obj->getOwnerInfo(array('access_token' => $access_token));
                     $uid = $me['id'];
                     $permissions = $obj->hasPermission(array('uid' => $uid, 'access_token' => $access_token));
                     if ($permissions) {
                         if (empty($permissions[0]['publish_stream']) || empty($permissions[0]['status_update'])) {
                             $scope = 'publish_stream,status_update';
                             //$scope = "email,user_about_me,user_birthday,user_hometown,user_interests,user_location,user_photos,user_website,publish_stream,status_update";
                         } else {
                             try {
                                 $profile = $obj->getOwnerInfo($_SESSION['socialbridge_session'][$serviceName]);
                             } catch (Exception $e) {
                                 $profile = null;
                             }
                         }
                     }
                 } else {
                     $profile = $obj->getOwnerInfo($_SESSION['socialbridge_session'][$serviceName]);
                 }
             } else {
                 $scope = "";
                 switch ($serviceName) {
                     case 'facebook':
                         //$scope = "email,user_about_me,user_birthday,user_hometown,user_interests,user_location,user_photos,user_website";
                         $scope = 'publish_stream,status_update';
                         break;
                     case 'twitter':
                         $scope = "";
                         break;
                     case 'linkedin':
                         $scope = "r_basicprofile,rw_nus,r_network,w_messages";
                         break;
                 }
             }
             $connect_url = $obj->getConnectUrl() . "?scope=" . $scope . "&" . http_build_query(array('callbackUrl' => $callbackUrl, 'isFromSocialPublisher' => 1, 'pluginKey' => $pluginKey, 'entityType' => $entityType, 'entityId' => $entityId));
             $objService['has_config'] = 1;
         } else {
             $objService['has_config'] = 0;
         }
         $objService['serviceName'] = $serviceName;
         $objService['connectUrl'] = $connect_url;
         $objService['disconnectUrl'] = $disconnect_url;
         $objService['profile'] = $profile;
         $objService['logo'] = OW::getPluginManager()->getPlugin('ynsocialpublisher')->getStaticUrl() . "img/" . $serviceName . ".png";
         $arrObjServices[$serviceName] = $objService;
     }
     //print_r($userSetting);
     //print_r($arrObjServices);
     $this->assign('arrObjServices', $arrObjServices);
     // create form
     $formUrl = OW::getRouter()->urlFor('YNSOCIALPUBLISHER_CTRL_Ynsocialpublisher', 'ajaxPublish');
     $form = new Form('ynsocialpubisher_share');
     $form->setAction($formUrl);
     $form->setAjax();
     // -- hidden fields
     // for plugin key
     $pluginKeyHiddenField = new HiddenField('ynsocialpublisher_pluginKey');
     $pluginKeyHiddenField->setValue($pluginKey);
     $form->addElement($pluginKeyHiddenField);
     // for entity id
     $entityIdHiddenField = new HiddenField('ynsocialpublisher_entityId');
     $entityIdHiddenField->setValue($entityId);
     $form->addElement($entityIdHiddenField);
     // for entity type
     $entityTypeHiddenField = new HiddenField('ynsocialpublisher_entityType');
     $entityTypeHiddenField->setValue($entityType);
     $form->addElement($entityTypeHiddenField);
     // Status - textarea
     $status = new Textarea('ynsocialpublisher_status');
     $status->setValue($defaultStatus);
     $form->addElement($status);
     // Options - radio buttons
     $options = new RadioField('ynsocialpublisher_options');
     $options->setRequired();
     $options->addOptions(array('0' => $language->text('ynsocialpublisher', 'ask'), '1' => $language->text('ynsocialpublisher', 'auto'), '2' => $language->text('ynsocialpublisher', 'not_ask')));
     $options->setValue($userSetting['option']);
     $form->addElement($options);
     // Providers - checkboxes
     foreach (array('facebook', 'twitter', 'linkedin') as $provider) {
         if (in_array($provider, $userSetting['adminProviders']) && $arrObjServices[$provider]['has_config']) {
             $providerField = new CheckboxField('ynsocialpublisher_' . $provider);
             $form->addElement($providerField);
         }
     }
     // add js action to form
     $form->bindJsFunction(Form::BIND_SUCCESS, 'function(data){if( data.result ){OW.info(data.message);OWActiveFloatBox.close();}else{OW.error(data.message);}}');
     // submit button
     $submit = new Submit('submit');
     $submit->setValue(OW::getLanguage()->text('ynsocialpublisher', 'submit_label'));
     $form->addElement($submit);
     $this->addForm($form);
     // assign to view
     $this->assign('formUrl', $formUrl);
 }
Example #20
0
 /**
  *
  * @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;
 }