kUtRL/_install.php

85 lines
3.8 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_CONTEXT_ADMIN')) {
return;
}
2021-08-25 23:06:22 +00:00
try {
2022-12-07 23:10:29 +00:00
# Compare versions
2022-12-10 14:34:50 +00:00
if (!dcCore::app()->newVersion(
2022-12-22 14:37:09 +00:00
basename(__DIR__),
2022-12-10 14:34:50 +00:00
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
2022-12-07 23:10:29 +00:00
)) {
return null;
}
# Table
2022-11-20 16:15:36 +00:00
$t = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
2022-12-01 22:22:10 +00:00
$t->{initkUtRL::KURL_TABLE_NAME}
->kut_id('bigint', 0, false)
->blog_id('varchar', 32, false)
->kut_service('varchar', 32, false, "'kUtRL'")
->kut_type('varchar', 32, false)
->kut_hash('varchar', 32, false)
->kut_url('text', 0, false)
->kut_dt('timestamp', 0, false, 'now()')
->kut_password('varchar', 32, true)
->kut_counter('bigint', 0, false, 0)
->primary('pk_kutrl', 'kut_id')
->index('idx_kut_blog_id', 'btree', 'blog_id')
->index('idx_kut_hash', 'btree', 'kut_hash')
->index('idx_kut_service', 'btree', 'kut_service')
->index('idx_kut_type', 'btree', 'kut_type');
2022-11-20 16:15:36 +00:00
$ti = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
$changes = $ti->synchronize($t);
# Settings
2022-12-22 14:37:09 +00:00
$s = dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
$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_admin_service', 'local', 'string', 'Service to use to shorten links on admin', false, true);
$s->put('kutrl_tpl_service', 'local', 'string', 'Service to use to shorten links on template', false, true);
$s->put('kutrl_wiki_service', 'local', 'string', 'Service to use to shorten links on contents', false, true);
$s->put('kutrl_allow_external_url', true, 'boolean', 'Limited short url to current blog\'s url', false, true);
$s->put('kutrl_tpl_passive', true, 'boolean', 'Return long url on kutrl tags if kutrl is unactivate', false, true);
$s->put('kutrl_tpl_active', false, 'boolean', 'Return short url on dotclear tags if kutrl is active', false, true);
2021-09-16 21:52:13 +00:00
$s->put('kutrl_admin_entry_default', true, 'boolean', 'Create short link on new entry by default', false, true);
# Settings for "local" service
2021-11-06 15:43:02 +00:00
$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);
$s->put('kutrl_srv_local_404_active', false, 'boolean', 'Use special 404 page on unknow urls', false, true);
# Settings for "bilbolinks" service
$s->put('kutrl_srv_bilbolinks_base', 'http://tux-pla.net/', 'string', 'URL of bilbolinks service', false, true);
# Settings for "YOURLS" service
$s->put('kutrl_srv_yourls_base', '', 'string', 'URL of YOURLS service', false, true);
$s->put('kutrl_srv_yourls_username', '', 'string', 'User name to YOURLS service', false, true);
$s->put('kutrl_srv_yourls_password', '', 'string', 'User password to YOURLS service', false, true);
# Get dcMiniUrl records as this plugin do the same
2022-11-20 16:15:36 +00:00
if (dcCore::app()->plugins->moduleExists('dcMiniUrl')) {
require_once __DIR__ . '/inc/patch.dcminiurl.php';
}
2021-11-06 15:43:02 +00:00
return true;
} catch (Exception $e) {
2022-11-20 16:15:36 +00:00
dcCore::app()->error->add($e->getMessage());
2021-10-26 21:03:38 +00:00
}
2021-11-06 15:43:02 +00:00
return false;