periodical/src/Install.php

61 lines
2.0 KiB
PHP
Raw Normal View History

2021-08-23 11:24:19 +00:00
<?php
2021-09-02 12:56:02 +00:00
/**
* @brief periodical, a plugin for Dotclear 2
*
2021-09-02 12:56:02 +00:00
* @package Dotclear
* @subpackage Plugin
*
2021-09-02 12:56:02 +00:00
* @author Jean-Christian Denis and contributors
*
2021-09-02 12:56:02 +00:00
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
2021-08-23 11:24:19 +00:00
if (!defined('DC_CONTEXT_ADMIN')) {
2021-08-23 22:52:29 +00:00
return null;
2021-08-23 11:24:19 +00:00
}
2022-12-03 15:30:57 +00:00
try {
# Check installed version
2022-12-10 14:47:51 +00:00
if (!dcCore::app()->newVersion(
basename(__DIR__),
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
2022-12-07 23:24:31 +00:00
)) {
2022-12-03 15:30:57 +00:00
return null;
}
2021-08-23 11:24:19 +00:00
2021-08-23 22:52:29 +00:00
# Tables
$t = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
2021-08-23 11:24:19 +00:00
2021-08-23 22:52:29 +00:00
# Table principale des sondages
2022-12-03 15:30:57 +00:00
$t->{initPeriodical::PERIOD_TABLE_NAME}
->periodical_id('bigint', 0, false)
2021-08-23 22:52:29 +00:00
->blog_id('varchar', 32, false)
->periodical_type('varchar', 32, false, "'post'")
->periodical_title('varchar', 255, false, "''")
->periodical_tz('varchar', 128, false, "'UTC'")
->periodical_curdt('timestamp', 0, false, ' now()')
->periodical_enddt('timestamp', 0, false, 'now()')
->periodical_pub_int('varchar', 32, false, "'day'")
->periodical_pub_nb('smallint', 0, false, 1)
2021-08-23 11:24:19 +00:00
2021-08-23 22:52:29 +00:00
->primary('pk_periodical', 'periodical_id')
->index('idx_periodical_type', 'btree', 'periodical_type');
2021-08-23 11:24:19 +00:00
$ti = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
2021-08-23 22:52:29 +00:00
$changes = $ti->synchronize($t);
2021-08-23 11:24:19 +00:00
2021-08-23 22:52:29 +00:00
# Settings
2022-12-10 14:47:51 +00:00
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
2021-08-23 22:52:29 +00:00
$s->put('periodical_active', false, 'boolean', 'Enable extension', false, true);
$s->put('periodical_upddate', true, 'boolean', 'Update post date', false, true);
$s->put('periodical_updurl', false, 'boolean', 'Update post url', false, true);
$s->put('periodical_pub_order', 'post_dt asc', 'string', 'Order of publication', false, true);
2021-08-23 11:24:19 +00:00
2021-08-23 22:52:29 +00:00
return true;
} catch (Exception $e) {
2022-11-14 19:55:22 +00:00
dcCore::app()->error->add($e->getMessage());
2021-08-23 11:24:19 +00:00
}
return false;