Source for file mod_poll.php

Documentation is available at mod_poll.php

  1. <?php
  2. /**
  3. @package Mambo
  4. @author Mambo Foundation Inc see README.php
  5. @copyright Mambo Foundation Inc.
  6. *  See COPYRIGHT.php for copyright notices and details.
  7. @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see
  8. *  LICENSE.php
  9. *  Mambo is free software; you can redistribute it and/or
  10. *  modify it under the terms of the GNU General Public License
  11. *  as published by the Free Software Foundation; version 2 of the
  12. *  License.
  13. */
  14.  
  15. /** ensure this file is being included by a parent file */
  16. defined'_VALID_MOS' or die'Direct Access to this location is not allowed.' );
  17.  
  18. if (!defined'_MOS_POLL_MODULE' )) {
  19.     /** ensure that functions are declared only once */
  20.     define'_MOS_POLL_MODULE');
  21.  
  22.     function show_poll_vote_form$Itemid {
  23.         global $database;
  24.  
  25.         $Itemid mosGetParam$_REQUEST'Itemid');
  26.  
  27.         $query1 "SELECT p.id, p.title"
  28.         ."\nFROM #__polls AS p, #__poll_menu AS pm"
  29.         ."\nWHERE (pm.menuid='$Itemid' OR pm.menuid='0') AND p.id=pm.pollid"
  30.         ."\nAND p.published=1";
  31.  
  32.         $database->setQuery$query1 );
  33.         $polls $database->loadObjectList();
  34.  
  35.         if($database->getErrorNum()) {
  36.             echo "MB ".$database->stderr(true);
  37.             return;
  38.         }
  39.  
  40.         if ($pollsforeach ($polls as $poll{
  41.             if ($poll->id && $poll->title{
  42.  
  43.                 $query "SELECT id, text FROM #__poll_data"
  44.                 . "\nWHERE pollid='$poll->id' AND text <> ''"
  45.                 . "\nORDER BY id";
  46.                 $database->setQuery($query);
  47.  
  48.                 if(!($options $database->loadObjectList())) {
  49.                     echo "MD ".$database->stderr(true);
  50.                     return;
  51.                 }
  52.                 poll_vote_form_html$poll$options$Itemid );
  53.             }
  54.         }
  55.     }
  56.  
  57.     function poll_vote_form_html&$poll&$options$Itemid {
  58.         $tabclass_arr=array("sectiontableentry2","sectiontableentry1");
  59.         $tabcnt 0;
  60.         ?>
  61.         <form name="form2" method="post" action="<?php echo sefRelToAbs("index.php?option=com_poll&amp;Itemid=$Itemid")?>">
  62.         <table width="95%" border="0" cellspacing="0" cellpadding="1" align="center">
  63.             <tr>
  64.               <td colspan="2" class="poll"><b><?php echo $poll->title?></b></td>
  65.             </tr>
  66.             <tr>
  67.               <td align="center">
  68.               <table class='pollstableborder' cellspacing='0' cellpadding='0' border='0'>
  69.         <?php
  70.         for ($i=0$n=count$options )$i $n$i++?>
  71.             <tr>
  72.               <td class='<?php echo $tabclass_arr[$tabcnt]?>' valign="top"><input type="radio" name="voteid" id="voteid<?php echo $options[$i]->id;?>" value="<?php echo $options[$i]->id;?>" alt="<?php echo $options[$i]->id;?>" /></td>
  73.               <td class='<?php echo $tabclass_arr[$tabcnt]?>' valign="top"><label for="voteid<?php echo $options[$i]->id;?>"><?php echo $options[$i]->text?></label></td>
  74.             </tr>
  75.             <?php
  76.             if ($tabcnt == 1){
  77.                 $tabcnt 0;
  78.             else {
  79.                 $tabcnt++;
  80.             }
  81.         }
  82.         ?>
  83.               </table>
  84.               </td>
  85.             </tr>
  86.             <tr>
  87.               <td colspan="2" align="center">
  88.               <input type="submit" name="task_button" class="button" value="<?php echo T_('Vote')?>" />&nbsp;&nbsp;
  89.               <input type="button" name="option" class="button" value="<?php echo T_('Results')?>" onclick="document.location.href='<?php echo sefRelToAbs("index.php?option=com_poll&amp;task=results&amp;id=$poll->id")?>';" />
  90.               </td>
  91.             </tr>
  92.         </table>
  93.         <input type="hidden" name="id" value="<?php echo $poll->id;?>" />
  94.         <input type="hidden" name="task" value="vote" />
  95.         </form>
  96.     <?php
  97.     }
  98. }
  99. show_poll_vote_form$Itemid );
  100. ?>

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