diff --git a/_admin.php b/_admin.php index 43eb29e..40e1404 100644 --- a/_admin.php +++ b/_admin.php @@ -1,16 +1,15 @@ register( - 'kUtRL', + 'kUtRL', [ 'title' => __('Links shortener'), 'url' => $core->adminurl->get('admin.plugin.kUtRL'), @@ -118,14 +117,13 @@ class adminKutrl if ($post) { $post_url = $post->getURL(); - $rs = $kut->isKnowUrl($post_url); + $rs = $kut->isKnowUrl($post_url); } else { $post_url = ''; - $rs = false; + $rs = false; } - $ret = - '
' . + $ret .= '' . form::checkbox('kutrl_create', 1, $chk, '', 3) . ' ' . __('Create short link') . ''; if ($kut->allow_custom_hash) { - $ret .= - '' . + $ret .= '' . '' . __('Custom short link:') . ' ' . form::field('kutrl_create_custom', 32, 32, '', 3) . ''; @@ -153,12 +149,11 @@ class adminKutrl } elseif ($count == 1) { $title = __('followed one time'); } else { - $title = sprintf(__('followed %s times'),$count); + $title = sprintf(__('followed %s times'), $count); } $href = $kut->url_base . $rs->hash; - $ret .= - '' . + $ret .= '' . form::checkbox('kutrl_delete', 1, !empty($_POST['kutrl_delete']), '', 3) . ' ' . __('Delete short link') . '' . '' . $href . ''; @@ -194,7 +189,7 @@ class adminKutrl if ($rs->isEmpty()) { return null; } - $title = html::escapeHTML($rs->post_title); + $title = html::escapeHTML($rs->post_title); $new_post_url = $rs->getURL(); # Delete @@ -208,12 +203,12 @@ class adminKutrl $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; # ex: Send new url to messengers if (!empty($rs)) { - $core->callBehavior('adminAfterKutrlCreate' ,$core, $rs, $title); + $core->callBehavior('adminAfterKutrlCreate', $core, $rs, $title); } } } @@ -239,7 +234,7 @@ class adminKutrl $custom = !empty($_POST['kutrl_create_custom']) && $kut->allow_custom_hash ? $_POST['kutrl_create_custom'] : null; - $rs = $kut->hash($rs->getURL(), $custom); + $rs = $kut->hash($rs->getURL(), $custom); $url = $kut->url_base . $rs->hash; # ex: Send new url to messengers @@ -273,8 +268,8 @@ class adminKutrl global $core; $s = $core->blog->settings->kUtRL; - if (!$s->kutrl_active - || !$core->auth->check('admin',$core->blog->id)) { + if (!$s->kutrl_active + || !$core->auth->check('admin', $core->blog->id)) { return null; } @@ -284,7 +279,7 @@ class adminKutrl public static function adminPostsActions(dcCore $core, $posts, $action, $redir) { - if ($action != 'kutrl_create' + if ($action != 'kutrl_create' && $action != 'kutrl_delete') { return null; } @@ -316,7 +311,8 @@ class backupKutrl { public static function exportSingle($core, $exp, $blog_id) { - $exp->export('kutrl', + $exp->export( + 'kutrl', 'SELECT kut_id, blog_id, kut_service, kut_type, ' . 'kut_hash, kut_url, kut_dt, kut_password, kut_counter ' . 'FROM ' . $core->prefix . 'kutrl ' . @@ -332,10 +328,10 @@ class backupKutrl public static function importInit($bk, $core) { $bk->cur_kutrl = $core->con->openCursor($core->prefix . 'kutrl'); - $bk->kutrl = new kutrlLog($core); + $bk->kutrl = new kutrlLog($core); } - public static function importSingle($line,$bk,$core) + public static function importSingle($line, $bk, $core) { if ($line->__name == 'kutrl') { # Do nothing if str/type exists ! @@ -349,16 +345,16 @@ class backupKutrl { if ($line->__name == 'kutrl') { $bk->cur_kutrl->clean(); - $bk->cur_kutrl->kut_id = (integer) $line->kut_id; - $bk->cur_kutrl->blog_id = (string) $line->blog_id; - $bk->cur_kutrl->kut_service = (string) $line->kut_service; - $bk->cur_kutrl->kut_type = (string) $line->kut_type; - $bk->cur_kutrl->kut_hash = (string) $line->kut_hash; - $bk->cur_kutrl->kut_url = (string) $line->kut_url; - $bk->cur_kutrl->kut_dt = (string) $line->miniurl_dt; - $bk->cur_kutrl->kut_counter = (integer) $line->kut_counter; + $bk->cur_kutrl->kut_id = (int) $line->kut_id; + $bk->cur_kutrl->blog_id = (string) $line->blog_id; + $bk->cur_kutrl->kut_service = (string) $line->kut_service; + $bk->cur_kutrl->kut_type = (string) $line->kut_type; + $bk->cur_kutrl->kut_hash = (string) $line->kut_hash; + $bk->cur_kutrl->kut_url = (string) $line->kut_url; + $bk->cur_kutrl->kut_dt = (string) $line->miniurl_dt; + $bk->cur_kutrl->kut_counter = (int) $line->kut_counter; $bk->cur_kutrl->kut_password = (string) $line->kut_password; $bk->cur_kutrl->insert(); } } -} \ No newline at end of file +} diff --git a/_config.php b/_config.php index e1cca75..6c7d405 100644 --- a/_config.php +++ b/_config.php @@ -1,16 +1,15 @@ '; $img_red = ''; $services_combo = []; -foreach(kutrl::getServices($core) as $service_id => $service) { - $o = new $service($core); +foreach (kutrl::getServices($core) as $service_id => $service) { + $o = new $service($core); $services_combo[__($o->name)] = $o->id; } $ext_services_combo = array_merge([__('Disabled') => ''], $services_combo); $lst_services_combo = array_merge(['-' => ''], $services_combo); -$s_active = (boolean) $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 = (boolean) $s->kutrl_allow_external_url; -$s_tpl_passive = (boolean) $s->kutrl_tpl_passive; -$s_tpl_active = (boolean) $s->kutrl_tpl_active; +$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_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); @@ -67,7 +66,7 @@ if (!empty($_POST['save'])) { $s->put('kutrl_admin_entry_default', $s_admin_entry_default); # services - foreach(kutrl::getServices($core) as $service_id => $service) { + foreach (kutrl::getServices($core) as $service_id => $service) { $o = new $service($core); $o->saveSettings(); } @@ -79,7 +78,7 @@ if (!empty($_POST['save'])) { ); $core->adminurl->redirect( - 'admin.plugins', + 'admin.plugins', ['module' => 'kUtRL', 'conf' => 1, 'chk' => 1, 'redir' => $list->getRedir()] ); } catch (Exception $e) { @@ -88,45 +87,45 @@ if (!empty($_POST['save'])) { } echo ' -' . __('Settings') . ' +' . __('Settings') . ' -' . __('Activation') . ' -' . -form::checkbox(['s_active'], '1', $s_active) . +' . __('Activation') . ' +' . +form::checkbox(['s_active'], '1', $s_active) . __('Enable plugin') . ' -' . __('Behaviors') . ' -' . -form::checkbox(['s_allow_external_url'], '1', $s_allow_external_url) . +' . __('Behaviors') . ' +' . +form::checkbox(['s_allow_external_url'], '1', $s_allow_external_url) . __('Allow short link for external URL') . ' ' . __('Not only link started with this blog URL could be shortened.') . ' -' . -form::checkbox(['s_tpl_passive'], '1', $s_tpl_passive) . +' . +form::checkbox(['s_tpl_passive'], '1', $s_tpl_passive) . __('Passive mode') . ' ' . __('If this extension is disabled and the passive mode is enabled, "kutrl" tags (like EntryKurl) will display long urls instead of nothing on templates.') . ' -' . -form::checkbox(['s_tpl_active'], '1', $s_tpl_active) . +' . +form::checkbox(['s_tpl_active'], '1', $s_tpl_active) . __('Active mode') . ' -' . __('If the active mode is enabled, all know default template tags (like EntryURL) will display short urls instead of long ones 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.') . ' -' . -form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . +' . +form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . __('Create short link for new entries') . ' ' . __('This can be changed on page of creation/edition of an entry.') . ' -' . __('Default services') . ' +' . __('Default services') . ' '; if (!empty($_REQUEST['chk'])) { if (null !== ($o = kutrl::quickPlace($s_admin_service))) { echo $o->testService() ? $img_green : $img_red; } } -echo ' ' . __('Administration:') . '' . +echo ' ' . __('Administration:') . '' . form::combo(['s_admin_service'], $services_combo, $s_admin_service) . ' ' . __('Service to use in this admin page and on edit page of an entry.') . ' @@ -136,7 +135,7 @@ if (!empty($_REQUEST['chk'])) { echo $o->testService() ? $img_green : $img_red; } } -echo ' ' . __('Extensions:') . '' . +echo ' ' . __('Extensions:') . '' . form::combo(['s_plugin_service'], $services_combo, $s_plugin_service) . ' ' . __('Service to use on third part plugins.') . ' @@ -146,7 +145,7 @@ if (!empty($_REQUEST['chk'])) { echo $o->testService() ? $img_green : $img_red; } } -echo ' ' . __('Templates:') . '' . +echo ' ' . __('Templates:') . '' . form::combo(['s_tpl_service'], $ext_services_combo, $s_tpl_service) . ' ' . __('Shorten links automatically when using template value like "EntryKutrl".') . ' @@ -156,7 +155,7 @@ if (!empty($_REQUEST['chk'])) { echo $o->testService() ? $img_green : $img_red; } } -echo ' ' . __('Contents:') . '' . +echo ' ' . __('Contents:') . '' . form::combo(['s_wiki_service'], $ext_services_combo, $s_wiki_service) . ' ' . __('Shorten links automatically found in contents using wiki synthax.') . ' @@ -164,17 +163,18 @@ form::combo(['s_wiki_service'], $ext_services_combo, $s_wiki_service) . ' -' .__('Services') . ' +' . __('Services') . ' ' . __('List of services you can use to shorten links with pkugin kUtRL.') . ' '; -foreach(kutrl::getServices($core) as $service_id => $service) { +foreach (kutrl::getServices($core) as $service_id => $service) { $o = new $service($core); 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); @@ -192,4 +192,4 @@ foreach(kutrl::getServices($core) as $service_id => $service) { echo ''; } -echo''; \ No newline at end of file +echo''; diff --git a/_define.php b/_define.php index 03e08b8..f6d04c5 100644 --- a/_define.php +++ b/_define.php @@ -1,16 +1,15 @@ registerModule( 'details' => 'http://plugins.dotaddict.org/dc2/details/kUtRL', 'repository' => 'https://raw.githubusercontent.com/JcDenis/kUtRL/master/dcstore.xml' ] -); \ No newline at end of file +); diff --git a/_install.php b/_install.php index eea6e86..e4304b1 100644 --- a/_install.php +++ b/_install.php @@ -1,16 +1,15 @@ index('idx_kut_service', 'btree', 'kut_service') ->index('idx_kut_type', 'btree', 'kut_type'); - $ti = new dbStruct($core->con, $core->prefix); + $ti = new dbStruct($core->con, $core->prefix); $changes = $ti->synchronize($t); # Settings @@ -61,9 +60,8 @@ try { $s->put('kutrl_tpl_active', false, 'boolean', 'Return short url on dotclear tags if kutrl is active', false, true); $s->put('kutrl_admin_entry_default', true, 'boolean', 'Create short link on new entry by default', false, true); # Settings for "local" service - $local_css = - ".shortenkutrlwidget input { border: 1px solid #CCCCCC; }\n" . - ".dc-kutrl input { border: 1px solid #CCCCCC; margin: 10px; }"; + $local_css = ".shortenkutrlwidget input { border: 1px solid #CCCCCC; }\n" . + '.dc-kutrl input { border: 1px solid #CCCCCC; margin: 10px; }'; $s->put('kutrl_srv_local_protocols', 'http:,https:,ftp:,ftps:,irc:', 'string', 'Allowed kutrl local service protocols', false, true); $s->put('kutrl_srv_local_public', false, 'boolean', 'Enabled local service public page', false, true); $s->put('kutrl_srv_local_css', $local_css, 'string', 'Special CSS for kutrl local service', false, true); @@ -82,9 +80,10 @@ try { if ($core->plugins->moduleExists('dcMiniUrl')) { require_once dirname(__FILE__) . '/inc/patch.dcminiurl.php'; } + return true; } catch (Exception $e) { $core->error->add($e->getMessage()); } -return false; \ No newline at end of file +return false; diff --git a/_prepend.php b/_prepend.php index 9964869..a728060 100644 --- a/_prepend.php +++ b/_prepend.php @@ -1,16 +1,15 @@ addBehavior('kutrlService', function() { return ["default","defaultKutrlService"]; } ); +$core->addBehavior('kutrlService', function () { return ['default','defaultKutrlService']; }); if (!defined('SHORTEN_SERVICE_DISABLE_CUSTOM')) { $__autoload['customKutrlService'] = $d . 'services/class.custom.service.php'; - $core->addBehavior('kutrlService', function() { return ["custom","customKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['custom','customKutrlService']; }); } if (!defined('SHORTEN_SERVICE_DISABLE_LOCAL')) { $__autoload['localKutrlService'] = $d . 'services/class.local.service.php'; - $core->addBehavior('kutrlService', function() { return ["local","localKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['local','localKutrlService']; }); } if (!defined('SHORTEN_SERVICE_DISABLE_BILBOLINKS')) { $__autoload['bilbolinksKutrlService'] = $d . 'services/class.bilbolinks.service.php'; - $core->addBehavior('kutrlService', function() { return ["bilbolinks","bilbolinksKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['bilbolinks','bilbolinksKutrlService']; }); } if (!defined('SHORTEN_SERVICE_DISABLE_BITLY')) { $__autoload['bitlyKutrlService'] = $d . 'services/class.bitly.service.php'; - $core->addBehavior('kutrlService', function() { return ["bitly","bitlyKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['bitly','bitlyKutrlService']; }); } //if (!defined('SHORTEN_SERVICE_DISABLE_GOOGL')) { // $__autoload['googlKutrlService'] = $d . 'services/class.googl.service.php'; @@ -64,7 +63,7 @@ if (!defined('SHORTEN_SERVICE_DISABLE_BITLY')) { //} if (!defined('SHORTEN_SERVICE_DISABLE_ISGD')) { $__autoload['isgdKutrlService'] = $d . 'services/class.isgd.service.php'; - $core->addBehavior('kutrlService', function() { return ["isgd","isgdKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['isgd','isgdKutrlService']; }); } //if (!defined('SHORTEN_SERVICE_DISABLE_SHORTTO')) { // $__autoload['shorttoKutrlService'] = $d . 'services/class.shortto.service.php'; @@ -76,7 +75,7 @@ if (!defined('SHORTEN_SERVICE_DISABLE_ISGD')) { //} if (!defined('SHORTEN_SERVICE_DISABLE_YOURLS')) { $__autoload['yourlsKutrlService'] = $d . 'services/class.yourls.service.php'; - $core->addBehavior('kutrlService', function() { return ["yourls","yourlsKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['yourls','yourlsKutrlService']; }); } //if (!defined('SHORTEN_SERVICE_DISABLE_SUPR')) { // $__autoload['suprKutrlService'] = $d . 'services/class.supr.service.php'; @@ -85,9 +84,9 @@ if (!defined('SHORTEN_SERVICE_DISABLE_YOURLS')) { # Shorten url passed through wiki functions $__autoload['kutrlWiki'] = $d . 'lib.wiki.kutrl.php'; -$core->addBehavior('coreInitWikiPost',['kutrlWiki','coreInitWiki']); -$core->addBehavior('coreInitWikiComment',['kutrlWiki','coreInitWiki']); -$core->addBehavior('coreInitWikiSimpleComment',['kutrlWiki','coreInitWiki']); +$core->addBehavior('coreInitWikiPost', ['kutrlWiki','coreInitWiki']); +$core->addBehavior('coreInitWikiComment', ['kutrlWiki','coreInitWiki']); +$core->addBehavior('coreInitWikiSimpleComment', ['kutrlWiki','coreInitWiki']); # Public page $core->url->register('kutrl', 'go', '^go(/(.*?)|)$', ['urlKutrl', 'redirectUrl']); @@ -95,4 +94,4 @@ $core->url->register('kutrl', 'go', '^go(/(.*?)|)$', ['urlKutrl', 'redirectUrl'] # Add kUtRL events on plugin activityReport if (defined('ACTIVITY_REPORT')) { require_once $d . 'lib.kutrl.activityreport.php'; -} \ No newline at end of file +} diff --git a/_public.php b/_public.php index 2608f12..69db51f 100644 --- a/_public.php +++ b/_public.php @@ -1,16 +1,15 @@ kutrl_msg = ''; - $_ctx->kutrl_hmf = hmfKutrl::create(); + $args = $m[3] ?? ''; + $_ctx->kutrl_msg = ''; + $_ctx->kutrl_hmf = hmfKutrl::create(); $_ctx->kutrl_hmfp = hmfKutrl::protect($_ctx->kutrl_hmf); $kut = new localKutrlService($core); @@ -81,7 +80,7 @@ class urlKutrl extends dcUrlHandlers # find suffix on redirect url $suffix = ''; if (preg_match('@^([^?/#]+)(.*?)$@', $args, $more)) { - $args = $more[1]; + $args = $more[1]; $suffix = $more[2]; } # No arg, go to kurtl page @@ -131,50 +130,50 @@ class urlKutrl extends dcUrlHandlers # Validation form $url = !empty($_POST['longurl']) ? trim($core->con->escape($_POST['longurl'])) : ''; if (!empty($url)) { - $hmf = !empty($_POST['hmf']) ? $_POST['hmf'] : '!'; + $hmf = !empty($_POST['hmf']) ? $_POST['hmf'] : '!'; $hmfu = !empty($_POST['hmfp']) ? hmfKutrl::unprotect($_POST['hmfp']) : '?'; $err = false; if (!$err) { if ($hmf != $hmfu) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('Failed to verify protected field.'); } } if (!$err) { if (!$kut->testService()) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('Service is not well configured.'); } } if (!$err) { if (!$kut->isValidUrl($url)) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('This string is not a valid URL.'); } } if (!$err) { if (!$kut->isLongerUrl($url)) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('This link is too short.'); } } if (!$err) { if (!$kut->isProtocolUrl($url)) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('This type of link is not allowed.'); } } if (!$err) { if (!$kut->allow_external_url && !$kut->isBlogUrl($url)) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('Short links are limited to this blog URL.'); } } if (!$err) { if ($kut->isServiceUrl($url)) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('This link is already a short link.'); } } @@ -182,7 +181,7 @@ class urlKutrl extends dcUrlHandlers if (false !== ($rs = $kut->isKnowUrl($url))) { $err = true; - $url = $rs->url; + $url = $rs->url; $new_url = $kut->url_base . $rs->hash; $_ctx->kutrl_msg = sprintf( @@ -194,10 +193,10 @@ class urlKutrl extends dcUrlHandlers } if (!$err) { if (false === ($rs = $kut->hash($url))) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('Failed to create short link.'); } else { - $url = $rs->url; + $url = $rs->url; $new_url = $kut->url_base . $rs->hash; $_ctx->kutrl_msg = sprintf( @@ -232,13 +231,13 @@ class urlKutrl extends dcUrlHandlers } $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__) . '/default-templates'); - $_ctx =& $GLOBALS['_ctx']; + $_ctx = & $GLOBALS['_ctx']; $core = $GLOBALS['core']; header('Content-Type: text/html; charset=UTF-8'); http::head(404, 'Not Found'); - $core->url->type = '404'; - $_ctx->current_tpl = 'kutrl404.html'; + $core->url->type = '404'; + $_ctx->current_tpl = 'kutrl404.html'; $_ctx->content_type = 'text/html'; echo $core->tpl->getData($_ctx->current_tpl); @@ -266,18 +265,20 @@ class pubKutrl # Disable URL shoretning on filtered tag public static function templateBeforeValue($core, $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 ''; } + return null; } # Re unable it after tag public static function templateAfterValue($core, $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 ''; } + return null; } @@ -285,13 +286,13 @@ class pubKutrl public static function publicBeforeContentFilter($core, $tag, $args) { # Unknow tag - if (!in_array($tag,pubKutrl::$know_tags)) { + if (!in_array($tag, pubKutrl::$know_tags)) { return null; } # URL shortening is disabled by tag attribute if (empty($GLOBALS['disable_kutrl'])) { # kUtRL is not activated - if (!$core->blog->settings->kUtRL->kutrl_active + if (!$core->blog->settings->kUtRL->kutrl_active || !$core->blog->settings->kUtRL->kutrl_tpl_active ) { return null; @@ -324,7 +325,7 @@ class pubKutrl $s = $core->blog->settings->kUtRL; # Passive : all kutrl tag return long url - $_ctx->kutrl_passive = (boolean) $s->kutrl_tpl_passive; + $_ctx->kutrl_passive = (bool) $s->kutrl_tpl_passive; if (!$s->kutrl_active || !$s->kutrl_tpl_service) { return null; @@ -339,7 +340,7 @@ class pubKutrl { $css = $core->blog->settings->kUtRL->kutrl_srv_local_css; if ($css) { - echo + echo "\n \n" . "
' . form::checkbox('kutrl_create', 1, $chk, '', 3) . ' ' . __('Create short link') . '
' . + $ret .= '
' . '' . __('Custom short link:') . ' ' . form::field('kutrl_create_custom', 32, 32, '', 3) . '
' . + $ret .= '' . form::checkbox('kutrl_delete', 1, !empty($_POST['kutrl_delete']), '', 3) . ' ' . __('Delete short link') . '' . '' . $href . ''; @@ -194,7 +189,7 @@ class adminKutrl if ($rs->isEmpty()) { return null; } - $title = html::escapeHTML($rs->post_title); + $title = html::escapeHTML($rs->post_title); $new_post_url = $rs->getURL(); # Delete @@ -208,12 +203,12 @@ class adminKutrl $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; # ex: Send new url to messengers if (!empty($rs)) { - $core->callBehavior('adminAfterKutrlCreate' ,$core, $rs, $title); + $core->callBehavior('adminAfterKutrlCreate', $core, $rs, $title); } } } @@ -239,7 +234,7 @@ class adminKutrl $custom = !empty($_POST['kutrl_create_custom']) && $kut->allow_custom_hash ? $_POST['kutrl_create_custom'] : null; - $rs = $kut->hash($rs->getURL(), $custom); + $rs = $kut->hash($rs->getURL(), $custom); $url = $kut->url_base . $rs->hash; # ex: Send new url to messengers @@ -273,8 +268,8 @@ class adminKutrl global $core; $s = $core->blog->settings->kUtRL; - if (!$s->kutrl_active - || !$core->auth->check('admin',$core->blog->id)) { + if (!$s->kutrl_active + || !$core->auth->check('admin', $core->blog->id)) { return null; } @@ -284,7 +279,7 @@ class adminKutrl public static function adminPostsActions(dcCore $core, $posts, $action, $redir) { - if ($action != 'kutrl_create' + if ($action != 'kutrl_create' && $action != 'kutrl_delete') { return null; } @@ -316,7 +311,8 @@ class backupKutrl { public static function exportSingle($core, $exp, $blog_id) { - $exp->export('kutrl', + $exp->export( + 'kutrl', 'SELECT kut_id, blog_id, kut_service, kut_type, ' . 'kut_hash, kut_url, kut_dt, kut_password, kut_counter ' . 'FROM ' . $core->prefix . 'kutrl ' . @@ -332,10 +328,10 @@ class backupKutrl public static function importInit($bk, $core) { $bk->cur_kutrl = $core->con->openCursor($core->prefix . 'kutrl'); - $bk->kutrl = new kutrlLog($core); + $bk->kutrl = new kutrlLog($core); } - public static function importSingle($line,$bk,$core) + public static function importSingle($line, $bk, $core) { if ($line->__name == 'kutrl') { # Do nothing if str/type exists ! @@ -349,16 +345,16 @@ class backupKutrl { if ($line->__name == 'kutrl') { $bk->cur_kutrl->clean(); - $bk->cur_kutrl->kut_id = (integer) $line->kut_id; - $bk->cur_kutrl->blog_id = (string) $line->blog_id; - $bk->cur_kutrl->kut_service = (string) $line->kut_service; - $bk->cur_kutrl->kut_type = (string) $line->kut_type; - $bk->cur_kutrl->kut_hash = (string) $line->kut_hash; - $bk->cur_kutrl->kut_url = (string) $line->kut_url; - $bk->cur_kutrl->kut_dt = (string) $line->miniurl_dt; - $bk->cur_kutrl->kut_counter = (integer) $line->kut_counter; + $bk->cur_kutrl->kut_id = (int) $line->kut_id; + $bk->cur_kutrl->blog_id = (string) $line->blog_id; + $bk->cur_kutrl->kut_service = (string) $line->kut_service; + $bk->cur_kutrl->kut_type = (string) $line->kut_type; + $bk->cur_kutrl->kut_hash = (string) $line->kut_hash; + $bk->cur_kutrl->kut_url = (string) $line->kut_url; + $bk->cur_kutrl->kut_dt = (string) $line->miniurl_dt; + $bk->cur_kutrl->kut_counter = (int) $line->kut_counter; $bk->cur_kutrl->kut_password = (string) $line->kut_password; $bk->cur_kutrl->insert(); } } -} \ No newline at end of file +} diff --git a/_config.php b/_config.php index e1cca75..6c7d405 100644 --- a/_config.php +++ b/_config.php @@ -1,16 +1,15 @@ '; $img_red = ''; $services_combo = []; -foreach(kutrl::getServices($core) as $service_id => $service) { - $o = new $service($core); +foreach (kutrl::getServices($core) as $service_id => $service) { + $o = new $service($core); $services_combo[__($o->name)] = $o->id; } $ext_services_combo = array_merge([__('Disabled') => ''], $services_combo); $lst_services_combo = array_merge(['-' => ''], $services_combo); -$s_active = (boolean) $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 = (boolean) $s->kutrl_allow_external_url; -$s_tpl_passive = (boolean) $s->kutrl_tpl_passive; -$s_tpl_active = (boolean) $s->kutrl_tpl_active; +$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_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); @@ -67,7 +66,7 @@ if (!empty($_POST['save'])) { $s->put('kutrl_admin_entry_default', $s_admin_entry_default); # services - foreach(kutrl::getServices($core) as $service_id => $service) { + foreach (kutrl::getServices($core) as $service_id => $service) { $o = new $service($core); $o->saveSettings(); } @@ -79,7 +78,7 @@ if (!empty($_POST['save'])) { ); $core->adminurl->redirect( - 'admin.plugins', + 'admin.plugins', ['module' => 'kUtRL', 'conf' => 1, 'chk' => 1, 'redir' => $list->getRedir()] ); } catch (Exception $e) { @@ -88,45 +87,45 @@ if (!empty($_POST['save'])) { } echo ' -' . __('Settings') . ' +' . __('Settings') . ' -' . __('Activation') . ' -' . -form::checkbox(['s_active'], '1', $s_active) . +' . __('Activation') . ' +' . +form::checkbox(['s_active'], '1', $s_active) . __('Enable plugin') . ' -' . __('Behaviors') . ' -' . -form::checkbox(['s_allow_external_url'], '1', $s_allow_external_url) . +' . __('Behaviors') . ' +' . +form::checkbox(['s_allow_external_url'], '1', $s_allow_external_url) . __('Allow short link for external URL') . ' ' . __('Not only link started with this blog URL could be shortened.') . ' -' . -form::checkbox(['s_tpl_passive'], '1', $s_tpl_passive) . +' . +form::checkbox(['s_tpl_passive'], '1', $s_tpl_passive) . __('Passive mode') . ' ' . __('If this extension is disabled and the passive mode is enabled, "kutrl" tags (like EntryKurl) will display long urls instead of nothing on templates.') . ' -' . -form::checkbox(['s_tpl_active'], '1', $s_tpl_active) . +' . +form::checkbox(['s_tpl_active'], '1', $s_tpl_active) . __('Active mode') . ' -' . __('If the active mode is enabled, all know default template tags (like EntryURL) will display short urls instead of long ones 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.') . ' -' . -form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . +' . +form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . __('Create short link for new entries') . ' ' . __('This can be changed on page of creation/edition of an entry.') . ' -' . __('Default services') . ' +' . __('Default services') . ' '; if (!empty($_REQUEST['chk'])) { if (null !== ($o = kutrl::quickPlace($s_admin_service))) { echo $o->testService() ? $img_green : $img_red; } } -echo ' ' . __('Administration:') . '' . +echo ' ' . __('Administration:') . '' . form::combo(['s_admin_service'], $services_combo, $s_admin_service) . ' ' . __('Service to use in this admin page and on edit page of an entry.') . ' @@ -136,7 +135,7 @@ if (!empty($_REQUEST['chk'])) { echo $o->testService() ? $img_green : $img_red; } } -echo ' ' . __('Extensions:') . '' . +echo ' ' . __('Extensions:') . '' . form::combo(['s_plugin_service'], $services_combo, $s_plugin_service) . ' ' . __('Service to use on third part plugins.') . ' @@ -146,7 +145,7 @@ if (!empty($_REQUEST['chk'])) { echo $o->testService() ? $img_green : $img_red; } } -echo ' ' . __('Templates:') . '' . +echo ' ' . __('Templates:') . '' . form::combo(['s_tpl_service'], $ext_services_combo, $s_tpl_service) . ' ' . __('Shorten links automatically when using template value like "EntryKutrl".') . ' @@ -156,7 +155,7 @@ if (!empty($_REQUEST['chk'])) { echo $o->testService() ? $img_green : $img_red; } } -echo ' ' . __('Contents:') . '' . +echo ' ' . __('Contents:') . '' . form::combo(['s_wiki_service'], $ext_services_combo, $s_wiki_service) . ' ' . __('Shorten links automatically found in contents using wiki synthax.') . ' @@ -164,17 +163,18 @@ form::combo(['s_wiki_service'], $ext_services_combo, $s_wiki_service) . ' -' .__('Services') . ' +' . __('Services') . ' ' . __('List of services you can use to shorten links with pkugin kUtRL.') . ' '; -foreach(kutrl::getServices($core) as $service_id => $service) { +foreach (kutrl::getServices($core) as $service_id => $service) { $o = new $service($core); 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); @@ -192,4 +192,4 @@ foreach(kutrl::getServices($core) as $service_id => $service) { echo ''; } -echo''; \ No newline at end of file +echo''; diff --git a/_define.php b/_define.php index 03e08b8..f6d04c5 100644 --- a/_define.php +++ b/_define.php @@ -1,16 +1,15 @@ registerModule( 'details' => 'http://plugins.dotaddict.org/dc2/details/kUtRL', 'repository' => 'https://raw.githubusercontent.com/JcDenis/kUtRL/master/dcstore.xml' ] -); \ No newline at end of file +); diff --git a/_install.php b/_install.php index eea6e86..e4304b1 100644 --- a/_install.php +++ b/_install.php @@ -1,16 +1,15 @@ index('idx_kut_service', 'btree', 'kut_service') ->index('idx_kut_type', 'btree', 'kut_type'); - $ti = new dbStruct($core->con, $core->prefix); + $ti = new dbStruct($core->con, $core->prefix); $changes = $ti->synchronize($t); # Settings @@ -61,9 +60,8 @@ try { $s->put('kutrl_tpl_active', false, 'boolean', 'Return short url on dotclear tags if kutrl is active', false, true); $s->put('kutrl_admin_entry_default', true, 'boolean', 'Create short link on new entry by default', false, true); # Settings for "local" service - $local_css = - ".shortenkutrlwidget input { border: 1px solid #CCCCCC; }\n" . - ".dc-kutrl input { border: 1px solid #CCCCCC; margin: 10px; }"; + $local_css = ".shortenkutrlwidget input { border: 1px solid #CCCCCC; }\n" . + '.dc-kutrl input { border: 1px solid #CCCCCC; margin: 10px; }'; $s->put('kutrl_srv_local_protocols', 'http:,https:,ftp:,ftps:,irc:', 'string', 'Allowed kutrl local service protocols', false, true); $s->put('kutrl_srv_local_public', false, 'boolean', 'Enabled local service public page', false, true); $s->put('kutrl_srv_local_css', $local_css, 'string', 'Special CSS for kutrl local service', false, true); @@ -82,9 +80,10 @@ try { if ($core->plugins->moduleExists('dcMiniUrl')) { require_once dirname(__FILE__) . '/inc/patch.dcminiurl.php'; } + return true; } catch (Exception $e) { $core->error->add($e->getMessage()); } -return false; \ No newline at end of file +return false; diff --git a/_prepend.php b/_prepend.php index 9964869..a728060 100644 --- a/_prepend.php +++ b/_prepend.php @@ -1,16 +1,15 @@ addBehavior('kutrlService', function() { return ["default","defaultKutrlService"]; } ); +$core->addBehavior('kutrlService', function () { return ['default','defaultKutrlService']; }); if (!defined('SHORTEN_SERVICE_DISABLE_CUSTOM')) { $__autoload['customKutrlService'] = $d . 'services/class.custom.service.php'; - $core->addBehavior('kutrlService', function() { return ["custom","customKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['custom','customKutrlService']; }); } if (!defined('SHORTEN_SERVICE_DISABLE_LOCAL')) { $__autoload['localKutrlService'] = $d . 'services/class.local.service.php'; - $core->addBehavior('kutrlService', function() { return ["local","localKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['local','localKutrlService']; }); } if (!defined('SHORTEN_SERVICE_DISABLE_BILBOLINKS')) { $__autoload['bilbolinksKutrlService'] = $d . 'services/class.bilbolinks.service.php'; - $core->addBehavior('kutrlService', function() { return ["bilbolinks","bilbolinksKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['bilbolinks','bilbolinksKutrlService']; }); } if (!defined('SHORTEN_SERVICE_DISABLE_BITLY')) { $__autoload['bitlyKutrlService'] = $d . 'services/class.bitly.service.php'; - $core->addBehavior('kutrlService', function() { return ["bitly","bitlyKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['bitly','bitlyKutrlService']; }); } //if (!defined('SHORTEN_SERVICE_DISABLE_GOOGL')) { // $__autoload['googlKutrlService'] = $d . 'services/class.googl.service.php'; @@ -64,7 +63,7 @@ if (!defined('SHORTEN_SERVICE_DISABLE_BITLY')) { //} if (!defined('SHORTEN_SERVICE_DISABLE_ISGD')) { $__autoload['isgdKutrlService'] = $d . 'services/class.isgd.service.php'; - $core->addBehavior('kutrlService', function() { return ["isgd","isgdKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['isgd','isgdKutrlService']; }); } //if (!defined('SHORTEN_SERVICE_DISABLE_SHORTTO')) { // $__autoload['shorttoKutrlService'] = $d . 'services/class.shortto.service.php'; @@ -76,7 +75,7 @@ if (!defined('SHORTEN_SERVICE_DISABLE_ISGD')) { //} if (!defined('SHORTEN_SERVICE_DISABLE_YOURLS')) { $__autoload['yourlsKutrlService'] = $d . 'services/class.yourls.service.php'; - $core->addBehavior('kutrlService', function() { return ["yourls","yourlsKutrlService"]; } ); + $core->addBehavior('kutrlService', function () { return ['yourls','yourlsKutrlService']; }); } //if (!defined('SHORTEN_SERVICE_DISABLE_SUPR')) { // $__autoload['suprKutrlService'] = $d . 'services/class.supr.service.php'; @@ -85,9 +84,9 @@ if (!defined('SHORTEN_SERVICE_DISABLE_YOURLS')) { # Shorten url passed through wiki functions $__autoload['kutrlWiki'] = $d . 'lib.wiki.kutrl.php'; -$core->addBehavior('coreInitWikiPost',['kutrlWiki','coreInitWiki']); -$core->addBehavior('coreInitWikiComment',['kutrlWiki','coreInitWiki']); -$core->addBehavior('coreInitWikiSimpleComment',['kutrlWiki','coreInitWiki']); +$core->addBehavior('coreInitWikiPost', ['kutrlWiki','coreInitWiki']); +$core->addBehavior('coreInitWikiComment', ['kutrlWiki','coreInitWiki']); +$core->addBehavior('coreInitWikiSimpleComment', ['kutrlWiki','coreInitWiki']); # Public page $core->url->register('kutrl', 'go', '^go(/(.*?)|)$', ['urlKutrl', 'redirectUrl']); @@ -95,4 +94,4 @@ $core->url->register('kutrl', 'go', '^go(/(.*?)|)$', ['urlKutrl', 'redirectUrl'] # Add kUtRL events on plugin activityReport if (defined('ACTIVITY_REPORT')) { require_once $d . 'lib.kutrl.activityreport.php'; -} \ No newline at end of file +} diff --git a/_public.php b/_public.php index 2608f12..69db51f 100644 --- a/_public.php +++ b/_public.php @@ -1,16 +1,15 @@ kutrl_msg = ''; - $_ctx->kutrl_hmf = hmfKutrl::create(); + $args = $m[3] ?? ''; + $_ctx->kutrl_msg = ''; + $_ctx->kutrl_hmf = hmfKutrl::create(); $_ctx->kutrl_hmfp = hmfKutrl::protect($_ctx->kutrl_hmf); $kut = new localKutrlService($core); @@ -81,7 +80,7 @@ class urlKutrl extends dcUrlHandlers # find suffix on redirect url $suffix = ''; if (preg_match('@^([^?/#]+)(.*?)$@', $args, $more)) { - $args = $more[1]; + $args = $more[1]; $suffix = $more[2]; } # No arg, go to kurtl page @@ -131,50 +130,50 @@ class urlKutrl extends dcUrlHandlers # Validation form $url = !empty($_POST['longurl']) ? trim($core->con->escape($_POST['longurl'])) : ''; if (!empty($url)) { - $hmf = !empty($_POST['hmf']) ? $_POST['hmf'] : '!'; + $hmf = !empty($_POST['hmf']) ? $_POST['hmf'] : '!'; $hmfu = !empty($_POST['hmfp']) ? hmfKutrl::unprotect($_POST['hmfp']) : '?'; $err = false; if (!$err) { if ($hmf != $hmfu) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('Failed to verify protected field.'); } } if (!$err) { if (!$kut->testService()) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('Service is not well configured.'); } } if (!$err) { if (!$kut->isValidUrl($url)) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('This string is not a valid URL.'); } } if (!$err) { if (!$kut->isLongerUrl($url)) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('This link is too short.'); } } if (!$err) { if (!$kut->isProtocolUrl($url)) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('This type of link is not allowed.'); } } if (!$err) { if (!$kut->allow_external_url && !$kut->isBlogUrl($url)) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('Short links are limited to this blog URL.'); } } if (!$err) { if ($kut->isServiceUrl($url)) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('This link is already a short link.'); } } @@ -182,7 +181,7 @@ class urlKutrl extends dcUrlHandlers if (false !== ($rs = $kut->isKnowUrl($url))) { $err = true; - $url = $rs->url; + $url = $rs->url; $new_url = $kut->url_base . $rs->hash; $_ctx->kutrl_msg = sprintf( @@ -194,10 +193,10 @@ class urlKutrl extends dcUrlHandlers } if (!$err) { if (false === ($rs = $kut->hash($url))) { - $err = true; + $err = true; $_ctx->kutrl_msg = __('Failed to create short link.'); } else { - $url = $rs->url; + $url = $rs->url; $new_url = $kut->url_base . $rs->hash; $_ctx->kutrl_msg = sprintf( @@ -232,13 +231,13 @@ class urlKutrl extends dcUrlHandlers } $core->tpl->setPath($core->tpl->getPath(), dirname(__FILE__) . '/default-templates'); - $_ctx =& $GLOBALS['_ctx']; + $_ctx = & $GLOBALS['_ctx']; $core = $GLOBALS['core']; header('Content-Type: text/html; charset=UTF-8'); http::head(404, 'Not Found'); - $core->url->type = '404'; - $_ctx->current_tpl = 'kutrl404.html'; + $core->url->type = '404'; + $_ctx->current_tpl = 'kutrl404.html'; $_ctx->content_type = 'text/html'; echo $core->tpl->getData($_ctx->current_tpl); @@ -266,18 +265,20 @@ class pubKutrl # Disable URL shoretning on filtered tag public static function templateBeforeValue($core, $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 ''; } + return null; } # Re unable it after tag public static function templateAfterValue($core, $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 ''; } + return null; } @@ -285,13 +286,13 @@ class pubKutrl public static function publicBeforeContentFilter($core, $tag, $args) { # Unknow tag - if (!in_array($tag,pubKutrl::$know_tags)) { + if (!in_array($tag, pubKutrl::$know_tags)) { return null; } # URL shortening is disabled by tag attribute if (empty($GLOBALS['disable_kutrl'])) { # kUtRL is not activated - if (!$core->blog->settings->kUtRL->kutrl_active + if (!$core->blog->settings->kUtRL->kutrl_active || !$core->blog->settings->kUtRL->kutrl_tpl_active ) { return null; @@ -324,7 +325,7 @@ class pubKutrl $s = $core->blog->settings->kUtRL; # Passive : all kutrl tag return long url - $_ctx->kutrl_passive = (boolean) $s->kutrl_tpl_passive; + $_ctx->kutrl_passive = (bool) $s->kutrl_tpl_passive; if (!$s->kutrl_active || !$s->kutrl_tpl_service) { return null; @@ -339,7 +340,7 @@ class pubKutrl { $css = $core->blog->settings->kUtRL->kutrl_srv_local_css; if ($css) { - echo + echo "\n \n" . "
' . form::checkbox('kutrl_delete', 1, !empty($_POST['kutrl_delete']), '', 3) . ' ' . __('Delete short link') . '
' . $href . '
' . -form::checkbox(['s_active'], '1', $s_active) . +' . __('Activation') . ' +' . +form::checkbox(['s_active'], '1', $s_active) . __('Enable plugin') . '
' . +form::checkbox(['s_active'], '1', $s_active) . __('Enable plugin') . '
' . -form::checkbox(['s_allow_external_url'], '1', $s_allow_external_url) . +' . __('Behaviors') . ' +' . +form::checkbox(['s_allow_external_url'], '1', $s_allow_external_url) . __('Allow short link for external URL') . ' ' . __('Not only link started with this blog URL could be shortened.') . ' -' . -form::checkbox(['s_tpl_passive'], '1', $s_tpl_passive) . +' . +form::checkbox(['s_tpl_passive'], '1', $s_tpl_passive) . __('Passive mode') . ' ' . __('If this extension is disabled and the passive mode is enabled, "kutrl" tags (like EntryKurl) will display long urls instead of nothing on templates.') . ' -' . -form::checkbox(['s_tpl_active'], '1', $s_tpl_active) . +' . +form::checkbox(['s_tpl_active'], '1', $s_tpl_active) . __('Active mode') . ' -' . __('If the active mode is enabled, all know default template tags (like EntryURL) will display short urls instead of long ones 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.') . ' -' . -form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . +' . +form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . __('Create short link for new entries') . ' ' . __('This can be changed on page of creation/edition of an entry.') . '
' . +form::checkbox(['s_allow_external_url'], '1', $s_allow_external_url) . __('Allow short link for external URL') . '
' . __('Not only link started with this blog URL could be shortened.') . '
' . -form::checkbox(['s_tpl_passive'], '1', $s_tpl_passive) . +' . +form::checkbox(['s_tpl_passive'], '1', $s_tpl_passive) . __('Passive mode') . ' ' . __('If this extension is disabled and the passive mode is enabled, "kutrl" tags (like EntryKurl) will display long urls instead of nothing on templates.') . ' -' . -form::checkbox(['s_tpl_active'], '1', $s_tpl_active) . +' . +form::checkbox(['s_tpl_active'], '1', $s_tpl_active) . __('Active mode') . ' -' . __('If the active mode is enabled, all know default template tags (like EntryURL) will display short urls instead of long ones 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.') . ' -' . -form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . +' . +form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . __('Create short link for new entries') . ' ' . __('This can be changed on page of creation/edition of an entry.') . '
' . +form::checkbox(['s_tpl_passive'], '1', $s_tpl_passive) . __('Passive mode') . '
' . __('If this extension is disabled and the passive mode is enabled, "kutrl" tags (like EntryKurl) will display long urls instead of nothing on templates.') . '
' . -form::checkbox(['s_tpl_active'], '1', $s_tpl_active) . +' . +form::checkbox(['s_tpl_active'], '1', $s_tpl_active) . __('Active mode') . ' -' . __('If the active mode is enabled, all know default template tags (like EntryURL) will display short urls instead of long ones 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.') . ' -' . -form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . +' . +form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . __('Create short link for new entries') . ' ' . __('This can be changed on page of creation/edition of an entry.') . '
' . +form::checkbox(['s_tpl_active'], '1', $s_tpl_active) . __('Active mode') . '
' . __('If the active mode is enabled, all know default template tags (like EntryURL) will display short urls instead of long ones 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.') . '
' . -form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . +' . +form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . __('Create short link for new entries') . ' ' . __('This can be changed on page of creation/edition of an entry.') . '
' . +form::checkbox(['s_admin_entry_default'], '1', $s_admin_entry_default) . __('Create short link for new entries') . '
' . __('This can be changed on page of creation/edition of an entry.') . '
'; if (!empty($_REQUEST['chk'])) { if (null !== ($o = kutrl::quickPlace($s_admin_service))) { echo $o->testService() ? $img_green : $img_red; } } -echo ' ' . __('Administration:') . '' . +echo ' ' . __('Administration:') . '' . form::combo(['s_admin_service'], $services_combo, $s_admin_service) . '
' . __('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.') . '
' . __('List of services you can use to shorten links with pkugin kUtRL.') . '