| [0] | 1 | <?php |
|---|
| [3731] | 2 | /** |
|---|
| 3 | * @brief widgets, 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 | |
|---|
| [3730] | 14 | require dirname(__FILE__) . '/class.widgets.php'; |
|---|
| [0] | 15 | |
|---|
| 16 | # Available widgets |
|---|
| 17 | global $__widgets; |
|---|
| 18 | $__widgets = new dcWidgets; |
|---|
| 19 | |
|---|
| [3730] | 20 | $__widgets->create('search', __('Search engine'), array('defaultWidgets', 'search'), null, 'Search engine form'); |
|---|
| 21 | $__widgets->search->setting('title', __('Title (optional)') . ' :', __('Search')); |
|---|
| 22 | $__widgets->search->setting('placeholder', __('Placeholder (HTML5 only, optional):'), ''); |
|---|
| 23 | $__widgets->search->setting('homeonly', __('Display on:'), 0, 'combo', |
|---|
| 24 | array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); |
|---|
| 25 | $__widgets->search->setting('content_only', __('Content only'), 0, 'check'); |
|---|
| 26 | $__widgets->search->setting('class', __('CSS class:'), ''); |
|---|
| 27 | $__widgets->search->setting('offline', __('Offline'), 0, 'check'); |
|---|
| [0] | 28 | |
|---|
| [3730] | 29 | $__widgets->create('navigation', __('Navigation links'), array('defaultWidgets', 'navigation'), null, 'List of navigation links'); |
|---|
| 30 | $__widgets->navigation->setting('title', __('Title (optional)') . ' :', ''); |
|---|
| 31 | $__widgets->navigation->setting('homeonly', __('Display on:'), 0, 'combo', |
|---|
| 32 | array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); |
|---|
| 33 | $__widgets->navigation->setting('content_only', __('Content only'), 0, 'check'); |
|---|
| 34 | $__widgets->navigation->setting('class', __('CSS class:'), ''); |
|---|
| 35 | $__widgets->navigation->setting('offline', __('Offline'), 0, 'check'); |
|---|
| [0] | 36 | |
|---|
| [3730] | 37 | $__widgets->create('bestof', __('Selected entries'), array('defaultWidgets', 'bestof'), null, 'List of selected entries'); |
|---|
| 38 | $__widgets->bestof->setting('title', __('Title (optional)') . ' :', __('Best of me')); |
|---|
| 39 | $__widgets->bestof->setting('orderby', __('Sort:'), 'asc', 'combo', array(__('Ascending') => 'asc', __('Descending') => 'desc')); |
|---|
| 40 | $__widgets->bestof->setting('homeonly', __('Display on:'), 1, 'combo', |
|---|
| 41 | array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); |
|---|
| 42 | $__widgets->bestof->setting('content_only', __('Content only'), 0, 'check'); |
|---|
| 43 | $__widgets->bestof->setting('class', __('CSS class:'), ''); |
|---|
| 44 | $__widgets->bestof->setting('offline', __('Offline'), 0, 'check'); |
|---|
| [0] | 45 | |
|---|
| [3730] | 46 | $__widgets->create('langs', __('Blog languages'), array('defaultWidgets', 'langs'), null, 'List of available languages'); |
|---|
| 47 | $__widgets->langs->setting('title', __('Title (optional)') . ' :', __('Languages')); |
|---|
| 48 | $__widgets->langs->setting('homeonly', __('Display on:'), 1, 'combo', |
|---|
| 49 | array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); |
|---|
| 50 | $__widgets->langs->setting('content_only', __('Content only'), 0, 'check'); |
|---|
| 51 | $__widgets->langs->setting('class', __('CSS class:'), ''); |
|---|
| 52 | $__widgets->langs->setting('offline', __('Offline'), 0, 'check'); |
|---|
| [0] | 53 | |
|---|
| [3730] | 54 | $__widgets->create('categories', __('List of categories'), array('defaultWidgets', 'categories'), null, 'List of categories'); |
|---|
| 55 | $__widgets->categories->setting('title', __('Title (optional)') . ' :', __('Categories')); |
|---|
| 56 | $__widgets->categories->setting('postcount', __('With entries counts'), 0, 'check'); |
|---|
| [2198] | 57 | $__widgets->categories->setting('subcatscount', __('Include sub cats in count'), false, 'check'); |
|---|
| [3730] | 58 | $__widgets->categories->setting('with_empty', __('Include empty categories'), 0, 'check'); |
|---|
| 59 | $__widgets->categories->setting('homeonly', __('Display on:'), 0, 'combo', |
|---|
| 60 | array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); |
|---|
| 61 | $__widgets->categories->setting('content_only', __('Content only'), 0, 'check'); |
|---|
| 62 | $__widgets->categories->setting('class', __('CSS class:'), ''); |
|---|
| 63 | $__widgets->categories->setting('offline', __('Offline'), 0, 'check'); |
|---|
| [0] | 64 | |
|---|
| [3730] | 65 | $__widgets->create('subscribe', __('Subscribe links'), array('defaultWidgets', 'subscribe'), null, 'Feed subscription links (RSS or Atom)'); |
|---|
| 66 | $__widgets->subscribe->setting('title', __('Title (optional)') . ' :', __('Subscribe')); |
|---|
| 67 | $__widgets->subscribe->setting('type', __('Feeds type:'), 'atom', 'combo', array('Atom' => 'atom', 'RSS' => 'rss2')); |
|---|
| 68 | $__widgets->subscribe->setting('homeonly', __('Display on:'), 1, 'combo', |
|---|
| 69 | array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); |
|---|
| 70 | $__widgets->subscribe->setting('content_only', __('Content only'), 0, 'check'); |
|---|
| 71 | $__widgets->subscribe->setting('class', __('CSS class:'), ''); |
|---|
| 72 | $__widgets->subscribe->setting('offline', __('Offline'), 0, 'check'); |
|---|
| [0] | 73 | |
|---|
| [3730] | 74 | $__widgets->create('feed', __('Feed reader'), array('defaultWidgets', 'feed'), null, 'List of last entries from feed (RSS or Atom)'); |
|---|
| 75 | $__widgets->feed->setting('title', __('Title (optional)') . ' :', __('Somewhere else')); |
|---|
| 76 | $__widgets->feed->setting('url', __('Feed URL:'), ''); |
|---|
| 77 | $__widgets->feed->setting('limit', __('Entries limit:'), 10); |
|---|
| 78 | $__widgets->feed->setting('homeonly', __('Display on:'), 1, 'combo', |
|---|
| 79 | array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); |
|---|
| 80 | $__widgets->feed->setting('content_only', __('Content only'), 0, 'check'); |
|---|
| 81 | $__widgets->feed->setting('class', __('CSS class:'), ''); |
|---|
| 82 | $__widgets->feed->setting('offline', __('Offline'), 0, 'check'); |
|---|
| [0] | 83 | |
|---|
| [3730] | 84 | $__widgets->create('text', __('Text'), array('defaultWidgets', 'text'), null, 'Simple text'); |
|---|
| 85 | $__widgets->text->setting('title', __('Title (optional)') . ' :', ''); |
|---|
| 86 | $__widgets->text->setting('text', __('Text:'), '', 'textarea'); |
|---|
| 87 | $__widgets->text->setting('homeonly', __('Display on:'), 0, 'combo', |
|---|
| 88 | array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); |
|---|
| 89 | $__widgets->text->setting('content_only', __('Content only'), 0, 'check'); |
|---|
| 90 | $__widgets->text->setting('class', __('CSS class:'), ''); |
|---|
| 91 | $__widgets->text->setting('offline', __('Offline'), 0, 'check'); |
|---|
| [0] | 92 | |
|---|
| [3730] | 93 | $__widgets->create('lastposts', __('Last entries'), array('defaultWidgets', 'lastposts'), null, 'List of last entries published'); |
|---|
| 94 | $__widgets->lastposts->setting('title', __('Title (optional)') . ' :', __('Last entries')); |
|---|
| 95 | $rs = $core->blog->getCategories(array('post_type' => 'post')); |
|---|
| [0] | 96 | $categories = array('' => '', __('Uncategorized') => 'null'); |
|---|
| 97 | while ($rs->fetch()) { |
|---|
| [3730] | 98 | $categories[str_repeat(' ', $rs->level - 1) . ($rs->level - 1 == 0 ? '' : '• ') . html::escapeHTML($rs->cat_title)] = $rs->cat_id; |
|---|
| [0] | 99 | } |
|---|
| [3730] | 100 | $__widgets->lastposts->setting('category', __('Category:'), '', 'combo', $categories); |
|---|
| 101 | unset($rs, $categories); |
|---|
| [0] | 102 | if ($core->plugins->moduleExists('tags')) { |
|---|
| [3730] | 103 | $__widgets->lastposts->setting('tag', __('Tag:'), ''); |
|---|
| [0] | 104 | } |
|---|
| [3730] | 105 | $__widgets->lastposts->setting('limit', __('Entries limit:'), 10); |
|---|
| 106 | $__widgets->lastposts->setting('homeonly', __('Display on:'), 1, 'combo', |
|---|
| 107 | array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); |
|---|
| 108 | $__widgets->lastposts->setting('content_only', __('Content only'), 0, 'check'); |
|---|
| 109 | $__widgets->lastposts->setting('class', __('CSS class:'), ''); |
|---|
| 110 | $__widgets->lastposts->setting('offline', __('Offline'), 0, 'check'); |
|---|
| [0] | 111 | |
|---|
| [3730] | 112 | $__widgets->create('lastcomments', __('Last comments'), array('defaultWidgets', 'lastcomments'), null, 'List of last comments published'); |
|---|
| 113 | $__widgets->lastcomments->setting('title', __('Title (optional)') . ' :', __('Last comments')); |
|---|
| 114 | $__widgets->lastcomments->setting('limit', __('Comments limit:'), 10); |
|---|
| 115 | $__widgets->lastcomments->setting('homeonly', __('Display on:'), 1, 'combo', |
|---|
| 116 | array(__('All pages') => 0, __('Home page only') => 1, __('Except on home page') => 2)); |
|---|
| 117 | $__widgets->lastcomments->setting('content_only', __('Content only'), 0, 'check'); |
|---|
| 118 | $__widgets->lastcomments->setting('class', __('CSS class:'), ''); |
|---|
| 119 | $__widgets->lastcomments->setting('offline', __('Offline'), 0, 'check'); |
|---|
| [0] | 120 | |
|---|
| 121 | # --BEHAVIOR-- initWidgets |
|---|
| [3730] | 122 | $core->callBehavior('initWidgets', $__widgets); |
|---|
| [0] | 123 | |
|---|
| 124 | # Default widgets |
|---|
| 125 | global $__default_widgets; |
|---|
| [3730] | 126 | $__default_widgets = array('nav' => new dcWidgets(), 'extra' => new dcWidgets(), 'custom' => new dcWidgets()); |
|---|
| [0] | 127 | |
|---|
| 128 | $__default_widgets['nav']->append($__widgets->search); |
|---|
| 129 | $__default_widgets['nav']->append($__widgets->bestof); |
|---|
| 130 | $__default_widgets['nav']->append($__widgets->categories); |
|---|
| [2671] | 131 | $__default_widgets['custom']->append($__widgets->subscribe); |
|---|
| [0] | 132 | |
|---|
| 133 | # --BEHAVIOR-- initDefaultWidgets |
|---|
| [3730] | 134 | $core->callBehavior('initDefaultWidgets', $__widgets, $__default_widgets); |
|---|