addBehavior( 'initWidgets', ['zoneclearFeedServerWidget', 'adminSource'] ); dcCore::app()->addBehavior( 'initWidgets', ['zoneclearFeedServerWidget', 'adminNumber'] ); /** * @ingroup DC_PLUGIN_ZONECLEARFEEDSERVER * @brief Mix your blog with a feeds planet - widgets methods. * @since 2.6 */ class zoneclearFeedServerWidget { /** * Widget configuration for sources list. * * @param dcWidgets $w dcWidgets instance */ public static function adminSource($w) { $w ->create( 'zcfssource', __('Feeds server: sources'), ['zoneclearFeedServerWidget', 'publicSource'], null, __('List sources of feeds') ) ->addTitle( __('Feeds sources'), ) ->setting( 'sortby', __('Order by:'), 'feed_upd_last', 'combo', [ __('Last update') => 'feed_upd_last', __('Name') => 'lowername', __('Create date') => 'feed_creadt', ] ) ->setting( 'sort', __('Sort:'), 'desc', 'combo', [ __('Ascending') => 'asc', __('Descending') => 'desc', ] ) ->setting( 'limit', __('Limit:'), 10, 'text' ) ->setting( 'pagelink', __('Link to the list of sources:'), __('All sources'), 'text' ) ->addHomeOnly() ->addContentOnly() ->addClass() ->addOffline(); } /** * Widget configuration for feeds info. * * @param dcWidgets $w dcWidgets instance */ public static function adminNumber($w) { $w ->create( 'zcfsnumber', __('Feeds server: numbers'), ['zoneclearFeedServerWidget', 'publicNumber'], null, __('Show some numbers about feeds') ) ->addTitle( __('Feeds numbers'), ) ->setting( 'title', __('Title:'), __('Feeds numbers'), 'text' ) ->setting( 'feed_show', __('Show feeds count'), 1, 'check' ) ->setting( 'feed_title', __('Title for feeds count:'), __('Feeds:'), 'text' ) ->setting( 'entry_show', __('Show entries count'), 1, 'check' ) ->setting( 'entry_title', __('Title for entries count:'), __('Entries:'), 'text' ) ->addHomeOnly() ->addContentOnly() ->addClass() ->addOffline(); } /** * Widget for sources list. * * @param dcWidget $w dcWidget instance */ public static function publicSource($w) { if ($w->offline) { return null; } if (!dcCore::app()->blog->settings->__get(basename(__DIR__))->active || !$w->checkHomeOnly(dcCore::app()->url->type) ) { return null; } $p = []; $p['order'] = ($w->sortby && in_array($w->sortby, ['feed_upd_last', 'lowername', 'feed_creadt'])) ? $w->sortby . ' ' : 'feed_upd_last '; $p['order'] .= $w->sort == 'desc' ? 'DESC' : 'ASC'; $p['limit'] = abs((int) $w->limit); $p['feed_status'] = 1; $zc = new zoneclearFeedServer(); $rs = $zc->getFeeds($p); if ($rs->isEmpty()) { return null; } $lines = []; $i = 1; while ($rs->fetch()) { $lines[] = sprintf( '