/** * Support for i18n with wpml, polyglot or qtrans * * @param string $in * @param string $name (optional) required for wpml to determine the type of translation * @return string $in localized */ static function i18n($in, $name = null) { if (function_exists('langswitch_filter_langs_with_message')) { $in = langswitch_filter_langs_with_message($in); } if (function_exists('polyglot_filter')) { $in = polyglot_filter($in); } if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) { $in = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($in); } if (is_string($name) && !empty($name) && function_exists('icl_translate')) { $in = icl_translate('plugin_ngg', $name, $in, true); } $in = apply_filters('localization', $in); return $in; }
function internationalize($in) { if (function_exists('langswitch_filter_langs_with_message')) { $in = langswitch_filter_langs_with_message($in); } if (function_exists('polyglot_filter')) { $in = polyglot_filter($in); } if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) { $in = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($in); } $in = apply_filters('localization', $in); return $in; }
//$forever=$question['question_forever']; //if($forever != '') //$extra_options = explode(",", $forever); echo '<br /><select name="option[' . $question['question_id'] . '][0]" style="width:90%">'; echo '<option value="' . __('No response recorded', 'wp-surveys') . '">-- ' . __('Select an answer below', 'wp-surveys') . '</option>'; for ($q = 0; $q < 10; $q++) { $option = "question_option_" . $q; if ($question[$option] != '') { print "<option value='" . $question[$option] . "'"; if ($_POST['option'][$question['question_id']][0] == $question[$option]) { echo ' selected="selected">'; } else { echo '>'; } if ($polyglot) { print stripcslashes(polyglot_filter($question[$option])) . "</option>\n"; } elseif (!$polyglot) { print stripcslashes($question[$option]) . "</option>\n"; } } } /*if(isset($extra_options)) { foreach($extra_options as $option) { print("<option value=\"".trim($option)."\" "); print(" >"); print("".trim( stripcslashes ($option) )."</option>\n"); } }*/ echo '</select><br /><br />'; } /*if($question['question_type']=="mul-vert") {
function lang_picker($text) { return polyglot_filter($text); }
function manage_surveys() { global $table_prefix, $wpdb; $survey_table = $table_prefix . "surveys"; if (isset($_REQUEST["wpsurv_submit"])) { require_once 'functions.php'; if ($_POST["wpsurv_submit"] == __('Edit', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Cancel', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Back to Edit Survey', 'wp-surveys')) { edit($_POST['survey_id']); } elseif ($_POST["wpsurv_submit"] == __('Update', 'wp-surveys')) { update($_POST['survey_id']); } elseif ($_POST["wpsurv_submit"] == __('Update Options', 'wp-surveys')) { update_options($_POST['survey_id'], $_POST['question_id']); } elseif ($_POST["wpsurv_submit"] == __('Activate', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Make Active', 'wp-surveys')) { activate($_POST['survey_id']); } elseif ($_POST["wpsurv_submit"] == __('Retire', 'wp-surveys')) { retire($_POST['survey_id']); } elseif ($_POST["wpsurv_submit"] == __('Update Leaderboard', 'wp-surveys')) { recach_utility($_POST['survey_id']); } elseif ($_POST["wpsurv_submit"] == __('Edit Options', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Add Some Options', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Edit or Add more Options', 'wp-surveys')) { edit_options($_POST['survey_id'], $_POST['question_id']); } elseif ($_POST["wpsurv_submit"] == __('Add More Questions', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Add Some Questions', 'wp-surveys')) { add_question($_POST['survey_id']); } elseif ($_POST["wpsurv_submit"] == __('Step 2', 'wp-surveys')) { step2($_POST['survey_id']); } elseif ($_POST["wpsurv_submit"] == __('Create Question', 'wp-surveys')) { create_quest($_POST['survey_id']); } elseif ($_POST["wpsurv_submit"] == __('Change Survey', 'wp-surveys') || $_POST["wpsurv_submit"] == __('Add Survey', 'wp-surveys')) { survey($_POST['survey_id']); } elseif ($_POST["wpsurv_submit"] == __('Add This Survey', 'wp-surveys')) { add_survey($_POST['survey_id']); } elseif ($_POST["wpsurv_submit"] == __('View Survey Results', 'wp-surveys')) { results($_POST['survey_id']); } //elseif($_POST["wpsurv_submit"] == __('View Survey Results in CSV File', 'wp-surveys')) //results_CSV($_POST['survey_id']); //elseif($_POST["wpsurv_submit"] == __('Delete File', 'wp-surveys')) //delete_file($_POST['survey_id']); } else { $current_plugins = get_option('active_plugins'); if (file_exists(ABSPATH . PLUGINDIR . '/polyglot.php') && in_array('polyglot.php', $current_plugins)) { $polyglot = true; } echo '<div class="wrap">'; $open_surveys = $wpdb->get_results("SELECT * FROM `" . $survey_table . "` WHERE `survey_open`='1' LIMIT 1;", ARRAY_A); echo '<h2>' . __('Survey Management', 'wp-surveys') . '</h2><h3><u>' . __('Active Survey', 'wp-surveys') . '</u>:</h3>'; if ($open_surveys) { echo '<table class="widefat" width="100%" cellpadding="4" cellspacing="4">'; echo '<tr><th align="left">' . __('Title', 'wp-surveys') . '</th><th align="left">' . __('Description', 'wp-surveys') . '</th><th></th><th></th><th></th></tr>'; foreach ($open_surveys as $survey) { echo '<tr class="alternate">'; if ($polyglot) { echo '<td><b>' . polyglot_filter(stripcslashes($survey['survey_name'])) . '</b></td><td>' . polyglot_filter(stripcslashes($survey['survey_describe'])) . '</td>'; } elseif (!$polyglot) { echo '<td><b>' . stripcslashes($survey['survey_name']) . '</b></td><td>' . stripcslashes($survey['survey_describe']) . '</td>'; } echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />'; echo '<input type="submit" name="wpsurv_submit" value="' . __('Edit', 'wp-surveys') . '" /></form></td>'; echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />'; echo '<input type="submit" name="wpsurv_submit" value="' . __('Retire', 'wp-surveys') . '" /></form></td>'; echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />'; echo '<input type="submit" name="wpsurv_submit" value="' . __('View Survey Results', 'wp-surveys') . '" /></form></td>'; //echo '<td align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="'.$survey['survey_id'].'" />'; //echo '<input type="submit" name="wpsurv_submit" value="'.__('View Survey Results in CSV File', 'wp-surveys').'" /></form></td>'; echo '</tr>'; } echo '</table>'; $next = ++$survey['survey_id']; echo '<br /><form method="post" action=""><input type="hidden" name="survey_id" value="' . $next . '" /><input class="button" type="submit" name="wpsurv_submit" value="' . __('Change Survey', 'wp-surveys') . '" title="' . __('Current Survey will be saved as Retired', 'wp-surveys') . '" /></form>'; } else { echo __('There are no open tournaments or contests.', 'wp-surveys') . '.'; //$last = $wpdb->get_var("SELECT COUNT(`survey_id`) FROM `".$survey_table."`;"); $last = $wpdb->get_var("SELECT `survey_id` FROM `" . $survey_table . "` ORDER BY `survey_id` DESC LIMIT 1;"); $next = ++$last; echo '<br /><br /><form method="post" action=""><input type="hidden" name="survey_id" value="' . $next . '" /><input class="button" type="submit" name="wpsurv_submit" value="' . __('Add Survey', 'wp-surveys') . '" /></form>'; } $closed_surveys = $wpdb->get_results("SELECT * FROM `" . $survey_table . "` WHERE `survey_open`='0';", ARRAY_A); echo '<h3><u>' . __('Retired Surveys', 'wp-surveys') . '</u>:</h3>'; if ($closed_surveys) { echo '<table class="widefat" width="100%" cellpadding="4" cellspacing="4">'; echo '<tr><th align="left">' . __('Title', 'wp-surveys') . '</th><th align="left">' . __('Description', 'wp-surveys') . '</th><th></th><th></th><th></th></tr>'; foreach ($closed_surveys as $survey) { echo '<tr class="alternate">'; if ($polyglot) { echo '<td><b>' . polyglot_filter(stripcslashes($survey['survey_name'])) . '</b></td><td>' . polyglot_filter(stripcslashes($survey['survey_describe'])) . '</td>'; } elseif (!$polyglot) { echo '<td><b>' . stripcslashes($survey['survey_name']) . '</b></td><td>' . stripcslashes($survey['survey_describe']) . '</td>'; } echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />'; echo '<input type="submit" name="wpsurv_submit" value="' . __('Edit', 'wp-surveys') . '" /></form></td>'; echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />'; echo '<input type="submit" name="wpsurv_submit" value="' . __('Make Active', 'wp-surveys') . '" /></form></td>'; echo '<td class="submit" align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey['survey_id'] . '" />'; echo '<input type="submit" name="wpsurv_submit" value="' . __('View Survey Results', 'wp-surveys') . '" /></form></td>'; //echo '<td align="center"><form method="post" action=""><input type="hidden" name="survey_id" value="'.$survey['survey_id'].'" />'; //echo '<input type="submit" name="wpsurv_submit" value="'.__('View Survey Results in CSV File', 'wp-surveys').'" /></form></td>'; echo '</tr>'; } echo '</table>'; } else { echo __('There are no retired surveys', 'wp-surveys') . '.'; } echo '</div>'; } }
function results($survey_id) { global $table_prefix, $wpdb; $survey_table = $table_prefix . "surveys"; $question_table = $table_prefix . "surveys_questions"; $data_table = $table_prefix . "surveys_data"; $questions = $wpdb->get_results("SELECT * FROM `" . $question_table . "` WHERE `survey_id`=" . $survey_id . ";", ARRAY_A); if ($questions) { echo '<div class="wrap">'; echo '<h2>' . __('Your Survey Results', 'wp-surveys') . '</h2>'; echo '<p align="right"><a href="http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '" >' . __('Go back!', 'wp-surveys') . '</a></p>'; echo '<table class="widefat" id="the-list-x" width="100%" cellpadding="4" cellspacing="4">'; $current_plugins = get_option('active_plugins'); if (file_exists(ABSPATH . PLUGINDIR . '/polyglot.php') && in_array('polyglot.php', $current_plugins)) { $polyglot = true; } foreach ($questions as $question) { if ($question['question_type'] == 'one-vert' || $question['question_type'] == 'one-hori' || $question['question_type'] == 'one-menu' || $question['question_type'] == 'mul-vert' || $question['question_type'] == 'mul-hori') { $all_responses = array("RESPONSESARRAY"); $response_data = $wpdb->get_results("SELECT data_option FROM " . $data_table . " WHERE question_id = " . $question['question_id'] . " ORDER BY data_option", ARRAY_A); if ($response_data) { foreach ($response_data as $responses) { $mash_up = $responses['data_option']; if ($mash_up) { $these_responses = explode("|", $mash_up); foreach ($these_responses as $response) { array_push($all_responses, trim($response)); } } } } $dropt = array_shift($all_responses); $first_options = array("OPTIONARRAY"); $score_options = array("0"); $option_data = $wpdb->get_results("SELECT * FROM " . $question_table . " WHERE question_id = " . $question['question_id'], ARRAY_A); for ($o = 0; $o < 10; $o++) { $option = "question_option_" . $o; if ($option_data[0][$option]) { $first_options[] = $option_data[0][$option]; array_push($score_options, "0"); } } //$forever = $option_data[0]['question_forever']; //if($forever != '') { //$extra_options = explode(",", $forever); //foreach($extra_options as $extra) { //array_push($first_options, trim($extra)); //array_push($score_options, "0"); //} //} array_push($first_options, __('No response recorded', 'wp-surveys')); array_push($score_options, "0"); $all_options = $first_options; foreach ($all_responses as $count_response) { $key = array_search(trim($count_response), $all_options); if ($key) { $score_options[$key]++; } } $running = 0; $totalscore = 0; foreach ($score_options as $scores) { $totalscore = $totalscore + $scores; } if ($polyglot) { echo '<tr class="alternate"><td><u>' . __('Question', 'wp-surveys') . '</u>: <strong>' . polyglot_filter($question['question_name']) . '</strong></td>'; } elseif (!$polyglot) { echo '<tr class="alternate"><td><strong>' . $question['question_name'] . '</strong></td>'; } $current_quest = $wpdb->get_results("SELECT * FROM `" . $question_table . "` WHERE `question_id`=" . $question['question_id'] . ";", ARRAY_A); $empty_opts = 0; for ($j = 0; $j < 10; $j++) { $opt = 'question_option_' . $j; if ($current_quest[0][$opt] == '') { $empty_opts++; } } if ($empty_opts < 10) { echo '<td class="alternate"><strong>'; printf(__('%s responses', 'wp-surveys'), $totalscore); echo '</strong></td></tr>'; foreach ($all_options as $this_option) { if ($score_options[$running] > 0) { if ($polyglot) { echo '<tr><td>' . polyglot_filter($this_option) . '</td><td>' . $score_options[$running] . ' / ' . $totalscore . '</td></tr>'; } elseif (!$polyglot) { echo '<tr><td>' . $this_option . '</td><td>' . $score_options[$running] . ' / ' . $totalscore . '</td></tr>'; } } $running++; } } elseif ($empty_opts == 10) { echo '<form method="post" action="">'; echo '<input type="hidden" name="survey_id" value="' . $survey_id . '" />'; echo '<input type="hidden" name="question_id" value="' . $question['question_id'] . '" />'; echo '<td class="submit"><strong>' . __('No option(s) defined yet', 'wp-surveys') . '...</strong> '; echo '<input type="submit" name="wpsurv_submit" value="' . __('Add Some Options', 'wp-surveys') . '" /></form>'; echo '</td></tr>'; } } //if($question['question_type']=='open-more' || $question['question_type']=='open-onep' || $question['question_type']=='one-essa') { //echo '<tr><td><strong>'.$question['question_name'].'</strong></td><td></td></tr>'; //if(!is_null($response_data)) { //foreach($response_data as $responses) { //if($score_options[$running] != __('No Response Recorded', 'wp-surveys')) //echo '<tr><td>'.trim($responses['data_option']).'</td><td></td></tr>'; //} //} //} } echo '</table>'; echo '<p align="right"><a href="http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '" >' . __('Go back!', 'wp-surveys') . '</a></p>'; echo '</div>'; } elseif (!$questions) { echo '<form method="post" action=""><input type="hidden" name="survey_id" value="' . $survey_id . '" />'; echo '<div id="message" class="updated fade"><h3><strong>' . __('There are no Question defined yet', 'wp-surveys') . '</strong></h3>'; echo '<p class="submit"><input type="submit" name="wpsurv_submit" value="' . __('Add Some Questions', 'wp-surveys') . '" /></p></form>'; echo '<p><a href="http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] . '" >' . __('Go back!', 'wp-surveys') . '</a></p></div>'; } }
function internationalize($in) { if (function_exists('langswitch_filter_langs_with_message')) { $in = langswitch_filter_langs_with_message($in); } if (function_exists('polyglot_filter')) { $in = polyglot_filter($in); } return $in; }