addBehavior('initWidgets', ['topWriterWidget', 'init']); class topWriterWidget { public static function init($w) { #Top comments widget $w ->create( 'topcom', __('Top writer: comments'), ['topWriterWidget', 'topCom'], null, __('List users who write more comments') ) ->addTitle(__('Top comments')) ->setting( 'text', __('Text:') . ' (%rank%, %author%, %count%)', '%author% (%count%)', 'text' ) ->setting( 'period', __('Period:'), 'year', 'combo', topWriter::periods() ) ->setting( 'sort', __('Sort:'), 'desc', 'combo', [ __('Ascending') => 'asc', __('Descending') => 'desc' ] ) ->setting( 'limit', __('Limit:'), '10', 'text' ) ->setting( 'exclude', __('Exclude post writer from list'), 0, 'check' ) ->addHomeOnly() ->addContentOnly() ->addClass() ->addOffline(); #Top entries widget $w ->create( 'toppost', __('Top writer: entries'), ['topWriterWidget', 'topPost'], null, __('List users who write more posts') ) ->addTitle(__('Top entries')) ->setting( 'text', __('Text:') . ' (%rank%, %author%, %count%)', '%author% (%count%)', 'text' ) ->setting( 'period', __('Period:'), 'year', 'combo', topWriter::periods() ) ->setting( 'sort', __('Sort:'), 'desc', 'combo', [ __('Ascending') => 'asc', __('Descending') => 'desc' ] ) ->setting( 'limit', __('Limit:'), '10', 'text' ) ->addHomeOnly() ->addContentOnly() ->addClass() ->addOffline(); } public static function topCom($w) { global $core; if ($w->offline || ($w->homeonly == 1 && !$core->url->isHome($core->url->type)) || ($w->homeonly == 2 && $core->url->isHome($core->url->type)) ) { return null; } $lines = topWriter::comments($core, $w->period, $w->limit, $w->sort == 'desc', $w->exclude); if (empty($lines)) { return null; } return $w->renderDiv( $w->content_only, 'topcomments ' . $w->class, '', ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . sprintf('