public function __construct() { parent::__construct('bookmarks_settings'); $language = OW::getLanguage(); $this->setAjax(); $this->setAjaxResetOnSuccess(FALSE); $this->setAction(OW::getRouter()->urlForRoute('bookmarks.admin')); $this->bindJsFunction('success', 'function() { OW.info("' . $language->text('bookmarks', 'settings_saved') . '"); }'); $notifyIntervalConfigVal = OW::getConfig()->getValue('bookmarks', 'notify_interval'); $notifyIntervalVal = array(0 => $language->text('bookmarks', 'remainderinterval_dont_send'), 10 => $language->text('bookmarks', 'remainderinterval_10'), 20 => $language->text('bookmarks', 'remainderinterval_20'), 30 => $language->text('bookmarks', 'remainderinterval_30')); $notifyInterval = new Selectbox('notify_interval'); $notifyInterval->addValidator(new BookmarkSelectboxValidator($notifyIntervalVal)); $notifyInterval->setOptions($notifyIntervalVal); $notifyInterval->setValue($notifyIntervalConfigVal); $notifyInterval->setLabel($language->text('bookmarks', 'notify_interval_label')); $notifyInterval->setDescription($language->text('bookmarks', 'notify_interval_desc')); $notifyInterval->setHasInvitation(FALSE); $this->addElement($notifyInterval); $submit = new Submit('save'); $submit->setValue($language->text('bookmarks', 'submit_label')); $this->addElement($submit); }
public function index() { $language = OW::getLanguage(); $config = OW::getConfig(); $adminForm = new Form('adminForm'); $element = new Selectbox('actionMember'); $element->setLabel($language->text('grouprss', 'action_member_label')); $element->setDescription($language->text('grouprss', 'action_member_desc')); $element->setValue($config->getValue('grouprss', 'actionMember')); $element->setRequired(); $element->addOption('admin', $language->text('grouprss', 'site_admin')); $element->addOption('owner', $language->text('grouprss', 'group_owner')); $element->addOption('both', $language->text('grouprss', 'both_admin_owner')); $adminForm->addElement($element); $element = new Selectbox('postLocation'); $element->setLabel($language->text('grouprss', 'post_location_label')); $element->setDescription($language->text('grouprss', 'post_location_desc')); $element->setValue($config->getValue('grouprss', 'postLocation')); $element->setRequired(); $element->addOption('wall', $language->text('grouprss', 'wall_location')); $element->addOption('newsfeed', $language->text('grouprss', 'newsfeed_location')); $adminForm->addElement($element); $element = new CheckboxField('disablePosting'); $element->setLabel($language->text('grouprss', 'disable_posting_label')); $element->setDescription($language->text('grouprss', 'disable_posting_desc')); $element->setValue($config->getValue('grouprss', 'disablePosting')); $adminForm->addElement($element); $element = new Submit('saveSettings'); $element->setValue(OW::getLanguage()->text('grouprss', 'admin_save_settings')); $adminForm->addElement($element); if (OW::getRequest()->isPost()) { if ($adminForm->isValid($_POST)) { $values = $adminForm->getValues(); $config->saveConfig('grouprss', 'actionMember', $values['actionMember']); $config->saveConfig('grouprss', 'postLocation', $values['postLocation']); $config->saveConfig('grouprss', 'disablePosting', $values['disablePosting']); GROUPRSS_BOL_FeedService::getInstance()->addAllGroupFeed(); //OW::getFeedback()->info($language->text('grouprss', 'user_save_success')); } } $this->addForm($adminForm); }
public function sitemap() { $language = OW::getLanguage(); $config = OW::getConfig(); $form = new Form('sitemap_form'); $sitemapUrl = new TextField('sitemap_url'); $sitemapUrl->setLabel($language->text('oaseo', 'sitemap_url_label')); $sitemapUrl->setDescription($language->text('oaseo', 'sitemap_url_desc')); $sitemapUrl->setValue(OW_URL_HOME . $config->getValue('oaseo', 'sitemap_url')); $form->addElement($sitemapUrl); // $rorUrl = new TextField('ror_url'); // $rorUrl->setLabel($language->text('oaseo', 'ror_url_label')); // $rorUrl->setDescription($language->text('oaseo', 'ror_url_desc')); // $rorUrl->setValue(OW_URL_HOME . $config->getValue('oaseo', 'ror_url')); // $form->addElement($rorUrl); $imageUrl = new TextField('imagemap_url'); $imageUrl->setLabel($language->text('oaseo', 'imagemap_url_label')); $imageUrl->setDescription($language->text('oaseo', 'imagemap_url_desc')); $imageUrl->setValue(OW_URL_HOME . $config->getValue('oaseo', 'imagemap_url')); $form->addElement($imageUrl); $undateFreq = new Selectbox('update_freq'); $options = array('86400' => 'Daily', '604800' => 'Weekly', '2419200' => 'Monthly'); $undateFreq->setHasInvitation(false); $undateFreq->addOptions($options); $undateFreq->setLabel($language->text('oaseo', 'update_freq_label')); $undateFreq->setDescription($language->text('oaseo', 'update_freq_desc')); $form->addElement($undateFreq); $undateFreq->setValue($config->getValue('oaseo', 'update_freq')); // $prio = new CheckboxField('prio'); // $prio->setLabel($language->text('oaseo', 'prio_label')); // $prio->setDescription($language->text('oaseo', 'prio_desc')); // $form->addElement($prio); // $email = new TextField('email'); // $email->setLabel($language->text('oaseo', 'email_label')); // $email->setDescription($language->text('oaseo', 'email_desc')); // $form->addElement($email); $inform = new CheckboxGroup('inform'); $inform->setLabel($language->text('oaseo', 'inform_label')); $inform->setDescription($language->text('oaseo', 'inform_desc')); $inform->setOptions(array('google' => 'Google', 'bing' => 'Bing', 'yahoo' => 'Yahoo', 'ask' => 'Ask')); $form->addElement($inform); $inform->setValue(json_decode($config->getValue('oaseo', 'inform'))); // $extlink = new CheckboxField('extlink'); // $extlink->setLabel($language->text('oaseo', 'extlink_label')); // $extlink->setDescription($language->text('oaseo', 'extlink_desc')); // $form->addElement($extlink); // // $brock = new CheckboxField('brock_link'); // $brock->setLabel($language->text('oaseo', 'brock_link_label')); // $brock->setDescription($language->text('oaseo', 'brock_link_desc')); // $form->addElement($brock); $submit = new Submit('submit'); $submit->setValue(OW::getLanguage()->text('admin', 'save_btn_label')); $form->addElement($submit); $this->addForm($form); if (OW::getRequest()->isPost() && $form->isValid($_POST)) { $data = $form->getValues(); $config->saveConfig('oaseo', 'sitemap_url', str_replace(OW_URL_HOME, '', $data['sitemap_url'])); $config->saveConfig('oaseo', 'imagemap_url', str_replace(OW_URL_HOME, '', $data['imagemap_url'])); $config->saveConfig('oaseo', 'update_freq', (int) $data['update_freq']); $config->saveConfig('oaseo', 'inform', json_encode($data['inform'] ? $data['inform'] : array())); } }
public function index($params) { $userId = OW::getUser()->getId(); if (OW::getRequest()->isAjax()) { exit; } if (!OW::getUser()->isAuthenticated() || $userId === null) { throw new AuthenticateException(); } $contentMenu = new BASE_CMP_PreferenceContentMenu(); $contentMenu->getElement('privacy')->setActive(true); $this->addComponent('contentMenu', $contentMenu); $language = OW::getLanguage(); $this->setPageHeading($language->text('privacy', 'privacy_index')); $this->setPageHeadingIconClass('ow_ic_lock'); // -- Action form -- $privacyForm = new Form('privacyForm'); $privacyForm->setId('privacyForm'); $actionSubmit = new Submit('privacySubmit'); $actionSubmit->addAttribute('class', 'ow_button ow_ic_save'); $actionSubmit->setValue($language->text('privacy', 'privacy_submit_button')); $privacyForm->addElement($actionSubmit); // -- $actionList = PRIVACY_BOL_ActionService::getInstance()->findAllAction(); $actionNameList = array(); foreach ($actionList as $action) { $actionNameList[$action->key] = $action->key; } $actionValueList = PRIVACY_BOL_ActionService::getInstance()->getActionValueList($actionNameList, $userId); $actionValuesEvent = new BASE_CLASS_EventCollector(PRIVACY_BOL_ActionService::EVENT_GET_PRIVACY_LIST); OW::getEventManager()->trigger($actionValuesEvent); $data = $actionValuesEvent->getData(); $actionValuesInfo = empty($data) ? array() : $data; $optionsList = array(); $sortOptionsList = array(); $order = array(); // -- sort action values foreach ($actionValuesInfo as $value) { $optionsList[$value['key']] = $value['label']; $order[$value['sortOrder']] = $value['key']; } asort($order); foreach ($order as $key) { $sortOptionsList[$key] = $optionsList[$key]; } // -- $resultList = array(); foreach ($actionList as $action) { /* @var $action PRIVACY_CLASS_Action */ if (!empty($action->label)) { $formElement = new Selectbox($action->key); $formElement->setLabel($action->label); $formElement->setDescription(''); if (!empty($action->description)) { $formElement->setDescription($action->description); } $formElement->setOptions($sortOptionsList); $formElement->setHasInvitation(false); if (!empty($actionValueList[$action->key])) { $formElement->setValue($actionValueList[$action->key]); if (array_key_exists($actionValueList[$action->key], $sortOptionsList)) { $formElement->setValue($actionValueList[$action->key]); } else { if ($actionValueList[$action->key] != 'everybody') { $formElement->setValue('only_for_me'); } } } $privacyForm->addElement($formElement); $resultList[$action->key] = $action->key; } } if (OW::getRequest()->isPost()) { if ($privacyForm->isValid($_POST)) { $values = $privacyForm->getValues(); $restul = PRIVACY_BOL_ActionService::getInstance()->saveActionValues($values, $userId); if ($restul) { OW::getFeedback()->info($language->text('privacy', 'action_action_data_was_saved')); } else { OW::getFeedback()->warning($language->text('privacy', 'action_action_data_not_changed')); } $this->redirect(); } } $this->addForm($privacyForm); $this->assign('actionList', $resultList); }
public function edit($params) { if (!isset($params['questionId'])) { throw new Redirect404Exception(); } $questionId = (int) @$params['questionId']; if (empty($questionId)) { throw new Redirect404Exception(); } $this->addContentMenu(); $this->contentMenu->getElement('qst_index')->setActive(true); $editQuestion = $this->questionService->findQuestionById($questionId); $parent = $editQuestion->parent; $parentIsset = false; if (!empty($parent)) { $parentDto = $this->questionService->findQuestionByName($parent); $parentIsset = !empty($parentDto) ? true : false; if ($parentIsset) { $this->assign('parentUrl', OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'edit', array("questionId" => $parentDto->id))); $this->assign('parentLabel', $this->questionService->getQuestionLang($parentDto->name)); } } $this->assign('parentIsset', $parentIsset); if ($editQuestion === null) { throw new Redirect404Exception(); } $this->assign('question', $editQuestion); //$editQuestionToAccountType = $this->questionService->findAccountTypeByQuestionName( $editQuestion->name ); // get available account types from DB /* @var BOL_QuestionService $this->questionService */ $accountTypes = $this->questionService->findAllAccountTypes(); $serviceLang = BOL_LanguageService::getInstance(); $language = OW::getLanguage(); $currentLanguageId = OW::getLanguage()->getCurrentId(); $accounts = array(BOL_QuestionService::ALL_ACCOUNT_TYPES => $language->text('base', 'questions_account_type_all')); /* @var $value BOL_QuestionAccount */ foreach ($accountTypes as $value) { $accounts[$value->name] = $language->text('base', 'questions_account_type_' . $value->name); } $sections = $this->questionService->findAllSections(); // need to hide sections select box if (empty($section)) { $this->assign('no_sections', true); } $sectionsArray = array(); /* @var $section BOL_QuestionSection */ foreach ($sections as $section) { $sectionsArray[$section->name] = $language->text('base', 'questions_section_' . $section->name . '_label'); } $presentations = array(); $presentationsLabel = array(); $presentationList = $this->questionService->getPresentations(); if ($editQuestion->name != 'password') { unset($presentationList[BOL_QuestionService::QUESTION_PRESENTATION_PASSWORD]); } foreach ($presentationList as $presentationKey => $presentation) { if ($presentationList[$editQuestion->presentation] == $presentation) { $presentations[$presentationKey] = $presentationKey; //TODO add langs with presentation labels $presentationsLabel[$presentationKey] = $language->text('base', 'questions_question_presentation_' . $presentationKey . '_label'); } } $presentation = $editQuestion->presentation; if (OW::getSession()->isKeySet(self::EDIT_QUESTION_SESSION_VAR)) { $session = OW::getSession()->get(self::EDIT_QUESTION_SESSION_VAR); if (isset($session['qst_answer_type']) && isset($presentations[$session['qst_answer_type']])) { $presentation = $presentations[$session['qst_answer_type']]; } } if (isset($_POST['qst_answer_type']) && isset($presentations[$_POST['qst_answer_type']])) { $presentation = $presentations[$_POST['qst_answer_type']]; } //$this->addForm(new LanguageValueEditForm( 'base', 'questions_question_' . ($editQuestion->id) . '_label', $this ) ); //-- ------------------------------------- //-- add question values form creating //-- ------------------------------------- $questionValues = $this->questionService->findQuestionValues($editQuestion->name); $this->assign('questionValues', $questionValues); //add field values form $addQuestionValuesForm = new AddValuesForm($questionId); $addQuestionValuesForm->setAction($this->ajaxResponderUrl); $this->addForm($addQuestionValuesForm); //-- ------------------------------------- //-- edit field form creating //-- ------------------------------------- $editForm = new Form('qst_edit_form'); $editForm->setId('qst_edit_form'); $disableActionList = array('disable_account_type' => false, 'disable_answer_type' => false, 'disable_presentation' => false, 'disable_column_count' => false, 'disable_display_config' => false, 'disable_required' => false, 'disable_on_join' => false, 'disable_on_view' => false, 'disable_on_search' => false, 'disable_on_edit' => false); $event = new OW_Event('admin.disable_fields_on_edit_profile_question', array('questionDto' => $editQuestion), $disableActionList); OW::getEventManager()->trigger($event); $disableActionList = $event->getData(); if (count($accountTypes) > 1) { $qstAccountType = new Selectbox('qst_account_type'); $qstAccountType->setLabel($language->text('admin', 'questions_for_account_type_label')); $qstAccountType->setDescription($language->text('admin', 'questions_for_account_type_description')); $qstAccountType->setOptions($accounts); $qstAccountType->setValue(BOL_QuestionService::ALL_ACCOUNT_TYPES); $qstAccountType->setHasInvitation(false); if ($editQuestion->accountTypeName !== null) { $qstAccountType->setValue($editQuestion->accountTypeName); } if ($editQuestion->base == 1) { $qstAccountType->addAttribute('disabled', 'disabled'); } else { if ($disableActionList['disable_account_type']) { $qstAnswerType->setRequired(false); $qstAccountType->addAttribute('disabled', 'disabled'); } } $editForm->addElement($qstAccountType); } if (!empty($sectionsArray)) { $qstSection = new Selectbox('qst_section'); $qstSection->setLabel($language->text('admin', 'questions_question_section_label')); $qstSection->setOptions($sectionsArray); $qstSection->setValue($editQuestion->sectionName); $qstSection->setHasInvitation(false); $editForm->addElement($qstSection); } $qstAnswerType = new Selectbox('qst_answer_type'); $qstAnswerType->setLabel($language->text('admin', 'questions_answer_type_label')); $qstAnswerType->addAttribute('class', $qstAnswerType->getName()); $qstAnswerType->setOptions($presentationsLabel); $qstAnswerType->setValue($presentation); $qstAnswerType->setRequired(); $qstAnswerType->setHasInvitation(false); if ($parentIsset) { $qstAnswerType->setValue($parentDto->columnCount); $qstAnswerType->addAttribute('disabled', 'disabled'); } if ((int) $editQuestion->base === 1 || count($presentations) <= 1 || $parentIsset || $disableActionList['disable_answer_type']) { $qstAnswerType->setRequired(false); $qstAnswerType->addAttribute('disabled', 'disabled'); } $editForm->addElement($qstAnswerType); $columnCountPresentation = array(BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX, BOL_QuestionService::QUESTION_PRESENTATION_RADIO); if (in_array($presentation, $columnCountPresentation)) { $qstColumnCount = new Selectbox('qst_column_count'); $qstColumnCount->addAttribute('class', $qstColumnCount->getName()); $qstColumnCount->setLabel($language->text('admin', 'questions_columns_count_label')); $qstColumnCount->setRequired(); $qstColumnCount->setOptions($this->qstColumnCountValues); $qstColumnCount->setValue($editQuestion->columnCount); $parentIsset = !empty($parentDto) ? true : false; if ($parentIsset) { $qstColumnCount->setValue($parentDto->columnCount); $qstColumnCount->addAttribute('disabled', 'disabled'); $qstColumnCount->setRequired(false); } else { if ($disableActionList['disable_column_count']) { $qstAnswerType->setRequired(false); $qstAnswerType->addAttribute('disabled', 'disabled'); } } $editForm->addElement($qstColumnCount); } $presentationConfigList = BOL_QuestionService::getInstance()->getConfigList($presentation); $presentationConfigValues = json_decode($editQuestion->custom, true); if ($editQuestion->name !== 'joinStamp' && !$disableActionList['disable_display_config']) { foreach ($presentationConfigList as $config) { $className = $config->presentationClass; /* @var $qstConfig OW_FormElement */ $qstConfig = new $className($config->name); $qstConfig->setLabel($language->text('admin', 'questions_config_' . $config->name . '_label')); if (!empty($config->description)) { $qstConfig->setDescription($config->description); } if (isset($presentationConfigValues[$config->name])) { $qstConfig->setValue($presentationConfigValues[$config->name]); } $editForm->addElement($qstConfig); } } $qstRequired = new CheckboxField('qst_required'); $qstRequired->setLabel($language->text('admin', 'questions_required_label')); $qstRequired->setDescription($language->text('admin', 'questions_required_description')); $qstRequired->setValue((bool) $editQuestion->required); if ((int) $editQuestion->base === 1 || $disableActionList['disable_required']) { $qstRequired->addAttribute('disabled', 'disabled'); } $editForm->addElement($qstRequired); $qstOnSignUp = new CheckboxField('qst_on_sign_up'); $qstOnSignUp->setLabel($language->text('admin', 'questions_on_sing_up_label')); $qstOnSignUp->setDescription($language->text('admin', 'questions_on_sing_up_description')); $qstOnSignUp->setValue((bool) $editQuestion->onJoin); if ((int) $editQuestion->base === 1 || $disableActionList['disable_on_join']) { $qstOnSignUp->addAttribute('disabled', 'disabled'); } $editForm->addElement($qstOnSignUp); $qstOnEdit = new CheckboxField('qst_on_edit'); $qstOnEdit->setLabel($language->text('admin', 'questions_on_edit_label')); $qstOnEdit->setDescription($language->text('admin', 'questions_on_edit_description')); $qstOnEdit->setValue((bool) $editQuestion->onEdit); $description = $language->text('admin', 'questions_on_edit_description'); if ($editQuestion->name === 'username') { $qstOnEdit->setDescription($language->text('admin', 'questions_on_edit_description') . "<br/><br/>" . $language->text('admin', 'questions_edit_username_warning')); } else { if ((int) $editQuestion->base === 1 || $disableActionList['disable_on_edit']) { $qstOnEdit->addAttribute('disabled', 'disabled'); } } $editForm->addElement($qstOnEdit); $qstOnView = new CheckboxField('qst_on_view'); $qstOnView->setLabel($language->text('admin', 'questions_on_view_label')); $qstOnView->setDescription($language->text('admin', 'questions_on_view_description')); $qstOnView->setValue((bool) $editQuestion->onView); if ((int) $editQuestion->base === 1 && $editQuestion->name !== 'joinStamp' || $disableActionList['disable_on_view']) { $qstOnView->addAttribute('disabled', 'disabled'); } $editForm->addElement($qstOnView); $qstOnSearch = new CheckboxField('qst_on_search'); $qstOnSearch->setLabel($language->text('admin', 'questions_on_search_label')); $qstOnSearch->setDescription($language->text('admin', 'questions_on_search_description')); $qstOnSearch->setValue((bool) $editQuestion->onSearch); if ((int) $editQuestion->base === 1 && $editQuestion->name != 'username' || $parentIsset || $disableActionList['disable_on_search']) { $qstOnSearch->addAttribute('disabled', 'disabled'); } $editForm->addElement($qstOnSearch); $qstSubmit = new Submit('qst_submit'); $qstSubmit->addAttribute('class', 'ow_button ow_ic_save'); $qstSubmit->setValue($language->text('admin', 'btn_label_edit')); $editForm->addElement($qstSubmit); if (OW::getSession()->isKeySet(self::EDIT_QUESTION_SESSION_VAR)) { $editForm->setValues(OW::getSession()->get(self::EDIT_QUESTION_SESSION_VAR)); OW::getSession()->delete(self::EDIT_QUESTION_SESSION_VAR); } $this->addForm($editForm); if (OW_Request::getInstance()->isPost()) { if ((isset($_POST['qst_submit_and_add']) || isset($_POST['qst_submit'])) && $editForm->isValid($_POST)) { OW::getSession()->delete(self::EDIT_QUESTION_SESSION_VAR); $updated = false; $data = $editForm->getValues(); $elements = $editForm->getElements(); foreach ($elements as $element) { if (!$element->getAttribute('disabled')) { switch ($element->getName()) { case 'qst_required': $editQuestion->required = isset($_POST['qst_required']) ? 1 : 0; break; case 'qst_on_sign_up': $editQuestion->onJoin = isset($_POST['qst_on_sign_up']) ? 1 : 0; break; case 'qst_on_edit': $editQuestion->onEdit = isset($_POST['qst_on_edit']) ? 1 : 0; break; case 'qst_on_search': $editQuestion->onSearch = isset($_POST['qst_on_search']) ? 1 : 0; break; case 'qst_on_view': $editQuestion->onView = isset($_POST['qst_on_view']) ? 1 : 0; break; case 'qst_answer_type': $editQuestion->presentation = htmlspecialchars($data['qst_answer_type']); break; case 'qst_column_count': $editQuestion->columnCount = htmlspecialchars($data['qst_column_count']); break; case 'qst_section': if (!empty($data['qst_section'])) { $section = $this->questionService->findSectionBySectionName(htmlspecialchars(trim($data['qst_section']))); $sectionName = null; if (isset($section)) { $sectionName = $section->name; } if ($editQuestion->sectionName !== $sectionName) { $editQuestion->sectionName = $sectionName; $editQuestion->sortOrder = (int) BOL_QuestionService::getInstance()->findLastQuestionOrder($editQuestion->sectionName) + 1; } } break; case 'qst_account_type': if ($data['qst_account_type'] !== null) { $editQuestion->accountTypeName = htmlspecialchars(trim($data['qst_account_type'])); if ($editQuestion->accountTypeName === BOL_QuestionService::ALL_ACCOUNT_TYPES) { $editQuestion->accountTypeName = null; } } break; } } } if (!$disableActionList['disable_display_config']) { // save question configs $configs = array(); foreach ($presentationConfigList as $config) { if (isset($data[$config->name])) { $configs[$config->name] = $data[$config->name]; } } $editQuestion->custom = json_encode($configs); } $this->questionService->saveOrUpdateQuestion($editQuestion); if (OW::getDbo()->getAffectedRows() > 0) { $updated = true; $list = $this->questionService->findQuestionChildren($editQuestion->name); /* @var BOL_Question $child */ foreach ($list as $child) { $child->columnCount = $editQuestion->columnCount; $this->questionService->saveOrUpdateQuestion($child); } } //update question values sort if (isset($_POST['question_values_order'])) { $valuesOrder = json_decode($_POST['question_values_order'], true); if (isset($valuesOrder) && count($valuesOrder) > 0 && is_array($valuesOrder)) { foreach ($questionValues as $questionValue) { if (isset($valuesOrder[$questionValue->value])) { $questionValue->sortOrder = (int) $valuesOrder[$questionValue->value]; } $this->questionService->saveOrUpdateQuestionValue($questionValue); if (OW::getDbo()->getAffectedRows() > 0) { $updated = true; } } } } if ($updated) { OW::getFeedback()->info($language->text('admin', 'questions_update_question_message')); } else { OW::getFeedback()->info($language->text('admin', 'questions_question_was_not_updated_message')); } //exit; $this->redirect(OW::getRouter()->urlFor('ADMIN_CTRL_Questions', 'index')); } $editForm->setValues($_POST); OW::getSession()->set(self::EDIT_QUESTION_SESSION_VAR, $_POST); //OW::getFeedback()->error($language->text('admin', 'questions_question_was_not_updated_message')); $this->redirect(); } $types = array(); foreach ($this->questionService->getPresentations() as $presentation => $type) { if ($type === 'select') { $types[] = $presentation; } } $questionLabel = $this->questionService->getQuestionLang($editQuestion->name); $questionDescription = $this->questionService->getQuestionDescriptionLang($editQuestion->name); $noValue = $language->text('admin', 'questions_empty_lang_value'); $questionLabel = mb_strlen(trim($questionLabel)) == 0 || $questionLabel == ' ' ? $noValue : $questionLabel; $questionDescription = mb_strlen(trim($questionDescription)) == 0 || $questionDescription == ' ' ? $noValue : $questionDescription; $this->assign('questionLabel', $questionLabel); $this->assign('questionDescription', $questionDescription); $language->addKeyForJs('admin', 'questions_empty_lang_value'); $language->addKeyForJs('admin', 'questions_edit_question_name_title'); $language->addKeyForJs('admin', 'questions_edit_question_description_title'); $language->addKeyForJs('admin', 'questions_edit_question_value_title'); $language->addKeyForJs('admin', 'questions_edit_delete_value_confirm_message'); $fields = array(); foreach ($editForm->getElements() as $element) { if (!$element instanceof HiddenField) { $fields[$element->getName()] = $element->getName(); } } $this->assign('formData', $fields); $script = ' window.editQuestion = new editQuestion(' . json_encode(array('types' => $types, 'ajaxResponderUrl' => $this->ajaxResponderUrl)) . '); '; OW::getDocument()->addOnloadScript($script); $jsDir = OW::getPluginManager()->getPlugin("admin")->getStaticJsUrl(); $baseJsDir = OW::getPluginManager()->getPlugin("base")->getStaticJsUrl(); OW::getDocument()->addScript($jsDir . "questions.js"); OW::getDocument()->addScript($baseJsDir . "jquery-ui.min.js"); }
public function index() { $language = OW::getLanguage(); $config = OW::getConfig(); $adminForm = new Form('adminForm'); $element = new TextField('allowedFileSize'); $element->setRequired(true); $element->setValue($config->getValue('ivideo', 'allowedFileSize')); $element->setLabel($language->text('ivideo', 'admin_allowed_file_size')); $element->setDescription($language->text('ivideo', 'admin_allowed_file_size_desc')); $validator = new FloatValidator(1); $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error')); $element->addValidator($validator); $adminForm->addElement($element); $element = new Multiselect('allowedExtensions'); $element->setRequired(true); $element->setValue(explode(",", $config->getValue('ivideo', 'allowedExtensions'))); $element->setLabel($language->text('ivideo', 'admin_allowed_extension')); $element->setDescription($language->text('ivideo', 'admin_allowed_extension_desc')); $element->addOption('mp4', 'MP4'); $element->addOption('flv', 'FLV'); $element->addOption('avi', 'AVI'); $element->addOption('wmv', 'WMV'); $element->addOption('swf', 'SWF'); $element->addOption('mov', 'MOV'); $element->addOption('mpg', 'MPG'); $element->addOption('3g2', '3G2'); $element->addOption('ram', 'RAM'); $element->setSize(6); $adminForm->addElement($element); $element = new TextField('videosPerRow'); $element->setValue($config->getValue('ivideo', 'videosPerRow')); $element->setLabel($language->text('ivideo', 'admin_videos_per_row')); $element->setDescription($language->text('ivideo', 'admin_videos_per_row_desc')); $validator = new IntValidator(); $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error')); $element->addValidator($validator); $adminForm->addElement($element); $element = new TextField('videoPreviewWidth'); $element->setValue($config->getValue('ivideo', 'videoPreviewWidth')); $element->setLabel($language->text('ivideo', 'admin_video_preview_size')); $element->setDescription($language->text('ivideo', 'admin_video_preview_size_desc')); $validator = new IntValidator(); $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error')); $element->addValidator($validator); $adminForm->addElement($element); $element = new TextField('videoPreviewHeight'); $element->setValue($config->getValue('ivideo', 'videoPreviewHeight')); $element->setLabel($language->text('ivideo', 'admin_video_preview_height')); $validator = new IntValidator(); $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error')); $element->addValidator($validator); $adminForm->addElement($element); $element = new TextField('videoWidth'); $element->setValue($config->getValue('ivideo', 'videoWidth')); $element->setLabel($language->text('ivideo', 'admin_video_size')); $element->setDescription($language->text('ivideo', 'admin_video_size_desc')); $validator = new IntValidator(); $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error')); $element->addValidator($validator); $adminForm->addElement($element); $element = new TextField('videoHeight'); $element->setValue($config->getValue('ivideo', 'videoHeight')); $element->setLabel($language->text('ivideo', 'admin_video_height')); $validator = new IntValidator(); $validator->setErrorMessage($language->text('ivideo', 'admin_invalid_number_error')); $element->addValidator($validator); $adminForm->addElement($element); $element = new Selectbox('videoApproval'); $element->setRequired(true); $element->setValue($config->getValue('ivideo', 'videoApproval')); $element->setLabel($language->text('ivideo', 'admin_video_approval')); $element->addOption('auto', $language->text('ivideo', 'auto_approve')); $element->addOption('admin', $language->text('ivideo', 'admin_approve')); $element->setDescription($language->text('ivideo', 'admin_video_approval_desc')); $adminForm->addElement($element); $element = new Selectbox('theme'); $element->setRequired(true); $element->setValue($config->getValue('ivideo', 'theme')); $element->setLabel($language->text('ivideo', 'admin_video_theme')); $element->addOption('baseTheme', $language->text('ivideo', 'baseTheme')); $element->addOption('classicTheme', $language->text('ivideo', 'classicTheme')); $element->addOption('fancyTheme', $language->text('ivideo', 'fancyTheme')); $element->addOption('listTheme', $language->text('ivideo', 'listTheme')); $element->setDescription($language->text('ivideo', 'admin_video_theme_desc')); $adminForm->addElement($element); $element = new TextField('resultsPerPage'); $element->setRequired(true); $element->setLabel($language->text('ivideo', 'admin_results_per_page')); $element->setDescription($language->text('ivideo', 'admin_results_per_page_desc')); $element->setValue($config->getValue('ivideo', 'resultsPerPage')); $adminForm->addElement($element); $element = new TextField('ffmpegPath'); $element->setLabel($language->text('ivideo', 'admin_ffmpeg_path')); $element->setDescription($language->text('ivideo', 'admin_ffmpeg_path_desc')); $element->setValue($config->getValue('ivideo', 'ffmpegPath')); $adminForm->addElement($element); $element = new CheckboxField('makeUploaderMain'); $element->setLabel($language->text('ivideo', 'admin_make_uploader_main')); $element->setDescription($language->text('ivideo', 'admin_make_uploader_main_desc')); $element->setValue($config->getValue('ivideo', 'makeUploaderMain')); $adminForm->addElement($element); $element = new Submit('saveSettings'); $element->setValue(OW::getLanguage()->text('ivideo', 'admin_save_settings')); $adminForm->addElement($element); if (OW::getRequest()->isPost()) { if ($adminForm->isValid($_POST)) { $values = $adminForm->getValues(); $config->saveConfig('ivideo', 'allowedFileSize', $values['allowedFileSize']); $config->saveConfig('ivideo', 'allowedExtensions', implode(",", $values['allowedExtensions'])); $config->saveConfig('ivideo', 'videoWidth', $values['videoWidth']); $config->saveConfig('ivideo', 'videoHeight', $values['videoHeight']); $config->saveConfig('ivideo', 'videoPreviewWidth', $values['videoPreviewWidth']); $config->saveConfig('ivideo', 'videoPreviewHeight', $values['videoPreviewHeight']); $config->saveConfig('ivideo', 'resultsPerPage', $values['resultsPerPage']); $config->saveConfig('ivideo', 'videoApproval', $values['videoApproval']); $config->saveConfig('ivideo', 'theme', $values['theme']); $config->saveConfig('ivideo', 'videosPerRow', $values['videosPerRow']); $config->saveConfig('ivideo', 'makeUploaderMain', $values['makeUploaderMain']); $config->saveConfig('ivideo', 'ffmpegPath', $values['ffmpegPath']); OW::getFeedback()->info($language->text('ivideo', 'user_save_success')); } } $this->addForm($adminForm); }