code review
This commit is contained in:
parent
8b112f8fec
commit
1b1d6fb40f
@ -40,7 +40,7 @@ dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $f
|
||||
|
||||
# Preference form
|
||||
dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function (dcSettings $blog_settings) {
|
||||
$active = (bool) $blog_settings->__get(basename(__DIR__))->active;
|
||||
$active = (bool) $blog_settings->get(basename(__DIR__))->get('active');
|
||||
$allowedtplvalues = enhancePostContent::blogAllowedTplValues();
|
||||
$allowedpubpages = enhancePostContent::blogAllowedPubPages();
|
||||
|
||||
@ -78,9 +78,9 @@ dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function (dcSettings
|
||||
$allowedtplvalues = enhancePostContent::explode($_POST['epc_allowedtplvalues']);
|
||||
$allowedpubpages = enhancePostContent::explode($_POST['epc_allowedpubpages']);
|
||||
|
||||
$blog_settings->__get(basename(__DIR__))->put('active', $active);
|
||||
$blog_settings->__get(basename(__DIR__))->put('allowedtplvalues', json_encode($allowedtplvalues));
|
||||
$blog_settings->__get(basename(__DIR__))->put('allowedpubpages', json_encode($allowedpubpages));
|
||||
$blog_settings->get(basename(__DIR__))->put('active', $active);
|
||||
$blog_settings->get(basename(__DIR__))->put('allowedtplvalues', json_encode($allowedtplvalues));
|
||||
$blog_settings->get(basename(__DIR__))->put('allowedpubpages', json_encode($allowedpubpages));
|
||||
});
|
||||
|
||||
# List filter
|
||||
|
@ -17,7 +17,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
try {
|
||||
// Version
|
||||
if (!dcCore::app()->newVersion(
|
||||
basename(__DIR__),
|
||||
basename(__DIR__),
|
||||
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
|
||||
)) {
|
||||
return null;
|
||||
@ -48,8 +48,7 @@ try {
|
||||
epcUpgrade::growUp();
|
||||
|
||||
// Settings
|
||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
||||
$s = dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||
|
||||
$s->put('active', false, 'boolean', 'Enable enhancePostContent', false, true);
|
||||
$s->put('list_sortby', 'epc_key', 'string', 'Admin records list field order', false, true);
|
||||
|
@ -31,10 +31,10 @@ $d = __DIR__ . '/inc/';
|
||||
|
||||
Clearbricks::lib()->autoload([
|
||||
'enhancePostContent' => $d . 'class.enhancepostcontent.php',
|
||||
'epcFilter' => $d . 'class.epcfilter.php',
|
||||
'epcRecords' => $d . 'class.epcrecords.php',
|
||||
'epcUpgrade' => $d . 'class.epcupgrade.php',
|
||||
'adminEpcList' => $d . 'class.adminepclist.php',
|
||||
'epcFilter' => $d . 'class.epcfilter.php',
|
||||
'epcRecords' => $d . 'class.epcrecords.php',
|
||||
'epcUpgrade' => $d . 'class.epcupgrade.php',
|
||||
'adminEpcList' => $d . 'class.adminepclist.php',
|
||||
]);
|
||||
|
||||
foreach ($filters as $f) {
|
||||
|
@ -18,7 +18,7 @@ require __DIR__ . '/_widgets.php';
|
||||
|
||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||
|
||||
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->active) {
|
||||
if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('active')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ class enhancePostContentWidget
|
||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||
|
||||
# Page
|
||||
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->active
|
||||
if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('active')
|
||||
|| !in_array(dcCore::app()->ctx->current_tpl, ['post.html', 'page.html'])
|
||||
) {
|
||||
return null;
|
||||
|
@ -24,11 +24,7 @@ class adminEpcList extends adminGenericList
|
||||
public function display($filter, $pager_url, $enclose_block = '')
|
||||
{
|
||||
if ($this->rs->isEmpty()) {
|
||||
if ($filter->show()) {
|
||||
echo '<p><strong>' . __('No record matches the filter') . '</strong></p>';
|
||||
} else {
|
||||
echo '<p><strong>' . __('No record') . '</strong></p>';
|
||||
}
|
||||
echo '<p><strong>' . ($filter->show() ? __('No record matches the filter') : __('No record')) . '</strong></p>';
|
||||
} else {
|
||||
$pager = new dcPager($filter->page, $this->rs_count, $filter->nb, 10);
|
||||
$pager->base_url = $pager_url;
|
||||
|
@ -46,7 +46,7 @@ class enhancePostContent
|
||||
public static function blogAllowedTplValues()
|
||||
{
|
||||
dcCore::app()->blog->settings->addNamespace(basename(dirname('../' . __DIR__)));
|
||||
$rs = json_decode(dcCore::app()->blog->settings->__get(basename(dirname('../' . __DIR__)))->allowedtplvalues);
|
||||
$rs = json_decode(dcCore::app()->blog->settings->get(basename(dirname('../' . __DIR__)))->get('allowedtplvalues'));
|
||||
|
||||
return is_array($rs) ? $rs : self::defaultAllowedTplValues();
|
||||
}
|
||||
@ -54,11 +54,11 @@ class enhancePostContent
|
||||
public static function defaultAllowedWidgetValues()
|
||||
{
|
||||
$rs = new arrayObject([
|
||||
'entry excerpt' => [
|
||||
'entry excerpt' => [
|
||||
'id' => 'entryexcerpt',
|
||||
'cb' => ['enhancePostContent','widgetContentEntryExcerpt'],
|
||||
],
|
||||
'entry content' => [
|
||||
'entry content' => [
|
||||
'id' => 'entrycontent',
|
||||
'cb' => ['enhancePostContent','widgetContentEntryContent'],
|
||||
],
|
||||
@ -92,7 +92,7 @@ class enhancePostContent
|
||||
public static function blogAllowedPubPages()
|
||||
{
|
||||
dcCore::app()->blog->settings->addNamespace(basename(dirname('../' . __DIR__)));
|
||||
$rs = json_decode(dcCore::app()->blog->settings->__get(basename(dirname('../' . __DIR__)))->allowedpubpages);
|
||||
$rs = json_decode(dcCore::app()->blog->settings->get(basename(dirname('../' . __DIR__)))->get('allowedpubpages'));
|
||||
|
||||
return is_array($rs) ? $rs : self::defaultAllowedPubPages();
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ abstract class epcFilter
|
||||
|
||||
private function blogSettings()
|
||||
{
|
||||
$opt = json_decode((string) dcCore::app()->blog->settings->__get(basename(dirname('../' . __DIR__)))->__get($this->id));
|
||||
$opt = json_decode((string) dcCore::app()->blog->settings->get(basename(dirname('../' . __DIR__)))->get($this->id));
|
||||
|
||||
if (empty($opt)) {
|
||||
$opt = [];
|
||||
|
@ -1,58 +1,69 @@
|
||||
<?php
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class epcFilterAbbreviation extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 400,
|
||||
'name' => __('Abbreviation'),
|
||||
'help' => __('Explain some abbreviation. First term of the list is the abbreviation and second term the explanation.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => 'a',
|
||||
'class' => ['abbr.epc-abbr'],
|
||||
'replace' => '<abbr class="epc-abbr" title="%s">%s</abbr>',
|
||||
'widget' => '<abbr title="%s">%s</abbr>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['font-weight: bold;'],
|
||||
'notag' => 'a,acronym,abbr,dfn,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'abbreviation';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
<?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 epcFilterAbbreviation extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 400,
|
||||
'name' => __('Abbreviation'),
|
||||
'help' => __('Explain some abbreviation. First term of the list is the abbreviation and second term the explanation.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => 'a',
|
||||
'class' => ['abbr.epc-abbr'],
|
||||
'replace' => '<abbr class="epc-abbr" title="%s">%s</abbr>',
|
||||
'widget' => '<abbr title="%s">%s</abbr>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['font-weight: bold;'],
|
||||
'notag' => 'a,acronym,abbr,dfn,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'abbreviation';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +1,69 @@
|
||||
<?php
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class epcFilterAcronym extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 700,
|
||||
'name' => __('Acronym'),
|
||||
'help' => __('Explain some acronyms. First term of the list is the acornym and second term the explanation.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => 'acronym',
|
||||
'class' => ['acronym.epc-acronym'],
|
||||
'replace' => '<acronym class="epc-acronym" title="%s">%s</acronym>',
|
||||
'widget' => '<acronym title="%s">%s</acronym>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['font-weight: bold;'],
|
||||
'notag' => 'a,acronym,abbr,dfn,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'acronym';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
<?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 epcFilterAcronym extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 700,
|
||||
'name' => __('Acronym'),
|
||||
'help' => __('Explain some acronyms. First term of the list is the acornym and second term the explanation.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => 'acronym',
|
||||
'class' => ['acronym.epc-acronym'],
|
||||
'replace' => '<acronym class="epc-acronym" title="%s">%s</acronym>',
|
||||
'widget' => '<acronym title="%s">%s</acronym>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['font-weight: bold;'],
|
||||
'notag' => 'a,acronym,abbr,dfn,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'acronym';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,59 +1,70 @@
|
||||
<?php
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class epcFilterCitation extends epcFilter
|
||||
{
|
||||
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';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
<?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 epcFilterCitation extends epcFilter
|
||||
{
|
||||
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';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +1,69 @@
|
||||
<?php
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class epcFilterDefinition extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 800,
|
||||
'name' => __('Definition'),
|
||||
'help' => __('Explain some definition. First term of the list is the sample to define and second term the explanation.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => 'dfn',
|
||||
'class' => ['dfn.epc-dfn'],
|
||||
'replace' => '<dfn class="epc-dfn" title="%s">%s</dfn>',
|
||||
'widget' => '<dfn class="epc-dfn" title="%s">%s</dfn>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['font-weight: bold;'],
|
||||
'notag' => 'a,acronym,abbr,dfn,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'definition';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
<?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 epcFilterDefinition extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 800,
|
||||
'name' => __('Definition'),
|
||||
'help' => __('Explain some definition. First term of the list is the sample to define and second term the explanation.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => 'dfn',
|
||||
'class' => ['dfn.epc-dfn'],
|
||||
'replace' => '<dfn class="epc-dfn" title="%s">%s</dfn>',
|
||||
'widget' => '<dfn class="epc-dfn" title="%s">%s</dfn>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['font-weight: bold;'],
|
||||
'notag' => 'a,acronym,abbr,dfn,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'definition';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, __($this->records()->epc_value), '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->widget, __($this->records()->epc_value), '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,58 +1,69 @@
|
||||
<?php
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class epcFilterLink extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 500,
|
||||
'name' => __('Link'),
|
||||
'help' => __('Link some words. First term of the list is the term to link and second term the link.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => 'a',
|
||||
'class' => ['a.epc-link'],
|
||||
'replace' => '<a class="epc-link" title="%s" href="%s">%s</a>',
|
||||
'widget' => '<a title="%s" href="%s">%s</a>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['text-decoration: none; font-style: italic; color: #0000FF;'],
|
||||
'notag' => 'a,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'link';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, '\\1', $this->records()->epc_value, '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->widget, $this->records()->epc_value, $this->records()->epc_value, '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
<?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 epcFilterLink extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 500,
|
||||
'name' => __('Link'),
|
||||
'help' => __('Link some words. First term of the list is the term to link and second term the link.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => 'a',
|
||||
'class' => ['a.epc-link'],
|
||||
'replace' => '<a class="epc-link" title="%s" href="%s">%s</a>',
|
||||
'widget' => '<a title="%s" href="%s">%s</a>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['text-decoration: none; font-style: italic; color: #0000FF;'],
|
||||
'notag' => 'a,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'link';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, '\\1', $this->records()->epc_value, '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->widget, $this->records()->epc_value, $this->records()->epc_value, '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,45 +1,56 @@
|
||||
<?php
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class epcFilterReplace extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 200,
|
||||
'name' => __('Replace'),
|
||||
'help' => __('Replace some text. First term of the list is the text to replace and second term the replacement.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => '',
|
||||
'class' => ['span.epc-replace'],
|
||||
'replace' => '<span class="epc-replace">%s</span>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'nocase' => true,
|
||||
'plural' => true,
|
||||
'style' => ['font-style: italic;'],
|
||||
'notag' => 'h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'replace';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, $this->records()->epc_value, '\\2'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
<?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 epcFilterReplace extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 200,
|
||||
'name' => __('Replace'),
|
||||
'help' => __('Replace some text. First term of the list is the text to replace and second term the replacement.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => '',
|
||||
'class' => ['span.epc-replace'],
|
||||
'replace' => '<span class="epc-replace">%s</span>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'nocase' => true,
|
||||
'plural' => true,
|
||||
'style' => ['font-style: italic;'],
|
||||
'notag' => 'h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'replace';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, $this->records()->epc_value, '\\2'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,50 +1,61 @@
|
||||
<?php
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class epcFilterSearch extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 100,
|
||||
'name' => __('Search'),
|
||||
'help' => __('Highlight searched words.'),
|
||||
'htmltag' => '',
|
||||
'class' => ['span.epc-search'],
|
||||
'replace' => '<span class="epc-search" title="' . __('Search') . '">%s</span>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'nocase' => true,
|
||||
'plural' => true,
|
||||
'style' => ['color: #FFCC66;'],
|
||||
'notag' => 'h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['search.html'],
|
||||
]);
|
||||
|
||||
return 'search';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
if (empty(dcCore::app()->public->search)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$searchs = explode(' ', dcCore::app()->public->search);
|
||||
|
||||
foreach ($searchs as $k => $v) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$v,
|
||||
sprintf($this->replace, '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
<?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 epcFilterSearch extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 100,
|
||||
'name' => __('Search'),
|
||||
'help' => __('Highlight searched words.'),
|
||||
'htmltag' => '',
|
||||
'class' => ['span.epc-search'],
|
||||
'replace' => '<span class="epc-search" title="' . __('Search') . '">%s</span>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'nocase' => true,
|
||||
'plural' => true,
|
||||
'style' => ['color: #FFCC66;'],
|
||||
'notag' => 'h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['search.html'],
|
||||
]);
|
||||
|
||||
return 'search';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
if (empty(dcCore::app()->public->search)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$searchs = explode(' ', dcCore::app()->public->search);
|
||||
|
||||
foreach ($searchs as $k => $v) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$v,
|
||||
sprintf($this->replace, '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,69 +1,80 @@
|
||||
<?php
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class epcFilterTag extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 900,
|
||||
'name' => __('Tag'),
|
||||
'help' => __('Highlight tags of your blog.'),
|
||||
'htmltag' => 'a',
|
||||
'class' => ['a.epc-tag'],
|
||||
'replace' => '<a class="epc-tag" href="%s" title="' . __('Tag') . '">%s</a>',
|
||||
'widget' => '<a href="%s" title="' . __('Tag') . '">%s</a>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['text-decoration: none; border-bottom: 3px double #CCCCCC;'],
|
||||
'notag' => 'a,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'tag';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
if (!dcCore::app()->plugins->moduleExists('tags')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$metas = dcCore::app()->meta->getMetadata(['meta_type' => 'tag']);
|
||||
|
||||
while ($metas->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$metas->meta_id,
|
||||
sprintf($this->replace, dcCore::app()->blog->url . dcCore::app()->url->getBase('tag') . '/' . $metas->meta_id, '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
if (!dcCore::app()->plugins->moduleExists('tags')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$metas = dcCore::app()->meta->getMetadata(['meta_type' => 'tag']);
|
||||
|
||||
while ($metas->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$metas->meta_id,
|
||||
sprintf($this->widget, dcCore::app()->blog->url . dcCore::app()->url->getBase('tag') . '/' . $metas->meta_id, '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
<?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 epcFilterTag extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 900,
|
||||
'name' => __('Tag'),
|
||||
'help' => __('Highlight tags of your blog.'),
|
||||
'htmltag' => 'a',
|
||||
'class' => ['a.epc-tag'],
|
||||
'replace' => '<a class="epc-tag" href="%s" title="' . __('Tag') . '">%s</a>',
|
||||
'widget' => '<a href="%s" title="' . __('Tag') . '">%s</a>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['text-decoration: none; border-bottom: 3px double #CCCCCC;'],
|
||||
'notag' => 'a,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'tag';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
if (!dcCore::app()->plugins->moduleExists('tags')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$metas = dcCore::app()->meta->getMetadata(['meta_type' => 'tag']);
|
||||
|
||||
while ($metas->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$metas->meta_id,
|
||||
sprintf($this->replace, dcCore::app()->blog->url . dcCore::app()->url->getBase('tag') . '/' . $metas->meta_id, '\\1'),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function widgetList($content, $w, &$list)
|
||||
{
|
||||
if (!dcCore::app()->plugins->moduleExists('tags')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$metas = dcCore::app()->meta->getMetadata(['meta_type' => 'tag']);
|
||||
|
||||
while ($metas->fetch()) {
|
||||
$list[] = enhancePostContent::matchString(
|
||||
$metas->meta_id,
|
||||
sprintf($this->widget, dcCore::app()->blog->url . dcCore::app()->url->getBase('tag') . '/' . $metas->meta_id, '\\1'),
|
||||
$content,
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +1,53 @@
|
||||
<?php
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class epcFilterTwitter extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 1000,
|
||||
'name' => __('Twitter'),
|
||||
'help' => __('Add link to twitter user page. Every word started with "@" will be considered as twitter user.'),
|
||||
'htmltag' => 'a',
|
||||
'class' => ['a.epc-twitter'],
|
||||
'replace' => '<a class="epc-twitter" title="' . __("View this user's twitter page") . '" href="%s">%s</a>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['text-decoration: none; font-weight: bold; font-style: italic; color: #0000FF;'],
|
||||
'notag' => 'a,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'twitter';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
'[A-Za-z0-9_]{2,}',
|
||||
sprintf($this->replace, 'http://twitter.com/\\1', '\\1'),
|
||||
$args[0],
|
||||
$this,
|
||||
'[^@]@',
|
||||
'\b'
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
<?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 epcFilterTwitter extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 1000,
|
||||
'name' => __('Twitter'),
|
||||
'help' => __('Add link to twitter user page. Every word started with "@" will be considered as twitter user.'),
|
||||
'htmltag' => 'a',
|
||||
'class' => ['a.epc-twitter'],
|
||||
'replace' => '<a class="epc-twitter" title="' . __("View this user's twitter page") . '" href="%s">%s</a>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'style' => ['text-decoration: none; font-weight: bold; font-style: italic; color: #0000FF;'],
|
||||
'notag' => 'a,h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'twitter';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
'[A-Za-z0-9_]{2,}',
|
||||
sprintf($this->replace, 'http://twitter.com/\\1', '\\1'),
|
||||
$args[0],
|
||||
$this,
|
||||
'[^@]@',
|
||||
'\b'
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,45 +1,56 @@
|
||||
<?php
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
class epcFilterUpdate extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 300,
|
||||
'name' => __('Update'),
|
||||
'help' => __('Update and show terms. First term of the list is the term to update and second term the new term.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => 'del,ins',
|
||||
'class' => ['del.epc-update', 'ins.epc-update'],
|
||||
'replace' => '<del class="epc-update">%s</del> <ins class="epc-update">%s</ins>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'nocase' => true,
|
||||
'plural' => true,
|
||||
'style' => ['text-decoration: line-through;', 'font-style: italic;'],
|
||||
'notag' => 'h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'update';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, '\\1', $this->records()->epc_value),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
<?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 epcFilterUpdate extends epcFilter
|
||||
{
|
||||
protected function init(): string
|
||||
{
|
||||
$this->setProperties([
|
||||
'priority' => 300,
|
||||
'name' => __('Update'),
|
||||
'help' => __('Update and show terms. First term of the list is the term to update and second term the new term.'),
|
||||
'has_list' => true,
|
||||
'htmltag' => 'del,ins',
|
||||
'class' => ['del.epc-update', 'ins.epc-update'],
|
||||
'replace' => '<del class="epc-update">%s</del> <ins class="epc-update">%s</ins>',
|
||||
]);
|
||||
|
||||
$this->setSettings([
|
||||
'nocase' => true,
|
||||
'plural' => true,
|
||||
'style' => ['text-decoration: line-through;', 'font-style: italic;'],
|
||||
'notag' => 'h1,h2,h3',
|
||||
'tplValues' => ['EntryContent'],
|
||||
'pubPages' => ['post.html'],
|
||||
]);
|
||||
|
||||
return 'update';
|
||||
}
|
||||
|
||||
public function publicContent($tag, $args)
|
||||
{
|
||||
while ($this->records()->fetch()) {
|
||||
$args[0] = enhancePostContent::replaceString(
|
||||
$this->records()->epc_key,
|
||||
sprintf($this->replace, '\\1', $this->records()->epc_value),
|
||||
$args[0],
|
||||
$this
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -21,24 +21,24 @@ class epcUpgrade
|
||||
$current = dcCore::app()->getVersion(basename(dirname('../' . __DIR__)));
|
||||
|
||||
if ($current && version_compare($current, '0.6.6', '<=')) {
|
||||
self::postUpgrade00060607();
|
||||
self::upTo00060607();
|
||||
}
|
||||
|
||||
if ($current && version_compare($current, '2021.10.06', '<=')) {
|
||||
self::postUpgrade20211006();
|
||||
self::upTo20211006();
|
||||
}
|
||||
|
||||
if ($current && version_compare($current, '2022.11.20', '<=')) {
|
||||
self::preUpgrade20221120();
|
||||
self::upTo20221120();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 0.6.6
|
||||
*
|
||||
*
|
||||
* - filters move from settings to dedicated table
|
||||
*/
|
||||
private static function postUpgrade00060607()
|
||||
private static function upTo00060607()
|
||||
{
|
||||
# Move old filters lists from settings to database
|
||||
$f = dcCore::app()->con->select('SELECT * FROM ' . dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME . " WHERE setting_ns='enhancePostContent' AND blog_id IS NOT NULL ");
|
||||
@ -68,10 +68,10 @@ class epcUpgrade
|
||||
|
||||
/**
|
||||
* 2021.10.06
|
||||
*
|
||||
*
|
||||
* - filters change name to id
|
||||
*/
|
||||
private static function postUpgrade20211006()
|
||||
private static function upTo20211006()
|
||||
{
|
||||
# Move old filter name to filter id
|
||||
$rs = dcCore::app()->con->select('SELECT epc_id, epc_filter FROM ' . dcCore::app()->prefix . initEnhancePostContent::TABLE_NAME);
|
||||
@ -88,18 +88,18 @@ class epcUpgrade
|
||||
/**
|
||||
* 2022.11.20
|
||||
*
|
||||
* - setting id changes to shorter one,
|
||||
* - setting id changes to shorter one,
|
||||
* - setting ns changes to abstract one (no real changes),
|
||||
* - setting value change from serialize to json_encode (if it's array)
|
||||
*/
|
||||
private static function preUpgrade20221120()
|
||||
private static function upTo20221120()
|
||||
{
|
||||
// list of settings using serialize values to move to json
|
||||
$ids = [
|
||||
'allowedtplvalues',
|
||||
'allowedpubpages'
|
||||
'allowedtplvalues',
|
||||
'allowedpubpages',
|
||||
];
|
||||
foreach(enhancePostContent::getFilters() as $id => $f) {
|
||||
foreach (enhancePostContent::getFilters() as $id => $f) {
|
||||
$ids[] = $id;
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ try {
|
||||
];
|
||||
|
||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||
dcCore::app()->blog->settings->__get(basename(__DIR__))->put($filter->id(), json_encode($f));
|
||||
dcCore::app()->blog->settings->get(basename(__DIR__))->put($filter->id(), json_encode($f));
|
||||
|
||||
dcCore::app()->blog->triggerBlog();
|
||||
|
||||
@ -159,7 +159,7 @@ if ($filter->has_list) {
|
||||
echo '
|
||||
<html><head><title>' . __('Enhance post content') . '</title>' .
|
||||
dcPage::jsPageTabs() .
|
||||
dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/index.js')) .
|
||||
dcPage::jsModuleLoad(basename(__DIR__) . '/js/index.js') .
|
||||
$header .
|
||||
|
||||
# --BEHAVIOR-- enhancePostContentAdminHeader
|
||||
|
Loading…
Reference in New Issue
Block a user