[0] | 1 | <?php |
---|
[3731] | 2 | /** |
---|
| 3 | * @brief blogroll, a plugin for Dotclear 2 |
---|
| 4 | * |
---|
| 5 | * @package Dotclear |
---|
| 6 | * @subpackage Plugins |
---|
| 7 | * |
---|
| 8 | * @copyright Olivier Meunier & Association Dotclear |
---|
| 9 | * @copyright GPL-2.0-only |
---|
| 10 | */ |
---|
| 11 | |
---|
[3730] | 12 | if (!defined('DC_RC_PATH')) {return;} |
---|
[0] | 13 | |
---|
[3874] | 14 | $core->addBehavior('initWidgets', ['blogrollWidgets', 'initWidgets']); |
---|
| 15 | $core->addBehavior('initDefaultWidgets', ['blogrollWidgets', 'initDefaultWidgets']); |
---|
[0] | 16 | |
---|
| 17 | class blogrollWidgets |
---|
| 18 | { |
---|
[3730] | 19 | public static function initWidgets($w) |
---|
| 20 | { |
---|
[3874] | 21 | $w->create('links', __('Blogroll'), ['tplBlogroll', 'linksWidget'], null, 'Blogroll list'); |
---|
[3730] | 22 | $w->links->setting('title', __('Title (optional)') . ' :', __('Links')); |
---|
[2566] | 23 | |
---|
[3730] | 24 | $br = new dcBlogroll($GLOBALS['core']->blog); |
---|
| 25 | $h = $br->getLinksHierarchy($br->getLinks()); |
---|
| 26 | $h = array_keys($h); |
---|
[3874] | 27 | $categories = [__('All categories') => '']; |
---|
[3730] | 28 | foreach ($h as $v) { |
---|
| 29 | if ($v) { |
---|
| 30 | $categories[$v] = $v; |
---|
| 31 | } |
---|
| 32 | } |
---|
| 33 | unset($br, $h); |
---|
| 34 | $w->links->setting('category', __('Category'), '', 'combo', $categories); |
---|
[2566] | 35 | |
---|
[3730] | 36 | $w->links->setting('homeonly', __('Display on:'), 1, 'combo', |
---|
[3874] | 37 | [ |
---|
[3730] | 38 | __('All pages') => 0, |
---|
| 39 | __('Home page only') => 1, |
---|
| 40 | __('Except on home page') => 2 |
---|
[3874] | 41 | ] |
---|
[3730] | 42 | ); |
---|
| 43 | $w->links->setting('content_only', __('Content only'), 0, 'check'); |
---|
| 44 | $w->links->setting('class', __('CSS class:'), ''); |
---|
| 45 | $w->links->setting('offline', __('Offline'), 0, 'check'); |
---|
| 46 | } |
---|
[2566] | 47 | |
---|
[3730] | 48 | public static function initDefaultWidgets($w, $d) |
---|
| 49 | { |
---|
| 50 | $d['extra']->append($w->links); |
---|
| 51 | } |
---|
[0] | 52 | } |
---|