Dotclear

source: plugins/multiToc/trunk/_widgets.php @ 2808

Revision 2808, 1.9 KB checked in by Tomtom33, 13 years ago (diff)

multiToc 1.5:

  • Dotclear 2.2 compatibility
  • fixed notices issue, closes #517
  • fixed smilies issue, closes #407
  • added numbering TOC in entries, closes #365
Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of multiToc, a plugin for Dotclear.
4#
5# Copyright (c) 2009-2010 Tomtom and contributors
6# http://blog.zenstyle.fr/
7#
8# Licensed under the GPL version 2.0 license.
9# A copy of this license is available in LICENSE file or at
10# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11# -- END LICENSE BLOCK ------------------------------------
12
13if (!defined('DC_RC_PATH')) { return; }
14
15$core->addBehavior('initWidgets',array('multiTocWidgets','initWidgets'));
16
17class multiTocWidgets
18{
19     public static function initWidgets($w)
20     {
21          $w->create('multiToc',__('Table of content'),array('multiTocWidgets','widget'));
22          $w->multiToc->setting('title',__('Title:'),__('Table of content'));
23          $w->multiToc->setting('homeonly',__('Home page only'),true,'check');
24     }
25     
26     public static function widget($w)
27     {
28          global $core;
29         
30          if ($w->homeonly && $core->url->type != 'default') {
31               return;
32          }
33         
34          $amask = '<a href="%1$s">%2$s</a>';
35          $limask = '<li class="%1$s">%2$s</li>';
36         
37          $title = (strlen($w->title) > 0) ? '<h2>'.html::escapeHTML($w->title).'</h2>' : '';
38         
39          $res = '';
40         
41          $settings = unserialize($core->blog->settings->multiToc->multitoc_settings);
42         
43          if ($settings['cat']['enable']) {
44               $link = sprintf($amask,$core->blog->url.$core->url->getBase('multitoc').'/cat',__('By category'));
45               $res .= sprintf($limask,'toc-cat',$link);
46          }
47          if ($settings['tag']['enable']) {
48               $link = sprintf($amask,$core->blog->url.$core->url->getBase('multitoc').'/tag',__('By tag'));
49               $res .= sprintf($limask,'toc-tag',$link);
50          }
51          if ($settings['alpha']['enable']) {
52               $link = sprintf($amask,$core->blog->url.$core->url->getBase('multitoc').'/alpha',__('By alpha order'));
53               $res .= sprintf($limask,'toc-alpha',$link);
54          }
55         
56          $res = !empty($res) ? '<ul>'.$res.'</ul>' : '';
57         
58          return
59               '<div id="info-blog">'.
60               $title.
61               $res.
62               '</div>';
63     }
64}
65
66?>
Note: See TracBrowser for help on using the repository browser.

Sites map