cinecturlink2/_install.php

86 lines
3.5 KiB
PHP
Raw Normal View History

2021-09-07 12:33:18 +00:00
<?php
2021-09-07 13:21:38 +00:00
/**
* @brief cinecturlink2, a plugin for Dotclear 2
2021-11-02 22:55:41 +00:00
*
2021-09-07 13:21:38 +00:00
* @package Dotclear
* @subpackage Plugin
2021-11-02 22:55:41 +00:00
*
2021-09-07 13:21:38 +00:00
* @author Jean-Christian Denis and Contributors
2021-11-02 22:55:41 +00:00
*
2021-09-07 13:21:38 +00:00
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
2021-09-07 12:33:18 +00:00
if (!defined('DC_CONTEXT_ADMIN')) {
2021-09-07 13:21:38 +00:00
return null;
2021-09-07 12:33:18 +00:00
}
2021-09-07 12:51:25 +00:00
try {
2022-12-10 14:04:01 +00:00
if (!dcCore::app()->newVersion(
2022-12-20 20:25:13 +00:00
basename(__DIR__),
2022-12-10 14:04:01 +00:00
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
2022-12-07 22:58:40 +00:00
)) {
return null;
}
2022-11-17 21:01:00 +00:00
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
2022-11-30 22:43:36 +00:00
$s->{initCinecturlink2::CINECTURLINK_TABLE_NAME}
2021-11-02 22:55:41 +00:00
->link_id('bigint', 0, false)
->blog_id('varchar', 32, false)
->cat_id('bigint', 0, true)
->user_id('varchar', 32, true)
->link_type('varchar', 32, false, "'cinecturlink'")
->link_title('varchar', 255, false)
->link_desc('varchar', 255, false)
->link_author('varchar', 255, false)
->link_lang('varchar', 5, false, "'en'")
->link_url('varchar', 255, false)
->link_img('varchar', 255, false)
->link_creadt('timestamp', 0, false, 'now()')
->link_upddt('timestamp', 0, false, 'now()')
->link_pos('smallint', 0, false, "'0'")
2021-09-07 13:21:38 +00:00
->link_note('smallint', 0, false, "'10'")
->link_count('bigint', 0, false, "'0'")
2021-09-07 12:33:18 +00:00
2021-09-07 13:21:38 +00:00
->primary('pk_cinecturlink2', 'link_id')
->index('idx_cinecturlink2_title', 'btree', 'link_title')
->index('idx_cinecturlink2_author', 'btree', 'link_author')
->index('idx_cinecturlink2_blog_id', 'btree', 'blog_id')
->index('idx_cinecturlink2_cat_id', 'btree', 'cat_id')
->index('idx_cinecturlink2_user_id', 'btree', 'user_id')
->index('idx_cinecturlink2_type', 'btree', 'link_type');
2021-09-07 12:33:18 +00:00
2022-11-30 22:43:36 +00:00
$s->{initCinecturlink2::CATEGORY_TABLE_NAME}
2021-11-02 22:55:41 +00:00
->cat_id('bigint', 0, false)
->blog_id('varchar', 32, false)
->cat_title('varchar', 255, false)
->cat_desc('varchar', 255, false)
->cat_creadt('timestamp', 0, false, 'now()')
->cat_upddt('timestamp', 0, false, 'now()')
->cat_pos('smallint', 0, false, "'0'")
2021-09-07 12:33:18 +00:00
2021-09-07 13:21:38 +00:00
->primary('pk_cinecturlink2_cat', 'cat_id')
->index('idx_cinecturlink2_cat_blog_id', 'btree', 'blog_id')
->unique('uk_cinecturlink2_cat_title', 'cat_title', 'blog_id');
2021-09-07 12:33:18 +00:00
2022-11-17 21:01:00 +00:00
$si = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
2021-09-07 13:21:38 +00:00
$changes = $si->synchronize($s);
2021-09-07 12:33:18 +00:00
2022-11-17 21:01:00 +00:00
dcCore::app()->blog->settings->addNamespace('cinecturlink2');
$s = dcCore::app()->blog->settings->cinecturlink2;
2021-09-07 13:21:38 +00:00
$s->put('cinecturlink2_active', true, 'boolean', 'Enable cinecturlink2', false, true);
$s->put('cinecturlink2_widthmax', 100, 'integer', 'Maximum width of picture', false, true);
$s->put('cinecturlink2_folder', 'cinecturlink', 'string', 'Public folder of pictures', false, true);
$s->put('cinecturlink2_triggeronrandom', false, 'boolean', 'Open link in new window', false, true);
$s->put('cinecturlink2_public_active', false, 'boolean', 'Enable cinecturlink2', false, true);
$s->put('cinecturlink2_public_title', '', 'string', 'Title of public page', false, true);
2021-11-02 22:55:41 +00:00
$s->put('cinecturlink2_public_description', '', 'string', 'Description of public page', false, true);
2021-09-07 13:21:38 +00:00
$s->put('cinecturlink2_public_nbrpp', 20, 'integer', 'Number of entries per page on public page', false, true);
$s->put('cinecturlink2_public_caturl', 'c2cat', 'string', 'Part of URL for a category list', false, true);
2021-09-07 12:33:18 +00:00
2021-09-07 13:21:38 +00:00
return true;
2021-09-07 12:51:25 +00:00
} catch (Exception $e) {
2022-11-17 21:01:00 +00:00
dcCore::app()->error->add($e->getMessage());
2021-09-07 12:33:18 +00:00
}
2021-11-02 22:55:41 +00:00
return false;