rs->isEmpty()) { if ($filter->show()) { echo '

' . __('No period matches the filter') . '

'; } else { echo '

' . __('No period') . '

'; } } else { $pager = new Pager((int) $filter->value('page'), (int) $this->rs_count, (int) $filter->value('nb'), 10); $pager->var_page = 'page'; $periods = []; if (isset($_REQUEST['periods'])) { foreach ($_REQUEST['periods'] as $v) { $periods[(int) $v] = true; } } $html_block = '
'; $cols = new ArrayObject([ 'name' => '', 'curdt' => '', 'pub_int' => '', 'pub_nb' => '', 'nbposts' => '', 'enddt' => '', ]); $this->userColumns(My::id(), $cols); $html_block .= '' . implode(iterator_to_array($cols)) . '%s
' . ( $filter->show() ? sprintf(__('List of %s periods matching the filter.'), $this->rs_count) : sprintf(__('List of %s periods.'), $this->rs_count) ) . '
' . __('Name') . '' . __('Next update') . '' . __('Frequency') . '' . __('Entries per update') . '' . __('Entries') . '' . __('End date') . '
%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()) { $this->periodLine(isset($periods[(int) $this->rs->f('periodical_id')])); } echo $blocks[1] . $blocks[2] . $pager->getLinks(); } } /** * Display a period list line. * * @param bool $checked Selected line */ private function periodLine(bool $checked): void { $tz = App::auth()->getInfo('user_tz'); $nb_posts = Utils::getPosts(['periodical_id' => $this->rs->f('periodical_id')], true)->f(0); $url = My::manageUrl(['part' => 'period', 'period_id' => $this->rs->f('periodical_id')]); $name = '' . Html::escapeHTML($this->rs->periodical_title) . ''; $posts = $nb_posts ? '' . $nb_posts . '' : '0'; $interval = in_array($this->rs->f('periodical_pub_int'), My::periodCombo()) ? __((string) array_search($this->rs->f('periodical_pub_int'), My::periodCombo())) : __('Unknow frequence'); $cols = new ArrayObject([ 'check' => '' . (new Checkbox(['periods[]'], $checked))->value($this->rs->f('periodical_id'))->render() . '', 'name' => '' . $name . '', 'curdt' => '' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('periodical_curdt'), $tz ?? 'UTC') . '', 'pub_int' => '' . $interval . '', 'pub_nb' => '' . $this->rs->f('periodical_pub_nb') . '', 'nbposts' => '' . $posts . '', 'enddt' => '' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('periodical_enddt'), $tz ?? 'UTC') . '', ]); $this->userColumns(My::id(), $cols); echo '' . implode(iterator_to_array($cols)) . ''; } /** * Display period posts list. * * @param FilterPosts $filter The posts filter * @param string $base_url The page base URL * @param string $enclose_block The enclose block */ public function postDisplay(FilterPosts $filter, string $base_url, string $enclose_block = ''): void { $echo = ''; if ($this->rs->isEmpty()) { if ($filter->show()) { echo '

' . __('No entry matches the filter') . '

'; } else { echo '

' . __('No entry') . '

'; } } else { $pager = new Pager((int) $filter->value('page'), (int) $this->rs_count, (int) $filter->value('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[(int) $v] = true; } } $cols = [ 'title' => '' . __('Title') . '', 'date' => '' . __('Date') . '', 'category' => '' . __('Category') . '', 'author' => '' . __('Author') . '', 'status' => '' . __('Status') . '', 'create' => '' . __('Create date') . '', ]; $html_block = '
' . implode($cols) . '%s
' . ( $filter->show() ? sprintf(__('List of %s entries matching the filter.'), $this->rs_count) : sprintf(__('List of %s entries.'), $this->rs_count) ) . '
%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()) { $this->postLine(isset($periodical_entries[(int) $this->rs->f('post_id')])); } $img = '%1$s %1$s'; echo $blocks[1] . '

' . __('Legend: ') . sprintf($img, __('Published'), 'check-on.png') . ' - ' . sprintf($img, __('Unpublished'), 'check-off.png') . ' - ' . sprintf($img, __('Scheduled'), 'scheduled.png') . ' - ' . sprintf($img, __('Pending'), 'check-wrn.png') . ' - ' . sprintf($img, __('Protected'), 'locker.png') . ' - ' . sprintf($img, __('Selected'), 'selected.png') . ' - ' . sprintf($img, __('Attachments'), 'attach.png') . '

' . $blocks[2] . $pager->getLinks(); } } /** * Display post list line. * * @param bool $checked Selected line */ private function postLine(bool $checked): void { if (App::auth()->check(App::auth()->makePermissions([App::auth()::PERMISSION_CATEGORIES]), App::blog()->id())) { $cat_link = '%s'; } else { $cat_link = '%2$s'; } if ($this->rs->f('cat_title')) { $cat_title = sprintf( $cat_link, $this->rs->f('cat_id'), Html::escapeHTML($this->rs->f('cat_title')) ); } else { $cat_title = __('None'); } $img_status = ''; $img = '%1$s'; switch ((int) $this->rs->f('post_status')) { case App::blog()::POST_PUBLISHED: $img_status = sprintf($img, __('published'), 'check-on.png'); break; case App::blog()::POST_UNPUBLISHED: $img_status = sprintf($img, __('unpublished'), 'check-off.png'); break; case App::blog()::POST_SCHEDULED: $img_status = sprintf($img, __('scheduled'), 'scheduled.png'); break; case App::blog()::POST_PENDING: $img_status = sprintf($img, __('pending'), 'check-wrn.png'); break; } $protected = ''; if ($this->rs->f('post_password')) { $protected = sprintf($img, __('protected'), 'locker.png'); } $selected = ''; if ($this->rs->f('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'); } $tz = App::auth()->getInfo('user_tz'); $cols = [ 'check' => '' . (new Checkbox(['periodical_entries[]'], $checked))->value($this->rs->f('post_id'))->render() . '', 'title' => '' . Html::escapeHTML($this->rs->post_title) . '', 'date' => '' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('post_dt')) . '', 'category' => '' . $cat_title . '', 'author' => '' . $this->rs->f('user_id') . '', 'status' => '' . $img_status . ' ' . $selected . ' ' . $protected . ' ' . $attach . '', 'create' => '' . Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->f('post_creadt'), $tz ?? 'UTC') . '', ]; echo '' . implode($cols) . ''; } }