[ Index ]

PHP Cross Reference of Mambo 4.6.5

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

title

Body

[close]

/components/com_poll/ -> poll.html.php (source)

   1  <?php
   2  /**
   3  * @package Mambo
   4  * @subpackage Polls
   5  * @author Mambo Foundation Inc see README.php
   6  * @copyright (C) 2000 - 2009 Mambo Foundation Inc.
   7  * See COPYRIGHT.php for copyright notices and details.
   8  * @license GNU/GPL Version 2, see LICENSE.php
   9  *
  10  * Redistributions of files must retain the above copyright notice.
  11  *
  12  * Mambo is free software; you can redistribute it and/or
  13  * modify it under the terms of the GNU General Public License
  14  * as published by the Free Software Foundation; version 2 of the License.
  15  */
  16  
  17  /** ensure this file is being included by a parent file */
  18  defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
  19  
  20  
  21  class poll_html {
  22  
  23  
  24  	function showResults( &$poll, &$votes, $first_vote, $last_vote, $pollist, $params ) {
  25          global $mosConfig_live_site;
  26          ?>
  27          <script type = "text/javascript">
  28          <!--
  29          var link = document.createElement('link');
  30          link.setAttribute('href', 'components/com_poll/poll_bars.css');
  31          link.setAttribute('rel', 'stylesheet');
  32          link.setAttribute('type', 'text/css');
  33          var head = document.getElementsByTagName('head').item(0);
  34          head.appendChild(link);
  35          //-->
  36          </script>
  37          <form action="index.php" method="post" name="poll" id="poll"> 
  38          <?php 
  39          if ( $params->get( 'page_title' ) ) {
  40              ?>
  41              <div class="componentheading<?php echo $params->get( 'pageclass_sfx' ); ?>">
  42              <?php echo $params->get( 'header' ); ?>
  43              </div> 
  44              <?php 
  45          }
  46          ?>
  47          <table width="100%" class="contentpane<?php echo $params->get( 'pageclass_sfx' ); ?>"> 
  48          <tr> 
  49              <td align="center"> 
  50                  <table class="contentpane<?php echo $params->get( 'pageclass_sfx' ); ?>"> 
  51                  <tr> 
  52                      <td align="left">
  53                      <?php echo T_('Select Poll:'); ?>&nbsp;
  54                      </td> 
  55                      <td align="left">
  56                      <?php echo $pollist; ?>
  57                      </td> 
  58                  </tr> 
  59                  </table> 
  60  
  61                  <table cellpadding="0" cellspacing="0" border="0" class="contentpane<?php echo $params->get( 'pageclass_sfx' ); ?>"> 
  62                  <?php
  63                  if ($votes) {
  64                      $j=0;
  65                      $data_arr["text"]=null;
  66                      $data_arr["hits"]=null;
  67                      foreach ($votes as $vote) {
  68                          $data_arr["text"][$j]=trim($vote->text);
  69                          $data_arr["hits"][$j]=$vote->hits;
  70                          $j++;
  71                      }
  72                      ?>
  73                      <tr> 
  74                          <td> 
  75                          <?php 
  76                          poll_html::graphit( $data_arr, $poll->title, $first_vote, $last_vote );
  77                          ?>
  78                          </td> 
  79                      </tr> 
  80                      <?php
  81                  } else {
  82                      ?>
  83                      <tr> 
  84                          <td valign="bottom">
  85                          <?php echo T_('There are no results for this poll.'); ?>
  86                          </td> 
  87                      </tr> 
  88                      <?php
  89                  }
  90                  ?> 
  91                  </table> 
  92              </td>    
  93          </tr> 
  94          </table> 
  95          <?php
  96          // displays back button
  97          mosHTML::BackButton ( $params );
  98          ?>
  99          </form> 
 100          <?php 
 101      }
 102      
 103      
 104  	function graphit( $data_arr, $graphtitle, $first_vote, $last_vote ) {
 105          global $mosConfig_live_site, $polls_maxcolors, $tabclass,
 106          $polls_barheight, $polls_graphwidth, $polls_barcolor;
 107      
 108          $tabclass_arr = explode( ",", $tabclass );
 109          $tabcnt = 0;
 110          $colorx = 0;
 111          $maxval = 0;
 112      
 113          array_multisort( $data_arr["hits"], SORT_NUMERIC,SORT_DESC, $data_arr["text"] );
 114      
 115          foreach($data_arr["hits"] as $hits) {
 116              if ($maxval < $hits) {
 117                  $maxval = $hits;
 118              }
 119          }
 120          $sumval = array_sum( $data_arr["hits"] );
 121          ?> 
 122          <br /> 
 123          <table class='pollstableborder' cellspacing="0" cellpadding="0" border="0"> 
 124          <tr> 
 125              <td colspan="2" class="sectiontableheader"> 
 126              <img src="<?php echo $mosConfig_live_site; ?>/components/com_poll/images/poll.png" align="middle" border="0" width="12" height="14" alt="" /> 
 127              <?php echo $graphtitle; ?> 
 128              </td> 
 129          </tr> 
 130          <?php
 131          for ($i=0, $n=count($data_arr["text"]); $i < $n; $i++) {
 132              $text = &$data_arr["text"][$i];
 133              $hits = &$data_arr["hits"][$i];
 134              if ($maxval > 0 && $sumval > 0) {
 135                  $width = ceil( $hits*$polls_graphwidth/$maxval );
 136                  $percent = round( 100*$hits/$sumval, 1 );
 137              } else {
 138                  $width = 0;
 139                  $percent = 0;
 140              }
 141              ?> 
 142              <tr class="<?php echo $tabclass_arr[$tabcnt]; ?>"> 
 143                  <td width='100%' colspan='2'>
 144                  <?php echo $text; ?>
 145                  </td> 
 146              </tr> 
 147              <tr class="<?php echo $tabclass_arr[$tabcnt]; ?>"> 
 148                  <td> 
 149                      <table cellspacing="0" cellpadding="0" border="0" width="100%">
 150                      <tr class='<?php echo $tabclass_arr[$tabcnt]; ?>'> 
 151                          <td align="right" width="25"> 
 152                          <strong>
 153                          <?php echo $hits; ?>
 154                          </strong> 
 155                          </td> 
 156                          <td align="left" width="2">&nbsp;
 157                           
 158                          </td> 
 159                          <td width="30" align="left"> 
 160                          <?php echo $percent; ?>% 
 161                          </td> 
 162                          <?php
 163                          $tdclass='';
 164                          if ($polls_barcolor==0) {
 165                              if ($colorx < $polls_maxcolors) {
 166                                  $colorx = ++$colorx;
 167                              } else {
 168                                  $colorx = 1;
 169                              }
 170                              $tdclass = "polls_color_".$colorx;
 171                          } else {
 172                              $tdclass = "polls_color_".$polls_barcolor;
 173                          }
 174                          ?> 
 175                          <td width="300" align="left"> 
 176                          <div align="left">
 177                          &nbsp;
 178                          <img src='<?php echo $mosConfig_live_site; ?>/components/com_poll/images/blank.png' class='<?php echo $tdclass; ?>' height='<?php echo $polls_barheight; ?>' width='<?php echo $width; ?>' alt="" /> 
 179                          </div>
 180                          </td> 
 181                      </tr> 
 182                      </table>
 183                  </td> 
 184              </tr> 
 185              <?php
 186              $tabcnt = 1 - $tabcnt;
 187          }
 188          ?> 
 189          </table> 
 190          
 191          <br /> 
 192          <table cellspacing="0" cellpadding="0" border="0"> 
 193          <tr> 
 194              <td class='smalldark'> 
 195              <?php echo T_('Number of Voters'); ?> 
 196              </td> 
 197              <td class='smalldark'> 
 198              &nbsp;:&nbsp;
 199              <?php echo $sumval; ?> 
 200              </td> 
 201          </tr> 
 202          <tr> 
 203              <td class='smalldark'> 
 204              <?php echo T_('First Vote'); ?> 
 205              </td> 
 206              <td class='smalldark'> 
 207              &nbsp;:&nbsp;
 208              <?php echo $first_vote; ?> 
 209              </td> 
 210          </tr> 
 211          <tr> 
 212              <td class='smalldark'> 
 213              <?php echo T_('Last Vote'); ?> 
 214              </td> 
 215              <td class='smalldark'> 
 216              &nbsp;:&nbsp;
 217              <?php echo $last_vote; ?> 
 218              </td> 
 219          </tr> 
 220          </table> 
 221          <?php
 222      }
 223  
 224  
 225  }
 226  ?>