| [ Index ] |
|
Code source de Joomla 1.0.13 |
1 <?php 2 /** 3 * @version $Id: mod_poll.php 5911 2006-12-01 16:22:26Z friesengeist $ 4 * @package Joomla 5 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. 6 * @license http://www.gnu.org/copyleft/gpl.html 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( '_VALID_MOS' ) or die( 'Restricted access' ); 16 17 if (!defined( '_JOS_POLL_MODULE' )) { 18 /** ensure that functions are declared only once */ 19 define( '_JOS_POLL_MODULE', 1 ); 20 21 /** 22 * @param int The current menu item 23 * @param string CSS suffix 24 */ 25 function show_poll_vote_form( $Itemid, &$params ) { 26 global $database; 27 28 $query = "SELECT p.id, p.title" 29 . "\n FROM #__polls AS p" 30 . "\n INNER JOIN #__poll_menu AS pm ON pm.pollid = p.id" 31 . "\n WHERE ( pm.menuid = " . (int) $Itemid . " OR pm.menuid = 0 )" 32 . "\n AND p.published = 1"; 33 34 $database->setQuery( $query ); 35 $polls = $database->loadObjectList(); 36 37 if($database->getErrorNum()) { 38 echo "MB ".$database->stderr(true); 39 return; 40 } 41 42 // try to find poll component's Itemid 43 $query = "SELECT id" 44 . "\n FROM #__menu" 45 . "\n WHERE type = 'components'" 46 . "\n AND published = 1" 47 . "\n AND link = 'index.php?option=com_poll'" 48 ; 49 $database->setQuery( $query ); 50 $_Itemid = $database->loadResult(); 51 52 if ($_Itemid) { 53 $_Itemid = '&Itemid='. $_Itemid; 54 } 55 56 $z = 1; 57 foreach ($polls as $poll) { 58 if ($poll->id && $poll->title) { 59 60 $query = "SELECT id, text" 61 . "\n FROM #__poll_data" 62 . "\n WHERE pollid = " . (int) $poll->id 63 . "\n AND text != ''" 64 . "\n ORDER BY id"; 65 $database->setQuery($query); 66 67 if(!($options = $database->loadObjectList())) { 68 echo "MD ".$database->stderr(true); 69 return; 70 } 71 72 poll_vote_form_html( $poll, $options, $_Itemid, $params, $z ); 73 74 $z++; 75 } 76 } 77 } 78 79 /** 80 * @param object Poll object 81 * @param array 82 * @param int The current menu item 83 * @param string CSS suffix 84 */ 85 function poll_vote_form_html( &$poll, &$options, $_Itemid, &$params, $z ) { 86 $tabclass_arr = array( 'sectiontableentry2', 'sectiontableentry1' ); 87 $tabcnt = 0; 88 $moduleclass_sfx = $params->get('moduleclass_sfx'); 89 90 $cookiename = "voted$poll->id"; 91 $voted = mosGetParam( $_COOKIE, $cookiename, 'z' ); 92 93 // used for spoof hardening 94 $validate = josSpoofValue('poll'); 95 ?> 96 <script language="javascript" type="text/javascript"> 97 <!-- 98 function submitbutton_Poll<?php echo $z;?>() { 99 var form = document.pollxtd<?php echo $z;?>; 100 var radio = form.voteid; 101 var radioLength = radio.length; 102 var check = 0; 103 104 if ( '<?php echo $voted; ?>' != 'z' ) { 105 alert('<?php echo addslashes( _ALREADY_VOTE ); ?>'); 106 return; 107 } 108 for(var i = 0; i < radioLength; i++) { 109 if(radio[i].checked) { 110 form.submit(); 111 check = 1; 112 } 113 } 114 if (check == 0) { 115 alert('<?php echo addslashes( _NO_SELECTION ); ?>'); 116 } 117 } 118 //--> 119 </script> 120 <form name="pollxtd<?php echo $z;?>" method="post" action="<?php echo sefRelToAbs("index.php?option=com_poll$_Itemid"); ?>"> 121 122 <table width="95%" border="0" cellspacing="0" cellpadding="1" align="center" class="poll<?php echo $moduleclass_sfx; ?>"> 123 <thead> 124 <tr> 125 <td style="font-weight: bold;"> 126 <?php echo $poll->title; ?> 127 </td> 128 </tr> 129 </thead> 130 <tr> 131 <td align="center"> 132 <table class="pollstableborder<?php echo $moduleclass_sfx; ?>" cellspacing="0" cellpadding="0" border="0"> 133 <?php 134 for ($i=0, $n=count( $options ); $i < $n; $i++) { ?> 135 <tr> 136 <td class="<?php echo $tabclass_arr[$tabcnt]; ?><?php echo $moduleclass_sfx; ?>" valign="top"> 137 <input type="radio" name="voteid" id="voteid<?php echo $options[$i]->id;?>" value="<?php echo $options[$i]->id;?>" alt="<?php echo $options[$i]->id;?>" /> 138 </td> 139 <td class="<?php echo $tabclass_arr[$tabcnt]; ?><?php echo $moduleclass_sfx; ?>" valign="top"> 140 <label for="voteid<?php echo $options[$i]->id;?>"> 141 <?php echo stripslashes($options[$i]->text); ?> 142 </label> 143 </td> 144 </tr> 145 <?php 146 if ($tabcnt == 1){ 147 $tabcnt = 0; 148 } else { 149 $tabcnt++; 150 } 151 } 152 ?> 153 </table> 154 </td> 155 </tr> 156 <tr> 157 <td> 158 <div align="center"> 159 <input type="button" onclick="submitbutton_Poll<?php echo $z;?>();" name="task_button" class="button" value="<?php echo _BUTTON_VOTE; ?>" /> 160 161 <input type="button" name="option" class="button" value="<?php echo _BUTTON_RESULTS; ?>" onclick="document.location.href='<?php echo sefRelToAbs("index.php?option=com_poll&task=results&id=$poll->id$_Itemid"); ?>';" /> 162 </div> 163 </td> 164 </tr> 165 </table> 166 167 <input type="hidden" name="id" value="<?php echo $poll->id;?>" /> 168 <input type="hidden" name="task" value="vote" /> 169 <input type="hidden" name="<?php echo $validate; ?>" value="1" /> 170 </form> 171 <?php 172 } 173 } 174 175 show_poll_vote_form( $Itemid, $params ); 176 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Wed Nov 21 14:43:32 2007 | par Balluche grâce à PHPXref 0.7 |
|