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
|
|
|
|
*/
|
2023-04-09 08:17:36 +00:00
|
|
|
declare(strict_types=1);
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2023-04-09 08:17:36 +00:00
|
|
|
namespace Dotclear\Plugin\enhancePostContent;
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2023-04-09 08:17:36 +00:00
|
|
|
use dcCore;
|
|
|
|
use dcNsProcess;
|
|
|
|
use dcUtils;
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2023-04-09 08:17:36 +00:00
|
|
|
class Frontend extends dcNsProcess
|
|
|
|
{
|
|
|
|
public static function init(): bool
|
|
|
|
{
|
|
|
|
static::$init = My::phpCompliant();
|
|
|
|
|
|
|
|
return static::$init;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function process(): bool
|
|
|
|
{
|
|
|
|
if (!static::$init) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2023-04-09 08:17:36 +00:00
|
|
|
if (!dcCore::app()->blog->settings->get(My::id())->get('active')) {
|
|
|
|
return null;
|
2021-08-24 20:05:23 +00:00
|
|
|
}
|
2023-04-09 08:17:36 +00:00
|
|
|
|
|
|
|
dcCore::app()->addBehaviors([
|
|
|
|
// add CSS URL to header
|
|
|
|
'publicHeadContent' => function (): void {
|
|
|
|
echo dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('epccss'));
|
|
|
|
},
|
|
|
|
// Filter template blocks content
|
|
|
|
'publicBeforeContentFilterV2' => function (string $tag, array $args): void {
|
|
|
|
$filters = Epc::getFilters();
|
|
|
|
|
|
|
|
foreach ($filters as $id => $filter) {
|
|
|
|
if (!Epc::testContext($tag, $args, $filter)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$filter->publicContent($tag, $args);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// Widgets
|
|
|
|
'initWidgets' => [Widgets::class, 'initWidgets'],
|
|
|
|
]);
|
|
|
|
|
|
|
|
return true;
|
2021-08-24 20:05:23 +00:00
|
|
|
}
|
2023-04-09 08:17:36 +00:00
|
|
|
}
|