update php code to PSR-2 and short array
This commit is contained in:
parent
450ada59a1
commit
64e42494ca
14 changed files with 1668 additions and 1740 deletions
|
@ -2,12 +2,14 @@ enhancePostContent xxxx.xx.xx
|
||||||
* Not added priority on filters for replacement order
|
* Not added priority on filters for replacement order
|
||||||
* Not added priority on lists of filters for replacement order
|
* Not added priority on lists of filters for replacement order
|
||||||
* Not added auto-find post title in content
|
* Not added auto-find post title in content
|
||||||
|
* move settings from plugin to blog
|
||||||
|
|
||||||
enhancePostContent 2021.08.xx
|
enhancePostContent 2021.08.xx
|
||||||
* switch to Dotclear 2.19
|
* switch to Dotclear 2.19
|
||||||
* switch to php 7.3+ and php 8.0.x
|
* switch to php 7.3+ and php 8.0.x
|
||||||
* switch to Github
|
* switch to Github
|
||||||
* update license
|
* update license
|
||||||
|
* update php code to PSR-2 and short array
|
||||||
|
|
||||||
enhancePostContent 2013.11.08
|
enhancePostContent 2013.11.08
|
||||||
* Switch to Dotclear 2.6 (admin styles and settings)
|
* Switch to Dotclear 2.6 (admin styles and settings)
|
||||||
|
|
65
_admin.php
65
_admin.php
|
@ -12,50 +12,49 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require dirname(__FILE__).'/_widgets.php';
|
require dirname(__FILE__) . '/_widgets.php';
|
||||||
|
|
||||||
# Admin menu
|
# Admin menu
|
||||||
$_menu['Blog']->addItem(
|
$_menu['Blog']->addItem(
|
||||||
__('Enhance post content'),
|
__('Enhance post content'),
|
||||||
'plugin.php?p=enhancePostContent',
|
'plugin.php?p=enhancePostContent',
|
||||||
'index.php?pf=enhancePostContent/icon.png',
|
'index.php?pf=enhancePostContent/icon.png',
|
||||||
preg_match(
|
preg_match(
|
||||||
'/plugin.php\?p=enhancePostContent(&.*)?$/',
|
'/plugin.php\?p=enhancePostContent(&.*)?$/',
|
||||||
$_SERVER['REQUEST_URI']
|
$_SERVER['REQUEST_URI']
|
||||||
),
|
),
|
||||||
$core->auth->check('contentadmin', $core->blog->id)
|
$core->auth->check('contentadmin', $core->blog->id)
|
||||||
);
|
);
|
||||||
|
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'adminDashboardFavorites',
|
'adminDashboardFavorites',
|
||||||
array('epcAdminBehaviors', 'adminDashboardFavorites')
|
['epcAdminBehaviors', 'adminDashboardFavorites']
|
||||||
);
|
);
|
||||||
|
|
||||||
class epcAdminBehaviors
|
class epcAdminBehaviors
|
||||||
{
|
{
|
||||||
public static function adminDashboardFavorites($core, $favs)
|
public static function adminDashboardFavorites($core, $favs)
|
||||||
{
|
{
|
||||||
$favs->register('enhancePostContent', array(
|
$favs->register('enhancePostContent', [
|
||||||
'title' => __('Enhance post content'),
|
'title' => __('Enhance post content'),
|
||||||
'url' => 'plugin.php?p=enhancePostContent',
|
'url' => 'plugin.php?p=enhancePostContent',
|
||||||
'small-icon' => 'index.php?pf=enhancePostContent/icon.png',
|
'small-icon' => 'index.php?pf=enhancePostContent/icon.png',
|
||||||
'large-icon' => 'index.php?pf=enhancePostContent/icon-big.png',
|
'large-icon' => 'index.php?pf=enhancePostContent/icon-big.png',
|
||||||
'permissions' => $core->auth->check('contentadmin', $core->blog->id),
|
'permissions' => $core->auth->check('contentadmin', $core->blog->id),
|
||||||
'active_cb' => array(
|
'active_cb' => [
|
||||||
'epcAdminBehaviors',
|
'epcAdminBehaviors',
|
||||||
'adminDashboardFavoritesActive'
|
'adminDashboardFavoritesActive'
|
||||||
)
|
]
|
||||||
));
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function adminDashboardFavoritesActive($request, $params)
|
public static function adminDashboardFavoritesActive($request, $params)
|
||||||
{
|
{
|
||||||
return $request == 'plugin.php'
|
return $request == 'plugin.php'
|
||||||
&& isset($params['p'])
|
&& isset($params['p'])
|
||||||
&& $params['p'] == 'enhancePostContent';
|
&& $params['p'] == 'enhancePostContent';
|
||||||
}
|
}
|
||||||
}
|
}
|
29
_define.php
29
_define.php
|
@ -12,24 +12,19 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->registerModule(
|
$this->registerModule(
|
||||||
/* Name */
|
'Enhance post content',
|
||||||
"Enhance post content",
|
'Add features to words in post content',
|
||||||
/* Description*/
|
'Jean-Christian Denis and Contributors',
|
||||||
"Add features to words in post content",
|
'2021.08.0',
|
||||||
/* Author */
|
[
|
||||||
"Jean-Christian Denis",
|
'permissions' => 'contentadmin',
|
||||||
/* Version */
|
'type' => 'plugin',
|
||||||
'2013.11.08',
|
'dc_min' => '2.18',
|
||||||
array(
|
'support' => 'https://github.com/JcDenis/enhancePostContent',
|
||||||
'permissions' => 'contentadmin',
|
'details' => 'https://plugins.dotaddict.org/dc2/details/enhancePostContent'
|
||||||
'type' => 'plugin',
|
]
|
||||||
'dc_min' => '2.6',
|
|
||||||
'support' => 'http://jcd.lv/q=enhancePostContent',
|
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/enhancePostContent'
|
|
||||||
)
|
|
||||||
);
|
);
|
134
_install.php
134
_install.php
|
@ -12,93 +12,89 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$dc_min = '2.6';
|
$dc_min = '2.18';
|
||||||
$mod_id = 'enhancePostContent';
|
$mod_id = 'enhancePostContent';
|
||||||
$new_version = $core->plugins->moduleInfo($mod_id, 'version');
|
$new_version = $core->plugins->moduleInfo($mod_id, 'version');
|
||||||
$old_version = $core->getVersion($mod_id);
|
$old_version = $core->getVersion($mod_id);
|
||||||
|
|
||||||
if (version_compare($old_version, $new_version, '>=')) {
|
if (version_compare($old_version, $new_version, '>=')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
# Check Dotclear version
|
||||||
# Check Dotclear version
|
if (!method_exists('dcUtils', 'versionsCompare')
|
||||||
if (!method_exists('dcUtils', 'versionsCompare')
|
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
|
||||||
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
|
throw new Exception(sprintf(
|
||||||
throw new Exception(sprintf(
|
'%s requires Dotclear %s', $mod_id, $dc_min
|
||||||
'%s requires Dotclear %s', $mod_id, $dc_min
|
));
|
||||||
));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# Database
|
# Database
|
||||||
$s = new dbStruct($core->con, $core->prefix);
|
$s = new dbStruct($core->con, $core->prefix);
|
||||||
$s->epc
|
$s->epc
|
||||||
->epc_id ('bigint', 0, false)
|
->epc_id ('bigint', 0, false)
|
||||||
->blog_id ('varchar', 32, false)
|
->blog_id ('varchar', 32, false)
|
||||||
->epc_type('varchar', 32, false, "'epc'")
|
->epc_type('varchar', 32, false, "'epc'")
|
||||||
->epc_filter('varchar', 64, false)
|
->epc_filter('varchar', 64, false)
|
||||||
->epc_key('varchar', 255, false)
|
->epc_key('varchar', 255, false)
|
||||||
->epc_value('text', 0, false)
|
->epc_value('text', 0, false)
|
||||||
->epc_upddt('timestamp', 0, false, 'now()')
|
->epc_upddt('timestamp', 0, false, 'now()')
|
||||||
|
|
||||||
->primary('pk_epc', 'epc_id')
|
->primary('pk_epc', 'epc_id')
|
||||||
->index('idx_epc_blog_id', 'btree', 'blog_id')
|
->index('idx_epc_blog_id', 'btree', 'blog_id')
|
||||||
->index('idx_epc_type', 'btree', 'epc_type')
|
->index('idx_epc_type', 'btree', 'epc_type')
|
||||||
->index('idx_epc_filter', 'btree', 'epc_filter')
|
->index('idx_epc_filter', 'btree', 'epc_filter')
|
||||||
->index('idx_epc_key', 'btree', 'epc_key');
|
->index('idx_epc_key', 'btree', 'epc_key');
|
||||||
|
|
||||||
$si = new dbStruct($core->con, $core->prefix);
|
$si = new dbStruct($core->con, $core->prefix);
|
||||||
$changes = $si->synchronize($s);
|
$changes = $si->synchronize($s);
|
||||||
$s = null;
|
$s = null;
|
||||||
|
|
||||||
# Settings
|
# Settings
|
||||||
$core->blog->settings->addNamespace($mod_id);
|
$core->blog->settings->addNamespace($mod_id);
|
||||||
$s = $core->blog->settings->enhancePostContent;
|
$s = $core->blog->settings->enhancePostContent;
|
||||||
|
|
||||||
$s->put('enhancePostContent_active', false,'boolean', 'Enable enhancePostContent', false, true);
|
$s->put('enhancePostContent_active', false,'boolean', 'Enable enhancePostContent', false, true);
|
||||||
$s->put('enhancePostContent_list_sortby', 'epc_key', 'string', 'Admin records list field order', false, true);
|
$s->put('enhancePostContent_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('enhancePostContent_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('enhancePostContent_list_nb', 20, 'integer', 'Admin records list nb per page', false, true);
|
||||||
$s->put('enhancePostContent_allowedtplvalues', serialize(libEPC::defaultAllowedTplValues()), 'string', 'List of allowed template values', false, true);
|
$s->put('enhancePostContent_allowedtplvalues', serialize(libEPC::defaultAllowedTplValues()), 'string', 'List of allowed template values', false, true);
|
||||||
$s->put('enhancePostContent_allowedpubpages', serialize(libEPC::defaultAllowedPubPages()), 'string', 'List of allowed template pages', false, true);
|
$s->put('enhancePostContent_allowedpubpages', serialize(libEPC::defaultAllowedPubPages()), 'string', 'List of allowed template pages', false, true);
|
||||||
|
|
||||||
# Filters settings
|
# Filters settings
|
||||||
$filters = libEPC::defaultFilters();
|
$filters = libEPC::defaultFilters();
|
||||||
foreach($filters as $name => $filter) {
|
foreach($filters as $name => $filter) {
|
||||||
# Only editable options
|
# Only editable options
|
||||||
$opt = array(
|
$opt = [
|
||||||
'nocase' => $filter['nocase'],
|
'nocase' => $filter['nocase'],
|
||||||
'plural' => $filter['plural'],
|
'plural' => $filter['plural'],
|
||||||
'style' => $filter['style'],
|
'style' => $filter['style'],
|
||||||
'notag' => $filter['notag'],
|
'notag' => $filter['notag'],
|
||||||
'tplValues' => $filter['tplValues'],
|
'tplValues' => $filter['tplValues'],
|
||||||
'pubPages' => $filter['pubPages']
|
'pubPages' => $filter['pubPages']
|
||||||
);
|
];
|
||||||
$s->put('enhancePostContent_'.$name, serialize($opt), 'string', 'Settings for '.$name, false, true);
|
$s->put('enhancePostContent_' . $name, serialize($opt), 'string', 'Settings for ' . $name, false, true);
|
||||||
# only tables
|
# only tables
|
||||||
if (isset($filter['list'])) {
|
if (isset($filter['list'])) {
|
||||||
$s->put('enhancePostContent_'.$name.'List', serialize($filter['list']), 'string', 'List for '.$name, false, true);
|
$s->put('enhancePostContent_' . $name . 'List', serialize($filter['list']), 'string', 'List for ' . $name, false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Move old filters lists from settings to database
|
# Move old filters lists from settings to database
|
||||||
if ($old_version && version_compare('0.6.6', $old_version, '>=')) {
|
if ($old_version && version_compare('0.6.6', $old_version, '>=')) {
|
||||||
include_once dirname(__FILE__).'/inc/lib.epc.update.php';
|
include_once dirname(__FILE__) . '/inc/lib.epc.update.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Version
|
# Version
|
||||||
$core->setVersion($mod_id, $new_version);
|
$core->setVersion($mod_id, $new_version);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
$core->error->add($e->getMessage());
|
||||||
$core->error->add($e->getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
|
@ -12,11 +12,10 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$d = dirname(__FILE__).'/inc/';
|
$d = dirname(__FILE__) . '/inc/';
|
||||||
|
|
||||||
$__autoload['libEPC'] = $d.'lib.epc.php';
|
$__autoload['libEPC'] = $d . 'lib.epc.php';
|
||||||
$__autoload['epcRecords'] = $d.'lib.epc.records.php';
|
$__autoload['epcRecords'] = $d . 'lib.epc.records.php';
|
139
_public.php
139
_public.php
|
@ -12,24 +12,23 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
require dirname(__FILE__).'/_widgets.php';
|
require dirname(__FILE__) . '/_widgets.php';
|
||||||
|
|
||||||
$core->blog->settings->addNamespace('enhancePostContent');
|
$core->blog->settings->addNamespace('enhancePostContent');
|
||||||
|
|
||||||
if ($core->blog->settings->enhancePostContent->enhancePostContent_active) {
|
if ($core->blog->settings->enhancePostContent->enhancePostContent_active) {
|
||||||
|
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'publicHeadContent',
|
'publicHeadContent',
|
||||||
array('publicEnhancePostContent', 'publicHeadContent')
|
['publicEnhancePostContent', 'publicHeadContent']
|
||||||
);
|
);
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'publicBeforeContentFilter',
|
'publicBeforeContentFilter',
|
||||||
array('publicEnhancePostContent', 'publicContentFilter')
|
['publicEnhancePostContent', 'publicContentFilter']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,73 +38,71 @@ if ($core->blog->settings->enhancePostContent->enhancePostContent_active) {
|
||||||
*/
|
*/
|
||||||
class publicEnhancePostContent
|
class publicEnhancePostContent
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Add filters CSS to page header
|
* Add filters CSS to page header
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
* @param dcCore $core dcCore instance
|
||||||
*/
|
*/
|
||||||
public static function publicHeadContent(dcCore $core)
|
public static function publicHeadContent(dcCore $core)
|
||||||
{
|
{
|
||||||
$filters = libEPC::blogFilters();
|
$filters = libEPC::blogFilters();
|
||||||
|
|
||||||
foreach($filters as $name => $filter) {
|
foreach($filters as $name => $filter) {
|
||||||
|
|
||||||
if (empty($filter['class'])
|
if (empty($filter['class'])
|
||||||
|| empty($filter['style'])
|
|| empty($filter['style'])) {
|
||||||
) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$res = '';
|
$res = '';
|
||||||
foreach($filter['class'] as $k => $class) {
|
foreach($filter['class'] as $k => $class) {
|
||||||
$style = html::escapeHTML(trim($filter['style'][$k]));
|
$style = html::escapeHTML(trim($filter['style'][$k]));
|
||||||
if ('' != $style) {
|
if ('' != $style) {
|
||||||
$res .= $class." {".$style."} ";
|
$res .= $class . " {" . $style . "} ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($res)) {
|
if (!empty($res)) {
|
||||||
echo
|
echo
|
||||||
"\n<!-- CSS for enhancePostContent ".$name." --> \n".
|
"\n<!-- CSS for enhancePostContent " . $name . " --> \n" .
|
||||||
"<style type=\"text/css\"> ".$res."</style> \n";
|
"<style type=\"text/css\"> " . $res . "</style> \n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter template blocks content
|
* Filter template blocks content
|
||||||
*
|
*
|
||||||
* @param dcCore $core dcCore instance
|
* @param dcCore $core dcCore instance
|
||||||
* @param string $tag Tempalte block name
|
* @param string $tag Tempalte block name
|
||||||
* @param array $args Tempalte Block arguments
|
* @param array $args Tempalte Block arguments
|
||||||
*/
|
*/
|
||||||
public static function publicContentFilter(dcCore $core, $tag, $args)
|
public static function publicContentFilter(dcCore $core, $tag, $args)
|
||||||
{
|
{
|
||||||
$filters = libEPC::blogFilters();
|
$filters = libEPC::blogFilters();
|
||||||
$records = new epcRecords($core);
|
$records = new epcRecords($core);
|
||||||
|
|
||||||
foreach($filters as $name => $filter) {
|
foreach($filters as $name => $filter) {
|
||||||
|
|
||||||
if (!isset($filter['publicContentFilter'])
|
if (!isset($filter['publicContentFilter'])
|
||||||
|| !is_callable($filter['publicContentFilter'])
|
|| !is_callable($filter['publicContentFilter'])
|
||||||
|| !libEPC::testContext($tag,$args,$filter)
|
|| !libEPC::testContext($tag,$args,$filter)) {
|
||||||
) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ($filter['has_list']) {
|
if ($filter['has_list']) {
|
||||||
$filter['list'] = $records->getRecords(array(
|
$filter['list'] = $records->getRecords(array(
|
||||||
'epc_filter' => $name)
|
'epc_filter' => $name)
|
||||||
);
|
);
|
||||||
if ($filter['list']->isEmpty()) {
|
if ($filter['list']->isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
call_user_func_array(
|
call_user_func_array(
|
||||||
$filter['publicContentFilter'],
|
$filter['publicContentFilter'],
|
||||||
array($core, $filter, $tag, $args)
|
[$core, $filter, $tag, $args]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,48 +11,48 @@
|
||||||
#
|
#
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')){return;}
|
if (!defined('DC_CONTEXT_ADMIN')){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this->addUserAction(
|
$this->addUserAction(
|
||||||
/* type */ 'settings',
|
/* type */ 'settings',
|
||||||
/* action */ 'delete_all',
|
/* action */ 'delete_all',
|
||||||
/* ns */ 'enhancePostContent',
|
/* ns */ 'enhancePostContent',
|
||||||
/* description */ __('delete all settings')
|
/* description */ __('delete all settings')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addUserAction(
|
$this->addUserAction(
|
||||||
/* type */ 'plugins',
|
/* type */ 'plugins',
|
||||||
/* action */ 'delete',
|
/* action */ 'delete',
|
||||||
/* ns */ 'enhancePostContent',
|
/* ns */ 'enhancePostContent',
|
||||||
/* description */ __('delete plugin files')
|
/* description */ __('delete plugin files')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addUserAction(
|
$this->addUserAction(
|
||||||
/* type */ 'versions',
|
/* type */ 'versions',
|
||||||
/* action */ 'delete',
|
/* action */ 'delete',
|
||||||
/* ns */ 'enhancePostContent',
|
/* ns */ 'enhancePostContent',
|
||||||
/* description */ __('delete the version number')
|
/* description */ __('delete the version number')
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$this->addDirectAction(
|
|
||||||
/* type */ 'settings',
|
|
||||||
/* action */ 'delete_all',
|
|
||||||
/* ns */ 'enhancePostContent',
|
|
||||||
/* description */ sprintf(__('delete all %s settings'),'enhancePostContent')
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
/* type */ 'plugins',
|
/* type */ 'settings',
|
||||||
/* action */ 'delete',
|
/* action */ 'delete_all',
|
||||||
/* ns */ 'enhancePostContent',
|
/* ns */ 'enhancePostContent',
|
||||||
/* description */ sprintf(__('delete %s plugin files'),'enhancePostContent')
|
/* description */ sprintf(__('delete all %s settings'), 'enhancePostContent')
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addDirectAction(
|
$this->addDirectAction(
|
||||||
/* type */ 'versions',
|
/* type */ 'plugins',
|
||||||
/* action */ 'delete',
|
/* action */ 'delete',
|
||||||
/* ns */ 'enhancePostContent',
|
/* ns */ 'enhancePostContent',
|
||||||
/* description */ sprintf(__('delete %s version number'),'enhancePostContent')
|
/* description */ sprintf(__('delete %s plugin files'), 'enhancePostContent')
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addDirectAction(
|
||||||
|
/* type */ 'versions',
|
||||||
|
/* action */ 'delete',
|
||||||
|
/* ns */ 'enhancePostContent',
|
||||||
|
/* description */ sprintf(__('delete %s version number'), 'enhancePostContent')
|
||||||
);
|
);
|
||||||
?>
|
|
342
_widgets.php
342
_widgets.php
|
@ -12,13 +12,12 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->addBehavior(
|
$core->addBehavior(
|
||||||
'initWidgets',
|
'initWidgets',
|
||||||
array('enhancePostContentWidget', 'adminContentList')
|
['enhancePostContentWidget', 'adminContentList']
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,193 +27,186 @@ $core->addBehavior(
|
||||||
*/
|
*/
|
||||||
class enhancePostContentWidget
|
class enhancePostContentWidget
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Admin part for widget that show extracted content
|
* Admin part for widget that show extracted content
|
||||||
*
|
*
|
||||||
* @param dcWidgets $w dcWidgets instance
|
* @param dcWidgets $w dcWidgets instance
|
||||||
*/
|
*/
|
||||||
public static function adminContentList($w)
|
public static function adminContentList($w)
|
||||||
{
|
{
|
||||||
global $core;
|
global $core;
|
||||||
|
|
||||||
$w->create(
|
$w->create(
|
||||||
'epclist',
|
'epclist',
|
||||||
__('Enhance post content'),
|
__('Enhance post content'),
|
||||||
array('enhancePostContentWidget', 'publicContentList'),
|
['enhancePostContentWidget', 'publicContentList'],
|
||||||
null,
|
null,
|
||||||
__('List filtered contents.')
|
__('List filtered contents.')
|
||||||
);
|
);
|
||||||
# Title
|
# Title
|
||||||
$w->epclist->setting(
|
$w->epclist->setting(
|
||||||
'title',
|
'title',
|
||||||
__('Title:'),
|
__('Title:'),
|
||||||
__('In this article'),
|
__('In this article'),
|
||||||
'text'
|
'text'
|
||||||
);
|
);
|
||||||
# Text
|
# Text
|
||||||
$w->epclist->setting(
|
$w->epclist->setting(
|
||||||
'text',
|
'text',
|
||||||
__('Description:'),
|
__('Description:'),
|
||||||
'',
|
'',
|
||||||
'text'
|
'text'
|
||||||
);
|
);
|
||||||
# Type
|
# Type
|
||||||
$filters = libEPC::blogFilters();
|
$filters = libEPC::blogFilters();
|
||||||
$types = array();
|
$types = [];
|
||||||
foreach($filters as $name => $filter)
|
foreach($filters as $name => $filter) {
|
||||||
{
|
if (!isset($filter['widgetListFilter'])
|
||||||
if (!isset($filter['widgetListFilter'])
|
|| !is_callable($filter['widgetListFilter'])) {
|
||||||
|| !is_callable($filter['widgetListFilter'])
|
continue;
|
||||||
) {
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$types[__($name)] = $name;
|
$types[__($name)] = $name;
|
||||||
}
|
}
|
||||||
$w->epclist->setting(
|
$w->epclist->setting(
|
||||||
'type',
|
'type',
|
||||||
__('Type:'),
|
__('Type:'),
|
||||||
'Definition',
|
'Definition',
|
||||||
'combo',
|
'combo',
|
||||||
$types
|
$types
|
||||||
);
|
);
|
||||||
# Content
|
# Content
|
||||||
$contents = libEPC::defaultAllowedWidgetValues();
|
$contents = libEPC::defaultAllowedWidgetValues();
|
||||||
foreach($contents as $k => $v) {
|
foreach($contents as $k => $v) {
|
||||||
$w->epclist->setting(
|
$w->epclist->setting(
|
||||||
'content'.$v['id'],
|
'content' . $v['id'],
|
||||||
sprintf(__('Enable filter on %s'), __($k)),
|
sprintf(__('Enable filter on %s'), __($k)),
|
||||||
1,
|
1,
|
||||||
'check'
|
'check'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
# Case sensitive
|
# Case sensitive
|
||||||
$w->epclist->setting(
|
$w->epclist->setting(
|
||||||
'nocase',
|
'nocase',
|
||||||
__('Search case insensitive'),
|
__('Search case insensitive'),
|
||||||
0,
|
0,
|
||||||
'check'
|
'check'
|
||||||
);
|
);
|
||||||
# Plural
|
# Plural
|
||||||
$w->epclist->setting(
|
$w->epclist->setting(
|
||||||
'plural',
|
'plural',
|
||||||
__('Search also plural'),
|
__('Search also plural'),
|
||||||
0,
|
0,
|
||||||
'check'
|
'check'
|
||||||
);
|
);
|
||||||
# Show count
|
# Show count
|
||||||
$w->epclist->setting(
|
$w->epclist->setting(
|
||||||
'show_total',
|
'show_total',
|
||||||
__('Show the number of appearance'),
|
__('Show the number of appearance'),
|
||||||
1,
|
1,
|
||||||
'check'
|
'check'
|
||||||
);
|
);
|
||||||
# widget option - content only
|
# widget option - content only
|
||||||
$w->epclist->setting(
|
$w->epclist->setting(
|
||||||
'content_only',
|
'content_only',
|
||||||
__('Content only'),
|
__('Content only'),
|
||||||
0,
|
0,
|
||||||
'check'
|
'check'
|
||||||
);
|
);
|
||||||
# widget option - additionnal CSS
|
# widget option - additionnal CSS
|
||||||
$w->epclist->setting(
|
$w->epclist->setting(
|
||||||
'class',
|
'class',
|
||||||
__('CSS class:'),
|
__('CSS class:'),
|
||||||
''
|
''
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public part for widget that show extracted content
|
* Public part for widget that show extracted content
|
||||||
*
|
*
|
||||||
* @param dcWidget $w dcWidget instance
|
* @param dcWidget $w dcWidget instance
|
||||||
*/
|
*/
|
||||||
public static function publicContentList($w)
|
public static function publicContentList($w)
|
||||||
{
|
{
|
||||||
global $core, $_ctx;
|
global $core, $_ctx;
|
||||||
|
|
||||||
$core->blog->settings->addNamespace('enhancePostContent');
|
$core->blog->settings->addNamespace('enhancePostContent');
|
||||||
|
|
||||||
# Page
|
# Page
|
||||||
if (!$core->blog->settings->enhancePostContent->enhancePostContent_active
|
if (!$core->blog->settings->enhancePostContent->enhancePostContent_active
|
||||||
|| !in_array($_ctx->current_tpl,array('post.html','page.html'))
|
|| !in_array($_ctx->current_tpl, ['post.html', 'page.html'])) {
|
||||||
) {
|
return null;
|
||||||
return null;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# Content
|
# Content
|
||||||
$content = '';
|
$content = '';
|
||||||
$allowedwidgetvalues = libEPC::defaultAllowedWidgetValues();
|
$allowedwidgetvalues = libEPC::defaultAllowedWidgetValues();
|
||||||
foreach($allowedwidgetvalues as $k => $v) {
|
foreach($allowedwidgetvalues as $k => $v) {
|
||||||
|
|
||||||
$ns = 'content'.$v['id'];
|
$ns = 'content' . $v['id'];
|
||||||
if ($w->$ns && is_callable($v['callback'])) {
|
if ($w->$ns && is_callable($v['callback'])) {
|
||||||
|
|
||||||
$content .= call_user_func_array(
|
$content .= call_user_func_array(
|
||||||
$v['callback'],
|
$v['callback'],
|
||||||
array($core,$w)
|
[$core, $w]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($content)) {
|
if (empty($content)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
# Filter
|
||||||
}
|
$list = [];
|
||||||
|
$filters = libEPC::blogFilters();
|
||||||
|
|
||||||
# Filter
|
if (isset($filters[$w->type])
|
||||||
$list = array();
|
&& isset($filters[$w->type]['widgetListFilter'])
|
||||||
$filters = libEPC::blogFilters();
|
&& is_callable($filters[$w->type]['widgetListFilter'])) {
|
||||||
|
$filters[$w->type]['nocase'] = $w->nocase;
|
||||||
|
$filters[$w->type]['plural'] = $w->plural;
|
||||||
|
|
||||||
if (isset($filters[$w->type])
|
if ($filters[$w->type]['has_list']) {
|
||||||
&& isset($filters[$w->type]['widgetListFilter'])
|
$records = new epcRecords($core);
|
||||||
&& is_callable($filters[$w->type]['widgetListFilter'])
|
$filters[$w->type]['list'] = $records->getRecords(
|
||||||
) {
|
['epc_filter' => $w->type]
|
||||||
$filters[$w->type]['nocase'] = $w->nocase;
|
);
|
||||||
$filters[$w->type]['plural'] = $w->plural;
|
}
|
||||||
|
|
||||||
if ($filters[$w->type]['has_list']) {
|
call_user_func_array(
|
||||||
$records = new epcRecords($core);
|
$filters[$w->type]['widgetListFilter'],
|
||||||
$filters[$w->type]['list'] = $records->getRecords(
|
[$core, $filters[$w->type], $content, $w, &$list]
|
||||||
array('epc_filter' => $w->type)
|
);
|
||||||
);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
call_user_func_array(
|
if (empty($list)) {
|
||||||
$filters[$w->type]['widgetListFilter'],
|
return null;
|
||||||
array($core, $filters[$w->type], $content, $w, &$list)
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (empty($list)) {
|
# Parse result
|
||||||
|
$res = '';
|
||||||
|
foreach($list as $line) {
|
||||||
|
if (empty($line['matches'][0]['match'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
$res .=
|
||||||
}
|
'<li>' . $line['matches'][0]['match'] .
|
||||||
|
($w->show_total ? ' (' . $line['total'] .')' : '') .
|
||||||
|
'</li>';
|
||||||
|
}
|
||||||
|
|
||||||
# Parse result
|
if (empty($res)) {
|
||||||
$res = '';
|
return null;
|
||||||
foreach($list as $line) {
|
}
|
||||||
if (empty($line['matches'][0]['match'])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$res .=
|
return
|
||||||
'<li>'.$line['matches'][0]['match'].
|
($w->content_only ? '' : '<div class="epc-widgetlist' .
|
||||||
($w->show_total ? ' ('.$line['total'].')' : '').
|
($w->class ? ' ' . html::escapeHTML($w->class) : '') . '"">') .
|
||||||
'</li>';
|
($w->title ? '<h2>' . html::escapeHTML($w->title) . '</h2>' : '') .
|
||||||
}
|
($w->text ? '<p>' . html::escapeHTML($w->text) . '</p>' : '') .
|
||||||
|
'<ul>' . $res . '</ul>' .
|
||||||
if (empty($res)) {
|
($w->content_only ? '' : '</div>');
|
||||||
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
($w->content_only ? '' : '<div class="epc-widgetlist'.
|
|
||||||
($w->class ? ' '.html::escapeHTML($w->class) : '').'"">').
|
|
||||||
($w->title ? '<h2>'.html::escapeHTML($w->title).'</h2>' : '').
|
|
||||||
($w->text ? '<p>'.html::escapeHTML($w->text).'</p>' : '').
|
|
||||||
'<ul>'.$res.'</ul>'.
|
|
||||||
($w->content_only ? '' : '</div>');
|
|
||||||
}
|
|
||||||
}
|
}
|
1550
inc/lib.epc.php
1550
inc/lib.epc.php
File diff suppressed because it is too large
Load diff
|
@ -13,212 +13,179 @@
|
||||||
|
|
||||||
class epcRecords
|
class epcRecords
|
||||||
{
|
{
|
||||||
public $core;
|
public $core;
|
||||||
public $con;
|
public $con;
|
||||||
public $table;
|
public $table;
|
||||||
public $blog;
|
public $blog;
|
||||||
|
|
||||||
public function __construct($core)
|
public function __construct($core)
|
||||||
{
|
{
|
||||||
$this->core = $core;
|
$this->core = $core;
|
||||||
$this->con = $core->con;
|
$this->con = $core->con;
|
||||||
$this->table = $core->prefix.'epc';
|
$this->table = $core->prefix . 'epc';
|
||||||
$this->blog = $core->con->escape($core->blog->id);
|
$this->blog = $core->con->escape($core->blog->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRecords($params,$count_only=false)
|
public function getRecords($params, $count_only = false)
|
||||||
{
|
{
|
||||||
if ($count_only)
|
if ($count_only) {
|
||||||
{
|
$strReq = 'SELECT count(E.epc_id) ';
|
||||||
$strReq = 'SELECT count(E.epc_id) ';
|
} else {
|
||||||
}
|
$content_req = '';
|
||||||
else
|
if (!empty($params['columns']) && is_array($params['columns'])) {
|
||||||
{
|
$content_req .= implode(', ', $params['columns']) . ', ';
|
||||||
$content_req = '';
|
}
|
||||||
if (!empty($params['columns']) && is_array($params['columns']))
|
$strReq =
|
||||||
{
|
'SELECT E.epc_id, E.blog_id, E.epc_type, E.epc_upddt, ' .
|
||||||
$content_req .= implode(', ',$params['columns']).', ';
|
$content_req .
|
||||||
}
|
'E.epc_filter, E.epc_key, E.epc_value ';
|
||||||
$strReq =
|
}
|
||||||
'SELECT E.epc_id, E.blog_id, E.epc_type, E.epc_upddt, '.
|
|
||||||
$content_req.
|
|
||||||
'E.epc_filter, E.epc_key, E.epc_value ';
|
|
||||||
}
|
|
||||||
|
|
||||||
$strReq .=
|
$strReq .=
|
||||||
'FROM '.$this->table.' E ';
|
'FROM ' . $this->table . ' E ';
|
||||||
|
|
||||||
if (!empty($params['from']))
|
if (!empty($params['from'])) {
|
||||||
{
|
$strReq .= $params['from'] . ' ';
|
||||||
$strReq .= $params['from'].' ';
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$strReq .= "WHERE E.blog_id = '".$this->blog."' ";
|
$strReq .= "WHERE E.blog_id = '" . $this->blog . "' ";
|
||||||
|
|
||||||
if (isset($params['epc_type']))
|
if (isset($params['epc_type'])) {
|
||||||
{
|
if (is_array($params['epc_type']) && !empty($params['epc_type'])) {
|
||||||
if (is_array($params['epc_type']) && !empty($params['epc_type']))
|
$strReq .= 'AND E.epc_type ' . $this->con->in($params['epc_type']);
|
||||||
{
|
} elseif ($params['epc_type'] != '') {
|
||||||
$strReq .= 'AND E.epc_type '.$this->con->in($params['epc_type']);
|
$strReq .= "AND E.epc_type = '" . $this->con->escape($params['epc_type']) . "' ";
|
||||||
}
|
}
|
||||||
elseif ($params['epc_type'] != '')
|
} else {
|
||||||
{
|
$strReq .= "AND E.epc_type = 'epc' ";
|
||||||
$strReq .= "AND E.epc_type = '".$this->con->escape($params['epc_type'])."' ";
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$strReq .= "AND E.epc_type = 'epc' ";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($params['epc_filter']))
|
if (isset($params['epc_filter'])) {
|
||||||
{
|
if (is_array($params['epc_filter']) && !empty($params['epc_filter'])) {
|
||||||
if (is_array($params['epc_filter']) && !empty($params['epc_filter']))
|
$strReq .= 'AND E.epc_filter ' . $this->con->in($params['epc_filter']);
|
||||||
{
|
} elseif ($params['epc_filter'] != '') {
|
||||||
$strReq .= 'AND E.epc_filter '.$this->con->in($params['epc_filter']);
|
$strReq .= "AND E.epc_filter = '" . $this->con->escape($params['epc_filter']) . "' ";
|
||||||
}
|
}
|
||||||
elseif ($params['epc_filter'] != '')
|
}
|
||||||
{
|
|
||||||
$strReq .= "AND E.epc_filter = '".$this->con->escape($params['epc_filter'])."' ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($params['epc_id']))
|
if (!empty($params['epc_id'])) {
|
||||||
{
|
if (is_array($params['epc_id'])) {
|
||||||
if (is_array($params['epc_id']))
|
array_walk($params['epc_id'], create_function('&$v,$k', 'if($v!==null){$v=(integer)$v;}'));
|
||||||
{
|
} else {
|
||||||
array_walk($params['epc_id'],create_function('&$v,$k','if($v!==null){$v=(integer)$v;}'));
|
$params['epc_id'] = [(integer) $params['epc_id']];
|
||||||
}
|
}
|
||||||
else
|
$strReq .= 'AND E.epc_id ' . $this->con->in($params['epc_id']);
|
||||||
{
|
}
|
||||||
$params['epc_id'] = array((integer) $params['epc_id']);
|
|
||||||
}
|
|
||||||
$strReq .= 'AND E.epc_id '.$this->con->in($params['epc_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($params['sql']))
|
if (!empty($params['sql'])) {
|
||||||
{
|
$strReq .= $params['sql'] . ' ';
|
||||||
$strReq .= $params['sql'].' ';
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!$count_only)
|
if (!$count_only) {
|
||||||
{
|
if (!empty($params['order'])) {
|
||||||
if (!empty($params['order']))
|
$strReq .= 'ORDER BY ' . $this->con->escape($params['order']) . ' ';
|
||||||
{
|
} else {
|
||||||
$strReq .= 'ORDER BY '.$this->con->escape($params['order']).' ';
|
$strReq .= 'ORDER BY E.epc_key ASC ';
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
|
||||||
$strReq .= 'ORDER BY E.epc_key ASC ';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$count_only && !empty($params['limit']))
|
if (!$count_only && !empty($params['limit'])) {
|
||||||
{
|
$strReq .= $this->con->limit($params['limit']);
|
||||||
$strReq .= $this->con->limit($params['limit']);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return $this->con->select($strReq);
|
return $this->con->select($strReq);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addRecord($cur)
|
public function addRecord($cur)
|
||||||
{
|
{
|
||||||
$this->con->writeLock($this->table);
|
$this->con->writeLock($this->table);
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
$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)
|
$this->con->unlock();
|
||||||
{
|
throw $e;
|
||||||
$this->con->unlock();
|
}
|
||||||
throw $e;
|
$this->trigger();
|
||||||
}
|
|
||||||
$this->trigger();
|
|
||||||
|
|
||||||
# --BEHAVIOR-- enhancePostContentAfterAddRecord
|
# --BEHAVIOR-- enhancePostContentAfterAddRecord
|
||||||
$this->core->callBehavior('enhancePostContentAfterAddRecord',$cur);
|
$this->core->callBehavior('enhancePostContentAfterAddRecord', $cur);
|
||||||
|
|
||||||
return $cur->epc_id;
|
return $cur->epc_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updRecord($id,$cur)
|
public function updRecord($id, $cur)
|
||||||
{
|
{
|
||||||
$id = (integer) $id;
|
$id = (integer) $id;
|
||||||
|
|
||||||
if (empty($id))
|
if (empty($id)) {
|
||||||
{
|
throw new Exception(__('No such record ID'));
|
||||||
throw new Exception(__('No such record ID'));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$cur->epc_upddt = date('Y-m-d H:i:s');
|
$cur->epc_upddt = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
$cur->update("WHERE epc_id = ".$id." AND blog_id = '".$this->blog."' ");
|
$cur->update("WHERE epc_id = " . $id . " AND blog_id = '" . $this->blog . "' ");
|
||||||
$this->trigger();
|
$this->trigger();
|
||||||
|
|
||||||
# --BEHAVIOR-- enhancePostContentAfterUpdRecord
|
# --BEHAVIOR-- enhancePostContentAfterUpdRecord
|
||||||
$this->core->callBehavior('enhancePostContentAfterUpdRecord',$cur,$id);
|
$this->core->callBehavior('enhancePostContentAfterUpdRecord', $cur, $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delRecord($id)
|
public function delRecord($id)
|
||||||
{
|
{
|
||||||
$id = (integer) $id;
|
$id = (integer) $id;
|
||||||
|
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
throw new Exception(__('No such record ID'));
|
throw new Exception(__('No such record ID'));
|
||||||
}
|
}
|
||||||
|
|
||||||
# --BEHAVIOR-- enhancePostContentBeforeDelRecord
|
# --BEHAVIOR-- enhancePostContentBeforeDelRecord
|
||||||
$this->core->callBehavior('enhancePostContentbeforeDelRecord',$id);
|
$this->core->callBehavior('enhancePostContentbeforeDelRecord', $id);
|
||||||
|
|
||||||
$this->con->execute(
|
$this->con->execute(
|
||||||
'DELETE FROM '.$this->table.' '.
|
'DELETE FROM ' . $this->table . ' ' .
|
||||||
'WHERE epc_id = '.$id.' '.
|
'WHERE epc_id = ' . $id .' ' .
|
||||||
"AND blog_id = '".$this->blog."' "
|
"AND blog_id = '" . $this->blog . "' "
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->trigger();
|
$this->trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getNextId()
|
private function getNextId()
|
||||||
{
|
{
|
||||||
return $this->con->select(
|
return $this->con->select(
|
||||||
'SELECT MAX(epc_id) FROM '.$this->table.' '
|
'SELECT MAX(epc_id) FROM ' . $this->table . ' '
|
||||||
)->f(0) + 1;
|
)->f(0) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function openCursor()
|
public function openCursor()
|
||||||
{
|
{
|
||||||
return $this->con->openCursor($this->table);
|
return $this->con->openCursor($this->table);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getCursor($cur,$epc_id=null)
|
private function getCursor($cur, $epc_id = null)
|
||||||
{
|
{
|
||||||
if ($cur->epc_key == '')
|
if ($cur->epc_key == '') {
|
||||||
{
|
throw new Exception(__('No record key'));
|
||||||
throw new Exception(__('No record key'));
|
}
|
||||||
}
|
if ($cur->epc_value == '') {
|
||||||
if ($cur->epc_value == '')
|
throw new Exception(__('No record value'));
|
||||||
{
|
}
|
||||||
throw new Exception(__('No record value'));
|
if ($cur->epc_filter == '') {
|
||||||
}
|
throw new Exception(__('No record filter'));
|
||||||
if ($cur->epc_filter == '')
|
}
|
||||||
{
|
$epc_id = is_int($epc_id) ? $epc_id : $cur->epc_id;
|
||||||
throw new Exception(__('No record filter'));
|
}
|
||||||
}
|
|
||||||
$epc_id = is_int($epc_id) ? $epc_id : $cur->epc_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function trigger()
|
private function trigger()
|
||||||
{
|
{
|
||||||
$this->core->blog->triggerBlog();
|
$this->core->blog->triggerBlog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
|
@ -13,31 +13,26 @@
|
||||||
|
|
||||||
# This file only update old filters lists from settings to database
|
# This file only update old filters lists from settings to database
|
||||||
|
|
||||||
$f = $core->con->select("SELECT * FROM ".$core->prefix."setting WHERE setting_ns='enhancePostContent' AND blog_id IS NOT NULL ");
|
$f = $core->con->select("SELECT * FROM " . $core->prefix . "setting WHERE setting_ns='enhancePostContent' AND blog_id IS NOT NULL ");
|
||||||
|
|
||||||
while ($f->fetch())
|
while ($f->fetch()) {
|
||||||
{
|
if (preg_match('#enhancePostContent_(.*?)List#', $f->setting_id, $m)) {
|
||||||
if (preg_match('#enhancePostContent_(.*?)List#',$f->setting_id,$m))
|
$curlist = @unserialize($f->setting_value);
|
||||||
{
|
if (is_array($curlist)) {
|
||||||
$curlist = @unserialize($f->setting_value);
|
foreach($curlist as $k => $v) {
|
||||||
if (is_array($curlist))
|
$cur = $core->con->openCursor($core->prefix . 'epc');
|
||||||
{
|
$core->con->writeLock($core->prefix . 'epc');
|
||||||
foreach($curlist as $k => $v)
|
|
||||||
{
|
|
||||||
$cur = $core->con->openCursor($core->prefix.'epc');
|
|
||||||
$core->con->writeLock($core->prefix.'epc');
|
|
||||||
|
|
||||||
$cur->epc_id = $core->con->select('SELECT MAX(epc_id) FROM '.$core->prefix.'epc'.' ')->f(0) + 1;
|
$cur->epc_id = $core->con->select('SELECT MAX(epc_id) FROM ' . $core->prefix . 'epc' . ' ')->f(0) + 1;
|
||||||
$cur->blog_id = $f->blog_id;
|
$cur->blog_id = $f->blog_id;
|
||||||
$cur->epc_filter = $m[1];
|
$cur->epc_filter = $m[1];
|
||||||
$cur->epc_key = $k;
|
$cur->epc_key = $k;
|
||||||
$cur->epc_value = $v;
|
$cur->epc_value = $v;
|
||||||
|
|
||||||
$cur->insert();
|
$cur->insert();
|
||||||
$core->con->unlock();
|
$core->con->unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$core->con->execute("DELETE FROM ".$core->prefix."setting WHERE setting_id='".$f->setting_id."' AND setting_ns='enhancePostContent' AND blog_id='".$f->blog_id."' ");
|
$core->con->execute("DELETE FROM " . $core->prefix . "setting WHERE setting_id='" . $f->setting_id . "' AND setting_ns='enhancePostContent' AND blog_id='" . $f->blog_id . "' ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
|
612
index.php
612
index.php
|
@ -12,8 +12,7 @@
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dcPage::check('contentadmin');
|
dcPage::check('contentadmin');
|
||||||
|
@ -26,7 +25,7 @@ $s = $core->blog->settings->enhancePostContent;
|
||||||
$_filters = libEPC::blogFilters();
|
$_filters = libEPC::blogFilters();
|
||||||
$filters_id = array();
|
$filters_id = array();
|
||||||
foreach($_filters as $name => $filter) {
|
foreach($_filters as $name => $filter) {
|
||||||
$filters_id[$filter['id']] = $name;
|
$filters_id[$filter['id']] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
||||||
|
@ -37,404 +36,391 @@ $records = new epcRecords($core);
|
||||||
# -- Action --
|
# -- Action --
|
||||||
|
|
||||||
if (!empty($action)) {
|
if (!empty($action)) {
|
||||||
# --BEHAVIOR-- enhancePostContentAdminSave
|
# --BEHAVIOR-- enhancePostContentAdminSave
|
||||||
$core->callBehavior('enhancePostContentAdminSave',$core);
|
$core->callBehavior('enhancePostContentAdminSave', $core);
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
# Update filter settings
|
||||||
# Update filter settings
|
if ($action == 'savefiltersetting'
|
||||||
if ($action == 'savefiltersetting'
|
&& isset($filters_id[$default_part])) {
|
||||||
&& isset($filters_id[$default_part])
|
# Parse filters options
|
||||||
) {
|
$name = $filters_id[$default_part];
|
||||||
# Parse filters options
|
$f = [
|
||||||
$name = $filters_id[$default_part];
|
'nocase' => !empty($_POST['filter_nocase']),
|
||||||
$f = array(
|
'plural' => !empty($_POST['filter_plural']),
|
||||||
'nocase' => !empty($_POST['filter_nocase']),
|
'limit' => abs((integer) $_POST['filter_limit']),
|
||||||
'plural' => !empty($_POST['filter_plural']),
|
'style' => (array) $_POST['filter_style'],
|
||||||
'limit' => abs((integer) $_POST['filter_limit']),
|
'notag' => (string) $_POST['filter_notag'],
|
||||||
'style' => (array) $_POST['filter_style'],
|
'tplValues' => (array) $_POST['filter_tplValues'],
|
||||||
'notag' => (string) $_POST['filter_notag'],
|
'pubPages' => (array) $_POST['filter_pubPages']
|
||||||
'tplValues' => (array) $_POST['filter_tplValues'],
|
];
|
||||||
'pubPages' => (array) $_POST['filter_pubPages']
|
|
||||||
);
|
|
||||||
|
|
||||||
$s->put('enhancePostContent_'.$name, serialize($f));
|
$s->put('enhancePostContent_' . $name, serialize($f));
|
||||||
|
|
||||||
$core->blog->triggerBlog();
|
$core->blog->triggerBlog();
|
||||||
|
|
||||||
dcPage::addSuccessNotice(
|
dcPage::addSuccessNotice(
|
||||||
__('Filter successfully updated.')
|
__('Filter successfully updated.')
|
||||||
);
|
);
|
||||||
http::redirect(
|
http::redirect(
|
||||||
$p_url.'part='.$default_part.'#setting'
|
$p_url . 'part=' . $default_part . '#setting'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add new filter record
|
# Add new filter record
|
||||||
if ($action == 'savenewrecord'
|
if ($action == 'savenewrecord'
|
||||||
&& isset($filters_id[$default_part])
|
&& isset($filters_id[$default_part])
|
||||||
&& !empty($_POST['new_key'])
|
&& !empty($_POST['new_key'])
|
||||||
&& !empty($_POST['new_value'])
|
&& !empty($_POST['new_value'])) {
|
||||||
) {
|
$cur = $records->openCursor();
|
||||||
$cur = $records->openCursor();
|
$cur->epc_filter = $filters_id[$default_part];
|
||||||
$cur->epc_filter = $filters_id[$default_part];
|
$cur->epc_key = html::escapeHTML($_POST['new_key']);
|
||||||
$cur->epc_key = html::escapeHTML($_POST['new_key']);
|
$cur->epc_value = html::escapeHTML($_POST['new_value']);
|
||||||
$cur->epc_value = html::escapeHTML($_POST['new_value']);
|
$records->addRecord($cur);
|
||||||
$records->addRecord($cur);
|
|
||||||
|
|
||||||
$core->blog->triggerBlog();
|
$core->blog->triggerBlog();
|
||||||
|
|
||||||
dcPage::addSuccessNotice(
|
dcPage::addSuccessNotice(
|
||||||
__('Filter successfully updated.')
|
__('Filter successfully updated.')
|
||||||
);
|
);
|
||||||
http::redirect(
|
http::redirect(
|
||||||
$p_url.'&part='.$default_part.'#record'
|
$p_url . '&part=' . $default_part . '#record'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update filter records
|
# Update filter records
|
||||||
if ($action == 'saveupdaterecords'
|
if ($action == 'saveupdaterecords'
|
||||||
&& isset($filters_id[$default_part])
|
&& isset($filters_id[$default_part])
|
||||||
&& $_filters[$filters_id[$default_part]]['has_list']
|
&& $_filters[$filters_id[$default_part]]['has_list']) {
|
||||||
) {
|
foreach($_POST['epc_id'] as $k => $id) {
|
||||||
foreach($_POST['epc_id'] as $k => $id) {
|
|
||||||
|
|
||||||
$k = abs((integer) $k);
|
$k = abs((integer) $k);
|
||||||
$id = abs((integer) $id);
|
$id = abs((integer) $id);
|
||||||
|
|
||||||
if (empty($_POST['epc_key'][$k])
|
if (empty($_POST['epc_key'][$k])
|
||||||
|| empty($_POST['epc_value'][$k])
|
|| empty($_POST['epc_value'][$k])) {
|
||||||
) {
|
$records->delRecord($id);
|
||||||
$records->delRecord($id);
|
} elseif ($_POST['epc_key'][$k] != $_POST['epc_old_key'][$k]
|
||||||
}
|
|| $_POST['epc_value'][$k] != $_POST['epc_old_value'][$k]) {
|
||||||
elseif ($_POST['epc_key'][$k] != $_POST['epc_old_key'][$k]
|
$cur = $records->openCursor();
|
||||||
|| $_POST['epc_value'][$k] != $_POST['epc_old_value'][$k]
|
$cur->epc_filter = $filters_id[$default_part];
|
||||||
) {
|
$cur->epc_key = html::escapeHTML($_POST['epc_key'][$k]);
|
||||||
$cur = $records->openCursor();
|
$cur->epc_value = html::escapeHTML($_POST['epc_value'][$k]);
|
||||||
$cur->epc_filter = $filters_id[$default_part];
|
$records->updRecord($id, $cur);
|
||||||
$cur->epc_key = html::escapeHTML($_POST['epc_key'][$k]);
|
}
|
||||||
$cur->epc_value = html::escapeHTML($_POST['epc_value'][$k]);
|
}
|
||||||
$records->updRecord($id,$cur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$core->blog->triggerBlog();
|
$core->blog->triggerBlog();
|
||||||
|
|
||||||
$redir = !empty($_REQUEST['redir']) ?
|
$redir = !empty($_REQUEST['redir']) ?
|
||||||
$_REQUEST['redir'] :
|
$_REQUEST['redir'] :
|
||||||
$p_url.'&part='.$default_part.'#record';
|
$p_url . '&part=' . $default_part . '#record';
|
||||||
|
|
||||||
dcPage::addSuccessNotice(
|
dcPage::addSuccessNotice(
|
||||||
__('Filter successfully updated.')
|
__('Filter successfully updated.')
|
||||||
);
|
);
|
||||||
http::redirect(
|
http::redirect(
|
||||||
$redir
|
$redir
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
} catch(Exception $e) {
|
||||||
catch(Exception $e) {
|
$core->error->add($e->getMessage());
|
||||||
$core->error->add($e->getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- Prepare page --
|
# -- Prepare page --
|
||||||
|
|
||||||
$breadcrumb = array(
|
$breadcrumb = [
|
||||||
html::escapeHTML($core->blog->name) => '',
|
html::escapeHTML($core->blog->name) => '',
|
||||||
__('Enhance post content') => $p_url
|
__('Enhance post content') => $p_url
|
||||||
);
|
];
|
||||||
$top_menu = array();
|
$top_menu = [];
|
||||||
|
|
||||||
foreach($filters_id as $id => $name) {
|
foreach($filters_id as $id => $name) {
|
||||||
|
|
||||||
$active = '';
|
$active = '';
|
||||||
if ($default_part == $id) {
|
if ($default_part == $id) {
|
||||||
$breadcrumb[__($filters_id[$default_part])] = '';
|
$breadcrumb[__($filters_id[$default_part])] = '';
|
||||||
$active = ' class="active"';
|
$active = ' class="active"';
|
||||||
}
|
}
|
||||||
|
|
||||||
$top_menu[] =
|
$top_menu[] =
|
||||||
'<a'.$active.' href="'.$p_url.'&part='.$id.'">'.__($name).'</a>';
|
'<a' . $active . ' href="' . $p_url . '&part=' . $id . '">' . __($name) . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- Display page --
|
# -- Display page --
|
||||||
|
|
||||||
# Headers
|
# Headers
|
||||||
echo '
|
echo '
|
||||||
<html><head><title>'.__('Enhance post content').'</title>'.
|
<html><head><title>' . __('Enhance post content') . '</title>' .
|
||||||
dcPage::jsLoad('js/_posts_list.js').
|
dcPage::jsLoad('js/_posts_list.js') .
|
||||||
dcPage::jsToolbar().
|
dcPage::jsToolbar() .
|
||||||
dcPage::jsPageTabs().
|
dcPage::jsPageTabs() .
|
||||||
|
|
||||||
# --BEHAVIOR-- enhancePostContentAdminHeader
|
# --BEHAVIOR-- enhancePostContentAdminHeader
|
||||||
$core->callBehavior('enhancePostContentAdminHeader',$core).'
|
$core->callBehavior('enhancePostContentAdminHeader', $core) . '
|
||||||
|
|
||||||
</head><body>'.
|
</head><body>' .
|
||||||
|
|
||||||
# Title
|
# Title
|
||||||
dcPage::breadcrumb($breadcrumb).
|
dcPage::breadcrumb($breadcrumb) .
|
||||||
dcPage::notices().
|
dcPage::notices() .
|
||||||
|
|
||||||
# Filters list
|
# Filters list
|
||||||
'<ul class="pseudo-tabs">'.
|
'<ul class="pseudo-tabs">' .
|
||||||
'<li>'.implode('</li><li>', $top_menu).'</li>'.
|
'<li>' . implode('</li><li>', $top_menu) . '</li>' .
|
||||||
'</ul>';
|
'</ul>';
|
||||||
|
|
||||||
# Filter content
|
# Filter content
|
||||||
if (isset($filters_id[$default_part])) {
|
if (isset($filters_id[$default_part])) {
|
||||||
|
|
||||||
$name = $filters_id[$default_part];
|
$name = $filters_id[$default_part];
|
||||||
$filter = $_filters[$name];
|
$filter = $_filters[$name];
|
||||||
|
|
||||||
# Filter title and description
|
# Filter title and description
|
||||||
echo '
|
echo '
|
||||||
<h3>'.__($filters_id[$default_part]).'</h3>
|
<h3>' . __($filters_id[$default_part]) . '</h3>
|
||||||
<p>'.$filter['help'].'</p>';
|
<p>' . $filter['help'] . '</p>';
|
||||||
|
|
||||||
# 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="'.$p_url.'&part='.$default_part.'&tab=setting"><div>';
|
<form method="post" action="' . $p_url . '&part=' . $default_part . '&tab=setting"><div>';
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<div class="two-boxes odd">
|
'<div class="two-boxes odd">
|
||||||
<h4>'.__('Pages to be filtered').'</h4>';
|
<h4>' . __('Pages to be filtered') . '</h4>';
|
||||||
|
|
||||||
foreach(libEPC::blogAllowedPubPages() as $k => $v) {
|
foreach(libEPC::blogAllowedPubPages() as $k => $v) {
|
||||||
echo '
|
echo '
|
||||||
<p><label for="filter_pubPages'.$v.'">'.
|
<p><label for="filter_pubPages' . $v . '">' .
|
||||||
form::checkbox(
|
form::checkbox(
|
||||||
array('filter_pubPages[]', 'filter_pubPages'.$v),
|
['filter_pubPages[]', 'filter_pubPages' . $v],
|
||||||
$v,
|
$v,
|
||||||
in_array($v,$filter['pubPages'])
|
in_array($v, $filter['pubPages'])
|
||||||
).
|
) .
|
||||||
__($k).'</label></p>';
|
__($k) . '</label></p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<div class="two-boxes even">
|
'<div class="two-boxes even">
|
||||||
<h4>'.__('Filtering').'</h4>
|
<h4>' . __('Filtering') . '</h4>
|
||||||
|
|
||||||
<p><label for="filter_nocase">'.
|
<p><label for="filter_nocase">' .
|
||||||
form::checkbox('filter_nocase', '1', $filter['nocase']).
|
form::checkbox('filter_nocase', '1', $filter['nocase']) .
|
||||||
__('Case insensitive').'</label></p>
|
__('Case insensitive') . '</label></p>
|
||||||
|
|
||||||
<p><label for="filter_plural">'.
|
<p><label for="filter_plural">' .
|
||||||
form::checkbox('filter_plural', '1', $filter['plural']).
|
form::checkbox('filter_plural', '1', $filter['plural']) .
|
||||||
__('Also use the plural').'</label></p>
|
__('Also use the plural') . '</label></p>
|
||||||
|
|
||||||
<p><label for="filter_limit">'.
|
<p><label for="filter_limit">' .
|
||||||
__('Limit the number of replacement to:').'</label>'.
|
__('Limit the number of replacement to:') . '</label>' .
|
||||||
form::field('filter_limit', 4, 10, html::escapeHTML($filter['limit'])).'
|
form::field('filter_limit', 4, 10, html::escapeHTML($filter['limit'])) . '
|
||||||
</p>
|
</p>
|
||||||
<p class="form-note">'.__('Leave it blank or set it to 0 for no limit').'</p>
|
<p class="form-note">' . __('Leave it blank or set it to 0 for no limit') . '</p>
|
||||||
|
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<div class="two-boxes odd">
|
'<div class="two-boxes odd">
|
||||||
<h4>'.__('Contents to be filtered').'</h4>';
|
<h4>' . __('Contents to be filtered') . '</h4>';
|
||||||
|
|
||||||
foreach(libEPC::blogAllowedTplValues() as $k => $v) {
|
foreach(libEPC::blogAllowedTplValues() as $k => $v) {
|
||||||
echo '
|
echo '
|
||||||
<p><label for="filter_tplValues'.$v.'">'.
|
<p><label for="filter_tplValues' . $v . '">' .
|
||||||
form::checkbox(
|
form::checkbox(
|
||||||
array('filter_tplValues[]', 'filter_tplValues'.$v),
|
['filter_tplValues[]', 'filter_tplValues' . $v],
|
||||||
$v,
|
$v,
|
||||||
in_array($v,$filter['tplValues'])
|
in_array($v, $filter['tplValues'])
|
||||||
).
|
) .
|
||||||
__($k).'</label></p>';
|
__($k) . '</label></p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'</div>';
|
'</div>';
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<div class="two-boxes even">
|
'<div class="two-boxes even">
|
||||||
<h4>'.__('Style').'</h4>';
|
<h4>' . __('Style') . '</h4>';
|
||||||
|
|
||||||
foreach($filter['class'] as $k => $v) {
|
foreach($filter['class'] as $k => $v) {
|
||||||
echo '
|
echo '
|
||||||
<p><label for="filter_style'.$k.'">'.
|
<p><label for="filter_style' . $k . '">' .
|
||||||
sprintf(__('Class "%s":'),$v).'</label>'.
|
sprintf(__('Class "%s":'), $v) . '</label>' .
|
||||||
form::field(
|
form::field(
|
||||||
array('filter_style[]', 'filter_style'.$k),
|
['filter_style[]', 'filter_style'.$k],
|
||||||
60,
|
60,
|
||||||
255,
|
255,
|
||||||
html::escapeHTML($filter['style'][$k])
|
html::escapeHTML($filter['style'][$k])
|
||||||
).
|
) .
|
||||||
'</p>';
|
'</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<p class="form-note">'.sprintf(__('The inserted HTML tag looks like: %s'), html::escapeHTML(str_replace('%s', '...', $filter['replace']))).'</p>
|
<p class="form-note">' . sprintf(__('The inserted HTML tag looks like: %s'), html::escapeHTML(str_replace('%s', '...', $filter['replace']))) . '</p>
|
||||||
|
|
||||||
<p><label for="filter_notag">'.__('Ignore HTML tags:').'</label>'.
|
<p><label for="filter_notag">' . __('Ignore HTML tags:') . '</label>' .
|
||||||
form::field('filter_notag', 60, 255, html::escapeHTML($filter['notag'])).'
|
form::field('filter_notag', 60, 255, html::escapeHTML($filter['notag'])) . '
|
||||||
</p>
|
</p>
|
||||||
<p class="form-note">'.__('This is the list of HTML tags where content will be ignored.').' '.
|
<p class="form-note">' . __('This is the list of HTML tags where content will be ignored.') . ' ' .
|
||||||
(empty($filter['htmltag']) ? '' : sprintf(__('Tag "%s" always be ignored.'), $filter['htmltag'])).'</p>
|
(empty($filter['htmltag']) ? '' : sprintf(__('Tag "%s" always be ignored.'), $filter['htmltag'])) . '</p>
|
||||||
|
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
echo '</div>
|
echo '</div>
|
||||||
<div class="clear">
|
<div class="clear">
|
||||||
<p>'.
|
<p>' .
|
||||||
$core->formNonce().
|
$core->formNonce() .
|
||||||
form::hidden(array('action'), 'savefiltersetting').'
|
form::hidden(['action'], 'savefiltersetting') . '
|
||||||
<input type="submit" name="save" value="'.__('Save').'" />
|
<input type="submit" name="save" value="' . __('Save') . '" />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
# Filter records list
|
# Filter records list
|
||||||
if ($filter['has_list']) {
|
if ($filter['has_list']) {
|
||||||
|
|
||||||
$sortby_combo = array(
|
$sortby_combo = [
|
||||||
'epc_upddt',
|
'epc_upddt',
|
||||||
'epc_key',
|
'epc_key',
|
||||||
'epc_value',
|
'epc_value',
|
||||||
'epc_id'
|
'epc_id'
|
||||||
);
|
];
|
||||||
|
|
||||||
$order_combo = array(
|
$order_combo = [
|
||||||
'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;
|
||||||
$nb = !empty($_GET['nb']) && (integer) $_GET['nb'] > 0 ? (integer) $_GET['nb'] : (integer) $s->enhancePostContent_list_nb;
|
$nb = !empty($_GET['nb']) && (integer) $_GET['nb'] > 0 ? (integer) $_GET['nb'] : (integer) $s->enhancePostContent_list_nb;
|
||||||
|
|
||||||
$params = array();
|
$params = [];
|
||||||
$params['epc_filter'] = $name;
|
$params['epc_filter'] = $name;
|
||||||
$params['limit'] = array((($page-1)*$nb), $nb);
|
$params['limit'] = [(($page - 1) * $nb), $nb];
|
||||||
|
|
||||||
if ($sortby !== '' && in_array($sortby, $sortby_combo)) {
|
if ($sortby !== '' && in_array($sortby, $sortby_combo)) {
|
||||||
if ($order !== '' && in_array($order, $order_combo)) {
|
if ($order !== '' && in_array($order, $order_combo)) {
|
||||||
$params['order'] = $sortby.' '.$order;
|
$params['order'] = $sortby . ' ' . $order;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$list = $records->getRecords($params);
|
$list = $records->getRecords($params);
|
||||||
$counter = $records->getRecords($params, true);
|
$counter = $records->getRecords($params, true);
|
||||||
}
|
} catch (Exception $e) {
|
||||||
catch (Exception $e) {
|
$core->error->add($e->getMessage());
|
||||||
$core->error->add($e->getMessage());
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$pager_url = $p_url.
|
$pager_url = $p_url .
|
||||||
'&nb='.$nb.
|
'&nb=' . $nb .
|
||||||
'&sortby=%s'.
|
'&sortby=%s' .
|
||||||
'&order='.($order == 'desc' ? 'desc' : 'asc').
|
'&order=' . ($order == 'desc' ? 'desc' : 'asc') .
|
||||||
'&page=%s'.
|
'&page=%s' .
|
||||||
'&part='.$default_part.
|
'&part=' . $default_part .
|
||||||
'#record';
|
'#record';
|
||||||
|
|
||||||
$pager = new pager($page, $counter->f(0), $nb, 10);
|
$pager = new pager($page, $counter->f(0), $nb, 10);
|
||||||
$pager->html_prev = __('«prev.');
|
$pager->html_prev = __('«prev.');
|
||||||
$pager->html_next = __('next»');
|
$pager->html_next = __('next»');
|
||||||
$pager->base_url = sprintf($pager_url, $sortby,'%s');
|
$pager->base_url = sprintf($pager_url, $sortby, '%s');
|
||||||
$pager->var_page = 'page';
|
$pager->var_page = 'page';
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<div class="multi-part" id="record" title="'.__('Records').'">';
|
<div class="multi-part" id="record" title="' . __('Records') . '">';
|
||||||
|
|
||||||
if ($core->error->flag() || $list->isEmpty()) {
|
if ($core->error->flag() || $list->isEmpty()) {
|
||||||
echo '<p>'.__('No record').'</p>';
|
echo '<p>' . __('No record') . '</p>';
|
||||||
}
|
} else {
|
||||||
else {
|
echo '
|
||||||
echo '
|
<form action="' . $pager_url . '" method="post">
|
||||||
<form action="'.$pager_url.'" method="post">
|
<p>' . __('Page(s)') . ' : ' . $pager->getLinks() . '</p>
|
||||||
<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>
|
<table>
|
||||||
<table>
|
<thead><tr>
|
||||||
<thead><tr>
|
<th><a href="' . sprintf($pager_url, 'epc_key', $page) . '">' .
|
||||||
<th><a href="'.sprintf($pager_url, 'epc_key', $page).'">'
|
__('Key') . '</a></th>
|
||||||
.__('Key').'</a></th>
|
<th><a href="' . sprintf($pager_url, 'epc_value', $page) . '">' .
|
||||||
<th><a href="'.sprintf($pager_url, 'epc_value', $page).'">'.
|
__('Value') . '</a></th>
|
||||||
__('Value').'</a></th>
|
<th><a href="' . sprintf($pager_url, 'epc_upddt', $page) . '">' .
|
||||||
<th><a href="'.sprintf($pager_url, 'epc_upddt', $page).'">'.
|
__('Date') . '</a></th>
|
||||||
__('Date').'</a></th>
|
</tr></thead>
|
||||||
</tr></thead>
|
<tbody>';
|
||||||
<tbody>';
|
|
||||||
|
|
||||||
while($list->fetch()) {
|
while($list->fetch()) {
|
||||||
echo '
|
echo '
|
||||||
<tr class="line">
|
<tr class="line">
|
||||||
<td class="nowrap">'.
|
<td class="nowrap">' .
|
||||||
form::hidden(array('epc_id[]'), $list->epc_id).
|
form::hidden(['epc_id[]'], $list->epc_id) .
|
||||||
form::hidden(array('epc_old_key[]'), html::escapeHTML($list->epc_key)).
|
form::hidden(['epc_old_key[]'], html::escapeHTML($list->epc_key)) .
|
||||||
form::hidden(array('epc_old_value[]'), html::escapeHTML($list->epc_value)).
|
form::hidden(['epc_old_value[]'], html::escapeHTML($list->epc_value)) .
|
||||||
form::field(array('epc_key[]'), 30, 225, html::escapeHTML($list->epc_key), '').'</td>
|
form::field(['epc_key[]'], 30, 225, html::escapeHTML($list->epc_key), '') . '</td>
|
||||||
<td class="maximal">'.
|
<td class="maximal">' .
|
||||||
form::field(array('epc_value[]'), 90, 225, html::escapeHTML($list->epc_value), 'maximal').'</td>
|
form::field(['epc_value[]'], 90, 225, html::escapeHTML($list->epc_value), 'maximal') . '</td>
|
||||||
<td class="nowrap">'.
|
<td class="nowrap">' .
|
||||||
dt::dt2str(__('%Y-%m-%d %H:%M'), $list->epc_upddt,$core->auth->getInfo('user_tz')).'</td>
|
dt::dt2str(__('%Y-%m-%d %H:%M'), $list->epc_upddt,$core->auth->getInfo('user_tz')) . '</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<p class="form-note">'.__('In order to remove a record, leave empty its key or value.').'</p>
|
<p class="form-note">' . __('In order to remove a record, leave empty its key or value.') . '</p>
|
||||||
<p>'.__('Page(s)').' : '.$pager->getLinks().'</p>
|
<p>' . __('Page(s)') . ' : ' . $pager->getLinks() . '</p>
|
||||||
|
|
||||||
<div class="clear">
|
<div class="clear">
|
||||||
<p>'.
|
<p>' .
|
||||||
$core->formNonce().
|
$core->formNonce() .
|
||||||
form::hidden(array('redir'), sprintf($pager_url, $sortby, $page)).
|
form::hidden(['redir'], sprintf($pager_url, $sortby, $page)) .
|
||||||
form::hidden(array('action'), 'saveupdaterecords').'
|
form::hidden(['action'], 'saveupdaterecords') . '
|
||||||
<input type="submit" name="save" value="'.__('Save').'" />
|
<input type="submit" name="save" value="' . __('Save') . '" />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</form>';
|
</form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
|
|
||||||
# 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="'.$p_url.'&part='.$default_part.'&tab=setting" method="post">'.
|
<form action="' . $p_url . '&part=' . $default_part . '&tab=setting" method="post">' .
|
||||||
|
|
||||||
'<p><label for="new_key">'.__('Key:').'</label>'.
|
'<p><label for="new_key">' . __('Key:') . '</label>' .
|
||||||
form::field('new_key', 60, 255).
|
form::field('new_key', 60, 255) .
|
||||||
'</p>'.
|
'</p>' .
|
||||||
|
|
||||||
'<p><label for="new_value">'.__('Value:').'</label>'.
|
'<p><label for="new_value">' . __('Value:') . '</label>' .
|
||||||
form::field('new_value', 60, 255).
|
form::field('new_value', 60, 255) .
|
||||||
'</p>
|
'</p>
|
||||||
|
|
||||||
<p class="clear">'.
|
<p class="clear">' .
|
||||||
form::hidden(array('action'), 'savenewrecord').
|
form::hidden(['action'], 'savenewrecord') .
|
||||||
$core->formNonce().'
|
$core->formNonce() . '
|
||||||
<input type="submit" name="save" value="'.__('Save').'" />
|
<input type="submit" name="save" value="' . __('Save') . '" />
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>';
|
</div>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# --BEHAVIOR-- enhancePostContentAdminPage
|
# --BEHAVIOR-- enhancePostContentAdminPage
|
||||||
$core->callBehavior('enhancePostContentAdminPage',$core);
|
$core->callBehavior('enhancePostContentAdminPage', $core);
|
||||||
|
|
||||||
dcPage::helpBlock('enhancePostContent');
|
dcPage::helpBlock('enhancePostContent');
|
||||||
|
|
||||||
# Footers
|
# Footers
|
||||||
echo
|
echo
|
||||||
'<hr class="clear"/><p class="right modules">
|
'<hr class="clear"/><p class="right modules">
|
||||||
<a class="module-config" '.
|
enhancePostContent - ' . $core->plugins->moduleInfo('enhancePostContent', 'version') . '
|
||||||
'href="plugins.php?module=enhancePostContent&conf=1&redir='.
|
<img alt="' . __('enhancePostContent') . '" src="index.php?pf=enhancePostContent/icon.png" />
|
||||||
urlencode('plugin.php?p=enhancePostContent').'">'.__('Configuration').'</a> -
|
|
||||||
enhancePostContent - '.$core->plugins->moduleInfo('enhancePostContent', 'version').'
|
|
||||||
<img alt="'.__('enhancePostContent').'" src="index.php?pf=enhancePostContent/icon.png" />
|
|
||||||
</p>
|
</p>
|
||||||
</body></html>';
|
</body></html>';
|
|
@ -11,7 +11,8 @@
|
||||||
#
|
#
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) { return; }
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$__resources['help']['enhancePostContent'] = dirname(__FILE__).'/help/help.html';
|
$__resources['help']['enhancePostContent'] = dirname(__FILE__) . '/help/help.html';
|
||||||
?>
|
|
|
@ -11,7 +11,8 @@
|
||||||
#
|
#
|
||||||
# -- END LICENSE BLOCK ------------------------------------
|
# -- END LICENSE BLOCK ------------------------------------
|
||||||
|
|
||||||
if (!defined('DC_RC_PATH')) { return; }
|
if (!defined('DC_RC_PATH')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$__resources['help']['enhancePostContent'] = dirname(__FILE__).'/help/help.html';
|
$__resources['help']['enhancePostContent'] = dirname(__FILE__) . '/help/help.html';
|
||||||
?>
|
|
Loading…
Reference in a new issue