2021-09-10 19:06:49 +00:00
|
|
|
<?php
|
2021-09-10 19:18:51 +00:00
|
|
|
/**
|
|
|
|
* @brief postWidgetText, a plugin for Dotclear 2
|
2021-11-06 15:11:19 +00:00
|
|
|
*
|
2021-09-10 19:18:51 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-06 15:11:19 +00:00
|
|
|
*
|
2021-09-10 19:18:51 +00:00
|
|
|
* @author Jean-Christian Denis and Contributors
|
2021-11-06 15:11:19 +00:00
|
|
|
*
|
2021-09-10 19:18:51 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-09-10 19:06:49 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
2021-09-10 19:18:51 +00:00
|
|
|
return null;
|
2021-09-10 19:06:49 +00:00
|
|
|
}
|
|
|
|
|
2022-12-03 15:57:39 +00:00
|
|
|
try {
|
|
|
|
# check installed version
|
2022-12-10 14:54:05 +00:00
|
|
|
if (!dcCore::app()->newVersion(
|
|
|
|
basename(__DIR__),
|
|
|
|
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
|
2022-12-07 23:28:16 +00:00
|
|
|
)) {
|
|
|
|
return null;
|
2022-12-03 15:57:39 +00:00
|
|
|
}
|
2021-09-10 19:06:49 +00:00
|
|
|
|
2021-09-10 19:18:51 +00:00
|
|
|
# Table is the same for plugins
|
|
|
|
# pollsFactory, postTask, postWidgetText
|
2022-11-15 21:05:23 +00:00
|
|
|
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
2022-12-03 15:57:39 +00:00
|
|
|
$s->{initPostWidgetText::PWT_TABLE_NAME}
|
2021-11-06 15:11:19 +00:00
|
|
|
->option_id('bigint', 0, false)
|
|
|
|
->post_id('bigint', 0, false)
|
|
|
|
->option_creadt('timestamp', 0, false, 'now()')
|
|
|
|
->option_upddt('timestamp', 0, false, 'now()')
|
|
|
|
->option_type('varchar', 32, false, "''")
|
|
|
|
->option_format('varchar', 32, false, "'xhtml'")
|
|
|
|
->option_lang('varchar', 5, true, null)
|
|
|
|
->option_title('varchar', 255, true, null)
|
|
|
|
->option_content('text', 0, true, null)
|
|
|
|
->option_content_xhtml('text', 0, false)
|
2021-09-10 19:06:49 +00:00
|
|
|
|
2021-10-29 22:59:40 +00:00
|
|
|
->index('idx_post_option_option', 'btree', 'option_id')
|
|
|
|
->index('idx_post_option_post', 'btree', 'post_id')
|
|
|
|
->index('idx_post_option_type', 'btree', 'option_type');
|
2021-09-10 19:06:49 +00:00
|
|
|
|
2022-11-15 21:05:23 +00:00
|
|
|
$si = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
2021-09-10 19:18:51 +00:00
|
|
|
$changes = $si->synchronize($s);
|
2021-09-10 19:06:49 +00:00
|
|
|
|
2021-09-10 19:18:51 +00:00
|
|
|
# Settings
|
2022-11-15 21:05:23 +00:00
|
|
|
dcCore::app()->blog->settings->addNamespace('postwidgettext');
|
|
|
|
dcCore::app()->blog->settings->postwidgettext->put(
|
2021-11-06 15:11:19 +00:00
|
|
|
'postwidgettext_active',
|
|
|
|
true,
|
|
|
|
'boolean',
|
|
|
|
'post widget text plugin enabled',
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
);
|
2022-11-15 21:05:23 +00:00
|
|
|
dcCore::app()->blog->settings->postwidgettext->put(
|
2021-11-06 15:11:19 +00:00
|
|
|
'postwidgettext_importexport_active',
|
|
|
|
true,
|
|
|
|
'boolean',
|
|
|
|
'activate import/export behaviors',
|
|
|
|
false,
|
|
|
|
true
|
|
|
|
);
|
2021-09-10 19:06:49 +00:00
|
|
|
|
2021-09-10 19:18:51 +00:00
|
|
|
# Transfert records from old table to the new one
|
2022-12-10 14:54:05 +00:00
|
|
|
if (dcCore::app()->getVersion(basename(__DIR__)) !== null
|
|
|
|
&& version_compare(dcCore::app()->getVersion(basename(__DIR__)), '0.5', '<')
|
2021-11-06 15:11:19 +00:00
|
|
|
) {
|
2022-11-15 21:05:23 +00:00
|
|
|
require_once __DIR__ . '/inc/patch.0.5.php';
|
2021-09-10 19:18:51 +00:00
|
|
|
}
|
2021-09-10 19:06:49 +00:00
|
|
|
|
2021-09-10 19:18:51 +00:00
|
|
|
return true;
|
2021-10-29 22:59:40 +00:00
|
|
|
} catch (Exception $e) {
|
2022-11-15 21:05:23 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-10-29 22:59:40 +00:00
|
|
|
}
|
2021-09-10 19:06:49 +00:00
|
|
|
|
2021-11-06 15:11:19 +00:00
|
|
|
return false;
|