diff --git a/inc/lib.epc.pager.php b/inc/class.adminepclist.php similarity index 100% rename from inc/lib.epc.pager.php rename to inc/class.adminepclist.php diff --git a/inc/lib.epc.php b/inc/class.enhancepostcontent.php similarity index 100% rename from inc/lib.epc.php rename to inc/class.enhancepostcontent.php diff --git a/inc/lib.epc.filter.php b/inc/class.epcfilter.php similarity index 100% rename from inc/lib.epc.filter.php rename to inc/class.epcfilter.php diff --git a/inc/class.epcfilterabbreviation.php b/inc/class.epcfilterabbreviation.php new file mode 100644 index 0000000..fb82cf5 --- /dev/null +++ b/inc/class.epcfilterabbreviation.php @@ -0,0 +1,58 @@ +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' => '%s', + 'widget' => '%s', + ]); + + $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; + } +} diff --git a/inc/class.epcfilteracronym.php b/inc/class.epcfilteracronym.php new file mode 100644 index 0000000..da0d964 --- /dev/null +++ b/inc/class.epcfilteracronym.php @@ -0,0 +1,58 @@ +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' => '%s', + 'widget' => '%s', + ]); + + $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; + } +} diff --git a/inc/class.epcfiltercitation.php b/inc/class.epcfiltercitation.php new file mode 100644 index 0000000..0d66902 --- /dev/null +++ b/inc/class.epcfiltercitation.php @@ -0,0 +1,59 @@ +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' => '%s', + 'widget' => '%s', + ]); + + $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; + } +} diff --git a/inc/class.epcfilterdefinition.php b/inc/class.epcfilterdefinition.php new file mode 100644 index 0000000..6aaed71 --- /dev/null +++ b/inc/class.epcfilterdefinition.php @@ -0,0 +1,58 @@ +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' => '%s', + 'widget' => '%s', + ]); + + $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; + } +} diff --git a/inc/class.epcfilterlink.php b/inc/class.epcfilterlink.php new file mode 100644 index 0000000..fc4146a --- /dev/null +++ b/inc/class.epcfilterlink.php @@ -0,0 +1,58 @@ +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' => '%s', + 'widget' => '%s', + ]); + + $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; + } +} diff --git a/inc/class.epcfilterreplace.php b/inc/class.epcfilterreplace.php new file mode 100644 index 0000000..527aaea --- /dev/null +++ b/inc/class.epcfilterreplace.php @@ -0,0 +1,45 @@ +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' => '%s', + ]); + + $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; + } +} diff --git a/inc/class.epcfiltersearch.php b/inc/class.epcfiltersearch.php new file mode 100644 index 0000000..3a9cbee --- /dev/null +++ b/inc/class.epcfiltersearch.php @@ -0,0 +1,50 @@ +setProperties([ + 'priority' => 100, + 'name' => __('Search'), + 'help' => __('Highlight searched words.'), + 'htmltag' => '', + 'class' => ['span.epc-search'], + 'replace' => '%s', + ]); + + $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; + } +} diff --git a/inc/class.epcfiltertag.php b/inc/class.epcfiltertag.php new file mode 100644 index 0000000..fa1f02d --- /dev/null +++ b/inc/class.epcfiltertag.php @@ -0,0 +1,69 @@ +setProperties([ + 'priority' => 900, + 'name' => __('Tag'), + 'help' => __('Highlight tags of your blog.'), + 'htmltag' => 'a', + 'class' => ['a.epc-tag'], + 'replace' => '%s', + 'widget' => '%s', + ]); + + $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; + } +} diff --git a/inc/class.epcfiltertwitter.php b/inc/class.epcfiltertwitter.php new file mode 100644 index 0000000..9d05fc9 --- /dev/null +++ b/inc/class.epcfiltertwitter.php @@ -0,0 +1,42 @@ +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' => '%s', + ]); + + $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; + } +} diff --git a/inc/class.epcfilterupdate.php b/inc/class.epcfilterupdate.php new file mode 100644 index 0000000..032bb0a --- /dev/null +++ b/inc/class.epcfilterupdate.php @@ -0,0 +1,45 @@ +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' => '%s %s', + ]); + + $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; + } +} diff --git a/inc/lib.epc.records.php b/inc/class.epcrecords.php similarity index 100% rename from inc/lib.epc.records.php rename to inc/class.epcrecords.php diff --git a/inc/lib.epc.update.php b/inc/class.epcupdate.php similarity index 100% rename from inc/lib.epc.update.php rename to inc/class.epcupdate.php diff --git a/inc/lib.epc.filters.php b/inc/lib.epc.filters.php deleted file mode 100644 index bd93132..0000000 --- a/inc/lib.epc.filters.php +++ /dev/null @@ -1,513 +0,0 @@ -setProperties([ - 'priority' => 900, - 'name' => __('Tag'), - 'help' => __('Highlight tags of your blog.'), - 'htmltag' => 'a', - 'class' => ['a.epc-tag'], - 'replace' => '%s', - 'widget' => '%s', - ]); - - $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] = libEPC::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[] = libEPC::matchString( - $metas->meta_id, - sprintf($this->widget, dcCore::app()->blog->url . dcCore::app()->url->getBase('tag') . '/' . $metas->meta_id, '\\1'), - $content, - $this - ); - } - - 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' => '%s', - ]); - - $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] = libEPC::replaceString( - $v, - sprintf($this->replace, '\\1'), - $args[0], - $this - ); - } - - 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' => '%s', - 'widget' => '%s', - ]); - - $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] = libEPC::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[] = libEPC::matchString( - $this->records()->epc_key, - sprintf($this->widget, __($this->records()->epc_value), '\\1'), - $content, - $this - ); - } - - 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' => '%s', - 'widget' => '%s', - ]); - - $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] = libEPC::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[] = libEPC::matchString( - $this->records()->epc_key, - sprintf($this->widget, __($this->records()->epc_value), '\\1'), - $content, - $this - ); - } - - 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' => '%s', - 'widget' => '%s', - ]); - - $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] = libEPC::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[] = libEPC::matchString( - $this->records()->epc_key, - sprintf($this->widget, __($this->records()->epc_value), '\\1'), - $content, - $this - ); - } - - 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' => '%s', - 'widget' => '%s', - ]); - - $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] = libEPC::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[] = libEPC::matchString( - $this->records()->epc_key, - sprintf($this->widget, __($this->records()->epc_value), '\\1'), - $content, - $this - ); - } - - 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' => '%s', - 'widget' => '%s', - ]); - - $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] = libEPC::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[] = libEPC::matchString( - $this->records()->epc_key, - sprintf($this->widget, $this->records()->epc_value, $this->records()->epc_value, '\\1'), - $content, - $this - ); - } - - 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' => '%s', - ]); - - $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] = libEPC::replaceString( - $this->records()->epc_key, - sprintf($this->replace, $this->records()->epc_value, '\\2'), - $args[0], - $this - ); - } - - 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' => '%s %s', - ]); - - $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] = libEPC::replaceString( - $this->records()->epc_key, - sprintf($this->replace, '\\1', $this->records()->epc_value), - $args[0], - $this - ); - } - - 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' => '%s', - ]); - - $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] = libEPC::replaceString( - '[A-Za-z0-9_]{2,}', - sprintf($this->replace, 'http://twitter.com/\\1', '\\1'), - $args[0], - $this, - '[^@]@', - '\b' - ); - - return null; - } -}