Changeset 947

Show
Ignore:
Timestamp:
03/14/08 18:56:05 (9 months ago)
Author:
_ck_
Message:

xhtml and non-ajax-edit bug fixes, props zmaroti

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • bbpress-polls/trunk/bb-polls.php

    r937 r947  
    66Author: _ck_ 
    77Author URI: http://bbShowcase.org 
    8 Version: 0.51 
     8Version: 0.5.2 
    99 
    1010License: CC-GNU-GPL http://creativecommons.org/licenses/GPL/2.0/ 
     
    190190} 
    191191 
    192 function bb_polls_pre_poll($topic_id,$edit_poll=0) {  
     192function bb_polls_pre_poll($topic_id, $edit_poll=0) {  
    193193global $bb_polls,$topic,$poll_options,$page; 
    194194if ($bb_polls['minimum_view_level']=="read" || bb_current_user_can($bb_polls['minimum_view_level']) ) :    
     
    197197$administrator=bb_current_user_can('administrate'); 
    198198bb_polls_add_javascript($topic_id);     // ajax-ish 
     199if (!$edit_poll && isset($_GET['edit_poll'])) {$edit_poll= intval($_GET['edit_poll']);} 
    199200if ($edit_poll || ! isset($topic->poll_options)) {      // no saved poll question with options 
    200201 
     
    214215                } else {         
    215216                        // ask if they want to start a new poll 
    216                                 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                                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>';  
    217218                 
    218219                } } }   // end new poll question + end show start_new_poll form  
     
    296297if ($bb_polls['minimum_view_level']=="read" || bb_current_user_can($bb_polls['minimum_view_level']) ) { 
    297298$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>'; 
    299300 
    300301if (!$poll_options['poll_multiple_choice'] && isset($poll_options['poll_count_0'])) {$real_vote_count=intval($poll_options['poll_count_0']);} 
     
    303304for ($i=1; $i<=$bb_polls['max_options']; $i++) { 
    304305        if (isset($poll_options[$i])) {                  
    305                 $output.= '<p class=poll_label>'.$poll_options[$i].' : ';      
     306                $output.= '<p class="poll_label">'.$poll_options[$i].' : ';    
    306307                $test=(isset($poll_options['poll_count_'.$i]) ? intval($poll_options['poll_count_'.$i]) : 0); 
    307308                $output.= ' ('.$test.' '.$bb_polls['label_votes_text'].')'; 
     
    309310                        $vote_percent=(round($test/$real_vote_count,2)*100); 
    310311                        $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> '; 
    312313                } 
    313314                $output.= ' </p>'; 
     
    315316} 
    316317$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>'; 
    318319if (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>'; 
    320321} 
    321322$output.=bb_polls_edit_link(); 
     
    331332if ($poll_options['poll_multiple_choice']==1) {$poll_type="checkbox";} else {$poll_type="radio";} 
    332333$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>'; 
    334335for ($i=1; $i<=$bb_polls['max_options']; $i++) { 
    335336        if (isset($poll_options[$i])) { 
    336337                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>'; 
    338339        } 
    339340} 
    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>'; 
    342343$output.=bb_polls_edit_link(); 
    343344$output=stripslashes($output); 
     
    390391$output='<form action="'.remove_query_arg(array('start_new_poll','edit_poll')).'" method="post"><p>'.$bb_polls['poll_instructions'].'</p>'; 
    391392                         
    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>'; 
    393394                         
    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" '; 
    395396$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" '; 
    397398$output.=($poll_options['poll_multiple_choice']) ? ' checked="checked" ' : ' '; 
    398 $output.='> '.$bb_polls['label_multiple'].'</span></p>'; 
     399$output.=' /> '.$bb_polls['label_multiple'].'</span></p>'; 
    399400                         
    400401for ($i=1; $i<=$bb_polls['max_options']; $i++) {                         
     
    402403                $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;">'; 
    403404        } 
    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>'; 
    405406} // loop  
    406407if ($bb_polls['max_options']>4 && !$poll_options[5]) {$output.='</div>';} 
    407408                 
    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>'; 
    411412$output=stripslashes($output);if ($display) {echo '<li id="bb_polls" class="extra-caps-row">'.$output.'</li>';} else {return $output;} 
    412413} 
     
    460461global $bb_polls; 
    461462if ($bb_polls['use_ajax']) : 
    462 echo '<scr'.'ipt type="text/javascript" DEFER> 
     463echo '<scr'.'ipt type="text/javascript" defer="defer"> 
     464<!-- 
    463465var dhead = document.getElementsByTagName("head")[0]; 
    464466var bb_polls_script = null; 
     
    517519else {alert("'.$bb_polls['label_nocheck_text'].'"); return false;} 
    518520} 
     521//--> 
    519522</scr'.'ipt>'; 
    520523endif; 
     
    536539                 
    537540                <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" /
    539542                        <table class="widefat"> 
    540543                                <thead> 
     
    560563                                                        switch (substr($bb_polls_type[$key],0,strpos($bb_polls_type[$key].",",","))) : 
    561564                                                        case 'binary' : 
    562                                                                 ?><input type=radio name="<?php echo $key;  ?>" value="1" <?php echo ($bb_polls[$key]==true ? 'checked="checked"' : ''); ?> >Yes                                                                      &nbsp;  
    563                                                                      <input type=radio name="<?php echo $key;  ?>" value="0" <?php echo ($bb_polls[$key]==false ? 'checked="checked"' : ''); ?> >No <?php 
     565                                                                ?><input type="radio" name="<?php echo $key;  ?>" value="1" <?php echo ($bb_polls[$key]==true ? 'checked="checked"' : ''); ?> />Yes                                                                   &nbsp;  
     566                                                                     <input type="radio" name="<?php echo $key;  ?>" value="0" <?php echo ($bb_polls[$key]==false ? 'checked="checked"' : ''); ?> />No <?php 
    564567                                                        break; 
    565568                                                        case 'numeric' : 
    566                                                                 ?><input type=text maxlength=3 name="<?php echo $key;  ?>" value="<?php echo $bb_polls[$key]; ?>"> <?php  
     569                                                                ?><input type="text" maxlength=3 name="<?php echo $key;  ?>" value="<?php echo $bb_polls[$key]; ?>" /> <?php  
    567570                                                        break; 
    568571                                                        case 'textarea' :                                                                
     
    576579                                                                echo '</select>'; 
    577580                                                                } else {                                                                                                                 
    578                                                                 ?><input type=text style="width:98%" name="<?php echo $key;  ?>" value="<?php echo $bb_polls[$key]; ?>"> <?php  
     581                                                                ?><input type="text" style="width:98%" name="<?php echo $key;  ?>" value="<?php echo $bb_polls[$key]; ?>" /> <?php  
    579582                                                                } 
    580583                                                        endswitch;                                                       
     
    588591                                </tbody> 
    589592                        </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> 
    591594                 
    592595                </form> 
  • bbpress-polls/trunk/readme.txt

    r922 r947  
    5353* 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) 
    5454* 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 
    5556         
    5657== To Do ==