Dotclear

source: plugins/rateIt/_widgets.php @ 1486

Revision 1486, 4.2 KB checked in by JcDenis, 13 years ago (diff)

rateIt 0.9.6:

  • Fixed DC 2.1.6 URL handlers ending
  • Added sort by sort rate by date (thanks to lottie14)
  • Cleaned some stuff
Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of rateIt, a plugin for Dotclear 2.
4#
5# Copyright (c) 2009 JC Denis and contributors
6# jcdenis@gdwd.com
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#
12# -- END LICENSE BLOCK ------------------------------------
13
14if (!defined('DC_RC_PATH')){return;}
15
16$core->addBehavior('initWidgets',array('rateItAdminWidget','vote'));
17$core->addBehavior('initWidgets',array('rateItAdminWidget','rank'));
18
19class rateItAdminWidget
20{
21     public static function vote($w)
22     {
23          global $core;
24
25          $w->create('rateit',__('Rating'),
26               array('rateItPublicWidget','vote'));
27          $w->rateit->setting('enable_post',__('Enable vote for entries'),
28               1,'check');
29          $w->rateit->setting('title_post',__('Title for entries:'),
30               __('Rate this entry'),'text');
31
32          $w->rateit->setting('enable_cat',__('Enable vote for categories'),
33               0,'check');
34          $w->rateit->setting('title_cat',__('Title for categories:'),
35               __('Rate this category'),'text');
36
37          if ($core->plugins->moduleExists('metadata')) {
38               $w->rateit->setting('enable_tag',__('Enable vote for tags'),
39                    0,'check');
40               $w->rateit->setting('title_tag',__('Title for tags:'),
41                    __('Rate this tag'),'text');
42          }
43
44          if ($core->plugins->moduleExists('gallery')) {
45               $w->rateit->setting('enable_gal',__('Enable vote for gallery'),
46                    0,'check');
47               $w->rateit->setting('title_gal',__('Title for gallery:'),
48                    __('Rate this gallery'),'text');
49               $w->rateit->setting('enable_galitem',__('Enable vote for gallery item'),
50                    0,'check');
51               $w->rateit->setting('title_galitem',__('Title for gallery item:'),
52                    __('Rate this gallery item'),'text');
53          }
54
55          # --BEHAVIOR-- initWidgetRateItVote
56          $core->callBehavior('initWidgetRateItVote',$w);
57
58
59          $w->rateit->setting('show_fullnote',__('Show full note'),'full','combo',
60               array(__('Hidden')=>'hide',__('Full note (5/20)')=>'full',__('Percent (25%)')=>'percent'));
61          $w->rateit->setting('show_note',__('Show note'),
62               1,'check');
63          $w->rateit->setting('show_vote',__('Show the count of vote'),
64               1,'check');
65          $w->rateit->setting('show_higher',__('Show the highest rate'),
66               1,'check');
67          $w->rateit->setting('show_lower',__('Show the lowest rate'),
68               1,'check');
69          $w->rateit->setting('type','type','','hidden');
70          $w->rateit->setting('id','id','0','hidden');
71          $w->rateit->setting('title','title','rateIt','hidden');
72     }
73
74     public static function rank($w)
75     {
76          global $core;
77
78          $w->create('rateitrank',__('Top rating'),
79               array('rateItPublicWidget','rank'));
80          $w->rateitrank->setting('title',__('Title:'),
81               __('Top rated entries'),'text');
82
83          $types = new ArrayObject();
84
85
86          # --BEHAVIOR-- initWidgetRateItRank
87          $core->callBehavior('initWidgetRateItRank',$types);
88
89
90          $types[] = array(__('entries')=>'post');
91          $types[] = array(__('Comments')=>'comment');
92          $types[] = array(__('Categories')=>'category');
93
94          if ($core->plugins->moduleExists('metadata')) {
95               $types[] = array(__('Tag')=>'tag');
96          }
97          if ($core->plugins->moduleExists('gallery')) {
98               $types[] = array(__('Gallery')=>'gal');
99               $types[] = array(__('Gallery item')=>'galitem');
100          }
101
102          $types = (array) $types;
103          $combo = array();
104          foreach($types as $k => $v){
105               $combo = array_merge($v,$combo);
106          }
107
108          $w->rateitrank->setting('type',__('Type:'),'post','combo',$combo);
109         
110          $w->rateitrank->setting('limit',__('Length:'),3,'combo',array(
111               1=>1,2=>2,3=>3,4=>4,5=>5,10=>10,15=>15,20=>20));
112          $w->rateitrank->setting('sortby',__('Order by:'),'rateit_avg','combo',array(
113               __('Note') => 'rateit_avg',
114               __('Votes') => 'rateit_total',
115               __('Date') => 'rateit_time'));
116          $w->rateitrank->setting('sort',__('Sort:'),'desc','combo',array(
117               __('Ascending') => 'asc',
118               __('Descending') => 'desc'));
119          $w->rateitrank->setting('text',__('Text'),'%rank% %title% (%note%/%quotient%)','text');
120          $w->rateitrank->setting('titlelen',__('Title length (if truncate)'),100);
121          $w->rateitrank->setting('homeonly',__('Home page only'),1,'check');
122          $w->rateitrank->setting('sql','sql','','hidden');
123     }
124}
125?>
Note: See TracBrowser for help on using the repository browser.

Sites map