kUtRL/_prepend.php

98 lines
4.1 KiB
PHP
Raw Normal View History

2021-08-25 23:06:22 +00:00
<?php
/**
* @brief kUtRL, a plugin for Dotclear 2
2021-11-06 15:43:02 +00:00
*
* @package Dotclear
* @subpackage Plugin
2021-11-06 15:43:02 +00:00
*
* @author Jean-Christian Denis and contributors
2021-11-06 15:43:02 +00:00
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return;
}
2021-08-25 23:06:22 +00:00
# Set a URL shortener for quick get request
if (!defined('SHORTEN_SERVICE_NAME')) {
define('SHORTEN_SERVICE_NAME', 'Is.gd');
2021-08-25 23:06:22 +00:00
}
if (!defined('SHORTEN_SERVICE_API')) {
define('SHORTEN_SERVICE_API', 'https://is.gd/api.php?');
2021-08-25 23:06:22 +00:00
}
if (!defined('SHORTEN_SERVICE_BASE')) {
define('SHORTEN_SERVICE_BASE', 'https://is.gd/');
2021-08-25 23:06:22 +00:00
}
if (!defined('SHORTEN_SERVICE_PARAM')) {
define('SHORTEN_SERVICE_PARAM', 'longurl');
2021-08-25 23:06:22 +00:00
}
if (!defined('SHORTEN_SERVICE_ENCODE')) {
define('SHORTEN_SERVICE_ENCODE', false);
2021-08-25 23:06:22 +00:00
}
# Main class
2021-11-06 15:43:02 +00:00
$d = dirname(__FILE__) . '/inc/';
2021-10-26 21:03:38 +00:00
$__autoload['kutrl'] = $d . 'class.kutrl.php';
$__autoload['kutrlService'] = $d . 'lib.kutrl.srv.php';
$__autoload['kutrlLog'] = $d . 'lib.kutrl.log.php';
$__autoload['kutrlLinksList'] = $d . 'lib.kutrl.lst.php';
2021-08-25 23:06:22 +00:00
# Services
$__autoload['defaultKutrlService'] = $d . 'services/class.default.service.php';
2021-11-06 15:43:02 +00:00
$core->addBehavior('kutrlService', function () { return ['default','defaultKutrlService']; });
if (!defined('SHORTEN_SERVICE_DISABLE_CUSTOM')) {
$__autoload['customKutrlService'] = $d . 'services/class.custom.service.php';
2021-11-06 15:43:02 +00:00
$core->addBehavior('kutrlService', function () { return ['custom','customKutrlService']; });
}
if (!defined('SHORTEN_SERVICE_DISABLE_LOCAL')) {
$__autoload['localKutrlService'] = $d . 'services/class.local.service.php';
2021-11-06 15:43:02 +00:00
$core->addBehavior('kutrlService', function () { return ['local','localKutrlService']; });
}
if (!defined('SHORTEN_SERVICE_DISABLE_BILBOLINKS')) {
$__autoload['bilbolinksKutrlService'] = $d . 'services/class.bilbolinks.service.php';
2021-11-06 15:43:02 +00:00
$core->addBehavior('kutrlService', function () { return ['bilbolinks','bilbolinksKutrlService']; });
}
2021-10-30 15:47:53 +00:00
if (!defined('SHORTEN_SERVICE_DISABLE_BITLY')) {
$__autoload['bitlyKutrlService'] = $d . 'services/class.bitly.service.php';
2021-11-06 15:43:02 +00:00
$core->addBehavior('kutrlService', function () { return ['bitly','bitlyKutrlService']; });
2021-10-30 15:47:53 +00:00
}
//if (!defined('SHORTEN_SERVICE_DISABLE_GOOGL')) {
// $__autoload['googlKutrlService'] = $d . 'services/class.googl.service.php';
// $core->addBehavior('kutrlService', function() { return ["googl","googlKutrlService"]; } );
//}
if (!defined('SHORTEN_SERVICE_DISABLE_ISGD')) {
$__autoload['isgdKutrlService'] = $d . 'services/class.isgd.service.php';
2021-11-06 15:43:02 +00:00
$core->addBehavior('kutrlService', function () { return ['isgd','isgdKutrlService']; });
}
//if (!defined('SHORTEN_SERVICE_DISABLE_SHORTTO')) {
// $__autoload['shorttoKutrlService'] = $d . 'services/class.shortto.service.php';
// $core->addBehavior('kutrlService', function() { return ["shortto","shorttoKutrlService"]; } );
//}
//if (!defined('SHORTEN_SERVICE_DISABLE_TRIM')) {
// $__autoload['trimKutrlService'] = $d . 'services/class.trim.service.php';
// $core->addBehavior('kutrlService', function() { return ["trim","trimKutrlService"]; } );
//}
if (!defined('SHORTEN_SERVICE_DISABLE_YOURLS')) {
$__autoload['yourlsKutrlService'] = $d . 'services/class.yourls.service.php';
2021-11-06 15:43:02 +00:00
$core->addBehavior('kutrlService', function () { return ['yourls','yourlsKutrlService']; });
}
//if (!defined('SHORTEN_SERVICE_DISABLE_SUPR')) {
// $__autoload['suprKutrlService'] = $d . 'services/class.supr.service.php';
// $core->addBehavior('kutrlService', function() { return ["supr","suprKutrlService"]; } );
//}
2021-08-25 23:06:22 +00:00
# Shorten url passed through wiki functions
$__autoload['kutrlWiki'] = $d . 'lib.wiki.kutrl.php';
2021-11-06 15:43:02 +00:00
$core->addBehavior('coreInitWikiPost', ['kutrlWiki','coreInitWiki']);
$core->addBehavior('coreInitWikiComment', ['kutrlWiki','coreInitWiki']);
$core->addBehavior('coreInitWikiSimpleComment', ['kutrlWiki','coreInitWiki']);
2021-08-25 23:06:22 +00:00
# Public page
$core->url->register('kutrl', 'go', '^go(/(.*?)|)$', ['urlKutrl', 'redirectUrl']);
2021-08-25 23:06:22 +00:00
# Add kUtRL events on plugin activityReport
if (defined('ACTIVITY_REPORT')) {
require_once $d . 'lib.kutrl.activityreport.php';
2021-11-06 15:43:02 +00:00
}