clean up php files

This commit is contained in:
Jean-Christian Paul Denis 2021-09-02 20:35:25 +02:00
parent f08fe78156
commit abb1308058
13 changed files with 298 additions and 289 deletions

View File

@ -1,81 +1,90 @@
enhancePostContent xxxx.xx.xx xxxx.xx.xx
* Not added priority on filters for replacement order - [ ] add priority on filters for replacement order
* Not added priority on lists of filters for replacement order - [ ] add priority on lists of filters for replacement order
* Not added auto-find post title in content - [ ] add auto-find post title in content
- [ ] split filters into modules
- [ ] fix filters on spaces after words
enhancePostContent 2021.08.24 2021.08.24.1
* switch to Dotclear 2.19 - add links to blog prefs
* switch to php 7.3+ and php 8.0.x - clean up php files style
* switch to Github - add dcstore.xml
* update license
* update php code to PSR-2 and short array
* move settings from plugin to blog
enhancePostContent 2013.11.08 2021.08.24
* Switch to Dotclear 2.6 (admin styles and settings) - switch to Dotclear 2.19
* Add dashboard icon - switch to php 7.3+ and php 8.0.x
* Add widget options (content_only and class) - switch to Github
* Fix records list pager - update license
- update php code to PSR-2 and short array
- move settings from plugin to blog
- fix widget rendering
- fix php strict warning on undeclared var on public content
enhancePostContent 2013.06.25 2013.11.08
* Fixed widget compatibility for php 5.4 - Switch to Dotclear 2.6 (admin styles and settings)
- Add dashboard icon
- Add widget options (content_only and class)
- Fix records list pager
enhancePostContent 2013.05.11 2013.06.25
* Fixed bug with Twitter replacement and wiki synthax of blockquote - Fixed widget compatibility for php 5.4
* Fixed page title
enhancePostContent 2011.06.03 2013.05.11
* Added 'feeds pages' - Fixed bug with Twitter replacement and wiki synthax of blockquote
- Fixed page title
enhancePostContent 0.9 - 2010-06-06 2011.06.03
* Switched to DC 2.2 - Added 'feeds pages'
enhancePostContent 0.8.1 - 2010-03-31 0.9 - 2010-06-06
* Fixed some l10n - Switched to DC 2.2
* Added option for default list order
enhancePostContent 0.8 - 2010-03-31 0.8.1 - 2010-03-31
* Added admin lists sortable - Fixed some l10n
* Added pager for admin lists - Added option for default list order
* Added update on records
* Changed title of HTML tag on links replacement
* Removed empty CSS from head
* Enhanced admin pages
enhancePostContent 0.7 - 2010-01-12 0.8 - 2010-03-31
* Moved lists from setting to a new database - Added admin lists sortable
- Added pager for admin lists
- Added update on records
- Changed title of HTML tag on links replacement
- Removed empty CSS from head
- Enhanced admin pages
enhancePostContent 0.6 - 2010-01-09 0.7 - 2010-01-12
* Fixed HTML tags to use standard tags. - Moved lists from setting to a new database
* Fixed CSS class names
* Changed settings management
* Added widget (only for post page)
* Added some post enhancement
enhancePostContent 0.5 - 2009-12-28 0.6 - 2010-01-09
* Added support of comment content - Fixed HTML tags to use standard tags.
* Added support of word replacement - Fixed CSS class names
* Added option for case sensitive - Changed settings management
* Added option for plural - Added widget (only for post page)
* Changed class from post-xxx to epc-xxx - Added some post enhancement
* Changed names from acronyme to acronym
* Changed acronym html tag from <span> to <acronym>
* Changed all settings management
enhancePostContent 0.4 - 2009-12-24 0.5 - 2009-12-28
* Merry Christmas! - Added support of comment content
* enhanced filters - Added support of word replacement
* Added support of entry excerpt - Added option for case sensitive
* Added support of custom ignored HTML tags - Added option for plural
* Added some help - Changed class from post-xxx to epc-xxx
- Changed names from acronyme to acronym
- Changed acronym html tag from <span> to <acronym>
- Changed all settings management
enhancePostContent 0.3 - 2009-12-21 0.4 - 2009-12-24
* Fixed filter with punctuation (slow hack) - Merry Christmas!
* Added word-to-link filter - enhanced filters
- Added support of entry excerpt
- Added support of custom ignored HTML tags
- Added some help
enhancePostContent 0.2 - 2009-12-12 0.3 - 2009-12-21
* Fixed case sensitive definition - Fixed filter with punctuation (slow hack)
* Prepared DC 2.2 è Added word-to-link filter
enhancePostContent 0.1 - 2009-10-17 0.2 - 2009-12-12
* First release - Fixed case sensitive definition
- Prepared DC 2.2
0.1 - 2009-10-17
- First release

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief enhancePostContent, a plugin for Dotclear 2
# This file is part of enhancePostContent, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief enhancePostContent, a plugin for Dotclear 2
# This file is part of enhancePostContent, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
@ -19,12 +19,13 @@ $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',
'2021.08.24', '2021.08.24.1',
[ [
'requires' => [['core', '2.19']],
'permissions' => 'contentadmin', 'permissions' => 'contentadmin',
'type' => 'plugin', 'type' => 'plugin',
'dc_min' => '2.18',
'support' => 'https://github.com/JcDenis/enhancePostContent', 'support' => 'https://github.com/JcDenis/enhancePostContent',
'details' => 'https://plugins.dotaddict.org/dc2/details/enhancePostContent' 'details' => 'https://plugins.dotaddict.org/dc2/details/enhancePostContent',
'repository' => 'https://raw.githubusercontent.com/JcDenis/enhancePostContent/master/dcstore.xml'
] ]
); );

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief enhancePostContent, a plugin for Dotclear 2
# This file is part of enhancePostContent, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief enhancePostContent, a plugin for Dotclear 2
# This file is part of enhancePostContent, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief enhancePostContent, a plugin for Dotclear 2
# This file is part of enhancePostContent, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief enhancePostContent, a plugin for Dotclear 2
# This file is part of enhancePostContent, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')){ if (!defined('DC_CONTEXT_ADMIN')){
return; return;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief enhancePostContent, a plugin for Dotclear 2
# This file is part of enhancePostContent, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief enhancePostContent, a plugin for Dotclear 2
# This file is part of enhancePostContent, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
# l10n # l10n
__('Tag');__('Search');__('Acronym');__('Abbreviation');__('Definition'); __('Tag');__('Search');__('Acronym');__('Abbreviation');__('Definition');
@ -23,7 +23,7 @@ class libEPC
# #
# Default definition # Default definition
# #
public static function defaultAllowedTplValues() public static function defaultAllowedTplValues()
{ {
return [ return [
@ -32,7 +32,7 @@ class libEPC
'comment content' => 'CommentContent', 'comment content' => 'CommentContent',
]; ];
} }
public static function blogAllowedTplValues() public static function blogAllowedTplValues()
{ {
global $core; global $core;
@ -41,11 +41,11 @@ class libEPC
$rs = @unserialize($core->blog->settings->enhancePostContent->enhancePostContent_allowedtplvalues); $rs = @unserialize($core->blog->settings->enhancePostContent->enhancePostContent_allowedtplvalues);
return is_array($rs) ? $rs : $allowedtplvalues; return is_array($rs) ? $rs : $allowedtplvalues;
} }
public static function defaultAllowedWidgetValues() public static function defaultAllowedWidgetValues()
{ {
global $core; global $core;
$rs = [ $rs = [
'entry excerpt' => [ 'entry excerpt' => [
'id' => 'entryexcerpt', 'id' => 'entryexcerpt',
@ -60,12 +60,12 @@ class libEPC
'callback' => ['libEPC','widgetContentCommentContent'] 'callback' => ['libEPC','widgetContentCommentContent']
] ]
]; ];
$core->callBehavior('enhancePostContentAllowedWidgetValues', $rs); $core->callBehavior('enhancePostContentAllowedWidgetValues', $rs);
return $rs; return $rs;
} }
public static function defaultAllowedPubPages() public static function defaultAllowedPubPages()
{ {
return [ return [
@ -77,7 +77,7 @@ class libEPC
'RSS feeds' => 'rss2.xml' 'RSS feeds' => 'rss2.xml'
]; ];
} }
public static function blogAllowedPubPages() public static function blogAllowedPubPages()
{ {
global $core; global $core;
@ -86,24 +86,24 @@ class libEPC
$rs = @unserialize($core->blog->settings->enhancePostContent->enhancePostContent_allowedpubpages); $rs = @unserialize($core->blog->settings->enhancePostContent->enhancePostContent_allowedpubpages);
return is_array($rs) ? $rs : $allowedpubpages; return is_array($rs) ? $rs : $allowedpubpages;
} }
public static function defaultFilters() public static function defaultFilters()
{ {
global $core; global $core;
$filters = [ $filters = [
'Tag' => [ 'Tag' => [
'id' => 'tag', 'id' => 'tag',
'publicContentFilter' => ['libEPC', 'publicContentFilterTag'], 'publicContentFilter' => ['libEPC', 'publicContentFilterTag'],
'widgetListFilter' => ['libEPC', 'widgetListTag'], 'widgetListFilter' => ['libEPC', 'widgetListTag'],
'help' => __('Highlight tags of your blog.'), 'help' => __('Highlight tags of your blog.'),
'has_list' => false, 'has_list' => false,
'htmltag' => 'a', 'htmltag' => 'a',
'class' => ['a.epc-tag'], 'class' => ['a.epc-tag'],
'replace' => '<a class="epc-tag" href="%s" title="' . __('Tag') . '">%s</a>', 'replace' => '<a class="epc-tag" href="%s" title="' . __('Tag') . '">%s</a>',
'widget' => '<a href="%s" title="' . __('Tag') . '">%s</a>', 'widget' => '<a href="%s" title="' . __('Tag') . '">%s</a>',
'nocase' => false, 'nocase' => false,
'plural' => false, 'plural' => false,
'limit' => 0, 'limit' => 0,
@ -115,13 +115,13 @@ class libEPC
'Search' => [ 'Search' => [
'id' => 'search', 'id' => 'search',
'publicContentFilter' => ['libEPC', 'publicContentFilterSearch'], 'publicContentFilter' => ['libEPC', 'publicContentFilterSearch'],
'help' => __('Highlight searched words.'), 'help' => __('Highlight searched words.'),
'has_list' => false, 'has_list' => false,
'htmltag' => '', 'htmltag' => '',
'class' => ['span.epc-search'], 'class' => ['span.epc-search'],
'replace' => '<span class="epc-search" title="' . __('Search') . '">%s</span>', 'replace' => '<span class="epc-search" title="' . __('Search') . '">%s</span>',
'nocase' => true, 'nocase' => true,
'plural' => true, 'plural' => true,
'limit' => 0, 'limit' => 0,
@ -134,14 +134,14 @@ class libEPC
'id' => 'acronym', 'id' => 'acronym',
'publicContentFilter' => ['libEPC', 'publicContentFilterAcronym'], 'publicContentFilter' => ['libEPC', 'publicContentFilterAcronym'],
'widgetListFilter' => ['libEPC', 'widgetListAcronym'], 'widgetListFilter' => ['libEPC', 'widgetListAcronym'],
'help' => __('Explain some acronyms. First term of the list is the acornym and second term the explanation.'), 'help' => __('Explain some acronyms. First term of the list is the acornym and second term the explanation.'),
'has_list' => true, 'has_list' => true,
'htmltag' => 'acronym', 'htmltag' => 'acronym',
'class' => ['acronym.epc-acronym'], 'class' => ['acronym.epc-acronym'],
'replace' => '<acronym class="epc-acronym" title="%s">%s</acronym>', 'replace' => '<acronym class="epc-acronym" title="%s">%s</acronym>',
'widget' => '<acronym title="%s">%s</acronym>', 'widget' => '<acronym title="%s">%s</acronym>',
'nocase' => false, 'nocase' => false,
'plural' => false, 'plural' => false,
'limit' => 0, 'limit' => 0,
@ -154,14 +154,14 @@ class libEPC
'id' => 'abbreviation', 'id' => 'abbreviation',
'publicContentFilter' => ['libEPC', 'publicContentFilterAbbreviation'], 'publicContentFilter' => ['libEPC', 'publicContentFilterAbbreviation'],
'widgetListFilter' => ['libEPC', 'widgetListAbbreviation'], 'widgetListFilter' => ['libEPC', 'widgetListAbbreviation'],
'help' => __('Explain some abbreviation. First term of the list is the abbreviation and second term the explanation.'), 'help' => __('Explain some abbreviation. First term of the list is the abbreviation and second term the explanation.'),
'has_list' => true, 'has_list' => true,
'htmltag' => 'a', 'htmltag' => 'a',
'class' => ['abbr.epc-abbr'], 'class' => ['abbr.epc-abbr'],
'replace' => '<abbr class="epc-abbr" title="%s">%s</abbr>', 'replace' => '<abbr class="epc-abbr" title="%s">%s</abbr>',
'widget' => '<abbr title="%s">%s</abbr>', 'widget' => '<abbr title="%s">%s</abbr>',
'nocase' => false, 'nocase' => false,
'plural' => false, 'plural' => false,
'limit' => 0, 'limit' => 0,
@ -174,14 +174,14 @@ class libEPC
'id' => 'definition', 'id' => 'definition',
'publicContentFilter' => ['libEPC', 'publicContentFilterDefinition'], 'publicContentFilter' => ['libEPC', 'publicContentFilterDefinition'],
'widgetListFilter' => ['libEPC', 'widgetListDefinition'], 'widgetListFilter' => ['libEPC', 'widgetListDefinition'],
'help' => __('Explain some definition. First term of the list is the sample to define and second term the explanation.'), 'help' => __('Explain some definition. First term of the list is the sample to define and second term the explanation.'),
'has_list' => true, 'has_list' => true,
'htmltag' => 'dfn', 'htmltag' => 'dfn',
'class' => ['dfn.epc-dfn'], 'class' => ['dfn.epc-dfn'],
'replace' => '<dfn class="epc-dfn" title="%s">%s</dfn>', 'replace' => '<dfn class="epc-dfn" title="%s">%s</dfn>',
'widget' => '<dfn class="epc-dfn" title="%s">%s</dfn>', 'widget' => '<dfn class="epc-dfn" title="%s">%s</dfn>',
'nocase' => false, 'nocase' => false,
'plural' => false, 'plural' => false,
'limit' => 0, 'limit' => 0,
@ -194,14 +194,14 @@ class libEPC
'id' => 'citation', 'id' => 'citation',
'publicContentFilter' => ['libEPC', 'publicContentFilterCitation'], 'publicContentFilter' => ['libEPC', 'publicContentFilterCitation'],
'widgetListFilter' => ['libEPC', 'widgetListCitation'], 'widgetListFilter' => ['libEPC', 'widgetListCitation'],
'help' => __('Highlight citation of people. First term of the list is the citation and second term the author.'), 'help' => __('Highlight citation of people. First term of the list is the citation and second term the author.'),
'has_list' => true, 'has_list' => true,
'htmltag' => 'cite', 'htmltag' => 'cite',
'class' => ['cite.epc-cite'], 'class' => ['cite.epc-cite'],
'replace' => '<cite class="epc-cite" title="%s">%s</cite>', 'replace' => '<cite class="epc-cite" title="%s">%s</cite>',
'widget' => '<cite title="%s">%s</cite>', 'widget' => '<cite title="%s">%s</cite>',
'nocase' => true, 'nocase' => true,
'plural' => false, 'plural' => false,
'limit' => 0, 'limit' => 0,
@ -214,14 +214,14 @@ class libEPC
'id' => 'link', 'id' => 'link',
'publicContentFilter' => ['libEPC', 'publicContentFilterLink'], 'publicContentFilter' => ['libEPC', 'publicContentFilterLink'],
'widgetListFilter' => ['libEPC', 'widgetListLink'], 'widgetListFilter' => ['libEPC', 'widgetListLink'],
'help' => __('Link some words. First term of the list is the term to link and second term the link.'), 'help' => __('Link some words. First term of the list is the term to link and second term the link.'),
'has_list' => true, 'has_list' => true,
'htmltag' => 'a', 'htmltag' => 'a',
'class' => ['a.epc-link'], 'class' => ['a.epc-link'],
'replace' => '<a class="epc-link" title="%s" href="%s">%s</a>', 'replace' => '<a class="epc-link" title="%s" href="%s">%s</a>',
'widget' => '<a title="%s" href="%s">%s</a>', 'widget' => '<a title="%s" href="%s">%s</a>',
'nocase' => false, 'nocase' => false,
'plural' => false, 'plural' => false,
'limit' => 0, 'limit' => 0,
@ -233,13 +233,13 @@ class libEPC
'Replace' => [ 'Replace' => [
'id' => 'replace', 'id' => 'replace',
'publicContentFilter' => ['libEPC', 'publicContentFilterReplace'], 'publicContentFilter' => ['libEPC', 'publicContentFilterReplace'],
'help' => __('Replace some text. First term of the list is the text to replace and second term the replacement.'), 'help' => __('Replace some text. First term of the list is the text to replace and second term the replacement.'),
'has_list' => true, 'has_list' => true,
'htmltag' => '', 'htmltag' => '',
'class' => ['span.epc-replace'], 'class' => ['span.epc-replace'],
'replace' => '<span class="epc-replace">%s</span>', 'replace' => '<span class="epc-replace">%s</span>',
'nocase' => true, 'nocase' => true,
'plural' => true, 'plural' => true,
'limit' => 0, 'limit' => 0,
@ -251,13 +251,13 @@ class libEPC
'Update' => [ 'Update' => [
'id' => 'update', 'id' => 'update',
'publicContentFilter' => ['libEPC', 'publicContentFilterUpdate'], 'publicContentFilter' => ['libEPC', 'publicContentFilterUpdate'],
'help' => __('Update and show terms. First term of the list is the term to update and second term the new term.'), 'help' => __('Update and show terms. First term of the list is the term to update and second term the new term.'),
'has_list' => true, 'has_list' => true,
'htmltag' => 'del,ins', 'htmltag' => 'del,ins',
'class' => ['del.epc-update', 'ins.epc-update'], 'class' => ['del.epc-update', 'ins.epc-update'],
'replace' => '<del class="epc-update">%s</del> <ins class="epc-update">%s</ins>', 'replace' => '<del class="epc-update">%s</del> <ins class="epc-update">%s</ins>',
'nocase' => true, 'nocase' => true,
'plural' => true, 'plural' => true,
'limit' => 0, 'limit' => 0,
@ -269,13 +269,13 @@ class libEPC
'Twitter' => [ 'Twitter' => [
'id' => 'twitter', 'id' => 'twitter',
'publicContentFilter' => ['libEPC', 'publicContentFilterTwitter'], 'publicContentFilter' => ['libEPC', 'publicContentFilterTwitter'],
'help' => __('Add link to twitter user page. Every word started with "@" will be considered as twitter user.'), 'help' => __('Add link to twitter user page. Every word started with "@" will be considered as twitter user.'),
'has_list' => false, 'has_list' => false,
'htmltag' => 'a', 'htmltag' => 'a',
'class' => ['a.epc-twitter'], 'class' => ['a.epc-twitter'],
'replace' => '<a class="epc-twitter" title="' . __("View this user's twitter page") . '" href="%s">%s</a>', 'replace' => '<a class="epc-twitter" title="' . __("View this user's twitter page") . '" href="%s">%s</a>',
'nocase' => false, 'nocase' => false,
'plural' => false, 'plural' => false,
'limit' => 0, 'limit' => 0,
@ -285,23 +285,23 @@ class libEPC
'pubPages' => ['post.html'] 'pubPages' => ['post.html']
] ]
]; ];
$core->callBehavior('enhancePostContentDefaultFilters', $filters); $core->callBehavior('enhancePostContentDefaultFilters', $filters);
return $filters; return $filters;
} }
public static function blogFilters($one = null) public static function blogFilters($one = null)
{ {
global $core; global $core;
$core->blog->settings->addNamespace('enhancePostContent'); $core->blog->settings->addNamespace('enhancePostContent');
$filters = self::defaultFilters(); $filters = self::defaultFilters();
foreach($filters as $name => $filter) { foreach($filters as $name => $filter) {
# Parse filters options # Parse filters options
$ns = 'enhancePostContent_' . $name; $ns = 'enhancePostContent_' . $name;
$opt[$name] = @unserialize($core->blog->settings->enhancePostContent->$ns); $opt[$name] = @unserialize($core->blog->settings->enhancePostContent->$ns);
if (!is_array($opt[$name])) { if (!is_array($opt[$name])) {
$opt[$name] = []; $opt[$name] = [];
} }
@ -327,9 +327,9 @@ class libEPC
$filters[$name]['pubPages'] = (array) $opt[$name]['pubPages']; $filters[$name]['pubPages'] = (array) $opt[$name]['pubPages'];
} }
} }
$core->callBehavior('enhancePostContentBlogFilters', $filters); $core->callBehavior('enhancePostContentBlogFilters', $filters);
return $filters; return $filters;
} }
@ -346,7 +346,7 @@ class libEPC
&& empty($args[2]) // remove html && empty($args[2]) // remove html
; ;
} }
public static function replaceString($p, $r, $s, $filter, $before = '\b', $after = '\b') public static function replaceString($p, $r, $s, $filter, $before = '\b', $after = '\b')
{ {
# Limit # Limit
@ -386,7 +386,7 @@ class libEPC
# Clean rest # Clean rest
return $s = preg_replace('#ççççç(.*?)ççççç#s', '$1', $s); return $s = preg_replace('#ççççç(.*?)ççççç#s', '$1', $s);
} }
public static function matchString($p, $r, $s, $filter, $before = '\b', $after = '\b') public static function matchString($p, $r, $s, $filter, $before = '\b', $after = '\b')
{ {
# Case sensitive # Case sensitive
@ -399,7 +399,7 @@ class libEPC
if (!$t) { if (!$t) {
return ['total' => 0, 'matches' => []]; return ['total' => 0, 'matches' => []];
} }
# Build array # Build array
$m = []; $m = [];
$loop = 0; $loop = 0;
@ -411,22 +411,22 @@ class libEPC
} }
return ['total' => $t, 'matches' => $m]; return ['total' => $t, 'matches' => $m];
} }
public static function quote($s) public static function quote($s)
{ {
return preg_quote($s, '#'); return preg_quote($s, '#');
} }
public static function removeTags($m) public static function removeTags($m)
{ {
return $m[1] . preg_replace('#ççççç(?!ççççç)#s', '$1', $m[3]) . $m[4]; return $m[1] . preg_replace('#ççççç(?!ççççç)#s', '$1', $m[3]) . $m[4];
} }
public static function decodeTags($t) public static function decodeTags($t)
{ {
return preg_match_all('#([A-Za-z0-9]+)#', (string) $t, $m) ? $m[1] : []; return preg_match_all('#([A-Za-z0-9]+)#', (string) $t, $m) ? $m[1] : [];
} }
public static function implode($a) public static function implode($a)
{ {
if (is_string($a)) { if (is_string($a)) {
@ -435,14 +435,14 @@ class libEPC
if (!is_array($a)) { if (!is_array($a)) {
return []; return [];
} }
$r = ''; $r = '';
foreach($a as $k => $v) { foreach($a as $k => $v) {
$r .= $k . ':' . $v . ';'; $r .= $k . ':' . $v . ';';
} }
return $r; return $r;
} }
public static function explode($s) public static function explode($s)
{ {
if (is_array($s)) { if (is_array($s)) {
@ -451,71 +451,71 @@ class libEPC
if (!is_string($s)) { if (!is_string($s)) {
return ''; return '';
} }
$r = []; $r = [];
$s = explode(';', (string) $s); $s = explode(';', (string) $s);
if (!is_array($s)) { if (!is_array($s)) {
return []; return [];
} }
foreach($s as $cpl) { foreach($s as $cpl) {
$cur = explode(':', $cpl); $cur = explode(':', $cpl);
if (!is_array($cur) || !isset($cur[1])) { if (!is_array($cur) || !isset($cur[1])) {
continue; continue;
} }
$key = html::escapeHTML(trim($cur[0])); $key = html::escapeHTML(trim($cur[0]));
$val = html::escapeHTML(trim($cur[1])); $val = html::escapeHTML(trim($cur[1]));
if (empty($key) || empty($val)) { if (empty($key) || empty($val)) {
continue; continue;
} }
$r[$key] = $val; $r[$key] = $val;
} }
return $r; return $r;
} }
# #
# Widgets # Widgets
# #
public static function widgetContentEntryExcerpt($core, $w) public static function widgetContentEntryExcerpt($core, $w)
{ {
global $_ctx; global $_ctx;
if (!$_ctx->exists('posts')) { if (!$_ctx->exists('posts')) {
return; return;
} }
$res = ''; $res = '';
while ($_ctx->posts->fetch()) { while ($_ctx->posts->fetch()) {
$res .= $_ctx->posts->post_excerpt; $res .= $_ctx->posts->post_excerpt;
} }
return $res; return $res;
} }
public static function widgetContentEntryContent() public static function widgetContentEntryContent()
{ {
global $_ctx; global $_ctx;
if (!$_ctx->exists('posts')) { if (!$_ctx->exists('posts')) {
return; return;
} }
$res = ''; $res = '';
while ($_ctx->posts->fetch()) { while ($_ctx->posts->fetch()) {
$res .= $_ctx->posts->post_content; $res .= $_ctx->posts->post_content;
} }
return $res; return $res;
} }
public static function widgetContentCommentContent() public static function widgetContentCommentContent()
{ {
global $core, $_ctx; global $core, $_ctx;
if (!$_ctx->exists('posts')) { if (!$_ctx->exists('posts')) {
return; return;
} }
$res = ''; $res = '';
$post_ids = []; $post_ids = [];
while ($_ctx->posts->fetch()) { while ($_ctx->posts->fetch()) {
@ -526,19 +526,19 @@ class libEPC
} }
return $res; return $res;
} }
# #
# Filters # Filters
# #
public static function publicContentFilterTag($core, $filter, $tag, $args) public static function publicContentFilterTag($core, $filter, $tag, $args)
{ {
if (!$core->plugins->moduleExists('tags')) { if (!$core->plugins->moduleExists('tags')) {
return; return;
} }
$metas = $core->meta->getMetadata(['meta_type' => 'tag']); $metas = $core->meta->getMetadata(['meta_type' => 'tag']);
while($metas->fetch()) { while($metas->fetch()) {
$k = $metas->meta_id; $k = $metas->meta_id;
$args[0] = self::replaceString( $args[0] = self::replaceString(
@ -550,7 +550,7 @@ class libEPC
} }
return; return;
} }
public static function widgetListTag($core, $filter, $content, $w, &$list) public static function widgetListTag($core, $filter, $content, $w, &$list)
{ {
if (!$core->plugins->moduleExists('tags')) { if (!$core->plugins->moduleExists('tags')) {
@ -558,7 +558,7 @@ class libEPC
} }
$metas = $core->meta->getMetadata(['meta_type' => 'tag']); $metas = $core->meta->getMetadata(['meta_type' => 'tag']);
while($metas->fetch()) { while($metas->fetch()) {
$k = $metas->meta_id; $k = $metas->meta_id;
$list[] = self::matchString( $list[] = self::matchString(
@ -570,15 +570,15 @@ class libEPC
} }
return; return;
} }
public static function publicContentFilterSearch($core, $filter, $tag, $args) public static function publicContentFilterSearch($core, $filter, $tag, $args)
{ {
if (!isset($GLOBALS['_search'])) { if (!isset($GLOBALS['_search'])) {
return; return;
} }
$searchs = explode(' ', $GLOBALS['_search']); $searchs = explode(' ', $GLOBALS['_search']);
foreach($searchs as $k => $v) { foreach($searchs as $k => $v) {
$args[0] = self::replaceString( $args[0] = self::replaceString(
$v, $v,
@ -589,13 +589,13 @@ class libEPC
} }
return; return;
} }
public static function publicContentFilterAcronym($core, $filter, $tag, $args) public static function publicContentFilterAcronym($core, $filter, $tag, $args)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$args[0] = self::replaceString( $args[0] = self::replaceString(
$k, $k,
sprintf($filter['replace'], __($v), '\\1'), sprintf($filter['replace'], __($v), '\\1'),
@ -605,13 +605,13 @@ class libEPC
} }
return; return;
} }
public static function widgetListAcronym($core, $filter, $content, $w, &$list) public static function widgetListAcronym($core, $filter, $content, $w, &$list)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$list[] = self::matchString( $list[] = self::matchString(
$k, $k,
sprintf($filter['widget'], __($v), '\\1'), sprintf($filter['widget'], __($v), '\\1'),
@ -621,13 +621,13 @@ class libEPC
} }
return; return;
} }
public static function publicContentFilterAbbreviation($core, $filter, $tag, $args) public static function publicContentFilterAbbreviation($core, $filter, $tag, $args)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$args[0] = self::replaceString( $args[0] = self::replaceString(
$k, $k,
sprintf($filter['replace'], __($v), '\\1'), sprintf($filter['replace'], __($v), '\\1'),
@ -637,13 +637,13 @@ class libEPC
} }
return; return;
} }
public static function widgetListAbbreviation($core, $filter, $content, $w, &$list) public static function widgetListAbbreviation($core, $filter, $content, $w, &$list)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$list[] = self::matchString( $list[] = self::matchString(
$k, $k,
sprintf($filter['widget'], __($v), '\\1'), sprintf($filter['widget'], __($v), '\\1'),
@ -653,13 +653,13 @@ class libEPC
} }
return; return;
} }
public static function publicContentFilterDefinition($core, $filter, $tag, $args) public static function publicContentFilterDefinition($core, $filter, $tag, $args)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$args[0] = self::replaceString( $args[0] = self::replaceString(
$k, $k,
sprintf($filter['replace'], __($v), '\\1'), sprintf($filter['replace'], __($v), '\\1'),
@ -669,13 +669,13 @@ class libEPC
} }
return; return;
} }
public static function widgetListDefinition($core, $filter, $content, $w, &$list) public static function widgetListDefinition($core, $filter, $content, $w, &$list)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$list[] = self::matchString( $list[] = self::matchString(
$k, $k,
sprintf($filter['widget'], __($v), '\\1'), sprintf($filter['widget'], __($v), '\\1'),
@ -685,13 +685,13 @@ class libEPC
} }
return; return;
} }
public static function publicContentFilterCitation($core, $filter, $tag, $args) public static function publicContentFilterCitation($core, $filter, $tag, $args)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$args[0] = self::replaceString( $args[0] = self::replaceString(
$k, $k,
sprintf($filter['replace'], __($v), '\\1'), sprintf($filter['replace'], __($v), '\\1'),
@ -701,13 +701,13 @@ class libEPC
} }
return; return;
} }
public static function widgetListCitation($core, $filter, $content, $w, &$list) public static function widgetListCitation($core, $filter, $content, $w, &$list)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$list[] = self::matchString( $list[] = self::matchString(
$k, $k,
sprintf($filter['widget'], __($v), '\\1'), sprintf($filter['widget'], __($v), '\\1'),
@ -717,13 +717,13 @@ class libEPC
} }
return; return;
} }
public static function publicContentFilterLink($core, $filter, $tag, $args) public static function publicContentFilterLink($core, $filter, $tag, $args)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$args[0] = self::replaceString( $args[0] = self::replaceString(
$k, $k,
sprintf($filter['replace'], '\\1', $v, '\\1'), sprintf($filter['replace'], '\\1', $v, '\\1'),
@ -733,13 +733,13 @@ class libEPC
} }
return; return;
} }
public static function widgetListLink($core, $filter, $content, $w, &$list) public static function widgetListLink($core, $filter, $content, $w, &$list)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$list[] = self::matchString( $list[] = self::matchString(
$k, $k,
sprintf($filter['widget'], $v, $v, '\\1'), sprintf($filter['widget'], $v, $v, '\\1'),
@ -749,13 +749,13 @@ class libEPC
} }
return; return;
} }
public static function publicContentFilterReplace($core, $filter, $tag, $args) public static function publicContentFilterReplace($core, $filter, $tag, $args)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$args[0] = self::replaceString( $args[0] = self::replaceString(
$k, $k,
sprintf($filter['replace'], $v, '\\2'), sprintf($filter['replace'], $v, '\\2'),
@ -765,13 +765,13 @@ class libEPC
} }
return; return;
} }
public static function publicContentFilterUpdate($core, $filter, $tag, $args) public static function publicContentFilterUpdate($core, $filter, $tag, $args)
{ {
while($filter['list']->fetch()) { while($filter['list']->fetch()) {
$k = $filter['list']->epc_key; $k = $filter['list']->epc_key;
$v = $filter['list']->epc_value; $v = $filter['list']->epc_value;
$args[0] = self::replaceString( $args[0] = self::replaceString(
$k, $k,
sprintf($filter['replace'], '\\1', $v), sprintf($filter['replace'], '\\1', $v),
@ -781,7 +781,7 @@ class libEPC
} }
return; return;
} }
public static function publicContentFilterTwitter($core, $filter, $tag, $args) public static function publicContentFilterTwitter($core, $filter, $tag, $args)
{ {
$args[0] = self::replaceString( $args[0] = self::replaceString(

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief enhancePostContent, a plugin for Dotclear 2
# This file is part of enhancePostContent, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
class epcRecords class epcRecords
{ {
@ -104,9 +104,9 @@ class epcRecords
$cur->epc_id = $this->getNextId(); $cur->epc_id = $this->getNextId();
$cur->blog_id = $this->blog; $cur->blog_id = $this->blog;
$cur->epc_upddt = date('Y-m-d H:i:s'); $cur->epc_upddt = date('Y-m-d H:i:s');
$this->getCursor($cur); $this->getCursor($cur);
$cur->insert(); $cur->insert();
$this->con->unlock(); $this->con->unlock();
} catch (Exception $e) { } catch (Exception $e) {
@ -120,7 +120,7 @@ class epcRecords
return $cur->epc_id; return $cur->epc_id;
} }
public function updRecord($id, $cur) public function updRecord($id, $cur)
{ {
$id = (integer) $id; $id = (integer) $id;

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief enhancePostContent, a plugin for Dotclear 2
# This file is part of enhancePostContent, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
# This file only update old filters lists from settings to database # This file only update old filters lists from settings to database

View File

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief enhancePostContent, a plugin for Dotclear 2
# This file is part of enhancePostContent, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis and Contributors
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
@ -297,7 +297,7 @@ if (isset($filters_id[$default_part])) {
'asc', 'asc',
'desc' 'desc'
]; ];
$sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : (string) $s->enhancePostContent_list_sortby; $sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : (string) $s->enhancePostContent_list_sortby;
$order = !empty($_GET['order']) ? $_GET['order'] : (string) $s->enhancePostContent_list_order; $order = !empty($_GET['order']) ? $_GET['order'] : (string) $s->enhancePostContent_list_order;
$page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1; $page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;

View File

@ -210,5 +210,4 @@ $GLOBALS['__l10n']['Key:'] = 'Clé :';
#index.php:401 #index.php:401
$GLOBALS['__l10n']['Value:'] = 'Valeur :'; $GLOBALS['__l10n']['Value:'] = 'Valeur :';
$GLOBALS['__l10n']['Configuration has been successfully updated.'] = 'La configuration a été mise à jour avec succés.'; $GLOBALS['__l10n']['Configuration has been successfully updated.'] = 'La configuration a été mise à jour avec succés.';