use abstract plugin id and settings ns

This commit is contained in:
Jean-Christian Denis 2022-12-22 15:37:09 +01:00
parent e538e23c93
commit 59a603437c
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
22 changed files with 169 additions and 185 deletions

View file

@ -14,24 +14,24 @@ if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
dcCore::app()->blog->settings->addNamespace('kUtRL'); dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
require_once __DIR__ . '/_widgets.php'; require_once __DIR__ . '/_widgets.php';
# Plugin menu # Plugin menu
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Links shortener'), __('Links shortener'),
dcCore::app()->adminurl->get('admin.plugin.kUtRL'), dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
urldecode(dcPage::getPF('kUtRL/icon.svg')), urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.kUtRL')) . '(&.*)?$/', $_SERVER['REQUEST_URI']), preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]), dcCore::app()->blog->id) dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]), dcCore::app()->blog->id)
); );
# Admin behaviors # Admin behaviors
if (dcCore::app()->blog->settings->kUtRL->kutrl_active) { if (dcCore::app()->blog->settings->get(basename(__DIR__))->get('kutrl_active')) {
dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['adminKutrl', 'antispamDashboardFavorites']); dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['adminKutrl', 'antispamDashboardFavoritesV2']);
dcCore::app()->addBehavior('adminColumnsListsV2', ['adminKutrl', 'adminColumnsLists']); dcCore::app()->addBehavior('adminColumnsListsV2', ['adminKutrl', 'adminColumnsListsV2']);
dcCore::app()->addBehavior('adminFiltersListsV2', ['adminKutrl', 'adminFiltersLists']); dcCore::app()->addBehavior('adminFiltersListsV2', ['adminKutrl', 'adminFiltersListsV2']);
dcCore::app()->addBehavior('adminPostHeaders', ['adminKutrl', 'adminPostHeaders']); dcCore::app()->addBehavior('adminPostHeaders', ['adminKutrl', 'adminPostHeaders']);
dcCore::app()->addBehavior('adminPostFormItems', ['adminKutrl', 'adminPostFormItems']); dcCore::app()->addBehavior('adminPostFormItems', ['adminKutrl', 'adminPostFormItems']);
dcCore::app()->addBehavior('adminAfterPostUpdate', ['adminKutrl', 'adminAfterPostUpdate']); // update existing short url dcCore::app()->addBehavior('adminAfterPostUpdate', ['adminKutrl', 'adminAfterPostUpdate']); // update existing short url
@ -41,11 +41,11 @@ if (dcCore::app()->blog->settings->kUtRL->kutrl_active) {
dcCore::app()->addBehavior('adminPostsActions', ['adminKutrl', 'adminPostsActions']); dcCore::app()->addBehavior('adminPostsActions', ['adminKutrl', 'adminPostsActions']);
} }
dcCore::app()->addBehavior('exportFullV2', ['backupKutrl', 'exportFull']); dcCore::app()->addBehavior('exportFullV2', ['backupKutrl', 'exportFullV2']);
dcCore::app()->addBehavior('exportSingleV2', ['backupKutrl', 'exportSingle']); dcCore::app()->addBehavior('exportSingleV2', ['backupKutrl', 'exportSingleV2']);
dcCore::app()->addBehavior('importInitV2', ['backupKutrl', 'importInit']); dcCore::app()->addBehavior('importInitV2', ['backupKutrl', 'importInitV2']);
dcCore::app()->addBehavior('importSingleV2', ['backupKutrl', 'importSingle']); dcCore::app()->addBehavior('importSingleV2', ['backupKutrl', 'importSingleV2']);
dcCore::app()->addBehavior('importFullV2', ['backupKutrl', 'importFull']); dcCore::app()->addBehavior('importFullV2', ['backupKutrl', 'importFullV2']);
# Admin behaviors class # Admin behaviors class
class adminKutrl class adminKutrl
@ -60,21 +60,21 @@ class adminKutrl
]; ];
} }
public static function antispamDashboardFavorites(dcFavorites $favs) public static function antispamDashboardFavoritesV2(dcFavorites $favs)
{ {
$favs->register( $favs->register(
'kUtRL', 'kUtRL',
[ [
'title' => __('Links shortener'), 'title' => __('Links shortener'),
'url' => dcCore::app()->adminurl->get('admin.plugin.kUtRL'), 'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
'small-icon' => dcPage::getPF('kUtRL/icon.png'), 'small-icon' => dcPage::getPF(basename(__DIR__) . '/icon.png'),
'large-icon' => dcPage::getPF('kUtRL/icon-b.png'), 'large-icon' => dcPage::getPF(basename(__DIR__) . '/icon-b.png'),
'permissions' => dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]), 'permissions' => dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]),
] ]
); );
} }
public static function adminColumnsLists($cols) public static function adminColumnsListsV2($cols)
{ {
$cols['kUtRL'] = [ $cols['kUtRL'] = [
__('Links shortener'), __('Links shortener'),
@ -86,7 +86,7 @@ class adminKutrl
]; ];
} }
public static function adminFiltersLists($sorts) public static function adminFiltersListsV2($sorts)
{ {
$sorts['kUtRL'] = [ $sorts['kUtRL'] = [
__('Links shortener'), __('Links shortener'),
@ -99,14 +99,14 @@ class adminKutrl
public static function adminPostHeaders() public static function adminPostHeaders()
{ {
return dcPage::jsLoad(dcPage::getPF('kUtRL/js/posts.js')); return dcPage::jsModuleLoad(basename(__DIR__) . '/js/posts.js');
} }
public static function adminPostFormItems($main_items, $sidebar_items, $post) public static function adminPostFormItems($main_items, $sidebar_items, $post)
{ {
$s = dcCore::app()->blog->settings->kUtRL; $s = dcCore::app()->blog->settings->get(basename(__DIR__));
if (!$s->kutrl_active || !$s->kutrl_admin_service) { if (!$s->get('kutrl_active') || !$s->get('kutrl_admin_service')) {
return null; return null;
} }
if (null === ($kut = kUtRL::quickPlace('admin'))) { if (null === ($kut = kUtRL::quickPlace('admin'))) {
@ -125,19 +125,19 @@ class adminKutrl
form::hidden(['kutrl_old_post_url'], $post_url); form::hidden(['kutrl_old_post_url'], $post_url);
if (!$rs) { if (!$rs) {
if (empty($_POST['kutrl_old_post_url']) && $s->kutrl_admin_entry_default) { if (empty($_POST['kutrl_old_post_url']) && $s->get('kutrl_admin_entry_default')) {
$chk = true; $chk = true;
} else { } else {
$chk = !empty($_POST['kutrl_create']); $chk = !empty($_POST['kutrl_create']);
} }
$ret .= '<p><label class="classic">' . $ret .= '<p><label class="classic">' .
form::checkbox('kutrl_create', 1, $chk, '', 3) . ' ' . form::checkbox('kutrl_create', 1, $chk, '', '3') . ' ' .
__('Create short link') . '</label></p>'; __('Create short link') . '</label></p>';
if ($kut->allow_custom_hash) { if ($kut->allow_custom_hash) {
$ret .= '<p class="classic">' . $ret .= '<p class="classic">' .
'<label for="custom">' . __('Custom short link:') . ' ' . '<label for="custom">' . __('Custom short link:') . ' ' .
form::field('kutrl_create_custom', 32, 32, '', 3) . form::field('kutrl_create_custom', 32, 32, '', '3') .
'</label></p>'; '</label></p>';
} }
} else { } else {
@ -152,7 +152,7 @@ class adminKutrl
$href = $kut->url_base . $rs->hash; $href = $kut->url_base . $rs->hash;
$ret .= '<p><label class="classic">' . $ret .= '<p><label class="classic">' .
form::checkbox('kutrl_delete', 1, !empty($_POST['kutrl_delete']), '', 3) . ' ' . form::checkbox('kutrl_delete', 1, !empty($_POST['kutrl_delete']), '', '3') . ' ' .
__('Delete short link') . '</label></p>' . __('Delete short link') . '</label></p>' .
'<p><a href="' . $href . '" ' . 'title="' . $title . '">' . $href . '</a></p>'; '<p><a href="' . $href . '" ' . 'title="' . $title . '">' . $href . '</a></p>';
} }
@ -163,10 +163,8 @@ class adminKutrl
public static function adminAfterPostUpdate($cur, $post_id) public static function adminAfterPostUpdate($cur, $post_id)
{ {
$s = dcCore::app()->blog->settings->kUtRL;
# Create: see adminAfterPostCreate # Create: see adminAfterPostCreate
if (!empty($_POST['kutrl_create']) || !$s->kutrl_active) { if (!empty($_POST['kutrl_create']) || !dcCore::app()->blog->settings->get(basename(__DIR__))->get('kutrl_active')) {
return null; return null;
} }
if (null === ($kut = kUtRL::quickPlace('admin'))) { if (null === ($kut = kUtRL::quickPlace('admin'))) {
@ -200,7 +198,7 @@ class adminKutrl
$kut->remove($old_post_url); $kut->remove($old_post_url);
$rs = $kut->hash($new_post_url, $custom); // better to update (not yet implemented) $rs = $kut->hash($new_post_url, '');//$custom); // better to update (not yet implemented)
$url = $kut->url_base . $rs->hash; $url = $kut->url_base . $rs->hash;
# ex: Send new url to messengers # ex: Send new url to messengers
@ -212,11 +210,10 @@ class adminKutrl
public static function adminAfterPostCreate($cur, $post_id) public static function adminAfterPostCreate($cur, $post_id)
{ {
$s = dcCore::app()->blog->settings->kUtRL; if (empty($_POST['kutrl_create']) || !dcCore::app()->blog->settings->get(basename(__DIR__))->get('kutrl_active')) {
if (empty($_POST['kutrl_create']) || !$s->kutrl_active) {
return null; return null;
} }
if (null === ($kut = kUtRL::quickPlace('admin'))) { if (null === ($kut = kUtRL::quickPlace('admin'))) {
return null; return null;
} }
@ -241,11 +238,10 @@ class adminKutrl
public static function adminBeforePostDelete($post_id) public static function adminBeforePostDelete($post_id)
{ {
$s = dcCore::app()->blog->settings->kUtRL; if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('kutrl_active')) {
if (!$s->kutrl_active) {
return null; return null;
} }
if (null === ($kut = kUtRL::quickPlace('admin'))) { if (null === ($kut = kUtRL::quickPlace('admin'))) {
return null; return null;
} }
@ -260,9 +256,7 @@ class adminKutrl
public static function adminPostsActions(dcPostsActions $pa) public static function adminPostsActions(dcPostsActions $pa)
{ {
$s = dcCore::app()->blog->settings->kUtRL; if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('kutrl_active')
if (!$s->kutrl_active
|| !dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]), dcCore::app()->blog->id)) { || !dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]), dcCore::app()->blog->id)) {
return null; return null;
} }
@ -279,10 +273,6 @@ class adminKutrl
public static function callbackCreate(dcPostsActions $pa, ArrayObject $post) public static function callbackCreate(dcPostsActions $pa, ArrayObject $post)
{ {
if (null === ($kut = kUtRL::quickPlace('admin'))) {
return null;
}
# No entry # No entry
$posts_ids = $pa->getIDs(); $posts_ids = $pa->getIDs();
if (empty($posts_ids)) { if (empty($posts_ids)) {
@ -294,6 +284,10 @@ class adminKutrl
throw new Exception(__('No enough right')); throw new Exception(__('No enough right'));
} }
if (null === ($kut = kUtRL::quickPlace('admin'))) {
return null;
}
# retrieve posts info and create hash # retrieve posts info and create hash
$posts = dcCore::app()->blog->getPosts(['post_id' => $posts_ids]); $posts = dcCore::app()->blog->getPosts(['post_id' => $posts_ids]);
while ($posts->fetch()) { while ($posts->fetch()) {
@ -317,6 +311,10 @@ class adminKutrl
throw new Exception(__('No enough right')); throw new Exception(__('No enough right'));
} }
if (null === ($kut = kUtRL::quickPlace('admin'))) {
return null;
}
# retrieve posts info and create hash # retrieve posts info and create hash
$posts = dcCore::app()->blog->getPosts(['post_id' => $posts_ids]); $posts = dcCore::app()->blog->getPosts(['post_id' => $posts_ids]);
while ($posts->fetch()) { while ($posts->fetch()) {
@ -331,7 +329,7 @@ class adminKutrl
# Import/export behaviors for Import/export plugin # Import/export behaviors for Import/export plugin
class backupKutrl class backupKutrl
{ {
public static function exportSingle($exp, $blog_id) public static function exportSingleV2($exp, $blog_id)
{ {
$exp->export( $exp->export(
'kutrl', 'kutrl',
@ -342,18 +340,18 @@ class backupKutrl
); );
} }
public static function exportFull($exp) public static function exportFullV2($exp)
{ {
$exp->exportTable('kutrl'); $exp->exportTable('kutrl');
} }
public static function importInit($bk) public static function importInitV2($bk)
{ {
$bk->cur_kutrl = dcCore::app()->con->openCursor(dcCore::app()->prefix . initkUtRL::KURL_TABLE_NAME); $bk->cur_kutrl = dcCore::app()->con->openCursor(dcCore::app()->prefix . initkUtRL::KURL_TABLE_NAME);
$bk->kutrl = new kutrlLog(); $bk->kutrl = new kutrlLog();
} }
public static function importSingle($line, $bk) public static function importSingleV2($line, $bk)
{ {
if ($line->__name == 'kutrl') { if ($line->__name == 'kutrl') {
# Do nothing if str/type exists ! # Do nothing if str/type exists !
@ -363,7 +361,7 @@ class backupKutrl
} }
} }
public static function importFull($line, $bk) public static function importFullV2($line, $bk)
{ {
if ($line->__name == 'kutrl') { if ($line->__name == 'kutrl') {
$bk->cur_kutrl->clean(); $bk->cur_kutrl->clean();

View file

@ -18,7 +18,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
dcPage::check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN])); dcPage::check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_ADMIN]));
# Settings # Settings
$s = dcCore::app()->blog->settings->kUtRL; $s = dcCore::app()->blog->settings->get(basename(__DIR__));
# Default values # Default values
$img_green = '<img src="images/check-on.png" alt="ok" />'; $img_green = '<img src="images/check-on.png" alt="ok" />';
@ -32,15 +32,15 @@ foreach (kUtRL::getServices() as $service_id => $service) {
$ext_services_combo = array_merge([__('Disabled') => ''], $services_combo); $ext_services_combo = array_merge([__('Disabled') => ''], $services_combo);
$lst_services_combo = array_merge(['-' => ''], $services_combo); $lst_services_combo = array_merge(['-' => ''], $services_combo);
$s_active = (bool) $s->kutrl_active; $s_active = (bool) $s->get('kutrl_active');
$s_plugin_service = (string) $s->kutrl_plugin_service; $s_plugin_service = (string) $s->get('kutrl_plugin_service');
$s_admin_service = (string) $s->kutrl_admin_service; $s_admin_service = (string) $s->get('kutrl_admin_service');
$s_tpl_service = (string) $s->kutrl_tpl_service; $s_tpl_service = (string) $s->get('kutrl_tpl_service');
$s_wiki_service = (string) $s->kutrl_wiki_service; $s_wiki_service = (string) $s->get('kutrl_wiki_service');
$s_allow_external_url = (bool) $s->kutrl_allow_external_url; $s_allow_external_url = (bool) $s->get('kutrl_allow_external_url');
$s_tpl_passive = (bool) $s->kutrl_tpl_passive; $s_tpl_passive = (bool) $s->get('kutrl_tpl_passive');
$s_tpl_active = (bool) $s->kutrl_tpl_active; $s_tpl_active = (bool) $s->get('kutrl_tpl_active');
$s_admin_entry_default = (string) $s->kutrl_admin_entry_default; $s_admin_entry_default = (string) $s->get('kutrl_admin_entry_default');
if (!empty($_POST['save'])) { if (!empty($_POST['save'])) {
try { try {
@ -79,7 +79,7 @@ if (!empty($_POST['save'])) {
dcCore::app()->adminurl->redirect( dcCore::app()->adminurl->redirect(
'admin.plugins', 'admin.plugins',
['module' => 'kUtRL', 'conf' => 1, 'chk' => 1, 'redir' => dcCore::app()->admin->list->getRedir()] ['module' => basename(__DIR__), 'conf' => 1, 'chk' => 1, 'redir' => dcCore::app()->admin->list->getRedir()]
); );
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());

View file

@ -17,7 +17,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
try { try {
# Compare versions # Compare versions
if (!dcCore::app()->newVersion( if (!dcCore::app()->newVersion(
basename(__DIR__), basename(__DIR__),
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version') dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
)) { )) {
return null; return null;
@ -46,8 +46,8 @@ try {
$changes = $ti->synchronize($t); $changes = $ti->synchronize($t);
# Settings # Settings
dcCore::app()->blog->settings->addNamespace(basename(__DIR__)); $s = dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
$s->put('kutrl_active', false, 'boolean', 'Enabled kutrl plugin', false, true); $s->put('kutrl_active', false, 'boolean', 'Enabled kutrl plugin', false, true);
$s->put('kutrl_plugin_service', 'default', 'string', 'Service to use to shorten links on third part plugins', false, true); $s->put('kutrl_plugin_service', 'default', 'string', 'Service to use to shorten links on third part plugins', false, true);
$s->put('kutrl_admin_service', 'local', 'string', 'Service to use to shorten links on admin', false, true); $s->put('kutrl_admin_service', 'local', 'string', 'Service to use to shorten links on admin', false, true);

View file

@ -18,11 +18,11 @@ require_once __DIR__ . '/_widgets.php';
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), __DIR__ . '/default-templates'); dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), __DIR__ . '/default-templates');
dcCore::app()->addBehavior('publicBeforeDocumentV2', ['pubKutrl', 'publicBeforeDocument']); dcCore::app()->addBehavior('publicBeforeDocumentV2', ['pubKutrl', 'publicBeforeDocumentV2']);
dcCore::app()->addBehavior('publicHeadContent', ['pubKutrl', 'publicHeadContent']); dcCore::app()->addBehavior('publicHeadContent', ['pubKutrl', 'publicHeadContent']);
dcCore::app()->addBehavior('publicBeforeContentFilterV2', ['pubKutrl', 'publicBeforeContentFilter']); dcCore::app()->addBehavior('publicBeforeContentFilterV2', ['pubKutrl', 'publicBeforeContentFilterV2']);
dcCore::app()->addBehavior('templateBeforeValueV2', ['pubKutrl', 'templateBeforeValue']); dcCore::app()->addBehavior('templateBeforeValueV2', ['pubKutrl', 'templateBeforeValueV2']);
dcCore::app()->addBehavior('templateAfterValueV2', ['pubKutrl', 'templateAfterValue']); dcCore::app()->addBehavior('templateAfterValueV2', ['pubKutrl', 'templateAfterValueV2']);
dcCore::app()->tpl->addBlock('kutrlPageIf', ['tplKutrl', 'pageIf']); dcCore::app()->tpl->addBlock('kutrlPageIf', ['tplKutrl', 'pageIf']);
dcCore::app()->tpl->addBlock('kutrlMsgIf', ['tplKutrl', 'pageMsgIf']); dcCore::app()->tpl->addBlock('kutrlMsgIf', ['tplKutrl', 'pageMsgIf']);
@ -50,10 +50,8 @@ class urlKutrl extends dcUrlHandlers
# Redirect !!! local !!! service only # Redirect !!! local !!! service only
public static function redirectUrl($args) public static function redirectUrl($args)
{ {
$s = dcCore::app()->blog->settings->kUtRL;
# Not active, go to default 404 # Not active, go to default 404
if (!$s->kutrl_active) { if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('kutrl_active')) {
self::p404(); self::p404();
return null; return null;
@ -90,7 +88,7 @@ class urlKutrl extends dcUrlHandlers
} }
# Not find, go to kutrl 404 # Not find, go to kutrl 404
if (false === ($url = $kut->getUrl($args))) { if (false === ($url = $kut->getUrl($args))) {
//$_ctx->kutrl_msg = 'Failed to find short link.'; //dcCore::app()->ctx->kutrl_msg = 'Failed to find short link.';
//self::pageKutrl($kut); //self::pageKutrl($kut);
self::kutrl404(); self::kutrl404();
@ -111,16 +109,16 @@ class urlKutrl extends dcUrlHandlers
private static function pageKutrl($kut) private static function pageKutrl($kut)
{ {
$s = dcCore::app()->blog->settings->kUtRL; $s = dcCore::app()->blog->settings->get(basename(__DIR__));
# Not active, go to default 404 # Not active, go to default 404
if (!$s->kutrl_active) { if (!$s->get('kutrl_active')) {
self::p404(); self::p404();
return null; return null;
} }
# Public page not active, go to kutrl 404 # Public page not active, go to kutrl 404
if (!$s->kutrl_srv_local_public) { if (!$s->get('kutrl_srv_local_public')) {
self::kutrl404(); self::kutrl404();
return null; return null;
@ -220,7 +218,7 @@ class urlKutrl extends dcUrlHandlers
protected static function kutrl404() protected static function kutrl404()
{ {
if (!dcCore::app()->blog->settings->kUtRL->kutrl_srv_local_404_active) { if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('kutrl_srv_local_404_active')) {
self::p404(); self::p404();
return null; return null;
@ -257,37 +255,37 @@ class pubKutrl
]; ];
# Disable URL shoretning on filtered tag # Disable URL shoretning on filtered tag
public static function templateBeforeValue($tag, $attr) public static function templateBeforeValueV2($tag, $attr)
{ {
if (!empty($attr['disable_kutrl']) && in_array($tag, pubKutrl::$know_tags)) { if (!empty($attr['disable_kutrl']) && in_array($tag, pubKutrl::$know_tags)) {
return '<?php $GLOBALS["disable_kutrl"] = true; ?>'; return '<?php dcCore::app()->ctx->__set("disable_kutrl", true); ?>';
} }
return null; return null;
} }
# Re unable it after tag # Re unable it after tag
public static function templateAfterValue($tag, $attr) public static function templateAfterValueV2($tag, $attr)
{ {
if (!empty($attr['disable_kutrl']) && in_array($tag, pubKutrl::$know_tags)) { if (!empty($attr['disable_kutrl']) && in_array($tag, pubKutrl::$know_tags)) {
return '<?php $GLOBALS["disable_kutrl"] = false; ?>'; return '<?php dcCore::app()->ctx->__set("disable_kutrl", false); ?>';
} }
return null; return null;
} }
# Replace long urls on the fly (on filter) for default tags # Replace long urls on the fly (on filter) for default tags
public static function publicBeforeContentFilter($tag, $args) public static function publicBeforeContentFilterV2($tag, $args)
{ {
# Unknow tag # Unknow tag
if (!in_array($tag, pubKutrl::$know_tags)) { if (!in_array($tag, pubKutrl::$know_tags)) {
return null; return null;
} }
# URL shortening is disabled by tag attribute # URL shortening is disabled by tag attribute
if (empty($GLOBALS['disable_kutrl'])) { if (true !== dcCore::app()->ctx->__get('disable_kutrl')) {
# kUtRL is not activated # kUtRL is not activated
if (!dcCore::app()->blog->settings->kUtRL->kutrl_active if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('kutrl_active')
|| !dcCore::app()->blog->settings->kUtRL->kutrl_tpl_active || !dcCore::app()->blog->settings->get(basename(__DIR__))->get('kutrl_tpl_active')
) { ) {
return null; return null;
} }
@ -311,14 +309,14 @@ class pubKutrl
} }
} }
public static function publicBeforeDocument() public static function publicBeforeDocumentV2()
{ {
$s = dcCore::app()->blog->settings->kUtRL; $s = dcCore::app()->blog->settings->get(basename(__DIR__));
# Passive : all kutrl tag return long url # Passive : all kutrl tag return long url
dcCore::app()->ctx->kutrl_passive = (bool) $s->kutrl_tpl_passive; dcCore::app()->ctx->kutrl_passive = (bool) $s->get('kutrl_tpl_passive');
if (!$s->kutrl_active || !$s->kutrl_tpl_service) { if (!$s->get('kutrl_active') || !$s->get('kutrl_tpl_service')) {
return null; return null;
} }
if (null === ($kut = kUtRL::quickPlace('tpl'))) { if (null === ($kut = kUtRL::quickPlace('tpl'))) {
@ -327,9 +325,9 @@ class pubKutrl
dcCore::app()->ctx->kutrl = $kut; dcCore::app()->ctx->kutrl = $kut;
} }
public static function publicHeadContent($core) public static function publicHeadContent($_)
{ {
$css = dcCore::app()->blog->settings->kUtRL->kutrl_srv_local_css; $css = dcCore::app()->blog->settings->get(basename(__DIR__))->get('kutrl_srv_local_css');
if ($css) { if ($css) {
echo echo
"\n<!-- CSS for kUtRL --> \n" . "\n<!-- CSS for kUtRL --> \n" .
@ -355,7 +353,7 @@ class tplKutrl
if (isset($attr['is_active'])) { if (isset($attr['is_active'])) {
$sign = (bool) $attr['is_active'] ? '' : '!'; $sign = (bool) $attr['is_active'] ? '' : '!';
$if[] = $sign . 'dcCore::app()->blog->settings->kUtRL->kutrl_srv_local_public'; $if[] = $sign . 'dcCore::app()->blog->settings->get("kUtRL")->get("kutrl_srv_local_public")';
} }
if (empty($if)) { if (empty($if)) {
return $content; return $content;

View file

@ -20,7 +20,7 @@ $this->addUserAction(
/* action */ /* action */
'delete_all', 'delete_all',
/* ns */ /* ns */
'kUtRL', basename(__DIR__),
/* description */ /* description */
__('delete all settings') __('delete all settings')
); );
@ -42,7 +42,7 @@ $this->addUserAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
'kUtRL', basename(__DIR__),
/* description */ /* description */
__('delete plugin files') __('delete plugin files')
); );
@ -53,7 +53,7 @@ $this->addUserAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
'kUtRL', basename(__DIR__),
/* description */ /* description */
__('delete the version number') __('delete the version number')
); );
@ -67,7 +67,7 @@ $this->addDirectAction(
/* action */ /* action */
'delete_all', 'delete_all',
/* ns */ /* ns */
'kUtRL', basename(__DIR__),
/* description */ /* description */
sprintf(__('delete all %s settings'), 'kUtRL') sprintf(__('delete all %s settings'), 'kUtRL')
); );
@ -78,7 +78,7 @@ $this->addDirectAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
'kUtRL', basename(__DIR__),
/* description */ /* description */
sprintf(__('delete %s version number'), 'kUtRL') sprintf(__('delete %s version number'), 'kUtRL')
); );
@ -89,7 +89,7 @@ $this->addDirectAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
'kUtRL', basename(__DIR__),
/* description */ /* description */
sprintf(__('delete %s plugin files'), 'kUtRL') sprintf(__('delete %s plugin files'), 'kUtRL')
); );

View file

@ -114,10 +114,10 @@ class widgetKutrl
public static function publicShorten($w) public static function publicShorten($w)
{ {
$s = dcCore::app()->blog->settings->kUtRL; $s = dcCore::app()->blog->settings->get(basename(__DIR__));
if (!$s->kutrl_active if (!$s->get('kutrl_active')
|| !$s->kutrl_srv_local_public || !$s->get('kutrl_srv_local_public')
|| !$w->checkHomeOnly(dcCore::app()->url->type) || !$w->checkHomeOnly(dcCore::app()->url->type)
|| dcCore::app()->url->type == 'kutrl') { || dcCore::app()->url->type == 'kutrl') {
return null; return null;
@ -151,9 +151,9 @@ class widgetKutrl
public static function publicRank($w) public static function publicRank($w)
{ {
$s = dcCore::app()->blog->settings->kUtRL; $s = dcCore::app()->blog->settings->get(basename(__DIR__));
if (!$s->kutrl_active || !$w->checkHomeOnly(dcCore::app()->url->type)) { if (!$s->get('kutrl_active') || !$w->checkHomeOnly(dcCore::app()->url->type)) {
return null; return null;
} }

View file

@ -63,7 +63,7 @@ class kUtRL
if (!in_array($place, ['tpl', 'wiki', 'admin', 'plugin'])) { if (!in_array($place, ['tpl', 'wiki', 'admin', 'plugin'])) {
return null; return null;
} }
$id = dcCore::app()->blog->settings->kUtRL->get('kutrl_' . $place . '_service'); $id = dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->get('kutrl_' . $place . '_service');
if (!empty($id)) { if (!empty($id)) {
return self::quickService($id); return self::quickService($id);
} }

View file

@ -16,24 +16,16 @@ if (!defined('DC_RC_PATH')) {
return null; return null;
} }
dcCore::app()->activityReport->addGroup('kutrl', __('Plugin kUtRL')); dcCore::app()->__get('activityReport')->addGroup('kutrl', __('Plugin kUtRL'));
# from BEHAVIOR kutrlAfterCreateShortUrl in kUtRL/inc/lib.kutrl.srv.php # from BEHAVIOR kutrlAfterCreateShortUrl in kUtRL/inc/lib.kutrl.srv.php
dcCore::app()->activityReport->addAction( dcCore::app()->__get('activityReport')->addAction(
'kutrl', 'kutrl',
'create', 'create',
__('Short link creation'), __('Short link creation'),
__('New short link of type "%s" and hash "%s" was created.'), __('New short link of type "%s" and hash "%s" was created.'),
'kutrlAfterCreateShortUrl', 'kutrlAfterCreateShortUrl',
['kutrlActivityReportBehaviors', 'kutrlCreate'] function ($rs) {
); dcCore::app()->__get('activityReport')->addLog('kutrl', 'create', [$rs->type, $rs->hash]);
class kutrlActivityReportBehaviors
{
public static function kutrlCreate($rs)
{
$logs = [$rs->type,$rs->hash];
dcCore::app()->activityReport->addLog('kutrl', 'create', $logs);
} }
} );

View file

@ -105,16 +105,16 @@ class kutrlLinkslist
} }
$cols = [ $cols = [
'check' => '<td class="nowrap">' . 'check' => '<td class="nowrap">' .
form::checkbox(['entries[]'], $this->rs->kut_id, ['checked' => isset($entries[$this->rs->kut_id])]) . form::checkbox(['entries[]'], $this->rs->kut_id, ['checked' => $checked]) .
'</td>', '</td>',
'kut_url' => '<td class="maximal" scope="row">' . 'kut_url' => '<td class="maximal" scope="row">' .
'<a href="' . $this->rs->kut_url . '">' . $this->rs->kut_url . '</a>' . '<a href="' . $this->rs->kut_url . '">' . $this->rs->kut_url . '</a>' .
'</td>', '</td>',
'kut_hash' => '<td class="nowrap">' . 'kut_hash' => '<td class="nowrap">' .
$hash . $hash .
'</td>', '</td>',
'kut_dt' => '<td class="nowrap count">' . 'kut_dt' => '<td class="nowrap count">' .
dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->kut_dt, dcCore::app()->auth->getInfo('user_tz')) . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->kut_dt, dcCore::app()->auth->getInfo('user_tz')) .
'</td>', '</td>',
'kut_service' => '<td class="nowrap">' . 'kut_service' => '<td class="nowrap">' .

View file

@ -22,7 +22,7 @@ class kutrlService
public function __construct() public function __construct()
{ {
$this->settings = dcCore::app()->blog->settings->kUtRL; $this->settings = dcCore::app()->blog->settings->get(basename(dirname(__DIR__)));
$this->log = new kutrlLog(); $this->log = new kutrlLog();
$this->error = new dcError(); $this->error = new dcError();
//$this->error->setHTMLFormat('%s', "%s\n"); //$this->error->setHTMLFormat('%s', "%s\n");
@ -30,24 +30,24 @@ class kutrlService
$this->init(); $this->init();
// Force setting // Force setting
$allow_external_url = $this->settings->kutrl_allow_external_url; $allow_external_url = $this->settings->get('kutrl_allow_external_url');
$this->config['$allow_external_url'] = null === $allow_external_url ? $this->config['$allow_external_url'] = null === $allow_external_url ?
true : $allow_external_url; true : $allow_external_url;
$this->config = array_merge( $this->config = array_merge(
[ [
'id' => 'undefined', 'id' => 'undefined',
'name' => 'undefined', 'name' => 'undefined',
'home' => '', 'home' => '',
'allow_external_url' => true, 'allow_external_url' => true,
'allow_custom_hash' => false, 'allow_custom_hash' => false,
'allow_protocols' => ['http://'], 'allow_protocols' => ['http://'],
'url_test' => 'http://dotclear.jcdenis.com/go/kUtRL', 'url_test' => 'http://dotclear.jcdenis.com/go/kUtRL',
'url_api' => '', 'url_api' => '',
'url_base' => '', 'url_base' => '',
'url_min_len' => 0, 'url_min_len' => 0,
], ],
$this->config $this->config
); );

View file

@ -20,12 +20,10 @@ class kutrlWiki
{ {
public static function coreInitWiki($wiki2xhtml) public static function coreInitWiki($wiki2xhtml)
{ {
$s = dcCore::app()->blog->settings->kUtRL;
# Do nothing on comment preview and post preview # Do nothing on comment preview and post preview
if (!empty($_POST['preview']) if (!empty($_POST['preview'])
|| isset(dcCore::app()->ctx) && dcCore::app()->ctx->preview || isset(dcCore::app()->ctx) && dcCore::app()->ctx->preview
|| !$s->kutrl_active || !dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->get('kutrl_active')
) { ) {
return null; return null;
} }
@ -42,9 +40,7 @@ class kutrlWiki
public static function transform($url, $content) public static function transform($url, $content)
{ {
$s = dcCore::app()->blog->settings->kUtRL; if (!dcCore::app()->blog->settings->get(basename(dirname(__DIR__)))->get('kutrl_active')) {
if (!$s->kutrl_active) {
return null; return null;
} }
if (null === ($kut = kUtRL::quickPlace('wiki'))) { if (null === ($kut = kUtRL::quickPlace('wiki'))) {

View file

@ -24,7 +24,7 @@ class bilbolinksKutrlService extends kutrlService
protected function init() protected function init()
{ {
$base = (string) $this->settings->kutrl_srv_bilbolinks_base; $base = (string) $this->settings->get('kutrl_srv_bilbolinks_base');
if (!empty($base) && substr($base, -1, 1) != '/') { if (!empty($base) && substr($base, -1, 1) != '/') {
$base .= '/'; $base .= '/';
} }
@ -50,7 +50,7 @@ class bilbolinksKutrlService extends kutrlService
echo echo
'<p><label class="classic">' . '<p><label class="classic">' .
__('Url of the service:') . '<br />' . __('Url of the service:') . '<br />' .
form::field(['kutrl_srv_bilbolinks_base'], 50, 255, $this->settings->kutrl_srv_bilbolinks_base) . form::field(['kutrl_srv_bilbolinks_base'], 50, 255, $this->settings->get('kutrl_srv_bilbolinks_base')) .
'</label></p>' . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
__('This is the root URL of the "bilbolinks" service you want to use. Ex: "http://tux-pla.net/".') . __('This is the root URL of the "bilbolinks" service you want to use. Ex: "http://tux-pla.net/".') .

View file

@ -17,13 +17,13 @@ if (!defined('DC_RC_PATH')) {
class bitlyKutrlService extends kutrlService class bitlyKutrlService extends kutrlService
{ {
protected $config = [ protected $config = [
'id' => 'bitly', 'id' => 'bitly',
'name' => 'bit.ly', 'name' => 'bit.ly',
'home' => 'https://bit.ly', 'home' => 'https://bit.ly',
'url_api' => 'https://api-ssl.bitly.com/v4/', 'url_api' => 'https://api-ssl.bitly.com/v4/',
'url_base' => 'https://bit.ly/', 'url_base' => 'https://bit.ly/',
'url_min_len' => 25, 'url_min_len' => 25,
'allow_protocols' => ['http://', 'https://'], 'allow_protocols' => ['http://', 'https://'],
]; ];

View file

@ -23,7 +23,7 @@ class customKutrlService extends kutrlService
protected function init() protected function init()
{ {
$config = unserialize(base64_decode((string) $this->settings->kutrl_srv_custom)); $config = unserialize(base64_decode((string) $this->settings->get('kutrl_srv_custom')));
if (!is_array($config)) { if (!is_array($config)) {
$config = []; $config = [];
} }
@ -55,7 +55,7 @@ class customKutrlService extends kutrlService
'url_param' => '', 'url_param' => '',
'url_encode' => true, 'url_encode' => true,
]; ];
$config = unserialize(base64_decode((string) $this->settings->kutrl_srv_custom)); $config = unserialize(base64_decode((string) $this->settings->get('kutrl_srv_custom')));
if (!is_array($config)) { if (!is_array($config)) {
$config = []; $config = [];
} }

View file

@ -24,16 +24,16 @@ class defaultKutrlService extends kutrlService
protected function init() protected function init()
{ {
$this->config = [ $this->config = [
'id' => 'default', 'id' => 'default',
'name' => 'Default', 'name' => 'Default',
'home' => '', 'home' => '',
'url_api' => SHORTEN_SERVICE_API, 'url_api' => SHORTEN_SERVICE_API,
'url_base' => SHORTEN_SERVICE_BASE, 'url_base' => SHORTEN_SERVICE_BASE,
'url_min_len' => strlen(SHORTEN_SERVICE_BASE) + 2, 'url_min_len' => strlen(SHORTEN_SERVICE_BASE) + 2,
'url_param' => SHORTEN_SERVICE_PARAM, 'url_param' => SHORTEN_SERVICE_PARAM,
'url_encode' => SHORTEN_SERVICE_ENCODE, 'url_encode' => SHORTEN_SERVICE_ENCODE,
]; ];
} }

View file

@ -17,9 +17,9 @@ if (!defined('DC_RC_PATH')) {
class isgdKutrlService extends kutrlService class isgdKutrlService extends kutrlService
{ {
protected $config = [ protected $config = [
'id' => 'isgd', 'id' => 'isgd',
'name' => 'is.gd', 'name' => 'is.gd',
'home' => 'http://is.gd/', 'home' => 'http://is.gd/',
'url_api' => 'http://is.gd/api.php', 'url_api' => 'http://is.gd/api.php',
'url_base' => 'http://is.gd/', 'url_base' => 'http://is.gd/',

View file

@ -17,16 +17,16 @@ if (!defined('DC_RC_PATH')) {
class localKutrlService extends kutrlService class localKutrlService extends kutrlService
{ {
protected $config = [ protected $config = [
'id' => 'local', 'id' => 'local',
'name' => 'kUtRL', 'name' => 'kUtRL',
'home' => 'https://github.com/JcDenis/kUtRL', 'home' => 'https://github.com/JcDenis/kUtRL',
'allow_custom_hash' => true, 'allow_custom_hash' => true,
]; ];
protected function init() protected function init()
{ {
$protocols = (string) $this->settings->kutrl_srv_local_protocols; $protocols = (string) $this->settings->get('kutrl_srv_local_protocols');
$this->config['allow_protocols'] = empty($protocols) ? [] : explode(',', $protocols); $this->config['allow_protocols'] = empty($protocols) ? [] : explode(',', $protocols);
$this->config['url_base'] = dcCore::app()->blog->url . dcCore::app()->url->getBase('kutrl') . '/'; $this->config['url_base'] = dcCore::app()->blog->url . dcCore::app()->url->getBase('kutrl') . '/';
@ -49,7 +49,7 @@ class localKutrlService extends kutrlService
'<p><strong>' . __('Settings:') . '</strong></p>' . '<p><strong>' . __('Settings:') . '</strong></p>' .
'<p><label class="classic">' . '<p><label class="classic">' .
__('Allowed protocols:') . '<br />' . __('Allowed protocols:') . '<br />' .
form::field(['kutrl_srv_local_protocols'], 50, 255, $this->settings->kutrl_srv_local_protocols) . form::field(['kutrl_srv_local_protocols'], 50, 255, $this->settings->get('kutrl_srv_local_protocols')) .
'</label></p>' . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
@ -57,17 +57,17 @@ class localKutrlService extends kutrlService
'</p>' . '</p>' .
'<p><label class="classic">' . '<p><label class="classic">' .
form::checkbox(['kutrl_srv_local_public'], '1', $this->settings->kutrl_srv_local_public) . ' ' . form::checkbox(['kutrl_srv_local_public'], '1', $this->settings->get('kutrl_srv_local_public')) . ' ' .
__('Enable public page for visitors to shorten links') . __('Enable public page for visitors to shorten links') .
'</label></p>' . '</label></p>' .
'<p class="area" id="style-area"><label for="_style">' . __('CSS:') . '</label>' . '<p class="area" id="style-area"><label for="_style">' . __('CSS:') . '</label>' .
form::textarea('kutrl_srv_local_css', 50, 3, html::escapeHTML($this->settings->kutrl_srv_local_css), '', '2') . form::textarea('kutrl_srv_local_css', 50, 3, html::escapeHTML($this->settings->get('kutrl_srv_local_css')), '', '2') .
'</p>' . '</p>' .
'<p class="form-note">' . __('You can add here special cascading style sheet. Body of page has class "dc-kutrl" and widgets have class "shortenkutrlwidget" and "rankkutrlwidget".') . '</p>' . '<p class="form-note">' . __('You can add here special cascading style sheet. Body of page has class "dc-kutrl" and widgets have class "shortenkutrlwidget" and "rankkutrlwidget".') . '</p>' .
'<p><label class="classic">' . '<p><label class="classic">' .
form::checkbox(['kutrl_srv_local_404_active'], '1', $this->settings->kutrl_srv_local_404_active) . ' ' . form::checkbox(['kutrl_srv_local_404_active'], '1', $this->settings->get('kutrl_srv_local_404_active')) . ' ' .
__('Enable special 404 error public page for unknow urls') . __('Enable special 404 error public page for unknow urls') .
'</label></p>' . '</label></p>' .
'<p class="form-note">' . __('If this is not activated, the default 404 page of the theme will be display.') . '</p>' . '<p class="form-note">' . __('If this is not activated, the default 404 page of the theme will be display.') . '</p>' .

View file

@ -17,9 +17,9 @@ if (!defined('DC_RC_PATH')) {
class shorttoKutrlService extends kutrlService class shorttoKutrlService extends kutrlService
{ {
protected $config = [ protected $config = [
'id' => 'shortto', 'id' => 'shortto',
'name' => 'short.to', 'name' => 'short.to',
'home' => 'http://short.to', 'home' => 'http://short.to',
'url_api' => 'http://short.to/s.txt', 'url_api' => 'http://short.to/s.txt',
'url_base' => 'http://short.to/', 'url_base' => 'http://short.to/',

View file

@ -17,9 +17,9 @@ if (!defined('DC_RC_PATH')) {
class suprKutrlService extends kutrlService class suprKutrlService extends kutrlService
{ {
protected $config = [ protected $config = [
'id' => 'supr', 'id' => 'supr',
'name' => 'su.pr StumbleUpon', 'name' => 'su.pr StumbleUpon',
'home' => 'http://su.pr', 'home' => 'http://su.pr',
'url_api' => 'http://su.pr/api/', 'url_api' => 'http://su.pr/api/',
'url_base' => 'http://su.pr/', 'url_base' => 'http://su.pr/',
@ -35,8 +35,8 @@ class suprKutrlService extends kutrlService
protected function init() protected function init()
{ {
$this->args['login'] = $this->settings->kutrl_srv_supr_login; $this->args['login'] = $this->settings->get('kutrl_srv_supr_login');
$this->args['apiKey'] = $this->settings->kutrl_srv_supr_apikey; $this->args['apiKey'] = $this->settings->get('kutrl_srv_supr_apikey');
} }
public function saveSettings() public function saveSettings()
@ -49,13 +49,13 @@ class suprKutrlService extends kutrlService
{ {
echo echo
'<p><label class="classic">' . __('Login:') . '<br />' . '<p><label class="classic">' . __('Login:') . '<br />' .
form::field(['kutrl_srv_supr_login'], 50, 255, $this->settings->kutrl_srv_supr_login) . form::field(['kutrl_srv_supr_login'], 50, 255, $this->settings->get('kutrl_srv_supr_login')) .
'</label></p>' . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
sprintf(__('This is your login to sign up to %s'), $this->config['name']) . sprintf(__('This is your login to sign up to %s'), $this->config['name']) .
'</p>' . '</p>' .
'<p><label class="classic">' . __('API Key:') . '<br />' . '<p><label class="classic">' . __('API Key:') . '<br />' .
form::field(['kutrl_srv_supr_apikey'], 50, 255, $this->settings->kutrl_srv_supr_apikey) . form::field(['kutrl_srv_supr_apikey'], 50, 255, $this->settings->get('kutrl_srv_supr_apikey')) .
'</label></p>' . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
sprintf(__('This is your personnal %s API key. You can find it on your account page.'), $this->config['name']) . sprintf(__('This is your personnal %s API key. You can find it on your account page.'), $this->config['name']) .

View file

@ -17,9 +17,9 @@ if (!defined('DC_RC_PATH')) {
class trimKutrlService extends kutrlService class trimKutrlService extends kutrlService
{ {
protected $config = [ protected $config = [
'id' => 'trim', 'id' => 'trim',
'name' => 'tr.im', 'name' => 'tr.im',
'home' => 'http://tr.im', 'home' => 'http://tr.im',
'url_api' => 'http://api.tr.im/v1/', 'url_api' => 'http://api.tr.im/v1/',
'url_base' => 'http://tr.im/', 'url_base' => 'http://tr.im/',
@ -35,10 +35,10 @@ class trimKutrlService extends kutrlService
protected function init() protected function init()
{ {
$this->args['username'] = $this->settings->kutrl_srv_trim_username; $this->args['username'] = $this->settings->get('kutrl_srv_trim_username');
$this->args['password'] = $this->settings->kutrl_srv_trim_password; $this->args['password'] = $this->settings->get('kutrl_srv_trim_password');
$this->api_rate_time = (int) $this->settings->kutrl_srv_trim_apiratetime; $this->api_rate_time = (int) $this->settings->get('kutrl_srv_trim_apiratetime');
} }
public function saveSettings() public function saveSettings()
@ -51,13 +51,13 @@ class trimKutrlService extends kutrlService
{ {
echo echo
'<p><label class="classic">' . __('Login:') . '<br />' . '<p><label class="classic">' . __('Login:') . '<br />' .
form::field(['kutrl_srv_trim_username'], 50, 255, $this->settings->kutrl_srv_trim_username) . form::field(['kutrl_srv_trim_username'], 50, 255, $this->settings->get('kutrl_srv_trim_username')) .
'</label></p>' . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
__('This is your login to sign up to tr.im.') . __('This is your login to sign up to tr.im.') .
'</p>' . '</p>' .
'<p><label class="classic">' . __('Password:') . '<br />' . '<p><label class="classic">' . __('Password:') . '<br />' .
form::field(['kutrl_srv_trim_password'], 50, 255, $this->settings->kutrl_srv_trim_password) . form::field(['kutrl_srv_trim_password'], 50, 255, $this->settings->get('kutrl_srv_trim_password')) .
'</label></p>' . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
__('This is your password to sign up to tr.im.') . __('This is your password to sign up to tr.im.') .

View file

@ -31,10 +31,10 @@ class yourlsKutrlService extends kutrlService
protected function init() protected function init()
{ {
$this->args['username'] = $this->settings->kutrl_srv_yourls_username; $this->args['username'] = $this->settings->get('kutrl_srv_yourls_username');
$this->args['password'] = $this->settings->kutrl_srv_yourls_password; $this->args['password'] = $this->settings->get('kutrl_srv_yourls_password');
$base = (string) $this->settings->kutrl_srv_yourls_base; $base = (string) $this->settings->get('kutrl_srv_yourls_base');
//if (!empty($base) && substr($base,-1,1) != '/') $base .= '/'; //if (!empty($base) && substr($base,-1,1) != '/') $base .= '/';
$this->config['url_api'] = $base; $this->config['url_api'] = $base;
@ -54,19 +54,19 @@ class yourlsKutrlService extends kutrlService
echo echo
'<p><label class="classic">' . '<p><label class="classic">' .
__('Url of the service:') . '<br />' . __('Url of the service:') . '<br />' .
form::field(['kutrl_srv_yourls_base'], 50, 255, $this->settings->kutrl_srv_yourls_base) . form::field(['kutrl_srv_yourls_base'], 50, 255, $this->settings->get('kutrl_srv_yourls_base')) .
'</label></p>' . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
__('This is the URL of the YOURLS service you want to use. Ex: "http://www.smaller.org/api.php".') . __('This is the URL of the YOURLS service you want to use. Ex: "http://www.smaller.org/api.php".') .
'</p>' . '</p>' .
'<p><label class="classic">' . __('Login:') . '<br />' . '<p><label class="classic">' . __('Login:') . '<br />' .
form::field(['kutrl_srv_yourls_username'], 50, 255, $this->settings->kutrl_srv_yourls_username) . form::field(['kutrl_srv_yourls_username'], 50, 255, $this->settings->get('kutrl_srv_yourls_username')) .
'</label></p>' . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
__('This is your user name to sign up to this YOURLS service.') . __('This is your user name to sign up to this YOURLS service.') .
'</p>' . '</p>' .
'<p><label class="classic">' . __('Password:') . '<br />' . '<p><label class="classic">' . __('Password:') . '<br />' .
form::field(['kutrl_srv_yourls_password'], 50, 255, $this->settings->kutrl_srv_yourls_password) . form::field(['kutrl_srv_yourls_password'], 50, 255, $this->settings->get('kutrl_srv_yourls_password')) .
'</label></p>' . '</label></p>' .
'<p class="form-note">' . '<p class="form-note">' .
__('This is your password to sign up to this YOURLS service.') . __('This is your password to sign up to this YOURLS service.') .

View file

@ -175,7 +175,7 @@ if ($part == 'link') {
]) . ]) .
dcPage::notices(); dcPage::notices();
if (null === $kut) { if (!isset($kut) || null === $kut) {
echo '<p>' . __('You must set an admin service.') . '</p>'; echo '<p>' . __('You must set an admin service.') . '</p>';
} else { } else {
echo ' echo '