auth->makePermissions([dcAuth::PERMISSION_ADMIN])); # Settings $s = dcCore::app()->blog->settings->kUtRL; # Default values $img_green = 'ok'; $img_red = 'fail'; $services_combo = []; foreach (kUtRL::getServices() as $service_id => $service) { $o = new $service(); $services_combo[__($o->name)] = $o->id; } $ext_services_combo = array_merge([__('Disabled') => ''], $services_combo); $lst_services_combo = array_merge(['-' => ''], $services_combo); $s_active = (bool) $s->kutrl_active; $s_plugin_service = (string) $s->kutrl_plugin_service; $s_admin_service = (string) $s->kutrl_admin_service; $s_tpl_service = (string) $s->kutrl_tpl_service; $s_wiki_service = (string) $s->kutrl_wiki_service; $s_allow_external_url = (bool) $s->kutrl_allow_external_url; $s_tpl_passive = (bool) $s->kutrl_tpl_passive; $s_tpl_active = (bool) $s->kutrl_tpl_active; $s_admin_entry_default = (string) $s->kutrl_admin_entry_default; if (!empty($_POST['save'])) { try { # settings $s_active = !empty($_POST['s_active']); $s_admin_service = (string) $_POST['s_admin_service']; $s_plugin_service = (string) $_POST['s_plugin_service']; $s_tpl_service = (string) $_POST['s_tpl_service']; $s_wiki_service = (string) $_POST['s_wiki_service']; $s_allow_external_url = !empty($_POST['s_allow_external_url']); $s_tpl_passive = !empty($_POST['s_tpl_passive']); $s_tpl_active = !empty($_POST['s_tpl_active']); $s_admin_entry_default = !empty($_POST['s_admin_entry_default']); $s->put('kutrl_active', $s_active); $s->put('kutrl_plugin_service', $s_plugin_service); $s->put('kutrl_admin_service', $s_admin_service); $s->put('kutrl_tpl_service', $s_tpl_service); $s->put('kutrl_wiki_service', $s_wiki_service); $s->put('kutrl_allow_external_url', $s_allow_external_url); $s->put('kutrl_tpl_passive', $s_tpl_passive); $s->put('kutrl_tpl_active', $s_tpl_active); $s->put('kutrl_admin_entry_default', $s_admin_entry_default); # services foreach (kUtRL::getServices() as $service_id => $service) { $o = new $service(); $o->saveSettings(); } dcCore::app()->blog->triggerBlog(); dcAdminNotices::addSuccessNotice( __('Configuration successfully updated.') ); dcCore::app()->adminurl->redirect( 'admin.plugins', ['module' => 'kUtRL', 'conf' => 1, 'chk' => 1, 'redir' => dcCore::app()->admin->list->getRedir()] ); } catch (Exception $e) { dcCore::app()->error->add($e->getMessage()); } } echo '

' . __('Settings') . '

' . __('Activation') . '


' . __('Behaviors') . '

' . __('Not only link started with this blog URL could be shortened.') . '

' . __('If this extension is disabled and the passive mode is enabled, "kutrl" tags (like EntryKurl) will display long urls instead of nothing on templates.') . '

' . __('If the active mode is enabled, all know default template tags (like EntryURL) will display short urls instead of long ones on templates.') . '
' . __('You can disable URL shortening for a specific template tag by adding attribute disable_kutrl="1" to it . ') . '

' . __('We strongly discourage using active mode as it crashes public post form and complex url if theme is not customize for kUtRL.') . '

' . __('This can be changed on page of creation/edition of an entry.') . '


' . __('Default services') . '

' . __('Service to use in this admin page and on edit page of an entry.') . '

' . __('Service to use on third part plugins.') . '

' . __('Shorten links automatically when using template value like "EntryKutrl".') . '

' . __('Shorten links automatically found in contents using wiki synthax.') . '

' . __('Services') . '

' . __('List of services you can use to shorten links with pkugin kUtRL.') . '

'; foreach (kUtRL::getServices() as $service_id => $service) { $o = new $service(); echo '
' . $o->name . '
'; if (!empty($_REQUEST['chk'])) { $img_chk = $img_red . ' ' . sprintf(__('Failed to test %s API.'), $o->name); try { if ($o->testService()) { $img_chk = $img_green . ' ' . sprintf(__('%s API is well configured and runing.'), $o->name); } } catch (Exception $e) { dcCore::app()->error->add(sprintf(__('Failed to test service %s: %s'), $o->name, $e->getMessage())); } echo sprintf('

%s

', $img_chk) . $o->error->toHTML(); } if ($o->home != '') { echo '

' . sprintf(__('Learn more about %s.'), $o->name) . '

'; } $o->settingsForm(); echo '
'; } echo'
';