add user pref filters for periods
parent
58a72dcab2
commit
5951c2b7a6
50
_admin.php
50
_admin.php
|
@ -25,6 +25,10 @@ $core->addBehavior(
|
||||||
'adminBeforeBlogSettingsUpdate',
|
'adminBeforeBlogSettingsUpdate',
|
||||||
['adminPeriodical', 'adminBeforeBlogSettingsUpdate']
|
['adminPeriodical', 'adminBeforeBlogSettingsUpdate']
|
||||||
);
|
);
|
||||||
|
$core->addBehavior(
|
||||||
|
'adminFiltersLists',
|
||||||
|
['adminPeriodical', 'adminFiltersLists']
|
||||||
|
);
|
||||||
|
|
||||||
if ($core->blog->settings->periodical->periodical_active) {
|
if ($core->blog->settings->periodical->periodical_active) {
|
||||||
|
|
||||||
|
@ -79,6 +83,15 @@ class adminPeriodical
|
||||||
{
|
{
|
||||||
public static $combo_period = null;
|
public static $combo_period = null;
|
||||||
|
|
||||||
|
public static function sortbyCombo()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
__('Next update') => 'periodical_curdt',
|
||||||
|
__('End date') => 'periodical_enddt',
|
||||||
|
__('Frequence') => 'periodical_pub_int'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add settings to blog preference
|
* Add settings to blog preference
|
||||||
*
|
*
|
||||||
|
@ -87,32 +100,20 @@ class adminPeriodical
|
||||||
*/
|
*/
|
||||||
public static function adminBlogPreferencesForm(dcCore $core, dcSettings $blog_settings)
|
public static function adminBlogPreferencesForm(dcCore $core, dcSettings $blog_settings)
|
||||||
{
|
{
|
||||||
$sortby_combo = [
|
|
||||||
__('Create date') => 'post_creadt',
|
|
||||||
__('Date') => 'post_dt',
|
|
||||||
__('Id') => 'post_id'
|
|
||||||
];
|
|
||||||
$order_combo = [
|
|
||||||
__('Descending') => 'desc',
|
|
||||||
__('Ascending') => 'asc'
|
|
||||||
];
|
|
||||||
|
|
||||||
$s_active = (boolean) $blog_settings->periodical->periodical_active;
|
$s_active = (boolean) $blog_settings->periodical->periodical_active;
|
||||||
$s_upddate = (boolean) $blog_settings->periodical->periodical_upddate;
|
$s_upddate = (boolean) $blog_settings->periodical->periodical_upddate;
|
||||||
$s_updurl = (boolean) $blog_settings->periodical->periodical_updurl;
|
$s_updurl = (boolean) $blog_settings->periodical->periodical_updurl;
|
||||||
$e_order = (string) $blog_settings->periodical->periodical_pub_order;
|
|
||||||
$e_order = explode(' ', $e_order);
|
|
||||||
$s_sortby = in_array($e_order[0], $sortby_combo) ? $e_order[0] : 'post_dt';
|
|
||||||
$s_order = isset($e_order[1]) && strtolower($e_order[1]) == 'desc' ? 'desc' : 'asc';
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
'<div class="fieldset"><h4 id="fac_params">' . __('Periodical') . '</h4>' .
|
'<div class="fieldset"><h4 id="periodical_params">' . __('Periodical') . '</h4>' .
|
||||||
'<div class="two-cols">' .
|
'<div class="two-cols">' .
|
||||||
'<div class="col">' .
|
'<div class="col">' .
|
||||||
'<h5>' . __('Activation') . '</h5>' .
|
'<h5>' . __('Activation') . '</h5>' .
|
||||||
'<p><label class="classic" for="periodical_active">' .
|
'<p><label class="classic" for="periodical_active">' .
|
||||||
form::checkbox('periodical_active', 1, $s_active) .
|
form::checkbox('periodical_active', 1, $s_active) .
|
||||||
__('Enable plugin') . '</label></p>' .
|
__('Enable plugin') . '</label></p>' .
|
||||||
|
'</div>' .
|
||||||
|
'<div class="col">' .
|
||||||
'<h5>' . __('Dates of published entries') . '</h5>' .
|
'<h5>' . __('Dates of published entries') . '</h5>' .
|
||||||
'<p><label for="periodical_upddate">' .
|
'<p><label for="periodical_upddate">' .
|
||||||
form::checkbox('periodical_upddate', 1, $s_upddate) .
|
form::checkbox('periodical_upddate', 1, $s_upddate) .
|
||||||
|
@ -121,13 +122,6 @@ class adminPeriodical
|
||||||
form::checkbox('periodical_updurl', 1, $s_updurl) .
|
form::checkbox('periodical_updurl', 1, $s_updurl) .
|
||||||
__('Update post url') . '</label></p>' .
|
__('Update post url') . '</label></p>' .
|
||||||
'</div>' .
|
'</div>' .
|
||||||
'<div class="col">' .
|
|
||||||
'<h5>' . __('Order of publication of entries') . '</h5>' .
|
|
||||||
'<p><label for="periodical_sortby">'.__('Order by:') . '</label>' .
|
|
||||||
form::combo('periodical_sortby', $sortby_combo, $s_sortby) . '</p>' .
|
|
||||||
'<p><label for="periodical_order">'.__('Sort:').'</label>' .
|
|
||||||
form::combo('periodical_order', $order_combo, $s_order) . '</p>' .
|
|
||||||
'</div>' .
|
|
||||||
'</div>' .
|
'</div>' .
|
||||||
'<br class="clear" />' .
|
'<br class="clear" />' .
|
||||||
'</div>';
|
'</div>';
|
||||||
|
@ -143,7 +137,17 @@ class adminPeriodical
|
||||||
$blog_settings->periodical->put('periodical_active', !empty($_POST['periodical_active']));
|
$blog_settings->periodical->put('periodical_active', !empty($_POST['periodical_active']));
|
||||||
$blog_settings->periodical->put('periodical_upddate', !empty($_POST['periodical_upddate']));
|
$blog_settings->periodical->put('periodical_upddate', !empty($_POST['periodical_upddate']));
|
||||||
$blog_settings->periodical->put('periodical_updurl', !empty($_POST['periodical_updurl']));
|
$blog_settings->periodical->put('periodical_updurl', !empty($_POST['periodical_updurl']));
|
||||||
$blog_settings->periodical->put('periodical_pub_order', $_POST['periodical_sortby'] . ' ' . $_POST['periodical_order']);
|
}
|
||||||
|
|
||||||
|
public static function adminFiltersLists(dcCore $core, $sorts)
|
||||||
|
{
|
||||||
|
$sorts['periodical'] = [
|
||||||
|
__('Periodical'),
|
||||||
|
self::sortbyCombo(),
|
||||||
|
'periodical_curdt',
|
||||||
|
'desc',
|
||||||
|
[__('periods per page'), 10]
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
126
index.php
126
index.php
|
@ -442,13 +442,11 @@ if ($part == 'period') {
|
||||||
<body>';
|
<body>';
|
||||||
|
|
||||||
echo
|
echo
|
||||||
dcPage::breadcrumb(
|
dcPage::breadcrumb([
|
||||||
[
|
|
||||||
html::escapeHTML($core->blog->name) => '',
|
html::escapeHTML($core->blog->name) => '',
|
||||||
__('Periodical') => $p_url . '&part=periods',
|
__('Periodical') => $p_url . '&part=periods',
|
||||||
(null === $period_id ? __('New period') : __('Edit period')) => ''
|
(null === $period_id ? __('New period') : __('Edit period')) => ''
|
||||||
]
|
]) .
|
||||||
) .
|
|
||||||
dcPage::notices();
|
dcPage::notices();
|
||||||
|
|
||||||
# Period form
|
# Period form
|
||||||
|
@ -655,49 +653,16 @@ if ($part == 'period') {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Combos
|
$combo_action = [
|
||||||
$sortby_combo = [
|
__('empty periods') => 'emptyperiods',
|
||||||
__('Next update') => 'periodical_curdt',
|
__('delete periods') => 'deleteperiods'
|
||||||
__('End date') => 'periodical_enddt',
|
|
||||||
__('Frequence') => 'periodical_pub_int'
|
|
||||||
];
|
];
|
||||||
|
|
||||||
$order_combo = [
|
|
||||||
__('Descending') => 'desc',
|
|
||||||
__('Ascending') => 'asc'
|
|
||||||
];
|
|
||||||
|
|
||||||
$combo_action = [];
|
|
||||||
$combo_action[__('empty periods')] = 'emptyperiods';
|
|
||||||
$combo_action[__('delete periods')] = 'deleteperiods';
|
|
||||||
|
|
||||||
# Filters
|
# Filters
|
||||||
$sortby = !empty($_GET['sortby']) ? $_GET['sortby'] : 'periodical_curdt';
|
$p_filter = new adminGenericFilter($core, 'periodical');
|
||||||
$order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
|
$p_filter->add('part', 'period');
|
||||||
|
|
||||||
$show_filters = false;
|
$params = $p_filter->params();
|
||||||
|
|
||||||
$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['limit'] = [(($page-1)*$nb_per_page), $nb_per_page];
|
|
||||||
|
|
||||||
if ($sortby !== '' && in_array($sortby, $sortby_combo)) {
|
|
||||||
if ($order !== '' && in_array($order, $order_combo)) {
|
|
||||||
$params['order'] = $sortby . ' ' . $order;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($sortby != 'periodical_curdt' || $order != 'desc') {
|
|
||||||
$show_filters = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get periods
|
# Get periods
|
||||||
try {
|
try {
|
||||||
|
@ -711,25 +676,8 @@ if ($part == 'period') {
|
||||||
# Display
|
# Display
|
||||||
echo
|
echo
|
||||||
'<html><head><title>' . __('Periodical') . '</title>' .
|
'<html><head><title>' . __('Periodical') . '</title>' .
|
||||||
dcPage::jsLoad(
|
//dcPage::jsLoad('index.php?pf=periodical/js/periodsfilter.js') .
|
||||||
'index.php?pf=periodical/js/periodsfilter.js'
|
$p_filter->js($core->adminurl->get('admin.plugin.periodical', ['part' => 'periods'])) .
|
||||||
) .
|
|
||||||
'<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" .
|
|
||||||
'</head>' .
|
'</head>' .
|
||||||
'<body>' .
|
'<body>' .
|
||||||
|
|
||||||
|
@ -745,44 +693,11 @@ if ($part == 'period') {
|
||||||
<a class="button add" href="' . $p_url . '&part=period">' . __('New period') . '</a>
|
<a class="button add" href="' . $p_url . '&part=period">' . __('New period') . '</a>
|
||||||
</p>';
|
</p>';
|
||||||
|
|
||||||
# Filter
|
# Filters
|
||||||
echo
|
$p_filter->display('admin.plugin.periodical', form::hidden('p', 'periodical') . form::hidden('part', 'periods'));
|
||||||
'<form action="' . $p_url . '" method="get" id="filters-form">' .
|
|
||||||
|
|
||||||
'<h3 class="out-of-screen-if-js">' .
|
|
||||||
__('Show filters and display options') .
|
|
||||||
'</h3>' .
|
|
||||||
|
|
||||||
'<div class="table">' .
|
|
||||||
|
|
||||||
'<div class="cell">' .
|
|
||||||
'<p><label for="sortby">' . __('Order by:') . '</label>' .
|
|
||||||
form::combo('sortby', $sortby_combo, $sortby) . '</p>' .
|
|
||||||
'</div>' .
|
|
||||||
|
|
||||||
'<div class="cell">' .
|
|
||||||
'<p><label for="order">' . __('Sort:') . '</label>' .
|
|
||||||
form::combo('order', $order_combo, $order) . '</p>' .
|
|
||||||
'</div>' .
|
|
||||||
|
|
||||||
'<div class="cell">' .
|
|
||||||
'<p><label for="nb">' . __('Results per page :') . '</label>' .
|
|
||||||
form::field('nb', 3, 3, $nb_per_page) . '</p>' .
|
|
||||||
'</div>' .
|
|
||||||
|
|
||||||
'</div>' .
|
|
||||||
|
|
||||||
'<p>' .
|
|
||||||
'<input type="submit" value="' . __('Apply filters and display options') . '" />' .
|
|
||||||
form::hidden(['p'], 'periodical') .
|
|
||||||
form::hidden(['part'], 'periods') .
|
|
||||||
'<br class="clear" />' . //Opera sucks
|
|
||||||
'</p>' .
|
|
||||||
|
|
||||||
'</form>';
|
|
||||||
|
|
||||||
# Posts list
|
# Posts list
|
||||||
echo $period_list->periodDisplay($page, $nb_per_page,
|
echo $period_list->periodDisplay($p_filter->page, $p_filter->nb,
|
||||||
'<form action="' . $p_url . '" method="post" id="form-periods">' .
|
'<form action="' . $p_url . '" method="post" id="form-periods">' .
|
||||||
|
|
||||||
'%s' .
|
'%s' .
|
||||||
|
@ -793,12 +708,7 @@ if ($part == 'period') {
|
||||||
'<p class="col right">' . __('Selected periods action:') . ' ' .
|
'<p class="col right">' . __('Selected periods action:') . ' ' .
|
||||||
form::combo('action', $combo_action) .
|
form::combo('action', $combo_action) .
|
||||||
'<input type="submit" value="' . __('ok') . '" /></p>' .
|
'<input type="submit" value="' . __('ok') . '" /></p>' .
|
||||||
form::hidden(['sortby'], $sortby) .
|
$core->adminurl->getHiddenFormFields('admin.plugin.periodical', array_merge(['p' => 'periodical'], $p_filter->values(true))) .
|
||||||
form::hidden(['order'], $order) .
|
|
||||||
form::hidden(['page'], $page) .
|
|
||||||
form::hidden(['nb'], $nb_per_page) .
|
|
||||||
form::hidden(['p'], 'periodical') .
|
|
||||||
form::hidden(['part'], 'periods') .
|
|
||||||
$core->formNonce() .
|
$core->formNonce() .
|
||||||
'</div>' .
|
'</div>' .
|
||||||
'</form>'
|
'</form>'
|
||||||
|
@ -808,10 +718,4 @@ if ($part == 'period') {
|
||||||
|
|
||||||
dcPage::helpBlock('periodical');
|
dcPage::helpBlock('periodical');
|
||||||
|
|
||||||
# Page footer
|
echo '</body></html>';
|
||||||
echo
|
|
||||||
'<hr class="clear"/><p class="right modules">
|
|
||||||
periodical - '. $core->plugins->moduleInfo('periodical', 'version') . '
|
|
||||||
<img alt="' . __('periodical') . '" src="index.php?pf=periodical/icon.png" />
|
|
||||||
</p>
|
|
||||||
</body></html>';
|
|
Loading…
Reference in New Issue