';
$cols = [
'check' => ''.
form::checkbox(array('entries[]'), $this->rs->post_id, '', '', '', !$this->rs->isEditable()).' | ',
'title' => 'rs->getURL()) . '">' .
html::escapeHTML(trim(html::clean($this->rs->post_title))) . ' | ',
'date' => '' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt) . ' | ',
'author' => '' . html::escapeHTML($this->rs->user_id) . ' | ',
'category' => ''.$cat_title.' | ',
'status' => '' . $img_status . ' | '
];
$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 .= '
';
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)
));
}
}