kUtRL/_prepend.php

100 lines
4.4 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
2022-11-20 16:15:36 +00:00
$d = __DIR__ . '/inc/';
2022-12-01 22:22:10 +00:00
Clearbricks::lib()->autoload([
'kUtRL' => $d . 'class.kutrl.php',
'kutrlService' => $d . 'lib.kutrl.srv.php',
'kutrlLog' => $d . 'lib.kutrl.log.php',
'kutrlLinkslist' => $d . 'lib.kutrl.lst.php',
]);
2021-08-25 23:06:22 +00:00
# Services
2022-11-20 16:15:36 +00:00
Clearbricks::lib()->autoload(['defaultKutrlService' => $d . 'services/class.default.service.php']);
dcCore::app()->addBehavior('kutrlService', function () { return ['default','defaultKutrlService']; });
if (!defined('SHORTEN_SERVICE_DISABLE_CUSTOM')) {
2022-11-20 16:15:36 +00:00
Clearbricks::lib()->autoload(['customKutrlService' => $d . 'services/class.custom.service.php']);
dcCore::app()->addBehavior('kutrlService', function () { return ['custom','customKutrlService']; });
}
if (!defined('SHORTEN_SERVICE_DISABLE_LOCAL')) {
2022-11-20 16:15:36 +00:00
Clearbricks::lib()->autoload(['localKutrlService' => $d . 'services/class.local.service.php']);
dcCore::app()->addBehavior('kutrlService', function () { return ['local','localKutrlService']; });
}
if (!defined('SHORTEN_SERVICE_DISABLE_BILBOLINKS')) {
2022-11-20 16:15:36 +00:00
Clearbricks::lib()->autoload(['bilbolinksKutrlService' => $d . 'services/class.bilbolinks.service.php']);
dcCore::app()->addBehavior('kutrlService', function () { return ['bilbolinks','bilbolinksKutrlService']; });
}
2021-10-30 15:47:53 +00:00
if (!defined('SHORTEN_SERVICE_DISABLE_BITLY')) {
2022-11-20 16:15:36 +00:00
Clearbricks::lib()->autoload(['bitlyKutrlService' => $d . 'services/class.bitly.service.php']);
dcCore::app()->addBehavior('kutrlService', function () { return ['bitly','bitlyKutrlService']; });
2021-10-30 15:47:53 +00:00
}
//if (!defined('SHORTEN_SERVICE_DISABLE_GOOGL')) {
2022-11-20 16:15:36 +00:00
// Clearbricks::lib()->autoload(['googlKutrlService' => $d . 'services/class.googl.service.php']);
// dcCore::app()->addBehavior('kutrlService', function() { return ["googl","googlKutrlService"]; } );
//}
if (!defined('SHORTEN_SERVICE_DISABLE_ISGD')) {
2022-11-20 16:15:36 +00:00
Clearbricks::lib()->autoload(['isgdKutrlService' => $d . 'services/class.isgd.service.php']);
dcCore::app()->addBehavior('kutrlService', function () { return ['isgd','isgdKutrlService']; });
}
//if (!defined('SHORTEN_SERVICE_DISABLE_SHORTTO')) {
2022-11-20 16:15:36 +00:00
// Clearbricks::lib()->autoload(['shorttoKutrlService' => $d . 'services/class.shortto.service.php']);
// dcCore::app()->addBehavior('kutrlService', function() { return ["shortto","shorttoKutrlService"]; } );
//}
//if (!defined('SHORTEN_SERVICE_DISABLE_TRIM')) {
2022-11-20 16:15:36 +00:00
// Clearbricks::lib()->autoload(['trimKutrlService' => $d . 'services/class.trim.service.php']);
// dcCore::app()->addBehavior('kutrlService', function() { return ["trim","trimKutrlService"]; } );
//}
if (!defined('SHORTEN_SERVICE_DISABLE_YOURLS')) {
2022-11-20 16:15:36 +00:00
Clearbricks::lib()->autoload(['yourlsKutrlService' => $d . 'services/class.yourls.service.php']);
dcCore::app()->addBehavior('kutrlService', function () { return ['yourls','yourlsKutrlService']; });
}
//if (!defined('SHORTEN_SERVICE_DISABLE_SUPR')) {
2022-11-20 16:15:36 +00:00
// Clearbricks::lib()->autoload(['suprKutrlService' => $d . 'services/class.supr.service.php']);
// dcCore::app()->addBehavior('kutrlService', function() { return ["supr","suprKutrlService"]; } );
//}
2021-08-25 23:06:22 +00:00
# Shorten url passed through wiki functions
2022-11-20 16:15:36 +00:00
Clearbricks::lib()->autoload(['kutrlWiki' => $d . 'lib.wiki.kutrl.php']);
dcCore::app()->addBehavior('coreInitWikiPost', ['kutrlWiki','coreInitWiki']);
dcCore::app()->addBehavior('coreInitWikiComment', ['kutrlWiki','coreInitWiki']);
dcCore::app()->addBehavior('coreInitWikiSimpleComment', ['kutrlWiki','coreInitWiki']);
2021-08-25 23:06:22 +00:00
# Public page
2022-11-20 16:15:36 +00:00
dcCore::app()->url->register('kutrl', 'go', '^go(/(.*?)|)$', ['urlKutrl', 'redirectUrl']);
2021-08-25 23:06:22 +00:00
# Add kUtRL events on plugin activityReport
2022-11-20 16:15:36 +00:00
if (defined('ACTIVITY_REPORT_V2')) {
require_once $d . 'lib.kutrl.activityreport.php';
2021-11-06 15:43:02 +00:00
}