2015-04-25 19:25:03 +00:00
|
|
|
<?php
|
2021-09-11 09:56:57 +00:00
|
|
|
/**
|
|
|
|
* @brief zoneclearFeedServer, a plugin for Dotclear 2
|
2021-11-06 15:30:19 +00:00
|
|
|
*
|
2021-09-11 09:56:57 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-06 15:30:19 +00:00
|
|
|
*
|
2021-09-11 09:56:57 +00:00
|
|
|
* @author Jean-Christian Denis, BG, Pierre Van Glabeke
|
2021-11-06 15:30:19 +00:00
|
|
|
*
|
2021-09-11 09:56:57 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2015-04-25 19:25:03 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
2021-09-11 09:56:57 +00:00
|
|
|
return null;
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup DC_PLUGIN_ZONECLEARFEEDSERVER
|
|
|
|
* @brief Feeds server - feeds list methods
|
|
|
|
* @since 2.6
|
|
|
|
* @see adminGenericList for more info
|
|
|
|
*/
|
|
|
|
class zcfsFeedsList extends adminGenericList
|
|
|
|
{
|
2022-11-15 20:05:21 +00:00
|
|
|
private $zc = null;
|
|
|
|
|
2021-10-09 20:21:31 +00:00
|
|
|
public function feedsDisplay($page, $nb_per_page, $enclose_block = '', $filter = false)
|
2021-09-11 09:56:57 +00:00
|
|
|
{
|
|
|
|
if ($this->rs->isEmpty()) {
|
2021-10-09 20:21:31 +00:00
|
|
|
if ($filter) {
|
|
|
|
echo '<p><strong>' . __('No feeds matches the filter') . '</strong></p>';
|
|
|
|
} else {
|
|
|
|
echo '<p><strong>' . __('No feeds') . '</strong></p>';
|
|
|
|
}
|
|
|
|
} else {
|
2022-11-15 20:05:21 +00:00
|
|
|
$this->zc = new zoneclearFeedServer();
|
|
|
|
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
|
|
|
|
$entries = [];
|
2021-10-09 20:21:31 +00:00
|
|
|
if (isset($_REQUEST['feeds'])) {
|
|
|
|
foreach ($_REQUEST['feeds'] as $v) {
|
2021-11-06 15:30:19 +00:00
|
|
|
$entries[(int) $v] = true;
|
2021-10-09 20:21:31 +00:00
|
|
|
}
|
|
|
|
}
|
2021-11-06 15:30:19 +00:00
|
|
|
$html_block = '<div class="table-outer">' .
|
|
|
|
'<table>' .
|
|
|
|
'<caption>' . (
|
|
|
|
$filter ?
|
2021-10-09 20:21:31 +00:00
|
|
|
sprintf(__('List of %s feeds matching the filter.'), $this->rs_count) :
|
2021-10-09 22:43:37 +00:00
|
|
|
sprintf(__('List of feeds (%s)'), $this->rs_count)
|
2021-10-09 20:21:31 +00:00
|
|
|
) . '</caption>';
|
2021-09-11 09:56:57 +00:00
|
|
|
|
2021-10-09 20:21:31 +00:00
|
|
|
$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>',
|
2022-11-15 20:05:21 +00:00
|
|
|
'status' => '<th scope="col">' . __('Status') . '</th>',
|
2021-10-09 20:21:31 +00:00
|
|
|
];
|
|
|
|
$cols = new ArrayObject($cols);
|
2021-09-11 09:56:57 +00:00
|
|
|
|
2022-11-15 20:05:21 +00:00
|
|
|
dcCore::app()->callBehavior('adminZcfsFeedsListHeader', $this->rs, $cols);
|
2021-09-11 09:56:57 +00:00
|
|
|
|
2021-10-09 20:21:31 +00:00
|
|
|
$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];
|
|
|
|
|
|
|
|
while ($this->rs->fetch()) {
|
|
|
|
echo $this->feedsLine(isset($entries[$this->rs->feed_id]));
|
|
|
|
}
|
|
|
|
|
|
|
|
echo $blocks[1];
|
|
|
|
echo $blocks[2];
|
|
|
|
echo $pager->getLinks();
|
|
|
|
}
|
2021-09-11 09:56:57 +00:00
|
|
|
}
|
|
|
|
|
2021-10-09 20:21:31 +00:00
|
|
|
private function feedsLine($checked)
|
2021-09-11 09:56:57 +00:00
|
|
|
{
|
2021-11-06 15:30:19 +00:00
|
|
|
$combo_status = zoneclearFeedServer::getAllStatus();
|
2021-09-11 09:56:57 +00:00
|
|
|
$combo_upd_int = zoneclearFeedServer::getAllUpdateInterval();
|
2021-11-06 15:30:19 +00:00
|
|
|
$status = $this->rs->feed_status ?
|
2021-09-11 09:56:57 +00:00
|
|
|
'<img src="images/check-on.png" alt="enable" />' :
|
|
|
|
'<img src="images/check-off.png" alt="disable" />';
|
|
|
|
|
2022-11-15 20:05:21 +00:00
|
|
|
$entries_count = $this->zc->getPostsByFeed(['feed_id' => $this->rs->feed_id], true)->f(0);
|
2021-11-06 15:30:19 +00:00
|
|
|
$shunk_feed = $this->rs->feed_feed;
|
2021-09-11 09:56:57 +00:00
|
|
|
if (strlen($shunk_feed) > 83) {
|
2021-11-06 15:30:19 +00:00
|
|
|
$shunk_feed = substr($shunk_feed, 0, 50) . '...' . substr($shunk_feed, -20);
|
2021-09-11 09:56:57 +00:00
|
|
|
}
|
|
|
|
|
2021-10-09 20:21:31 +00:00
|
|
|
$url = 'plugin.php?p=zoneclearFeedServer&part=feed&feed_id=' . $this->rs->feed_id;
|
|
|
|
|
|
|
|
$cols = [
|
2021-11-06 15:30:19 +00:00
|
|
|
'check' => '<td class="nowrap minimal">' .
|
|
|
|
form::checkbox(['feeds[]'], $this->rs->feed_id, ['checked' => $checked]) .
|
2021-10-09 20:21:31 +00:00
|
|
|
'</td>',
|
|
|
|
'title' => '<td class="nowrap" scope="row">' .
|
|
|
|
'<a href="' . $url . '#feed" title="' . __('Edit') . '">' . html::escapeHTML($this->rs->feed_name) . '</a>' .
|
|
|
|
'</td>',
|
2021-11-06 15:30:19 +00:00
|
|
|
'desc' => '<td class="nowrap maximal">' .
|
|
|
|
'<a href="' . $this->rs->feed_feed . '" title="' . html::escapeHTML($this->rs->feed_desc) . '">' . html::escapeHTML($shunk_feed) . '</a>' .
|
2021-10-09 20:21:31 +00:00
|
|
|
'</td>',
|
2021-11-06 15:30:19 +00:00
|
|
|
'period' => '<td class="nowrap minimal count">' .
|
|
|
|
array_search($this->rs->feed_upd_int, $combo_upd_int) .
|
2021-10-09 20:21:31 +00:00
|
|
|
'</td>',
|
2021-11-06 15:30:19 +00:00
|
|
|
'update' => '<td class="nowrap minimal count">' .
|
|
|
|
(
|
|
|
|
$this->rs->feed_upd_last < 1 ?
|
|
|
|
__('never') :
|
2022-11-15 20:05:21 +00:00
|
|
|
dt::str(__('%Y-%m-%d %H:%M'), (int) $this->rs->feed_upd_last, dcCore::app()->auth->getInfo('user_tz'))
|
2021-10-09 20:21:31 +00:00
|
|
|
) . '</td>',
|
2021-11-06 15:30:19 +00:00
|
|
|
'entries' => '<td class="nowrap minimal count">' .
|
|
|
|
(
|
|
|
|
$entries_count ?
|
2021-10-09 20:21:31 +00:00
|
|
|
'<a href="' . $url . '#entries" title="' . __('View entries') . '">' . $entries_count . '</a>' :
|
|
|
|
$entries_count
|
|
|
|
) . '</td>',
|
2022-11-15 20:05:21 +00:00
|
|
|
'status' => '<td class="nowrap minimal status">' . $status . '</td>',
|
2021-10-09 20:21:31 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
$cols = new ArrayObject($cols);
|
2022-11-15 20:05:21 +00:00
|
|
|
dcCore::app()->callBehavior('adminZcfsFeedsListValue', $this->rs, $cols);
|
2021-10-09 20:21:31 +00:00
|
|
|
|
|
|
|
$this->userColumns('zcfs_feeds', $cols);
|
|
|
|
|
2021-11-06 15:30:19 +00:00
|
|
|
return
|
2021-10-09 20:21:31 +00:00
|
|
|
'<tr class="line ' . ($this->rs->feed_status ? '' : 'offline ') . '" id="p' . $this->rs->feed_id . '">' .
|
|
|
|
implode(iterator_to_array($cols)) .
|
|
|
|
'</tr>';
|
2021-09-11 09:56:57 +00:00
|
|
|
}
|
2015-04-25 19:25:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup DC_PLUGIN_ZONECLEARFEEDSERVER
|
|
|
|
* @brief Feeds server - Posts list methods
|
|
|
|
* @since 2.6
|
|
|
|
* @see adminGenericList for more info
|
|
|
|
*/
|
|
|
|
class zcfsEntriesList extends adminGenericList
|
|
|
|
{
|
2021-10-09 22:43:37 +00:00
|
|
|
public function display($page, $nb_per_page, $base_url, $enclose_block = '', $filter = false)
|
2021-09-11 09:56:57 +00:00
|
|
|
{
|
|
|
|
if ($this->rs->isEmpty()) {
|
2021-11-06 15:30:19 +00:00
|
|
|
echo '<p><strong>' . (
|
|
|
|
$filter ?
|
2021-10-09 22:43:37 +00:00
|
|
|
__('No entries matches the filter') :
|
|
|
|
__('No entries')
|
2021-11-06 15:30:19 +00:00
|
|
|
) . '</strong></p>';
|
2021-10-09 22:43:37 +00:00
|
|
|
} else {
|
2021-11-06 15:30:19 +00:00
|
|
|
$pager = new dcPager($page, $this->rs_count, $nb_per_page, 10);
|
2021-10-09 22:43:37 +00:00
|
|
|
$pager->base_url = $base_url;
|
2021-09-11 09:56:57 +00:00
|
|
|
|
2021-10-09 22:43:37 +00:00
|
|
|
$entries = [];
|
|
|
|
if (isset($_REQUEST['feeds'])) {
|
|
|
|
foreach ($_REQUEST['feeds'] as $v) {
|
2021-11-06 15:30:19 +00:00
|
|
|
$entries[(int) $v] = true;
|
2021-10-09 22:43:37 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-11 09:56:57 +00:00
|
|
|
|
2021-10-09 22:43:37 +00:00
|
|
|
$html_block = '<div class="table-outer clear">' .
|
2021-11-06 15:30:19 +00:00
|
|
|
'<table>' .
|
|
|
|
'<caption>' . (
|
|
|
|
$filter ?
|
2021-10-09 22:43:37 +00:00
|
|
|
sprintf(__('List of %s entries matching the filter.'), $this->rs_count) :
|
|
|
|
sprintf(__('List of entries (%s)'), $this->rs_count)
|
|
|
|
) . '</caption>';
|
2021-09-11 09:56:57 +00:00
|
|
|
|
2021-10-09 22:43:37 +00:00
|
|
|
$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>',
|
2022-11-15 20:05:21 +00:00
|
|
|
'status' => '<th scope="col">' . __('Status') . '</th>',
|
2021-10-09 22:43:37 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
$cols = new ArrayObject($cols);
|
2022-11-15 20:05:21 +00:00
|
|
|
dcCore::app()->callBehavior('adminZcfsPostListHeader', $this->rs, $cols);
|
2021-10-09 22:43:37 +00:00
|
|
|
|
|
|
|
$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()) {
|
2022-11-15 20:05:21 +00:00
|
|
|
echo $this->postLine();
|
2021-10-09 22:43:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo $blocks[1];
|
|
|
|
|
|
|
|
echo $pager->getLinks();
|
|
|
|
}
|
2021-09-11 09:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private function postLine()
|
|
|
|
{
|
2022-11-30 20:54:56 +00:00
|
|
|
$cat_link = dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CATEGORIES]), dcCore::app()->blog->id) ?
|
2021-11-06 15:30:19 +00:00
|
|
|
'<a href="category.php?id=%s" title="' . __('Edit category') . '">%s</a>'
|
2021-09-11 09:56:57 +00:00
|
|
|
: '%2$s';
|
|
|
|
|
2021-11-06 15:30:19 +00:00
|
|
|
$cat_title = $this->rs->cat_title ?
|
|
|
|
sprintf($cat_link, $this->rs->cat_id, html::escapeHTML($this->rs->cat_title))
|
2021-09-11 09:56:57 +00:00
|
|
|
: __('None');
|
|
|
|
|
2021-10-09 22:43:37 +00:00
|
|
|
$img = '<img alt="%1$s" title="%1$s" src="images/%2$s" />';
|
|
|
|
$img_status = '';
|
|
|
|
$sts_class = '';
|
2021-09-11 09:56:57 +00:00
|
|
|
switch ($this->rs->post_status) {
|
|
|
|
case 1:
|
2021-10-09 22:43:37 +00:00
|
|
|
$img_status = sprintf($img, __('Published'), 'check-on.png');
|
|
|
|
$sts_class = 'sts-online';
|
|
|
|
|
2021-09-11 09:56:57 +00:00
|
|
|
break;
|
|
|
|
case 0:
|
2021-10-09 22:43:37 +00:00
|
|
|
$img_status = sprintf($img, __('Unpublished'), 'check-off.png');
|
|
|
|
$sts_class = 'sts-offline';
|
|
|
|
|
2021-09-11 09:56:57 +00:00
|
|
|
break;
|
|
|
|
case -1:
|
2021-10-09 22:43:37 +00:00
|
|
|
$img_status = sprintf($img, __('Scheduled'), 'scheduled.png');
|
|
|
|
$sts_class = 'sts-scheduled';
|
|
|
|
|
2021-09-11 09:56:57 +00:00
|
|
|
break;
|
|
|
|
case -2:
|
2021-10-09 22:43:37 +00:00
|
|
|
$img_status = sprintf($img, __('Pending'), 'check-wrn.png');
|
|
|
|
$sts_class = 'sts-pending';
|
|
|
|
|
2021-09-11 09:56:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-10-09 22:43:37 +00:00
|
|
|
$res = '<tr class="line ' . ($this->rs->post_status != 1 ? 'offline ' : '') . $sts_class . '"' .
|
|
|
|
' id="p' . $this->rs->post_id . '">';
|
|
|
|
|
|
|
|
$cols = [
|
2021-11-06 15:30:19 +00:00
|
|
|
'check' => '<td class="nowrap minimal">' .
|
|
|
|
form::checkbox(['entries[]'], $this->rs->post_id, '', '', '', !$this->rs->isEditable()) . '</td>',
|
|
|
|
'title' => '<td scope="row" class="maximal"><a href="' .
|
2022-11-15 20:05:21 +00:00
|
|
|
dcCore::app()->getPostAdminURL($this->rs->post_type, $this->rs->post_id) . '" ' .
|
2021-10-09 22:43:37 +00:00
|
|
|
'title="' . html::escapeHTML($this->rs->getURL()) . '">' .
|
|
|
|
html::escapeHTML(trim(html::clean($this->rs->post_title))) . '</a></td>',
|
|
|
|
'date' => '<td class="nowrap count">' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt) . '</td>',
|
|
|
|
'author' => '<td class="nowrap">' . html::escapeHTML($this->rs->user_id) . '</td>',
|
2021-11-06 15:30:19 +00:00
|
|
|
'category' => '<td class="nowrap">' . $cat_title . '</td>',
|
2022-11-15 20:05:21 +00:00
|
|
|
'status' => '<td class="nowrap status">' . $img_status . '</td>',
|
2021-10-09 22:43:37 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
$cols = new ArrayObject($cols);
|
2022-11-15 20:05:21 +00:00
|
|
|
dcCore::app()->callBehavior('adminZcfsPostListValue', $this->rs, $cols);
|
2021-10-09 22:43:37 +00:00
|
|
|
|
|
|
|
$this->userColumns('zcfs_entries', $cols);
|
|
|
|
|
|
|
|
$res .= implode(iterator_to_array($cols));
|
|
|
|
$res .= '</tr>';
|
|
|
|
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-10-28 20:55:43 +00:00
|
|
|
/**
|
|
|
|
* @ingroup DC_PLUGIN_ZONECLEARFEEDSERVER
|
|
|
|
* @brief Feeds server - Posts list filters methods
|
|
|
|
* @since 2.20
|
|
|
|
* @see adminGenericFilter for more info
|
|
|
|
*/
|
2021-10-09 22:43:37 +00:00
|
|
|
class adminZcfsPostFilter extends adminGenericFilter
|
|
|
|
{
|
2022-11-15 20:05:21 +00:00
|
|
|
public function __construct()
|
2021-10-09 22:43:37 +00:00
|
|
|
{
|
2022-11-15 20:05:21 +00:00
|
|
|
parent::__construct(dcCore::app(), 'zcfs_entries');
|
2021-10-09 22:43:37 +00:00
|
|
|
|
|
|
|
$filters = new arrayObject([
|
|
|
|
dcAdminFilters::getPageFilter(),
|
|
|
|
$this->getPostUserFilter(),
|
|
|
|
$this->getPostCategoriesFilter(),
|
|
|
|
$this->getPostStatusFilter(),
|
2022-11-15 20:05:21 +00:00
|
|
|
$this->getPostMonthFilter(),
|
2021-10-09 22:43:37 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
# --BEHAVIOR-- adminPostFilter
|
2022-11-15 20:05:21 +00:00
|
|
|
dcCore::app()->callBehavior('adminZcfsPostFilter', $filters);
|
2021-10-09 22:43:37 +00:00
|
|
|
|
|
|
|
$filters = $filters->getArrayCopy();
|
|
|
|
|
|
|
|
$this->add($filters);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Posts users select
|
|
|
|
*/
|
|
|
|
public function getPostUserFilter(): ?dcAdminFilter
|
|
|
|
{
|
|
|
|
$users = null;
|
2021-11-06 15:30:19 +00:00
|
|
|
|
2021-10-09 22:43:37 +00:00
|
|
|
try {
|
2022-11-15 20:05:21 +00:00
|
|
|
$users = dcCore::app()->blog->getPostsUsers();
|
2021-10-09 22:43:37 +00:00
|
|
|
if ($users->isEmpty()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2022-11-15 20:05:21 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-11-06 15:30:19 +00:00
|
|
|
|
2021-10-09 22:43:37 +00:00
|
|
|
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;
|
2021-11-06 15:30:19 +00:00
|
|
|
|
2021-10-09 22:43:37 +00:00
|
|
|
try {
|
2022-11-15 20:05:21 +00:00
|
|
|
$categories = dcCore::app()->blog->getCategories();
|
2021-10-09 22:43:37 +00:00
|
|
|
if ($categories->isEmpty()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2022-11-15 20:05:21 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-11-06 15:30:19 +00:00
|
|
|
|
2021-10-09 22:43:37 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$combo = [
|
2021-11-06 15:30:19 +00:00
|
|
|
'-' => '',
|
2022-11-15 20:05:21 +00:00
|
|
|
__('(No cat)') => 'NULL',
|
2021-10-09 22:43:37 +00:00
|
|
|
];
|
|
|
|
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);
|
2021-09-11 09:56:57 +00:00
|
|
|
}
|
2021-10-09 22:43:37 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
2021-11-06 15:30:19 +00:00
|
|
|
|
2021-10-09 22:43:37 +00:00
|
|
|
try {
|
2022-11-15 20:05:21 +00:00
|
|
|
$dates = dcCore::app()->blog->getDates(['type' => 'month']);
|
2021-10-09 22:43:37 +00:00
|
|
|
if ($dates->isEmpty()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
} catch (Exception $e) {
|
2022-11-15 20:05:21 +00:00
|
|
|
dcCore::app()->error->add($e->getMessage());
|
2021-11-06 15:30:19 +00:00
|
|
|
|
2021-10-09 22:43:37 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (new dcAdminFilter('month'))
|
2021-11-06 15:30:19 +00:00
|
|
|
->param('post_month', function ($f) { return substr($f[0], 4, 2); })
|
|
|
|
->param('post_year', function ($f) { return substr($f[0], 0, 4); })
|
2021-10-09 22:43:37 +00:00
|
|
|
->title(__('Month:'))
|
|
|
|
->options(array_merge(
|
|
|
|
['-' => ''],
|
|
|
|
dcAdminCombos::getDatesCombo($dates)
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|