addBehavior('initWidgets', ['shortArchivesWidgets','initWidgets']); class shortArchivesWidgets { public static function initWidgets($w) { $w->create( 'shortArchives', __('Short Archives'), ['shortArchivesWidgets', 'shortArchivesWidgets'], null, __('Blog Archive List an accordion menu, sorted by year') ) ->addTitle(__('Archives')) ->setting('postcount', __('With entries counts'), 1, 'check') ->setting('allarchivesslinktitle', __('Link to all archives:'), __('All archives')) ->addHomeOnly() ->addContentOnly() ->addClass() ->addOffline(); } public static function shortArchivesWidgets($w) { if ($w->offline) { return; } if (!$w->checkHomeOnly(dcCore::app()->url->type)) { return; } $rs = dcCore::app()->blog->getDates(['type' => 'month']); if ($rs->isEmpty()) { return; } $active_year = null; if ((dcCore::app()->url->type == 'archive') && preg_match('`^/([0-9]{4})/([0-9]{2})$`', dcCore::app()->url->args, $matches)) { $active_year = $matches[1]; } $posts = []; while ($rs->fetch()) { $posts[dt::dt2str(__('%Y'), $rs->dt)][] = [ 'url' => $rs->url(), 'date' => html::escapeHTML(dt::dt2str(__('%B'), $rs->dt)), 'nbpost' => $rs->nb_post, ]; } $res = '