Changeset 176325
- Timestamp:
- 11/24/2009 03:33:13 AM (16 years ago)
- Location:
- surveys/trunk
- Files:
-
- 14 edited
-
individual_responses.php (modified) (4 diffs)
-
options.php (modified) (2 diffs)
-
question.php (modified) (3 diffs)
-
question_form.php (modified) (5 diffs)
-
readme.txt (modified) (3 diffs)
-
responses.php (modified) (3 diffs)
-
script.js (modified) (3 diffs)
-
show_individual_response.php (modified) (2 diffs)
-
show_survey.php (modified) (8 diffs)
-
style.css (modified) (2 diffs)
-
survey.php (modified) (1 diff)
-
survey_form.php (modified) (2 diffs)
-
surveys.php (modified) (4 diffs)
-
wpframe.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
surveys/trunk/individual_responses.php
r134220 r176325 1 1 <?php 2 2 include('wpframe.php'); 3 stopDirectCall(__FILE__);3 wpframe_stop_direct_call(__FILE__); 4 4 5 5 $survey_id = $_REQUEST['survey']; … … 28 28 <th scope="col"><div style="text-align: center;">#</div></th> 29 29 <th scope="col"><?php e('Name') ?></th> 30 <th scope="col"><?php e('Email') ?></th> 30 31 <th scope="col"><?php e('Answered On') ?></th> 31 32 <th scope="col" colspan="3"><?php e('Action') ?></th> … … 45 46 46 47 // Retrieve the survey results 47 $results = $wpdb->get_results("SELECT ID, name, added_on FROM {$wpdb->prefix}surveys_result WHERE survey_ID=$survey_id48 $results = $wpdb->get_results("SELECT ID, name,email, added_on FROM {$wpdb->prefix}surveys_result WHERE survey_ID=$survey_id 48 49 ORDER BY added_on DESC LIMIT $offset, $items_per_page"); 49 50 … … 59 60 <th scope="row" style="text-align: center;"><?php echo $count ?></th> 60 61 <td><?php echo stripslashes($survey->name) ?></td> 62 <td><?php if($survey->email) echo "<a href='mailto:".stripslashes($survey->email)."'>".stripslashes($survey->email)."</a>"; ?></td> 61 63 <td><?php echo date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($survey->added_on)) ?></td> 62 64 <td><a href='edit.php?page=surveys/show_individual_response.php&result=<?php echo $survey->ID?>&survey=<?php echo $survey_id ?>&action=show' class='show-result'><?php e('Show'); ?></a></td> -
surveys/trunk/options.php
r115755 r176325 3 3 4 4 if(isset($_REQUEST['submit']) and $_REQUEST['submit']) { 5 $options = array('questions_per_page', 'insert_csv_header' );5 $options = array('questions_per_page', 'insert_csv_header', 'email'); 6 6 foreach($options as $opt) { 7 7 if(isset($_POST[$opt])) update_option('surveys_' . $opt, $_POST[$opt]); 8 8 else update_option('surveys_' . $opt, 0); 9 9 } 10 showMessage("Options updated");10 wpframe_message("Options updated"); 11 11 } 12 12 ?> … … 18 18 <label for="questions"><?php e('Number of questions per page. If 0, all the questions will be shown in a single page') ?></label> 19 19 <input type="text" name="questions_per_page" value="<?php echo get_option('surveys_questions_per_page') ?>" id="questions_per_page" size="3" /><br /> 20 21 <label for="surveys_email"><?php e('Send all survey results by email') ?></label> 22 <input type="text" name="email" value="<?php echo get_option('surveys_email') ?>" id="email" /><br /> 20 23 21 24 <?php showOption('insert_csv_header', 'Insert the questions of the survey as the first line(header) in CSV export'); ?> -
surveys/trunk/question.php
r134220 r176325 1 1 <?php 2 2 include('wpframe.php'); 3 stopDirectCall(__FILE__);3 wpframe_stop_direct_call(__FILE__); 4 4 5 5 $action = 'new'; … … 8 8 if(isset($_REQUEST['submit'])) { 9 9 if($action == 'edit') { //update goes here 10 $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}surveys_question SET question='%s',allow_user_answer=%d,allow_multiple_answers=%d, survey_ID=%d WHERE ID=%d",11 $_REQUEST['content'], $_REQUEST['allow_user_answer'], $_REQUEST['allow_multiple_answers'], 10 $wpdb->query($wpdb->prepare("UPDATE {$wpdb->prefix}surveys_question SET question='%s',allow_user_answer=%d,allow_multiple_answers=%d,user_answer_format=%s, survey_ID=%d WHERE ID=%d", 11 $_REQUEST['content'], $_REQUEST['allow_user_answer'], $_REQUEST['allow_multiple_answers'], $_REQUEST['user_answer_format'], 12 12 $_REQUEST['survey'], $_REQUEST['question'])); 13 13 … … 33 33 34 34 } else { 35 $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->prefix}surveys_question(survey_ID,question,allow_user_answer, allow_multiple_answers ) VALUES(%d,'%s',%d, %d)",36 $_REQUEST['survey'], $_REQUEST['content'], $_REQUEST['allow_user_answer'], $_REQUEST['allow_multiple_answers'] ));//Inserting the questions;35 $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->prefix}surveys_question(survey_ID,question,allow_user_answer, allow_multiple_answers, user_answer_format) VALUES(%d,'%s',%d, %d, %s)", 36 $_REQUEST['survey'], $_REQUEST['content'], $_REQUEST['allow_user_answer'], $_REQUEST['allow_multiple_answers'], $_REQUEST['user_answer_format']));//Inserting the questions; 37 37 print '<div id="message" class="updated fade"><p>'.t('Question added.') . '</p></div>'; 38 38 $question_id = $_REQUEST['question'] = $wpdb->insert_id; -
surveys/trunk/question_form.php
r134220 r176325 1 1 <?php 2 2 include('wpframe.php'); 3 stopDirectCall(__FILE__);3 wpframe_stop_direct_call(__FILE__); 4 4 5 5 $action = 'new'; … … 10 10 if($action == 'edit') { 11 11 $answer = $wpdb->get_results($wpdb->prepare("SELECT ID, answer FROM {$wpdb->prefix}surveys_answer WHERE question_ID=%d ORDER BY sort_order", $_REQUEST['question'])); 12 $question = $wpdb->get_row($wpdb->prepare("SELECT question,allow_user_answer,allow_multiple_answers FROM {$wpdb->prefix}surveys_question WHERE ID=%d", $_REQUEST['question']));12 $question = $wpdb->get_row($wpdb->prepare("SELECT question,allow_user_answer,allow_multiple_answers,user_answer_format FROM {$wpdb->prefix}surveys_question WHERE ID=%d", $_REQUEST['question'])); 13 13 } 14 14 … … 23 23 24 24 <?php 25 wp_enqueue_script( 'jquery' ); 26 wp_enqueue_script( 'prototype' ); 27 wp_print_scripts('post'); 28 wp_print_scripts('editor'); 29 if(function_exists('add_thickbox')) add_thickbox(); //Make sure it works with WP 2.5 30 wp_enqueue_script('media-upload'); 31 if (function_exists('wp_tiny_mce')) wp_tiny_mce(); 32 wp_print_scripts(); 25 wpframe_add_editor_js(); 33 26 ?> 34 27 <script type="text/javascript"> … … 47 40 } 48 41 function init() { 42 jQuery("#allow_user_answer").change(function() { 43 if(jQuery("#allow_user_answer").is(":checked")) { 44 jQuery("#user_answer_format_area").show('slow'); 45 } else { 46 jQuery("#user_answer_format_area").hide('slow'); 47 } 48 }); 49 49 jQuery("#post").submit(function(e) { 50 50 // Make sure question is suplied … … 102 102 <label for="allow_user_answer"><?php e('Allow User Inputed Answers') ?></label> 103 103 <input type="checkbox" id="allow_user_answer" name="allow_user_answer" value="1" <?php if($question->allow_user_answer) echo 'checked=checked' ?> /><br /> 104 <div id="user_answer_format_area" <?php if(!$question->allow_user_answer) echo 'style="display:none;"'; ?>> 105 <label for="user_answer_format"><?php e('User Answer Format') ?></label> 106 <select id="user_answer_format" name="user_answer_format"> 107 <option value="entry" <?php if($question->user_answer_format == 'entry') echo 'selected="selected"'; ?>>Text Entry</option> 108 <option value="textarea" <?php if($question->user_answer_format == 'textarea') echo 'selected="selected"'; ?>>Textarea</option> 109 <option value="checkbox" <?php if($question->user_answer_format == 'checkbox') echo 'selected="selected"'; ?>>CheckBox</option> 110 </select> 111 </div> 112 113 104 114 <label for="allow_multiple_answers"><?php e('Allow Multiple Answers') ?></label> 105 115 <input type="checkbox" id="allow_multiple_answers" name="allow_multiple_answers" value="1" <?php if($question->allow_multiple_answers) echo 'checked=checked' ?> /> -
surveys/trunk/readme.txt
r134220 r176325 5 5 Requires at least: 2.5 6 6 Tested up to: 2.8 7 Stable tag: 1.01. 37 Stable tag: 1.01.4 8 8 9 9 The Surveys WordPress plugin lets you add surveys to your blog. You can let the vistors take surveys and see the result from the admin side. … … 43 43 44 44 = 1.01.1 = 45 * Bugfix relase - fixed some bugs that I will notice only after the re sease has been made.45 * Bugfix relase - fixed some bugs that I will notice only after the release has been made. 46 46 47 47 = 1.01.2 = … … 53 53 * Made the admin forms a bit more easier on the eye. 54 54 * Made the plugin WP 2.8 compatible. 55 56 = 1.01.4 = 57 * Made sure this works with 2.8.5 58 * Changed the editor code to make sure it works with 2.8.5 59 * Fixed bug that showed a permission error in WAMP servers 60 * Depreciated the old <!-- SURVEYS 1 --> type insertion - it will no longer work. Use [SURVEYS 1] in your posts/pages. 61 * Shows the email in individual response section -
surveys/trunk/responses.php
r115755 r176325 1 1 <?php 2 2 include('wpframe.php'); 3 stopDirectCall(__FILE__);3 wpframe_stop_direct_call(__FILE__); 4 4 5 5 $colors = array('bf1a1d', 'bfa024', '830088', '3e4cb9', '52803b', '805b6f', '827f71', '4bc0e0', 'c12a8f', '000000'); … … 31 31 $answers = $wpdb->get_results($wpdb->prepare("SELECT A.ID, A.answer, (SELECT COUNT(*) FROM {$wpdb->prefix}surveys_result_answer WHERE answer_ID=A.ID) AS votes 32 32 FROM {$wpdb->prefix}surveys_answer AS A WHERE A.question_ID=%d ORDER BY A.sort_order", $question->ID)); 33 34 if(count($answers)) { 33 35 ?> 34 36 <table class="widefat"> … … 66 68 <strong>Total Votes: <?=$total?></strong><br /><hr /> 67 69 68 <?php } ?> 70 <?php } else { ?> 71 <p>User inputed answers. Use the <a href="edit.php?page=surveys/individual_responses.php&survey=<?php echo $survey_id ?>">Individual Responses</a> section to see the answers to this question.</p> 72 <hr /> 73 <?php } 74 75 } ?> 76 69 77 <a href="edit.php?page=surveys/survey.php">Manage Surveys</a> 70 78 </div> -
surveys/trunk/script.js
r115755 r176325 1 var current_question = 1;2 var questions_per_page = 1;3 var total_questions = 0;4 var current_page = 1;1 var survey_current_question = 1; 2 var survey_questions_per_page = 1; 3 var survey_total_questions = 0; 4 var survey_current_page = 1; 5 5 6 6 function nextQuestion(e) { 7 if( questions_per_page != 0) return nextPage(e); // Multi question per page7 if(survey_questions_per_page != 0) return nextPage(e); // Multi question per page 8 8 var answered = false; 9 9 10 jQuery("#question-" + current_question + " .answer").each(function(i) {10 jQuery("#question-" + survey_current_question + " .answer").each(function(i) { 11 11 if(this.checked) { 12 12 answered = true; … … 22 22 } 23 23 24 jQuery("#question-" + current_question).hide();25 current_question++;26 jQuery("#question-" + current_question).show();24 jQuery("#question-" + survey_current_question).hide(); 25 survey_current_question++; 26 jQuery("#question-" + survey_current_question).show(); 27 27 28 if( total_questions <=current_question) {29 jQuery("# next-question").hide();30 jQuery("# action-button").show();28 if(survey_total_questions <= survey_current_question) { 29 jQuery("#survey-next-question").hide(); 30 jQuery("#survey-action-button").show(); 31 31 } 32 32 } 33 33 34 34 function nextPage(e) { 35 current_page++;35 survey_current_page++; 36 36 showNextXQuestions(); 37 37 } 38 38 39 39 function showNextXQuestions() { 40 jQuery(". question").hide();40 jQuery(".survey-question").hide(); 41 41 42 var from_question = (( current_page - 1) *questions_per_page) + 1;43 var to_question = current_page *questions_per_page;42 var from_question = ((survey_current_page - 1) * survey_questions_per_page) + 1; 43 var to_question = survey_current_page * survey_questions_per_page; 44 44 for(var i = from_question; i <= to_question; i++) { 45 45 jQuery("#question-" + i).show(); 46 46 } 47 47 48 if(to_question >= total_questions) {49 jQuery("# action-button").show();50 jQuery("# next-question").hide();48 if(to_question >= survey_total_questions) { 49 jQuery("#survey-action-button").show(); 50 jQuery("#survey-next-question").hide(); 51 51 } 52 52 } 53 53 54 function init() {55 total_questions = jQuery(".question").length;56 if( questions_per_page > 1) {57 jQuery("# action-button").hide();58 jQuery("# next-question").show();54 function surveyInit() { 55 survey_total_questions = jQuery(".survey-question").length; 56 if(survey_questions_per_page > 1) { 57 jQuery("#survey-action-button").hide(); 58 jQuery("#survey-next-question").show(); 59 59 showNextXQuestions(); 60 60 61 } else if( questions_per_page == 0) { //Single page mode.62 jQuery(". question").show();63 jQuery("# action-button").show();64 jQuery("# next-question").hide();61 } else if(survey_questions_per_page == 0) { //Single page mode. 62 jQuery(".survey-question").show(); 63 jQuery("#survey-action-button").show(); 64 jQuery("#survey-next-question").hide(); 65 65 66 66 } else { … … 68 68 } 69 69 70 jQuery("# next-question").click(nextQuestion);70 jQuery("#survey-next-question").click(nextQuestion); 71 71 } 72 72 73 jQuery(document).ready(init); 74 75 76 function p() { 77 if(arguments.length > 1) console.group(); 78 for(var i=0; i<arguments.length; i++) console.log(arguments[i]); 79 if(arguments.length > 1) console.groupEnd(); 80 } 73 jQuery(document).ready(surveyInit); -
surveys/trunk/show_individual_response.php
r134220 r176325 1 1 <?php 2 2 include('wpframe.php'); 3 stopDirectCall(__FILE__);3 wpframe_stop_direct_call(__FILE__); 4 4 5 5 $result_id = $_REQUEST['result']; 6 6 7 $survey = $wpdb->get_row("SELECT S.ID, S.name, R.name AS rname, R. added_on FROM {$wpdb->prefix}surveys_survey AS S INNER JOIN {$wpdb->prefix}surveys_result AS R ON S.ID=R.survey_ID WHERE R.ID=$result_id");7 $survey = $wpdb->get_row("SELECT S.ID, S.name, R.name AS rname, R.email, R.added_on FROM {$wpdb->prefix}surveys_survey AS S INNER JOIN {$wpdb->prefix}surveys_result AS R ON S.ID=R.survey_ID WHERE R.ID=$result_id"); 8 8 9 9 print "<div class='wrap'><h2>" . t('Response to ') . stripslashes($survey->name) . "</h2>"; 10 10 print "<h4>"; 11 if($survey->rname) print t('By ') . stripslashes($survey->rname) . t(' on '); 12 else print t('On '); 11 if($survey->rname) print t('By ') . stripslashes($survey->rname); 12 if($survey->email) print "(". stripslashes($survey->email) . ")"; 13 print t(' On '); 13 14 print date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($survey->added_on)) . "</h4>"; 14 15 15 $questions = $wpdb->get_results("SELECT ID, questionFROM {$wpdb->prefix}surveys_question WHERE survey_ID={$survey->ID}");16 $questions = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}surveys_question WHERE survey_ID={$survey->ID}"); 16 17 17 18 foreach($questions as $q) { … … 29 30 30 31 print t("Answer: ") . "<strong>"; 31 print implode('</strong>, <strong>', $answers); 32 if($q->allow_user_answer and $q->user_answer_format == 'checkbox') { 33 if($answers[0]) print 'Yes'; 34 else print 'No'; 35 } else { 36 print implode('</strong>, <strong>', $answers); 37 } 32 38 print "</strong>\n<br /><hr />"; 33 39 } -
surveys/trunk/show_survey.php
r134220 r176325 1 1 <?php 2 2 include('wpframe.php'); 3 stopDirectCall(__FILE__); 3 wpframe_stop_direct_call(__FILE__); 4 5 if(!is_single() and isset($GLOBALS['surveys_client_includes_loaded'])) { #If this is in the listing page - and a quiz is already shown, don't show another. 6 printf(t("Please go to <a href='%s'>%s</a> to view the survey"), get_permalink(), get_the_title()); 7 } else { 8 4 9 global $wpdb; 5 10 6 $question = $wpdb->get_results($wpdb->prepare("SELECT ID,question,allow_user_answer,allow_multiple_answers FROM {$wpdb->prefix}surveys_question WHERE survey_id=%d ORDER BY ID", $survey_id));11 $question = $wpdb->get_results($wpdb->prepare("SELECT ID,question,allow_user_answer,allow_multiple_answers,user_answer_format FROM {$wpdb->prefix}surveys_question WHERE survey_id=%d ORDER BY ID", $survey_id)); 7 12 8 13 if(isset($_POST['action']) and $_POST['action']) { // Save the survey … … 12 17 13 18 } else { //Save the survey details. 19 //$wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->prefix}surveys_result (survey_ID, added_on) VALUES(%d, DATE_ADD(NOW(), INTERVAL %f HOUR))", $survey_id, get_option('gmt_offset'))); 14 20 $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->prefix}surveys_result (survey_ID, added_on) VALUES(%d, NOW())", $survey_id)); 15 21 $result_id = $wpdb->insert_id; 16 22 17 23 $question_count = 0; 18 24 foreach($_POST['question_id'] as $question_id) { … … 22 28 23 29 } else { 24 foreach($_POST['answer-' . $question_id] as $answer_id) {30 foreach($_POST['answer-' . $question_id] as $answer_id) { 25 31 $user_answer = ''; 26 32 … … 35 41 36 42 if(!$question[$question_count]->allow_multiple_answers) break; // If this question don't allow multiple answers, break to the next question. This is basically a security measure. Users will have to edit the page HTML to make this necessary(very unlikely.). 37 }43 } 38 44 } 39 45 $question_count++; 46 } 47 48 $email = get_option('surveys_email'); 49 if($email) { 50 51 $email_body = printf(t("Hi,\nThere is a new result for the survey at %s...\n"), $_SERVER['REQUEST_URI']); 52 53 //Code lifted from show_individual_response.php file 54 $questions = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$wpdb->prefix}surveys_question WHERE survey_ID=%d", $survey_id)); 55 56 foreach($questions as $q) { 57 $email_body .= $q->question . "\n"; 58 $all_answers_for_question = $wpdb->get_results($wpdb->prepare("SELECT A.answer,RA.answer_ID,RA.user_answer 59 FROM {$wpdb->prefix}surveys_result_answer AS RA 60 LEFT JOIN {$wpdb->prefix}surveys_answer AS A 61 ON A.ID=RA.answer_ID WHERE RA.result_ID=%d AND RA.question_ID=%d", $result_id, $q->ID)); 62 63 $answers = array(); 64 foreach($all_answers_for_question as $one_answer) { // There is a chance that there is multiple answers for this question. 65 if($one_answer->answer_ID) $answers[] = stripslashes($one_answer->answer); 66 else $answers[] = stripslashes($one_answer->user_answer); //Custom User answer. 67 } 68 69 $email_body .= t("Answer: "); 70 if($q->allow_user_answer and $q->user_answer_format == 'checkbox') { 71 if($answers[0]) $email_body .= 'Yes'; 72 else $email_body .= 'No'; 73 } else { 74 $email_body .= implode(', ', $answers); 75 } 76 $email_body .= "\n\n"; 77 } 78 79 80 mail($email, t("Survey Result"), $email_body); 81 40 82 } 41 83 … … 43 85 ?> 44 86 <form action="" method="post" class="survey-form" style="text-align: left;"> 45 <label for="name"> Name</label> <input type="text" name="survey_taker_name" id="name" value="" /><br />46 <label for="email"> Email</label> <input type="text" name="email" id="email" value=""/><br />87 <label for="name"><?php e("Name") ?></label> <input type="text" name="survey_taker_name" id="name" value="" /><br /> 88 <label for="email"><?php e("Email") ?></label> <input type="text" name="email" id="email" value=""/><br /> 47 89 <input type="submit" name="action" id="action-button" value="<?php e("Submit Survey") ?>" /> 48 90 <input type="hidden" name="result_id" value="<?php echo $result_id ?>" /> … … 73 115 74 116 foreach ($question as $ques) { 75 echo "<div class=' question' id='question-$question_count'>";76 echo " <div class='question-content'>{$ques->question}</div><br />\n";117 echo "<div class='survey-question' id='question-$question_count'>"; 118 echo "{$ques->question}\n"; 77 119 echo "<input type='hidden' name='question_id[]' value='{$ques->ID}' />\n"; 78 $all_answers = $wpdb->get_results("SELECT ID,answer FROM {$wpdb->prefix}surveys_answer WHERE question_id={$ques->ID} ");120 $all_answers = $wpdb->get_results("SELECT ID,answer FROM {$wpdb->prefix}surveys_answer WHERE question_id={$ques->ID} ORDER BY sort_order"); 79 121 80 122 $type = ($ques->allow_multiple_answers) ? 'checkbox' : 'radio'; //If this is a multi answer question, make it a checkbox. Else, it will be a radio. 81 123 if(count($all_answers) == 0 and $ques->allow_user_answer) $type = 'hidden'; //If there are no admin specified answer, and it allows user answer, keep it as selected - user don't have to check anything. 124 125 if(count($all_answers) or $ques->user_answer_format == 'textarea') echo "<br />"; 82 126 83 127 foreach ($all_answers as $ans) { … … 88 132 if($ques->allow_user_answer) { 89 133 echo "<input type='$type' name='answer-{$ques->ID}[]' id='answer-id-{$ans->ID}' class='answer' value='user-answer' />\n"; 90 echo "<input type='text' name='user-answer-{$ques->ID}' class='user-answer' value='' /><br />\n"; 134 135 if($ques->user_answer_format == 'textarea') 136 echo "<textarea name='user-answer-{$ques->ID}' rows='5' cols='30' class='user-answer'></textarea>"; 137 elseif($ques->user_answer_format == 'checkbox') 138 echo "<input type='checkbox' name='user-answer-{$ques->ID}' class='user-answer' value='1' />"; 139 else 140 echo "<input type='text' name='user-answer-{$ques->ID}' class='user-answer' value='' />"; 141 142 echo "<br />\n"; 91 143 } 92 144 … … 96 148 97 149 ?><br /> 98 <input type="button" id=" next-question" value="<?php e("Next") ?> >" /><br />150 <input type="button" id="survey-next-question" value="<?php e("Next") ?> >" /><br /> 99 151 100 <input type="submit" name="action" id=" action-button" value="<?php e("Submit Survey") ?>" />152 <input type="submit" name="action" id="survey-action-button" value="<?php e("Submit Survey") ?>" /> 101 153 <input type="hidden" name="survey_id" value="<?php echo $survey_id ?>" /> 102 154 </form> 103 155 104 <script type="text/javascript"> questions_per_page = <?php echo $questions_per_page ?>;</script>156 <script type="text/javascript">survey_questions_per_page = <?php echo $questions_per_page ?>;</script> 105 157 </div> 106 158 107 159 <?php } 108 160 } 161 } 109 162 ?> -
surveys/trunk/style.css
r115755 r176325 1 . question, #action-button {1 .survey-question, #action-button { 2 2 display:none; 3 3 } … … 7 7 } 8 8 9 .multi-question . question {9 .multi-question .survey-question { 10 10 display:block; 11 11 padding-bottom:5px; -
surveys/trunk/survey.php
r115755 r176325 1 1 <?php 2 2 include('wpframe.php'); 3 stopDirectCall(__FILE__);3 wpframe_stop_direct_call(__FILE__); 4 4 5 5 if($_REQUEST['message'] == 'updated') { -
surveys/trunk/survey_form.php
r134220 r176325 1 1 <?php 2 2 include('wpframe.php'); 3 stopDirectCall(__FILE__);3 wpframe_stop_direct_call(__FILE__); 4 4 5 5 $action = 'new'; … … 16 16 <input type="hidden" id="title" name="ignore_me" value="This is here for a workaround for a editor bug" /> 17 17 18 <?php 19 wp_admin_css('thickbox'); 20 wp_print_scripts('jquery-ui-core'); 21 wp_print_scripts('jquery-ui-tabs'); 22 wp_print_scripts('post'); 23 wp_print_scripts('editor'); 24 if (function_exists('add_thickbox')) add_thickbox(); 25 wp_print_scripts('media-upload'); 26 if (function_exists('wp_tiny_mce')) wp_tiny_mce(); 27 28 ?> 18 <?php wpframe_add_editor_js(); ?> 29 19 30 20 <form name="post" action="<?php echo $wpframe_plugin_folder?>/survey_action.php" method="post" id="post"> -
surveys/trunk/surveys.php
r134220 r176325 4 4 Plugin URI: http://www.bin-co.com/tools/wordpress/plugins/surveys/ 5 5 Description: The Surveys WordPress plugin lets you add surveys to your blog. You can let the vistors take surveys and see the result from the admin side. 6 Version: 1.01. 36 Version: 1.01.4 7 7 Author: Binny V A 8 8 Author URI: http://www.binnyva.com/ 9 9 */ 10 require_once('wpframe.php');11 10 12 11 /** … … 15 14 add_action( 'admin_menu', 'surveys_add_menu_links' ); 16 15 function surveys_add_menu_links() { 17 global $wp_version ;16 global $wp_version, $_registered_pages; 18 17 $view_level= 2; 19 18 $page = 'edit.php'; 20 19 if($wp_version >= '2.7') $page = 'tools.php'; 21 20 22 add_submenu_page($page, t('Manage Surveys'), t('Manage Surveys'), $view_level, 'surveys/survey.php'); 23 wpf_register_pages(array('export.php','individual_responses.php','question.php','question_form.php','responses.php','show_individual_response.php','survey_action.php','survey_form.php'), 'surveys'); 21 add_submenu_page($page, __('Manage Surveys', 'surveys'), __('Manage Surveys', 'surveys'), $view_level, 'surveys/survey.php'); 22 23 $code_pages = array('export.php','individual_responses.php','question.php','question_form.php','responses.php','show_individual_response.php','survey_action.php','survey_form.php'); 24 foreach($code_pages as $code_page) { 25 $hookname = get_plugin_page_hookname("surveys/$code_page", '' ); 26 $_registered_pages[$hookname] = true; 27 } 24 28 } 25 29 … … 27 31 * This will scan all the content pages that wordpress outputs for our special code. If the code is found, it will replace the requested survey. 28 32 */ 29 add_filter('the_content', 'surveys_scan_content'); 30 function surveys_scan_content($body) { 31 if(strpos($body, 'SURVEYS') !== false) { 32 if(preg_match('/(<!--|\[)\s*SURVEYS\s*(\d+)\s*(\]|-->)/', $body, $matches)) { 33 $survey_id = $matches[2]; 34 35 if(is_numeric($survey_id)) { // Basic validiation - more on the show_quiz.php file. 36 ob_start(); 37 include(ABSPATH . 'wp-content/plugins/surveys/show_survey.php'); 38 $contents = ob_get_contents(); 39 ob_end_clean(); 40 41 $body = str_replace($matches[0], $contents, $body); 42 } 43 } 33 add_shortcode( 'SURVEYS', 'surveys_shortcode' ); 34 function surveys_shortcode( $attr ) { 35 $survey_id = $attr[0]; 36 37 $contents = ''; 38 if(is_numeric($survey_id)) { // Basic validiation - more on the show_quiz.php file. 39 ob_start(); 40 include(ABSPATH . 'wp-content/plugins/surveys/show_survey.php'); 41 $contents = ob_get_contents(); 42 ob_end_clean(); 44 43 } 45 return $ body;44 return $contents; 46 45 } 47 46 … … 49 48 add_action('admin_menu', 'surveys_option_page'); 50 49 function surveys_option_page() { 51 add_options_page( t('Surveys Settings'), t('Surveys Settings'), 8, basename(__FILE__), 'surveys_options');50 add_options_page(__('Surveys Settings', 'surveys'), __('Surveys Settings', 'surveys'), 8, basename(__FILE__), 'surveys_options'); 52 51 } 53 52 function surveys_options() { 54 if ( function_exists('current_user_can') && !current_user_can('manage_options') ) die( t('Cheatin’ uh?'));55 if (! user_can_access_admin_page()) wp_die( t('You do not have sufficient permissions to access this page.') );53 if ( function_exists('current_user_can') && !current_user_can('manage_options') ) die(__("Cheatin' uh?", 'surveys')); 54 if (! user_can_access_admin_page()) wp_die( __('You do not have sufficient permissions to access this page.', 'surveys') ); 56 55 57 56 require(ABSPATH. '/wp-content/plugins/surveys/options.php'); -
surveys/trunk/wpframe.php
r134220 r176325 13 13 //* :DEBUG: */ $GLOBALS['wpdb']->show_errors(); 14 14 15 if(!function_exists(' stopDirectCall')) { //Make sure multiple plugins can be created using WPFrame15 if(!function_exists('wpframe_add_editor_js')) { //Make sure multiple plugins can be created using WPFrame 16 16 17 /// Need to register a page to use it in a plugin in WP2.8.1+. THIS IS A HACK. 18 function wpf_register_pages($pages, $folder) { 19 foreach($pages as $p) wpf_register_page($folder . DIRECTORY_SEPARATOR . $p); 20 } 21 function wpf_register_page($file) { 22 global $_registered_pages; 23 $hookname = get_plugin_page_hookname($file, '' ); 24 $_registered_pages[$hookname] = true; 17 /// Adds the JS code needed for the editor. Changes often. So made it centralized 18 function wpframe_add_editor_js() { 19 wp_enqueue_script( 'common' ); 20 wp_enqueue_script( 'jquery-color' ); 21 wp_print_scripts('editor'); 22 if (function_exists('add_thickbox')) add_thickbox(); 23 wp_print_scripts('media-upload'); 24 if (function_exists('wp_tiny_mce')) wp_tiny_mce(); 25 wp_admin_css(); 26 wp_enqueue_script('utils'); 27 do_action("admin_print_styles-post-php"); 28 do_action('admin_print_styles'); 25 29 } 26 30 27 31 /// Make sure that the user don't call this file directly - forces the use of the WP interface 28 function stopDirectCall($file) {32 function wpframe_stop_direct_call($file) { 29 33 if(preg_match('#' . basename($file) . '#', $_SERVER['PHP_SELF'])) die('Don\'t call this page directly.'); // Stop direct call 30 34 } 31 35 32 36 /// Shows a message in the admin interface of Wordpress 33 function showMessage($message, $type='updated') {37 function wpframe_message($message, $type='updated') { 34 38 if($type == 'updated') $class = 'updated fade'; 35 39 elseif($type == 'error') $class = 'updated error';
Note: See TracChangeset
for help on using the changeset viewer.