Plugin Directory

Changeset 176325


Ignore:
Timestamp:
11/24/2009 03:33:13 AM (16 years ago)
Author:
binnyva
Message:

New version

Location:
surveys/trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • surveys/trunk/individual_responses.php

    r134220 r176325  
    11<?php
    22include('wpframe.php');
    3 stopDirectCall(__FILE__);
     3wpframe_stop_direct_call(__FILE__);
    44
    55$survey_id = $_REQUEST['survey'];
     
    2828        <th scope="col"><div style="text-align: center;">#</div></th>
    2929        <th scope="col"><?php e('Name') ?></th>
     30        <th scope="col"><?php e('Email') ?></th>
    3031        <th scope="col"><?php e('Answered On') ?></th>
    3132        <th scope="col" colspan="3"><?php e('Action') ?></th>
     
    4546
    4647// Retrieve the survey results
    47 $results = $wpdb->get_results("SELECT ID, name, added_on FROM {$wpdb->prefix}surveys_result WHERE survey_ID=$survey_id
     48$results = $wpdb->get_results("SELECT ID, name,email, added_on FROM {$wpdb->prefix}surveys_result WHERE survey_ID=$survey_id
    4849                                    ORDER BY added_on DESC LIMIT $offset, $items_per_page");
    4950
     
    5960        <th scope="row" style="text-align: center;"><?php echo $count ?></th>
    6061        <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>
    6163        <td><?php echo date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($survey->added_on)) ?></td>
    6264        <td><a href='edit.php?page=surveys/show_individual_response.php&amp;result=<?php echo $survey->ID?>&amp;survey=<?php echo $survey_id ?>&amp;action=show' class='show-result'><?php e('Show'); ?></a></td>
  • surveys/trunk/options.php

    r115755 r176325  
    33
    44if(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');
    66    foreach($options as $opt) {
    77        if(isset($_POST[$opt])) update_option('surveys_' . $opt, $_POST[$opt]);
    88        else update_option('surveys_' . $opt, 0);
    99    }
    10     showMessage("Options updated");
     10    wpframe_message("Options updated");
    1111}
    1212?>
     
    1818<label for="questions"><?php e('Number of questions per page. If 0, all the questions will be shown in a single page') ?></label>
    1919<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 />
    2023
    2124<?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  
    11<?php
    22include('wpframe.php');
    3 stopDirectCall(__FILE__);
     3wpframe_stop_direct_call(__FILE__);
    44
    55$action = 'new';
     
    88if(isset($_REQUEST['submit'])) {
    99    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'],
    1212                                        $_REQUEST['survey'], $_REQUEST['question']));
    1313       
     
    3333       
    3434    } 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;
    3737        print '<div id="message" class="updated fade"><p>'.t('Question added.') . '</p></div>';
    3838        $question_id = $_REQUEST['question'] = $wpdb->insert_id;
  • surveys/trunk/question_form.php

    r134220 r176325  
    11<?php
    22include('wpframe.php');
    3 stopDirectCall(__FILE__);
     3wpframe_stop_direct_call(__FILE__);
    44
    55$action = 'new';
     
    1010if($action == 'edit') {
    1111    $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']));
    1313}
    1414
     
    2323
    2424<?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();
     25wpframe_add_editor_js();
    3326?>
    3427<script type="text/javascript">
     
    4740}
    4841function 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    });
    4949    jQuery("#post").submit(function(e) {
    5050        // Make sure question is suplied
     
    102102<label for="allow_user_answer"><?php e('Allow User Inputed Answers') ?></label>
    103103<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
    104114<label for="allow_multiple_answers"><?php e('Allow Multiple Answers') ?></label>
    105115<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  
    55Requires at least: 2.5
    66Tested up to: 2.8
    7 Stable tag: 1.01.3
     7Stable tag: 1.01.4
    88
    99The 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.
     
    4343
    4444= 1.01.1 =
    45 * Bugfix relase - fixed some bugs that I will notice only after the resease has been made.
     45* Bugfix relase - fixed some bugs that I will notice only after the release has been made.
    4646
    4747= 1.01.2 =
     
    5353* Made the admin forms a bit more easier on the eye.
    5454* 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  
    11<?php
    22include('wpframe.php');
    3 stopDirectCall(__FILE__);
     3wpframe_stop_direct_call(__FILE__);
    44
    55$colors = array('bf1a1d', 'bfa024', '830088', '3e4cb9', '52803b', '805b6f', '827f71', '4bc0e0', 'c12a8f', '000000');
     
    3131$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
    3232    FROM {$wpdb->prefix}surveys_answer AS A WHERE A.question_ID=%d ORDER BY A.sort_order", $question->ID));
     33
     34if(count($answers)) {
    3335?>
    3436<table class="widefat">
     
    6668<strong>Total Votes: <?=$total?></strong><br /><hr />
    6769
    68 <?php } ?>
     70<?php } else { ?>
     71<p>User inputed answers. Use the <a href="edit.php?page=surveys/individual_responses.php&amp;survey=<?php echo $survey_id ?>">Individual Responses</a> section to see the answers to this question.</p>
     72<hr />
     73<?php }
     74
     75} ?>
     76
    6977<a href="edit.php?page=surveys/survey.php">Manage Surveys</a>
    7078</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;
     1var survey_current_question = 1;
     2var survey_questions_per_page = 1;
     3var survey_total_questions = 0;
     4var survey_current_page = 1;
    55
    66function nextQuestion(e) {
    7     if(questions_per_page != 0) return nextPage(e); // Multi question per page
     7    if(survey_questions_per_page != 0) return nextPage(e); // Multi question per page
    88    var answered = false;
    99   
    10     jQuery("#question-" + current_question + " .answer").each(function(i) {
     10    jQuery("#question-" + survey_current_question + " .answer").each(function(i) {
    1111        if(this.checked) {
    1212            answered = true;
     
    2222    }
    2323   
    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();
    2727   
    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();
    3131    }
    3232}
    3333
    3434function nextPage(e) {
    35     current_page++;
     35    survey_current_page++;
    3636    showNextXQuestions();
    3737}
    3838
    3939function showNextXQuestions() {
    40     jQuery(".question").hide();
     40    jQuery(".survey-question").hide();
    4141   
    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;
    4444    for(var i = from_question; i <= to_question; i++) {
    4545        jQuery("#question-" + i).show();
    4646    }
    4747   
    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();
    5151    }
    5252}
    5353
    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();
     54function 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();
    5959        showNextXQuestions();
    6060   
    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();
    6565   
    6666    } else {
     
    6868    }
    6969   
    70     jQuery("#next-question").click(nextQuestion);
     70    jQuery("#survey-next-question").click(nextQuestion);
    7171}
    7272
    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 }
     73jQuery(document).ready(surveyInit);
  • surveys/trunk/show_individual_response.php

    r134220 r176325  
    11<?php
    22include('wpframe.php');
    3 stopDirectCall(__FILE__);
     3wpframe_stop_direct_call(__FILE__);
    44
    55$result_id = $_REQUEST['result'];
    66
    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");
    88
    99print "<div class='wrap'><h2>" . t('Response to ') . stripslashes($survey->name) . "</h2>";
    1010print "<h4>";
    11 if($survey->rname) print t('By ') . stripslashes($survey->rname) . t(' on ');
    12 else print t('On ');
     11if($survey->rname) print t('By ') . stripslashes($survey->rname);
     12if($survey->email) print "(". stripslashes($survey->email) . ")";
     13print t(' On ');
    1314print date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($survey->added_on)) . "</h4>";
    1415
    15 $questions = $wpdb->get_results("SELECT ID, question FROM {$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}");
    1617
    1718foreach($questions as $q) {
     
    2930   
    3031    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    }
    3238    print "</strong>\n<br /><hr />";
    3339}
  • surveys/trunk/show_survey.php

    r134220 r176325  
    11<?php
    22include('wpframe.php');
    3 stopDirectCall(__FILE__);
     3wpframe_stop_direct_call(__FILE__);
     4
     5if(!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
    49global $wpdb;
    510
    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));
    712
    813if(isset($_POST['action']) and $_POST['action']) { // Save the survey
     
    1217       
    1318    } 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')));
    1420        $wpdb->query($wpdb->prepare("INSERT INTO {$wpdb->prefix}surveys_result (survey_ID, added_on) VALUES(%d, NOW())", $survey_id));
    1521        $result_id = $wpdb->insert_id;
    16        
     22
    1723        $question_count = 0;
    1824        foreach($_POST['question_id'] as $question_id) {
     
    2228           
    2329            } else {
    24             foreach($_POST['answer-' . $question_id] as $answer_id) {
     30                foreach($_POST['answer-' . $question_id] as $answer_id) {
    2531                $user_answer = '';
    2632               
     
    3541               
    3642                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                }
    3844            }
    3945            $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
    4082        }
    4183       
     
    4385        ?>
    4486        <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 />
    4789            <input type="submit" name="action" id="action-button" value="<?php e("Submit Survey") ?>"  />
    4890            <input type="hidden" name="result_id" value="<?php echo $result_id ?>" />
     
    73115
    74116foreach ($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";
    77119    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");
    79121   
    80122    $type = ($ques->allow_multiple_answers) ? 'checkbox' : 'radio'; //If this is a multi answer question, make it a checkbox. Else, it will be a radio.
    81123    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 />";
    82126   
    83127    foreach ($all_answers as $ans) {
     
    88132    if($ques->allow_user_answer) {
    89133        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";
    91143    }
    92144   
     
    96148
    97149?><br />
    98 <input type="button" id="next-question" value="<?php e("Next") ?> &gt;"  /><br />
     150<input type="button" id="survey-next-question" value="<?php e("Next") ?> &gt;"  /><br />
    99151
    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") ?>"  />
    101153<input type="hidden" name="survey_id" value="<?php echo $survey_id ?>" />
    102154</form>
    103155
    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>
    105157</div>
    106158
    107159<?php }
    108160}
     161}
    109162?>
  • surveys/trunk/style.css

    r115755 r176325  
    1 .question, #action-button {
     1.survey-question, #action-button {
    22    display:none;
    33}
     
    77}
    88
    9 .multi-question .question {
     9.multi-question .survey-question {
    1010    display:block;
    1111    padding-bottom:5px;
  • surveys/trunk/survey.php

    r115755 r176325  
    11<?php
    22include('wpframe.php');
    3 stopDirectCall(__FILE__);
     3wpframe_stop_direct_call(__FILE__);
    44
    55if($_REQUEST['message'] == 'updated') {
  • surveys/trunk/survey_form.php

    r134220 r176325  
    11<?php
    22include('wpframe.php');
    3 stopDirectCall(__FILE__);
     3wpframe_stop_direct_call(__FILE__);
    44
    55$action = 'new';
     
    1616<input type="hidden" id="title" name="ignore_me" value="This is here for a workaround for a editor bug" />
    1717
    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(); ?>
    2919
    3020<form name="post" action="<?php echo $wpframe_plugin_folder?>/survey_action.php" method="post" id="post">
  • surveys/trunk/surveys.php

    r134220 r176325  
    44Plugin URI: http://www.bin-co.com/tools/wordpress/plugins/surveys/
    55Description: 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.3
     6Version: 1.01.4
    77Author: Binny V A
    88Author URI: http://www.binnyva.com/
    99*/
    10 require_once('wpframe.php');
    1110
    1211/**
     
    1514add_action( 'admin_menu', 'surveys_add_menu_links' );
    1615function surveys_add_menu_links() {
    17     global $wp_version;
     16    global $wp_version, $_registered_pages;
    1817    $view_level= 2;
    1918    $page = 'edit.php';
    2019    if($wp_version >= '2.7') $page = 'tools.php';
    2120   
    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    }
    2428}
    2529
     
    2731 * 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.
    2832 */
    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         }
     33add_shortcode( 'SURVEYS', 'surveys_shortcode' );
     34function 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();
    4443    }
    45     return $body;
     44    return $contents;
    4645}
    4746
     
    4948add_action('admin_menu', 'surveys_option_page');
    5049function 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');
    5251}
    5352function surveys_options() {
    54     if ( function_exists('current_user_can') && !current_user_can('manage_options') ) die(t('Cheatin&#8217; 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') );
    5655
    5756    require(ABSPATH. '/wp-content/plugins/surveys/options.php');
  • surveys/trunk/wpframe.php

    r134220 r176325  
    1313//* :DEBUG: */ $GLOBALS['wpdb']->show_errors();
    1414
    15 if(!function_exists('stopDirectCall')) { //Make sure multiple plugins can be created using WPFrame
     15if(!function_exists('wpframe_add_editor_js')) { //Make sure multiple plugins can be created using WPFrame
    1616
    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
     18function 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');
    2529}
    2630
    2731/// Make sure that the user don't call this file directly - forces the use of the WP interface
    28 function stopDirectCall($file) {
     32function wpframe_stop_direct_call($file) {
    2933    if(preg_match('#' . basename($file) . '#', $_SERVER['PHP_SELF'])) die('Don\'t call this page directly.'); // Stop direct call
    3034}
    3135
    3236/// Shows a message in the admin interface of Wordpress
    33 function showMessage($message, $type='updated') {
     37function wpframe_message($message, $type='updated') {
    3438    if($type == 'updated') $class = 'updated fade';
    3539    elseif($type == 'error') $class = 'updated error';
Note: See TracChangeset for help on using the changeset viewer.