use abstract plugin name
This commit is contained in:
parent
9be8e6bac7
commit
a068ecef9c
8 changed files with 47 additions and 53 deletions
|
@ -18,16 +18,16 @@ $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',
|
||||||
'2022.11.20',
|
'2022.12.01-dev',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.24']],
|
'requires' => [['core', '2.24']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||||
]),
|
]),
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/enhancePostContent',
|
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
|
||||||
'details' => 'https://plugins.dotaddict.org/dc2/details/enhancePostContent',
|
'details' => 'https://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
|
||||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/enhancePostContent/master/dcstore.xml',
|
'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
|
||||||
'settings' => [
|
'settings' => [
|
||||||
'blog' => '#params.epc_params',
|
'blog' => '#params.epc_params',
|
||||||
],
|
],
|
||||||
|
|
21
_install.php
21
_install.php
|
@ -48,12 +48,12 @@ try {
|
||||||
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||||
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
$s = dcCore::app()->blog->settings->__get(basename(__DIR__));
|
||||||
|
|
||||||
$s->put('enhancePostContent_active', false, 'boolean', 'Enable enhancePostContent', false, true);
|
$s->put('active', false, 'boolean', 'Enable enhancePostContent', false, true);
|
||||||
$s->put('enhancePostContent_list_sortby', 'epc_key', 'string', 'Admin records list field order', false, true);
|
$s->put('list_sortby', 'epc_key', 'string', 'Admin records list field order', false, true);
|
||||||
$s->put('enhancePostContent_list_order', 'desc', 'string', 'Admin records list order', false, true);
|
$s->put('list_order', 'desc', 'string', 'Admin records list order', false, true);
|
||||||
$s->put('enhancePostContent_list_nb', 20, 'integer', 'Admin records list nb per page', false, true);
|
$s->put('list_nb', 20, 'integer', 'Admin records list nb per page', false, true);
|
||||||
$s->put('enhancePostContent_allowedtplvalues', serialize(enhancePostContent::defaultAllowedTplValues()), 'string', 'List of allowed template values', false, true);
|
$s->put('allowedtplvalues', serialize(enhancePostContent::defaultAllowedTplValues()), 'string', 'List of allowed template values', false, true);
|
||||||
$s->put('enhancePostContent_allowedpubpages', serialize(enhancePostContent::defaultAllowedPubPages()), 'string', 'List of allowed template pages', false, true);
|
$s->put('allowedpubpages', serialize(enhancePostContent::defaultAllowedPubPages()), 'string', 'List of allowed template pages', false, true);
|
||||||
|
|
||||||
# Filters settings
|
# Filters settings
|
||||||
$filters = enhancePostContent::getFilters();
|
$filters = enhancePostContent::getFilters();
|
||||||
|
@ -67,16 +67,11 @@ try {
|
||||||
'tplValues' => $filter->tplValues,
|
'tplValues' => $filter->tplValues,
|
||||||
'pubPages' => $filter->pubPages,
|
'pubPages' => $filter->pubPages,
|
||||||
];
|
];
|
||||||
$s->put('enhancePostContent_' . $id, serialize($opt), 'string', 'Settings for ' . $id, false, true);
|
$s->put($id, serialize($opt), 'string', 'Settings for ' . $id, false, true);
|
||||||
/* # only tables
|
|
||||||
if (isset($filter['list'])) {
|
|
||||||
$s->put('enhancePostContent_' . $id . 'List', serialize($filter['list']), 'string', 'List for ' . $id, false, true);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update old versions
|
# Update old versions
|
||||||
$old_version = dcCore::app()->getVersion($mod_id);
|
$old_version = dcCore::app()->getVersion(basename(__DIR__));
|
||||||
if ($old_version && version_compare('2021.10.05', $old_version, '>=')) {
|
if ($old_version && version_compare('2021.10.05', $old_version, '>=')) {
|
||||||
include_once dirname(__FILE__) . '/inc/lib.epc.update.php';
|
include_once dirname(__FILE__) . '/inc/lib.epc.update.php';
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,9 @@ if (!defined('DC_RC_PATH')) {
|
||||||
|
|
||||||
require __DIR__ . '/_widgets.php';
|
require __DIR__ . '/_widgets.php';
|
||||||
|
|
||||||
dcCore::app()->blog->settings->addNamespace('enhancePostContent');
|
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||||
|
|
||||||
if (!dcCore::app()->blog->settings->enhancePostContent->enhancePostContent_active) {
|
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->active) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ $this->addUserAction(
|
||||||
/* action */
|
/* action */
|
||||||
'delete_all',
|
'delete_all',
|
||||||
/* ns */
|
/* ns */
|
||||||
'enhancePostContent',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
__('delete all settings')
|
__('delete all settings')
|
||||||
);
|
);
|
||||||
|
@ -42,7 +42,7 @@ $this->addUserAction(
|
||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
'enhancePostContent',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
__('delete plugin files')
|
__('delete plugin files')
|
||||||
);
|
);
|
||||||
|
@ -53,7 +53,7 @@ $this->addUserAction(
|
||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
'enhancePostContent',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
__('delete the version number')
|
__('delete the version number')
|
||||||
);
|
);
|
||||||
|
@ -64,9 +64,9 @@ $this->addDirectAction(
|
||||||
/* action */
|
/* action */
|
||||||
'delete_all',
|
'delete_all',
|
||||||
/* ns */
|
/* ns */
|
||||||
'enhancePostContent',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
sprintf(__('delete all %s settings'), 'enhancePostContent')
|
sprintf(__('delete all %s settings'), basename(__DIR__))
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
|
@ -77,7 +77,7 @@ $this->addDirectAction(
|
||||||
/* ns */
|
/* ns */
|
||||||
initEnhancePostContent::TABLE_NAME,
|
initEnhancePostContent::TABLE_NAME,
|
||||||
/* desc */
|
/* desc */
|
||||||
sprintf(__('delete %s table'), 'enhancePostContent')
|
sprintf(__('delete %s table'), basename(__DIR__))
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
|
@ -86,9 +86,9 @@ $this->addDirectAction(
|
||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
'enhancePostContent',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
sprintf(__('delete %s plugin files'), 'enhancePostContent')
|
sprintf(__('delete %s plugin files'), basename(__DIR__))
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
|
@ -97,7 +97,7 @@ $this->addDirectAction(
|
||||||
/* action */
|
/* action */
|
||||||
'delete',
|
'delete',
|
||||||
/* ns */
|
/* ns */
|
||||||
'enhancePostContent',
|
basename(__DIR__),
|
||||||
/* description */
|
/* description */
|
||||||
sprintf(__('delete %s version number'), 'enhancePostContent')
|
sprintf(__('delete %s version number'), basename(__DIR__))
|
||||||
);
|
);
|
||||||
|
|
|
@ -111,10 +111,10 @@ class enhancePostContentWidget
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->blog->settings->addNamespace('enhancePostContent');
|
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||||
|
|
||||||
# Page
|
# Page
|
||||||
if (!dcCore::app()->blog->settings->enhancePostContent->enhancePostContent_active
|
if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->active
|
||||||
|| !in_array(dcCore::app()->ctx->current_tpl, ['post.html', 'page.html'])
|
|| !in_array(dcCore::app()->ctx->current_tpl, ['post.html', 'page.html'])
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -45,8 +45,8 @@ class enhancePostContent
|
||||||
|
|
||||||
public static function blogAllowedTplValues()
|
public static function blogAllowedTplValues()
|
||||||
{
|
{
|
||||||
dcCore::app()->blog->settings->addNamespace('enhancePostContent');
|
dcCore::app()->blog->settings->addNamespace(basename(dirname('../' . __DIR__)));
|
||||||
$rs = @unserialize(dcCore::app()->blog->settings->enhancePostContent->enhancePostContent_allowedtplvalues);
|
$rs = @unserialize(dcCore::app()->blog->settings->__get(basename(dirname('../' . __DIR__)))->allowedtplvalues);
|
||||||
|
|
||||||
return is_array($rs) ? $rs : self::defaultAllowedTplValues();
|
return is_array($rs) ? $rs : self::defaultAllowedTplValues();
|
||||||
}
|
}
|
||||||
|
@ -91,8 +91,8 @@ class enhancePostContent
|
||||||
|
|
||||||
public static function blogAllowedPubPages()
|
public static function blogAllowedPubPages()
|
||||||
{
|
{
|
||||||
dcCore::app()->blog->settings->addNamespace('enhancePostContent');
|
dcCore::app()->blog->settings->addNamespace(basename(dirname('../' . __DIR__)));
|
||||||
$rs = @unserialize(dcCore::app()->blog->settings->enhancePostContent->enhancePostContent_allowedpubpages);
|
$rs = @unserialize(dcCore::app()->blog->settings->__get(basename(dirname('../' . __DIR__)))->allowedpubpages);
|
||||||
|
|
||||||
return is_array($rs) ? $rs : self::defaultAllowedPubPages();
|
return is_array($rs) ? $rs : self::defaultAllowedPubPages();
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,8 +108,7 @@ abstract class epcFilter
|
||||||
|
|
||||||
private function blogSettings()
|
private function blogSettings()
|
||||||
{
|
{
|
||||||
$ns = 'enhancePostContent_' . $this->id;
|
$opt = @unserialize(dcCore::app()->blog->settings->__get(basename(dirname('../' . __DIR__)))->__get($this->id));
|
||||||
$opt = @unserialize(dcCore::app()->blog->settings->enhancePostContent->$ns);
|
|
||||||
|
|
||||||
if (!is_array($opt)) {
|
if (!is_array($opt)) {
|
||||||
$opt = [];
|
$opt = [];
|
||||||
|
|
32
index.php
32
index.php
|
@ -60,8 +60,8 @@ try {
|
||||||
'pubPages' => (array) $_POST['filter_pubPages'],
|
'pubPages' => (array) $_POST['filter_pubPages'],
|
||||||
];
|
];
|
||||||
|
|
||||||
dcCore::app()->blog->settings->addNamespace('enhancePostContent');
|
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
||||||
dcCore::app()->blog->settings->enhancePostContent->put('enhancePostContent_' . $filter->id(), serialize($f));
|
dcCore::app()->blog->settings->__get(basename(__DIR__))->put($filter->id(), serialize($f));
|
||||||
|
|
||||||
dcCore::app()->blog->triggerBlog();
|
dcCore::app()->blog->triggerBlog();
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ try {
|
||||||
);
|
);
|
||||||
|
|
||||||
dcCore::app()->adminurl->redirect(
|
dcCore::app()->adminurl->redirect(
|
||||||
'admin.plugin.enhancePostContent',
|
'admin.plugin.' . basename(__DIR__),
|
||||||
['part' => $part],
|
['part' => $part],
|
||||||
'#settings'
|
'#settings'
|
||||||
);
|
);
|
||||||
|
@ -98,7 +98,7 @@ try {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
dcCore::app()->adminurl->redirect(
|
dcCore::app()->adminurl->redirect(
|
||||||
'admin.plugin.enhancePostContent',
|
'admin.plugin.' . basename(__DIR__),
|
||||||
['part' => $part],
|
['part' => $part],
|
||||||
'#record'
|
'#record'
|
||||||
);
|
);
|
||||||
|
@ -122,7 +122,7 @@ try {
|
||||||
http::redirect($_REQUEST['redir']);
|
http::redirect($_REQUEST['redir']);
|
||||||
} else {
|
} else {
|
||||||
dcCore::app()->adminurl->redirect(
|
dcCore::app()->adminurl->redirect(
|
||||||
'admin.plugin.enhancePostContent',
|
'admin.plugin.' . basename(__DIR__),
|
||||||
['part' => $part],
|
['part' => $part],
|
||||||
'#record'
|
'#record'
|
||||||
);
|
);
|
||||||
|
@ -150,7 +150,7 @@ if ($filter->has_list) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = $sorts->js(dcCore::app()->adminurl->get('admin.plugin.enhancePostContent', ['part' => $part], '&') . '#record');
|
$header = $sorts->js(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['part' => $part], '&') . '#record');
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- Display page --
|
# -- Display page --
|
||||||
|
@ -159,7 +159,7 @@ if ($filter->has_list) {
|
||||||
echo '
|
echo '
|
||||||
<html><head><title>' . __('Enhance post content') . '</title>' .
|
<html><head><title>' . __('Enhance post content') . '</title>' .
|
||||||
dcPage::jsPageTabs() .
|
dcPage::jsPageTabs() .
|
||||||
dcPage::jsLoad(dcPage::getPF('enhancePostContent/js/index.js')) .
|
dcPage::jsLoad(dcPage::getPF(basename(__DIR__) . '/js/index.js')) .
|
||||||
$header .
|
$header .
|
||||||
|
|
||||||
# --BEHAVIOR-- enhancePostContentAdminHeader
|
# --BEHAVIOR-- enhancePostContentAdminHeader
|
||||||
|
@ -176,11 +176,11 @@ dcPage::breadcrumb([
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
|
|
||||||
# Filters select menu list
|
# Filters select menu list
|
||||||
'<form method="get" action="' . dcCore::app()->adminurl->get('admin.plugin.enhancePostContent') . '" id="filters_menu">' .
|
'<form method="get" action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" id="filters_menu">' .
|
||||||
'<p class="anchor-nav"><label for="part" class="classic">' . __('Select filter:') . ' </label>' .
|
'<p class="anchor-nav"><label for="part" class="classic">' . __('Select filter:') . ' </label>' .
|
||||||
form::combo('part', $filters_combo, $part) . ' ' .
|
form::combo('part', $filters_combo, $part) . ' ' .
|
||||||
'<input type="submit" value="' . __('Ok') . '" />' .
|
'<input type="submit" value="' . __('Ok') . '" />' .
|
||||||
form::hidden('p', 'enhancePostContent') . '</p>' .
|
form::hidden('p', basename(__DIR__)) . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
# Filter title and description
|
# Filter title and description
|
||||||
|
@ -191,7 +191,7 @@ echo '
|
||||||
# Filter settings
|
# Filter settings
|
||||||
echo '
|
echo '
|
||||||
<div class="multi-part" id="setting" title="' . __('Settings') . '">
|
<div class="multi-part" id="setting" title="' . __('Settings') . '">
|
||||||
<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.enhancePostContent') . '#setting">
|
<form method="post" action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '#setting">
|
||||||
|
|
||||||
<div class="two-boxes odd">
|
<div class="two-boxes odd">
|
||||||
<h4>' . __('Pages to be filtered') . '</h4>';
|
<h4>' . __('Pages to be filtered') . '</h4>';
|
||||||
|
@ -279,17 +279,17 @@ form::hidden(['part'], $part) . '
|
||||||
|
|
||||||
# Filter records list
|
# Filter records list
|
||||||
if ($filter->has_list && isset($sorts) && isset($pager)) {
|
if ($filter->has_list && isset($sorts) && isset($pager)) {
|
||||||
$pager_url = dcCore::app()->adminurl->get('admin.plugin.enhancePostContent', array_diff_key($sorts->values(true), ['page' => ''])) . '&page=%s#record';
|
$pager_url = dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), array_diff_key($sorts->values(true), ['page' => ''])) . '&page=%s#record';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="multi-part" id="record" title="' . __('Records') . '">';
|
<div class="multi-part" id="record" title="' . __('Records') . '">';
|
||||||
|
|
||||||
$sorts->display(['admin.plugin.enhancePostContent', '#record'], form::hidden('p', 'enhancePostContent') . form::hidden('part', $part));
|
$sorts->display(['admin.plugin.' . basename(__DIR__), '#record'], form::hidden('p', basename(__DIR__)) . form::hidden('part', $part));
|
||||||
|
|
||||||
$pager->display(
|
$pager->display(
|
||||||
$sorts,
|
$sorts,
|
||||||
$pager_url,
|
$pager_url,
|
||||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.enhancePostContent') . '#record" method="post" id="form-records">' .
|
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '#record" method="post" id="form-records">' .
|
||||||
'%s' .
|
'%s' .
|
||||||
|
|
||||||
'<div class="two-cols">' .
|
'<div class="two-cols">' .
|
||||||
|
@ -298,8 +298,8 @@ if ($filter->has_list && isset($sorts) && isset($pager)) {
|
||||||
'<p class="col right">' .
|
'<p class="col right">' .
|
||||||
form::hidden('action', 'deleterecords') .
|
form::hidden('action', 'deleterecords') .
|
||||||
'<input id="del-action" type="submit" name="save" value="' . __('Delete selected records') . '" /></p>' .
|
'<input id="del-action" type="submit" name="save" value="' . __('Delete selected records') . '" /></p>' .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.enhancePostContent', array_merge(['p' => 'enhancePostContent'], $sorts->values(true))) .
|
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), array_merge(['p' => basename(__DIR__)], $sorts->values(true))) .
|
||||||
form::hidden('redir', dcCore::app()->adminurl->get('admin.plugin.enhancePostContent', $sorts->values(true))) .
|
form::hidden('redir', dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), $sorts->values(true))) .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
'</div>' .
|
'</div>' .
|
||||||
'</form>'
|
'</form>'
|
||||||
|
@ -310,7 +310,7 @@ if ($filter->has_list && isset($sorts) && isset($pager)) {
|
||||||
# New record
|
# New record
|
||||||
echo '
|
echo '
|
||||||
<div class="multi-part" id="newrecord" title="' . __('New record') . '">
|
<div class="multi-part" id="newrecord" title="' . __('New record') . '">
|
||||||
<form action="' . dcCore::app()->adminurl->get('admin.plugin.enhancePostContent') . '#record" method="post" id="form-create">' .
|
<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '#record" method="post" id="form-create">' .
|
||||||
|
|
||||||
'<p><label for="new_key">' . __('Key:') . '</label>' .
|
'<p><label for="new_key">' . __('Key:') . '</label>' .
|
||||||
form::field('new_key', 60, 255, ['extra_html' => 'required']) .
|
form::field('new_key', 60, 255, ['extra_html' => 'required']) .
|
||||||
|
|
Loading…
Reference in a new issue