[ Index ]

PHP Cross Reference of Mambo 4.6.5

[ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/mambots/content/ -> mosvote.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @author Mambo Foundation Inc see README.php
   5  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   6  * See COPYRIGHT.php for copyright notices and details.
   7  * @license GNU/GPL Version 2, see LICENSE.php
   8  *
   9  * Redistributions of files must retain the above copyright notice.
  10  *
  11  * Mambo is free software; you can redistribute it and/or
  12  * modify it under the terms of the GNU General Public License
  13  * as published by the Free Software Foundation; version 2 of the License.
  14  */
  15  
  16  /** ensure this file is being included by a parent file */
  17  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  18  
  19  $this->registerFunction( 'onBeforeDisplayContent', 'botVoting' );
  20  
  21  function botVoting( &$row, &$params, $page=0 ) {
  22      global $mosConfig_live_site, $mosConfig_absolute_path, $cur_template;
  23      global $Itemid;
  24      if (strtolower( get_class($row) ) != strtolower( 'mosExtendedContent' )) return;
  25      if (is_callable(array($row,'getId'))) $id = $row->getId();
  26      else $id = $row->id;
  27      $option = 'com_content';
  28      $task = mosGetParam( $_REQUEST, 'task', '' );
  29  
  30      $html = '';
  31      if ($params->get( 'rating' ) && !$params->get( 'popup' )){
  32          if (is_callable(array($row,'getRating'))) $rating = $row->getRating();
  33          else $rating = $row->rating;
  34          if (is_callable(array($row,'getRatingCount'))) $rating_count = $row->getRatingCount();
  35          else $rating_count = $row->rating_count;
  36          $html .= '<form method="post" action="' . sefRelToAbs( 'index.php' ) . '">';
  37          $img = '';
  38          
  39          // look for images in template if available
  40          $mainframe =& mosMainFrame::getInstance();
  41          $starImageOn = $mainframe->ImageCheck( 'rating_star.png', '/images/M_images/' );
  42          $starImageOff = $mainframe->ImageCheck( 'rating_star_blank.png', '/images/M_images/' );
  43  
  44          for ($i=0; $i < $rating; $i++) {
  45              $img .= $starImageOn;
  46          }
  47          for ($i=$rating; $i < 5; $i++) {
  48              $img .= $starImageOff;
  49          }
  50          $html .= '<span class="content_rating">';
  51          $html .= T_('User Rating') . ':' . $img . '&nbsp;/&nbsp;';
  52          $html .= intval( $rating_count );
  53          $html .= "</span>\n<br />\n";
  54          $url = @$_SERVER['REQUEST_URI'];
  55          $url = ampReplace( $url );
  56          
  57          require_once(mamboCore::get('mosConfig_absolute_path').'/includes/phpInputFilter/class.inputfilter.php');
  58          $iFilter = new InputFilter( null, null, 1, 1 );
  59          $url = trim( $iFilter->process( $url ) );
  60          
  61          if (!$params->get( 'intro_only' ) && $task != "blogsection") {
  62              $html .= '<span class="content_vote">';
  63              $html .= T_('Poor');
  64              $html .= '<input type="radio" alt="'.T_('vote 1 star').'" name="user_rating" value="1" />';
  65              $html .= '<input type="radio" alt="'.T_('vote 2 star').'" name="user_rating" value="2" />';
  66              $html .= '<input type="radio" alt="'.T_('vote 3 star').'" name="user_rating" value="3" />';
  67              $html .= '<input type="radio" alt="'.T_('vote 4 star').'" name="user_rating" value="4" />';
  68              $html .= '<input type="radio" alt="'.T_('vote 5 star').'" name="user_rating" value="5" checked="checked" />';
  69              $html .= T_('Best');
  70              $html .= '&nbsp;<input class="button" type="submit" name="submit_vote" value="'. T_('Rate') .'" />';
  71              $html .= '<input type="hidden" name="task" value="vote" />';
  72              $html .= '<input type="hidden" name="pop" value="0" />';
  73              $html .= '<input type="hidden" name="option" value="com_content" />';
  74              $html .= '<input type="hidden" name="Itemid" value="'. $Itemid .'" />';
  75              $html .= '<input type="hidden" name="cid" value="'. $id .'" />';
  76              //$html .= '<input type="hidden" name="url" value="'. $url .'" />';
  77              $html .= '</span>';
  78          }
  79          $html .= "</form>\n";
  80      }
  81      return $html;
  82  }
  83  ?>