User pref columns and filters : part 1 : feeds
This commit is contained in:
parent
f2a7e3bbf4
commit
ca7a47ffe0
16
CHANGELOG.md
16
CHANGELOG.md
@ -1,13 +1,17 @@
|
||||
dev
|
||||
- [ ] fix Dotclear 2.19 compatibility
|
||||
- [ ] fix php7.3+ php8.0 compatibility
|
||||
- [ ] clean up code
|
||||
- [x] fix license
|
||||
- [ ] fix translations
|
||||
- [x] remove all SoCialMe feature as this plugin is dead
|
||||
- [ ] fix disallow self blog feeds
|
||||
- [ ] add plugin muppet support (request Mathieu M.)
|
||||
- [ ] add log for errors
|
||||
- [ ] add generic filters
|
||||
- [ ] add user pref for columns and filters options
|
||||
|
||||
2021.09.16
|
||||
- fix Dotclear 2.19 compatibility
|
||||
- fix php7.3+ php8.0 compatibility
|
||||
- clean up code
|
||||
- fix license
|
||||
- remove all SoCialMe feature as this plugin is dead
|
||||
- cometics fixes on admin pages
|
||||
|
||||
2015.07.19 - Pierre Van Glabeke
|
||||
- modif lien vers tous les flux
|
||||
|
@ -42,7 +42,7 @@ Once it's done you can manage your feeds from menu
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Jean-Chirstian Denis
|
||||
* Jean-Christian Denis
|
||||
* BG
|
||||
* Pierre Van Glabeke
|
||||
|
||||
|
50
_admin.php
50
_admin.php
@ -37,6 +37,9 @@ if ($core->auth->check('admin', $core->blog->id)) {
|
||||
|
||||
# Dashboard icon
|
||||
$core->addBehavior('adminDashboardFavorites', ['zcfsAdminBehaviors', 'adminDashboardFavorites']);
|
||||
# User pref
|
||||
$core->addBehavior('adminColumnsLists', ['zcfsAdminBehaviors', 'adminColumnsLists']);
|
||||
$core->addBehavior('adminFiltersLists', ['zcfsAdminBehaviors', 'adminFiltersLists']);
|
||||
# Add info about feed on post page sidebar
|
||||
$core->addBehavior('adminPostHeaders', ['zcfsAdminBehaviors', 'adminPostHeaders']);
|
||||
$core->addBehavior('adminPostFormItems', ['zcfsAdminBehaviors', 'adminPostFormItems']);
|
||||
@ -55,6 +58,17 @@ if (version_compare($core->plugins->moduleInfo('tweakurls', 'version'), '0.8', '
|
||||
*/
|
||||
class zcfsAdminBehaviors
|
||||
{
|
||||
public static function feedsSortbyCombo()
|
||||
{
|
||||
return [
|
||||
__('Date') => 'feed_upddt',
|
||||
__('Name') => 'lowername',
|
||||
__('Frequency') => 'feed_upd_int',
|
||||
__('Date of update') => 'feed_upd_last',
|
||||
__('Status') => 'feed_status'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Favorites.
|
||||
*
|
||||
@ -110,6 +124,42 @@ class zcfsAdminBehaviors
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* User pref columns lists.
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param arrayObject $cols Columns
|
||||
*/
|
||||
public static function adminColumnsLists(dcCore $core, $cols)
|
||||
{
|
||||
$cols['zcfs_feeds'] = [
|
||||
__('Feeds server: Feeds'),
|
||||
[
|
||||
'desc' => [true, __('Feed')],
|
||||
'period' => [true, __('Frequency')],
|
||||
'update' => [true, __('Last update')],
|
||||
'entries' => [true, __('Entries')]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* User pref filters options.
|
||||
*
|
||||
* @param dcCore $core dcCore instance
|
||||
* @param arrayObject $sorts Sort options
|
||||
*/
|
||||
public static function adminFiltersLists(dcCore $core, $sorts)
|
||||
{
|
||||
$sorts['zcfs_feeds'] = [
|
||||
__('Feeds server: Feeds'),
|
||||
self::feedsSortbyCombo(),
|
||||
'lowername',
|
||||
'asc',
|
||||
[__('Links per page'), 30]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add javascript for toggle to post edition page header.
|
||||
*
|
||||
|
@ -24,94 +24,116 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
*/
|
||||
class zcfsFeedsList extends adminGenericList
|
||||
{
|
||||
public function feedsDisplay($page, $nb_per_page, $url, $enclose='')
|
||||
public function feedsDisplay($page, $nb_per_page, $enclose_block = '', $filter = false)
|
||||
{
|
||||
if ($this->rs->isEmpty()) {
|
||||
|
||||
return '<p><strong>'.__('There is no feed').'</strong></p>';
|
||||
if ($filter) {
|
||||
echo '<p><strong>' . __('No feeds matches the filter') . '</strong></p>';
|
||||
} else {
|
||||
echo '<p><strong>' . __('No feeds') . '</strong></p>';
|
||||
}
|
||||
} else {
|
||||
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
|
||||
$entries = [];
|
||||
if (isset($_REQUEST['feeds'])) {
|
||||
foreach ($_REQUEST['feeds'] as $v) {
|
||||
$entries[(integer) $v] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$pager = new dcPager($page, $this->rs_count ,$nb_per_page, 10);
|
||||
|
||||
$pager->base_url = $url;
|
||||
|
||||
$html_block =
|
||||
'<div class="table-outer">'.
|
||||
'<table class="clear">'.
|
||||
'<thead>'.
|
||||
'<tr>'.
|
||||
'<th class="nowrap first" colspan="2">'.__('Name').'</th>'.
|
||||
'<th class="nowrap">'.__('Feed').'</th>'.
|
||||
'<th class="nowrap">'.__('Frequency').'</th>'.
|
||||
'<th class="nowrap">'.__('Last update').'</th>'.
|
||||
'<th class="nowrap">'.__('Entries').'</th>'.
|
||||
'<th class="nowrap">'.__('Status').'</th>'.
|
||||
'</tr>'.
|
||||
'</thead>'.
|
||||
'<tbody>%s</tbody>'.
|
||||
'</table>'.
|
||||
'</div>';
|
||||
'<div class="table-outer">' .
|
||||
'<table>' .
|
||||
'<caption>' . ($filter ?
|
||||
sprintf(__('List of %s feeds matching the filter.'), $this->rs_count) :
|
||||
sprintf(__('List of entries (%s)'), $this->rs_count)
|
||||
) . '</caption>';
|
||||
|
||||
$cols = [
|
||||
'title' => '<th colspan="2" class="first">' . __('Name') . '</th>',
|
||||
'desc' => '<th scope="col">' . __('Feed') . '</th>',
|
||||
'period' => '<th scope="col">' . __('Frequency') . '</th>',
|
||||
'update' => '<th scope="col">' . __('Last update') . '</th>',
|
||||
'entries' => '<th scope="col">' . __('Entries') . '</th>',
|
||||
'status' => '<th scope="col">' . __('Status') . '</th>'
|
||||
];
|
||||
$cols = new ArrayObject($cols);
|
||||
|
||||
$this->core->callBehavior('adminZcfsFeedsListHeader', $this->core, $this->rs, $cols);
|
||||
|
||||
$this->userColumns('zcfs_feeds', $cols);
|
||||
|
||||
$html_block .= '<tr>' . implode(iterator_to_array($cols)) . '</tr>%s</table>%s</div>';
|
||||
if ($enclose_block) {
|
||||
$html_block = sprintf($enclose_block, $html_block);
|
||||
}
|
||||
|
||||
echo $pager->getLinks();
|
||||
|
||||
$blocks = explode('%s', $html_block);
|
||||
|
||||
echo $blocks[0];
|
||||
|
||||
$res = '';
|
||||
while ($this->rs->fetch()) {
|
||||
$res .= $this->feedsLine();
|
||||
echo $this->feedsLine(isset($entries[$this->rs->feed_id]));
|
||||
}
|
||||
|
||||
return
|
||||
$pager->getLinks().
|
||||
sprintf($enclose, sprintf($html_block, $res)).
|
||||
$pager->getLinks();
|
||||
echo $blocks[1];
|
||||
echo $blocks[2];
|
||||
echo $pager->getLinks();
|
||||
}
|
||||
}
|
||||
|
||||
private function feedsLine()
|
||||
private function feedsLine($checked)
|
||||
{
|
||||
$combo_status = zoneclearFeedServer::getAllStatus();
|
||||
$combo_upd_int = zoneclearFeedServer::getAllUpdateInterval();
|
||||
$status = $this->rs->feed_status ?
|
||||
'<img src="images/check-on.png" alt="enable" />' :
|
||||
'<img src="images/check-off.png" alt="disable" />';
|
||||
$category = $this->rs->cat_id ?
|
||||
$this->rs->cat_title : __('no categories');
|
||||
|
||||
$entries_count = $this->rs->zc->getPostsByFeed(array('feed_id' => $this->rs->feed_id), true)->f(0);
|
||||
$entries_count = $this->rs->zc->getPostsByFeed(['feed_id' => $this->rs->feed_id], true)->f(0);
|
||||
$shunk_feed = $this->rs->feed_feed;
|
||||
if (strlen($shunk_feed) > 83) {
|
||||
$shunk_feed = substr($shunk_feed,0,50).'...'.substr($shunk_feed,-20);
|
||||
}
|
||||
|
||||
$url = 'plugin.php?p=zoneclearFeedServer&part=feed&feed_id='.$this->rs->feed_id;
|
||||
$url = 'plugin.php?p=zoneclearFeedServer&part=feed&feed_id=' . $this->rs->feed_id;
|
||||
|
||||
return
|
||||
'<tr class="line">'."\n".
|
||||
'<td class="nowrap">'.
|
||||
form::checkbox(array('feeds[]'), $this->rs->feed_id, 0).
|
||||
'</td>'.
|
||||
'<td class="nowrap">'.
|
||||
'<a href="'.$url.'#feed" title="'.__('Edit').'">'.
|
||||
html::escapeHTML($this->rs->feed_name).'</a>'.
|
||||
"</td>\n".
|
||||
'<td class="maximal nowrap">'.
|
||||
'<a href="'.$this->rs->feed_feed.'" title="'.html::escapeHTML($this->rs->feed_desc).'">'.html::escapeHTML($shunk_feed).'</a>'.
|
||||
"</td>\n".
|
||||
'<td class="nowrap">'.
|
||||
array_search($this->rs->feed_upd_int,$combo_upd_int).
|
||||
"</td>\n".
|
||||
'<td class="nowrap">'.
|
||||
$cols = [
|
||||
'check' => '<td class="nowrap minimal">' .
|
||||
form::checkbox(['feeds[]'], $this->rs->feed_id, ['checked' => $checked]) .
|
||||
'</td>',
|
||||
'title' => '<td class="nowrap" scope="row">' .
|
||||
'<a href="' . $url . '#feed" title="' . __('Edit') . '">' . html::escapeHTML($this->rs->feed_name) . '</a>' .
|
||||
'</td>',
|
||||
'desc' => '<td class="nowrap maximal">' .
|
||||
'<a href="' . $this->rs->feed_feed . '" title="' . html::escapeHTML($this->rs->feed_desc) . '">' . html::escapeHTML($shunk_feed) . '</a>'.
|
||||
'</td>',
|
||||
'period' => '<td class="nowrap minimal count">' .
|
||||
array_search($this->rs->feed_upd_int,$combo_upd_int) .
|
||||
'</td>',
|
||||
'update' => '<td class="nowrap minimal count">' .
|
||||
($this->rs->feed_upd_last < 1 ?
|
||||
__('never') :
|
||||
dt::str(__('%Y-%m-%d %H:%M'), $this->rs->feed_upd_last,$this->rs->zc->core->auth->getInfo('user_tz'))
|
||||
).
|
||||
"</td>\n".
|
||||
'<td class="nowrap">'.
|
||||
dt::str(__('%Y-%m-%d %H:%M'), $this->rs->feed_upd_last, $this->rs->zc->core->auth->getInfo('user_tz'))
|
||||
) . '</td>',
|
||||
'entries' => '<td class="nowrap minimal count">' .
|
||||
($entries_count ?
|
||||
'<a href="'.$url.'#entries" title="'.__('View entries').'">'.$entries_count.'</a>' :
|
||||
'<a href="' . $url . '#entries" title="' . __('View entries') . '">' . $entries_count . '</a>' :
|
||||
$entries_count
|
||||
).
|
||||
"</td>\n".
|
||||
'<td>'.
|
||||
$status.
|
||||
"</td>\n".
|
||||
'</tr>'."\n";
|
||||
) . '</td>',
|
||||
'status' => '<td class="nowrap minimal status">' . $status . '</td>'
|
||||
];
|
||||
|
||||
$cols = new ArrayObject($cols);
|
||||
$this->core->callBehavior('adminZcfsFeedsListValue', $this->core, $this->rs, $cols);
|
||||
|
||||
$this->userColumns('zcfs_feeds', $cols);
|
||||
|
||||
return
|
||||
'<tr class="line ' . ($this->rs->feed_status ? '' : 'offline ') . '" id="p' . $this->rs->feed_id . '">' .
|
||||
implode(iterator_to_array($cols)) .
|
||||
'</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
|
114
index.php
114
index.php
@ -696,53 +696,13 @@ else {
|
||||
);
|
||||
|
||||
if ($feeds_actions_page->process()) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
# Combos
|
||||
$combo_sortby = array(
|
||||
__('Date') => 'feed_upddt',
|
||||
__('Name') => 'lowername',
|
||||
__('Frequency') => 'feed_upd_int',
|
||||
__('Date of update') => 'feed_upd_last',
|
||||
__('Status') => 'feed_status'
|
||||
);
|
||||
|
||||
$combo_order = array(
|
||||
__('Descending') => 'desc',
|
||||
__('Ascending') => 'asc'
|
||||
);
|
||||
|
||||
# Prepared lists
|
||||
$show_filters = false;
|
||||
$sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'feed_upddt';
|
||||
$order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
|
||||
$page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
|
||||
$nb_per_page = 30;
|
||||
if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
|
||||
if ($nb_per_page != $_GET['nb']) $show_filters = true;
|
||||
$nb_per_page = (integer) $_GET['nb'];
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['limit'] = array((($page-1)*$nb_per_page), $nb_per_page);
|
||||
|
||||
if ($sortby != '' && in_array($sortby, $combo_sortby)) {
|
||||
if ($order != '' && in_array($order, $combo_order)) {
|
||||
$params['order'] = $sortby.' '.$order;
|
||||
}
|
||||
if ($sortby != 'feed_upddt' || $order != 'desc') {
|
||||
$show_filters = true;
|
||||
}
|
||||
}
|
||||
|
||||
$pager_base_url = $p_url.
|
||||
'&part=feeds'.
|
||||
'&sortby='.$sortby.
|
||||
'&order='.$order.
|
||||
'&nb='.$nb_per_page.
|
||||
'&page=%s';
|
||||
$feeds_filter = new adminGenericFilter($core, 'zcfs_feeds');
|
||||
$feeds_filter->add('part', 'feeds');
|
||||
$feeds_filter->add(dcAdminFilters::getPageFilter());
|
||||
$params = $feeds_filter->params();
|
||||
|
||||
try {
|
||||
$feeds = $zcfs->getFeeds($params);
|
||||
@ -750,8 +710,7 @@ else {
|
||||
$feeds_list = new zcfsFeedsList(
|
||||
$core,
|
||||
$feeds,
|
||||
$feeds_counter,
|
||||
$pager_base_url
|
||||
$feeds_counter
|
||||
);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
@ -761,25 +720,9 @@ else {
|
||||
# Display
|
||||
echo
|
||||
'<html><head><title>'.__('Feeds server').'</title>'.
|
||||
dcPage::jsLoad(
|
||||
'index.php?pf=zoneclearFeedServer/js/feedsfilter.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::jsVars(['dotclear.filter_reset_url' => $core->adminurl->get('admin.plugin.zoneclearFeedServer', ['part' => 'feeds'])]) .
|
||||
dcPage::jsFilterControl($feeds_filter->show()) .
|
||||
dcPage::jsLoad(dcPage::getPF('zoneclearFeedServer/js/feedsfilter.js')) .
|
||||
dcPage::jsPageTabs().
|
||||
|
||||
# --BEHAVIOR-- packmanAdminHeader
|
||||
@ -798,51 +741,24 @@ else {
|
||||
|
||||
'<p class="top-add">'.
|
||||
'<a class="button add" href="'.$p_url.'&part=feed">'.
|
||||
__('New feed').'</a></p>'.
|
||||
__('New feed').'</a></p>';
|
||||
|
||||
'<form action="'.$p_url.'&part=feeds" method="get" id="filters-form">'.
|
||||
'<h3 class="out-of-screen-if-js">'.__('Show filters and display options').'</h3>'.
|
||||
$feeds_filter->display('admin.plugin.zoneclearFeedServer', form::hidden('p', 'zoneclearFeedServer') . form::hidden('part', 'feeds'));
|
||||
|
||||
'<div class="table">'.
|
||||
'<div class="cell">'.
|
||||
'<p><label for="sortby" class="ib">'.__('Order by:').'</label> '.
|
||||
form::combo('sortby',$combo_sortby, $sortby).'</p>'.
|
||||
'</div>'.
|
||||
'<div class="cell">'.
|
||||
'<p><label for="order" class="ib">'.__('Sort:').'</label> '.
|
||||
form::combo('order',$combo_order, $order).'</p>'.
|
||||
'</div>'.
|
||||
'<div class="cell">'.
|
||||
'<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'), 'feeds').
|
||||
'<br class="clear" /></p>'. //Opera sucks
|
||||
'</form>'.
|
||||
|
||||
$feeds_list->feedsDisplay($page, $nb_per_page, $pager_base_url,
|
||||
$feeds_list->feedsDisplay($feeds_filter->page, $feeds_filter->nb,
|
||||
'<form action="'.$p_url.'&part=feeds" method="post" id="form-actions">'.
|
||||
'%s'.
|
||||
'<div class="two-cols">'.
|
||||
'<p class="col checkboxes-helpers"></p>'.
|
||||
'<p class="col right">'.__('Selected feeds action:').' '.
|
||||
form::combo(array('action'), $feeds_actions_page->getCombo()).
|
||||
form::combo(['action'], $feeds_actions_page->getCombo()).
|
||||
'<input type="submit" value="'.__('ok').'" />'.
|
||||
form::hidden(array('sortby'), $sortby).
|
||||
form::hidden(array('order'), $order).
|
||||
form::hidden(array('page'), $page).
|
||||
form::hidden(array('nb'), $nb_per_page).
|
||||
form::hidden(array('p'), 'zoneclearFeedServer').
|
||||
form::hidden(array('part'), 'feeds').
|
||||
$core->adminurl->getHiddenFormFields('admin.plugin.zoneclearFeedServer', $feeds_filter->values(true)) .
|
||||
$core->formNonce().
|
||||
'</p>'.
|
||||
'</div>'.
|
||||
'</form>'
|
||||
'</form>',
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,31 +1,3 @@
|
||||
$(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=feeds" 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 New Issue
Block a user