User pref columns and filters : part 2 : entries
This commit is contained in:
parent
ca7a47ffe0
commit
4169b0533f
6 changed files with 288 additions and 322 deletions
28
_admin.php
28
_admin.php
|
@ -69,6 +69,17 @@ class zcfsAdminBehaviors
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function entriesSortbyCombo()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
__('Date') => 'post_dt',
|
||||||
|
__('Title') => 'post_title',
|
||||||
|
__('Category') => 'cat_title',
|
||||||
|
__('Author') => 'user_id',
|
||||||
|
__('Status') => 'post_status'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Favorites.
|
* Favorites.
|
||||||
*
|
*
|
||||||
|
@ -141,6 +152,14 @@ class zcfsAdminBehaviors
|
||||||
'entries' => [true, __('Entries')]
|
'entries' => [true, __('Entries')]
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
|
$cols['zcfs_entries'] = [
|
||||||
|
__('Feeds server: Entries'),
|
||||||
|
[
|
||||||
|
'date' => [true, __('Date')],
|
||||||
|
'category' => [true, __('Category')],
|
||||||
|
'author' => [true, __('Author')]
|
||||||
|
]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,7 +175,14 @@ class zcfsAdminBehaviors
|
||||||
self::feedsSortbyCombo(),
|
self::feedsSortbyCombo(),
|
||||||
'lowername',
|
'lowername',
|
||||||
'asc',
|
'asc',
|
||||||
[__('Links per page'), 30]
|
[__('feeds per page'), 30]
|
||||||
|
];
|
||||||
|
$sorts['zcfs_entries'] = [
|
||||||
|
__('Feeds server: Entries'),
|
||||||
|
self::entriesSortbyCombo(),
|
||||||
|
'post_dt',
|
||||||
|
'desc',
|
||||||
|
[__('entries per page'), 30]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ $d = dirname(__FILE__).'/inc/';
|
||||||
$__autoload['zoneclearFeedServer'] = $d . 'class.zoneclear.feed.server.php';
|
$__autoload['zoneclearFeedServer'] = $d . 'class.zoneclear.feed.server.php';
|
||||||
$__autoload['zcfsFeedsList'] = $d . 'lib.zcfs.list.php';
|
$__autoload['zcfsFeedsList'] = $d . 'lib.zcfs.list.php';
|
||||||
$__autoload['zcfsEntriesList'] = $d . 'lib.zcfs.list.php';
|
$__autoload['zcfsEntriesList'] = $d . 'lib.zcfs.list.php';
|
||||||
|
$__autoload['adminZcfsPostFilter'] = $d . 'lib.zcfs.list.php';
|
||||||
$__autoload['zcfsFeedsActionsPage'] = $d . 'class.zcfs.feedsactions.php';
|
$__autoload['zcfsFeedsActionsPage'] = $d . 'class.zcfs.feedsactions.php';
|
||||||
$__autoload['zcfsDefaultFeedsActions'] = $d . 'class.zcfs.feedsactions.php';
|
$__autoload['zcfsDefaultFeedsActions'] = $d . 'class.zcfs.feedsactions.php';
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ class zcfsFeedsList extends adminGenericList
|
||||||
'<table>' .
|
'<table>' .
|
||||||
'<caption>' . ($filter ?
|
'<caption>' . ($filter ?
|
||||||
sprintf(__('List of %s feeds matching the filter.'), $this->rs_count) :
|
sprintf(__('List of %s feeds matching the filter.'), $this->rs_count) :
|
||||||
sprintf(__('List of entries (%s)'), $this->rs_count)
|
sprintf(__('List of feeds (%s)'), $this->rs_count)
|
||||||
) . '</caption>';
|
) . '</caption>';
|
||||||
|
|
||||||
$cols = [
|
$cols = [
|
||||||
|
@ -145,40 +145,63 @@ class zcfsFeedsList extends adminGenericList
|
||||||
*/
|
*/
|
||||||
class zcfsEntriesList extends adminGenericList
|
class zcfsEntriesList extends adminGenericList
|
||||||
{
|
{
|
||||||
public function display($page, $nb_per_page, $url, $enclose='')
|
public function display($page, $nb_per_page, $base_url, $enclose_block = '', $filter = false)
|
||||||
{
|
{
|
||||||
if ($this->rs->isEmpty()) {
|
if ($this->rs->isEmpty()) {
|
||||||
|
echo '<p><strong>' . ($filter ?
|
||||||
|
__('No entries matches the filter') :
|
||||||
|
__('No entries')
|
||||||
|
) . '</strong></p>';
|
||||||
|
} else {
|
||||||
|
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
|
||||||
|
$pager->base_url = $base_url;
|
||||||
|
|
||||||
return '<p><strong>'.__('No entry').'</strong></p>';
|
$entries = [];
|
||||||
|
if (isset($_REQUEST['feeds'])) {
|
||||||
|
foreach ($_REQUEST['feeds'] as $v) {
|
||||||
|
$entries[(integer) $v] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$html_block = '<div class="table-outer clear">' .
|
||||||
|
'<table>' .
|
||||||
|
'<caption>' . ($filter ?
|
||||||
|
sprintf(__('List of %s entries matching the filter.'), $this->rs_count) :
|
||||||
|
sprintf(__('List of entries (%s)'), $this->rs_count)
|
||||||
|
) . '</caption>';
|
||||||
|
|
||||||
|
$cols = [
|
||||||
|
'title' => '<th scope="col" colspan="2" class="first">' . __('Title') . '</th>',
|
||||||
|
'date' => '<th scope="col">' . __('Date') . '</th>',
|
||||||
|
'author' => '<th scope="col">' . __('Author') . '</th>',
|
||||||
|
'category' => '<th scope="col">' . __('Category') . '</th>',
|
||||||
|
'status' => '<th scope="col">' . __('Status') . '</th>'
|
||||||
|
];
|
||||||
|
|
||||||
|
$cols = new ArrayObject($cols);
|
||||||
|
$this->core->callBehavior('adminZcfsPostListHeader', $this->core, $this->rs, $cols);
|
||||||
|
|
||||||
|
$this->userColumns('zcfs_entries', $cols);
|
||||||
|
|
||||||
|
$html_block .= '<tr>' . implode(iterator_to_array($cols)) . '</tr>%s</table></div>';
|
||||||
|
if ($enclose_block) {
|
||||||
|
$html_block = sprintf($enclose_block, $html_block);
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $pager->getLinks();
|
||||||
|
|
||||||
|
$blocks = explode('%s', $html_block);
|
||||||
|
|
||||||
|
echo $blocks[0];
|
||||||
|
|
||||||
|
while ($this->rs->fetch()) {
|
||||||
|
echo $this->postLine(isset($entries[$this->rs->post_id]));
|
||||||
|
}
|
||||||
|
|
||||||
|
echo $blocks[1];
|
||||||
|
|
||||||
|
echo $pager->getLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
|
|
||||||
$pager->base_url = $url;
|
|
||||||
$pager->html_prev = $this->html_prev;
|
|
||||||
$pager->html_next = $this->html_next;
|
|
||||||
$pager->var_page = 'page';
|
|
||||||
|
|
||||||
$html_block =
|
|
||||||
'<div class="table-outer">'.
|
|
||||||
'<table class="clear"><tr>'.
|
|
||||||
'<th colspan="2">'.__('Title').'</th>'.
|
|
||||||
'<th>'.__('Date').'</th>'.
|
|
||||||
'<th>'.__('Category').'</th>'.
|
|
||||||
'<th>'.__('Author').'</th>'.
|
|
||||||
'<th>'.__('Comments').'</th>'.
|
|
||||||
'<th>'.__('Trackbacks').'</th>'.
|
|
||||||
'<th>'.__('Status').'</th>'.
|
|
||||||
'</tr>%s</table></div>';
|
|
||||||
|
|
||||||
$res = '';
|
|
||||||
while ($this->rs->fetch()) {
|
|
||||||
$res .= $this->postLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
|
||||||
$pager->getLinks().
|
|
||||||
sprintf($enclose, sprintf($html_block, $res)).
|
|
||||||
$pager->getLinks();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function postLine()
|
private function postLine()
|
||||||
|
@ -191,36 +214,182 @@ class zcfsEntriesList extends adminGenericList
|
||||||
sprintf($cat_link,$this->rs->cat_id, html::escapeHTML($this->rs->cat_title))
|
sprintf($cat_link,$this->rs->cat_id, html::escapeHTML($this->rs->cat_title))
|
||||||
: __('None');
|
: __('None');
|
||||||
|
|
||||||
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
|
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
|
||||||
|
$img_status = '';
|
||||||
|
$sts_class = '';
|
||||||
switch ($this->rs->post_status) {
|
switch ($this->rs->post_status) {
|
||||||
case 1:
|
case 1:
|
||||||
$img_status = sprintf($img, __('published'), 'check-on.png');
|
$img_status = sprintf($img, __('Published'), 'check-on.png');
|
||||||
|
$sts_class = 'sts-online';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
$img_status = sprintf($img, __('unpublished'), 'check-off.png');
|
$img_status = sprintf($img, __('Unpublished'), 'check-off.png');
|
||||||
|
$sts_class = 'sts-offline';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case -1:
|
case -1:
|
||||||
$img_status = sprintf($img, __('scheduled'), 'scheduled.png');
|
$img_status = sprintf($img, __('Scheduled'), 'scheduled.png');
|
||||||
|
$sts_class = 'sts-scheduled';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case -2:
|
case -2:
|
||||||
$img_status = sprintf($img, __('pending'), 'check-wrn.png');
|
$img_status = sprintf($img, __('Pending'), 'check-wrn.png');
|
||||||
|
$sts_class = 'sts-pending';
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
$res = '<tr class="line ' . ($this->rs->post_status != 1 ? 'offline ' : '') . $sts_class . '"' .
|
||||||
'<tr class="line'.($this->rs->post_status != 1 ? ' offline' : '').'"'.
|
' id="p' . $this->rs->post_id . '">';
|
||||||
' id="p'.$this->rs->post_id.'">'.
|
|
||||||
'<td class="nowrap">'.
|
$cols = [
|
||||||
form::checkbox(array('entries[]'), $this->rs->post_id, '', '', '', !$this->rs->isEditable()).'</td>'.
|
'check' => '<td class="nowrap minimal">'.
|
||||||
'<td class="maximal"><a href="'.$this->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id).
|
form::checkbox(array('entries[]'), $this->rs->post_id, '', '', '', !$this->rs->isEditable()).'</td>',
|
||||||
'" title="'.__('Edit entry').'">'.
|
'title' => '<td scope="row" class="maximal"><a href="' .
|
||||||
html::escapeHTML($this->rs->post_title).'</a></td>'.
|
$this->core->getPostAdminURL($this->rs->post_type, $this->rs->post_id) . '" ' .
|
||||||
'<td class="nowrap">'.dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt).'</td>'.
|
'title="' . html::escapeHTML($this->rs->getURL()) . '">' .
|
||||||
'<td class="nowrap">'.$cat_title.'</td>'.
|
html::escapeHTML(trim(html::clean($this->rs->post_title))) . '</a></td>',
|
||||||
'<td class="nowrap">'.$this->rs->user_id.'</td>'.
|
'date' => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt) . '</td>',
|
||||||
'<td class="nowrap">'.$this->rs->nb_comment.'</td>'.
|
'author' => '<td class="nowrap">' . html::escapeHTML($this->rs->user_id) . '</td>',
|
||||||
'<td class="nowrap">'.$this->rs->nb_trackback.'</td>'.
|
'category' => '<td class="nowrap">'.$cat_title.'</td>',
|
||||||
'<td class="nowrap status">'.$img_status.'</td>'.
|
'status' => '<td class="nowrap status">' . $img_status . '</td>'
|
||||||
'</tr>';
|
];
|
||||||
|
|
||||||
|
$cols = new ArrayObject($cols);
|
||||||
|
$this->core->callBehavior('adminZcfsPostListValue', $this->core, $this->rs, $cols);
|
||||||
|
|
||||||
|
$this->userColumns('zcfs_entries', $cols);
|
||||||
|
|
||||||
|
$res .= implode(iterator_to_array($cols));
|
||||||
|
$res .= '</tr>';
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class adminZcfsPostFilter extends adminGenericFilter
|
||||||
|
{
|
||||||
|
public function __construct(dcCore $core)
|
||||||
|
{
|
||||||
|
parent::__construct($core, 'zcfs_entries');
|
||||||
|
|
||||||
|
$filters = new arrayObject([
|
||||||
|
dcAdminFilters::getPageFilter(),
|
||||||
|
$this->getPostUserFilter(),
|
||||||
|
$this->getPostCategoriesFilter(),
|
||||||
|
$this->getPostStatusFilter(),
|
||||||
|
$this->getPostMonthFilter()
|
||||||
|
]);
|
||||||
|
|
||||||
|
# --BEHAVIOR-- adminPostFilter
|
||||||
|
$core->callBehavior('adminZcfsPostFilter', $core, $filters);
|
||||||
|
|
||||||
|
$filters = $filters->getArrayCopy();
|
||||||
|
|
||||||
|
$this->add($filters);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Posts users select
|
||||||
|
*/
|
||||||
|
public function getPostUserFilter(): ?dcAdminFilter
|
||||||
|
{
|
||||||
|
$users = null;
|
||||||
|
try {
|
||||||
|
$users = $this->core->blog->getPostsUsers();
|
||||||
|
if ($users->isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->core->error->add($e->getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$combo = dcAdminCombos::getUsersCombo($users);
|
||||||
|
dcUtils::lexicalKeySort($combo);
|
||||||
|
|
||||||
|
return (new dcAdminFilter('user_id'))
|
||||||
|
->param()
|
||||||
|
->title(__('Author:'))
|
||||||
|
->options(array_merge(
|
||||||
|
['-' => ''],
|
||||||
|
$combo
|
||||||
|
))
|
||||||
|
->prime(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Posts categories select
|
||||||
|
*/
|
||||||
|
public function getPostCategoriesFilter(): ?dcAdminFilter
|
||||||
|
{
|
||||||
|
$categories = null;
|
||||||
|
try {
|
||||||
|
$categories = $this->core->blog->getCategories();
|
||||||
|
if ($categories->isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->core->error->add($e->getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$combo = [
|
||||||
|
'-' => '',
|
||||||
|
__('(No cat)') => 'NULL'
|
||||||
|
];
|
||||||
|
while ($categories->fetch()) {
|
||||||
|
$combo[
|
||||||
|
str_repeat(' ', ($categories->level - 1) * 4) .
|
||||||
|
html::escapeHTML($categories->cat_title) . ' (' . $categories->nb_post . ')'
|
||||||
|
] = $categories->cat_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new dcAdminFilter('cat_id'))
|
||||||
|
->param()
|
||||||
|
->title(__('Category:'))
|
||||||
|
->options($combo)
|
||||||
|
->prime(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Posts status select
|
||||||
|
*/
|
||||||
|
public function getPostStatusFilter(): dcAdminFilter
|
||||||
|
{
|
||||||
|
return (new dcAdminFilter('status'))
|
||||||
|
->param('post_status')
|
||||||
|
->title(__('Status:'))
|
||||||
|
->options(array_merge(
|
||||||
|
['-' => ''],
|
||||||
|
dcAdminCombos::getPostStatusesCombo()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Posts by month select
|
||||||
|
*/
|
||||||
|
public function getPostMonthFilter(): ?dcAdminFilter
|
||||||
|
{
|
||||||
|
$dates = null;
|
||||||
|
try {
|
||||||
|
$dates = $this->core->blog->getDates(['type' => 'month']);
|
||||||
|
if ($dates->isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$this->core->error->add($e->getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new dcAdminFilter('month'))
|
||||||
|
->param('post_month', function($f) { return substr($f[0], 4, 2); })
|
||||||
|
->param('post_year', function($f) { return substr($f[0], 0, 4); })
|
||||||
|
->title(__('Month:'))
|
||||||
|
->options(array_merge(
|
||||||
|
['-' => ''],
|
||||||
|
dcAdminCombos::getDatesCombo($dates)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
277
index.php
277
index.php
|
@ -251,95 +251,16 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
||||||
|
|
||||||
# Prepared entries list
|
# Prepared entries list
|
||||||
if ($feed_id && $can_view_page) {
|
if ($feed_id && $can_view_page) {
|
||||||
try {
|
|
||||||
# Getting categories
|
|
||||||
$categories = $core->blog->getCategories(array(
|
|
||||||
'post_type' => 'post'
|
|
||||||
));
|
|
||||||
|
|
||||||
# Getting authors
|
|
||||||
$users = $core->blog->getPostsUsers();
|
|
||||||
|
|
||||||
# Getting dates
|
|
||||||
$dates = $core->blog->getDates(array(
|
|
||||||
'type' => 'month'
|
|
||||||
));
|
|
||||||
|
|
||||||
# Getting langs
|
|
||||||
$langs = $core->blog->getLangs();
|
|
||||||
}
|
|
||||||
catch (Exception $e) {
|
|
||||||
$core->error->add($e->getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
# Creating filter combo boxes
|
|
||||||
if (!$core->error->flag()) {
|
|
||||||
|
|
||||||
$users_combo = array_merge(
|
|
||||||
array('-' => ''),
|
|
||||||
dcAdminCombos::getUsersCombo($users)
|
|
||||||
);
|
|
||||||
|
|
||||||
$categories_combo = array_merge(
|
|
||||||
array(
|
|
||||||
new formSelectOption('-', ''),
|
|
||||||
new formSelectOption(__('(No cat)'), 'NULL')
|
|
||||||
),
|
|
||||||
dcAdminCombos::getCategoriesCombo($categories, false)
|
|
||||||
);
|
|
||||||
$categories_values = array();
|
|
||||||
foreach ($categories_combo as $cat) {
|
|
||||||
if (isset($cat->value)) {
|
|
||||||
$categories_values[$cat->value] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$status_combo = array_merge(
|
|
||||||
array('-' => ''),
|
|
||||||
dcAdminCombos::getPostStatusesCombo()
|
|
||||||
);
|
|
||||||
|
|
||||||
$selected_combo = array(
|
|
||||||
'-' => '',
|
|
||||||
__('Selected') => '1',
|
|
||||||
__('Not selected') => '0'
|
|
||||||
);
|
|
||||||
|
|
||||||
$dt_m_combo = array_merge(
|
|
||||||
array('-' => ''),
|
|
||||||
dcAdminCombos::getDatesCombo($dates)
|
|
||||||
);
|
|
||||||
|
|
||||||
$lang_combo = array_merge(
|
|
||||||
array('-' => ''),
|
|
||||||
dcAdminCombos::getLangsCombo($langs,false)
|
|
||||||
);
|
|
||||||
|
|
||||||
$sortby_combo = array(
|
|
||||||
__('Date') => 'post_dt',
|
|
||||||
__('Title') => 'post_title',
|
|
||||||
__('Category') => 'cat_title',
|
|
||||||
__('Author') => 'user_id',
|
|
||||||
__('Status') => 'post_status',
|
|
||||||
__('Selected') => 'post_selected'
|
|
||||||
);
|
|
||||||
|
|
||||||
$order_combo = array(
|
|
||||||
__('Descending') => 'desc',
|
|
||||||
__('Ascending') => 'asc'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Posts action
|
# Posts action
|
||||||
$posts_actions_page = new dcPostsActionsPage(
|
$posts_actions_page = new dcPostsActionsPage(
|
||||||
$core,
|
$core,
|
||||||
'plugin.php',
|
'plugin.php',
|
||||||
array(
|
[
|
||||||
'p' => 'zoneclearFeedServer',
|
'p' => 'zoneclearFeedServer',
|
||||||
'part' => 'feed',
|
'part' => 'feed',
|
||||||
'feed_id' => $feed_id,
|
'feed_id' => $feed_id,
|
||||||
'_ANCHOR' => 'entries'
|
'_ANCHOR' => 'entries'
|
||||||
)
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($posts_actions_page->process()) {
|
if ($posts_actions_page->process()) {
|
||||||
|
@ -348,71 +269,29 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
||||||
|
|
||||||
/* Get posts
|
/* Get posts
|
||||||
-------------------------------------------------------- */
|
-------------------------------------------------------- */
|
||||||
$user_id = !empty($_GET['user_id']) ? $_GET['user_id'] : '';
|
$post_filter = new adminZcfsPostFilter($core);
|
||||||
$cat_id = !empty($_GET['cat_id']) ? $_GET['cat_id'] : '';
|
$post_filter->add('part', 'feed');
|
||||||
$status = isset($_GET['status']) ? $_GET['status'] : '';
|
$post_filter->add('feed_id', $feed_id);
|
||||||
$selected = isset($_GET['selected']) ? $_GET['selected'] : '';
|
|
||||||
$month = !empty($_GET['month']) ? $_GET['month'] : '';
|
|
||||||
$lang = !empty($_GET['lang']) ? $_GET['lang'] : '';
|
|
||||||
$sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'post_dt';
|
|
||||||
$order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
|
|
||||||
|
|
||||||
$show_filters = false;
|
# get list params
|
||||||
|
$params = $post_filter->params();
|
||||||
|
|
||||||
$page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
|
# lexical sort
|
||||||
$nb_per_page = 30;
|
$sortby_lex = [
|
||||||
|
// key in sorty_combo (see above) => field in SQL request
|
||||||
|
'post_title' => 'post_title',
|
||||||
|
'cat_title' => 'cat_title',
|
||||||
|
'user_id' => 'P.user_id'];
|
||||||
|
|
||||||
if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
|
# --BEHAVIOR-- adminPostsSortbyLexCombo
|
||||||
if ($nb_per_page != $_GET['nb']) {
|
$core->callBehavior('adminPostsSortbyLexCombo', [& $sortby_lex]);
|
||||||
$show_filters = true;
|
|
||||||
}
|
$params['order'] = (array_key_exists($post_filter->sortby, $sortby_lex) ?
|
||||||
$nb_per_page = (integer) $_GET['nb'];
|
$core->con->lexFields($sortby_lex[$post_filter->sortby]) :
|
||||||
}
|
$post_filter->sortby) . ' ' . $post_filter->order;
|
||||||
|
|
||||||
$params['limit'] = array((($page-1)*$nb_per_page), $nb_per_page);
|
|
||||||
$params['no_content'] = true;
|
$params['no_content'] = true;
|
||||||
|
|
||||||
# - User filter
|
|
||||||
if ($user_id !== '' && in_array($user_id, $users_combo)) {
|
|
||||||
$params['user_id'] = $user_id;
|
|
||||||
$show_filters = true;
|
|
||||||
}
|
|
||||||
# - Categories filter
|
|
||||||
if ($cat_id !== '' && in_array($cat_id, $categories_combo)) {
|
|
||||||
$params['cat_id'] = $cat_id;
|
|
||||||
$show_filters = true;
|
|
||||||
}
|
|
||||||
# - Status filter
|
|
||||||
if ($status !== '' && in_array($status, $status_combo)) {
|
|
||||||
$params['post_status'] = $status;
|
|
||||||
$show_filters = true;
|
|
||||||
}
|
|
||||||
# - Selected filter
|
|
||||||
if ($selected !== '' && in_array($selected, $selected_combo)) {
|
|
||||||
$params['post_selected'] = $selected;
|
|
||||||
$show_filters = true;
|
|
||||||
}
|
|
||||||
# - Month filter
|
|
||||||
if ($month !== '' && in_array($month, $dt_m_combo)) {
|
|
||||||
$params['post_month'] = substr($month, 4, 2);
|
|
||||||
$params['post_year'] = substr($month, 0, 4);
|
|
||||||
$show_filters = true;
|
|
||||||
}
|
|
||||||
# - Lang filter
|
|
||||||
if ($lang !== '' && in_array($lang, $lang_combo)) {
|
|
||||||
$params['post_lang'] = $lang;
|
|
||||||
$show_filters = true;
|
|
||||||
}
|
|
||||||
# - Sortby and order filter
|
|
||||||
if ($sortby !== '' && in_array($sortby, $sortby_combo)) {
|
|
||||||
if ($order !== '' && in_array($order, $order_combo)){
|
|
||||||
$params['order'] = $sortby.' '.$order;
|
|
||||||
}
|
|
||||||
if ($sortby != 'post_dt' || $order != 'desc') {
|
|
||||||
$show_filters = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get posts
|
# Get posts
|
||||||
try {
|
try {
|
||||||
$params['feed_id'] = $feed_id;
|
$params['feed_id'] = $feed_id;
|
||||||
|
@ -433,25 +312,8 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
||||||
echo
|
echo
|
||||||
'<html><head><title>'.__('Feeds server').'</title>'.
|
'<html><head><title>'.__('Feeds server').'</title>'.
|
||||||
($feed_id && !$core->error->flag() ?
|
($feed_id && !$core->error->flag() ?
|
||||||
dcPage::jsLoad(
|
$post_filter->js($core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feed', 'feed_id' => $feed_id], '&').'#entries') .
|
||||||
'index.php?pf=periodical/js/postsfilter.js'
|
dcPage::jsLoad(dcPage::getPF('zoneclearFeedServer/js/list.js'))
|
||||||
).
|
|
||||||
'<script type="text/javascript">'."\n".
|
|
||||||
"//<![CDATA["."\n".
|
|
||||||
dcPage::jsVar(
|
|
||||||
'dotclear.msg.show_filters',
|
|
||||||
$show_filters ? 'true':'false'
|
|
||||||
)."\n".
|
|
||||||
dcPage::jsVar(
|
|
||||||
'dotclear.msg.filter_posts_list',
|
|
||||||
__('Show filters and display options')
|
|
||||||
)."\n".
|
|
||||||
dcPage::jsVar(
|
|
||||||
'dotclear.msg.cancel_the_filter',
|
|
||||||
__('Cancel filters and display options')
|
|
||||||
)."\n".
|
|
||||||
"//]]>\n".
|
|
||||||
"</script>\n"
|
|
||||||
: '').
|
: '').
|
||||||
dcPage::jsPageTabs().
|
dcPage::jsPageTabs().
|
||||||
$next_headlink."\n".$prev_headlink.
|
$next_headlink."\n".$prev_headlink.
|
||||||
|
@ -582,73 +444,22 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
||||||
|
|
||||||
# Entries
|
# Entries
|
||||||
if ($feed_id && $can_view_page && !$core->error->flag()) {
|
if ($feed_id && $can_view_page && !$core->error->flag()) {
|
||||||
echo
|
echo '<div class="multi-part" title="'.__('Entries').'" id="entries">';
|
||||||
'<div class="multi-part" title="'.__('Entries').'" id="entries">'.
|
|
||||||
|
|
||||||
'<form action="'.$p_url.'&part=feed#entries" method="get" id="filters-form">'.
|
$post_filter->display(['admin.plugin.zoneclearFeedServer','#entries'],
|
||||||
|
form::hidden('p', 'zoneclearFeedServer') .
|
||||||
|
form::hidden('part', 'feed') .
|
||||||
|
form::hidden('feed_id', $feed_id)
|
||||||
|
);
|
||||||
|
|
||||||
'<h3 class="out-of-screen-if-js">'.
|
# fix pager url
|
||||||
__('Cancel filters and display options').
|
$args = $post_filter->values();
|
||||||
'</h3>'.
|
unset($args['page']);
|
||||||
|
$args['page'] = '%s';
|
||||||
'<div class="table">'.
|
$base_url = $core->adminurl->get('admin.plugin.zoneclearFeedServer', $args, '&').'#entries';
|
||||||
'<div class="cell">'.
|
|
||||||
'<h4>'.__('Filters').'</h4>'.
|
|
||||||
'<p><label for="user_id" class="ib">'.__('Author:').'</label> '.
|
|
||||||
form::combo('user_id',$users_combo,$user_id).'</p>'.
|
|
||||||
'<p><label for="cat_id" class="ib">'.__('Category:').'</label> '.
|
|
||||||
form::combo('cat_id',$categories_combo,$cat_id).'</p>'.
|
|
||||||
'<p><label for="status" class="ib">'.__('Status:').'</label> ' .
|
|
||||||
form::combo('status',$status_combo,$status).'</p> '.
|
|
||||||
'</div>'.
|
|
||||||
|
|
||||||
'<div class="cell filters-sibling-cell">'.
|
|
||||||
'<p><label for="selected" class="ib">'.__('Selected:').'</label> '.
|
|
||||||
form::combo('selected',$selected_combo,$selected).'</p>'.
|
|
||||||
'<p><label for="month" class="ib">'.__('Month:').'</label> '.
|
|
||||||
form::combo('month',$dt_m_combo,$month).'</p>'.
|
|
||||||
'<p><label for="lang" class="ib">'.__('Lang:').'</label> '.
|
|
||||||
form::combo('lang',$lang_combo,$lang).'</p> '.
|
|
||||||
'</div>'.
|
|
||||||
|
|
||||||
'<div class="cell filters-options">'.
|
|
||||||
'<h4>'.__('Display options').'</h4>'.
|
|
||||||
'<p><label for="sortby" class="ib">'.__('Order by:').'</label> '.
|
|
||||||
form::combo('sortby',$sortby_combo,$sortby).'</p>'.
|
|
||||||
'<p><label for="order" class="ib">'.__('Sort:').'</label> '.
|
|
||||||
form::combo('order',$order_combo,$order).'</p>'.
|
|
||||||
'<p><span class="label ib">'.__('Show').'</span> <label for="nb" class="classic">'.
|
|
||||||
form::field('nb', 3, 3, $nb_per_page).' '.
|
|
||||||
__('entries per page').'</label></p>'.
|
|
||||||
'</div>'.
|
|
||||||
'</div>'.
|
|
||||||
|
|
||||||
'<p><input type="submit" value="'.__('Apply filters and display options').'" />'.
|
|
||||||
form::hidden(array('p'), 'zoneclearFeedServer').
|
|
||||||
form::hidden(array('part'), 'feed').
|
|
||||||
form::hidden(array('feed_id') ,$feed_id).
|
|
||||||
'<br class="clear" />'. //Opera sucks
|
|
||||||
'</p>'.
|
|
||||||
'</form>'.
|
|
||||||
|
|
||||||
# Show posts
|
# Show posts
|
||||||
$post_list->display($page, $nb_per_page,
|
$post_list->display($post_filter->page, $post_filter->nb, $base_url,
|
||||||
|
|
||||||
$p_url.
|
|
||||||
'&part=feed'.
|
|
||||||
'&tab=entries'.
|
|
||||||
'&feed_id='.$feed_id.
|
|
||||||
'&user_id='.$user_id.
|
|
||||||
'&cat_id='.$cat_id.
|
|
||||||
'&status='.$status.
|
|
||||||
'&selected='.$selected.
|
|
||||||
'&month='.$month.
|
|
||||||
'&lang='.$lang.
|
|
||||||
'&sortby='.$sortby.
|
|
||||||
'&order='.$order.
|
|
||||||
'&nb='.$nb_per_page.
|
|
||||||
'&page=%s',
|
|
||||||
|
|
||||||
'<form action="'.$p_url.'&part=feed#entries" method="post" id="form-entries">'.
|
'<form action="'.$p_url.'&part=feed#entries" method="post" id="form-entries">'.
|
||||||
'%s'.
|
'%s'.
|
||||||
|
|
||||||
|
@ -658,21 +469,12 @@ if (isset($_REQUEST['part']) && $_REQUEST['part'] == 'feed') {
|
||||||
'<p class="col right">'.__('Selected entries action:').' '.
|
'<p class="col right">'.__('Selected entries action:').' '.
|
||||||
form::combo('action', $posts_actions_page->getCombo()).
|
form::combo('action', $posts_actions_page->getCombo()).
|
||||||
'<input type="submit" name="save" value="'.__('ok').'" /></p>'.
|
'<input type="submit" name="save" value="'.__('ok').'" /></p>'.
|
||||||
form::hidden(array('part'), 'feed').
|
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', $post_filter->values()) .
|
||||||
form::hidden(array('feed_id'), $feed_id).
|
form::hidden('redir', $core->adminurl->get('admin.plugin.zoneclearFeedServer', $post_filter->values())) .
|
||||||
form::hidden(array('user_id'), $user_id).
|
|
||||||
form::hidden(array('cat_id'), $cat_id).
|
|
||||||
form::hidden(array('status'), $status).
|
|
||||||
form::hidden(array('selected'), $selected).
|
|
||||||
form::hidden(array('month'), $month).
|
|
||||||
form::hidden(array('lang'), $lang).
|
|
||||||
form::hidden(array('sortby'), $sortby).
|
|
||||||
form::hidden(array('order'), $order).
|
|
||||||
form::hidden(array('page'), $page).
|
|
||||||
form::hidden(array('nb'), $nb_per_page).
|
|
||||||
$core->formNonce().
|
$core->formNonce().
|
||||||
'</div>'.
|
'</div>'.
|
||||||
'</form>'
|
'</form>',
|
||||||
|
$post_filter->show()
|
||||||
);
|
);
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
@ -720,9 +522,8 @@ else {
|
||||||
# Display
|
# Display
|
||||||
echo
|
echo
|
||||||
'<html><head><title>'.__('Feeds server').'</title>'.
|
'<html><head><title>'.__('Feeds server').'</title>'.
|
||||||
dcPage::jsVars(['dotclear.filter_reset_url' => $core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feeds'])]) .
|
$feeds_filter->js($core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feeds'], '&')) .
|
||||||
dcPage::jsFilterControl($feeds_filter->show()) .
|
dcPage::jsLoad(dcPage::getPF('zoneclearFeedServer/js/list.js')) .
|
||||||
dcPage::jsLoad(dcPage::getPF('zoneclearFeedServer/js/feedsfilter.js')) .
|
|
||||||
dcPage::jsPageTabs().
|
dcPage::jsPageTabs().
|
||||||
|
|
||||||
# --BEHAVIOR-- packmanAdminHeader
|
# --BEHAVIOR-- packmanAdminHeader
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
$(function(){
|
|
||||||
$('.checkboxes-helpers').each(function(){dotclear.checkboxesHelpers(this);});
|
|
||||||
|
|
||||||
$filtersform = $('#filters-form');
|
|
||||||
$filtersform.before('<p><a id="filter-control" class="form-control" href="plugin.php?p=zoneclearFeedServer&part=feed#entries" style="display:inline">'+dotclear.msg.filter_posts_list+'</a></p>')
|
|
||||||
|
|
||||||
if( dotclear.msg.show_filters == 'false' ) {
|
|
||||||
$filtersform.hide();
|
|
||||||
} else {
|
|
||||||
$('#filter-control')
|
|
||||||
.addClass('open')
|
|
||||||
.text(dotclear.msg.cancel_the_filter);
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#filter-control').click(function() {
|
|
||||||
if( $(this).hasClass('open') ) {
|
|
||||||
if( dotclear.msg.show_filters == 'true' ) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
$filtersform.hide();
|
|
||||||
$(this).removeClass('open')
|
|
||||||
.text(dotclear.msg.filter_posts_list);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$filtersform.show();
|
|
||||||
$(this).addClass('open')
|
|
||||||
.text(dotclear.msg.cancel_the_filter);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
});
|
|
Loading…
Reference in a new issue