Compare commits
No commits in common. "master" and "v2023.10.08" have entirely different histories.
master
...
v2023.10.0
24
CHANGELOG.md
24
CHANGELOG.md
@ -1,27 +1,3 @@
|
|||||||
enhancePostContent 2023.10.24
|
|
||||||
===========================================================
|
|
||||||
* Require Dotclear 2.28
|
|
||||||
* Require PHP 8.1
|
|
||||||
* Fix widgets
|
|
||||||
|
|
||||||
enhancePostContent 2023.10.16
|
|
||||||
===========================================================
|
|
||||||
* Require Dotclear 2.28
|
|
||||||
* Require PHP 8.1
|
|
||||||
* Code review
|
|
||||||
|
|
||||||
enhancePostContent 2023.10.13
|
|
||||||
===========================================================
|
|
||||||
* Require Dotclear 2.28
|
|
||||||
* Require PHP 8.1
|
|
||||||
* Upgrade to last minute change to Dotclear 2.28
|
|
||||||
|
|
||||||
enhancePostContent 2023.10.11
|
|
||||||
===========================================================
|
|
||||||
* Require Dotclear 2.28
|
|
||||||
* Require PHP 8.1
|
|
||||||
* Code review
|
|
||||||
|
|
||||||
enhancePostContent 2023.10.08
|
enhancePostContent 2023.10.08
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.28
|
* Require Dotclear 2.28
|
||||||
|
14
README.md
14
README.md
@ -1,7 +1,7 @@
|
|||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-2023.10.24-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/enhancePostContent/releases)
|
[![Release](https://img.shields.io/badge/release-2023.10.08-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/enhancePostContent/releases)
|
||||||
![Date](https://img.shields.io/badge/date-2023.10.24-c44d58.svg)
|
![Date](https://img.shields.io/badge/date-2023.10.08-c44d58.svg)
|
||||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
||||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/enhancePostContent)
|
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/enhancePostContent)
|
||||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/enhancePostContent/src/branch/master/LICENSE)
|
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/enhancePostContent/src/branch/master/LICENSE)
|
||||||
@ -14,10 +14,10 @@ _enhancePostContent_ is a plugin for the open-source web publishing software cal
|
|||||||
|
|
||||||
## REQUIREMENTS
|
## REQUIREMENTS
|
||||||
|
|
||||||
|
* admin permissions to set up plugin
|
||||||
|
* content admin permissions to manage fitlers
|
||||||
* Dotclear 2.28
|
* Dotclear 2.28
|
||||||
* PHP 8.1+
|
* PHP 8.1+
|
||||||
* Dotclear admin permissions to set up plugin
|
|
||||||
* Dotclear content admin permissions to manage fitlers
|
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
@ -32,6 +32,10 @@ you should also add widgets.
|
|||||||
|
|
||||||
## LINKS
|
## LINKS
|
||||||
|
|
||||||
|
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||||
|
* Source & contribution : [Gitea Page](https://git.dotclear.watch/JcDenis/enhancePostContent) or [GitHub Page](https://github.com/JcDenis/enhancePostContent)
|
||||||
|
* Packages & details: [Gitea Page](https://git.dotclear.watch/JcDenis/enhancePostContent/releases) or [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/enhancePostContent)
|
||||||
|
|
||||||
* [License](https://git.dotclear.watch/JcDenis/enhancePostContent/src/branch/master/LICENSE)
|
* [License](https://git.dotclear.watch/JcDenis/enhancePostContent/src/branch/master/LICENSE)
|
||||||
* [Packages & details](https://git.dotclear.watch/JcDenis/enhancePostContent/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/enhancePostContent))
|
* [Packages & details](https://git.dotclear.watch/JcDenis/enhancePostContent/releases) (or on [Dotaddict](https://plugins.dotaddict.org/dc2/details/enhancePostContent))
|
||||||
* [Sources & contributions](https://git.dotclear.watch/JcDenis/enhancePostContent) (or on [GitHub](https://github.com/JcDenis/enhancePostContent))
|
* [Sources & contributions](https://git.dotclear.watch/JcDenis/enhancePostContent) (or on [GitHub](https://github.com/JcDenis/enhancePostContent))
|
||||||
@ -40,6 +44,6 @@ you should also add widgets.
|
|||||||
|
|
||||||
## CONTRIBUTORS
|
## CONTRIBUTORS
|
||||||
|
|
||||||
* Jean-Christian Denis (author)
|
* Jean-Christian Denis
|
||||||
|
|
||||||
You are welcome to contribute to this code.
|
You are welcome to contribute to this code.
|
||||||
|
32
_define.php
32
_define.php
@ -1,29 +1,35 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
* @brief The plugin enhancePostContent definition
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
*
|
||||||
* @defgroup enhancePostContent Plugin enhancePostContent.
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
*
|
*
|
||||||
* Add features to words in post content.
|
* @author Jean-Christian Denis and Contributors
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use Dotclear\App;
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
'Enhance post content',
|
'Enhance post content',
|
||||||
'Add features to words in post content',
|
'Add features to words in post content',
|
||||||
'Jean-Christian Denis and Contributors',
|
'Jean-Christian Denis and Contributors',
|
||||||
'2023.10.24',
|
'2023.08.14',
|
||||||
[
|
[
|
||||||
'type' => 'plugin',
|
'requires' => [
|
||||||
'requires' => [['core', '2.28']],
|
['php', '8.1'],
|
||||||
'permissions' => 'My',
|
['core', '2.28'],
|
||||||
'settings' => [
|
],
|
||||||
'self' => '',
|
'permissions' => App::auth()->makePermissions([
|
||||||
|
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||||
|
]),
|
||||||
|
'settings' => [
|
||||||
'blog' => '#params.epc_params',
|
'blog' => '#params.epc_params',
|
||||||
],
|
],
|
||||||
|
'type' => 'plugin',
|
||||||
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
|
||||||
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',
|
||||||
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
'repository' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/raw/branch/master/dcstore.xml',
|
||||||
|
20
_init.php
Normal file
20
_init.php
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
class initEnhancePostContent
|
||||||
|
{
|
||||||
|
public const TABLE_NAME = 'epc';
|
||||||
|
}
|
@ -2,10 +2,10 @@
|
|||||||
<modules xmlns:da="http://dotaddict.org/da/">
|
<modules xmlns:da="http://dotaddict.org/da/">
|
||||||
<module id="enhancePostContent">
|
<module id="enhancePostContent">
|
||||||
<name>Enhance post content</name>
|
<name>Enhance post content</name>
|
||||||
<version>2023.10.24</version>
|
<version>2023.10.08</version>
|
||||||
<author>Jean-Christian Denis and Contributors</author>
|
<author>Jean-Christian Denis and Contributors</author>
|
||||||
<desc>Add features to words in post content</desc>
|
<desc>Add features to words in post content</desc>
|
||||||
<file>https://git.dotclear.watch/JcDenis/enhancePostContent/releases/download/v2023.10.24/plugin-enhancePostContent.zip</file>
|
<file>https://git.dotclear.watch/JcDenis/enhancePostContent/releases/download/v2023.10.08/plugin-enhancePostContent.zip</file>
|
||||||
<da:dcmin>2.28</da:dcmin>
|
<da:dcmin>2.28</da:dcmin>
|
||||||
<da:details>https://git.dotclear.watch/JcDenis/enhancePostContent/src/branch/master/README.md</da:details>
|
<da:details>https://git.dotclear.watch/JcDenis/enhancePostContent/src/branch/master/README.md</da:details>
|
||||||
<da:support>https://git.dotclear.watch/JcDenis/enhancePostContent/issues</da:support>
|
<da:support>https://git.dotclear.watch/JcDenis/enhancePostContent/issues</da:support>
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
* @brief The plugin enhancePostContent resources
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @package Dotclear
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
\Dotclear\App::backend()->resources()->set('help', 'enhancePostContent', __DIR__ . '/help/help.html');
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dcCore::app()->resources['help']['enhancePostContent'] = __DIR__ . '/help/help.html';
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* @file
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
* @brief The plugin enhancePostContent resources
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
*
|
||||||
* @author Jean-Christian Denis
|
* @package Dotclear
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
\Dotclear\App::backend()->resources()->set('help', 'enhancePostContent', __DIR__ . '/help/help.html');
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dcCore::app()->resources['help']['enhancePostContent'] = __DIR__ . '/help/help.html';
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -7,6 +17,7 @@ namespace Dotclear\Plugin\enhancePostContent;
|
|||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use Dotclear\App;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Backend\Favorites;
|
use Dotclear\Core\Backend\Favorites;
|
||||||
|
use Dotclear\Core\BlogSettings;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Helper\Html\Form\{
|
use Dotclear\Helper\Html\Form\{
|
||||||
Checkbox,
|
Checkbox,
|
||||||
@ -18,15 +29,7 @@ use Dotclear\Helper\Html\Form\{
|
|||||||
Para,
|
Para,
|
||||||
Text
|
Text
|
||||||
};
|
};
|
||||||
use Dotclear\Interface\Core\BlogSettingsInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent backend class.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Backend extends Process
|
class Backend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
@ -54,7 +57,7 @@ class Backend extends Process
|
|||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
// backend user preference form
|
// backend user preference form
|
||||||
'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void {
|
'adminBlogPreferencesFormV2' => function (BlogSettings $blog_settings): void {
|
||||||
$active = (bool) $blog_settings->get(My::id())->get('active');
|
$active = (bool) $blog_settings->get(My::id())->get('active');
|
||||||
$allowedtplvalues = Epc::blogAllowedTemplateValue();
|
$allowedtplvalues = Epc::blogAllowedTemplateValue();
|
||||||
$allowedpubpages = Epc::blogAllowedTemplatePage();
|
$allowedpubpages = Epc::blogAllowedTemplatePage();
|
||||||
@ -99,7 +102,7 @@ class Backend extends Process
|
|||||||
// allowedtplvalues
|
// allowedtplvalues
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Label(__('Allowed DC template values:'), Label::OUTSIDE_LABEL_BEFORE))->for('epc_allowedtplvalues'),
|
(new Label(__('Allowed DC template values:'), Label::OUTSIDE_LABEL_BEFORE))->for('epc_allowedtplvalues'),
|
||||||
(new Input('epc_allowedtplvalues'))->size(100)->maxlength(0)->value(Epc::encodeMulti($allowedtplvalues)),
|
(new Input('epc_allowedtplvalues'))->size(100)->maxlenght(0)->value(Epc::encodeMulti($allowedtplvalues)),
|
||||||
]),
|
]),
|
||||||
(new Note())
|
(new Note())
|
||||||
->class('form-note')
|
->class('form-note')
|
||||||
@ -107,7 +110,7 @@ class Backend extends Process
|
|||||||
// allowedpubpages
|
// allowedpubpages
|
||||||
(new Para())->items([
|
(new Para())->items([
|
||||||
(new Label(__('Allowed public pages:'), Label::OUTSIDE_LABEL_BEFORE))->for('epc_allowedpubpages'),
|
(new Label(__('Allowed public pages:'), Label::OUTSIDE_LABEL_BEFORE))->for('epc_allowedpubpages'),
|
||||||
(new Input('epc_allowedpubpages'))->size(100)->maxlength(0)->value(Epc::encodeMulti($allowedpubpages)),
|
(new Input('epc_allowedpubpages'))->size(100)->maxlenght(0)->value(Epc::encodeMulti($allowedpubpages)),
|
||||||
]),
|
]),
|
||||||
(new Note())
|
(new Note())
|
||||||
->class('form-note')
|
->class('form-note')
|
||||||
@ -120,7 +123,7 @@ class Backend extends Process
|
|||||||
->render();
|
->render();
|
||||||
},
|
},
|
||||||
// backend user preference save
|
// backend user preference save
|
||||||
'adminBeforeBlogSettingsUpdate' => function (BlogSettingsInterface $blog_settings): void {
|
'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void {
|
||||||
$active = !empty($_POST['epc_active']);
|
$active = !empty($_POST['epc_active']);
|
||||||
$allowedtplvalues = Epc::decodeMulti($_POST['epc_allowedtplvalues']);
|
$allowedtplvalues = Epc::decodeMulti($_POST['epc_allowedtplvalues']);
|
||||||
$allowedpubpages = Epc::decodeMulti($_POST['epc_allowedpubpages']);
|
$allowedpubpages = Epc::decodeMulti($_POST['epc_allowedpubpages']);
|
||||||
@ -145,7 +148,7 @@ class Backend extends Process
|
|||||||
];
|
];
|
||||||
},
|
},
|
||||||
// widgets registration
|
// widgets registration
|
||||||
'initWidgets' => Widgets::initWidgets(...),
|
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -14,11 +24,7 @@ use Dotclear\Helper\Html\Form\Checkbox;
|
|||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief enhancePostContent filters list class.
|
* Backend filters values list.
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
*/
|
||||||
class BackendList extends Listing
|
class BackendList extends Listing
|
||||||
{
|
{
|
||||||
@ -37,7 +43,7 @@ class BackendList extends Listing
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$pager = new Pager($filter->value('page'), (int) $this->rs_count, $filter->value('nb'), 10);
|
$pager = new Pager($filter->value('page'), $this->rs_count, $filter->value('nb'), 10);
|
||||||
$pager->base_url = $url;
|
$pager->base_url = $url;
|
||||||
|
|
||||||
$epc_id = [];
|
$epc_id = [];
|
||||||
@ -65,7 +71,7 @@ class BackendList extends Listing
|
|||||||
echo $pager->getLinks() . $blocks[0];
|
echo $pager->getLinks() . $blocks[0];
|
||||||
|
|
||||||
while ($this->rs->fetch()) {
|
while ($this->rs->fetch()) {
|
||||||
$this->line(isset($epc_id[$this->rs->f('epc_id')]));
|
$this->line(isset($epc_id[$this->rs->epc_id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $blocks[1] . $blocks[2] . $pager->getLinks();
|
echo $blocks[1] . $blocks[2] . $pager->getLinks();
|
||||||
@ -79,14 +85,14 @@ class BackendList extends Listing
|
|||||||
private function line(bool $checked): void
|
private function line(bool $checked): void
|
||||||
{
|
{
|
||||||
$cols = [
|
$cols = [
|
||||||
'check' => '<td class="nowrap">' . (new Checkbox(['epc_id[]'], $checked))->value($this->rs->f('epc_id'))->render() . '</td>',
|
'check' => '<td class="nowrap">' . (new Checkbox(['epc_id[]'], $checked))->value($this->rs->epc_id)->render() . '</td>',
|
||||||
'key' => '<td class="nowrap">' . Html::escapeHTML($this->rs->f('epc_key')) . '</td>',
|
'key' => '<td class="nowrap">' . Html::escapeHTML($this->rs->epc_key) . '</td>',
|
||||||
'value' => '<td class="maximal">' . Html::escapeHTML($this->rs->f('epc_value')) . '</td>',
|
'value' => '<td class="maximal">' . Html::escapeHTML($this->rs->epc_value) . '</td>',
|
||||||
'date' => '<td class="nowrap count">' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('epc_upddt')) . '</td>',
|
'date' => '<td class="nowrap count">' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->epc_upddt) . '</td>',
|
||||||
];
|
];
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<tr class="line" id="p' . $this->rs->f('epc_id') . '">' .
|
'<tr class="line" id="p' . $this->rs->epc_id . '">' .
|
||||||
implode($cols) .
|
implode($cols) .
|
||||||
'</tr>';
|
'</tr>';
|
||||||
}
|
}
|
||||||
|
90
src/Epc.php
90
src/Epc.php
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -21,59 +31,15 @@ __('search results page');
|
|||||||
__('atom feeds');
|
__('atom feeds');
|
||||||
__('RSS feeds');
|
__('RSS feeds');
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent main class.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Epc
|
class Epc
|
||||||
{
|
{
|
||||||
/**
|
/** @var string The temporary pattern to tag words to replace */
|
||||||
* Plugin table name.
|
|
||||||
*
|
|
||||||
* @var string TABLE_NAME
|
|
||||||
*/
|
|
||||||
public const TABLE_NAME = 'epc';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Distributed filters.
|
|
||||||
*
|
|
||||||
* @var array<int,string> DEFAULT_FILTERS
|
|
||||||
*/
|
|
||||||
public const DEFAULT_FILTERS = [
|
|
||||||
Filter\EpcFilterTag::class,
|
|
||||||
Filter\EpcFilterSearch::class,
|
|
||||||
Filter\EpcFilterAcronym::class,
|
|
||||||
Filter\EpcFilterAbbreviation::class,
|
|
||||||
Filter\EpcFilterDefinition::class,
|
|
||||||
Filter\EpcFilterCitation::class,
|
|
||||||
Filter\EpcFilterLink::class,
|
|
||||||
Filter\EpcFilterReplace::class,
|
|
||||||
Filter\EpcFilterUpdate::class,
|
|
||||||
Filter\EpcFilterTwitter::class,
|
|
||||||
];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The temporary pattern to tag words to replace.
|
|
||||||
*
|
|
||||||
* @var string FLAGGER
|
|
||||||
*/
|
|
||||||
public const FLAGGER = 'ççççç%sççççç';
|
public const FLAGGER = 'ççççç%sççççç';
|
||||||
|
|
||||||
/**
|
/** @var EpcFilters $filters THe filters stack */
|
||||||
* The filters stack.
|
|
||||||
*
|
|
||||||
* @var EpcFilters $filters
|
|
||||||
*/
|
|
||||||
private static EpcFilters $filters;
|
private static EpcFilters $filters;
|
||||||
|
|
||||||
/**
|
/** @var array<string,int> $limits The replacment limit per filtre */
|
||||||
* The replacment limit per filtre.
|
|
||||||
*
|
|
||||||
* @var array<string,int> $limits
|
|
||||||
*/
|
|
||||||
private static array $limits = [];
|
private static array $limits = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,22 +76,22 @@ class Epc
|
|||||||
/**
|
/**
|
||||||
* Get list of allowed templates name->[tag,callback] to list on epc widgets.
|
* Get list of allowed templates name->[tag,callback] to list on epc widgets.
|
||||||
*
|
*
|
||||||
* @return array<string, array<string, mixed>> The templates name->[id,cb] values
|
* @return array The templates name->[id,cb] values
|
||||||
*/
|
*/
|
||||||
public static function widgetAllowedTemplateValue(): array
|
public static function widgetAllowedTemplateValue(): array
|
||||||
{
|
{
|
||||||
$list = new ArrayObject([
|
$list = new ArrayObject([
|
||||||
'entry excerpt' => [
|
'entry excerpt' => [
|
||||||
'id' => 'entryexcerpt',
|
'id' => 'entryexcerpt',
|
||||||
'cb' => self::widgetContentEntryExcerpt(...),
|
'cb' => [self::class, 'widgetContentEntryExcerpt'],
|
||||||
],
|
],
|
||||||
'entry content' => [
|
'entry content' => [
|
||||||
'id' => 'entrycontent',
|
'id' => 'entrycontent',
|
||||||
'cb' => self::widgetContentEntryContent(...),
|
'cb' => [self::class, 'widgetContentEntryContent'],
|
||||||
],
|
],
|
||||||
'comment content' => [
|
'comment content' => [
|
||||||
'id' => 'commentcontent',
|
'id' => 'commentcontent',
|
||||||
'cb' => self::widgetContentCommentContent(...),
|
'cb' => [self::class, 'widgetContentCommentContent'],
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@ -409,13 +375,13 @@ class Epc
|
|||||||
*/
|
*/
|
||||||
public static function widgetContentEntryExcerpt(?WidgetsElement $widget = null): string
|
public static function widgetContentEntryExcerpt(?WidgetsElement $widget = null): string
|
||||||
{
|
{
|
||||||
if (!App::frontend()->context()->exists('posts')) {
|
if (!App::frontend()->ctx->exists('posts')) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = '';
|
$content = '';
|
||||||
while (App::frontend()->context()->__get('posts')?->fetch()) {
|
while (App::frontend()->ctx->__get('posts')?->fetch()) {
|
||||||
$content .= App::frontend()->context()->__get('posts')->f('post_excerpt');
|
$content .= App::frontend()->__get('posts')->f('post_excerpt');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
@ -430,13 +396,13 @@ class Epc
|
|||||||
*/
|
*/
|
||||||
public static function widgetContentEntryContent(?WidgetsElement $widget = null): string
|
public static function widgetContentEntryContent(?WidgetsElement $widget = null): string
|
||||||
{
|
{
|
||||||
if (!App::frontend()->context()->exists('posts')) {
|
if (!App::frontend()->ctx->exists('posts')) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = '';
|
$content = '';
|
||||||
while (App::frontend()->context()->__get('posts')?->fetch()) {
|
while (App::frontend()->ctx->__get('posts')?->fetch()) {
|
||||||
$content .= App::frontend()->context()->__get('posts')->f('post_content');
|
$content .= dApp::frontend()->ctx->__get('posts')->f('post_content');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
@ -451,14 +417,14 @@ class Epc
|
|||||||
*/
|
*/
|
||||||
public static function widgetContentCommentContent(?WidgetsElement $widget = null): string
|
public static function widgetContentCommentContent(?WidgetsElement $widget = null): string
|
||||||
{
|
{
|
||||||
if (!App::frontend()->context()->exists('posts')) {
|
if (!App::frontend()->ctx->exists('posts')) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = '';
|
$content = '';
|
||||||
while (App::frontend()->context()->__get('posts')->fetch()) {
|
while (App::frontend()->ctx->__get('posts')?->fetch()) {
|
||||||
$comments = App::blog()->getComments(['post_id' => App::frontend()->context()->__get('posts')->f('post_id')]);
|
$comments = App::blog()->getComments(['post_id' => App::frontend()->ctx->__get('posts')->f('post_id')]);
|
||||||
while ($comments->fetch()) {
|
while ($comments?->fetch()) {
|
||||||
$content .= $comments->__call('getContent', []);
|
$content .= $comments->__call('getContent', []);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -10,13 +20,9 @@ use Dotclear\Plugin\widgets\WidgetsElement;
|
|||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief enhancePostContent abstract filter class.
|
* Filter abstract class.
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
*
|
||||||
* All filter must extends this class.
|
* All filter must extends this class.
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
*/
|
||||||
abstract class EpcFilter
|
abstract class EpcFilter
|
||||||
{
|
{
|
||||||
@ -38,10 +44,10 @@ abstract class EpcFilter
|
|||||||
/** @var bool $has_list Filter has list of records (property) */
|
/** @var bool $has_list Filter has list of records (property) */
|
||||||
public readonly bool $has_list;
|
public readonly bool $has_list;
|
||||||
|
|
||||||
/** @var array<int,string> $ignore The filter disabled html tags (property) */
|
/** @var array $ignore The filter disabled html tags (property) */
|
||||||
public readonly array $ignore;
|
public readonly array $ignore;
|
||||||
|
|
||||||
/** @var array<int,string> $class The css class that apply to filter (property) */
|
/** @var array $class The css class that apply to filter (property) */
|
||||||
public readonly array $class;
|
public readonly array $class;
|
||||||
|
|
||||||
/** @var string $replace The filter replacement bloc in content (property) */
|
/** @var string $replace The filter replacement bloc in content (property) */
|
||||||
@ -59,16 +65,16 @@ abstract class EpcFilter
|
|||||||
/** @var bool $plural The replacement limit per filter (settings) */
|
/** @var bool $plural The replacement limit per filter (settings) */
|
||||||
public readonly int $limit;
|
public readonly int $limit;
|
||||||
|
|
||||||
/** @var array<int,string> $style The style applied to filter class (settings) */
|
/** @var array $style The style applied to filter class (settings) */
|
||||||
public readonly array $style;
|
public readonly array $style;
|
||||||
|
|
||||||
/** @var array<int,string> $notag The filter disabled html tags (settings) */
|
/** @var array $notag The filter disabled html tags (settings) */
|
||||||
public readonly array $notag;
|
public readonly array $notag;
|
||||||
|
|
||||||
/** @var array<int,string> $template The extra template value to scan (settings) */
|
/** @var array $template The extra template value to scan (settings) */
|
||||||
public readonly array $template;
|
public readonly array $template;
|
||||||
|
|
||||||
/** @var array<int,string> $page The extra frontend pages to scan (settings) */
|
/** @var array $page The extra frontend pages to scan (settings) */
|
||||||
public readonly array $page;
|
public readonly array $page;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,25 +1,27 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief enhancePostContent filters stack.
|
* Filters stack.
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
*
|
||||||
* Use Epc::getFilters() to get loaded stack
|
* Use Epc::getFilters() to get loaded stack
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
*/
|
||||||
class EpcFilters
|
class EpcFilters
|
||||||
{
|
{
|
||||||
/**
|
/** @var array<int,EpcFilter> $satck The filters stack */
|
||||||
* The filters stack.
|
|
||||||
*
|
|
||||||
* @var array<int, EpcFilter> $stack
|
|
||||||
*/
|
|
||||||
private array $stack = [];
|
private array $stack = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -12,11 +22,7 @@ use Dotclear\Database\{
|
|||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief enhancePostContent filters records.
|
* Filter records.
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
*/
|
||||||
class EpcRecord
|
class EpcRecord
|
||||||
{
|
{
|
||||||
@ -42,7 +48,7 @@ class EpcRecord
|
|||||||
'E.epc_filter, E.epc_key, E.epc_value ';
|
'E.epc_filter, E.epc_key, E.epc_value ';
|
||||||
}
|
}
|
||||||
|
|
||||||
$strReq .= 'FROM ' . App::con()->prefix() . Epc::TABLE_NAME . ' E ';
|
$strReq .= 'FROM ' . App::con()->prefix() . My::TABLE_NAME . ' E ';
|
||||||
|
|
||||||
if (!empty($params['from'])) {
|
if (!empty($params['from'])) {
|
||||||
$strReq .= $params['from'] . ' ';
|
$strReq .= $params['from'] . ' ';
|
||||||
@ -115,7 +121,7 @@ class EpcRecord
|
|||||||
*/
|
*/
|
||||||
public static function addRecord(Cursor $cur): int
|
public static function addRecord(Cursor $cur): int
|
||||||
{
|
{
|
||||||
App::con()->writeLock(App::con()->prefix() . Epc::TABLE_NAME);
|
App::con()->writeLock(App::con()->prefix() . My::TABLE_NAME);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$cur->setField('epc_id', self::getNextId());
|
$cur->setField('epc_id', self::getNextId());
|
||||||
@ -193,7 +199,7 @@ class EpcRecord
|
|||||||
App::behavior()->callBehavior('enhancePostContentbeforeDelRecord', $id);
|
App::behavior()->callBehavior('enhancePostContentbeforeDelRecord', $id);
|
||||||
|
|
||||||
App::con()->execute(
|
App::con()->execute(
|
||||||
'DELETE FROM ' . App::con()->prefix() . Epc::TABLE_NAME . ' ' .
|
'DELETE FROM ' . App::con()->prefix() . My::TABLE_NAME . ' ' .
|
||||||
'WHERE epc_id = ' . $id . ' ' .
|
'WHERE epc_id = ' . $id . ' ' .
|
||||||
"AND blog_id = '" . App::con()->escapeStr(App::blog()->id()) . "' "
|
"AND blog_id = '" . App::con()->escapeStr(App::blog()->id()) . "' "
|
||||||
);
|
);
|
||||||
@ -209,7 +215,7 @@ class EpcRecord
|
|||||||
private static function getNextId(): int
|
private static function getNextId(): int
|
||||||
{
|
{
|
||||||
return (int) App::con()->select(
|
return (int) App::con()->select(
|
||||||
'SELECT MAX(epc_id) FROM ' . App::con()->prefix() . Epc::TABLE_NAME . ' '
|
'SELECT MAX(epc_id) FROM ' . App::con()->prefix() . My::TABLE_NAME . ' '
|
||||||
)->f(0) + 1;
|
)->f(0) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +226,7 @@ class EpcRecord
|
|||||||
*/
|
*/
|
||||||
public static function openCursor(): Cursor
|
public static function openCursor(): Cursor
|
||||||
{
|
{
|
||||||
return App::con()->openCursor(App::con()->prefix() . Epc::TABLE_NAME);
|
return App::con()->openCursor(App::con()->prefix() . My::TABLE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
||||||
@ -9,14 +19,6 @@ use Dotclear\Plugin\enhancePostContent\Epc;
|
|||||||
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent abbreviation filter.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class EpcFilterAbbreviation extends EpcFilter
|
class EpcFilterAbbreviation extends EpcFilter
|
||||||
{
|
{
|
||||||
protected string $id = 'abbreviation';
|
protected string $id = 'abbreviation';
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
||||||
@ -9,14 +19,6 @@ use Dotclear\Plugin\enhancePostContent\Epc;
|
|||||||
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent acronym filter.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class EpcFilterAcronym extends EpcFilter
|
class EpcFilterAcronym extends EpcFilter
|
||||||
{
|
{
|
||||||
protected string $id = 'acronym';
|
protected string $id = 'acronym';
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
||||||
@ -9,14 +19,6 @@ use Dotclear\Plugin\enhancePostContent\Epc;
|
|||||||
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent citaion filter.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class EpcFilterCitation extends EpcFilter
|
class EpcFilterCitation extends EpcFilter
|
||||||
{
|
{
|
||||||
protected string $id = 'citation';
|
protected string $id = 'citation';
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
||||||
@ -9,14 +19,6 @@ use Dotclear\Plugin\enhancePostContent\Epc;
|
|||||||
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent definition filter.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class EpcFilterDefinition extends EpcFilter
|
class EpcFilterDefinition extends EpcFilter
|
||||||
{
|
{
|
||||||
protected string $id = 'definition';
|
protected string $id = 'definition';
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
||||||
@ -9,14 +19,6 @@ use Dotclear\Plugin\enhancePostContent\Epc;
|
|||||||
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent link filter.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class EpcFilterLink extends EpcFilter
|
class EpcFilterLink extends EpcFilter
|
||||||
{
|
{
|
||||||
protected string $id = 'link';
|
protected string $id = 'link';
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
||||||
@ -7,14 +17,6 @@ namespace Dotclear\Plugin\enhancePostContent\Filter;
|
|||||||
use Dotclear\Plugin\enhancePostContent\Epc;
|
use Dotclear\Plugin\enhancePostContent\Epc;
|
||||||
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent replacement filter.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class EpcFilterReplace extends EpcFilter
|
class EpcFilterReplace extends EpcFilter
|
||||||
{
|
{
|
||||||
protected string $id = 'replace';
|
protected string $id = 'replace';
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
||||||
@ -8,14 +18,6 @@ use Dotclear\App;
|
|||||||
use Dotclear\Plugin\enhancePostContent\Epc;
|
use Dotclear\Plugin\enhancePostContent\Epc;
|
||||||
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent search filter.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class EpcFilterSearch extends EpcFilter
|
class EpcFilterSearch extends EpcFilter
|
||||||
{
|
{
|
||||||
protected string $id = 'search';
|
protected string $id = 'search';
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
||||||
@ -10,14 +20,6 @@ use Dotclear\Plugin\enhancePostContent\Epc;
|
|||||||
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent tag filter.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class EpcFilterTag extends EpcFilter
|
class EpcFilterTag extends EpcFilter
|
||||||
{
|
{
|
||||||
protected string $id = 'tag';
|
protected string $id = 'tag';
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
||||||
@ -7,14 +17,6 @@ namespace Dotclear\Plugin\enhancePostContent\Filter;
|
|||||||
use Dotclear\Plugin\enhancePostContent\Epc;
|
use Dotclear\Plugin\enhancePostContent\Epc;
|
||||||
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent twitter filter.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class EpcFilterTwitter extends EpcFilter
|
class EpcFilterTwitter extends EpcFilter
|
||||||
{
|
{
|
||||||
protected string $id = 'twitter';
|
protected string $id = 'twitter';
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
||||||
@ -7,14 +17,6 @@ namespace Dotclear\Plugin\enhancePostContent\Filter;
|
|||||||
use Dotclear\Plugin\enhancePostContent\Epc;
|
use Dotclear\Plugin\enhancePostContent\Epc;
|
||||||
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent update filter.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class EpcFilterUpdate extends EpcFilter
|
class EpcFilterUpdate extends EpcFilter
|
||||||
{
|
{
|
||||||
protected string $id = 'update';
|
protected string $id = 'update';
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -7,13 +17,6 @@ namespace Dotclear\Plugin\enhancePostContent;
|
|||||||
use Dotclear\App;
|
use Dotclear\App;
|
||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent frontend class.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Frontend extends Process
|
class Frontend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
@ -36,7 +39,7 @@ class Frontend extends Process
|
|||||||
'publicBeforeContentFilterV2' => function (string $tag, array $args): void {
|
'publicBeforeContentFilterV2' => function (string $tag, array $args): void {
|
||||||
foreach (Epc::getFilters()->dump() as $filter) {
|
foreach (Epc::getFilters()->dump() as $filter) {
|
||||||
// test context
|
// test context
|
||||||
if (in_array((string) App::frontend()->context()->__get('current_tpl'), $filter->page)
|
if (in_array((string) App::frontend()->ctx->__get('current_tpl'), $filter->page)
|
||||||
&& in_array($tag, $filter->template)
|
&& in_array($tag, $filter->template)
|
||||||
&& $args[0] != '' //content
|
&& $args[0] != '' //content
|
||||||
&& empty($args['encode_xml'])
|
&& empty($args['encode_xml'])
|
||||||
@ -49,7 +52,7 @@ class Frontend extends Process
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Widgets
|
// Widgets
|
||||||
'initWidgets' => Widgets::initWidgets(...),
|
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -9,13 +19,6 @@ use Dotclear\Core\Process;
|
|||||||
use Dotclear\Database\Structure;
|
use Dotclear\Database\Structure;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent installation class.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Install extends Process
|
class Install extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
@ -32,7 +35,7 @@ class Install extends Process
|
|||||||
try {
|
try {
|
||||||
// Database
|
// Database
|
||||||
$s = new Structure(App::con(), App::con()->prefix());
|
$s = new Structure(App::con(), App::con()->prefix());
|
||||||
$s->__get(Epc::TABLE_NAME)
|
$s->__get(My::TABLE_NAME)
|
||||||
->field('epc_id', 'bigint', 0, false)
|
->field('epc_id', 'bigint', 0, false)
|
||||||
->field('blog_id', 'varchar', 32, false)
|
->field('blog_id', 'varchar', 32, false)
|
||||||
->field('epc_type', 'varchar', 32, false, "'epc'")
|
->field('epc_type', 'varchar', 32, false, "'epc'")
|
||||||
@ -121,10 +124,10 @@ class Install extends Process
|
|||||||
$curlist = @unserialize($record->f('setting_value'));
|
$curlist = @unserialize($record->f('setting_value'));
|
||||||
if (is_array($curlist)) {
|
if (is_array($curlist)) {
|
||||||
foreach ($curlist as $k => $v) {
|
foreach ($curlist as $k => $v) {
|
||||||
$cur = App::con()->openCursor(App::con()->prefix() . Epc::TABLE_NAME);
|
$cur = App::con()->openCursor(App::con()->prefix() . My::TABLE_NAME);
|
||||||
App::con()->writeLock(App::con()->prefix() . Epc::TABLE_NAME);
|
App::con()->writeLock(App::con()->prefix() . My::TABLE_NAME);
|
||||||
|
|
||||||
$cur->setField('epc_id', (int) App::con()->select('SELECT MAX(epc_id) FROM ' . App::con()->prefix() . Epc::TABLE_NAME . ' ')->f(0) + 1);
|
$cur->setField('epc_id', (int) App::con()->select('SELECT MAX(epc_id) FROM ' . App::con()->prefix() . My::TABLE_NAME . ' ')->f(0) + 1);
|
||||||
$cur->setField('blog_id', $record->f('blog_id'));
|
$cur->setField('blog_id', $record->f('blog_id'));
|
||||||
$cur->setField('epc_filter', strtolower($m[1]));
|
$cur->setField('epc_filter', strtolower($m[1]));
|
||||||
$cur->setField('epc_key', $k);
|
$cur->setField('epc_key', $k);
|
||||||
@ -147,9 +150,9 @@ class Install extends Process
|
|||||||
private static function upTo20211006(): void
|
private static function upTo20211006(): void
|
||||||
{
|
{
|
||||||
# Move old filter name to filter id
|
# Move old filter name to filter id
|
||||||
$record = App::con()->select('SELECT epc_id, epc_filter FROM ' . App::con()->prefix() . Epc::TABLE_NAME);
|
$record = App::con()->select('SELECT epc_id, epc_filter FROM ' . App::con()->prefix() . My::TABLE_NAME);
|
||||||
while ($record->fetch()) {
|
while ($record->fetch()) {
|
||||||
$cur = App::con()->openCursor(App::con()->prefix() . Epc::TABLE_NAME);
|
$cur = App::con()->openCursor(App::con()->prefix() . My::TABLE_NAME);
|
||||||
|
|
||||||
$cur->setField('epc_filter', strtolower($record->f('epc_filter')));
|
$cur->setField('epc_filter', strtolower($record->f('epc_filter')));
|
||||||
|
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -32,13 +42,6 @@ use Dotclear\Helper\Html\Html;
|
|||||||
use Dotclear\Helper\Network\Http;
|
use Dotclear\Helper\Network\Http;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent manage class.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Manage extends Process
|
class Manage extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
@ -265,7 +268,7 @@ class Manage extends Process
|
|||||||
->for('filter_style' . $k),
|
->for('filter_style' . $k),
|
||||||
(new Input(['filter_style[]', 'filter_style' . $k]))
|
(new Input(['filter_style[]', 'filter_style' . $k]))
|
||||||
->size(60)
|
->size(60)
|
||||||
->maxlength(255)
|
->maxlenght(255)
|
||||||
->value(Html::escapeHTML($filter->style[$k])),
|
->value(Html::escapeHTML($filter->style[$k])),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
@ -337,7 +340,7 @@ class Manage extends Process
|
|||||||
->for('filter_notag'),
|
->for('filter_notag'),
|
||||||
(new Input('filter_notag'))
|
(new Input('filter_notag'))
|
||||||
->size(60)
|
->size(60)
|
||||||
->maxlength(255)
|
->maxlenght(255)
|
||||||
->value(Epc::encodeSingle($filter->notag)),
|
->value(Epc::encodeSingle($filter->notag)),
|
||||||
]),
|
]),
|
||||||
(new Note())
|
(new Note())
|
||||||
@ -406,7 +409,7 @@ class Manage extends Process
|
|||||||
->for('new_key'),
|
->for('new_key'),
|
||||||
(new Input('new_key'))
|
(new Input('new_key'))
|
||||||
->size(60)
|
->size(60)
|
||||||
->maxlength(255)
|
->maxlenght(255)
|
||||||
->required(true),
|
->required(true),
|
||||||
]),
|
]),
|
||||||
(new Para())
|
(new Para())
|
||||||
@ -415,7 +418,7 @@ class Manage extends Process
|
|||||||
->for('new_value'),
|
->for('new_value'),
|
||||||
(new Input('new_value'))
|
(new Input('new_value'))
|
||||||
->size(60)
|
->size(60)
|
||||||
->maxlength(255)
|
->maxlenght(255)
|
||||||
->required(true),
|
->required(true),
|
||||||
]),
|
]),
|
||||||
(new Para())
|
(new Para())
|
||||||
|
45
src/My.php
45
src/My.php
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -8,23 +18,32 @@ use Dotclear\App;
|
|||||||
use Dotclear\Module\MyPlugin;
|
use Dotclear\Module\MyPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief enhancePostContent My helper.
|
* This module definitions.
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
*/
|
||||||
class My extends MyPlugin
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
|
/** @var string Plugin table name */
|
||||||
|
public const TABLE_NAME = 'epc';
|
||||||
|
|
||||||
|
/** @var array Distributed filters */
|
||||||
|
public const DEFAULT_FILTERS = [
|
||||||
|
Filter\EpcFilterTag::class,
|
||||||
|
Filter\EpcFilterSearch::class,
|
||||||
|
Filter\EpcFilterAcronym::class,
|
||||||
|
Filter\EpcFilterAbbreviation::class,
|
||||||
|
Filter\EpcFilterDefinition::class,
|
||||||
|
Filter\EpcFilterCitation::class,
|
||||||
|
Filter\EpcFilterLink::class,
|
||||||
|
Filter\EpcFilterReplace::class,
|
||||||
|
Filter\EpcFilterUpdate::class,
|
||||||
|
Filter\EpcFilterTwitter::class,
|
||||||
|
];
|
||||||
|
|
||||||
public static function checkCustomContext(int $context): ?bool
|
public static function checkCustomContext(int $context): ?bool
|
||||||
{
|
{
|
||||||
return match ($context) {
|
return !in_array($context, [My::BACKEND, My::MANAGE, My::MENU]) ? null :
|
||||||
// Limit main backend featrues to content admin
|
App::auth()->check(App::auth()->makePermissions([
|
||||||
self::BACKEND, self::MANAGE, self::MENU => App::auth()->check(App::auth()->makePermissions([
|
|
||||||
App::auth()::PERMISSION_CONTENT_ADMIN,
|
App::auth()::PERMISSION_CONTENT_ADMIN,
|
||||||
]), App::blog()->id()),
|
]), App::blog()->id());
|
||||||
|
|
||||||
default => null,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -8,13 +18,6 @@ use Dotclear\App;
|
|||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Helper\Html\Html;
|
use Dotclear\Helper\Html\Html;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent prepend class.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Prepend extends Process
|
class Prepend extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
@ -29,8 +32,8 @@ class Prepend extends Process
|
|||||||
}
|
}
|
||||||
|
|
||||||
// register epc filters
|
// register epc filters
|
||||||
App::behavior()->addBehavior('enhancePostContentFilters', function (EpcFilters $stack): void {
|
app::behavior()->addBehavior('enhancePostContentFilters', function (EpcFilters $stack): void {
|
||||||
foreach (Epc::DEFAULT_FILTERS as $class) {
|
foreach (My::DEFAULT_FILTERS as $class) {
|
||||||
$stack->add(new $class());
|
$stack->add(new $class());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -7,13 +17,6 @@ namespace Dotclear\Plugin\enhancePostContent;
|
|||||||
use Dotclear\Core\Process;
|
use Dotclear\Core\Process;
|
||||||
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief enhancePostContent uninstall class.
|
|
||||||
* @ingroup enhancePostContent
|
|
||||||
*
|
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
|
||||||
class Uninstall extends Process
|
class Uninstall extends Process
|
||||||
{
|
{
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
@ -36,7 +39,7 @@ class Uninstall extends Process
|
|||||||
->addUserAction(
|
->addUserAction(
|
||||||
'tables',
|
'tables',
|
||||||
'delete',
|
'delete',
|
||||||
Epc::TABLE_NAME
|
My::TABLE_NAME
|
||||||
)
|
)
|
||||||
->addUserAction(
|
->addUserAction(
|
||||||
'plugins',
|
'plugins',
|
||||||
@ -56,7 +59,7 @@ class Uninstall extends Process
|
|||||||
->addDirectAction(
|
->addDirectAction(
|
||||||
'tables',
|
'tables',
|
||||||
'delete',
|
'delete',
|
||||||
Epc::TABLE_NAME
|
My::TABLE_NAME
|
||||||
)
|
)
|
||||||
->addDirectAction(
|
->addDirectAction(
|
||||||
'plugins',
|
'plugins',
|
||||||
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/**
|
||||||
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||||
|
*
|
||||||
|
* @package Dotclear
|
||||||
|
* @subpackage Plugin
|
||||||
|
*
|
||||||
|
* @author Jean-Christian Denis and Contributors
|
||||||
|
*
|
||||||
|
* @copyright Jean-Christian Denis
|
||||||
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*/
|
||||||
declare(strict_types=1);
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace Dotclear\Plugin\enhancePostContent;
|
namespace Dotclear\Plugin\enhancePostContent;
|
||||||
@ -11,11 +21,9 @@ use Dotclear\Plugin\widgets\WidgetsStack;
|
|||||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief enhancePostContent widgets class.
|
* @ingroup DC_PLUGIN_ENHANCEPOSTCONTENT
|
||||||
* @ingroup enhancePostContent
|
* @brief Filter posts content - widgets methods.
|
||||||
*
|
* @since 2.6
|
||||||
* @author Jean-Christian Denis
|
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
||||||
*/
|
*/
|
||||||
class Widgets
|
class Widgets
|
||||||
{
|
{
|
||||||
@ -29,7 +37,7 @@ class Widgets
|
|||||||
$w->create(
|
$w->create(
|
||||||
'epclist',
|
'epclist',
|
||||||
My::name(),
|
My::name(),
|
||||||
self::parseWidget(...),
|
[self::class, 'parseWidget'],
|
||||||
null,
|
null,
|
||||||
__('List filtered contents.')
|
__('List filtered contents.')
|
||||||
);
|
);
|
||||||
@ -86,7 +94,7 @@ class Widgets
|
|||||||
|
|
||||||
# Page
|
# Page
|
||||||
if (!My::settings()->get('active')
|
if (!My::settings()->get('active')
|
||||||
|| !in_array(App::frontend()->context()->__get('current_tpl'), ['post.html', 'page.html'])
|
|| !in_array(App::frontend()->ctx->__get('current_tpl'), ['post.html', 'page.html'])
|
||||||
) {
|
) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user