fix list and pager, remove record edition
This commit is contained in:
parent
d4eded0c29
commit
2ec18b5b49
5 changed files with 274 additions and 274 deletions
|
@ -17,5 +17,6 @@ if (!defined('DC_RC_PATH')) {
|
||||||
|
|
||||||
$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';
|
||||||
|
$__autoload['adminEpcList'] = $d . 'lib.epc.pager.php';
|
76
inc/lib.epc.pager.php
Normal file
76
inc/lib.epc.pager.php
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup DC_PLUGIN_PERIODICAL
|
||||||
|
* @brief Periodical - admin pager methods.
|
||||||
|
* @since 2.6
|
||||||
|
*/
|
||||||
|
class adminEpcList extends adminGenericList
|
||||||
|
{
|
||||||
|
public function display($filter, $pager_url, $enclose_block='')
|
||||||
|
{
|
||||||
|
if ($this->rs->isEmpty()) {
|
||||||
|
if ($filter->show()) {
|
||||||
|
echo '<p><strong>' . __('No record matches the filter') . '</strong></p>';
|
||||||
|
} else {
|
||||||
|
echo '<p><strong>' . __('No record') . '</strong></p>';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$pager = new dcPager($filter->page, $this->rs_count, $filter->nb, 10);
|
||||||
|
$pager->base_url = $pager_url;
|
||||||
|
|
||||||
|
$epc_id = [];
|
||||||
|
if (isset($_REQUEST['epc_id'])) {
|
||||||
|
foreach ($_REQUEST['epc_id'] as $v) {
|
||||||
|
$epc_id[(integer) $v] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$cols = [
|
||||||
|
'key' => '<th colspan="2" class="first">' . __('Key') . '</th>',
|
||||||
|
'value' => '<th scope="col">' . __('Value') . '</th>',
|
||||||
|
'date' => '<th scope="col">' . __('Date') . '</th>'
|
||||||
|
];
|
||||||
|
|
||||||
|
$html_block =
|
||||||
|
'<div class="table-outer"><table><caption>' .
|
||||||
|
($filter->show() ?
|
||||||
|
sprintf(__('List of %s records matching the filter.'), $this->rs_count) :
|
||||||
|
sprintf(__('List of %s records.'), $this->rs_count)
|
||||||
|
). '</caption>' .
|
||||||
|
'<tr>' . implode($cols) . '</tr>%s</table>%s</div>';
|
||||||
|
|
||||||
|
if ($enclose_block) {
|
||||||
|
$html_block = sprintf($enclose_block, $html_block);
|
||||||
|
}
|
||||||
|
$blocks = explode('%s', $html_block);
|
||||||
|
|
||||||
|
echo $pager->getLinks() . $blocks[0];
|
||||||
|
|
||||||
|
while ($this->rs->fetch()) {
|
||||||
|
echo $this->line(isset($epc_id[$this->rs->epc_id]));
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $blocks[1] . $blocks[2] . $pager->getLinks();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function line($checked)
|
||||||
|
{
|
||||||
|
$cols = [
|
||||||
|
'check' => '<td class="nowrap">' . form::checkbox(['epc_id[]'], $this->rs->epc_id, ['checked' => $checked]) . '</td>',
|
||||||
|
'key' => '<td class="nowrap">' . html::escapeHTML($this->rs->epc_key) . '</td>',
|
||||||
|
'value' => '<td class="maximal">' . html::escapeHTML($this->rs->epc_value) . '</td>',
|
||||||
|
'date' => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->epc_upddt) . '</td>'
|
||||||
|
];
|
||||||
|
|
||||||
|
return
|
||||||
|
'<tr class="line" id="p' . $this->rs->epc_id . '">' .
|
||||||
|
implode($cols) .
|
||||||
|
'</tr>';
|
||||||
|
}
|
||||||
|
}
|
|
@ -328,6 +328,7 @@ class libEPC
|
||||||
if (isset($opt[$name]['pubPages'])) {
|
if (isset($opt[$name]['pubPages'])) {
|
||||||
$filters[$name]['pubPages'] = (array) $opt[$name]['pubPages'];
|
$filters[$name]['pubPages'] = (array) $opt[$name]['pubPages'];
|
||||||
}
|
}
|
||||||
|
$filters[$name]['name'] = $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->callBehavior('enhancePostContentBlogFilters', $filters);
|
$core->callBehavior('enhancePostContentBlogFilters', $filters);
|
||||||
|
|
457
index.php
457
index.php
|
@ -21,14 +21,22 @@ dcPage::check('contentadmin');
|
||||||
# -- Prepare queries and object --
|
# -- Prepare queries and object --
|
||||||
|
|
||||||
$_filters = libEPC::blogFilters();
|
$_filters = libEPC::blogFilters();
|
||||||
$filters_id = array();
|
|
||||||
|
$filters_id = $filters_combo = [];
|
||||||
foreach($_filters as $name => $filter) {
|
foreach($_filters as $name => $filter) {
|
||||||
$filters_id[$filter['id']] = $name;
|
$filters_id[$filter['id']] = $name;
|
||||||
|
$filters_combo[__($name)] = $filter['id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$action = isset($_POST['action']) ? $_POST['action'] : '';
|
$action = $_POST['action'] ?? '';
|
||||||
$default_part = isset($_REQUEST['part']) ? $_REQUEST['part'] : key($filters_id);
|
$part = $_REQUEST['part'] ?? key($filters_id);
|
||||||
|
|
||||||
|
if (!isset($filters_id[$part])) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$header = '';
|
||||||
|
$filter = $_filters[$filters_id[$part]];
|
||||||
$records = new epcRecords($core);
|
$records = new epcRecords($core);
|
||||||
|
|
||||||
# -- Action --
|
# -- Action --
|
||||||
|
@ -40,11 +48,8 @@ if (!empty($action)) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
# Update filter settings
|
# Update filter settings
|
||||||
if ($action == 'savefiltersetting'
|
if ($action == 'savefiltersetting') {
|
||||||
&& isset($filters_id[$default_part])
|
|
||||||
) {
|
|
||||||
# Parse filters options
|
# Parse filters options
|
||||||
$name = $filters_id[$default_part];
|
|
||||||
$f = [
|
$f = [
|
||||||
'nocase' => !empty($_POST['filter_nocase']),
|
'nocase' => !empty($_POST['filter_nocase']),
|
||||||
'plural' => !empty($_POST['filter_plural']),
|
'plural' => !empty($_POST['filter_plural']),
|
||||||
|
@ -56,7 +61,7 @@ try {
|
||||||
];
|
];
|
||||||
|
|
||||||
$core->blog->settings->addNamespace('enhancePostContent');
|
$core->blog->settings->addNamespace('enhancePostContent');
|
||||||
$core->blog->settings->enhancePostContent->put('enhancePostContent_' . $name, serialize($f));
|
$core->blog->settings->enhancePostContent->put('enhancePostContent_' . $filter['name'], serialize($f));
|
||||||
|
|
||||||
$core->blog->triggerBlog();
|
$core->blog->triggerBlog();
|
||||||
|
|
||||||
|
@ -66,19 +71,18 @@ try {
|
||||||
|
|
||||||
$core->adminurl->redirect(
|
$core->adminurl->redirect(
|
||||||
'admin.plugin.enhancePostContent',
|
'admin.plugin.enhancePostContent',
|
||||||
['part' => $default_part],
|
['part' => $part],
|
||||||
'#settings'
|
'#settings'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add new filter record
|
# Add new filter record
|
||||||
if ($action == 'savenewrecord'
|
if ($action == 'savenewrecord'
|
||||||
&& 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 = $filter['name'];
|
||||||
$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']);
|
||||||
|
|
||||||
|
@ -95,55 +99,34 @@ try {
|
||||||
}
|
}
|
||||||
$core->adminurl->redirect(
|
$core->adminurl->redirect(
|
||||||
'admin.plugin.enhancePostContent',
|
'admin.plugin.enhancePostContent',
|
||||||
['part' => $default_part],
|
['part' => $part],
|
||||||
'#record'
|
'#record'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update filter records
|
# Update filter records
|
||||||
$error = false;
|
if ($action == 'deleterecords' && $filter['has_list']
|
||||||
if ($action == 'saveupdaterecords'
|
&& !empty($_POST['epc_id']) && is_array($_POST['epc_id'])
|
||||||
&& isset($filters_id[$default_part])
|
|
||||||
&& $_filters[$filters_id[$default_part]]['has_list']
|
|
||||||
) {
|
) {
|
||||||
foreach($_POST['epc_id'] as $k => $id) {
|
foreach($_POST['epc_id'] as $id) {
|
||||||
$k = abs((integer) $k);
|
$records->delRecord($id);
|
||||||
$id = abs((integer) $id);
|
|
||||||
|
|
||||||
if (empty($_POST['epc_key'][$k])
|
|
||||||
|| empty($_POST['epc_value'][$k])
|
|
||||||
) {
|
|
||||||
$records->delRecord($id);
|
|
||||||
} elseif ($_POST['epc_key'][$k] != $_POST['epc_old_key'][$k]
|
|
||||||
|| $_POST['epc_value'][$k] != $_POST['epc_old_value'][$k]
|
|
||||||
) {
|
|
||||||
$cur = $records->openCursor();
|
|
||||||
$cur->epc_filter = $filters_id[$default_part];
|
|
||||||
$cur->epc_key = html::escapeHTML($_POST['epc_key'][$k]);
|
|
||||||
$cur->epc_value = html::escapeHTML($_POST['epc_value'][$k]);
|
|
||||||
|
|
||||||
if ($records->isRecord($cur->epc_filter, $cur->epc_key, $id)) {
|
|
||||||
dcPage::addErrorNotice(__('Key already exists for this filter'));
|
|
||||||
$error = true;
|
|
||||||
} else {
|
|
||||||
$records->updRecord($id, $cur);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->blog->triggerBlog();
|
$core->blog->triggerBlog();
|
||||||
|
|
||||||
$redir = !empty($_REQUEST['redir']) ?
|
dcPage::addSuccessNotice(
|
||||||
$_REQUEST['redir'] :
|
__('Filter successfully updated.')
|
||||||
$core->adminurl->get('admin.plugin.enhancePostContent', ['part' => $default_part]) . '#record';
|
);
|
||||||
if (!$error) {
|
|
||||||
dcPage::addSuccessNotice(
|
if (!empty($_REQUEST['redir'])) {
|
||||||
__('Filter successfully updated.')
|
http::redirect($_REQUEST['redir']);
|
||||||
|
} else {
|
||||||
|
$core->adminurl->redirect(
|
||||||
|
'admin.plugin.enhancePostContent',
|
||||||
|
['part' => $part],
|
||||||
|
'#record'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
http::redirect(
|
|
||||||
$redir
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} catch(Exception $e) {
|
} catch(Exception $e) {
|
||||||
$core->error->add($e->getMessage());
|
$core->error->add($e->getMessage());
|
||||||
|
@ -151,267 +134,201 @@ try {
|
||||||
|
|
||||||
# -- Prepare page --
|
# -- Prepare page --
|
||||||
|
|
||||||
$breadcrumb = [html::escapeHTML($core->blog->name) => '', __('Enhance post content') => '', __('Filters') => ''];
|
if ($filter['has_list']) {
|
||||||
|
$sorts = new adminGenericFilter($core, 'epc');
|
||||||
|
$sorts->add(dcAdminFilters::getPageFilter());
|
||||||
|
$sorts->add('part', $part);
|
||||||
|
|
||||||
$filters_combo = [];
|
$params = $sorts->params();
|
||||||
foreach($filters_id as $id => $name) {
|
$params['epc_filter'] = $filter['name'];
|
||||||
if ($default_part == $id) {
|
|
||||||
$breadcrumb[__($filters_id[$default_part])] = '';
|
try {
|
||||||
|
$list = $records->getRecords($params);
|
||||||
|
$counter = $records->getRecords($params, true);
|
||||||
|
$pager = new adminEpcList($core, $list, $counter->f(0));
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$core->error->add($e->getMessage());
|
||||||
}
|
}
|
||||||
$filters_combo[__($name)] = $id;
|
|
||||||
|
$header = $sorts->js($core->adminurl->get('admin.plugin.enhancePostContent', ['part' => $part], '&').'#record');
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- Display page --
|
# -- Display page --
|
||||||
|
|
||||||
# Headers
|
# Page 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() .
|
||||||
dcPage::jsLoad(dcPage::getPF('enhancePostContent/js/index.js')) .
|
dcPage::jsLoad(dcPage::getPF('enhancePostContent/js/index.js')) .
|
||||||
|
$header .
|
||||||
|
|
||||||
# --BEHAVIOR-- enhancePostContentAdminHeader
|
# --BEHAVIOR-- enhancePostContentAdminHeader
|
||||||
$core->callBehavior('enhancePostContentAdminHeader', $core) . '
|
$core->callBehavior('enhancePostContentAdminHeader', $core) . '
|
||||||
|
|
||||||
</head><body>' .
|
</head><body>' .
|
||||||
|
|
||||||
# Title
|
# Page title
|
||||||
dcPage::breadcrumb($breadcrumb) .
|
dcPage::breadcrumb([
|
||||||
|
__('Plugins') => '',
|
||||||
|
__('Enhance post content') => '',
|
||||||
|
__($filter['name']) => ''
|
||||||
|
]) .
|
||||||
dcPage::notices() .
|
dcPage::notices() .
|
||||||
|
|
||||||
# Filters list
|
# Filters select menu list
|
||||||
'<form method="post" action="' . $p_url . '&tab=settings">' .
|
'<form method="get" action="' . $core->adminurl->get('admin.plugin.enhancePostContent') . '" id="filters_menu">' .
|
||||||
'<p class="anchor-nav"><label for="epc_tab" class="classic">' . __('Select filter:') . ' </label>' .
|
'<p class="anchor-nav"><label for="epc_tab" class="classic">' . __('Select filter:') . ' </label>' .
|
||||||
form::combo('part', $filters_combo, $default_part) . ' ' .
|
form::combo('part', $filters_combo, $part) . ' ' .
|
||||||
$core->formNonce() .
|
'<input type="submit" value="' . __('Ok') . '" />' .
|
||||||
'<input type="submit" value="' . __('Ok') . '" /></p>' .
|
form::hidden('p', 'enhancePostContent') . '</p>' .
|
||||||
'</form>';
|
'</form>';
|
||||||
|
|
||||||
# Filter content
|
# Filter title and description
|
||||||
if (isset($filters_id[$default_part])) {
|
echo '
|
||||||
$name = $filters_id[$default_part];
|
<h3>' . __($filter['name']) . '</h3>
|
||||||
$filter = $_filters[$name];
|
<p>' . $filter['help'] . '</p>';
|
||||||
|
|
||||||
# Filter title and description
|
# Filter settings
|
||||||
|
echo '
|
||||||
|
<div class="multi-part" id="setting" title="' . __('Settings') . '">
|
||||||
|
<form method="post" action="' . $core->adminurl->get('admin.plugin.enhancePostContent') . '#setting">
|
||||||
|
|
||||||
|
<div class="two-boxes odd">
|
||||||
|
<h4>' . __('Pages to be filtered') . '</h4>';
|
||||||
|
|
||||||
|
foreach(libEPC::blogAllowedPubPages() as $k => $v) {
|
||||||
echo '
|
echo '
|
||||||
<h3>' . __($filters_id[$default_part]) . '</h3>
|
<p><label for="filter_pubPages' . $v . '">' .
|
||||||
<p>' . $filter['help'] . '</p>';
|
form::checkbox(
|
||||||
|
['filter_pubPages[]', 'filter_pubPages' . $v],
|
||||||
|
$v,
|
||||||
|
in_array($v, $filter['pubPages'])
|
||||||
|
) .
|
||||||
|
__($k) . '</label></p>';
|
||||||
|
}
|
||||||
|
|
||||||
# Filter settings
|
echo '
|
||||||
|
</div><div class="two-boxes even">
|
||||||
|
<h4>' . __('Filtering') . '</h4>
|
||||||
|
|
||||||
|
<p><label for="filter_nocase">' .
|
||||||
|
form::checkbox('filter_nocase', '1', $filter['nocase']) .
|
||||||
|
__('Case insensitive') . '</label></p>
|
||||||
|
|
||||||
|
<p><label for="filter_plural">' .
|
||||||
|
form::checkbox('filter_plural', '1', $filter['plural']) .
|
||||||
|
__('Also use the plural') . '</label></p>
|
||||||
|
|
||||||
|
<p><label for="filter_limit">' .
|
||||||
|
__('Limit the number of replacement to:') . '</label>' .
|
||||||
|
form::number('filter_limit', ['min' => 0, 'max' => 99, 'default' => (integer) $filter['limit']]) . '
|
||||||
|
</p>
|
||||||
|
<p class="form-note">' . __('Leave it blank or set it to 0 for no limit') . '</p>
|
||||||
|
|
||||||
|
</div><div class="two-boxes odd">
|
||||||
|
<h4>' . __('Contents to be filtered') . '</h4>';
|
||||||
|
|
||||||
|
foreach(libEPC::blogAllowedTplValues() as $k => $v) {
|
||||||
echo '
|
echo '
|
||||||
<div class="multi-part" id="setting" title="' . __('Settings') . '">
|
<p><label for="filter_tplValues' . $v . '">' .
|
||||||
<form method="post" action="' . $p_url . '&part=' . $default_part . '&tab=setting"><div>';
|
form::checkbox(
|
||||||
|
['filter_tplValues[]', 'filter_tplValues' . $v],
|
||||||
|
$v,
|
||||||
|
in_array($v, $filter['tplValues'])
|
||||||
|
) .
|
||||||
|
__($k) . '</label></p>';
|
||||||
|
}
|
||||||
|
|
||||||
echo
|
echo '
|
||||||
'<div class="two-boxes odd">
|
</div><div class="two-boxes even">
|
||||||
<h4>' . __('Pages to be filtered') . '</h4>';
|
<h4>' . __('Style') . '</h4>';
|
||||||
|
|
||||||
foreach(libEPC::blogAllowedPubPages() as $k => $v) {
|
foreach($filter['class'] as $k => $v) {
|
||||||
echo '
|
echo '
|
||||||
<p><label for="filter_pubPages' . $v . '">' .
|
<p><label for="filter_style' . $k . '">' .
|
||||||
form::checkbox(
|
sprintf(__('Class "%s":'), $v) . '</label>' .
|
||||||
['filter_pubPages[]', 'filter_pubPages' . $v],
|
form::field(
|
||||||
$v,
|
['filter_style[]', 'filter_style'.$k],
|
||||||
in_array($v, $filter['pubPages'])
|
60,
|
||||||
) .
|
255,
|
||||||
__($k) . '</label></p>';
|
html::escapeHTML($filter['style'][$k])
|
||||||
}
|
) .
|
||||||
|
'</p>';
|
||||||
|
}
|
||||||
|
|
||||||
echo
|
echo '
|
||||||
'</div>';
|
<p class="form-note">' . sprintf(__('The inserted HTML tag looks like: %s'), html::escapeHTML(str_replace('%s', '...', $filter['replace']))) . '</p>
|
||||||
|
|
||||||
echo
|
<p><label for="filter_notag">' . __('Ignore HTML tags:') . '</label>' .
|
||||||
'<div class="two-boxes even">
|
form::field('filter_notag', 60, 255, html::escapeHTML($filter['notag'])) . '
|
||||||
<h4>' . __('Filtering') . '</h4>
|
</p>
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
<div class="clear">
|
||||||
|
<p>' .
|
||||||
|
$core->formNonce() .
|
||||||
|
form::hidden(['action'], 'savefiltersetting') .
|
||||||
|
form::hidden(['part'], $part) . '
|
||||||
|
<input type="submit" name="save" value="' . __('Save') . '" />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<p><label for="filter_nocase">' .
|
</form>
|
||||||
form::checkbox('filter_nocase', '1', $filter['nocase']) .
|
</div>';
|
||||||
__('Case insensitive') . '</label></p>
|
|
||||||
|
|
||||||
<p><label for="filter_plural">' .
|
# Filter records list
|
||||||
form::checkbox('filter_plural', '1', $filter['plural']) .
|
if ($filter['has_list']) {
|
||||||
__('Also use the plural') . '</label></p>
|
$pager_url = $core->adminurl->get('admin.plugin.enhancePostContent', array_diff_key($sorts->values(true), ['page' => ''])).'&page=%s#record';
|
||||||
|
|
||||||
<p><label for="filter_limit">' .
|
|
||||||
__('Limit the number of replacement to:') . '</label>' .
|
|
||||||
form::field('filter_limit', 4, 10, html::escapeHTML($filter['limit'])) . '
|
|
||||||
</p>
|
|
||||||
<p class="form-note">' . __('Leave it blank or set it to 0 for no limit') . '</p>
|
|
||||||
|
|
||||||
</div>';
|
|
||||||
|
|
||||||
echo
|
|
||||||
'<div class="two-boxes odd">
|
|
||||||
<h4>' . __('Contents to be filtered') . '</h4>';
|
|
||||||
|
|
||||||
foreach(libEPC::blogAllowedTplValues() as $k => $v) {
|
|
||||||
echo '
|
|
||||||
<p><label for="filter_tplValues' . $v . '">' .
|
|
||||||
form::checkbox(
|
|
||||||
['filter_tplValues[]', 'filter_tplValues' . $v],
|
|
||||||
$v,
|
|
||||||
in_array($v, $filter['tplValues'])
|
|
||||||
) .
|
|
||||||
__($k) . '</label></p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo
|
|
||||||
'</div>';
|
|
||||||
|
|
||||||
echo
|
|
||||||
'<div class="two-boxes even">
|
|
||||||
<h4>' . __('Style') . '</h4>';
|
|
||||||
|
|
||||||
foreach($filter['class'] as $k => $v) {
|
|
||||||
echo '
|
|
||||||
<p><label for="filter_style' . $k . '">' .
|
|
||||||
sprintf(__('Class "%s":'), $v) . '</label>' .
|
|
||||||
form::field(
|
|
||||||
['filter_style[]', 'filter_style'.$k],
|
|
||||||
60,
|
|
||||||
255,
|
|
||||||
html::escapeHTML($filter['style'][$k])
|
|
||||||
) .
|
|
||||||
'</p>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '
|
echo '
|
||||||
<p class="form-note">' . sprintf(__('The inserted HTML tag looks like: %s'), html::escapeHTML(str_replace('%s', '...', $filter['replace']))) . '</p>
|
<div class="multi-part" id="record" title="' . __('Records') . '">';
|
||||||
|
|
||||||
<p><label for="filter_notag">' . __('Ignore HTML tags:') . '</label>' .
|
$sorts->display(['admin.plugin.enhancePostContent', '#record'], form::hidden('p', 'enhancePostContent') . form::hidden('part', $part));
|
||||||
form::field('filter_notag', 60, 255, html::escapeHTML($filter['notag'])) . '
|
|
||||||
|
$pager->display($sorts, $pager_url,
|
||||||
|
'<form action="' . $core->adminurl->get('admin.plugin.enhancePostContent') . '#record" method="post" id="form-records">' .
|
||||||
|
'%s' .
|
||||||
|
|
||||||
|
'<div class="two-cols">' .
|
||||||
|
'<p class="col checkboxes-helpers"></p>' .
|
||||||
|
|
||||||
|
'<p class="col right">' .
|
||||||
|
form::hidden('action', 'deleterecords') .
|
||||||
|
'<input id="del-action" type="submit" name="save" value="' . __('Delete selected records') . '" /></p>' .
|
||||||
|
$core->adminurl->getHiddenFormFields('admin.plugin.enhancePostContent', array_merge(['p' => 'enhancePostContent'], $sorts->values(true))) .
|
||||||
|
form::hidden('redir', $core->adminurl->get('admin.plugin.enhancePostContent', $sorts->values(true))) .
|
||||||
|
$core->formNonce() .
|
||||||
|
'</div>' .
|
||||||
|
'</form>'
|
||||||
|
);
|
||||||
|
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
# New record
|
||||||
|
echo '
|
||||||
|
<div class="multi-part" id="newrecord" title="' . __('New record') . '">
|
||||||
|
<form action="' . $core->adminurl->get('admin.plugin.enhancePostContent') . '#record" method="post" id="form-create">' .
|
||||||
|
|
||||||
|
'<p><label for="new_key">' . __('Key:') . '</label>' .
|
||||||
|
form::field('new_key', 60, 255, ['extra_html' => 'required']) .
|
||||||
|
'</p>' .
|
||||||
|
|
||||||
|
'<p><label for="new_value">' . __('Value:') . '</label>' .
|
||||||
|
form::field('new_value', 60, 255, ['extra_html' => 'required']) .
|
||||||
|
'</p>
|
||||||
|
|
||||||
|
<p class="clear">' .
|
||||||
|
form::hidden(['action'], 'savenewrecord') .
|
||||||
|
form::hidden(['part'], $part) .
|
||||||
|
$core->formNonce() . '
|
||||||
|
<input id="new-action" type="submit" name="save" value="' . __('Save') . '" />
|
||||||
</p>
|
</p>
|
||||||
<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>
|
|
||||||
|
|
||||||
</div>';
|
|
||||||
|
|
||||||
echo '</div>
|
|
||||||
<div class="clear">
|
|
||||||
<p>' .
|
|
||||||
$core->formNonce() .
|
|
||||||
form::hidden(['action'], 'savefiltersetting') . '
|
|
||||||
<input type="submit" name="save" value="' . __('Save') . '" />
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
</div>';
|
</div>';
|
||||||
|
|
||||||
# Filter records list
|
|
||||||
if ($filter['has_list']) {
|
|
||||||
$sorts = new adminGenericFilter($core, 'epc');
|
|
||||||
$sorts->add(dcAdminFilters::getPageFilter());
|
|
||||||
|
|
||||||
$params = $sorts->params();
|
|
||||||
$params['epc_filter'] = $name;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$list = $records->getRecords($params);
|
|
||||||
$counter = $records->getRecords($params, true);
|
|
||||||
|
|
||||||
$pager_url = $p_url .
|
|
||||||
'&nb=' . $sorts->nb .
|
|
||||||
'&sortby=%s' .
|
|
||||||
'&order=%s' .
|
|
||||||
'&page=%s' .
|
|
||||||
'&part=' . $default_part .
|
|
||||||
'#record';
|
|
||||||
|
|
||||||
$pager = new dcPager($sorts->page, $counter->f(0), $sorts->nb, 10);
|
|
||||||
$pager->base_url = sprintf($pager_url, $sorts->sortby, $sorts->order, '%s');
|
|
||||||
} catch (Exception $e) {
|
|
||||||
$core->error->add($e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '
|
|
||||||
<div class="multi-part" id="record" title="' . __('Records') . '">';
|
|
||||||
|
|
||||||
if ($core->error->flag() || $list->isEmpty()) {
|
|
||||||
echo '<p>' . __('No record') . '</p>';
|
|
||||||
} else {
|
|
||||||
echo '
|
|
||||||
<form action="' . sprintf($pager_url, $sorts->sortby, $sorts->order, $sorts->page) . '" method="post">' .
|
|
||||||
|
|
||||||
$pager->getLinks() . '
|
|
||||||
|
|
||||||
<div class="table-outer">
|
|
||||||
<table><caption class="hidden">' . __('Records') . '</caption>
|
|
||||||
<thead><tr>';
|
|
||||||
|
|
||||||
$lines = [
|
|
||||||
__('Key') => 'epc_key',
|
|
||||||
__('Value') => 'epc_value',
|
|
||||||
__('Date') => 'epc_date'
|
|
||||||
];
|
|
||||||
foreach($lines as $k => $v) {
|
|
||||||
echo '<th><a href="' . sprintf($pager_url, $v, $sorts->sortby == $v ? $sorts->order == 'asc' ? 'desc' : 'asc' : $sorts->order, $sorts->page) . '">' .$k . '</a></th>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '
|
|
||||||
</tr></thead>
|
|
||||||
<tbody>';
|
|
||||||
|
|
||||||
while($list->fetch()) {
|
|
||||||
echo '
|
|
||||||
<tr class="line">
|
|
||||||
<td class="nowrap">' .
|
|
||||||
form::hidden(['epc_id[]'], $list->epc_id) .
|
|
||||||
form::hidden(['epc_old_key[]'], html::escapeHTML($list->epc_key)) .
|
|
||||||
form::hidden(['epc_old_value[]'], html::escapeHTML($list->epc_value)) .
|
|
||||||
form::field(['epc_key[]'], 30, 225, html::escapeHTML($list->epc_key), '') . '</td>
|
|
||||||
<td class="maximal">' .
|
|
||||||
form::field(['epc_value[]'], 90, 225, html::escapeHTML($list->epc_value), '') . '</td>
|
|
||||||
<td class="nowrap count">' .
|
|
||||||
dt::dt2str(__('%Y-%m-%d %H:%M'), $list->epc_upddt,$core->auth->getInfo('user_tz')) . '</td>
|
|
||||||
</tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '
|
|
||||||
</tbody>
|
|
||||||
</table></div>
|
|
||||||
<p class="form-note">' . __('In order to remove a record, leave empty its key or value.') . '</p>' .
|
|
||||||
|
|
||||||
$pager->getLinks() . '
|
|
||||||
|
|
||||||
<div class="clear">
|
|
||||||
<p>' .
|
|
||||||
$core->formNonce() .
|
|
||||||
form::hidden(['redir'], sprintf($pager_url, $sorts->sortby, $sorts->order, $sorts->page)) .
|
|
||||||
form::hidden(['action'], 'saveupdaterecords') . '
|
|
||||||
<input type="submit" name="save" value="' . __('Save') . '" />
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</form>';
|
|
||||||
}
|
|
||||||
|
|
||||||
echo '</div>';
|
|
||||||
|
|
||||||
# New record
|
|
||||||
echo '
|
|
||||||
<div class="multi-part" id="newrecord" title="' . __('New record') . '">
|
|
||||||
<form action="' .
|
|
||||||
$core->adminurl->get('admin.plugin.enhancePostContent', ['part' => $default_part]) .
|
|
||||||
'#record" method="post">' .
|
|
||||||
|
|
||||||
'<p><label for="new_key">' . __('Key:') . '</label>' .
|
|
||||||
form::field('new_key', 60, 255) .
|
|
||||||
'</p>' .
|
|
||||||
|
|
||||||
'<p><label for="new_value">' . __('Value:') . '</label>' .
|
|
||||||
form::field('new_value', 60, 255) .
|
|
||||||
'</p>
|
|
||||||
|
|
||||||
<p class="clear">' .
|
|
||||||
form::hidden(['action'], 'savenewrecord') .
|
|
||||||
$core->formNonce() . '
|
|
||||||
<input type="submit" name="save" value="' . __('Save') . '" />
|
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
</div>';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# --BEHAVIOR-- enhancePostContentAdminPage
|
# --BEHAVIOR-- enhancePostContentAdminPage
|
||||||
|
|
|
@ -2,7 +2,12 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
$('#part').on('change', function () {
|
$('#filters_menu input[type=submit]').hide();
|
||||||
this.form.submit();
|
$('#filters_menu #part').on('change', function () {this.form.submit();});
|
||||||
|
|
||||||
|
$('.checkboxes-helpers').each(function () {
|
||||||
|
dotclear.checkboxesHelpers(this, undefined, '#form-records td input[type=checkbox]', '#form-records #del-action');
|
||||||
});
|
});
|
||||||
|
$('#form-records td input[type=checkbox]').enableShiftClick();
|
||||||
|
dotclear.condSubmit('#form-records td input[type=checkbox]', '#form-records #del-action');
|
||||||
});
|
});
|
Loading…
Reference in a new issue