addBehavior('initWidgets', [comListeWidget::class,'initWidget']); class comListeWidget { public static function initWidget($w) { $w->create( 'comListe', __('Comments list'), ['comListeWidget','publicWidget'], null, __('Link to comments list public page') ) ->addTitle(__('Comments list')) ->setting( 'link_title', __('Link title: (leave empty to use page title'), __('Comments list') ) ->addHomeOnly() ->addContentOnly() ->addClass() ->addOffline(); } public static function publicWidget($w) { if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type) || !dcCore::app()->blog->settings->get(basename(__DIR__))->get('enable') ) { return null; } return $w->renderDiv( $w->content_only, 'comliste ' . $w->class, '', ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . sprintf( '
', dcCore::app()->blog->url . dcCore::app()->url->getBase('comListe'), $w->link_title ? html::escapeHTML($w->link_title) : (dcCore::app()->blog->settings->get(basename(__DIR__))->get('page_title') ?? __('Comments list')) ) ); } }