Crowdsignal Dashboard – Polls, Surveys & more - Version 1.7

Version Description

  • Added Poll Style Editor
  • Updated the PollDaddy API Client code
  • Removed style picker javascript, now reference static file on Polldaddy
  • Bug Fix: PollDaddy Answers link to poll in poll embed code now correct
  • Bug Fix: iframe view of poll editor now display design area
  • Bug Fix: Only print API error once
Download this release

Release Info

Developer eoigal
Plugin Icon 128x128 Crowdsignal Dashboard – Polls, Surveys & more
Version 1.7
Comparing to
See all releases

Code changes from version 1.6 to 1.7

Files changed (9) hide show
  1. common.js +1 -0
  2. poll-style-picker.js +0 -356
  3. polldaddy-client.php +584 -137
  4. polldaddy-xml.php +293 -20
  5. polldaddy.css +63 -339
  6. polldaddy.js +19 -37
  7. polldaddy.php +1408 -125
  8. readme.txt +16 -8
  9. style-editor.css +20 -0
common.js ADDED
@@ -0,0 +1 @@
 
1
+ function $(id){return document.getElementById(id)}function pd_style(){this.name='';this.n_id=0;this.n_desc='';this.m_id=0;this.m_desc='';this.w_id=0;this.w_desc='';this.tag=''}function preload_pd_style(){if($('preload_value').value!='0'){url=window.location.href;fnd='';qs=window.location.search.substring(1);qv=qs.split("&");for(i=0;i<qv.length;i++){ft=qv[i].split("=");if(ft[0]=='preload'){fnd='&preload='+ft[1];url=url.replace(fnd,'')}}window.location=url+"&preload="+$('preload_value').value}}
poll-style-picker.js DELETED
@@ -1,356 +0,0 @@
1
- function $(id) {
2
- return document.getElementById(id);
3
- }
4
-
5
- function pd_style() {
6
- this.name = ''; // style name
7
- this.n_id = 0; // narrow style id
8
- this.n_desc = ''; // narrow style description
9
- this.m_id = 0; // medium style id
10
- this.m_desc = ''; // medium style description
11
- this.w_id = 0; // wide style id
12
- this.w_desc = ''; // wide style description
13
- this.tag = ''; // tag name for styles
14
- }
15
-
16
- var styles_array = new Array();
17
-
18
- var s = new pd_style;
19
- s.name = 'Aluminum';
20
- s.n_id = 101;
21
- s.m_id = 102;
22
- s.w_id = 103;
23
- s.tag = 'st-alum-light';
24
- styles_array.push(s);
25
-
26
- var s = new pd_style;
27
- s.name = 'Plain White';
28
- s.n_id = 104;
29
- s.m_id = 105;
30
- s.w_id = 106;
31
- s.tag = 'st-plain-light';
32
- styles_array.push(s);
33
-
34
- var s = new pd_style;
35
- s.name = 'Plain Black';
36
- s.n_id = 107;
37
- s.m_id = 108;
38
- s.w_id = 109;
39
- s.tag = 'st-plain-dark';
40
- styles_array.push(s);
41
-
42
- var s = new pd_style;
43
- s.name = 'Paper';
44
- s.n_id = 110;
45
- s.m_id = 111;
46
- s.w_id = 112;
47
- s.tag = 'st-paper';
48
- styles_array.push(s);
49
-
50
- var s = new pd_style;
51
- s.name = 'Skull Dark';
52
- s.n_id = 113;
53
- s.m_id = 114;
54
- s.w_id = 115;
55
- s.tag = 'st-skull-dark';
56
- styles_array.push(s);
57
-
58
- var s = new pd_style;
59
- s.name = 'Skull Light';
60
- s.n_id = 116;
61
- s.m_id = 117;
62
- s.w_id = 118;
63
- s.tag = 'st-skull-light';
64
- styles_array.push(s);
65
-
66
- var s = new pd_style;
67
- s.name = 'Micro';
68
- s.m_id = 157;
69
- s.m_desc = 'Width 150px. The micro style is useful when space is tight.';
70
- s.tag = 'st-micro';
71
- styles_array.push(s);
72
-
73
- var s = new pd_style;
74
- s.name = 'Plastic White';
75
- s.n_id = 119;
76
- s.m_id = 120;
77
- s.w_id = 121;
78
- s.tag = 'st-plastic-white';
79
- styles_array.push(s);
80
-
81
- var s = new pd_style;
82
- s.name = 'Plastic Grey';
83
- s.n_id = 122;
84
- s.m_id = 123;
85
- s.w_id = 124;
86
- s.tag = 'st-plastic-grey';
87
- styles_array.push(s);
88
-
89
- var s = new pd_style;
90
- s.name = 'Plastic Black';
91
- s.n_id = 125;
92
- s.m_id = 126;
93
- s.w_id = 127;
94
- s.tag = 'st-plastic-black';
95
- styles_array.push(s);
96
-
97
- var s = new pd_style;
98
- s.name = 'Manga';
99
- s.n_id = 128;
100
- s.m_id = 129;
101
- s.w_id = 130;
102
- s.tag = 'st-manga';
103
- styles_array.push(s);
104
-
105
- var s = new pd_style;
106
- s.name = 'Tech Dark';
107
- s.n_id = 131;
108
- s.m_id = 132;
109
- s.w_id = 133;
110
- s.tag = 'st-tech-dark';
111
- styles_array.push(s);
112
-
113
- var s = new pd_style;
114
- s.name = 'Tech Grey';
115
- s.n_id = 134;
116
- s.m_id = 135;
117
- s.w_id = 136;
118
- s.tag = 'st-tech-grey';
119
- styles_array.push(s);
120
-
121
- var s = new pd_style;
122
- s.name = 'Tech Light';
123
- s.n_id = 137;
124
- s.m_id = 138;
125
- s.w_id = 139;
126
- s.tag = 'st-tech-light';
127
- styles_array.push(s);
128
-
129
- var s = new pd_style;
130
- s.name = 'Working Male';
131
- s.n_id = 140;
132
- s.m_id = 141;
133
- s.w_id = 142;
134
- s.tag = 'st-working-male';
135
- styles_array.push(s);
136
-
137
- var s = new pd_style;
138
- s.name = 'Working Female';
139
- s.n_id = 143;
140
- s.m_id = 144;
141
- s.w_id = 145;
142
- s.tag = 'st-working-female';
143
- styles_array.push(s);
144
-
145
- var s = new pd_style;
146
- s.name = 'Thinking Male';
147
- s.n_id = 146;
148
- s.m_id = 147;
149
- s.w_id = 148;
150
- s.tag = 'st-thinking-male';
151
- styles_array.push(s);
152
-
153
- var s = new pd_style;
154
- s.name = 'Thinking Female';
155
- s.n_id = 149;
156
- s.m_id = 150;
157
- s.w_id = 151;
158
- s.tag = 'st-thinking-female';
159
- styles_array.push(s);
160
-
161
- var s = new pd_style;
162
- s.name = 'Sunset';
163
- s.n_id = 152;
164
- s.m_id = 153;
165
- s.w_id = 154;
166
- s.tag = 'st-sunset';
167
- styles_array.push(s);
168
-
169
- var s = new pd_style;
170
- s.name = 'Music';
171
- s.m_id = 155;
172
- s.w_id = 156;
173
- s.tag = 'st-music';
174
- styles_array.push(s);
175
-
176
-
177
- var style_id = 0;
178
-
179
-
180
- function pd_build_styles( current_pos )
181
- {
182
- var style = styles_array[ current_pos ];
183
- $('st_name').innerHTML = style.name;
184
-
185
- var style_sizes = '';
186
-
187
- if ( style_id == 0 )
188
- {
189
- if ( style.m_id > 0 )
190
- {
191
- style_id = style.m_id;
192
- }
193
- else if ( style.w_id > 0 )
194
- {
195
- style_id = style.w_id;
196
- }
197
- else if ( style.n_id > 0 )
198
- {
199
- style_id = style.w_id;
200
- }
201
- }
202
-
203
- if ( style.w_id > 0 )
204
- {
205
- if ( style_id == style.w_id )
206
- {
207
- style_sizes += 'Wide | ';
208
-
209
- if ( style.w_desc == '' )
210
- {
211
- $('st_description').innerHTML = 'Width: 630px, the wide style is good for blog posts.';
212
- }
213
- else
214
- {
215
- $('st_description').innerHTML = style.w_desc;
216
- }
217
- }
218
- else
219
- {
220
- style_sizes += '<a href="javascript:pd_change_style(' + style.w_id + ');">Wide</a> | ';
221
- }
222
- }
223
- if ( style.m_id > 0 )
224
- {
225
- if ( style_id == style.m_id )
226
- {
227
- style_sizes += 'Medium';
228
-
229
- if ( style.n_id > 0 ){
230
- style_sizes += ' | ';
231
- }
232
-
233
- if ( style.m_desc == '' )
234
- {
235
- $('st_description').innerHTML = 'Width: 300px, the medium style is good for general use.';
236
- }
237
- else
238
- {
239
- $('st_description').innerHTML = style.m_desc;
240
- }
241
-
242
- }
243
- else
244
- {
245
- style_sizes += '<a href="javascript:pd_change_style(' + style.m_id + ');">Medium</a>';
246
- if ( style.n_id > 0 ){
247
- style_sizes += ' | ';
248
- }
249
- }
250
- }
251
- if ( style.n_id > 0 )
252
- {
253
- if ( style_id == style.n_id )
254
- {
255
- style_sizes += 'Narrow ';
256
-
257
- if ( style.n_desc == '' )
258
- {
259
- $('st_description').innerHTML = 'Width: 150px, the narrow style is good for sidebars etc.';
260
- }
261
- else
262
- {
263
- $('st_description').innerHTML = style.n_desc;
264
- }
265
-
266
- }
267
- else
268
- {
269
- style_sizes += '<a href="javascript:pd_change_style(' + style.n_id + ');">Narrow</a> ';
270
- }
271
- }
272
-
273
- $('st_sizes').innerHTML = style_sizes;
274
- $('st_number').innerHTML = (current_pos + 1) +' of '+ styles_array.length;
275
- $('st_image').style.background = 'url(http://i.polldaddy.com/polls/' + style.tag + '.png) no-repeat top left';
276
-
277
- $('regular').checked = true;
278
- $('styleID').value = style_id;
279
- }
280
-
281
- function pd_pick_style( id )
282
- {
283
- found = false;
284
- for ( x=0; x<=styles_array.length - 1; x++ )
285
- {
286
- if ( styles_array[x].n_id == id || styles_array[x].m_id == id || styles_array[x].w_id == id )
287
- {
288
- current_pos = x;
289
- pd_change_style( id );
290
- found = true;
291
- break;
292
- }
293
- }
294
-
295
- if (!found)
296
- {
297
- current_pos = 0;
298
- pd_build_styles( current_pos );
299
- }
300
- }
301
-
302
- function pd_change_style( id ){
303
- style_id = id;
304
-
305
- if ( style_id < 1000 ) // Regular
306
- {
307
- $('regular').checked = true;
308
- pd_build_styles( current_pos );
309
- }
310
- else // custom
311
- {
312
- $('custom').checked = true;
313
- }
314
-
315
- $('styleID').value = style_id;
316
- }
317
-
318
- function pd_move( dir )
319
- {
320
- if ( dir == 'next' )
321
- {
322
- if ( styles_array.length <= ( current_pos + 1 ) )
323
- {
324
- current_pos = 0;
325
- }
326
- else
327
- {
328
- current_pos = current_pos + 1;
329
- }
330
- }
331
- else if ( dir == 'prev' )
332
- {
333
- if ( current_pos == 0 )
334
- {
335
- current_pos = styles_array.length - 1;
336
- }
337
- else
338
- {
339
- current_pos = current_pos - 1;
340
- }
341
- }
342
- style_id = 0;
343
- pd_build_styles( current_pos );
344
- }
345
-
346
- function st_results( obj, cmd )
347
- {
348
- if ( cmd == 'show' )
349
- {
350
- obj.style.backgroundPosition = 'top right';
351
- }
352
- else if ( cmd == 'hide' )
353
- {
354
- obj.style.backgroundPosition = 'top left';
355
- }
356
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
polldaddy-client.php CHANGED
@@ -3,19 +3,24 @@
3
  require_once dirname( __FILE__ ) . '/polldaddy-xml.php';
4
 
5
  // TODO: polls->poll should always be an array and similar bad typing
6
- class PollDaddy_Client {
7
  var $polldaddy_url = 'http://api.polldaddy.com/';
8
  var $partnerGUID;
9
  var $userCode;
 
 
10
 
11
  var $request = null;
12
  var $response = null;
13
  var $request_xml = '';
14
- var $response_xml = '';
 
 
 
15
 
16
  var $errors = array();
17
 
18
- function PollDaddy_Client( $partnerGUID = '', $userCode = null ) {
19
  $this->partnerGUID = $partnerGUID;
20
  $this->userCode = $userCode;
21
  }
@@ -23,6 +28,8 @@ class PollDaddy_Client {
23
  function send_request() {
24
  $this->request_xml = "<?xml version='1.0' encoding='utf-8' ?>\n";
25
  $this->request_xml .= $this->request->xml( 'all' );
 
 
26
 
27
  if ( function_exists( 'wp_remote_post' ) ) {
28
  $response = wp_remote_post( $this->polldaddy_url, array(
@@ -38,6 +45,11 @@ class PollDaddy_Client {
38
  } else {
39
  $parsed = parse_url( $this->polldaddy_url );
40
 
 
 
 
 
 
41
  $fp = fsockopen(
42
  $parsed['host'],
43
  $parsed['scheme'] == 'ssl' || $parsed['scheme'] == 'https' && extension_loaded('openssl') ? 443 : 80,
@@ -54,7 +66,7 @@ class PollDaddy_Client {
54
  if ( function_exists( 'stream_set_timeout' ) )
55
  stream_set_timeout( $fp, 3 );
56
 
57
- if ( !$path = $parsed['path'] . ( isset($parsed['query']) ? '?' . $parsed['query'] : '' ) )
58
  $path = '/';
59
 
60
  $request = "POST $path HTTP/1.0\r\n";
@@ -77,6 +89,8 @@ class PollDaddy_Client {
77
 
78
  list($headers, $this->response_xml) = explode( "\r\n\r\n", $response, 2 );
79
  }
 
 
80
 
81
  $parser = new PollDaddy_XML_Parser( $this->response_xml );
82
  $this->response =& $parser->objects[0];
@@ -110,6 +124,8 @@ class PollDaddy_Client {
110
  'userCode' => $this->userCode,
111
  'demands' => new PollDaddy_Demands( array( 'demand' => array() ) )
112
  ), array(
 
 
113
  'partnerGUID' => $this->partnerGUID
114
  ) );
115
 
@@ -141,7 +157,7 @@ class PollDaddy_Client {
141
  * @param int $partnerUserID
142
  * @return string|false PollDaddy userCode or false on failure
143
  */
144
- function Initiate( $Email, $Password, $partnerUserID ) {
145
  $this->request = new PollDaddy_Initiate( compact( 'Email', 'Password' ), array( 'partnerGUID' => $this->partnerGUID, 'partnerUserID' => $partnerUserID ) );
146
  $this->send_request();
147
  if ( isset( $this->response->userCode ) )
@@ -156,10 +172,10 @@ class PollDaddy_Client {
156
  * @param string $partnerUserID
157
  * @return string|false PollDaddy userCode or false on failure
158
  */
159
- function GetUserCode( $partnerUserID ) {
160
  $this->request = new PollDaddy_Access( array(
161
  // 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( null, array( 'id' => __FUNCTION__ ) ) ) )
162
- 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( null, array( 'id' => 'GetUserCode' ) ) ) )
163
  ), array(
164
  'partnerGUID' => $this->partnerGUID,
165
  'partnerUserID' => $partnerUserID
@@ -171,7 +187,7 @@ class PollDaddy_Client {
171
  }
172
 
173
  // Not Implemented
174
- function RemoveUserCode() {
175
  return false;
176
  }
177
 
@@ -181,13 +197,13 @@ class PollDaddy_Client {
181
  * @param array $args polldaddy_account() args
182
  * @return string|false PollDaddy userCode or false on failure
183
  */
184
- function CreateAccount( $partnerUserID, $args ) {
185
  if ( !$account = polldaddy_account( $args ) )
186
  return false;
187
 
188
  $this->request = new PollDaddy_Access( array(
189
  // 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( compact( 'account' ), array( 'id' => __FUNCTION__ ) ) ) )
190
- 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( compact( 'account' ), array( 'id' => 'CreateAccount' ) ) ) )
191
  ), array(
192
  'partnerGUID' => $this->partnerGUID,
193
  'partnerUserID' => $partnerUserID
@@ -205,9 +221,9 @@ class PollDaddy_Client {
205
  /**
206
  * @return object|false PollDaddy Account or false on failure
207
  */
208
- function GetAccount() {
209
  // $pos = $this->add_request( __FUNCTION__ );
210
- $pos = $this->add_request( 'GetAccount' );
211
  $this->send_request();
212
  $r = $this->response_part( $pos );
213
  if ( isset( $r->account ) && !is_null( $r->account->email ) )
@@ -220,12 +236,12 @@ class PollDaddy_Client {
220
  * @param array $args polldaddy_account() args
221
  * @return string|false PollDaddy userCode or false on failure
222
  */
223
- function UpdateAccount( $args ) {
224
  if ( !$account = polldaddy_account( $args ) )
225
  return false;
226
 
227
  // $this->add_request( __FUNCTION__, $account );
228
- $this->add_request( 'UpdateAccount', $account );
229
  $this->send_request();
230
  if ( isset( $this->response->userCode ) )
231
  return $this->response->userCode;
@@ -236,15 +252,15 @@ class PollDaddy_Client {
236
  /**
237
  * @return array|false Array of PollDaddy Polls or false on failure
238
  */
239
- function ListPolls( $start = 0, $end = 0 ) {
240
  $start = (int) $start;
241
  $end = (int) $end;
242
  if ( !$start && !$end )
243
  // $pos = $this->add_request( __FUNCTION__ );
244
- $pos = $this->add_request( 'ListPolls' );
245
  else
246
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_List( null, compact( 'start', 'end' ) ) );
247
- $pos = $this->add_request( 'ListPolls', new PollDaddy_List( null, compact( 'start', 'end' ) ) );
248
  $this->send_request();
249
  $r = $this->response_part( $pos );
250
  if ( isset( $r->polls ) ) {
@@ -260,7 +276,7 @@ class PollDaddy_Client {
260
  /**
261
  * @return array|false Array of PollDaddy Polls or false on failure
262
  */
263
- function listPollsByBlog( $start = 0, $end = 0, $id = null ) {
264
  $start = (int) $start;
265
  $end = (int) $end;
266
  if ( !is_numeric( $id ) )
@@ -268,10 +284,10 @@ class PollDaddy_Client {
268
 
269
  if ( !$start && !$end )
270
  // $pos = $this->add_request( __FUNCTION__ );
271
- $pos = $this->add_request( 'listPollsByBlog', compact( 'id' ) );
272
  else
273
- // $pos = $this->add_request( __FUNCTION__, new PollDaddy_List( null, compact( 'start', 'end' ) ) );
274
- $pos = $this->add_request( 'listPollsByBlog', new PollDaddy_List( null, compact( 'start', 'end', 'id' ) ) );
275
  $this->send_request();
276
  $r = $this->response_part( $pos );
277
  if ( isset( $r->polls ) ) {
@@ -288,12 +304,12 @@ class PollDaddy_Client {
288
  * @param int $id PollDaddy Poll ID
289
  * @return array|false PollDaddy Poll or false on failure
290
  */
291
- function GetPoll( $id ) {
292
  if ( !$id = (int) $id )
293
  return false;
294
 
295
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll( null, compact( 'id' ) ) );
296
- $pos = $this->add_request( 'GetPoll', new PollDaddy_Poll( null, compact( 'id' ) ) );
297
  $this->send_request();
298
 
299
  $demand = $this->response_part( $pos );
@@ -311,44 +327,39 @@ class PollDaddy_Client {
311
 
312
  /**
313
  * @param int $id PollDaddy Poll ID
314
- * @return bool success
315
- */
316
- function DeletePoll( $id ) {
317
- if ( !$id = (int) $id )
318
- return false;
319
-
320
- // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll( null, compact( 'id' ) ) );
321
- $pos = $this->add_request( 'DeletePoll', new PollDaddy_Poll( null, compact( 'id' ) ) );
322
- $this->send_request();
323
-
324
- return empty( $this->errors );
325
- }
326
-
327
- /**
328
- * @param int $id PollDaddy Poll ID
329
- * @return bool success
330
  */
331
- function OpenPoll( $id ) {
332
  if ( !$id = (int) $id )
333
  return false;
334
 
335
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll( null, compact( 'id' ) ) );
336
- $pos = $this->add_request( 'OpenPoll', new PollDaddy_Poll( null, compact( 'id' ) ) );
337
  $this->send_request();
338
 
339
- return empty( $this->errors );
 
 
 
 
 
 
 
 
 
 
340
  }
341
-
342
  /**
343
  * @param int $id PollDaddy Poll ID
344
  * @return bool success
345
  */
346
- function ClosePoll( $id ) {
347
  if ( !$id = (int) $id )
348
  return false;
349
 
350
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll( null, compact( 'id' ) ) );
351
- $pos = $this->add_request( 'ClosePoll', new PollDaddy_Poll( null, compact( 'id' ) ) );
352
  $this->send_request();
353
 
354
  return empty( $this->errors );
@@ -359,11 +370,11 @@ class PollDaddy_Client {
359
  * @param array $args polldaddy_poll() args
360
  * @return array|false PollDaddy Poll or false on failure
361
  */
362
- function CreatePoll( $args = null ) {
363
  if ( !$poll = polldaddy_poll( $args ) )
364
  return false;
365
  // $pos = $this->add_request( __FUNCTION__, $poll );
366
- $pos = $this->add_request( 'CreatePoll', $poll );
367
  $this->send_request();
368
  if ( !$demand = $this->response_part( $pos ) )
369
  return $demand;
@@ -379,7 +390,7 @@ class PollDaddy_Client {
379
  * @param array $args polldaddy_poll() args
380
  * @return array|false PollDaddy Poll or false on failure
381
  */
382
- function UpdatePoll( $id, $args = null ) {
383
  if ( !$id = (int) $id )
384
  return false;
385
 
@@ -387,45 +398,31 @@ class PollDaddy_Client {
387
  return false;
388
 
389
  // $pos = $this->add_request( __FUNCTION__, $poll );
390
- $pos = $this->add_request( 'UpdatePoll', $poll );
391
  $this->send_request();
392
- return $this->response_part( $pos );
393
- }
394
-
395
- function SearchPolls( $search ) {
396
- // $pos = $this->add_request( __FUNCTION__, compact( 'search' ) );
397
- $pos = $this->add_request( 'SearchPolls', compact( 'search' ) );
398
- $this->send_request();
399
-
400
- $r = $this->response_part( $pos );
401
- if ( isset( $r->search ) ) {
402
- if ( isset( $r->search->poll ) ) {
403
- if ( is_array( $r->search->poll ) )
404
- return $r->search->poll;
405
- else
406
- return array( $r->search->poll );
407
- }
408
- return array();
409
- }
410
- return false;
411
- }
412
-
413
- // Not Implemented
414
- function ListSurveys() {
415
- return false;
416
  }
417
 
418
  /* Poll Results */
419
  /**
420
  * @param int $id PollDaddy Poll ID
421
- * @return object|false PollDaddy Result or false on failure
422
  */
423
- function GetPollResults( $id ) {
424
  if ( !$id = (int) $id )
425
  return false;
 
 
 
426
 
427
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll_Result( null, compact( 'id' ) ) );
428
- $pos = $this->add_request( 'GetPollResults', new PollDaddy_Poll_Result( null, compact( 'id' ) ) );
 
 
429
  $this->send_request();
430
 
431
  $demand = $this->response_part( $pos );
@@ -455,73 +452,189 @@ class PollDaddy_Client {
455
 
456
  /**
457
  * @param int $id PollDaddy Poll ID
458
- * @return object|false PollDaddy Result or false on failure
459
  */
460
- function ResetPollResults( $id ) {
461
  if ( !$id = (int) $id )
462
  return false;
463
 
464
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll_Result( null, compact( 'id' ) ) );
465
- $pos = $this->add_request( 'ResetPollResults', new PollDaddy_Poll_Result( null, compact( 'id' ) ) );
466
  $this->send_request();
467
 
468
  return empty( $this->errors );
469
  }
470
 
471
  /* Poll Comments */
472
- // Not Implemented
473
- function GetPollComments() {
474
- return false;
475
- }
 
 
 
476
 
477
- // Not Implemented
478
- function ModerateComment() {
 
 
 
 
 
 
 
 
 
 
 
 
 
479
  return false;
480
  }
481
 
482
- /* Extensions */
 
 
 
 
 
 
 
 
 
 
483
 
484
- // Not Implemented
485
- function GetAllExtensions() {
486
- return false;
 
 
487
  }
488
 
489
- // Not Implemented
490
- function GetLanguages() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
491
  return false;
492
  }
493
 
494
  /* Language Packs */
495
- // Not Implemented
496
- function GetPacks() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
497
  return false;
498
  }
 
 
 
 
 
 
 
 
499
 
500
- // Not Implemented
501
- function GetPack() {
 
 
 
 
 
 
 
502
  return false;
503
  }
504
 
505
- // Not Implemented
506
- function DeletePack() {
507
- return false;
 
 
 
 
 
 
 
 
 
 
508
  }
509
 
510
- // Not Implemented
511
- function CreatePack() {
512
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
513
  }
514
 
515
- // Not Implemented
516
- function UpdatePack() {
517
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518
  }
519
 
520
- /* Styles */
521
- /**
522
- * @return array|false PollDaddy Styles or false on failure
523
- */
524
- function GetStyles() {
 
 
525
  $pos = $this->add_request( 'getstyles', null );
526
  $this->send_request();
527
 
@@ -536,42 +649,317 @@ class PollDaddy_Client {
536
  return false;
537
  }
538
 
539
- // Not Implemented
540
- function GetStyle() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
541
  return false;
542
  }
543
 
544
- // Not Implemented
545
- function DeleteStyle() {
546
- return false;
 
 
 
 
 
 
 
 
 
 
547
  }
548
 
549
- // Not Implemented
550
- function CreateStyle() {
551
- return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
552
  }
553
 
554
- // Not Implemented
555
- function UpdateStyle() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
556
  return false;
 
557
  }
 
 
558
 
559
- /* Folders */
560
- // Not Implemented
561
- function GetFolders() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
562
  return false;
563
  }
 
564
 
565
- /* Account Activities */
566
- // Not Implemented
567
- function GetActivity() {
568
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
569
  }
570
 
571
- // Not Implemented
572
- function SetActivity() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
573
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
574
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
575
  }
576
 
577
  /**
@@ -601,7 +989,9 @@ function &polldaddy_account( $args = null ) {
601
  if ( !is_string( $args[$required] ) || !$args[$required] )
602
  return $false;
603
 
604
- return new PollDaddy_Account( $args );
 
 
605
  }
606
 
607
  function _polldaddy_account_defaults() {
@@ -657,16 +1047,16 @@ function &polldaddy_poll( $args = null, $id = null, $_require_data = true ) {
657
  if ( !in_array( $args['resultsType'], array( 'show', 'percent', 'hide' ) ) )
658
  $args['resultsType'] = $defaults['resultsType'];
659
 
660
- if ( !in_array( $args['blockRepeatVotersType'], array( 'off', 'cookie', 'cookieIP' ) ) )
661
  $args['blockRepeatVotersType'] = $defaults['blockRepeatVotersType'];
662
 
663
  if ( !in_array( $args['comments'], array( 'off', 'allow', 'moderate' ) ) )
664
  $args['comments'] = $defaults['comments'];
665
 
666
  if ( is_numeric( $args['closeDate'] ) )
667
- $args['closeDate'] = gmdate( 'Y-m-d\TH:i:s', $args['closeDate'] ) . 'Z';
668
  if ( !$args['closeDate'] )
669
- $args['closeDate'] = gmdate( 'Y-m-d\TH:i:s' ) . 'Z';
670
 
671
  $args['answers'] = new PollDaddy_Poll_Answers( array( 'answer' => $args['answers'] ) );
672
 
@@ -674,8 +1064,10 @@ function &polldaddy_poll( $args = null, $id = null, $_require_data = true ) {
674
  $id = $args['id'];
675
  unset( $args['id'] );
676
  }
 
 
677
 
678
- return new PollDaddy_Poll( $args, compact( 'id' ) );
679
  }
680
 
681
  function _polldaddy_poll_defaults() {
@@ -687,32 +1079,86 @@ function _polldaddy_poll_defaults() {
687
  'otherAnswer' => 'no',
688
  'resultsType' => 'show',
689
  'blockRepeatVotersType' => 'cookie',
690
- 'comments' => 'off',
691
  'makePublic' => 'yes',
692
  'closePoll' => 'no',
693
  'closePollNow' => 'no',
694
- 'closeDate' => null,
695
  'sharing' => 'yes',
 
696
  'styleID' => 0,
697
  'packID' => 0,
698
  'folderID' => 0,
699
  'languageID' => _polldaddy_poll_default_language_id(),
700
  'parentID' => (int) $GLOBALS['blog_id'],
 
 
701
  'answers' => array()
702
  );
703
  }
704
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
705
  if ( !function_exists( '_polldaddy_poll_default_language_id' ) ) :
706
  function _polldaddy_poll_default_language_id() {
707
  return 1;
708
  }
709
  endif;
710
 
711
- function &polldaddy_poll_answer( $answer, $id = null ) {
712
- if ( !is_string( $answer ) || !$answer )
713
  return false;
 
 
714
 
715
- return new PollDaddy_Poll_Answer( $answer, compact( 'id' ) );
716
  }
717
 
718
  if ( !function_exists( 'wp_parse_args' ) ) :
@@ -782,3 +1228,4 @@ function stripslashes_deep($value) {
782
  return $value;
783
  }
784
  endif;
 
3
  require_once dirname( __FILE__ ) . '/polldaddy-xml.php';
4
 
5
  // TODO: polls->poll should always be an array and similar bad typing
6
+ class api_client {
7
  var $polldaddy_url = 'http://api.polldaddy.com/';
8
  var $partnerGUID;
9
  var $userCode;
10
+ var $admin = 0;
11
+ var $version = '1.0';
12
 
13
  var $request = null;
14
  var $response = null;
15
  var $request_xml = '';
16
+ var $response_xml = '';
17
+
18
+ var $requests = array();
19
+ var $responses = array();
20
 
21
  var $errors = array();
22
 
23
+ function api_client( $partnerGUID = '', $userCode = null ) {
24
  $this->partnerGUID = $partnerGUID;
25
  $this->userCode = $userCode;
26
  }
28
  function send_request() {
29
  $this->request_xml = "<?xml version='1.0' encoding='utf-8' ?>\n";
30
  $this->request_xml .= $this->request->xml( 'all' );
31
+
32
+ $this->requests[] = $this->request_xml;
33
 
34
  if ( function_exists( 'wp_remote_post' ) ) {
35
  $response = wp_remote_post( $this->polldaddy_url, array(
45
  } else {
46
  $parsed = parse_url( $this->polldaddy_url );
47
 
48
+ if ( !isset( $parsed['host'] ) && !isset( $parsed['scheme'] ) ) {
49
+ $errors[-1] = 'Invalid API URL';
50
+ return false;
51
+ }
52
+
53
  $fp = fsockopen(
54
  $parsed['host'],
55
  $parsed['scheme'] == 'ssl' || $parsed['scheme'] == 'https' && extension_loaded('openssl') ? 443 : 80,
66
  if ( function_exists( 'stream_set_timeout' ) )
67
  stream_set_timeout( $fp, 3 );
68
 
69
+ if ( !isset( $parsed['path']) || !$path = $parsed['path'] . ( isset($parsed['query']) ? '?' . $parsed['query'] : '' ) )
70
  $path = '/';
71
 
72
  $request = "POST $path HTTP/1.0\r\n";
89
 
90
  list($headers, $this->response_xml) = explode( "\r\n\r\n", $response, 2 );
91
  }
92
+
93
+ $this->responses[] = $this->response_xml;
94
 
95
  $parser = new PollDaddy_XML_Parser( $this->response_xml );
96
  $this->response =& $parser->objects[0];
124
  'userCode' => $this->userCode,
125
  'demands' => new PollDaddy_Demands( array( 'demand' => array() ) )
126
  ), array(
127
+ 'version' => $this->version,
128
+ 'admin' => $this->admin,
129
  'partnerGUID' => $this->partnerGUID
130
  ) );
131
 
157
  * @param int $partnerUserID
158
  * @return string|false PollDaddy userCode or false on failure
159
  */
160
+ function initiate( $Email, $Password, $partnerUserID ) {
161
  $this->request = new PollDaddy_Initiate( compact( 'Email', 'Password' ), array( 'partnerGUID' => $this->partnerGUID, 'partnerUserID' => $partnerUserID ) );
162
  $this->send_request();
163
  if ( isset( $this->response->userCode ) )
172
  * @param string $partnerUserID
173
  * @return string|false PollDaddy userCode or false on failure
174
  */
175
+ function get_usercode( $partnerUserID ) {
176
  $this->request = new PollDaddy_Access( array(
177
  // 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( null, array( 'id' => __FUNCTION__ ) ) ) )
178
+ 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( null, array( 'id' => 'getusercode' ) ) ) )
179
  ), array(
180
  'partnerGUID' => $this->partnerGUID,
181
  'partnerUserID' => $partnerUserID
187
  }
188
 
189
  // Not Implemented
190
+ function remove_usercode() {
191
  return false;
192
  }
193
 
197
  * @param array $args polldaddy_account() args
198
  * @return string|false PollDaddy userCode or false on failure
199
  */
200
+ function create_account( $partnerUserID, $args ) {
201
  if ( !$account = polldaddy_account( $args ) )
202
  return false;
203
 
204
  $this->request = new PollDaddy_Access( array(
205
  // 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( compact( 'account' ), array( 'id' => __FUNCTION__ ) ) ) )
206
+ 'demands' => new PollDaddy_Demands( array( 'demand' => new PollDaddy_Demand( compact( 'account' ), array( 'id' => 'createaccount' ) ) ) )
207
  ), array(
208
  'partnerGUID' => $this->partnerGUID,
209
  'partnerUserID' => $partnerUserID
221
  /**
222
  * @return object|false PollDaddy Account or false on failure
223
  */
224
+ function get_account() {
225
  // $pos = $this->add_request( __FUNCTION__ );
226
+ $pos = $this->add_request( 'getaccount' );
227
  $this->send_request();
228
  $r = $this->response_part( $pos );
229
  if ( isset( $r->account ) && !is_null( $r->account->email ) )
236
  * @param array $args polldaddy_account() args
237
  * @return string|false PollDaddy userCode or false on failure
238
  */
239
+ function update_account( $args ) {
240
  if ( !$account = polldaddy_account( $args ) )
241
  return false;
242
 
243
  // $this->add_request( __FUNCTION__, $account );
244
+ $this->add_request( 'updateaccount', $account );
245
  $this->send_request();
246
  if ( isset( $this->response->userCode ) )
247
  return $this->response->userCode;
252
  /**
253
  * @return array|false Array of PollDaddy Polls or false on failure
254
  */
255
+ function get_polls( $start = 0, $end = 0 ) {
256
  $start = (int) $start;
257
  $end = (int) $end;
258
  if ( !$start && !$end )
259
  // $pos = $this->add_request( __FUNCTION__ );
260
+ $pos = $this->add_request( 'getpolls' );
261
  else
262
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_List( null, compact( 'start', 'end' ) ) );
263
+ $pos = $this->add_request( 'getpolls', new PollDaddy_List( null, compact( 'start', 'end' ) ) );
264
  $this->send_request();
265
  $r = $this->response_part( $pos );
266
  if ( isset( $r->polls ) ) {
276
  /**
277
  * @return array|false Array of PollDaddy Polls or false on failure
278
  */
279
+ function get_polls_by_parent_id( $start = 0, $end = 0, $id = null ) {
280
  $start = (int) $start;
281
  $end = (int) $end;
282
  if ( !is_numeric( $id ) )
284
 
285
  if ( !$start && !$end )
286
  // $pos = $this->add_request( __FUNCTION__ );
287
+ $pos = $this->add_request( 'getpolls', compact( 'id' ) );
288
  else
289
+ // $pos = $this->add_request( __FUNCTION__, new PollDaddy_List( null, compact( 'start', 'end', 'id' ) ) );
290
+ $pos = $this->add_request( 'getpolls', new PollDaddy_List( null, compact( 'start', 'end', 'id' ) ) );
291
  $this->send_request();
292
  $r = $this->response_part( $pos );
293
  if ( isset( $r->polls ) ) {
304
  * @param int $id PollDaddy Poll ID
305
  * @return array|false PollDaddy Poll or false on failure
306
  */
307
+ function get_poll( $id ) {
308
  if ( !$id = (int) $id )
309
  return false;
310
 
311
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll( null, compact( 'id' ) ) );
312
+ $pos = $this->add_request( 'getpoll', new PollDaddy_Poll( null, compact( 'id' ) ) );
313
  $this->send_request();
314
 
315
  $demand = $this->response_part( $pos );
327
 
328
  /**
329
  * @param int $id PollDaddy Poll ID
330
+ * @return array|false PollDaddy Poll or false on failure
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
331
  */
332
+ function build_poll( $id ) {
333
  if ( !$id = (int) $id )
334
  return false;
335
 
336
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll( null, compact( 'id' ) ) );
337
+ $pos = $this->add_request( 'buildpoll', new PollDaddy_Poll( null, compact( 'id' ) ) );
338
  $this->send_request();
339
 
340
+ $demand = $this->response_part( $pos );
341
+ if ( is_a( $demand, 'Ghetto_XML_Object' ) && isset( $demand->poll ) && !is_null( $demand->poll->question ) ) {
342
+ if ( isset( $demand->poll->answers->answer ) && !is_array( $demand->poll->answers->answer ) ) {
343
+ if ( $demand->poll->answers->answer )
344
+ $demand->poll->answers->answer = array( $demand->poll->answers->answer );
345
+ else
346
+ $demand->poll->answers->answer = array();
347
+ }
348
+ return $demand->poll;
349
+ }
350
+ return false;
351
  }
352
+
353
  /**
354
  * @param int $id PollDaddy Poll ID
355
  * @return bool success
356
  */
357
+ function delete_poll( $id ) {
358
  if ( !$id = (int) $id )
359
  return false;
360
 
361
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll( null, compact( 'id' ) ) );
362
+ $pos = $this->add_request( 'deletepoll', new PollDaddy_Poll( null, compact( 'id' ) ) );
363
  $this->send_request();
364
 
365
  return empty( $this->errors );
370
  * @param array $args polldaddy_poll() args
371
  * @return array|false PollDaddy Poll or false on failure
372
  */
373
+ function create_poll( $args = null ) {
374
  if ( !$poll = polldaddy_poll( $args ) )
375
  return false;
376
  // $pos = $this->add_request( __FUNCTION__, $poll );
377
+ $pos = $this->add_request( 'createpoll', $poll );
378
  $this->send_request();
379
  if ( !$demand = $this->response_part( $pos ) )
380
  return $demand;
390
  * @param array $args polldaddy_poll() args
391
  * @return array|false PollDaddy Poll or false on failure
392
  */
393
+ function update_poll( $id, $args = null ) {
394
  if ( !$id = (int) $id )
395
  return false;
396
 
398
  return false;
399
 
400
  // $pos = $this->add_request( __FUNCTION__, $poll );
401
+ $pos = $this->add_request( 'updatepoll', $poll );
402
  $this->send_request();
403
+ if ( !$demand = $this->response_part( $pos ) )
404
+ return $demand;
405
+ if ( !isset( $demand->poll ) )
406
+ return false;
407
+ return $demand->poll;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  }
409
 
410
  /* Poll Results */
411
  /**
412
  * @param int $id PollDaddy Poll ID
413
+ * @return array|false PollDaddy Result or false on failure
414
  */
415
+ function get_poll_results( $id ) {
416
  if ( !$id = (int) $id )
417
  return false;
418
+
419
+ $start = 0;
420
+ $end = 2;
421
 
422
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll_Result( null, compact( 'id' ) ) );
423
+ $pos = $this->add_request( 'getpollresults', new PollDaddy_Poll( null, compact( 'id' ) ) );
424
+ //Optionally if you want to list other answers...
425
+ //$pos = $this->add_request( 'getpollresults', new PollDaddy_List( null, compact( 'id', 'start', 'end' ) ) );
426
  $this->send_request();
427
 
428
  $demand = $this->response_part( $pos );
452
 
453
  /**
454
  * @param int $id PollDaddy Poll ID
455
+ * @return bool success
456
  */
457
+ function reset_poll_results( $id ) {
458
  if ( !$id = (int) $id )
459
  return false;
460
 
461
  // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Poll_Result( null, compact( 'id' ) ) );
462
+ $pos = $this->add_request( 'resetpollresults', new PollDaddy_Poll( null, compact( 'id' ) ) );
463
  $this->send_request();
464
 
465
  return empty( $this->errors );
466
  }
467
 
468
  /* Poll Comments */
469
+ /**
470
+ * @param int $id PollDaddy Poll ID
471
+ * @return array|false PollDaddy Comments or false on failure
472
+ */
473
+ function get_poll_comments( $id ) {
474
+ if ( !$id = (int) $id )
475
+ return false;
476
 
477
+ // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Comments( null, compact( 'id' ) ) );
478
+ $pos = $this->add_request( 'getpollcomments', new PollDaddy_Poll( null, compact( 'id' ) ) );
479
+ $this->send_request();
480
+
481
+ $demand = $this->response_part( $pos );
482
+
483
+ if ( is_a( $demand, 'Ghetto_XML_Object' ) && isset( $demand->comments ) ) {
484
+ if ( isset( $demand->comments->comment ) && !is_array( $demand->comments->comment ) ) {
485
+ if ( $demand->comments->comment )
486
+ $demand->comments->comment = array( $demand->comments->comment );
487
+ else
488
+ $demand->comments->comment = array();
489
+ }
490
+ return $demand->comments;
491
+ }
492
  return false;
493
  }
494
 
495
+ /**
496
+ * @see polldaddy_comment()
497
+ * @param array $args polldaddy_comment() args
498
+ * @return bool success
499
+ */
500
+ function moderate_comment( $id, $args = null ) {
501
+ if ( !$id = (int) $id )
502
+ return false;
503
+
504
+ if ( !$comment = polldaddy_comment( $args, $id ) )
505
+ return false;
506
 
507
+ // $this->add_request( __FUNCTION__, new PollDaddy_Comments( $comments ) );
508
+ $this->add_request( 'moderatecomment', $comment);
509
+ $this->send_request();
510
+
511
+ return empty( $this->errors );
512
  }
513
 
514
+ /* Languages */
515
+ /**
516
+ * @return array|false PollDaddy Languages or false on failure
517
+ */
518
+ function get_languages() {
519
+
520
+ // $pos = $this->add_request( __FUNCTION__, null );
521
+ $pos = $this->add_request( 'getlanguages', null );
522
+ $this->send_request();
523
+
524
+ $demand = $this->response_part( $pos );
525
+
526
+ if ( is_a( $demand, 'Ghetto_XML_Object' ) && isset( $demand->languages ) ) {
527
+ if ( isset( $demand->languages->language ) && !is_array( $demand->languages->language ) ) {
528
+ if ( $demand->languages->language )
529
+ $demand->languages->language = array( $demand->languages->language );
530
+ else
531
+ $demand->languages->language = array();
532
+ }
533
+ return $demand->languages->language;
534
+ }
535
  return false;
536
  }
537
 
538
  /* Language Packs */
539
+ /**
540
+ * @return array|false PollDaddy Packs or false on failure
541
+ */
542
+ function get_packs() {
543
+
544
+ // $pos = $this->add_request( __FUNCTION__, null );
545
+ $pos = $this->add_request( 'getpacks', null );
546
+ $this->send_request();
547
+
548
+ $demand = $this->response_part( $pos );
549
+ if ( isset( $demand->packs ) ) {
550
+ if ( isset( $demand->packs->pack ) ) {
551
+ if ( !is_array( $demand->packs->pack ) )
552
+ $demand->packs->pack = array( $demand->packs->pack );
553
+ }
554
+ return $demand->packs;
555
+ }
556
  return false;
557
  }
558
+
559
+ /**
560
+ * @param int $id PollDaddy Pack ID
561
+ * @return array|false PollDaddy Pack or false on failure
562
+ */
563
+ function get_pack( $id ) {
564
+ if ( !$id = (int) $id )
565
+ return false;
566
 
567
+ // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Pack( null, compact( 'id' ) ) );
568
+ $pos = $this->add_request( 'getpack', new PollDaddy_Pack( null, compact( 'id' ) ) );
569
+ $this->send_request();
570
+
571
+ $demand = $this->response_part( $pos );
572
+
573
+ if ( is_a( $demand, 'Ghetto_XML_Object' ) && isset( $demand->pack ) ) {
574
+ return $demand->pack;
575
+ }
576
  return false;
577
  }
578
 
579
+ /**
580
+ * @param int $id PollDaddy Pack ID
581
+ * @return bool success
582
+ */
583
+ function delete_pack( $id ) {
584
+ if ( !$id = (int) $id )
585
+ return false;
586
+
587
+ // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Pack( null, compact( 'id' ) ) );
588
+ $pos = $this->add_request( 'deletepack', new PollDaddy_Pack( null, compact( 'id' ) ) );
589
+ $this->send_request();
590
+
591
+ return empty( $this->errors );
592
  }
593
 
594
+ /**
595
+ * @see polldaddy_pack()
596
+ * @param array $args polldaddy_pack() args
597
+ * @return array|false PollDaddy Pack or false on failure
598
+ */
599
+ function create_pack( $args = null ) {
600
+ if ( !$pack = polldaddy_pack( $args ) )
601
+ return false;
602
+ // $pos = $this->add_request( __FUNCTION__, $pack );
603
+ $pos = $this->add_request( 'createpack', $pack );
604
+ $this->send_request();
605
+ if ( !$demand = $this->response_part( $pos ) )
606
+ return $demand;
607
+ if ( !isset( $demand->pack ) )
608
+ return false;
609
+ return $demand->pack;
610
  }
611
 
612
+ /**
613
+ * @see polldaddy_pack()
614
+ * @param int $id PollDaddy Pack ID
615
+ * @param array $args polldaddy_pack() args
616
+ * @return array|false PollDaddy Pack or false on failure
617
+ */
618
+ function update_pack( $id, $args = null ) {
619
+ if ( !$id = (int) $id )
620
+ return false;
621
+
622
+ if ( !$pack = polldaddy_pack( $args, $id ) )
623
+ return false;
624
+
625
+ // $pos = $this->add_request( __FUNCTION__, $pack );
626
+ $pos = $this->add_request( 'updatepack', $pack );
627
+ $this->send_request();
628
+ return $this->response_part( $pos );
629
  }
630
 
631
+ /* Styles */
632
+ /**
633
+ * @return array|false PollDaddy Styles or false on failure
634
+ */
635
+ function get_styles() {
636
+
637
+ // $pos = $this->add_request( __FUNCTION__, null );
638
  $pos = $this->add_request( 'getstyles', null );
639
  $this->send_request();
640
 
649
  return false;
650
  }
651
 
652
+ /**
653
+ * @param int $id PollDaddy Style ID
654
+ * @return array|false PollDaddy Style or false on failure
655
+ */
656
+ function get_style( $id ) {
657
+ if ( !$id = (int) $id )
658
+ return false;
659
+
660
+ // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Style( null, compact( 'id' ) ) );
661
+ $pos = $this->add_request( 'getstyle', new PollDaddy_Style( null, compact( 'id' ) ) );
662
+ $this->send_request();
663
+
664
+ $demand = $this->response_part( $pos );
665
+
666
+ if ( is_a( $demand, 'Ghetto_XML_Object' ) && isset( $demand->style ) ) {
667
+ return $demand->style;
668
+ }
669
  return false;
670
  }
671
 
672
+ /**
673
+ * @param int $id PollDaddy Style ID
674
+ * @return bool success
675
+ */
676
+ function delete_style( $id ) {
677
+ if ( !$id = (int) $id )
678
+ return false;
679
+
680
+ // $pos = $this->add_request( __FUNCTION__, new PollDaddy_Style( null, compact( 'id' ) ) );
681
+ $pos = $this->add_request( 'deletestyle', new PollDaddy_Style( null, compact( 'id' ) ) );
682
+ $this->send_request();
683
+
684
+ return empty( $this->errors );
685
  }
686
 
687
+ /**
688
+ * @see polldaddy_style()
689
+ * @param array $args polldaddy_style() args
690
+ * @return array|false PollDaddy Style or false on failure
691
+ */
692
+ function create_style( $args = null ) {
693
+ if ( !$style = polldaddy_style( $args ) )
694
+ return false;
695
+ // $pos = $this->add_request( __FUNCTION__, $style );
696
+ $pos = $this->add_request( 'createstyle', $style );
697
+ $this->send_request();
698
+ if ( !$demand = $this->response_part( $pos ) )
699
+ return $demand;
700
+ if ( !isset( $demand->style ) )
701
+ return false;
702
+ return $demand->style;
703
  }
704
 
705
+ /**
706
+ * @see polldaddy_style()
707
+ * @param int $id PollDaddy Style ID
708
+ * @param array $args polldaddy_style() args
709
+ * @return array|false PollDaddy Style or false on failure
710
+ */
711
+ function update_style( $id, $args = null ) {
712
+ if ( !$id = (int) $id )
713
+ return false;
714
+
715
+ if ( !$style = polldaddy_style( $args, $id ) )
716
+ return false;
717
+
718
+ // $pos = $this->add_request( __FUNCTION__, $style );
719
+ $pos = $this->add_request( 'updatestyle', $style );
720
+ $this->send_request();
721
+ if ( !$demand = $this->response_part( $pos ) )
722
+ return $demand;
723
+ if ( !isset( $demand->style ) )
724
+ return false;
725
+ return $demand->style;
726
+ }
727
+
728
+ function get_rating( $id ){
729
+ if ( !$id = (int) $id )
730
+ return false;
731
+
732
+ $pos = $this->add_request( 'getrating', new PollDaddy_Rating( null , compact( 'id' ) ) );
733
+
734
+ $this->send_request();
735
+
736
+ $demand = $this->response_part( $pos );
737
+
738
+ if ( is_a( $demand, 'Ghetto_XML_Object' ) && isset( $demand->rating ) ){
739
+ return $demand->rating;
740
+ }
741
+
742
  return false;
743
+
744
  }
745
+
746
+ function update_rating( $id, $settings, $type ){
747
 
748
+ if ( !$id = (int) $id )
749
+ return false;
750
+
751
+ $pos = $this->add_request( 'updaterating', new PollDaddy_Rating( compact( 'settings' ) , compact( 'id', 'type' ) ) );
752
+
753
+ $this->send_request();
754
+
755
+ $demand = $this->response_part( $pos );
756
+
757
+ if ( is_a( $demand, 'Ghetto_XML_Object' ) && isset( $demand->rating ) ){
758
+ return $demand->rating;
759
+ }
760
+
761
+ return false;
762
+
763
+ }
764
+
765
+ /* Create Rating
766
+ * @param string $name PollDaddy rating name
767
+ * @param string $type PollDaddy rating type
768
+ * @return array|false PollDaddy Result or false on failure
769
+ */
770
+
771
+ function create_rating( $name, $type ){
772
+
773
+ $pos = $this->add_request( 'createrating', new PollDaddy_Rating( compact( 'name' ) , compact( 'type' ) ) );
774
+
775
+ $this->send_request();
776
+
777
+ $demand = $this->response_part( $pos );
778
+
779
+ if ( is_a( $demand, 'Ghetto_XML_Object' ) && isset( $demand->rating ) ){
780
+ return $demand->rating;
781
+ }
782
+
783
+ return false;
784
+
785
+ }
786
+
787
+
788
+ /* Rating Results */
789
+ /**
790
+ * @param int $id PollDaddy Poll ID
791
+ * @param string $period Rating period
792
+ * @param int $start paging start
793
+ * @param int $end paging end
794
+ * @return array|false PollDaddy Rating Result or false on failure
795
+ */
796
+ function get_rating_results( $id, $period = '90', $start = 0, $end = 2 ) {
797
+ if ( !$id = (int) $id )
798
+ return false;
799
+
800
+ $pos = $this->add_request( 'getratingresults', new PollDaddy_List( compact( 'period' ) , compact( 'id', 'start', 'end' ) ) );
801
+
802
+ $this->send_request();
803
+
804
+ $demand = $this->response_part( $pos );
805
+
806
+ if ( is_a( $demand, 'Ghetto_XML_Object' ) && isset( $demand->rating_result ) ) {
807
+ if ( isset( $demand->rating_result->ratings ) ) {
808
+ if ( isset( $demand->rating_result->ratings->rating ) ) {
809
+ if ( !is_array( $demand->rating_result->ratings->rating ) )
810
+ $demand->rating_result->ratings->rating = array( $demand->rating_result->ratings->rating );
811
+ }
812
+ return $demand->rating_result->ratings;
813
+ }
814
+ }
815
  return false;
816
  }
817
+ }
818
 
819
+ function &polldaddy_activity( $act ) {
820
+ if ( !is_string( $act ) || !$act )
 
821
  return false;
822
+
823
+ $obj = new PollDaddy_Activity( $act );
824
+
825
+ return $obj;
826
+ }
827
+
828
+ /**
829
+ * @param int $id
830
+ * @param string $title
831
+ * @param string $css
832
+ */
833
+ function &polldaddy_style( $args = null, $id = null, $_require_data = true ) {
834
+ $false = false;
835
+ if ( is_a( $args, 'PollDaddy_Style' ) ) {
836
+ if ( is_null( $id ) )
837
+ return $args;
838
+ if ( !$id = (int) $id )
839
+ return $false;
840
+ $args->_id = $id;
841
+ return $args;
842
  }
843
 
844
+ $defaults = _polldaddy_style_defaults();
845
+ $retro = 0;
846
+
847
+ if ( !is_null( $args ) ) {
848
+ $args = wp_parse_args( $args, $defaults );
849
+
850
+ //if ( $_require_data ) {}
851
+
852
+ $retro = (int) $args['retro'];
853
+
854
+ if ( is_null( $id ) )
855
+ $id = $args['id'];
856
+ unset( $args['id'] );
857
+ }
858
+
859
+ $obj = new PollDaddy_Style( $args, compact( 'id', 'retro' ) );
860
+
861
+ return $obj;
862
+ }
863
+
864
+ function _polldaddy_style_defaults() {
865
+ return array(
866
+ 'id' => null,
867
+ 'title' => false,
868
+ 'css' => false,
869
+ 'retro' => 0
870
+ );
871
+ }
872
+
873
+ /**
874
+ * @param int $id
875
+ * @param string $title
876
+ * @param array $phrases
877
+ */
878
+ function &polldaddy_pack( $args = null, $id = null, $_require_data = true ) {
879
+ $false = false;
880
+ if ( is_a( $args, 'PollDaddy_Pack' ) ) {
881
+ if ( is_null( $id ) )
882
+ return $args;
883
+ if ( !$id = (int) $id )
884
+ return $false;
885
+ $args->_id = $id;
886
+ return $args;
887
+ }
888
+
889
+ $defaults = _polldaddy_pack_defaults();
890
+ $retro = 0;
891
+
892
+ if ( !is_null( $args ) ) {
893
+ $args = wp_parse_args( $args, $defaults );
894
+
895
+ //if ( $_require_data ) {}
896
+
897
+ $retro = (int) $args['retro'];
898
+
899
+ $args['pack'] = new Custom_Pack( $args['pack'] );
900
+
901
+ if ( is_null( $id ) )
902
+ $id = $args['id'];
903
+ unset( $args['id'] );
904
+ }
905
+
906
+ $obj = new PollDaddy_Pack( $args, compact( 'id', 'retro' ) );
907
+
908
+ return $obj;
909
+ }
910
+
911
+ function _polldaddy_pack_defaults() {
912
+ return array(
913
+ 'id' => null,
914
+ 'retro' => 0,
915
+ 'pack' => array()
916
+ );
917
+ }
918
+
919
+ function _polldaddy_pack_phrases_defaults() {
920
+ return array(
921
+ 'id' => null,
922
+ 'type' => null,
923
+ 'title' => false,
924
+ 'phrase' => array()
925
+ );
926
+ }
927
+
928
+ function &polldaddy_custom_phrase( $phrase, $phraseID = null ) {
929
+ if ( !is_string( $phrase ) || !$phrase )
930
  return false;
931
+
932
+ $obj = new Custom_Pack_Phrase( $phrase, compact( 'phraseID' ) );
933
+
934
+ return $obj;
935
+ }
936
+
937
+ function polldaddy_email( $args = null, $id = null, $_require_data = true ) {
938
+ if ( is_a( $args, 'PollDaddy_Email' ) ) {
939
+ if ( is_null( $id ) )
940
+ return $args;
941
+ if ( !$id = (int) $id )
942
+ return $false;
943
+ $args->_id = $id;
944
+ return $args;
945
  }
946
+
947
+ $defaults = array();
948
+
949
+ if ( !is_null( $args ) ) {
950
+ $args = wp_parse_args( $args, $defaults );
951
+
952
+ if ( $_require_data ) {
953
+ if ( !isset( $args['address'] ) || !is_string( $args['address'] ) )
954
+ return false;
955
+ }
956
+
957
+ // Check email is an email address
958
+ if ( preg_match( '/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $args['address'], $matches ) == 0 )
959
+ return false;
960
+ }
961
+
962
+ return new PollDaddy_Email( $args, compact( 'id' ) );
963
  }
964
 
965
  /**
989
  if ( !is_string( $args[$required] ) || !$args[$required] )
990
  return $false;
991
 
992
+ $obj = new PollDaddy_Account( $args );
993
+
994
+ return $obj;
995
  }
996
 
997
  function _polldaddy_account_defaults() {
1047
  if ( !in_array( $args['resultsType'], array( 'show', 'percent', 'hide' ) ) )
1048
  $args['resultsType'] = $defaults['resultsType'];
1049
 
1050
+ if ( !in_array( $args['blockRepeatVotersType'], array( 'off', 'cookie', 'cookieip' ) ) )
1051
  $args['blockRepeatVotersType'] = $defaults['blockRepeatVotersType'];
1052
 
1053
  if ( !in_array( $args['comments'], array( 'off', 'allow', 'moderate' ) ) )
1054
  $args['comments'] = $defaults['comments'];
1055
 
1056
  if ( is_numeric( $args['closeDate'] ) )
1057
+ $args['closeDate'] = gmdate( 'Y-m-d H:i:s', $args['closeDate'] );
1058
  if ( !$args['closeDate'] )
1059
+ $args['closeDate'] = gmdate( 'Y-m-d H:i:s' );
1060
 
1061
  $args['answers'] = new PollDaddy_Poll_Answers( array( 'answer' => $args['answers'] ) );
1062
 
1064
  $id = $args['id'];
1065
  unset( $args['id'] );
1066
  }
1067
+
1068
+ $obj = new PollDaddy_Poll( $args, compact( 'id' ) );
1069
 
1070
+ return $obj;
1071
  }
1072
 
1073
  function _polldaddy_poll_defaults() {
1079
  'otherAnswer' => 'no',
1080
  'resultsType' => 'show',
1081
  'blockRepeatVotersType' => 'cookie',
1082
+ 'comments' => 'allow',
1083
  'makePublic' => 'yes',
1084
  'closePoll' => 'no',
1085
  'closePollNow' => 'no',
 
1086
  'sharing' => 'yes',
1087
+ 'closeDate' => gmdate( 'Y-m-d H:i:s' ),
1088
  'styleID' => 0,
1089
  'packID' => 0,
1090
  'folderID' => 0,
1091
  'languageID' => _polldaddy_poll_default_language_id(),
1092
  'parentID' => (int) $GLOBALS['blog_id'],
1093
+ 'mediaCode' => '',
1094
+ 'mediaType' => 0,
1095
  'answers' => array()
1096
  );
1097
  }
1098
 
1099
+ /**
1100
+ * @param int $id
1101
+ * @param int $type
1102
+ */
1103
+ function &polldaddy_comment( $args = null, $id = null ) {
1104
+ $defaults = _polldaddy_comment_defaults();
1105
+
1106
+ $atts = wp_parse_args( $args, $defaults );
1107
+
1108
+ $obj = new PollDaddy_Comment( null, $atts );
1109
+
1110
+ return $obj;
1111
+ }
1112
+
1113
+ function _polldaddy_comment_defaults() {
1114
+ return array(
1115
+ 'id' => null,
1116
+ 'method' => 0
1117
+ );
1118
+ }
1119
+
1120
+ /**
1121
+ * @param int $id
1122
+ * @param array $comment
1123
+ */
1124
+ function &polldaddy_comments( $args = null, $id = null ) {
1125
+ $false = false;
1126
+ if ( is_a( $args, 'PollDaddy_Comments' ) )
1127
+ return $args;
1128
+
1129
+ $defaults = _polldaddy_comments_defaults();
1130
+
1131
+ $args = wp_parse_args( $args, $defaults );
1132
+
1133
+ if ( is_null( $id ) )
1134
+ $id = $args['id'];
1135
+ unset( $args['id'] );
1136
+
1137
+ $obj = new PollDaddy_Comments( $args, compact( 'id' ) );
1138
+
1139
+ return $obj;
1140
+ }
1141
+
1142
+ function _polldaddy_comments_defaults() {
1143
+ return array(
1144
+ 'id' => null,
1145
+ 'comment' => array()
1146
+ );
1147
+ }
1148
+
1149
  if ( !function_exists( '_polldaddy_poll_default_language_id' ) ) :
1150
  function _polldaddy_poll_default_language_id() {
1151
  return 1;
1152
  }
1153
  endif;
1154
 
1155
+ function &polldaddy_poll_answer( $args, $id = null ) {
1156
+ if ( !is_string( $args['text'] ) || !$args['text'] )
1157
  return false;
1158
+
1159
+ $answer = new PollDaddy_Poll_Answer( $args, compact( 'id' ) );
1160
 
1161
+ return $answer;
1162
  }
1163
 
1164
  if ( !function_exists( 'wp_parse_args' ) ) :
1228
  return $value;
1229
  }
1230
  endif;
1231
+ ?>
polldaddy-xml.php CHANGED
@@ -33,11 +33,16 @@ class Ghetto_XML_Object {
33
 
34
  $prepend_ns = 'all' === $prepend_ns;
35
 
 
 
 
 
36
  if ( !$cdata = $atts['___cdata'] )
37
  $cdata = array();
38
 
39
  $x = "<$name";
40
- if ( $atts['___content'] ) {
 
41
  $inner = in_array( '___content', $cdata ) ? '<![CDATA[' . $atts['___content'] . ']]>' : $atts['___content'];
42
  $empty = false;
43
  } else {
@@ -49,7 +54,7 @@ class Ghetto_XML_Object {
49
 
50
  $_pad = str_repeat( "\t", $pad + 1 );
51
 
52
- foreach ( $atts as $key => $value ) {
53
  if ( is_null( $value ) )
54
  continue;
55
  if ( '_' == $key[0] ) {
@@ -65,17 +70,19 @@ class Ghetto_XML_Object {
65
  $empty = false;
66
  if ( false === $value ) {
67
  $inner .= "$_pad<$key />\n";
68
- } elseif ( is_array( $value ) ) {
 
69
  foreach ( $value as $array_value ) {
70
  if ( is_a( $array_value, 'Ghetto_XML_Object' ) )
71
  $inner .= $_pad . $array_value->xml( $_prepend_ns, $pad + 1 ) . "\n";
72
  else
73
  $inner .= in_array( $_key, $cdata ) ? "$_pad<$key>" . '<![CDATA[' . $array_value . ']]>' . "</$key>\n" : "$_pad<$key>$array_value</$key>\n";
74
  }
75
- } else {
 
76
  if ( is_a( $value, 'Ghetto_XML_Object' ) )
77
  $inner .= $_pad . $value->xml( $_prepend_ns, $pad + 1 ) . "\n";
78
- else {
79
  $inner .= in_array( $_key, $cdata ) ? "$_pad<$key>" . '<![CDATA[' . $value . ']]>' . "</$key>\n" : "$_pad<$key>$value</$key>\n";
80
  }
81
  }
@@ -146,6 +153,8 @@ class PollDaddy_Request extends PollDaddy_XML_Root {
146
  var $___name = 'pdRequest';
147
 
148
  var $_partnerGUID;
 
 
149
 
150
  var $userCode;
151
  var $demands;
@@ -155,10 +164,12 @@ class PollDaddy_Response extends PollDaddy_XML_Root {
155
  var $___name = 'pdResponse';
156
 
157
  var $_partnerGUID;
 
158
 
159
  var $userCode;
160
  var $demands;
161
  var $errors;
 
162
  }
163
 
164
  class PollDaddy_Errors extends PollDaddy_XML_Object {
@@ -168,6 +179,7 @@ class PollDaddy_Errors extends PollDaddy_XML_Object {
168
  }
169
 
170
  class PollDaddy_Error extends PollDaddy_XML_Object {
 
171
  var $___name = 'error';
172
 
173
  var $___content;
@@ -175,6 +187,23 @@ class PollDaddy_Error extends PollDaddy_XML_Object {
175
  var $_id;
176
  }
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  class PollDaddy_Demands extends PollDaddy_XML_Object {
179
  var $___name = 'demands';
180
 
@@ -189,15 +218,28 @@ class PollDaddy_Demand extends PollDaddy_XML_Object {
189
  var $account;
190
  var $poll;
191
  var $polls;
 
 
192
  var $list;
193
  var $search;
194
  var $result;
 
 
 
 
195
  var $styles;
196
  var $style;
 
 
 
 
 
 
 
197
  }
198
 
199
  class PollDaddy_Account extends PollDaddy_XML_Object {
200
- var $___cdata = array( 'userName', 'password', 'firstName', 'lastName', 'websiteURL', 'avatarURL', 'bio' );
201
  var $___name = 'account';
202
 
203
  var $userName;
@@ -219,6 +261,8 @@ class PollDaddy_List extends PollDaddy_XML_Object {
219
  var $_start;
220
  var $_end;
221
  var $_id;
 
 
222
  }
223
 
224
  class PollDaddy_Polls extends PollDaddy_XML_Object {
@@ -239,7 +283,7 @@ class PollDaddy_Search extends PollDaddy_XML_Object {
239
  }
240
 
241
  class PollDaddy_Poll extends PollDaddy_XML_Object {
242
- var $___cdata = array( '___content', 'question' );
243
  var $___name = 'poll';
244
 
245
  var $___content;
@@ -267,13 +311,24 @@ class PollDaddy_Poll extends PollDaddy_XML_Object {
267
  var $folderID;
268
  var $languageID;
269
  var $parentID;
 
 
 
270
  var $answers;
271
-
272
  var $sharing;
273
  var $rank;
274
  var $url;
275
  }
276
 
 
 
 
 
 
 
 
 
 
277
  class PollDaddy_Poll_Answers extends PollDaddy_XML_Object {
278
  var $___name = 'answers';
279
 
@@ -281,29 +336,85 @@ class PollDaddy_Poll_Answers extends PollDaddy_XML_Object {
281
  }
282
 
283
  class PollDaddy_Poll_Answer extends PollDaddy_XML_Object {
284
- var $___cdata = array( '___content' );
285
  var $___name = 'answer';
286
 
287
- var $___content;
288
-
289
  var $_id;
290
  var $_total;
291
  var $_percent;
 
 
 
 
 
 
 
 
292
  }
293
 
294
- class PollDaddy_Poll_Result extends PollDaddy_XML_Object {
295
- var $___name = 'result';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
296
 
297
  var $_id;
298
 
299
- var $answers;
300
- var $otherAnswers;
301
  }
302
 
303
- class PollDaddy_Other_Answers extends PollDaddy_XML_Object {
304
- var $___name = 'otherAnswers';
 
305
 
306
- var $otherAnswer;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  }
308
 
309
  class PollDaddy_Styles extends PollDaddy_XML_Object {
@@ -318,12 +429,153 @@ class PollDaddy_Style extends PollDaddy_XML_Object {
318
 
319
  var $_id;
320
  var $_type;
 
321
 
322
  var $title;
323
  var $date;
324
  var $css;
325
  }
326
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
327
  class PollDaddy_XML_Parser {
328
  var $parser;
329
  var $polldaddy_objects = array(
@@ -335,18 +587,38 @@ class PollDaddy_XML_Parser {
335
  'http://api.polldaddy.com/pdapi.xsd:error' => 'PollDaddy_Error',
336
  'http://api.polldaddy.com/pdapi.xsd:demands' => 'PollDaddy_Demands',
337
  'http://api.polldaddy.com/pdapi.xsd:demand' => 'PollDaddy_Demand',
 
 
338
  'http://api.polldaddy.com/pdapi.xsd:account' => 'PollDaddy_Account',
339
  'http://api.polldaddy.com/pdapi.xsd:list' => 'PollDaddy_List',
340
  'http://api.polldaddy.com/pdapi.xsd:polls' => 'PollDaddy_Polls',
341
  'http://api.polldaddy.com/pdapi.xsd:search' => 'PollDaddy_Search',
342
  'http://api.polldaddy.com/pdapi.xsd:poll' => 'PollDaddy_Poll',
 
 
343
  'http://api.polldaddy.com/pdapi.xsd:answers' => 'PollDaddy_Poll_Answers',
344
  'http://api.polldaddy.com/pdapi.xsd:answer' => 'PollDaddy_Poll_Answer',
345
  'http://api.polldaddy.com/pdapi.xsd:otherAnswers' => 'PollDaddy_Other_Answers',
346
  'http://api.polldaddy.com/pdapi.xsd:result' => 'PollDaddy_Poll_Result',
 
 
 
 
 
347
  'http://api.polldaddy.com/pdapi.xsd:styles' => 'PollDaddy_Styles',
348
- 'http://api.polldaddy.com/pdapi.xsd:style' => 'PollDaddy_Style'
349
- );
 
 
 
 
 
 
 
 
 
 
 
350
 
351
  var $object_stack = array();
352
  var $object_pos = null;
@@ -454,3 +726,4 @@ class PollDaddy_XML_Parser {
454
  }
455
  }
456
  }
 
33
 
34
  $prepend_ns = 'all' === $prepend_ns;
35
 
36
+ // added this to remove the Warning ( PHP Notice: Undefined index ) in following condition
37
+ if ( !isset( $atts['___cdata'] ) )
38
+ $atts['___cdata'] = '';
39
+
40
  if ( !$cdata = $atts['___cdata'] )
41
  $cdata = array();
42
 
43
  $x = "<$name";
44
+
45
+ if ( isset( $atts['___content'] ) ) {
46
  $inner = in_array( '___content', $cdata ) ? '<![CDATA[' . $atts['___content'] . ']]>' : $atts['___content'];
47
  $empty = false;
48
  } else {
54
 
55
  $_pad = str_repeat( "\t", $pad + 1 );
56
 
57
+ foreach ( $atts as $key => $value ) {
58
  if ( is_null( $value ) )
59
  continue;
60
  if ( '_' == $key[0] ) {
70
  $empty = false;
71
  if ( false === $value ) {
72
  $inner .= "$_pad<$key />\n";
73
+ }
74
+ elseif ( is_array( $value ) ) {
75
  foreach ( $value as $array_value ) {
76
  if ( is_a( $array_value, 'Ghetto_XML_Object' ) )
77
  $inner .= $_pad . $array_value->xml( $_prepend_ns, $pad + 1 ) . "\n";
78
  else
79
  $inner .= in_array( $_key, $cdata ) ? "$_pad<$key>" . '<![CDATA[' . $array_value . ']]>' . "</$key>\n" : "$_pad<$key>$array_value</$key>\n";
80
  }
81
+ }
82
+ else {
83
  if ( is_a( $value, 'Ghetto_XML_Object' ) )
84
  $inner .= $_pad . $value->xml( $_prepend_ns, $pad + 1 ) . "\n";
85
+ else{
86
  $inner .= in_array( $_key, $cdata ) ? "$_pad<$key>" . '<![CDATA[' . $value . ']]>' . "</$key>\n" : "$_pad<$key>$value</$key>\n";
87
  }
88
  }
153
  var $___name = 'pdRequest';
154
 
155
  var $_partnerGUID;
156
+ var $_version;
157
+ var $_admin;
158
 
159
  var $userCode;
160
  var $demands;
164
  var $___name = 'pdResponse';
165
 
166
  var $_partnerGUID;
167
+ var $_partnerUserID;
168
 
169
  var $userCode;
170
  var $demands;
171
  var $errors;
172
+ var $queries;
173
  }
174
 
175
  class PollDaddy_Errors extends PollDaddy_XML_Object {
179
  }
180
 
181
  class PollDaddy_Error extends PollDaddy_XML_Object {
182
+ var $___cdata = array( '___content' );
183
  var $___name = 'error';
184
 
185
  var $___content;
187
  var $_id;
188
  }
189
 
190
+ class PollDaddy_Queries extends PollDaddy_XML_Object {
191
+ var $___name = 'queries';
192
+
193
+ var $query;
194
+ }
195
+
196
+ class PollDaddy_Query extends PollDaddy_XML_Object {
197
+ var $___cdata = array( 'text' );
198
+ var $___name = 'query';
199
+
200
+ var $_id;
201
+
202
+ var $time;
203
+ var $text;
204
+ var $caller;
205
+ }
206
+
207
  class PollDaddy_Demands extends PollDaddy_XML_Object {
208
  var $___name = 'demands';
209
 
218
  var $account;
219
  var $poll;
220
  var $polls;
221
+ var $emailAddress;
222
+ var $message;
223
  var $list;
224
  var $search;
225
  var $result;
226
+ var $comments; //need to add an request object for each new type
227
+ var $comment;
228
+ var $extensions;
229
+ var $folders;
230
  var $styles;
231
  var $style;
232
+ var $packs;
233
+ var $pack;
234
+ var $languages;
235
+ var $activity;
236
+ var $rating_result;
237
+ var $rating;
238
+ var $nonce;
239
  }
240
 
241
  class PollDaddy_Account extends PollDaddy_XML_Object {
242
+ var $___cdata = array( 'userName', 'email', 'password', 'firstName', 'lastName', 'websiteURL', 'avatarURL', 'bio' );
243
  var $___name = 'account';
244
 
245
  var $userName;
261
  var $_start;
262
  var $_end;
263
  var $_id;
264
+
265
+ var $period;
266
  }
267
 
268
  class PollDaddy_Polls extends PollDaddy_XML_Object {
283
  }
284
 
285
  class PollDaddy_Poll extends PollDaddy_XML_Object {
286
+ var $___cdata = array( '___content', 'question', 'mediaCode', 'url' );
287
  var $___name = 'poll';
288
 
289
  var $___content;
311
  var $folderID;
312
  var $languageID;
313
  var $parentID;
314
+ var $keyword;
315
+ var $mediaType; // new
316
+ var $mediaCode; // new
317
  var $answers;
 
318
  var $sharing;
319
  var $rank;
320
  var $url;
321
  }
322
 
323
+ class PollDaddy_Poll_Result extends PollDaddy_XML_Object {
324
+ var $___name = 'result';
325
+
326
+ var $_id;
327
+
328
+ var $answers;
329
+ var $otherAnswers;
330
+ }
331
+
332
  class PollDaddy_Poll_Answers extends PollDaddy_XML_Object {
333
  var $___name = 'answers';
334
 
336
  }
337
 
338
  class PollDaddy_Poll_Answer extends PollDaddy_XML_Object {
339
+ var $___cdata = array( '___content', 'text', 'mediaCode' );
340
  var $___name = 'answer';
341
 
 
 
342
  var $_id;
343
  var $_total;
344
  var $_percent;
345
+ var $_mediaType; // old way
346
+ var $_mediaCode; // old way
347
+
348
+ var $___content;
349
+
350
+ var $text; //removed ___content and replaced it with text node
351
+ var $mediaType; // new
352
+ var $mediaCode; // new
353
  }
354
 
355
+ class PollDaddy_Other_Answers extends PollDaddy_XML_Object {
356
+ var $___name = 'otherAnswers';
357
+
358
+ var $otherAnswer;
359
+ }
360
+
361
+ class PollDaddy_Other_Answer extends PollDaddy_XML_Object {
362
+ var $___cdata = array( '___content' );
363
+ var $___name = 'otherAnswer';
364
+
365
+ var $___content;
366
+ }
367
+
368
+ class PollDaddy_Comments extends PollDaddy_XML_Object {
369
+ var $___cdata = array( '___content' );
370
+ var $___name = 'comments';
371
+
372
+ var $___content;
373
 
374
  var $_id;
375
 
376
+ var $comment;
 
377
  }
378
 
379
+ class PollDaddy_Comment extends PollDaddy_XML_Object {
380
+ var $___cdata = array( 'name', 'email', 'text', 'url' );
381
+ var $___name = 'comment';
382
 
383
+ var $_id; //_ means variable corresponds to an attribute
384
+ var $_method;
385
+ var $_type;
386
+
387
+ var $poll; // without _ means variable corresponds to an element
388
+ var $name;
389
+ var $email;
390
+ var $text;
391
+ var $url;
392
+ var $date;
393
+ var $ip;
394
+ }
395
+
396
+ class PollDaddy_Extensions extends PollDaddy_XML_Object {
397
+ var $___name = 'extensions';
398
+
399
+ var $folders;
400
+ var $styles;
401
+ var $packs;
402
+ var $languages;
403
+ }
404
+
405
+ class PollDaddy_Folders extends PollDaddy_XML_Object {
406
+ var $___name = 'folders';
407
+
408
+ var $folder;
409
+ }
410
+
411
+ class PollDaddy_Folder extends PollDaddy_XML_Object {
412
+ var $___cdata = array( '___content' );
413
+ var $___name = 'folder';
414
+
415
+ var $___content;
416
+
417
+ var $_id;
418
  }
419
 
420
  class PollDaddy_Styles extends PollDaddy_XML_Object {
429
 
430
  var $_id;
431
  var $_type;
432
+ var $_retro;
433
 
434
  var $title;
435
  var $date;
436
  var $css;
437
  }
438
 
439
+ class PollDaddy_Packs extends PollDaddy_XML_Object {
440
+ var $___name = 'packs';
441
+
442
+ var $pack;
443
+ }
444
+
445
+ class PollDaddy_Pack extends PollDaddy_XML_Object {
446
+ var $___name = 'pack';
447
+
448
+ var $_id;
449
+ var $_date;
450
+ var $_retro;
451
+
452
+ var $pack;
453
+ }
454
+
455
+ class Custom_Pack extends PollDaddy_XML_Object {
456
+ var $___name = 'pack';
457
+
458
+ var $_type = 'user'; //type attribute is constant (for now)
459
+
460
+ var $title;
461
+ var $phrase;
462
+
463
+ function xml( $prepend_ns = true, $pad = 0 ) {
464
+ $xml = parent::xml( false, $pad );
465
+ return $xml;
466
+ }
467
+ }
468
+
469
+ class Custom_Pack_Phrase extends PollDaddy_XML_Object {
470
+ var $___cdata = array( '___content' );
471
+ var $___name = 'phrase';
472
+
473
+ var $___content;
474
+
475
+ var $_phraseID;
476
+
477
+ function xml( $prepend_ns = true, $pad = 0 ) {
478
+ $xml = parent::xml( false, $pad );
479
+ return $xml;
480
+ }
481
+ }
482
+
483
+ class PollDaddy_Languages extends PollDaddy_XML_Object {
484
+ var $___name = 'languages';
485
+
486
+ var $language;
487
+ }
488
+
489
+ class PollDaddy_Language extends PollDaddy_XML_Object {
490
+ var $___cdata = array( '___content' );
491
+ var $___name = 'language';
492
+
493
+ var $___content;
494
+
495
+ var $_id;
496
+ }
497
+
498
+ class PollDaddy_Activity extends PollDaddy_XML_Object {
499
+ var $___cdata = array( '___content' );
500
+ var $___name = 'activity';
501
+
502
+ var $___content;
503
+ }
504
+
505
+ class PollDaddy_Nonce extends PollDaddy_XML_Object {
506
+ var $___cdata = array( 'text', 'action' );
507
+ var $___name = 'nonce';
508
+
509
+ var $text;
510
+ var $action;
511
+ var $userCode;
512
+ }
513
+
514
+ class PollDaddy_Rating_Result extends PollDaddy_XML_Object {
515
+ var $___name = 'rating_result';
516
+
517
+ var $_id;
518
+
519
+ var $ratings;
520
+ }
521
+
522
+ class PollDaddy_Ratings extends PollDaddy_XML_Object {
523
+ var $___name = 'ratings';
524
+
525
+ var $_total;
526
+ var $rating;
527
+ }
528
+
529
+ class PollDaddy_Rating extends PollDaddy_XML_Object {
530
+ var $___name = 'rating';
531
+ var $___cdata = array( 'settings' );
532
+
533
+ var $_id;
534
+
535
+ var $_type;
536
+ var $_votes;
537
+ var $uid;
538
+ var $total1;
539
+ var $total2;
540
+ var $total3;
541
+ var $total4;
542
+ var $total5;
543
+ var $average_rating;
544
+ var $date;
545
+ var $title;
546
+ var $permalink;
547
+
548
+ var $name;
549
+ var $folder_id;
550
+ var $settings;
551
+ }
552
+
553
+ class PollDaddy_Email extends PollDaddy_XML_Object {
554
+ var $___cdata = array( 'custom' );
555
+ var $___name = 'emailAddress';
556
+
557
+ var $_id;
558
+ var $_owner;
559
+
560
+ var $folderID;
561
+ var $address;
562
+ var $firstname;
563
+ var $lastname;
564
+ var $custom;
565
+ var $status;
566
+ }
567
+
568
+ class PollDaddy_Email_Message extends PollDaddy_XML_Object {
569
+ var $___cdata = array( 'text' );
570
+ var $___name = 'message';
571
+
572
+ var $_id;
573
+ var $_owner;
574
+
575
+ var $text;
576
+ var $groups;
577
+ }
578
+
579
  class PollDaddy_XML_Parser {
580
  var $parser;
581
  var $polldaddy_objects = array(
587
  'http://api.polldaddy.com/pdapi.xsd:error' => 'PollDaddy_Error',
588
  'http://api.polldaddy.com/pdapi.xsd:demands' => 'PollDaddy_Demands',
589
  'http://api.polldaddy.com/pdapi.xsd:demand' => 'PollDaddy_Demand',
590
+ 'http://api.polldaddy.com/pdapi.xsd:queries' => 'PollDaddy_Queries',
591
+ 'http://api.polldaddy.com/pdapi.xsd:query' => 'PollDaddy_Query',
592
  'http://api.polldaddy.com/pdapi.xsd:account' => 'PollDaddy_Account',
593
  'http://api.polldaddy.com/pdapi.xsd:list' => 'PollDaddy_List',
594
  'http://api.polldaddy.com/pdapi.xsd:polls' => 'PollDaddy_Polls',
595
  'http://api.polldaddy.com/pdapi.xsd:search' => 'PollDaddy_Search',
596
  'http://api.polldaddy.com/pdapi.xsd:poll' => 'PollDaddy_Poll',
597
+ 'http://api.polldaddy.com/pdapi.xsd:emailAddress' => 'PollDaddy_Email',
598
+ 'http://api.polldaddy.com/pdapi.xsd:message' => 'PollDaddy_Email_Message',
599
  'http://api.polldaddy.com/pdapi.xsd:answers' => 'PollDaddy_Poll_Answers',
600
  'http://api.polldaddy.com/pdapi.xsd:answer' => 'PollDaddy_Poll_Answer',
601
  'http://api.polldaddy.com/pdapi.xsd:otherAnswers' => 'PollDaddy_Other_Answers',
602
  'http://api.polldaddy.com/pdapi.xsd:result' => 'PollDaddy_Poll_Result',
603
+ 'http://api.polldaddy.com/pdapi.xsd:comments' => 'PollDaddy_Comments',
604
+ 'http://api.polldaddy.com/pdapi.xsd:comment' => 'PollDaddy_Comment',
605
+ 'http://api.polldaddy.com/pdapi.xsd:extensions' => 'PollDaddy_Extensions',
606
+ 'http://api.polldaddy.com/pdapi.xsd:folders' => 'PollDaddy_Folders',
607
+ 'http://api.polldaddy.com/pdapi.xsd:folder' => 'PollDaddy_Folder',
608
  'http://api.polldaddy.com/pdapi.xsd:styles' => 'PollDaddy_Styles',
609
+ 'http://api.polldaddy.com/pdapi.xsd:style' => 'PollDaddy_Style',
610
+ 'http://api.polldaddy.com/pdapi.xsd:packs' => 'PollDaddy_Packs',
611
+ 'http://api.polldaddy.com/pdapi.xsd:pack' => 'PollDaddy_Pack',
612
+ 'http://api.polldaddy.com/pdapi.xsd:languages' => 'PollDaddy_Languages',
613
+ 'http://api.polldaddy.com/pdapi.xsd:language' => 'PollDaddy_Language',
614
+ 'http://api.polldaddy.com/pdapi.xsd:activity' => 'PollDaddy_Activity',
615
+ 'pack' => 'Custom_Pack',
616
+ 'phrase' => 'Custom_Pack_Phrase',
617
+ 'http://api.polldaddy.com/pdapi.xsd:rating_result' => 'PollDaddy_Rating_Result',
618
+ 'http://api.polldaddy.com/pdapi.xsd:ratings' => 'PollDaddy_Ratings',
619
+ 'http://api.polldaddy.com/pdapi.xsd:rating' => 'PollDaddy_Rating',
620
+ 'http://api.polldaddy.com/pdapi.xsd:nonce' => 'PollDaddy_Nonce'
621
+ );// the parser matches the tag names to the class name and creates an object defined by that class
622
 
623
  var $object_stack = array();
624
  var $object_pos = null;
726
  }
727
  }
728
  }
729
+ ?>
polldaddy.css CHANGED
@@ -1,9 +1,5 @@
1
- html, body {
2
- height: auto !important;
3
- }
4
- body.poll-preview-iframe {
5
- min-width: 0;
6
- }
7
  body.poll-preview-iframe #sidemenu,
8
  body.poll-preview-iframe #submenu,
9
  body.poll-preview-iframe #wpcombar,
@@ -16,337 +12,65 @@ body.poll-preview-iframe #sidemenu-bg,
16
  body.poll-preview-iframe #footer,
17
  body.poll-preview-iframe #feedbacklink,
18
  body.poll-preview-iframe #screen-meta,
19
- body.poll-preview-iframe #manage-polls h2#preview-header {
20
- display: none;
21
- }
22
-
23
- body.poll-preview-iframe-editor #manage-polls h2#preview-header {
24
- display: block;
25
- }
26
-
27
- body.poll-preview-iframe h2 {
28
- padding-top: 0;
29
- }
30
-
31
- body.poll-preview-iframe {
32
- margin: 0 !important;
33
- padding: 0 !important;
34
- }
35
-
36
- body.poll-preview-iframe .wrap {
37
- max-width: 100%;
38
- }
39
-
40
- body.poll-preview-iframe #wpwrap {
41
- min-height: 0;
42
- }
43
-
44
- body.poll-preview-iframe div#wpcontent {
45
- margin: 0;
46
- padding: 0;
47
- }
48
-
49
- body.poll-preview-iframe div#wpbody {
50
- margin: 0;
51
- padding: 2em 3em;
52
- text-align: center;
53
- }
54
-
55
- body.poll-preview-iframe div#wpbody-content {
56
- margin: 0;
57
- padding: 0;
58
- border: none;
59
- }
60
-
61
- body.poll-preview-iframe div#manage-polls.wrap {
62
- text-align: left;
63
- }
64
-
65
- body.poll-preview-iframe .pds-box {
66
- margin-left: auto;
67
- margin-right: auto;
68
- }
69
-
70
- table td.post-title strong {
71
- display: block;
72
- }
73
-
74
- table.poll-results .column-vote {
75
- min-width: 50%;
76
- padding: 3px 5px 3px 3px;
77
- margin: 0;
78
- }
79
-
80
- table.poll-results div.result-holder {
81
- position: relative;
82
- }
83
-
84
- table.poll-results span.result-bar {
85
- display: block;
86
- padding: 5px 0 4px 0;
87
- margin: 0;
88
- height: 100%;
89
- border: 1px solid #EDB918;
90
- background-color: #FBD55E;
91
- }
92
-
93
- table.poll-results span.result-total {
94
- position: absolute;
95
- left: .75em;
96
- top: 6px;
97
- }
98
-
99
- table.poll-results span.result-percent {
100
- position: absolute;
101
- right: .75em;
102
- top: 6px;
103
- }
104
-
105
- table.poll-others {
106
- margin-top: 1.5em;
107
- }
108
-
109
- table.poll-others .column-vote {
110
- min-width: 50%;
111
- }
112
-
113
- ul#answers, ul.poll-options {
114
- list-style: none;
115
- padding: 0;
116
- }
117
-
118
- ul#answers li {
119
- position: relative;
120
- }
121
-
122
- ul#answers li div {
123
- border: 1px solid #ccc;
124
- padding: 2px 3px;
125
- margin: 0 20px;
126
- }
127
-
128
- ul#answers li span.handle {
129
- position: absolute;
130
- left: 0;
131
- top: 0;
132
- width: 18px;
133
- height: 100%;
134
- background-color: #E4F2FD;
135
- color: #70A6C4;
136
- display: none;
137
- cursor: move;
138
- text-align: center;
139
- line-height: 1.8em;
140
- }
141
-
142
- ul#answers li:hover span.handle {
143
- display: block;
144
- }
145
-
146
- ul#answers li a.delete {
147
- display: block;
148
- position: absolute;
149
- top: 0;
150
- right: 0;
151
- width: 18px;
152
- height: 100%;
153
- text-align: center;
154
- line-height: 1.8em;
155
- }
156
-
157
- ul#answers li a.delete:hover {
158
- color: white;
159
- background-color: #f00;
160
- }
161
-
162
- ul#answers input {
163
- padding: 0;
164
- width: 100%;
165
- border: none;
166
- }
167
-
168
- ul#answer-options {
169
- list-style: none;
170
- padding: 0;
171
- margin-left: 20px;
172
- }
173
-
174
- ul#answer-options li {
175
- display: inline;
176
- margin-right: 1em;
177
- white-space: nowrap;
178
- }
179
-
180
- p.submit input {
181
- padding: 6px;
182
- }
183
-
184
- p#add-answer-holder {
185
- display: none;
186
- text-align: right;
187
- }
188
-
189
- #design {
190
- text-align: center;
191
- }
192
-
193
- #design h3 {
194
- text-align: left;
195
- }
196
-
197
- #design_standard a {
198
- width: 1em;
199
- display: block;
200
- font-size: 4em;
201
- text-decoration: none;
202
- }
203
-
204
- .inner-sidebar {
205
- clear: right;
206
- float: right;
207
- position: relative;
208
- width: 220px;
209
- margin-top: 10px;
210
- }
211
-
212
- #poststuff #post-body.has-sidebar, .has-sidebar {
213
- clear: left;
214
- float: left;
215
- margin-right: -240px;
216
- width: 100%;
217
- }
218
-
219
  .has-sidebar .has-sidebar-content,
220
- .has-right-sidebar #post-body-content {
221
- margin-right: 245px;
222
- }
223
-
224
- #post-body-content #titlediv {
225
- margin: 10px 0;
226
- }
227
-
228
- .postbox {
229
- min-width: 220px;
230
- }
231
-
232
- tr.polldaddy-shortcode-row {
233
- background-color: #FFFEEB;
234
- }
235
-
236
- tr.polldaddy-shortcode-row h4 {
237
- padding: 0;
238
- margin: 0.3em 0;
239
- clear: both;
240
- }
241
-
242
- tr.polldaddy-shortcode-row pre {
243
- float: left;
244
- background-color: #fff;
245
- padding: .2em;
246
- margin: 0 0 .5em;
247
- border: 1px solid #ccc;
248
- }
249
-
250
- .polldaddy-show-design-options{
251
- text-align: left;
252
- width: 8em;
253
- display: block;
254
- font-size: 1em;
255
- padding: 1em 2em;
256
- text-decoration: none;
257
- }
258
-
259
- .design_standard {
260
- display: block;
261
- padding: 0px 0px 0px 20px;
262
- }
263
-
264
- .pollStyle
265
- {
266
- width: 100%;
267
- border-collapse:collapse;
268
- }
269
-
270
- .pollStyle .cb
271
- {
272
- height: 40px;
273
- width: 30px;
274
- padding: 0px 0px 2px 0px;
275
- }
276
-
277
- .pollStyle .selector
278
- {
279
- width: 250px;
280
- }
281
-
282
- .pollStyle .customSelect
283
- {
284
- vertical-align: top;
285
- text-align:left;
286
- margin: 0px;
287
- }
288
-
289
- .pollStyle TH
290
- {
291
- text-align: left;
292
- }
293
-
294
- .st_selector {
295
- border-collapse: collapse;
296
- }
297
-
298
- .st_selector .img {
299
- width: 150px;
300
- padding: 0px;
301
- margin: 0px;
302
- height: 200px;
303
- }
304
-
305
- .st_selector .dir_left {
306
- padding: 0px 10px 0px 0px;
307
- width:75px;
308
- }
309
-
310
- .st_selector .dir_right {
311
- padding: 0px 0px 0px 20px;
312
- width:75px;
313
- }
314
-
315
- .st_selector .title {
316
- text-align: center;
317
- height: 20px;
318
- font-weight: bold;
319
- }
320
-
321
- .st_selector .counter {
322
- text-align: center;
323
- width: 150px;
324
- padding: 10px 0px 0px 0px;
325
- }
326
-
327
- #st_image{
328
- width: 150px;
329
- padding: 0px;
330
- margin: 0px;
331
- height: 200px;
332
- }
333
-
334
- #st_sizes{
335
- width: 150px;
336
- text-align: center;
337
- font-size:12px;
338
- }
339
-
340
- .st_image_loader{
341
- width: 150px;
342
- padding: 0px;
343
- margin: 0px;
344
- background: url(http://i.polldaddy.com/polls/st-loader.gif) no-repeat center center;
345
- }
346
-
347
- #st_description{
348
- padding: 6px 0px;
349
- font-size: 10px;
350
- width: 300px;
351
- text-align: center;
352
- }
1
+ html,body{height:auto !important;}
2
+ body.poll-preview-iframe{min-width:0;}
 
 
 
 
3
  body.poll-preview-iframe #sidemenu,
4
  body.poll-preview-iframe #submenu,
5
  body.poll-preview-iframe #wpcombar,
12
  body.poll-preview-iframe #footer,
13
  body.poll-preview-iframe #feedbacklink,
14
  body.poll-preview-iframe #screen-meta,
15
+ body.poll-preview-iframe #manage-polls h2#preview-header{display:none;}
16
+ body.poll-preview-iframe-editor #manage-polls h2#preview-header{display:block;}
17
+ body.poll-preview-iframe h2{padding-top:0;}
18
+ body.poll-preview-iframe{margin:0 !important;padding:0 !important;}
19
+ body.poll-preview-iframe .wrap{max-width:100%;}
20
+ body.poll-preview-iframe #wpwrap{min-height:0;}
21
+ body.poll-preview-iframe div#wpcontent{margin:0;padding:0;}
22
+ body.poll-preview-iframe div#wpbody{margin:0;padding:2em 3em;text-align:center;}
23
+ body.poll-preview-iframe div#wpbody-content{margin:0;padding:0;border:none;}
24
+ body.poll-preview-iframe div#manage-polls.wrap{text-align:left;}
25
+ body.poll-preview-iframe .pds-box{margin-left:auto;margin-right:auto;}
26
+ table td.post-title strong{display:block;}
27
+ table.poll-results .column-vote{min-width:50%;padding:3px 5px 3px 3px;margin:0;}
28
+ table.poll-results div.result-holder{position:relative;}
29
+ table.poll-results span.result-bar{display:block;padding:5px 0 4px 0;margin:0;height:100%;border:1px solid #EDB918;background-color:#FBD55E;}
30
+ table.poll-results span.result-total{position:absolute;left:.75em;top:6px;}
31
+ table.poll-results span.result-percent{position:absolute;right:.75em;top:6px;}
32
+ table.poll-others{margin-top:1.5em;}
33
+ table.poll-others .column-vote{min-width:50%;}
34
+ ul#answers,ul.poll-options{list-style:none;padding:0;}
35
+ ul#answers li{position:relative;}
36
+ ul#answers li div{border:1px solid #ccc;padding:2px 3px;margin:0 20px;}
37
+ ul#answers li span.handle{position:absolute;left:0;top:0;width:18px;height:100%;background-color:#E4F2FD;color:#70A6C4;display:none;cursor:move;text-align:center;line-height:1.8em;}
38
+ ul#answers li:hover span.handle{display:block;}
39
+ ul#answers li a.delete{display:block;position:absolute;top:0;right:0;width:18px;height:100%;text-align:center;line-height:1.8em;}
40
+ ul#answers li a.delete:hover{color:white;background-color:#f00;}
41
+ ul#answers input{padding:0;width:100%;border:none;}
42
+ ul#answer-options{list-style:none;padding:0;margin-left:20px;}
43
+ ul#answer-options li{display:inline;margin-right:1em;white-space:nowrap;}
44
+ p.submit input{padding:6px;}
45
+ p#add-answer-holder{display:none;text-align:right;}
46
+ .inner-sidebar{clear:right;float:right;position:relative;width:220px;margin-top:10px;}
47
+ #poststuff #post-body.has-sidebar,.has-sidebar{clear:left;float:left;margin-right:-240px;width:100%;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  .has-sidebar .has-sidebar-content,
49
+ .has-right-sidebar #post-body-content{margin-right:245px;}
50
+ #post-body-content #titlediv{margin:10px 0;}
51
+ .postbox{min-width:220px;}
52
+ tr.polldaddy-shortcode-row{background-color:#FFFEEB;}
53
+ tr.polldaddy-shortcode-row h4{padding:0;margin:0.3em 0;clear:both;}
54
+ tr.polldaddy-shortcode-row pre{float:left;background-color:#fff;padding:.2em;margin:0 0 .5em;border:1px solid #ccc;}
55
+ .polldaddy-show-design-options{text-align:left;width:8em;display:block;font-size:1em;padding:1em 2em;text-decoration:none;}
56
+ #design{text-align:center;}
57
+ #design h3{text-align:left;}
58
+ #design_standard{display:block;padding:0px 0px 0px 20px;}
59
+ #design_standard a{width:1em;font-size:4em;text-decoration:none;}
60
+ #design_custom {display:none;}
61
+ .pollStyle{width:100%;border-collapse:collapse;}
62
+ .pollStyle .cb{height:40px;width:30px;padding:0px 0px 2px 0px;}
63
+ .pollStyle .selector{width:250px;}
64
+ .pollStyle .customSelect{vertical-align:top;text-align:left;margin:0px;}
65
+ .pollStyle TH{text-align:left;}
66
+ .st_selector{border-collapse:collapse;}
67
+ .st_selector .img{width:150px;padding:0px;margin:0px;height:200px;}
68
+ .st_selector .dir_left{padding:0px 10px 0px 0px;width:75px;}
69
+ .st_selector .dir_right{padding:0px 0px 0px 20px;width:75px;}
70
+ .st_selector .title{text-align:center;height:20px;font-weight:bold;}
71
+ .st_selector .counter{text-align:center;width:150px;padding:10px 0px 0px 0px;}
72
+ #st_image{width:150px;padding:0px;margin:0px;height:200px;}
73
+ #st_sizes{width:150px;text-align:center;font-size:12px;}
74
+ #st_sizes a{width:150px;text-align:center;font-size:12px;}
75
+ .st_image_loader{width:150px;padding:0px;margin:0px;background:url(http://i.polldaddy.com/polls/st-loader.gif) no-repeat center center;}
76
+ #st_description{padding:6px 0px;font-size:10px;width:300px;text-align:center;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
polldaddy.js CHANGED
@@ -1,7 +1,7 @@
1
  jQuery(function($){
2
  $('.hide-if-js').hide();
3
  $('.hide-if-no-js').removeClass( 'hide-if-no-js' );
4
-
5
  $('a.delete-poll').click( function() {
6
  return confirm( 'Are you sure you want to delete "' + $(this).parents( 'td' ).find( 'strong' ).text() + '"?' );
7
  } );
@@ -48,35 +48,9 @@ jQuery(function($){
48
  $(this).parents('tr:first').next('tr').fadeOut();
49
  return false;
50
  } );
51
-
52
- var img1 = $('#design_standard img:first');
53
- if ( !img1.size() ) {
54
- return;
55
- }
56
- var img2 = $('#design_standard img:last');
57
- var imgPath = 'http://polldaddy.com/images/';
58
-
59
- var styleCount = $(':input[name=styleID] option').size();
60
- var styles = $(':input[name=styleID]').remove();
61
- var o = parseInt( styles.val() );
62
- $('#design_standard').append( '<input type="hidden" id="hidden-styleID" name="styleID" value="' + o.toString() + '" /><p><strong id="styleID-name">' + $(styles.find('option').get(o)).text() + '</strong><br /><span id="span-styleID">' + ( o + 1 ).toString() + '</span> of ' + styleCount + '</p>');
63
- var hiddenStyleID = $('#hidden-styleID');
64
- var spanStyleID = $('#span-styleID');
65
- var styleIDName = $('#styleID-name');
66
-
67
- var changePreview = function( i ) {
68
- var o = parseInt( img1.attr( 'src' ).substr( imgPath.length ) );
69
- img1.attr( 'src', imgPath + ( ( i + o + styleCount ) % styleCount ).toString() + '.gif' );
70
- img2.attr( 'src', imgPath + ( ( 2 * i + o + styleCount ) % styleCount ).toString() + '.gif' );
71
- hiddenStyleID.val( ( ( i + o + styleCount ) % styleCount ).toString() );
72
- spanStyleID.text( ( ( i + o + styleCount ) % styleCount + 1 ).toString() );
73
- styleIDName.text( $(styles.find('option').get( ( i + o + styleCount ) % styleCount )).text() );
74
- };
75
-
76
- $('#design_standard a.alignleft').click( function() { changePreview( -1 ); return false; } );
77
- $('#design_standard a.alignright').click( function() { changePreview( 1 ); return false; } );
78
 
79
- var customStyle = $(':input[name=styleID_custom]');
 
80
  var customStyleVal = parseInt( customStyle.val() );
81
 
82
  customStyle.change(function() {
@@ -94,16 +68,20 @@ jQuery(function($){
94
  $('#design_custom').hide();
95
  $('#design_standard').fadeIn();
96
  $('.polldaddy-show-design-options').html('Custom Styles');
97
- var styleVal = parseInt( img1.attr( 'src' ).substr( imgPath.length ) );
98
- hiddenStyleID.val( styleVal.toString() );
99
  return false;
100
  }, function() {
101
  $('#design_standard').hide();
102
  $('#design_custom').fadeIn();
103
  $('.polldaddy-show-design-options').html('Standard Styles');
104
- var customStyle = $(':input[name=styleID_custom]');
105
  var customStyleVal = parseInt( customStyle.val() );
106
- hiddenStyleID.val( customStyleVal.toString() );
 
 
 
 
 
107
  return false;
108
  } );
109
  }
@@ -115,16 +93,20 @@ jQuery(function($){
115
  $('#design_standard').hide();
116
  $('#design_custom').fadeIn();
117
  $('.polldaddy-show-design-options').html('Standard Styles');
118
- var customStyle = $(':input[name=styleID_custom]');
119
  var customStyleVal = parseInt( customStyle.val() );
120
- hiddenStyleID.val( customStyleVal.toString() );
 
 
 
 
 
121
  return false;
122
  }, function() {
123
  $('#design_custom').hide();
124
  $('#design_standard').fadeIn();
125
  $('.polldaddy-show-design-options').html('Custom Styles');
126
- var styleVal = parseInt( img1.attr( 'src' ).substr( imgPath.length ) );
127
- hiddenStyleID.val( styleVal.toString() );
128
  return false;
129
  } );
130
  }
1
  jQuery(function($){
2
  $('.hide-if-js').hide();
3
  $('.hide-if-no-js').removeClass( 'hide-if-no-js' );
4
+
5
  $('a.delete-poll').click( function() {
6
  return confirm( 'Are you sure you want to delete "' + $(this).parents( 'td' ).find( 'strong' ).text() + '"?' );
7
  } );
48
  $(this).parents('tr:first').next('tr').fadeOut();
49
  return false;
50
  } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
+ var hiddenStyleID = $(':input[name=styleID]');
53
+ var customStyle = $(':input[name=customSelect]');
54
  var customStyleVal = parseInt( customStyle.val() );
55
 
56
  customStyle.change(function() {
68
  $('#design_custom').hide();
69
  $('#design_standard').fadeIn();
70
  $('.polldaddy-show-design-options').html('Custom Styles');
71
+ hiddenStyleID.val( 'x' );
 
72
  return false;
73
  }, function() {
74
  $('#design_standard').hide();
75
  $('#design_custom').fadeIn();
76
  $('.polldaddy-show-design-options').html('Standard Styles');
77
+ var customStyle = $(':input[name=customSelect]');
78
  var customStyleVal = parseInt( customStyle.val() );
79
+ if ( customStyleVal > 0 ){
80
+ hiddenStyleID.val( customStyleVal.toString() );
81
+ }
82
+ else{
83
+ hiddenStyleID.val( 'x' );
84
+ }
85
  return false;
86
  } );
87
  }
93
  $('#design_standard').hide();
94
  $('#design_custom').fadeIn();
95
  $('.polldaddy-show-design-options').html('Standard Styles');
96
+ var customStyle = $(':input[name=customSelect]');
97
  var customStyleVal = parseInt( customStyle.val() );
98
+ if ( customStyleVal > 0 ){
99
+ hiddenStyleID.val( customStyleVal.toString() );
100
+ }
101
+ else{
102
+ hiddenStyleID.val( 'x' );
103
+ }
104
  return false;
105
  }, function() {
106
  $('#design_custom').hide();
107
  $('#design_standard').fadeIn();
108
  $('.polldaddy-show-design-options').html('Custom Styles');
109
+ hiddenStyleID.val( 'x' );
 
110
  return false;
111
  } );
112
  }
polldaddy.php CHANGED
@@ -5,7 +5,7 @@ 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.6
9
  */
10
 
11
  // You can hardcode your PollDaddy PartnerGUID (API Key) here
@@ -20,11 +20,11 @@ if ( !defined( 'WP_POLLDADDY__POLLDADDY_CLIENT_PATH' ) )
20
  // TODO: when user changes PollDaddy password, userCode changes
21
  class WP_PollDaddy {
22
  var $errors;
23
- var $polldaddy_client_class = 'PollDaddy_Client';
24
  var $base_url = false;
25
  var $use_ssl = 0;
26
  var $scheme = 'https';
27
- var $version = '1.6';
28
 
29
  var $polldaddy_clients = array();
30
 
@@ -73,8 +73,9 @@ class WP_PollDaddy {
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' ); //, array( &$this, 'management_page' ) );
77
  add_submenu_page( 'polls', __( 'Add New Poll' ), __( 'Add New' ), 'edit_posts', 'polls&amp;action=create-poll', array( &$this, 'management_page' ) );
 
78
 
79
  add_action( 'media_buttons', array( &$this, 'media_buttons' ) );
80
  }
@@ -180,7 +181,7 @@ class WP_PollDaddy {
180
 
181
  $polldaddy = $this->get_client( $polldaddy_api_key );
182
  $polldaddy->reset();
183
- if ( !$polldaddy->GetUserCode( $GLOBALS['current_user']->ID ) ) {
184
  $this->parse_errors( $polldaddy );
185
  $this->errors->add( 'GetUserCode', __( 'Account could not be accessed. Are your email address and password correct?' ) );
186
  return false;
@@ -218,6 +219,8 @@ class WP_PollDaddy {
218
  <?php
219
  endforeach;
220
  endforeach;
 
 
221
  ?>
222
 
223
  </div>
@@ -292,22 +295,37 @@ class WP_PollDaddy {
292
  function management_page_load() {
293
  global $current_user;
294
 
295
- $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID );
296
  $polldaddy->reset();
297
-
298
  if ( !defined( 'WP_POLLDADDY__USERCODE' ) )
299
- define( 'WP_POLLDADDY__USERCODE', $polldaddy->GetUserCode( $current_user->ID ) );
300
 
301
- wp_reset_vars( array( 'action', 'poll' ) );
302
- global $action, $poll;
303
 
304
  if ( !WP_POLLDADDY__USERCODE )
305
  $action = 'signup';
306
 
307
  require_once WP_POLLDADDY__POLLDADDY_CLIENT_PATH;
308
 
309
- wp_enqueue_script( 'polls-style', "{$this->base_url}poll-style-picker.js", array(), $this->version );
310
  wp_enqueue_script( 'polls', "{$this->base_url}polldaddy.js", array( 'jquery', 'jquery-ui-sortable' ), $this->version );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  wp_enqueue_script( 'admin-forms' );
312
  add_thickbox();
313
 
@@ -317,6 +335,7 @@ class WP_PollDaddy {
317
  add_action( 'admin_notices', array( &$this, 'management_page_notices' ) );
318
 
319
  $query_args = array();
 
320
 
321
  $allowedtags = array(
322
  'a' => array(
@@ -386,7 +405,7 @@ class WP_PollDaddy {
386
 
387
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
388
  $polldaddy->reset();
389
- $poll_object = $polldaddy->GetPoll( $poll );
390
 
391
  if ( !$this->can_edit( $poll_object ) ) {
392
  $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) );
@@ -396,14 +415,14 @@ class WP_PollDaddy {
396
  // Send Poll Author credentials
397
  if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
398
  $polldaddy->reset();
399
- if ( !$userCode = $polldaddy->GetUserCode( $poll_object->_owner ) ) {
400
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
401
  }
402
  $polldaddy->userCode = $userCode;
403
  }
404
 
405
  $polldaddy->reset();
406
- $polldaddy->DeletePoll( $poll_id );
407
  }
408
 
409
  $query_args['message'] = 'deleted';
@@ -422,7 +441,7 @@ class WP_PollDaddy {
422
 
423
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
424
  $polldaddy->reset();
425
- $poll_object = $polldaddy->GetPoll( $poll );
426
 
427
  if ( !$this->can_edit( $poll_object ) ) {
428
  $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) );
@@ -432,14 +451,14 @@ class WP_PollDaddy {
432
  // Send Poll Author credentials
433
  if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
434
  $polldaddy->reset();
435
- if ( !$userCode = $polldaddy->GetUserCode( $poll_object->_owner ) ) {
436
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
437
  }
438
  $polldaddy->userCode = $userCode;
439
  }
440
 
441
  $polldaddy->reset();
442
- $polldaddy->OpenPoll( $poll_id );
443
  }
444
 
445
  $query_args['message'] = 'opened';
@@ -458,7 +477,7 @@ class WP_PollDaddy {
458
 
459
  foreach ( (array) $_REQUEST['poll'] as $poll_id ) {
460
  $polldaddy->reset();
461
- $poll_object = $polldaddy->GetPoll( $poll );
462
 
463
  if ( !$this->can_edit( $poll_object ) ) {
464
  $this->errors->add( 'permission', __( 'You are not allowed to delete this poll.' ) );
@@ -468,14 +487,14 @@ class WP_PollDaddy {
468
  // Send Poll Author credentials
469
  if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
470
  $polldaddy->reset();
471
- if ( !$userCode = $polldaddy->GetUserCode( $poll_object->_owner ) ) {
472
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
473
  }
474
  $polldaddy->userCode = $userCode;
475
  }
476
 
477
  $polldaddy->reset();
478
- $polldaddy->ClosePoll( $poll_id );
479
  }
480
 
481
  $query_args['message'] = 'closed';
@@ -490,7 +509,7 @@ class WP_PollDaddy {
490
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
491
  $polldaddy->reset();
492
 
493
- $poll_object = $polldaddy->GetPoll( $poll );
494
  $this->parse_errors( $polldaddy );
495
 
496
  if ( !$this->can_edit( $poll_object ) ) {
@@ -502,7 +521,7 @@ class WP_PollDaddy {
502
 
503
  if ( !empty( $poll_object->_owner ) && $current_user->ID != $poll_object->_owner ) {
504
  $polldaddy->reset();
505
- if ( !$userCode = $polldaddy->GetUserCode( $poll_object->_owner ) ) {
506
  $this->errors->add( 'no_usercode', __( 'Invalid Poll Author' ) );
507
  }
508
  $this->parse_errors( $polldaddy );
@@ -543,13 +562,13 @@ class WP_PollDaddy {
543
  foreach ( $_POST['answer'] as $answer_id => $answer ) {
544
  if ( !$answer = trim( stripslashes( $answer ) ) )
545
  continue;
546
-
547
- $answer = wp_kses( $answer, $allowedtags );
548
 
549
  if ( is_numeric( $answer_id ) )
550
- $answers[] = polldaddy_poll_answer( $answer, $answer_id );
551
  else
552
- $answers[] = polldaddy_poll_answer( $answer );
553
  }
554
 
555
  if ( 2 > count( $answers ) )
@@ -572,7 +591,7 @@ class WP_PollDaddy {
572
 
573
  $polldaddy->reset();
574
 
575
- $update_response = $polldaddy->UpdatePoll( $poll, $poll_data );
576
 
577
  $this->parse_errors( $polldaddy );
578
 
@@ -600,9 +619,9 @@ class WP_PollDaddy {
600
  if ( !$answer = trim( stripslashes( $answer ) ) )
601
  continue;
602
 
603
- $answer = wp_kses( $answer, $allowedtags );
604
 
605
- $answers[] = polldaddy_poll_answer( $answer );
606
  }
607
 
608
  if ( !$answers )
@@ -625,7 +644,7 @@ class WP_PollDaddy {
625
  }
626
  $poll_data['styleID'] = $_POST['styleID'];
627
 
628
- $poll = $polldaddy->CreatePoll( $poll_data );
629
  $this->parse_errors( $polldaddy );
630
 
631
  if ( !$poll || empty( $poll->_id ) )
@@ -640,6 +659,88 @@ class WP_PollDaddy {
640
  if ( isset($_POST['iframe']) )
641
  $query_args['iframe'] = '';
642
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
643
  default :
644
  return;
645
  endswitch;
@@ -665,7 +766,7 @@ class WP_PollDaddy {
665
  if ( $this->errors->get_error_codes() )
666
  return false;
667
 
668
- if ( !$polldaddy->Initiate( $email, $password, $GLOBALS['user_ID'] ) ) {
669
  $this->parse_errors( $polldaddy );
670
  $this->errors->add( 'import-account', __( 'Account could not be imported. Are your email address and password correct?' ) );
671
  return false;
@@ -716,6 +817,19 @@ class WP_PollDaddy {
716
  if ( isset( $_GET['iframe'] ) )
717
  $message .= ' <input type="button" class="button polldaddy-send-to-editor" value="' . attribute_escape( __( 'Send to Editor' ) ) . '" />';
718
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
719
  endswitch;
720
 
721
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
@@ -746,9 +860,10 @@ class WP_PollDaddy {
746
  }
747
 
748
  function management_page() {
749
- global $action, $poll;
750
  $poll = (int) $poll;
751
-
 
752
  ?>
753
 
754
  <div class="wrap" id="manage-polls">
@@ -796,6 +911,32 @@ class WP_PollDaddy {
796
  <?php
797
  $this->poll_edit_form();
798
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
799
  default :
800
 
801
  ?>
@@ -824,9 +965,9 @@ class WP_PollDaddy {
824
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
825
  $polldaddy->reset();
826
  if ( 'user' == $view )
827
- $polls_object = $polldaddy->listPolls( ( $page - 1 ) * 10 + 1, $page * 10 );
828
  else
829
- $polls_object = $polldaddy->listPollsByBlog( ( $page - 1 ) * 10 + 1, $page * 10 );
830
  $this->parse_errors( $polldaddy );
831
  $this->print_errors();
832
  $polls = & $polls_object->poll;
@@ -938,7 +1079,7 @@ class WP_PollDaddy {
938
  <pre>&lt;script type="text/javascript" language="javascript"
939
  src="http://static.polldaddy.com/p/<?php echo (int) $poll_id; ?>.js"&gt;&lt;/script&gt;
940
  &lt;noscript&gt;
941
- &lt;a href="http://answers.polldaddy.com/poll/1000076/"&gt;<?php echo wp_specialchars( $poll->___content ); ?>&lt;/a&gt;&lt;br/&gt;
942
  &lt;span style="font:9px;"&gt;(&lt;a href="http://www.polldaddy.com"&gt;polls&lt;/a&gt;)&lt;/span&gt;
943
  &lt;/noscript&gt;</pre>
944
  </td>
@@ -982,7 +1123,7 @@ class WP_PollDaddy {
982
  $is_POST = 'post' == strtolower( $_SERVER['REQUEST_METHOD'] );
983
 
984
  if ( $poll_id ) {
985
- $poll = $polldaddy->GetPoll( $poll_id );
986
  $this->parse_errors( $polldaddy );
987
 
988
  if ( !$this->can_edit( $poll ) ) {
@@ -1093,7 +1234,7 @@ class WP_PollDaddy {
1093
  $answers[attribute_escape($answer_id)] = attribute_escape( stripslashes($answer) );
1094
  } elseif ( isset( $poll->answers->answer ) ) {
1095
  foreach ( $poll->answers->answer as $answer )
1096
- $answers[(int) $answer->_id] = attribute_escape( $answer->___content );
1097
  }
1098
 
1099
  foreach ( $answers as $answer_id => $answer ) :
@@ -1154,8 +1295,12 @@ class WP_PollDaddy {
1154
 
1155
  <?php $style_ID = (int) ( $is_POST ? $_POST['styleID'] : $poll->styleID );
1156
 
 
 
 
 
1157
  $polldaddy->reset();
1158
- $styles = $polldaddy->GetStyles();
1159
 
1160
  $show_custom = false;
1161
  if( isset( $styles ) && count( $styles ) > 0 ){
@@ -1175,105 +1320,236 @@ class WP_PollDaddy {
1175
  <h3><?php _e( 'Design' ); ?></h3>
1176
  <input type="hidden" name="styleID" id="styleID" value="<?php echo $style_ID ?>">
1177
  <div class="inside">
1178
- <div class="design_standard">
1179
- <table class="pollStyle">
1180
- <thead>
1181
- <tr>
1182
- <th class="cb">
1183
- <input type="radio" name="styleTypeCB" id="regular" onclick="javascript:pd_build_styles( 0 );"/>
1184
- </th>
1185
- <th>
1186
- <label for="skin" onclick="javascript:pd_build_styles( 0 );">PollDaddy Style</label>
1187
- </th>
1188
- <th/>
1189
- <th class="cb">
1190
- <?php $disabled = $show_custom == false ? ' disabled="true"' : ''; ?>
1191
- <input type="radio" name="styleTypeCB" id="custom" onclick="javascript:pd_change_style($('customSelect').value);" <?php echo $disabled; ?>></input>
1192
- </th>
1193
- <th>
1194
- <label onclick="javascript:pd_change_style($('customSelect').value);">Custom Style</label>
1195
- </th>
1196
- </tr>
1197
- </thead>
1198
- <tr>
1199
- <td/>
1200
- <td class="selector">
1201
- <table class="st_selector">
1202
  <tr>
1203
- <td class="dir_left">
1204
- <a href="javascript:pd_move('prev');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">&#171;</a>
1205
- </td>
1206
- <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>
1207
- <td class="dir_right">
1208
- <a href="javascript:pd_move('next');" style="width: 1em;display: block;font-size: 4em;text-decoration: none;">&#187;</a>
1209
- </td>
1210
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1211
  <tr>
1212
- <td></td>
1213
- <td class="counter">
1214
- <div id="st_number"></div>
1215
- </td>
1216
- <td></td>
 
 
1217
  </tr>
 
 
1218
  <tr>
1219
- <td></td>
1220
- <td class="title">
1221
- <div id="st_name"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1222
  </td>
1223
- <td></td>
1224
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
1225
  <tr>
1226
- <td></td>
1227
- <td>
1228
- <div id="st_sizes"></div>
1229
- </td>
1230
- <td></td>
 
 
 
 
 
 
 
 
 
1231
  </tr>
 
 
1232
  <tr>
1233
- <td colspan="3">
1234
- <div id="st_description"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1235
  </td>
1236
- </tr>
1237
- </table>
1238
- </td>
1239
- <td width="100"></td>
1240
- <td/>
1241
- <td class="customSelect">
1242
- <table>
1243
- <tr>
1244
- <td><?php $hide = $show_custom == true ? ' style="display:block;"' : ' style="display:none;"'; ?>
1245
- <select id="customSelect" name="customSelect" onclick="pd_change_style(this.value);" <?php echo $hide ?>>
1246
- <?php $selected = $custom_style_ID == 0 ? ' selected="selected"' : ''; ?>
1247
- <option value="x"<?php echo $selected; ?>>Please choose a custom style...</option>
1248
- <?php foreach ( $styles->style as $style ) :
1249
- $selected = $style->_id == $custom_style_ID ? ' selected="selected"' : ''; ?>
1250
- <option value="<?php echo (int) $style->_id; ?>"<?php echo $selected; ?>><?php echo wp_specialchars( $style->title ); ?></option>
1251
- <?php endforeach;?>
1252
- </select>
1253
- <div id="styleIDErr" class="formErr" style="display:none;">Please choose a style.</div></td>
1254
- </tr>
1255
- <tr>
1256
- <td><?php $extra = $show_custom == false ? 'You currently have no custom styles created.' : ''; ?>
1257
- <p><?php echo $extra ?></p>
1258
- <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>
1259
  </td>
1260
  </tr>
1261
- </table>
1262
- </td>
1263
- </tr>
1264
- </table>
1265
-
1266
- <script language="javascript">
1267
- current_pos = 0;
1268
- pd_build_styles( current_pos );
1269
- <?php if( $style_ID > 0 && $style_ID <= 1000 ){ ?>
1270
- pd_pick_style( <?php echo $style_ID ?> );
1271
- <?php }else{ ?>
1272
- pd_change_style( <?php echo $style_ID ?> );
1273
- <?php } ?>
1274
- </script>
1275
- </div>
 
 
 
 
 
 
 
 
 
1276
  </div>
 
1277
  </div>
1278
 
1279
  </div>
@@ -1288,7 +1564,7 @@ pd_change_style( <?php echo $style_ID ?> );
1288
  $polldaddy = $this->get_client( WP_POLLDADDY__PARTNERGUID, WP_POLLDADDY__USERCODE );
1289
  $polldaddy->reset();
1290
 
1291
- $results = $polldaddy->GetPollResults( $poll_id );
1292
  ?>
1293
 
1294
  <table class="poll-results widefat">
@@ -1366,6 +1642,1013 @@ pd_change_style( <?php echo $style_ID ?> );
1366
 
1367
  <?php
1368
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1369
 
1370
  function signup() {
1371
  return $this->api_key_page();
5
  Description: Create and manage PollDaddy polls in WordPress
6
  Author: Automattic, Inc.
7
  Author URL: http://automattic.com/
8
+ Version: 1.7
9
  */
10
 
11
  // You can hardcode your PollDaddy PartnerGUID (API Key) here
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';
28
 
29
  var $polldaddy_clients = array();
30
 
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
  }
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;
219
  <?php
220
  endforeach;
221
  endforeach;
222
+
223
+ $this->errors = new WP_Error;
224
  ?>
225
 
226
  </div>
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
 
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(
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.' ) );
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';
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.' ) );
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';
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.' ) );
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';
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 ) ) {
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 );
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 ) )
591
 
592
  $polldaddy->reset();
593
 
594
+ $update_response = $polldaddy->update_poll( $poll, $poll_data );
595
 
596
  $this->parse_errors( $polldaddy );
597
 
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 )
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 ) )
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;
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;
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'] );
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">
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
  ?>
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;
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>
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 ) ) {
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 ) :
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 ){
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>
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">
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();
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: mdawaffe, eoigal
3
  Tags: polls, poll, polldaddy, wppolls, vote, polling, surveys
4
  Requires at least: 2.6
5
  Tested up to: 2.7.1
6
- Stable tag: 1.6
7
 
8
  Create and manage PollDaddy polls from within WordPress.
9
 
@@ -32,12 +32,20 @@ Yes. You'll be able to edit the polls they create from your blog. (You won't be
32
  Nope. The permissions are the same as for posts. So Editors and Administrators can edit anyone's polls for that blog. Authors can only edit their own.
33
 
34
  == Change Log ==
 
 
 
 
 
 
 
 
35
  = 1.6 =
36
  * Added Poll Question and Answer fields now accept limited HTML tags
37
  * Added 'Share This' link option to allow voters to share the poll around the interweb
38
 
39
  = 1.5 =
40
- Bug Fix: Other answers in the poll results are now displaying.
41
 
42
  = 1.4 =
43
  * Added new poll styles selector
@@ -48,14 +56,14 @@ Bug Fix: Other answers in the poll results are now displaying.
48
  * Added option to make normal request every login
49
 
50
  = 1.2 =
51
- Bug Fix: SSL request for PollDaddy API key sometimes failed due to host constraints, included option to make a normal http request in this case.
52
- Bug Fix: Redirect after login now goes to list polls
53
 
54
  = 1.1 =
55
- Bug Fix: Don't call PollDaddy API on every admin page load
56
- Bug Fix: Correct Image locations
57
- Bug Fix: CSS Tweaks for upcoming WordPress 2.8
58
- Make Javascript image selector more robust
59
 
60
  = 1.0 =
61
  * New PollDaddy API
3
  Tags: polls, poll, polldaddy, wppolls, vote, polling, surveys
4
  Requires at least: 2.6
5
  Tested up to: 2.7.1
6
+ Stable tag: 1.7
7
 
8
  Create and manage PollDaddy polls from within WordPress.
9
 
32
  Nope. The permissions are the same as for posts. So Editors and Administrators can edit anyone's polls for that blog. Authors can only edit their own.
33
 
34
  == Change Log ==
35
+ = 1.7 =
36
+ * Added Poll Style Editor
37
+ * Updated the PollDaddy API Client code
38
+ * Removed style picker javascript, now reference static file on Polldaddy
39
+ * Bug Fix: PollDaddy Answers link to poll in poll embed code now correct
40
+ * Bug Fix: iframe view of poll editor now display design area
41
+ * Bug Fix: Only print API error once
42
+
43
  = 1.6 =
44
  * Added Poll Question and Answer fields now accept limited HTML tags
45
  * Added 'Share This' link option to allow voters to share the poll around the interweb
46
 
47
  = 1.5 =
48
+ * Bug Fix: Other answers in the poll results are now displaying.
49
 
50
  = 1.4 =
51
  * Added new poll styles selector
56
  * Added option to make normal request every login
57
 
58
  = 1.2 =
59
+ * Bug Fix: SSL request for PollDaddy API key sometimes failed due to host constraints, included option to make a normal http request in this case.
60
+ * Bug Fix: Redirect after login now goes to list polls
61
 
62
  = 1.1 =
63
+ * Bug Fix: Don't call PollDaddy API on every admin page load
64
+ * Bug Fix: Correct Image locations
65
+ * Bug Fix: CSS Tweaks for upcoming WordPress 2.8
66
+ * Make Javascript image selector more robust
67
 
68
  = 1.0 =
69
  * New PollDaddy API
style-editor.css ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .CSSE_main{width:374px;border-collapse:collapse;padding:0px;margin:0px 6px;}
2
+ .CSSE_main_l{width:79px;border:0px;padding:11px 0px 0px 0px;text-align:right;}
3
+ .CSSE_main_l a{line-height:2;text-decoration:none;font-size:11px;text-align:right;padding-right:5px;}
4
+ .CSSE_main_r{width:295px;height:280px;padding:0px;margin:0px;border-color:#DFDFDF;border-style:solid;border-width:1px;padding:0.5em 0.9em;}
5
+ .CSSE_main_l .off{height:23px;width:79px;margin:0px 0px 3px 0px;}
6
+ .CSSE_main_l .on{-moz-border-radius-bottomleft:3px;-moz-border-radius-bottomright:0;-moz-border-radius-topleft:3px;-moz-border-radius-topright:0;border-style:solid none solid solid;border-color:#DFDFDF;border-width:1px 0 1px 1px;margin-right:-1px;background-color:#F1F1F1;font-color:#333333;font-weight:bold;text-decoration:none;text-shadow:0 1px 0 #FFFFFF;border-style:solid none solid solid;}
7
+ .CSSE_main_l .Aoff,.CSSE_main_l .Aon{list-style-image:none;list-style-position:outside;list-style-type:none;margin:8px 5px 5px 0px;padding:0;white-space:nowrap;}
8
+ .CSSE_main_l .Aon{color:#333333;-moz-background-clip:border;-moz-background-inline-policy:continuous;-moz-background-origin:padding;background:transparent none repeat scroll 0 0;border:medium none;}
9
+ .CSSE_sub{width:295px;border-collapse:collapse;border:0;}
10
+ .CSSE_sub .top{height:11px;}
11
+ .CSSE_sub .btm{height:11px;}
12
+ .CSSE_edit{border-collapse:collapse;width:100%;margin:0px 0px 0px 25px;min-height:160px;}
13
+ .CSSE_edit TD{font-size:11px;color:#666;height:36px;}
14
+ .pds-clear{clear:both;display:block;}
15
+ .pds-answer-group{display:block;padding:5px 0px;}
16
+ .pds-answer-input{display:block;float:left;width:25px;}
17
+ .pds-answer{position:relative;cursor:pointer;display:block;float:left;}
18
+ .pds-answer-other{display:block;}
19
+ .pds-answer-group{display:block;}
20
+ .pds-link{display:block;float:left;}