2022-12-21 21:27:20 +00:00
|
|
|
<?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
|
|
|
|
*/
|
2023-04-09 08:17:36 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Dotclear\Plugin\enhancePostContent\Filter;
|
|
|
|
|
|
|
|
use Dotclear\Plugin\enhancePostContent\Epc;
|
|
|
|
use Dotclear\Plugin\enhancePostContent\EpcFilter;
|
|
|
|
use Dotclear\Plugin\widgets\WidgetsElement;
|
2022-12-21 21:27:20 +00:00
|
|
|
|
2023-04-09 08:17:36 +00:00
|
|
|
class EpcFilterCitation extends EpcFilter
|
2022-12-21 21:27:20 +00:00
|
|
|
{
|
|
|
|
protected function init(): string
|
|
|
|
{
|
|
|
|
$this->setProperties([
|
|
|
|
'priority' => 600,
|
|
|
|
'name' => __('Citation'),
|
|
|
|
'help' => __('Highlight citation of people. First term of the list is the citation and second term the author.'),
|
|
|
|
'has_list' => true,
|
|
|
|
'htmltag' => 'cite',
|
|
|
|
'class' => ['cite.epc-cite'],
|
|
|
|
'replace' => '<cite class="epc-cite" title="%s">%s</cite>',
|
|
|
|
'widget' => '<cite title="%s">%s</cite>',
|
|
|
|
]);
|
|
|
|
|
|
|
|
$this->setSettings([
|
|
|
|
'nocase' => true,
|
|
|
|
'style' => ['font-style: italic;'],
|
|
|
|
'notag' => 'a,h1,h2,h3',
|
|
|
|
'tplValues' => ['EntryContent'],
|
|
|
|
'pubPages' => ['post.html'],
|
|
|
|
]);
|
|
|
|
|
|
|
|
return 'citation';
|
|
|
|
}
|
|
|
|
|
2023-04-09 08:17:36 +00:00
|
|
|
public function publicContent(string $tag, array $args): void
|
2022-12-21 21:27:20 +00:00
|
|
|
{
|
|
|
|
while ($this->records()->fetch()) {
|
2023-04-09 08:17:36 +00:00
|
|
|
$args[0] = Epc::replaceString(
|
2022-12-21 21:27:20 +00:00
|
|
|
$this->records()->epc_key,
|
|
|
|
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
|
|
|
|
$args[0],
|
|
|
|
$this
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-09 08:17:36 +00:00
|
|
|
public function widgetList(string $content, WidgetsElement $w, array &$list): void
|
2022-12-21 21:27:20 +00:00
|
|
|
{
|
|
|
|
while ($this->records()->fetch()) {
|
2023-04-09 08:17:36 +00:00
|
|
|
$list[] = Epc::matchString(
|
2022-12-21 21:27:20 +00:00
|
|
|
$this->records()->epc_key,
|
|
|
|
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
|
|
|
|
$content,
|
|
|
|
$this
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|