[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/plugins/content/ -> vote.php (source)

   1  <?php
   2  /**
   3  * @version        $Id: vote.php 14401 2010-01-26 14:10:00Z louis $
   4  * @package        Joomla
   5  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   6  * @license        GNU/GPL, see LICENSE.php
   7  * Joomla! is free software. This version may have been modified pursuant
   8  * to the GNU General Public License, and as distributed it includes or
   9  * is derivative of works licensed under the GNU General Public License or
  10  * other free or open source software licenses.
  11  * See COPYRIGHT.php for copyright notices and details.
  12  */
  13  
  14  // no direct access
  15  defined( '_JEXEC' ) or die( 'Restricted access' );
  16  
  17  $mainframe->registerEvent( 'onBeforeDisplayContent', 'plgContentVote' );
  18  
  19  function plgContentVote( &$row, &$params, $page=0 )
  20  {
  21      $uri = & JFactory::getURI();
  22  
  23      $id     = $row->id;
  24      $html     = '';
  25  
  26      if (isset($row->rating_count) && $params->get( 'show_vote' ) && !$params->get( 'popup' ))
  27      {
  28          JPlugin::loadLanguage( 'plg_content_vote' );
  29          $html .= '<form method="post" action="' . $uri->toString( ) . '">';
  30          $img = '';
  31  
  32          // look for images in template if available
  33          $starImageOn     = JHTML::_('image.site',  'rating_star.png', '/images/M_images/' );
  34          $starImageOff     = JHTML::_('image.site',  'rating_star_blank.png', '/images/M_images/' );
  35  
  36          for ($i=0; $i < $row->rating; $i++) {
  37              $img .= $starImageOn;
  38          }
  39          for ($i=$row->rating; $i < 5; $i++) {
  40              $img .= $starImageOff;
  41          }
  42          $html .= '<span class="content_rating">';
  43          $html .= JText::_( 'User Rating' ) .':'. $img .'&nbsp;/&nbsp;';
  44          $html .= intval( $row->rating_count );
  45          $html .= "</span>\n<br />\n";
  46  
  47          if (!$params->get( 'intro_only' ))
  48          {
  49              $html .= '<span class="content_vote">';
  50              $html .= JText::_( 'Poor' );
  51              $html .= '<input type="radio" alt="vote 1 star" name="user_rating" value="1" />';
  52              $html .= '<input type="radio" alt="vote 2 star" name="user_rating" value="2" />';
  53              $html .= '<input type="radio" alt="vote 3 star" name="user_rating" value="3" />';
  54              $html .= '<input type="radio" alt="vote 4 star" name="user_rating" value="4" />';
  55              $html .= '<input type="radio" alt="vote 5 star" name="user_rating" value="5" checked="checked" />';
  56              $html .= JText::_( 'Best' );
  57              $html .= '&nbsp;<input class="button" type="submit" name="submit_vote" value="'. JText::_( 'Rate' ) .'" />';
  58              $html .= '<input type="hidden" name="task" value="vote" />';
  59              $html .= '<input type="hidden" name="option" value="com_content" />';
  60              $html .= '<input type="hidden" name="cid" value="'. $id .'" />';
  61              $html .= '<input type="hidden" name="url" value="'.  $uri->toString( ) .'" />';
  62              $html .= '</span>';
  63          }
  64          $html .= '</form>';
  65      }
  66      return $html;
  67  }


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1