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); }