| [ Index ] | PHP Cross Reference of Mambo 4.6.5 |
|
| [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
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 if (!defined( '_MOS_POLL_MODULE' )) { 20 /** ensure that functions are declared only once */ 21 define( '_MOS_POLL_MODULE', 1 ); 22 23 function show_poll_vote_form( $Itemid ) { 24 global $database; 25 26 // Search for poll component in menu table 27 // use static in case of multiple poll modules 28 static $menuId; 29 if (!isset($menuId)) { 30 $menuId = $Itemid; 31 $database->setQuery("SELECT * FROM #__menu WHERE link LIKE '%option=com_poll%' and published <> '-2'"); 32 $menus = $database->loadObjectList(); 33 if (count($menus)) { 34 // test to make sure option is com_poll and not something like com_pollextended 35 $uri = new mosUriHelper(); 36 $testIds = array(); 37 foreach ($menus as $menu) { 38 $uri->setUri($menu->link); 39 if ( $uri->get('option') == 'com_poll' ) $testIds[] = $menu->id; 40 } 41 if ( count($testIds) ) $menuId = $testIds[0]; 42 } 43 } 44 45 $query1 = "SELECT p.id, p.title" 46 ."\nFROM #__polls AS p, #__poll_menu AS pm" 47 ."\nWHERE (pm.menuid='$Itemid' OR pm.menuid='0') AND p.id=pm.pollid" 48 ."\nAND p.published=1"; 49 50 $database->setQuery( $query1 ); 51 $polls = $database->loadObjectList(); 52 53 // Scrub the Itemid if it isnt an existing polls menu item 54 $Itemid = $menuId ? $menuId : '0'; 55 56 57 if($database->getErrorNum()) { 58 echo "MB ".$database->stderr(true); 59 return; 60 } 61 62 if ($polls) foreach ($polls as $poll) { 63 if ($poll->id && $poll->title) { 64 65 $query = "SELECT id, text FROM #__poll_data" 66 . "\nWHERE pollid='$poll->id' AND text <> ''" 67 . "\nORDER BY id"; 68 $database->setQuery($query); 69 70 if(!($options = $database->loadObjectList())) { 71 echo "MD ".$database->stderr(true); 72 return; 73 } 74 poll_vote_form_html( $poll, $options, $Itemid ); 75 } 76 } 77 } 78 79 function poll_vote_form_html( &$poll, &$options, $Itemid ) { 80 $tabclass_arr=array("sectiontableentry2","sectiontableentry1"); 81 $tabcnt = 0; 82 $ItemidStr = ($Itemid?"&Itemid=$Itemid":''); 83 ?> 84 <form name="form2" method="post" action="<?php echo sefRelToAbs("index.php?option=com_poll&id=$poll->id{$ItemidStr}"); ?>"> 85 <table width="95%" border="0" cellspacing="0" cellpadding="1" align="center"> 86 <tr> 87 <td colspan="2" class="poll"><strong><?php echo $poll->title; ?></strong></td> 88 </tr> 89 <tr> 90 <td align="center"> 91 <table class='pollstableborder' cellspacing='0' cellpadding='0' border='0'> 92 <?php 93 for ($i=0, $n=count( $options ); $i < $n; $i++) { ?> 94 <tr> 95 <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> 96 <td class='<?php echo $tabclass_arr[$tabcnt]; ?>' valign="top"><label for="voteid<?php echo $options[$i]->id;?>"><?php echo $options[$i]->text; ?></label></td> 97 </tr> 98 <?php 99 if ($tabcnt == 1){ 100 $tabcnt = 0; 101 } else { 102 $tabcnt++; 103 } 104 } 105 ?> 106 </table> 107 </td> 108 </tr> 109 <tr> 110 <td colspan="2" align="center"> 111 <input type="submit" name="task_button" class="button" value="<?php echo T_('Vote'); ?>" /> 112 <input type="button" name="option" class="button" value="<?php echo T_('Results'); ?>" onclick="document.location.href='<?php echo sefRelToAbs("index.php?option=com_poll&task=results&id=$poll->id{$ItemidStr}"); ?>';" /> 113 </td> 114 </tr> 115 </table> 116 <input type="hidden" name="id" value="<?php echo $poll->id;?>" /> 117 <input type="hidden" name="task" value="vote" /> 118 </form> 119 <?php 120 } 121 } 122 show_poll_vote_form( $Itemid ); 123 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Feb 8 00:05:01 2012 | Cross-referenced by PHPXref 0.7 |
| Mambo API: Mambo is Free software released under the GNU/General Public License, Version 2 |