| 43 | | $pollq_timestamp_day = intval($_POST['pollq_timestamp_day']); |
|---|
| 44 | | $pollq_timestamp_month = intval($_POST['pollq_timestamp_month']); |
|---|
| 45 | | $pollq_timestamp_year = intval($_POST['pollq_timestamp_year']); |
|---|
| 46 | | $pollq_timestamp_hour = intval($_POST['pollq_timestamp_hour']); |
|---|
| 47 | | $pollq_timestamp_minute = intval($_POST['pollq_timestamp_minute']); |
|---|
| 48 | | $pollq_timestamp_second = intval($_POST['pollq_timestamp_second']); |
|---|
| 49 | | $pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year); |
|---|
| 50 | | if($pollq_timestamp > current_time('timestamp')) { |
|---|
| 51 | | $pollq_active = -1; |
|---|
| 52 | | } else { |
|---|
| 53 | | $pollq_active = 1; |
|---|
| 54 | | } |
|---|
| | 51 | if($edit_polltimestamp == 1) { |
|---|
| | 52 | $pollq_timestamp_day = intval($_POST['pollq_timestamp_day']); |
|---|
| | 53 | $pollq_timestamp_month = intval($_POST['pollq_timestamp_month']); |
|---|
| | 54 | $pollq_timestamp_year = intval($_POST['pollq_timestamp_year']); |
|---|
| | 55 | $pollq_timestamp_hour = intval($_POST['pollq_timestamp_hour']); |
|---|
| | 56 | $pollq_timestamp_minute = intval($_POST['pollq_timestamp_minute']); |
|---|
| | 57 | $pollq_timestamp_second = intval($_POST['pollq_timestamp_second']); |
|---|
| | 58 | $pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year); |
|---|
| | 59 | $timestamp_sql = ", pollq_timestamp = '$pollq_timestamp'"; |
|---|
| | 60 | if($pollq_timestamp > current_time('timestamp')) { |
|---|
| | 61 | $pollq_active = -1; |
|---|
| | 62 | } |
|---|
| | 63 | } |
|---|
| | 64 | // Poll End Date |
|---|
| 69 | | } |
|---|
| 70 | | $add_poll_question = $wpdb->query("INSERT INTO $wpdb->pollsq VALUES (0, '$pollq_question', '$pollq_timestamp', 0, $pollq_active, '$pollq_expiry')"); |
|---|
| 71 | | if(!$add_poll_question) { |
|---|
| 72 | | $text .= '<font color="red">'.sprintf(__('Error In Adding Poll \'%s\'', 'wp-polls'), stripslashes($pollq_question)).'</font>'; |
|---|
| 73 | | } |
|---|
| 74 | | // Add Poll Answers |
|---|
| 75 | | $polla_answers = $_POST['polla_answers']; |
|---|
| 76 | | $polla_qid = intval($wpdb->insert_id); |
|---|
| 77 | | foreach($polla_answers as $polla_answer) { |
|---|
| 78 | | $polla_answer = addslashes(trim($polla_answer)); |
|---|
| 79 | | $add_poll_answers = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $polla_qid, '$polla_answer', 0)"); |
|---|
| 80 | | if(!$add_poll_answers) { |
|---|
| 81 | | $text .= '<font color="red">'.sprintf(__('Error In Adding Poll\'s Answer \'%s\'', 'wp-polls'), stripslashes($polla_answer)).'</font>'; |
|---|
| 82 | | } |
|---|
| 83 | | } |
|---|
| 84 | | // Update Lastest Poll ID To Poll Options |
|---|
| 85 | | $latest_pollid = polls_latest_id(); |
|---|
| 86 | | $update_latestpoll = update_option('poll_latestpoll', $latest_pollid); |
|---|
| 87 | | if(empty($text)) { |
|---|
| 88 | | $text = '<font color="green">'.__('Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\' '.__('Added Successfully', 'wp-polls').'</font>'; |
|---|
| 89 | | } |
|---|
| 90 | | break; |
|---|
| 91 | | // Edit Poll |
|---|
| 92 | | case __('Edit Poll', 'wp-polls'): |
|---|
| 93 | | // Update Poll's Question |
|---|
| 94 | | $pollq_id = intval($_POST['pollq_id']); |
|---|
| 95 | | $pollq_totalvotes = intval($_POST['pollq_totalvotes']); |
|---|
| 96 | | $pollq_question = addslashes(trim($_POST['pollq_question'])); |
|---|
| 97 | | $edit_polltimestamp = intval($_POST['edit_polltimestamp']); |
|---|
| 98 | | $timestamp_sql = ''; |
|---|
| 99 | | $pollq_active = 1; |
|---|
| 100 | | if($edit_polltimestamp == 1) { |
|---|
| 101 | | $pollq_timestamp_day = intval($_POST['pollq_timestamp_day']); |
|---|
| 102 | | $pollq_timestamp_month = intval($_POST['pollq_timestamp_month']); |
|---|
| 103 | | $pollq_timestamp_year = intval($_POST['pollq_timestamp_year']); |
|---|
| 104 | | $pollq_timestamp_hour = intval($_POST['pollq_timestamp_hour']); |
|---|
| 105 | | $pollq_timestamp_minute = intval($_POST['pollq_timestamp_minute']); |
|---|
| 106 | | $pollq_timestamp_second = intval($_POST['pollq_timestamp_second']); |
|---|
| 107 | | $pollq_timestamp = gmmktime($pollq_timestamp_hour, $pollq_timestamp_minute, $pollq_timestamp_second, $pollq_timestamp_month, $pollq_timestamp_day, $pollq_timestamp_year); |
|---|
| 108 | | $timestamp_sql = ", pollq_timestamp = '$pollq_timestamp'"; |
|---|
| 109 | | if($pollq_timestamp > current_time('timestamp')) { |
|---|
| 110 | | $pollq_active = -1; |
|---|
| 111 | | } |
|---|
| 112 | | } |
|---|
| 113 | | $pollq_expiry_no = intval($_POST['pollq_expiry_no']); |
|---|
| 114 | | if($pollq_expiry_no == 1) { |
|---|
| 115 | | $pollq_expiry = ''; |
|---|
| 116 | | } else { |
|---|
| 117 | | $pollq_expiry_day = intval($_POST['pollq_expiry_day']); |
|---|
| 118 | | $pollq_expiry_month = intval($_POST['pollq_expiry_month']); |
|---|
| 119 | | $pollq_expiry_year = intval($_POST['pollq_expiry_year']); |
|---|
| 120 | | $pollq_expiry_hour = intval($_POST['pollq_expiry_hour']); |
|---|
| 121 | | $pollq_expiry_minute = intval($_POST['pollq_expiry_minute']); |
|---|
| 122 | | $pollq_expiry_second = intval($_POST['pollq_expiry_second']); |
|---|
| 123 | | $pollq_expiry = gmmktime($pollq_expiry_hour, $pollq_expiry_minute, $pollq_expiry_second, $pollq_expiry_month, $pollq_expiry_day, $pollq_expiry_year); |
|---|
| 124 | | if($pollq_expiry <= current_time('timestamp')) { |
|---|
| 125 | | $pollq_active = 0; |
|---|
| 126 | | } |
|---|
| 162 | | // Open Poll |
|---|
| 163 | | case __('Open Poll', 'wp-polls'): |
|---|
| 164 | | $pollq_id = intval($_POST['pollq_id']); |
|---|
| 165 | | $pollq_question = addslashes(trim($_POST['pollq_question'])); |
|---|
| 166 | | $close_poll = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_active = 1 WHERE pollq_id = $pollq_id;"); |
|---|
| 167 | | if($close_poll) { |
|---|
| 168 | | $text = '<font color="green">'.__('Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\' '.__('Is Now Opened', 'wp-polls').'</font>'; |
|---|
| 169 | | } else { |
|---|
| 170 | | $text = '<font color="red">'.__('Error Opening Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\'</font>'; |
|---|
| 171 | | } |
|---|
| 172 | | break; |
|---|
| 173 | | // Close Poll |
|---|
| 174 | | case __('Close Poll', 'wp-polls'): |
|---|
| 175 | | $pollq_id = intval($_POST['pollq_id']); |
|---|
| 176 | | $pollq_question = addslashes(trim($_POST['pollq_question'])); |
|---|
| 177 | | $close_poll = $wpdb->query("UPDATE $wpdb->pollsq SET pollq_active = 0 WHERE pollq_id = $pollq_id;"); |
|---|
| 178 | | if($close_poll) { |
|---|
| 179 | | $text = '<font color="green">'.__('Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\' '.__('Is Now Closed', 'wp-polls').'</font>'; |
|---|
| 180 | | } else { |
|---|
| 181 | | $text = '<font color="red">'.__('Error Closing Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\'</font>'; |
|---|
| 182 | | } |
|---|
| 183 | | break; |
|---|
| 184 | | // Delete Poll |
|---|
| 185 | | case __('Delete Poll', 'wp-polls'): |
|---|
| 186 | | $pollq_id = intval($_POST['pollq_id']); |
|---|
| 187 | | $pollq_question = trim($_POST['pollq_question']); |
|---|
| 188 | | $delete_poll_question = $wpdb->query("DELETE FROM $wpdb->pollsq WHERE pollq_id = $pollq_id"); |
|---|
| 189 | | $delete_poll_answers = $wpdb->query("DELETE FROM $wpdb->pollsa WHERE polla_qid = $pollq_id"); |
|---|
| 190 | | $delete_poll_ip = $wpdb->query("DELETE FROM $wpdb->pollsip WHERE pollip_qid = $pollq_id"); |
|---|
| 191 | | $poll_option_lastestpoll = $wpdb->get_var("SELECT option_value FROM $wpdb->options WHERE option_name = 'poll_latestpoll'"); |
|---|
| 192 | | if(!$delete_poll_question) { |
|---|
| 193 | | $text = '<font color="red">'.sprintf(__('Error In Deleting Poll \'%s\' Question', 'wp-polls'), stripslashes($pollq_question)).'</font>'; |
|---|
| 194 | | } |
|---|
| 195 | | if(!$delete_poll_answers) { |
|---|
| 196 | | $text .= '<br /><font color="blue">'.sprintf(__('No Poll Answers For \'%s\'', 'wp-polls'), stripslashes($pollq_question)).'</font>'; |
|---|
| 197 | | } |
|---|
| 198 | | if(!$delete_poll_ip) { |
|---|
| 199 | | $text .= '<br /><font color="blue">'.sprintf(__('No Voted IPs For \'%s\'', 'wp-polls'), stripslashes($pollq_question)).'</font>'; |
|---|
| 200 | | } |
|---|
| 201 | | if(empty($text)) { |
|---|
| 202 | | $text = '<font color="green">'.__('Poll', 'wp-polls').' \''.stripslashes($pollq_question).'\' '.__('Deleted Successfully', 'wp-polls').'</font>'; |
|---|
| 203 | | } |
|---|
| 204 | | // Update Lastest Poll ID To Poll Options |
|---|
| 205 | | $latest_pollid = polls_latest_id(); |
|---|
| 206 | | $update_latestpoll = update_option('poll_latestpoll', $latest_pollid); |
|---|
| 207 | | break; |
|---|
| 208 | | // Add Poll's Answer |
|---|
| 209 | | case __('Add Answer', 'wp-polls'): |
|---|
| 210 | | $polla_qid = intval($_POST['polla_qid']); |
|---|
| 211 | | $polla_answers = addslashes(trim($_POST['polla_answers'])); |
|---|
| 212 | | $add_poll_question = $wpdb->query("INSERT INTO $wpdb->pollsa VALUES (0, $polla_qid, '$polla_answers', 0)"); |
|---|
| 213 | | if(!$add_poll_question) { |
|---|
| 214 | | $text = '<font color="red">'.sprintf(__('Error In Adding Poll Answer \'%s\'', 'wp-polls'), stripslashes($polla_answers)).'</font>'; |
|---|
| 215 | | } else { |
|---|
| 216 | | $text = '<font color="green">'.__('Poll Answer', 'wp-polls').' \''.stripslashes($polla_answers).'\' '.__('Added Successfully', 'wp-polls').'</font>'; |
|---|
| 217 | | } |
|---|
| 218 | | break; |
|---|
| 219 | | // Delete Polls Logs |
|---|
| 220 | | case __('Delete All Logs', 'wp-polls'): |
|---|
| 221 | | if(trim($_POST['delete_logs_yes']) == 'yes') { |
|---|
| 222 | | $delete_logs = $wpdb->query("DELETE FROM $wpdb->pollsip"); |
|---|
| 223 | | if($delete_logs) { |
|---|
| 224 | | $text = '<font color="green">'.__('All Polls Logs Have Been Deleted.', 'wp-polls').'</font>'; |
|---|
| 225 | | } else { |
|---|
| 226 | | $text = '<font color="red">'.__('An Error Has Occured While Deleting All Polls Logs.', 'wp-polls').'</font>'; |
|---|
| 227 | | } |
|---|
| 228 | | } |
|---|
| 229 | | break; |
|---|
| 230 | | // Delete Poll Logs For Individual Poll |
|---|
| 231 | | case __('Delete Logs For This Poll Only', 'wp-polls'): |
|---|
| 232 | | $pollq_id = intval($_POST['pollq_id']); |
|---|
| 233 | | if(trim($_POST['delete_logs_yes']) == 'yes') { |
|---|
| 234 | | $delete_logs = $wpdb->query("DELETE FROM $wpdb->pollsip WHERE pollip_qid = $pollq_id"); |
|---|
| 235 | | if($delete_logs) { |
|---|
| 236 | | $text = '<font color="green">'.__('All Logs For This Poll Have Been Deleted.', 'wp-polls').'</font>'; |
|---|
| 237 | | } else { |
|---|
| 238 | | $text = '<font color="red">'.__('An Error Has Occured While Deleting All Logs For This Poll.', 'wp-polls').'</font>'; |
|---|
| 239 | | } |
|---|
| 240 | | } |
|---|
| 241 | | break; |
|---|
| 242 | | // Uninstall WP-Polls (By: Philippe Corbes) |
|---|
| 243 | | case __('UNINSTALL Polls', 'wp-polls') : |
|---|
| 244 | | if(trim($_POST['uninstall_poll_yes']) == 'yes') { |
|---|
| 245 | | echo '<div id="message" class="updated fade"><p>'; |
|---|
| 246 | | $polls_tables = array($wpdb->pollsq, $wpdb->pollsa, $wpdb->pollsip); |
|---|
| 247 | | foreach($polls_tables as $table) { |
|---|
| 248 | | $wpdb->query("DROP TABLE {$table}"); |
|---|
| 249 | | echo '<font color="green">'; |
|---|
| 250 | | printf(__('Table "%s" Has Been Dropped.', 'wp-polls'), "<strong><em>{$table}</em></strong>"); |
|---|
| 251 | | echo '</font><br />'; |
|---|
| 252 | | } |
|---|
| 253 | | $polls_settings = array('poll_template_voteheader', 'poll_template_votebody', 'poll_template_votefooter', 'poll_template_resultheader', |
|---|
| 254 | | 'poll_template_resultbody', 'poll_template_resultbody2', 'poll_template_resultfooter', 'poll_template_resultfooter2', |
|---|
| 255 | | 'poll_template_disable', 'poll_template_error', 'poll_currentpoll', 'poll_latestpoll', |
|---|
| 256 | | 'poll_archive_perpage', 'poll_ans_sortby', 'poll_ans_sortorder', 'poll_ans_result_sortby', |
|---|
| 257 | | 'poll_ans_result_sortorder', 'poll_logging_method', 'poll_allowtovote', 'poll_archive_show', |
|---|
| 258 | | 'poll_archive_url', 'poll_bar', 'poll_close'); |
|---|
| 259 | | foreach($polls_settings as $setting) { |
|---|
| 260 | | $delete_setting = delete_option($setting); |
|---|
| 261 | | if($delete_setting) { |
|---|
| 262 | | echo '<font color="green">'; |
|---|
| 263 | | printf(__('Setting Key \'%s\' Has been Errased.', 'wp-polls'), "<strong><em>{$setting}</em></strong>"); |
|---|
| 264 | | } else { |
|---|
| 265 | | echo '<font color="red">'; |
|---|
| 266 | | printf(__('Error Deleting Setting Key \'%s\'.', 'wp-polls'), "<strong><em>{$setting}</em></strong>"); |
|---|
| 267 | | } |
|---|
| 268 | | echo '</font><br />'; |
|---|
| 269 | | } |
|---|
| 270 | | echo '</p></div>'; |
|---|
| 271 | | $mode = 'end-UNINSTALL'; |
|---|
| 272 | | } |
|---|
| 273 | | break; |
|---|
| 280 | | // Add A Poll |
|---|
| 281 | | case 'add': |
|---|
| 282 | | ?> |
|---|
| 283 | | <script type="text/javascript"> |
|---|
| 284 | | /* <![CDATA[*/ |
|---|
| 285 | | function check_pollexpiry() { |
|---|
| 286 | | poll_expiry = document.getElementById("pollq_expiry_no").checked; |
|---|
| 287 | | if(poll_expiry) { |
|---|
| 288 | | document.getElementById("pollq_expiry").style.display = 'none'; |
|---|
| 289 | | } else { |
|---|
| 290 | | document.getElementById("pollq_expiry").style.display = 'block'; |
|---|
| 291 | | } |
|---|
| 292 | | } |
|---|
| 293 | | /* ]]> */ |
|---|
| 294 | | </script> |
|---|
| 295 | | <div class="wrap"> |
|---|
| 296 | | <h2><?php _e('Add Poll', 'wp-polls'); ?></h2> |
|---|
| 297 | | <?php |
|---|
| 298 | | if(isset($_POST['addpollquestion'])) { |
|---|
| 299 | | $poll_noquestion = intval($_POST['poll_noquestion']); |
|---|
| 300 | | $pollq_question = stripslashes(trim($_POST['pollq_question'])); |
|---|
| 301 | | ?> |
|---|
| 302 | | <form action="<?php echo $base_page; ?>" method="post"> |
|---|
| 303 | | <table width="100%" border="0" cellspacing="3" cellpadding="3"> |
|---|
| 304 | | <tr class="thead"> |
|---|
| 305 | | <th align="left"><?php _e('Question', 'wp-polls') ?></th> |
|---|
| 306 | | <td><input type="text" size="50" maxlength="200" name="pollq_question" value="<?php echo htmlspecialchars($pollq_question); ?>" /></td> |
|---|
| 307 | | </tr> |
|---|
| 308 | | <?php |
|---|
| 309 | | $count = 0; |
|---|
| 310 | | for($i=1; $i<=$poll_noquestion; $i++) { |
|---|
| 311 | | if($i%2 == 0) { |
|---|
| 312 | | $style = 'style=\'background-color: #eee;\''; |
|---|
| 313 | | } else { |
|---|
| 314 | | $style = 'style=\'background: none;\''; |
|---|
| 315 | | } |
|---|
| 316 | | echo "<tr $style>\n"; |
|---|
| 317 | | echo "<th align=\"left\" scope=\"row\">Answers $i:</th>\n"; |
|---|
| 318 | | echo "<td><input type=\"text\" size=\"30\" maxlength=\"200\" name=\"polla_answers[]\" /></td>\n"; |
|---|
| 319 | | echo "</tr>\n"; |
|---|
| 320 | | $count++; |
|---|
| 321 | | } |
|---|
| 322 | | ?> |
|---|
| 323 | | <tr style="<?php if($count%2 == 0) { echo 'background: none;'; } else { echo 'background-color: #eee;' ;} $count++; ?>"> |
|---|
| 324 | | <th align="left"><?php _e('Start Date/Time:', 'wp-polls') ?></th> |
|---|
| 325 | | <td> |
|---|
| 326 | | <?php |
|---|
| 327 | | poll_timestamp(current_time('timestamp')); |
|---|
| 328 | | ?> |
|---|
| 329 | | </td> |
|---|
| 330 | | </tr> |
|---|
| 331 | | <tr style="<?php if($count%2 == 0) { echo 'background: none;'; } else { echo 'background-color: #eee;' ;} ?>"> |
|---|
| 332 | | <th valign="top" align="left"><?php _e('End Date/Time:', 'wp-polls') ?></th> |
|---|
| 333 | | <td> |
|---|
| 334 | | <input type="checkbox" name="pollq_expiry_no" id="pollq_expiry_no" value="1" checked="checked" onclick="check_pollexpiry();" /> <label for="pollq_expiry_no"><?php _e('Do NOT Expire This Poll', 'wp-polls'); ?></label> |
|---|
| 335 | | <?php |
|---|
| 336 | | poll_timestamp(current_time('timestamp'), 'pollq_expiry', 'none'); |
|---|
| 337 | | ?> |
|---|
| 338 | | </td> |
|---|
| 339 | | </tr> |
|---|
| 340 | | <tr> |
|---|
| 341 | | <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Add Poll', 'wp-polls'); ?>" class="button" /> <input type="button" name="cancel" value="<?php _e('Cancel', 'wp-polls'); ?>" class="button" onclick="javascript:history.go(-1)" /></td> |
|---|
| 342 | | </tr> |
|---|
| 343 | | </table> |
|---|
| 344 | | </form> |
|---|
| 345 | | <?php } else {?> |
|---|
| 346 | | <form action="<?php echo $_SERVER['REQUEST_URI']; ?>&mode=add" method="post"> |
|---|
| 347 | | <table width="100%" border="0" cellspacing="3" cellpadding="3"> |
|---|
| 348 | | <tr> |
|---|
| 349 | | <th align="left"><?php _e('Question', 'wp-polls') ?></th> |
|---|
| 350 | | <td><input type="text" size="50" maxlength="200" name="pollq_question" /></td> |
|---|
| 351 | | </tr> |
|---|
| 352 | | <tr> |
|---|
| 353 | | <th align="left"><?php _e('No. Of Answers:', 'wp-polls') ?></th> |
|---|
| 354 | | <td> |
|---|
| 355 | | <select size="1" name="poll_noquestion"> |
|---|
| 356 | | <?php |
|---|
| 357 | | for($i=2; $i <= 20; $i++) { |
|---|
| 358 | | echo "<option value=\"$i\">$i</option>"; |
|---|
| 359 | | } |
|---|
| 360 | | ?> |
|---|
| 361 | | </select> |
|---|
| 362 | | </td> |
|---|
| 363 | | </tr> |
|---|
| 364 | | <tr> |
|---|
| 365 | | <td colspan="2" align="center"><input type="submit" name="addpollquestion" value="<?php _e('Add Question', 'wp-polls'); ?>" class="button" /> <input type="button" name="cancel" value="<?php _e('Cancel', 'wp-polls'); ?>" class="button" onclick="javascript:history.go(-1)" /></td> |
|---|
| 366 | | </tr> |
|---|
| 367 | | </table> |
|---|
| 368 | | </form> |
|---|
| 369 | | <?php } ?> |
|---|
| 370 | | </div> |
|---|
| 371 | | <?php |
|---|
| 372 | | break; |
|---|
| | 173 | function check_pollexpiry() { |
|---|
| | 174 | pollq_expiry_no = document.getElementById("pollq_expiry_no").checked; |
|---|
| | 175 | if(pollq_expiry_no) { |
|---|
| | 176 | document.getElementById("pollq_expiry_timestamp").style.display = 'none'; |
|---|
| | 177 | } else { |
|---|
| | 178 | document.getElementById("pollq_expiry_timestamp").style.display = 'block'; |
|---|
| | 179 | } |
|---|
| | 180 | } |
|---|
| | 181 | var count_poll_answer = <?php echo $poll_noquestion; ?>; |
|---|
| | 182 | var count_poll_answer_new = 0; |
|---|
| | 183 | function create_poll_answer() { |
|---|
| | 184 | // Create Elements |
|---|
| | 185 | var poll_tr = document.createElement("tr"); |
|---|
| | 186 | var poll_td1 = document.createElement("td"); |
|---|
| | 187 | var poll_td2 = document.createElement("td"); |
|---|
| | 188 | var poll_td3 = document.createElement("td"); |
|---|
| | 189 | var poll_answer = document.createElement("input"); |
|---|
| | 190 | var poll_votes = document.createElement("input"); |
|---|
| | 191 | var poll_answer_count = document.createTextNode("<?php _e('Answer', 'wp-polls'); ?> " + (count_poll_answer+1) + ":"); |
|---|
| | 192 | var poll_votes_count = document.createTextNode("0 "); |
|---|
| | 193 | var poll_answer_bold = document.createElement("strong"); |
|---|
| | 194 | count_poll_answer++; |
|---|
| | 195 | count_poll_answer_new++; |
|---|
| | 196 | // Elements - Input |
|---|
| | 197 | poll_answer.setAttribute('type', "text"); |
|---|
| | 198 | poll_answer.setAttribute('name', "polla_answers_new[]"); |
|---|
| | 199 | poll_answer.setAttribute('size', "50"); |
|---|
| | 200 | poll_votes.setAttribute('type', "text"); |
|---|
| | 201 | poll_votes.setAttribute('size', "4"); |
|---|
| | 202 | poll_votes.setAttribute('value', "0"); |
|---|
| | 203 | // Elements - TD/TR |
|---|
| | 204 | if(count_poll_answer%2 != 0) { poll_tr.style.background = "#eee"; } |
|---|
| | 205 | poll_tr.setAttribute('id', "poll-answer-new-" + count_poll_answer_new); |
|---|
| | 206 | poll_td1.setAttribute('width', "20%"); |
|---|
| | 207 | poll_td2.setAttribute('width', "60%"); |
|---|
| | 208 | poll_td3.setAttribute('width', "10%"); |
|---|
| | 209 | poll_td3.setAttribute('align', "right"); |
|---|
| | 210 | //<input type=\"text\" size=\"4\" id=\"polla_votes-$polla_aid\" name=\"polla_votes-$polla_aid\" value=\"$polla_votes\" onblur=\"check_totalvotes();\" |
|---|
| | 211 | // Appending To Elements |
|---|
| | 212 | poll_tr.appendChild(poll_td1); |
|---|
| | 213 | poll_tr.appendChild(poll_td2); |
|---|
| | 214 | poll_tr.appendChild(poll_td3); |
|---|
| | 215 | poll_answer_bold.appendChild(poll_answer_count); |
|---|
| | 216 | poll_td1.appendChild(poll_answer_bold); |
|---|
| | 217 | poll_td2.appendChild(poll_answer); |
|---|
| | 218 | poll_td3.appendChild(poll_votes_count); |
|---|
| | 219 | poll_td3.appendChild(poll_votes); |
|---|
| | 220 | document.getElementById("poll_answers").appendChild(poll_tr); |
|---|
| | 221 | } |
|---|
| | 222 | function remove_poll_answer() { |
|---|
| | 223 | if(count_poll_answer_new == 0) { |
|---|
| | 224 | alert("<?php _e('No more poll\'s answer to be removed.', 'wp-polls'); ?>"); |
|---|
| | 225 | } else { |
|---|
| | 226 | document.getElementById("poll_answers").removeChild(document.getElementById("poll-answer-new-" + count_poll_answer_new)); |
|---|
| | 227 | count_poll_answer--; |
|---|
| | 228 | count_poll_answer_new--; |
|---|
| | 229 | } |
|---|
| | 230 | } |
|---|