PluginProbe
Crowdsignal Dashboard – Polls, Surveys & more / 1.7.1
Crowdsignal Dashboard – Polls, Surveys & more v1.7.1
3.1.8 3.1.7 trunk 0.8 0.9 1.0 1.2 1.3 1.4 1.5 1.6 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.1 1.8.10 1.8.2 All 97 releases
polldaddy / polldaddy.php

polldaddy.php in Crowdsignal Dashboard – Polls, Surveys & more 1.7.1, at polldaddy.php

2,691 lines 97.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 Plugin Name: PollDaddy Polls
5 Description: Create and manage PollDaddy polls in WordPress
6 Author: Automattic, Inc.
7 Author URL: http://automattic.com/
8 Version: 1.7.1
9 */
10
11 // You can hardcode your PollDaddy PartnerGUID (API Key) here
12 //define( 'WP_POLLDADDY__PARTNERGUID', '12345...' );
13
14 if ( !defined( 'WP_POLLDADDY__CLASS' ) )
15 define( 'WP_POLLDADDY__CLASS', 'WP_PollDaddy' );
16
17 if ( !defined( 'WP_POLLDADDY__POLLDADDY_CLIENT_PATH' ) )
18 define( 'WP_POLLDADDY__POLLDADDY_CLIENT_PATH', dirname( __FILE__ ) . '/polldaddy-client.php' );
19
20 // TODO: when user changes PollDaddy password, userCode changes
21 class WP_PollDaddy {
22 var $errors;
23 var $polldaddy_client_class = 'api_client';
24 var $base_url = false;
25 var $use_ssl = 0;
26 var $scheme = 'https';
27 var $version = '1.7.1';
28
29 var $polldaddy_clients = array();
30
31 function &get_client( $api_key, $userCode = null ) {
32 if ( isset( $this->polldaddy_clients[$api_key] ) ) {
33 if ( !is_null( $userCode ) )
34 $this->polldaddy_clients[$api_key]->userCode = $userCode;
35 return $this->polldaddy_clients[$api_key];
36 }
37 require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
38 $this->polldaddy_clients[$api_key] = new $this->polldaddy_client_class( $api_key, $userCode );
39 return $this->polldaddy_clients[$api_key];
40 }
41
42 function admin_menu() {
43 $this->errors = new WP_Error;
44
45 if ( !$this->base_url )
46 $this->base_url = plugins_url() . '/' . dirname( plugin_basename( __FILE__ ) ) . '/';
47
48 if ( !defined( 'WP_POLLDADDY__PARTNERGUID' ) ) {
49 $guid = get_option( 'polldaddy_api_key' );
50 if ( !$guid || !is_string( $guid ) )
51 $guid = false;
52 define( 'WP_POLLDADDY__PARTNERGUID', $guid );
53 }
54
55 if ( !WP_POLLDADDY__PARTNERGUID ) {
56 $this->use_ssl = (int) get_option( 'polldaddy_use_ssl' );
57
58 if ( function_exists( 'add_object_page' ) ) // WP 2.7+
59 $hook = add_object_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ), "{$this->base_url}polldaddy.png" );
60 else
61 $hook = add_management_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'api_key_page' ) );
62
63 add_action( "load-$hook", array( &$this, 'api_key_page_load' ) );
64 if ( empty( $_GET['page'] ) || 'polls' != $_GET['page'] )
65 add_action( 'admin_notices', create_function( '', 'echo "<div class=\"error\"><p>" . sprintf( "You need to <a href=\"%s\">input your PollDaddy.com account details</a>.", "edit.php?page=polls" ) . "</p></div>";' ) );
66 return false;
67 }
68
69 if ( function_exists( 'add_object_page' ) ) // WP 2.7+
70 $hook = add_object_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'management_page' ), "{$this->base_url}polldaddy.png" );
71 else
72 $hook = add_management_page( __( 'Polls' ), __( 'Polls' ), 'edit_posts', 'polls', array( &$this, 'management_page' ) );
73 add_action( "load-$hook", array( &$this, 'management_page_load' ) );
74
75 // Hack-a-lack-a
76 add_submenu_page( 'polls', __( 'Edit Polls' ), __( 'Edit' ), 'edit_posts', 'polls' );
77 add_submenu_page( 'polls', __( 'Add New Poll' ), __( 'Add New' ), 'edit_posts', 'polls&amp;action=create-poll', array( &$this, 'management_page' ) );
78 add_submenu_page( 'polls', __( 'Custom Styles' ), __( 'Custom Styles' ), 'edit_posts', 'polls&amp;action=list-styles', array( &$this, 'management_page' ) );
79
80 add_action( 'media_buttons', array( &$this, 'media_buttons' ) );
81 }
82
83 function api_key_page_load() {
84 if ( 'post' != strtolower( $_SERVER['REQUEST_METHOD'] ) || empty( $_POST['action'] ) || 'account' != $_POST['action'] )
85 return false;
86
87 check_admin_referer( 'polldaddy-account' );
88
89 $polldaddy_email = stripslashes( $_POST['polldaddy_email'] );
90 $polldaddy_password = stripslashes( $_POST['polldaddy_password'] );
91
92 if ( !$polldaddy_email )
93 $this->errors->add( 'polldaddy_email', __( 'Email address required' ) );
94
95 if ( !$polldaddy_password )
96 $this->errors->add( 'polldaddy_password', __( 'Password required' ) );
97
98 if ( $this->errors->get_error_codes() )
99 return false;
100
101 if ( !empty( $_POST['polldaddy_use_ssl_checkbox'] ) ) {
102 if ( $polldaddy_use_ssl = (int) $_POST['polldaddy_use_ssl'] ) {
103 $this->use_ssl = 0; //checked (by default)
104 } else {
105 $this->use_ssl = 1; //unchecked
106 $this->scheme = 'http';
107 }
108 update_option( 'polldaddy_use_ssl', $this->use_ssl );
109 }
110
111 $details = array(
112 'uName' => get_bloginfo( 'name' ),
113 'uEmail' => $polldaddy_email,
114 'uPass' => $polldaddy_password,
115 'partner_userid' => $GLOBALS['current_user']->ID
116 );
117
118 if ( function_exists( 'wp_remote_post' ) ) { // WP 2.7+
119 $polldaddy_api_key = wp_remote_post( $this->scheme . '://api.polldaddy.com/key.php', array(
120 'body' => $details
121 ) );
122 if ( is_wp_error( $polldaddy_api_key ) ) {
123 $this->errors = $polldaddy_api_key;
124 return false;
125 }
126 $response_code = wp_remote_retrieve_response_code( $polldaddy_api_key );
127 if ( 200 != $response_code ) {
128 $this->errors->add( 'http_code', __( 'Could not connect to PollDaddy API Key service' ) );
129 return false;
130 }
131 $polldaddy_api_key = wp_remote_retrieve_body( $polldaddy_api_key );
132 } else {
133 $fp = fsockopen(
134 'api.polldaddy.com',
135 80,
136 $err_num,
137 $err_str,
138 3
139 );
140
141 if ( !$fp ) {
142 $this->errors->add( 'connect', __( "Can't connect to PollDaddy.com" ) );
143 return false;
144 }
145
146 if ( function_exists( 'stream_set_timeout' ) )
147 stream_set_timeout( $fp, 3 );
148
149 global $wp_version;
150
151 $request_body = http_build_query( $details, null, '&' );
152
153 $request = "POST /key.php HTTP/1.0\r\n";
154 $request .= "Host: api.polldaddy.com\r\n";
155 $request .= "User-agent: WordPress/$wp_version\r\n";
156 $request .= 'Content-Type: application/x-www-form-urlencoded; charset=' . get_option('blog_charset') . "\r\n";
157 $request .= 'Content-Length: ' . strlen( $request_body ) . "\r\n";
158
159 fwrite( $fp, "$request\r\n$request_body" );
160
161 $response = '';
162 while ( !feof( $fp ) )
163 $response .= fread( $fp, 4096 );
164 fclose( $fp );
165 list($headers, $polldaddy_api_key) = explode( "\r\n\r\n", $response, 2 );
166 }
167
168 if( isset( $polldaddy_api_key ) && strlen( $polldaddy_api_key ) > 0 ){
169 update_option( 'polldaddy_api_key', $polldaddy_api_key );
170 }
171 else{
172 $this->errors->add( 'polldaddy_api_key', __( 'Login to PollDaddy failed. Double check your email address and password.' ) );
173 if ( 1 !== $this->use_ssl ) {
174 $this->errors->add( 'polldaddy_api_key', __( 'If your email address and password are correct, your host may not support secure logins.' ) );
175 $this->errors->add( 'polldaddy_api_key', __( 'In that case, you may be able to log in to PollDaddy by unchecking the "Use SSL to Log in" checkbox.' ) );
176 $this->use_ssl = 0;
177 }
178 update_option( 'polldaddy_use_ssl', $this->use_ssl );
179 return false;
180 }
181
182 $polldaddy = $this->get_client( $polldaddy_api_key );
183 $polldaddy->reset();
184 if ( !$polldaddy->get_usercode( $GLOBALS['current_user']->ID ) ) {
185 $this->parse_errors( $polldaddy );
186 $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?' ) );
187 return false;
188 }
189
190 wp_redirect( add_query_arg( array( 'page' => 'polls' ), wp_get_referer() ) );
191 exit;
192 }
193
194 function parse_errors( &$polldaddy ) {
195 if ( $polldaddy->errors )
196 foreach ( $polldaddy->errors as $code => $error )
197 $this->errors->add( $code, $error );
198 if ( isset( $this->errors->errors[4] ) ) {
199 $this->errors->errors[4] = array( sprintf( __( 'Obsolete PollDaddy User API Key: <a href="%s">Sign in again to re-authenticate</a>' ), add_query_arg( array( 'action' => 'signup', 'reaction' => empty( $_GET['action'] ) ? false : $_GET['action'] ) ) ) );
200 $this->errors->add_data( true, 4 );
201 }
202 }
203
204 function print_errors() {
205 if ( !$error_codes = $this->errors->get_error_codes() )
206 return;
207 ?>
208
209 <div class="error">
210
211 <?php
212
213 foreach ( $error_codes as $error_code ) :
214 foreach ( $this->errors->get_error_messages( $error_code ) as $error_message ) :
215 ?>
216
217 <p><?php echo $this->errors->get_error_data( $error_code ) ? $error_message : wp_specialchars( $error_message ); ?></p>
218
219 <?php
220 endforeach;
221 endforeach;
222
223 $this->errors = new WP_Error;
224 ?>
225
226 </div>
227 <br class="clear" />
228
229 <?php
230 }
231
232 function api_key_page() {
233 $this->print_errors();
234 ?>
235
236 <div class="wrap">
237
238 <h2><?php _e( 'PollDaddy Account' ); ?></h2>
239
240 <p><?php printf( __('Before you can use the PollDaddy plugin, you need to enter your <a href="%s">PollDaddy.com</a> account details.' ), 'http://polldaddy.com/' ); ?></p>
241
242 <form action="" method="post">
243 <table class="form-table">
244 <tbody>
245 <tr class="form-field form-required">
246 <th valign="top" scope="row">
247 <label for="polldaddy-email">PollDaddy Email Address</label>
248 </th>
249 <td>
250 <input type="text" name="polldaddy_email" id="polldaddy-email" aria-required="true" size="40" value="<?php if ( isset( $_POST['polldaddy_email'] ) ) echo attribute_escape( $_POST['polldaddy_email'] ); ?>" />
251 </td>
252 </tr>
253 <tr class="form-field form-required">
254 <th valign="top" scope="row">
255 <label for="polldaddy-password">PollDaddy Password</label>
256 </th>
257 <td>
258 <input type="password" name="polldaddy_password" id="polldaddy-password" aria-required="true" size="40" />
259 </td>
260 </tr>
261 <?php
262 $checked = '';
263 if ( $this->use_ssl == 0 )
264 $checked = 'checked="checked"';
265 ?>
266 <tr class="form-field form-required">
267 <th valign="top" scope="row">
268 <label for="polldaddy-use-ssl">Use SSL to Log in</label>
269 </th>
270 <td>
271 <input type="checkbox" name="polldaddy_use_ssl" id="polldaddy-use-ssl" value="1" <?php echo $checked ?> style="width: auto"/>
272 <label for="polldaddy-use-ssl">This ensures a secure login to your PollDaddy account. Only uncheck if you are having problems logging in.</label>
273 <input type="hidden" name="polldaddy_use_ssl_checkbox" value="1" />
274 </td>
275 </tr>
276 </tbody>
277 </table>
278 <p class="submit">
279 <?php wp_nonce_field( 'polldaddy-account' ); ?>
280 <input type="hidden" name="action" value="account" />
281 <input type="hidden" name="account" value="import" />
282 <input type="submit" value="<?php echo attribute_escape( __( 'Submit' ) ); ?>" />
283 </p>
284 </form>
285 </div>
286
287 <?php
288 }
289
290 function media_buttons() {
291 $title = __( 'Add Poll' );
292 echo "<a href='admin.php?page=polls&amp;iframe&amp;TB_iframe=true' id='add_poll' class='thickbox' title='$title'><img src='{$this->base_url}polldaddy.png' alt='$title' /></a>";
293 }
294
295 function management_page_load() {
296 global $current_user;
297
298 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
299 $polldaddy->reset();
300
301 if ( !defined( 'WP_POLLDADDY__USERCODE' ) )
302 define( 'WP_POLLDADDY__USERCODE', $polldaddy->get_usercode( $current_user->ID ) );
303
304 wp_reset_vars( array( 'action', 'poll', 'style' ) );
305 global $action, $poll, $style;
306
307 if ( !WP_POLLDADDY__USERCODE )
308 $action = 'signup';
309
310 require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
311
312 wp_enqueue_script( 'polls', "{$this->base_url}polldaddy.js", array( 'jquery', 'jquery-ui-sortable' ), $this->version );
313 wp_enqueue_script( 'polls-common', "{$this->base_url}common.js", array(), $this->version );
314
315 switch ( $action ) :
316 case 'edit' :
317 case 'edit-poll' :
318 case 'create-poll' :
319 wp_enqueue_script( 'polls-style', "http://i.polldaddy.com/js/poll-style-picker.js", array(), $this->version );
320 break;
321 case 'edit-style' :
322 case 'create-style' :
323 wp_enqueue_script( 'polls-style', "http://i.polldaddy.com/js/style-editor.js", array(), $this->version );
324 wp_enqueue_script( 'polls-style-color', "http://i.polldaddy.com/js/jscolor.js", array(), $this->version );
325 wp_enqueue_style( 'polls', "{$this->base_url}style-editor.css", array(), $this->version );
326 break;
327 endswitch;
328
329 wp_enqueue_script( 'admin-forms' );
330 add_thickbox();
331
332 wp_enqueue_style( 'polls', "{$this->base_url}polldaddy.css", array( 'global', 'wp-admin' ), $this->version );
333 add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
334
335 add_action( 'admin_notices', array( &$this, 'management_page_notices' ) );
336
337 $query_args = array();
338 $args = array();
339
340 $allowedtags = array(
341 'a' => array(
342 'href' => array (),
343 'title' => array (),
344 'target' => array ()),
345 'img' => array(
346 'alt' => array (),
347 'align' => array (),
348 'border' => array (),
349 'class' => array (),
350 'height' => array (),
351 'hspace' => array (),
352 'longdesc' => array (),
353 'vspace' => array (),
354 'src' => array (),
355 'width' => array ()),
356 'abbr' => array(
357 'title' => array ()),
358 'acronym' => array(
359 'title' => array ()),
360 'b' => array(),
361 'blockquote' => array(
362 'cite' => array ()),
363 'cite' => array (),
364 'em' => array (),
365 'i' => array (),
366 'q' => array(
367 'cite' => array ()),
368 'strike' => array(),
369 'strong' => array()
370 );
371
372 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
373
374 switch ( $action ) :
375 case 'signup' : // sign up for first time
376 case 'account' : // reauthenticate
377 if ( !$is_POST )
378 return;
379
380 check_admin_referer( 'polldaddy-account' );
381
382 if ( $new_args = $this->management_page_load_signup() )
383 $query_args = array_merge( $query_args, $new_args );
384 if ( $this->errors->get_error_codes() )
385 return false;
386
387 wp_reset_vars( array( 'action' ) );
388 if ( !empty( $_GET['reaction'] ) )
389 $query_args['action'] = $_GET['reaction'];
390 elseif ( !empty( $_GET['action'] ) && 'signup' != $_GET['action'] )
391 $query_args['action'] = $_GET['action'];
392 else
393 $query_args['action'] = false;
394 break;
395 case 'delete' :
396 if ( empty( $poll ) )
397 return;
398
399 if ( is_array( $poll ) )
400 check_admin_referer( 'delete-poll_bulk' );
401 else
402 check_admin_referer( "delete-poll_$poll" );
403
404 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
405
406 foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
407 $polldaddy->reset();
408 $poll_object = $polldaddy->get_poll( $poll );
409
410 if ( !$this->can_edit( $poll_object ) ) {
411 $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) );
412 return false;
413 }
414
415 // Send Poll Author credentials
416 if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
417 $polldaddy->reset();
418 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
419 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
420 }
421 $polldaddy->userCode = $userCode;
422 }
423
424 $polldaddy->reset();
425 $polldaddy->delete_poll( $poll_id );
426 }
427
428 $query_args['message'] = 'deleted';
429 $query_args['deleted'] = count( (array) $poll );
430 break;
431 case 'open' :
432 if ( empty( $poll ) )
433 return;
434
435 if ( is_array( $poll ) )
436 check_admin_referer( 'action-poll_bulk' );
437 else
438 check_admin_referer( "open-poll_$poll" );
439
440 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
441
442 foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
443 $polldaddy->reset();
444 $poll_object = $polldaddy->get_poll( $poll );
445
446 if ( !$this->can_edit( $poll_object ) ) {
447 $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) );
448 return false;
449 }
450
451 // Send Poll Author credentials
452 if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
453 $polldaddy->reset();
454 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
455 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
456 }
457 $polldaddy->userCode = $userCode;
458 }
459
460 $polldaddy->reset();
461 $polldaddy->open_poll( $poll_id );
462 }
463
464 $query_args['message'] = 'opened';
465 $query_args['opened'] = count( (array) $poll );
466 break;
467 case 'close' :
468 if ( empty( $poll ) )
469 return;
470
471 if ( is_array( $poll ) )
472 check_admin_referer( 'action-poll_bulk' );
473 else
474 check_admin_referer( "close-poll_$poll" );
475
476 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
477
478 foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
479 $polldaddy->reset();
480 $poll_object = $polldaddy->get_poll( $poll );
481
482 if ( !$this->can_edit( $poll_object ) ) {
483 $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) );
484 return false;
485 }
486
487 // Send Poll Author credentials
488 if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
489 $polldaddy->reset();
490 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
491 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
492 }
493 $polldaddy->userCode = $userCode;
494 }
495
496 $polldaddy->reset();
497 $polldaddy->close_poll( $poll_id );
498 }
499
500 $query_args['message'] = 'closed';
501 $query_args['closed'] = count( (array) $poll );
502 break;
503 case 'edit-poll' : // TODO: use polldaddy_poll
504 if ( !$is_POST || !$poll = (int) $poll )
505 return;
506
507 check_admin_referer( "edit-poll_$poll" );
508
509 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
510 $polldaddy->reset();
511
512 $poll_object = $polldaddy->get_poll( $poll );
513 $this->parse_errors( $polldaddy );
514
515 if ( !$this->can_edit( $poll_object ) ) {
516 $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.' ) );
517 return false;
518 }
519
520 // Send Poll Author credentials
521
522 if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
523 $polldaddy->reset();
524 if ( !$userCode = $polldaddy->get_usercode( $poll_object->_owner ) ) {
525 $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
526 }
527 $this->parse_errors( $polldaddy );
528 $polldaddy->userCode = $userCode;
529 }
530
531 if ( !$poll_object )
532 $this->errors->add( 'GetPoll', __( 'Poll not found' ) );
533
534 if ( $this->errors->get_error_codes() )
535 return false;
536
537 $poll_data = get_object_vars( $poll_object );
538 foreach ( $poll_data as $key => $value )
539 if ( '_' === $key[0] )
540 unset( $poll_data[$key] );
541
542 foreach ( array( 'multipleChoice', 'randomiseAnswers', 'otherAnswer', 'sharing' ) as $option ) {
543 if ( isset( $_POST[$option] ) && $_POST[$option] )
544 $poll_data[$option] = 'yes';
545 else
546 $poll_data[$option] = 'no';
547 }
548
549 $blocks = array( 'off', 'cookie', 'cookieIP' );
550 if ( isset( $_POST['blockRepeatVotersType'] ) && in_array( $_POST['blockRepeatVotersType'], $blocks ) )
551 $poll_data['blockRepeatVotersType'] = $_POST['blockRepeatVotersType'];
552
553 $results = array( 'show', 'percent', 'hide' );
554 if ( isset( $_POST['resultsType'] ) && in_array( $_POST['resultsType'], $results ) )
555 $poll_data['resultsType'] = $_POST['resultsType'];
556 $poll_data['question'] = stripslashes( $_POST['question'] );
557
558 if ( empty( $_POST['answer'] ) || !is_array( $_POST['answer'] ) )
559 $this->errors->add( 'answer', __( 'Invalid answers' ) );
560
561 $answers = array();
562 foreach ( $_POST['answer'] as $answer_id => $answer ) {
563 if ( !$answer = trim( stripslashes( $answer ) ) )
564 continue;
565
566 $args['text'] = wp_kses( $answer, $allowedtags );
567
568 if ( is_numeric( $answer_id ) )
569 $answers[] = polldaddy_poll_answer( $args, $answer_id );
570 else
571 $answers[] = polldaddy_poll_answer( $args );
572 }
573
574 if ( 2 > count( $answers ) )
575 $this->errors->add( 'answer', __( 'You must include at least 2 answers' ) );
576
577 if ( $this->errors->get_error_codes() )
578 return false;
579
580 $poll_data['answers'] = $answers;
581
582 $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
583
584 if ( isset ( $_POST['styleID'] ) ){
585 if ( $_POST['styleID'] == 'x' ){
586 $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style' ) );
587 return false;
588 }
589 }
590 $poll_data['styleID'] = (int) $_POST['styleID'];
591
592 $polldaddy->reset();
593
594 $update_response = $polldaddy->update_poll( $poll, $poll_data );
595
596 $this->parse_errors( $polldaddy );
597
598 if ( !$update_response )
599 $this->errors->add( 'UpdatePoll', __( 'Poll could not be updated' ) );
600
601 if ( $this->errors->get_error_codes() )
602 return false;
603
604 $query_args['message'] = 'updated';
605 if ( isset($_POST['iframe']) )
606 $query_args['iframe'] = '';
607 break;
608 case 'create-poll' :
609 if ( !$is_POST )
610 return;
611
612 check_admin_referer( 'create-poll' );
613
614 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
615 $polldaddy->reset();
616
617 $answers = array();
618 foreach ( $_POST['answer'] as $answer ){
619 if ( !$answer = trim( stripslashes( $answer ) ) )
620 continue;
621
622 $args['text'] = wp_kses( $answer, $allowedtags );
623
624 $answers[] = polldaddy_poll_answer( $args );
625 }
626
627 if ( !$answers )
628 return false;
629
630 $poll_data = _polldaddy_poll_defaults();
631 foreach ( $poll_data as $key => $value )
632 if ( isset($_POST[$key]) )
633 $poll_data[$key] = stripslashes( $_POST[$key] );
634
635 $poll_data['answers'] = $answers;
636
637 $poll_data['question'] = wp_kses( $poll_data['question'], $allowedtags );
638
639 if ( isset ( $_POST['styleID'] ) ){
640 if ( $_POST['styleID'] == 'x' ){
641 $this->errors->add( 'UpdatePoll', __( 'Please choose a poll style' ) );
642 return false;
643 }
644 }
645 $poll_data['styleID'] = $_POST['styleID'];
646
647 $poll = $polldaddy->create_poll( $poll_data );
648 $this->parse_errors( $polldaddy );
649
650 if ( !$poll || empty( $poll->_id ) )
651 $this->errors->add( 'CreatePoll', __( 'Poll could not be created' ) );
652
653 if ( $this->errors->get_error_codes() )
654 return false;
655
656 $query_args['message'] = 'created';
657 $query_args['action'] = 'edit-poll';
658 $query_args['poll'] = $poll->_id;
659 if ( isset($_POST['iframe']) )
660 $query_args['iframe'] = '';
661 break;
662 case 'delete-style' :
663 if ( empty( $style ) )
664 return;
665
666 if ( is_array( $style ) )
667 check_admin_referer( 'action-style_bulk' );
668 else
669 check_admin_referer( "delete-style_$style" );
670
671 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
672
673 foreach ( (array) $_REQUEST['style'] as $style_id ) {
674 $polldaddy->reset();
675 $polldaddy->delete_style( $style_id );
676 }
677
678 $query_args['message'] = 'deleted-style';
679 $query_args['deleted'] = count( (array) $style );
680 break;
681 case 'edit-style' :
682 if ( !$is_POST || !$style = (int) $style )
683 return;
684
685 check_admin_referer( "edit-style$style" );
686
687 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
688 $polldaddy->reset();
689
690 $style_data = _polldaddy_style_defaults();
691
692 if ( isset($_POST['style-title'] ) )
693 $style_data['title'] = stripslashes( trim ( (string) $_POST['style-title'] ) );
694
695 if ( isset($_POST['CSSXML'] ) )
696 $style_data['css'] = urlencode( stripslashes( trim ( (string) $_POST['CSSXML'] ) ) );
697
698 $update_response = $polldaddy->update_style( $style, $style_data );
699
700 $this->parse_errors( $polldaddy );
701
702 if ( !$update_response )
703 $this->errors->add( 'UpdateStyle', __( 'Style could not be updated' ) );
704
705 if ( $this->errors->get_error_codes() )
706 return false;
707
708 $query_args['message'] = 'updated-style';
709 if ( isset($_POST['iframe']) )
710 $query_args['iframe'] = '';
711 break;
712 case 'create-style' :
713 if ( !$is_POST )
714 return;
715
716 check_admin_referer( 'create-style' );
717
718 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
719 $polldaddy->reset();
720
721 $style_data = _polldaddy_style_defaults();
722
723 if ( isset($_POST['style-title'] ) )
724 $style_data['title'] = stripslashes( strip_tags( trim ( (string) $_POST['style-title'] ) ) );
725
726 if ( isset($_POST['CSSXML'] ) )
727 $style_data['css'] = urlencode( stripslashes( trim ( (string) $_POST['CSSXML'] ) ) );
728
729 $style = $polldaddy->create_style( $style_data );
730 $this->parse_errors( $polldaddy );
731
732 if ( !$style || empty( $style->_id ) )
733 $this->errors->add( 'CreateStyle', __( 'Style could not be created' ) );
734
735 if ( $this->errors->get_error_codes() )
736 return false;
737
738 $query_args['message'] = 'created-style';
739 $query_args['action'] = 'edit-style';
740 $query_args['style'] = $style->_id;
741 if ( isset($_POST['iframe']) )
742 $query_args['iframe'] = '';
743 break;
744 default :
745 return;
746 endswitch;
747
748 wp_redirect( add_query_arg( $query_args, wp_get_referer() ) );
749 exit;
750 }
751
752 function management_page_load_signup() {
753 switch ( $_POST['account'] ) :
754 case 'import' :
755 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
756 $polldaddy->reset();
757 $email = trim( stripslashes( $_POST['polldaddy_email'] ) );
758 $password = trim( stripslashes( $_POST['polldaddy_password'] ) );
759
760 if ( !is_email( $email ) )
761 $this->errors->add( 'polldaddy_email', __( 'Email address required' ) );
762
763 if ( !$password )
764 $this->errors->add( 'polldaddy_password', __( 'Password required' ) );
765
766 if ( $this->errors->get_error_codes() )
767 return false;
768
769 if ( !$polldaddy->initiate( $email, $password, $GLOBALS['user_ID'] ) ) {
770 $this->parse_errors( $polldaddy );
771 $this->errors->add( 'import-account', __( 'Account could not be imported. Are your email address and password correct?' ) );
772 return false;
773 }
774 break;
775 default :
776 return;
777 endswitch;
778 }
779
780 function admin_body_class( $class ) {
781 if ( isset( $_GET['iframe'] ) )
782 $class .= 'poll-preview-iframe ';
783 if ( isset( $_GET['TB_iframe'] ) )
784 $class .= 'poll-preview-iframe-editor ';
785 return $class;
786 }
787
788 function management_page_notices() {
789 $message = false;
790 switch ( (string) @$_GET['message'] ) :
791 case 'deleted' :
792 $deleted = (int) $_GET['deleted'];
793 if ( 1 == $deleted )
794 $message = __( 'Poll deleted.' );
795 else
796 $message = sprintf( __ngettext( '%s Poll Deleted.', '%s Polls Deleted.', $deleted ), number_format_i18n( $deleted ) );
797 break;
798 case 'opened' :
799 $opened = (int) $_GET['opened'];
800 if ( 1 == $opened )
801 $message = __( 'Poll opened.' );
802 else
803 $message = sprintf( __ngettext( '%s Poll Opened.', '%s Polls Opened.', $opened ), number_format_i18n( $opened ) );
804 break;
805 case 'closed' :
806 $closed = (int) $_GET['closed'];
807 if ( 1 == $closed )
808 $message = __( 'Poll closed.' );
809 else
810 $message = sprintf( __ngettext( '%s Poll Closed.', '%s Polls Closed.', $closed ), number_format_i18n( $closed ) );
811 break;
812 case 'updated' :
813 $message = __( 'Poll updated.' );
814 break;
815 case 'created' :
816 $message = __( 'Poll created.' );
817 if ( isset( $_GET['iframe'] ) )
818 $message .= ' <input type="button" class="button polldaddy-send-to-editor" value="' . attribute_escape( __( 'Send to Editor' ) ) . '" />';
819 break;
820 case 'updated-style' :
821 $message = __( 'Custom Style updated.' );
822 break;
823 case 'created-style' :
824 $message = __( 'Custom Style created.' );
825 break;
826 case 'deleted-style' :
827 $deleted = (int) $_GET['deleted'];
828 if ( 1 == $deleted )
829 $message = __( 'Custom Style deleted.' );
830 else
831 $message = sprintf( __ngettext( '%s Style Deleted.', '%s Custom Styles Deleted.', $deleted ), number_format_i18n( $deleted ) );
832 break;
833 endswitch;
834
835 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
836
837 if ( $is_POST ) {
838 switch ( $GLOBALS['action'] ) :
839 case 'create-poll' :
840 $message = __( 'Error: An error has occurred; Poll not created.' );
841 break;
842 case 'edit-poll' :
843 $message = __( 'Error: An error has occurred; Poll not updated.' );
844 break;
845 case 'account' :
846 if ( 'import' == $_POST['account'] )
847 $message = __( 'Error: An error has occurred; Account could not be imported. Perhaps your email address or password is incorrect?' );
848 else
849 $message = __( 'Error: An error has occurred; Account could not be created.' );
850 break;
851 endswitch;
852 }
853
854 if ( !$message )
855 return;
856 ?>
857 <div class='updated'><p><?php echo $message; ?></p></div>
858 <?php
859 $this->print_errors();
860 }
861
862 function management_page() {
863 global $action, $poll, $style;
864 $poll = (int) $poll;
865 $style = (int) $style;
866
867 ?>
868
869 <div class="wrap" id="manage-polls">
870
871 <?php
872 switch ( $action ) :
873 case 'signup' :
874 case 'account' :
875 $this->signup();
876 break;
877 case 'preview' :
878 ?>
879
880 <h2 id="preview-header"><?php printf( __( 'Poll Preview (<a href="%s">Edit Poll</a>, <a href="%s">List Polls</a>)' ),
881 clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ),
882 clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) )
883 ); ?></h2>
884
885 <?php
886 echo do_shortcode( "[polldaddy poll=$poll cb=1]" );
887 break;
888 case 'results' :
889 ?>
890
891 <h2><?php printf( __( 'Poll Results (<a href="%s">Edit</a>)' ), clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll, 'message' => false ) ) ) ); ?></h2>
892
893 <?php
894 $this->poll_results_page( $poll );
895 break;
896 case 'edit' :
897 case 'edit-poll' :
898 ?>
899
900 <h2><?php printf( __('Edit Poll (<a href="%s">List Polls</a>)'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
901
902 <?php
903
904 $this->poll_edit_form( $poll );
905 break;
906 case 'create-poll' :
907 ?>
908
909 <h2><?php printf( __('Create Poll (<a href="%s">List Polls</a>)'), clean_url( add_query_arg( array( 'action' => false, 'poll' => false, 'message' => false ) ) ) ); ?></h2>
910
911 <?php
912 $this->poll_edit_form();
913 break;
914 case 'list-styles' :
915 ?>
916
917 <h2><?php printf( __('Custom Styles (<a href="%s">Add New</a>)'), clean_url( add_query_arg( array(
918 'action' => 'create-style', 'poll' => false, 'message' => false ) ) ) ); ?></h2>
919
920 <?php
921 $this->styles_table();
922 break;
923 case 'edit-style' :
924 ?>
925
926 <h2><?php printf( __('Edit Style (<a href="%s">List Styles</a>)'), clean_url( add_query_arg( array( 'action' => 'list-styles', 'style' => false, 'message' => false, 'preload' => false ) ) ) ); ?></h2>
927
928 <?php
929
930 $this->style_edit_form( $style );
931 break;
932 case 'create-style' :
933 ?>
934
935 <h2><?php printf( __('Create Style (<a href="%s">List Styles</a>)'), clean_url( add_query_arg( array( 'action' => 'list-styles', 'style' => false, 'message' => false, 'preload' => false ) ) ) ); ?></h2>
936
937 <?php
938 $this->style_edit_form();
939 break;
940 default :
941
942 ?>
943
944 <h2 id="poll-list-header"><?php printf( __( 'Polls (<a href="%s">Add New</a>)' ), clean_url( add_query_arg( array(
945 'action' => 'create-poll',
946 'poll' => false,
947 'message' => false
948 ) ) ) ); ?></h2>
949
950 <?php
951 $this->polls_table( isset( $_GET['view'] ) && 'user' == $_GET['view'] ? 'user' : 'blog' );
952 endswitch;
953 ?>
954
955 </div>
956
957 <?php
958
959 }
960
961 function polls_table( $view = 'blog' ) {
962 $page = absint($_GET['paged']);
963 if ( !$page )
964 $page = 1;
965 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
966 $polldaddy->reset();
967 if ( 'user' == $view )
968 $polls_object = $polldaddy->get_polls( ( $page - 1 ) * 10 + 1, $page * 10 );
969 else
970 $polls_object = $polldaddy->get_polls_by_parent_id( ( $page - 1 ) * 10 + 1, $page * 10 );
971 $this->parse_errors( $polldaddy );
972 $this->print_errors();
973 $polls = & $polls_object->poll;
974 $total_polls = $polls_object->_total;
975 $class = '';
976
977 $page_links = paginate_links( array(
978 'base' => add_query_arg( 'paged', '%#%' ),
979 'format' => '',
980 'total' => ceil( $total_polls / 10 ),
981 'current' => $page
982 ) );
983 ?>
984
985 <ul class="subsubsub">
986 <li><a href="<?php echo clean_url( add_query_arg( array( 'view' => false, 'paged' => false ) ) ); ?>"<?php if ( 'blog' == $view ) echo ' class="current"'; ?>><?php _e( "All Blog's Polls" ); ?></a> | </li>
987 <li><a href="<?php echo clean_url( add_query_arg( array( 'view' => 'user', 'paged' => false ) ) ); ?>"<?php if ( 'user' == $view ) echo ' class="current"'; ?>><?php _e( "All My Polls" ); ?></a></li>
988 </ul>
989 <form method="post" action="">
990 <div class="tablenav">
991 <div class="alignleft">
992 <select name="action">
993 <option selected="selected" value=""><?php _e( 'Actions' ); ?></option>
994 <option value="delete"><?php _e( 'Delete' ); ?></option>
995 <option value="close"><?php _e( 'Close' ); ?></option>
996 <option value="open"><?php _e( 'Open' ); ?></option>
997 </select>
998 <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply' ); ?>" />
999 <?php wp_nonce_field( 'action-poll_bulk' ); ?>
1000 </div>
1001 <div class="tablenav-pages"><?php echo $page_links; ?></div>
1002 </div>
1003 <br class="clear" />
1004 <table class="widefat">
1005 <thead>
1006 <tr>
1007 <th id="cb" class="manage-column column-cb check-column" scope="col" /><input type="checkbox" /></th>
1008 <th id="title" class="manage-column column-title" scope="col">Poll</th>
1009 <th id="votes" class="manage-column column-vote" scope="col">Votes</th>
1010 <th id="date" class="manage-column column-date" scope="col">Created</th>
1011 </tr>
1012 </thead>
1013 <tbody>
1014
1015 <?php
1016 if ( $polls ) :
1017 foreach ( $polls as $poll ) :
1018 $poll_id = (int) $poll->_id;
1019
1020 $poll->___content = trim( strip_tags( $poll->___content ) );
1021 if( strlen( $poll->___content ) == 0 ){
1022 $poll->___content = '-- empty HTML tag --';
1023 }
1024
1025 $poll_closed = (int) $poll->_closed;
1026
1027 if ( $this->can_edit( $poll ) )
1028 $edit_link = clean_url( add_query_arg( array( 'action' => 'edit', 'poll' => $poll_id, 'message' => false ) ) );
1029 else
1030 $edit_link = false;
1031
1032 $class = $class ? '' : ' class="alternate"';
1033 $results_link = clean_url( add_query_arg( array( 'action' => 'results', 'poll' => $poll_id, 'message' => false ) ) );
1034 $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete', 'poll' => $poll_id, 'message' => false ) ), "delete-poll_$poll_id" ) );
1035 $open_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'open', 'poll' => $poll_id, 'message' => false ) ), "open-poll_$poll_id" ) );
1036 $close_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'close', 'poll' => $poll_id, 'message' => false ) ), "close-poll_$poll_id" ) );
1037 $preview_link = clean_url( add_query_arg( array( 'action' => 'preview', 'poll' => $poll_id, 'message' => false ) ) ); //, 'iframe' => '', 'TB_iframe' => 'true' ) ) );
1038 list($poll_time) = explode( '.', $poll->_created );
1039 $poll_time = strtotime( $poll_time );
1040 ?>
1041
1042 <tr<?php echo $class; ?>>
1043 <th class="check-column" scope="row"><input type="checkbox" value="<?php echo (int) $poll_id; ?>" name="poll[]" /></th>
1044 <td class="post-title column-title">
1045 <?php if ( $edit_link ) : ?>
1046 <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $poll->___content ); ?></a></strong>
1047 <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit' ); ?></a> | </span>
1048 <?php else : ?>
1049 <strong><?php echo wp_specialchars( $poll->___content ); ?></strong>
1050 <?php endif; ?>
1051
1052 <span class="results"><a href="<?php echo $results_link; ?>"><?php _e( 'Results' ); ?></a> | </span>
1053 <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete' ); ?></a> | </span>
1054 <?php if ( $poll_closed == 2 ) : ?>
1055 <span class="open"><a class="open-poll" href="<?php echo $open_link; ?>"><?php _e( 'Open' ); ?></a> | </span>
1056 <?php else : ?>
1057 <span class="close"><a class="close-poll" href="<?php echo $close_link; ?>"><?php _e( 'Close' ); ?></a> | </span>
1058 <?php endif; ?>
1059 <?php if ( isset( $_GET['iframe'] ) ) : ?>
1060 <span class="view"><a href="<?php echo $preview_link; ?>"><?php _e( 'Preview' ); ?></a> | </span>
1061 <span class="editor">
1062 <a href="#" class="polldaddy-send-to-editor"><?php _e( 'Send to editor' ); ?></a>
1063 <input type="hidden" class="polldaddy-poll-id hack" value="<?php echo (int) $poll_id; ?>" /> |
1064 </span>
1065 <?php else : ?>
1066 <span class="view"><a class="thickbox" href="<?php echo $preview_link; ?>"><?php _e( 'Preview' ); ?></a> | </span>
1067 <?php endif; ?>
1068 <span class="shortcode"><a href="#" class="polldaddy-show-shortcode"><?php _e( 'HTML code' ); ?></a></span>
1069 </td>
1070 <td class="poll-votes column-vote"><?php echo number_format_i18n( $poll->_responses ); ?></td>
1071 <td class="date column-date"><abbr title="<?php echo date( __('Y/m/d g:i:s A'), $poll_time ); ?>"><?php echo date( __('Y/m/d'), $poll_time ); ?></abbr></td>
1072 </tr>
1073 <tr class="polldaddy-shortcode-row" style="display: none;">
1074 <td colspan="4">
1075 <h4><?php _e( 'Shortcode' ); ?></h4>
1076 <pre>[polldaddy poll=<?php echo (int) $poll_id; ?>]</pre>
1077
1078 <h4><?php _e( 'JavaScript' ); ?></h4>
1079 <pre>&lt;script type="text/javascript" language="javascript"
1080 src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/script&gt;
1081 &lt;noscript&gt;
1082 &lt;a href="http://answers.polldaddy.com/poll/<?php echo (int) $poll_id; ?>/"&gt;<?php echo trim( strip_tags( $poll->___content ) ); ?>&lt;/a&gt;&lt;br/&gt;
1083 &lt;span style="font:9px;"&gt;(&lt;a href="http://www.polldaddy.com"&gt;polls&lt;/a&gt;)&lt;/span&gt;
1084 &lt;/noscript&gt;</pre>
1085 </td>
1086 </tr>
1087
1088 <?php
1089 endforeach;
1090 elseif ( $total_polls ) : // $polls
1091 ?>
1092
1093 <tr>
1094 <td colspan="4"><?php printf( __( 'What are you doing here? <a href="%s">Go back</a>.' ), clean_url( add_query_arg( 'paged', false ) ) ); ?></td>
1095 </tr>
1096
1097 <?php
1098 else : // $polls
1099 ?>
1100
1101 <tr>
1102 <td colspan="4"><?php printf( __( 'No polls yet. <a href="%s">Create one</a>' ), clean_url( add_query_arg( array( 'action' => 'create-poll' ) ) ) ); ?></td>
1103 </tr>
1104 <?php endif; // $polls ?>
1105
1106 </tbody>
1107 </table>
1108 </form>
1109 <div class="tablenav">
1110 <div class="tablenav-pages"><?php echo $page_links; ?></div>
1111 </div>
1112 <br class="clear" />
1113
1114 <?php
1115 }
1116
1117 function poll_edit_form( $poll_id = 0 ) {
1118 $poll_id = (int) $poll_id;
1119
1120 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
1121 $polldaddy->reset();
1122
1123 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
1124
1125 if ( $poll_id ) {
1126 $poll = $polldaddy->get_poll( $poll_id );
1127 $this->parse_errors( $polldaddy );
1128
1129 if ( !$this->can_edit( $poll ) ) {
1130 $this->errors->add( 'permission', __( 'You are not allowed to edit this poll.' ) );
1131 }
1132 } else {
1133 $poll = polldaddy_poll( array(), null, false );
1134 }
1135
1136 $question = $is_POST ? attribute_escape( stripslashes( $_POST['question'] ) ) : attribute_escape( $poll->question );
1137
1138 $this->print_errors();
1139 ?>
1140
1141 <form action="" method="post">
1142 <div id="poststuff"><div id="post-body" class="has-sidebar has-right-sidebar">
1143
1144 <div class="inner-sidebar" id="side-info-column">
1145 <div id="submitdiv" class="postbox">
1146 <h3><?php _e( 'Publish' ); ?></h3>
1147 <div class="inside">
1148 <div id="major-publishing-actions">
1149 <p id="publishing-action">
1150 <?php wp_nonce_field( $poll_id ? "edit-poll_$poll_id" : 'create-poll' ); ?>
1151 <input type="hidden" name="action" value="<?php echo $poll_id ? 'edit-poll' : 'create-poll'; ?>" />
1152 <input type="hidden" class="polldaddy-poll-id" name="poll" value="<?php echo $poll_id; ?>" />
1153 <input type="submit" class="button-primary" value="<?php echo attribute_escape( __( 'Save Poll' ) ); ?>" />
1154
1155 <?php if ( isset( $_GET['iframe'] ) && $poll_id ) : ?>
1156
1157 <input type="button" class="button polldaddy-send-to-editor" value="<?php echo attribute_escape( __( 'Send to Editor' ) ); ?>" />
1158
1159 <?php endif; ?>
1160
1161 </p>
1162 <br class="clear" />
1163 </div>
1164 </div>
1165 </div>
1166
1167 <div class="postbox">
1168 <h3><?php _e( 'Poll results' ); ?></h3>
1169 <div class="inside">
1170 <ul class="poll-options">
1171
1172 <?php
1173 foreach ( array( 'show' => __( 'Show results to voters' ), 'percent' => __( 'Only show percentages' ), 'hide' => __( 'Hide all results' ) ) as $value => $label ) :
1174 if ( $is_POST )
1175 $checked = $value === $_POST['resultsType'] ? ' checked="checked"' : '';
1176 else
1177 $checked = $value === $poll->resultsType ? ' checked="checked"' : '';
1178 ?>
1179
1180 <li>
1181 <label for="resultsType-<?php echo $value; ?>"><input type="radio"<?php echo $checked; ?> value="<?php echo $value; ?>" name="resultsType" id="resultsType-<?php echo $value; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
1182 </li>
1183
1184 <?php endforeach; ?>
1185
1186 </ul>
1187 </div>
1188 </div>
1189
1190 <div class="postbox">
1191 <h3><?php _e( 'Block repeat voters' ); ?></h3>
1192 <div class="inside">
1193 <ul class="poll-options">
1194
1195 <?php
1196 foreach ( array( 'off' => __( "Don't block repeat voters" ), 'cookie' => __( 'Block by cookie (recommended)' ), 'cookieIP' => __( 'Block by cookie and by IP address' ) ) as $value => $label ) :
1197 if ( $is_POST )
1198 $checked = $value === $_POST['blockRepeatVotersType'] ? ' checked="checked"' : '';
1199 else
1200 $checked = $value === $poll->blockRepeatVotersType ? ' checked="checked"' : '';
1201 ?>
1202
1203 <li>
1204 <label for="blockRepeatVotersType-<?php echo $value; ?>"><input type="radio"<?php echo $checked; ?> value="<?php echo $value; ?>" name="blockRepeatVotersType" id="blockRepeatVotersType-<?php echo $value; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
1205 </li>
1206
1207 <?php endforeach; ?>
1208
1209 </ul>
1210 <p>Note: Blocking by cookie and IP address can be problematic for some voters.</p>
1211 </div>
1212 </div>
1213 </div>
1214
1215
1216 <div id="post-body-content" class="has-sidebar-content">
1217
1218 <div id="titlediv">
1219 <div id="titlewrap">
1220 <input type="text" autocomplete="off" id="title" value="<?php echo $question; ?>" tabindex="1" size="30" name="question" />
1221 </div>
1222 </div>
1223
1224 <div id="answersdiv" class="postbox">
1225 <h3><?php _e( 'Answers' ); ?></h3>
1226
1227 <div id="answerswrap" class="inside">
1228 <ul id="answers">
1229 <?php
1230 $a = 0;
1231 $answers = array();
1232 if ( $is_POST && $_POST['answer'] ) {
1233 foreach( $_POST['answer'] as $answer_id => $answer )
1234 $answers[attribute_escape($answer_id)] = attribute_escape( stripslashes($answer) );
1235 } elseif ( isset( $poll->answers->answer ) ) {
1236 foreach ( $poll->answers->answer as $answer )
1237 $answers[(int) $answer->_id] = attribute_escape( $answer->text );
1238 }
1239
1240 foreach ( $answers as $answer_id => $answer ) :
1241 $a++;
1242 $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete-answer', 'poll' => $poll_id, 'answer' => $answer_id, 'message' => false ) ), "delete-answer_$answer_id" ) );
1243 ?>
1244
1245 <li>
1246 <span class="handle" title="<?php echo attribute_escape( 'click and drag to move' ); ?>">&#x2195;</span>
1247 <div><input type="text" autocomplete="off" id="answer-<?php echo $answer_id; ?>" value="<?php echo $answer; ?>" tabindex="2" size="30" name="answer[<?php echo $answer_id; ?>]" /></div>
1248 <a href="<?php echo $delete_link; ?>" class="delete-answer delete" title="<?php echo attribute_escape( 'delete this answer' ); ?>">&times;</a>
1249 </li>
1250
1251 <?php
1252 endforeach;
1253
1254 while ( 3 - $a > 0 ) :
1255 $a++;
1256 ?>
1257
1258 <li>
1259 <span class="handle" title="<?php echo attribute_escape( 'click and drag to move' ); ?>">&#x2195;</span>
1260 <div><input type="text" autocomplete="off" value="" tabindex="2" size="30" name="answer[new<?php echo $a; ?>]" /></div>
1261 <a href="#" class="delete-answer delete" title="<?php echo attribute_escape( 'delete this answer' ); ?>">&times;</a>
1262 </li>
1263
1264 <?php
1265 endwhile;
1266 ?>
1267
1268 </ul>
1269
1270 <p id="add-answer-holder">
1271 <button class="button"><?php echo wp_specialchars( __( 'Add another' ) ); ?></button>
1272 </p>
1273
1274 <ul id="answer-options">
1275
1276 <?php
1277 foreach ( array( 'multipleChoice' => __( 'Multiple choice' ), 'randomiseAnswers' => __( 'Randomize answer order' ), 'otherAnswer' => __( 'Allow other answers' ), 'sharing' => __( "'Share This' link" ) ) as $option => $label ) :
1278 if ( $is_POST )
1279 $checked = 'yes' === $_POST[$option] ? ' checked="checked"' : '';
1280 else
1281 $checked = 'yes' === $poll->$option ? ' checked="checked"' : '';
1282 ?>
1283
1284 <li>
1285 <label for="<?php echo $option; ?>"><input type="checkbox"<?php echo $checked; ?> value="yes" id="<?php echo $option; ?>" name="<?php echo $option; ?>" /> <?php echo wp_specialchars( $label ); ?></label>
1286 </li>
1287
1288 <?php endforeach; ?>
1289
1290 </ul>
1291 </div>
1292 </div>
1293
1294 <div id="design" class="postbox">
1295
1296 <?php $style_ID = (int) ( $is_POST ? $_POST['styleID'] : $poll->styleID );
1297
1298 $iframe_view = false;
1299 if ( isset($_GET['iframe']) )
1300 $iframe_view = true;
1301
1302 $polldaddy->reset();
1303 $styles = $polldaddy->get_styles();
1304
1305 $show_custom = false;
1306 if( isset( $styles ) && count( $styles ) > 0 ){
1307 $show_custom = true;
1308 }
1309
1310 if ( $style_ID > 18 ){
1311 $standard_style_ID = 0;
1312 $custom_style_ID = $style_ID;
1313 }
1314 else{
1315 $standard_style_ID = $style_ID;
1316 $custom_style_ID = 0;
1317 }
1318 ?>
1319
1320 <h3><?php _e( 'Design' ); ?></h3>
1321 <input type="hidden" name="styleID" id="styleID" value="<?php echo $style_ID ?>">
1322 <div class="inside">
1323 <?php if ( $iframe_view ){ ?>
1324 <div id="design_standard" style="padding:0px;">
1325 <div class="hide-if-no-js">
1326 <table class="pollStyle">
1327 <thead>
1328 <tr>
1329 <th>
1330 <div style="display:none;">
1331 <input type="radio" name="styleTypeCB" id="regular" onclick="javascript:pd_build_styles( 0 );"/>
1332 </div>
1333 </th>
1334 </tr>
1335 </thead>
1336 <tr>
1337 <td class="selector">
1338 <table class="st_selector">
1339 <tr>
1340 <td class="dir_left">
1341 <a href="javascript:pd_move('prev');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">&#171;</a>
1342 </td>
1343 <td class="img"><div class="st_image_loader"><div id="st_image" onmouseover="st_results(this, 'show');" onmouseout="st_results(this, 'hide');"></div></div></td>
1344 <td class="dir_right">
1345 <a href="javascript:pd_move('next');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">&#187;</a>
1346 </td>
1347 </tr>
1348 <tr>
1349 <td></td>
1350 <td class="counter">
1351 <div id="st_number"></div>
1352 </td>
1353 <td></td>
1354 </tr>
1355 <tr>
1356 <td></td>
1357 <td class="title">
1358 <div id="st_name"></div>
1359 </td>
1360 <td></td>
1361 </tr>
1362 <tr>
1363 <td></td>
1364 <td>
1365 <div id="st_sizes"></div>
1366 </td>
1367 <td></td>
1368 </tr>
1369 <tr>
1370 <td colspan="3">
1371 <div id="st_description"></div>
1372 </td>
1373 </tr>
1374 </table>
1375 </td>
1376 </tr>
1377 </table>
1378 </div>
1379
1380 <p class="hide-if-js" id="no-js-styleID">
1381 <select name="styleID">
1382
1383 <?php foreach ( $options as $styleID => $label ) :
1384 $selected = $styleID == $standard_style_ID ? ' selected="selected"' : ''; ?>
1385 <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option>
1386 <?php endforeach; ?>
1387
1388 </select>
1389 </p>
1390 </div>
1391 <?php if ( $show_custom ){ ?>
1392 <div id="design_custom">
1393 <p class="hide-if-no-js">
1394 <table class="pollStyle">
1395 <thead>
1396 <tr>
1397 <th>
1398 <div style="display:none;">
1399 <?php $disabled = $show_custom == false ? ' disabled="true"' : ''; ?>
1400 <input type="radio" name="styleTypeCB" id="custom" onclick="javascript:pd_change_style($('customSelect').value);" <?php echo $disabled; ?>></input>
1401 <label onclick="javascript:pd_change_style($('customSelect').value);">Custom Style</label>
1402 </div>
1403 </th>
1404 </tr>
1405 </thead>
1406 <tbody>
1407 <tr>
1408 <td class="customSelect">
1409 <table>
1410 <tr>
1411 <td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
1412 <select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>>
1413 <?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?>
1414 <option value="x"<?php echo $selected; ?>>Please choose a custom style...</option>
1415 <?php foreach ( $styles->style as $style ) :
1416 $selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?>
1417 <option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option>
1418 <?php endforeach;?>
1419 </select>
1420 <div id="styleIDErr" class="formErr" style="display:none;">Please choose a style.</div></td>
1421 </tr>
1422 <tr>
1423 <td><?php $extra = $show_custom == false ? 'You currently have no custom styles created.' : ''; ?>
1424 <p><?php echo $extra ?></p>
1425 <p>Did you know we have a new editor for building your own custom poll styles? Find out more <a href="http://support.polldaddy.com/custom-poll-styles/" target="_blank">here</a>.</p>
1426 </td>
1427 </tr>
1428 </table>
1429 </td>
1430 </tr>
1431 </tbody>
1432 </table>
1433 </p>
1434 </div>
1435 <div id="design_options">
1436 <a href="#" class="polldaddy-show-design-options"><?php _e( 'Custom Styles' ); ?></a>
1437 </div>
1438 <?php }}else{?>
1439 <div class="design_standard">
1440 <div class="hide-if-no-js">
1441 <table class="pollStyle">
1442 <thead>
1443 <tr>
1444 <th class="cb">
1445 <input type="radio" name="styleTypeCB" id="regular" onclick="javascript:pd_build_styles( 0 );"/>
1446 </th>
1447 <th>
1448 <label for="skin" onclick="javascript:pd_build_styles( 0 );">PollDaddy Style</label>
1449 </th>
1450 <th/>
1451 <th class="cb">
1452 <?php $disabled = $show_custom == false ? ' disabled="true"' : ''; ?>
1453 <input type="radio" name="styleTypeCB" id="custom" onclick="javascript:pd_change_style($('customSelect').value);" <?php echo $disabled; ?>></input>
1454 </th>
1455 <th>
1456 <label onclick="javascript:pd_change_style($('customSelect').value);">Custom Style</label>
1457 </th>
1458 </tr>
1459 </thead>
1460 <tbody>
1461 <tr>
1462 <td/>
1463 <td class="selector">
1464 <table class="st_selector">
1465 <tr>
1466 <td class="dir_left">
1467 <a href="javascript:pd_move('prev');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">&#171;</a>
1468 </td>
1469 <td class="img"><div class="st_image_loader"><div id="st_image" onmouseover="st_results(this, 'show');" onmouseout="st_results(this, 'hide');"></div></div></td>
1470 <td class="dir_right">
1471 <a href="javascript:pd_move('next');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">&#187;</a>
1472 </td>
1473 </tr>
1474 <tr>
1475 <td></td>
1476 <td class="counter">
1477 <div id="st_number"></div>
1478 </td>
1479 <td></td>
1480 </tr>
1481 <tr>
1482 <td></td>
1483 <td class="title">
1484 <div id="st_name"></div>
1485 </td>
1486 <td></td>
1487 </tr>
1488 <tr>
1489 <td></td>
1490 <td>
1491 <div id="st_sizes"></div>
1492 </td>
1493 <td></td>
1494 </tr>
1495 <tr>
1496 <td colspan="3">
1497 <div id="st_description"></div>
1498 </td>
1499 </tr>
1500 </table>
1501 </td>
1502 <td width="100"></td>
1503 <td/>
1504 <td class="customSelect">
1505 <table>
1506 <tr>
1507 <td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
1508 <select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>>
1509 <?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?>
1510 <option value="x"<?php echo $selected; ?>>Please choose a custom style...</option>
1511 <?php foreach ( $styles->style as $style ) :
1512 $selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?>
1513 <option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option>
1514 <?php endforeach;?>
1515 </select>
1516 <div id="styleIDErr" class="formErr" style="display:none;">Please choose a style.</div></td>
1517 </tr>
1518 <tr>
1519 <td><?php $extra = $show_custom == false ? 'You currently have no custom styles created.' : ''; ?>
1520 <p><?php echo $extra ?></p>
1521 <p>Did you know we have a new editor for building your own custom poll styles? Find out more <a href="http://support.polldaddy.com/custom-poll-styles/" target="_blank">here</a>.</p>
1522 </td>
1523 </tr>
1524 </table>
1525 </td>
1526 </tr>
1527 </tbody>
1528 </table>
1529 </div>
1530 <p class="hide-if-js" id="no-js-styleID">
1531 <select name="styleID">
1532
1533 <?php foreach ( $options as $styleID => $label ) :
1534 $selected = $styleID == $standard_style_ID ? ' selected="selected"' : ''; ?>
1535 <option value="<?php echo (int) $styleID; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $label ); ?></option>
1536 <?php endforeach; ?>
1537
1538 </select>
1539 </p>
1540 </div>
1541 <?php } ?>
1542 <script language="javascript">
1543 current_pos = 0;
1544 pd_build_styles( current_pos );
1545 <?php if( $style_ID > 0 && $style_ID <= 1000 ){ ?>
1546 pd_pick_style( <?php echo $style_ID ?> );
1547 <?php }else{ ?>
1548 pd_change_style( <?php echo $style_ID ?> );
1549 <?php } ?>
1550 </script>
1551 </div>
1552
1553 </div>
1554
1555 </div>
1556 </div></div>
1557 </form>
1558 <br class="clear" />
1559
1560 <?php
1561 }
1562
1563 function poll_results_page( $poll_id ) {
1564 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
1565 $polldaddy->reset();
1566
1567 $results = $polldaddy->get_poll_results( $poll_id );
1568 ?>
1569
1570 <table class="poll-results widefat">
1571 <thead>
1572 <tr>
1573 <th scope="col" class="column-title"><?php _e( 'Answer' ); ?></th>
1574 <th scope="col" class="column-vote"><?php _e( 'Votes' ); ?></th>
1575 </tr>
1576 </thead>
1577 <tbody>
1578
1579 <?php
1580 $class = '';
1581 foreach ( $results->answers as $answer ) :
1582 $answer->text = trim( strip_tags( $answer->text ) );
1583 if( strlen( $answer->text ) == 0 ){
1584 $answer->text = '-- empty HTML tag --';
1585 }
1586
1587 $class = $class ? '' : ' class="alternate"';
1588 $content = $results->others && 'Other answer...' === $answer->text ? sprintf( __( 'Other (<a href="%s">see below</a>)' ), '#other-answers-results' ) : wp_specialchars( $answer->text );
1589
1590 ?>
1591
1592 <tr<?php echo $class; ?>>
1593 <th scope="row" class="column-title"><?php echo $content; ?></th>
1594 <td class="column-vote">
1595 <div class="result-holder">
1596 <span class="result-bar" style="width: <?php echo number_format( $answer->_percent, 2 ); ?>%;">&nbsp;</span>
1597 <span class="result-total alignleft"><?php echo number_format_i18n( $answer->_total ); ?></span>
1598 <span class="result-percent alignright"><?php echo number_format_i18n( $answer->_percent ); ?>%</span>
1599 </div>
1600 </td>
1601 </tr>
1602 <?php
1603 endforeach;
1604 ?>
1605
1606 </tbody>
1607 </table>
1608
1609 <?php
1610
1611 if ( !$results->others )
1612 return;
1613 ?>
1614
1615 <table id="other-answers-results" class="poll-others widefat">
1616 <thead>
1617 <tr>
1618 <th scope="col" class="column-title"><?php _e( 'Other Answer' ); ?></th>
1619 <th scope="col" class="column-vote"><?php _e( 'Votes' ); ?></th>
1620 </tr>
1621 </thead>
1622 <tbody>
1623
1624 <?php
1625 $class = '';
1626 $others = array_count_values( $results->others );
1627 arsort( $others );
1628 foreach ( $others as $other => $freq ) :
1629 $class = $class ? '' : ' class="alternate"';
1630 ?>
1631
1632 <tr<?php echo $class; ?>>
1633 <th scope="row" class="column-title"><?php echo wp_specialchars( $other ); ?></th>
1634 <td class="column-vote"><?php echo number_format_i18n( $freq ); ?></td>
1635 </tr>
1636 <?php
1637 endforeach;
1638 ?>
1639
1640 </tbody>
1641 </table>
1642
1643 <?php
1644 }
1645
1646 function styles_table() {
1647 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
1648 $polldaddy->reset();
1649
1650 $styles_object = $polldaddy->get_styles();
1651
1652 $this->parse_errors( $polldaddy );
1653 $this->print_errors();
1654 $styles = & $styles_object->style;
1655 $class = '';
1656 $styles_exist = false;
1657
1658 foreach ( $styles as $style ) :
1659 if( (int) $style->_type == 1 ):
1660 $styles_exist = true;
1661 break;
1662 endif;
1663 endforeach;
1664 ?>
1665
1666 <form method="post" action="">
1667 <div class="tablenav">
1668 <div class="alignleft">
1669 <select name="action">
1670 <option selected="selected" value=""><?php _e( 'Actions' ); ?></option>
1671 <option value="delete-style"><?php _e( 'Delete' ); ?></option>
1672 </select>
1673 <input class="button-secondary action" type="submit" name="doaction" value="<?php _e( 'Apply' ); ?>" />
1674 <?php wp_nonce_field( 'action-style_bulk' ); ?>
1675 </div>
1676 <div class="tablenav-pages"><?php echo $page_links; ?></div>
1677 </div>
1678 <br class="clear" />
1679 <table class="widefat">
1680 <thead>
1681 <tr>
1682 <th id="cb" class="manage-column column-cb check-column" scope="col" /><input type="checkbox" /></th>
1683 <th id="title" class="manage-column column-title" scope="col">Style</th>
1684 <th id="date" class="manage-column column-date" scope="col">Last Modified</th>
1685 </tr>
1686 </thead>
1687 <tbody>
1688
1689 <?php
1690 if ( $styles_exist ) :
1691 foreach ( $styles as $style ) :
1692 if( (int) $style->_type == 1 ):
1693 $style_id = (int) $style->_id;
1694
1695 $class = $class ? '' : ' class="alternate"';
1696 $edit_link = clean_url( add_query_arg( array( 'action' => 'edit-style', 'style' => $style_id, 'message' => false ) ) );
1697 $delete_link = clean_url( wp_nonce_url( add_query_arg( array( 'action' => 'delete-style', 'style' => $style_id, 'message' => false ) ), "delete-style_$style_id" ) );
1698 list($style_time) = explode( '.', $style->date );
1699 $style_time = strtotime( $style_time );
1700 ?>
1701
1702 <tr<?php echo $class; ?>>
1703 <th class="check-column" scope="row"><input type="checkbox" value="<?php echo (int) $style_id; ?>" name="style[]" /></th>
1704 <td class="post-title column-title">
1705 <?php if ( $edit_link ) : ?>
1706 <strong><a class="row-title" href="<?php echo $edit_link; ?>"><?php echo wp_specialchars( $style->title ); ?></a></strong>
1707 <span class="edit"><a href="<?php echo $edit_link; ?>"><?php _e( 'Edit' ); ?></a> | </span>
1708 <?php else : ?>
1709 <strong><?php echo wp_specialchars( $style->title ); ?></strong>
1710 <?php endif; ?>
1711
1712 <span class="delete"><a class="delete-poll delete" href="<?php echo $delete_link; ?>"><?php _e( 'Delete' ); ?></a></span>
1713 </td>
1714 <td class="date column-date"><abbr title="<?php echo date( __('Y/m/d g:i:s A'), $style_time ); ?>"><?php echo date( __('Y/m/d'), $style_time ); ?></abbr></td>
1715 </tr>
1716
1717 <?php
1718 endif;
1719 endforeach;
1720 else : // $styles
1721 ?>
1722
1723 <tr>
1724 <td colspan="4"><?php printf( __( 'No custom styles yet. <a href="%s">Create one</a>' ), clean_url( add_query_arg( array( 'action' => 'create-style' ) ) ) ); ?></td>
1725 </tr>
1726 <?php endif; // $styles ?>
1727
1728 </tbody>
1729 </table>
1730 </form>
1731 <div class="tablenav">
1732 <div class="tablenav-pages"><?php echo $page_links; ?></div>
1733 </div>
1734 <br class="clear" />
1735
1736 <?php
1737 }
1738
1739 function style_edit_form( $style_id = 105 ) {
1740 $style_id = (int) $style_id;
1741
1742 $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
1743 $polldaddy->reset();
1744
1745 $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
1746
1747 if ( $style_id ) {
1748 $style = $polldaddy->get_style( $style_id );
1749 $this->parse_errors( $polldaddy );
1750 } else {
1751 $style = polldaddy_style( array(), null, false );
1752 }
1753
1754 $style->css = trim( urldecode( $style->css ) );
1755
1756 if ( $start = stripos( $style->css, '<data>' ) ){
1757 $style->css = substr( $style->css, $start );
1758 }
1759
1760 $style->css = addslashes( $style->css );
1761
1762 $preload_style_id = 0;
1763 $preload_style = null;
1764
1765 if ( isset ( $_REQUEST['preload'] ) )
1766 {
1767 $preload_style_id = (int) $_REQUEST['preload'];
1768
1769 if ( $preload_style_id > 1000 || $preload_style_id < 100 )
1770 {
1771 $preload_style_id = 0;
1772 }
1773
1774 if ( $preload_style_id > 0 ) {
1775 $polldaddy->reset();
1776 $preload_style = $polldaddy->get_style( $preload_style_id );
1777 $this->parse_errors( $polldaddy );
1778 }
1779
1780 $preload_style->css = trim( urldecode( $preload_style->css ) );
1781
1782 if ( $start = stripos( $preload_style->css, '<data>' ) ){
1783 $preload_style->css = substr( $preload_style->css, $start );
1784 }
1785
1786 $style->css = addslashes( $preload_style->css );
1787 }
1788
1789 $this->print_errors();
1790
1791 echo '<script language="javascript">var CSSXMLString = "' . $style->css .'";</script>';
1792 ?>
1793
1794 <form action="" method="post">
1795 <div id="poststuff">
1796 <div id="post-body">
1797 <br/>
1798 <table width="100%">
1799 <tr>
1800 <td colspan="2">
1801 <table width="100%">
1802 <tr>
1803 <td valign="middle" width="8%">
1804 <label class="CSSE_title_label"><?php _e( 'Style Name' ); ?></label>
1805 </td>
1806 <td>
1807 <div id="titlediv" style="margin:0px;">
1808 <div id="titlewrap">
1809 <input type="text" autocomplete="off" id="title" value="<?php echo $style_id > 1000 ? $style->title : ''; ?>" tabindex="1" size="30" name="style-title"></input>
1810 </div>
1811 </div>
1812 </td>
1813 </tr>
1814 </table>
1815 </td>
1816 </tr>
1817 <tr>
1818 <td width="13%">
1819 <label class="CSSE_title_label"><?php _e( 'Preload Basic Style' ); ?></label>
1820 </td>
1821 <td>
1822 <div class="CSSE_preload">
1823 <select id="preload_value">
1824 <option value="0"></option>
1825 <option value="102">Aluminum</option>
1826 <option value="105">Plain White</option>
1827 <option value="108">Plain Black</option>
1828 <option value="111">Paper</option>
1829 <option value="114">Skull Dark</option>
1830 <option value="117">Skull Light</option>
1831 <option value="157">Micro</option>
1832 </select>
1833 <a tabindex="4" id="style-preload" href="javascript:preload_pd_style();" class="button"><?php echo attribute_escape( __( 'Load Style' ) ); ?></a>
1834 </div>
1835 </td>
1836 </tr>
1837 <tr>
1838 <td width="13%">
1839 <p>Choose a part to edit...</p>
1840 </td>
1841 <td>
1842 <select id="styleName" onchange="renderStyleEdit(this.value);">
1843 <option value="pds-box" selected="selected">Poll Box</option>
1844 <option value="pds-question-top">Question</option>
1845 <option value="pds-answer-group">Answer Group</option>
1846 <option value="pds-answer-input">Answer Check</option>
1847 <option value="pds-answer">Answers</option>
1848 <option value="pds-textfield">Other Input</option>
1849 <option value="pds-vote-button">Vote Button</option>
1850 <option value="pds-link">Links</option>
1851 <option value="pds-answer-feedback">Result Background</option>
1852 <option value="pds-answer-feedback-bar">Result Bar</option>
1853 <option value="pds-totalvotes-inner">Total Votes</option>
1854 </select>
1855 </td>
1856 </tr>
1857 </table>
1858 <table width="100%">
1859 <tr>
1860 <td valign="top">
1861 <table class="CSSE_main">
1862 <tr>
1863 <td class="CSSE_main_l" valign="top">
1864 <div class="off" id="D_Font">
1865 <a href="javascript:CSSE_changeView('Font');" id="A_Font" class="Aoff">Font</a>
1866 </div>
1867 <div class="on" id="D_Background">
1868 <a href="javascript:CSSE_changeView('Background');" id="A_Background" class="Aon">Background</a>
1869 </div>
1870 <div class="off" id="D_Border">
1871 <a href="javascript:CSSE_changeView('Border');" id="A_Border" class="Aoff">Border</a>
1872 </div>
1873 <div class="off" id="D_Margin">
1874 <a href="javascript:CSSE_changeView('Margin');" id="A_Margin" class="Aoff">Margin</a>
1875 </div>
1876 <div class="off" id="D_Padding">
1877 <a href="javascript:CSSE_changeView('Padding');" id="A_Padding" class="Aoff">Padding</a>
1878 </div>
1879 <div class="off" id="D_Scale">
1880 <a href="javascript:CSSE_changeView('Scale');" id="A_Scale" class="Aoff">Width</a>
1881 </div>
1882 <div class="off" id="D_Height">
1883 <a href="javascript:CSSE_changeView('Height');" id="A_Height" class="Aoff">Height</a>
1884 </div>
1885 </td>
1886 <td class="CSSE_main_r" valign="top">
1887 <table class="CSSE_sub">
1888 <tr>
1889 <td class="top"/>
1890 </tr>
1891 <tr>
1892 <td class="mid">
1893 <!-- Font Table -->
1894 <table class="CSSE_edit" id="editFont" style="display:none;">
1895 <tr>
1896 <td width="85">Font Size:</td>
1897 <td>
1898 <select id="font-size" onchange="bind(this);">
1899 <option value="6px">6px</option>
1900 <option value="8px">8px</option>
1901 <option value="9px">9px</option>
1902 <option value="10px">10px</option>
1903 <option value="11px">11px</option>
1904 <option value="12px">12px</option>
1905 <option value="13px">13px</option>
1906 <option value="14px">14px</option>
1907 <option value="15px">15px</option>
1908 <option value="16px">16px</option>
1909 <option value="18px">18px</option>
1910 <option value="20px">20px</option>
1911 <option value="24px">24px</option>
1912 <option value="30px">30px</option>
1913 <option value="36px">36px</option>
1914 </select>
1915 </td>
1916 </tr>
1917 <tr>
1918 <td>Font Size</td>
1919 <td>
1920 <select id="font-family" onchange="bind(this);">
1921 <option value="Arial">Arial</option>
1922 <option value="Comic Sans MS">Comic Sans MS</option>
1923 <option value="Courier">Courier</option>
1924 <option value="Georgia">Georgia</option>
1925 <option value="Lucida Grande">Lucida Grande</option>
1926 <option value="Trebuchet MS">Trebuchet MS</option>
1927 <option value="Times">Times</option>
1928 <option value="Verdana">Verdana</option>
1929 </select>
1930 </td>
1931 </tr>
1932 <tr>
1933 <td>Color (#hex):</td>
1934 <td>
1935 <input type="text" maxlength="11" id="color" class="elmColor jscolor-picker" onblur="bind(this);" style="float:left;"/>
1936 </td>
1937 </tr>
1938 <tr>
1939 <td>Bold:</td>
1940 <td>
1941 <input type="checkbox" id="font-weight" value="bold" onclick="bind(this);"/>
1942 </td>
1943 </tr>
1944 <tr>
1945 <td>Italic:</td>
1946 <td>
1947 <input type="checkbox" id="font-style" value="italic" onclick="bind(this);"/>
1948 </td>
1949 </tr>
1950 <tr>
1951 <td>Underline:</td>
1952 <td>
1953 <input type="checkbox" id="text-decoration" value="underline" onclick="bind(this);"/>
1954 </td>
1955 </tr>
1956 <tr>
1957 <td>Line Height:</td>
1958 <td>
1959 <select id="line-height" onchange="bind(this);">
1960 <option value="6px">6px</option>
1961 <option value="8px">8px</option>
1962 <option value="9px">9px</option>
1963 <option value="10px">10px</option>
1964 <option value="11px">11px</option>
1965 <option value="12px">12px</option>
1966 <option value="13px">13px</option>
1967 <option value="14px">14px</option>
1968 <option value="15px">15px</option>
1969 <option value="16px">16px</option>
1970 <option value="18px">18px</option>
1971 <option value="20px">20px</option>
1972 <option value="24px">24px</option>
1973 <option value="30px">30px</option>
1974 <option value="36px">36px</option>
1975 </select>
1976 </td>
1977 </tr>
1978 <tr>
1979 <td>Align:</td>
1980 <td>
1981 <select id="text-align" onchange="bind(this);">
1982 <option value="left">Left</option>
1983 <option value="center">Center</option>
1984 <option value="right">Right</option>
1985 </select>
1986 </td>
1987 </tr>
1988 </table>
1989 <!-- Background Table -->
1990 <table class="CSSE_edit" id="editBackground" style="display:none;">
1991 <tr>
1992 <td width="85">Color (#hex):</td>
1993 <td>
1994 <input type="text" maxlength="11" id="background-color" class="elmColor jscolor-picker" onblur="bind(this);"/>
1995 </td>
1996 </tr>
1997 <tr>
1998 <td>Image URL: <a class="noteLink" title="Click here for more information" onclick="showNote('noteImageURL',this, 'Image URL');">(?)</a></td>
1999 <td>
2000 <input type="text" id="background-image" onblur="bind(this);"/>
2001 </td>
2002 </tr>
2003 <tr>
2004 <td>Image Repeat:</td>
2005 <td>
2006 <select id="background-repeat" onchange="bind(this);">
2007 <option value="repeat">repeat</option>
2008 <option value="no-repeat">no-repeat</option>
2009 <option value="repeat-x">repeat-x</option>
2010 <option value="repeat-y">repeat-y</option>
2011 </select>
2012 </td>
2013 </tr>
2014 <tr>
2015 <td>Image Position:</td>
2016 <td>
2017 <select id="background-position" onchange="bind(this);">
2018 <option value="left top">left top</option>
2019 <option value="left center">left center</option>
2020 <option value="left bottom">left bottom</option>
2021 <option value="center top">center top</option>
2022 <option value="center center">center center</option>
2023 <option value="center bottom">center bottom</option>
2024 <option value="right top">right top</option>
2025 <option value="right center">right center</option>
2026 <option value="right bottom">right bottom</option>
2027 </select>
2028 </td>
2029 </tr>
2030 </table>
2031 <!-- Border Table -->
2032 <table class="CSSE_edit" id="editBorder" style="display:none;">
2033 <tr>
2034 <td width="85">Width:</td>
2035 <td>
2036 <select id="border-width" onchange="bind(this);">
2037 <option value="0px">0px</option>
2038 <option value="1px">1px</option>
2039 <option value="2px">2px</option>
2040 <option value="3px">3px</option>
2041 <option value="4px">4px</option>
2042 <option value="5px">5px</option>
2043 <option value="6px">6px</option>
2044 <option value="7px">7px</option>
2045 <option value="8px">8px</option>
2046 <option value="9px">9px</option>
2047 <option value="10px">10px</option>
2048 <option value="11px">11px</option>
2049 <option value="12px">12px</option>
2050 <option value="13px">13px</option>
2051 <option value="14px">14px</option>
2052 <option value="15px">15px</option>
2053 <option value="16px">16px</option>
2054 <option value="17px">17px</option>
2055 <option value="18px">18px</option>
2056 <option value="19px">19px</option>
2057 <option value="20px">20px</option>
2058 <option value="21px">21px</option>
2059 <option value="22px">22px</option>
2060 <option value="23px">23px</option>
2061 <option value="24px">24px</option>
2062 <option value="25px">25px</option>
2063 <option value="26px">26px</option>
2064 <option value="27px">27px</option>
2065 <option value="28px">28px</option>
2066 <option value="29px">29px</option>
2067 <option value="30px">30px</option>
2068 </select>
2069 </td>
2070 </tr>
2071 <tr>
2072 <td>Style:</td>
2073 <td>
2074 <select id="border-style" onchange="bind(this);">
2075 <option value="none">none</option>
2076 <option value="solid">solid</option>
2077 <option value="dotted">dotted</option>
2078 <option value="dashed">dashed</option>
2079 <option value="double">double</option>
2080 <option value="groove">groove</option>
2081 <option value="inset">inset</option>
2082 <option value="outset">outset</option>
2083 <option value="ridge">ridge</option>
2084 <option value="hidden">hidden</option>
2085 </select>
2086 </td>
2087 </tr>
2088 <tr>
2089 <td>Color (#hex):</td>
2090 <td>
2091 <input type="text" maxlength="11" class="elmColor jscolor-picker" id="border-color" onblur="bind(this);"/>
2092 </td>
2093 </tr>
2094 <tr>
2095 <td width="85">Rounded Corners:</td>
2096 <td>
2097 <select id="border-radius" onchange="bind(this);">
2098 <option value="0px">0px</option>
2099 <option value="1px">1px</option>
2100 <option value="2px">2px</option>
2101 <option value="3px">3px</option>
2102 <option value="4px">4px</option>
2103 <option value="5px">5px</option>
2104 <option value="6px">6px</option>
2105 <option value="7px">7px</option>
2106 <option value="8px">8px</option>
2107 <option value="9px">9px</option>
2108 <option value="10px">10px</option>
2109 <option value="11px">11px</option>
2110 <option value="12px">12px</option>
2111 <option value="13px">13px</option>
2112 <option value="14px">14px</option>
2113 <option value="15px">15px</option>
2114 <option value="16px">16px</option>
2115 <option value="17px">17px</option>
2116 <option value="18px">18px</option>
2117 <option value="19px">19px</option>
2118 <option value="20px">20px</option>
2119 <option value="21px">21px</option>
2120 <option value="22px">22px</option>
2121 <option value="23px">23px</option>
2122 <option value="24px">24px</option>
2123 <option value="25px">25px</option>
2124 <option value="26px">26px</option>
2125 <option value="27px">27px</option>
2126 <option value="28px">28px</option>
2127 <option value="29px">29px</option>
2128 <option value="30px">30px</option>
2129 </select>
2130 <br/>
2131 Not supported in Internet Explorer.
2132 </td>
2133 </tr>
2134 </table>
2135 <!-- Margin Table -->
2136 <table class="CSSE_edit" id="editMargin" style="display:none;">
2137 <tr>
2138 <td width="85">Top: </td>
2139 <td>
2140 <select id="margin-top" onchange="bind(this);">
2141 <option value="0px">0px</option>
2142 <option value="1px">1px</option>
2143 <option value="2px">2px</option>
2144 <option value="3px">3px</option>
2145 <option value="4px">4px</option>
2146 <option value="5px">5px</option>
2147 <option value="6px">6px</option>
2148 <option value="7px">7px</option>
2149 <option value="8px">8px</option>
2150 <option value="9px">9px</option>
2151 <option value="10px">10px</option>
2152 <option value="11px">11px</option>
2153 <option value="12px">12px</option>
2154 <option value="13px">13px</option>
2155 <option value="14px">14px</option>
2156 <option value="15px">15px</option>
2157 <option value="16px">16px</option>
2158 <option value="17px">17px</option>
2159 <option value="18px">18px</option>
2160 <option value="19px">19px</option>
2161 <option value="20px">20px</option>
2162 <option value="21px">21px</option>
2163 <option value="22px">22px</option>
2164 <option value="23px">23px</option>
2165 <option value="24px">24px</option>
2166 <option value="25px">25px</option>
2167 <option value="26px">26px</option>
2168 <option value="27px">27px</option>
2169 <option value="28px">28px</option>
2170 <option value="29px">29px</option>
2171 <option value="30px">30px</option>
2172 </select>
2173 </td>
2174 </tr>
2175 <tr>
2176 <td>Right:</td>
2177 <td>
2178 <select id="margin-right" onchange="bind(this);">
2179 <option value="0px">0px</option>
2180 <option value="1px">1px</option>
2181 <option value="2px">2px</option>
2182 <option value="3px">3px</option>
2183 <option value="4px">4px</option>
2184 <option value="5px">5px</option>
2185 <option value="6px">6px</option>
2186 <option value="7px">7px</option>
2187 <option value="8px">8px</option>
2188 <option value="9px">9px</option>
2189 <option value="10px">10px</option>
2190 <option value="11px">11px</option>
2191 <option value="12px">12px</option>
2192 <option value="13px">13px</option>
2193 <option value="14px">14px</option>
2194 <option value="15px">15px</option>
2195 <option value="16px">16px</option>
2196 <option value="17px">17px</option>
2197 <option value="18px">18px</option>
2198 <option value="19px">19px</option>
2199 <option value="20px">20px</option>
2200 <option value="21px">21px</option>
2201 <option value="22px">22px</option>
2202 <option value="23px">23px</option>
2203 <option value="24px">24px</option>
2204 <option value="25px">25px</option>
2205 <option value="26px">26px</option>
2206 <option value="27px">27px</option>
2207 <option value="28px">28px</option>
2208 <option value="29px">29px</option>
2209 <option value="30px">30px</option>
2210 </select>
2211 </td>
2212 </tr>
2213 <tr>
2214 <td>Bottom:</td>
2215 <td>
2216 <select id="margin-bottom" onchange="bind(this);">
2217 <option value="0px">0px</option>
2218 <option value="1px">1px</option>
2219 <option value="2px">2px</option>
2220 <option value="3px">3px</option>
2221 <option value="4px">4px</option>
2222 <option value="5px">5px</option>
2223 <option value="6px">6px</option>
2224 <option value="7px">7px</option>
2225 <option value="8px">8px</option>
2226 <option value="9px">9px</option>
2227 <option value="10px">10px</option>
2228 <option value="11px">11px</option>
2229 <option value="12px">12px</option>
2230 <option value="13px">13px</option>
2231 <option value="14px">14px</option>
2232 <option value="15px">15px</option>
2233 <option value="16px">16px</option>
2234 <option value="17px">17px</option>
2235 <option value="18px">18px</option>
2236 <option value="19px">19px</option>
2237 <option value="20px">20px</option>
2238 <option value="21px">21px</option>
2239 <option value="22px">22px</option>
2240 <option value="23px">23px</option>
2241 <option value="24px">24px</option>
2242 <option value="25px">25px</option>
2243 <option value="26px">26px</option>
2244 <option value="27px">27px</option>
2245 <option value="28px">28px</option>
2246 <option value="29px">29px</option>
2247 <option value="30px">30px</option>
2248 </select>
2249 </td>
2250 </tr>
2251 <tr>
2252 <td>Left:</td>
2253 <td>
2254 <select id="margin-left" onchange="bind(this);">
2255 <option value="0px">0px</option>
2256 <option value="1px">1px</option>
2257 <option value="2px">2px</option>
2258 <option value="3px">3px</option>
2259 <option value="4px">4px</option>
2260 <option value="5px">5px</option>
2261 <option value="6px">6px</option>
2262 <option value="7px">7px</option>
2263 <option value="8px">8px</option>
2264 <option value="9px">9px</option>
2265 <option value="10px">10px</option>
2266 <option value="11px">11px</option>
2267 <option value="12px">12px</option>
2268 <option value="13px">13px</option>
2269 <option value="14px">14px</option>
2270 <option value="15px">15px</option>
2271 <option value="16px">16px</option>
2272 <option value="17px">17px</option>
2273 <option value="18px">18px</option>
2274 <option value="19px">19px</option>
2275 <option value="20px">20px</option>
2276 <option value="21px">21px</option>
2277 <option value="22px">22px</option>
2278 <option value="23px">23px</option>
2279 <option value="24px">24px</option>
2280 <option value="25px">25px</option>
2281 <option value="26px">26px</option>
2282 <option value="27px">27px</option>
2283 <option value="28px">28px</option>
2284 <option value="29px">29px</option>
2285 <option value="30px">30px</option>
2286 </select>
2287 </td>
2288 </tr>
2289 </table>
2290 <!-- Padding Table -->
2291 <table class="CSSE_edit" id="editPadding" style="display:none;">
2292 <tr>
2293 <td width="85">Top:</td>
2294 <td>
2295 <select id="padding-top" onchange="bind(this);">
2296 <option value="0px">0px</option>
2297 <option value="1px">1px</option>
2298 <option value="2px">2px</option>
2299 <option value="3px">3px</option>
2300 <option value="4px">4px</option>
2301 <option value="5px">5px</option>
2302 <option value="6px">6px</option>
2303 <option value="7px">7px</option>
2304 <option value="8px">8px</option>
2305 <option value="9px">9px</option>
2306 <option value="10px">10px</option>
2307 <option value="11px">11px</option>
2308 <option value="12px">12px</option>
2309 <option value="13px">13px</option>
2310 <option value="14px">14px</option>
2311 <option value="15px">15px</option>
2312 <option value="16px">16px</option>
2313 <option value="17px">17px</option>
2314 <option value="18px">18px</option>
2315 <option value="19px">19px</option>
2316 <option value="20px">20px</option>
2317 <option value="21px">21px</option>
2318 <option value="22px">22px</option>
2319 <option value="23px">23px</option>
2320 <option value="24px">24px</option>
2321 <option value="25px">25px</option>
2322 <option value="26px">26px</option>
2323 <option value="27px">27px</option>
2324 <option value="28px">28px</option>
2325 <option value="29px">29px</option>
2326 <option value="30px">30px</option>
2327 </select>
2328 </td>
2329 </tr>
2330 <tr>
2331 <td>Right:</td>
2332 <td>
2333 <select id="padding-right" onchange="bind(this);">
2334 <option value="0px">0px</option>
2335 <option value="1px">1px</option>
2336 <option value="2px">2px</option>
2337 <option value="3px">3px</option>
2338 <option value="4px">4px</option>
2339 <option value="5px">5px</option>
2340 <option value="6px">6px</option>
2341 <option value="7px">7px</option>
2342 <option value="8px">8px</option>
2343 <option value="9px">9px</option>
2344 <option value="10px">10px</option>
2345 <option value="11px">11px</option>
2346 <option value="12px">12px</option>
2347 <option value="13px">13px</option>
2348 <option value="14px">14px</option>
2349 <option value="15px">15px</option>
2350 <option value="16px">16px</option>
2351 <option value="17px">17px</option>
2352 <option value="18px">18px</option>
2353 <option value="19px">19px</option>
2354 <option value="20px">20px</option>
2355 <option value="21px">21px</option>
2356 <option value="22px">22px</option>
2357 <option value="23px">23px</option>
2358 <option value="24px">24px</option>
2359 <option value="25px">25px</option>
2360 <option value="26px">26px</option>
2361 <option value="27px">27px</option>
2362 <option value="28px">28px</option>
2363 <option value="29px">29px</option>
2364 <option value="30px">30px</option>
2365 </select>
2366 </td>
2367 </tr>
2368 <tr>
2369 <td>Bottom:</td>
2370 <td>
2371 <select id="padding-bottom" onchange="bind(this);">
2372 <option value="0px">0px</option>
2373 <option value="1px">1px</option>
2374 <option value="2px">2px</option>
2375 <option value="3px">3px</option>
2376 <option value="4px">4px</option>
2377 <option value="5px">5px</option>
2378 <option value="6px">6px</option>
2379 <option value="7px">7px</option>
2380 <option value="8px">8px</option>
2381 <option value="9px">9px</option>
2382 <option value="10px">10px</option>
2383 <option value="11px">11px</option>
2384 <option value="12px">12px</option>
2385 <option value="13px">13px</option>
2386 <option value="14px">14px</option>
2387 <option value="15px">15px</option>
2388 <option value="16px">16px</option>
2389 <option value="17px">17px</option>
2390 <option value="18px">18px</option>
2391 <option value="19px">19px</option>
2392 <option value="20px">20px</option>
2393 <option value="21px">21px</option>
2394 <option value="22px">22px</option>
2395 <option value="23px">23px</option>
2396 <option value="24px">24px</option>
2397 <option value="25px">25px</option>
2398 <option value="26px">26px</option>
2399 <option value="27px">27px</option>
2400 <option value="28px">28px</option>
2401 <option value="29px">29px</option>
2402 <option value="30px">30px</option>
2403 </select>
2404 </td>
2405 </tr>
2406 <tr>
2407 <td>Left:</td>
2408 <td>
2409 <select id="padding-left" onchange="bind(this);">
2410 <option value="0px">0px</option>
2411 <option value="1px">1px</option>
2412 <option value="2px">2px</option>
2413 <option value="3px">3px</option>
2414 <option value="4px">4px</option>
2415 <option value="5px">5px</option>
2416 <option value="6px">6px</option>
2417 <option value="7px">7px</option>
2418 <option value="8px">8px</option>
2419 <option value="9px">9px</option>
2420 <option value="10px">10px</option>
2421 <option value="11px">11px</option>
2422 <option value="12px">12px</option>
2423 <option value="13px">13px</option>
2424 <option value="14px">14px</option>
2425 <option value="15px">15px</option>
2426 <option value="16px">16px</option>
2427 <option value="17px">17px</option>
2428 <option value="18px">18px</option>
2429 <option value="19px">19px</option>
2430 <option value="20px">20px</option>
2431 <option value="21px">21px</option>
2432 <option value="22px">22px</option>
2433 <option value="23px">23px</option>
2434 <option value="24px">24px</option>
2435 <option value="25px">25px</option>
2436 <option value="26px">26px</option>
2437 <option value="27px">27px</option>
2438 <option value="28px">28px</option>
2439 <option value="29px">29px</option>
2440 <option value="30px">30px</option>
2441 </select>
2442 </td>
2443 </tr>
2444 </table>
2445 <!-- Scale Table -->
2446 <table class="CSSE_edit" id="editScale" style="display:none;">
2447 <tr>
2448 <td width="85">Width (px): <a class="noteLink" title="Click here for more information" onclick="showNote('noteWidth',this, 'Width');">(?)</a></td>
2449 <td>
2450 <input type="text" maxlength="4" class="elmColor" id="width" onblur="bind(this);"/>
2451 </td>
2452 </tr>
2453 <tr>
2454 <td width="85"></td>
2455 <td>
2456 If you change the width of the<br/> poll you may also need to change<br/> the width of your answers.
2457 </td>
2458 </tr>
2459 </table>
2460
2461 <!-- Height Table -->
2462 <table class="CSSE_edit" id="editHeight" style="display:none;">
2463 <tr>
2464 <td width="85">Height (px):</td>
2465 <td>
2466 <input type="text" maxlength="4" class="elmColor" id="height" onblur="bind(this);"/>
2467 </td>
2468 </tr>
2469 </table>
2470 </td>
2471 </tr>
2472 <tr>
2473 <td class="btm"/>
2474 </tr>
2475 </table>
2476 </td>
2477 </tr>
2478 </table>
2479 </td>
2480 <td width="10"> </td>
2481 <td valign="top">
2482 <div style="overflow-x:auto;width:633px;">
2483 <!-- POLL XHTML START -->
2484 <div class="pds-box" id="pds-box">
2485 <div class="pds-box-outer">
2486 <div class="pds-box-inner">
2487 <div class="pds-box-top">
2488 <div class="pds-question">
2489 <div class="pds-question-outer">
2490 <div class="pds-question-inner">
2491 <div class="pds-question-top" id="pds-question-top">Do you mostly use the internet at work, in school or at home?</div>
2492 </div>
2493 </div>
2494 </div>
2495 <div>
2496 <!-- divAnswers -->
2497 <div id="divAnswers">
2498 <span id="pds-answer143974">
2499
2500 <span class="pds-answer-group" id="pds-answer-group">
2501 <span class="pds-answer-input" id="pds-answer-input">
2502 <input type="radio" name="PDI_answer" value="1" id="p1" class="pds-checkbox"/>
2503 </span>
2504 <label for="p1" class="pds-answer" id="pds-answer"><span class="pds-answer-span">I use it in school.</span></label>
2505 <span class="pds-clear"></span>
2506 </span>
2507
2508 <span class="pds-answer-group" id="pds-answer-group1">
2509 <span class="pds-answer-input" id="pds-answer-input1">
2510 <input type="radio" name="PDI_answer" value="2" id="p2" class="pds-checkbox"/>
2511 </span>
2512 <label for="p2" class="pds-answer" id="pds-answer1"><span class="pds-answer-span">I use it at home.</span></label>
2513 <span class="pds-clear"></span>
2514 </span>
2515
2516 <span class="pds-answer-group" id="pds-answer-group2">
2517 <span class="pds-answer-input" id="pds-answer-input2">
2518 <input type="radio" name="PDI_answer" value="3" id="p3" class="pds-checkbox"/>
2519 </span>
2520 <label for="p3" class="pds-answer" id="pds-answer2"><span class="pds-answer-span">I use it every where I go, at work and home and anywhere else that I can!</span></label>
2521 <span class="pds-clear"></span>
2522 </span>
2523
2524 <span class="pds-answer-group" id="pds-answer-group3">
2525 <span class="pds-answer-input" id="pds-answer-input3">
2526 <input type="radio" name="PDI_answer" value="4" id="p4" class="pds-checkbox"/>
2527 </span>
2528 <label for="p4" class="pds-answer" id="pds-answer3"><span class="pds-answer-span">Other:</span></label>
2529 <span class="pds-clear"></span>
2530 <span class="pds-answer-other">
2531 <input type="text" name="PDI_OtherText1761982" id="pds-textfield" maxlength="80" class="pds-textfield"/>
2532 </span>
2533 <span class="pds-clear"></span>
2534 </span>
2535
2536 </span>
2537 <br/>
2538 <div class="pds-vote" id="pds-links">
2539 <div class="pds-votebutton-outer">
2540 <a href="javascript:renderStyleEdit('pds-answer-feedback');" id="pds-vote-button" style="display:block;float:left;" class="pds-vote-button"><span>Vote</span></a>
2541 <span class="pds-links">
2542 <div style="padding: 0px 0px 0px 15px; float:left;"><a href="javascript:renderStyleEdit('pds-answer-feedback');" class="pds-link" id="pds-link">View Results</a></div>
2543 <span class="pds-clear"></span>
2544 </span>
2545 <span class="pds-clear"></span>
2546 </div>
2547 </div>
2548
2549 </div>
2550 <!-- End divAnswers -->
2551 <!-- divResults -->
2552 <div id="divResults">
2553
2554 <div class="pds-answer-group" id="pds-answer-group4">
2555 <label for="PDI_feedback1" class="pds-answer" id="pds-answer4"><span class="pds-answer-text">I use it in school!</span><xsl:text> </xsl:text><span class="pds-feedback-per"><strong>46%</strong></span><xsl:text> </xsl:text><span class="pds-feedback-votes">(620 votes)</span></label>
2556 <span class="pds-clear"></span>
2557 <div id="pds-answer-feedback">
2558 <div style="width:46%;" id="pds-answer-feedback-bar" class="pds-answer-feedback-bar"></div>
2559 </div>
2560 <span class="pds-clear"></span>
2561 </div>
2562
2563 <div class="pds-answer-group" id="pds-answer-group5">
2564 <label for="PDI_feedback2" class="pds-answer" id="pds-answer5"><span class="pds-answer-text">I use it at home.</span><xsl:text> </xsl:text><span class="pds-feedback-per"><strong>30%</strong></span><xsl:text> </xsl:text><span class="pds-feedback-votes">(400 votes)</span></label>
2565 <span class="pds-clear"></span>
2566 <div id="pds-answer-feedback2">
2567 <div style="width:46%;" id="pds-answer-feedback-bar2" class="pds-answer-feedback-bar"></div>
2568 </div>
2569 <span class="pds-clear"></span>
2570 </div>
2571
2572 <div class="pds-answer-group" id="pds-answer-group6">
2573 <label for="PDI_feedback3" class="pds-answer" id="pds-answer6"><span class="pds-answer-text">I use it every where I go, at work and home and anywhere else that I can!</span><xsl:text> </xsl:text><span class="pds-feedback-per"><strong>16%</strong></span><xsl:text> </xsl:text><span class="pds-feedback-votes">(220 votes)</span></label>
2574 <span class="pds-clear"></span>
2575 <div id="pds-answer-feedback3">
2576 <div style="width:16%;" id="pds-answer-feedback-bar3" class="pds-answer-feedback-bar"></div>
2577 </div>
2578 <span class="pds-clear"></span>
2579 </div>
2580
2581 <div class="pds-answer-group" id="pds-answer-group7">
2582 <label for="PDI_feedback4" class="pds-answer" id="pds-answer7"><span class="pds-answer-text">Other</span><xsl:text> </xsl:text><span class="pds-feedback-per"><strong>8%</strong></span><xsl:text> </xsl:text><span class="pds-feedback-votes">(110 votes)</span></label>
2583 <span class="pds-clear"></span>
2584 <div id="pds-answer-feedback4">
2585 <div style="width:8%;" id="pds-answer-feedback-bar4" class="pds-answer-feedback-bar"></div>
2586 </div>
2587 <span class="pds-clear"></span>
2588 </div>
2589
2590 </div>
2591 <!-- End divResults -->
2592 <span class="pds-clear"></span>
2593 <div style="height: 10px;"></div>
2594 <div id="pds-totalvotes-inner">Total Votes: <strong>1,350</strong></div>
2595 </div>
2596 <div class="pds-vote" id="pds-links-back">
2597 <div class="pds-totalvotes-outer">
2598 <span class="pds-links-back">
2599 <br/>
2600 <a href="javascript:" class="pds-link" id="pds-link1">Comments <strong>(19)</strong></a>
2601 <xsl:text> </xsl:text>
2602 <a href="javascript:renderStyleEdit('pds-box');" class="pds-link" id="pds-link2">Return To Poll</a>
2603 <span class="pds-clear"></span>
2604 </span>
2605 <span class="pds-clear"></span>
2606 </div>
2607 </div>
2608 </div>
2609 </div>
2610 </div>
2611 </div>
2612 <!-- POLL XHTML END -->
2613 </div>
2614 </td>
2615 </tr>
2616 </table>
2617 <div id="editBox"></div>
2618
2619 <p class="pds-clear"></p>
2620
2621 <?php wp_nonce_field( $style_id > 1000 ? "edit-style$style_id" : 'create-style' ); ?>
2622 <input type="hidden" name="action" value="<?php echo $style_id > 1000 ? 'edit-style' : 'create-style'; ?>" />
2623 <input type="hidden" class="polldaddy-style-id" name="style" value="<?php echo $style_id; ?>" />
2624 <input type="submit" class="button-primary" value="<?php echo attribute_escape( __( 'Save Style' ) ); ?>" />
2625
2626 </div>
2627 </div>
2628 <textarea id="S_www" name="CSSXML" style="display:none;width: 1000px; height: 500px;" rows="10" cols="10"> </textarea>
2629 </form>
2630 <div id="S_js"/>
2631 <div id="P_tab"/>
2632 <script type="text/javascript" language="javascript">window.onload = function() {
2633 var CSSXML;
2634 loadStyle();
2635 showResults( false );
2636 renderStyleEdit( $('styleName').value );
2637 }</script>
2638 <div id="noteImageURL" style="display:none">
2639 You can place a link to an image here and it<br/>
2640 will appear in your poll. You must use a URL<br/>
2641 linking to an image already hosted somewhere<br/>
2642 on the internet.
2643 </div>
2644 <div id="noteWidth" style="display:none">
2645 To control the width of this element you must<br/>
2646 enter a numeric value in pixels.
2647 </div>
2648 <br class="clear" />
2649
2650 <?php
2651 }
2652
2653 function signup() {
2654 return $this->api_key_page();
2655 }
2656
2657 function can_edit( &$poll ) {
2658 global $current_user;
2659 if ( empty( $poll->_owner ) )
2660 return true;
2661
2662 if ( $current_user->ID == $poll->_owner )
2663 return true;
2664
2665 return current_user_can( 'edit_others_posts' );
2666 }
2667 }
2668
2669 function polldaddy_loader() {
2670 global $polldaddy_object;
2671 $polldaddy_class = WP_POLLDADDY__CLASS;
2672 $polldaddy_object = new $polldaddy_class;
2673 add_action( 'admin_menu', array( &$polldaddy_object, 'admin_menu' ) );
2674 }
2675
2676 add_action( 'init', 'polldaddy_loader' );
2677
2678 function polldaddy_shortcode($atts, $content=null) {
2679 extract(shortcode_atts(array(
2680 'poll' => 'empty',
2681 'cb' => '',
2682 ), $atts));
2683
2684 $poll = (int) $poll;
2685 $cb = ( $cb == 1 ? '?cb=' . mktime() : '' );
2686
2687 return "<script type='text/javascript' language='javascript' charset='utf-8' src='http://s3.polldaddy.com/p/$poll.js$cb'></script><noscript> <a href='http://answers.polldaddy.com/poll/$poll/'>View Poll</a></noscript>";
2688 }
2689
2690 add_shortcode('polldaddy', 'polldaddy_shortcode');
2691