Changeset 947
- Timestamp:
- 03/14/08 18:56:05 (9 months ago)
- Files:
-
- bbpress-polls/trunk/bb-polls.php (modified) (17 diffs)
- bbpress-polls/trunk/readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
bbpress-polls/trunk/bb-polls.php
r937 r947 6 6 Author: _ck_ 7 7 Author URI: http://bbShowcase.org 8 Version: 0.5 18 Version: 0.5.2 9 9 10 10 License: CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ … … 190 190 } 191 191 192 function bb_polls_pre_poll($topic_id, $edit_poll=0) {192 function bb_polls_pre_poll($topic_id, $edit_poll=0) { 193 193 global $bb_polls,$topic,$poll_options,$page; 194 194 if ($bb_polls['minimum_view_level']=="read" || bb_current_user_can($bb_polls['minimum_view_level']) ) : … … 197 197 $administrator=bb_current_user_can('administrate'); 198 198 bb_polls_add_javascript($topic_id); // ajax-ish 199 if (!$edit_poll && isset($_GET['edit_poll'])) {$edit_poll= intval($_GET['edit_poll']);} 199 200 if ($edit_poll || ! isset($topic->poll_options)) { // no saved poll question with options 200 201 … … 214 215 } else { 215 216 // ask if they want to start a new poll 216 echo '<li id="bb_polls"><a class= nowraponClick="if (window.bb_polls_insert_ajax) {bb_polls_start_new_poll_ajax();return false;}" href="'.add_query_arg( 'start_new_poll', '1').'">'.$bb_polls['poll_question'].'</a></li>';217 echo '<li id="bb_polls"><a class="nowrap" onClick="if (window.bb_polls_insert_ajax) {bb_polls_start_new_poll_ajax();return false;}" href="'.add_query_arg( 'start_new_poll', '1').'">'.$bb_polls['poll_question'].'</a></li>'; 217 218 218 219 } } } // end new poll question + end show start_new_poll form … … 296 297 if ($bb_polls['minimum_view_level']=="read" || bb_current_user_can($bb_polls['minimum_view_level']) ) { 297 298 $topic_id=bb_polls_check_cache($topic_id); 298 $output='<p class= poll_question>'.$bb_polls['label_poll_text'].': '.$poll_options['poll_question'].'</p>';299 $output='<p class="poll_question">'.$bb_polls['label_poll_text'].': '.$poll_options['poll_question'].'</p>'; 299 300 300 301 if (!$poll_options['poll_multiple_choice'] && isset($poll_options['poll_count_0'])) {$real_vote_count=intval($poll_options['poll_count_0']);} … … 303 304 for ($i=1; $i<=$bb_polls['max_options']; $i++) { 304 305 if (isset($poll_options[$i])) { 305 $output.= '<p class= poll_label>'.$poll_options[$i].' : ';306 $output.= '<p class="poll_label">'.$poll_options[$i].' : '; 306 307 $test=(isset($poll_options['poll_count_'.$i]) ? intval($poll_options['poll_count_'.$i]) : 0); 307 308 $output.= ' ('.$test.' '.$bb_polls['label_votes_text'].')'; … … 309 310 $vote_percent=(round($test/$real_vote_count,2)*100); 310 311 $vote_width=$vote_percent; if ($vote_width < 5) {$vote_width=5;} else {if ($vote_width >98 ) {$vote_width=98;}} 311 $output.= ' <div style="width:'.$vote_width.'%" class="poll_option poll_option'.$i.'"> '.$vote_percent.' % </div> ';312 $output.= ' <div style="width:'.$vote_width.'%" class="poll_option poll_option'.$i.'"> '.$vote_percent.' % </div> '; 312 313 } 313 314 $output.= ' </p>'; … … 315 316 } 316 317 $test=(isset($poll_options['poll_count_0']) ? intval($poll_options['poll_count_0']) : 0); 317 $output.= '<p class= poll_footer>'.intval($test).' '.$bb_polls['label_votes_text'].'</p>';318 $output.= '<p class="poll_footer">'.intval($test).' '.$bb_polls['label_votes_text'].'</p>'; 318 319 if (isset($_GET['show_poll_results']) || (bb_get_current_user_info( 'id' ) && !bb_polls_has_voted(bb_get_current_user_info( 'id' ),$topic_id) )) { 319 $output.= '<p class= poll_footer>( <a onClick="if (window.bb_polls_insert_ajax) {bb_polls_show_poll_vote_form_ajax();return false;}" href="'.remove_query_arg( 'show_poll_results').'">'.$bb_polls['label_now_text'].'</a> )</p>';320 $output.= '<p class="poll_footer">( <a onClick="if (window.bb_polls_insert_ajax) {bb_polls_show_poll_vote_form_ajax();return false;}" href="'.remove_query_arg( 'show_poll_results').'">'.$bb_polls['label_now_text'].'</a> )</p>'; 320 321 } 321 322 $output.=bb_polls_edit_link(); … … 331 332 if ($poll_options['poll_multiple_choice']==1) {$poll_type="checkbox";} else {$poll_type="radio";} 332 333 $output='<form action="'.remove_query_arg( 'show_poll_results').'" method="post" name="bb_polls" onSubmit="if (window.bb_polls_insert_ajax) {bb_polls_add_vote_ajax();return false;}"> 333 <p class= poll_question>'.$bb_polls['label_poll_text'].': '.$poll_options['poll_question'].'</p>';334 <p class="poll_question">'.$bb_polls['label_poll_text'].': '.$poll_options['poll_question'].'</p>'; 334 335 for ($i=1; $i<=$bb_polls['max_options']; $i++) { 335 336 if (isset($poll_options[$i])) { 336 337 if ($poll_options['poll_multiple_choice']==1) {$poll_name="poll_vote_".$i;} else {$poll_name="poll_vote_0";} 337 $output.= '<p><input type="'.$poll_type.'" name="'.$poll_name.'" value="'.$i.'" > '.$poll_options[$i].' </p>';338 $output.= '<p><input type="'.$poll_type.'" name="'.$poll_name.'" value="'.$i.'" /> '.$poll_options[$i].' </p>'; 338 339 } 339 340 } 340 $output.= '<p class= poll_footer><input class=submit type=submit name="poll_vote" value="'.$bb_polls['label_vote_text'].'"></p>341 <p class= poll_footer>( <a onClick="if (window.bb_polls_insert_ajax) {bb_polls_show_poll_results_ajax();return false;}" href="'.add_query_arg( 'show_poll_results', '1').'">'.$bb_polls['label_results_text'].'</a> )</p></form>';341 $output.= '<p class="poll_footer"><input class="submit" type="submit" name="poll_vote" value="'.$bb_polls['label_vote_text'].'" /></p> 342 <p class="poll_footer">( <a onClick="if (window.bb_polls_insert_ajax) {bb_polls_show_poll_results_ajax();return false;}" href="'.add_query_arg( 'show_poll_results', '1').'">'.$bb_polls['label_results_text'].'</a> )</p></form>'; 342 343 $output.=bb_polls_edit_link(); 343 344 $output=stripslashes($output); … … 390 391 $output='<form action="'.remove_query_arg(array('start_new_poll','edit_poll')).'" method="post"><p>'.$bb_polls['poll_instructions'].'</p>'; 391 392 392 $output.='<p class= poll_label>'.$bb_polls['label_question_text'].' : <input name="poll_question" type=text style="width:98%" maxlength="'.$bb_polls['max_length'].'" value="'.$poll_options['poll_question'].'"></p>';393 $output.='<p class="poll_label">'.$bb_polls['label_question_text'].' : <input name="poll_question" type="text" style="width:98%" maxlength="'.$bb_polls['max_length'].'" value="'.$poll_options['poll_question'].'" /></p>'; 393 394 394 $output.='<p class= poll_label><span class=nowrap><input name="poll_multiple_choice" type="radio" value="0" ';395 $output.='<p class="poll_label"><span class="nowrap"><input name="poll_multiple_choice" type="radio" value="0" '; 395 396 $output.=($poll_options['poll_multiple_choice']) ? ' ' : ' checked="checked" '; 396 $output.=' >'.$bb_polls['label_single'].'</span> <span class=nowrap><input name="poll_multiple_choice" type="radio" value="1" ';397 $output.=' />'.$bb_polls['label_single'].'</span> <span class="nowrap"><input name="poll_multiple_choice" type="radio" value="1" '; 397 398 $output.=($poll_options['poll_multiple_choice']) ? ' checked="checked" ' : ' '; 398 $output.=' > '.$bb_polls['label_multiple'].'</span></p>';399 $output.=' /> '.$bb_polls['label_multiple'].'</span></p>'; 399 400 400 401 for ($i=1; $i<=$bb_polls['max_options']; $i++) { … … 402 403 $output.='<a href="javascript:void(0)" onClick="this.style.display='."'none'".'; document.getElementById('."'poll_more_options'".').style.display='."'block'".'">[+] '.$bb_polls['label_option_text'].'</a><div id="poll_more_options" style="display:none;">'; 403 404 } 404 $output.='<p class= poll_label>'.$bb_polls['label_option_text'].' #'.$i.' : <input name="poll_option_'.$i.'" type=text style="width:98%" maxlength="'.$bb_polls['max_length'].'" value="'.$poll_options[$i].'"></p>';405 $output.='<p class="poll_label">'.$bb_polls['label_option_text'].' #'.$i.' : <input name="poll_option_'.$i.'" type="text" style="width:98%" maxlength="'.$bb_polls['max_length'].'" value="'.$poll_options[$i].'" /></p>'; 405 406 } // loop 406 407 if ($bb_polls['max_options']>4 && !$poll_options[5]) {$output.='</div>';} 407 408 408 $output.='<p class= poll_footer>409 <input class= submit type=button value="'.$bb_polls['label_cancel_text'].'" onClick="document.location='."'".remove_query_arg( 'start_new_poll')."'".'">410 <input class= submit type=submit value="'.$bb_polls['label_save_text'].'"></p></form>';409 $output.='<p class="poll_footer"> 410 <input class="submit" type="button" value="'.$bb_polls['label_cancel_text'].'" onClick="document.location='."'".remove_query_arg( 'start_new_poll')."'".'" /> 411 <input class="submit" type="submit" value="'.$bb_polls['label_save_text'].'" /></p></form>'; 411 412 $output=stripslashes($output);if ($display) {echo '<li id="bb_polls" class="extra-caps-row">'.$output.'</li>';} else {return $output;} 412 413 } … … 460 461 global $bb_polls; 461 462 if ($bb_polls['use_ajax']) : 462 echo '<scr'.'ipt type="text/javascript" DEFER> 463 echo '<scr'.'ipt type="text/javascript" defer="defer"> 464 <!-- 463 465 var dhead = document.getElementsByTagName("head")[0]; 464 466 var bb_polls_script = null; … … 517 519 else {alert("'.$bb_polls['label_nocheck_text'].'"); return false;} 518 520 } 521 //--> 519 522 </scr'.'ipt>'; 520 523 endif; … … 536 539 537 540 <form method="post" name="bb_polls_form" id="bb_polls_form" action="<?php echo remove_query_arg(array('bb_polls_reset','bb_polls_recount')); ?>"> 538 <input type= hidden name="bb_polls" value="1">541 <input type="hidden" name="bb_polls" value="1" /> 539 542 <table class="widefat"> 540 543 <thead> … … 560 563 switch (substr($bb_polls_type[$key],0,strpos($bb_polls_type[$key].",",","))) : 561 564 case 'binary' : 562 ?><input type= radio name="<?php echo $key; ?>" value="1" <?php echo ($bb_polls[$key]==true ? 'checked="checked"' : ''); ?>>Yes 563 <input type= radio name="<?php echo $key; ?>" value="0" <?php echo ($bb_polls[$key]==false ? 'checked="checked"' : ''); ?>>No <?php565 ?><input type="radio" name="<?php echo $key; ?>" value="1" <?php echo ($bb_polls[$key]==true ? 'checked="checked"' : ''); ?> />Yes 566 <input type="radio" name="<?php echo $key; ?>" value="0" <?php echo ($bb_polls[$key]==false ? 'checked="checked"' : ''); ?> />No <?php 564 567 break; 565 568 case 'numeric' : 566 ?><input type= text maxlength=3 name="<?php echo $key; ?>" value="<?php echo $bb_polls[$key]; ?>"> <?php569 ?><input type="text" maxlength=3 name="<?php echo $key; ?>" value="<?php echo $bb_polls[$key]; ?>" /> <?php 567 570 break; 568 571 case 'textarea' : … … 576 579 echo '</select>'; 577 580 } else { 578 ?><input type= text style="width:98%" name="<?php echo $key; ?>" value="<?php echo $bb_polls[$key]; ?>"> <?php581 ?><input type="text" style="width:98%" name="<?php echo $key; ?>" value="<?php echo $bb_polls[$key]; ?>" /> <?php 579 582 } 580 583 endswitch; … … 588 591 </tbody> 589 592 </table> 590 <p class="submit"><input type="submit" name="submit" value="Save bbPress Polls Settings" ></p>593 <p class="submit"><input type="submit" name="submit" value="Save bbPress Polls Settings" /></p> 591 594 592 595 </form> bbpress-polls/trunk/readme.txt
r922 r947 53 53 * 0.30 enhancement so admin can edit any poll (don't try to change the order of questions, it's a simple edit for now) 54 54 * 0.50 2008-March-1 basic admin menu added 55 * 0.5.2 2008-March-14 xhtml and non-ajax-edit bug fixes, props zmaroti 55 56 56 57 == To Do ==
