Dotclear

source: plugins/rateIt/inc/lib.rateIt.context.php @ 2358

Revision 2358, 2.5 KB checked in by JcDenis, 13 years ago (diff)

rateIt 2.0-alpha

  • Switched to DC 2.2
  • Added simple ratting mode
  • Added double rating mode
  • Fixed JS bug on multiple rating forms
  • Fixed IE8 bug (by cleaning html errors!)
  • Changed modules management (and behaviors)
  • Included rating on plugin cinecturlink2
Line 
1<?php
2# -- BEGIN LICENSE BLOCK ----------------------------------
3# This file is part of rateIt, a plugin for Dotclear 2.
4#
5# Copyright (c) 2009-2010 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# -- END LICENSE BLOCK ------------------------------------
12
13if (!defined('DC_RC_PATH')){return;}
14
15class rateItContext
16{
17     # Form
18     public static function linker($enable,$type,$id,$note,$quotient)
19     {
20          global $core;
21         
22          $like = $core->blog->settings->rateit->rateit_msglike;
23          if (empty($like)) { $like = __('I like'); }
24          $notlike = $core->blog->settings->rateit->rateit_msgnotlike;
25          if (empty($notlike)) { $notlike = __("I don't like"); }
26          $uid = uniqid();
27          $dis = $enable ? ' disabled="disabled"' : '';
28         
29          $res =
30          '<form class="rateit-linker" method="post" action="'.
31          $core->blog->url.$core->url->getBase('rateItpostform').'/'.$type.'/'.$id.'">'.
32          '<p>'.
33          '<input type="hidden" name="linkertype" value="'.$type.'" />'.
34          '<input type="hidden" name="linkerid" value="'.$id.'" />'.
35          '<input type="hidden" name="linkeruid" value="'.$uid.'" />';
36         
37         
38          if ($core->blog->settings->rateit->rateit_rating_style == 'simple')
39          {
40               $chk = $enable ? ' checked="checked"' : '';
41               $res .= '<input title="'.$like.'" name="'.$uid.'" class="rateit-'.$type.'-'.$id.'" type="radio" value="'.$quotient.'" '.$chk.$dis.' />';
42          }
43          elseif ($core->blog->settings->rateit->rateit_rating_style == 'twin')
44          {
45               $chk = $enable ? ' checked="checked"' : '';
46               $res .= '<input title="'.$notlike.'" name="'.$uid.'" class="rateit-'.$type.'-'.$id.'" type="radio" value="1" checked="checked"'.$dis.' />';
47               $res .= '<input title="'.$like.'" name="'.$uid.'" class="rateit-'.$type.'-'.$id.'" type="radio" value="'.$quotient.'" '.$dis.' />';
48          }
49          else
50          {
51               for($i = 0; $i < $quotient; $i++)
52               {
53                    $chk = $note > $i && $note <= $i+1 ? ' checked="checked"' : '';
54                   
55                    $res .= '<input name="'.$uid.'" class="rateit-'.$type.'-'.$id.'" type="radio" value="'.($i+1).'"'.$chk.$dis.' />';
56               }
57          }
58
59          if (!$enable)
60          {
61               $res .= '<input class="rateit-submit" name="rateit_submit_'.$uid.'" type="submit" value="'.__('Vote').'" />';
62          }
63          $res .= '</p></form>';
64         
65          return $res;
66     }
67     
68     # Info
69     public static function value($name,$type,$id,$value)
70     {
71          return '<span class="rateit-'.$name.' rateit-'.$name.'-'.$type.'-'.$id.'">'.$value.'</span>';
72     }
73}
74?>
Note: See TracBrowser for help on using the repository browser.

Sites map