Source for file poll.html.php

Documentation is available at poll.html.php

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

Documentation generated on Mon, 05 May 2008 16:22:31 +0400 by phpDocumentor 1.4.0