2021-08-23 23:55:52 +00:00
|
|
|
<?php
|
2021-09-02 18:35:25 +00:00
|
|
|
/**
|
|
|
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
2021-11-01 09:33:43 +00:00
|
|
|
*
|
2021-09-02 18:35:25 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-01 09:33:43 +00:00
|
|
|
*
|
2021-09-02 18:35:25 +00:00
|
|
|
* @author Jean-Christian Denis and Contributors
|
2021-11-01 09:33:43 +00:00
|
|
|
*
|
2021-09-02 18:35:25 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-08-23 23:55:52 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
2021-08-24 20:05:23 +00:00
|
|
|
return null;
|
2021-08-23 23:55:52 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 09:32:38 +00:00
|
|
|
try {
|
2022-12-12 23:43:29 +00:00
|
|
|
// Version
|
2022-12-10 14:20:39 +00:00
|
|
|
if (!dcCore::app()->newVersion(
|
2022-12-21 21:27:20 +00:00
|
|
|
basename(__DIR__),
|
2022-12-10 14:20:39 +00:00
|
|
|
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
|
|
|
|
)) {
|
2022-12-01 09:32:38 +00:00
|
|
|
return null;
|
|
|
|
}
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2022-12-12 23:43:29 +00:00
|
|
|
// Database
|
2022-11-13 20:30:48 +00:00
|
|
|
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
2022-12-12 22:09:12 +00:00
|
|
|
$s->{initEnhancePostContent::TABLE_NAME}
|
2021-11-01 09:33:43 +00:00
|
|
|
->epc_id('bigint', 0, false)
|
|
|
|
->blog_id('varchar', 32, false)
|
2021-08-24 20:05:23 +00:00
|
|
|
->epc_type('varchar', 32, false, "'epc'")
|
|
|
|
->epc_filter('varchar', 64, false)
|
|
|
|
->epc_key('varchar', 255, false)
|
|
|
|
->epc_value('text', 0, false)
|
|
|
|
->epc_upddt('timestamp', 0, false, 'now()')
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2021-08-24 20:05:23 +00:00
|
|
|
->primary('pk_epc', 'epc_id')
|
|
|
|
->index('idx_epc_blog_id', 'btree', 'blog_id')
|
|
|
|
->index('idx_epc_type', 'btree', 'epc_type')
|
|
|
|
->index('idx_epc_filter', 'btree', 'epc_filter')
|
|
|
|
->index('idx_epc_key', 'btree', 'epc_key');
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2022-11-13 20:30:48 +00:00
|
|
|
$si = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
2021-08-24 20:05:23 +00:00
|
|
|
$changes = $si->synchronize($s);
|
2021-11-01 09:33:43 +00:00
|
|
|
$s = null;
|
2021-08-24 20:05:23 +00:00
|
|
|
|
2022-12-13 20:39:18 +00:00
|
|
|
// Uppgrade
|
|
|
|
epcUpgrade::growUp();
|
|
|
|
|
2022-12-12 23:43:29 +00:00
|
|
|
// Settings
|
2022-12-21 21:27:20 +00:00
|
|
|
$s = dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
2021-08-24 20:05:23 +00:00
|
|
|
|
2022-12-12 23:16:35 +00:00
|
|
|
$s->put('active', false, 'boolean', 'Enable enhancePostContent', false, true);
|
|
|
|
$s->put('list_sortby', 'epc_key', 'string', 'Admin records list field order', false, true);
|
|
|
|
$s->put('list_order', 'desc', 'string', 'Admin records list order', false, true);
|
|
|
|
$s->put('list_nb', 20, 'integer', 'Admin records list nb per page', false, true);
|
2022-12-12 23:43:29 +00:00
|
|
|
$s->put('allowedtplvalues', json_encode(enhancePostContent::defaultAllowedTplValues()), 'string', 'List of allowed template values', false, true);
|
|
|
|
$s->put('allowedpubpages', json_encode(enhancePostContent::defaultAllowedPubPages()), 'string', 'List of allowed template pages', false, true);
|
2021-08-24 20:05:23 +00:00
|
|
|
|
2022-12-12 23:43:29 +00:00
|
|
|
// Filters settings
|
2022-12-12 22:40:10 +00:00
|
|
|
$filters = enhancePostContent::getFilters();
|
2021-11-01 09:33:43 +00:00
|
|
|
foreach ($filters as $id => $filter) {
|
2022-12-12 23:43:29 +00:00
|
|
|
// Only editable options
|
2021-08-24 20:05:23 +00:00
|
|
|
$opt = [
|
2021-10-31 22:22:34 +00:00
|
|
|
'nocase' => $filter->nocase,
|
|
|
|
'plural' => $filter->plural,
|
|
|
|
'style' => $filter->style,
|
|
|
|
'notag' => $filter->notag,
|
|
|
|
'tplValues' => $filter->tplValues,
|
2022-11-13 20:30:48 +00:00
|
|
|
'pubPages' => $filter->pubPages,
|
2021-08-24 20:05:23 +00:00
|
|
|
];
|
2022-12-12 23:43:29 +00:00
|
|
|
$s->put($id, json_encode($opt), 'string', 'Settings for ' . $id, false, true);
|
2021-11-01 09:33:43 +00:00
|
|
|
}
|
2021-08-24 20:05:23 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
} catch (Exception $e) {
|
2022-11-13 20:30:48 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-08-23 23:55:52 +00:00
|
|
|
}
|
|
|
|
|
2021-11-01 09:33:43 +00:00
|
|
|
return false;
|