rs->isEmpty()) {
if ($filter->show()) {
echo '
' . __('No period matches the filter') . '
';
} else {
echo '' . __('No period') . '
';
}
} else {
$pager = new dcPager($filter->page, $this->rs_count, $filter->nb, 10);
$pager->var_page = 'page';
$periods = [];
if (isset($_REQUEST['periods'])) {
foreach ($_REQUEST['periods'] as $v) {
$periods[(integer) $v] = true;
}
}
$html_block = '' . ($filter->show() ?
sprintf(__('List of %s periods matching the filter.'), $this->rs_count) :
sprintf(__('List of %s periods.'), $this->rs_count)
). '';
$cols = new ArrayObject([
'name' => '' . __('Name') . ' | ',
'curdt' => '' . __('Next update') . ' | ',
'pub_int' => '' . __('Frequency') . ' | ',
'pub_nb' => '' . __('Pub per update') . ' | ',
'nbposts' => '' . __('Entries') . ' | ',
'enddt' => '' . __('End date') . ' | '
]);
$this->userColumns('periodical', $cols);
$html_block .= '' . implode(iterator_to_array($cols)) . '
%s
%s
';
if ($enclose_block) {
$html_block = sprintf($enclose_block, $html_block);
}
$blocks = explode('%s', $html_block);
echo $pager->getLinks() . $blocks[0];
while ($this->rs->fetch()) {
echo $this->periodLine(isset($periods[$this->rs->periodical_id]));
}
echo $blocks[1] . $blocks[2] . $pager->getLinks();
}
}
private function periodLine($checked)
{
$nb_posts = $this->rs->periodical->getPosts(['periodical_id' => $this->rs->periodical_id], true)->f(0);
$url = $this->core->adminurl->get('admin.plugin.periodical', ['part' => 'period', 'period_id' => $this->rs->periodical_id]);
$name = '' . html::escapeHTML($this->rs->periodical_title) . '';
$posts = $nb_posts ?
'' . $nb_posts . '' :
'0';
$interval = in_array($this->rs->periodical_pub_int, $this->rs->periodical->getTimesCombo()) ?
__(array_search($this->rs->periodical_pub_int, $this->rs->periodical->getTimesCombo())) : __('Unknow frequence');
$cols = new ArrayObject([
'check' => '' . form::checkbox(['periods[]'], $this->rs->periodical_id, ['checked' => $checked]) . ' | ',
'name' => '' . $name . ' | ',
'curdt' => '' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->periodical_curdt) . ' | ',
'pub_int' => '' . $interval . ' | ',
'pub_nb' => '' . $this->rs->periodical_pub_nb . ' | ',
'nbposts' => '' . $posts. ' | ',
'enddt' => '' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->periodical_enddt) . ' | '
]);
$this->userColumns('periodical', $cols);
return
'' .
implode(iterator_to_array($cols)) .
'
';
}
public function postDisplay($filter, $base_url, $enclose_block='')
{
$echo = '';
if ($this->rs->isEmpty()) {
if ($filter->show()) {
echo '' . __('No entry matches the filter') . '
';
} else {
echo '' . __('No entry') . '
';
}
} else {
$pager = new dcPager($filter->page, $this->rs_count, $filter->nb, 10);
$pager->base_url = $base_url;
$pager->var_page = 'page';
$periodical_entries = [];
if (isset($_REQUEST['periodical_entries'])) {
foreach ($_REQUEST['periodical_entries'] as $v) {
$periodical_entries[(integer) $v] = true;
}
}
$html_block =
'' .
'' . __('Title') . ' | ' .
'' . __('Date') . ' | ' .
'' . __('Category') . ' | ' .
'' . __('Author') . ' | ' .
'' . __('Status') . ' | ' .
'' . __('Create date') . ' | ' .
'
%s
';
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($periodical_entries[$this->rs->post_id]));
}
$echo .= $blocks[1];
$echo .= $pager->getLinks();
}
return $echo;
}
private function postLine($checked)
{
if ($this->core->auth->check('categories', $this->core->blog->id)) {
$cat_link = '%s';
} else {
$cat_link = '%2$s';
}
if ($this->rs->cat_title) {
$cat_title = sprintf(
$cat_link,
$this->rs->cat_id,
html::escapeHTML($this->rs->cat_title)
);
} else {
$cat_title = __('None');
}
$img = '';
switch ($this->rs->post_status)
{
case 1:
$img_status = sprintf($img, __('published'), 'check-on.png');
break;
case 0:
$img_status = sprintf($img, __('unpublished'), 'check-off.png');
break;
case -1:
$img_status = sprintf($img, __('scheduled'), 'scheduled.png');
break;
case -2:
$img_status = sprintf($img, __('pending'), 'check-wrn.png');
break;
}
$protected = '';
if ($this->rs->post_password) {
$protected = sprintf($img, __('protected'), 'locker.png');
}
$selected = '';
if ($this->rs->post_selected) {
$selected = sprintf($img, __('selected'), 'selected.png');
}
$attach = '';
$nb_media = $this->rs->countMedia();
if ($nb_media > 0) {
$attach_str = $nb_media == 1 ? __('%d attachment') : __('%d attachments');
$attach = sprintf($img, sprintf($attach_str, $nb_media), 'attach.png');
}
$res =
'' .
'' . form::checkbox(['periodical_entries[]'], $this->rs->post_id, 0) . ' | ' .
'rs->getURL()) . '">' .
html::escapeHTML($this->rs->post_title) . ' | ' .
'' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_dt) . ' | ' .
'' . $cat_title . ' | ' .
'' . $this->rs->user_id . ' | ' .
'' . $img_status . ' ' . $selected . ' ' . $protected . ' ' . $attach . ' | ' .
'' . dt::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->post_creadt, $this->rs->core->auth->getInfo('user_tz')) . ' | ' .
'
';
return $res;
}
}