MailPoet Newsletters (Previous) - Version 2.6.5

Version Description

  • 2014-04-18 =
  • Fixed TinyMCE issue with WordPress 3.9, our editor in Step 2 is working again
  • Fixed conflicting shortcode between MailPoet's custom fields and Ultimate TinyMCE shortcode
Download this release

Release Info

Developer wysija
Plugin Icon 128x128 MailPoet Newsletters (Previous)
Version 2.6.5
Comparing to
See all releases

Code changes from version 2.6.8 to 2.6.5

add-ons/add-ons-list.php CHANGED
@@ -8,46 +8,30 @@ function add_ons_list(){
8
  'name' => 'WooCommerce: Subscribe on Checkout',
9
  'search' => 'MailPoet WooCommerce Add-on',
10
  'thumbnail' => 'woocommerce.png',
11
- 'description' => __( 'Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA ),
12
  'plugin_url' => 'mailpoet-woocommerce-addon/mailpoet-woocommerce-addon.php',
13
  'version' => '1.0.2',
14
  'config_url' => 'admin.php?page=woocommerce_settings&tab=mailpoet',
15
- 'official' => true,
16
- 'on_wordpress.org' => true,
17
- 'free' => true,
18
- 'service' => false,
19
  'requires' => 'woocommerce/woocommerce.php',
20
  'requires_name' => 'WooCommerce',
21
  ),
22
 
23
- array(
24
- 'name' => 'Autoresponders for WooCommerce Products',
25
- 'search' => 'Autoresponders for WooCommerce Products',
26
- 'thumbnail' => 'woocommerce.png',
27
- 'description' => __( 'Decide which emails a new customer gets automatically, based on the product he just purchased. This a Premium add-on for WooCommerce.', WYSIJA ),
28
- 'review' => '',
29
- 'plugin_url' => '',
30
- 'author_url' => 'http://clicky.me/woocommerce-autoresponder',
31
- 'purchase_url' => 'http://clicky.me/woocommerce-autoresponder',
32
- 'version' => '1.0.1',
33
- 'official' => true,
34
- 'on_wordpress.org' => false,
35
- 'free' => false,
36
- 'service' => false,
37
- ),
38
-
39
  array(
40
  'name' => 'Jigoshop: Subscribe on Checkout',
41
  'search' => 'MailPoet Jigoshop Add-on',
42
  'thumbnail' => 'jigoshop.png',
43
- 'description' => __( 'Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA ),
44
  'plugin_url' => 'mailpoet-jigoshop-addon/mailpoet-jigoshop-addon.php',
45
  'version' => '1.0.3',
46
  'config_url' => 'admin.php?page=jigoshop_settings&tab=mailpoet',
47
- 'official' => true,
48
- 'on_wordpress.org' => true,
49
- 'free' => true,
50
- 'service' => false,
51
  'requires' => 'jigoshop/jigoshop.php',
52
  'requires_name' => 'Jigoshop',
53
  ),
@@ -56,13 +40,13 @@ function add_ons_list(){
56
  'name' => 'Gravity Forms: Subscribe Add-on',
57
  'search' => 'MailPoet Gravity Forms Add-on',
58
  'thumbnail' => 'gravity-forms.png',
59
- 'description' => __( 'Add a new field to add to your forms so your visitors can subscriber to your MailPoet newsletters.', WYSIJA ),
60
  'plugin_url' => 'mailpoet-gravity-forms-addon/mailpoet-gravity-forms-addon.php',
61
  'version' => '1.0.0',
62
- 'official' => true,
63
- 'on_wordpress.org' => true,
64
- 'free' => true,
65
- 'service' => false,
66
  'requires' => 'gravityforms/gravityforms.php',
67
  'requires_name' => 'Gravity Forms',
68
  ),
@@ -71,14 +55,14 @@ function add_ons_list(){
71
  'name' => 'WP e-Commerce: Subscribe on Checkout',
72
  'search' => 'MailPoet WP e-Commerce Add-on',
73
  'thumbnail' => 'wp-e-commerce.png',
74
- 'description' => __( 'Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA ),
75
  'plugin_url' => 'mailpoet-wp-ecommerce-addon/mailpoet-wp-ecommerce-addon.php',
76
  'version' => '1.0.0',
77
  'config_url' => 'edit.php?post_type=wpsc-product&page=mailpoet',
78
- 'official' => true,
79
- 'on_wordpress.org' => true,
80
- 'free' => true,
81
- 'service' => false,
82
  'requires' => 'wp-e-commerce/wp-shopping-cart.php',
83
  'requires_name' => 'WP e-Commerce',
84
  ),
@@ -87,13 +71,13 @@ function add_ons_list(){
87
  'name' => 'Restrict Content Pro: Registration Add-on',
88
  'search' => 'Restrict Content Pro Wysija',
89
  'thumbnail' => 'pippins.png',
90
- 'description' => __( 'Add a checkbox on the registration form of this plugin so your new users join a list of your choice.', WYSIJA ),
91
  'plugin_url' => 'restrict-content-pro-wysija/rcp-wysija.php',
92
  'version' => '1.0',
93
- 'official' => true,
94
- 'on_wordpress.org' => true,
95
- 'free' => true,
96
- 'service' => false,
97
  'requires' => 'restrict-content-pro/restrict-content-pro.php',
98
  'requires_name' => 'Restrict Content Pro',
99
  ),
@@ -102,14 +86,14 @@ function add_ons_list(){
102
  'name' => 'Contact Form 7: MailPoet Add-on',
103
  'search' => 'MailPoet Contact Form 7',
104
  'thumbnail' => 'cf7.png',
105
- 'description' => __( 'Add a checkbox in your forms, and choose which lists the user gets added to.', WYSIJA ),
106
  'plugin_url' => 'mailpoet-contact-form-7/mailpoet-contact-form-7.php',
107
  'author_url' => '',
108
  'version' => '1.0.0',
109
- 'official' => true,
110
- 'on_wordpress.org' => true,
111
- 'free' => true,
112
- 'service' => false,
113
  'requires' => 'contact-form-7/wp-contact-form-7.php',
114
  'requires_name' => 'Contact Form 7',
115
  ),
@@ -118,15 +102,15 @@ function add_ons_list(){
118
  'name' => 'WangGuard: MailPoet Connector',
119
  'search' => 'WangGuard Wysija Newsletter Connector',
120
  'thumbnail' => 'wangguard.png',
121
- 'description' => __( 'Stop fake signups by robots with WangGuard, a free white listing service, and plugin.', WYSIJA ),
122
- 'review' => __( 'If you have this problem, then this is your solution. Totally free too.', WYSIJA ),
123
  'plugin_url' => 'wangguard-wysija-newsletter-connector/wangguard-wysija.php',
124
  'author_url' => 'http://clicky.me/wangguard',
125
  'version' => '1.0.0',
126
- 'official' => true,
127
- 'on_wordpress.org' => true,
128
- 'free' => true,
129
- 'service' => false,
130
  'requires' => '',
131
  ),
132
 
@@ -134,29 +118,29 @@ function add_ons_list(){
134
  'name' => 'Leaky Paywall: MailPoet Add-on',
135
  'search' => 'Leaky Paywall: MailPoet Add-on',
136
  'thumbnail' => 'leakypw.png',
137
- 'description' => __( 'Leaky Paywall is a Premium plugin to put content behind a paywall. This add-on manages your customers\' customers subscriptions.', WYSIJA ),
138
  'plugin_url' => 'leaky-paywall-mail-poet/issuem-leaky-paywall-mailpoet.php',
139
  'author_url' => 'http://clicky.me/leakypw',
140
  'version' => '1.0.0',
141
- 'official' => true,
142
- 'on_wordpress.org' => true,
143
- 'free' => true,
144
- 'service' => false,
145
  ),
146
 
147
  array(
148
  'name' => 'GetConversion: Bar and Box Forms Add-on',
149
  'search' => 'GC MailPoet EX',
150
  'thumbnail' => 'getconversion.png',
151
- 'description' => __( 'Put a form in a top or bottom bar of your site, or in a nice box within your posts with GetConversion\'s free plugins. Connect them to MailPoet with this add-on.<br/></br>Get 30% off the Premium version of their add-on by clicking <a href="http://getconversion.com/products/gc-mailpoet-ex-pro/?coupon=MAILPOET">here</a>.', WYSIJA ),
152
- 'review' => __( 'Try it yourself, we were impressed by the free versions.', WYSIJA ),
153
  'plugin_url' => 'gc-message-bar/main.php',
154
  'author_url' => 'http://clicky.me/GC-add-on',
155
  'version' => '1.0.0',
156
- 'official' => true,
157
- 'on_wordpress.org' => true,
158
- 'free' => true,
159
- 'service' => false,
160
  ),
161
 
162
  /* Below is the list of services that work with MailPoet */
@@ -165,34 +149,34 @@ function add_ons_list(){
165
  'name' => 'OptinMonster: Slick Forms',
166
  'search' => 'OptinMonster: slick forms',
167
  'thumbnail' => 'optinmonster.png',
168
- 'description' => __( 'Put a subscription form in a popup, footer bar or slide-in to add subscribers with this Premium plugin.', WYSIJA ),
169
- 'review' => __( 'The authors have done a pretty awesome job.', WYSIJA ),
170
  'plugin_url' => '',
171
  'author_url' => 'http://clicky.me/optinmonsteraddon',
172
  'purchase_url' => '',
173
  'version' => '',
174
- 'official' => false,
175
- 'on_wordpress.org' => false,
176
- 'free' => false,
177
- 'service' => true,
178
- 'premium_offer' => __( 'Premium users save 20% with this coupon: MP20', WYSIJA ),
179
  ),
180
 
181
  array(
182
  'name' => 'Pippity: Form in a Popup',
183
  'search' => 'Pippity: form in a popup',
184
  'thumbnail' => 'pippity.png',
185
- 'description' => __( 'This Premium plugin allows you to add a MailPoet form in a popup.', WYSIJA ),
186
- 'review' => __( 'You\'ll need to know CSS to design it to your taste.', WYSIJA ),
187
  'plugin_url' => '',
188
  'author_url' => 'http://clicky.me/pippity',
189
  'purchase_url' => '',
190
  'version' => '',
191
- 'official' => false,
192
- 'on_wordpress.org' => false,
193
- 'free' => false,
194
- 'service' => true,
195
- 'premium_offer' => __( 'Premium users save 25% with this coupon: mailpoet25', WYSIJA ),
196
  ),
197
 
198
 
@@ -200,16 +184,16 @@ function add_ons_list(){
200
  'name' => 'Hybrid Connect: Forms and Facebook',
201
  'search' => 'Hybrid Connect: forms and Facebook',
202
  'thumbnail' => 'hybrid-connect.png',
203
- 'description' => __( 'This Premium plugin allows you to add MailPoet\'s forms in many places, and in Facebook.', WYSIJA ),
204
- 'review' => __( 'Very powerful, if not a quirky user interface.', WYSIJA ),
205
  'plugin_url' => '',
206
  'author_url' => 'http://clicky.me/hybrid-connect',
207
  'purchase_url' => '',
208
  'version' => '',
209
- 'official' => false,
210
- 'on_wordpress.org' => false,
211
- 'free' => false,
212
- 'service' => true,
213
  'premium_offer' => '',
214
  ),
215
 
@@ -217,16 +201,16 @@ function add_ons_list(){
217
  'name' => 'Magic Action Box: Pretty forms in post',
218
  'search' => 'Magic Action Box: pretty forms in post',
219
  'thumbnail' => 'magic-action-box.png',
220
- 'description' => __( 'This free plugin allows you to design and position a form at the beginning or bottom of a post.', WYSIJA ),
221
- 'review' => __( 'It\'s free, and has proven popular with our users.', WYSIJA ),
222
  'plugin_url' => '',
223
  'author_url' => 'http://clicky.me/magic-action-box',
224
  'purchase_url' => '',
225
  'version' => '',
226
- 'official' => false,
227
- 'on_wordpress.org' => false,
228
- 'free' => false,
229
- 'service' => true,
230
  'premium_offer' => '',
231
  ),
232
 
@@ -234,16 +218,16 @@ function add_ons_list(){
234
  'name' => 'Optin Revolution: Popup form',
235
  'search' => 'Optin Revolution: popup form',
236
  'thumbnail' => 'optin-revolution.png',
237
- 'description' => __( 'This free plugin allows you to put a form in a popup, that\'s it.', WYSIJA ),
238
- 'review' => __( 'This is the free version of a more powerful Premium version.', WYSIJA ),
239
  'plugin_url' => '',
240
  'author_url' => 'http://clicky.me/optin-revolution',
241
  'purchase_url' => '',
242
  'version' => '',
243
- 'official' => false,
244
- 'on_wordpress.org' => false,
245
- 'free' => false,
246
- 'service' => true,
247
  'premium_offer' => '',
248
  ),
249
 
@@ -251,33 +235,33 @@ function add_ons_list(){
251
  'name' => 'Ultimate Coming Soon Page',
252
  'search' => 'Ultimate Coming Soon Page',
253
  'thumbnail' => 'ultimate-coming-soon.png',
254
- 'description' => __( 'Your new site is not yet launched? Put a coming soon page with a form to capture emails with this Premium plugin.', WYSIJA ),
255
- 'review' => __( 'A well designed plugin for a simple idea.', WYSIJA ),
256
  'plugin_url' => '',
257
  'author_url' => 'http://clicky.me/coming-soon',
258
  'purchase_url' => '',
259
  'version' => '',
260
- 'official' => false,
261
- 'on_wordpress.org' => false,
262
- 'free' => false,
263
- 'service' => true,
264
- 'premium_offer' => __( 'Premium users save 20% with this coupon: MAILPOET20', WYSIJA ),
265
  ),
266
 
267
  array(
268
  'name' => 'Plugmatter: form below your header',
269
  'search' => 'Plugmatter',
270
  'thumbnail' => 'plugmatter.png',
271
- 'description' => __( 'This Premium plugin allows you to put a pretty form right below the header. Nothing more, nothing less.', WYSIJA ),
272
  'review' => '',
273
  'plugin_url' => '',
274
  'author_url' => 'http://clicky.me/plugmatter',
275
  'purchase_url' => '',
276
  'version' => '',
277
- 'official' => false,
278
- 'on_wordpress.org' => false,
279
- 'free' => false,
280
- 'service' => true,
281
  'premium_offer' => '',
282
  ),
283
 
@@ -285,16 +269,16 @@ function add_ons_list(){
285
  'name' => 'EDD: MailPoet: Subscribe on Checkout',
286
  'search' => 'Easy Digital Downloads - MailPoet',
287
  'thumbnail' => 'easy-digital-downloads.png',
288
- 'description' => __( 'A checkbox is added as option for your customers to signup for your newsletter while purchasing from your digital store.', WYSIJA ),
289
  'review' => '',
290
  'plugin_url' => '',
291
  'author_url' => 'http://clicky.me/easy-digital-downloads',
292
  'purchase_url' => 'http://clicky.me/easy-digital-downloads',
293
  'version' => '1.1.2',
294
- 'official' => false,
295
- 'on_wordpress.org' => false,
296
- 'free' => false,
297
- 'service' => false,
298
  'requires' => 'easy-digital-downloads/easy-digital-downloads.php',
299
  'requires_name' => 'Easy Digital Downloads',
300
  'premium_offer' => '',
@@ -304,21 +288,39 @@ function add_ons_list(){
304
  'name' => 'Ninja Forms: Subscribe Add-on',
305
  'search' => 'Ninja Forms: Subscribe Add-on',
306
  'thumbnail' => 'ninja-forms.png',
307
- 'description' => __( 'Quickly create newsletter signup forms for your MailPoet mailing lists using the power and flexibility that Ninja Forms provides.', WYSIJA ),
308
  'review' => '',
309
  'plugin_url' => 'ninja-forms-mailpoet/nf-mailpoet.php',
310
  'author_url' => 'http://clicky.me/ninja-forms',
311
  'purchase_url' => 'http://clicky.me/ninja-forms',
312
  'version' => '1.0.1',
313
- 'official' => false,
314
- 'on_wordpress.org' => false,
315
- 'free' => true,
316
- 'service' => false,
317
  'requires' => 'ninja-forms/ninja-forms.php',
318
  'requires_name' => 'Ninja Forms',
319
  'premium_offer' => '',
320
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  );
322
 
323
  return $available_add_ons;
324
- }
 
8
  'name' => 'WooCommerce: Subscribe on Checkout',
9
  'search' => 'MailPoet WooCommerce Add-on',
10
  'thumbnail' => 'woocommerce.png',
11
+ 'description' => __('Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA),
12
  'plugin_url' => 'mailpoet-woocommerce-addon/mailpoet-woocommerce-addon.php',
13
  'version' => '1.0.2',
14
  'config_url' => 'admin.php?page=woocommerce_settings&tab=mailpoet',
15
+ 'official' => 'yes',
16
+ 'on_wordpress.org' => 'yes',
17
+ 'free' => 'yes',
18
+ 'service' => 'no',
19
  'requires' => 'woocommerce/woocommerce.php',
20
  'requires_name' => 'WooCommerce',
21
  ),
22
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
  array(
24
  'name' => 'Jigoshop: Subscribe on Checkout',
25
  'search' => 'MailPoet Jigoshop Add-on',
26
  'thumbnail' => 'jigoshop.png',
27
+ 'description' => __('Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA),
28
  'plugin_url' => 'mailpoet-jigoshop-addon/mailpoet-jigoshop-addon.php',
29
  'version' => '1.0.3',
30
  'config_url' => 'admin.php?page=jigoshop_settings&tab=mailpoet',
31
+ 'official' => 'yes',
32
+ 'on_wordpress.org' => 'yes',
33
+ 'free' => 'yes',
34
+ 'service' => 'no',
35
  'requires' => 'jigoshop/jigoshop.php',
36
  'requires_name' => 'Jigoshop',
37
  ),
40
  'name' => 'Gravity Forms: Subscribe Add-on',
41
  'search' => 'MailPoet Gravity Forms Add-on',
42
  'thumbnail' => 'gravity-forms.png',
43
+ 'description' => __('Add a new field to add to your forms so your visitors can subscriber to your MailPoet newsletters.', WYSIJA),
44
  'plugin_url' => 'mailpoet-gravity-forms-addon/mailpoet-gravity-forms-addon.php',
45
  'version' => '1.0.0',
46
+ 'official' => 'yes',
47
+ 'on_wordpress.org' => 'yes',
48
+ 'free' => 'yes',
49
+ 'service' => 'no',
50
  'requires' => 'gravityforms/gravityforms.php',
51
  'requires_name' => 'Gravity Forms',
52
  ),
55
  'name' => 'WP e-Commerce: Subscribe on Checkout',
56
  'search' => 'MailPoet WP e-Commerce Add-on',
57
  'thumbnail' => 'wp-e-commerce.png',
58
+ 'description' => __('Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA),
59
  'plugin_url' => 'mailpoet-wp-ecommerce-addon/mailpoet-wp-ecommerce-addon.php',
60
  'version' => '1.0.0',
61
  'config_url' => 'edit.php?post_type=wpsc-product&page=mailpoet',
62
+ 'official' => 'yes',
63
+ 'on_wordpress.org' => 'yes',
64
+ 'free' => 'yes',
65
+ 'service' => 'no',
66
  'requires' => 'wp-e-commerce/wp-shopping-cart.php',
67
  'requires_name' => 'WP e-Commerce',
68
  ),
71
  'name' => 'Restrict Content Pro: Registration Add-on',
72
  'search' => 'Restrict Content Pro Wysija',
73
  'thumbnail' => 'pippins.png',
74
+ 'description' => __('Add a checkbox on the registration form of this plugin so your new users join a list of your choice.', WYSIJA),
75
  'plugin_url' => 'restrict-content-pro-wysija/rcp-wysija.php',
76
  'version' => '1.0',
77
+ 'official' => 'yes',
78
+ 'on_wordpress.org' => 'yes',
79
+ 'free' => 'yes',
80
+ 'service' => 'no',
81
  'requires' => 'restrict-content-pro/restrict-content-pro.php',
82
  'requires_name' => 'Restrict Content Pro',
83
  ),
86
  'name' => 'Contact Form 7: MailPoet Add-on',
87
  'search' => 'MailPoet Contact Form 7',
88
  'thumbnail' => 'cf7.png',
89
+ 'description' => __('Add a checkbox in your forms, and choose which lists the user gets added to.', WYSIJA),
90
  'plugin_url' => 'mailpoet-contact-form-7/mailpoet-contact-form-7.php',
91
  'author_url' => '',
92
  'version' => '1.0.0',
93
+ 'official' => 'yes',
94
+ 'on_wordpress.org' => 'yes',
95
+ 'free' => 'yes',
96
+ 'service' => 'no',
97
  'requires' => 'contact-form-7/wp-contact-form-7.php',
98
  'requires_name' => 'Contact Form 7',
99
  ),
102
  'name' => 'WangGuard: MailPoet Connector',
103
  'search' => 'WangGuard Wysija Newsletter Connector',
104
  'thumbnail' => 'wangguard.png',
105
+ 'description' => __('Stop fake signups by robots with WangGuard, a free white listing service, and plugin.', WYSIJA),
106
+ 'review' => __('If you have this problem, then this is your solution. Totally free too.', WYSIJA),
107
  'plugin_url' => 'wangguard-wysija-newsletter-connector/wangguard-wysija.php',
108
  'author_url' => 'http://clicky.me/wangguard',
109
  'version' => '1.0.0',
110
+ 'official' => 'yes',
111
+ 'on_wordpress.org' => 'yes',
112
+ 'free' => 'yes',
113
+ 'service' => 'no',
114
  'requires' => '',
115
  ),
116
 
118
  'name' => 'Leaky Paywall: MailPoet Add-on',
119
  'search' => 'Leaky Paywall: MailPoet Add-on',
120
  'thumbnail' => 'leakypw.png',
121
+ 'description' => __('Leaky Paywall is a Premium plugin to put content behind a paywall. This add-on manages your customers\' customers subscriptions.', WYSIJA),
122
  'plugin_url' => 'leaky-paywall-mail-poet/issuem-leaky-paywall-mailpoet.php',
123
  'author_url' => 'http://clicky.me/leakypw',
124
  'version' => '1.0.0',
125
+ 'official' => 'yes',
126
+ 'on_wordpress.org' => 'yes',
127
+ 'free' => 'yes',
128
+ 'service' => 'no',
129
  ),
130
 
131
  array(
132
  'name' => 'GetConversion: Bar and Box Forms Add-on',
133
  'search' => 'GC MailPoet EX',
134
  'thumbnail' => 'getconversion.png',
135
+ 'description' => __('Put a form in a top or bottom bar of your site, or in a nice box within your posts with GetConversion\'s free plugins. Connect them to MailPoet with this add-on.', WYSIJA),
136
+ 'review' => __('Try it yourself, we were impressed by the free versions.', WYSIJA),
137
  'plugin_url' => 'gc-message-bar/main.php',
138
  'author_url' => 'http://clicky.me/GC-add-on',
139
  'version' => '1.0.0',
140
+ 'official' => 'yes',
141
+ 'on_wordpress.org' => 'yes',
142
+ 'free' => 'yes',
143
+ 'service' => 'no',
144
  ),
145
 
146
  /* Below is the list of services that work with MailPoet */
149
  'name' => 'OptinMonster: Slick Forms',
150
  'search' => 'OptinMonster: slick forms',
151
  'thumbnail' => 'optinmonster.png',
152
+ 'description' => __('Put a subscription form in a popup, footer bar or slide-in to add subscribers with this Premium plugin.', WYSIJA),
153
+ 'review' => __('The authors have done a pretty awesome job.', WYSIJA),
154
  'plugin_url' => '',
155
  'author_url' => 'http://clicky.me/optinmonsteraddon',
156
  'purchase_url' => '',
157
  'version' => '',
158
+ 'official' => 'no',
159
+ 'on_wordpress.org' => 'no',
160
+ 'free' => 'no',
161
+ 'service' => 'yes',
162
+ 'premium_offer' => __('Premium users save 20% with this coupon: MP20', WYSIJA),
163
  ),
164
 
165
  array(
166
  'name' => 'Pippity: Form in a Popup',
167
  'search' => 'Pippity: form in a popup',
168
  'thumbnail' => 'pippity.png',
169
+ 'description' => __('This Premium plugin allows you to add a MailPoet form in a popup.', WYSIJA),
170
+ 'review' => __('You\'ll need to know CSS to design it to your taste.', WYSIJA),
171
  'plugin_url' => '',
172
  'author_url' => 'http://clicky.me/pippity',
173
  'purchase_url' => '',
174
  'version' => '',
175
+ 'official' => 'no',
176
+ 'on_wordpress.org' => 'no',
177
+ 'free' => 'no',
178
+ 'service' => 'yes',
179
+ 'premium_offer' => __('Premium users save 20% with this coupon: mailpoet25', WYSIJA),
180
  ),
181
 
182
 
184
  'name' => 'Hybrid Connect: Forms and Facebook',
185
  'search' => 'Hybrid Connect: forms and Facebook',
186
  'thumbnail' => 'hybrid-connect.png',
187
+ 'description' => __('This Premium plugin allows you to add MailPoet\'s forms in many places, and in Facebook.', WYSIJA),
188
+ 'review' => __('Very powerful, if not a quirky user interface.', WYSIJA),
189
  'plugin_url' => '',
190
  'author_url' => 'http://clicky.me/hybrid-connect',
191
  'purchase_url' => '',
192
  'version' => '',
193
+ 'official' => 'no',
194
+ 'on_wordpress.org' => 'no',
195
+ 'free' => 'no',
196
+ 'service' => 'yes',
197
  'premium_offer' => '',
198
  ),
199
 
201
  'name' => 'Magic Action Box: Pretty forms in post',
202
  'search' => 'Magic Action Box: pretty forms in post',
203
  'thumbnail' => 'magic-action-box.png',
204
+ 'description' => __('This free plugin allows you to design and position a form at the beginning or bottom of a post.', WYSIJA),
205
+ 'review' => __('It\'s free, and has proven popular with our users.', WYSIJA),
206
  'plugin_url' => '',
207
  'author_url' => 'http://clicky.me/magic-action-box',
208
  'purchase_url' => '',
209
  'version' => '',
210
+ 'official' => 'no',
211
+ 'on_wordpress.org' => 'no',
212
+ 'free' => 'no',
213
+ 'service' => 'yes',
214
  'premium_offer' => '',
215
  ),
216
 
218
  'name' => 'Optin Revolution: Popup form',
219
  'search' => 'Optin Revolution: popup form',
220
  'thumbnail' => 'optin-revolution.png',
221
+ 'description' => __('This free plugin allows you to put a form in a popup, that\'s it.', WYSIJA),
222
+ 'review' => __('This is the free version of a more powerful Premium version.', WYSIJA),
223
  'plugin_url' => '',
224
  'author_url' => 'http://clicky.me/optin-revolution',
225
  'purchase_url' => '',
226
  'version' => '',
227
+ 'official' => 'no',
228
+ 'on_wordpress.org' => 'no',
229
+ 'free' => 'no',
230
+ 'service' => 'yes',
231
  'premium_offer' => '',
232
  ),
233
 
235
  'name' => 'Ultimate Coming Soon Page',
236
  'search' => 'Ultimate Coming Soon Page',
237
  'thumbnail' => 'ultimate-coming-soon.png',
238
+ 'description' => __('Your new site is not yet launched? Put a coming soon page with a form to capture emails with this Premium plugin.', WYSIJA),
239
+ 'review' => __('A well designed plugin for a simple idea.', WYSIJA),
240
  'plugin_url' => '',
241
  'author_url' => 'http://clicky.me/coming-soon',
242
  'purchase_url' => '',
243
  'version' => '',
244
+ 'official' => 'no',
245
+ 'on_wordpress.org' => 'no',
246
+ 'free' => 'no',
247
+ 'service' => 'yes',
248
+ 'premium_offer' => __('Premium users save 20% with this coupon: MAILPOET20', WYSIJA),
249
  ),
250
 
251
  array(
252
  'name' => 'Plugmatter: form below your header',
253
  'search' => 'Plugmatter',
254
  'thumbnail' => 'plugmatter.png',
255
+ 'description' => __('This Premium plugin allows you to put a pretty form right below the header. Nothing more, nothing less.', WYSIJA),
256
  'review' => '',
257
  'plugin_url' => '',
258
  'author_url' => 'http://clicky.me/plugmatter',
259
  'purchase_url' => '',
260
  'version' => '',
261
+ 'official' => 'no',
262
+ 'on_wordpress.org' => 'no',
263
+ 'free' => 'no',
264
+ 'service' => 'yes',
265
  'premium_offer' => '',
266
  ),
267
 
269
  'name' => 'EDD: MailPoet: Subscribe on Checkout',
270
  'search' => 'Easy Digital Downloads - MailPoet',
271
  'thumbnail' => 'easy-digital-downloads.png',
272
+ 'description' => __('A checkbox is added as option for your customers to signup for your newsletter while purchasing from your digital store.', WYSIJA),
273
  'review' => '',
274
  'plugin_url' => '',
275
  'author_url' => 'http://clicky.me/easy-digital-downloads',
276
  'purchase_url' => 'http://clicky.me/easy-digital-downloads',
277
  'version' => '1.1.2',
278
+ 'official' => 'no',
279
+ 'on_wordpress.org' => 'no',
280
+ 'free' => 'no',
281
+ 'service' => 'no',
282
  'requires' => 'easy-digital-downloads/easy-digital-downloads.php',
283
  'requires_name' => 'Easy Digital Downloads',
284
  'premium_offer' => '',
288
  'name' => 'Ninja Forms: Subscribe Add-on',
289
  'search' => 'Ninja Forms: Subscribe Add-on',
290
  'thumbnail' => 'ninja-forms.png',
291
+ 'description' => __('Quickly create newsletter signup forms for your MailPoet mailing lists using the power and flexibility that Ninja Forms provides.', WYSIJA),
292
  'review' => '',
293
  'plugin_url' => 'ninja-forms-mailpoet/nf-mailpoet.php',
294
  'author_url' => 'http://clicky.me/ninja-forms',
295
  'purchase_url' => 'http://clicky.me/ninja-forms',
296
  'version' => '1.0.1',
297
+ 'official' => 'no',
298
+ 'on_wordpress.org' => 'no',
299
+ 'free' => 'no',
300
+ 'service' => 'no',
301
  'requires' => 'ninja-forms/ninja-forms.php',
302
  'requires_name' => 'Ninja Forms',
303
  'premium_offer' => '',
304
  ),
305
+
306
+ /*array(
307
+ 'name' => 'WangGuard: block fake signups',
308
+ 'search' => 'WangGuard: block fake signups',
309
+ 'thumbnail' => 'wangguard.png',
310
+ 'description' => __('This plugin blocks spam signups to your site. Connect it to MailPoet with an additional add-on.'),
311
+ 'review' => __('If you have this problem, then this is your solution. Totally free too.', WYSIJA),
312
+ 'plugin_url' => '',
313
+ 'author_url' => 'http://clicky.me/wangguard-plugin',
314
+ 'purchase_url' => '',
315
+ 'version' => '',
316
+ 'official' => 'no',
317
+ 'on_wordpress.org' => 'yes',
318
+ 'free' => 'yes',
319
+ 'service' => 'yes',
320
+ 'premium_offer' => '',
321
+ ),*/
322
  );
323
 
324
  return $available_add_ons;
325
+ }
326
+ ?>
add-ons/add-ons.php CHANGED
@@ -1,15 +1,13 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ){
3
- exit; // Exit if accessed directly
4
- }
5
 
 
6
  class MailPoet_Add_ons {
7
  /**
8
  * Constructor
9
  */
10
  public function __construct(){
11
  $this->plugin_path = WYSIJA_DIR;
12
- $this->wp_plugin_path = str_replace( 'wysija-newsletters', '', $this->plugin_path );
13
  $this->plugin_url = WYSIJA_URL;
14
  $this->image_url = 'http://ps.w.org/wysija-newsletters/assets/add-ons/';
15
 
@@ -30,9 +28,9 @@ class MailPoet_Add_ons {
30
  * administration panel and the public facing site.
31
  */
32
  public function register_scripts_and_styles(){
33
- if ( is_admin() ) {
34
- wp_register_style( 'mail_poet_add_ons', WYSIJA_URL . 'css/add-ons.css' );
35
- wp_enqueue_style( 'mail_poet_add_ons' );
36
  } // end if
37
  } // end register_scripts_and_styles
38
 
@@ -46,34 +44,35 @@ class MailPoet_Add_ons {
46
 
47
  require_once(ABSPATH.'/wp-admin/includes/plugin.php');
48
 
49
- if ( isset($_GET['action'] ) && $_GET['action'] == 'activate' && isset( $_GET['module'] ) ) {
50
 
51
- $plugin = plugin_basename( $_GET['module'] );
52
- $plugin_data = get_plugin_data( $this->wp_plugin_path . $plugin );
53
 
54
- $plugin_name = esc_attr( str_replace( ' ', '_', $plugin_data['Name'] ) );
55
- $plugin_name = esc_attr( str_replace( '&#039;', '_', $plugin_name ) );
56
 
57
- if ( isset( $_GET['requires'] ) ) {
58
- if ( file_exists( $this->wp_plugin_path . plugin_basename( $_GET['requires'] ) ) ) {
59
- if ( ! WYSIJA::is_plugin_active( $_GET['requires'] ) ) {
60
- $location = admin_url( 'admin.php?page=wysija_config&status=not-activated&add-on=' . $plugin_name . '&requires=' . esc_attr( str_replace( ' ', '_', $_GET['requires_name'] ) ) . '#tab-add-ons' );
61
- wp_safe_redirect( $location );
62
  exit;
63
  }
64
- } else {
65
- $location = admin_url( 'admin.php?page=wysija_config&status=not-installed&add-on=' . $plugin_name . '&requires=' . esc_attr( str_replace( ' ', '_', $_GET['requires_name'] ) ) . '#tab-add-ons' );
66
- wp_safe_redirect( $location );
 
67
  exit;
68
  }
69
  }
70
 
71
  // Activate the add-on plugin.
72
- activate_plugin( $plugin );
73
 
74
  // Return back to add-on page.
75
- $location = admin_url( 'admin.php?page=wysija_config&status=activated&add-on=' . $plugin_name . '#tab-add-ons' );
76
- wp_safe_redirect( $location );
77
  exit;
78
  }
79
 
@@ -81,24 +80,13 @@ class MailPoet_Add_ons {
81
  * Display message if the plugin was not able to activate due
82
  * to a required plugin is not active first.
83
  */
84
- if ( $current_screen->parent_base == 'wysija_campaigns' && isset( $_GET['status'] ) && $_GET['status'] == 'not-activated' || isset( $_GET['status'] ) && $_GET['status'] == 'not-installed' ){
85
- echo
86
- '<div id="message" class="error fade" style="display:block !important;">' .
87
- '<p>' .
88
- '<strong>' . esc_attr( str_replace( '_', ' ', $_GET['add-on'] ) ) . '</strong> ' .
89
- wp_kses( sprintf(
90
- __( 'was not activated as it requires <strong><a href="%s">%s</a></strong> to be installed and active first.', WYSIJA ),
91
- esc_url( admin_url( 'plugin-install.php?tab=search&type=term&s=' . esc_attr( strtolower( str_replace( ' ', '+', $_GET['requires'] ) ) ) ) ),
92
- str_replace( '_', ' ', $_GET['requires'] )
93
- ), array( 'a' => array( 'href' => array() ), 'strong' => array(), 'b' => array(), 'em' => array() ) ) .
94
- ' <input type="button" class="button" value="' . esc_attr__( 'Hide this message', WYSIJA ) . '" onclick="document.location.href=\'' . esc_url( admin_url( 'admin.php?page=wysija_config#tab-add_ons' ) ) . '\';">' .
95
- '</p>' .
96
- '</div>';
97
  }
98
 
99
  // Display message once the add-on has been activated.
100
- if ( $current_screen->parent_base == 'wysija_campaigns' && isset( $_GET['status'] ) && $_GET['status'] == 'activated' ){
101
- echo '<div id="message" class="updated fade" style="display:block !important;"><p><strong>' . esc_attr( str_replace( '_', ' ', $_GET['add-on'] ) ) . '</strong> ' . esc_attr__( 'has been activated.', WYSIJA ) . '</p></div>';
102
  }
103
  }
104
 
@@ -110,24 +98,24 @@ class MailPoet_Add_ons {
110
  public function mailpoet_add_on_deactivated_notice(){
111
  global $current_screen;
112
 
113
- require_once ABSPATH . '/wp-admin/includes/plugin.php';
114
 
115
- if ( isset( $_GET['action'] ) && $_GET['action'] == 'deactivate' && isset( $_GET['module'] ) ) {
116
- $plugin = plugin_basename( $_GET['module'] );
117
- $plugin_data = get_plugin_data( $this->wp_plugin_path . $plugin );
118
 
119
  // Deactivate the add-on plugin.
120
- deactivate_plugins( $plugin );
121
 
122
  // Return back to add-on page.
123
- $location = admin_url( 'admin.php?page=wysija_config&status=deactivated&add-on=' . esc_html( str_replace( ' ', '_', $plugin_data['Name'] ) ) . '#tab-add-ons' );
124
- wp_safe_redirect( $location );
125
  exit;
126
  }
127
 
128
  // Display message once the add-on has been deactivated.
129
- if ( $current_screen->parent_base == 'wysija_campaigns' && isset( $_GET['status'] ) && $_GET['status'] == 'deactivated' ) {
130
- echo '<div id="message" class="updated fade" style="display:block !important;"><p><strong>' . esc_attr( str_replace( '_', ' ', $_GET['add-on'] ) ) . '</strong> ' . esc_attr__( 'has been de-activated.', WYSIJA ) . '</p></div>';
131
  }
132
 
133
  }
@@ -137,116 +125,136 @@ class MailPoet_Add_ons {
137
  * the plugins and services available.
138
  */
139
  public function add_ons_page(){
140
- require_once WYSIJA_DIR . '/add-ons/add-ons-list.php';
141
-
142
- echo '<div class="module-container">';
143
- foreach ( add_ons_list() as $plugin => $product ){
144
- $status = ''; // Status class.
145
-
146
- /**
147
- * Queries if the plugin is installed,
148
- * active and meets the requirements
149
- * it requires if any.
150
- */
151
- if ( file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
152
- $status .= ' installed';
153
- } else {
154
- $status .= ' not-installed';
155
- }
156
-
157
- if ( WYSIJA::is_plugin_active( $product['plugin_url'] ) ) {
158
- $status .= ' active';
159
- } else {
160
- $status .= ' inactive';
161
- }
162
-
163
- if ( empty( $product['requires'] ) ) {
164
- $status .= ' ready';
165
- } elseif ( ! empty( $product['requires'] ) && file_exists( $this->wp_plugin_path . plugin_basename( $product['requires'] ) ) ) {
166
- $status .= ' ready';
167
- if ( WYSIJA::is_plugin_active( $product['requires'] ) ) {
168
  $status .= ' ready';
169
- } else {
170
- $status .= ' not-ready';
171
  }
172
- } elseif ( ! empty( $product['requires'] ) && ! file_exists( $this->wp_plugin_path . plugin_basename( $product['requires'] ) ) ) {
173
- $status .= ' not-ready';
174
- }
175
-
176
- if ( WYSIJA::is_plugin_active( 'wysija-newsletters-premium/index.php' ) ) {
177
- $status .= ' premium-active';
178
- }
179
-
180
- echo
181
- '<div class="mailpoet-module' . esc_attr( $status ) . '" id="product">' .
182
- '<h3>' . esc_attr( $product['name'] ) . '</h3>';
183
-
184
- if ( ! empty( $product['thumbnail'] ) ) {
185
- echo '<div class="mailpoet-module-image"><img src="' . esc_url( $this->image_url . $product['thumbnail'] ) . '" width="100%" title="' . esc_attr( $product['name'] ) . '" alt=""></div>';
186
- }
187
-
188
- echo
189
- '<div class="mailpoet-module-content">' .
190
- '<div class="mailpoet-module-description">' .
191
- '<p>' . wp_kses( $product['description'], array() ) . '</p>';
192
-
193
- if ( ! empty( $product['review'] ) ) {
194
- echo '<p><strong>' . esc_attr__( 'MailPoet says: ', WYSIJA ) . '<em>' . esc_attr( $product['review'] ) . '</em>' . '</strong></p>';
195
- }
196
-
197
- if ( WYSIJA::is_plugin_active( 'wysija-newsletters-premium/index.php' ) && ! empty( $product['premium_offer'] ) ) {
198
- echo '<p><strong>' . esc_attr( $product['premium_offer'] ) . '</strong></p>';
199
- }
200
- echo
201
- '</div>' .
202
- '</div>' .
203
-
204
- '<div class="mailpoet-module-actions">';
205
-
206
- if ( ! empty( $product['author_url'] ) ) {
207
- echo '<a href="' . esc_url( $product['author_url'] ) . '" target="_blank" rel="external" class="button-primary website">' . esc_attr__( 'Website', WYSIJA ) . '</a>&nbsp;';
208
- }
209
-
210
- if ( $product['free'] == false && ! empty( $product['purchase_url'] ) ) {
211
- if ( ! empty( $product['plugin_url'] ) && ! file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
212
- echo '<a href="' . esc_url( $product['purchase_url'] ) . '" target="_blank" rel="external" class="button-primary purchase">' . esc_attr__( 'Purchase', WYSIJA ) . '</a>&nbsp;';
213
- } // end if plugin is installed, don't show purchase button.
214
- } // end if product is not free.
215
-
216
- if ( $product['service'] == false ){
217
- if ( $product['on_wordpress.org'] == true ){
218
- if ( ! file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
219
- echo '<a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&type=term&s=' . strtolower( str_replace( ' ', '+', $product['search'] ) ) ) ) . '" class="button-primary install">' . esc_attr__( 'Install from WordPress.org', WYSIJA ) . '</a>&nbsp;';
220
- }
221
- } // end if $product['on_wordpress.org'];
222
-
223
- if ( ! empty( $product['plugin_url'] ) && file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
224
- if ( ! WYSIJA::is_plugin_active( $product['plugin_url'] ) ) {
225
- if ( ! empty( $product['requires'] ) ) {
226
- $requires = '&amp;requires=' . $product['requires'] . '&amp;requires_name=' . $product['requires_name'];
227
- } else {
228
- $requires = '';
229
- }
230
- echo '<a href="' . esc_url( admin_url( 'admin.php?page=wysija_config&amp;action=activate&amp;module=' . $product['plugin_url'] . $requires ) ) . '" class="button-primary activate">' . esc_attr__( 'Activate', WYSIJA ) . '</a>&nbsp;';
231
- } else {
232
- if ( ! empty( $product['config_url'] ) ) {
233
- echo '<a href="' . esc_url( $product['config_url'] ) . '" class="mailpoet-configure-button button-secondary">' . esc_attr__( 'Configure', WYSIJA ) . '</a>';
234
- }
235
- }
236
  }
237
- }
238
-
239
- echo
240
- '</div>' .
241
- '</div>';
242
- } // end if local is yes.
243
-
244
- echo
245
- '<div class="submit-idea">' .
246
- '<p>' . wp_kses( sprintf( __( 'Don\'t see the add-on you\'re looking for? <a href="%s">Submit it</a> in our contact form.', WYSIJA ), 'http://www.mailpoet.com/contact/" target="blank' ), array( 'a' => array( 'href' => array() ) ) ) . '</p>' .
247
- '</div>' .
248
- '</div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
  }
 
250
  } // end class
251
 
252
  /**
@@ -260,4 +268,5 @@ function load_add_ons_manager(){
260
  $mailpoet_add_ons->init_mail_poet_add_ons();
261
  $mailpoet_add_ons->add_ons_page();
262
  }
263
- load_add_ons_manager();
 
1
+ <?php if(!defined('ABSPATH')) exit; // Exit if accessed directly ?>
 
 
 
2
 
3
+ <?php
4
  class MailPoet_Add_ons {
5
  /**
6
  * Constructor
7
  */
8
  public function __construct(){
9
  $this->plugin_path = WYSIJA_DIR;
10
+ $this->wp_plugin_path = str_replace('wysija-newsletters', '', $this->plugin_path);
11
  $this->plugin_url = WYSIJA_URL;
12
  $this->image_url = 'http://ps.w.org/wysija-newsletters/assets/add-ons/';
13
 
28
  * administration panel and the public facing site.
29
  */
30
  public function register_scripts_and_styles(){
31
+ if(is_admin()){
32
+ wp_register_style('mail_poet_add_ons', WYSIJA_URL.'css/add-ons.css');
33
+ wp_enqueue_style('mail_poet_add_ons');
34
  } // end if
35
  } // end register_scripts_and_styles
36
 
44
 
45
  require_once(ABSPATH.'/wp-admin/includes/plugin.php');
46
 
47
+ if(isset($_GET['action']) && $_GET['action'] == 'activate' && isset($_GET['module'])){
48
 
49
+ $plugin = plugin_basename($_GET['module']);
50
+ $plugin_data = get_plugin_data($this->wp_plugin_path.''.$plugin);
51
 
52
+ $plugin_name = esc_attr(str_replace(' ', '_', $plugin_data['Name']));
53
+ $plugin_name = esc_attr(str_replace('&#039;', '_', $plugin_name));
54
 
55
+ if(isset($_GET['requires'])){
56
+ if(file_exists($this->wp_plugin_path.''.plugin_basename($_GET['requires']))){
57
+ if(!WYSIJA::is_plugin_active($_GET['requires'])){
58
+ $location = admin_url('admin.php?page=wysija_config&status=not-activated&add-on='.$plugin_name.'&requires='.esc_attr(str_replace(' ', '_', $_GET['requires_name'])).'#tab-add-ons');
59
+ wp_safe_redirect($location);
60
  exit;
61
  }
62
+ }
63
+ else{
64
+ $location = admin_url('admin.php?page=wysija_config&status=not-installed&add-on='.$plugin_name.'&requires='.esc_attr(str_replace(' ', '_', $_GET['requires_name'])).'#tab-add-ons');
65
+ wp_safe_redirect($location);
66
  exit;
67
  }
68
  }
69
 
70
  // Activate the add-on plugin.
71
+ activate_plugin($plugin);
72
 
73
  // Return back to add-on page.
74
+ $location = admin_url('admin.php?page=wysija_config&status=activated&add-on='.$plugin_name.'#tab-add-ons');
75
+ wp_safe_redirect($location);
76
  exit;
77
  }
78
 
80
  * Display message if the plugin was not able to activate due
81
  * to a required plugin is not active first.
82
  */
83
+ if($current_screen->parent_base == 'wysija_campaigns' && isset($_GET['status']) && $_GET['status'] == 'not-activated' || isset($_GET['status']) && $_GET['status'] == 'not-installed'){
84
+ echo '<div id="message" class="error fade" style="display:block !important;"><p><strong>'.str_replace('_', ' ', $_GET['add-on']).'</strong> '.sprintf(__('was not activated as it requires <strong><a href="%s">%s</a></strong> to be installed and active first.', WYSIJA), admin_url('plugin-install.php?tab=search&type=term&s='.strtolower(str_replace(' ', '+', $_GET['requires']))), str_replace('_', ' ', $_GET['requires'])).' <input type="button" class="button" value="'.__('Hide this message', WYSIJA).'" onclick="document.location.href=\''.admin_url('admin.php?page=wysija_config#tab-add_ons').'\';"></p></div>';
 
 
 
 
 
 
 
 
 
 
 
85
  }
86
 
87
  // Display message once the add-on has been activated.
88
+ if($current_screen->parent_base == 'wysija_campaigns' && isset($_GET['status']) && $_GET['status'] == 'activated'){
89
+ echo '<div id="message" class="updated fade" style="display:block !important;"><p><strong>'.str_replace('_', ' ', $_GET['add-on']).'</strong> '.__('has been activated.', WYSIJA).'</p></div>';
90
  }
91
  }
92
 
98
  public function mailpoet_add_on_deactivated_notice(){
99
  global $current_screen;
100
 
101
+ require_once(ABSPATH.'/wp-admin/includes/plugin.php');
102
 
103
+ if(isset($_GET['action']) && $_GET['action'] == 'deactivate' && isset($_GET['module'])){
104
+ $plugin = plugin_basename($_GET['module']);
105
+ $plugin_data = get_plugin_data($this->wp_plugin_path.''.$plugin);
106
 
107
  // Deactivate the add-on plugin.
108
+ deactivate_plugins($plugin);
109
 
110
  // Return back to add-on page.
111
+ $location = admin_url('admin.php?page=wysija_config&status=deactivated&add-on='.esc_html(str_replace(' ', '_', $plugin_data['Name'])).'#tab-add-ons');
112
+ wp_safe_redirect($location);
113
  exit;
114
  }
115
 
116
  // Display message once the add-on has been deactivated.
117
+ if($current_screen->parent_base == 'wysija_campaigns' && isset($_GET['status']) && $_GET['status'] == 'deactivated'){
118
+ echo '<div id="message" class="updated fade" style="display:block !important;"><p><strong>'.str_replace('_', ' ', $_GET['add-on']).'</strong> '.__('has been de-activated.', WYSIJA).'</p></div>';
119
  }
120
 
121
  }
125
  * the plugins and services available.
126
  */
127
  public function add_ons_page(){
128
+ require_once(WYSIJA_DIR.'/add-ons/add-ons-list.php');
129
+ ?>
130
+ <div class="module-container">
131
+ <?php
132
+ foreach(add_ons_list() as $plugin => $product){
133
+ if(empty($product['official']) || $product['official'] == 'yes'){
134
+
135
+ $status = ''; // Status class.
136
+
137
+ /**
138
+ * Queries if the plugin is installed,
139
+ * active and meets the requirements
140
+ * it requires if any.
141
+ */
142
+ if(file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ $status .= ' installed'; }else{ $status .= ' not-installed'; }
143
+ if(WYSIJA::is_plugin_active($product['plugin_url'])){ $status .= ' active'; }else{ $status .= ' inactive'; }
144
+ if(empty($product['requires'])){ $status .= ' ready'; }
145
+ else if(!empty($product['requires']) && file_exists($this->wp_plugin_path.''.plugin_basename($product['requires']))){
 
 
 
 
 
 
 
 
 
 
146
  $status .= ' ready';
147
+ if(WYSIJA::is_plugin_active($product['requires'])){ $status .= ' ready'; }
148
+ else{ $status .= ' not-ready'; }
149
  }
150
+ else if(!empty($product['requires']) && !file_exists($this->wp_plugin_path.''.plugin_basename($product['requires']))){ $status .= ' not-ready'; }
151
+ if(WYSIJA::is_plugin_active('wysija-newsletters-premium/index.php')){ $status .= ' premium-active'; }
152
+ ?>
153
+ <div class="mailpoet-module<?php echo $status; ?>" id="product">
154
+ <h3><?php echo $product['name']; ?></h3>
155
+
156
+ <?php if(!empty($product['thumbnail'])){ ?><div class="mailpoet-module-image"><img src="<?php echo $this->image_url.$product['thumbnail']; ?>" width="100%" title="<?php echo $product['name']; ?>" alt=""></div><?php } ?>
157
+
158
+ <div class="mailpoet-module-content">
159
+ <div class="mailpoet-module-description">
160
+ <p><?php echo $product['description']; ?></p>
161
+ <p><?php if(!empty($product['review'])){ echo '<strong>'.sprintf(__('MailPoet says:&nbsp;<em>%s</em>', WYSIJA), $product['review']).'</strong>'; } ?></p>
162
+ <?php if(WYSIJA::is_plugin_active('wysija-newsletters-premium/index.php') && !empty($product['premium_offer'])){ ?><p><strong><?php echo $product['premium_offer']; ?></strong></p><?php } ?>
163
+ </div>
164
+
165
+ <div class="mailpoet-module-actions">
166
+ <?php if(!empty($product['author_url'])){ ?><a href="<?php echo esc_url($product['author_url']); ?>" target="_blank" class="button-primary website"><?php _e('Website', WYSIJA); ?></a>&nbsp;<?php } ?>
167
+ <?php if($product['free'] == 'yes' && !empty($product['download_url'])){ if(!file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ ?><a href="<?php echo $product['download_url']; ?>" target="_blank" class="button-primary download"><?php _e('Download Plugin', WYSIJA); ?></a>&nbsp;<?php } } ?>
168
+ <?php if($product['service'] == 'no'){ ?>
169
+ <?php if($product['on_wordpress.org'] == 'yes'){ if(!file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ ?><a href="<?php echo admin_url('plugin-install.php?tab=search&type=term&s='.strtolower(str_replace(' ', '+', $product['search']))); ?>" class="button-primary install"><?php _e('Install from WordPress.org', WYSIJA); ?></a>&nbsp;<?php } } ?>
170
+ <?php if(file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ if(!WYSIJA::is_plugin_active($product['plugin_url'])){ ?><a href="<?php if(!empty($product['requires'])){ $requires = '&amp;requires='.$product['requires'].'&amp;requires_name='.$product['requires_name']; }else{ $requires = ''; } echo admin_url('admin.php?page=wysija_config&amp;action=activate&amp;module='.$product['plugin_url'].''.$requires); ?>" class="button-primary activate"><?php _e('Activate', WYSIJA); ?></a>&nbsp;<?php }else{ ?>
171
+ <?php if(!empty($product['config_url'])){ ?><a href="<?php echo $product['config_url']; ?>" class="mailpoet-configure-button button-secondary"><?php _e('Configure', WYSIJA); ?></a><?php } } } ?>
172
+ <?php } ?>
173
+ </div>
174
+ </div>
175
+ </div>
176
+ <?php
177
+ } // end if local is yes.
178
+ }
179
+ ?>
180
+ </div><!-- .module-container -->
181
+
182
+ <div class="submit-idea">
183
+ <p><?php echo sprintf(__('Don\'t see the add-on you\'re looking for? <a href="%s">Submit it</a> in our contact form.', WYSIJA), 'http://www.mailpoet.com/contact/" target="blank'); ?></p>
184
+ </div>
185
+
186
+ <div class="module-container">
187
+ <h2><?php _e('Works with MailPoet', WYSIJA); ?></h2>
188
+ <p><?php _e('This list of plugins and services that might be useful to you. We don\'t offer support for them, and we\'re not affiliated with them.', WYSIJA); ?></p>
189
+
190
+ <?php
191
+ foreach(add_ons_list() as $plugin => $product){
192
+ if($product['official'] == 'no'){
193
+
194
+ $status = ''; // Status class.
195
+
196
+ /**
197
+ * Queries if the plugin is installed,
198
+ * active and meets the requirements
199
+ * it requires if any.
200
+ */
201
+ if(file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ $status .= ' installed'; }else{ $status .= ' not-installed'; }
202
+ if(WYSIJA::is_plugin_active($product['plugin_url'])){ $status .= ' active'; }else{ $status .= ' inactive'; }
203
+ if(empty($product['requires'])){ $status .= ' ready'; }
204
+ else if(!empty($product['requires']) && file_exists($this->wp_plugin_path.''.plugin_basename($product['requires']))){
205
+ $status .= ' ready';
206
+ if(WYSIJA::is_plugin_active($product['requires'])){ $status .= ' ready'; }
207
+ else{ $status .= ' not-ready'; }
 
 
 
 
 
 
208
  }
209
+ else if(!empty($product['requires']) && !file_exists($this->wp_plugin_path.''.plugin_basename($product['requires']))){ $status .= ' not-ready'; }
210
+ if(WYSIJA::is_plugin_active('wysija-newsletters-premium/index.php')){ $status .= ' premium-active'; }
211
+ ?>
212
+ <div class="mailpoet-module<?php echo $status; ?>" id="product">
213
+ <h3><?php echo $product['name']; ?></h3>
214
+ <?php if(!empty($product['thumbnail'])){ ?><div class="mailpoet-module-image"><img src="<?php echo $this->image_url.$product['thumbnail']; ?>" width="100%" title="<?php echo $product['name']; ?>" alt=""></div><?php } ?>
215
+
216
+ <div class="mailpoet-module-content">
217
+ <div class="mailpoet-module-description">
218
+ <p><?php echo $product['description']; ?></p>
219
+ <p><?php if(!empty($product['review'])){ echo '<strong>'.sprintf(__('MailPoet says:&nbsp;<em>%s</em>', WYSIJA), $product['review']).'</strong>'; } ?></p>
220
+ <?php if(WYSIJA::is_plugin_active('wysija-newsletters-premium/index.php') && !empty($product['premium_offer'])){ ?><p><strong><?php echo $product['premium_offer']; ?></strong></p><?php } ?>
221
+ </div>
222
+
223
+ <div class="mailpoet-module-actions">
224
+ <?php if(!empty($product['author_url'])){ ?><a href="<?php echo esc_url($product['author_url']); ?>" target="_blank" rel="external" class="button-primary website"><?php _e('Website', WYSIJA); ?></a>&nbsp;<?php } ?>
225
+ <?php
226
+ if($product['free'] == 'no' && !empty($product['purchase_url'])){
227
+ if(!empty($product['plugin_url']) && !file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ ?><a href="<?php echo $product['purchase_url']; ?>" target="_blank" rel="external" class="button-primary purchase"><?php _e('Purchase', WYSIJA); ?></a>&nbsp;
228
+ <?php
229
+ } // end if plugin is installed, don't show purchase button.
230
+ } // end if product is not free.
231
+ ?>
232
+
233
+ <?php
234
+ if($product['service'] == 'no'){
235
+ if($product['on_wordpress.org'] == 'yes'){
236
+ if(!file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){ ?><a href="<?php echo admin_url('plugin-install.php?tab=search&type=term&s='.strtolower(str_replace(' ', '+', $product['search']))); ?>" class="button-primary install"><?php _e('Install from WordPress.org', WYSIJA); ?></a>&nbsp;
237
+ <?php } // end if file_exists.
238
+ } // end if $product['on_wordpress.org'];
239
+
240
+ if(!empty($product['plugin_url']) && file_exists($this->wp_plugin_path.''.plugin_basename($product['plugin_url']))){
241
+ if(!WYSIJA::is_plugin_active($product['plugin_url'])){ ?><a href="<?php if(!empty($product['requires'])){ $requires = '&amp;requires='.$product['requires'].'&amp;requires_name='.$product['requires_name']; }else{ $requires = ''; } echo admin_url('admin.php?page=wysija_config&amp;action=activate&amp;module='.$product['plugin_url'].''.$requires); ?>" class="button-primary activate"><?php _e('Activate', WYSIJA); ?></a>&nbsp;<?php }else{ ?>
242
+ <?php if(!empty($product['config_url'])){ ?><a href="<?php echo $product['config_url']; ?>" class="mailpoet-configure-button button-secondary"><?php _e('Configure', WYSIJA); ?></a><?php } // end if ?>
243
+ <?php
244
+ }
245
+ }
246
+ } // end if plugin is installed. ?>
247
+ </div>
248
+ </div>
249
+ </div>
250
+ <?php
251
+ } // end if local is yes.
252
+ }
253
+ ?>
254
+ </div><!-- .module-container -->
255
+ <?php
256
  }
257
+
258
  } // end class
259
 
260
  /**
268
  $mailpoet_add_ons->init_mail_poet_add_ons();
269
  $mailpoet_add_ons->add_ons_page();
270
  }
271
+ load_add_ons_manager();
272
+ ?>
classes/WJ_Export.php CHANGED
@@ -182,8 +182,7 @@ class WJ_Export extends WYSIJA_object {
182
 
183
  $rows_count = count( $data );
184
 
185
- // As required in Wysija/plugin#798 removed BOM from file
186
- // fwrite( $this->_file_handle, "\xEF\xBB\xBF" );
187
 
188
  // append content to the file
189
  foreach ( $data as $k => $row ) {
182
 
183
  $rows_count = count( $data );
184
 
185
+ fwrite( $this->_file_handle, "\xEF\xBB\xBF" );
 
186
 
187
  // append content to the file
188
  foreach ( $data as $k => $row ) {
classes/WJ_Import.php CHANGED
@@ -120,10 +120,7 @@ class WJ_Import extends WYSIJA_object {
120
  'type' => $maybe_newfield[1],
121
  'required' => false,
122
  'settings' => array(
123
- 'label' => $maybe_newfield[2],
124
- 'date_type' => 'year_month_day',
125
- 'is_default_today' => 0,
126
- 'date_order' => 'mm/dd/yyyy'
127
  )
128
  ));
129
 
120
  'type' => $maybe_newfield[1],
121
  'required' => false,
122
  'settings' => array(
123
+ 'label' => $maybe_newfield[2]
 
 
 
124
  )
125
  ));
126
 
classes/WJ_Upgrade.php CHANGED
@@ -32,11 +32,7 @@ class WJ_Upgrade extends WYSIJA_object {
32
  }
33
 
34
  public function update_warning() {
35
- if ( ! is_admin() ){
36
- return;
37
- }
38
-
39
- if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
40
  return;
41
  }
42
 
32
  }
33
 
34
  public function update_warning() {
35
+ if ( ! is_admin() ){
 
 
 
 
36
  return;
37
  }
38
 
controllers/ajax/campaigns.php CHANGED
@@ -2,1003 +2,943 @@
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_control_back_campaigns extends WYSIJA_control{
4
 
5
- function WYSIJA_control_back_campaigns(){
6
- if(!WYSIJA::current_user_can('wysija_newsletters')) die('Action is forbidden.');
7
- parent::WYSIJA_control();
8
- }
9
-
10
- function save_poll(){
11
- $model_config = WYSIJA::get('config','model');
12
- $model_config->save(array('poll_origin' => $_REQUEST['how'] , 'poll_origin_url' => $_REQUEST['where']));
13
-
14
- $res['result'] = true;
15
- $res['msg'] = '<span><span class="checkmark">---</span>'. __('Thanks!',WYSIJA). '</span>';
16
- return $res;
17
- }
18
-
19
- function search_terms( $request = null ){
20
- $response = (object) array(
21
- 'status' => false,
22
- 'message' => __( 'Your request has failed', WYSIJA ),
23
- 'results' => array(),
24
- 'more' => true,
25
- );
26
-
27
- if ( ( ! defined( 'DOING_AJAX' ) && is_null( $request ) ) || ! is_user_logged_in() ){
28
- return $response;
29
- }
30
-
31
- $request = (object) wp_parse_args(
32
- $request,
33
- array(
34
- 'search' => isset( $_GET['search'] ) ? $_GET['search'] : '',
35
- 'post_type' => isset( $_GET['post_type'] ) ? $_GET['post_type'] : null,
36
- 'page' => absint( isset( $_GET['page'] ) ? $_GET['page'] : 0 ),
37
- 'page_limit' => absint( isset( $_GET['page_limit'] ) ? $_GET['page_limit'] : 10 ),
38
- )
39
- );
40
-
41
- if ( is_null( $request->post_type ) ){
42
- return $response;
43
- }
44
-
45
- $response->status = true;
46
- $response->message = __( 'Request successful', WYSIJA );
47
-
48
- $response->post_type = get_post_types( array( 'name' => $request->post_type ) );
49
- $response->post_type = reset( $response->post_type );
50
-
51
- preg_match( '/@(\w+)/i', $request->search, $response->regex );
52
-
53
- if ( ! empty( $response->regex ) ){
54
- $request->search = array_filter( array_map( 'trim', explode( '|', str_replace( $response->regex[0], '|', $request->search ) ) ) );
55
- $request->search = reset( $request->search );
56
- $taxonomies = $response->regex[1];
57
- } else {
58
- $taxonomies = get_object_taxonomies( $response->post_type );
59
- }
60
- $response->taxonomies = get_object_taxonomies( $response->post_type, 'objects' );
61
-
62
- $response->results = get_terms(
63
- (array) $taxonomies,
64
- array(
65
- 'hide_empty' => false,
66
- 'search' => $request->search,
67
- 'number' => $request->page_limit,
68
- 'offset' => $request->page_limit * ( $request->page - 1 ),
69
- )
70
- );
71
-
72
- if ( empty( $response->results ) || count( $response->results ) < $request->page_limit ){
73
- $response->more = false;
74
- }
75
-
76
- return $response;
77
- }
78
-
79
- function switch_theme() {
80
- if(isset($_POST['wysijaData'])) {
81
- $rawData = $_POST['wysijaData'];
82
- // avoid using stripslashes as it's not reliable depending on the magic quotes settings
83
- $rawData = str_replace('\"', '"', $rawData);
84
- // decode JSON data
85
- $rawData = json_decode($rawData, true);
86
-
87
- $theme = (isset($rawData['theme'])) ? $rawData['theme'] : 'default';
88
-
89
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
90
- $res['templates'] = $helper_wj_engine->renderTheme($theme);
91
-
92
- $email_id = (int)$_REQUEST['id'];
93
-
94
- $campaignsHelper = WYSIJA::get('campaigns', 'helper');
95
-
96
- if(isset($res['templates']['divider_options'])) {
97
- // save divider
98
- $campaignsHelper->saveParameters($email_id, 'divider', $res['templates']['divider_options']);
99
- }
100
-
101
- // save theme used
102
- $campaignsHelper->saveParameters($email_id, 'theme', $theme);
103
-
104
- $res['templates']['theme'] = $theme;
105
- $res['styles'] = $helper_wj_engine->renderThemeStyles($theme);
106
- } else {
107
- $res['msg'] = __("The theme you selected could not be loaded.",WYSIJA);
108
- $res['result'] = false;
109
- }
110
- return $res;
111
- }
112
-
113
- function save_editor() {
114
- // decode json data and convert to array
115
- $rawData = '';
116
- if(isset($_POST['wysijaData'])) {
117
- $rawData = $_POST['wysijaData'];
118
- // avoid using stripslashes as it's not reliable depending on the magic quotes settings
119
- $rawData = str_replace('\"', '"', $rawData);
120
- // decode JSON data
121
- $rawData = json_decode($rawData, true);
122
- }
123
-
124
- if(!$rawData){
125
- $this->error('Error saving',false);
126
- return array('result' => false);
127
- }
128
-
129
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
130
- $helper_wj_engine->setData($rawData);
131
- $result = false;
132
-
133
- // get email id
134
- $email_id = (int)$_REQUEST['id'];
135
-
136
- $model_email = WYSIJA::get('email', 'model');
137
- $emailData = $model_email->getOne(array('wj_styles', 'subject', 'params', 'email_id', 'campaign_id'), array('email_id' => $email_id));
138
-
139
- $helper_wj_engine->setStyles($emailData['wj_styles'], true);
140
-
141
- $values = array('wj_data' => $helper_wj_engine->getEncoded('data'));
142
- $values['body'] = $helper_wj_engine->renderEmail($emailData);
143
- $values['email_id'] = $email_id;
144
-
145
- $updated_email = $helper_wj_engine->getEmailData();
146
-
147
- // update modified_at timestamp
148
- $model_email->columns['modified_at']['autoup']=1;
149
-
150
- // update data in DB
151
- $result = $model_email->update($values, array('email_id' => $email_id));
152
-
153
- if(!$result) {
154
- // throw error
155
- $this->error(__('Your email could not be saved', WYSIJA));
156
- } else {
157
- // save successful
158
- $this->notice(__('Your email has been saved', WYSIJA));
159
- }
160
-
161
- return array('result' => $result);
162
- }
163
-
164
- function save_styles() {
165
- // decode json data and convert to array
166
- $rawData = '';
167
- if(isset($_POST['wysijaStyles'])) {
168
- $rawData = $_POST['wysijaStyles'];
169
- // avoid using stripslashes as it's not reliable depending on the magic quotes settings
170
- $rawData = str_replace('\"', '"', $rawData);
171
- // decode JSON data
172
- $rawData = json_decode($rawData, true);
173
-
174
- }
175
-
176
- // handle checkboxes
177
- if(array_key_exists('a-underline', $rawData) === false) {
178
- $rawData['a-underline'] = -1;
179
- }
180
-
181
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
182
- $helper_wj_engine->setStyles($helper_wj_engine->formatStyles($rawData));
183
-
184
- $result = false;
185
-
186
- $values = array(
187
- 'wj_styles' => $helper_wj_engine->getEncoded('styles')
188
- );
189
-
190
- // get email id
191
- $email_id = (int)$_REQUEST['id'];
192
-
193
- // update data in DB
194
- $model_email = WYSIJA::get('email', 'model');
195
- $result = $model_email->update($values, array('email_id' => $email_id));
196
-
197
- if(!$result) {
198
- // throw error
199
- $this->error(__('Styles could not be saved', WYSIJA));
200
- } else {
201
- // save successful
202
- $this->notice(__('Styles have been saved', WYSIJA));
203
- }
204
-
205
- return array(
206
- 'styles' => $helper_wj_engine->renderStyles(),
207
- 'result' => $result
208
- );
209
- }
210
-
211
- function deleteimg(){
212
-
213
- if(isset($_REQUEST['imgid']) && $_REQUEST['imgid']>0){
214
- /* delete the image with id imgid */
215
- $result=wp_delete_attachment($_REQUEST['imgid'],true);
216
- if($result){
217
- $this->notice(__('Image has been deleted.',WYSIJA));
218
- }
219
- }
220
-
221
- $res=array();
222
- $res['result'] = $result;
223
- return $res;
224
- }
225
-
226
- function deleteTheme(){
227
- if(isset($_REQUEST['themekey']) && $_REQUEST['themekey']){
228
- /* delete the image with id imgid */
229
- $helperTheme=WYSIJA::get('themes','helper');
230
- $result=$helperTheme->delete($_REQUEST['themekey']);
231
- }
232
-
233
- $res=array();
234
- $res['result'] = $result;
235
- return $res;
236
- }
237
-
238
- // set newsletter default theme
239
- function setDefaultTheme() {
240
- if(isset($_REQUEST['theme']) && $_REQUEST['theme']) {
241
- // check that the theme exists
242
- // TODO
243
- $theme_exists = true;
244
- if($theme_exists === true) {
245
- // update config
246
- $model_config = WYSIJA::get('config', 'model');
247
- $model_config->save(array('newsletter_default_theme' => $_REQUEST['theme']));
248
-
249
- $result = true;
250
- } else {
251
- $result = false;
252
- }
253
- }
254
-
255
- return array('result' => $result);
256
- }
257
-
258
- function save_IQS() {
259
- // decode json data and convert to array
260
- $wysijaIMG = '';
261
- if(isset($_POST['wysijaIMG'])) {
262
- $wysijaIMG = json_decode(stripslashes($_POST['wysijaIMG']), TRUE);
263
- }
264
- $values = array(
265
- 'params' => array('quickselection'=>$wysijaIMG)
266
- );
267
-
268
- // get email id
269
- $email_id = (int)$_REQUEST['id'];
270
- $values['email_id']=$email_id;
271
-
272
- // update data in DB
273
- $model_email = WYSIJA::get('email', 'model');
274
- $result = $model_email->update($values, array('email_id' => $email_id));
275
-
276
- if(!$result) {
277
- // throw error
278
- $this->error(__('Image selection has not been saved.', WYSIJA));
279
- } else {
280
- // save successful
281
- $this->notice(__('Image selection has been saved.', WYSIJA));
282
- }
283
-
284
- return array('result' => $result);
285
- }
286
-
287
-
288
- function view_NL() {
289
- // get campaign id
290
- $email_id = (int)$_REQUEST['id'];
291
-
292
- // update data in DB
293
- $model_email = WYSIJA::get('email', 'model');
294
- $result = $model_email->getOne(false,array('email_id' => $email_id));
295
-
296
- echo $result['body'];
297
- exit;
298
- }
299
-
300
- function display_NL() {
301
- // get email id
302
- $email_id = (int)$_REQUEST['id'];
303
-
304
- // update data in DB
305
- $model_email = WYSIJA::get('email', 'model');
306
- $email= $model_email->getOne(false,array('email_id' => $email_id));
307
-
308
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
309
- $helper_wj_engine->setStyles($result['wj_styles'], true);
310
- $helper_wj_engine->setData($result['wj_data'], true);
311
- $html = $helper_wj_engine->renderEmail($email);
312
- print $html;
313
- exit;
314
- }
315
-
316
- /**
317
- * returns the images attached to displayed posts
318
- */
319
- function get_post_images() {
320
- // get parameters
321
- $params = array(
322
-
323
- );
324
-
325
- $result = true;
326
-
327
- if($params['post_id'] === null) {
328
-
329
- }
330
-
331
- return array(
332
- 'result' => $result,
333
- 'images' => $images
334
- );
335
- }
336
-
337
- /**
338
- * returns a list of articles to the popup in the visual editor
339
- * @global type $wpdb
340
- * @return boolean
341
- */
342
- function get_articles(){
343
- // fixes issue with pcre functions
344
- @ini_set('pcre.backtrack_limit', 1000000);
345
-
346
- // get parameters
347
- $raw_data = $_REQUEST['data'];
348
- $params = array();
349
- foreach ($raw_data as $value) {
350
- $params[$value['name']] = $value['value'];
351
- }
352
-
353
- // get options
354
- $model_config = WYSIJA::get('config', 'model');
355
- $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
356
-
357
- // post statuses
358
- $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
359
- $post_statuses = $helper_wp_tools->get_post_statuses();
360
- $post_types = $helper_wp_tools->get_post_types();
361
-
362
- // filter by post_type
363
- if(isset($params['post_type'])) {
364
- $post_types_filter = array();
365
- if(strlen(trim($params['post_type'])) === 0) {
366
- $post_types_filter = array_keys($post_types);
367
- $post_types_filter[] = 'post';
368
- $post_types_filter[] = 'page';
369
- } else {
370
- $post_types_filter = trim($params['post_type']);
371
- }
372
- // set condition on post type
373
- $params['post_type'] = $post_types_filter;
374
- }
375
-
376
- // query offset when doing incremental loading
377
- $query_offset = (isset($_REQUEST['query_offset']) && (int)$_REQUEST['query_offset'] >= 0) ? (int)$_REQUEST['query_offset'] : 0;
378
- $params['query_offset'] = $query_offset;
379
-
380
- // fetch posts
381
- $helper_articles = WYSIJA::get('articles', 'helper');
382
-
383
- // set is_search_query (true) to get a count in addition to the results
384
- $params['is_search_query'] = true;
385
-
386
- $model_wp_posts = WYSIJA::get('wp_posts','model');
387
- $data = $model_wp_posts->get_posts($params);
388
-
389
- // extract data
390
- $posts = $data['rows'];
391
- // contains the total number of rows available
392
- $count = $data['count'];
393
-
394
- // return results
395
- $result = array(
396
- 'result' => true,
397
- 'append' => ($query_offset > 0)
398
- );
399
-
400
- if(empty($posts) === false) {
401
- foreach($posts as $key => $post) {
402
- // interpret shortcodes
403
- if($interpret_shortcode === true) {
404
- $posts[$key]['post_content'] = apply_filters('the_content', $posts[$key]['post_content']);
405
- }
406
-
407
- // get thumbnail
408
- $posts[$key]['post_image'] = $helper_articles->getImage($post);
409
-
410
- // set post status
411
- $post_status_label = '';
412
- if(isset($post_statuses[$posts[$key]['post_status']])) {
413
- $post_status_label = $post_statuses[$posts[$key]['post_status']];
414
- }
415
- $posts[$key]['post_status'] = $post_status_label;
416
- }
417
- $result['posts'] = $posts;
418
- $result['total'] = (int)$count['total'];
419
- }else {
420
- $result['msg'] = __('There are no posts corresponding to that search.', WYSIJA);
421
- $result['result'] = false;
422
- }
423
-
424
- return $result;
425
- }
426
-
427
- function insert_articles() {
428
- // get raw params
429
- $raw_params = $_REQUEST['data'];
430
-
431
- // format params
432
- $params = array();
433
- foreach($raw_params as $value) {
434
- $params[$value['name']] = $value['value'];
435
- }
436
-
437
- if($params['show_divider'] === 'yes') {
438
- // get divider
439
- $divider = $_REQUEST['divider'];
440
- } else {
441
- $divider = null;
442
- }
443
- $params['divider'] = $divider;
444
-
445
- // get post ids
446
- $post_ids = array();
447
- if(isset($_REQUEST['post_ids']) && strlen(trim($_REQUEST['post_ids'])) > 0) {
448
- $post_ids = explode(',', $_REQUEST['post_ids']);
449
- }
450
-
451
- if(empty($post_ids)) {
452
- // return error
453
- $res['msg'] = __('Please select an article.', WYSIJA);
454
- $res['result'] = false;
455
- return $res;
456
- }
457
-
458
- // specify custom fields to get from posts
459
- $post_params = array('include' => $post_ids);
460
-
461
- // include sort by parameter into post params
462
- $post_params['sort_by'] = $params['sort_by'];
463
-
464
- // get posts
465
- $model_wp_posts = WYSIJA::get('wp_posts', 'model');
466
- $posts = $model_wp_posts->get_posts($post_params);
467
-
468
- // check if we need to interpret shortcodes
469
- $model_config = WYSIJA::get('config', 'model');
470
- $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
471
-
472
- // get some model and helpers
473
- $helper_articles = WYSIJA::get('articles', 'helper');
474
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
475
-
476
- $output = '';
477
-
478
- // save parameters for next time
479
- $model_config->save(array('insert_post_parameters' => $helper_wj_engine->encodeParameters($params)));
480
-
481
- foreach($posts as $key => $post) {
482
- if($interpret_shortcode === true) {
483
- // interpret shortcodes
484
- $posts[$key]['post_content'] = apply_filters('the_content', $post['post_content']);
485
- }
486
- // get thumbnail
487
- $posts[$key]['post_image'] = $helper_articles->getImage($post);
488
- }
489
-
490
- $output .= base64_encode($helper_wj_engine->renderPostsToBlocks($posts, $params));
491
-
492
- if(strlen($output) > 0) {
493
- $res['result'] = true;
494
- $res['posts'] = $output;
495
- }else {
496
- $res['msg'] = __('There are no posts corresponding to that search.',WYSIJA);
497
- $res['result'] = false;
498
- }
499
-
500
- return $res;
501
- }
502
-
503
- function send_preview($spamtest=false){
504
- $mailer=WYSIJA::get('mailer','helper');
505
- $email_id = $_REQUEST['id'];
506
- $resultarray=array();
507
-
508
- // update data in DB
509
- $model_email = WYSIJA::get('email', 'model');
510
- $model_email->getFormat=OBJECT;
511
- $email_object = $model_email->getOne(false,array('email_id' => $email_id));
512
- $mailer->testemail=true;
513
-
514
-
515
- if(isset($_REQUEST['data'])){
516
- $dataTemp=$_REQUEST['data'];
517
- $_REQUEST['data']=array();
518
- foreach($dataTemp as $val) $_REQUEST['data'][$val['name']]=$val['value'];
519
- unset($dataTemp);
520
- foreach($_REQUEST['data'] as $k =>$v){
521
- $newkey=str_replace(array('wysija[email][',']'),'',$k);
522
- $configVal[$newkey]=$v;
523
- }
524
- if(isset($configVal['from_name'])){
525
- $params=array(
526
- 'from_name'=>$configVal['from_name'],
527
- 'from_email'=>$configVal['from_email'],
528
- 'replyto_name'=>$configVal['replyto_name'],
529
- 'replyto_email'=>$configVal['replyto_email']);
530
- if(isset($configVal['subject'])) $email_object->subject=$configVal['subject'];
531
- }
532
-
533
- }else{
534
- $params=array(
535
- 'from_name'=>$email_object->from_name,
536
- 'from_email'=>$email_object->from_email,
537
- 'replyto_name'=>$email_object->replyto_name,
538
- 'replyto_email'=>$email_object->replyto_email
539
- );
540
- }
541
- if(strpos($_REQUEST['receiver'], ',')) {
542
- $receivers = explode(',',$_REQUEST['receiver']);
543
- } else if(strpos($_REQUEST['receiver'], ';')) {
544
- $receivers = explode(';',$_REQUEST['receiver']);
545
- } else {
546
- $receivers = array($_REQUEST['receiver']);
547
- }
548
-
549
- $user_model = WYSIJA::get('user', 'model');
550
- foreach($receivers as $key => $receiver){
551
- $receiver = trim($receiver);
552
- $dummy_receiver = $user_model->get_object_by_email($receiver);
553
- if(empty($dummy_receiver)){
554
- $dummy_receiver = new stdClass();
555
- $dummy_receiver->user_id = 0;
556
- $dummy_receiver->email = $receiver;
557
- $dummy_receiver->status = 1;
558
- $dummy_receiver->lastname = $dummy_receiver->firstname = '';
559
- }
560
-
561
- if($spamtest){
562
- $langextra = '';
563
- $dummy_receiver->firstname ='Mail Tester';
564
-
565
- $wp_lang = get_locale();
566
- if(!empty($wp_lang)) $langextra ='&lang='.$wp_lang;
567
- $resultarray['urlredirect']='http://www.mail-tester.com/check.php?id='.urlencode($dummy_receiver->email).$langextra;
568
- }
569
- $receivers[$key] = $dummy_receiver;
570
-
571
- }
572
-
573
- $email_clone=array();
574
- foreach($email_object as $kk=>$vv) $email_clone[$kk]=$vv;
575
-
576
-
577
- $wj_engine = WYSIJA::get('wj_engine', 'helper');
578
- // set data & styles
579
- if(isset($email_clone['wj_data'])) { $wj_engine->setData($email_clone['wj_data'], true); } else { $wj_engine->setData(); }
580
- if(isset($email_clone['wj_styles'])) { $wj_engine->setStyles($email_clone['wj_styles'], true); } else { $wj_engine->setStyles(); }
581
-
582
- // generate email html body
583
- $body = $wj_engine->renderEmail($email_clone);
584
-
585
- // get back email data as it will be updated during the rendering (articles ids + articles count)
586
- $email_child = $wj_engine->getEmailData();
587
-
588
- // [total] [number] and [post_title] are only valid for post notifications newsletter
589
- if((int)$email_child['type'] === 2 && isset($email_child['params']['autonl']['event']) &&
590
- $email_child['params']['autonl']['event'] === 'new-articles' && isset($email_child['params']['autonl']['articles'])){
591
-
592
- $item_count = 0;
593
- $total_count = 1;
594
- $first_subject = '';
595
-
596
- if(isset($email_child['params']['autonl']['articles']['count'])) $item_count = (int)$email_child['params']['autonl']['articles']['count'];
597
- if(isset($email_child['params']['autonl']['articles']['first_subject'])) $first_subject = $email_child['params']['autonl']['articles']['first_subject'];
598
- if(isset($email_child['params']['autonl']['total_child'])) $total_count = (int)$email_child['params']['autonl']['total_child'] + 1;
599
-
600
- $email_object->subject = str_replace(
601
- array('[total]','[number]','[post_title]'),
602
- array($item_count, $total_count, $first_subject),
603
- $email_child['subject']
604
- );
605
- }
606
- $successmsg = __('Your email preview has been sent to %1$s', WYSIJA);
607
-
608
- // correction added for post notifications with the tag [newsletter:post_title] failing to send
609
- if(isset($email_object->params['autonl']) && isset($email_child['params']['autonl'])){
610
- $email_object->params['autonl']=$email_child['params']['autonl'];
611
- }
612
-
613
- if(isset($email_object->params)) {
614
- $params['params']=$email_object->params;
615
-
616
- if(isset($configVal['params[googletrackingcode'])){
617
- $paramsemail=array();
618
- if(!is_array($email_object->params)) $paramsemail=unserialize(base64_decode($email_object->params));
619
-
620
- if(trim($configVal['params[googletrackingcode'])) {
621
- $paramsemail['googletrackingcode']=$configVal['params[googletrackingcode'];
622
- }
623
- else {
624
- unset($paramsemail['googletrackingcode']);
625
- }
626
- $params['params'] = base64_encode(serialize($paramsemail));
627
- }
628
- }
629
-
630
- $params['email_id'] = $email_object->email_id;
631
- $receiversList = array();
632
- $res = false;
633
- foreach($receivers as $receiver){
634
- if($mailer->sendSimple($receiver, stripslashes($email_object->subject),$email_object->body,$params)) {
635
- $res = true;
636
- $receiversList[] = $receiver->email;
637
- }
638
- WYSIJA::log('preview_sent', $mailer, 'manual');
639
- }
640
-
641
- if($res === true) {
642
- $this->notice(sprintf($successmsg, implode(', ', $receiversList)));
643
- }
644
-
645
- $resultarray['result'] = $res;
646
-
647
- return $resultarray;
648
- }
649
-
650
- /**
651
- * send spam test function step 2 of the newsletter edition process
652
- */
653
- function send_spamtest(){
654
- return apply_filters('wysija_send_spam_test','',$this);
655
- }
656
-
657
- function set_divider()
658
- {
659
- $src = isset($_POST['wysijaData']['src']) ? $_POST['wysijaData']['src'] : NULL;
660
- $width = isset($_POST['wysijaData']['width']) ? (int)$_POST['wysijaData']['width'] : NULL;
661
- $height = isset($_POST['wysijaData']['height']) ? (int)$_POST['wysijaData']['height'] : NULL;
662
-
663
- if($src === NULL OR $width === NULL OR $height === NULL) {
664
- // there is a least one missing parameter, fallback to default divider
665
- $dividersHelper = WYSIJA::get('dividers', 'helper');
666
- $divider = $dividersHelper->getDefault();
667
- } else {
668
- // use provided params
669
- $divider = array(
670
- 'src' => $src,
671
- 'width' => $width,
672
- 'height' => $height
673
- );
674
- }
675
-
676
- // update campaign parameters
677
- $email_id = (int)$_REQUEST['id'];
678
- $campaignsHelper = WYSIJA::get('campaigns', 'helper');
679
- $campaignsHelper->saveParameters($email_id, 'divider', $divider);
680
-
681
- // set params
682
- $block = array_merge(array('no-block' => true, 'type' => 'divider'), $divider);
683
-
684
- $helper_wj_engine=WYSIJA::get('wj_engine','helper');
685
- return base64_encode($helper_wj_engine->renderEditorBlock($block));
686
- }
687
-
688
- function get_social_bookmarks() {
689
- $size = isset($_POST['wysijaData']['size']) ? $_POST['wysijaData']['size'] : NULL;
690
- $theme = isset($_POST['wysijaData']['theme']) ? $_POST['wysijaData']['theme'] : NULL;
691
-
692
- $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
693
- $bookmarks = $bookmarksHelper->getAll($size, $theme);
694
- return json_encode(array('icons' => $bookmarks));
695
- }
696
-
697
- function generate_social_bookmarks() {
698
-
699
- $size = 'medium';
700
- $iconset = '01';
701
-
702
- if(isset($_POST['wysijaData']) && !empty($_POST['wysijaData'])) {
703
- $data = $_POST['wysijaData'];
704
- $items = array();
705
-
706
- foreach($data as $key => $values) {
707
- if($values['name'] === 'bookmarks-size') {
708
- // get size
709
- $size = $values['value'];
710
- } else if($values['name'] === 'bookmarks-theme') {
711
- // get theme name
712
- $theme = $values['value'];
713
- } else if($values['name'] === 'bookmarks-iconset') {
714
- // get iconset
715
- $iconset = $values['value'];
716
- if(strlen(trim($iconset)) === 0) {
717
- $this->error('No iconset specified', false);
718
- return false;
719
- }
720
- } else {
721
- $keys = explode('-', $values['name']);
722
- $network = $keys[1];
723
- $property = $keys[2];
724
- if(array_key_exists($network, $items)) {
725
- $items[$network][$property] = $values['value'];
726
- } else {
727
- $items[$network] = array($property => $values['value']);
728
- }
729
- }
730
- }
731
- }
732
-
733
- $urls = array();
734
- // check data and remove network with an empty url
735
- foreach($items as $network => $item) {
736
- if(strlen(trim($item['url'])) === 0) {
737
- // empty url
738
- unset($items[$network]);
739
- } else {
740
- // url specified
741
- $urls[$network] = $item['url'];
742
- }
743
- }
744
-
745
- // check if there's at least one url left
746
- if(empty($urls)) {
747
- $this->error('No url specified', false);
748
- return false;
749
- }
750
-
751
- // save url in config
752
- $config=WYSIJA::get('config','model');
753
- $config->save(array('social_bookmarks' => $urls));
754
-
755
- // get iconset icons
756
- $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
757
-
758
- // if the iconset is 00, then it's the theme's bookmarks
759
- if($iconset === '00') {
760
- $icons = $bookmarksHelper->getAllByTheme($theme);
761
- } else {
762
- // otherwise it's a basic iconset
763
- $icons = $bookmarksHelper->getAllByIconset($size, $iconset);
764
- }
765
-
766
-
767
- // format data
768
- $block = array(
769
- 'position' => 1,
770
- 'type' => 'gallery',
771
- 'items' => array(),
772
- 'alignment' => 'center'
773
- );
774
-
775
- $width = 0;
776
- foreach($items as $key => $item) {
777
- $block['items'][] = array_merge($item, $icons[$key], array('alt' => ucfirst($key)));
778
- $width += (int)$icons[$key]['width'];
779
- }
780
- // add margin between icons
781
- $width += (count($block['items']) - 1) * 10;
782
- // set optimal width
783
- $block['width'] = max(0, min($width, 564));
784
-
785
- $helper_wj_engine=WYSIJA::get('wj_engine','helper');
786
- return base64_encode($helper_wj_engine->renderEditorBlock($block));
787
- }
788
-
789
- function install_theme() {
790
- if( isset($_REQUEST['theme_id'])){
791
- global $wp_version;
792
- //check if theme is premium if you have the premium licence
793
- if(isset($_REQUEST['premium']) && $_REQUEST['premium']){
794
- $getpremiumtheme=apply_filters('wysija_install_theme_premium', false);
795
-
796
- if(!$getpremiumtheme){
797
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
798
- $themes = $helper_wj_engine->renderThemes();
799
- return array('result'=>false, 'themes' => $themes);
800
- }
801
- }
802
-
803
- $helperToolbox = WYSIJA::get('toolbox','helper');
804
- $domain_name = $helperToolbox->_make_domain_name(admin_url('admin.php'));
805
-
806
- $request = 'http://api.mailpoet.com/download/zip/'.$_REQUEST['theme_id'].'?domain='.$domain_name;
807
-
808
- $args = array(
809
- 'timeout' => 30,
810
- 'body' => array( ),
811
  'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
812
- );
813
- $raw_response = wp_remote_post( $request, $args );
814
-
815
- if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ){
816
- if(method_exists($raw_response, 'get_error_messages')){
817
- $this->error($raw_response->get_error_messages());
818
- }
819
- $ZipfileResult = false;
820
- }else{
821
- $ZipfileResult = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
822
- }
823
-
824
- if($ZipfileResult === false){
825
- $result = false;
826
- $this->error(__('We were unable to contact the API, the site may be down. Please try again later.',WYSIJA),true);
827
- }else{
828
- $themesHelp=WYSIJA::get('themes','helper');
829
- $result = $themesHelp->installTheme($ZipfileResult);
830
-
831
- // refresh themes list
832
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
833
- $themes = $helper_wj_engine->renderThemes();
834
- }
835
- }else{
836
- $result = false;
837
- $themes = '';
838
- $this->notice('missing info');
839
- }
840
-
841
- return array('result' => $result, 'themes' => $themes);
842
- }
843
-
844
- function refresh_themes() {
845
- // refresh themes list
846
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
847
- return array('result'=>true, 'themes' => $helper_wj_engine->renderThemes());
848
- }
849
-
850
- function generate_auto_post() {
851
- // get params and generate html
852
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
853
- $helper_articles = WYSIJA::get('articles', 'helper');
854
-
855
- // get parameters
856
- $block_params = array();
857
- if(isset($_POST['wysijaData'])) {
858
- // store category ids (TBR)
859
- $category_ids = array();
860
-
861
- foreach($_POST['wysijaData'] as $pairs) {
862
- // special cases
863
- switch($pairs['name']) {
864
- case 'author_label':
865
- case 'category_label':
866
- case 'readmore':
867
- case 'nopost_message':
868
- $block_params[] = array('key' => $pairs['name'], 'value' => base64_encode(stripslashes($pairs['value'])));
869
- break;
870
- case 'category_ids':
871
- $category_ids = array_filter( array_map( 'absint', explode( ',', $pairs['value'] ) ) );
872
- break;
873
- default:
874
- $block_params[] = array('key' => $pairs['name'], 'value' => $pairs['value']);
875
- }
876
- }
877
-
878
- // make sure we have only unique ids in categories
879
- $block_params[] = array('key' => 'category_ids', 'value' => join(',', array_unique($category_ids)));
880
- }
881
-
882
- if(empty($block_params)) {
883
- // an error occurred, do something!
884
- return false;
885
- } else {
886
- $data = array(
887
- 'type' => 'auto-post',
888
- 'params' => $block_params
889
- );
890
- return base64_encode($helper_wj_engine->renderEditorBlock($data));
891
- }
892
- }
893
-
894
- function load_auto_post() {
895
- $params = array();
896
-
897
- if(isset($_POST['wysijaData'])) {
898
-
899
- $pairs = explode('&', $_POST['wysijaData']);
900
-
901
- foreach($pairs as $pair) {
902
- list($key, $value) = explode('=', $pair);
903
- switch($key) {
904
- case 'autopost_count':
905
- $params[$key] = (int)$value;
906
- break;
907
- case 'readmore':
908
- case 'author_label':
909
- case 'category_label':
910
- case 'nopost_message':
911
- $params[$key] = base64_decode($value);
912
- break;
913
- case 'exclude':
914
- $params[$key] = explode(',', $value);
915
- break;
916
- default:
917
- $params[$key] = $value;
918
- }
919
- }
920
- }
921
-
922
- if(empty($params)) {
923
- // an error occurred, do something!
924
- return false;
925
- } else {
926
-
927
- // get email params
928
- $email_id = (int)$_REQUEST['id'];
929
- $model_email = WYSIJA::get('email', 'model');
930
- $email = $model_email->getOne(array('params','sent_at','campaign_id'), array('email_id' => $email_id));
931
-
932
- $helper_articles = WYSIJA::get('articles', 'helper');
933
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
934
-
935
- // see if posts have already been sent
936
- if(!empty($email['params']['autonl']['articles']['ids'])) {
937
- if(!isset($params['exclude'])) { $params['exclude'] = array(); }
938
-
939
- $params['exclude'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $params['exclude']));
940
- }
941
-
942
- //we set the post_date to filter articles only older than that one
943
- if(isset($email['params']['autonl']['firstSend'])){
944
- $params['post_date'] = $email['params']['autonl']['firstSend'];
945
- }
946
-
947
- // if immediate let it know to the get post
948
- if(isset($email['params']['autonl']['articles']['immediatepostid'])){
949
- $params['include'] = $email['params']['autonl']['articles']['immediatepostid'];
950
- $params['post_limit'] = 1;
951
- }else{
952
- //we set the post_date to filter articles only older than the last time we sent articles
953
- if(isset($email['params']['autonl']['lastSend'])){
954
- $params['post_date'] = $email['params']['autonl']['lastSend'];
955
- }else{
956
- //get the latest child newsletter sent_at value
957
- $mEmail=WYSIJA::get('email','model');
958
- $mEmail->reset();
959
- $mEmail->orderBy('email_id','DESC');
960
- $lastEmailSent=$mEmail->getOne(false,array('campaign_id'=>$email['campaign_id'],'type'=>'1'));
961
-
962
- if(!empty($lastEmailSent)) $params['post_date'] = $lastEmailSent['sent_at'];
963
- }
964
- }
965
-
966
- // get posts
967
- $model_wp_posts = WYSIJA::get('wp_posts','model');
968
- $posts = $model_wp_posts->get_posts($params);
969
-
970
- if(empty($posts)) {
971
- // nothing to display
972
- $posts = array();
973
- } else {
974
- // used to keep track of post ids present in the auto post
975
- $post_ids = array();
976
-
977
- // cleanup post and get image
978
- foreach($posts as $key => $post) {
979
- if($params['image_alignment'] !== 'none') {
980
- // attempt to get post image
981
- $posts[$key]['post_image'] = $helper_articles->getImage($post);
982
- }
983
-
984
- // store article id
985
- $post_ids[] = $post['ID'];
986
- }
987
- // store article ids
988
- $params['post_ids'] = join(',', $post_ids);
989
- }
990
-
991
- // get divider if necessary (for immediate post notification, the "show_divider" parameter is not available)
992
- if(isset($params['show_divider']) && $params['show_divider'] === 'yes') {
993
- if(isset($email['params']['divider'])) {
994
- $params['divider'] = $email['params']['divider'];
995
- } else {
996
- $helper_dividers = WYSIJA::get('dividers', 'helper');
997
- $params['divider'] = $helper_dividers->getDefault();
998
- }
999
- }
1000
-
1001
- return base64_encode($helper_wj_engine->renderEditorAutoPost($posts, $params));
1002
- }
1003
- }
1004
  }
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_control_back_campaigns extends WYSIJA_control{
4
 
5
+ function WYSIJA_control_back_campaigns(){
6
+ if(!WYSIJA::current_user_can('wysija_newsletters')) die('Action is forbidden.');
7
+ parent::WYSIJA_control();
8
+ }
9
+
10
+ function save_poll(){
11
+ $model_config = WYSIJA::get('config','model');
12
+ $model_config->save(array('poll_origin' => $_REQUEST['how'] , 'poll_origin_url' => $_REQUEST['where']));
13
+
14
+ $res['result'] = true;
15
+ $res['msg'] = '<span><span class="checkmark">---</span>'. __('Thanks!',WYSIJA). '</span>';
16
+ return $res;
17
+ }
18
+
19
+ function switch_theme() {
20
+ if(isset($_POST['wysijaData'])) {
21
+ $rawData = $_POST['wysijaData'];
22
+ // avoid using stripslashes as it's not reliable depending on the magic quotes settings
23
+ $rawData = str_replace('\"', '"', $rawData);
24
+ // decode JSON data
25
+ $rawData = json_decode($rawData, true);
26
+
27
+ $theme = (isset($rawData['theme'])) ? $rawData['theme'] : 'default';
28
+
29
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
30
+ $res['templates'] = $helper_wj_engine->renderTheme($theme);
31
+
32
+ $email_id = (int)$_REQUEST['id'];
33
+
34
+ $campaignsHelper = WYSIJA::get('campaigns', 'helper');
35
+
36
+ if(isset($res['templates']['divider_options'])) {
37
+ // save divider
38
+ $campaignsHelper->saveParameters($email_id, 'divider', $res['templates']['divider_options']);
39
+ }
40
+
41
+ // save theme used
42
+ $campaignsHelper->saveParameters($email_id, 'theme', $theme);
43
+
44
+ $res['templates']['theme'] = $theme;
45
+ $res['styles'] = $helper_wj_engine->renderThemeStyles($theme);
46
+ } else {
47
+ $res['msg'] = __("The theme you selected could not be loaded.",WYSIJA);
48
+ $res['result'] = false;
49
+ }
50
+ return $res;
51
+ }
52
+
53
+ function save_editor() {
54
+ // decode json data and convert to array
55
+ $rawData = '';
56
+ if(isset($_POST['wysijaData'])) {
57
+ $rawData = $_POST['wysijaData'];
58
+ // avoid using stripslashes as it's not reliable depending on the magic quotes settings
59
+ $rawData = str_replace('\"', '"', $rawData);
60
+ // decode JSON data
61
+ $rawData = json_decode($rawData, true);
62
+ }
63
+
64
+ if(!$rawData){
65
+ $this->error('Error saving',false);
66
+ return array('result' => false);
67
+ }
68
+
69
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
70
+ $helper_wj_engine->setData($rawData);
71
+ $result = false;
72
+
73
+ // get email id
74
+ $email_id = (int)$_REQUEST['id'];
75
+
76
+ $model_email = WYSIJA::get('email', 'model');
77
+ $emailData = $model_email->getOne(array('wj_styles', 'subject', 'params', 'email_id', 'campaign_id'), array('email_id' => $email_id));
78
+
79
+ $helper_wj_engine->setStyles($emailData['wj_styles'], true);
80
+
81
+ $values = array('wj_data' => $helper_wj_engine->getEncoded('data'));
82
+ $values['body'] = $helper_wj_engine->renderEmail($emailData);
83
+ $values['email_id'] = $email_id;
84
+
85
+ $updated_email = $helper_wj_engine->getEmailData();
86
+
87
+ // update modified_at timestamp
88
+ $model_email->columns['modified_at']['autoup']=1;
89
+
90
+ // update data in DB
91
+ $result = $model_email->update($values, array('email_id' => $email_id));
92
+
93
+ if(!$result) {
94
+ // throw error
95
+ $this->error(__('Your email could not be saved', WYSIJA));
96
+ } else {
97
+ // save successful
98
+ $this->notice(__('Your email has been saved', WYSIJA));
99
+ }
100
+
101
+ return array('result' => $result);
102
+ }
103
+
104
+ function save_styles() {
105
+ // decode json data and convert to array
106
+ $rawData = '';
107
+ if(isset($_POST['wysijaStyles'])) {
108
+ $rawData = $_POST['wysijaStyles'];
109
+ // avoid using stripslashes as it's not reliable depending on the magic quotes settings
110
+ $rawData = str_replace('\"', '"', $rawData);
111
+ // decode JSON data
112
+ $rawData = json_decode($rawData, true);
113
+
114
+ }
115
+
116
+ // handle checkboxes
117
+ if(array_key_exists('a-underline', $rawData) === false) {
118
+ $rawData['a-underline'] = -1;
119
+ }
120
+
121
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
122
+ $helper_wj_engine->setStyles($helper_wj_engine->formatStyles($rawData));
123
+
124
+ $result = false;
125
+
126
+ $values = array(
127
+ 'wj_styles' => $helper_wj_engine->getEncoded('styles')
128
+ );
129
+
130
+ // get email id
131
+ $email_id = (int)$_REQUEST['id'];
132
+
133
+ // update data in DB
134
+ $model_email = WYSIJA::get('email', 'model');
135
+ $result = $model_email->update($values, array('email_id' => $email_id));
136
+
137
+ if(!$result) {
138
+ // throw error
139
+ $this->error(__('Styles could not be saved', WYSIJA));
140
+ } else {
141
+ // save successful
142
+ $this->notice(__('Styles have been saved', WYSIJA));
143
+ }
144
+
145
+ return array(
146
+ 'styles' => $helper_wj_engine->renderStyles(),
147
+ 'result' => $result
148
+ );
149
+ }
150
+
151
+ function deleteimg(){
152
+
153
+ if(isset($_REQUEST['imgid']) && $_REQUEST['imgid']>0){
154
+ /* delete the image with id imgid */
155
+ $result=wp_delete_attachment($_REQUEST['imgid'],true);
156
+ if($result){
157
+ $this->notice(__('Image has been deleted.',WYSIJA));
158
+ }
159
+ }
160
+
161
+ $res=array();
162
+ $res['result'] = $result;
163
+ return $res;
164
+ }
165
+
166
+ function deleteTheme(){
167
+ if(isset($_REQUEST['themekey']) && $_REQUEST['themekey']){
168
+ /* delete the image with id imgid */
169
+ $helperTheme=WYSIJA::get('themes','helper');
170
+ $result=$helperTheme->delete($_REQUEST['themekey']);
171
+ }
172
+
173
+ $res=array();
174
+ $res['result'] = $result;
175
+ return $res;
176
+ }
177
+
178
+ // set newsletter default theme
179
+ function setDefaultTheme() {
180
+ if(isset($_REQUEST['theme']) && $_REQUEST['theme']) {
181
+ // check that the theme exists
182
+ // TODO
183
+ $theme_exists = true;
184
+ if($theme_exists === true) {
185
+ // update config
186
+ $model_config = WYSIJA::get('config', 'model');
187
+ $model_config->save(array('newsletter_default_theme' => $_REQUEST['theme']));
188
+
189
+ $result = true;
190
+ } else {
191
+ $result = false;
192
+ }
193
+ }
194
+
195
+ return array('result' => $result);
196
+ }
197
+
198
+ function save_IQS() {
199
+ // decode json data and convert to array
200
+ $wysijaIMG = '';
201
+ if(isset($_POST['wysijaIMG'])) {
202
+ $wysijaIMG = json_decode(stripslashes($_POST['wysijaIMG']), TRUE);
203
+ }
204
+ $values = array(
205
+ 'params' => array('quickselection'=>$wysijaIMG)
206
+ );
207
+
208
+ // get email id
209
+ $email_id = (int)$_REQUEST['id'];
210
+ $values['email_id']=$email_id;
211
+
212
+ // update data in DB
213
+ $model_email = WYSIJA::get('email', 'model');
214
+ $result = $model_email->update($values, array('email_id' => $email_id));
215
+
216
+ if(!$result) {
217
+ // throw error
218
+ $this->error(__('Image selection has not been saved.', WYSIJA));
219
+ } else {
220
+ // save successful
221
+ $this->notice(__('Image selection has been saved.', WYSIJA));
222
+ }
223
+
224
+ return array('result' => $result);
225
+ }
226
+
227
+
228
+ function view_NL() {
229
+ // get campaign id
230
+ $email_id = (int)$_REQUEST['id'];
231
+
232
+ // update data in DB
233
+ $model_email = WYSIJA::get('email', 'model');
234
+ $result = $model_email->getOne(false,array('email_id' => $email_id));
235
+
236
+ echo $result['body'];
237
+ exit;
238
+ }
239
+
240
+ function display_NL() {
241
+ // get email id
242
+ $email_id = (int)$_REQUEST['id'];
243
+
244
+ // update data in DB
245
+ $model_email = WYSIJA::get('email', 'model');
246
+ $email= $model_email->getOne(false,array('email_id' => $email_id));
247
+
248
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
249
+ $helper_wj_engine->setStyles($result['wj_styles'], true);
250
+ $helper_wj_engine->setData($result['wj_data'], true);
251
+ $html = $helper_wj_engine->renderEmail($email);
252
+ print $html;
253
+ exit;
254
+ }
255
+
256
+ /**
257
+ * returns the images attached to displayed posts
258
+ */
259
+ function get_post_images() {
260
+ // get parameters
261
+ $params = array(
262
+
263
+ );
264
+
265
+ $result = true;
266
+
267
+ if($params['post_id'] === null) {
268
+
269
+ }
270
+
271
+ return array(
272
+ 'result' => $result,
273
+ 'images' => $images
274
+ );
275
+ }
276
+
277
+ /**
278
+ * returns a list of articles to the popup in the visual editor
279
+ * @global type $wpdb
280
+ * @return boolean
281
+ */
282
+ function get_articles(){
283
+ // fixes issue with pcre functions
284
+ @ini_set('pcre.backtrack_limit', 1000000);
285
+
286
+ // get parameters
287
+ $raw_data = $_REQUEST['data'];
288
+ $params = array();
289
+ foreach ($raw_data as $value) {
290
+ $params[$value['name']] = $value['value'];
291
+ }
292
+
293
+ // get options
294
+ $model_config = WYSIJA::get('config', 'model');
295
+ $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
296
+
297
+ // post statuses
298
+ $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
299
+ $post_statuses = $helper_wp_tools->get_post_statuses();
300
+ $post_types = $helper_wp_tools->get_post_types();
301
+
302
+ // filter by post_type
303
+ if(isset($params['post_type'])) {
304
+ $post_types_filter = array();
305
+ if(strlen(trim($params['post_type'])) === 0) {
306
+ $post_types_filter = array_keys($post_types);
307
+ $post_types_filter[] = 'post';
308
+ $post_types_filter[] = 'page';
309
+ } else {
310
+ $post_types_filter = trim($params['post_type']);
311
+ }
312
+ // set condition on post type
313
+ $params['post_type'] = $post_types_filter;
314
+ }
315
+
316
+ // query offset when doing incremental loading
317
+ $query_offset = (isset($_REQUEST['query_offset']) && (int)$_REQUEST['query_offset'] >= 0) ? (int)$_REQUEST['query_offset'] : 0;
318
+ $params['query_offset'] = $query_offset;
319
+
320
+ // fetch posts
321
+ $helper_articles = WYSIJA::get('articles', 'helper');
322
+
323
+ // set is_search_query (true) to get a count in addition to the results
324
+ $params['is_search_query'] = true;
325
+
326
+ $model_wp_posts = WYSIJA::get('wp_posts','model');
327
+ $data = $model_wp_posts->get_posts($params);
328
+
329
+ // extract data
330
+ $posts = $data['rows'];
331
+ // contains the total number of rows available
332
+ $count = $data['count'];
333
+
334
+ // return results
335
+ $result = array(
336
+ 'result' => true,
337
+ 'append' => ($query_offset > 0)
338
+ );
339
+
340
+ if(empty($posts) === false) {
341
+ foreach($posts as $key => $post) {
342
+ // interpret shortcodes
343
+ if($interpret_shortcode === true) {
344
+ $posts[$key]['post_content'] = apply_filters('the_content', $posts[$key]['post_content']);
345
+ }
346
+
347
+ // get thumbnail
348
+ $posts[$key]['post_image'] = $helper_articles->getImage($post);
349
+
350
+ // set post status
351
+ $post_status_label = '';
352
+ if(isset($post_statuses[$posts[$key]['post_status']])) {
353
+ $post_status_label = $post_statuses[$posts[$key]['post_status']];
354
+ }
355
+ $posts[$key]['post_status'] = $post_status_label;
356
+ }
357
+ $result['posts'] = $posts;
358
+ $result['total'] = (int)$count['total'];
359
+ }else {
360
+ $result['msg'] = __('There are no posts corresponding to that search.', WYSIJA);
361
+ $result['result'] = false;
362
+ }
363
+
364
+ return $result;
365
+ }
366
+
367
+ function insert_articles() {
368
+ // get raw params
369
+ $raw_params = $_REQUEST['data'];
370
+
371
+ // format params
372
+ $params = array();
373
+ foreach($raw_params as $value) {
374
+ $params[$value['name']] = $value['value'];
375
+ }
376
+
377
+ if($params['show_divider'] === 'yes') {
378
+ // get divider
379
+ $divider = $_REQUEST['divider'];
380
+ } else {
381
+ $divider = null;
382
+ }
383
+ $params['divider'] = $divider;
384
+
385
+ // get post ids
386
+ $post_ids = array();
387
+ if(isset($_REQUEST['post_ids']) && strlen(trim($_REQUEST['post_ids'])) > 0) {
388
+ $post_ids = explode(',', $_REQUEST['post_ids']);
389
+ }
390
+
391
+ if(empty($post_ids)) {
392
+ // return error
393
+ $res['msg'] = __('Please select an article.', WYSIJA);
394
+ $res['result'] = false;
395
+ return $res;
396
+ }
397
+
398
+ // specify custom fields to get from posts
399
+ $post_params = array('include' => $post_ids);
400
+
401
+ // include sort by parameter into post params
402
+ $post_params['sort_by'] = $params['sort_by'];
403
+
404
+ // get posts
405
+ $model_wp_posts = WYSIJA::get('wp_posts', 'model');
406
+ $posts = $model_wp_posts->get_posts($post_params);
407
+
408
+ // check if we need to interpret shortcodes
409
+ $model_config = WYSIJA::get('config', 'model');
410
+ $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
411
+
412
+ // get some model and helpers
413
+ $helper_articles = WYSIJA::get('articles', 'helper');
414
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
415
+
416
+ $output = '';
417
+
418
+ // save parameters for next time
419
+ $model_config->save(array('insert_post_parameters' => $helper_wj_engine->encodeParameters($params)));
420
+
421
+ foreach($posts as $key => $post) {
422
+ if($interpret_shortcode === true) {
423
+ // interpret shortcodes
424
+ $posts[$key]['post_content'] = apply_filters('the_content', $post['post_content']);
425
+ }
426
+ // get thumbnail
427
+ $posts[$key]['post_image'] = $helper_articles->getImage($post);
428
+ }
429
+
430
+ $output .= base64_encode($helper_wj_engine->renderPostsToBlocks($posts, $params));
431
+
432
+ if(strlen($output) > 0) {
433
+ $res['result'] = true;
434
+ $res['posts'] = $output;
435
+ }else {
436
+ $res['msg'] = __('There are no posts corresponding to that search.',WYSIJA);
437
+ $res['result'] = false;
438
+ }
439
+
440
+ return $res;
441
+ }
442
+
443
+ function send_preview($spamtest=false){
444
+ $mailer=WYSIJA::get('mailer','helper');
445
+ $email_id = $_REQUEST['id'];
446
+ $resultarray=array();
447
+
448
+ // update data in DB
449
+ $model_email = WYSIJA::get('email', 'model');
450
+ $model_email->getFormat=OBJECT;
451
+ $email_object = $model_email->getOne(false,array('email_id' => $email_id));
452
+ $mailer->testemail=true;
453
+
454
+
455
+ if(isset($_REQUEST['data'])){
456
+ $dataTemp=$_REQUEST['data'];
457
+ $_REQUEST['data']=array();
458
+ foreach($dataTemp as $val) $_REQUEST['data'][$val['name']]=$val['value'];
459
+ unset($dataTemp);
460
+ foreach($_REQUEST['data'] as $k =>$v){
461
+ $newkey=str_replace(array('wysija[email][',']'),'',$k);
462
+ $configVal[$newkey]=$v;
463
+ }
464
+ if(isset($configVal['from_name'])){
465
+ $params=array(
466
+ 'from_name'=>$configVal['from_name'],
467
+ 'from_email'=>$configVal['from_email'],
468
+ 'replyto_name'=>$configVal['replyto_name'],
469
+ 'replyto_email'=>$configVal['replyto_email']);
470
+ if(isset($configVal['subject'])) $email_object->subject=$configVal['subject'];
471
+ }
472
+
473
+ }else{
474
+ $params=array(
475
+ 'from_name'=>$email_object->from_name,
476
+ 'from_email'=>$email_object->from_email,
477
+ 'replyto_name'=>$email_object->replyto_name,
478
+ 'replyto_email'=>$email_object->replyto_email
479
+ );
480
+ }
481
+ if(strpos($_REQUEST['receiver'], ',')) {
482
+ $receivers = explode(',',$_REQUEST['receiver']);
483
+ } else if(strpos($_REQUEST['receiver'], ';')) {
484
+ $receivers = explode(';',$_REQUEST['receiver']);
485
+ } else {
486
+ $receivers = array($_REQUEST['receiver']);
487
+ }
488
+
489
+ $user_model = WYSIJA::get('user', 'model');
490
+ foreach($receivers as $key => $receiver){
491
+ $receiver = trim($receiver);
492
+ $dummy_receiver = $user_model->get_object_by_email($receiver);
493
+ if(empty($dummy_receiver)){
494
+ $dummy_receiver = new stdClass();
495
+ $dummy_receiver->user_id = 0;
496
+ $dummy_receiver->email = $receiver;
497
+ $dummy_receiver->status = 1;
498
+ $dummy_receiver->lastname = $dummy_receiver->firstname = '';
499
+ }
500
+
501
+ if($spamtest){
502
+ $langextra = '';
503
+ $dummy_receiver->firstname ='Mail Tester';
504
+
505
+ $wp_lang = get_locale();
506
+ if(!empty($wp_lang)) $langextra ='&lang='.$wp_lang;
507
+ $resultarray['urlredirect']='http://www.mail-tester.com/check.php?id='.urlencode($dummy_receiver->email).$langextra;
508
+ }
509
+ $receivers[$key] = $dummy_receiver;
510
+
511
+ }
512
+
513
+ $email_clone=array();
514
+ foreach($email_object as $kk=>$vv) $email_clone[$kk]=$vv;
515
+
516
+
517
+ $wj_engine = WYSIJA::get('wj_engine', 'helper');
518
+ // set data & styles
519
+ if(isset($email_clone['wj_data'])) { $wj_engine->setData($email_clone['wj_data'], true); } else { $wj_engine->setData(); }
520
+ if(isset($email_clone['wj_styles'])) { $wj_engine->setStyles($email_clone['wj_styles'], true); } else { $wj_engine->setStyles(); }
521
+
522
+ // generate email html body
523
+ $body = $wj_engine->renderEmail($email_clone);
524
+
525
+ // get back email data as it will be updated during the rendering (articles ids + articles count)
526
+ $email_child = $wj_engine->getEmailData();
527
+
528
+ // [total] [number] and [post_title] are only valid for post notifications newsletter
529
+ if((int)$email_child['type'] === 2 && isset($email_child['params']['autonl']['event']) &&
530
+ $email_child['params']['autonl']['event'] === 'new-articles' && isset($email_child['params']['autonl']['articles'])){
531
+
532
+ $item_count = 0;
533
+ $total_count = 1;
534
+ $first_subject = '';
535
+
536
+ if(isset($email_child['params']['autonl']['articles']['count'])) $item_count = (int)$email_child['params']['autonl']['articles']['count'];
537
+ if(isset($email_child['params']['autonl']['articles']['first_subject'])) $first_subject = $email_child['params']['autonl']['articles']['first_subject'];
538
+ if(isset($email_child['params']['autonl']['total_child'])) $total_count = (int)$email_child['params']['autonl']['total_child'] + 1;
539
+
540
+ $email_object->subject = str_replace(
541
+ array('[total]','[number]','[post_title]'),
542
+ array($item_count, $total_count, $first_subject),
543
+ $email_child['subject']
544
+ );
545
+ }
546
+ $successmsg = __('Your email preview has been sent to %1$s', WYSIJA);
547
+
548
+ // correction added for post notifications with the tag [newsletter:post_title] failing to send
549
+ if(isset($email_object->params['autonl']) && isset($email_child['params']['autonl'])){
550
+ $email_object->params['autonl']=$email_child['params']['autonl'];
551
+ }
552
+
553
+ if(isset($email_object->params)) {
554
+ $params['params']=$email_object->params;
555
+
556
+ if(isset($configVal['params[googletrackingcode'])){
557
+ $paramsemail=array();
558
+ if(!is_array($email_object->params)) $paramsemail=unserialize(base64_decode($email_object->params));
559
+
560
+ if(trim($configVal['params[googletrackingcode'])) {
561
+ $paramsemail['googletrackingcode']=$configVal['params[googletrackingcode'];
562
+ }
563
+ else {
564
+ unset($paramsemail['googletrackingcode']);
565
+ }
566
+ $params['params'] = base64_encode(serialize($paramsemail));
567
+ }
568
+ }
569
+
570
+ $params['email_id'] = $email_object->email_id;
571
+ $receiversList = array();
572
+ $res = false;
573
+ foreach($receivers as $receiver){
574
+ if($mailer->sendSimple($receiver, stripslashes($email_object->subject),$email_object->body,$params)) {
575
+ $res = true;
576
+ $receiversList[] = $receiver->email;
577
+ }
578
+ WYSIJA::log('preview_sent', $mailer, 'manual');
579
+ }
580
+
581
+ if($res === true) {
582
+ $this->notice(sprintf($successmsg, implode(', ', $receiversList)));
583
+ }
584
+
585
+ $resultarray['result'] = $res;
586
+
587
+ return $resultarray;
588
+ }
589
+
590
+ /**
591
+ * send spam test function step 2 of the newsletter edition process
592
+ */
593
+ function send_spamtest(){
594
+ return apply_filters('wysija_send_spam_test','',$this);
595
+ }
596
+
597
+ function set_divider()
598
+ {
599
+ $src = isset($_POST['wysijaData']['src']) ? $_POST['wysijaData']['src'] : NULL;
600
+ $width = isset($_POST['wysijaData']['width']) ? (int)$_POST['wysijaData']['width'] : NULL;
601
+ $height = isset($_POST['wysijaData']['height']) ? (int)$_POST['wysijaData']['height'] : NULL;
602
+
603
+ if($src === NULL OR $width === NULL OR $height === NULL) {
604
+ // there is a least one missing parameter, fallback to default divider
605
+ $dividersHelper = WYSIJA::get('dividers', 'helper');
606
+ $divider = $dividersHelper->getDefault();
607
+ } else {
608
+ // use provided params
609
+ $divider = array(
610
+ 'src' => $src,
611
+ 'width' => $width,
612
+ 'height' => $height
613
+ );
614
+ }
615
+
616
+ // update campaign parameters
617
+ $email_id = (int)$_REQUEST['id'];
618
+ $campaignsHelper = WYSIJA::get('campaigns', 'helper');
619
+ $campaignsHelper->saveParameters($email_id, 'divider', $divider);
620
+
621
+ // set params
622
+ $block = array_merge(array('no-block' => true, 'type' => 'divider'), $divider);
623
+
624
+ $helper_wj_engine=WYSIJA::get('wj_engine','helper');
625
+ return base64_encode($helper_wj_engine->renderEditorBlock($block));
626
+ }
627
+
628
+ function get_social_bookmarks() {
629
+ $size = isset($_POST['wysijaData']['size']) ? $_POST['wysijaData']['size'] : NULL;
630
+ $theme = isset($_POST['wysijaData']['theme']) ? $_POST['wysijaData']['theme'] : NULL;
631
+
632
+ $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
633
+ $bookmarks = $bookmarksHelper->getAll($size, $theme);
634
+ return json_encode(array('icons' => $bookmarks));
635
+ }
636
+
637
+ function generate_social_bookmarks() {
638
+
639
+ $size = 'medium';
640
+ $iconset = '01';
641
+
642
+ if(isset($_POST['wysijaData']) && !empty($_POST['wysijaData'])) {
643
+ $data = $_POST['wysijaData'];
644
+ $items = array();
645
+
646
+ foreach($data as $key => $values) {
647
+ if($values['name'] === 'bookmarks-size') {
648
+ // get size
649
+ $size = $values['value'];
650
+ } else if($values['name'] === 'bookmarks-theme') {
651
+ // get theme name
652
+ $theme = $values['value'];
653
+ } else if($values['name'] === 'bookmarks-iconset') {
654
+ // get iconset
655
+ $iconset = $values['value'];
656
+ if(strlen(trim($iconset)) === 0) {
657
+ $this->error('No iconset specified', false);
658
+ return false;
659
+ }
660
+ } else {
661
+ $keys = explode('-', $values['name']);
662
+ $network = $keys[1];
663
+ $property = $keys[2];
664
+ if(array_key_exists($network, $items)) {
665
+ $items[$network][$property] = $values['value'];
666
+ } else {
667
+ $items[$network] = array($property => $values['value']);
668
+ }
669
+ }
670
+ }
671
+ }
672
+
673
+ $urls = array();
674
+ // check data and remove network with an empty url
675
+ foreach($items as $network => $item) {
676
+ if(strlen(trim($item['url'])) === 0) {
677
+ // empty url
678
+ unset($items[$network]);
679
+ } else {
680
+ // url specified
681
+ $urls[$network] = $item['url'];
682
+ }
683
+ }
684
+
685
+ // check if there's at least one url left
686
+ if(empty($urls)) {
687
+ $this->error('No url specified', false);
688
+ return false;
689
+ }
690
+
691
+ // save url in config
692
+ $config=WYSIJA::get('config','model');
693
+ $config->save(array('social_bookmarks' => $urls));
694
+
695
+ // get iconset icons
696
+ $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
697
+
698
+ // if the iconset is 00, then it's the theme's bookmarks
699
+ if($iconset === '00') {
700
+ $icons = $bookmarksHelper->getAllByTheme($theme);
701
+ } else {
702
+ // otherwise it's a basic iconset
703
+ $icons = $bookmarksHelper->getAllByIconset($size, $iconset);
704
+ }
705
+
706
+
707
+ // format data
708
+ $block = array(
709
+ 'position' => 1,
710
+ 'type' => 'gallery',
711
+ 'items' => array(),
712
+ 'alignment' => 'center'
713
+ );
714
+
715
+ $width = 0;
716
+ foreach($items as $key => $item) {
717
+ $block['items'][] = array_merge($item, $icons[$key], array('alt' => ucfirst($key)));
718
+ $width += (int)$icons[$key]['width'];
719
+ }
720
+ // add margin between icons
721
+ $width += (count($block['items']) - 1) * 10;
722
+ // set optimal width
723
+ $block['width'] = max(0, min($width, 564));
724
+
725
+ $helper_wj_engine=WYSIJA::get('wj_engine','helper');
726
+ return base64_encode($helper_wj_engine->renderEditorBlock($block));
727
+ }
728
+
729
+ function install_theme() {
730
+ if( isset($_REQUEST['theme_id'])){
731
+ global $wp_version;
732
+ //check if theme is premium if you have the premium licence
733
+ if(isset($_REQUEST['premium']) && $_REQUEST['premium']){
734
+ $getpremiumtheme=apply_filters('wysija_install_theme_premium', false);
735
+
736
+ if(!$getpremiumtheme){
737
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
738
+ $themes = $helper_wj_engine->renderThemes();
739
+ return array('result'=>false, 'themes' => $themes);
740
+ }
741
+ }
742
+
743
+ $helperToolbox = WYSIJA::get('toolbox','helper');
744
+ $domain_name = $helperToolbox->_make_domain_name(admin_url('admin.php'));
745
+
746
+ $request = 'http://api.mailpoet.com/download/zip/'.$_REQUEST['theme_id'].'?domain='.$domain_name;
747
+
748
+ $args = array(
749
+ 'timeout' => 30,
750
+ 'body' => array( ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
751
  'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
752
+ );
753
+ $raw_response = wp_remote_post( $request, $args );
754
+
755
+ if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ){
756
+ if(method_exists($raw_response, 'get_error_messages')){
757
+ $this->error($raw_response->get_error_messages());
758
+ }
759
+ $ZipfileResult = false;
760
+ }else{
761
+ $ZipfileResult = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
762
+ }
763
+
764
+ if($ZipfileResult === false){
765
+ $result = false;
766
+ $this->error(__('We were unable to contact the API, the site may be down. Please try again later.',WYSIJA),true);
767
+ }else{
768
+ $themesHelp=WYSIJA::get('themes','helper');
769
+ $result = $themesHelp->installTheme($ZipfileResult);
770
+
771
+ // refresh themes list
772
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
773
+ $themes = $helper_wj_engine->renderThemes();
774
+ }
775
+ }else{
776
+ $result = false;
777
+ $themes = '';
778
+ $this->notice('missing info');
779
+ }
780
+
781
+ return array('result' => $result, 'themes' => $themes);
782
+ }
783
+
784
+ function refresh_themes() {
785
+ // refresh themes list
786
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
787
+ return array('result'=>true, 'themes' => $helper_wj_engine->renderThemes());
788
+ }
789
+
790
+ function generate_auto_post() {
791
+ // get params and generate html
792
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
793
+ $helper_articles = WYSIJA::get('articles', 'helper');
794
+
795
+ // get parameters
796
+ $block_params = array();
797
+ if(isset($_POST['wysijaData'])) {
798
+ // store category ids (TBR)
799
+ $category_ids = array();
800
+
801
+ foreach($_POST['wysijaData'] as $pairs) {
802
+ // special cases
803
+ switch($pairs['name']) {
804
+ case 'author_label':
805
+ case 'category_label':
806
+ case 'readmore':
807
+ case 'nopost_message':
808
+ $block_params[] = array('key' => $pairs['name'], 'value' => base64_encode(stripslashes($pairs['value'])));
809
+ break;
810
+ case 'category_ids':
811
+ $category_ids[] = (int)$pairs['value'];
812
+ break;
813
+ default:
814
+ $block_params[] = array('key' => $pairs['name'], 'value' => $pairs['value']);
815
+ }
816
+ }
817
+
818
+ // make sure we have only unique ids in categories
819
+ $block_params[] = array('key' => 'category_ids', 'value' => join(',', array_unique($category_ids)));
820
+ }
821
+
822
+ if(empty($block_params)) {
823
+ // an error occurred, do something!
824
+ return false;
825
+ } else {
826
+ $data = array(
827
+ 'type' => 'auto-post',
828
+ 'params' => $block_params
829
+ );
830
+ return base64_encode($helper_wj_engine->renderEditorBlock($data));
831
+ }
832
+ }
833
+
834
+ function load_auto_post() {
835
+ $params = array();
836
+
837
+ if(isset($_POST['wysijaData'])) {
838
+
839
+ $pairs = explode('&', $_POST['wysijaData']);
840
+
841
+ foreach($pairs as $pair) {
842
+ list($key, $value) = explode('=', $pair);
843
+ switch($key) {
844
+ case 'autopost_count':
845
+ $params[$key] = (int)$value;
846
+ break;
847
+ case 'readmore':
848
+ case 'author_label':
849
+ case 'category_label':
850
+ case 'nopost_message':
851
+ $params[$key] = base64_decode($value);
852
+ break;
853
+ case 'exclude':
854
+ $params[$key] = explode(',', $value);
855
+ break;
856
+ default:
857
+ $params[$key] = $value;
858
+ }
859
+ }
860
+ }
861
+
862
+ if(empty($params)) {
863
+ // an error occurred, do something!
864
+ return false;
865
+ } else {
866
+
867
+ // get email params
868
+ $email_id = (int)$_REQUEST['id'];
869
+ $model_email = WYSIJA::get('email', 'model');
870
+ $email = $model_email->getOne(array('params','sent_at','campaign_id'), array('email_id' => $email_id));
871
+
872
+ $helper_articles = WYSIJA::get('articles', 'helper');
873
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
874
+
875
+ // see if posts have already been sent
876
+ if(!empty($email['params']['autonl']['articles']['ids'])) {
877
+ if(!isset($params['exclude'])) { $params['exclude'] = array(); }
878
+
879
+ $params['exclude'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $params['exclude']));
880
+ }
881
+
882
+ //we set the post_date to filter articles only older than that one
883
+ if(isset($email['params']['autonl']['firstSend'])){
884
+ $params['post_date'] = $email['params']['autonl']['firstSend'];
885
+ }
886
+
887
+ // if immediate let it know to the get post
888
+ if(isset($email['params']['autonl']['articles']['immediatepostid'])){
889
+ $params['include'] = $email['params']['autonl']['articles']['immediatepostid'];
890
+ $params['post_limit'] = 1;
891
+ }else{
892
+ //we set the post_date to filter articles only older than the last time we sent articles
893
+ if(isset($email['params']['autonl']['lastSend'])){
894
+ $params['post_date'] = $email['params']['autonl']['lastSend'];
895
+ }else{
896
+ //get the latest child newsletter sent_at value
897
+ $mEmail=WYSIJA::get('email','model');
898
+ $mEmail->reset();
899
+ $mEmail->orderBy('email_id','DESC');
900
+ $lastEmailSent=$mEmail->getOne(false,array('campaign_id'=>$email['campaign_id'],'type'=>'1'));
901
+
902
+ if(!empty($lastEmailSent)) $params['post_date'] = $lastEmailSent['sent_at'];
903
+ }
904
+ }
905
+
906
+ // get posts
907
+ $model_wp_posts = WYSIJA::get('wp_posts','model');
908
+ $posts = $model_wp_posts->get_posts($params);
909
+
910
+ if(empty($posts)) {
911
+ // nothing to display
912
+ $posts = array();
913
+ } else {
914
+ // used to keep track of post ids present in the auto post
915
+ $post_ids = array();
916
+
917
+ // cleanup post and get image
918
+ foreach($posts as $key => $post) {
919
+ if($params['image_alignment'] !== 'none') {
920
+ // attempt to get post image
921
+ $posts[$key]['post_image'] = $helper_articles->getImage($post);
922
+ }
923
+
924
+ // store article id
925
+ $post_ids[] = $post['ID'];
926
+ }
927
+ // store article ids
928
+ $params['post_ids'] = join(',', $post_ids);
929
+ }
930
+
931
+ // get divider if necessary (for immediate post notification, the "show_divider" parameter is not available)
932
+ if(isset($params['show_divider']) && $params['show_divider'] === 'yes') {
933
+ if(isset($email['params']['divider'])) {
934
+ $params['divider'] = $email['params']['divider'];
935
+ } else {
936
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
937
+ $params['divider'] = $helper_dividers->getDefault();
938
+ }
939
+ }
940
+
941
+ return base64_encode($helper_wj_engine->renderEditorAutoPost($posts, $params));
942
+ }
943
+ }
944
  }
controllers/ajax/statistics.php CHANGED
@@ -1,95 +1,86 @@
1
  <?php
 
2
  defined('WYSIJA') or die('Restricted access');
3
 
4
  require_once(WYSIJA_CORE.'module'.DS.'statistics.php'); // @todo
5
 
6
- class WYSIJA_control_back_statistics extends WYSIJA_control
7
- {
8
 
9
- /**
10
- * Main model of this controller
11
- * @var string
12
- */
13
- public $model = 'statistics';
14
 
15
- /**
16
- * Main view of this controller
17
- * @var string
18
- */
19
- public $view = 'statistics';
20
 
21
- /**
22
- * Render a hook of a specific module
23
- * @return string
24
- */
25
- public function get_block()
26
- {
27
- if (empty($_REQUEST['block']))
28
- return '';
29
- $module = $_REQUEST['block'];
30
- $hook_name = 'hook_stats';
31
- return apply_filters('custom_module_hook', '', $module, $hook_name, $this->get_post_params());
32
- }
33
 
34
- protected function get_post_params()
35
- {
36
- $params = array( );
37
- $order_by = !empty($_REQUEST['filter']['orderBy']) ? $_REQUEST['filter']['orderBy'] : null;
38
- switch (strtolower($order_by))
39
- {
40
- case 'sent':
41
- $order_by = WYSIJA_module_statistics::ORDER_BY_SENT;
42
- break;
43
- case 'open':
44
- $order_by = WYSIJA_module_statistics::ORDER_BY_OPEN;
45
- break;
46
- case 'click':
47
- $order_by = WYSIJA_module_statistics::ORDER_BY_CLICK;
48
- break;
49
- case 'unsubscribe':
50
- $order_by = WYSIJA_module_statistics::ORDER_BY_UNSUBSCRIBE;
51
- break;
52
- default:
53
- $order_by = null;
54
- break;
55
- }
56
- $order_direction = !empty($_REQUEST['filter']['orderDirection']) ? $_REQUEST['filter']['orderDirection'] : null;
57
- switch (strtolower($order_direction))
58
- {
59
- case 'asc':
60
- $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_ASC;
61
- break;
62
- case 'desc':
63
- default:
64
- $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_DESC;
65
- break;
66
- }
67
- $params['top'] = !empty($_REQUEST['filter']['itemPerPage']) ? (int)$_REQUEST['filter']['itemPerPage'] : WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
68
- $params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : null;
69
- $params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : null;
70
- $params['order_by'] = $order_by;
71
- $params['order_direction'] = $order_direction;
72
 
73
- // this doesn't work when php is less than 5.3, this is the case on my host (ben) which is very popular in France, SPain and UK
74
- // we cannot use functions from php 5.3
75
- if (function_exists('date_diff'))
76
- {
77
- $this->data['date_interval'] = date_diff(date_create($params['from']), date_create($params['to']));
78
- }
79
- else
80
- {
81
- $duration = strtotime($params['to']) - strtotime($params['from']);
82
- $helper_toolbox = WYSIJA::get('toolbox', 'helper');
83
- $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration, false);
84
- }
85
- $params['group_by'] = ( $this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
86
- WYSIJA_module_statistics::GROUP_BY_MONTH :
87
- WYSIJA_module_statistics::GROUP_BY_DATE; // $date_interval->days == 0, means, no begin date, no end date
88
 
89
- // Hack!
90
- $_REQUEST['limit_pp'] = $params['top'];// Pagination, mark current selected value
91
 
92
- return $params;
93
- }
94
 
95
  }
1
  <?php
2
+
3
  defined('WYSIJA') or die('Restricted access');
4
 
5
  require_once(WYSIJA_CORE.'module'.DS.'statistics.php'); // @todo
6
 
7
+ class WYSIJA_control_back_statistics extends WYSIJA_control {
 
8
 
9
+ /**
10
+ * Main model of this controller
11
+ * @var string
12
+ */
13
+ public $model = 'statistics';
14
 
15
+ /**
16
+ * Main view of this controller
17
+ * @var string
18
+ */
19
+ public $view = 'statistics';
20
 
21
+ /**
22
+ * Render a hook of a specific module
23
+ * @return string
24
+ */
25
+ public function get_block() {
26
+ if (empty($_REQUEST['block']))
27
+ return '';
28
+ $module = $_REQUEST['block'];
29
+ $hook_name = 'hook_stats';
30
+ return apply_filters('custom_module_hook', '', $module, $hook_name, $this->get_post_params());
31
+ }
 
32
 
33
+ protected function get_post_params() {
34
+ $params = array();
35
+ $order_by = !empty($_REQUEST['filter']['orderBy']) ? $_REQUEST['filter']['orderBy'] : null;
36
+ switch (strtolower($order_by)) {
37
+ case 'sent':
38
+ $order_by = WYSIJA_module_statistics::ORDER_BY_SENT;
39
+ break;
40
+ case 'open':
41
+ $order_by = WYSIJA_module_statistics::ORDER_BY_OPEN;
42
+ break;
43
+ case 'click':
44
+ $order_by = WYSIJA_module_statistics::ORDER_BY_CLICK;
45
+ break;
46
+ case 'unsubscribe':
47
+ $order_by = WYSIJA_module_statistics::ORDER_BY_UNSUBSCRIBE;
48
+ break;
49
+ default:
50
+ $order_by = null;
51
+ break;
52
+ }
53
+ $order_direction = !empty($_REQUEST['filter']['orderDirection']) ? $_REQUEST['filter']['orderDirection'] : null;
54
+ switch (strtolower($order_direction)) {
55
+ case 'asc':
56
+ $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_ASC;
57
+ break;
58
+ case 'desc':
59
+ default:
60
+ $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_DESC;
61
+ break;
62
+ }
63
+ $params['top'] = !empty($_REQUEST['filter']['itemPerPage']) ? (int) $_REQUEST['filter']['itemPerPage'] : WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
64
+ $params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : null;
65
+ $params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : null;
66
+ $params['order_by'] = $order_by;
67
+ $params['order_direction'] = $order_direction;
 
 
 
68
 
69
+ // this doesn't work when php is less than 5.3, this is the case on my host (ben) which is very popular in France, SPain and UK
70
+ // we cannot use functions from php 5.3
71
+ if(function_exists('date_diff')){
72
+ $this->data['date_interval'] = date_diff(date_create($params['from']), date_create($params['to']));
73
+ }else{
74
+ $duration = strtotime($params['to']) - strtotime($params['from']);
75
+ $helper_toolbox = WYSIJA::get('toolbox' , 'helper');
76
+ $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration , false);
77
+ }
78
+ $params['group_by'] = ( $this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
79
+ WYSIJA_module_statistics::GROUP_BY_MONTH :
80
+ WYSIJA_module_statistics::GROUP_BY_DATE; // $date_interval->days == 0, means, no begin date, no end date
81
+ return $params;
82
+ }
 
83
 
 
 
84
 
 
 
85
 
86
  }
controllers/back/campaigns.php CHANGED
@@ -5,2755 +5,2747 @@ defined('WYSIJA') or die('Restricted access');
5
 
6
  class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
7
 
8
- var $model = 'campaign';
9
- var $view = 'campaigns';
10
- var $list_columns = array('campaign_id', 'name', 'description');
11
- var $searchable = array('name', 'subject');
12
- var $filters = array();
13
- var $base_url = 'admin.php';
14
-
15
- function WYSIJA_control_back_campaigns() {
16
-
17
- }
18
-
19
- function installation(){
20
-
21
- $start_time = time();
22
- $check_max_execution_time = get_option( 'mpoet_check_max_execution_time' );
23
- $ini_max_execution_time = ini_get( 'max_execution_time' );
24
-
25
- // 1 - we haven't run the max execution time extension test yet, let's do it
26
- // this test should be run in the background, it may take more than 5 minutes to validate
27
- if( empty( $check_max_execution_time ) ){
28
-
29
- // we set the max_execution_time to infinite
30
- @ini_set( 'max_execution_time' , 0 );
31
- // we keep running the script even if the user abort his request
32
- @ignore_user_abort( true );
33
-
34
- $reset_max_execution_time = ini_get( 'max_execution_time' );
35
-
36
- // FAILURE some servers the "max execution time" returned is Array we make sure our value is numeric
37
- if( !is_numeric( $ini_max_execution_time ) ){
38
- WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time-1 );
39
- return;
40
- }
41
-
42
- // FAILURE this server doesn't allow us to set the max_execution_time
43
- if( $reset_max_execution_time == $ini_max_execution_time ){
44
- WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time-1 );
45
- return;
46
- }
47
-
48
- // we set a FAILURE value to our flag so we know if the process crash while executing
49
- WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time );
50
-
51
- // the common default timeout value is 300, so if by default the timelimit is 0 (which might have been set by another application)
52
- // we default it to 300 known as a common default value and we run the extension test
53
- if( $ini_max_execution_time == 0 ) $ini_max_execution_time = 300;
54
-
55
- // we run asleep script during the initial max execution time to a larger value
56
- $total_time_to_run_script = $ini_max_execution_time + 20;
57
- $sleeping_intervals = 5;
58
- $duration_so_far = 0;
59
-
60
- // we sleep until the extended total timeout value is reached or it breaks before but we have the value we need
61
- while($total_time_to_run_script >0){
62
- $total_time_to_run_script = $total_time_to_run_script - $sleeping_intervals;
63
- sleep( $sleeping_intervals );
64
-
65
- $duration_so_far = time() - $start_time;
66
- WYSIJA::update_option( 'mpoet_check_max_execution_time' , $duration_so_far );
67
- }
68
-
69
- // SUCCESS the scripts didn't die we set our flag in the db so that we know the test is a success
70
- WYSIJA::update_option( 'mpoet_check_max_execution_time' , $duration_so_far );
71
-
72
- }else{
73
- // 2 - the max execution time extension test has been run, this is the results we get
74
- if( $check_max_execution_time > $ini_max_execution_time ){
75
- echo 'max_execution_time('.$ini_max_execution_time.') can be extended('.$check_max_execution_time.')';
76
- }else{
77
- echo 'max_execution_time('.$ini_max_execution_time.') cannot be extended( max value : '.$check_max_execution_time.')';
78
- }
79
- }
80
- exit;
81
- }
82
-
83
- /**
84
- * Welcome page first time install
85
- * @return boolean
86
- */
87
- function welcome_new() {
88
- $this->title = $this->viewObj->title = __('Welcome Page!', WYSIJA);
89
- $this->jsTrans['instalwjp'] = __('Installing MailPoet Newsletter Premium plugin', WYSIJA);
90
- $helper_readme = WYSIJA::get('readme', 'helper');
91
- $helper_readme->scan();
92
- $this->data = array();
93
- $this->data['abouttext'] = __('A Brand New MailPoet. Let the Fun Begin.', WYSIJA);
94
-
95
- $model_config = WYSIJA::get('config', 'model');
96
- $is_multisite = is_multisite();
97
- $is_network_admin = WYSIJA::current_user_can('manage_network');
98
- if ($is_multisite && $is_network_admin) {
99
- $model_config->save(array('ms_wysija_whats_new' => WYSIJA::get_version()));
100
- } else {
101
- $model_config->save(array('wysija_whats_new' => WYSIJA::get_version()));
102
- }
103
-
104
- //add a new language code with a new video
105
- $video_language=array();
106
- //$video_language['en_EN'] = '<iframe width="853" height="480" src="http://www.youtube.com/embed/pYzaHDTg5Jk" frameborder="0" allowfullscreen></iframe>';
107
- $video_language['en_EN'] = '<iframe src="//player.vimeo.com/video/81479899" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
108
- //$video_language['fr_FR'] = '<iframe width="853" height="480" src="http://www.youtube.com/embed/W5EyW5w7aWQ" frameborder="0" allowfullscreen></iframe>';
109
- // $video_language['sv_SE']='<iframe width="853" height="480" src="http://www.youtube.com/embed/O8_t_dekx74" frameborder="0" allowfullscreen></iframe>';
110
- //$video_language['ar']='<iframe width="853" height="480" src="http://www.youtube.com/embed/cyDHlX_qgOo" frameborder="0" allowfullscreen></iframe>';
111
-
112
- $wp_lang = get_locale();
113
- if (!empty($wp_lang) && isset($video_language[$wp_lang])) {
114
- $welcome_video_link = $video_language[$wp_lang];
115
- } else {
116
- $welcome_video_link = $video_language['en_EN'];
117
- }
118
-
119
- $this->data['sections'][] = array(
120
- 'title' => __('Hey, we\'re curious! How did you find out about us?', WYSIJA) . '<span id="poll_result"></span>',
121
- 'format' => 'normal',
122
- 'paragraphs' => array(
123
- '<ul class="welcome_poll">
124
- <li>
125
- <input type="radio" id="how_did_you_find_us_1" value="repository" name="how_did_you_find_us">
126
- <label value="lab1" for="how_did_you_find_us_1">' . __('WordPress.org plugin repository', WYSIJA) . '</label>
127
- </li>
128
- <li>
129
- <input type="radio" id="how_did_you_find_us_2" value="search_engine" name="how_did_you_find_us">
130
- <label value="lab2" for="how_did_you_find_us_2">' . __('Google or other search engine', WYSIJA) . '</label>
131
- </li>
132
- <li>
133
- <input type="radio" id="how_did_you_find_us_3" value="friend" name="how_did_you_find_us">
134
- <label value="lab3" for="how_did_you_find_us_3">' . __('Friend recommendation', WYSIJA) . '</label>
135
- </li>
136
- <li>
137
- <input type="radio" id="how_did_you_find_us_4" value="url" name="how_did_you_find_us">
138
- <label value="lab4" for="how_did_you_find_us_4">' . __('Blog post, online review, forum:', WYSIJA) . '</label>
139
- <input type="text" id="how_did_you_find_us_4_url" name="how_did_you_find_us_url" placeholder="' . __('Please enter the address where you\'ve found out about us', WYSIJA) . '">
140
- </li>
141
- </ul>'
142
- )
143
- );
144
-
145
- $this->data['sections'][]=array(
146
- 'title'=>__('First Time? See it in Action',WYSIJA),
147
- 'format'=>'normal',
148
- 'paragraphs'=>array(
149
- __('You can start by watching this video by one of our users.',WYSIJA),
150
- $welcome_video_link
151
- )
152
- );
153
-
154
- // Check if user is already sharing data, and hide the share link.
155
- if (!$model_config->getValue('analytics')) {
156
- $share_section = array(
157
- 'title' => __('Share your data', WYSIJA),
158
- 'content' => str_replace(
159
- array('[link]', '[/link]', '[ajaxlink]', '[/ajaxlink]'), array('<a title="Anonymous Data" target="_blank" href="http://support.mailpoet.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=welcome_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'), __("We know too little about our users. We're looking for [link]anonymous data[/link] to build a better plugin. [ajaxlink]Yes, count me in![/ajaxlink]", WYSIJA))
160
- );
161
- } else {
162
- $share_section = array(
163
- 'title' => __('Share your data', WYSIJA),
164
- 'content' => str_replace(
165
- array('[link]', '[/link]'), array('<a title="Anonymous Data" target="_blank" href="http://support.mailpoet.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=welcome_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'), __("We know too little about our users. We're looking for [link]anonymous data[/link] to build a better plugin. Thanks, you're already sharing!", WYSIJA))
166
- );
167
- }
168
-
169
- $this->data['sections'][] = array(
170
- 'title' => __('What You Can Do', WYSIJA),
171
- 'cols' => array(
172
- array(
173
- 'title' => __('5 minute newbie guide', WYSIJA),
174
- 'content' => __('Your MailPoet comes with an example newsletter. You\'ll see it when you close this welcome page. Edit it to start playing with it.', WYSIJA)
175
- ),
176
- $share_section,
177
- array(
178
- 'title' => __('Help yourself. Or let us help you.', WYSIJA),
179
- 'content' => str_replace(
180
- array('[link]', '[/link]'), array('<a href="http://support.mailpoet.com/" target="_blank" title="On our blog!">', '</a>'), __('We got documentation and a ticket system on [link]support.mailpoet.com[/link]. We answer within 24h.', WYSIJA))
181
- )
182
- ),
183
- 'format' => 'three-col',
184
- );
185
-
186
- $this->viewObj->skip_header = true;
187
-
188
- return true;
189
- }
190
-
191
- /**
192
- * Welcome page for updaters
193
- * @return boolean
194
- */
195
- function whats_new() {
196
-
197
- $this->title = $this->viewObj->title = __('What\'s new?', WYSIJA);
198
- $this->jsTrans['instalwjp'] = __('Installing MailPoet Newsletter Premium plugin', WYSIJA);
199
- wp_enqueue_style('wysija-admin-css-premium', WYSIJA_URL.'css/admin-premium.css',array(),WYSIJA::get_version());
200
-
201
- $this->viewObj->skip_header = true;
202
- return true;
203
- }
204
-
205
-
206
-
207
- /* START prem check hook */
208
-
209
- // when curl or any php remote function not available mailpoet.com returns lcheck to that function
210
- function licok() {
211
- parent::WYSIJA_control_back();
212
- $dt = get_option('wysijey');
213
-
214
- if (isset($_REQUEST['xtz']) && $dt === $_REQUEST['xtz']) {
215
- $dataconf = array('premium_key' => base64_encode(get_option('home') . time()), 'premium_val' => time());
216
- $this->notice(__('Premium version is valid for your site.', WYSIJA));
217
- } else {
218
- $dataconf = array('premium_key' => '', 'premium_val' => '');
219
-
220
- $helper_licence = WYSIJA::get('licence', 'helper');
221
- $url_premium = 'http://www.mailpoet.com/checkout/?wysijadomain=' . $dt . '&nc=1&utm_source=wpadmin&utm_campaign=error_licence_activation';
222
-
223
- $this->error(str_replace(array('[link]', '[/link]'), array('<a href="' . $url_premium . '" target="_blank">', '</a>'), __('Premium licence does not exist for your site. Purchase it [link]here[/link].', WYSIJA)), 1);
224
- }
225
- WYSIJA::update_option('wysicheck', false);
226
- $modelConf = WYSIJA::get('config', 'model');
227
- $modelConf->save($dataconf);
228
-
229
- $this->redirect('admin.php?page=wysija_config#tab-premium');
230
- }
231
-
232
- /* END prem check hook */
233
-
234
- function validateLic() {
235
- $helpLic = WYSIJA::get('licence', 'helper');
236
- $res = $helpLic->check();
237
-
238
- $this->redirect();
239
- }
240
-
241
- /**
242
- * this function is triggered when sending manually the emails with the "Don't wait and send right now" button
243
- * @param type $dataPost
244
- */
245
- function manual_send($dataPost = false) {
246
- $modelQ = WYSIJA::get('queue', 'model');
247
- $config = WYSIJA::get('config', 'model');
248
- if ((int) $config->getValue('total_subscribers') < 2000) {
249
- if ($modelQ->count() > 0) {
250
- $helperQ = WYSIJA::get('queue', 'helper');
251
- $emailid = false;
252
- if ($_REQUEST['emailid']) {
253
- $emailid = $_REQUEST['emailid'];
254
- }
255
- $helperQ->process($emailid);
256
- } else {
257
- echo '<strong style="font-family: Arial; font-weight: bold; font-size: 12px;">' . __('Queue is empty!', WYSIJA) . '</strong>';
258
- }
259
- exit;
260
- } else {
261
- //deprecated
262
- do_action('wysija_send_test_editor');
263
-
264
- do_action('wysija_manual_send');
265
- }
266
-
267
- exit;
268
- }
269
-
270
- /**
271
- * test the bounce handling maybe this should move somewhere else like config controller
272
- * @return boolean
273
- */
274
- function test_bounce() {
275
- // bounce handling
276
- $helper_bounce = WYSIJA::get('bounce', 'helper');
277
-
278
- // in a multisite case we process first the bounce recording into the bounce table
279
- if (is_multisite()) {
280
- $helper_bounce->record_bounce_ms();
281
-
282
- // then we take actions from what has been returned by the bounce
283
- $helper_bounce->process_bounce_ms();
284
- } else {
285
- $helper_bounce->process_bounce();
286
- }
287
- exit;
288
- }
289
-
290
- function add($dataPost = false) {
291
- $this->title = sprintf(__('Step %1$s', WYSIJA), 1);
292
- $this->js[] = 'wysija-validator';
293
-
294
- $this->js[] = 'wysija-edit-autonl';
295
- $this->js['admin-campaigns-edit'] = 'admin-campaigns-edit';
296
- $this->jsTrans['descauto'] = str_replace(array('[newsletter:number]', '[newsletter:total]', '[newsletter:post_title]'), array('<b>[newsletter:number]</b>', '<b>[newsletter:total]</b>', '<b>[newsletter:post_title]</b>'), __('Insert [newsletter:total] to show number of posts, [newsletter:post_title] to show the latest post\'s title & [newsletter:number] to display the issue number.', WYSIJA));
297
- $this->jsTrans['descstandard'] = __('The first thing your subscribers see. Be creative and increase your open rate!', WYSIJA);
298
- $this->immediateWarning();
299
- $this->viewObj->title = __('First step: main details', WYSIJA);
300
- $this->viewShow = 'add';
301
- $this->data = array();
302
- $this->data['campaign'] = array('name' => '', 'description' => '');
303
- $modelConfig = WYSIJA::get('config', 'model');
304
- $this->data['email'] = array('subject' => '', 'from_email' => $modelConfig->getValue('from_email'), 'from_name' => $modelConfig->getValue('from_name'));
305
- $this->data['lists'] = $this->__getLists(false, true, true);
306
-
307
- $this->dataAutoNl();
308
- $this->jsLoc['admin-campaigns-edit']['autofields'] = $this->data['autonl']['fields'];
309
- }
310
-
311
- /**
312
- * get the fields and fields value necessary when dealing with automatic newsletters
313
- */
314
- function dataAutoNl() {
315
- $dataFrequencyNoImmediate = $dataFrequency = array('daily' => __('once a day at...', WYSIJA),
316
- 'weekly' => __('weekly on...', WYSIJA),
317
- 'monthly' => __('monthly on the...', WYSIJA),
318
- 'monthlyevery' => __('monthly every...', WYSIJA),
319
- 'immediate' => __('immediately.', WYSIJA));
320
-
321
- unset($dataFrequencyNoImmediate['immediate']);
322
-
323
- $times = array();
324
- $time = strtotime('00:00:00');
325
- $toolboxH = WYSIJA::get('toolbox', 'helper');
326
- $times['00:00:00'] = $toolboxH->localtime($time);
327
-
328
- for ($i = 1; $i < 24; $i++) {
329
- $time = strtotime('+ 1hour', $time);
330
- $key = date('H:i:s', $time);
331
- $times[$key] = $toolboxH->localtime($time);
332
- }
333
-
334
- $daysvalues = $toolboxH->getday();
335
-
336
- $numberweeks = $toolboxH->getweeksnumber();
337
- $daynumbers = $toolboxH->getdaynumber();
338
-
339
-
340
- $dataLists = array();
341
-
342
- foreach ($this->data['lists'] as $datal) {
343
- if ($datal['is_enabled'])
344
- $dataLists[$datal['list_id']] = $datal['name'];
345
- }
346
-
347
- // Get all available roles
348
- $wptoolsH = WYSIJA::get('wp_tools', 'helper');
349
- $roles = $wptoolsH->wp_get_all_roles();
350
- $available_roles = array('any' => __('in any WordPress role', WYSIJA));
351
- foreach ($roles as $role => $name) {
352
- $available_roles[$role] = $name;
353
- }
354
-
355
- $this->data['autonl']['fields'] = array(
356
- 'event' => array(
357
- 'values' => array(
358
- 'new-articles' => __('When there\'s new content...', WYSIJA),
359
- 'subs-2-nl' => __('When someone subscribes to the list...', WYSIJA),
360
- 'new-user' => __('When a new WordPress user is added to your site...', WYSIJA),
361
- ),
362
- 'valueshow' => array(
363
- 'new-articles' => array('when-article'),
364
- 'subs-2-nl' => array('subscribetolist', 'numberafter', 'numberofwhat', 'unique_send'),
365
- 'new-user' => array('roles', 'numberafter', 'numberofwhat', 'unique_send'),
366
- ),
367
- 'style' => 'width:300px;'
368
- ),
369
- 'when-article' => array(
370
- 'values' => $dataFrequency,
371
- 'valueshow' => array(
372
- 'daily' => array('time'),
373
- 'weekly' => array('dayname', 'time'),
374
- 'monthly' => array('daynumber', 'time'),
375
- 'monthlyevery' => array('dayevery', 'dayname', 'time'),
376
- )
377
- ),
378
- 'subscribetolist' => array(
379
- 'values' => $dataLists,
380
- 'style' => 'width:300px;'
381
- ),
382
- 'roles' => array(
383
- 'values' => $available_roles
384
- ),
385
- 'numberafter' => array(
386
- 'type' => 'input',
387
- 'style' => 'width:35px;',
388
- 'class' => 'validate[required,custom[integer],min[1]]',
389
- ),
390
- 'numberofwhat' => array(
391
- 'values' => array(
392
- 'immediate' => __('immediately.', WYSIJA),
393
- 'hours' => __('hour(s) after.', WYSIJA),
394
- 'days' => __('day(s) after.', WYSIJA),
395
- 'weeks' => __('week(s) after.', WYSIJA)
396
- ),
397
- 'valuesunit' => array(
398
- 'immediate' => __('immediately', WYSIJA),
399
- 'hours' => __('hour(s)', WYSIJA),
400
- 'days' => __('day(s)', WYSIJA),
401
- 'weeks' => __('week(s)', WYSIJA)
402
- ),
403
- ),
404
- 'dayevery' => array(
405
- 'values' => $numberweeks,
406
- ),
407
- 'dayname' => array(
408
- 'values' => $daysvalues,
409
- ),
410
- 'daynumber' => array(
411
- 'values' => $daynumbers,
412
- ),
413
- 'time' => array(
414
- 'values' => $times,
415
- ),
416
- /* 'unique_send'=>array(
417
- 'label_before'=>__('Send this email only once.',WYSIJA),
418
- 'type'=>'checkbox'
419
- ), */
420
- );
421
- $helpersEvent = WYSIJA::get('autonews', 'helper');
422
- $extraEvents = $helpersEvent->events();
423
-
424
- /* if there are plugin to add autonewsletter event they are adding their customized field over here */
425
- if ($extraEvents) {
426
- foreach ($extraEvents as $k => $v) {
427
-
428
- $this->data['autonl']['fields']['event']['values'][$k] = $v['title'];
429
- foreach ($v['fields'] as $fieldCKEY => $fieldCVAL) {
430
- if (isset($this->data['autonl']['fields'][$fieldCKEY]))
431
- continue;
432
- }
433
- $this->data['autonl']['fields']['event']['valueshow'][$k] = array_keys($v['fields']);
434
- }
435
- }
436
- }
437
-
438
- function __getLists($enabled = true, $count = false, $notgetalllistid = false) {
439
- $modelList = WYSIJA::get('list', 'model');
440
- //get lists which have users and are enabled */
441
- if ($enabled)
442
- $enabledstrg = ' is_enabled>0 and';
443
- else
444
- $enabledstrg = '';
445
-
446
- $extrasql = '';
447
- if (!$notgetalllistid)
448
- $extrasql = 'WHERE list_id in (SELECT distinct(list_id) from [wysija]user_list )';
449
- $query = 'SELECT * FROM [wysija]list ' . $extrasql;
450
- $listres = $modelList->query('get_res', $query);
451
-
452
- if ($count) {
453
- $mConfig = WYSIJA::get('config', 'model');
454
- $condit = '>=';
455
- if ($mConfig->getValue('confirm_dbleoptin'))
456
- $condit = '>';
457
- $qry1 = "SELECT count(distinct A.user_id) as nbsub,A.list_id FROM `[wysija]user_list` as A LEFT JOIN `[wysija]user` as B on A.user_id=B.user_id WHERE B.status $condit 0 and A.sub_date>0 and A.unsub_date=0 GROUP BY list_id";
458
-
459
- $total = $modelList->getResults($qry1);
460
-
461
- foreach ($total as $tot) {
462
- foreach ($listres as $key => $res) {
463
- if ($tot['list_id'] == $res['list_id'])
464
- $listres[$key]['count'] = $tot['nbsub'];
465
- }
466
- }
467
- }
468
- foreach ($listres as $key => $res) {
469
- if (!isset($res['count']))
470
- $listres[$key]['count'] = 0;
471
- }
472
- return $listres;
473
- }
474
-
475
- function edit($dataPost = false) {
476
- if (!$this->_checkEmailExists($_REQUEST['id']))
477
- return;
478
- $this->add();
479
-
480
- $modelEmail = WYSIJA::get('email', 'model');
481
-
482
- $this->data['email'] = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
483
-
484
- if ($this->data['email']['status'] > 0) {
485
- $this->redirect();
486
- }
487
- $this->title = sprintf(__('Step %1$s', WYSIJA), 1) . ' | ' . $this->data['email']['subject'];
488
- $modelCamp = WYSIJA::get('campaign', 'model');
489
- $this->data['campaign'] = $modelCamp->getOne(false, array('campaign_id' => $this->data['email']['campaign_id']));
490
-
491
- $modelCL = WYSIJA::get('campaign_list', 'model');
492
- $this->data['campaign_list'] = $modelCL->get(false, array('campaign_id' => $this->data['email']['campaign_id']));
493
- }
494
-
495
- function editTemplate() {
496
- // make sure the editor content is not cached
497
- header('Cache-Control: no-cache, max-age=0, must-revalidate, no-store'); // HTTP/1.1
498
- header('Expires: Fri, 9 Mar 1984 00:00:00 GMT');
499
-
500
- if (!$this->_checkEmailExists($_REQUEST['id']))
501
- return;
502
- $this->viewShow = 'editTemplate';
503
-
504
- wp_enqueue_style('thickbox');
505
-
506
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
507
- /* WJ editor translations */
508
- $this->jsTrans = array_merge($this->jsTrans, $wjEngine->getTranslations(), $wjEngine->getApplicationData());
509
-
510
- $this->jsTrans['savingnl'] = __('Saving newsletter...', WYSIJA);
511
- $this->jsTrans['errorsavingnl'] = __('Error Saving newsletter...', WYSIJA);
512
- $this->jsTrans['savednl'] = __('Newsletter has been saved.', WYSIJA);
513
- $this->jsTrans['previewemail'] = __('Sending preview...', WYSIJA);
514
- $this->jsTrans['spamtestresult'] = __('Spam test results', WYSIJA);
515
-
516
- /* WJ editor JS */
517
- $this->js[] = 'wysija-editor';
518
- $this->js[] = 'wysija-admin-ajax-proto';
519
- $this->js[] = 'wysija-admin-ajax';
520
- $this->js[] = 'wysija-base-script-64';
521
- $this->js[] = 'media-upload';
522
- $this->js['admin-campaigns-editDetails'] = 'admin-campaigns-editDetails';
523
- $modelEmail = WYSIJA::get('email', 'model');
524
- $this->data = array();
525
- $this->data['email'] = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
526
-
527
- $this->checkIsEditable();
528
-
529
- $this->viewObj->title = sprintf(__('Second step: "%1$s"', WYSIJA), $this->data['email']['subject']);
530
- $this->title = sprintf(__('Step %1$s', WYSIJA), 2) . " | " . $this->data['email']['subject'];
531
-
532
- // check if html source is enabled in the config (this will add the "html source" button in tinymce)
533
- $model_config = WYSIJA::get('config', 'model');
534
- $this->jsTrans['html_source_enabled'] = (int) $model_config->getValue('html_source');
535
- }
536
-
537
- function checkIsEditable() {
538
- if (
539
- !($this->data['email'] == 2 || isset($this->data['email']['params']['schedule']['isscheduled'])) && $this->data['email']['status'] > 0
540
- ) {
541
- $this->redirect();
542
- }
543
- }
544
-
545
- function pause() {
546
- /* pause the campaign entry */
547
- if (isset($_REQUEST['id']) && $_REQUEST['id']) {
548
- $modelEmail = WYSIJA::get('email', 'model');
549
- $myemail = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
550
- $modelEmail->reset();
551
- $modelEmail->columns['modified_at']['autoup'] = 1;
552
- $modelEmail->update(array('status' => -1), array('email_id' => $_REQUEST['id']));
553
-
554
- if ($myemail['type'] == 2) {
555
- return $this->redirect('admin.php?page=wysija_campaigns&id=' . $myemail['email_id'] . '&action=edit');
556
- } else {
557
- $this->notice(__('Sending is now paused.', WYSIJA));
558
- }
559
- }
560
-
561
- $this->redirect();
562
- }
563
-
564
- function resume() {
565
- /* pause the campaign entry */
566
- if (isset($_REQUEST['id']) && $_REQUEST['id']) {
567
- $modelEmail = WYSIJA::get('email', 'model');
568
- $modelEmail->columns['modified_at']['autoup'] = 1;
569
- $modelEmail->update(array('status' => 99), array('email_id' => $_REQUEST['id']));
570
- $this->notice(__('Sending has resumed.', WYSIJA));
571
- }
572
-
573
- $this->redirect();
574
- }
575
-
576
- function duplicate() {
577
-
578
- /* 1 - copy the campaign entry */
579
-
580
- $model = WYSIJA::get('campaign', 'model');
581
- $query = 'INSERT INTO `[wysija]campaign` (`name`,`description`)
582
- SELECT concat("' . stripslashes(__('Copy of ', WYSIJA)) . '",`name`),`description` FROM [wysija]campaign
583
- WHERE campaign_id=' . (int) $_REQUEST['id'];
584
- $campaignid = $model->query($query);
585
-
586
- /* 2 - copy the email entry */
587
- $query = 'INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
588
- SELECT ' . $campaignid . ', concat("' . stripslashes(__('Copy of ', WYSIJA)) . '",`subject`),`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,' . time() . ',' . time() . ' FROM [wysija]email
589
- WHERE email_id=' . (int) $_REQUEST['email_id'];
590
- $emailid = $model->query($query);
591
-
592
- //let's reset the count of total childs for auto newsletter
593
- $mEmail = WYSIJA::get('email', 'model');
594
- $emailData = $mEmail->getOne(false, array('email_id' => $emailid));
595
-
596
- if ($emailData['type'] == 2) {
597
- $paramsReseted = $emailData['params'];
598
- if (isset($paramsReseted['autonl']['total_child']))
599
- $paramsReseted['autonl']['total_child'] = 0;
600
- if (isset($paramsReseted['autonl']['nextSend']))
601
- $paramsReseted['autonl']['nextSend'] = 0;
602
- if (isset($paramsReseted['autonl']['firstSend']))
603
- unset($paramsReseted['autonl']['firstSend']);
604
- if (isset($paramsReseted['autonl']['lastSend']))
605
- unset($paramsReseted['autonl']['lastSend']);
606
- if (isset($paramsReseted['autonl']['articles']['ids']))
607
- unset($paramsReseted['autonl']['articles']['ids']);
608
-
609
-
610
- $mEmail->update(array('params' => $paramsReseted), array('email_id' => $emailid));
611
- }
612
-
613
- /* 3 - copy the campaign_list entry */
614
- $query = "INSERT INTO `[wysija]campaign_list` (`campaign_id`,`list_id`,`filter`)
615
- SELECT $campaignid,`list_id`,`filter` FROM [wysija]campaign_list
616
- WHERE campaign_id=" . (int) $_REQUEST['id'];
617
- $model->query($query);
618
-
619
- $this->notice(__('The newsletter has been duplicated.', WYSIJA));
620
-
621
- $this->redirect('admin.php?page=wysija_campaigns&id=' . $emailid . '&action=edit');
622
- }
623
-
624
- function duplicateEmail() {
625
- if (!$this->_checkEmailExists($_REQUEST['id']))
626
- return;
627
-
628
- $model = WYSIJA::get('campaign', 'model');
629
- /* 2 - copy the email entry */
630
- $query = 'INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
631
- SELECT `campaign_id`, concat("' . stripslashes(__("Copy of ", WYSIJA)) . '",`subject`),`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,' . time() . ',' . time() . ' FROM [wysija]email
632
- WHERE email_id=' . (int) $_REQUEST['id'];
633
- $emailid = $model->query($query);
634
-
635
- $this->notice(__('The newsletter has been duplicated.', WYSIJA));
636
-
637
- $this->redirect('admin.php?page=wysija_campaigns&id=' . $emailid . '&action=edit');
638
- }
639
-
640
- function immediateWarning() {
641
- $model_config = WYSIJA::get('config', 'model');
642
- $is_multisite = is_multisite();
643
-
644
- //$is_multisite=true;//PROD comment that line
645
- if ($is_multisite && $model_config->getValue('sending_method') == 'network') {
646
- $sending_emails_each = $model_config->getValue('ms_sending_emails_each');
647
- $number = $model_config->getValue('ms_sending_emails_number');
648
- } else {
649
- $sending_emails_each = $model_config->getValue('sending_emails_each');
650
- $number = $model_config->getValue('sending_emails_number');
651
- }
652
-
653
- $formsHelp = WYSIJA::get('forms', 'helper');
654
-
655
- $timespan = $formsHelp->eachValuesSec[$sending_emails_each];
656
- $tb = WYSIJA::get('toolbox', 'helper');
657
-
658
- $this->immediatewarning = str_replace(
659
- array('[link]', '[/link]', '[settings]'), array('<a href="#">', '</a>', sprintf(__('%1$s emails every %2$s', WYSIJA), $number, trim($tb->duration_string($timespan, true)))), __('Your sending settings ([settings]) can\'t send that quickly to [number] subscribers. Expect delivery delays. [link]Read more[/link]', WYSIJA));
660
- $this->viewObj->immediatewarning = '<span class="warning-msg" id="immediatewarning">' . $this->immediatewarning . '</span>';
661
-
662
- $this->jsTrans['immediatewarning'] = $this->immediatewarning;
663
-
664
- //how many emails can be sent in 12 hours
665
- //if the frequency is less than 12hours
666
- if ($timespan < 43200) {
667
- $ratio = floor(43200 / $timespan);
668
- $this->jsTrans['possibleemails'] = $ratio * $number;
669
- } else {
670
- if ($timespan == 43200) {
671
- $this->jsTrans['possibleemails'] = $number;
672
- } else {
673
- $ratio = floor($timespan / 43200);
674
- $this->jsTrans['possibleemails'] = $number / $ratio;
675
- }
676
- }
677
- }
678
-
679
- function editDetails() {
680
- if (!$this->_checkEmailExists($_REQUEST['id']))
681
- return;
682
- $this->viewObj->title = __('Final step: last details', WYSIJA);
683
- $this->viewShow = 'editDetails';
684
- $this->js[] = 'wysija-validator';
685
- $this->jsTrans['previewemail'] = __('Sending preview...', WYSIJA);
686
- $this->jsTrans['pickadate'] = __('Pick a date', WYSIJA);
687
- $this->jsTrans['saveclose'] = __('Save & close', WYSIJA);
688
- $this->jsTrans['sendlater'] = __('Send later', WYSIJA);
689
-
690
- $this->jsTrans['schedule'] = __('Schedule', WYSIJA);
691
-
692
- $this->jsTrans['emailCheck'] = WJ_Utils::get_tip_data();
693
-
694
-
695
- $this->js[] = 'jquery-ui-datepicker';
696
- $this->js[] = 'wysija-tooltip';
697
-
698
- $model_list = WYSIJA::get('list', 'model');
699
- $model_list->limitON = false;
700
- $this->data = array();
701
- $this->data['lists'] = $this->__getLists(false, true, true);
702
-
703
- $model_email = WYSIJA::get('email', 'model');
704
- $this->data['email'] = $model_email->getOne(false, array('email_id' => $_REQUEST['id']));
705
-
706
- // The first newsletter, we don't have replyto_email and replyto_name
707
- if (empty($this->data['email']['replyto_email']) || empty($this->data['email']['replyto_name'])) {
708
- $current_user = wp_get_current_user();
709
- $this->data['email']['replyto_email'] = $current_user->data->user_email;
710
- $this->data['email']['replyto_name'] = $current_user->data->display_name;
711
- }
712
-
713
-
714
- if ((int) $this->data['email']['type'] == 2) {
715
- $this->js['wysija-edit-autonl'] = 'wysija-edit-autonl';
716
- $this->jsTrans['autonl'] = true;
717
- $this->immediateWarning();
718
- $this->jsTrans['send'] = __('Activate now', WYSIJA);
719
- } else {
720
- $this->jsTrans['autonl'] = true;
721
- $this->viewObj->immediatewarning = '';
722
- $this->jsTrans['send'] = __('Send', WYSIJA);
723
- }
724
-
725
- if ((int) $this->data['email']['type'] == 1) {
726
- $this->jsTrans['alertsend'] = __('You are about to send this newsletter. Please confirm.', WYSIJA);
727
- } else {
728
- if (isset($this->data['email']['params']['autonl']['event']) && $this->data['email']['params']['autonl']['event'] == 'subs-2-nl') {
729
- $this->data['autoresponder'] = 1;
730
- foreach ($this->data['lists'] as $list) {
731
- if ($list['list_id'] == $this->data['email']['params']['autonl']['subscribetolist']) {
732
- break;
733
- }
734
- }
735
-
736
- $this->jsTrans['ignoreprevious'] = sprintf(__('Are you sure you want to ignore the %1$s subscribers of the list %2$s?', WYSIJA), '"' . $list['count'] . '"', '"' . $list['name'] . '"');
737
- }
738
- }
739
-
740
- $this->checkIsEditable();
741
-
742
- $this->title = sprintf(__('Step %1$s', WYSIJA), 3) . " | " . $this->data['email']['subject'];
743
- $this->dataAutoNl();
744
-
745
- $this->jsLoc['wysija-edit-autonl']['autofields'] = $this->data['autonl']['fields'];
746
-
747
- $modelCL = WYSIJA::get('campaign_list', 'model');
748
- $this->data['campaign_list'] = $modelCL->get(false, array('campaign_id' => $this->data['email']['campaign_id']));
749
- }
750
-
751
- function delete() {
752
- $this->requireSecurity();
753
-
754
- $campaign_ids = array();
755
- if(isset($_REQUEST['id'])) $campaign_ids[] = $_REQUEST['id'];
756
- if(isset($_REQUEST['campaign']['campaign_id'])) $campaign_ids[] = $_REQUEST['campaign']['campaign_id'];
757
- if(isset($_REQUEST['wysija']['campaign']['campaign_id'][0])){
758
- $campaign_ids = array_merge($campaign_ids, $_REQUEST['wysija']['campaign']['campaign_id']);
759
- }
760
-
761
- if (!empty($campaign_ids)) {
762
- foreach($campaign_ids as $campaign_id){
763
- if($campaign_id > 0){
764
- $model_campaign = WYSIJA::get('campaign', 'model');
765
- $model_campaign->delete(array('campaign_id' => $campaign_id));
766
-
767
- $model_campaign_list = WYSIJA::get('campaign_list', 'model');
768
- $model_campaign_list->delete(array('campaign_id' => $campaign_id));
769
-
770
- $modelEmail = WYSIJA::get('email', 'model');
771
- $modelEmail->delete(array('campaign_id' => $campaign_id));
772
- }
773
- }
774
-
775
- $this->notice(_n(__('Newsletter deleted.', WYSIJA), __('Newsletters deleted.', WYSIJA), count($campaign_ids), WYSIJA));
776
- } else {
777
- $this->notice(__('Newsletter can\'t be deleted.', WYSIJA));
778
- }
779
-
780
- // retrieve saved filter
781
- if (!empty($_REQUEST['action']))
782
- unset($_REQUEST['action']);
783
- if (!empty($_REQUEST['id']))
784
- unset($_REQUEST['id']);
785
- if (!empty($_REQUEST['_wpnonce']))
786
- unset($_REQUEST['_wpnonce']);
787
- $redirect = $this->base_url . '?' . http_build_query($_REQUEST);
788
- $this->redirect($redirect);
789
- }
790
-
791
- /**
792
- *
793
- * this function is to delete an email that belongs to a campaign
794
- * when we have a post notification all emails belong to the same campaign
795
- * we don't want to delete an entire campaign when we delete a single email
796
- */
797
- function deleteEmail(){
798
- $this->requireSecurity();
799
- if(!$this->_checkEmailExists($_REQUEST['id'])) return;
800
-
801
- if(isset($_REQUEST['id'])){
802
- $modelEmail=WYSIJA::get('email','model');
803
- $modelEmail->delete(array('email_id'=>$_REQUEST['id']));
804
- $this->notice(__('Newsletter deleted.',WYSIJA));
805
- }else{
806
- $this->notice(__('Newsletter can\'t be deleted.',WYSIJA));
807
- }
808
-
809
- $this->redirect();
810
- }
811
-
812
- function savecamp() {
813
- $this->redirectAfterSave = false;
814
-
815
- /* update email */
816
- $data = array();
817
-
818
- // in case the newsletter already exists
819
- if (isset($_REQUEST['id'])) {
820
- $modelEmail = WYSIJA::get('email', 'model');
821
- $modelEmail->fieldValid = false;
822
- $emaildataarr = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
823
-
824
- $model_campaign = WYSIJA::get('campaign', 'model');
825
- $model_campaign->update(array('name' => $_POST['wysija']['email']['subject'], 'description' => ''), array('campaign_id' => $emaildataarr['campaign_id']));
826
-
827
- $campaign_id = $emaildataarr['campaign_id'];
828
- $email_id = $emaildataarr['email_id'];
829
- $dataEmail = array(
830
- 'campaign_id' => $campaign_id,
831
- 'subject' => $_POST['wysija']['email']['subject'],
832
- 'type' => $_POST['wysija']['email']['type']);
833
-
834
- if((int)$dataEmail['type'] === 2) {
835
- // set autonl params
836
- $dataEmail['params'] = array('autonl' => $_POST['wysija']['email']['params']['autonl']);
837
-
838
- // WTF?
839
- if(!isset($newparams['autonl']['unique_send'])) {
840
- unset($dataEmail['params']['autonl']['unique_send']);
841
- } else {
842
- $dataEmail['params']['autonl']['unique_send'] = true;
843
- }
844
- }
845
-
846
- // check if the newsletter used to be an automatic newsletter (if )
847
- if((int)$dataEmail['type'] === 1 && (int)$emaildataarr['type'] === 2) {
848
- // make sure we remove any kind of auto-post block
849
- $helper_autonews = WYSIJA::get('autonews', 'helper');
850
- $updated_email_data = $helper_autonews->remove_autopost_blocks($emaildataarr['wj_data']);
851
- if($updated_email_data !== false) {
852
- // if the email data has been changed, make sure to update it in the DB
853
- $dataEmail['wj_data'] = $updated_email_data;
854
- }
855
- }
856
-
857
- $modelEmail->columns['modified_at']['autoup'] = 1;
858
- $modelEmail->debugupdate = true;
859
- $dataEmail['email_id'] = $_REQUEST['id'];
860
-
861
- if(isset($_REQUEST['save-reactivate'])) {
862
- //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
863
- $dataEmail['status'] = 99;
864
- $_REQUEST['return'] = 1;
865
- }
866
-
867
- $data['email']['email_id'] = $modelEmail->update($dataEmail, array('email_id' => (int)$_REQUEST['id']));
868
- } else {
869
- // get default theme
870
- $model_config = WYSIJA::get('config', 'model');
871
- $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
872
-
873
- $helper_themes = WYSIJA::get('themes', 'helper');
874
- $theme_data = $helper_themes->getData($default_theme);
875
-
876
- // get campaign data
877
- $model_campaign = WYSIJA::get('campaign', 'model');
878
- $campaign_id = $model_campaign->insert(array('name' => $_POST['wysija']['email']['subject'], 'description' => ''));
879
-
880
- $modelEmail = WYSIJA::get('email', 'model');
881
- $modelEmail->fieldValid = false;
882
- $emaildata = array(
883
- 'campaign_id' => $campaign_id,
884
- 'subject' => $_POST['wysija']['email']['subject'],
885
- 'type' => (int) $_POST['wysija']['email']['type']
886
- );
887
-
888
-
889
- // create autonl parameters if necessary
890
- if ((int) $_POST['wysija']['email']['type'] === 2 && isset($_POST['wysija']['email']['params']['autonl'])) {
891
- $emaildata['params'] = array('autonl' => $_POST['wysija']['email']['params']['autonl']);
892
- }
893
-
894
- // create sample data depending on newsletter's type
895
- if ((int) $_POST['wysija']['email']['type'] === 2 && $_POST['wysija']['email']['params']['autonl']['event'] === 'new-articles') {
896
-
897
- // if immediate, post_limit is set to 1
898
- if ($emaildata['params']['autonl']['when-article'] === 'immediate') {
899
- $autopostParams = array(
900
- array('key' => 'category_ids', 'value' => null),
901
- array('key' => 'title_tag', 'value' => 'h2'),
902
- array('key' => 'title_alignment', 'value' => 'left'),
903
- array('key' => 'title_position', 'value' => 'inside'),
904
- array('key' => 'image_alignment', 'value' => 'alternate'),
905
- array('key' => 'image_width', 'value' => 325),
906
- array('key' => 'post_content', 'value' => 'excerpt'),
907
- array('key' => 'readmore', 'value' => base64_encode(__('Read more.', WYSIJA))),
908
- array('key' => 'show_divider', 'value' => 'yes'),
909
- array('key' => 'post_limit', 'value' => 1),
910
- array('key' => 'post_type', 'value' => 'post'),
911
- array('key' => 'author_show', 'value' => 'no'),
912
- array('key' => 'author_label', 'value' => base64_encode(__('Author:', WYSIJA))),
913
- array('key' => 'category_show', 'value' => 'no'),
914
- array('key' => 'category_label', 'value' => base64_encode(__('Categories:', WYSIJA))),
915
- array('key' => 'nopost_message', 'value' => base64_encode(__('Latest content already sent.', WYSIJA))),
916
- array('key' => 'bgcolor1', 'value' => null),
917
- array('key' => 'bgcolor2', 'value' => null),
918
- array('key' => 'sort_by', 'value' => 'newest')
919
- );
920
- } else {
921
- $autopostParams = array(
922
- array('key' => 'category_ids', 'value' => null),
923
- array('key' => 'title_tag', 'value' => 'h2'),
924
- array('key' => 'title_alignment', 'value' => 'left'),
925
- array('key' => 'title_position', 'value' => 'inside'),
926
- array('key' => 'image_alignment', 'value' => 'alternate'),
927
- array('key' => 'image_width', 'value' => 325),
928
- array('key' => 'post_content', 'value' => 'excerpt'),
929
- array('key' => 'readmore', 'value' => base64_encode(__('Read more.', WYSIJA))),
930
- array('key' => 'show_divider', 'value' => 'yes'),
931
- array('key' => 'post_limit', 'value' => 2),
932
- array('key' => 'post_type', 'value' => 'post'),
933
- array('key' => 'author_show', 'value' => 'no'),
934
- array('key' => 'author_label', 'value' => base64_encode(__('Author:', WYSIJA))),
935
- array('key' => 'category_show', 'value' => 'no'),
936
- array('key' => 'category_label', 'value' => base64_encode(__('Categories:', WYSIJA))),
937
- array('key' => 'nopost_message', 'value' => base64_encode(__('Latest content already sent.', WYSIJA))),
938
- array('key' => 'bgcolor1', 'value' => null),
939
- array('key' => 'bgcolor2', 'value' => null),
940
- array('key' => 'sort_by', 'value' => 'newest')
941
- );
942
- }
943
-
944
- // sample data for post notifications
945
- $newwjdata = array(
946
- 'version' => WYSIJA::get_version(),
947
- 'header' => array(
948
- 'text' => NULL,
949
- 'image' => array(
950
- 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
951
- 'width' => 600,
952
- 'height' => 86,
953
- 'alignment' => 'center',
954
- 'static' => true,
955
- ),
956
- 'alignment' => 'center',
957
- 'static' => true,
958
- 'type' => 'header'
959
- ),
960
- 'body' => array(
961
- 'block-1' => array(
962
- 'text' => array(
963
- 'value' => '<h3 class="align-right">' . sprintf(__("The posts below were added with the widget %sAutomatic latest content%s", WYSIJA), '<strong>', '</strong>') . '</h3>'
964
- ),
965
- 'image' => array(
966
- 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/autonewsletter/arrow-up.png',
967
- 'width' => 45,
968
- 'height' => 45,
969
- 'alignment' => 'right',
970
- 'static' => false
971
- ),
972
- 'alignment' => 'right',
973
- 'static' => false,
974
- 'position' => '1',
975
- 'type' => 'content'
976
- ),
977
- 'block-2' => array(
978
- 'text' => array(
979
- 'value' => '<h3>' . sprintf(__('%sTo edit%s, mouse over to show edit button below.', WYSIJA), '<strong>', '</strong>') . '</h3>'
980
- ),
981
- 'image' => array(
982
- 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/autonewsletter/arrow-down.png',
983
- 'width' => 150,
984
- 'height' => 53,
985
- 'alignment' => 'left',
986
- 'static' => false
987
- ),
988
- 'alignment' => 'left',
989
- 'static' => false,
990
- 'position' => '2',
991
- 'type' => 'content'
992
- ),
993
- 'block-3' => array(
994
- 'params' => $autopostParams,
995
- 'position' => '3',
996
- 'type' => 'auto-post'
997
- )
998
- ),
999
- 'footer' => array(
1000
- 'text' => NULL,
1001
- 'image' => array(
1002
- 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1003
- 'width' => 600,
1004
- 'height' => 86,
1005
- 'alignment' => 'center',
1006
- 'static' => true,
1007
- ),
1008
- 'alignment' => 'center',
1009
- 'static' => true,
1010
- 'type' => 'footer'
1011
- )
1012
- );
1013
- } else {
1014
- if(!isset($emaildata['params'])) {
1015
- $emaildata['params'] = array();
1016
- }
1017
-
1018
- $emaildata['params']['quickselection'] = array(
1019
- 'wp-301' => array(
1020
- 'identifier' => 'wp-301',
1021
- 'width' => 281,
1022
- 'height' => 190,
1023
- 'url' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon.png',
1024
- 'thumb_url' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon-150x150.png'
1025
- )
1026
- );
1027
-
1028
- if($theme_data['divider'] === null) {
1029
- // default theme does not exist anymore or there is no divider associated to the theme
1030
- // we need to get the default divider in this case
1031
- $helper_dividers = WYSIJA::get('dividers', 'helper');
1032
- $default_divider = $helper_dividers->getDefault();
1033
- } else {
1034
- // set default divider
1035
- $default_divider = $theme_data['divider'];
1036
- }
1037
- // set default divider in email parameters
1038
- $emaildata['params']['divider'] = $default_divider;
1039
-
1040
- // get bookmarks from iconset 2
1041
- $helper_bookmarks = WYSIJA::get('bookmarks', 'helper');
1042
- $bookmarks = $helper_bookmarks->getAllByIconset('medium', '02');
1043
-
1044
- // sample data for regular newsletter
1045
- $newwjdata = array(
1046
- 'version' => WYSIJA::get_version(),
1047
- 'header' => array(
1048
- 'text' => null,
1049
- 'image' => array(
1050
- // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/header.png',
1051
- 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1052
- 'width' => 600,
1053
- 'height' => 86,
1054
- 'alignment' => 'center',
1055
- 'static' => true
1056
- ),
1057
- 'alignment' => 'center',
1058
- 'static' => true,
1059
- 'type' => 'header'
1060
- ),
1061
- 'body' => array(
1062
- 'block-1' => array(
1063
- 'text' => array(
1064
- 'value' => '<h2><strong>' . __('Step 1:', WYSIJA) . '</strong> ' . __('hey, click on this text!', WYSIJA) . '</h2>' . '<p>' . __('To edit, simply click on this block of text.', WYSIJA) . '</p>'
1065
- ),
1066
- 'image' => null,
1067
- 'alignment' => 'left',
1068
- 'static' => false,
1069
- 'position' => 1,
1070
- 'type' => 'content'
1071
- ),
1072
- 'block-2' => array_merge(array(
1073
- 'position' => 2,
1074
- 'type' => 'divider'
1075
- ),
1076
- $default_divider
1077
- ),
1078
- 'block-3' => array(
1079
- 'text' => array(
1080
- 'value' => '<h2><strong>' . __('Step 2:', WYSIJA) . '</strong> ' . __('play with this image', WYSIJA) . '</h2>'
1081
- ),
1082
- 'image' => null,
1083
- 'alignment' => 'left',
1084
- 'static' => false,
1085
- 'position' => 3,
1086
- 'type' => 'content'
1087
- ),
1088
- 'block-4' => array(
1089
- 'text' => array(
1090
- 'value' => '<p>' . __('Position your mouse over the image to the left.', WYSIJA) . '</p>'
1091
- ),
1092
- 'image' => array(
1093
- 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon.png',
1094
- 'width' => 281,
1095
- 'height' => 190,
1096
- 'alignment' => 'left',
1097
- 'static' => false
1098
- ),
1099
- 'alignment' => 'left',
1100
- 'static' => false,
1101
- 'position' => 4,
1102
- 'type' => 'content'
1103
- ),
1104
- 'block-5' => array_merge(array(
1105
- 'position' => 5,
1106
- 'type' => 'divider'
1107
- ), $default_divider
1108
- ),
1109
- 'block-6' => array(
1110
- 'text' => array(
1111
- 'value' => '<h2><strong>' . __('Step 3:', WYSIJA) . '</strong> ' . __('drop content here', WYSIJA) . '</h2>' .
1112
- '<p>' . sprintf(__('Drag and drop %1$stext, posts, dividers.%2$s Look on the right!', WYSIJA), '<strong>', '</strong>') . '</p>' .
1113
- '<p>' . sprintf(__('You can even %1$ssocial bookmarks%2$s like these:', WYSIJA), '<strong>', '</strong>') . '</p>'
1114
- ),
1115
- 'image' => null,
1116
- 'alignment' => 'left',
1117
- 'static' => false,
1118
- 'position' => 6,
1119
- 'type' => 'content'
1120
- ),
1121
- 'block-7' => array(
1122
- 'width' => 184,
1123
- 'alignment' => 'center',
1124
- 'items' => array(
1125
- array_merge(array(
1126
- 'url' => 'http://www.facebook.com/mailpoetplugin',
1127
- 'alt' => 'Facebook',
1128
- 'cellWidth' => 61,
1129
- 'cellHeight' => 32
1130
- ), $bookmarks['facebook']),
1131
- array_merge(array(
1132
- 'url' => 'http://www.twitter.com/mail_poet',
1133
- 'alt' => 'Twitter',
1134
- 'cellWidth' => 61,
1135
- 'cellHeight' => 32
1136
- ), $bookmarks['twitter']),
1137
- array_merge(array(
1138
- 'url' => 'https://plus.google.com/+Mailpoet',
1139
- 'alt' => 'Google',
1140
- 'cellWidth' => 61,
1141
- 'cellHeight' => 32
1142
- ), $bookmarks['google'])
1143
- ),
1144
- 'position' => 7,
1145
- 'type' => 'gallery'
1146
- ),
1147
- 'block-8' => array_merge(array(
1148
- 'position' => 8,
1149
- 'type' => 'divider'
1150
- ), $default_divider
1151
- ),
1152
- 'block-9' => array(
1153
- 'text' => array(
1154
- 'value' => '<h2><strong>' . __('Step 4:', WYSIJA) . '</strong> ' . __('and the footer?', WYSIJA) . '</h2>' .
1155
- '<p>' . sprintf(__('Change the footer\'s content in MailPoet\'s %1$sSettings%2$s page.', WYSIJA), '<strong>', '</strong>') . '</p>'
1156
- ),
1157
- 'image' => null,
1158
- 'alignment' => 'left',
1159
- 'static' => false,
1160
- 'position' => 9,
1161
- 'type' => 'content'
1162
- )
1163
- ),
1164
- 'footer' => array(
1165
- 'text' => NULL,
1166
- 'image' => array(
1167
- // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/footer.png',
1168
- 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1169
- 'width' => 600,
1170
- 'height' => 86,
1171
- 'alignment' => 'center',
1172
- 'static' => true,
1173
- ),
1174
- 'alignment' => 'center',
1175
- 'static' => true,
1176
- 'type' => 'footer'
1177
- )
1178
- );
1179
- }
1180
-
1181
- // set default styles
1182
- $helper_engine = WYSIJA::get('wj_engine', 'helper');
1183
- $styles = $helper_engine->getDefaultStyles();
1184
- // end - set default styles
1185
-
1186
- // set theme specific data
1187
- if($theme_data['header'] !== null) {
1188
- $newwjdata['header'] = $theme_data['header'];
1189
- }
1190
- if($theme_data['footer'] !== null) {
1191
- $newwjdata['footer'] = $theme_data['footer'];
1192
- }
1193
- if($theme_data['divider'] !== null) {
1194
- $newwjdata['widgets'] = array('divider' => $theme_data['divider']);
1195
- }
1196
- // end - set theme specific data
1197
-
1198
- $emaildata['wj_data'] = base64_encode(serialize($newwjdata));
1199
- $emaildata['wj_styles'] = base64_encode(serialize($styles));
1200
-
1201
- $email_id = $data['email']['email_id'] = $modelEmail->insert($emaildata);
1202
-
1203
- $this->notice(__('Newsletter successfully created.', WYSIJA));
1204
- }
1205
-
1206
- $this->_saveLists($campaign_id, true);
1207
-
1208
- if (isset($_REQUEST['return']))
1209
- $this->redirect();
1210
- else {
1211
- $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id=' . $email_id);
1212
- }
1213
- }
1214
-
1215
- function saveemail() {
1216
- $this->redirectAfterSave = false;
1217
- //$this->requireSecurity();
1218
- $modelEmail = WYSIJA::get("email", "model");
1219
- $modelEmail->fieldValid = false;
1220
- $emaildataarr = $modelEmail->getOne(array('email_id' => $_REQUEST['id']));
1221
-
1222
- if (isset($_REQUEST['save-reactivate'])) {
1223
- //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
1224
- $dataEmail['status'] = 99;
1225
- $_REQUEST['return'] = 1;
1226
- }
1227
-
1228
- if (isset($_REQUEST['return']))
1229
- $this->redirect();
1230
- else {
1231
- $this->redirect('admin.php?page=wysija_campaigns&action=editDetails&id=' . $emaildataarr['email_id']);
1232
- }
1233
- }
1234
-
1235
- function savelast() {
1236
- $this->redirectAfterSave = false;
1237
- $post_notification = false;
1238
- $this->requireSecurity();
1239
-
1240
- if (!isset($_POST['wysija']['email']['from_name']) || !isset($_POST['wysija']['email']['from_email']) || !isset($_POST['wysija']['email']['replyto_name']) || !isset($_POST['wysija']['email']['replyto_email'])) {
1241
- $this->error(__('Information is missing.', WYSIJA));
1242
- return $this->editDetails();
1243
- }
1244
- if (isset($_REQUEST['wysija']['email']['params']['googletrackingcode']) && $_REQUEST['wysija']['email']['params']['googletrackingcode'] &&
1245
- (!is_string($_REQUEST['wysija']['email']['params']['googletrackingcode']) OR
1246
- preg_match('#[^a-z0-9_\-\s]#i', $_REQUEST['wysija']['email']['params']['googletrackingcode']) !== 0 )) {
1247
- //force to simple text
1248
- $_REQUEST['wysija']['email']['params']['googletrackingcode'] = preg_replace('#[^a-z0-9_\-\s]#i', '_', $_REQUEST['wysija']['email']['params']['googletrackingcode']);
1249
- $this->error(__('Your Google Campaign can only contain latin characters, numbers, spaces and hyphens!', WYSIJA), 1);
1250
- return $this->editDetails();
1251
- }
1252
-
1253
- $update_email = array(
1254
- 'email_id' => $_POST['wysija']['email']['email_id'],
1255
- 'from_name' => $_POST['wysija']['email']['from_name'],
1256
- 'from_email' => $_POST['wysija']['email']['from_email'],
1257
- 'replyto_name' => $_POST['wysija']['email']['replyto_name'],
1258
- 'replyto_email' => $_POST['wysija']['email']['replyto_email'],
1259
- 'subject' => $_POST['wysija']['email']['subject'],
1260
- );
1261
- $model_email = WYSIJA::get('email', 'model');
1262
- if (isset($_POST['wysija']['email']['params']))
1263
- $update_email['params'] = $_POST['wysija']['email']['params'];
1264
-
1265
- //insert into campaigns lists
1266
- $this->_saveLists($_POST['wysija']['campaign']['campaign_id']);
1267
- $email_data = $model_email->getOne($_POST['wysija']['email']['email_id']);
1268
-
1269
- // if we just save the draf we don't go through the big sending process setup
1270
- if (isset($_POST['submit-draft']) || isset($_POST['submit-pause']) || (isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir'] == 'savelastback')) {
1271
- if (isset($_POST['wysija']['email']['params']['schedule']['isscheduled']))
1272
- $this->notice(__('Newsletter has been scheduled.', WYSIJA));
1273
- else
1274
- $this->notice(__('Newsletter has been saved as a draft.', WYSIJA));
1275
- }else {
1276
- // we update the param attribute with what's has been posted
1277
- foreach ($update_email as $ki => $vi) {
1278
- if ($ki == 'params') {
1279
- foreach ($vi as $parake => $paraval) {
1280
- $email_data['params'][$parake] = $paraval;
1281
- }
1282
- $update_email[$ki] = $email_data[$ki];
1283
- }
1284
- else
1285
- $email_data[$ki] = $vi;
1286
- }
1287
-
1288
- // if the checkbox to ignore retroactivity is here we just tell the class
1289
- if (isset($_POST['wysija']['email']['ignore_subscribers'])) {
1290
- $model_email->retro_active_autoresponders = false;
1291
- }
1292
-
1293
- // activate or send the email depending on the typ
1294
- $model_email->send_activate($email_data);
1295
- }
1296
-
1297
- // update email
1298
- $update_email['type'] = $email_data['type'];
1299
-
1300
- if ($post_notification) {
1301
- $helper_autonews = WYSIJA::get('autonews', 'helper');
1302
- $update_email['params']['autonl']['nextSend'] = $helper_autonews->getNextSend($update_email);
1303
- }
1304
-
1305
- $model_email->reset();
1306
- $model_email->columns['modified_at']['autoup'] = 1;
1307
-
1308
- // update some fields of the email
1309
- $model_email->update($update_email);
1310
-
1311
- // update the campaign subject which ispretty much useless but good to keep in sync with the email
1312
- $model_campaign = WYSIJA::get('campaign', 'model');
1313
- $model_campaign->reset();
1314
- $update_campaign = array('campaign_id' => $_REQUEST['id'], 'name' => $_POST['wysija']['email']['subject']);
1315
- $model_campaign->update($update_campaign);
1316
-
1317
- if (isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir'] == 'savelastback') {
1318
- return $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id=' . $_POST['wysija']['email']['email_id']);
1319
- }
1320
- else
1321
- return $this->redirect();
1322
- }
1323
-
1324
- function _saveLists($campaignId, $flagup = false) {
1325
- //record the list that we have in that campaign
1326
- $modelCampL = WYSIJA::get('campaign_list', 'model');
1327
- if ($flagup || (int) $campaignId > 0) {
1328
- $modelCampL->delete(array('equal' => array('campaign_id' => $campaignId)));
1329
- $modelCampL->reset();
1330
- }
1331
-
1332
- if (isset($_POST['wysija']['campaign_list']['list_id'])) {
1333
- //$modelCampL=WYSIJA::get("campaign_list","model");
1334
- foreach ($_POST['wysija']['campaign_list']['list_id'] as $listid) {
1335
- $modelCampL->insert(array('campaign_id' => $campaignId, "list_id" => $listid));
1336
- }
1337
- }
1338
- }
1339
-
1340
- function _addLinkFilter($status, $type = 'status') {
1341
- switch ($type) {
1342
- case 'status':
1343
- switch ($status) {
1344
- case 'draft':
1345
- $this->filters['equal'] = array('status' => 0);
1346
- break;
1347
- case 'sending':
1348
- $this->filters['equal'] = array('status' => 99);
1349
- break;
1350
- case 'sent':
1351
- $this->filters['equal'] = array('status' => 2);
1352
- break;
1353
- case 'paused':
1354
- $this->filters['equal'] = array('status' => -1);
1355
- break;
1356
- case 'scheduled':
1357
- $this->filters['equal'] = array('status' => 4);
1358
- break;
1359
- }
1360
- break;
1361
- case 'type':
1362
- switch ($status) {
1363
- case 'regular':
1364
- $this->filters['equal'] = array('type' => 1);
1365
- break;
1366
- case 'autonl':
1367
- $this->filters['equal'] = array('type' => 2);
1368
- break;
1369
- }
1370
- break;
1371
- }
1372
- }
1373
-
1374
- /**
1375
- * Get all campaigns, based on the filters
1376
- */
1377
- protected function get_campaigns() {
1378
- $order_by = ' ORDER BY ';
1379
-
1380
- if (isset($_REQUEST['orderby'])) {
1381
- if (!is_string($_REQUEST['orderby']) OR preg_match('|[^a-z0-9#_.-]|i', $_REQUEST['orderby']) !== 0) {
1382
- $_REQUEST['orderby'] = '';
1383
- }
1384
- if (!in_array(strtoupper($_REQUEST['ordert']), array('DESC', 'ASC')))
1385
- $_REQUEST['ordert'] = 'DESC';
1386
- $order_by.=$_REQUEST['orderby'] . ' ' . $_REQUEST['ordert'];
1387
- }else {
1388
- $order_by.='FIELD(B.status, 99,3,1,0,2), ';
1389
- $order_by.='B.status desc, ';
1390
- $order_by.='B.modified_at desc, ';
1391
- $order_by.='B.sent_at desc, ';
1392
- $order_by.='B.type desc, ';
1393
- $order_by.='A.' . $this->modelObj->getPk() . ' DESC';
1394
- }
1395
-
1396
- $query = '
1397
- SELECT
1398
- A.`campaign_id`,
1399
- A.`name` as `campaign_name`,
1400
- B.`subject` as `name`,
1401
- A.`description`,
1402
- B.`params`,
1403
- B.`type`,
1404
- B.`number_sent`,
1405
- B.`number_opened`,
1406
- B.`number_clicked`,
1407
- B.`number_unsub`,
1408
- (B.`number_sent` +
1409
- B.`number_opened` +
1410
- B.`number_clicked` +
1411
- B.`number_unsub` +
1412
- B.`number_bounce` +
1413
- B.`number_forward`
1414
- ) AS `number_total`,
1415
- B.`status`,
1416
- B.`created_at`,
1417
- B.`modified_at`,
1418
- B.`sent_at`,
1419
- B.`email_id`
1420
- FROM
1421
- `[wysija]' . $this->modelObj->table_name . '` AS A
1422
- LEFT JOIN
1423
- `[wysija]email` AS B on A.`campaign_id` = B.`campaign_id`
1424
- LEFT JOIN
1425
- `[wysija]campaign_list` AS C on A.`campaign_id` = C.`campaign_id`';
1426
- $campaigns = $this->modelObj->getResults($query . $this->modelObj->makeWhere() . ' GROUP BY B.email_id' . $order_by . $this->modelObj->setLimit());
1427
-
1428
- // calculate percetange of open / click / unsubscribe
1429
- $helper_numbers = WYSIJA::get('numbers', 'helper');
1430
- foreach ($campaigns as &$campaign) {
1431
- // open rate, based on sent number
1432
- $campaign['rate_opened'] = $helper_numbers->calculate_percetage($campaign['number_opened'], $campaign['number_total'], 1);
1433
- // click rate, based on opened number
1434
- $campaign['rate_clicked'] = $helper_numbers->calculate_percetage($campaign['number_clicked'], $campaign['number_total'], 1);
1435
- // unsubscribe rate, based on opened number
1436
- $campaign['rate_unsub'] = $helper_numbers->calculate_percetage($campaign['number_unsub'], $campaign['number_total'], 1);
1437
- }
1438
- return $campaigns;
1439
- }
1440
-
1441
- /**
1442
- * Get the first campaign in history
1443
- */
1444
- protected function get_oldest_compaign() {
1445
- $query = '
1446
- SELECT
1447
- MIN(B.created_at) as datemin
1448
- FROM `[wysija]' . $this->modelObj->table_name . '` as A
1449
- LEFT JOIN
1450
- `[wysija]email` AS B on A.campaign_id = B.campaign_id
1451
- LEFT JOIN
1452
- `[wysija]campaign_list` as C on A.campaign_id = C.campaign_id';
1453
-
1454
- return $this->modelObj->query('get_row', $query . $this->modelObj->makeWhere());
1455
- }
1456
-
1457
- /**
1458
- * Count ALL emails of each email-status
1459
- * @todo: move to model
1460
- */
1461
- protected function count_emails_by_status() {
1462
- $query = '
1463
- SELECT
1464
- COUNT(`email_id`) AS `campaigns`,
1465
- `status`
1466
- FROM
1467
- `[wysija]email`
1468
- WHERE
1469
- `campaign_id` > 0
1470
- GROUP BY `status`';
1471
-
1472
- $countss = $this->modelObj->query('get_res', $query);
1473
- $counts = array();
1474
- $total = 0;
1475
-
1476
- foreach ($countss as $count) {
1477
- switch ($count['status']) {
1478
- case '0':
1479
- $type = 'draft';
1480
- break;
1481
- case '1':
1482
- case '3':
1483
- case '99':
1484
- $type = 'sending';
1485
- break;
1486
- case '2':
1487
- $type = 'sent';
1488
- break;
1489
- case '-1':
1490
- $type = 'paused';
1491
- break;
1492
- case '4':
1493
- $type = 'scheduled';
1494
- break;
1495
- }
1496
- $total = $total + $count['campaigns'];
1497
- $counts['status-' . $type] = $count['campaigns'];
1498
- }
1499
- return $counts;
1500
- }
1501
-
1502
- /**
1503
- * Count emails which matched the filters
1504
- */
1505
- protected function count_emails() {
1506
- $query = '
1507
- SELECT
1508
- COUNT(DISTINCT B.`email_id`) AS `campaigns`
1509
- FROM
1510
- `[wysija]' . $this->modelObj->table_name . '` AS A
1511
- LEFT JOIN
1512
- `[wysija]email` AS B ON A.`campaign_id` = B.`campaign_id`
1513
- LEFT JOIN
1514
- `[wysija]campaign_list` AS C ON A.`campaign_id` = C.`campaign_id`';
1515
- return $this->modelObj->count($query . $this->modelObj->makeWhere(), 'campaigns');
1516
- }
1517
-
1518
- /**
1519
- * Count ALL emails of each type of email
1520
- */
1521
- protected function count_emails_by_type() {
1522
- $query = '
1523
- SELECT
1524
- COUNT(`email_id`) AS `campaigns`,
1525
- `type`
1526
- FROM
1527
- `[wysija]email`
1528
- WHERE
1529
- `campaign_id` > 0
1530
- GROUP BY `type`';
1531
- $countss = $this->modelObj->query('get_res', $query, ARRAY_A);
1532
- $counts = array();
1533
- foreach ($countss as $count) {
1534
- switch ($count['type']) {
1535
- case '1':
1536
- $type = 'regular';
1537
- break;
1538
- case '2':
1539
- $type = 'autonl';
1540
- break;
1541
- }
1542
- $counts['type-' . $type] = $count['campaigns'];
1543
- }
1544
- return $counts;
1545
- }
1546
-
1547
- /**
1548
- * Get all existing lists
1549
- */
1550
- protected function get_lists() {
1551
- $model_list = WYSIJA::get('list', 'model');
1552
- $query = '
1553
- SELECT
1554
- A.`list_id`,
1555
- A.`name`,
1556
- A.`is_enabled`,
1557
- COUNT( B.`campaign_id` ) AS `users`
1558
- FROM
1559
- `[wysija]' . $model_list->table_name . '` as A
1560
- LEFT JOIN
1561
- `[wysija]campaign_list` AS B on A.`list_id` = B.`list_id`
1562
- GROUP BY A.`list_id`';
1563
- $result = $model_list->getResults($query);
1564
- $lists = array();
1565
- foreach ($result as $list_obj) {
1566
- $lists[$list_obj['list_id']] = $list_obj;
1567
- }
1568
- return $lists;
1569
- }
1570
-
1571
- function defaultDisplay() {
1572
- $this->data['base_url'] = $this->base_url . '?' . http_build_query($_REQUEST); // saved filter
1573
- $this->title = __('Newsletters', WYSIJA);
1574
- $this->viewShow = $this->action = 'main';
1575
- $this->js[] = 'wysija-admin-list';
1576
- $this->jsTrans["selecmiss"] = __('Please select a newsletter.', WYSIJA);
1577
- $this->jsTrans['suredelete'] = __('Delete this newsletter for ever?', WYSIJA);
1578
- $this->jsTrans['suredelete_bulk'] = __('Delete these newsletters for ever?', WYSIJA);
1579
- $this->jsTrans['processqueue'] = __('Sending batch of emails...', WYSIJA);
1580
- $this->jsTrans['viewnews'] = __('View newsletter', WYSIJA);
1581
- $this->jsTrans['confirmpauseedit'] = __('The newsletter will be deactivated, you will need to reactivate it once you\'re over editing it. Do you want to proceed?', WYSIJA);
1582
-
1583
-
1584
- //get the filters
1585
- if (isset($_REQUEST['search']) && $_REQUEST['search']) {
1586
- $this->filters['like'] = array();
1587
- foreach ($this->searchable as $field)
1588
- $this->filters['like'][$field] = $_REQUEST['search'];
1589
- }
1590
-
1591
- if (isset($_REQUEST['filter-list']) && $_REQUEST['filter-list']) {
1592
- $this->filters['equal'] = array('C.list_id' => $_REQUEST['filter-list']);
1593
- }
1594
-
1595
- if (isset($_REQUEST['filter-date']) && $_REQUEST['filter-date']) {
1596
- $this->filters['greater_eq'] = array('created_at' => $_REQUEST['filter-date']);
1597
- $this->filters['less_eq'] = array('created_at' => strtotime('+1 month', $_REQUEST['filter-date']));
1598
- }
1599
-
1600
- $this->filters['is'] = array('type' => 'IS NOT NULL');
1601
-
1602
-
1603
- if (isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']) {
1604
- $linkfilters = explode('-', $_REQUEST['link_filter']);
1605
-
1606
- if (count($linkfilters) > 1) {
1607
- $this->_addLinkFilter($linkfilters[1], $linkfilters[0]);
1608
- } else {
1609
- $this->_addLinkFilter($_REQUEST['link_filter']);
1610
- }
1611
- }
1612
-
1613
- $this->modelObj->noCheck = true;
1614
- $this->modelObj->reset();
1615
- if ($this->filters)
1616
- $this->modelObj->setConditions($this->filters);
1617
-
1618
-
1619
- // Count emails by status and type
1620
- $emails_by_status = $this->count_emails_by_status();
1621
- $emails_by_type = $this->count_emails_by_type();
1622
- $counts = array_merge($emails_by_status, $emails_by_type);
1623
- $counts['all'] = array_sum($emails_by_status);
1624
-
1625
- // collect data
1626
- $this->data['campaigns'] = $this->get_campaigns();
1627
- $this->data['datemin'] = $this->get_oldest_compaign();
1628
- $lists = $this->get_lists(); // $lists is in use later within this scope
1629
- $this->data['lists'] = $lists;
1630
-
1631
- // for paging
1632
- $this->modelObj->countRows = $this->filters ? $this->count_emails () : $counts['all'];
1633
-
1634
-
1635
- // count queue
1636
- $email_ids = array();
1637
- foreach ($this->data['campaigns'] as $emailcamp) {
1638
- if (in_array($emailcamp['status'], array(1, 3, 99)))
1639
- $email_ids[] = $emailcamp['email_id'];
1640
- }
1641
- $model_queue = WYSIJA::get('queue', 'model');
1642
- $model_queue->setConditions(array("email_id" => $email_ids));
1643
- $model_queue->groupBy('email_id');
1644
- $queue = $model_queue->count();
1645
- if ($queue) {
1646
- $this->viewObj->queuedemails = $queue;
1647
- }
1648
-
1649
- $this->modelObj->reset();
1650
-
1651
- //make a loop from the first created to now and increment an array of months
1652
- $now = time();
1653
- $this->data['dates'] = array();
1654
-
1655
- if ((int) $this->data['datemin']['datemin'] > 1) {
1656
- setlocale(LC_TIME, 'en_US');
1657
- $formtlettres = "1 " . date('F', $this->data['datemin']['datemin']) . ' ' . date("Y", $this->data['datemin']['datemin']);
1658
- $month_start = strtotime($formtlettres);
1659
-
1660
- if ($month_start > 0) {
1661
- for ($i = $month_start; $i < $now; $i = strtotime('+1 month', $i)) {
1662
- $this->data['dates'][$i] = date_i18n('F Y', $i); //date('F Y',$i);
1663
- }
1664
- }
1665
- }
1666
-
1667
-
1668
-
1669
- $campaign_ids_sent = $campaign_ids = array();
1670
- foreach ($this->data['campaigns'] as &$campaign) {
1671
- $campaign_ids[] = $campaign['campaign_id'];
1672
- $modelEmail = WYSIJA::get('email', 'model');
1673
- $modelEmail->getParams($campaign);
1674
- if (in_array((int) $campaign['status'], array(-1, 1, 2, 3, 99)))
1675
- $campaign_ids_sent[] = $campaign['campaign_id'];
1676
- }
1677
-
1678
- // 3 - campaign_list request & count request for queue */
1679
- if ($campaign_ids) {
1680
- $modeluList = WYSIJA::get('campaign_list', 'model');
1681
- $userlists = $modeluList->get(array('list_id', 'campaign_id'), array('campaign_id' => $campaign_ids));
1682
-
1683
- if ($campaign_ids_sent) {
1684
- $modeluList = WYSIJA::get("email_user_stat", "model");
1685
- $statstotal = $modeluList->getResults("SELECT COUNT(A.user_id) as count,B.email_id FROM `[wysija]queue` as A
1686
- JOIN `[wysija]email` as B on A.email_id=B.email_id
1687
- WHERE B.campaign_id IN (" . implode(",", $campaign_ids_sent) . ") group by B.email_id");
1688
-
1689
- $senttotalgroupedby = $modeluList->getResults("SELECT COUNT(A.user_id) as count,B.campaign_id,B.email_id,B.type,B.status,A.status as statususer FROM `[wysija]" . $modeluList->table_name . "` as A
1690
- JOIN `[wysija]email` as B on A.email_id=B.email_id
1691
- WHERE B.campaign_id IN (" . implode(",", $campaign_ids_sent) . ") group by A.status,B.email_id"); //,A.status
1692
-
1693
-
1694
- $updateEmail = array();
1695
- $columnnamestatus = array(0 => "number_sent", 1 => "number_opened", 2 => "number_clicked", 3 => "number_unsub", -1 => "number_bounce");
1696
- foreach ($senttotalgroupedby as $sentbystatus) {
1697
- if ($sentbystatus['statususer'] != "-2")
1698
- $updateEmail[$sentbystatus['email_id']][$columnnamestatus[$sentbystatus['statususer']]] = $sentbystatus['count'];
1699
- if (isset($senttotal[$sentbystatus['email_id']])) {
1700
- $senttotal[$sentbystatus['email_id']]['count'] = (int) $senttotal[$sentbystatus['email_id']]['count'] + (int) $sentbystatus['count'];
1701
- } else {
1702
- unset($sentbystatus['statususer']);
1703
- $senttotal[$sentbystatus['email_id']] = $sentbystatus;
1704
- }
1705
- }
1706
-
1707
- $modelEmail = WYSIJA::get('email', 'model');
1708
-
1709
- foreach ($updateEmail as $emailid => $update) {
1710
-
1711
- foreach ($columnnamestatus as $v) {
1712
- if (!isset($update[$v]))
1713
- $update[$v] = 0;
1714
- }
1715
-
1716
- $modelEmail->update($update, array('email_id' => $emailid));
1717
- $modelEmail->reset();
1718
- }
1719
-
1720
-
1721
- /**/
1722
- $modelC = WYSIJA::get('config', 'model');
1723
- $running = false;
1724
-
1725
- $is_multisite = is_multisite();
1726
-
1727
- //$is_multisite=true;//PROD comment that line
1728
- if ($is_multisite && $modelC->getValue('sending_method') == 'network') {
1729
- $sending_emails_each = $modelC->getValue('ms_sending_emails_each');
1730
- } else {
1731
- $sending_emails_each = $modelC->getValue('sending_emails_each');
1732
- }
1733
-
1734
- if ($modelC->getValue('cron_manual')) {
1735
- $formsHelp = WYSIJA::get('forms', 'helper');
1736
- $queue_frequency = $formsHelp->eachValuesSec[$sending_emails_each];
1737
- $queue_scheduled = WYSIJA::get_cron_schedule('queue');
1738
-
1739
- $next_scheduled_queue = $queue_scheduled['next_schedule'];
1740
- $running = $queue_scheduled['running'];
1741
-
1742
- if ($running) {
1743
- $helperToolbox = WYSIJA::get('toolbox', 'helper');
1744
- $running = time() - $running;
1745
- $running = $helperToolbox->duration_string($running, true, 4);
1746
- }
1747
- } else {
1748
- $schedules = wp_get_schedules();
1749
- $queue_frequency = $schedules[wp_get_schedule('wysija_cron_queue')]['interval'];
1750
- $next_scheduled_queue = wp_next_scheduled('wysija_cron_queue');
1751
- }
1752
-
1753
-
1754
-
1755
- $status_sent_complete = array();
1756
- if (isset($senttotal) && $senttotal) {
1757
- foreach ($senttotal as $sentot) {
1758
- if ($sentot) {
1759
- $this->data['sent'][$sentot['email_id']]['total'] = $sentot['count'];
1760
- $this->data['sent'][$sentot['email_id']]['to'] = $sentot['count'];
1761
- } else {
1762
- $this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['to'] = 0;
1763
- }
1764
- $this->data['sent'][$sentot['email_id']]['status'] = $sentot['status'];
1765
- $this->data['sent'][$sentot['email_id']]['type'] = $sentot['type'];
1766
- $this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
1767
- }
1768
- }
1769
-
1770
- foreach ($statstotal as $sentot) {
1771
- if (!isset($this->data['sent'][$sentot['email_id']])) {
1772
- $this->data['sent'][$sentot['email_id']]['total'] = 0;
1773
- $this->data['sent'][$sentot['email_id']]['to'] = 0;
1774
- }
1775
- $this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['total'] + $sentot['count'];
1776
- $this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
1777
- }
1778
-
1779
- //$is_multisite=true;//PROD comment that line
1780
- if ($is_multisite && $modelC->getValue('sending_method') == 'network') {
1781
- $sending_emails_number = $modelC->getValue('ms_sending_emails_number');
1782
- } else {
1783
- $sending_emails_number = $modelC->getValue('sending_emails_number');
1784
- }
1785
-
1786
- if (isset($this->data['sent'])) {
1787
- foreach ($this->data['sent'] as $key => &$camp) {
1788
- if ($this->data['sent'][$key]['left'] > 0) {
1789
- $cronsneeded = ceil($this->data['sent'][$key]['left'] / $sending_emails_number);
1790
- $this->data['sent'][$key]['remaining_time'] = $cronsneeded * $queue_frequency;
1791
- $this->data['sent'][$key]['running_for'] = $running;
1792
- $this->data['sent'][$key]['next_batch'] = $next_scheduled_queue - time();
1793
- $this->data['sent'][$key]['remaining_time'] = $this->data['sent'][$key]['remaining_time'] - ($queue_frequency) + $this->data['sent'][$key]['next_batch'];
1794
- } else {
1795
- if ((in_array($this->data['sent'][$key]['status'], array(1, 3, 99))) && $this->data['sent'][$key]['type'] == 1)
1796
- $status_sent_complete[] = $key;
1797
- }
1798
- }
1799
- }
1800
-
1801
-
1802
- // status update to sent for the one that are sent
1803
- if (count($status_sent_complete) > 0) {
1804
- $modelEmail = WYSIJA::get('email', 'model');
1805
- $modelEmail->noCheck = true;
1806
- $modelEmail->reset();
1807
- $modelEmail->update(array('status' => 2), array('equal' => array('email_id' => $status_sent_complete)));
1808
- }
1809
- }
1810
- }
1811
-
1812
- $this->data['counts'] = array_reverse($counts);
1813
-
1814
- /* regrouping all the data in the same array */
1815
- foreach ($this->data['campaigns'] as &$campaign) {
1816
- /* default key while we don't have the data */
1817
- //TODO add data for stats about emails opened clicked etc
1818
- $campaign["emails"] = 0;
1819
- $campaign["opened"] = 0;
1820
- $campaign["clicked"] = 0;
1821
-
1822
- if ($userlists) {
1823
- foreach ($userlists as $key => $userlist) {
1824
- if ($campaign["campaign_id"] == $userlist["campaign_id"] && isset($lists[$userlist["list_id"]])) {
1825
- if (!isset($campaign["lists"]))
1826
- $campaign["lists"] = $lists[$userlist["list_id"]]["name"];
1827
- else
1828
- $campaign["lists"].=", " . $lists[$userlist["list_id"]]["name"];
1829
- }
1830
- }
1831
- }
1832
- if (isset($campaign["lists"]) && !$campaign["lists"])
1833
- unset($campaign["lists"]);
1834
-
1835
- if (((isset($campaign['params']['schedule']['isscheduled']) ||
1836
- ($campaign['type'] == 2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'], array('new-articles'/* ,'subs-2-nl' */)))
1837
- ) && $campaign['status'] != 2 && !isset($campaign["lists"])) || ($campaign['type'] == 2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'], array('subs-2-nl')) && $campaign['status'] != 2 && (!isset($campaign['params']['autonl']['subscribetolist']) || !isset($lists[$campaign['params']['autonl']['subscribetolist']]) ))
1838
- ) {
1839
- $campaign['classRow'] = " listmissing ";
1840
- $campaign['msgListEdit'] = '<strong>' . __('The list has been deleted.', WYSIJA) . '</strong>';
1841
- $campaign['msgSendSuspended'] = '<strong>' . __('Sending suspended.', WYSIJA) . '</strong>';
1842
- }
1843
- }
1844
-
1845
- $this->dataAutoNl();
1846
- if (!$this->data['campaigns']) {
1847
- $this->notice(__('There are no newsletters.', WYSIJA));
1848
- }
1849
- }
1850
-
1851
- function setviewStatsfilter() {
1852
- /* get the filters */
1853
- $this->searchable = array("email", "firstname", "lastname");
1854
- $this->filters = array();
1855
- if (isset($_REQUEST['search']) && $_REQUEST['search']) {
1856
- $this->filters["like"] = array();
1857
- foreach ($this->searchable as $field)
1858
- $this->filters["like"][$field] = $_REQUEST['search'];
1859
- }
1860
- $this->tableQuery = 'email_user_stat';
1861
- $this->statusemail = 'B.status as umstatus';
1862
- if (isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']) {
1863
- switch ($_REQUEST['link_filter']) {
1864
- case 'inqueue':
1865
- $this->tableQuery = 'queue';
1866
- $this->statusemail = '-2 as umstatus';
1867
- break;
1868
- case 'sent':
1869
- $this->filters['equal'] = array('B.status' => 0);
1870
- break;
1871
- case 'bounced':
1872
- $this->filters['equal'] = array('B.status' => -1);
1873
- break;
1874
- case 'opened':
1875
- $this->filters['equal'] = array('B.status' => 1);
1876
- break;
1877
- case 'clicked':
1878
- $this->filters['equal'] = array('B.status' => 2);
1879
- break;
1880
- case 'unsubscribe':
1881
- $this->filters['equal'] = array('B.status' => 3);
1882
- break;
1883
- case 'notsent':
1884
- $this->filters['equal'] = array('B.status' => -2);
1885
- break;
1886
- }
1887
- }
1888
- // filter by url id
1889
- if (isset($_REQUEST['url_id']) && (int) $_REQUEST['url_id'] > 0) {
1890
- $this->tableQuery = 'email_user_url';
1891
- $this->filters['equal'] = array('B.url_id' => (int) $_REQUEST['url_id']);
1892
- $this->statusemail = '2 as umstatus'; //by default, when filter by url_id, all subscribers had clicked
1893
- }
1894
- }
1895
-
1896
- function viewstats() {
1897
- $this->js[] = 'wysija-admin-list';
1898
- $this->js[] = 'wysija-charts';
1899
- $this->viewShow = 'viewstats';
1900
-
1901
- $this->modelObj = WYSIJA::get("email", "model");
1902
- $this->modelObj->limitON = false;
1903
-
1904
- $email_object = $this->modelObj->getOne(false, array("email_id" => $_REQUEST['id']));
1905
- $this->viewObj->model = $this->modelObj;
1906
- $this->viewObj->namecampaign = $email_object['subject'];
1907
- $this->viewObj->title = sprintf(__('Stats : %1$s', WYSIJA), $email_object['subject']);
1908
-
1909
- $modelObjCamp = WYSIJA::get("campaign", "model");
1910
- $limit_pp = false;
1911
- if (isset($modelObjCamp->limit_pp))
1912
- $limit_pp = $modelObjCamp->limit_pp;
1913
- $modelObjCamp->limitON = false;
1914
- $campaign = $modelObjCamp->getOne(false, array("campaign_id" => $email_object['campaign_id']));
1915
-
1916
-
1917
- $this->setviewStatsfilter();
1918
-
1919
- $this->modelObj->reset();
1920
- $this->modelObj->noCheck = true;
1921
-
1922
- /* 0 - counting request */
1923
- $queryCmmonStart = 'SELECT count(distinct B.user_id) as users FROM `[wysija]user` as A';
1924
- $queryCmmonStart.=' LEFT JOIN `[wysija]' . $this->tableQuery . '` as B on A.user_id=B.user_id';
1925
-
1926
- /* all the counts query */
1927
- $query = "SELECT count(user_id) as users, status FROM `[wysija]email_user_stat` as A
1928
- WHERE A.email_id=" . $email_object['email_id'] . " GROUP BY status";
1929
- $countss = $this->modelObj->query("get_res", $query, ARRAY_A);
1930
-
1931
- /* we also count what is in the queue */
1932
- $query = "SELECT count(user_id) as users FROM `[wysija]queue` as A
1933
- WHERE A.email_id=" . $email_object['email_id'];
1934
- $countss[-2]['status'] = -3;
1935
- $countss[-2]['users'] = $this->modelObj->count($query, 'users');
1936
-
1937
- $counts = array();
1938
- $truetotal = $total = 0;
1939
-
1940
- foreach ($countss as $count) {
1941
- switch ($count['status']) {
1942
- case "-3":
1943
- $type = 'inqueue';
1944
- break;
1945
- case "-2":
1946
- $type = 'notsent';
1947
- break;
1948
- case "-1":
1949
- $type = 'bounced';
1950
- break;
1951
- case "0":
1952
- $type = 'sent';
1953
- break;
1954
- case "1":
1955
- $type = 'opened';
1956
- break;
1957
- case "2":
1958
- $type = 'clicked';
1959
- break;
1960
- case "3":
1961
- $type = 'unsubscribe';
1962
- break;
1963
- }
1964
- if ($count['status'] != "-2")
1965
- $total = $total + $count['users'];
1966
- $truetotal = $truetotal + $count['users'];
1967
- $counts[$type] = $count['users'];
1968
- }
1969
-
1970
- $counts['allsent'] = $total;
1971
- $counts['all'] = $truetotal;
1972
-
1973
- $this->modelObj->reset();
1974
- $this->filters['equal']["B.email_id"] = $email_object['email_id'];
1975
-
1976
- $this->modelObj->noCheck = true;
1977
- if ($this->filters)
1978
- $this->modelObj->setConditions($this->filters);
1979
-
1980
- //$this->modelObj->setConditions(array("equal"=>array("B.email_id"=>$emailObj['email_id'])));
1981
-
1982
- /* 1 - subscriber request */
1983
- $query = 'SELECT A.user_id, A.firstname, A.lastname,A.status as ustatus,' . $this->statusemail . ' , A.email, B.* FROM `[wysija]user` as A';
1984
- $query.=' LEFT JOIN `[wysija]' . $this->tableQuery . '` as B on A.user_id=B.user_id';
1985
- $queryFinal = $this->modelObj->makeWhere();
1986
-
1987
- /* without filter we already have the total number of subscribers */
1988
- if ($this->filters)
1989
- $this->modelObj->countRows = $this->modelObj->count($queryCmmonStart . $queryFinal, 'users');
1990
- else
1991
- $this->modelObj->countRows = $counts['all'];
1992
-
1993
- $orderby = " ORDER BY ";
1994
- /**
1995
- * Until now, we have
1996
- * - 3 possible values of $this->tableQuery (queue, email_user_url, email_user_stat), set by $this->setviewStatsfilter()
1997
- * - 2 possible values of $_REQUEST['orderby']
1998
- * => 3x2 = 6 cases
1999
- */
2000
- if (isset($_REQUEST['orderby'])) {
2001
- switch ($this->tableQuery) {
2002
- case 'email_user_url':
2003
- case 'email_user_stat':
2004
- $orderby .= 'B.' . $_REQUEST['orderby'] . " " . $_REQUEST['ordert'];
2005
- break;
2006
-
2007
- case 'queue':
2008
- default:
2009
- $orderby .= 'A.user_id DESC';
2010
- break;
2011
- }
2012
- } else {
2013
- switch ($this->tableQuery) {
2014
- case 'email_user_url':
2015
- $orderby .= 'B.clicked_at DESC, B.number_clicked DESC'; // by default, sort by last clicked and biggest hit
2016
- break;
2017
-
2018
- case 'email_user_stat':
2019
- $orderby .= 'B.opened_at DESC, B.status DESC'; // by default, sort by last open and its staus value
2020
- break;
2021
-
2022
- case 'queue':
2023
- default:
2024
- $orderby .= 'A.user_id DESC';
2025
- break;
2026
- }
2027
- }
2028
- $this->data['tableQuery'] = $this->tableQuery;
2029
- $this->modelObj->limitON = true;
2030
-
2031
- $subscribers = array();
2032
- $hook_params = array(
2033
- 'email_id' => $email_object['email_id'],
2034
- 'url_id' => isset($_REQUEST['url_id']) && $_REQUEST['url_id'] ? $_REQUEST['url_id'] : false,
2035
- 'subscribers' => &$subscribers
2036
- );
2037
- $this->data['subscribers'] = $this->modelObj->getResults($query . $queryFinal . " GROUP BY A.user_id" . $orderby . $this->modelObj->setLimit(0, (int)$limit_pp));
2038
- $this->modelObj->reset();
2039
-
2040
- /* make the data object for the listing view */
2041
- $modelList = WYSIJA::get("list", "model");
2042
-
2043
- /* 2 - list request */
2044
- $query = "SELECT A.list_id, A.name,A.is_enabled, count( B.user_id ) AS users FROM `[wysija]" . $modelList->table_name . "` as A";
2045
- $query.=" LEFT JOIN `[wysija]user_list` as B on A.list_id = B.list_id";
2046
- $query.=" GROUP BY A.list_id";
2047
- $listsDB = $modelList->getResults($query);
2048
-
2049
- $lists = array();
2050
- foreach ($listsDB as $listobj) {
2051
- $lists[$listobj["list_id"]] = $listobj;
2052
- }
2053
-
2054
- $listsDB = null;
2055
-
2056
- $user_ids = array();
2057
- foreach ($this->data['subscribers'] as $subscriber) {
2058
- $user_ids[] = $subscriber['user_id'];
2059
- }
2060
-
2061
- /* 3 - user_list request */
2062
- if ($user_ids) {
2063
- $modeluList = WYSIJA::get("user_list", "model");
2064
- $userlists = $modeluList->get(array("list_id", "user_id"), array("user_id" => $user_ids));
2065
- }
2066
-
2067
-
2068
- $this->data['lists'] = $lists;
2069
- $this->data['counts'] = array_reverse($counts);
2070
-
2071
- /* regrouping all the data in the same array */
2072
- foreach ($this->data['subscribers'] as $keysus => $subscriber) {
2073
- /* default key while we don't have the data */
2074
- //TODO add data for stats about emails opened clicked etc
2075
- $this->data['subscribers'][$keysus]["emails"] = 0;
2076
- $this->data['subscribers'][$keysus]["opened"] = 0;
2077
- $this->data['subscribers'][$keysus]["clicked"] = 0;
2078
-
2079
- if ($userlists) {
2080
- foreach ($userlists as $key => $userlist) {
2081
- if ($subscriber["user_id"] == $userlist["user_id"] && isset($lists[$userlist["list_id"]])) {
2082
- if (!isset($this->data['subscribers'][$keysus]["lists"]))
2083
- $this->data['subscribers'][$keysus]["lists"] = $lists[$userlist["list_id"]]["name"];
2084
- else
2085
- $this->data['subscribers'][$keysus]["lists"].=", " . $lists[$userlist["list_id"]]["name"];
2086
- }
2087
- }
2088
- }
2089
- }
2090
-
2091
- $this->data['email'] = $email_object;
2092
-
2093
- if (!$this->data['subscribers']) {
2094
- $this->notice(__("Your request can't retrieve any subscribers. Change your filters!", WYSIJA));
2095
- }
2096
-
2097
- // execute hooks
2098
- $hook_params = array(
2099
- 'email_id' => $_REQUEST['id'],
2100
- 'email_object' => $email_object,
2101
- 'url_id' => !empty($_REQUEST['url_id']) ? (int)$_REQUEST['url_id'] : null
2102
- );
2103
-
2104
- $this->data['hooks']['hook_newsletter_top'] = apply_filters('hook_newsletter_top', WYSIJA_module::execute_hook('hook_newsletter_top', $hook_params), $hook_params);
2105
- $this->data['hooks']['hook_newsletter_bottom'] = apply_filters('hook_newsletter_bottom', WYSIJA_module::execute_hook('hook_newsletter_bottom', $hook_params), $hook_params);
2106
- }
2107
-
2108
- function getListSubscriberQry($selectcolumns) {
2109
- $this->modelObj = WYSIJA::get("email", "model");
2110
- $this->emailObj = $this->modelObj->getOne(false, array('email_id' => $_REQUEST['id']));
2111
-
2112
- /* use the filter if there is */
2113
- $this->setviewStatsfilter();
2114
-
2115
- if ($selectcolumns == "B.user_id") {
2116
- //unset($this->filters["like"]);
2117
- }
2118
-
2119
- $this->filters['equal']["B.email_id"] = $this->emailObj['email_id'];
2120
- $this->modelObj->noCheck = true;
2121
- if ($this->filters)
2122
- $this->modelObj->setConditions($this->filters);
2123
-
2124
- /* select insert all the subscribers from that campaign into user_list */
2125
- if ($selectcolumns == "B.user_id") {
2126
- $query = "SELECT $selectcolumns FROM `[wysija]" . $this->tableQuery . "` as B";
2127
- $query.=$this->modelObj->makeWhere();
2128
- } else {
2129
- $query = "SELECT $selectcolumns FROM `[wysija]user` as A";
2130
- $query.=" LEFT JOIN `[wysija]" . $this->tableQuery . "` as B on A.user_id=B.user_id";
2131
- $query.=$this->modelObj->makeWhere();
2132
- }
2133
-
2134
- return $query;
2135
- }
2136
-
2137
- function createnewlist() {
2138
- /* get the email subject */
2139
- $emailModel = WYSIJA::get('email', 'model');
2140
- $email = $emailModel->getOne(array('subject'), array('email_id' => $_REQUEST['id']));
2141
-
2142
- $this->modelObj->reset();
2143
-
2144
- /* set the name of the new list */
2145
- $prefix = "";
2146
- if (isset($_REQUEST['link_filter']))
2147
- $prefix = ' (' . $this->viewObj->getTransStatusEmail($_REQUEST['link_filter']) . ')';
2148
- $listname = sprintf(__('Segment of %1$s', WYSIJA), $email['subject'] . $prefix);
2149
-
2150
- /* insert new list */
2151
- $modelL = WYSIJA::get('list', 'model');
2152
- $listid = $modelL->insert(array('is_enabled' => 1, 'name' => $listname, 'description' => __('List created based on a newsletter segment.', WYSIJA)));
2153
-
2154
- /* get list of subscribers filtered or not */
2155
- $query = $this->getListSubscriberQry($listid . ', A.user_id, ' . time() . ', 0');
2156
-
2157
- $query2 = 'INSERT INTO `[wysija]user_list` (`list_id`,`user_id`,`sub_date`,`unsub_date`) ' . $query;
2158
-
2159
- $this->modelObj->query($query2);
2160
-
2161
- $this->notice(sprintf(__('A new list "%1$s" has been created out of this segment.', WYSIJA), $listname));
2162
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2163
- }
2164
-
2165
- function unsubscribeall() {
2166
- // Update user_list, set unsubdate and sub_date
2167
- $query = $this->getListSubscriberQry('B.user_id');
2168
  $query1 = "
2169
- UPDATE `[wysija]user_list`
2170
- SET
2171
  `unsub_date` = ".time().",
2172
  `sub_date` = 0
2173
- WHERE
2174
  `user_id` IN ($query)
2175
  AND `list_id` NOT IN (SELECT `list_id` FROM `[wysija]list` WHERE `is_enabled` < 1)
2176
  ";
2177
- $this->modelObj->query($query1);
2178
-
2179
- // unsubscribe from user where select from email_user_stat
2180
- $query2 = "UPDATE `[wysija]user` SET `status`=-1 WHERE `user_id` IN ($query)";
2181
- $this->modelObj->query($query2);
2182
-
2183
- $this->notice(__('The segment has been unsubscribed from all the lists.', WYSIJA));
2184
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2185
- }
2186
-
2187
- function sendconfirmation() {
2188
- //delete from user_lists where select from email_user_stat
2189
- $query = $this->getListSubscriberQry('B.user_id ');
2190
-
2191
- $user_ids = $this->modelObj->query('get_res', $query);
2192
-
2193
- $uids = array();
2194
- foreach ($user_ids as $data) {
2195
- $uids[] = $data['user_id'];
2196
- }
2197
-
2198
- $helperUser = WYSIJA::get('user', 'helper');
2199
- $helperUser->sendConfirmationEmail($uids);
2200
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2201
- }
2202
-
2203
- function removequeue() {
2204
- /* delete from queue where select from email_user_stat */
2205
- $query = $this->getListSubscriberQry('B.user_id');
2206
- $query2 = "DELETE FROM `[wysija]queue` where user_id IN ($query) AND email_id=" . $this->emailObj['email_id'];
2207
- $this->modelObj->query($query2);
2208
-
2209
- $this->notice(__('The segment has been removed from the queue of this newsletter.', WYSIJA));
2210
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2211
- }
2212
-
2213
- function export() {
2214
- /* select from email_user_stat left join user */
2215
- $query = $this->getListSubscriberQry('B.user_id');
2216
- $result = $this->modelObj->query('get_res', $query);
2217
- $user_ids = array();
2218
- foreach ($result as $user)
2219
- $user_ids[] = $user['user_id'];
2220
-
2221
- $fileHelp = WYSIJA::get('file', 'helper');
2222
- $tempfilename = $fileHelp->temp(implode(',', $user_ids), 'export_userids', '.txt');
2223
-
2224
- //$this->redirect("admin.php?page=wysija_campaigns&action=viewstats&id=".$_REQUEST['id']."&user_ids=".serialize($result));
2225
- $this->redirect('admin.php?page=wysija_subscribers&action=exportcampaign&camp_id=' . $_REQUEST['id'] . '&file_name=' . base64_encode($tempfilename['path']));
2226
- }
2227
-
2228
- function unsubscribelist($data) {
2229
-
2230
- $modelL = WYSIJA::get('list', 'model');
2231
- $list = $modelL->getOne(false, array('list_id' => $data['listid']));
2232
- if ($list['is_enabled']) {
2233
- /* delete from user_lists where select from email_user_stat */
2234
- $query = $this->getListSubscriberQry("B.user_id");
2235
- $query2 = "DELETE FROM `[wysija]user_list` where user_id IN ($query) and list_id=" . $data['listid'];
2236
- $this->modelObj->query($query2);
2237
-
2238
- $this->notice(sprintf(__('The segment has been unsubscribed from the list "%1$s".', WYSIJA), $list['name']));
2239
- } else {
2240
- $this->notice(sprintf(__('The segment cannot be unsubscribed from an [IMPORT] list.', WYSIJA), $list['name']));
2241
- }
2242
-
2243
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2244
- }
2245
-
2246
- function articles() {
2247
- $this->iframeTabs = array('articles' => __("Post Selection", WYSIJA));
2248
-
2249
- // required js files
2250
- $this->js[] = 'wysija-admin-ajax';
2251
- $this->js[] = 'wysija-base-script-64';
2252
- $this->js[] = 'wysija-scriptaculous';
2253
- $this->js[] = 'wysija-colorpicker';
2254
-
2255
- // translations
2256
- $this->jsTrans['show_advanced'] = __('Display and insert options', WYSIJA);
2257
- $this->jsTrans['hide_advanced'] = __('Back to selection', WYSIJA);
2258
- $this->jsTrans['loading_results'] = __('Loading results...', WYSIJA);
2259
- $this->jsTrans['inserting_selection'] = __('Inserting selected articles...', WYSIJA);
2260
- $this->jsTrans['post_selected'] = __('selected', WYSIJA);
2261
-
2262
- // default tab in popup (this needs to be removed at some point)
2263
- $_GET['tab'] = 'articles';
2264
-
2265
- // get parameters
2266
- $params = array(
2267
- 'category_ids' => null,
2268
- 'category' => null,
2269
- 'title_tag' => 'h2',
2270
- 'title_alignment' => 'left',
2271
- 'title_position' => 'inside',
2272
- 'image_alignment' => 'alternate',
2273
- 'image_width' => 325,
2274
- 'post_content' => 'excerpt',
2275
- 'readmore' => __('Read more.', WYSIJA),
2276
- 'show_divider' => 'yes',
2277
- 'post_limit' => 5,
2278
- 'post_type' => 'post',
2279
- 'author_show' => 'no',
2280
- 'author_label' => __('Author:', WYSIJA),
2281
- 'category_show' => 'no',
2282
- 'category_label' => __('Categories:', WYSIJA),
2283
- 'nopost_message' => __('Latest content already sent.', WYSIJA),
2284
- 'bgcolor1' => null,
2285
- 'bgcolor2' => null,
2286
- 'sort_by' => 'newest'
2287
- );
2288
-
2289
- // check if GET parameters are specified
2290
- foreach($params as $key => $value) {
2291
- if(array_key_exists($key, $_GET)) {
2292
- switch($key) {
2293
- case 'autopost_count':
2294
- $params[$key] = (int)$_GET[$key];
2295
- break;
2296
- case 'readmore':
2297
- case 'nopost_message':
2298
- $params[$key] = base64_decode($_GET[$key]);
2299
- break;
2300
- default:
2301
- $params[$key] = $_GET[$key];
2302
- }
2303
- }
2304
- }
2305
-
2306
- $model_config = WYSIJA::get('config', 'model');
2307
- $insert_post_parameters = $model_config->getValue('insert_post_parameters');
2308
- $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
2309
-
2310
- if($insert_post_parameters !== false) {
2311
- // there are user params
2312
- $params = $helper_wj_engine->decodeParameters(array_merge($params, $insert_post_parameters));
2313
- }
2314
-
2315
- // get autopost count
2316
- $this->data['autopost_count'] = (array_key_exists('autopost_count', $_GET)) ? (int) $_GET['autopost_count'] : 0;
2317
-
2318
- // get autopost type (single or multiple)
2319
- $this->data['autopost_type'] = (array_key_exists('autopost_type', $_GET)) ? $_GET['autopost_type'] : 'multiple';
2320
-
2321
- // if only one group of post can be added, change default alignment to left
2322
- if($this->data['autopost_type'] === 'single' && $params['image_alignment'] === 'alternate') {
2323
- $params['image_alignment'] = 'left';
2324
- }
2325
-
2326
- // get post categories (even when there's no post)
2327
- $post_categories = get_categories(array('hide_empty' => 0));
2328
- $categories = array();
2329
- foreach ($post_categories as $category) {
2330
- $categories[] = array('id' => $category->cat_ID, 'name' => $category->name);
2331
- }
2332
- $this->data['categories'] = $categories;
2333
-
2334
- // max number of posts
2335
- $this->data['post_limits'] = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 50);
2336
-
2337
- $this->data['params'] = $params;
2338
-
2339
- return $this->popupContent();
2340
- }
2341
-
2342
- function themeupload() {
2343
- $helperNumbers = WYSIJA::get('numbers', 'helper');
2344
- $bytes = $helperNumbers->get_max_file_upload();
2345
-
2346
- if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > $bytes['maxbytes']) {
2347
- if (isset($_FILES['my-theme']['name']) && $_FILES['my-theme']['name']) {
2348
- $filename = $_FILES['my-theme']['name'];
2349
- } else {
2350
- $filename = "";
2351
- }
2352
-
2353
- $this->error(sprintf(__('Upload error, file %1$s is too large! (MAX:%2$s)', WYSIJA), $filename, $bytes['maxmegas']), true);
2354
- $this->redirect('admin.php?page=wysija_campaigns&action=themes');
2355
-
2356
- return false;
2357
- }
2358
-
2359
-
2360
- $ZipfileResult = trim(file_get_contents($_FILES['my-theme']['tmp_name']));
2361
-
2362
- $themesHelp = WYSIJA::get('themes', 'helper');
2363
- $result = $themesHelp->installTheme($_FILES['my-theme']['tmp_name'], true);
2364
- $this->redirect('admin.php?page=wysija_campaigns&action=themes&reload=1');
2365
-
2366
- return true;
2367
- }
2368
-
2369
- function themes() {
2370
- $this->iframeTabs = array('themes' => __('Install Themes', WYSIJA));
2371
- $this->js[] = 'wysija-admin-ajax';
2372
- $this->js[] = 'wysija-base-script-64';
2373
- $this->jsTrans['viewinfos'] = __('Details & PSD', WYSIJA);
2374
- $this->jsTrans['viewback'] = __('<< Back', WYSIJA);
2375
- $this->jsTrans['install'] = __('Download', WYSIJA);
2376
- $this->jsTrans['reinstall'] = __('Reinstall', WYSIJA);
2377
- $this->jsTrans['premiumonly'] = __('Premium', WYSIJA);
2378
-
2379
- $model_config = WYSIJA::get('config', 'model');
2380
- //change the translation of the button when it's premium
2381
- if ($model_config->getValue('premium_key'))
2382
- $this->jsTrans['ispremium'] = 1;
2383
- else
2384
- $this->jsTrans['ispremium'] = 0;
2385
-
2386
- $this->jsTrans['premiumfiles'] = __('Photoshop file available as part of [link]Premium features[/link].', WYSIJA);
2387
-
2388
- $helper_licence = WYSIJA::get('licence', 'helper');
2389
- $url_checkout = $helper_licence->get_url_checkout('themes');
2390
- $this->jsTrans['premiumfiles'] = str_replace(array('[link]', '[/link]'), array('<a href="' . $url_checkout . '" target="_blank" >', '</a>'), $this->jsTrans['premiumfiles']);
2391
-
2392
- $this->jsTrans['showallthemes'] = __('Show all themes', WYSIJA);
2393
- $this->jsTrans['totalvotes'] = __('(%1$s votes)', WYSIJA);
2394
- $this->jsTrans['voterecorded'] = __("Your vote has been recorded.", WYSIJA);
2395
- $this->jsTrans['votenotrecorded'] = __("Your vote could not be recorded.", WYSIJA);
2396
- $this->jsTrans['reinstallwarning'] = __('Watch out! If you reinstall this theme all the files which are in the folder:/wp-content/uploads/wysija/themes/%1$s will be overwritten. Are you sure you want to reinstall?', WYSIJA);
2397
- $this->jsTrans['errorconnecting'] = __("We were unable to contact the API, the site may be down. Please try again later.", WYSIJA);
2398
-
2399
- $this->jsTrans['viewallthemes'] = __('View all themes by %1$s', WYSIJA);
2400
- $this->jsTrans['downloadpsd'] = __("Download original Photoshop file", WYSIJA);
2401
- $this->jsTrans['downloadzip'] = __("Download as .zip", WYSIJA);
2402
- $this->jsTrans['viewauthorsite'] = __("View author's website", WYSIJA);
2403
- $this->jsTrans['stars'] = __('Average rating: %1$s', WYSIJA);
2404
- $this->jsTrans['starsyr'] = __('My rating: %1$s', WYSIJA);
2405
- $this->jsTrans['downloads'] = __('Downloads: %1$s', WYSIJA);
2406
- $this->jsTrans['tags'] = __('Tags: %1$s', WYSIJA);
2407
- $this->jsTrans['lastupdated'] = __('Last updated: %1$s', WYSIJA);
2408
- $this->jsTrans['includes'] = __('Includes: %1$s', WYSIJA);
2409
-
2410
- $helper_themes = WYSIJA::get('themes', 'helper');
2411
-
2412
- $this->jsTrans['installedthemes'] = $helper_themes->getInstalled();
2413
-
2414
- $url = admin_url('admin.php');
2415
- $helper_toolbox = WYSIJA::get("toolbox", "helper");
2416
- $domain_name = $helper_toolbox->_make_domain_name($url);
2417
- $this->jsTrans['domainname'] = $domain_name;
2418
-
2419
- $_GET['tab'] = 'themes';
2420
-
2421
- return $this->popupContent();
2422
- }
2423
-
2424
- function bookmarks() {
2425
- $this->iframeTabs = array('bookmarks' => __('Bookmarks Selection', WYSIJA));
2426
- $this->js[] = 'wysija-admin-ajax';
2427
-
2428
- $_GET['tab'] = 'bookmarks';
2429
-
2430
- $networks = array(
2431
- 'facebook' => array(
2432
- 'label' => 'Facebook',
2433
- 'url' => null,
2434
- 'placeholder' => 'https://www.facebook.com/mailpoetplugin'
2435
- ),
2436
- 'twitter' => array(
2437
- 'label' => 'Twitter',
2438
- 'url' => null,
2439
- 'placeholder' => 'http://www.twitter.com/mail_poet'
2440
- ),
2441
- 'google' => array(
2442
- 'label' => 'Google+',
2443
- 'url' => null,
2444
- 'placeholder' => null
2445
- ),
2446
- 'linkedin' => array(
2447
- 'label' => 'LinkedIn',
2448
- 'url' => null,
2449
- 'placeholder' => null
2450
- )
2451
- );
2452
-
2453
- // get networks' url from config
2454
- $model_config = WYSIJA::get('config', 'model');
2455
- $urls = $model_config->getValue('social_bookmarks');
2456
-
2457
- // set url from config for each network if specified
2458
- foreach ($networks as $network => $values) {
2459
- if (isset($urls[$network]) and strlen(trim($urls[$network])) > 0) {
2460
- $networks[$network]['url'] = $urls[$network];
2461
- }
2462
- }
2463
-
2464
- $this->data['networks'] = $networks;
2465
- $this->data['size'] = 'medium';
2466
- $this->data['theme'] = isset($_REQUEST['theme']) ? $_REQUEST['theme'] : 'default';
2467
-
2468
- return $this->popupContent();
2469
- }
2470
-
2471
- function dividers() {
2472
- $this->iframeTabs = array('dividers' => __("Dividers Selection", WYSIJA));
2473
- $this->js[] = 'wysija-admin-ajax';
2474
- $this->js[] = 'wysija-base-script-64';
2475
-
2476
- $_GET['tab'] = 'dividers';
2477
-
2478
- $model_email = WYSIJA::get('email', 'model');
2479
- $this->data['email'] = $email = $model_email->getOne(false, array('email_id' => $_REQUEST['emailId']));
2480
-
2481
- // get dividers
2482
- $helper_dividers = WYSIJA::get('dividers', 'helper');
2483
- $dividers = $helper_dividers->getAll();
2484
-
2485
- // get theme divider if it's not the default theme
2486
- if (isset($email['params']['theme'])) {
2487
- $helper_themes = WYSIJA::get('themes', 'helper');
2488
- $themeDivider = $helper_themes->getDivider($email['params']['theme']);
2489
- if ($themeDivider !== NULL) {
2490
- array_unshift($dividers, $themeDivider);
2491
- }
2492
- }
2493
-
2494
- // get selected divider
2495
- if (isset($email['params']['divider'])) {
2496
- $selected_divider = $email['params']['divider'];
2497
- } else {
2498
- $helper_dividers = WYSIJA::get('dividers', 'helper');
2499
- $selected_divider = $helper_dividers->getDefault();
2500
- }
2501
-
2502
- // set selected divider in first position
2503
- array_unshift($dividers, $selected_divider);
2504
-
2505
- // remove selected divider if present in the list
2506
- for ($i = 1; $i < count($dividers); $i++) {
2507
- if ($dividers[$i]['src'] === $selected_divider['src']) {
2508
- unset($dividers[$i]);
2509
- break;
2510
- }
2511
- }
2512
-
2513
- $this->data['selected'] = $selected_divider;
2514
- $this->data['dividers'] = $dividers;
2515
- return $this->popupContent();
2516
- }
2517
-
2518
- function autopost() {
2519
- $this->iframeTabs = array('autopost' => __("Add / Edit group of posts", WYSIJA));
2520
- $this->js[] = 'wysija-admin-ajax';
2521
- $this->js[] = 'wysija-base64';
2522
- $this->js[] = 'wysija-scriptaculous';
2523
- $this->js[] = 'wysija-colorpicker';
2524
- $this->js[] = 'mailpoet-select2';
2525
-
2526
- // translations
2527
- $this->jsTrans['show_advanced'] = __('Show display options', WYSIJA);
2528
- $this->jsTrans['hide_advanced'] = __('Hide display options', WYSIJA);
2529
-
2530
- $_GET['tab'] = 'autopost';
2531
-
2532
- // get parameters
2533
- $params = array(
2534
- 'category_ids' => null,
2535
- 'category_condition' => 'include',
2536
- 'title_tag' => 'h2',
2537
- 'title_alignment' => 'left',
2538
- 'title_position' => 'inside',
2539
- 'image_alignment' => 'alternate',
2540
- 'image_width' => 325,
2541
- 'post_content' => 'excerpt',
2542
- 'readmore' => __('Read more.', WYSIJA),
2543
- 'show_divider' => 'yes',
2544
- 'post_limit' => 5,
2545
- 'post_type' => 'post',
2546
- 'author_show' => 'no',
2547
- 'author_label' => __('Author:', WYSIJA),
2548
- 'category_show' => 'no',
2549
- 'category_label' => __('Categories:', WYSIJA),
2550
- 'nopost_message' => __('Latest content already sent.', WYSIJA),
2551
- 'bgcolor1' => null,
2552
- 'bgcolor2' => null,
2553
- 'sort_by' => 'newest'
2554
- );
2555
-
2556
- // backwards compatibility since we replaced the 'cpt' parameter by 'post_type' in 2.6
2557
- if(isset($_GET['cpt']) && strlen(trim($_GET['cpt'])) > 0) {
2558
- $params['post_type'] = trim($_GET['cpt']);
2559
- }
2560
-
2561
- // check if GET parameters are specified
2562
- foreach ($params as $key => $value) {
2563
- if (array_key_exists($key, $_GET)) {
2564
- switch ($key) {
2565
- case 'autopost_count':
2566
- $params[$key] = (int)$_GET[$key];
2567
- break;
2568
- case 'author_label':
2569
- case 'category_label':
2570
- case 'readmore':
2571
- case 'nopost_message':
2572
- $params[$key] = base64_decode($_GET[$key]);
2573
- break;
2574
- default:
2575
- $params[$key] = trim($_GET[$key]);
2576
- }
2577
- }
2578
- }
2579
-
2580
- // get autopost count
2581
- $this->data['autopost_count'] = (array_key_exists('autopost_count', $_GET)) ? (int) $_GET['autopost_count'] : 0;
2582
-
2583
- // get autopost type (single or multiple)
2584
- $this->data['autopost_type'] = (array_key_exists('autopost_type', $_GET)) ? $_GET['autopost_type'] : 'multiple';
2585
-
2586
- // if only one group of post can be added, change default alignment to left
2587
- if ($this->data['autopost_type'] === 'single') {
2588
- if ($params['image_alignment'] === 'alternate')
2589
- $params['image_alignment'] = 'left';
2590
- }
2591
-
2592
- // we use that now, because categories from a post are different than categories from a CPT
2593
- // $helper_wp_tools = WYSIJA::get('wp_tools','helper');
2594
- // $this->data['categories'] = $helper_wp_tools->get_categories();
2595
-
2596
- // max number of posts
2597
- $this->data['post_limits'] = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 50);
2598
-
2599
- $this->data['params'] = $params;
2600
-
2601
- return $this->popupContent();
2602
- }
2603
-
2604
- function image_data() {
2605
- $this->data['url'] = (isset($_GET['url']) && $_GET['url'] !== '') ? trim(urldecode($_GET['url'])) : null;
2606
- $this->data['alt'] = (isset($_GET['alt'])) ? trim(urldecode($_GET['alt'])) : '';
2607
-
2608
- $this->iframeTabs = array('image_data' => __("Image Parameters", WYSIJA));
2609
- $_GET['tab'] = 'image_data';
2610
- return $this->popupContent();
2611
- }
2612
-
2613
- function medias() {
2614
- $this->popupContent();
2615
- }
2616
-
2617
- function special_wysija_browse() {
2618
- $this->_wysija_subaction();
2619
- $this->jsTrans['deleteimg'] = __('Delete image for all newsletters?', WYSIJA);
2620
- return wp_iframe(array($this->viewObj, 'popup_wysija_browse'), array());
2621
- }
2622
-
2623
- function special_wordp_browse() {
2624
- $this->_wysija_subaction();
2625
- $this->jsTrans['deleteimg'] = __('This image might be in an article. Delete anyway?', WYSIJA);
2626
- return wp_iframe(array($this->viewObj, 'popup_wp_browse'), array());
2627
- }
2628
-
2629
- function _wysija_subaction() {
2630
-
2631
- if (isset($_REQUEST['subaction'])) {
2632
- if ($_REQUEST['subaction'] === 'delete') {
2633
- if (isset($_REQUEST['imgid']) && (int) $_REQUEST['imgid'] > 0) {
2634
- /* delete the image with id imgid */
2635
- $res = wp_delete_attachment((int) $_REQUEST['imgid'], true);
2636
- if ($res) {
2637
- $this->notice(__('Image has been deleted.', WYSIJA));
2638
- }
2639
- }
2640
- }
2641
- }
2642
- return true;
2643
- }
2644
-
2645
- function special_new_wordp_upload() {
2646
-
2647
- //wp_enqueue_script('plupload-all');
2648
- wp_enqueue_script('wysija-plupload-handlers', WYSIJA_URL . 'js/jquery/pluploadHandler.js', array('plupload-all', 'jquery'));
2649
- $uploader_l10n = array(
2650
- 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
2651
- 'file_exceeds_size_limit' => __('%s exceeds the maximum upload size for this site.'),
2652
- 'zero_byte_file' => __('This file is empty. Please try another.'),
2653
- 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
2654
- 'not_an_image' => __('This file is not an image. Please try another.'),
2655
- 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
2656
- 'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
2657
- 'default_error' => __('An error occurred in the upload. Please try again later.'),
2658
- 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
2659
- 'upload_limit_exceeded' => __('You may only upload 1 file.'),
2660
- 'http_error' => __('HTTP error.'),
2661
- 'upload_failed' => __('Upload failed.'),
2662
- 'big_upload_failed' => __('Please try uploading this file with the %1$sbrowser uploader%2$s.'),
2663
- 'big_upload_queued' => __('%s exceeds the maximum upload size for the multi-file uploader when used in your browser.'),
2664
- 'io_error' => __('IO error.'),
2665
- 'security_error' => __('Security error.'),
2666
- 'file_cancelled' => __('File canceled.'),
2667
- 'upload_stopped' => __('Upload stopped.'),
2668
- 'dismiss' => __('Dismiss'),
2669
- 'crunching' => __('Crunching&hellip;'),
2670
- 'deleted' => __('moved to the trash.'),
2671
- 'error_uploading' => __('&#8220;%s&#8221; has failed to upload.')
2672
- );
2673
-
2674
- wp_localize_script('wysija-plupload-handlers', 'pluploadL10n', $uploader_l10n);
2675
-
2676
- wp_enqueue_script('image-edit');
2677
- wp_enqueue_script('set-post-thumbnail');
2678
- wp_enqueue_style('imgareaselect');
2679
- wp_enqueue_script('media-gallery');
2680
-
2681
- /* wp_register_style('myplupload', '/adjust-this-url/myplupload.css');
2682
- wp_enqueue_style('myplupload'); */
2683
-
2684
-
2685
- $errors = array();
2686
- return wp_iframe(array($this->viewObj, 'popup_new_wp_upload'), $errors);
2687
- }
2688
-
2689
- function special_wordp_upload() {
2690
-
2691
- wp_enqueue_script('swfupload-all');
2692
- wp_enqueue_script('swfupload-handlers');
2693
- wp_enqueue_script('wysija-upload-handlers', WYSIJA_URL . "js/jquery/uploadHandlers.js");
2694
- wp_enqueue_script('image-edit');
2695
- wp_enqueue_script('set-post-thumbnail');
2696
- wp_enqueue_style('imgareaselect');
2697
-
2698
- $errors = array();
2699
- $id = 0;
2700
- if (isset($_GET['flash']))
2701
- $_GET['flash'] = 1;
2702
- if (isset($_POST['html-upload']) && !empty($_FILES)) {
2703
- // Upload File button was clicked
2704
- $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
2705
- unset($_FILES);
2706
- if (is_wp_error($id)) {
2707
- $errors['upload_error'] = $id;
2708
- $id = false;
2709
- }
2710
- }
2711
-
2712
- if (!empty($_POST['insertonlybutton'])) {
2713
- $href = $_POST['insertonly']['href'];
2714
- if (!empty($href) && !strpos($href, '://'))
2715
- $href = "http://$href";
2716
-
2717
- $title = esc_attr($_POST['insertonly']['title']);
2718
- if (empty($title))
2719
- $title = basename($href);
2720
- if (!empty($title) && !empty($href))
2721
- $html = "<a href='" . esc_url($href) . "' >$title</a>";
2722
- $html = apply_filters('file_send_to_editor_url', $html, esc_url_raw($href), $title);
2723
- return media_send_to_editor($html);
2724
- }
2725
-
2726
- if (!empty($_POST)) {
2727
- $return = media_upload_form_handler();
2728
-
2729
- if (is_string($return))
2730
- return $return;
2731
- if (is_array($return))
2732
- $errors = $return;
2733
- }
2734
-
2735
- if (isset($_POST['save'])) {
2736
- $errors['upload_notice'] = __('Saved.', WYSIJA);
2737
- return media_upload_gallery();
2738
- }
2739
-
2740
-
2741
- return wp_iframe(array($this->viewObj, 'popup_wp_upload'), $errors);
2742
- }
2743
-
2744
- function _checkEmailExists($emailId) {
2745
- $result = false;
2746
- $modelEmail = WYSIJA::get('email', 'model');
2747
-
2748
- if ($modelEmail->exists(array('email_id' => $emailId)))
2749
- $result = true;
2750
-
2751
- if (!$result) {
2752
- $this->error(__("The newsletter doesn't exist.", WYSIJA), 1);
2753
- $this->redirect('admin.php?page=wysija_campaigns');
2754
- }
2755
- else
2756
- return true;
2757
- }
2758
 
2759
  }
5
 
6
  class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
7
 
8
+ var $model = 'campaign';
9
+ var $view = 'campaigns';
10
+ var $list_columns = array('campaign_id', 'name', 'description');
11
+ var $searchable = array('name', 'subject');
12
+ var $filters = array();
13
+ var $base_url = 'admin.php';
14
+
15
+ function WYSIJA_control_back_campaigns() {
16
+
17
+ }
18
+
19
+ function installation(){
20
+
21
+ $start_time = time();
22
+ $check_max_execution_time = get_option( 'mpoet_check_max_execution_time' );
23
+ $ini_max_execution_time = ini_get( 'max_execution_time' );
24
+
25
+ // 1 - we haven't run the max execution time extension test yet, let's do it
26
+ // this test should be run in the background, it may take more than 5 minutes to validate
27
+ if( empty( $check_max_execution_time ) ){
28
+
29
+ // we set the max_execution_time to infinite
30
+ @ini_set( 'max_execution_time' , 0 );
31
+ // we keep running the script even if the user abort his request
32
+ @ignore_user_abort( true );
33
+
34
+ $reset_max_execution_time = ini_get( 'max_execution_time' );
35
+
36
+ // FAILURE some servers the "max execution time" returned is Array we make sure our value is numeric
37
+ if( !is_numeric( $ini_max_execution_time ) ){
38
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time-1 );
39
+ return;
40
+ }
41
+
42
+ // FAILURE this server doesn't allow us to set the max_execution_time
43
+ if( $reset_max_execution_time == $ini_max_execution_time ){
44
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time-1 );
45
+ return;
46
+ }
47
+
48
+ // we set a FAILURE value to our flag so we know if the process crash while executing
49
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time );
50
+
51
+ // the common default timeout value is 300, so if by default the timelimit is 0 (which might have been set by another application)
52
+ // we default it to 300 known as a common default value and we run the extension test
53
+ if( $ini_max_execution_time == 0 ) $ini_max_execution_time = 300;
54
+
55
+ // we run asleep script during the initial max execution time to a larger value
56
+ $total_time_to_run_script = $ini_max_execution_time + 20;
57
+ $sleeping_intervals = 5;
58
+ $duration_so_far = 0;
59
+
60
+ // we sleep until the extended total timeout value is reached or it breaks before but we have the value we need
61
+ while($total_time_to_run_script >0){
62
+ $total_time_to_run_script = $total_time_to_run_script - $sleeping_intervals;
63
+ sleep( $sleeping_intervals );
64
+
65
+ $duration_so_far = time() - $start_time;
66
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $duration_so_far );
67
+ }
68
+
69
+ // SUCCESS the scripts didn't die we set our flag in the db so that we know the test is a success
70
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $duration_so_far );
71
+
72
+ }else{
73
+ // 2 - the max execution time extension test has been run, this is the results we get
74
+ if( $check_max_execution_time > $ini_max_execution_time ){
75
+ echo 'max_execution_time('.$ini_max_execution_time.') can be extended('.$check_max_execution_time.')';
76
+ }else{
77
+ echo 'max_execution_time('.$ini_max_execution_time.') cannot be extended( max value : '.$check_max_execution_time.')';
78
+ }
79
+ }
80
+ exit;
81
+ }
82
+
83
+ /**
84
+ * Welcome page first time install
85
+ * @return boolean
86
+ */
87
+ function welcome_new() {
88
+ $this->title = $this->viewObj->title = __('Welcome Page!', WYSIJA);
89
+ $this->jsTrans['instalwjp'] = __('Installing MailPoet Newsletter Premium plugin', WYSIJA);
90
+ $helper_readme = WYSIJA::get('readme', 'helper');
91
+ $helper_readme->scan();
92
+ $this->data = array();
93
+ $this->data['abouttext'] = __('A Brand New MailPoet. Let the Fun Begin.', WYSIJA);
94
+
95
+ $model_config = WYSIJA::get('config', 'model');
96
+ $is_multisite = is_multisite();
97
+ $is_network_admin = WYSIJA::current_user_can('manage_network');
98
+ if ($is_multisite && $is_network_admin) {
99
+ $model_config->save(array('ms_wysija_whats_new' => WYSIJA::get_version()));
100
+ } else {
101
+ $model_config->save(array('wysija_whats_new' => WYSIJA::get_version()));
102
+ }
103
+
104
+ //add a new language code with a new video
105
+ $video_language=array();
106
+ //$video_language['en_EN'] = '<iframe width="853" height="480" src="http://www.youtube.com/embed/pYzaHDTg5Jk" frameborder="0" allowfullscreen></iframe>';
107
+ $video_language['en_EN'] = '<iframe src="//player.vimeo.com/video/81479899" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
108
+ //$video_language['fr_FR'] = '<iframe width="853" height="480" src="http://www.youtube.com/embed/W5EyW5w7aWQ" frameborder="0" allowfullscreen></iframe>';
109
+ // $video_language['sv_SE']='<iframe width="853" height="480" src="http://www.youtube.com/embed/O8_t_dekx74" frameborder="0" allowfullscreen></iframe>';
110
+ //$video_language['ar']='<iframe width="853" height="480" src="http://www.youtube.com/embed/cyDHlX_qgOo" frameborder="0" allowfullscreen></iframe>';
111
+
112
+ $wp_lang = get_locale();
113
+ if (!empty($wp_lang) && isset($video_language[$wp_lang])) {
114
+ $welcome_video_link = $video_language[$wp_lang];
115
+ } else {
116
+ $welcome_video_link = $video_language['en_EN'];
117
+ }
118
+
119
+ $this->data['sections'][] = array(
120
+ 'title' => __('Hey, we\'re curious! How did you find out about us?', WYSIJA) . '<span id="poll_result"></span>',
121
+ 'format' => 'normal',
122
+ 'paragraphs' => array(
123
+ '<ul class="welcome_poll">
124
+ <li>
125
+ <input type="radio" id="how_did_you_find_us_1" value="repository" name="how_did_you_find_us">
126
+ <label value="lab1" for="how_did_you_find_us_1">' . __('WordPress.org plugin repository', WYSIJA) . '</label>
127
+ </li>
128
+ <li>
129
+ <input type="radio" id="how_did_you_find_us_2" value="search_engine" name="how_did_you_find_us">
130
+ <label value="lab2" for="how_did_you_find_us_2">' . __('Google or other search engine', WYSIJA) . '</label>
131
+ </li>
132
+ <li>
133
+ <input type="radio" id="how_did_you_find_us_3" value="friend" name="how_did_you_find_us">
134
+ <label value="lab3" for="how_did_you_find_us_3">' . __('Friend recommendation', WYSIJA) . '</label>
135
+ </li>
136
+ <li>
137
+ <input type="radio" id="how_did_you_find_us_4" value="url" name="how_did_you_find_us">
138
+ <label value="lab4" for="how_did_you_find_us_4">' . __('Blog post, online review, forum:', WYSIJA) . '</label>
139
+ <input type="text" id="how_did_you_find_us_4_url" name="how_did_you_find_us_url" placeholder="' . __('Please enter the address where you\'ve found out about us', WYSIJA) . '">
140
+ </li>
141
+ </ul>'
142
+ )
143
+ );
144
+
145
+ $this->data['sections'][]=array(
146
+ 'title'=>__('First Time? See it in Action',WYSIJA),
147
+ 'format'=>'normal',
148
+ 'paragraphs'=>array(
149
+ __('You can start by watching this video by one of our users.',WYSIJA),
150
+ $welcome_video_link
151
+ )
152
+ );
153
+
154
+ // Check if user is already sharing data, and hide the share link.
155
+ if (!$model_config->getValue('analytics')) {
156
+ $share_section = array(
157
+ 'title' => __('Share your data', WYSIJA),
158
+ 'content' => str_replace(
159
+ array('[link]', '[/link]', '[ajaxlink]', '[/ajaxlink]'), array('<a title="Anonymous Data" target="_blank" href="http://support.mailpoet.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=welcome_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'), __("We know too little about our users. We're looking for [link]anonymous data[/link] to build a better plugin. [ajaxlink]Yes, count me in![/ajaxlink]", WYSIJA))
160
+ );
161
+ } else {
162
+ $share_section = array(
163
+ 'title' => __('Share your data', WYSIJA),
164
+ 'content' => str_replace(
165
+ array('[link]', '[/link]'), array('<a title="Anonymous Data" target="_blank" href="http://support.mailpoet.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=welcome_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'), __("We know too little about our users. We're looking for [link]anonymous data[/link] to build a better plugin. Thanks, you're already sharing!", WYSIJA))
166
+ );
167
+ }
168
+
169
+ $this->data['sections'][] = array(
170
+ 'title' => __('What You Can Do', WYSIJA),
171
+ 'cols' => array(
172
+ array(
173
+ 'title' => __('5 minute newbie guide', WYSIJA),
174
+ 'content' => __('Your MailPoet comes with an example newsletter. You\'ll see it when you close this welcome page. Edit it to start playing with it.', WYSIJA)
175
+ ),
176
+ $share_section,
177
+ array(
178
+ 'title' => __('Help yourself. Or let us help you.', WYSIJA),
179
+ 'content' => str_replace(
180
+ array('[link]', '[/link]'), array('<a href="http://support.mailpoet.com/" target="_blank" title="On our blog!">', '</a>'), __('We got documentation and a ticket system on [link]support.mailpoet.com[/link]. We answer within 24h.', WYSIJA))
181
+ )
182
+ ),
183
+ 'format' => 'three-col',
184
+ );
185
+
186
+ $this->viewObj->skip_header = true;
187
+
188
+ return true;
189
+ }
190
+
191
+ /**
192
+ * Welcome page for updaters
193
+ * @return boolean
194
+ */
195
+ function whats_new() {
196
+
197
+ $this->title = $this->viewObj->title = __('What\'s new?', WYSIJA);
198
+ $this->jsTrans['instalwjp'] = __('Installing MailPoet Newsletter Premium plugin', WYSIJA);
199
+ wp_enqueue_style('wysija-admin-css-premium', WYSIJA_URL.'css/admin-premium.css',array(),WYSIJA::get_version());
200
+
201
+ $this->viewObj->skip_header = true;
202
+ return true;
203
+ }
204
+
205
+
206
+
207
+ /* START prem check hook */
208
+
209
+ // when curl or any php remote function not available mailpoet.com returns lcheck to that function
210
+ function licok() {
211
+ parent::WYSIJA_control_back();
212
+ $dt = get_option('wysijey');
213
+
214
+ if (isset($_REQUEST['xtz']) && $dt === $_REQUEST['xtz']) {
215
+ $dataconf = array('premium_key' => base64_encode(get_option('home') . time()), 'premium_val' => time());
216
+ $this->notice(__('Premium version is valid for your site.', WYSIJA));
217
+ } else {
218
+ $dataconf = array('premium_key' => '', 'premium_val' => '');
219
+
220
+ $helper_licence = WYSIJA::get('licence', 'helper');
221
+ $url_premium = 'http://www.mailpoet.com/checkout/?wysijadomain=' . $dt . '&nc=1&utm_source=wpadmin&utm_campaign=error_licence_activation';
222
+
223
+ $this->error(str_replace(array('[link]', '[/link]'), array('<a href="' . $url_premium . '" target="_blank">', '</a>'), __('Premium licence does not exist for your site. Purchase it [link]here[/link].', WYSIJA)), 1);
224
+ }
225
+ WYSIJA::update_option('wysicheck', false);
226
+ $modelConf = WYSIJA::get('config', 'model');
227
+ $modelConf->save($dataconf);
228
+
229
+ $this->redirect('admin.php?page=wysija_config#tab-premium');
230
+ }
231
+
232
+ /* END prem check hook */
233
+
234
+ function validateLic() {
235
+ $helpLic = WYSIJA::get('licence', 'helper');
236
+ $res = $helpLic->check();
237
+
238
+ $this->redirect();
239
+ }
240
+
241
+ /**
242
+ * this function is triggered when sending manually the emails with the "Don't wait and send right now" button
243
+ * @param type $dataPost
244
+ */
245
+ function manual_send($dataPost = false) {
246
+ $modelQ = WYSIJA::get('queue', 'model');
247
+ $config = WYSIJA::get('config', 'model');
248
+ if ((int) $config->getValue('total_subscribers') < 2000) {
249
+ if ($modelQ->count() > 0) {
250
+ $helperQ = WYSIJA::get('queue', 'helper');
251
+ $emailid = false;
252
+ if ($_REQUEST['emailid']) {
253
+ $emailid = $_REQUEST['emailid'];
254
+ }
255
+ $helperQ->process($emailid);
256
+ } else {
257
+ echo '<strong style="font-family: Arial; font-weight: bold; font-size: 12px;">' . __('Queue is empty!', WYSIJA) . '</strong>';
258
+ }
259
+ exit;
260
+ } else {
261
+ //deprecated
262
+ do_action('wysija_send_test_editor');
263
+
264
+ do_action('wysija_manual_send');
265
+ }
266
+
267
+ exit;
268
+ }
269
+
270
+ /**
271
+ * test the bounce handling maybe this should move somewhere else like config controller
272
+ * @return boolean
273
+ */
274
+ function test_bounce() {
275
+ // bounce handling
276
+ $helper_bounce = WYSIJA::get('bounce', 'helper');
277
+
278
+ // in a multisite case we process first the bounce recording into the bounce table
279
+ if (is_multisite()) {
280
+ $helper_bounce->record_bounce_ms();
281
+
282
+ // then we take actions from what has been returned by the bounce
283
+ $helper_bounce->process_bounce_ms();
284
+ } else {
285
+ $helper_bounce->process_bounce();
286
+ }
287
+ exit;
288
+ }
289
+
290
+ function add($dataPost = false) {
291
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 1);
292
+ $this->js[] = 'wysija-validator';
293
+
294
+ $this->js[] = 'wysija-edit-autonl';
295
+ $this->js['admin-campaigns-edit'] = 'admin-campaigns-edit';
296
+ $this->jsTrans['descauto'] = str_replace(array('[newsletter:number]', '[newsletter:total]', '[newsletter:post_title]'), array('<b>[newsletter:number]</b>', '<b>[newsletter:total]</b>', '<b>[newsletter:post_title]</b>'), __('Insert [newsletter:total] to show number of posts, [newsletter:post_title] to show the latest post\'s title & [newsletter:number] to display the issue number.', WYSIJA));
297
+ $this->jsTrans['descstandard'] = __('The first thing your subscribers see. Be creative and increase your open rate!', WYSIJA);
298
+ $this->immediateWarning();
299
+ $this->viewObj->title = __('First step: main details', WYSIJA);
300
+ $this->viewShow = 'add';
301
+ $this->data = array();
302
+ $this->data['campaign'] = array('name' => '', 'description' => '');
303
+ $modelConfig = WYSIJA::get('config', 'model');
304
+ $this->data['email'] = array('subject' => '', 'from_email' => $modelConfig->getValue('from_email'), 'from_name' => $modelConfig->getValue('from_name'));
305
+ $this->data['lists'] = $this->__getLists(false, true, true);
306
+
307
+ $this->dataAutoNl();
308
+ $this->jsLoc['admin-campaigns-edit']['autofields'] = $this->data['autonl']['fields'];
309
+ }
310
+
311
+ /**
312
+ * get the fields and fields value necessary when dealing with automatic newsletters
313
+ */
314
+ function dataAutoNl() {
315
+ $dataFrequencyNoImmediate = $dataFrequency = array('daily' => __('once a day at...', WYSIJA),
316
+ 'weekly' => __('weekly on...', WYSIJA),
317
+ 'monthly' => __('monthly on the...', WYSIJA),
318
+ 'monthlyevery' => __('monthly every...', WYSIJA),
319
+ 'immediate' => __('immediately.', WYSIJA));
320
+
321
+ unset($dataFrequencyNoImmediate['immediate']);
322
+
323
+ $times = array();
324
+ $time = strtotime('00:00:00');
325
+ $toolboxH = WYSIJA::get('toolbox', 'helper');
326
+ $times['00:00:00'] = $toolboxH->localtime($time);
327
+
328
+ for ($i = 1; $i < 24; $i++) {
329
+ $time = strtotime('+ 1hour', $time);
330
+ $key = date('H:i:s', $time);
331
+ $times[$key] = $toolboxH->localtime($time);
332
+ }
333
+
334
+ $daysvalues = $toolboxH->getday();
335
+
336
+ $numberweeks = $toolboxH->getweeksnumber();
337
+ $daynumbers = $toolboxH->getdaynumber();
338
+
339
+
340
+ $dataLists = array();
341
+
342
+ foreach ($this->data['lists'] as $datal) {
343
+ if ($datal['is_enabled'])
344
+ $dataLists[$datal['list_id']] = $datal['name'];
345
+ }
346
+
347
+ // Get all available roles
348
+ $wptoolsH = WYSIJA::get('wp_tools', 'helper');
349
+ $roles = $wptoolsH->wp_get_all_roles();
350
+ $available_roles = array('any' => __('in any WordPress role', WYSIJA));
351
+ foreach ($roles as $role => $name) {
352
+ $available_roles[$role] = $name;
353
+ }
354
+
355
+ $this->data['autonl']['fields'] = array(
356
+ 'event' => array(
357
+ 'values' => array(
358
+ 'new-articles' => __('When there\'s new content...', WYSIJA),
359
+ 'subs-2-nl' => __('When someone subscribes to the list...', WYSIJA),
360
+ 'new-user' => __('When a new WordPress user is added to your site...', WYSIJA),
361
+ ),
362
+ 'valueshow' => array(
363
+ 'new-articles' => array('when-article'),
364
+ 'subs-2-nl' => array('subscribetolist', 'numberafter', 'numberofwhat', 'unique_send'),
365
+ 'new-user' => array('roles', 'numberafter', 'numberofwhat', 'unique_send'),
366
+ ),
367
+ 'style' => 'width:300px;'
368
+ ),
369
+ 'when-article' => array(
370
+ 'values' => $dataFrequency,
371
+ 'valueshow' => array(
372
+ 'daily' => array('time'),
373
+ 'weekly' => array('dayname', 'time'),
374
+ 'monthly' => array('daynumber', 'time'),
375
+ 'monthlyevery' => array('dayevery', 'dayname', 'time'),
376
+ )
377
+ ),
378
+ 'subscribetolist' => array(
379
+ 'values' => $dataLists,
380
+ 'style' => 'width:300px;'
381
+ ),
382
+ 'roles' => array(
383
+ 'values' => $available_roles
384
+ ),
385
+ 'numberafter' => array(
386
+ 'type' => 'input',
387
+ 'style' => 'width:35px;',
388
+ 'class' => 'validate[required,custom[integer],min[1]]',
389
+ ),
390
+ 'numberofwhat' => array(
391
+ 'values' => array(
392
+ 'immediate' => __('immediately.', WYSIJA),
393
+ 'hours' => __('hour(s) after.', WYSIJA),
394
+ 'days' => __('day(s) after.', WYSIJA),
395
+ 'weeks' => __('week(s) after.', WYSIJA)
396
+ ),
397
+ 'valuesunit' => array(
398
+ 'immediate' => __('immediately', WYSIJA),
399
+ 'hours' => __('hour(s)', WYSIJA),
400
+ 'days' => __('day(s)', WYSIJA),
401
+ 'weeks' => __('week(s)', WYSIJA)
402
+ ),
403
+ ),
404
+ 'dayevery' => array(
405
+ 'values' => $numberweeks,
406
+ ),
407
+ 'dayname' => array(
408
+ 'values' => $daysvalues,
409
+ ),
410
+ 'daynumber' => array(
411
+ 'values' => $daynumbers,
412
+ ),
413
+ 'time' => array(
414
+ 'values' => $times,
415
+ ),
416
+ /* 'unique_send'=>array(
417
+ 'label_before'=>__('Send this email only once.',WYSIJA),
418
+ 'type'=>'checkbox'
419
+ ), */
420
+ );
421
+ $helpersEvent = WYSIJA::get('autonews', 'helper');
422
+ $extraEvents = $helpersEvent->events();
423
+
424
+ /* if there are plugin to add autonewsletter event they are adding their customized field over here */
425
+ if ($extraEvents) {
426
+ foreach ($extraEvents as $k => $v) {
427
+
428
+ $this->data['autonl']['fields']['event']['values'][$k] = $v['title'];
429
+ foreach ($v['fields'] as $fieldCKEY => $fieldCVAL) {
430
+ if (isset($this->data['autonl']['fields'][$fieldCKEY]))
431
+ continue;
432
+ }
433
+ $this->data['autonl']['fields']['event']['valueshow'][$k] = array_keys($v['fields']);
434
+ }
435
+ }
436
+ }
437
+
438
+ function __getLists($enabled = true, $count = false, $notgetalllistid = false) {
439
+ $modelList = WYSIJA::get('list', 'model');
440
+ //get lists which have users and are enabled */
441
+ if ($enabled)
442
+ $enabledstrg = ' is_enabled>0 and';
443
+ else
444
+ $enabledstrg = '';
445
+
446
+ $extrasql = '';
447
+ if (!$notgetalllistid)
448
+ $extrasql = 'WHERE list_id in (SELECT distinct(list_id) from [wysija]user_list )';
449
+ $query = 'SELECT * FROM [wysija]list ' . $extrasql;
450
+ $listres = $modelList->query('get_res', $query);
451
+
452
+ if ($count) {
453
+ $mConfig = WYSIJA::get('config', 'model');
454
+ $condit = '>=';
455
+ if ($mConfig->getValue('confirm_dbleoptin'))
456
+ $condit = '>';
457
+ $qry1 = "SELECT count(distinct A.user_id) as nbsub,A.list_id FROM `[wysija]user_list` as A LEFT JOIN `[wysija]user` as B on A.user_id=B.user_id WHERE B.status $condit 0 and A.sub_date>0 and A.unsub_date=0 GROUP BY list_id";
458
+
459
+ $total = $modelList->getResults($qry1);
460
+
461
+ foreach ($total as $tot) {
462
+ foreach ($listres as $key => $res) {
463
+ if ($tot['list_id'] == $res['list_id'])
464
+ $listres[$key]['count'] = $tot['nbsub'];
465
+ }
466
+ }
467
+ }
468
+ foreach ($listres as $key => $res) {
469
+ if (!isset($res['count']))
470
+ $listres[$key]['count'] = 0;
471
+ }
472
+ return $listres;
473
+ }
474
+
475
+ function edit($dataPost = false) {
476
+ if (!$this->_checkEmailExists($_REQUEST['id']))
477
+ return;
478
+ $this->add();
479
+
480
+ $modelEmail = WYSIJA::get('email', 'model');
481
+
482
+ $this->data['email'] = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
483
+
484
+ if ($this->data['email']['status'] > 0) {
485
+ $this->redirect();
486
+ }
487
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 1) . ' | ' . $this->data['email']['subject'];
488
+ $modelCamp = WYSIJA::get('campaign', 'model');
489
+ $this->data['campaign'] = $modelCamp->getOne(false, array('campaign_id' => $this->data['email']['campaign_id']));
490
+
491
+ $modelCL = WYSIJA::get('campaign_list', 'model');
492
+ $this->data['campaign_list'] = $modelCL->get(false, array('campaign_id' => $this->data['email']['campaign_id']));
493
+ }
494
+
495
+ function editTemplate() {
496
+ // make sure the editor content is not cached
497
+ header('Cache-Control: no-cache, max-age=0, must-revalidate, no-store'); // HTTP/1.1
498
+ header('Expires: Fri, 9 Mar 1984 00:00:00 GMT');
499
+
500
+ if (!$this->_checkEmailExists($_REQUEST['id']))
501
+ return;
502
+ $this->viewShow = 'editTemplate';
503
+
504
+ wp_enqueue_style('thickbox');
505
+
506
+ $wjEngine = WYSIJA::get('wj_engine', 'helper');
507
+ /* WJ editor translations */
508
+ $this->jsTrans = array_merge($this->jsTrans, $wjEngine->getTranslations(), $wjEngine->getApplicationData());
509
+
510
+ $this->jsTrans['savingnl'] = __('Saving newsletter...', WYSIJA);
511
+ $this->jsTrans['errorsavingnl'] = __('Error Saving newsletter...', WYSIJA);
512
+ $this->jsTrans['savednl'] = __('Newsletter has been saved.', WYSIJA);
513
+ $this->jsTrans['previewemail'] = __('Sending preview...', WYSIJA);
514
+ $this->jsTrans['spamtestresult'] = __('Spam test results', WYSIJA);
515
+
516
+ /* WJ editor JS */
517
+ $this->js[] = 'wysija-editor';
518
+ $this->js[] = 'wysija-admin-ajax-proto';
519
+ $this->js[] = 'wysija-admin-ajax';
520
+ $this->js[] = 'wysija-base-script-64';
521
+ $this->js[] = 'media-upload';
522
+ $this->js['admin-campaigns-editDetails'] = 'admin-campaigns-editDetails';
523
+ $modelEmail = WYSIJA::get('email', 'model');
524
+ $this->data = array();
525
+ $this->data['email'] = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
526
+
527
+ $this->checkIsEditable();
528
+
529
+ $this->viewObj->title = sprintf(__('Second step: "%1$s"', WYSIJA), $this->data['email']['subject']);
530
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 2) . " | " . $this->data['email']['subject'];
531
+
532
+ // check if html source is enabled in the config (this will add the "html source" button in tinymce)
533
+ $model_config = WYSIJA::get('config', 'model');
534
+ $this->jsTrans['html_source_enabled'] = (int) $model_config->getValue('html_source');
535
+ }
536
+
537
+ function checkIsEditable() {
538
+ if (
539
+ !($this->data['email'] == 2 || isset($this->data['email']['params']['schedule']['isscheduled'])) && $this->data['email']['status'] > 0
540
+ ) {
541
+ $this->redirect();
542
+ }
543
+ }
544
+
545
+ function pause() {
546
+ /* pause the campaign entry */
547
+ if (isset($_REQUEST['id']) && $_REQUEST['id']) {
548
+ $modelEmail = WYSIJA::get('email', 'model');
549
+ $myemail = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
550
+ $modelEmail->reset();
551
+ $modelEmail->columns['modified_at']['autoup'] = 1;
552
+ $modelEmail->update(array('status' => -1), array('email_id' => $_REQUEST['id']));
553
+
554
+ if ($myemail['type'] == 2) {
555
+ return $this->redirect('admin.php?page=wysija_campaigns&id=' . $myemail['email_id'] . '&action=edit');
556
+ } else {
557
+ $this->notice(__('Sending is now paused.', WYSIJA));
558
+ }
559
+ }
560
+
561
+ $this->redirect();
562
+ }
563
+
564
+ function resume() {
565
+ /* pause the campaign entry */
566
+ if (isset($_REQUEST['id']) && $_REQUEST['id']) {
567
+ $modelEmail = WYSIJA::get('email', 'model');
568
+ $modelEmail->columns['modified_at']['autoup'] = 1;
569
+ $modelEmail->update(array('status' => 99), array('email_id' => $_REQUEST['id']));
570
+ $this->notice(__('Sending has resumed.', WYSIJA));
571
+ }
572
+
573
+ $this->redirect();
574
+ }
575
+
576
+ function duplicate() {
577
+
578
+ /* 1 - copy the campaign entry */
579
+
580
+ $model = WYSIJA::get('campaign', 'model');
581
+ $query = 'INSERT INTO `[wysija]campaign` (`name`,`description`)
582
+ SELECT concat("' . stripslashes(__('Copy of ', WYSIJA)) . '",`name`),`description` FROM [wysija]campaign
583
+ WHERE campaign_id=' . (int) $_REQUEST['id'];
584
+ $campaignid = $model->query($query);
585
+
586
+ /* 2 - copy the email entry */
587
+ $query = 'INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
588
+ SELECT ' . $campaignid . ', concat("' . stripslashes(__('Copy of ', WYSIJA)) . '",`subject`),`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,' . time() . ',' . time() . ' FROM [wysija]email
589
+ WHERE email_id=' . (int) $_REQUEST['email_id'];
590
+ $emailid = $model->query($query);
591
+
592
+ //let's reset the count of total childs for auto newsletter
593
+ $mEmail = WYSIJA::get('email', 'model');
594
+ $emailData = $mEmail->getOne(false, array('email_id' => $emailid));
595
+
596
+ if ($emailData['type'] == 2) {
597
+ $paramsReseted = $emailData['params'];
598
+ if (isset($paramsReseted['autonl']['total_child']))
599
+ $paramsReseted['autonl']['total_child'] = 0;
600
+ if (isset($paramsReseted['autonl']['nextSend']))
601
+ $paramsReseted['autonl']['nextSend'] = 0;
602
+ if (isset($paramsReseted['autonl']['firstSend']))
603
+ unset($paramsReseted['autonl']['firstSend']);
604
+ if (isset($paramsReseted['autonl']['lastSend']))
605
+ unset($paramsReseted['autonl']['lastSend']);
606
+ if (isset($paramsReseted['autonl']['articles']['ids']))
607
+ unset($paramsReseted['autonl']['articles']['ids']);
608
+
609
+
610
+ $mEmail->update(array('params' => $paramsReseted), array('email_id' => $emailid));
611
+ }
612
+
613
+ /* 3 - copy the campaign_list entry */
614
+ $query = "INSERT INTO `[wysija]campaign_list` (`campaign_id`,`list_id`,`filter`)
615
+ SELECT $campaignid,`list_id`,`filter` FROM [wysija]campaign_list
616
+ WHERE campaign_id=" . (int) $_REQUEST['id'];
617
+ $model->query($query);
618
+
619
+ $this->notice(__('The newsletter has been duplicated.', WYSIJA));
620
+
621
+ $this->redirect('admin.php?page=wysija_campaigns&id=' . $emailid . '&action=edit');
622
+ }
623
+
624
+ function duplicateEmail() {
625
+ if (!$this->_checkEmailExists($_REQUEST['id']))
626
+ return;
627
+
628
+ $model = WYSIJA::get('campaign', 'model');
629
+ /* 2 - copy the email entry */
630
+ $query = 'INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
631
+ SELECT `campaign_id`, concat("' . stripslashes(__("Copy of ", WYSIJA)) . '",`subject`),`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,' . time() . ',' . time() . ' FROM [wysija]email
632
+ WHERE email_id=' . (int) $_REQUEST['id'];
633
+ $emailid = $model->query($query);
634
+
635
+ $this->notice(__('The newsletter has been duplicated.', WYSIJA));
636
+
637
+ $this->redirect('admin.php?page=wysija_campaigns&id=' . $emailid . '&action=edit');
638
+ }
639
+
640
+ function immediateWarning() {
641
+ $model_config = WYSIJA::get('config', 'model');
642
+ $is_multisite = is_multisite();
643
+
644
+ //$is_multisite=true;//PROD comment that line
645
+ if ($is_multisite && $model_config->getValue('sending_method') == 'network') {
646
+ $sending_emails_each = $model_config->getValue('ms_sending_emails_each');
647
+ $number = $model_config->getValue('ms_sending_emails_number');
648
+ } else {
649
+ $sending_emails_each = $model_config->getValue('sending_emails_each');
650
+ $number = $model_config->getValue('sending_emails_number');
651
+ }
652
+
653
+ $formsHelp = WYSIJA::get('forms', 'helper');
654
+
655
+ $timespan = $formsHelp->eachValuesSec[$sending_emails_each];
656
+ $tb = WYSIJA::get('toolbox', 'helper');
657
+
658
+ $this->immediatewarning = str_replace(
659
+ array('[link]', '[/link]', '[settings]'), array('<a href="#">', '</a>', sprintf(__('%1$s emails every %2$s', WYSIJA), $number, trim($tb->duration_string($timespan, true)))), __('Your sending settings ([settings]) can\'t send that quickly to [number] subscribers. Expect delivery delays. [link]Read more[/link]', WYSIJA));
660
+ $this->viewObj->immediatewarning = '<span class="warning-msg" id="immediatewarning">' . $this->immediatewarning . '</span>';
661
+
662
+ $this->jsTrans['immediatewarning'] = $this->immediatewarning;
663
+
664
+ //how many emails can be sent in 12 hours
665
+ //if the frequency is less than 12hours
666
+ if ($timespan < 43200) {
667
+ $ratio = floor(43200 / $timespan);
668
+ $this->jsTrans['possibleemails'] = $ratio * $number;
669
+ } else {
670
+ if ($timespan == 43200) {
671
+ $this->jsTrans['possibleemails'] = $number;
672
+ } else {
673
+ $ratio = floor($timespan / 43200);
674
+ $this->jsTrans['possibleemails'] = $number / $ratio;
675
+ }
676
+ }
677
+ }
678
+
679
+ function editDetails() {
680
+ if (!$this->_checkEmailExists($_REQUEST['id']))
681
+ return;
682
+ $this->viewObj->title = __('Final step: last details', WYSIJA);
683
+ $this->viewShow = 'editDetails';
684
+ $this->js[] = 'wysija-validator';
685
+ $this->jsTrans['previewemail'] = __('Sending preview...', WYSIJA);
686
+ $this->jsTrans['pickadate'] = __('Pick a date', WYSIJA);
687
+ $this->jsTrans['saveclose'] = __('Save & close', WYSIJA);
688
+ $this->jsTrans['sendlater'] = __('Send later', WYSIJA);
689
+
690
+ $this->jsTrans['schedule'] = __('Schedule', WYSIJA);
691
+
692
+ $this->jsTrans['emailCheck'] = WJ_Utils::get_tip_data();
693
+
694
+
695
+ $this->js[] = 'jquery-ui-datepicker';
696
+ $this->js[] = 'wysija-tooltip';
697
+
698
+ $model_list = WYSIJA::get('list', 'model');
699
+ $model_list->limitON = false;
700
+ $this->data = array();
701
+ $this->data['lists'] = $this->__getLists(false, true, true);
702
+
703
+ $model_email = WYSIJA::get('email', 'model');
704
+ $this->data['email'] = $model_email->getOne(false, array('email_id' => $_REQUEST['id']));
705
+
706
+ // The first newsletter, we don't have replyto_email and replyto_name
707
+ if (empty($this->data['email']['replyto_email']) || empty($this->data['email']['replyto_name'])) {
708
+ $current_user = wp_get_current_user();
709
+ $this->data['email']['replyto_email'] = $current_user->data->user_email;
710
+ $this->data['email']['replyto_name'] = $current_user->data->display_name;
711
+ }
712
+
713
+
714
+ if ((int) $this->data['email']['type'] == 2) {
715
+ $this->js['wysija-edit-autonl'] = 'wysija-edit-autonl';
716
+ $this->jsTrans['autonl'] = true;
717
+ $this->immediateWarning();
718
+ $this->jsTrans['send'] = __('Activate now', WYSIJA);
719
+ } else {
720
+ $this->jsTrans['autonl'] = true;
721
+ $this->viewObj->immediatewarning = '';
722
+ $this->jsTrans['send'] = __('Send', WYSIJA);
723
+ }
724
+
725
+ if ((int) $this->data['email']['type'] == 1) {
726
+ $this->jsTrans['alertsend'] = __('You are about to send this newsletter. Please confirm.', WYSIJA);
727
+ } else {
728
+ if (isset($this->data['email']['params']['autonl']['event']) && $this->data['email']['params']['autonl']['event'] == 'subs-2-nl') {
729
+ $this->data['autoresponder'] = 1;
730
+ foreach ($this->data['lists'] as $list) {
731
+ if ($list['list_id'] == $this->data['email']['params']['autonl']['subscribetolist']) {
732
+ break;
733
+ }
734
+ }
735
+
736
+ $this->jsTrans['ignoreprevious'] = sprintf(__('Are you sure you want to ignore the %1$s subscribers of the list %2$s?', WYSIJA), '"' . $list['count'] . '"', '"' . $list['name'] . '"');
737
+ }
738
+ }
739
+
740
+ $this->checkIsEditable();
741
+
742
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 3) . " | " . $this->data['email']['subject'];
743
+ $this->dataAutoNl();
744
+
745
+ $this->jsLoc['wysija-edit-autonl']['autofields'] = $this->data['autonl']['fields'];
746
+
747
+ $modelCL = WYSIJA::get('campaign_list', 'model');
748
+ $this->data['campaign_list'] = $modelCL->get(false, array('campaign_id' => $this->data['email']['campaign_id']));
749
+ }
750
+
751
+ function delete() {
752
+ $this->requireSecurity();
753
+
754
+ $campaign_ids = array();
755
+ if(isset($_REQUEST['id'])) $campaign_ids[] = $_REQUEST['id'];
756
+ if(isset($_REQUEST['campaign']['campaign_id'])) $campaign_ids[] = $_REQUEST['campaign']['campaign_id'];
757
+ if(isset($_REQUEST['wysija']['campaign']['campaign_id'][0])){
758
+ $campaign_ids = array_merge($campaign_ids, $_REQUEST['wysija']['campaign']['campaign_id']);
759
+ }
760
+
761
+ if (!empty($campaign_ids)) {
762
+ foreach($campaign_ids as $campaign_id){
763
+ if($campaign_id > 0){
764
+ $model_campaign = WYSIJA::get('campaign', 'model');
765
+ $model_campaign->delete(array('campaign_id' => $campaign_id));
766
+
767
+ $model_campaign_list = WYSIJA::get('campaign_list', 'model');
768
+ $model_campaign_list->delete(array('campaign_id' => $campaign_id));
769
+
770
+ $modelEmail = WYSIJA::get('email', 'model');
771
+ $modelEmail->delete(array('campaign_id' => $campaign_id));
772
+ }
773
+ }
774
+
775
+ $this->notice(_n(__('Newsletter deleted.', WYSIJA), __('Newsletters deleted.', WYSIJA), count($campaign_ids), WYSIJA));
776
+ } else {
777
+ $this->notice(__('Newsletter can\'t be deleted.', WYSIJA));
778
+ }
779
+
780
+ // retrieve saved filter
781
+ if (!empty($_REQUEST['action']))
782
+ unset($_REQUEST['action']);
783
+ if (!empty($_REQUEST['id']))
784
+ unset($_REQUEST['id']);
785
+ if (!empty($_REQUEST['_wpnonce']))
786
+ unset($_REQUEST['_wpnonce']);
787
+ $redirect = $this->base_url . '?' . http_build_query($_REQUEST);
788
+ $this->redirect($redirect);
789
+ }
790
+
791
+ /**
792
+ *
793
+ * this function is to delete an email that belongs to a campaign
794
+ * when we have a post notification all emails belong to the same campaign
795
+ * we don't want to delete an entire campaign when we delete a single email
796
+ */
797
+ function deleteEmail(){
798
+ $this->requireSecurity();
799
+ if(!$this->_checkEmailExists($_REQUEST['id'])) return;
800
+
801
+ if(isset($_REQUEST['id'])){
802
+ $modelEmail=WYSIJA::get('email','model');
803
+ $modelEmail->delete(array('email_id'=>$_REQUEST['id']));
804
+ $this->notice(__('Newsletter deleted.',WYSIJA));
805
+ }else{
806
+ $this->notice(__('Newsletter can\'t be deleted.',WYSIJA));
807
+ }
808
+
809
+ $this->redirect();
810
+ }
811
+
812
+ function savecamp() {
813
+ $this->redirectAfterSave = false;
814
+
815
+ /* update email */
816
+ $data = array();
817
+
818
+ // in case the newsletter already exists
819
+ if (isset($_REQUEST['id'])) {
820
+ $modelEmail = WYSIJA::get('email', 'model');
821
+ $modelEmail->fieldValid = false;
822
+ $emaildataarr = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
823
+
824
+ $model_campaign = WYSIJA::get('campaign', 'model');
825
+ $model_campaign->update(array('name' => $_POST['wysija']['email']['subject'], 'description' => ''), array('campaign_id' => $emaildataarr['campaign_id']));
826
+
827
+ $campaign_id = $emaildataarr['campaign_id'];
828
+ $email_id = $emaildataarr['email_id'];
829
+ $dataEmail = array(
830
+ 'campaign_id' => $campaign_id,
831
+ 'subject' => $_POST['wysija']['email']['subject'],
832
+ 'type' => $_POST['wysija']['email']['type']);
833
+
834
+ if((int)$dataEmail['type'] === 2) {
835
+ // set autonl params
836
+ $dataEmail['params'] = array('autonl' => $_POST['wysija']['email']['params']['autonl']);
837
+
838
+ // WTF?
839
+ if(!isset($newparams['autonl']['unique_send'])) {
840
+ unset($dataEmail['params']['autonl']['unique_send']);
841
+ } else {
842
+ $dataEmail['params']['autonl']['unique_send'] = true;
843
+ }
844
+ }
845
+
846
+ // check if the newsletter used to be an automatic newsletter (if )
847
+ if((int)$dataEmail['type'] === 1 && (int)$emaildataarr['type'] === 2) {
848
+ // make sure we remove any kind of auto-post block
849
+ $helper_autonews = WYSIJA::get('autonews', 'helper');
850
+ $updated_email_data = $helper_autonews->remove_autopost_blocks($emaildataarr['wj_data']);
851
+ if($updated_email_data !== false) {
852
+ // if the email data has been changed, make sure to update it in the DB
853
+ $dataEmail['wj_data'] = $updated_email_data;
854
+ }
855
+ }
856
+
857
+ $modelEmail->columns['modified_at']['autoup'] = 1;
858
+ $modelEmail->debugupdate = true;
859
+ $dataEmail['email_id'] = $_REQUEST['id'];
860
+
861
+ if(isset($_REQUEST['save-reactivate'])) {
862
+ //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
863
+ $dataEmail['status'] = 99;
864
+ $_REQUEST['return'] = 1;
865
+ }
866
+
867
+ $data['email']['email_id'] = $modelEmail->update($dataEmail, array('email_id' => (int)$_REQUEST['id']));
868
+ } else {
869
+ // get default theme
870
+ $model_config = WYSIJA::get('config', 'model');
871
+ $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
872
+
873
+ $helper_themes = WYSIJA::get('themes', 'helper');
874
+ $theme_data = $helper_themes->getData($default_theme);
875
+
876
+ // get campaign data
877
+ $model_campaign = WYSIJA::get('campaign', 'model');
878
+ $campaign_id = $model_campaign->insert(array('name' => $_POST['wysija']['email']['subject'], 'description' => ''));
879
+
880
+ $modelEmail = WYSIJA::get('email', 'model');
881
+ $modelEmail->fieldValid = false;
882
+ $emaildata = array(
883
+ 'campaign_id' => $campaign_id,
884
+ 'subject' => $_POST['wysija']['email']['subject'],
885
+ 'type' => (int) $_POST['wysija']['email']['type']
886
+ );
887
+
888
+
889
+ // create autonl parameters if necessary
890
+ if ((int) $_POST['wysija']['email']['type'] === 2 && isset($_POST['wysija']['email']['params']['autonl'])) {
891
+ $emaildata['params'] = array('autonl' => $_POST['wysija']['email']['params']['autonl']);
892
+ }
893
+
894
+ // create sample data depending on newsletter's type
895
+ if ((int) $_POST['wysija']['email']['type'] === 2 && $_POST['wysija']['email']['params']['autonl']['event'] === 'new-articles') {
896
+
897
+ // if immediate, post_limit is set to 1
898
+ if ($emaildata['params']['autonl']['when-article'] === 'immediate') {
899
+ $autopostParams = array(
900
+ array('key' => 'category_ids', 'value' => null),
901
+ array('key' => 'title_tag', 'value' => 'h2'),
902
+ array('key' => 'title_alignment', 'value' => 'left'),
903
+ array('key' => 'title_position', 'value' => 'inside'),
904
+ array('key' => 'image_alignment', 'value' => 'alternate'),
905
+ array('key' => 'image_width', 'value' => 325),
906
+ array('key' => 'post_content', 'value' => 'excerpt'),
907
+ array('key' => 'readmore', 'value' => base64_encode(__('Read more.', WYSIJA))),
908
+ array('key' => 'show_divider', 'value' => 'yes'),
909
+ array('key' => 'post_limit', 'value' => 1),
910
+ array('key' => 'post_type', 'value' => 'post'),
911
+ array('key' => 'author_show', 'value' => 'no'),
912
+ array('key' => 'author_label', 'value' => base64_encode(__('Author:', WYSIJA))),
913
+ array('key' => 'category_show', 'value' => 'no'),
914
+ array('key' => 'category_label', 'value' => base64_encode(__('Categories:', WYSIJA))),
915
+ array('key' => 'nopost_message', 'value' => base64_encode(__('Latest content already sent.', WYSIJA))),
916
+ array('key' => 'bgcolor1', 'value' => null),
917
+ array('key' => 'bgcolor2', 'value' => null),
918
+ array('key' => 'sort_by', 'value' => 'newest')
919
+ );
920
+ } else {
921
+ $autopostParams = array(
922
+ array('key' => 'category_ids', 'value' => null),
923
+ array('key' => 'title_tag', 'value' => 'h2'),
924
+ array('key' => 'title_alignment', 'value' => 'left'),
925
+ array('key' => 'title_position', 'value' => 'inside'),
926
+ array('key' => 'image_alignment', 'value' => 'alternate'),
927
+ array('key' => 'image_width', 'value' => 325),
928
+ array('key' => 'post_content', 'value' => 'excerpt'),
929
+ array('key' => 'readmore', 'value' => base64_encode(__('Read more.', WYSIJA))),
930
+ array('key' => 'show_divider', 'value' => 'yes'),
931
+ array('key' => 'post_limit', 'value' => 2),
932
+ array('key' => 'post_type', 'value' => 'post'),
933
+ array('key' => 'author_show', 'value' => 'no'),
934
+ array('key' => 'author_label', 'value' => base64_encode(__('Author:', WYSIJA))),
935
+ array('key' => 'category_show', 'value' => 'no'),
936
+ array('key' => 'category_label', 'value' => base64_encode(__('Categories:', WYSIJA))),
937
+ array('key' => 'nopost_message', 'value' => base64_encode(__('Latest content already sent.', WYSIJA))),
938
+ array('key' => 'bgcolor1', 'value' => null),
939
+ array('key' => 'bgcolor2', 'value' => null),
940
+ array('key' => 'sort_by', 'value' => 'newest')
941
+ );
942
+ }
943
+
944
+ // sample data for post notifications
945
+ $newwjdata = array(
946
+ 'version' => WYSIJA::get_version(),
947
+ 'header' => array(
948
+ 'text' => NULL,
949
+ 'image' => array(
950
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
951
+ 'width' => 600,
952
+ 'height' => 86,
953
+ 'alignment' => 'center',
954
+ 'static' => true,
955
+ ),
956
+ 'alignment' => 'center',
957
+ 'static' => true,
958
+ 'type' => 'header'
959
+ ),
960
+ 'body' => array(
961
+ 'block-1' => array(
962
+ 'text' => array(
963
+ 'value' => '<h3 class="align-right">' . sprintf(__("The posts below were added with the widget %sAutomatic latest content%s", WYSIJA), '<strong>', '</strong>') . '</h3>'
964
+ ),
965
+ 'image' => array(
966
+ 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/autonewsletter/arrow-up.png',
967
+ 'width' => 45,
968
+ 'height' => 45,
969
+ 'alignment' => 'right',
970
+ 'static' => false
971
+ ),
972
+ 'alignment' => 'right',
973
+ 'static' => false,
974
+ 'position' => '1',
975
+ 'type' => 'content'
976
+ ),
977
+ 'block-2' => array(
978
+ 'text' => array(
979
+ 'value' => '<h3>' . sprintf(__('%sTo edit%s, mouse over to show edit button below.', WYSIJA), '<strong>', '</strong>') . '</h3>'
980
+ ),
981
+ 'image' => array(
982
+ 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/autonewsletter/arrow-down.png',
983
+ 'width' => 150,
984
+ 'height' => 53,
985
+ 'alignment' => 'left',
986
+ 'static' => false
987
+ ),
988
+ 'alignment' => 'left',
989
+ 'static' => false,
990
+ 'position' => '2',
991
+ 'type' => 'content'
992
+ ),
993
+ 'block-3' => array(
994
+ 'params' => $autopostParams,
995
+ 'position' => '3',
996
+ 'type' => 'auto-post'
997
+ )
998
+ ),
999
+ 'footer' => array(
1000
+ 'text' => NULL,
1001
+ 'image' => array(
1002
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1003
+ 'width' => 600,
1004
+ 'height' => 86,
1005
+ 'alignment' => 'center',
1006
+ 'static' => true,
1007
+ ),
1008
+ 'alignment' => 'center',
1009
+ 'static' => true,
1010
+ 'type' => 'footer'
1011
+ )
1012
+ );
1013
+ } else {
1014
+ if(!isset($emaildata['params'])) {
1015
+ $emaildata['params'] = array();
1016
+ }
1017
+
1018
+ $emaildata['params']['quickselection'] = array(
1019
+ 'wp-301' => array(
1020
+ 'identifier' => 'wp-301',
1021
+ 'width' => 281,
1022
+ 'height' => 190,
1023
+ 'url' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon.png',
1024
+ 'thumb_url' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon-150x150.png'
1025
+ )
1026
+ );
1027
+
1028
+ if($theme_data['divider'] === null) {
1029
+ // default theme does not exist anymore or there is no divider associated to the theme
1030
+ // we need to get the default divider in this case
1031
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
1032
+ $default_divider = $helper_dividers->getDefault();
1033
+ } else {
1034
+ // set default divider
1035
+ $default_divider = $theme_data['divider'];
1036
+ }
1037
+ // set default divider in email parameters
1038
+ $emaildata['params']['divider'] = $default_divider;
1039
+
1040
+ // get bookmarks from iconset 2
1041
+ $helper_bookmarks = WYSIJA::get('bookmarks', 'helper');
1042
+ $bookmarks = $helper_bookmarks->getAllByIconset('medium', '02');
1043
+
1044
+ // sample data for regular newsletter
1045
+ $newwjdata = array(
1046
+ 'version' => WYSIJA::get_version(),
1047
+ 'header' => array(
1048
+ 'text' => null,
1049
+ 'image' => array(
1050
+ // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/header.png',
1051
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1052
+ 'width' => 600,
1053
+ 'height' => 86,
1054
+ 'alignment' => 'center',
1055
+ 'static' => true
1056
+ ),
1057
+ 'alignment' => 'center',
1058
+ 'static' => true,
1059
+ 'type' => 'header'
1060
+ ),
1061
+ 'body' => array(
1062
+ 'block-1' => array(
1063
+ 'text' => array(
1064
+ 'value' => '<h2><strong>' . __('Step 1:', WYSIJA) . '</strong> ' . __('hey, click on this text!', WYSIJA) . '</h2>' . '<p>' . __('To edit, simply click on this block of text.', WYSIJA) . '</p>'
1065
+ ),
1066
+ 'image' => null,
1067
+ 'alignment' => 'left',
1068
+ 'static' => false,
1069
+ 'position' => 1,
1070
+ 'type' => 'content'
1071
+ ),
1072
+ 'block-2' => array_merge(array(
1073
+ 'position' => 2,
1074
+ 'type' => 'divider'
1075
+ ),
1076
+ $default_divider
1077
+ ),
1078
+ 'block-3' => array(
1079
+ 'text' => array(
1080
+ 'value' => '<h2><strong>' . __('Step 2:', WYSIJA) . '</strong> ' . __('play with this image', WYSIJA) . '</h2>'
1081
+ ),
1082
+ 'image' => null,
1083
+ 'alignment' => 'left',
1084
+ 'static' => false,
1085
+ 'position' => 3,
1086
+ 'type' => 'content'
1087
+ ),
1088
+ 'block-4' => array(
1089
+ 'text' => array(
1090
+ 'value' => '<p>' . __('Position your mouse over the image to the left.', WYSIJA) . '</p>'
1091
+ ),
1092
+ 'image' => array(
1093
+ 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon.png',
1094
+ 'width' => 281,
1095
+ 'height' => 190,
1096
+ 'alignment' => 'left',
1097
+ 'static' => false
1098
+ ),
1099
+ 'alignment' => 'left',
1100
+ 'static' => false,
1101
+ 'position' => 4,
1102
+ 'type' => 'content'
1103
+ ),
1104
+ 'block-5' => array_merge(array(
1105
+ 'position' => 5,
1106
+ 'type' => 'divider'
1107
+ ), $default_divider
1108
+ ),
1109
+ 'block-6' => array(
1110
+ 'text' => array(
1111
+ 'value' => '<h2><strong>' . __('Step 3:', WYSIJA) . '</strong> ' . __('drop content here', WYSIJA) . '</h2>' .
1112
+ '<p>' . sprintf(__('Drag and drop %1$stext, posts, dividers.%2$s Look on the right!', WYSIJA), '<strong>', '</strong>') . '</p>' .
1113
+ '<p>' . sprintf(__('You can even %1$ssocial bookmarks%2$s like these:', WYSIJA), '<strong>', '</strong>') . '</p>'
1114
+ ),
1115
+ 'image' => null,
1116
+ 'alignment' => 'left',
1117
+ 'static' => false,
1118
+ 'position' => 6,
1119
+ 'type' => 'content'
1120
+ ),
1121
+ 'block-7' => array(
1122
+ 'width' => 184,
1123
+ 'alignment' => 'center',
1124
+ 'items' => array(
1125
+ array_merge(array(
1126
+ 'url' => 'http://www.facebook.com/mailpoetplugin',
1127
+ 'alt' => 'Facebook',
1128
+ 'cellWidth' => 61,
1129
+ 'cellHeight' => 32
1130
+ ), $bookmarks['facebook']),
1131
+ array_merge(array(
1132
+ 'url' => 'http://www.twitter.com/mail_poet',
1133
+ 'alt' => 'Twitter',
1134
+ 'cellWidth' => 61,
1135
+ 'cellHeight' => 32
1136
+ ), $bookmarks['twitter']),
1137
+ array_merge(array(
1138
+ 'url' => 'https://plus.google.com/+Mailpoet',
1139
+ 'alt' => 'Google',
1140
+ 'cellWidth' => 61,
1141
+ 'cellHeight' => 32
1142
+ ), $bookmarks['google'])
1143
+ ),
1144
+ 'position' => 7,
1145
+ 'type' => 'gallery'
1146
+ ),
1147
+ 'block-8' => array_merge(array(
1148
+ 'position' => 8,
1149
+ 'type' => 'divider'
1150
+ ), $default_divider
1151
+ ),
1152
+ 'block-9' => array(
1153
+ 'text' => array(
1154
+ 'value' => '<h2><strong>' . __('Step 4:', WYSIJA) . '</strong> ' . __('and the footer?', WYSIJA) . '</h2>' .
1155
+ '<p>' . sprintf(__('Change the footer\'s content in MailPoet\'s %1$sSettings%2$s page.', WYSIJA), '<strong>', '</strong>') . '</p>'
1156
+ ),
1157
+ 'image' => null,
1158
+ 'alignment' => 'left',
1159
+ 'static' => false,
1160
+ 'position' => 9,
1161
+ 'type' => 'content'
1162
+ )
1163
+ ),
1164
+ 'footer' => array(
1165
+ 'text' => NULL,
1166
+ 'image' => array(
1167
+ // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/footer.png',
1168
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1169
+ 'width' => 600,
1170
+ 'height' => 86,
1171
+ 'alignment' => 'center',
1172
+ 'static' => true,
1173
+ ),
1174
+ 'alignment' => 'center',
1175
+ 'static' => true,
1176
+ 'type' => 'footer'
1177
+ )
1178
+ );
1179
+ }
1180
+
1181
+ // set default styles
1182
+ $helper_engine = WYSIJA::get('wj_engine', 'helper');
1183
+ $styles = $helper_engine->getDefaultStyles();
1184
+ // end - set default styles
1185
+
1186
+ // set theme specific data
1187
+ if($theme_data['header'] !== null) {
1188
+ $newwjdata['header'] = $theme_data['header'];
1189
+ }
1190
+ if($theme_data['footer'] !== null) {
1191
+ $newwjdata['footer'] = $theme_data['footer'];
1192
+ }
1193
+ if($theme_data['divider'] !== null) {
1194
+ $newwjdata['widgets'] = array('divider' => $theme_data['divider']);
1195
+ }
1196
+ // end - set theme specific data
1197
+
1198
+ $emaildata['wj_data'] = base64_encode(serialize($newwjdata));
1199
+ $emaildata['wj_styles'] = base64_encode(serialize($styles));
1200
+
1201
+ $email_id = $data['email']['email_id'] = $modelEmail->insert($emaildata);
1202
+
1203
+ $this->notice(__('Newsletter successfully created.', WYSIJA));
1204
+ }
1205
+
1206
+ $this->_saveLists($campaign_id, true);
1207
+
1208
+ if (isset($_REQUEST['return']))
1209
+ $this->redirect();
1210
+ else {
1211
+ $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id=' . $email_id);
1212
+ }
1213
+ }
1214
+
1215
+ function saveemail() {
1216
+ $this->redirectAfterSave = false;
1217
+ //$this->requireSecurity();
1218
+ $modelEmail = WYSIJA::get("email", "model");
1219
+ $modelEmail->fieldValid = false;
1220
+ $emaildataarr = $modelEmail->getOne(array('email_id' => $_REQUEST['id']));
1221
+
1222
+ if (isset($_REQUEST['save-reactivate'])) {
1223
+ //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
1224
+ $dataEmail['status'] = 99;
1225
+ $_REQUEST['return'] = 1;
1226
+ }
1227
+
1228
+ if (isset($_REQUEST['return']))
1229
+ $this->redirect();
1230
+ else {
1231
+ $this->redirect('admin.php?page=wysija_campaigns&action=editDetails&id=' . $emaildataarr['email_id']);
1232
+ }
1233
+ }
1234
+
1235
+ function savelast() {
1236
+ $this->redirectAfterSave = false;
1237
+ $post_notification = false;
1238
+ $this->requireSecurity();
1239
+
1240
+ if (!isset($_POST['wysija']['email']['from_name']) || !isset($_POST['wysija']['email']['from_email']) || !isset($_POST['wysija']['email']['replyto_name']) || !isset($_POST['wysija']['email']['replyto_email'])) {
1241
+ $this->error(__('Information is missing.', WYSIJA));
1242
+ return $this->editDetails();
1243
+ }
1244
+ if (isset($_REQUEST['wysija']['email']['params']['googletrackingcode']) && $_REQUEST['wysija']['email']['params']['googletrackingcode'] &&
1245
+ (!is_string($_REQUEST['wysija']['email']['params']['googletrackingcode']) OR
1246
+ preg_match('#[^a-z0-9_\-\s]#i', $_REQUEST['wysija']['email']['params']['googletrackingcode']) !== 0 )) {
1247
+ //force to simple text
1248
+ $_REQUEST['wysija']['email']['params']['googletrackingcode'] = preg_replace('#[^a-z0-9_\-\s]#i', '_', $_REQUEST['wysija']['email']['params']['googletrackingcode']);
1249
+ $this->error(__('Your Google Campaign can only contain letters, number, spaces and hyphens!', WYSIJA), 1);
1250
+ return $this->editDetails();
1251
+ }
1252
+
1253
+ $update_email = array(
1254
+ 'email_id' => $_POST['wysija']['email']['email_id'],
1255
+ 'from_name' => $_POST['wysija']['email']['from_name'],
1256
+ 'from_email' => $_POST['wysija']['email']['from_email'],
1257
+ 'replyto_name' => $_POST['wysija']['email']['replyto_name'],
1258
+ 'replyto_email' => $_POST['wysija']['email']['replyto_email'],
1259
+ 'subject' => $_POST['wysija']['email']['subject'],
1260
+ );
1261
+ $model_email = WYSIJA::get('email', 'model');
1262
+ if (isset($_POST['wysija']['email']['params']))
1263
+ $update_email['params'] = $_POST['wysija']['email']['params'];
1264
+
1265
+ //insert into campaigns lists
1266
+ $this->_saveLists($_POST['wysija']['campaign']['campaign_id']);
1267
+ $email_data = $model_email->getOne($_POST['wysija']['email']['email_id']);
1268
+
1269
+ // if we just save the draf we don't go through the big sending process setup
1270
+ if (isset($_POST['submit-draft']) || isset($_POST['submit-pause']) || (isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir'] == 'savelastback')) {
1271
+ if (isset($_POST['wysija']['email']['params']['schedule']['isscheduled']))
1272
+ $this->notice(__('Newsletter has been scheduled.', WYSIJA));
1273
+ else
1274
+ $this->notice(__('Newsletter has been saved as a draft.', WYSIJA));
1275
+ }else {
1276
+ // we update the param attribute with what's has been posted
1277
+ foreach ($update_email as $ki => $vi) {
1278
+ if ($ki == 'params') {
1279
+ foreach ($vi as $parake => $paraval) {
1280
+ $email_data['params'][$parake] = $paraval;
1281
+ }
1282
+ $update_email[$ki] = $email_data[$ki];
1283
+ }
1284
+ else
1285
+ $email_data[$ki] = $vi;
1286
+ }
1287
+
1288
+ // if the checkbox to ignore retroactivity is here we just tell the class
1289
+ if (isset($_POST['wysija']['email']['ignore_subscribers'])) {
1290
+ $model_email->retro_active_autoresponders = false;
1291
+ }
1292
+
1293
+ // activate or send the email depending on the typ
1294
+ $model_email->send_activate($email_data);
1295
+ }
1296
+
1297
+ // update email
1298
+ $update_email['type'] = $email_data['type'];
1299
+
1300
+ if ($post_notification) {
1301
+ $helper_autonews = WYSIJA::get('autonews', 'helper');
1302
+ $update_email['params']['autonl']['nextSend'] = $helper_autonews->getNextSend($update_email);
1303
+ }
1304
+
1305
+ $model_email->reset();
1306
+ $model_email->columns['modified_at']['autoup'] = 1;
1307
+
1308
+ // update some fields of the email
1309
+ $model_email->update($update_email);
1310
+
1311
+ // update the campaign subject which ispretty much useless but good to keep in sync with the email
1312
+ $model_campaign = WYSIJA::get('campaign', 'model');
1313
+ $model_campaign->reset();
1314
+ $update_campaign = array('campaign_id' => $_REQUEST['id'], 'name' => $_POST['wysija']['email']['subject']);
1315
+ $model_campaign->update($update_campaign);
1316
+
1317
+ if (isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir'] == 'savelastback') {
1318
+ return $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id=' . $_POST['wysija']['email']['email_id']);
1319
+ }
1320
+ else
1321
+ return $this->redirect();
1322
+ }
1323
+
1324
+ function _saveLists($campaignId, $flagup = false) {
1325
+ //record the list that we have in that campaign
1326
+ $modelCampL = WYSIJA::get('campaign_list', 'model');
1327
+ if ($flagup || (int) $campaignId > 0) {
1328
+ $modelCampL->delete(array('equal' => array('campaign_id' => $campaignId)));
1329
+ $modelCampL->reset();
1330
+ }
1331
+
1332
+ if (isset($_POST['wysija']['campaign_list']['list_id'])) {
1333
+ //$modelCampL=WYSIJA::get("campaign_list","model");
1334
+ foreach ($_POST['wysija']['campaign_list']['list_id'] as $listid) {
1335
+ $modelCampL->insert(array('campaign_id' => $campaignId, "list_id" => $listid));
1336
+ }
1337
+ }
1338
+ }
1339
+
1340
+ function _addLinkFilter($status, $type = 'status') {
1341
+ switch ($type) {
1342
+ case 'status':
1343
+ switch ($status) {
1344
+ case 'draft':
1345
+ $this->filters['equal'] = array('status' => 0);
1346
+ break;
1347
+ case 'sending':
1348
+ $this->filters['equal'] = array('status' => 99);
1349
+ break;
1350
+ case 'sent':
1351
+ $this->filters['equal'] = array('status' => 2);
1352
+ break;
1353
+ case 'paused':
1354
+ $this->filters['equal'] = array('status' => -1);
1355
+ break;
1356
+ case 'scheduled':
1357
+ $this->filters['equal'] = array('status' => 4);
1358
+ break;
1359
+ }
1360
+ break;
1361
+ case 'type':
1362
+ switch ($status) {
1363
+ case 'regular':
1364
+ $this->filters['equal'] = array('type' => 1);
1365
+ break;
1366
+ case 'autonl':
1367
+ $this->filters['equal'] = array('type' => 2);
1368
+ break;
1369
+ }
1370
+ break;
1371
+ }
1372
+ }
1373
+
1374
+ /**
1375
+ * Get all campaigns, based on the filters
1376
+ */
1377
+ protected function get_campaigns() {
1378
+ $order_by = ' ORDER BY ';
1379
+
1380
+ if (isset($_REQUEST['orderby'])) {
1381
+ if (!is_string($_REQUEST['orderby']) OR preg_match('|[^a-z0-9#_.-]|i', $_REQUEST['orderby']) !== 0) {
1382
+ $_REQUEST['orderby'] = '';
1383
+ }
1384
+ if (!in_array(strtoupper($_REQUEST['ordert']), array('DESC', 'ASC')))
1385
+ $_REQUEST['ordert'] = 'DESC';
1386
+ $order_by.=$_REQUEST['orderby'] . ' ' . $_REQUEST['ordert'];
1387
+ }else {
1388
+ $order_by.='FIELD(B.status, 99,3,1,0,2), ';
1389
+ $order_by.='B.status desc, ';
1390
+ $order_by.='B.modified_at desc, ';
1391
+ $order_by.='B.sent_at desc, ';
1392
+ $order_by.='B.type desc, ';
1393
+ $order_by.='A.' . $this->modelObj->getPk() . ' DESC';
1394
+ }
1395
+
1396
+ $query = '
1397
+ SELECT
1398
+ A.`campaign_id`,
1399
+ A.`name` as `campaign_name`,
1400
+ B.`subject` as `name`,
1401
+ A.`description`,
1402
+ B.`params`,
1403
+ B.`type`,
1404
+ B.`number_sent`,
1405
+ B.`number_opened`,
1406
+ B.`number_clicked`,
1407
+ B.`number_unsub`,
1408
+ (B.`number_sent` +
1409
+ B.`number_opened` +
1410
+ B.`number_clicked` +
1411
+ B.`number_unsub` +
1412
+ B.`number_bounce` +
1413
+ B.`number_forward`
1414
+ ) AS `number_total`,
1415
+ B.`status`,
1416
+ B.`created_at`,
1417
+ B.`modified_at`,
1418
+ B.`sent_at`,
1419
+ B.`email_id`
1420
+ FROM
1421
+ `[wysija]' . $this->modelObj->table_name . '` AS A
1422
+ LEFT JOIN
1423
+ `[wysija]email` AS B on A.`campaign_id` = B.`campaign_id`
1424
+ LEFT JOIN
1425
+ `[wysija]campaign_list` AS C on A.`campaign_id` = C.`campaign_id`';
1426
+ $campaigns = $this->modelObj->getResults($query . $this->modelObj->makeWhere() . ' GROUP BY B.email_id' . $order_by . $this->modelObj->setLimit());
1427
+
1428
+ // calculate percetange of open / click / unsubscribe
1429
+ $helper_numbers = WYSIJA::get('numbers', 'helper');
1430
+ foreach ($campaigns as &$campaign) {
1431
+ // open rate, based on sent number
1432
+ $campaign['rate_opened'] = $helper_numbers->calculate_percetage($campaign['number_opened'], $campaign['number_total'], 1);
1433
+ // click rate, based on opened number
1434
+ $campaign['rate_clicked'] = $helper_numbers->calculate_percetage($campaign['number_clicked'], $campaign['number_total'], 1);
1435
+ // unsubscribe rate, based on opened number
1436
+ $campaign['rate_unsub'] = $helper_numbers->calculate_percetage($campaign['number_unsub'], $campaign['number_total'], 1);
1437
+ }
1438
+ return $campaigns;
1439
+ }
1440
+
1441
+ /**
1442
+ * Get the first campaign in history
1443
+ */
1444
+ protected function get_oldest_compaign() {
1445
+ $query = '
1446
+ SELECT
1447
+ MIN(B.created_at) as datemin
1448
+ FROM `[wysija]' . $this->modelObj->table_name . '` as A
1449
+ LEFT JOIN
1450
+ `[wysija]email` AS B on A.campaign_id = B.campaign_id
1451
+ LEFT JOIN
1452
+ `[wysija]campaign_list` as C on A.campaign_id = C.campaign_id';
1453
+
1454
+ return $this->modelObj->query('get_row', $query . $this->modelObj->makeWhere());
1455
+ }
1456
+
1457
+ /**
1458
+ * Count ALL emails of each email-status
1459
+ * @todo: move to model
1460
+ */
1461
+ protected function count_emails_by_status() {
1462
+ $query = '
1463
+ SELECT
1464
+ COUNT(`email_id`) AS `campaigns`,
1465
+ `status`
1466
+ FROM
1467
+ `[wysija]email`
1468
+ WHERE
1469
+ `campaign_id` > 0
1470
+ GROUP BY `status`';
1471
+
1472
+ $countss = $this->modelObj->query('get_res', $query);
1473
+ $counts = array();
1474
+ $total = 0;
1475
+
1476
+ foreach ($countss as $count) {
1477
+ switch ($count['status']) {
1478
+ case '0':
1479
+ $type = 'draft';
1480
+ break;
1481
+ case '1':
1482
+ case '3':
1483
+ case '99':
1484
+ $type = 'sending';
1485
+ break;
1486
+ case '2':
1487
+ $type = 'sent';
1488
+ break;
1489
+ case '-1':
1490
+ $type = 'paused';
1491
+ break;
1492
+ case '4':
1493
+ $type = 'scheduled';
1494
+ break;
1495
+ }
1496
+ $total = $total + $count['campaigns'];
1497
+ $counts['status-' . $type] = $count['campaigns'];
1498
+ }
1499
+ return $counts;
1500
+ }
1501
+
1502
+ /**
1503
+ * Count emails which matched the filters
1504
+ */
1505
+ protected function count_emails() {
1506
+ $query = '
1507
+ SELECT
1508
+ COUNT(DISTINCT B.`email_id`) AS `campaigns`
1509
+ FROM
1510
+ `[wysija]' . $this->modelObj->table_name . '` AS A
1511
+ LEFT JOIN
1512
+ `[wysija]email` AS B ON A.`campaign_id` = B.`campaign_id`
1513
+ LEFT JOIN
1514
+ `[wysija]campaign_list` AS C ON A.`campaign_id` = C.`campaign_id`';
1515
+ return $this->modelObj->count($query . $this->modelObj->makeWhere(), 'campaigns');
1516
+ }
1517
+
1518
+ /**
1519
+ * Count ALL emails of each type of email
1520
+ */
1521
+ protected function count_emails_by_type() {
1522
+ $query = '
1523
+ SELECT
1524
+ COUNT(`email_id`) AS `campaigns`,
1525
+ `type`
1526
+ FROM
1527
+ `[wysija]email`
1528
+ WHERE
1529
+ `campaign_id` > 0
1530
+ GROUP BY `type`';
1531
+ $countss = $this->modelObj->query('get_res', $query, ARRAY_A);
1532
+ $counts = array();
1533
+ foreach ($countss as $count) {
1534
+ switch ($count['type']) {
1535
+ case '1':
1536
+ $type = 'regular';
1537
+ break;
1538
+ case '2':
1539
+ $type = 'autonl';
1540
+ break;
1541
+ }
1542
+ $counts['type-' . $type] = $count['campaigns'];
1543
+ }
1544
+ return $counts;
1545
+ }
1546
+
1547
+ /**
1548
+ * Get all existing lists
1549
+ */
1550
+ protected function get_lists() {
1551
+ $model_list = WYSIJA::get('list', 'model');
1552
+ $query = '
1553
+ SELECT
1554
+ A.`list_id`,
1555
+ A.`name`,
1556
+ A.`is_enabled`,
1557
+ COUNT( B.`campaign_id` ) AS `users`
1558
+ FROM
1559
+ `[wysija]' . $model_list->table_name . '` as A
1560
+ LEFT JOIN
1561
+ `[wysija]campaign_list` AS B on A.`list_id` = B.`list_id`
1562
+ GROUP BY A.`list_id`';
1563
+ $result = $model_list->getResults($query);
1564
+ $lists = array();
1565
+ foreach ($result as $list_obj) {
1566
+ $lists[$list_obj['list_id']] = $list_obj;
1567
+ }
1568
+ return $lists;
1569
+ }
1570
+
1571
+ function defaultDisplay() {
1572
+ $this->data['base_url'] = $this->base_url . '?' . http_build_query($_REQUEST); // saved filter
1573
+ $this->title = __('Newsletters', WYSIJA);
1574
+ $this->viewShow = $this->action = 'main';
1575
+ $this->js[] = 'wysija-admin-list';
1576
+ $this->jsTrans["selecmiss"] = __('Please select a newsletter.', WYSIJA);
1577
+ $this->jsTrans['suredelete'] = __('Delete this newsletter for ever?', WYSIJA);
1578
+ $this->jsTrans['suredelete_bulk'] = __('Delete these newsletters for ever?', WYSIJA);
1579
+ $this->jsTrans['processqueue'] = __('Sending batch of emails...', WYSIJA);
1580
+ $this->jsTrans['viewnews'] = __('View newsletter', WYSIJA);
1581
+ $this->jsTrans['confirmpauseedit'] = __('The newsletter will be deactivated, you will need to reactivate it once you\'re over editing it. Do you want to proceed?', WYSIJA);
1582
+
1583
+
1584
+ //get the filters
1585
+ if (isset($_REQUEST['search']) && $_REQUEST['search']) {
1586
+ $this->filters['like'] = array();
1587
+ foreach ($this->searchable as $field)
1588
+ $this->filters['like'][$field] = $_REQUEST['search'];
1589
+ }
1590
+
1591
+ if (isset($_REQUEST['filter-list']) && $_REQUEST['filter-list']) {
1592
+ $this->filters['equal'] = array('C.list_id' => $_REQUEST['filter-list']);
1593
+ }
1594
+
1595
+ if (isset($_REQUEST['filter-date']) && $_REQUEST['filter-date']) {
1596
+ $this->filters['greater_eq'] = array('created_at' => $_REQUEST['filter-date']);
1597
+ $this->filters['less_eq'] = array('created_at' => strtotime('+1 month', $_REQUEST['filter-date']));
1598
+ }
1599
+
1600
+ $this->filters['is'] = array('type' => 'IS NOT NULL');
1601
+
1602
+
1603
+ if (isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']) {
1604
+ $linkfilters = explode('-', $_REQUEST['link_filter']);
1605
+
1606
+ if (count($linkfilters) > 1) {
1607
+ $this->_addLinkFilter($linkfilters[1], $linkfilters[0]);
1608
+ } else {
1609
+ $this->_addLinkFilter($_REQUEST['link_filter']);
1610
+ }
1611
+ }
1612
+
1613
+ $this->modelObj->noCheck = true;
1614
+ $this->modelObj->reset();
1615
+ if ($this->filters)
1616
+ $this->modelObj->setConditions($this->filters);
1617
+
1618
+
1619
+ // Count emails by status and type
1620
+ $emails_by_status = $this->count_emails_by_status();
1621
+ $emails_by_type = $this->count_emails_by_type();
1622
+ $counts = array_merge($emails_by_status, $emails_by_type);
1623
+ $counts['all'] = array_sum($emails_by_status);
1624
+
1625
+ // collect data
1626
+ $this->data['campaigns'] = $this->get_campaigns();
1627
+ $this->data['datemin'] = $this->get_oldest_compaign();
1628
+ $lists = $this->get_lists(); // $lists is in use later within this scope
1629
+ $this->data['lists'] = $lists;
1630
+
1631
+ // for paging
1632
+ $this->modelObj->countRows = $this->filters ? $this->count_emails () : $counts['all'];
1633
+
1634
+
1635
+ // count queue
1636
+ $email_ids = array();
1637
+ foreach ($this->data['campaigns'] as $emailcamp) {
1638
+ if (in_array($emailcamp['status'], array(1, 3, 99)))
1639
+ $email_ids[] = $emailcamp['email_id'];
1640
+ }
1641
+ $model_queue = WYSIJA::get('queue', 'model');
1642
+ $model_queue->setConditions(array("email_id" => $email_ids));
1643
+ $model_queue->groupBy('email_id');
1644
+ $queue = $model_queue->count();
1645
+ if ($queue) {
1646
+ $this->viewObj->queuedemails = $queue;
1647
+ }
1648
+
1649
+ $this->modelObj->reset();
1650
+
1651
+ //make a loop from the first created to now and increment an array of months
1652
+ $now = time();
1653
+ $this->data['dates'] = array();
1654
+
1655
+ if ((int) $this->data['datemin']['datemin'] > 1) {
1656
+ setlocale(LC_TIME, 'en_US');
1657
+ $formtlettres = "1 " . date('F', $this->data['datemin']['datemin']) . ' ' . date("Y", $this->data['datemin']['datemin']);
1658
+ $month_start = strtotime($formtlettres);
1659
+
1660
+ if ($month_start > 0) {
1661
+ for ($i = $month_start; $i < $now; $i = strtotime('+1 month', $i)) {
1662
+ $this->data['dates'][$i] = date_i18n('F Y', $i); //date('F Y',$i);
1663
+ }
1664
+ }
1665
+ }
1666
+
1667
+
1668
+
1669
+ $campaign_ids_sent = $campaign_ids = array();
1670
+ foreach ($this->data['campaigns'] as &$campaign) {
1671
+ $campaign_ids[] = $campaign['campaign_id'];
1672
+ $modelEmail = WYSIJA::get('email', 'model');
1673
+ $modelEmail->getParams($campaign);
1674
+ if (in_array((int) $campaign['status'], array(-1, 1, 2, 3, 99)))
1675
+ $campaign_ids_sent[] = $campaign['campaign_id'];
1676
+ }
1677
+
1678
+ // 3 - campaign_list request & count request for queue */
1679
+ if ($campaign_ids) {
1680
+ $modeluList = WYSIJA::get('campaign_list', 'model');
1681
+ $userlists = $modeluList->get(array('list_id', 'campaign_id'), array('campaign_id' => $campaign_ids));
1682
+
1683
+ if ($campaign_ids_sent) {
1684
+ $modeluList = WYSIJA::get("email_user_stat", "model");
1685
+ $statstotal = $modeluList->getResults("SELECT COUNT(A.user_id) as count,B.email_id FROM `[wysija]queue` as A
1686
+ JOIN `[wysija]email` as B on A.email_id=B.email_id
1687
+ WHERE B.campaign_id IN (" . implode(",", $campaign_ids_sent) . ") group by B.email_id");
1688
+
1689
+ $senttotalgroupedby = $modeluList->getResults("SELECT COUNT(A.user_id) as count,B.campaign_id,B.email_id,B.type,B.status,A.status as statususer FROM `[wysija]" . $modeluList->table_name . "` as A
1690
+ JOIN `[wysija]email` as B on A.email_id=B.email_id
1691
+ WHERE B.campaign_id IN (" . implode(",", $campaign_ids_sent) . ") group by A.status,B.email_id"); //,A.status
1692
+
1693
+
1694
+ $updateEmail = array();
1695
+ $columnnamestatus = array(0 => "number_sent", 1 => "number_opened", 2 => "number_clicked", 3 => "number_unsub", -1 => "number_bounce");
1696
+ foreach ($senttotalgroupedby as $sentbystatus) {
1697
+ if ($sentbystatus['statususer'] != "-2")
1698
+ $updateEmail[$sentbystatus['email_id']][$columnnamestatus[$sentbystatus['statususer']]] = $sentbystatus['count'];
1699
+ if (isset($senttotal[$sentbystatus['email_id']])) {
1700
+ $senttotal[$sentbystatus['email_id']]['count'] = (int) $senttotal[$sentbystatus['email_id']]['count'] + (int) $sentbystatus['count'];
1701
+ } else {
1702
+ unset($sentbystatus['statususer']);
1703
+ $senttotal[$sentbystatus['email_id']] = $sentbystatus;
1704
+ }
1705
+ }
1706
+
1707
+ $modelEmail = WYSIJA::get('email', 'model');
1708
+
1709
+ foreach ($updateEmail as $emailid => $update) {
1710
+
1711
+ foreach ($columnnamestatus as $v) {
1712
+ if (!isset($update[$v]))
1713
+ $update[$v] = 0;
1714
+ }
1715
+
1716
+ $modelEmail->update($update, array('email_id' => $emailid));
1717
+ $modelEmail->reset();
1718
+ }
1719
+
1720
+
1721
+ /**/
1722
+ $modelC = WYSIJA::get('config', 'model');
1723
+ $running = false;
1724
+
1725
+ $is_multisite = is_multisite();
1726
+
1727
+ //$is_multisite=true;//PROD comment that line
1728
+ if ($is_multisite && $modelC->getValue('sending_method') == 'network') {
1729
+ $sending_emails_each = $modelC->getValue('ms_sending_emails_each');
1730
+ } else {
1731
+ $sending_emails_each = $modelC->getValue('sending_emails_each');
1732
+ }
1733
+
1734
+ if ($modelC->getValue('cron_manual')) {
1735
+ $formsHelp = WYSIJA::get('forms', 'helper');
1736
+ $queue_frequency = $formsHelp->eachValuesSec[$sending_emails_each];
1737
+ $queue_scheduled = WYSIJA::get_cron_schedule('queue');
1738
+
1739
+ $next_scheduled_queue = $queue_scheduled['next_schedule'];
1740
+ $running = $queue_scheduled['running'];
1741
+
1742
+ if ($running) {
1743
+ $helperToolbox = WYSIJA::get('toolbox', 'helper');
1744
+ $running = time() - $running;
1745
+ $running = $helperToolbox->duration_string($running, true, 4);
1746
+ }
1747
+ } else {
1748
+ $schedules = wp_get_schedules();
1749
+ $queue_frequency = $schedules[wp_get_schedule('wysija_cron_queue')]['interval'];
1750
+ $next_scheduled_queue = wp_next_scheduled('wysija_cron_queue');
1751
+ }
1752
+
1753
+
1754
+
1755
+ $status_sent_complete = array();
1756
+ if (isset($senttotal) && $senttotal) {
1757
+ foreach ($senttotal as $sentot) {
1758
+ if ($sentot) {
1759
+ $this->data['sent'][$sentot['email_id']]['total'] = $sentot['count'];
1760
+ $this->data['sent'][$sentot['email_id']]['to'] = $sentot['count'];
1761
+ } else {
1762
+ $this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['to'] = 0;
1763
+ }
1764
+ $this->data['sent'][$sentot['email_id']]['status'] = $sentot['status'];
1765
+ $this->data['sent'][$sentot['email_id']]['type'] = $sentot['type'];
1766
+ $this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
1767
+ }
1768
+ }
1769
+
1770
+ foreach ($statstotal as $sentot) {
1771
+ if (!isset($this->data['sent'][$sentot['email_id']])) {
1772
+ $this->data['sent'][$sentot['email_id']]['total'] = 0;
1773
+ $this->data['sent'][$sentot['email_id']]['to'] = 0;
1774
+ }
1775
+ $this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['total'] + $sentot['count'];
1776
+ $this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
1777
+ }
1778
+
1779
+ //$is_multisite=true;//PROD comment that line
1780
+ if ($is_multisite && $modelC->getValue('sending_method') == 'network') {
1781
+ $sending_emails_number = $modelC->getValue('ms_sending_emails_number');
1782
+ } else {
1783
+ $sending_emails_number = $modelC->getValue('sending_emails_number');
1784
+ }
1785
+
1786
+ if (isset($this->data['sent'])) {
1787
+ foreach ($this->data['sent'] as $key => &$camp) {
1788
+ if ($this->data['sent'][$key]['left'] > 0) {
1789
+ $cronsneeded = ceil($this->data['sent'][$key]['left'] / $sending_emails_number);
1790
+ $this->data['sent'][$key]['remaining_time'] = $cronsneeded * $queue_frequency;
1791
+ $this->data['sent'][$key]['running_for'] = $running;
1792
+ $this->data['sent'][$key]['next_batch'] = $next_scheduled_queue - time();
1793
+ $this->data['sent'][$key]['remaining_time'] = $this->data['sent'][$key]['remaining_time'] - ($queue_frequency) + $this->data['sent'][$key]['next_batch'];
1794
+ } else {
1795
+ if ((in_array($this->data['sent'][$key]['status'], array(1, 3, 99))) && $this->data['sent'][$key]['type'] == 1)
1796
+ $status_sent_complete[] = $key;
1797
+ }
1798
+ }
1799
+ }
1800
+
1801
+
1802
+ // status update to sent for the one that are sent
1803
+ if (count($status_sent_complete) > 0) {
1804
+ $modelEmail = WYSIJA::get('email', 'model');
1805
+ $modelEmail->noCheck = true;
1806
+ $modelEmail->reset();
1807
+ $modelEmail->update(array('status' => 2), array('equal' => array('email_id' => $status_sent_complete)));
1808
+ }
1809
+ }
1810
+ }
1811
+
1812
+ $this->data['counts'] = array_reverse($counts);
1813
+
1814
+ /* regrouping all the data in the same array */
1815
+ foreach ($this->data['campaigns'] as &$campaign) {
1816
+ /* default key while we don't have the data */
1817
+ //TODO add data for stats about emails opened clicked etc
1818
+ $campaign["emails"] = 0;
1819
+ $campaign["opened"] = 0;
1820
+ $campaign["clicked"] = 0;
1821
+
1822
+ if ($userlists) {
1823
+ foreach ($userlists as $key => $userlist) {
1824
+ if ($campaign["campaign_id"] == $userlist["campaign_id"] && isset($lists[$userlist["list_id"]])) {
1825
+ if (!isset($campaign["lists"]))
1826
+ $campaign["lists"] = $lists[$userlist["list_id"]]["name"];
1827
+ else
1828
+ $campaign["lists"].=", " . $lists[$userlist["list_id"]]["name"];
1829
+ }
1830
+ }
1831
+ }
1832
+ if (isset($campaign["lists"]) && !$campaign["lists"])
1833
+ unset($campaign["lists"]);
1834
+
1835
+ if (((isset($campaign['params']['schedule']['isscheduled']) ||
1836
+ ($campaign['type'] == 2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'], array('new-articles'/* ,'subs-2-nl' */)))
1837
+ ) && $campaign['status'] != 2 && !isset($campaign["lists"])) || ($campaign['type'] == 2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'], array('subs-2-nl')) && $campaign['status'] != 2 && (!isset($campaign['params']['autonl']['subscribetolist']) || !isset($lists[$campaign['params']['autonl']['subscribetolist']]) ))
1838
+ ) {
1839
+ $campaign['classRow'] = " listmissing ";
1840
+ $campaign['msgListEdit'] = '<strong>' . __('The list has been deleted.', WYSIJA) . '</strong>';
1841
+ $campaign['msgSendSuspended'] = '<strong>' . __('Sending suspended.', WYSIJA) . '</strong>';
1842
+ }
1843
+ }
1844
+
1845
+ $this->dataAutoNl();
1846
+ if (!$this->data['campaigns']) {
1847
+ $this->notice(__('There are no newsletters.', WYSIJA));
1848
+ }
1849
+ }
1850
+
1851
+ function setviewStatsfilter() {
1852
+ /* get the filters */
1853
+ $this->searchable = array("email", "firstname", "lastname");
1854
+ $this->filters = array();
1855
+ if (isset($_REQUEST['search']) && $_REQUEST['search']) {
1856
+ $this->filters["like"] = array();
1857
+ foreach ($this->searchable as $field)
1858
+ $this->filters["like"][$field] = $_REQUEST['search'];
1859
+ }
1860
+ $this->tableQuery = 'email_user_stat';
1861
+ $this->statusemail = 'B.status as umstatus';
1862
+ if (isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']) {
1863
+ switch ($_REQUEST['link_filter']) {
1864
+ case 'inqueue':
1865
+ $this->tableQuery = 'queue';
1866
+ $this->statusemail = '-2 as umstatus';
1867
+ break;
1868
+ case 'sent':
1869
+ $this->filters['equal'] = array('B.status' => 0);
1870
+ break;
1871
+ case 'bounced':
1872
+ $this->filters['equal'] = array('B.status' => -1);
1873
+ break;
1874
+ case 'opened':
1875
+ $this->filters['equal'] = array('B.status' => 1);
1876
+ break;
1877
+ case 'clicked':
1878
+ $this->filters['equal'] = array('B.status' => 2);
1879
+ break;
1880
+ case 'unsubscribe':
1881
+ $this->filters['equal'] = array('B.status' => 3);
1882
+ break;
1883
+ case 'notsent':
1884
+ $this->filters['equal'] = array('B.status' => -2);
1885
+ break;
1886
+ }
1887
+ }
1888
+ // filter by url id
1889
+ if (isset($_REQUEST['url_id']) && (int) $_REQUEST['url_id'] > 0) {
1890
+ $this->tableQuery = 'email_user_url';
1891
+ $this->filters['equal'] = array('B.url_id' => (int) $_REQUEST['url_id']);
1892
+ $this->statusemail = '2 as umstatus'; //by default, when filter by url_id, all subscribers had clicked
1893
+ }
1894
+ }
1895
+
1896
+ function viewstats() {
1897
+ $this->js[] = 'wysija-admin-list';
1898
+ $this->js[] = 'wysija-charts';
1899
+ $this->viewShow = 'viewstats';
1900
+
1901
+ $this->modelObj = WYSIJA::get("email", "model");
1902
+ $this->modelObj->limitON = false;
1903
+
1904
+ $email_object = $this->modelObj->getOne(false, array("email_id" => $_REQUEST['id']));
1905
+ $this->viewObj->model = $this->modelObj;
1906
+ $this->viewObj->namecampaign = $email_object['subject'];
1907
+ $this->viewObj->title = sprintf(__('Stats : %1$s', WYSIJA), $email_object['subject']);
1908
+
1909
+ $modelObjCamp = WYSIJA::get("campaign", "model");
1910
+ $limit_pp = false;
1911
+ if (isset($modelObjCamp->limit_pp))
1912
+ $limit_pp = $modelObjCamp->limit_pp;
1913
+ $modelObjCamp->limitON = false;
1914
+ $campaign = $modelObjCamp->getOne(false, array("campaign_id" => $email_object['campaign_id']));
1915
+
1916
+
1917
+ $this->setviewStatsfilter();
1918
+
1919
+ $this->modelObj->reset();
1920
+ $this->modelObj->noCheck = true;
1921
+
1922
+ /* 0 - counting request */
1923
+ $queryCmmonStart = 'SELECT count(distinct B.user_id) as users FROM `[wysija]user` as A';
1924
+ $queryCmmonStart.=' LEFT JOIN `[wysija]' . $this->tableQuery . '` as B on A.user_id=B.user_id';
1925
+
1926
+ /* all the counts query */
1927
+ $query = "SELECT count(user_id) as users, status FROM `[wysija]email_user_stat` as A
1928
+ WHERE A.email_id=" . $email_object['email_id'] . " GROUP BY status";
1929
+ $countss = $this->modelObj->query("get_res", $query, ARRAY_A);
1930
+
1931
+ /* we also count what is in the queue */
1932
+ $query = "SELECT count(user_id) as users FROM `[wysija]queue` as A
1933
+ WHERE A.email_id=" . $email_object['email_id'];
1934
+ $countss[-2]['status'] = -3;
1935
+ $countss[-2]['users'] = $this->modelObj->count($query, 'users');
1936
+
1937
+ $counts = array();
1938
+ $truetotal = $total = 0;
1939
+
1940
+ foreach ($countss as $count) {
1941
+ switch ($count['status']) {
1942
+ case "-3":
1943
+ $type = 'inqueue';
1944
+ break;
1945
+ case "-2":
1946
+ $type = 'notsent';
1947
+ break;
1948
+ case "-1":
1949
+ $type = 'bounced';
1950
+ break;
1951
+ case "0":
1952
+ $type = 'sent';
1953
+ break;
1954
+ case "1":
1955
+ $type = 'opened';
1956
+ break;
1957
+ case "2":
1958
+ $type = 'clicked';
1959
+ break;
1960
+ case "3":
1961
+ $type = 'unsubscribe';
1962
+ break;
1963
+ }
1964
+ if ($count['status'] != "-2")
1965
+ $total = $total + $count['users'];
1966
+ $truetotal = $truetotal + $count['users'];
1967
+ $counts[$type] = $count['users'];
1968
+ }
1969
+
1970
+ $counts['allsent'] = $total;
1971
+ $counts['all'] = $truetotal;
1972
+
1973
+ $this->modelObj->reset();
1974
+ $this->filters['equal']["B.email_id"] = $email_object['email_id'];
1975
+
1976
+ $this->modelObj->noCheck = true;
1977
+ if ($this->filters)
1978
+ $this->modelObj->setConditions($this->filters);
1979
+
1980
+ //$this->modelObj->setConditions(array("equal"=>array("B.email_id"=>$emailObj['email_id'])));
1981
+
1982
+ /* 1 - subscriber request */
1983
+ $query = 'SELECT A.user_id, A.firstname, A.lastname,A.status as ustatus,' . $this->statusemail . ' , A.email, B.* FROM `[wysija]user` as A';
1984
+ $query.=' LEFT JOIN `[wysija]' . $this->tableQuery . '` as B on A.user_id=B.user_id';
1985
+ $queryFinal = $this->modelObj->makeWhere();
1986
+
1987
+ /* without filter we already have the total number of subscribers */
1988
+ if ($this->filters)
1989
+ $this->modelObj->countRows = $this->modelObj->count($queryCmmonStart . $queryFinal, 'users');
1990
+ else
1991
+ $this->modelObj->countRows = $counts['all'];
1992
+
1993
+ $orderby = " ORDER BY ";
1994
+ /**
1995
+ * Until now, we have
1996
+ * - 3 possible values of $this->tableQuery (queue, email_user_url, email_user_stat), set by $this->setviewStatsfilter()
1997
+ * - 2 possible values of $_REQUEST['orderby']
1998
+ * => 3x2 = 6 cases
1999
+ */
2000
+ if (isset($_REQUEST['orderby'])) {
2001
+ switch ($this->tableQuery) {
2002
+ case 'email_user_url':
2003
+ case 'email_user_stat':
2004
+ $orderby .= 'B.' . $_REQUEST['orderby'] . " " . $_REQUEST['ordert'];
2005
+ break;
2006
+
2007
+ case 'queue':
2008
+ default:
2009
+ $orderby .= 'A.user_id DESC';
2010
+ break;
2011
+ }
2012
+ } else {
2013
+ switch ($this->tableQuery) {
2014
+ case 'email_user_url':
2015
+ $orderby .= 'B.clicked_at DESC, B.number_clicked DESC'; // by default, sort by last clicked and biggest hit
2016
+ break;
2017
+
2018
+ case 'email_user_stat':
2019
+ $orderby .= 'B.opened_at DESC, B.status DESC'; // by default, sort by last open and its staus value
2020
+ break;
2021
+
2022
+ case 'queue':
2023
+ default:
2024
+ $orderby .= 'A.user_id DESC';
2025
+ break;
2026
+ }
2027
+ }
2028
+ $this->data['tableQuery'] = $this->tableQuery;
2029
+ $this->modelObj->limitON = true;
2030
+ $this->data['subscribers'] = $this->modelObj->getResults($query . $queryFinal . " GROUP BY A.user_id" . $orderby . $this->modelObj->setLimit(0, (int)$limit_pp));
2031
+ $this->modelObj->reset();
2032
+
2033
+ /* make the data object for the listing view */
2034
+ $modelList = WYSIJA::get("list", "model");
2035
+
2036
+ /* 2 - list request */
2037
+ $query = "SELECT A.list_id, A.name,A.is_enabled, count( B.user_id ) AS users FROM `[wysija]" . $modelList->table_name . "` as A";
2038
+ $query.=" LEFT JOIN `[wysija]user_list` as B on A.list_id = B.list_id";
2039
+ $query.=" GROUP BY A.list_id";
2040
+ $listsDB = $modelList->getResults($query);
2041
+
2042
+ $lists = array();
2043
+ foreach ($listsDB as $listobj) {
2044
+ $lists[$listobj["list_id"]] = $listobj;
2045
+ }
2046
+
2047
+ $listsDB = null;
2048
+
2049
+ $user_ids = array();
2050
+ foreach ($this->data['subscribers'] as $subscriber) {
2051
+ $user_ids[] = $subscriber['user_id'];
2052
+ }
2053
+
2054
+ /* 3 - user_list request */
2055
+ if ($user_ids) {
2056
+ $modeluList = WYSIJA::get("user_list", "model");
2057
+ $userlists = $modeluList->get(array("list_id", "user_id"), array("user_id" => $user_ids));
2058
+ }
2059
+
2060
+
2061
+ $this->data['lists'] = $lists;
2062
+ $this->data['counts'] = array_reverse($counts);
2063
+
2064
+ /* regrouping all the data in the same array */
2065
+ foreach ($this->data['subscribers'] as $keysus => $subscriber) {
2066
+ /* default key while we don't have the data */
2067
+ //TODO add data for stats about emails opened clicked etc
2068
+ $this->data['subscribers'][$keysus]["emails"] = 0;
2069
+ $this->data['subscribers'][$keysus]["opened"] = 0;
2070
+ $this->data['subscribers'][$keysus]["clicked"] = 0;
2071
+
2072
+ if ($userlists) {
2073
+ foreach ($userlists as $key => $userlist) {
2074
+ if ($subscriber["user_id"] == $userlist["user_id"] && isset($lists[$userlist["list_id"]])) {
2075
+ if (!isset($this->data['subscribers'][$keysus]["lists"]))
2076
+ $this->data['subscribers'][$keysus]["lists"] = $lists[$userlist["list_id"]]["name"];
2077
+ else
2078
+ $this->data['subscribers'][$keysus]["lists"].=", " . $lists[$userlist["list_id"]]["name"];
2079
+ }
2080
+ }
2081
+ }
2082
+ }
2083
+
2084
+ $this->data['email'] = $email_object;
2085
+
2086
+ if (!$this->data['subscribers']) {
2087
+ $this->notice(__("Your request can't retrieve any subscribers. Change your filters!", WYSIJA));
2088
+ }
2089
+
2090
+ // execute hooks
2091
+ $hook_params = array(
2092
+ 'email_id' => $_REQUEST['id'],
2093
+ 'email_object' => $email_object
2094
+ );
2095
+
2096
+ $this->data['hooks']['hook_newsletter_top'] = apply_filters('hook_newsletter_top', WYSIJA_module::execute_hook('hook_newsletter_top', $hook_params), $hook_params);
2097
+ $this->data['hooks']['hook_newsletter_bottom'] = apply_filters('hook_newsletter_bottom', WYSIJA_module::execute_hook('hook_newsletter_bottom', $hook_params), $hook_params);
2098
+ }
2099
+
2100
+ function getListSubscriberQry($selectcolumns) {
2101
+ $this->modelObj = WYSIJA::get("email", "model");
2102
+ $this->emailObj = $this->modelObj->getOne(false, array('email_id' => $_REQUEST['id']));
2103
+
2104
+ /* use the filter if there is */
2105
+ $this->setviewStatsfilter();
2106
+
2107
+ if ($selectcolumns == "B.user_id") {
2108
+ //unset($this->filters["like"]);
2109
+ }
2110
+
2111
+ $this->filters['equal']["B.email_id"] = $this->emailObj['email_id'];
2112
+ $this->modelObj->noCheck = true;
2113
+ if ($this->filters)
2114
+ $this->modelObj->setConditions($this->filters);
2115
+
2116
+ /* select insert all the subscribers from that campaign into user_list */
2117
+ if ($selectcolumns == "B.user_id") {
2118
+ $query = "SELECT $selectcolumns FROM `[wysija]" . $this->tableQuery . "` as B";
2119
+ $query.=$this->modelObj->makeWhere();
2120
+ } else {
2121
+ $query = "SELECT $selectcolumns FROM `[wysija]user` as A";
2122
+ $query.=" LEFT JOIN `[wysija]" . $this->tableQuery . "` as B on A.user_id=B.user_id";
2123
+ $query.=$this->modelObj->makeWhere();
2124
+ }
2125
+
2126
+ return $query;
2127
+ }
2128
+
2129
+ function createnewlist() {
2130
+ /* get the email subject */
2131
+ $emailModel = WYSIJA::get('email', 'model');
2132
+ $email = $emailModel->getOne(array('subject'), array('email_id' => $_REQUEST['id']));
2133
+
2134
+ $this->modelObj->reset();
2135
+
2136
+ /* set the name of the new list */
2137
+ $prefix = "";
2138
+ if (isset($_REQUEST['link_filter']))
2139
+ $prefix = ' (' . $this->viewObj->getTransStatusEmail($_REQUEST['link_filter']) . ')';
2140
+ $listname = sprintf(__('Segment of %1$s', WYSIJA), $email['subject'] . $prefix);
2141
+
2142
+ /* insert new list */
2143
+ $modelL = WYSIJA::get('list', 'model');
2144
+ $listid = $modelL->insert(array('is_enabled' => 1, 'name' => $listname, 'description' => __('List created based on a newsletter segment.', WYSIJA)));
2145
+
2146
+ /* get list of subscribers filtered or not */
2147
+ $query = $this->getListSubscriberQry($listid . ', A.user_id, ' . time() . ', 0');
2148
+
2149
+ $query2 = 'INSERT INTO `[wysija]user_list` (`list_id`,`user_id`,`sub_date`,`unsub_date`) ' . $query;
2150
+
2151
+ $this->modelObj->query($query2);
2152
+
2153
+ $this->notice(sprintf(__('A new list "%1$s" has been created out of this segment.', WYSIJA), $listname));
2154
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2155
+ }
2156
+
2157
+ function unsubscribeall() {
2158
+ // Update user_list, set unsubdate and sub_date
2159
+ $query = $this->getListSubscriberQry('B.user_id');
 
 
 
 
 
 
 
 
2160
  $query1 = "
2161
+ UPDATE `[wysija]user_list`
2162
+ SET
2163
  `unsub_date` = ".time().",
2164
  `sub_date` = 0
2165
+ WHERE
2166
  `user_id` IN ($query)
2167
  AND `list_id` NOT IN (SELECT `list_id` FROM `[wysija]list` WHERE `is_enabled` < 1)
2168
  ";
2169
+ $this->modelObj->query($query1);
2170
+
2171
+ // unsubscribe from user where select from email_user_stat
2172
+ $query2 = "UPDATE `[wysija]user` SET `status`=-1 WHERE `user_id` IN ($query)";
2173
+ $this->modelObj->query($query2);
2174
+
2175
+ $this->notice(__('The segment has been unbsubscribed from all the lists.', WYSIJA));
2176
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2177
+ }
2178
+
2179
+ function sendconfirmation() {
2180
+ //delete from user_lists where select from email_user_stat
2181
+ $query = $this->getListSubscriberQry('B.user_id ');
2182
+
2183
+ $user_ids = $this->modelObj->query('get_res', $query);
2184
+
2185
+ $uids = array();
2186
+ foreach ($user_ids as $data) {
2187
+ $uids[] = $data['user_id'];
2188
+ }
2189
+
2190
+ $helperUser = WYSIJA::get('user', 'helper');
2191
+ $helperUser->sendConfirmationEmail($uids);
2192
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2193
+ }
2194
+
2195
+ function removequeue() {
2196
+ /* delete from queue where select from email_user_stat */
2197
+ $query = $this->getListSubscriberQry('B.user_id');
2198
+ $query2 = "DELETE FROM `[wysija]queue` where user_id IN ($query) AND email_id=" . $this->emailObj['email_id'];
2199
+ $this->modelObj->query($query2);
2200
+
2201
+ $this->notice(__('The segment has been removed from the queue of this newsletter.', WYSIJA));
2202
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2203
+ }
2204
+
2205
+ function export() {
2206
+ /* select from email_user_stat left join user */
2207
+ $query = $this->getListSubscriberQry('B.user_id');
2208
+ $result = $this->modelObj->query('get_res', $query);
2209
+ $user_ids = array();
2210
+ foreach ($result as $user)
2211
+ $user_ids[] = $user['user_id'];
2212
+
2213
+ $fileHelp = WYSIJA::get('file', 'helper');
2214
+ $tempfilename = $fileHelp->temp(implode(',', $user_ids), 'export_userids', '.txt');
2215
+
2216
+ //$this->redirect("admin.php?page=wysija_campaigns&action=viewstats&id=".$_REQUEST['id']."&user_ids=".serialize($result));
2217
+ $this->redirect('admin.php?page=wysija_subscribers&action=exportcampaign&camp_id=' . $_REQUEST['id'] . '&file_name=' . base64_encode($tempfilename['path']));
2218
+ }
2219
+
2220
+ function unsubscribelist($data) {
2221
+
2222
+ $modelL = WYSIJA::get('list', 'model');
2223
+ $list = $modelL->getOne(false, array('list_id' => $data['listid']));
2224
+ if ($list['is_enabled']) {
2225
+ /* delete from user_lists where select from email_user_stat */
2226
+ $query = $this->getListSubscriberQry("B.user_id");
2227
+ $query2 = "DELETE FROM `[wysija]user_list` where user_id IN ($query) and list_id=" . $data['listid'];
2228
+ $this->modelObj->query($query2);
2229
+
2230
+ $this->notice(sprintf(__('The segment has been unbsubscribed from the list "%1$s".', WYSIJA), $list['name']));
2231
+ } else {
2232
+ $this->notice(sprintf(__('The segment cannot be unbsubscribed from an [IMPORT] list.', WYSIJA), $list['name']));
2233
+ }
2234
+
2235
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2236
+ }
2237
+
2238
+ function articles() {
2239
+ $this->iframeTabs = array('articles' => __("Post Selection", WYSIJA));
2240
+
2241
+ // required js files
2242
+ $this->js[] = 'wysija-admin-ajax';
2243
+ $this->js[] = 'wysija-base-script-64';
2244
+ $this->js[] = 'wysija-scriptaculous';
2245
+ $this->js[] = 'wysija-colorpicker';
2246
+
2247
+ // translations
2248
+ $this->jsTrans['show_advanced'] = __('Display and insert options', WYSIJA);
2249
+ $this->jsTrans['hide_advanced'] = __('Back to selection', WYSIJA);
2250
+ $this->jsTrans['loading_results'] = __('Loading results...', WYSIJA);
2251
+ $this->jsTrans['inserting_selection'] = __('Inserting selected articles...', WYSIJA);
2252
+ $this->jsTrans['post_selected'] = __('selected', WYSIJA);
2253
+
2254
+ // default tab in popup (this needs to be removed at some point)
2255
+ $_GET['tab'] = 'articles';
2256
+
2257
+ // get parameters
2258
+ $params = array(
2259
+ 'category_ids' => null,
2260
+ 'category' => null,
2261
+ 'title_tag' => 'h2',
2262
+ 'title_alignment' => 'left',
2263
+ 'title_position' => 'inside',
2264
+ 'image_alignment' => 'alternate',
2265
+ 'image_width' => 325,
2266
+ 'post_content' => 'excerpt',
2267
+ 'readmore' => __('Read more.', WYSIJA),
2268
+ 'show_divider' => 'yes',
2269
+ 'post_limit' => 5,
2270
+ 'post_type' => 'post',
2271
+ 'author_show' => 'no',
2272
+ 'author_label' => __('Author:', WYSIJA),
2273
+ 'category_show' => 'no',
2274
+ 'category_label' => __('Categories:', WYSIJA),
2275
+ 'nopost_message' => __('Latest content already sent.', WYSIJA),
2276
+ 'bgcolor1' => null,
2277
+ 'bgcolor2' => null,
2278
+ 'sort_by' => 'newest'
2279
+ );
2280
+
2281
+ // check if GET parameters are specified
2282
+ foreach($params as $key => $value) {
2283
+ if(array_key_exists($key, $_GET)) {
2284
+ switch($key) {
2285
+ case 'autopost_count':
2286
+ $params[$key] = (int)$_GET[$key];
2287
+ break;
2288
+ case 'readmore':
2289
+ case 'nopost_message':
2290
+ $params[$key] = base64_decode($_GET[$key]);
2291
+ break;
2292
+ default:
2293
+ $params[$key] = $_GET[$key];
2294
+ }
2295
+ }
2296
+ }
2297
+
2298
+ $model_config = WYSIJA::get('config', 'model');
2299
+ $insert_post_parameters = $model_config->getValue('insert_post_parameters');
2300
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
2301
+
2302
+ if($insert_post_parameters !== false) {
2303
+ // there are user params
2304
+ $params = $helper_wj_engine->decodeParameters(array_merge($params, $insert_post_parameters));
2305
+ }
2306
+
2307
+ // get autopost count
2308
+ $this->data['autopost_count'] = (array_key_exists('autopost_count', $_GET)) ? (int) $_GET['autopost_count'] : 0;
2309
+
2310
+ // get autopost type (single or multiple)
2311
+ $this->data['autopost_type'] = (array_key_exists('autopost_type', $_GET)) ? $_GET['autopost_type'] : 'multiple';
2312
+
2313
+ // if only one group of post can be added, change default alignment to left
2314
+ if($this->data['autopost_type'] === 'single' && $params['image_alignment'] === 'alternate') {
2315
+ $params['image_alignment'] = 'left';
2316
+ }
2317
+
2318
+ // get post categories (even when there's no post)
2319
+ $post_categories = get_categories(array('hide_empty' => 0));
2320
+ $categories = array();
2321
+ foreach ($post_categories as $category) {
2322
+ $categories[] = array('id' => $category->cat_ID, 'name' => $category->name);
2323
+ }
2324
+ $this->data['categories'] = $categories;
2325
+
2326
+ // max number of posts
2327
+ $this->data['post_limits'] = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 50);
2328
+
2329
+ $this->data['params'] = $params;
2330
+
2331
+ return $this->popupContent();
2332
+ }
2333
+
2334
+ function themeupload() {
2335
+ $helperNumbers = WYSIJA::get('numbers', 'helper');
2336
+ $bytes = $helperNumbers->get_max_file_upload();
2337
+
2338
+ if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > $bytes['maxbytes']) {
2339
+ if (isset($_FILES['my-theme']['name']) && $_FILES['my-theme']['name']) {
2340
+ $filename = $_FILES['my-theme']['name'];
2341
+ } else {
2342
+ $filename = "";
2343
+ }
2344
+
2345
+ $this->error(sprintf(__('Upload error, file %1$s is too large! (MAX:%2$s)', WYSIJA), $filename, $bytes['maxmegas']), true);
2346
+ $this->redirect('admin.php?page=wysija_campaigns&action=themes');
2347
+
2348
+ return false;
2349
+ }
2350
+
2351
+
2352
+ $ZipfileResult = trim(file_get_contents($_FILES['my-theme']['tmp_name']));
2353
+
2354
+ $themesHelp = WYSIJA::get('themes', 'helper');
2355
+ $result = $themesHelp->installTheme($_FILES['my-theme']['tmp_name'], true);
2356
+ $this->redirect('admin.php?page=wysija_campaigns&action=themes&reload=1');
2357
+
2358
+ return true;
2359
+ }
2360
+
2361
+ function themes() {
2362
+ $this->iframeTabs = array('themes' => __('Install Themes', WYSIJA));
2363
+ $this->js[] = 'wysija-admin-ajax';
2364
+ $this->js[] = 'wysija-base-script-64';
2365
+ $this->jsTrans['viewinfos'] = __('Details & PSD', WYSIJA);
2366
+ $this->jsTrans['viewback'] = __('<< Back', WYSIJA);
2367
+ $this->jsTrans['install'] = __('Download', WYSIJA);
2368
+ $this->jsTrans['reinstall'] = __('Reinstall', WYSIJA);
2369
+ $this->jsTrans['premiumonly'] = __('Premium', WYSIJA);
2370
+
2371
+ $model_config = WYSIJA::get('config', 'model');
2372
+ //change the translation of the button when it's premium
2373
+ if ($model_config->getValue('premium_key'))
2374
+ $this->jsTrans['ispremium'] = 1;
2375
+ else
2376
+ $this->jsTrans['ispremium'] = 0;
2377
+
2378
+ $this->jsTrans['premiumfiles'] = __('Photoshop file available as part of [link]Premium features[/link].', WYSIJA);
2379
+
2380
+ $helper_licence = WYSIJA::get('licence', 'helper');
2381
+ $url_checkout = $helper_licence->get_url_checkout('themes');
2382
+ $this->jsTrans['premiumfiles'] = str_replace(array('[link]', '[/link]'), array('<a href="' . $url_checkout . '" target="_blank" >', '</a>'), $this->jsTrans['premiumfiles']);
2383
+
2384
+ $this->jsTrans['showallthemes'] = __('Show all themes', WYSIJA);
2385
+ $this->jsTrans['totalvotes'] = __('(%1$s votes)', WYSIJA);
2386
+ $this->jsTrans['voterecorded'] = __("Your vote has been recorded.", WYSIJA);
2387
+ $this->jsTrans['votenotrecorded'] = __("Your vote could not be recorded.", WYSIJA);
2388
+ $this->jsTrans['reinstallwarning'] = __('Watch out! If you reinstall this theme all the files which are in the folder:/wp-content/uploads/wysija/themes/%1$s will be overwritten. Are you sure you want to reinstall?', WYSIJA);
2389
+ $this->jsTrans['errorconnecting'] = __("We were unable to contact the API, the site may be down. Please try again later.", WYSIJA);
2390
+
2391
+ $this->jsTrans['viewallthemes'] = __('View all themes by %1$s', WYSIJA);
2392
+ $this->jsTrans['downloadpsd'] = __("Download original Photoshop file", WYSIJA);
2393
+ $this->jsTrans['downloadzip'] = __("Download as .zip", WYSIJA);
2394
+ $this->jsTrans['viewauthorsite'] = __("View author's website", WYSIJA);
2395
+ $this->jsTrans['stars'] = __('Average rating: %1$s', WYSIJA);
2396
+ $this->jsTrans['starsyr'] = __('My rating: %1$s', WYSIJA);
2397
+ $this->jsTrans['downloads'] = __('Downloads: %1$s', WYSIJA);
2398
+ $this->jsTrans['tags'] = __('Tags: %1$s', WYSIJA);
2399
+ $this->jsTrans['lastupdated'] = __('Last updated: %1$s', WYSIJA);
2400
+ $this->jsTrans['includes'] = __('Includes: %1$s', WYSIJA);
2401
+
2402
+ $helper_themes = WYSIJA::get('themes', 'helper');
2403
+
2404
+ $this->jsTrans['installedthemes'] = $helper_themes->getInstalled();
2405
+
2406
+ $url = admin_url('admin.php');
2407
+ $helper_toolbox = WYSIJA::get("toolbox", "helper");
2408
+ $domain_name = $helper_toolbox->_make_domain_name($url);
2409
+ $this->jsTrans['domainname'] = $domain_name;
2410
+
2411
+ $_GET['tab'] = 'themes';
2412
+
2413
+ return $this->popupContent();
2414
+ }
2415
+
2416
+ function bookmarks() {
2417
+ $this->iframeTabs = array('bookmarks' => __('Bookmarks Selection', WYSIJA));
2418
+ $this->js[] = 'wysija-admin-ajax';
2419
+
2420
+ $_GET['tab'] = 'bookmarks';
2421
+
2422
+ $networks = array(
2423
+ 'facebook' => array(
2424
+ 'label' => 'Facebook',
2425
+ 'url' => null,
2426
+ 'placeholder' => 'https://www.facebook.com/mailpoetplugin'
2427
+ ),
2428
+ 'twitter' => array(
2429
+ 'label' => 'Twitter',
2430
+ 'url' => null,
2431
+ 'placeholder' => 'http://www.twitter.com/mail_poet'
2432
+ ),
2433
+ 'google' => array(
2434
+ 'label' => 'Google+',
2435
+ 'url' => null,
2436
+ 'placeholder' => null
2437
+ ),
2438
+ 'linkedin' => array(
2439
+ 'label' => 'LinkedIn',
2440
+ 'url' => null,
2441
+ 'placeholder' => null
2442
+ )
2443
+ );
2444
+
2445
+ // get networks' url from config
2446
+ $model_config = WYSIJA::get('config', 'model');
2447
+ $urls = $model_config->getValue('social_bookmarks');
2448
+
2449
+ // set url from config for each network if specified
2450
+ foreach ($networks as $network => $values) {
2451
+ if (isset($urls[$network]) and strlen(trim($urls[$network])) > 0) {
2452
+ $networks[$network]['url'] = $urls[$network];
2453
+ }
2454
+ }
2455
+
2456
+ $this->data['networks'] = $networks;
2457
+ $this->data['size'] = 'medium';
2458
+ $this->data['theme'] = isset($_REQUEST['theme']) ? $_REQUEST['theme'] : 'default';
2459
+
2460
+ return $this->popupContent();
2461
+ }
2462
+
2463
+ function dividers() {
2464
+ $this->iframeTabs = array('dividers' => __("Dividers Selection", WYSIJA));
2465
+ $this->js[] = 'wysija-admin-ajax';
2466
+ $this->js[] = 'wysija-base-script-64';
2467
+
2468
+ $_GET['tab'] = 'dividers';
2469
+
2470
+ $model_email = WYSIJA::get('email', 'model');
2471
+ $this->data['email'] = $email = $model_email->getOne(false, array('email_id' => $_REQUEST['emailId']));
2472
+
2473
+ // get dividers
2474
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
2475
+ $dividers = $helper_dividers->getAll();
2476
+
2477
+ // get theme divider if it's not the default theme
2478
+ if (isset($email['params']['theme'])) {
2479
+ $helper_themes = WYSIJA::get('themes', 'helper');
2480
+ $themeDivider = $helper_themes->getDivider($email['params']['theme']);
2481
+ if ($themeDivider !== NULL) {
2482
+ array_unshift($dividers, $themeDivider);
2483
+ }
2484
+ }
2485
+
2486
+ // get selected divider
2487
+ if (isset($email['params']['divider'])) {
2488
+ $selected_divider = $email['params']['divider'];
2489
+ } else {
2490
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
2491
+ $selected_divider = $helper_dividers->getDefault();
2492
+ }
2493
+
2494
+ // set selected divider in first position
2495
+ array_unshift($dividers, $selected_divider);
2496
+
2497
+ // remove selected divider if present in the list
2498
+ for ($i = 1; $i < count($dividers); $i++) {
2499
+ if ($dividers[$i]['src'] === $selected_divider['src']) {
2500
+ unset($dividers[$i]);
2501
+ break;
2502
+ }
2503
+ }
2504
+
2505
+ $this->data['selected'] = $selected_divider;
2506
+ $this->data['dividers'] = $dividers;
2507
+ return $this->popupContent();
2508
+ }
2509
+
2510
+ function autopost() {
2511
+ $this->iframeTabs = array('autopost' => __("Add / Edit group of posts", WYSIJA));
2512
+ $this->js[] = 'wysija-admin-ajax';
2513
+ $this->js[] = 'wysija-base64';
2514
+ $this->js[] = 'wysija-scriptaculous';
2515
+ $this->js[] = 'wysija-colorpicker';
2516
+ $this->js[] = 'mailpoet-select2';
2517
+
2518
+ // translations
2519
+ $this->jsTrans['show_advanced'] = __('Show display options', WYSIJA);
2520
+ $this->jsTrans['hide_advanced'] = __('Hide display options', WYSIJA);
2521
+
2522
+ $_GET['tab'] = 'autopost';
2523
+
2524
+ // get parameters
2525
+ $params = array(
2526
+ 'category_ids' => null,
2527
+ 'category_condition' => 'include',
2528
+ 'title_tag' => 'h2',
2529
+ 'title_alignment' => 'left',
2530
+ 'title_position' => 'inside',
2531
+ 'image_alignment' => 'alternate',
2532
+ 'image_width' => 325,
2533
+ 'post_content' => 'excerpt',
2534
+ 'readmore' => __('Read more.', WYSIJA),
2535
+ 'show_divider' => 'yes',
2536
+ 'post_limit' => 5,
2537
+ 'post_type' => 'post',
2538
+ 'author_show' => 'no',
2539
+ 'author_label' => __('Author:', WYSIJA),
2540
+ 'category_show' => 'no',
2541
+ 'category_label' => __('Categories:', WYSIJA),
2542
+ 'nopost_message' => __('Latest content already sent.', WYSIJA),
2543
+ 'bgcolor1' => null,
2544
+ 'bgcolor2' => null,
2545
+ 'sort_by' => 'newest'
2546
+ );
2547
+
2548
+ // backwards compatibility since we replaced the 'cpt' parameter by 'post_type' in 2.6
2549
+ if(isset($_GET['cpt']) && strlen(trim($_GET['cpt'])) > 0) {
2550
+ $params['post_type'] = trim($_GET['cpt']);
2551
+ }
2552
+
2553
+ // check if GET parameters are specified
2554
+ foreach ($params as $key => $value) {
2555
+ if (array_key_exists($key, $_GET)) {
2556
+ switch ($key) {
2557
+ case 'autopost_count':
2558
+ $params[$key] = (int)$_GET[$key];
2559
+ break;
2560
+ case 'author_label':
2561
+ case 'category_label':
2562
+ case 'readmore':
2563
+ case 'nopost_message':
2564
+ $params[$key] = base64_decode($_GET[$key]);
2565
+ break;
2566
+ default:
2567
+ $params[$key] = trim($_GET[$key]);
2568
+ }
2569
+ }
2570
+ }
2571
+
2572
+ // get autopost count
2573
+ $this->data['autopost_count'] = (array_key_exists('autopost_count', $_GET)) ? (int) $_GET['autopost_count'] : 0;
2574
+
2575
+ // get autopost type (single or multiple)
2576
+ $this->data['autopost_type'] = (array_key_exists('autopost_type', $_GET)) ? $_GET['autopost_type'] : 'multiple';
2577
+
2578
+ // if only one group of post can be added, change default alignment to left
2579
+ if ($this->data['autopost_type'] === 'single') {
2580
+ if ($params['image_alignment'] === 'alternate')
2581
+ $params['image_alignment'] = 'left';
2582
+ }
2583
+
2584
+ // we use that now, because categories from a post are different than categories from a CPT
2585
+ $helper_wp_tools = WYSIJA::get('wp_tools','helper');
2586
+ $this->data['categories'] = $helper_wp_tools->get_categories();
2587
+
2588
+ // max number of posts
2589
+ $this->data['post_limits'] = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 50);
2590
+
2591
+ $this->data['params'] = $params;
2592
+
2593
+ return $this->popupContent();
2594
+ }
2595
+
2596
+ function image_data() {
2597
+ $this->data['url'] = (isset($_GET['url']) && $_GET['url'] !== '') ? trim(urldecode($_GET['url'])) : null;
2598
+ $this->data['alt'] = (isset($_GET['alt'])) ? trim(urldecode($_GET['alt'])) : '';
2599
+
2600
+ $this->iframeTabs = array('image_data' => __("Image Parameters", WYSIJA));
2601
+ $_GET['tab'] = 'image_data';
2602
+ return $this->popupContent();
2603
+ }
2604
+
2605
+ function medias() {
2606
+ $this->popupContent();
2607
+ }
2608
+
2609
+ function special_wysija_browse() {
2610
+ $this->_wysija_subaction();
2611
+ $this->jsTrans['deleteimg'] = __('Delete image for all newsletters?', WYSIJA);
2612
+ return wp_iframe(array($this->viewObj, 'popup_wysija_browse'), array());
2613
+ }
2614
+
2615
+ function special_wordp_browse() {
2616
+ $this->_wysija_subaction();
2617
+ $this->jsTrans['deleteimg'] = __('This image might be in an article. Delete anyway?', WYSIJA);
2618
+ return wp_iframe(array($this->viewObj, 'popup_wp_browse'), array());
2619
+ }
2620
+
2621
+ function _wysija_subaction() {
2622
+
2623
+ if (isset($_REQUEST['subaction'])) {
2624
+ if ($_REQUEST['subaction'] === 'delete') {
2625
+ if (isset($_REQUEST['imgid']) && (int) $_REQUEST['imgid'] > 0) {
2626
+ /* delete the image with id imgid */
2627
+ $res = wp_delete_attachment((int) $_REQUEST['imgid'], true);
2628
+ if ($res) {
2629
+ $this->notice(__('Image has been deleted.', WYSIJA));
2630
+ }
2631
+ }
2632
+ }
2633
+ }
2634
+ return true;
2635
+ }
2636
+
2637
+ function special_new_wordp_upload() {
2638
+
2639
+ //wp_enqueue_script('plupload-all');
2640
+ wp_enqueue_script('wysija-plupload-handlers', WYSIJA_URL . 'js/jquery/pluploadHandler.js', array('plupload-all', 'jquery'));
2641
+ $uploader_l10n = array(
2642
+ 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
2643
+ 'file_exceeds_size_limit' => __('%s exceeds the maximum upload size for this site.'),
2644
+ 'zero_byte_file' => __('This file is empty. Please try another.'),
2645
+ 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
2646
+ 'not_an_image' => __('This file is not an image. Please try another.'),
2647
+ 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
2648
+ 'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
2649
+ 'default_error' => __('An error occurred in the upload. Please try again later.'),
2650
+ 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
2651
+ 'upload_limit_exceeded' => __('You may only upload 1 file.'),
2652
+ 'http_error' => __('HTTP error.'),
2653
+ 'upload_failed' => __('Upload failed.'),
2654
+ 'big_upload_failed' => __('Please try uploading this file with the %1$sbrowser uploader%2$s.'),
2655
+ 'big_upload_queued' => __('%s exceeds the maximum upload size for the multi-file uploader when used in your browser.'),
2656
+ 'io_error' => __('IO error.'),
2657
+ 'security_error' => __('Security error.'),
2658
+ 'file_cancelled' => __('File canceled.'),
2659
+ 'upload_stopped' => __('Upload stopped.'),
2660
+ 'dismiss' => __('Dismiss'),
2661
+ 'crunching' => __('Crunching&hellip;'),
2662
+ 'deleted' => __('moved to the trash.'),
2663
+ 'error_uploading' => __('&#8220;%s&#8221; has failed to upload.')
2664
+ );
2665
+
2666
+ wp_localize_script('wysija-plupload-handlers', 'pluploadL10n', $uploader_l10n);
2667
+
2668
+ wp_enqueue_script('image-edit');
2669
+ wp_enqueue_script('set-post-thumbnail');
2670
+ wp_enqueue_style('imgareaselect');
2671
+ wp_enqueue_script('media-gallery');
2672
+
2673
+ /* wp_register_style('myplupload', '/adjust-this-url/myplupload.css');
2674
+ wp_enqueue_style('myplupload'); */
2675
+
2676
+
2677
+ $errors = array();
2678
+ return wp_iframe(array($this->viewObj, 'popup_new_wp_upload'), $errors);
2679
+ }
2680
+
2681
+ function special_wordp_upload() {
2682
+
2683
+ wp_enqueue_script('swfupload-all');
2684
+ wp_enqueue_script('swfupload-handlers');
2685
+ wp_enqueue_script('wysija-upload-handlers', WYSIJA_URL . "js/jquery/uploadHandlers.js");
2686
+ wp_enqueue_script('image-edit');
2687
+ wp_enqueue_script('set-post-thumbnail');
2688
+ wp_enqueue_style('imgareaselect');
2689
+
2690
+ $errors = array();
2691
+ $id = 0;
2692
+ if (isset($_GET['flash']))
2693
+ $_GET['flash'] = 1;
2694
+ if (isset($_POST['html-upload']) && !empty($_FILES)) {
2695
+ // Upload File button was clicked
2696
+ $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
2697
+ unset($_FILES);
2698
+ if (is_wp_error($id)) {
2699
+ $errors['upload_error'] = $id;
2700
+ $id = false;
2701
+ }
2702
+ }
2703
+
2704
+ if (!empty($_POST['insertonlybutton'])) {
2705
+ $href = $_POST['insertonly']['href'];
2706
+ if (!empty($href) && !strpos($href, '://'))
2707
+ $href = "http://$href";
2708
+
2709
+ $title = esc_attr($_POST['insertonly']['title']);
2710
+ if (empty($title))
2711
+ $title = basename($href);
2712
+ if (!empty($title) && !empty($href))
2713
+ $html = "<a href='" . esc_url($href) . "' >$title</a>";
2714
+ $html = apply_filters('file_send_to_editor_url', $html, esc_url_raw($href), $title);
2715
+ return media_send_to_editor($html);
2716
+ }
2717
+
2718
+ if (!empty($_POST)) {
2719
+ $return = media_upload_form_handler();
2720
+
2721
+ if (is_string($return))
2722
+ return $return;
2723
+ if (is_array($return))
2724
+ $errors = $return;
2725
+ }
2726
+
2727
+ if (isset($_POST['save'])) {
2728
+ $errors['upload_notice'] = __('Saved.', WYSIJA);
2729
+ return media_upload_gallery();
2730
+ }
2731
+
2732
+
2733
+ return wp_iframe(array($this->viewObj, 'popup_wp_upload'), $errors);
2734
+ }
2735
+
2736
+ function _checkEmailExists($emailId) {
2737
+ $result = false;
2738
+ $modelEmail = WYSIJA::get('email', 'model');
2739
+
2740
+ if ($modelEmail->exists(array('email_id' => $emailId)))
2741
+ $result = true;
2742
+
2743
+ if (!$result) {
2744
+ $this->error(__("The newsletter doesn't exist.", WYSIJA), 1);
2745
+ $this->redirect('admin.php?page=wysija_campaigns');
2746
+ }
2747
+ else
2748
+ return true;
2749
+ }
2750
 
2751
  }
controllers/back/config.php CHANGED
@@ -18,7 +18,7 @@ class WYSIJA_control_back_config extends WYSIJA_control_back{
18
  $this->jsTrans['bounceconnect'] = __('Bounce handling connection test', WYSIJA);
19
  $this->jsTrans['processbounceT'] = __('Bounce handling processing', WYSIJA);
20
  $this->jsTrans['doubleoptinon'] = __('Subscribers will now need to activate their subscription by email in order to receive your newsletters. This is recommended.', WYSIJA);
21
- $this->jsTrans['doubleoptinoff'] = __('Unconfirmed subscribers will receive your newsletters from now on without the need to activate their subscriptions.', WYSIJA);
22
  $this->jsTrans['processbounce'] = __('Process bounce handling now!', WYSIJA);
23
  $this->jsTrans['errorbounceforward'] = __('When setting up the bounce system, you need to have a different address for the bounce email and the forward to address', WYSIJA);
24
 
18
  $this->jsTrans['bounceconnect'] = __('Bounce handling connection test', WYSIJA);
19
  $this->jsTrans['processbounceT'] = __('Bounce handling processing', WYSIJA);
20
  $this->jsTrans['doubleoptinon'] = __('Subscribers will now need to activate their subscription by email in order to receive your newsletters. This is recommended.', WYSIJA);
21
+ $this->jsTrans['doubleoptinoff'] = __('Unconfirmed subscribers will receive your newslettters from now on without the need to activate their subscriptions.', WYSIJA);
22
  $this->jsTrans['processbounce'] = __('Process bounce handling now!', WYSIJA);
23
  $this->jsTrans['errorbounceforward'] = __('When setting up the bounce system, you need to have a different address for the bounce email and the forward to address', WYSIJA);
24
 
controllers/back/statistics.php CHANGED
@@ -1,197 +1,176 @@
1
  <?php
 
2
  defined('WYSIJA') or die('Restricted access');
3
  require_once(WYSIJA_CORE.'module'.DS.'statistics.php'); // @todo
4
 
5
- class WYSIJA_control_back_statistics extends WYSIJA_control_back
6
- {
7
-
8
- /**
9
- * Main model of this controller
10
- * @var string
11
- */
12
- public $model = 'statistics';
13
-
14
- /**
15
- * Main view of this controller
16
- * @var string
17
- */
18
- public $view = 'statistics';
19
-
20
- /**
21
- * Base URL of all requests
22
- * @var string
23
- */
24
- public $base_url = 'admin.php';
25
-
26
- /**
27
- * Load blocks at a same time (FALSE) or one by one (TRUE)
28
- * @var TRUE
29
- */
30
- protected $lazy_load = true;
31
-
32
- /**
33
- * list of pre-defined dates
34
- * @var Array
35
- */
36
- protected $pre_defined_dates = array( );
37
-
38
- protected $date_format = 'Y/m/d';
39
-
40
- protected $js_date_format = 'yy/mm/dd';
41
-
42
- /**
43
- * Constructor
44
- */
45
- function WYSIJA_control_back_statistics()
46
- {
47
-
48
- }
49
-
50
- public function defaultDisplay()
51
- {
52
- $this->pre_defined_dates = $this->get_pre_defined_dates();
53
- // Define view
54
- $this->viewShow = $this->action = 'main';
55
- $this->js['jquery.core'] = 'jquery/ui/jquery.ui.core';
56
- $this->js['jquery.datepicker'] = 'jquery/ui/jquery.ui.datepicker';
57
- $this->js['wysijalazyload'] = 'wysija-lazyload';
58
- $this->js['admin-statistics-filter'] = 'admin-statistics-filter';
59
- wp_enqueue_style('jquery.core', WYSIJA_URL.'css/jquery/ui/themes/base/jquery.ui.core.min.css', array( ), WYSIJA::get_version());
60
- wp_enqueue_style('jquery.core', WYSIJA_URL.'css/jquery/ui/themes/base/jquery.ui.theme.min.css', array( ), WYSIJA::get_version());
61
-
62
- // date filter
63
- $default_duration = $this->get_default_duration();
64
- if (function_exists('date_diff'))
65
- {
66
- $this->data['date_interval'] = date_diff(date_create($default_duration['from']), date_create($default_duration['to']));
67
- }
68
- else
69
- {
70
- $duration = strtotime($default_duration['to']) - strtotime($default_duration['from']);
71
- $helper_toolbox = WYSIJA::get('toolbox', 'helper');
72
- $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration, false);
73
- }
74
-
75
- $this->data['custom_dates'] = $this->pre_defined_dates;
76
- $this->data['default_duration'] = $default_duration;
77
- $this->data['js_date_format'] = $this->js_date_format;
78
-
79
- // Process and push data into view
80
- $this->data['lazy_load'] = $this->lazy_load;
81
- $hook_name = 'hook_stats';
82
- $hook_params = array( );
83
- $hook_params['top'] = WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
84
- $hook_params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : $default_duration['from'];
85
- $hook_params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : $default_duration['to'];
86
- $hook_params['group_by'] = ($this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
87
- WYSIJA_module_statistics::GROUP_BY_MONTH :
88
- WYSIJA_module_statistics::GROUP_BY_DATE; // $this->data['date_interval']->days == 0, means, no begin date, no end date
89
-
90
- // Hack!
91
- $_REQUEST['limit_pp'] = $hook_params['top'];// Pagination, mark current selected value
92
-
93
- $modules = WYSIJA_module::get_modules_from_hook($hook_name);
94
- $this->data['modules'] = $modules;
95
- $this->data['lazy_load_modules'] = array( );
96
- $this->data['first_module'] = '';
97
-
98
- if (!$this->lazy_load)
99
- {
100
- $this->data['hooks'][$hook_name] = apply_filters('hook_stats', '', $hook_params);
101
- }
102
- else
103
- {
104
- if (!empty($modules))
105
- {
106
- $first_module = array_shift($modules);
107
- // List of lazy loaded modules
108
- $this->data['lazy_load_modules'] = $modules;
109
-
110
- // Evenly we are lazy loading, we always load the first module by default
111
- $this->data['first_module'] = apply_filters('custom_module_hook', '', $first_module, $hook_name, $hook_params);
112
- }
113
- }
114
- }
115
-
116
- /**
117
- * get pre defined dates (duration)
118
- * @return type
119
- */
120
- protected function get_pre_defined_dates()
121
- {
122
- return array(
123
- array(
124
- 'value' => 7,
125
- 'label' => __('Last 7 days', WYSIJA),
126
- 'selected' => false,
127
- 'from' => date($this->date_format, strtotime('-7 days')),
128
- 'to' => date($this->date_format, strtotime('tomorrow'))
129
- ),
130
- array(
131
- 'value' => 'last_month',
132
- 'label' => __('Last month', WYSIJA),
133
- 'selected' => false,
134
- 'from' => date($this->date_format, mktime(0, 0, 0, date('m')-1, 1, date('Y'))),
135
- 'to' => date($this->date_format, mktime(0, 0, 0, date('m'), 0, date('Y')))
136
-
137
-
138
- ),
139
- array(
140
- 'value' => 30,
141
- 'label' => __('Last 30 days', WYSIJA),
142
- 'selected' => false,
143
- 'from' => date($this->date_format, strtotime('-30 days')),
144
- 'to' => date($this->date_format, strtotime('tomorrow'))
145
- ),
146
- array(
147
- 'value' => 90,
148
- 'label' => __('Last 90 days', WYSIJA),
149
- 'selected' => true,
150
- 'from' => date($this->date_format, strtotime('-90 days')),
151
- 'to' => date($this->date_format, strtotime('tomorrow'))
152
- ),
153
- array(
154
- 'value' => 180,
155
- 'label' => __('Last 180 days', WYSIJA),
156
- 'selected' => false,
157
- 'from' => date($this->date_format, strtotime('-180 days')),
158
- 'to' => date($this->date_format, strtotime('tomorrow'))
159
- ),
160
- array(
161
- 'value' => 365,
162
- 'label' => __('Last 365 days', WYSIJA),
163
- 'selected' => false,
164
- 'from' => date($this->date_format, strtotime('-365 days')),
165
- 'to' => date($this->date_format, strtotime('tomorrow'))
166
- ),
167
- array(
168
- 'value' => 0,
169
- 'label' => __('Custom dates', WYSIJA),
170
- 'selected' => false,
171
- 'from' => '',
172
- 'to' => ''
173
- ),
174
- );
175
  }
176
-
177
- /**
178
- * Get default duration of stats
179
- * @return int
180
- */
181
- protected function get_default_duration()
182
- {
183
- foreach ($this->pre_defined_dates as $duration)
184
- if (isset($duration['selected']) && $duration['selected'])
185
- return $duration;
186
- return end($this->pre_defined_dates);
187
  }
188
-
189
- function date_diff($time_start, $time_end)
190
- {
191
- $result = null;
192
- $duration = $time_end - $time_start;
193
- $result->days = floor($duration / (60 * 60 * 24));
194
- return $result;
195
- }
196
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  }
1
  <?php
2
+
3
  defined('WYSIJA') or die('Restricted access');
4
  require_once(WYSIJA_CORE.'module'.DS.'statistics.php'); // @todo
5
 
6
+ class WYSIJA_control_back_statistics extends WYSIJA_control_back {
7
+
8
+ /**
9
+ * Main model of this controller
10
+ * @var string
11
+ */
12
+ public $model = 'statistics';
13
+
14
+ /**
15
+ * Main view of this controller
16
+ * @var string
17
+ */
18
+ public $view = 'statistics';
19
+
20
+ /**
21
+ * Base URL of all requests
22
+ * @var string
23
+ */
24
+ public $base_url = 'admin.php';
25
+
26
+ /**
27
+ * Load blocks at a same time (FALSE) or one by one (TRUE)
28
+ * @var TRUE
29
+ */
30
+ protected $lazy_load = true;
31
+
32
+ /**
33
+ * list of pre-defined dates
34
+ * @var Array
35
+ */
36
+ protected $pre_defined_dates = array();
37
+ protected $date_format = 'Y/m/d';
38
+ protected $js_date_format = 'yy/mm/dd';
39
+
40
+ /**
41
+ * Constructor
42
+ */
43
+ function WYSIJA_control_back_statistics() {}
44
+
45
+ public function defaultDisplay() {
46
+ $this->pre_defined_dates = $this->get_pre_defined_dates();
47
+ // Define view
48
+ $this->viewShow = $this->action = 'main';
49
+ $this->js['jquery.core'] = 'jquery/ui/jquery.ui.core';
50
+ $this->js['jquery.datepicker'] = 'jquery/ui/jquery.ui.datepicker';
51
+ $this->js['wysijalazyload'] = 'wysija-lazyload';
52
+ $this->js['admin-statistics-filter'] = 'admin-statistics-filter';
53
+ wp_enqueue_style('jquery.core', WYSIJA_URL.'css/jquery/ui/themes/base/jquery.ui.core.min.css', array(), WYSIJA::get_version());
54
+ wp_enqueue_style('jquery.core', WYSIJA_URL.'css/jquery/ui/themes/base/jquery.ui.theme.min.css', array(), WYSIJA::get_version());
55
+
56
+ // date filter
57
+ $default_duration = $this->get_default_duration();
58
+ if( function_exists('date_diff')){
59
+ $this->data['date_interval'] = date_diff(date_create($default_duration['from']), date_create($default_duration['to']));
60
+ }else{
61
+ $duration = strtotime($default_duration['to']) - strtotime($default_duration['from']);
62
+ $helper_toolbox = WYSIJA::get('toolbox' , 'helper');
63
+ $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration , false);
64
+ }
65
+
66
+ $this->data['custom_dates'] = $this->pre_defined_dates;
67
+ $this->data['default_duration'] = $default_duration;
68
+ $this->data['js_date_format'] = $this->js_date_format;
69
+
70
+ // Process and push data into view
71
+ $this->data['lazy_load'] = $this->lazy_load;
72
+ $hook_name = 'hook_stats';
73
+ $hook_params = array();
74
+ $hook_params['top'] = WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
75
+ $hook_params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : $default_duration['from'];
76
+ $hook_params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : $default_duration['to'];
77
+ $hook_params['group_by'] = ($this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
78
+ WYSIJA_module_statistics::GROUP_BY_MONTH :
79
+ WYSIJA_module_statistics::GROUP_BY_DATE;// $this->data['date_interval']->days == 0, means, no begin date, no end date
80
+
81
+ $modules = WYSIJA_module::get_modules_from_hook($hook_name);
82
+ $this->data['modules'] = $modules;
83
+ $this->data['lazy_load_modules'] = array();
84
+ $this->data['first_module'] = '';
85
+
86
+ if (!$this->lazy_load) {
87
+ $this->data['hooks'][$hook_name] = apply_filters('hook_stats', '', $hook_params);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  }
89
+ else {
90
+ if (!empty($modules)) {
91
+ $first_module = array_shift($modules);
92
+ // List of lazy loaded modules
93
+ $this->data['lazy_load_modules'] = $modules;
94
+
95
+ // Evenly we are lazy loading, we always load the first module by default
96
+ $this->data['first_module'] = apply_filters('custom_module_hook', '', $first_module, $hook_name, $hook_params);
97
+ }
 
 
98
  }
99
+ }
100
+
101
+ /**
102
+ * get pre defined dates (duration)
103
+ * @return type
104
+ */
105
+ protected function get_pre_defined_dates() {
106
+ return array(
107
+ array(
108
+ 'value' => 7,
109
+ 'label' => __('Last 7 days', WYSIJA),
110
+ 'selected' => false,
111
+ 'from' => date($this->date_format, strtotime('-7 days')),
112
+ 'to' => date($this->date_format, strtotime('tomorrow'))
113
+ ),
114
+ array(
115
+ 'value' => 'last_month',
116
+ 'label' => __('Last month', WYSIJA),
117
+ 'selected' => false,
118
+ 'from' => date($this->date_format, strtotime('first day of previous month')),
119
+ 'to' => date($this->date_format, strtotime('last day of previous month'))
120
+ ),
121
+ array(
122
+ 'value' => 30,
123
+ 'label' => __('Last 30 days', WYSIJA),
124
+ 'selected' => false,
125
+ 'from' => date($this->date_format, strtotime('-30 days')),
126
+ 'to' => date($this->date_format, strtotime('tomorrow'))
127
+ ),
128
+ array(
129
+ 'value' => 90,
130
+ 'label' => __('Last 90 days', WYSIJA),
131
+ 'selected' => true,
132
+ 'from' => date($this->date_format, strtotime('-90 days')),
133
+ 'to' => date($this->date_format, strtotime('tomorrow'))
134
+ ),
135
+ array(
136
+ 'value' => 180,
137
+ 'label' => __('Last 180 days', WYSIJA),
138
+ 'selected' => false,
139
+ 'from' => date($this->date_format, strtotime('-180 days')),
140
+ 'to' => date($this->date_format, strtotime('tomorrow'))
141
+ ),
142
+ array(
143
+ 'value' => 365,
144
+ 'label' => __('Last 365 days', WYSIJA),
145
+ 'selected' => false,
146
+ 'from' => date($this->date_format, strtotime('-365 days')),
147
+ 'to' => date($this->date_format, strtotime('tomorrow'))
148
+ ),
149
+ array(
150
+ 'value' => 0,
151
+ 'label' => __('Custom dates', WYSIJA),
152
+ 'selected' => false,
153
+ 'from' => '',
154
+ 'to' => ''
155
+ ),
156
+ );
157
+ }
158
+
159
+ /**
160
+ * Get default duration of stats
161
+ * @return int
162
+ */
163
+ protected function get_default_duration() {
164
+ foreach ($this->pre_defined_dates as $duration)
165
+ if (isset($duration['selected']) && $duration['selected'])
166
+ return $duration;
167
+ return end($this->pre_defined_dates);
168
+ }
169
+
170
+ function date_diff($time_start,$time_end){
171
+ $result = null;
172
+ $duration = $time_end - $time_start;
173
+ $result->days = floor($duration/(60*60*24));
174
+ return $result;
175
+ }
176
  }
controllers/back/subscribers.php CHANGED
@@ -145,22 +145,6 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
145
  }
146
 
147
 
148
- /**
149
- * Get selected lists
150
- * @return array
151
- */
152
- protected function get_selected_lists() {
153
- $result = array();
154
- if (isset($_REQUEST['wysija']['filter']['filter_list'])) {
155
- $result[] = $_REQUEST['wysija']['filter']['filter_list'];
156
- } elseif (!empty($_REQUEST['filter-list'])) {
157
- $lists = explode(',', trim($_REQUEST['filter-list']));// currently, only single list is allowed.
158
- if (!empty($lists)) {
159
- $result = array_merge ($result, $lists);
160
- }
161
- }
162
- return $result;
163
- }
164
 
165
  function defaultDisplay(){
166
  $this->viewShow=$this->action='main';
@@ -190,7 +174,6 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
190
 
191
  // count the rows based on the filters
192
  $filters = $this->modelObj->detect_filters();
193
-
194
  $select = array( 'COUNT(DISTINCT([wysija]user.user_id)) as total_users', 'MAX([wysija]user.created_at) as max_create_at');
195
  $count_rows = $this->modelObj->get_subscribers( $select, $filters);
196
 
@@ -221,7 +204,6 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
221
 
222
  $this->data['current_counts'] = $this->modelObj->countRows;
223
  $this->data['show_batch_select'] = ($this->modelObj->limit >= $this->modelObj->countRows) ? false : true;
224
- $this->data['selected_lists'] = $this->get_selected_lists();
225
  $this->modelObj->reset();
226
 
227
 
@@ -363,7 +345,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
363
  $this->notice(sprintf(__('%1$s subscribers have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
364
  else
365
  $this->notice(sprintf(__('%1$s subscriber have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
366
- $this->redirect_after_bulk_action();
367
  }
368
 
369
  /**
@@ -389,23 +371,9 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
389
  $this->notice(sprintf(__('%1$s subscriber have been moved to "%2$s".',WYSIJA), $this->_affected_rows, $result['name']));
390
  }
391
 
392
- $this->redirect_after_bulk_action();
393
  }
394
 
395
- /**
396
- * After performing a bulk action, let's keep the current list filter
397
- */
398
- protected function redirect_after_bulk_action() {
399
- $filter_list = !empty($_REQUEST['wysija']['filter']['filter_list']) ? $_REQUEST['wysija']['filter']['filter_list'] : 0;
400
- if (empty($filter_list)) {// view all lists
401
- $this->redirect('admin.php?page=wysija_subscribers');
402
- } elseif (is_numeric($filter_list)) {
403
- $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$filter_list);
404
- } else {// subscribers in no list
405
- $this->redirect('admin.php?page=wysija_subscribers&filter-list=orphaned');
406
- }
407
- }
408
-
409
  /**
410
  * Bulk action remove subscribers from all existing lists
411
  * @param type $data = array('list_id'=>?)
@@ -418,10 +386,10 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
418
  $helpU->removeFromLists(array(),$_POST['wysija']['user']['user_id']);
419
 
420
  if($this->_affected_rows > 1)
421
- $this->notice(sprintf(__('%1$s subscribers have been removed from all existing lists.',WYSIJA),$this->_affected_rows));
422
  else
423
- $this->notice(sprintf(__('%1$s subscriber have been removed from all existing lists.',WYSIJA),$this->_affected_rows));
424
- $this->redirect_after_bulk_action();
425
  }
426
 
427
  /**
@@ -441,8 +409,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
441
  $this->notice(sprintf(__('%1$s subscribers have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
442
  else
443
  $this->notice(sprintf(__('%1$s subscriber have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
444
-
445
- $this->redirect_after_bulk_action();
446
  }
447
 
448
  /**
@@ -459,7 +426,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
459
  $this->notice(sprintf(__('%1$s subscribers have been confirmed.',WYSIJA),$this->_affected_rows));
460
  else
461
  $this->notice(sprintf(__('%1$s subscriber have been confirmed.',WYSIJA),$this->_affected_rows));
462
- $this->redirect_after_bulk_action();
463
  }
464
 
465
  /**
@@ -974,7 +941,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
974
 
975
  // make sure the total count of subscribers is updated
976
  $helper_user->refreshUsers();
977
- $this->redirect_after_bulk_action();
978
  }
979
 
980
  /**
145
  }
146
 
147
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
 
149
  function defaultDisplay(){
150
  $this->viewShow=$this->action='main';
174
 
175
  // count the rows based on the filters
176
  $filters = $this->modelObj->detect_filters();
 
177
  $select = array( 'COUNT(DISTINCT([wysija]user.user_id)) as total_users', 'MAX([wysija]user.created_at) as max_create_at');
178
  $count_rows = $this->modelObj->get_subscribers( $select, $filters);
179
 
204
 
205
  $this->data['current_counts'] = $this->modelObj->countRows;
206
  $this->data['show_batch_select'] = ($this->modelObj->limit >= $this->modelObj->countRows) ? false : true;
 
207
  $this->modelObj->reset();
208
 
209
 
345
  $this->notice(sprintf(__('%1$s subscribers have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
346
  else
347
  $this->notice(sprintf(__('%1$s subscriber have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
348
+ $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$data['listid']);
349
  }
350
 
351
  /**
371
  $this->notice(sprintf(__('%1$s subscriber have been moved to "%2$s".',WYSIJA), $this->_affected_rows, $result['name']));
372
  }
373
 
374
+ $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$data['listid']);
375
  }
376
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
377
  /**
378
  * Bulk action remove subscribers from all existing lists
379
  * @param type $data = array('list_id'=>?)
386
  $helpU->removeFromLists(array(),$_POST['wysija']['user']['user_id']);
387
 
388
  if($this->_affected_rows > 1)
389
+ $this->notice(sprintf(__('%1$s subscribers have been removed from all exising lists.',WYSIJA),$this->_affected_rows));
390
  else
391
+ $this->notice(sprintf(__('%1$s subscriber have been removed from all exising lists.',WYSIJA),$this->_affected_rows));
392
+ $this->defaultDisplay();
393
  }
394
 
395
  /**
409
  $this->notice(sprintf(__('%1$s subscribers have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
410
  else
411
  $this->notice(sprintf(__('%1$s subscriber have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
412
+ $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$data['listid']);
 
413
  }
414
 
415
  /**
426
  $this->notice(sprintf(__('%1$s subscribers have been confirmed.',WYSIJA),$this->_affected_rows));
427
  else
428
  $this->notice(sprintf(__('%1$s subscriber have been confirmed.',WYSIJA),$this->_affected_rows));
429
+ $this->defaultDisplay();
430
  }
431
 
432
  /**
941
 
942
  // make sure the total count of subscribers is updated
943
  $helper_user->refreshUsers();
944
+ $this->redirect();
945
  }
946
 
947
  /**
controllers/front/stats.php CHANGED
@@ -5,14 +5,6 @@ defined('WYSIJA') or die('Restricted access');
5
  class WYSIJA_control_front_stats extends WYSIJA_control_front{
6
  var $model='' ;
7
  var $view='';
8
-
9
- /**
10
- * Possible characters to be url encoded
11
- * @var array
12
- */
13
- protected $characters_to_encode = array(
14
- '@'
15
- );
16
 
17
  function WYSIJA_control_front_stats(){
18
  parent::WYSIJA_control_front();
@@ -27,30 +19,17 @@ class WYSIJA_control_front_stats extends WYSIJA_control_front{
27
 
28
  $WJ_Stats = new WJ_Stats();
29
  if(!empty($WJ_Stats->clicked_url)){
30
- // clicked stats
31
- $url = $this->encode_url($WJ_Stats->subscriber_clicked());
32
  do_action('mpoet_click_stats', $WJ_Stats);
33
  $this->redirect($url);
34
  }else{
35
- // opened stat
36
  $WJ_Stats->subscriber_opened();
37
  }
38
  }
39
 
40
  return true;
41
  }
42
-
43
- /**
44
- * Encode some special characters in url
45
- * @param string $url
46
- * @return string
47
- */
48
- protected function encode_url($url) {
49
- return str_replace(
50
- $this->characters_to_encode,
51
- array_map('urlencode', $this->characters_to_encode),
52
- $url
53
- );
54
- }
55
-
56
  }
5
  class WYSIJA_control_front_stats extends WYSIJA_control_front{
6
  var $model='' ;
7
  var $view='';
 
 
 
 
 
 
 
 
8
 
9
  function WYSIJA_control_front_stats(){
10
  parent::WYSIJA_control_front();
19
 
20
  $WJ_Stats = new WJ_Stats();
21
  if(!empty($WJ_Stats->clicked_url)){
22
+ //clicked stats
23
+ $url = $WJ_Stats->subscriber_clicked();
24
  do_action('mpoet_click_stats', $WJ_Stats);
25
  $this->redirect($url);
26
  }else{
27
+ //opened stat */
28
  $WJ_Stats->subscriber_opened();
29
  }
30
  }
31
 
32
  return true;
33
  }
34
+
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
core/base.php CHANGED
@@ -19,7 +19,7 @@ class WYSIJA_object{
19
  * Static variable holding core MailPoet's version
20
  * @var array
21
  */
22
- static $version = '2.6.8';
23
 
24
  function WYSIJA_object(){
25
 
@@ -60,11 +60,7 @@ class WYSIJA_object{
60
  global $current_user;
61
  if ( $field ) {
62
  if ( function_exists( 'get_currentuserinfo' ) ) {
63
- // Here is an exception because of one of the weirdest bug
64
- // the idea is to make sure we don't call get_currentuserinfo on the wysija_subscribers page when on a multisite
65
- if ( ! ( isset( $_GET['page'] ) && $_GET['page'] === 'wysija_subscribers' && is_multisite() ) ){
66
- get_currentuserinfo();
67
- }
68
  }
69
  if ( isset( $current_user->{$field} ) ){
70
  return $current_user->{$field};
@@ -99,16 +95,14 @@ class WYSIJA_object{
99
  * @global array $wysija_wpmsg
100
  * @param type $msg
101
  */
102
- function wp_error( $msg ){
103
  global $wysija_wpmsg;
104
 
105
  //add the hook only once
106
- if ( ! $wysija_wpmsg ){
107
- add_action( 'admin_notices', array( $this, 'wp_msgs' ) );
108
- }
109
 
110
  //record msgs
111
- $wysija_wpmsg['error'][] = $msg;
112
  }
113
 
114
  /**
@@ -119,15 +113,13 @@ class WYSIJA_object{
119
  */
120
  function wp_msgs() {
121
  global $wysija_wpmsg;
122
- foreach ( $wysija_wpmsg as $keymsg => $wp2 ){
123
- $msgs = '<div class="' . $keymsg . ' fade">';
124
- foreach ( $wp2 as $mymsg ){
125
- $msgs .= '<p><strong>MailPoet</strong> : ' . $mymsg . '</p>';
126
- }
127
- $msgs .= '</div>';
128
  }
129
 
130
- // This is bad, we should be checking for valid HTML here.
131
  echo $msgs;
132
  }
133
 
@@ -137,12 +129,10 @@ class WYSIJA_object{
137
  * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
138
  * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
139
  */
140
- function error( $msg, $public = false, $global = false ){
141
- $status = 'error';
142
- if ( $global ){
143
- $status = 'g-' . $status;
144
- }
145
- $this->setInfo( $status, $msg, $public );
146
  }
147
 
148
  /**
@@ -151,12 +141,10 @@ class WYSIJA_object{
151
  * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
152
  * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
153
  */
154
- function notice( $msg, $public = true, $global = false ){
155
  $status = 'updated';
156
- if ( $global ){
157
- $status = 'g-' . $status;
158
- }
159
- $this->setInfo( $status, $msg, $public );
160
  }
161
 
162
  /**
@@ -209,17 +197,16 @@ class WYSIJA_object{
209
 
210
 
211
  class WYSIJA_help extends WYSIJA_object{
212
- var $controller = null;
213
 
214
  static $admin_body_class_runner = false;
215
 
216
  function WYSIJA_help(){
217
- add_action( 'widgets_init', array( $this, 'widgets_init' ), 1 );
218
 
219
- // Only load this when ajax is not used
220
- if ( !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
221
- add_action( 'init', array( $this, 'register_scripts' ), 1 );
222
  }
 
223
 
224
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
225
  add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
@@ -228,21 +215,20 @@ class WYSIJA_help extends WYSIJA_object{
228
  function widgets_init() {
229
  //load the widget file
230
  require_once(WYSIJA_WIDGETS.'wysija_nl.php');
231
- register_widget( 'WYSIJA_NL_Widget' );
232
  }
233
 
234
  public function admin_enqueue_scripts(){
235
- if ( WYSIJA_ITF ){
236
- wp_enqueue_script( 'mailpoet-global' );
237
- }
238
- wp_enqueue_style( 'mailpoet-dashicons' );
239
  }
240
 
241
  public function admin_body_class( $body_class_str ){
242
 
243
- if ( WYSIJA_help::$admin_body_class_runner === true ){
244
  return $body_class_str;
245
- }
246
 
247
  WYSIJA_help::$admin_body_class_runner = true;
248
 
@@ -269,42 +255,8 @@ class WYSIJA_help extends WYSIJA_object{
269
  function register_scripts(){
270
  $helper_toolbox = WYSIJA::get('toolbox','helper');
271
  $wp_language_code = $helper_toolbox->get_language_code();
272
- $valid_language = array(
273
- 'ar',
274
- 'ca',
275
- 'cs',
276
- 'cz',
277
- 'da',
278
- 'de',
279
- 'el',
280
- 'es',
281
- 'et',
282
- 'fa',
283
- 'fi',
284
- 'fr',
285
- 'he',
286
- 'hr',
287
- 'hu',
288
- 'id',
289
- 'it',
290
- 'ja',
291
- 'lt',
292
- 'nl',
293
- 'no',
294
- 'pl',
295
- 'pt',
296
- 'pt_BR',
297
- 'ro',
298
- 'ru',
299
- 'sv',
300
- 'tr',
301
- 'vi',
302
- 'zh_CN',
303
- 'zh_TW',
304
- );
305
 
306
-
307
- if ( in_array( $wp_language_code, $valid_language ) ) {
308
  wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-'.$wp_language_code.'.js', array( 'jquery' ),WYSIJA::get_version(),true );
309
  }else{
310
  wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-en.js', array( 'jquery' ),WYSIJA::get_version(),true );
@@ -326,58 +278,43 @@ class WYSIJA_help extends WYSIJA_object{
326
 
327
 
328
  /**
329
- * All the ajax requests are routed through here
330
  */
331
  function ajax() {
332
 
333
- $result_array = array();
334
- if( !$_REQUEST || !isset( $_REQUEST['controller'] ) || !isset( $_REQUEST['task'] ) ){
335
- $result_array = array( 'result' => false );
336
  }else{
337
- $plugin_requesting_ajax = 'wysija-newsletters';
338
-
339
- // we override the plugin resquesting ajax if specified in the request
340
- if( isset( $_REQUEST['wysijaplugin'] ) ){
341
- $plugin_requesting_ajax = $_REQUEST['wysijaplugin'];
342
- }
343
 
344
- // fetching the right controller
345
- $this->controller = WYSIJA::get( $_REQUEST['controller'] , 'controller' , false, $plugin_requesting_ajax );
346
 
347
- // let's make sure the requested task exist
348
- if( method_exists( $this->controller , $_REQUEST['task'] ) ){
349
- $result_array['result'] = $this->controller->$_REQUEST['task']();
350
  }else{
351
- $this->error( 'Method "' . $_REQUEST['task'] . '" doesn\'t exist for controller : "'.$_REQUEST['controller'] );
352
  }
353
  }
354
 
355
- // get the appended messages triggerred during the task execution
356
- $result_array['msgs'] = $this->getMsgs();
357
 
358
- // this header will allow ajax request from the home domain, this can be a lifesaver when domain mapping is on
359
- if(function_exists('home_url')){
360
- header('Access-Control-Allow-Origin: '.home_url());
361
- }
362
 
363
- // let's encode our response in the json format
364
- $json_data = json_encode($result_array);
365
 
366
- // in some case scenarios our client will have jQuery forcing the jsonp so we need to adapt ourselves
367
  if(isset($_REQUEST['callback'])) {
368
- // special header for json-p
369
- header('Content-type: application/javascript');
370
-
371
- $helper_jsonp = WYSIJA::get('jsonp', 'helper');
372
- if($helper_jsonp->isValidCallback($_REQUEST['callback'])) {
373
- print $_REQUEST['callback'] . '('.$json_data.');';
374
- }
375
  } else {
376
- // standard header for unwrapped classic json response
377
- header('Content-type: application/json');
378
- print $json_data;
379
  }
380
- // our ajax response is printed, no need to let WordPress or 3rd party plugin execute more code
381
  die();
382
  }
383
  }
@@ -396,9 +333,9 @@ class WYSIJA extends WYSIJA_object{
396
  * @param boolean $simple
397
  * @return type
398
  */
399
- public static function get_permalink( $pageid, $params = array(), $simple = false ){
400
- $hWPtools = WYSIJA::get( 'wp_tools', 'helper' );
401
- return $hWPtools->get_permalink( $pageid, $params, $simple );
402
  }
403
 
404
  /**
@@ -407,13 +344,11 @@ class WYSIJA extends WYSIJA_object{
407
  * @param type $extendedplugin
408
  * @return boolean
409
  */
410
- public static function load_lang( $extendedplugin = false ){
411
  static $extensionloaded = false;
412
 
413
  //we return the entire array of extensions loaded if non is specified
414
- if ( ! $extendedplugin ) {
415
- return $extensionloaded;
416
- }
417
 
418
  //we only need to load this translation loader once on init
419
  if(!$extensionloaded){
@@ -456,9 +391,10 @@ class WYSIJA extends WYSIJA_object{
456
  //to allow wysija team members to work in english mode if debug is activated
457
  global $current_user;
458
 
459
- if((int)$debugmode > 0 && empty($current_user)) return true;
460
 
461
- if(isset($current_user->data->user_email) && (strpos($current_user->data->user_email, '@mailpoet.com') !== false)) {
 
462
  return true;
463
  }
464
  return false;
@@ -466,28 +402,16 @@ class WYSIJA extends WYSIJA_object{
466
 
467
  /**
468
  * this function exists just to fix the issue with qtranslate :/ (it only fix it partially)
469
- * @param type $extended_plugin
470
  */
471
- public static function load_lang_init($extended_plugin=false){
472
- $model_config = WYSIJA::get('config','model');
473
- $debug_mode = (int)$model_config->getValue('debug_new');
474
-
475
- if($debug_mode === 0 || ($debug_mode > 0 && WYSIJA::is_wysija_admin($debug_mode) === false)) {
476
- $extensions_loaded = WYSIJA::load_lang('get_all');
477
- foreach($extensions_loaded as $extended_plugin => $translation_string){
478
-
479
- // check for translation file overriding from transstring wp-content/languages/wysija-newsletters/wysija-newsletters-en_US.mo
480
- $filename = WP_CONTENT_DIR.DS.'languages'.DS.$extended_plugin.DS.$translation_string.'-'.get_locale().'.mo';
481
-
482
- if( !file_exists($filename) ){
483
- // get the translation file in our local file
484
- $filename = WYSIJA_PLG_DIR.$extended_plugin.DS.'languages'.DS.$translation_string.'-'.get_locale().'.mo';
485
- }
486
-
487
- // load the translation file with WP's load_textdomain
488
- if( file_exists( $filename ) ){
489
- load_textdomain( $translation_string, $filename );
490
- }
491
  }
492
  }
493
  }
19
  * Static variable holding core MailPoet's version
20
  * @var array
21
  */
22
+ static $version = '2.6.5';
23
 
24
  function WYSIJA_object(){
25
 
60
  global $current_user;
61
  if ( $field ) {
62
  if ( function_exists( 'get_currentuserinfo' ) ) {
63
+ get_currentuserinfo();
 
 
 
 
64
  }
65
  if ( isset( $current_user->{$field} ) ){
66
  return $current_user->{$field};
95
  * @global array $wysija_wpmsg
96
  * @param type $msg
97
  */
98
+ function wp_error($msg){
99
  global $wysija_wpmsg;
100
 
101
  //add the hook only once
102
+ if(!$wysija_wpmsg) add_action('admin_notices', array($this,'wp_msgs'));
 
 
103
 
104
  //record msgs
105
+ $wysija_wpmsg['error'][]=$msg;
106
  }
107
 
108
  /**
113
  */
114
  function wp_msgs() {
115
  global $wysija_wpmsg;
116
+ foreach($wysija_wpmsg as $keymsg => $wp2){
117
+ $msgs= '<div class="'.$keymsg.' fade">';
118
+ foreach($wp2 as $mymsg)
119
+ $msgs.= '<p><strong>MailPoet</strong> : '.$mymsg.'</p>';
120
+ $msgs.= '</div>';
 
121
  }
122
 
 
123
  echo $msgs;
124
  }
125
 
129
  * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
130
  * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
131
  */
132
+ function error($msg,$public=false,$global=false){
133
+ $status='error';
134
+ if($global) $status='g-'.$status;
135
+ $this->setInfo($status,$msg,$public);
 
 
136
  }
137
 
138
  /**
141
  * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
142
  * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
143
  */
144
+ function notice($msg,$public=true,$global=false){
145
  $status = 'updated';
146
+ if($global) $status='g-'.$status;
147
+ $this->setInfo($status,$msg,$public);
 
 
148
  }
149
 
150
  /**
197
 
198
 
199
  class WYSIJA_help extends WYSIJA_object{
200
+ var $controller=null;
201
 
202
  static $admin_body_class_runner = false;
203
 
204
  function WYSIJA_help(){
 
205
 
206
+ if(!defined('DOING_AJAX')){
207
+ add_action('init', array($this, 'register_scripts'), 1);
 
208
  }
209
+ add_action('widgets_init', array($this, 'widgets_init'), 1);
210
 
211
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
212
  add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
215
  function widgets_init() {
216
  //load the widget file
217
  require_once(WYSIJA_WIDGETS.'wysija_nl.php');
218
+ register_widget('WYSIJA_NL_Widget');
219
  }
220
 
221
  public function admin_enqueue_scripts(){
222
+ if(WYSIJA_ITF){
223
+ wp_enqueue_script( 'mailpoet-global' );
224
+ }
225
+ wp_enqueue_style('mailpoet-dashicons');
226
  }
227
 
228
  public function admin_body_class( $body_class_str ){
229
 
230
+ if ( WYSIJA_help::$admin_body_class_runner === true )
231
  return $body_class_str;
 
232
 
233
  WYSIJA_help::$admin_body_class_runner = true;
234
 
255
  function register_scripts(){
256
  $helper_toolbox = WYSIJA::get('toolbox','helper');
257
  $wp_language_code = $helper_toolbox->get_language_code();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
 
259
+ if(file_exists(WYSIJA_DIR.'js'.DS.'validate'.DS.'languages'.DS.'jquery.validationEngine-'.$wp_language_code.'.js')){
 
260
  wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-'.$wp_language_code.'.js', array( 'jquery' ),WYSIJA::get_version(),true );
261
  }else{
262
  wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-en.js', array( 'jquery' ),WYSIJA::get_version(),true );
278
 
279
 
280
  /**
281
+ * when doing an ajax request in admin this is the first place we come to
282
  */
283
  function ajax() {
284
 
285
+ $resultArray=array();
286
+ if(!$_REQUEST || !isset($_REQUEST['controller']) || !isset($_REQUEST['task'])){
287
+ $resultArray=array('result'=>false);
288
  }else{
289
+ $wysijapp='wysija-newsletters';
290
+ if(isset($_REQUEST['wysijaplugin'])) $wysijapp=$_REQUEST['wysijaplugin'];
 
 
 
 
291
 
292
+ $this->controller=WYSIJA::get($_REQUEST['controller'],'controller', false, $wysijapp);
 
293
 
294
+ if(method_exists($this->controller, $_REQUEST['task'])){
295
+ $resultArray['result']=$this->controller->$_REQUEST['task']();
 
296
  }else{
297
+ $this->error('Method "'.$_REQUEST['task'].'" doesn\'t exist for controller : "'.$_REQUEST['controller']);
298
  }
299
  }
300
 
301
+ $resultArray['msgs'] = $this->getMsgs();
 
302
 
303
+ //this header will allow ajax request from the home domain, this can be a lifesaver when domain mapping is on
304
+ if(function_exists('home_url')) header('Access-Control-Allow-Origin: '.home_url());
 
 
305
 
306
+ header('Content-type: application/json');
307
+ $jsonData = json_encode($resultArray);
308
 
309
+ //in some case scenario our client will have jquery forcing the jsonp so we need to adapt ourselves
310
  if(isset($_REQUEST['callback'])) {
311
+ $hJSONP = WYSIJA::get('jsonp', 'helper');
312
+ if($hJSONP->isValidCallback($_REQUEST['callback'])) {
313
+ print $_REQUEST['callback'] . '('.$jsonData.');';
314
+ }
 
 
 
315
  } else {
316
+ print $jsonData;
 
 
317
  }
 
318
  die();
319
  }
320
  }
333
  * @param boolean $simple
334
  * @return type
335
  */
336
+ public static function get_permalink($pageid,$params=array(),$simple=false){
337
+ $hWPtools=WYSIJA::get('wp_tools','helper');
338
+ return $hWPtools->get_permalink($pageid,$params,$simple);
339
  }
340
 
341
  /**
344
  * @param type $extendedplugin
345
  * @return boolean
346
  */
347
+ public static function load_lang($extendedplugin=false){
348
  static $extensionloaded = false;
349
 
350
  //we return the entire array of extensions loaded if non is specified
351
+ if(!$extendedplugin) return $extensionloaded;
 
 
352
 
353
  //we only need to load this translation loader once on init
354
  if(!$extensionloaded){
391
  //to allow wysija team members to work in english mode if debug is activated
392
  global $current_user;
393
 
394
+ if((int)$debugmode>0 && empty($current_user)) return true;
395
 
396
+ if(isset($current_user->data->user_email) &&
397
+ (strpos($current_user->data->user_email, '@mailpoet.com') !== false)) {
398
  return true;
399
  }
400
  return false;
402
 
403
  /**
404
  * this function exists just to fix the issue with qtranslate :/ (it only fix it partially)
405
+ * @param type $extendedplugin
406
  */
407
+ public static function load_lang_init($extendedplugin=false){
408
+ $config=WYSIJA::get('config','model');
409
+ $debugmode=(int)$config->getValue('debug_new');
410
+ if($debugmode==0 || ($debugmode>0 && !WYSIJA::is_wysija_admin($debugmode))){
411
+ $extensionloaded=WYSIJA::load_lang('get_all');
412
+ foreach($extensionloaded as $extendedplugin => $transstring){
413
+ $filename=WYSIJA_PLG_DIR.$extendedplugin.DS.'languages'.DS.$transstring.'-'.get_locale().'.mo';
414
+ if(file_exists($filename)) load_textdomain($transstring, $filename);
 
 
 
 
 
 
 
 
 
 
 
 
415
  }
416
  }
417
  }
core/module/module.php CHANGED
@@ -3,19 +3,19 @@
3
  defined('WYSIJA') or die('Restricted access');
4
 
5
  class WYSIJA_module extends WYSIJA_control{
6
-
7
  /**
8
  * ID of module
9
  * @var string
10
  */
11
  protected $name;
12
-
13
  /**
14
  * view class of module
15
  * @var string
16
  */
17
  public $view;
18
-
19
  /**
20
  * instance of view class of module
21
  * @var string
@@ -27,74 +27,74 @@ class WYSIJA_module extends WYSIJA_control{
27
  * action/view of a hook
28
  * @var string
29
  */
30
-
31
  protected $view_show;
32
-
33
  /**
34
  * data which view class will pull from
35
  * @var array
36
  */
37
  protected $data;
38
-
39
  protected $extended_plugin='wysija-newsletters';
40
-
41
 
42
 
43
  /**
44
  * Define hook name and list of modules of each hook
45
  * @var Array
46
  * @todo: implement hook management which allows to manage hooks from admin side
47
- */
48
-
49
  protected $is_premium = false;
50
-
51
  public static $hooks = array(
52
  'hook_stats' => array(
53
  // 'stats_newsletters_in_time',
54
- 'stats_top_newsletters',
55
  'stats_top_subscribers',
56
  'stats_top_links',
57
  'stats_new_subscribers',
58
  'stats_subscriptions',
59
  'stats_top_domains'
60
  ),
61
-
62
  // the left block in the page "subscriber detail"
63
  'hook_subscriber_left' => array(
64
  ),
65
-
66
  // the righ block in the page "subscriber detail"
67
  'hook_subscriber_right' => array(
68
  'stats_subscriber'
69
- ),
70
  'hook_subscriber_bottom' => array(
71
  'stats_subscribers_std',
72
  // 'stats_newsletters_in_time' // not in use
73
  ),
74
  // top of newsletter (viewstats) page
75
  'hook_newsletter_top' => array(
76
-
77
  'stats_newsletter_std',
78
  'stats_newsletter',
79
  // 'stats_reportcards_std'
80
  ),
81
-
82
  // Newsletters >> Newsletter detail: bottom block
83
  'hook_newsletter_bottom' => array(
84
  //'stats_newsletter_std',
85
  // 'stats_newsletters_in_time'
86
  ),
87
-
88
  // the block "super advanced" in Settings >> Advanced tab
89
  'hook_settings_super_advanced' => array(
90
  'archive_std'
91
  ),
92
-
93
  // event: before saving settings (Admin)
94
  'hook_settings_before_save' => array(
95
  'archive_std'
96
  )
97
- );
98
  /**
99
  * Constructor
100
  * This is neccessary to override default action of WYSIJA_control::WYSIJA_control(),
@@ -110,16 +110,16 @@ class WYSIJA_module extends WYSIJA_control{
110
  if (!empty($this->view_obj) && !empty($this->model_obj)){
111
  $this->view_obj->model = $this->model_obj;
112
  }
113
-
114
  $this->data['module_name'] = $this->name;
115
-
116
-
117
  $model_config=WYSIJA::get('config','model');
118
  if($model_config->getValue('premium_key'))
119
  $this->is_premium = true;
120
  $this->data['is_premium'] = $this->is_premium;
121
  }
122
-
123
  /**
124
  * get name of module
125
  * @return string
@@ -127,7 +127,7 @@ class WYSIJA_module extends WYSIJA_control{
127
  public function get_name(){
128
  return $this->name;
129
  }
130
-
131
  /**
132
  * Get unique link to the module and hook. This link will be displayed as an independent page and actually it renders [wysijap] postype
133
  * @param string $module_name
@@ -147,7 +147,7 @@ class WYSIJA_module extends WYSIJA_control{
147
  ));
148
  return WYSIJA::get_permalink($model_config->getValue('confirm_email_link'),$params);
149
  }
150
-
151
  /**
152
  * Return Hooks List
153
  * @param string $hook_name name of hook
@@ -161,7 +161,7 @@ class WYSIJA_module extends WYSIJA_control{
161
  return isset($modules[$module_name]) ? array($modules[$module_name]) : array();
162
  return $modules;
163
  }
164
-
165
  /**
166
  * Get all registered hooks and modules
167
  * @return Array
@@ -175,9 +175,9 @@ class WYSIJA_module extends WYSIJA_control{
175
  * @param string $hook_name
176
  * @param string $params
177
  * @param string $extended_plugin
178
- *
179
- * @todo Performance factor:
180
- * We are calling the same method for free / Premium version.
181
  * Some modules don't exist at free side.
182
  * Some modules don't exist at Premium side.
183
  * This fact leads to an other fact: we have to check_exist() in both cases.
@@ -190,23 +190,23 @@ class WYSIJA_module extends WYSIJA_control{
190
  foreach (self::$hooks[$hook_name] as $module_name){
191
  $module = WYSIJA::get($module_name,'module',false,$extended_plugin);
192
  if(!empty($module) && method_exists($module, $hook_name))
193
- $hook_output .= $module->$hook_name($params);
194
  }
195
  }
196
  return $hook_output;
197
  }
198
-
199
  /**
200
  * get an instance of a module class
201
  * @param string $module_name module to be loaded
202
  * @param type $extended_plugin : used only when calling the url from a different plugin it is used watch those files :
203
  * -core/controller.php line 21, 23 ,24
204
  * @return an instance of WYSIJA_module or its derived classes
205
- */
206
  public static function get_instance_by_name($module_name,$extended_plugin='wysija-newsletters'){
207
  return WYSIJA::get($module_name,'module',false, $extended_plugin);
208
  }
209
-
210
  /**
211
  * Render a view/action
212
  * @return string
@@ -226,22 +226,22 @@ class WYSIJA_module extends WYSIJA_control{
226
  }
227
  }
228
  }
229
-
230
  /**
231
  * initialize WYSIJA_view instance
232
  * @return WYSIJA_view
233
  */
234
  protected function get_view_obj(){
235
  require_once(WYSIJA_CORE.'view.php');
236
- require_once(WYSIJA_VIEWS.WYSIJA_SIDE.'.php');
237
  if (empty($this->view_obj)){
238
-
239
- $view_dir=WYSIJA_PLG_DIR.$this->extended_plugin.DS.'modules'.DS.$this->name; // quickfix, @todo
240
  $class_path=$view_dir.DS.$this->view.'.php';// @todo: check exists
241
  $class_name = strtoupper('wysija').'_module_view_'.$this->view;
242
  require_once(WYSIJA_CORE.'view.php');
243
  require_once($class_path);
244
- $this->view_obj = new $class_name();
245
  }
246
  return $this->view_obj;
247
  }
3
  defined('WYSIJA') or die('Restricted access');
4
 
5
  class WYSIJA_module extends WYSIJA_control{
6
+
7
  /**
8
  * ID of module
9
  * @var string
10
  */
11
  protected $name;
12
+
13
  /**
14
  * view class of module
15
  * @var string
16
  */
17
  public $view;
18
+
19
  /**
20
  * instance of view class of module
21
  * @var string
27
  * action/view of a hook
28
  * @var string
29
  */
30
+
31
  protected $view_show;
32
+
33
  /**
34
  * data which view class will pull from
35
  * @var array
36
  */
37
  protected $data;
38
+
39
  protected $extended_plugin='wysija-newsletters';
40
+
41
 
42
 
43
  /**
44
  * Define hook name and list of modules of each hook
45
  * @var Array
46
  * @todo: implement hook management which allows to manage hooks from admin side
47
+ */
48
+
49
  protected $is_premium = false;
50
+
51
  public static $hooks = array(
52
  'hook_stats' => array(
53
  // 'stats_newsletters_in_time',
54
+ 'stats_top_newsletters',
55
  'stats_top_subscribers',
56
  'stats_top_links',
57
  'stats_new_subscribers',
58
  'stats_subscriptions',
59
  'stats_top_domains'
60
  ),
61
+
62
  // the left block in the page "subscriber detail"
63
  'hook_subscriber_left' => array(
64
  ),
65
+
66
  // the righ block in the page "subscriber detail"
67
  'hook_subscriber_right' => array(
68
  'stats_subscriber'
69
+ ),
70
  'hook_subscriber_bottom' => array(
71
  'stats_subscribers_std',
72
  // 'stats_newsletters_in_time' // not in use
73
  ),
74
  // top of newsletter (viewstats) page
75
  'hook_newsletter_top' => array(
76
+
77
  'stats_newsletter_std',
78
  'stats_newsletter',
79
  // 'stats_reportcards_std'
80
  ),
81
+
82
  // Newsletters >> Newsletter detail: bottom block
83
  'hook_newsletter_bottom' => array(
84
  //'stats_newsletter_std',
85
  // 'stats_newsletters_in_time'
86
  ),
87
+
88
  // the block "super advanced" in Settings >> Advanced tab
89
  'hook_settings_super_advanced' => array(
90
  'archive_std'
91
  ),
92
+
93
  // event: before saving settings (Admin)
94
  'hook_settings_before_save' => array(
95
  'archive_std'
96
  )
97
+ );
98
  /**
99
  * Constructor
100
  * This is neccessary to override default action of WYSIJA_control::WYSIJA_control(),
110
  if (!empty($this->view_obj) && !empty($this->model_obj)){
111
  $this->view_obj->model = $this->model_obj;
112
  }
113
+
114
  $this->data['module_name'] = $this->name;
115
+
116
+
117
  $model_config=WYSIJA::get('config','model');
118
  if($model_config->getValue('premium_key'))
119
  $this->is_premium = true;
120
  $this->data['is_premium'] = $this->is_premium;
121
  }
122
+
123
  /**
124
  * get name of module
125
  * @return string
127
  public function get_name(){
128
  return $this->name;
129
  }
130
+
131
  /**
132
  * Get unique link to the module and hook. This link will be displayed as an independent page and actually it renders [wysijap] postype
133
  * @param string $module_name
147
  ));
148
  return WYSIJA::get_permalink($model_config->getValue('confirm_email_link'),$params);
149
  }
150
+
151
  /**
152
  * Return Hooks List
153
  * @param string $hook_name name of hook
161
  return isset($modules[$module_name]) ? array($modules[$module_name]) : array();
162
  return $modules;
163
  }
164
+
165
  /**
166
  * Get all registered hooks and modules
167
  * @return Array
175
  * @param string $hook_name
176
  * @param string $params
177
  * @param string $extended_plugin
178
+ *
179
+ * @todo Performance factor:
180
+ * We are calling the same method for free / Premium version.
181
  * Some modules don't exist at free side.
182
  * Some modules don't exist at Premium side.
183
  * This fact leads to an other fact: we have to check_exist() in both cases.
190
  foreach (self::$hooks[$hook_name] as $module_name){
191
  $module = WYSIJA::get($module_name,'module',false,$extended_plugin);
192
  if(!empty($module) && method_exists($module, $hook_name))
193
+ $hook_output .= $module->$hook_name($params);
194
  }
195
  }
196
  return $hook_output;
197
  }
198
+
199
  /**
200
  * get an instance of a module class
201
  * @param string $module_name module to be loaded
202
  * @param type $extended_plugin : used only when calling the url from a different plugin it is used watch those files :
203
  * -core/controller.php line 21, 23 ,24
204
  * @return an instance of WYSIJA_module or its derived classes
205
+ */
206
  public static function get_instance_by_name($module_name,$extended_plugin='wysija-newsletters'){
207
  return WYSIJA::get($module_name,'module',false, $extended_plugin);
208
  }
209
+
210
  /**
211
  * Render a view/action
212
  * @return string
226
  }
227
  }
228
  }
229
+
230
  /**
231
  * initialize WYSIJA_view instance
232
  * @return WYSIJA_view
233
  */
234
  protected function get_view_obj(){
235
  require_once(WYSIJA_CORE.'view.php');
236
+ require_once(WYSIJA_VIEWS.WYSIJA_SIDE.'.php');
237
  if (empty($this->view_obj)){
238
+
239
+ $view_dir=WYSIJA_PLG_DIR.$this->extended_plugin.DS.'modules'.DS.$this->name; // quickfix, @todo
240
  $class_path=$view_dir.DS.$this->view.'.php';// @todo: check exists
241
  $class_name = strtoupper('wysija').'_module_view_'.$this->view;
242
  require_once(WYSIJA_CORE.'view.php');
243
  require_once($class_path);
244
+ $this->view_obj = new $class_name();
245
  }
246
  return $this->view_obj;
247
  }
core/view.php CHANGED
@@ -193,13 +193,7 @@ class WYSIJA_view extends WYSIJA_object{
193
 
194
  if(count($messages)>0){
195
  foreach($messages as $msg){
196
- // check type of msg variable
197
- if(is_array($msg)) {
198
- $msg = var_export($msg, true);
199
- }
200
-
201
- // display message
202
- $html.='<li>'.$msg.'</li>';
203
  }
204
  }
205
 
193
 
194
  if(count($messages)>0){
195
  foreach($messages as $msg){
196
+ $html.='<li>'.$msg.'</li>';
 
 
 
 
 
 
197
  }
198
  }
199
 
css/admin-campaigns-dividers.css CHANGED
@@ -1 +1 @@
1
- .wysija_popup_content.divider{width:620px}.dividers ul{height:350px;width:620px;overflow:auto;margin:0 0 20px 0}.dividers li{text-align:center;padding:5px 2px}.dividers li a{padding:2px;display:block}.dividers li a.selected{padding:0;border:2px solid #DD561A}.dividers li img{vertical-align:middle}
1
+ .wysija_popup_content.divider{width:620px}.dividers ul{height:400px;width:620px;overflow:auto;margin:0 0 20px 0}.dividers li{text-align:center;padding:5px 2px}.dividers li a{padding:2px;display:block}.dividers li a.selected{padding:0;border:2px solid #DD561A}.dividers li img{vertical-align:middle}
css/admin-campaigns-medias.css CHANGED
@@ -1 +1 @@
1
- .swfupload{vertical-align:middle}ul#sidemenu{bottom:-1px;float:none !important;font-weight:normal;left:0;margin:0 5px;overflow:hidden;float:none !important}.wysija-thumb{float:left;height:150px;margin:10px;width:150px;position:relative;border:2px dashed transparent;filter:alpha(opacity=60);-moz-opacity:0.6;opacity:0.6;margin:8px}.wysija-thumb:hover,.wysija-thumb.selected:hover{border-color:#000;border-style:dashed}.wysija-thumb.selected{border-color:#4a5b04;border-style:solid;filter:alpha(opacity=100);-moz-opacity:1;opacity:1}.wysija-thumb img{cursor:pointer;max-height:150px;max-width:150px}.wysija-thumb span.delete{background:url("../img/controls/icons.png") no-repeat scroll -100px 0 transparent;cursor:pointer;height:20px;text-indent:-9999px;display:block;width:20px}.wysija-thumb span.delete-wrap{background-color:#DFDFDF;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);border:1px solid #CCCCCC;border-radius:2px 2px 2px 2px;box-shadow:0 1px 0 rgba(0,0,0,0.15),0 0 2px 1px #fff inset;height:20px;position:absolute;right:2px;top:2px;margin:5px 3px 0 0;width:20px;display:none}.wysija-thumb span.thumb_url,.wysija-thumb span.url,.wysija-thumb span.width,.wysija-thumb span.height,.wysija-thumb span.identifier{display:none}.wysija-thumb:hover span.delete-wrap{display:block}.wysija-thumb span.delete:hover{background-position:-100px -20px}.clear{clear:both}.tablenav{margin-right:20px}#media-items{overflow:auto}.media-wp-upload #media-items{display:none}.media-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}.media-wp-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}#media-items em{margin:0 0 0 20px}#media-items,.ml-submit{float:left}.ml-submit{margin-top:15px;margin-left:15px}#loader{left:50%;position:relative;top:50%}#overlay{background-color:#FFFFFF;height:100%;opacity:0.8;position:absolute;width:100%;z-index:999;display:none}#flash-upload-ui{padding:10px 25px}.after-file-upload{padding:0 25px}.after-file-upload,.upload-flash-bypass,.howto{display:none}.wysija-thumb .slidetoggle,.wysija-thumb .toggle{display:none}.max-upload-size{margin:10px 0;display:block}
1
+ .swfupload{vertical-align:middle}ul#sidemenu{bottom:-1px;float:none !important;font-weight:normal;left:0;margin:0 5px;overflow:hidden;float:none !important}.wysija-thumb{float:left;height:150px;margin:10px;width:150px;position:relative;border:2px dashed transparent;filter:alpha(opacity=60);-moz-opacity:0.6;opacity:0.6;margin:8px}.wysija-thumb:hover,.wysija-thumb.selected:hover{border-color:#000;border-style:dashed}.wysija-thumb.selected{border-color:#4a5b04;border-style:solid;filter:alpha(opacity=100);-moz-opacity:1;opacity:1}.wysija-thumb img{max-height:150px;max-width:150px}.wysija-thumb span.delete{background:url("../img/controls/icons.png") no-repeat scroll -100px 0 transparent;cursor:pointer;height:20px;text-indent:-9999px;display:block;width:20px}.wysija-thumb span.delete-wrap{background-color:#DFDFDF;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);border:1px solid #CCCCCC;border-radius:2px 2px 2px 2px;box-shadow:0 1px 0 rgba(0,0,0,0.15),0 0 2px 1px #fff inset;height:20px;position:absolute;right:2px;top:2px;margin:5px 3px 0 0;width:20px;display:none}.wysija-thumb span.thumb_url,.wysija-thumb span.url,.wysija-thumb span.width,.wysija-thumb span.height,.wysija-thumb span.identifier{display:none}.wysija-thumb:hover span.delete-wrap{display:block}.wysija-thumb span.delete:hover{background-position:-100px -20px}.clear{clear:both}.tablenav{margin-right:20px}#media-items{overflow:auto}.media-wp-upload #media-items{display:none}.media-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}.media-wp-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}#media-items em{margin:0 0 0 20px}#media-items,.ml-submit{float:left}.ml-submit{margin-top:15px;margin-left:15px}#loader{left:50%;position:relative;top:50%}#overlay{background-color:#FFFFFF;height:100%;opacity:0.8;position:absolute;width:100%;z-index:999;display:none}#flash-upload-ui{padding:10px 25px}.after-file-upload{padding:0 25px}.after-file-upload,.upload-flash-bypass,.howto{display:none}.wysija-thumb .slidetoggle,.wysija-thumb .toggle{display:none}.max-upload-size{margin:10px 0;display:block}
css/admin-campaigns.css CHANGED
@@ -1 +1 @@
1
- #wysija-app{padding-top:10px}.icon32{margin-top:0px !important}#posts-filter{clear:both}#wysija-app h2{display:inline}#icon-edit-news{background:url(../img/mail-big.png) no-repeat scroll 0 5px transparent}#TB_window{display:block}.moredetails{display:none}.sending,.scheduled{background-color:#d5f0e6}.autonl.sending{background-color:#D7E6F2}#wysija-campaign .listmissing{background-color:#EFD5D5}#preview-receiver{width:230px;vertical-align:middle;margin:0 5px 0 0}.ml-submit{margin:15px 15px 0 15px}.automatic-nl{display:none}#titlediv .titlebox{font-size:1.7em;background-color:#FFFFFF;border-color:#CCCCCC;line-height:100%;outline:medium none;padding:3px 8px;width:100%}label .description{cursor:auto}.about-wrap .feature-section.three-col div{float:left;width:28%}#socials-block div{float:none;margin:5px 5px 2px 0;width:100%}.progress_bar{padding-bottom:10px}.progress_bar .bar{display:block;width:100%;height:22px;float:left;margin-right:10px;background:#eef6fc;border:1px solid #bbbbbb;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;line-height:22px;position:relative}.progress_bar .progress{display:block;background:#69b1e9;height:100%}.progress_bar .percent{height:100%;position:absolute;top:0px;left:10px}#wysija-badge{position:absolute;top:0;right:0;color:#fff;text-shadow:0 1px 0 rgba(0,0,0,0.3);padding-top:91px;height:50px;width:173px;font-weight:bold;font-size:14px;text-align:center;margin:0 -5px;background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/wysija-badge.png") no-repeat}#review-follow{position:relative;height:177px}#review-follow div{float:left;top:0}#review-follow .review-left{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/save-the-kitten.jpg") no-repeat;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef;padding-right:10px}#review-follow h4{margin:0 !important}#review-follow .review-left.small{width:450px}#review-follow .review-left.medium{width:490px}#review-follow .review-left.large{width:540px}#review-follow .small .description{margin-top:24px}#review-follow .medium .description{margin-top:20px}#review-follow .large .description{margin-top:18px}#review-follow .review-left p{margin-left:20px}#review-follow .review-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_middle.jpg") no-repeat scroll -30px 0 #f8f8f8;border-bottom:1px solid #EFEFEF;border-top:1px solid #EFEFEF;height:175px;width:24px}#review-follow #mailpoet-subscribe{margin-left:0px;margin-top:10px}#review-follow .subscribe-middle{width:220px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .socials{margin-left:30px}#review-follow .follow-left{width:220px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .follow-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_right.jpg") no-repeat;width:100px;height:175px}#review-follow .follow-right38{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow-right-38.jpg") no-repeat;width:100px;height:175px}#review-follow .review-left .description{margin-left:146px}#review-follow .link-cat-review{height:140px;left:20px;position:absolute;top:21px;width:120px;outline:medium none}a.ctaupdate,span.ctaupdate{font-size:12px}.pds-links,.pds-totalvotes-outer{display:none !important}#polldaddy_embed_0{width:680px;margin-left:-30px}span.local_time{margin-left:10px}#hook_newsletter_top .hook-column{width:50%}.card-title{font-weight:bold}.report-card{padding-top:10px}.googletrackingcode .action_buttons{padding-left:44px;padding-top:5px}.googletrackingcode span{font-weight:bold}.mpoet-page h1{font-size:34px}.mpoet-page h1,.mpoet-page h2,.mpoet-page h3,.mpoet-page h4{color:#626262;font-weight:bold}.mpoet-page h1 span.version{color:#5e869b}
1
+ #wysija-app{padding-top:10px}.icon32{margin-top:0px !important}#posts-filter{clear:both}#wysija-app h2{display:inline}#icon-edit-news{background:url(../img/mail-big.png) no-repeat scroll 0 5px transparent}#TB_window{display:block}.moredetails{display:none}.sending,.scheduled{background-color:#d5f0e6}.autonl.sending{background-color:#D7E6F2}#wysija-campaign .listmissing{background-color:#EFD5D5}#preview-receiver{width:230px;vertical-align:middle;margin:0 5px 0 0}.ml-submit{margin:15px 15px 0 15px}.automatic-nl{display:none}#titlediv .titlebox{font-size:1.7em;background-color:#FFFFFF;border-color:#CCCCCC;line-height:100%;outline:medium none;padding:3px 8px;width:100%}label .description{cursor:auto}.about-wrap .feature-section.three-col div{float:left;width:28%}#socials-block div{float:none;margin:5px 5px 2px 0;width:100%}.progress_bar{padding-bottom:10px}.progress_bar .bar{display:block;width:100%;height:22px;float:left;margin-right:10px;background:#eef6fc;border:1px solid #bbbbbb;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;line-height:22px;position:relative}.progress_bar .progress{display:block;background:#69b1e9;height:100%}.progress_bar .percent{height:100%;position:absolute;top:0px;left:10px}#wysija-badge{position:absolute;top:0;right:0;color:#fff;text-shadow:0 1px 0 rgba(0,0,0,0.3);padding-top:91px;height:50px;width:173px;font-weight:bold;font-size:14px;text-align:center;margin:0 -5px;background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/wysija-badge.png") no-repeat}#review-follow{position:relative;height:177px}#review-follow div{float:left;top:0}#review-follow .review-left{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/save-the-kitten.jpg") no-repeat;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef;padding-right:10px}#review-follow h4{margin:0 !important}#review-follow .review-left.small{width:450px}#review-follow .review-left.medium{width:490px}#review-follow .review-left.large{width:540px}#review-follow .small .description{margin-top:24px}#review-follow .medium .description{margin-top:20px}#review-follow .large .description{margin-top:18px}#review-follow .review-left p{margin-left:20px}#review-follow .review-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_middle.jpg") no-repeat;width:62px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .subscribe-middle{width:220px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .socials{margin-left:30px}#review-follow .follow-left{width:220px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .follow-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_right.jpg") no-repeat;width:100px;height:175px}#review-follow .follow-right38{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow-right-38.jpg") no-repeat;width:100px;height:175px}#review-follow .review-left .description{margin-left:146px}#review-follow .link-cat-review{height:140px;left:20px;position:absolute;top:21px;width:120px;outline:medium none}a.ctaupdate,span.ctaupdate{font-size:12px}.pds-links,.pds-totalvotes-outer{display:none !important}#polldaddy_embed_0{width:680px;margin-left:-30px}span.local_time{margin-left:10px}#hook_newsletter_top .hook-column{width:50%}.card-title{font-weight:bold}.report-card{padding-top:10px}.googletrackingcode .action_buttons{padding-left:44px;padding-top:5px}.googletrackingcode span{font-weight:bold}.mpoet-page h1{font-size:34px}.mpoet-page h1,.mpoet-page h2,.mpoet-page h3,.mpoet-page h4{color:#626262;font-family:"Arial","Open Sans",sans-serif;font-weight:bold}.mpoet-page h1 span.version{color:#5e869b}
css/admin-config.css CHANGED
@@ -1 +1 @@
1
- tr.title_row>td{padding-left:0}#wysija-tabs a{font-size:14px}#wysija-tabs a:focus{outline:0 none}#wysija-settings .premium_activated{color:#0074A2;font-size:1.2em;padding:15px 0 20px 0}#wysija-settings .premium_activated i{font-size:1.5em;margin:0 6px 3px 0;vertical-align:bottom}p.submit{padding:1em 1.4em 1em 0}span.title{font-size:16px;margin:0;color:#000}.mailpoet-frequency_inner_texting{padding:0 10px}.mailpoet-frequency_warning{margin-top:10px}#wysija-settings input[type="checkbox"],#wysija-settings input[type="radio"]{margin-right:6px;vertical-align:baseline}#wysija-settings label input[type="checkbox"],#cron_page_hit_trigger-1{margin-left:0}#wysija-settings .button-secondary{margin-left:6px}#wysija-settings .form-table th{width:300px}#wysija-settings .form-table th.row{border:1px solid #AAAAAA}#warning-msg-frequency{background-color:#FFFFE0;border-color:#E6DB55}#warning-msg-frequency{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}#warning-msg-frequency ul{margin:0}#wysija-settings .form-table th.rolestitle{padding:10px 0 10px 10px;text-align:left;vertical-align:middle;width:220px}#wysija-settings .form-table th.rolestable{padding:3px;text-align:center;vertical-align:middle;width:110px;word-wrap:break-word}#wysija-settings .form-table td.rolestable{padding:6px 0;text-align:center}#wysija-settings .form-table td.title{padding:10px 0 10px 10px;text-align:left;vertical-align:middle}#wysija-settings .form-table td.title p{margin:0}#wysija-settings .form-table td{vertical-align:top}#wysija-settings #bounce .intro{margin:10px 0 20px 10px}#wysija-settings #bounce #bounce-process-auto,#wysija-settings #bounce #bounce-connector{margin-left:0 !important}#wysija-settings #sendingmethod .methods{border-bottom:1px solid #000}#wysija-settings #sendingmethod .choice-sending-method-site{border-top:1px solid #cccccc}#wysija-settings #sendingmethod .choice-sending-method-site th,#wysija-settings #sendingmethod .choice-sending-method-site td{padding-top:18px}label.dkim{margin-right:20px}.cronleft,.cronright{float:left}.cronleft{width:20px;margin-right:10px}#cron_manual_linkname p{margin:0}.labelcheck{float:left;margin-right:15px}.checkbox_optin_label{margin:6px 6px 0 0;float:left}.checkbox_optin_value{float:left;width:500px}#smtp-rest-label{display:none;margin-left:10px}#wysija-settings #multisite #form-ms-config th{width:455px}#wysija-settings #multisite #ms-sendingmethod th{width:300px}#wysija-settings #multisite .intro{margin:0 0 0 10px}#wysija-settings #sendingmethod .methods input,#wysija-settings #multisite .methods input{margin:0 5px 0 0;float:left}#wysija-settings #sendingmethod .methods h3,#wysija-settings #multisite .methods p.title{float:left;margin:0 !important}#wysija-settings #multisite .choice-one-for-all{display:none}#wysija-settings a.view_all{font-style:italic}#wysija-settings .cronright label{display:block;margin-bottom:10px}#wysija-settings .cronright label span{margin-left:36px}#wysija-settings .capabilities_form{width:400px}span.icon{display:block;height:20px;width:20px;cursor:pointer}.geeky-option a,.geeky-option span{float:left}.show-more-geeky-options span{background:url(../img/controls/icons.png) no-repeat -200px 0}.show-more-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.hide-geeky-options span{background:url(../img/controls/icons.png) no-repeat -220px 0}.hide-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}@-webkit-keyframes opacity{0%{opacity:1}100%{opacity:0}}@-moz-keyframes opacity{0%{opacity:1}100%{opacity:0}}.wysija-button-loading{text-align:center;margin:100px 0 0 0}.wysija-button-loading span{-webkit-animation-name:opacity;-webkit-animation-duration:1s;-webkit-animation-iteration-count:infinite;-moz-animation-name:opacity;-moz-animation-duration:1s;-moz-animation-iteration-count:infinite}.wysija-button-loading span:nth-child(2){-webkit-animation-delay:100ms;-moz-animation-delay:100ms}.wysija-button-loading span:nth-child(3){-webkit-animation-delay:300ms;-moz-animation-delay:300ms}.links-page{display:none;margin-left:10px}.new_form{margin:16px 0}.new_form a{font-size:16px !important}
1
+ tr.title_row>td{padding-left:0}#wysija-tabs a{font-size:14px}#wysija-tabs a.tab-premium{background-color:#d7e6f2;font-weight:bold}p.submit{padding:1em 1.4em 1em 0}span.title{font-size:16px;margin:0;color:#000}.mailpoet-frequency_inner_texting{padding:0 10px}.mailpoet-frequency_warning{margin-top:10px}#wysija-settings input[type="checkbox"],#wysija-settings input[type="radio"]{margin-right:6px;vertical-align:baseline}#wysija-settings label input[type="checkbox"],#cron_page_hit_trigger-1{margin-left:0}#wysija-settings .button-secondary{margin-left:6px}#wysija-settings .form-table th{width:300px}#wysija-settings .form-table th.row{border:1px solid #AAAAAA}#warning-msg-frequency{background-color:#FFFFE0;border-color:#E6DB55}#warning-msg-frequency{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}#warning-msg-frequency ul{margin:0}#wysija-settings .form-table th.rolestitle{padding:10px 0 10px 10px;text-align:left;vertical-align:middle;width:220px}#wysija-settings .form-table th.rolestable{padding:3px;text-align:center;vertical-align:middle;width:110px;word-wrap:break-word}#wysija-settings .form-table td.rolestable{padding:6px 0;text-align:center}#wysija-settings .form-table td.title{padding:10px 0 10px 10px;text-align:left;vertical-align:middle}#wysija-settings .form-table td.title p{margin:0}#wysija-settings .form-table td{vertical-align:top}#wysija-settings #bounce .intro{margin:10px 0 20px 10px}#wysija-settings #bounce #bounce-process-auto,#wysija-settings #bounce #bounce-connector{margin-left:0 !important}#wysija-settings #sendingmethod .methods{border-bottom:1px solid #000}#wysija-settings #sendingmethod .choice-sending-method-site{border-top:1px solid #cccccc}#wysija-settings #sendingmethod .choice-sending-method-site th,#wysija-settings #sendingmethod .choice-sending-method-site td{padding-top:18px}label.dkim{margin-right:20px}.cronleft,.cronright{float:left}.cronleft{width:20px;margin-right:10px}#cron_manual_linkname p{margin:0}.labelcheck{float:left;margin-right:15px}.checkbox_optin_label{margin:6px 6px 0 0;float:left}.checkbox_optin_value{float:left;width:500px}#smtp-rest-label{display:none;margin-left:10px}#wysija-settings #multisite #form-ms-config th{width:455px}#wysija-settings #multisite #ms-sendingmethod th{width:300px}#wysija-settings #multisite .intro{margin:0 0 0 10px}#wysija-settings #sendingmethod .methods input,#wysija-settings #multisite .methods input{margin:0 5px 0 0;float:left}#wysija-settings #sendingmethod .methods h3,#wysija-settings #multisite .methods p.title{float:left;margin:0 !important}#wysija-settings #multisite .choice-one-for-all{display:none}#wysija-settings a.view_all{font-style:italic}#wysija-settings .cronright label{display:block;margin-bottom:10px}#wysija-settings .cronright label span{margin-left:36px}#wysija-settings .capabilities_form{width:400px}span.icon{display:block;height:20px;width:20px;cursor:pointer}.geeky-option a,.geeky-option span{float:left}.show-more-geeky-options span{background:url(../img/controls/icons.png) no-repeat -200px 0}.show-more-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.hide-geeky-options span{background:url(../img/controls/icons.png) no-repeat -220px 0}.hide-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}@-webkit-keyframes opacity{0%{opacity:1}100%{opacity:0}}@-moz-keyframes opacity{0%{opacity:1}100%{opacity:0}}.wysija-button-loading{text-align:center;margin:100px 0 0 0}.wysija-button-loading span{-webkit-animation-name:opacity;-webkit-animation-duration:1s;-webkit-animation-iteration-count:infinite;-moz-animation-name:opacity;-moz-animation-duration:1s;-moz-animation-iteration-count:infinite}.wysija-button-loading span:nth-child(2){-webkit-animation-delay:100ms;-moz-animation-delay:100ms}.wysija-button-loading span:nth-child(3){-webkit-animation-delay:300ms;-moz-animation-delay:300ms}.links-page{display:none;margin-left:10px}.new_form{margin:16px 0}.new_form a{font-size:16px !important}
css/admin-premium.css CHANGED
@@ -1 +1 @@
1
- #mainmenu .premium{background:url(../img/ui-bg_glass_premium_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #a9abc3}#mainmenu .premium:hover{background:url(../img/ui-bg_glass_premium_hover_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #9c9eb2}#mainmenu .premium a{font-weight:700;color:#5d5e76}#mainmenu .premium a:hover{color:#4b4d69}#mainmenu .ui-state-active{background:white !important;border:1px solid #d8d9e6}.mpoet-page h2{color:#4b4d69;font-size:1.8em;font-weight:200;line-height:1.2em;margin:0}.wysija-premium-wrapper{margin:0 0 20px 0}.wysija-premium-actions{position:fixed;width:1028px;bottom:0;background-color:#eee;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;-webkit-border-top-left-radius:7px;-webkit-border-top-right-radius:7px;-moz-border-radius-topleft:7px;-moz-border-radius-topright:7px;border-top-left-radius:7px;border-top-right-radius:7px;z-index:999;padding:10px 10px 0}.wysija-premium-actions .licence{margin-right:15px}.wysija-premium-actions p{margin:0px 0px 10px 0;text-align:center}.wysija-premium-actions span.conditions{font-size:12px;margin-right:15px}.wysija-premium-actions .button-primary.wysija-premium-activate{float:none}.wysija-premium-actions-kim{position:fixed;width:1066px;bottom:0;background-color:#eee;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;z-index:999;margin-left:-30px;padding:10px 10px;text-align:center}.mpoet-page .feature-section.three-col>div{width:29%}.mpoet-page .three-col img{margin:0.5em 0;max-width:100%}a.wysija-premium-purchase{background-color:#FFB30D !important;background:-webkit-gradient(linear, left top, left bottom, from(#fecb19), to(#ff9c00)) !important;background:-webkit-linear-gradient(#fecb19, #ff9c00) !important;background:-moz-linear-gradient(center top, #fecb19 0%, #ff9c00 100%) !important;background:-moz-gradient(center top, #fecb19 0%, #ff9c00 100%) !important;border:1px solid #ff9c00 !important;color:#ffffff;font-family:"Amaranth", Arial, sans-serif;font-style:italic;font-size:15px !important;font-weight:normal;letter-spacing:1px;text-decoration:none;text-shadow:0 1px 0 #434343;padding:10px 30px;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px;box-shadow:none !important;text-shadow:0px 2px 1px rgba(0,0,0,0.3) !important;display:inline-block;text-align:center;width:auto}a.wysija-premium-purchase:hover{box-shadow:none !important}a.wysija-premium-purchase:hover,a.wysija-premium-purchase:active{text-decoration:none !important;background:#ffd547;background:-webkit-gradient(linear, left top, left bottom, from(#ffd648), to(#ffbe38));background:-webkit-linear-gradient(#ffd648, #ffbe38);background:-moz-linear-gradient(center top, #ffd648 20%, #ffbe38 100%);background:-moz-gradient(center top, #ffd648 20%, #ffbe38 100%)}a.wysija-premium-purchase,a.wysija-premium-activate{margin:10px 0}.mpoet-page .bullet-hold{width:600px;margin:15px 30px 15px 5px}.mpoet-page div.description h3{margin:5px 0 4px 0;font-family:"HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;font-size:20px;font-weight:normal;color:black}.mpoet-page div.description p{margin:0}#prices_table{margin-top:55px}#prices_table .one-third{display:block;float:left;width:284px}#prices_table #prices_names{height:63px}#prices_table #prices_names .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;background:none repeat-x scroll left top rgba(0,0,0,0);border-color:#414141 -moz-use-text-color #414141 #414141;border-image:none;border-style:solid none solid solid;border-width:1px 0 1px 1px;height:61px;text-align:center}#prices_table #prices_names{display:block}#prices_table #prices_names h3{color:#FFF !important;line-height:1em !important}#prices_table #prices_names .blogger{background-color:#0074A2}#prices_table #prices_names .freelance{background-color:#026187}#prices_table #prices_names .agency{background-color:#014661;border-right:1px solid #414141}#prices_table #prices_cost{height:177px}#prices_table #prices_cost p{margin:0}#prices_table #prices_cost .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color -moz-use-text-color #849A97 #849A97;border-image:none;border-style:none none solid solid;border-width:0 0 1px 1px;font-family:'Amaranth',Arial,sans-serif;height:176px}#prices_table #prices_cost .agency{border-right:1px solid #849A97}#prices_table #prices_cost span{display:block}#prices_table #prices_cost .dollars{font-size:80px;height:80px;line-height:normal;padding:20px 55px 0;text-align:center}#prices_table #prices_cost .per_year{font-size:18px;padding:0 60px;text-align:right}#prices_table #prices_cost .blogger .dollars{padding:20px 75px 0}#prices_table #prices_cost .blogger .per_year{padding:0 80px}#prices_table #prices_description{height:62px}#prices_table #prices_description .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color -moz-use-text-color #849A97 #849A97;border-image:none;border-style:none none solid solid;border-width:0 0 1px 1px;font-size:22px;height:61px}#prices_table #prices_description .agency{border-right:1px solid #849A97}#prices_table #prices_description .agency p{display:block;margin:-15px 62px 0 0;text-align:right;font-size:.5em}#prices_table #prices_description span{display:block;padding:17px 0;text-align:center}#prices_table #prices_content{height:158px}#prices_table #prices_content .prices_content{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color #849A97 #849A97;border-image:none;border-right:1px solid #849A97;border-style:none solid solid;border-width:0 1px 1px;color:#414141;font-size:17px;padding:16px 0}#prices_table #prices_content .prices_content span{display:block;padding:2px 0;text-align:center}a.buy-button{background:none repeat scroll 0 0 #2EA2CC;border-color:#0074A2;box-shadow:0 1px 0 rgba(120,200,230,0.5) inset,0 1px 0 rgba(0,0,0,0.15);color:#FFFFFF;-moz-box-sizing:border-box;border-radius:3px;border-style:solid;border-width:1px;cursor:pointer;display:inline-block;font-size:20px;margin-top:20px;margin-bottom:60px;padding:7px 10px 7px;text-decoration:none;white-space:nowrap}a.buy-button:hover{color:#ecf3fe}.mpoet-page h1{font-size:34px}#wysija-app .mpoet-page h2{font-size:25px}.mpoet-page h1,.mpoet-page h2,.mpoet-page h3,.mpoet-page h4{color:#626262;font-weight:bold}.mpoet-page h3{margin-top:5px;line-height:24px}.mpoet-page .three-col .argument-cta{display:table;margin-top:5px}#premium-content-b .pick-licence{margin-bottom:15px}.mpoet-page hr{margin-bottom:20px}#premium-content-b .price{font-weight:bold}#footer-upgrade,#footer-left,#wpfooter .alignright,.wysija-footer{display:none}.about-wrap div.updated,.about-wrap div.error{display:block !important}#wysija-app .about-wrap .feature-section{margin-top:20px}
1
+ #mainmenu .premium{background:url(../img/ui-bg_glass_premium_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #a9abc3}#mainmenu .premium:hover{background:url(../img/ui-bg_glass_premium_hover_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #9c9eb2}#mainmenu .premium a{font-weight:700;color:#5d5e76}#mainmenu .premium a:hover{color:#4b4d69}#mainmenu .ui-state-active{background:white !important;border:1px solid #d8d9e6}.mpoet-page h2{color:#4b4d69;font-family:sans-serif;font-size:1.8em;font-weight:200;line-height:1.2em;margin:0}.wysija-premium-wrapper{margin:0 0 20px 0}.wysija-premium-actions{position:fixed;width:1028px;bottom:0;background-color:#eee;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;-webkit-border-top-left-radius:7px;-webkit-border-top-right-radius:7px;-moz-border-radius-topleft:7px;-moz-border-radius-topright:7px;border-top-left-radius:7px;border-top-right-radius:7px;z-index:999;padding:10px 10px 0}.wysija-premium-actions .licence{margin-right:15px}.wysija-premium-actions p{margin:0px 0px 10px 0;text-align:center}.wysija-premium-actions span.conditions{font-size:12px;margin-right:15px}.wysija-premium-actions .button-primary.wysija-premium-activate{float:none}.wysija-premium-actions-kim{position:fixed;width:1066px;bottom:0;background-color:#eee;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;z-index:999;margin-left:-30px;padding:10px 10px;text-align:center}.mpoet-page .feature-section.three-col>div{width:29%}.mpoet-page .three-col img{margin:0.5em 0;max-width:100%}a.wysija-premium-purchase{background-color:#FFB30D !important;background:-webkit-gradient(linear, left top, left bottom, from(#fecb19), to(#ff9c00)) !important;background:-webkit-linear-gradient(#fecb19, #ff9c00) !important;background:-moz-linear-gradient(center top, #fecb19 0%, #ff9c00 100%) !important;background:-moz-gradient(center top, #fecb19 0%, #ff9c00 100%) !important;border:1px solid #ff9c00 !important;color:#ffffff;font-family:"Amaranth", Arial, sans-serif;font-style:italic;font-size:15px !important;font-weight:normal;letter-spacing:1px;text-decoration:none;text-shadow:0 1px 0 #434343;padding:10px 30px;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px;box-shadow:none !important;text-shadow:0px 2px 1px rgba(0,0,0,0.3) !important;display:inline-block;text-align:center;width:auto}a.wysija-premium-purchase:hover{box-shadow:none !important}a.wysija-premium-purchase:hover,a.wysija-premium-purchase:active{text-decoration:none !important;background:#ffd547;background:-webkit-gradient(linear, left top, left bottom, from(#ffd648), to(#ffbe38));background:-webkit-linear-gradient(#ffd648, #ffbe38);background:-moz-linear-gradient(center top, #ffd648 20%, #ffbe38 100%);background:-moz-gradient(center top, #ffd648 20%, #ffbe38 100%)}a.wysija-premium-purchase,a.wysija-premium-activate{margin:10px 0}.mpoet-page .bullet-hold{width:600px;margin:15px 30px 15px 5px}.mpoet-page div.description h3{margin:5px 0 4px 0;font-family:"HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;font-size:20px;font-weight:normal;color:black}.mpoet-page div.description p{margin:0}#prices_table{margin-top:55px}#prices_table .one-third{display:block;float:left;width:284px}#prices_table #prices_names{height:63px}#prices_table #prices_names .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;background:none repeat-x scroll left top rgba(0,0,0,0);border-color:#414141 -moz-use-text-color #414141 #414141;border-image:none;border-style:solid none solid solid;border-width:1px 0 1px 1px;height:61px;text-align:center}#prices_table #prices_names{display:block}#prices_table #prices_names h3{color:#FFF !important;line-height:1em !important}#prices_table #prices_names .blogger{background-color:#0074A2}#prices_table #prices_names .freelance{background-color:#026187}#prices_table #prices_names .agency{background-color:#014661;border-right:1px solid #414141}#prices_table #prices_cost{height:177px}#prices_table #prices_cost p{margin:0}#prices_table #prices_cost .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color -moz-use-text-color #849A97 #849A97;border-image:none;border-style:none none solid solid;border-width:0 0 1px 1px;font-family:'Amaranth',Arial,sans-serif;height:176px}#prices_table #prices_cost .agency{border-right:1px solid #849A97}#prices_table #prices_cost span{display:block}#prices_table #prices_cost .dollars{font-size:80px;height:80px;line-height:normal;padding:20px 55px 0;text-align:center}#prices_table #prices_cost .per_year{font-size:18px;padding:0 60px;text-align:right}#prices_table #prices_cost .blogger .dollars{padding:20px 75px 0}#prices_table #prices_cost .blogger .per_year{padding:0 80px}#prices_table #prices_description{height:62px}#prices_table #prices_description .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color -moz-use-text-color #849A97 #849A97;border-image:none;border-style:none none solid solid;border-width:0 0 1px 1px;font-size:22px;height:61px}#prices_table #prices_description .agency{border-right:1px solid #849A97}#prices_table #prices_description .agency p{display:block;margin:-15px 62px 0 0;text-align:right;font-size:.5em}#prices_table #prices_description span{display:block;padding:17px 0;text-align:center}#prices_table #prices_content{height:158px}#prices_table #prices_content .prices_content{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color #849A97 #849A97;border-image:none;border-right:1px solid #849A97;border-style:none solid solid;border-width:0 1px 1px;color:#414141;font-size:17px;padding:16px 0}#prices_table #prices_content .prices_content span{display:block;padding:2px 0;text-align:center}a.buy-button{background:none repeat scroll 0 0 #2EA2CC;border-color:#0074A2;box-shadow:0 1px 0 rgba(120,200,230,0.5) inset,0 1px 0 rgba(0,0,0,0.15);color:#FFFFFF;-moz-box-sizing:border-box;border-radius:3px;border-style:solid;border-width:1px;cursor:pointer;display:inline-block;font-size:20px;margin-top:20px;margin-bottom:60px;padding:7px 10px 7px;text-decoration:none;white-space:nowrap}a.buy-button:hover{color:#ecf3fe}.mpoet-page h1{font-size:34px}#wysija-app .mpoet-page h2{font-size:25px}.mpoet-page h1,.mpoet-page h2,.mpoet-page h3,.mpoet-page h4{color:#626262;font-family:"Arial","Open Sans",sans-serif;font-weight:bold}.mpoet-page h3{margin-top:5px;line-height:24px}.mpoet-page .three-col .argument-cta{display:table;margin-top:5px}#premium-content-b .pick-licence{margin-bottom:15px}.mpoet-page hr{margin-bottom:20px}#premium-content-b .price{font-weight:bold}#footer-upgrade,#footer-left,#wpfooter .alignright,.wysija-footer{display:none}.about-wrap div.updated,.about-wrap div.error{display:block !important}
css/admin-statistics.css CHANGED
@@ -1 +1 @@
1
- .stats_date_filter{padding-top:10px}.statistic-title{clear:both;margin-top:5px}.cl{clear:both}#hook_stats .container{clear:both;padding-top:1px;margin-top:20px}#stats-filter .reset{background:none;border:none;cursor:pointer}#stats-filter .reset:hover{text-decoration:underline}.custom_date{margin-right:10px}.spinner{float:left !important}.hook{margin-top:10px;clear:both}.container-top-links .link_column{width:20%}.container-top-links .click_column{width:6%}.container .check-column{width:2.5em}.container-top-subscribers table th.subscriber{width:30%}.container-top-subscribers table th.clicks{width:7%}.container-top-subscribers table th.opens{width:7%}.container-top-subscribers table th.lists{width:41%}.container-top-subscribers table th.date{width:15%}.container-top-links a.newsletter{display:block;padding-top:5px}.container-top-newsletters th.newsletter{width:19%}.container-top-newsletters th.sent{width:8%}.container-top-newsletters th.opens{width:8%}.container-top-newsletters th.clicks{width:7%}.container-top-newsletters th.unsubscribes{width:11%}.container-top-newsletters th.rates{width:18%}.container-top-newsletters th.sent_at{width:12%}.container-top-newsletters th.lists{width:14%}.container-top-newsletters td a.stats{display:none}.container-top-newsletters td.newsletter:hover a.stats{display:block}.container-top-subscribers th.desc:hover span.sorting-indicator,.container-top-newsletters th.desc:hover span.sorting-indicator{background-position:-7px 0}.stats_feedback{font-weight:bold;margin-top:20px;clear:both}.tip{font-style:italic}.stats_subscriptions-container .tip{margin-left:70px}.container-top-newsletters th.desc:hover span.sorting-indicator:before,.container-top-subscribers th.desc:hover span.sorting-indicator:before,.container-top-newsletters th.asc span.sorting-indicator:before,.container-top-subscribers th.asc span.sorting-indicator:before{content:'\f140'}
1
+ .stats_date_filter{padding-top:10px}.statistic-title{clear:both;margin-top:5px}.cl{clear:both}#hook_stats .container{clear:both;padding-top:1px;margin-top:20px}#stats-filter .reset{background:none;border:none;cursor:pointer}#stats-filter .reset:hover{text-decoration:underline}.custom_date{margin-right:10px}.spinner{float:left !important}.hook{margin-top:10px;clear:both}.container-top-links .link_column{width:20%}.container-top-links .click_column{width:6%}.container .check-column{width:2.5em}.container-top-subscribers table th.subscriber{width:30%}.container-top-subscribers table th.clicks{width:7%}.container-top-subscribers table th.opens{width:7%}.container-top-subscribers table th.lists{width:41%}.container-top-subscribers table th.date{width:15%}.container-top-links a.newsletter{display:block;padding-top:5px}.container-top-newsletters th.newsletter{width:19%}.container-top-newsletters th.sent{width:8%}.container-top-newsletters th.opens{width:8%}.container-top-newsletters th.clicks{width:7%}.container-top-newsletters th.unsubscribes{width:11%}.container-top-newsletters th.rates{width:18%}.container-top-newsletters th.sent_at{width:12%}.container-top-newsletters th.lists{width:14%}.container-top-newsletters td a.stats{display:none}.container-top-newsletters td.newsletter:hover a.stats{display:block}.container-top-subscribers th.desc:hover span.sorting-indicator,.container-top-newsletters th.desc:hover span.sorting-indicator{background-position:-7px 0}.stats_feedback{font-weight:bold;margin-top:20px;clear:both}.tip{font-style:italic}.stats_subscriptions-container .tip{margin-left:70px}
css/qtip2/jquery.qtip.min.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /* qTip2 v2.2.0 basic css3 | qtip2.com | Licensed MIT, GPL | Fri Nov 29 2013 13:08:37 */
2
+ .qtip{position:absolute;left:-28000px;top:-28000px;display:none;max-width:280px;min-width:50px;font-size:10.5px;line-height:12px;direction:ltr;box-shadow:none;padding:0}.qtip-content{position:relative;padding:5px 9px;overflow:hidden;text-align:left;word-wrap:break-word}.qtip-titlebar{position:relative;padding:5px 35px 5px 10px;overflow:hidden;border-width:0 0 1px;font-weight:700}.qtip-titlebar+.qtip-content{border-top-width:0!important}.qtip-close{position:absolute;right:-9px;top:-9px;cursor:pointer;outline:medium none;border-width:1px;border-style:solid;border-color:transparent}.qtip-titlebar .qtip-close{right:4px;top:50%;margin-top:-9px}* html .qtip-titlebar .qtip-close{top:16px}.qtip-titlebar .ui-icon,.qtip-icon .ui-icon{display:block;text-indent:-1000em;direction:ltr}.qtip-icon,.qtip-icon .ui-icon{-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;text-decoration:none}.qtip-icon .ui-icon{width:18px;height:14px;line-height:14px;text-align:center;text-indent:0;font:400 bold 10px/13px Tahoma,sans-serif;color:inherit;background:transparent none no-repeat -100em -100em}.qtip-focus{}.qtip-hover{}.qtip-default{border-width:1px;border-style:solid;border-color:#F1D031;background-color:#FFFFA3;color:#555}.qtip-default .qtip-titlebar{background-color:#FFEF93}.qtip-default .qtip-icon{border-color:#CCC;background:#F1F1F1;color:#777}.qtip-default .qtip-titlebar .qtip-close{border-color:#AAA;color:#111} .qtip-light{background-color:#fff;border-color:#E2E2E2;color:#454545}.qtip-light .qtip-titlebar{background-color:#f1f1f1} .qtip-dark{background-color:#505050;border-color:#303030;color:#f3f3f3}.qtip-dark .qtip-titlebar{background-color:#404040}.qtip-dark .qtip-icon{border-color:#444}.qtip-dark .qtip-titlebar .ui-state-hover{border-color:#303030} .qtip-cream{background-color:#FBF7AA;border-color:#F9E98E;color:#A27D35}.qtip-cream .qtip-titlebar{background-color:#F0DE7D}.qtip-cream .qtip-close .qtip-icon{background-position:-82px 0} .qtip-red{background-color:#F78B83;border-color:#D95252;color:#912323}.qtip-red .qtip-titlebar{background-color:#F06D65}.qtip-red .qtip-close .qtip-icon{background-position:-102px 0}.qtip-red .qtip-icon{border-color:#D95252}.qtip-red .qtip-titlebar .ui-state-hover{border-color:#D95252} .qtip-green{background-color:#CAED9E;border-color:#90D93F;color:#3F6219}.qtip-green .qtip-titlebar{background-color:#B0DE78}.qtip-green .qtip-close .qtip-icon{background-position:-42px 0} .qtip-blue{background-color:#E5F6FE;border-color:#ADD9ED;color:#5E99BD}.qtip-blue .qtip-titlebar{background-color:#D0E9F5}.qtip-blue .qtip-close .qtip-icon{background-position:-2px 0}.qtip-shadow{-webkit-box-shadow:1px 1px 3px 1px rgba(0,0,0,.15);-moz-box-shadow:1px 1px 3px 1px rgba(0,0,0,.15);box-shadow:1px 1px 3px 1px rgba(0,0,0,.15)}.qtip-rounded,.qtip-tipsy,.qtip-bootstrap{-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px}.qtip-rounded .qtip-titlebar{-moz-border-radius:4px 4px 0 0;-webkit-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.qtip-youtube{-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 3px #333;-moz-box-shadow:0 0 3px #333;box-shadow:0 0 3px #333;color:#fff;border-width:0;background:#4A4A4A;background-image:-webkit-gradient(linear,left top,left bottom,color-stop(0,#4A4A4A),color-stop(100%,#000));background-image:-webkit-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-moz-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-ms-linear-gradient(top,#4A4A4A 0,#000 100%);background-image:-o-linear-gradient(top,#4A4A4A 0,#000 100%)}.qtip-youtube .qtip-titlebar{background-color:#4A4A4A;background-color:rgba(0,0,0,0)}.qtip-youtube .qtip-content{padding:.75em;font:12px arial,sans-serif;filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#4a4a4a, EndColorStr=#000000);-ms-filter:"progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#4a4a4a, EndColorStr=#000000);"}.qtip-youtube .qtip-icon{border-color:#222}.qtip-youtube .qtip-titlebar .ui-state-hover{border-color:#303030}.qtip-jtools{background:#232323;background:rgba(0,0,0,.7);background-image:-webkit-gradient(linear,left top,left bottom,from(#717171),to(#232323));background-image:-moz-linear-gradient(top,#717171,#232323);background-image:-webkit-linear-gradient(top,#717171,#232323);background-image:-ms-linear-gradient(top,#717171,#232323);background-image:-o-linear-gradient(top,#717171,#232323);border:2px solid #ddd;border:2px solid rgba(241,241,241,1);-moz-border-radius:2px;-webkit-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 0 12px #333;-moz-box-shadow:0 0 12px #333;box-shadow:0 0 12px #333}.qtip-jtools .qtip-titlebar{background-color:transparent;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171, endColorstr=#4A4A4A);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#717171, endColorstr=#4A4A4A)"}.qtip-jtools .qtip-content{filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A, endColorstr=#232323);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#4A4A4A, endColorstr=#232323)"}.qtip-jtools .qtip-titlebar,.qtip-jtools .qtip-content{background:transparent;color:#fff;border:0 dashed transparent}.qtip-jtools .qtip-icon{border-color:#555}.qtip-jtools .qtip-titlebar .ui-state-hover{border-color:#333}.qtip-cluetip{-webkit-box-shadow:4px 4px 5px rgba(0,0,0,.4);-moz-box-shadow:4px 4px 5px rgba(0,0,0,.4);box-shadow:4px 4px 5px rgba(0,0,0,.4);background-color:#D9D9C2;color:#111;border:0 dashed transparent}.qtip-cluetip .qtip-titlebar{background-color:#87876A;color:#fff;border:0 dashed transparent}.qtip-cluetip .qtip-icon{border-color:#808064}.qtip-cluetip .qtip-titlebar .ui-state-hover{border-color:#696952;color:#696952}.qtip-tipsy{background:#000;background:rgba(0,0,0,.87);color:#fff;border:0 solid transparent;font-size:11px;font-family:'Lucida Grande',sans-serif;font-weight:700;line-height:16px;text-shadow:0 1px #000}.qtip-tipsy .qtip-titlebar{padding:6px 35px 0 10px;background-color:transparent}.qtip-tipsy .qtip-content{padding:6px 10px}.qtip-tipsy .qtip-icon{border-color:#222;text-shadow:none}.qtip-tipsy .qtip-titlebar .ui-state-hover{border-color:#303030}.qtip-tipped{border:3px solid #959FA9;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;background-color:#F9F9F9;color:#454545;font-weight:400;font-family:serif}.qtip-tipped .qtip-titlebar{border-bottom-width:0;color:#fff;background:#3A79B8;background-image:-webkit-gradient(linear,left top,left bottom,from(#3A79B8),to(#2E629D));background-image:-webkit-linear-gradient(top,#3A79B8,#2E629D);background-image:-moz-linear-gradient(top,#3A79B8,#2E629D);background-image:-ms-linear-gradient(top,#3A79B8,#2E629D);background-image:-o-linear-gradient(top,#3A79B8,#2E629D);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8, endColorstr=#2E629D);-ms-filter:"progid:DXImageTransform.Microsoft.gradient(startColorstr=#3A79B8, endColorstr=#2E629D)"}.qtip-tipped .qtip-icon{border:2px solid #285589;background:#285589}.qtip-tipped .qtip-icon .ui-icon{background-color:#FBFBFB;color:#555}.qtip-bootstrap{font-size:14px;line-height:20px;color:#333;padding:1px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.qtip-bootstrap .qtip-titlebar{padding:8px 14px;margin:0;font-size:14px;font-weight:400;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.qtip-bootstrap .qtip-titlebar .qtip-close{right:11px;top:45%;border-style:none}.qtip-bootstrap .qtip-content{padding:9px 14px}.qtip-bootstrap .qtip-icon{background:transparent}.qtip-bootstrap .qtip-icon .ui-icon{width:auto;height:auto;float:right;font-size:20px;font-weight:700;line-height:18px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.qtip-bootstrap .qtip-icon .ui-icon:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}.qtip:not(.ie9haxors) div.qtip-content,.qtip:not(.ie9haxors) div.qtip-titlebar{filter:none;-ms-filter:none}.qtip .qtip-tip{margin:0 auto;overflow:hidden;z-index:10}x:-o-prefocus,.qtip .qtip-tip{visibility:hidden}.qtip .qtip-tip,.qtip .qtip-tip .qtip-vml,.qtip .qtip-tip canvas{position:absolute;color:#123456;background:transparent;border:0 dashed transparent}.qtip .qtip-tip canvas{top:0;left:0}.qtip .qtip-tip .qtip-vml{behavior:url(#default#VML);display:inline-block;visibility:visible}#qtip-overlay{position:fixed;left:0;top:0;width:100%;height:100%}#qtip-overlay.blurs{cursor:pointer}#qtip-overlay div{position:absolute;left:0;top:0;width:100%;height:100%;background-color:#000;opacity:.7;filter:alpha(opacity=70);-ms-filter:"alpha(Opacity=70)"}.qtipmodal-ie6fix{position:absolute!important}
css/tmce/editor.css CHANGED
@@ -99,11 +99,6 @@
99
  background: url("../js/tinymce/skins/wordpress/images/icons.gif") no-repeat 20px 20px;
100
  }
101
 
102
- .wp_themeSkin span.mce_code:after {
103
- content: '\f475';
104
- font-family: 'dashicons';
105
- }
106
-
107
  /* No @font-face support */
108
  .no-font-face .wp_themeSkin span.mce_undo,
109
  .no-font-face .wp_themeSkin span.mce_redo,
99
  background: url("../js/tinymce/skins/wordpress/images/icons.gif") no-repeat 20px 20px;
100
  }
101
 
 
 
 
 
 
102
  /* No @font-face support */
103
  .no-font-face .wp_themeSkin span.mce_undo,
104
  .no-font-face .wp_themeSkin span.mce_redo,
css/wysija-editor.css CHANGED
@@ -1 +1 @@
1
- .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hidden{display:none}strong{font-weight:bold}img{vertical-align:middle}:focus{outline:0 !important}.inline{display:-moz-inline-box;display:inline-block;*display:inline;*float:left}.wysija_tools li,.wysija_tools dd{margin:0 !important}.wysija_controls li{margin:0 0 0 3px !important}#wysija_items{position:fixed;width:275px;right:20px;top:20px;z-index:999}#wysija_items li{line-height:100px;height:100px;outline:1px solid #ccc;text-align:center}.wysija_items li.disabled{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20);-moz-opacity:0.2;opacity:0.2}.wysija_items li.active a{height:100px;cursor:pointer;display:block}.wysija_header,.wysija_footer{position:relative;display:inline-table;display:block;height:1%;margin:0;padding:0;z-index:98}.wysija_header:after,.wysija_footer:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block{position:relative;margin:0 10px;padding:10px 18px 10px 18px;display:inline-table;display:block;height:1%;margin:0;z-index:98}.wysija_block.dragging,.wysija_header.dragging,.wysija_footer.dragging{z-index:99000}.wysija_block:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block.hover{border:1px dashed #bbb;margin:0 0 0 0;padding:9px 17px 9px 17px}.wysija_block.static{padding:0;margin:0}.wysija_block .wysija_controls{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;position:absolute;margin:0;padding:0;width:598px;height:20px;left:-1px;right:0;top:-22px;width:100%}.wysija_block .wysija_controls .handle{width:600px}.wysija_block .wysija_controls li{float:left;width:20px;height:20px}.wysija_block .wysija_controls a{cursor:pointer;float:left;font-size:120%;font-weight:bold;height:20px;line-height:20px;text-align:center;width:20px;color:#000}.wysija_block .handle_container,.wysija_block .handle_container a{float:none;width:40px}.wysija_block .handle_container{left:280px;top:0;position:absolute}.wysija_gallery .wysija_tools,.wysija_image .wysija_tools{position:absolute;height:34px;line-height:34px;margin:0;width:152px;top:-36px;z-index:1010;background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;padding:0 0 0 5px}.wysija_gallery .wysija_tools{width:102px}.left .wysija_image .wysija_tools,.center .wysija_image .wysija_tools,.left.wysija_gallery .wysija_tools,.center.wysija_gallery .wysija_tools{left:0;text-align:left}.right .wysija_image .wysija_tools,.right.wysija_gallery .wysija_tools{right:0;text-align:right}.wysija_text .wysija_tools{position:absolute;height:20px;line-height:20px;top:0;right:0;margin:0;z-index:1000;width:20px}.wysija_text.alone .wysija_tools{display:none}.wysija_gallery .wysija_tools li,.wysija_image .wysija_tools li{float:left;width:25px;height:34px}.wysija_text .wysija_tools li{float:left;width:20px;height:20px}.wysija_gallery .wysija_tools a,.wysija_image .wysija_tools a,.wysija_text .wysija_tools a{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));float:left;width:20px;height:20px;margin:5px 3px 0 0;-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;-moz-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;border:1px solid #ccc;z-index:1010;position:relative}.wysija_text .wysija_tools a{margin:0}.wysija_gallery .wysija_tools a:hover,.wysija_image .wysija_tools a:hover,.wysija_text .wysija_tools a:hover{background-color:#ddd;border-color:#909090}.wysija_gallery .wysija_tools a.active,.wysija_image .wysija_tools a.active,.wysija_text .wysija_tools a.active{background-color:#ddd;background-image:-moz-linear-gradient(center bottom, #eee, #bbb);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#eee), to(#bbb));border-color:#909090}.wysija_controls a span,.wysija_gallery .wysija_tools a span,.wysija_image .wysija_tools a span,.wysija_text .wysija_tools a span,.wj_content a span{display:block;height:20px;width:20px}.wysija_controls span input{margin:2px 0 0 0;padding:0;color:transparent}.alignment-left span{background:url(../img/controls/icons.png) no-repeat 0 0}.alignment-left.active span,.alignment-left:hover span{background:url(../img/controls/icons.png) no-repeat 0 -20px}.alignment-center span{background:url(../img/controls/icons.png) no-repeat -20px 0}.alignment-center.active span,.alignment-center:hover span{background:url(../img/controls/icons.png) no-repeat -20px -20px}.alignment-right span{background:url(../img/controls/icons.png) no-repeat -40px 0}.alignment-right.active span,.alignment-right:hover span{background:url(../img/controls/icons.png) no-repeat -40px -20px}.add-link span{background:url(../img/controls/icons.png) no-repeat -60px 0}.add-link.active span,.add-link:hover span{background:url(../img/controls/icons.png) no-repeat -60px -20px}.remove-link span{background:url(../img/controls/icons.png) no-repeat -80px 0}.remove-link.active span,.remove-link:hover span{background:url(../img/controls/icons.png) no-repeat -80px -20px}.remove span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}.handle span{background:url(../img/controls/grip-handle.png) no-repeat;cursor:move;width:40px !important}.duplicate span{background:url(../img/controls/icons.png) no-repeat -140px 0}.duplicate.active span,.duplicate:hover span{background:url(../img/controls/icons.png) no-repeat -140px -20px}.settings span{background:url(../img/controls/icons.png) no-repeat -160px 0}.settings.active span,.settings:hover span{background:url(../img/controls/icons.png) no-repeat -160px -20px}.icon-plus span{background:url(../img/controls/icons.png) no-repeat -200px 0}.icon-plus.active span,.icon-plus:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.icon-minus span{background:url(../img/controls/icons.png) no-repeat -220px 0}.icon-minus.active span,.icon-minus:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}.banner{color:#000;z-index:999;text-align:center;width:600px;position:absolute;top:0;right:0;left:0;bottom:0;white-space:nowrap;font-size:16px !important;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.banner .banner-message{margin:20px auto 0 auto}.banner .banner-icon{background:url(../img/controls/image-placeholder.png) no-repeat;padding:2px 0 0 28px}.banner .banner-notice{margin:10px auto 0 auto;font-size:12px;font-style:italic}#wysija_wrapper{padding:20px;width:600px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}#wysija_wrapper:before,#wysija_wrapper:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}#wysija_wrapper:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}body.rtl #wysija_wrapper{right:603px !important}#wysija_container{margin:30px 0 0 0;width:600px;border-collapse:collapse;width:600px;margin:0;padding:0}#wysija_header{padding:0}#wysija_body{vertical-align:top;padding:0}#wysija_footer{padding:0}#wysija_block_placeholder{height:0;padding:0;margin:0}.block_placeholder,.text_placeholder{font-weight:bold;height:0;overflow:hidden;line-height:30px;text-align:center;border:0 none;width:598px;z-index:9500;margin:0 auto;text-indent:-9999px}.wysija_block .block_placeholder,.wysija_block .text_placeholder,.wysija_block .image_placeholder{margin:0}.image_placeholder{margin:1px 0 0 1px}.hover .image_placeholder{margin:0}.wysija_content .empty.editable{font-size:13px;line-height:30px}.wysija_image.empty{height:0;width:0;margin:0 !important;z-index:-1;overflow:hidden}.wysija_image.empty.active{height:auto}.wysija_image.active{background:url(../img/controls/image-placeholder.png) no-repeat center center #f5f5f5;border:1px dashed #dfdfdf}#wysija_header .wysija_image.empty,#wysija_footer .wysija_image.empty{background-image:none;height:auto}#wysija_header .wysija_image.active,#wysija_footer .wysija_image.active{border:0 none}.block_placeholder.active,.text_placeholder.active{text-indent:0;border:1px dashed #dfdfdf;background-color:#f5f5f5;display:block;overflow:auto;height:30px}.image_placeholder.empty.active{display:block}.block_placeholder.hover,.text_placeholder.hover,.image_hover .wysija_image{background-color:#0074a2;border-color:#0074a2;color:#fff !important}.image_placeholder.active{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=25)";filter:alpha(opacity=25);-moz-opacity:0.25;opacity:0.25;z-index:9501}.wysija_image.empty.active,.wysija_text.empty.active{display:block;margin:0}#wysija_header .wysija_image.active,#wysija_footer .wysija_image.active{left:0;top:0;right:0}.wysija_header .image_placeholder,.wysija_footer .image_placeholder{border:0 none !important;margin:0 !important}.wysija_header .image_placeholder.active,.wysija_footer .image_placeholder.active{border:0 none !important}.wysija_options{display:none}.wysija_content .wysija_image{margin:0 auto 15px auto;cursor:move}.wysija_header .wysija_content.left .wysija_image,.wysija_header .wysija_content.right .wysija_image,.wysija_footer .wysija_content.left .wysija_image,.wysija_footer .wysija_content.right .wysija_image{margin:0 0 0 0 !important}.wysija_content.center .image_placeholder.active{margin:0 0 -2px 0}.wysija_header .wysija_content.center .wysija_image,.wysija_footer .wysija_content.center .wysija_image{margin:0 auto !important}.wysija_header .wysija_content.center .image_placeholder.active,.wysija_footer .wysija_content.center .image_placeholder.active{margin:0}.wysija_block .wysija_content.center .wysija_image.empty.active{margin-bottom:5px !important}.wysija_content.left{float:none}.wysija_gallery.left{float:left}.wysija_content.left .wysija_image{float:left;margin:0 15px 5px 0}.wysija_content.left .wysija_image.active{margin:0 13px 3px 0}.wysija_content.left .wysija_image.empty.active{margin:0 15px 5px 0 !important}.wysija_gallery.right{float:right}.wysija_content.right .wysija_image{float:right;margin:0 0 5px 15px}.wysija_content.right .wysija_image.active{margin:0 0 3px 13px}.wysija_content.right .wysija_image.empty.active{margin:0 0 5px 15px !important}.wysija_content .wysija_image.alone{margin:0 !important}.wysija_content.center .wysija_image.alone{margin:0 auto !important}.wysija_image{position:relative;z-index:999}.wysija_image .url-info{position:absolute;bottom:0;left:0;font-size:0.7em;padding:2px;color:#000;background-color:#fff;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8}.wysija_content.left .wysija_image .url-info{right:0;left:auto}.wysija_text{position:relative;z-index:998}.wysija_text.editing{border:1px solid #dfdfdf}.wysija_content.left .wysija_text.editing{float:left}.wysija_text .editable:hover{cursor:pointer}#wysija_toolbar{left:657px;position:absolute;top:-1000px;width:295px}#wysija_toolbar .wysija_toolbar_tabs{border-bottom:1px solid #dfdfdf;line-height:0}#wysija_toolbar .wysija_toolbar_tabs li,#wysija_toolbar .wysija_toolbar_tabs a{margin:0;height:30px;line-height:30px;padding:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;outline:0 none}#wysija_toolbar .wysija_toolbar_tabs a{outline:0 none;text-decoration:none;color:#a6a6a6}#wysija_toolbar .wysija_toolbar_tabs li{margin:0 0 1px 0}#wysija_toolbar .wysija_toolbar_tabs a{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #f5f5f5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#F5F5F5', endColorstr='#F9F9F9');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f5f5f5));border:1px solid #DFDFDF;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;-khtml-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;box-shadow:0 1px 0 #FFFFFF inset;padding:0 7px}#wysija_toolbar .wysija_toolbar_tabs a:hover{background-color:#eee}#wysija_toolbar .wysija_toolbar_tabs a.selected{color:#000;border-bottom:0 none;background:#fcfcfc;filter:none;padding-bottom:1px}#wysija_toolbar .wysija_toolbar_tabs,#wysija_toolbar .wj_content,#wysija_toolbar .wj_images,#wysija_toolbar .wj_styles,#wysija_toolbar .wj_themes{position:relative;z-index:9998;margin:0}#wysija_toolbar #wysija_notices span{font-size:12px !important;font-weight:normal !important}.wj_content{background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:0 0 10px 0}.wj_content li{padding:10px 10px 0 10px;position:relative}.wj_content li.notice{font-style:italic;font-size:11px;margin:0 !important;border:0 none !important;background:none !important}.wj_images{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_images ul{height:360px;overflow:auto;margin:0;padding:0}.wj_images li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;position:relative;border:1px solid #dfdfdf}.wj_images li img{max-height:150px;width:80px}.wj_images li a{float:left;display:block;height:80px;width:80px}.wj_button{text-align:center;width:265px;margin:20px 0;height:30px;line-height:30px}.wj_images img{cursor:move;max-width:275px}#wysija-upload-browse,#wysija-themes-browse{float:none}.wj_images #wj_images_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wj_styles{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_styles p{margin:10px 0}.wj_styles .preview{width:20px;float:none !important;height:20px;vertical-align:middle;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;border:1px solid #333}.wj_styles input,.wj_styles select{height:20px;border:0 none;border:1px solid #CCC;margin:0 3px 0 0 !important;padding:0 !important;vertical-align:middle;line-height:20px;font-size:12px}.wj_styles #aUnderlineInput{margin:0 0 0 10px !important}.wj_styles select{width:75px}.wj_styles input.checkbox,.wj_styles input[type=checkbox]{border:0 none !important}.wj_styles input.color{width:55px;padding:0 0 0 2px !important}.wj_styles input.color.disabled{background-color:#eee !important;color:#eee !important}.wj_styles select.small-size{width:50px}.wj_styles select.type{width:68px}.wj_styles select.size{width:58px}.wj_styles form label{cursor:normal;margin:0 0 0 3px}.wj_themes{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_themes ul{height:360px;overflow:auto;margin:0;padding:0}.wj_themes li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;border:1px solid #dfdfdf;position:relative}.wj_themes li img{max-height:150px;width:80px}.wj_themes li a{display:block}.wj_themes #wj_themes_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wysija_widget{width:275px;height:25px;line-height:25px;z-index:9999 !important}.wj_content a.wysija_item,.wysija_widget{height:25px;line-height:25px;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;display:block;font-size:12px;font-weight:bold;padding:0 0 0 7px;cursor:move;color:#222;text-shadow:0 1px 0 #FFFFFF}.wj_content a.wysija_item.disabled{cursor:help;color:#cccccc}.wysija_item_settings{position:absolute;right:15px;top:13px}.wysija_widget.image{z-index:9999 !important;height:auto !important;width:150px !important;background:none !important;border:0 none !important;box-shadow:none !important;border-radius:0 !important;padding:0 !important}#wysija_notices{z-index:20000;position:relative;left:0;top:0;padding:5px;border:1px solid #dfdfdf;border-top:0 none}#wysija_notices.notice{background-color:#FFFFE0;border-color:#E6DB55;z-index:9999}#wysija_notices.error{background-color:#FFEBE8;border-color:#CC0000}#wysija_notice_msg{font-size:14px;font-weight:bold}.align-center{text-align:center}.align-left{text-align:left}.align-right{text-align:right}.align-justify{text-align:justify}.wysija_gallery{position:relative}.wysija_gallery.center{margin:0 auto}.wysija_gallery.right{text-align:right}.wysija_gallery.left{text-align:left}.wysija_row{width:100%}.wysija_cell{float:left;text-align:center}.resize-controls{position:absolute;left:0;right:0;top:0;bottom:0;z-index:99000;border:1px dashed #ccc}.resize-handle{position:absolute;bottom:0;right:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:se-resize;background:transparent url(../img/controls/resize-se.png) no-repeat scroll right bottom}.resize-info{position:absolute;bottom:0;left:4px;font-size:0.8em;padding:0;margin:0;text-shadow:0 1px 0 #F7F5F2;white-space:nowrap}.right .resize-handle{position:absolute;bottom:0;left:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:sw-resize;background:transparent url(../img/controls/resize-sw.png) no-repeat scroll left bottom}.right .resize-info{left:auto !important;right:4px}#adminmenu li .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{z-index:1001 !important}.wysija_divider{margin:0 auto;width:564px}.wysija_block.auto-post.hover .wysija_content *,.wysija_block.auto-post.hover .wysija_divider{z-index:1000;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3}.wysija_auto-post .wysija_divider{text-align:center;margin:0 !important;width:100% !important}.wysija_auto-post .nopost{height:100px}.wysija_auto-post .nopost p{margin:25px 0 0 0}.wysija_settings{left:10px;position:absolute;top:0;z-index:1000}.wysija_settings a{background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;font-size:12px;font-weight:normal;cursor:pointer;color:#222;text-shadow:0 1px 0 #FFFFFF;text-decoration:none;display:block;padding:5px 5px 3px 27px}.wysija_settings a span{width:20px;height:20px;position:absolute;top:3px;left:5px}#wysija_toggle_images{position:absolute;top:5px;right:5px;z-index:1000;width:73px;height:33px;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;background-color:#fff}#wysija_toggle_images.on{background:url(../img/controls/images-toggle-on.png) no-repeat}#wysija_toggle_images.off{background:url(../img/controls/images-toggle-off.png) no-repeat}#wysija_toggle_images:hover{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);-moz-opacity:1.0;opacity:1.0}.wysija_block.auto-post{padding:0 !important}.wysija_auto-post .wysija_content{padding:10px 17px !important}.wysija_auto-post .wysija_content:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_auto-post .wysija_content{display:inline-table}* html .wysija_auto-post .wysija_content{height:1%}.wysija_auto-post .wysija_content{display:block}.wysija_auto-post .wysija_divider{padding:9px 0 !important}.wysija_block.auto-post.hover .wysija_content{padding:10px 17px !important}.wysija_auto-post .wysija_text{pointer-events:none;cursor:default}.wysija_auto-post .wysija_image{pointer-events:none;cursor:default}.auto-post.hover .wysija_content:last-child{padding:9px 17px 9px 17px !important}.wysija_auto-post .loading{padding:10px 17px;font-size:10px}#wysija_popup_overlay{background-color:#000;height:100%;left:0;position:fixed;top:0;width:100%;z-index:999989;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";filter:alpha(opacity=75);-moz-opacity:0.75;opacity:0.75}#wysija_popup_overlay.loading{background:url(../img/popup/loading.gif) no-repeat 50% 50% #000}#wysija_popup{position:absolute;top:0;left:0;width:600px;height:400px;background-color:#fff;z-index:999999;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;-moz-box-shadow:#000 0 4px 30px;-webkit-box-shadow:#000 0 4px 30px;-khtml-box-shadow:#000 0 4px 30px;box-shadow:#000 0 4px 30px;border:1px solid #555}#wysija_popup_content{padding:0;overflow:hidden;position:relative}#wysija_popup_title{background-color:#222;border:1px solid #333;height:27px;margin:0;padding:0}#wysija_popup_title h3{color:#cfcfcf;font-size:12px;font-weight:normal;margin:6px 0 0 10px;padding:0;float:left;font:12px "Lucida Grande", Verdana, Arial, sans-serif}#wysija_popup_iframe{border:0 none;outline:0 none}#wysija_popup_close{background:url(../img/popup/close.png) no-repeat;height:15px;width:15px;background-color:#333;display:block;float:right;margin:6px 10px 0 0}.mpoet-ui .wysija_item_settings{text-decoration:none}.mpoet-ui .settings span{background:none;color:#999}.mpoet-ui .wysija_item_settings:hover .dashicons-admin-generic:before,.mpoet-ui .settings:hover .dashicons-admin-generic:before{color:#2ea2cc}.wp_themeSkin .mceToolbar{margin:0 !important;padding:0 !important}
1
+ .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hidden{display:none}strong{font-weight:bold}img{vertical-align:middle}:focus{outline:0 !important}.inline{display:-moz-inline-box;display:inline-block;*display:inline;*float:left}.wysija_tools li,.wysija_tools dd{margin:0 !important}.wysija_controls li{margin:0 0 0 3px !important}#wysija_items{position:fixed;width:275px;right:20px;top:20px;z-index:999}#wysija_items li{line-height:100px;height:100px;outline:1px solid #ccc;text-align:center}.wysija_items li.disabled{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20);-moz-opacity:0.2;opacity:0.2}.wysija_items li.active a{height:100px;cursor:pointer;display:block}.wysija_header,.wysija_footer{position:relative;display:inline-table;display:block;height:1%;margin:0;padding:0;z-index:98}.wysija_header:after,.wysija_footer:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block{position:relative;margin:0 10px;padding:10px 18px 10px 18px;display:inline-table;display:block;height:1%;margin:0;z-index:98}.wysija_block.dragging,.wysija_header.dragging,.wysija_footer.dragging{z-index:99000}.wysija_block:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block.hover{border:1px dashed #bbb;margin:0 0 0 0;padding:9px 17px 9px 17px}.wysija_block.static{padding:0;margin:0}.wysija_block .wysija_controls{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;position:absolute;margin:0;padding:0;width:598px;height:20px;left:-1px;right:0;top:-22px;width:100%}.wysija_block .wysija_controls .handle{width:600px}.wysija_block .wysija_controls li{float:left;width:20px;height:20px}.wysija_block .wysija_controls a{cursor:pointer;float:left;font-size:120%;font-weight:bold;height:20px;line-height:20px;text-align:center;width:20px;color:#000}.wysija_block .handle_container,.wysija_block .handle_container a{float:none;width:40px}.wysija_block .handle_container{left:280px;top:0;position:absolute}.wysija_gallery .wysija_tools,.wysija_image .wysija_tools{position:absolute;height:34px;line-height:34px;margin:0;width:152px;top:-36px;z-index:1010;background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;padding:0 0 0 5px}.wysija_gallery .wysija_tools{width:102px}.left .wysija_image .wysija_tools,.center .wysija_image .wysija_tools,.left.wysija_gallery .wysija_tools,.center.wysija_gallery .wysija_tools{left:0;text-align:left}.right .wysija_image .wysija_tools,.right.wysija_gallery .wysija_tools{right:0;text-align:right}.wysija_text .wysija_tools{position:absolute;height:20px;line-height:20px;top:0;right:0;margin:0;z-index:1000;width:20px}.wysija_text.alone .wysija_tools{display:none}.wysija_gallery .wysija_tools li,.wysija_image .wysija_tools li{float:left;width:25px;height:34px}.wysija_text .wysija_tools li{float:left;width:20px;height:20px}.wysija_gallery .wysija_tools a,.wysija_image .wysija_tools a,.wysija_text .wysija_tools a{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));float:left;width:20px;height:20px;margin:5px 3px 0 0;-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;-moz-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;border:1px solid #ccc;z-index:1010;position:relative}.wysija_text .wysija_tools a{margin:0}.wysija_gallery .wysija_tools a:hover,.wysija_image .wysija_tools a:hover,.wysija_text .wysija_tools a:hover{background-color:#ddd;border-color:#909090}.wysija_gallery .wysija_tools a.active,.wysija_image .wysija_tools a.active,.wysija_text .wysija_tools a.active{background-color:#ddd;background-image:-moz-linear-gradient(center bottom, #eee, #bbb);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#eee), to(#bbb));border-color:#909090}.wysija_controls a span,.wysija_gallery .wysija_tools a span,.wysija_image .wysija_tools a span,.wysija_text .wysija_tools a span,.wj_content a span{display:block;height:20px;width:20px}.wysija_controls span input{margin:2px 0 0 0;padding:0;color:transparent}.alignment-left span{background:url(../img/controls/icons.png) no-repeat 0 0}.alignment-left.active span,.alignment-left:hover span{background:url(../img/controls/icons.png) no-repeat 0 -20px}.alignment-center span{background:url(../img/controls/icons.png) no-repeat -20px 0}.alignment-center.active span,.alignment-center:hover span{background:url(../img/controls/icons.png) no-repeat -20px -20px}.alignment-right span{background:url(../img/controls/icons.png) no-repeat -40px 0}.alignment-right.active span,.alignment-right:hover span{background:url(../img/controls/icons.png) no-repeat -40px -20px}.add-link span{background:url(../img/controls/icons.png) no-repeat -60px 0}.add-link.active span,.add-link:hover span{background:url(../img/controls/icons.png) no-repeat -60px -20px}.remove-link span{background:url(../img/controls/icons.png) no-repeat -80px 0}.remove-link.active span,.remove-link:hover span{background:url(../img/controls/icons.png) no-repeat -80px -20px}.remove span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}.handle span{background:url(../img/controls/grip-handle.png) no-repeat;cursor:move;width:40px !important}.duplicate span{background:url(../img/controls/icons.png) no-repeat -140px 0}.duplicate.active span,.duplicate:hover span{background:url(../img/controls/icons.png) no-repeat -140px -20px}.settings span{background:url(../img/controls/icons.png) no-repeat -160px 0}.settings.active span,.settings:hover span{background:url(../img/controls/icons.png) no-repeat -160px -20px}.icon-plus span{background:url(../img/controls/icons.png) no-repeat -200px 0}.icon-plus.active span,.icon-plus:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.icon-minus span{background:url(../img/controls/icons.png) no-repeat -220px 0}.icon-minus.active span,.icon-minus:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}.banner{color:#000;background-color:#fff;z-index:999;text-align:center;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";filter:alpha(opacity=70);-moz-opacity:0.7;opacity:0.7;width:600px;position:absolute;top:0;right:0;left:0;bottom:0;white-space:nowrap;font-size:16px !important}.banner .banner-message{margin:20px auto 0 auto}.banner .banner-notice{margin:10px auto 0 auto;font-size:12px;font-style:italic}#wysija_wrapper{padding:20px;width:600px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}#wysija_wrapper:before,#wysija_wrapper:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}#wysija_wrapper:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}body.rtl #wysija_wrapper{right:603px !important}#wysija_container{margin:30px 0 0 0;width:600px;border-collapse:collapse;width:600px;margin:0;padding:0}#wysija_header{padding:0}#wysija_body{vertical-align:top;padding:0}#wysija_footer{padding:0}.empty{display:none}.empty.active.wysija_image,.empty.active.wysija_text{display:block}#wysija_block_placeholder{height:0;padding:0;margin:0}#block_placeholder{margin:0;height:0}#block_placeholder.active{margin:18px 18px 0px 18px;display:block;height:30px}.block_placeholder{border:0 none;z-index:9500;margin:0;position:relative;left:0;top:-10px;width:562px}.wysija_block .block_placeholder,.wysija_block .text_placeholder,.wysija_block .image_placeholder{margin:0}.image_placeholder{margin:1px 0 0 1px}.wysija_block .block_placeholder.active,.wysija_block .text_placeholder.active{height:30px}.block_placeholder,.text_placeholder,.image_placeholder.empty{transition:opacity .25s, height .25s linear;-moz-transition:opacity .25s, height .25s linear;-webkit-transition:opacity .25s, height .25s linear;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);-moz-opacity:0;opacity:0;height:0;margin:0}.image_placeholder.active{border:1px dashed #bbb;background-color:#f5f5f5;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;transition:opacity .25s;-moz-transition:opacity .25s;-webkit-transition:opacity .25s}.block_placeholder.active,.text_placeholder.active,.image_placeholder.empty.active{border:1px dashed #bbb;background-color:#f5f5f5;display:block;transition:opacity .25s, height .25s linear;-moz-transition:opacity .25s, height .25s linear;-webkit-transition:opacity .25s, height .25s linear;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5}.wysija_content .empty.editable{margin:0 !important}.block_placeholder.active,.wysija_content.center .text_placeholder.active{height:30px}.image_placeholder.empty.active{height:80px;width:80px}.wysija_image.empty.active{width:80px}.wysija_content.right .wysija_image.empty.active{margin-right:3px}.auto-post .block_placeholder.active{margin:0 0 0 18px}.block_placeholder.hover,.text_placeholder.hover,.image_placeholder.hover,.image_placeholder.empty.hover{background-color:#e5e5e5;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);-moz-opacity:1.0;opacity:1.0}.text_placeholder.hover{display:block}#wysija_header .wysija_image.active,#wysija_footer .wysija_image.active{left:0;top:0;right:0}.wysija_header .image_placeholder,.wysija_footer .image_placeholder{border:0 none !important;margin:0 !important}.wysija_header .image_placeholder.active,.wysija_footer .image_placeholder.active{border:0 none !important}.wysija_options{display:none}.wysija_content .wysija_image,.wysija_content.center .wysija_image{margin:0 auto 15px auto;cursor:move}.wysija_content.center .image_placeholder.active{margin:0 0 -2px 0}.wysija_header .wysija_content.center .wysija_image,.wysija_footer .wysija_content.center .wysija_image{margin:0 auto}.wysija_header .wysija_content.left .wysija_image,.wysija_header .wysija_content.right .wysija_image,.wysija_footer .wysija_content.left .wysija_image,.wysija_footer .wysija_content.right .wysija_image{margin:0 0 0 0}.wysija_header .wysija_content.center .image_placeholder.active,.wysija_footer .wysija_content.center .image_placeholder.active{margin:0}.wysija_content.left{float:none}.wysija_gallery.left{float:left}.wysija_content.left .wysija_image{float:left;margin:0 15px 5px 0}.wysija_gallery.right{float:right}.wysija_content.right .wysija_image{float:right;margin:0 0 5px 15px}.wysija_content .wysija_image.alone{margin:0 !important}.wysija_content.center .wysija_image.alone{margin:0 auto !important}.wysija_content.left .wysija_image.active{margin:0 13px 3px 0;left:-1px;top:-1px}.wysija_content.center .wysija_image.active{left:-1px;top:-1px}.wysija_content.right .wysija_image.active{margin:0 0 3px 13px;top:-1px;right:-1px}.wysija_image{position:relative;z-index:999}.wysija_image .url-info{position:absolute;bottom:0;left:0;font-size:0.7em;padding:2px;color:#000;background-color:#fff;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8}.wysija_content.left .wysija_image .url-info{right:0;left:auto}.wysija_text{position:relative;z-index:998}.wysija_text.editing{border:1px solid #dfdfdf}.wysija_content.left .wysija_text.editing{float:left}.wysija_text .editable:hover{cursor:pointer}#wysija_toolbar{left:657px;position:absolute;top:-1000px;width:295px}#wysija_toolbar .wysija_toolbar_tabs{border-bottom:1px solid #dfdfdf;line-height:0}#wysija_toolbar .wysija_toolbar_tabs li,#wysija_toolbar .wysija_toolbar_tabs a{margin:0;height:30px;line-height:30px;padding:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;outline:0 none}#wysija_toolbar .wysija_toolbar_tabs a{outline:0 none;text-decoration:none;color:#a6a6a6}#wysija_toolbar .wysija_toolbar_tabs li{margin:0 0 1px 0}#wysija_toolbar .wysija_toolbar_tabs a{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #f5f5f5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#F5F5F5', endColorstr='#F9F9F9');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f5f5f5));border:1px solid #DFDFDF;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;-khtml-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;box-shadow:0 1px 0 #FFFFFF inset;padding:0 7px}#wysija_toolbar .wysija_toolbar_tabs a:hover{background-color:#eee}#wysija_toolbar .wysija_toolbar_tabs a.selected{color:#000;border-bottom:0 none;background:#fcfcfc;filter:none;padding-bottom:1px}#wysija_toolbar .wysija_toolbar_tabs,#wysija_toolbar .wj_content,#wysija_toolbar .wj_images,#wysija_toolbar .wj_styles,#wysija_toolbar .wj_themes{position:relative;z-index:9998;margin:0}#wysija_toolbar #wysija_notices span{font-size:12px !important;font-weight:normal !important}.wj_content{background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:0 0 10px 0}.wj_content li{padding:10px 10px 0 10px;position:relative}.wj_content li.notice{font-style:italic;font-size:11px;margin:0 !important;border:0 none !important;background:none !important}.wj_images{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_images ul{height:360px;overflow:auto;margin:0;padding:0}.wj_images li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;position:relative;border:1px solid #dfdfdf}.wj_images li img{max-height:150px;width:80px}.wj_images li a{float:left;display:block;height:80px;width:80px}.wj_button{text-align:center;width:265px;margin:20px 0;height:30px;line-height:30px}.wj_images img{cursor:move;max-width:275px}#wysija-upload-browse,#wysija-themes-browse{float:none}.wj_images #wj_images_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wj_styles{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_styles p{margin:10px 0}.wj_styles .preview{width:20px;float:none !important;height:20px;vertical-align:middle;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;border:1px solid #333}.wj_styles input,.wj_styles select{height:20px;border:0 none;border:1px solid #CCC;margin:0 3px 0 0 !important;padding:0 !important;vertical-align:middle;line-height:20px;font-size:12px}.wj_styles #aUnderlineInput{margin:0 0 0 10px !important}.wj_styles select{width:75px}.wj_styles input.checkbox,.wj_styles input[type=checkbox]{border:0 none !important}.wj_styles input.color{width:55px;padding:0 0 0 2px !important}.wj_styles input.color.disabled{background-color:#eee !important;color:#eee !important}.wj_styles select.small-size{width:50px}.wj_styles select.type{width:68px}.wj_styles select.size{width:58px}.wj_styles form label{cursor:normal;margin:0 0 0 3px}.wj_themes{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_themes ul{height:360px;overflow:auto;margin:0;padding:0}.wj_themes li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;border:1px solid #dfdfdf;position:relative}.wj_themes li img{max-height:150px;width:80px}.wj_themes li a{display:block}.wj_themes #wj_themes_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wysija_widget{width:275px;height:25px;line-height:25px;z-index:9999 !important}.wj_content a.wysija_item,.wysija_widget{height:25px;line-height:25px;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;display:block;font-size:12px;font-weight:bold;padding:0 0 0 7px;cursor:move;color:#222;text-shadow:0 1px 0 #FFFFFF}.wj_content a.wysija_item.disabled{cursor:help;color:#cccccc}.wysija_item_settings{position:absolute;right:15px;top:13px}.wysija_widget.image{z-index:9999 !important;height:auto !important;width:150px !important;background:none !important;border:0 none !important;box-shadow:none !important;border-radius:0 !important;padding:0 !important}#wysija_notices{z-index:20000;position:relative;left:0;top:0;padding:5px;border:1px solid #dfdfdf;border-top:0 none}#wysija_notices.notice{background-color:#FFFFE0;border-color:#E6DB55;z-index:9999}#wysija_notices.error{background-color:#FFEBE8;border-color:#CC0000}#wysija_notice_msg{font-size:14px;font-weight:bold}.align-center{text-align:center}.align-left{text-align:left}.align-right{text-align:right}.align-justify{text-align:justify}.wysija_gallery{position:relative}.wysija_gallery.center{margin:0 auto}.wysija_gallery.right{text-align:right}.wysija_gallery.left{text-align:left}.wysija_row{width:100%}.wysija_cell{float:left;text-align:center}.resize-controls{position:absolute;left:-1px;right:-1px;top:-1px;height:100%;z-index:99000;border:1px dashed #ccc}.resize-handle{position:absolute;bottom:0;right:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:se-resize;background:transparent url(../img/controls/resize-se.png) no-repeat scroll right bottom}.resize-info{position:absolute;bottom:0;left:0;font-size:0.8em;padding:2px;text-shadow:0 1px 0 #F7F5F2}.right .resize-handle{position:absolute;bottom:0;left:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:sw-resize;background:transparent url(../img/controls/resize-sw.png) no-repeat scroll left bottom}.right .resize-info{position:absolute;bottom:0;right:0;text-align:right}#adminmenu li .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{z-index:1001 !important}.wysija_divider{margin:0 auto;width:564px}.wysija_block.auto-post.hover .wysija_content *,.wysija_block.auto-post.hover .wysija_divider{z-index:1000;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3}.wysija_auto-post .wysija_divider{text-align:center;margin:0 !important;width:100% !important}.wysija_auto-post .nopost{height:100px}.wysija_auto-post .nopost p{margin:25px 0 0 0}.wysija_settings{left:10px;position:absolute;top:0;z-index:1000}.wysija_settings a{background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;font-size:12px;font-weight:normal;cursor:pointer;color:#222;text-shadow:0 1px 0 #FFFFFF;text-decoration:none;display:block;padding:5px 5px 3px 27px}.wysija_settings a span{width:20px;height:20px;position:absolute;top:3px;left:5px}#wysija_toggle_images{position:absolute;top:5px;right:5px;z-index:1000;width:73px;height:33px;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;background-color:#fff}#wysija_toggle_images.on{background:url(../img/controls/images-toggle-on.png) no-repeat}#wysija_toggle_images.off{background:url(../img/controls/images-toggle-off.png) no-repeat}#wysija_toggle_images:hover{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);-moz-opacity:1.0;opacity:1.0}.wysija_block.auto-post{padding:0 !important}.wysija_auto-post .wysija_content{padding:10px 17px !important}.wysija_auto-post .wysija_content:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_auto-post .wysija_content{display:inline-table}* html .wysija_auto-post .wysija_content{height:1%}.wysija_auto-post .wysija_content{display:block}.wysija_auto-post .wysija_divider{padding:9px 0 !important}.wysija_block.auto-post.hover .wysija_content{padding:10px 17px !important}.wysija_auto-post .wysija_text{pointer-events:none;cursor:default}.wysija_auto-post .wysija_image{pointer-events:none;cursor:default}.auto-post.hover .wysija_content:last-child{padding:9px 17px 9px 17px !important}.wysija_auto-post .loading{padding:10px 17px;font-size:10px}#wysija_popup_overlay{background-color:#000;height:100%;left:0;position:fixed;top:0;width:100%;z-index:999989;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";filter:alpha(opacity=75);-moz-opacity:0.75;opacity:0.75}#wysija_popup_overlay.loading{background:url(../img/popup/loading.gif) no-repeat 50% 50% #000}#wysija_popup{position:absolute;top:0;left:0;width:600px;height:400px;background-color:#fff;z-index:999999;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;-moz-box-shadow:#000 0 4px 30px;-webkit-box-shadow:#000 0 4px 30px;-khtml-box-shadow:#000 0 4px 30px;box-shadow:#000 0 4px 30px;border:1px solid #555}#wysija_popup_content{padding:0;overflow:hidden;position:relative}#wysija_popup_title{background-color:#222;border:1px solid #333;height:27px;margin:0;padding:0}#wysija_popup_title h3{color:#cfcfcf;font-size:12px;font-weight:normal;margin:6px 0 0 10px;padding:0;float:left;font:12px "Lucida Grande", Verdana, Arial, sans-serif}#wysija_popup_iframe{border:0 none;outline:0 none}#wysija_popup_close{background:url(../img/popup/close.png) no-repeat;height:15px;width:15px;background-color:#333;display:block;float:right;margin:6px 10px 0 0}.debug-line{position:absolute;left:0;top:0;display:block;height:1px;width:100%}.debug-line.red{background-color:#f00}.debug-line.green{background-color:#0f0}.debug-line.blue{background-color:#00f}.mpoet-ui .wysija_item_settings{text-decoration:none}.mpoet-ui .settings span{background:none;color:#999}.mpoet-ui .wysija_item_settings:hover .dashicons-admin-generic:before,.mpoet-ui .settings:hover .dashicons-admin-generic:before{color:#2ea2cc}
helpers/back.php CHANGED
@@ -78,6 +78,42 @@ class WYSIJA_help_back extends WYSIJA_help{
78
  }
79
  }
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
  /**
83
  * On any of the administration pages related to MailPoet, if the user
@@ -172,43 +208,6 @@ class WYSIJA_help_back extends WYSIJA_help{
172
  }
173
  }
174
 
175
- /**
176
- * this function will check the role of the user executing the action, if it's called from another
177
- * WordPress admin page than page.php for instance admin-post.php
178
- * @return boolean
179
- */
180
- function verify_capability(){
181
- if( isset( $_GET['page'] ) && substr( $_GET['page'] ,0 ,7 ) == 'wysija_' ){
182
-
183
- switch( $_GET['page'] ){
184
- case 'wysija_campaigns':
185
- $role_needed = 'wysija_newsletters';
186
- break;
187
- case 'wysija_subscribers':
188
- $role_needed = 'wysija_subscribers';
189
- break;
190
- case 'wysija_config':
191
- $role_needed = 'wysija_config';
192
- break;
193
- case 'wysija_statistics':
194
- $role_needed = 'wysija_stats_dashboard';
195
- break;
196
- default:
197
- $role_needed = 'switch_themes';
198
- }
199
-
200
- if( current_user_can( $role_needed ) ){
201
- return true;
202
- } else{
203
- die( 'You are not allowed here.' );
204
- }
205
-
206
- }else{
207
- // this is not a wysija interface/action we can let it pass
208
- return true;
209
- }
210
- }
211
-
212
  /**
213
  * translatable strings need to be not loaded to early, this is why we put them ina separate function
214
  * @global type $wysija_installing
78
  }
79
  }
80
 
81
+ /**
82
+ * this function will check the role of the user executing the action, if it's called from another
83
+ * WordPress admin page than page.php for instance admin-post.php
84
+ * @return boolean
85
+ */
86
+ function verify_capability(){
87
+ if( isset( $_GET['page'] ) && substr( $_GET['page'] ,0 ,7 ) == 'wysija_' ){
88
+
89
+ switch( $_GET['page'] ){
90
+ case 'wysija_campaigns':
91
+ $role_needed = 'wysija_newsletters';
92
+ break;
93
+ case 'wysija_subscribers':
94
+ $role_needed = 'wysija_subscribers';
95
+ break;
96
+ case 'wysija_config':
97
+ $role_needed = 'wysija_config';
98
+ break;
99
+ case 'wysija_statistics':
100
+ $role_needed = 'wysija_stats_dashboard';
101
+ break;
102
+ default:
103
+ $role_needed = 'switch_themes';
104
+ }
105
+
106
+ if( current_user_can( $role_needed ) ){
107
+ return true;
108
+ } else{
109
+ die( 'You are not allowed here.' );
110
+ }
111
+
112
+ }else{
113
+ // this is not a wysija interface/action we can let it pass
114
+ return true;
115
+ }
116
+ }
117
 
118
  /**
119
  * On any of the administration pages related to MailPoet, if the user
208
  }
209
  }
210
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  /**
212
  * translatable strings need to be not loaded to early, this is why we put them ina separate function
213
  * @global type $wysija_installing
helpers/backloader.php CHANGED
@@ -24,6 +24,7 @@ class WYSIJA_help_backloader extends WYSIJA_help{
24
  /* default script on all wysija interfaces in admin */
25
  wp_enqueue_script( 'wysija-admin-if ', WYSIJA_URL . 'js/admin-wysija.js', array( 'jquery' ), WYSIJA::get_version() );
26
 
 
27
  // TO IMPROVE: This has NOTHING TO DO HERE. It has to be moved to the subscribers controller
28
  if ( ! $controller->jsTrans ) {
29
  $controller->jsTrans['selecmiss'] = __( 'Please make a selection first!', WYSIJA );
@@ -66,77 +67,13 @@ class WYSIJA_help_backloader extends WYSIJA_help{
66
  $possibleParameters = array( array( $pagename ), array( $pagename, $action ) );
67
  $enqueueFileTypes = array( 'wp_enqueue_script' => array( 'js' => 'js', 'php' => 'js' ), 'wp_enqueue_style' => array( 'css' => 'css' ) );
68
 
69
- // Files that we have, don't use file_exists if we know which files we have
70
- $files = (object) array(
71
- 'css' => array(
72
- 'add-ons',
73
- 'admin-campaigns-articles',
74
- 'admin-campaigns-autopost',
75
- 'admin-campaigns-bookmarks',
76
- 'admin-campaigns-dividers',
77
- 'admin-campaigns-editDetails',
78
- 'admin-campaigns-editTemplate',
79
- 'admin-campaigns-medias',
80
- 'admin-campaigns-themes',
81
- 'admin-campaigns-viewstats',
82
- 'admin-campaigns-welcome_new',
83
- 'admin-campaigns',
84
- 'admin-global',
85
- 'admin-premium',
86
- 'admin-statistics',
87
- 'admin-subscribers-addlist',
88
- 'admin-subscribers-edit',
89
- 'admin-subscribers-export',
90
- 'admin-subscribers-exportlist',
91
- 'admin-subscribers-import',
92
- 'admin-subscribers-importmatch',
93
- 'admin-subscribers-lists',
94
- 'admin-widget',
95
- 'admin-config',
96
- 'admin-config-form_widget_settings',
97
- ),
98
- 'js' => array(
99
- 'admin-ajax-proto',
100
- 'admin-ajax',
101
- 'admin-campaigns-articles',
102
- 'admin-campaigns-autopost',
103
- 'admin-campaigns-bookmarks',
104
- 'admin-campaigns-default',
105
- 'admin-campaigns-dividers',
106
- 'admin-campaigns-edit',
107
- 'admin-campaigns-editAutonl',
108
- 'admin-campaigns-editDetails',
109
- 'admin-campaigns-editTemplate',
110
- 'admin-campaigns-image_data',
111
- 'admin-campaigns-medias',
112
- 'admin-campaigns-themes',
113
- 'admin-campaigns-viewstats',
114
- 'admin-campaigns-welcome_new',
115
- 'admin-config-form_widget_settings',
116
- 'admin-config-settings',
117
- 'admin-global',
118
- 'admin-listing',
119
- 'admin-statistics-filter',
120
- 'admin-statistics',
121
- 'admin-subscribers-edit-manual',
122
- 'admin-subscribers-export',
123
- 'admin-subscribers-import',
124
- 'admin-subscribers-importmatch',
125
- 'admin-subscribers',
126
- 'admin-tmce',
127
- 'admin-wysija-global',
128
- 'admin-wysija',
129
- )
130
- );
131
-
132
  foreach ( $possibleParameters as $params ) {
133
- foreach ( $enqueueFileTypes as $method => $types ) {
134
- foreach ( $types as $file_type => $file_ext ){
135
- $file_slug = 'admin-' . implode( '-', $params );
136
- if ( in_array( $file_slug, $files->{ $file_ext } ) ) {
137
- $file_id = "wysija-autoinc-{$extension}-{$file_slug}-{$file_ext}";
138
- $file_url = "{$urlname}{$file_ext}/{$file_slug}.{$file_ext}";
139
- call_user_func_array( $method, array( $file_id, $file_url, array(), WYSIJA::get_version() ) );
140
  }
141
  }
142
  }
@@ -228,7 +165,7 @@ class WYSIJA_help_backloader extends WYSIJA_help{
228
  'mailpoet-select2-l10n',
229
  'mailpoet_l10n_select2',
230
  array(
231
- 'noMatches' => __( 'No Results were found', WYSIJA ),
232
  'inputTooShort' => __( 'Please enter <%= chars %> more character<%= plural %>', WYSIJA ),
233
  'inputTooLong' => __( 'Please delete <%= chars %> character<%= plural %>', WYSIJA ),
234
  'selectionTooBig' => __( 'You can only select <%= chars %> item<%= plural %>', WYSIJA ),
@@ -278,7 +215,7 @@ class WYSIJA_help_backloader extends WYSIJA_help{
278
  'image' => __( 'Image' ),
279
  'of' => __( 'of' ),
280
  'close' => __( 'Close' ),
281
- 'noif rames' => __( 'This feature requires inline frames. You have iframes disabled or your browser does not support them.' ),
282
  'l10n_print_after' => 'try{convertEntities( thickboxL10n );}catch( e ){};',
283
  )
284
  );
@@ -299,6 +236,7 @@ class WYSIJA_help_backloader extends WYSIJA_help{
299
  wp_enqueue_style( 'mailpoet-tinymce', WYSIJA_URL . 'css/tmce/editor.css', array(), WYSIJA::get_version() );
300
  }
301
 
 
302
  /* MailPoet editor i18n */
303
  wp_localize_script( 'wysija-editor', 'Wysija_i18n', $controller->jsTrans );
304
  break;
@@ -315,13 +253,9 @@ class WYSIJA_help_backloader extends WYSIJA_help{
315
  default:
316
  if ( is_string( $kjs ) ) {
317
  // check if there's a trailing slash in the urlbase
318
- if ( substr( $urlbase, -1 ) !== '/' ){
319
- $urlbase .= '/';
320
- }
321
  // check if there's already an extension specif ied for the file
322
- if ( substr( $urlbase, -3 ) !== '.js' ){
323
- $js .= '.js';
324
- }
325
  // enqueue script
326
 
327
  wp_enqueue_script( $kjs, $urlbase . 'js/' . $js, array(), WYSIJA::get_version() );
@@ -362,9 +296,8 @@ class WYSIJA_help_backloader extends WYSIJA_help{
362
  function localizeme( $handle, $object_name, $l10n ) {
363
 
364
  foreach ( ( array ) $l10n as $key => $value ) {
365
- if ( ! is_scalar( $value ) ){
366
  continue;
367
- }
368
  $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
369
  }
370
 
@@ -385,22 +318,23 @@ class WYSIJA_help_backloader extends WYSIJA_help{
385
 
386
 
387
 
388
- /**
389
- * this is for backward compatibility and avoid blank screen on older version of the premium plugin
390
- */
391
- function loadScriptsStyles( $pagename, $dirname, $urlname, &$controller, $extension = 'newsletter' ) {
392
- return $this->load_assets( $pagename, $dirname, $urlname, $controller, $extension );
393
- }
394
 
395
- /**
396
- * this is for backward compatibility and avoid blank screen on older version of the premium plugin
397
- */
398
- function initLoad( &$controller ){
399
- return $this->init( $controller );
400
- }
401
 
402
- function jsParse( &$controller, $pagename, $urlbase = WYSIJA_URL ){
403
- $this->parse_js( $controller, $pagename, $urlbase );
404
- }
 
 
 
 
 
 
 
405
 
406
  }
24
  /* default script on all wysija interfaces in admin */
25
  wp_enqueue_script( 'wysija-admin-if ', WYSIJA_URL . 'js/admin-wysija.js', array( 'jquery' ), WYSIJA::get_version() );
26
 
27
+
28
  // TO IMPROVE: This has NOTHING TO DO HERE. It has to be moved to the subscribers controller
29
  if ( ! $controller->jsTrans ) {
30
  $controller->jsTrans['selecmiss'] = __( 'Please make a selection first!', WYSIJA );
67
  $possibleParameters = array( array( $pagename ), array( $pagename, $action ) );
68
  $enqueueFileTypes = array( 'wp_enqueue_script' => array( 'js' => 'js', 'php' => 'js' ), 'wp_enqueue_style' => array( 'css' => 'css' ) );
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  foreach ( $possibleParameters as $params ) {
71
+ foreach ( $enqueueFileTypes as $wayToInclude => $fileTypes ) {
72
+ foreach ( $fileTypes as $fileType => $folderLocation ){
73
+ if ( file_exists( $dirname . $folderLocation . DS . 'admin-' . implode( '-', $params ) . '.' . $fileType ) ) {
74
+ $sourceIdentifier = 'wysija-autoinc-' . $extension . '-admin-' . implode( '-', $params ) . '-' . $fileType;
75
+ $sourceUrl = $urlname . $folderLocation . '/admin-' . implode( '-', $params ) . '.' . $fileType;
76
+ call_user_func_array( $wayToInclude, array( $sourceIdentifier, $sourceUrl, array(), WYSIJA::get_version() ) );
 
77
  }
78
  }
79
  }
165
  'mailpoet-select2-l10n',
166
  'mailpoet_l10n_select2',
167
  array(
168
+ 'noMatches' => __( 'No Results where found', WYSIJA ),
169
  'inputTooShort' => __( 'Please enter <%= chars %> more character<%= plural %>', WYSIJA ),
170
  'inputTooLong' => __( 'Please delete <%= chars %> character<%= plural %>', WYSIJA ),
171
  'selectionTooBig' => __( 'You can only select <%= chars %> item<%= plural %>', WYSIJA ),
215
  'image' => __( 'Image' ),
216
  'of' => __( 'of' ),
217
  'close' => __( 'Close' ),
218
+ 'noif rames' => __( 'This feature requires inline frames. You have if rames disabled or your browser does not support them.' ),
219
  'l10n_print_after' => 'try{convertEntities( thickboxL10n );}catch( e ){};',
220
  )
221
  );
236
  wp_enqueue_style( 'mailpoet-tinymce', WYSIJA_URL . 'css/tmce/editor.css', array(), WYSIJA::get_version() );
237
  }
238
 
239
+
240
  /* MailPoet editor i18n */
241
  wp_localize_script( 'wysija-editor', 'Wysija_i18n', $controller->jsTrans );
242
  break;
253
  default:
254
  if ( is_string( $kjs ) ) {
255
  // check if there's a trailing slash in the urlbase
256
+ if ( substr( $urlbase, -1 ) !== '/' ) $urlbase .= '/';
 
 
257
  // check if there's already an extension specif ied for the file
258
+ if ( substr( $urlbase, -3 ) !== '.js' ) $js .= '.js';
 
 
259
  // enqueue script
260
 
261
  wp_enqueue_script( $kjs, $urlbase . 'js/' . $js, array(), WYSIJA::get_version() );
296
  function localizeme( $handle, $object_name, $l10n ) {
297
 
298
  foreach ( ( array ) $l10n as $key => $value ) {
299
+ if ( ! is_scalar( $value ) )
300
  continue;
 
301
  $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
302
  }
303
 
318
 
319
 
320
 
321
+ /**
322
+ * this is for backward compatibility and avoid blank screen on older version of the premium plugin
323
+ */
324
+ function loadScriptsStyles($pagename,$dirname,$urlname,&$controller,$extension='newsletter') {
 
 
325
 
326
+ return $this->load_assets($pagename, $dirname, $urlname, $controller, $extension);
327
+ }
 
 
 
 
328
 
329
+ /**
330
+ * this is for backward compatibility and avoid blank screen on older version of the premium plugin
331
+ */
332
+ function initLoad(&$controller){
333
+ return $this->init($controller);
334
+ }
335
+
336
+ function jsParse(&$controller, $pagename, $urlbase = WYSIJA_URL){
337
+ $this->parse_js( $controller, $pagename, $urlbase );
338
+ }
339
 
340
  }
helpers/bounce.php CHANGED
@@ -543,6 +543,7 @@ class WYSIJA_help_bounce extends WYSIJA_help {
543
  }
544
 
545
  if (isset($one_rule['action_user']) && in_array($one_rule['action_user'], array('unsub'))) {
 
546
  if (empty($this->_message->subemail)) {
547
  $currentUser = $this->subClass->getObject($this->_message->user_id);
548
  if (!empty($currentUser->email))
543
  }
544
 
545
  if (isset($one_rule['action_user']) && in_array($one_rule['action_user'], array('unsub'))) {
546
+ $status = $this->subClass->getSubscriptionStatus($this->_message->user_id);
547
  if (empty($this->_message->subemail)) {
548
  $currentUser = $this->subClass->getObject($this->_message->user_id);
549
  if (!empty($currentUser->email))
helpers/campaigns.php CHANGED
@@ -1,52 +1,48 @@
1
  <?php
2
-
3
- /*
4
- add_action( 'wp_ajax_mailpoet.search_terms', 'WYSIJA_help_campaigns::ajax_search_terms' );
5
-
6
-
7
- */
8
  defined('WYSIJA') or die('Restricted access');
9
  class WYSIJA_help_campaigns extends WYSIJA_object{
10
- function WYSIJA_help_campaigns(){
11
-
12
- }
13
-
14
- function saveParameters($email_id, $key, $value)
15
- {
16
- // 1. get params field for given campaign
17
- $modelEmail = WYSIJA::get('email', 'model');
18
- $email = $modelEmail->getOne('params', array('email_id' => $email_id));
19
- $params = $email['params'];
20
-
21
- if(!is_array($params)) {
22
- $params = array();
23
- }
24
-
25
- // 2 update data for given key
26
- if(array_key_exists($key, $params)) {
27
- $params[$key] = $value;
28
- } else {
29
- $params = array_merge($params, array($key => $value));
30
- }
31
-
32
- // 3. update campaign
33
- return $modelEmail->update(array('params' => $params), array('email_id' => $email_id));
34
- }
35
-
36
- function getParameters($email_id, $key = null) {
37
- // 1. get params field for given campaign
38
- $modelEmail = WYSIJA::get('email', 'model');
39
- $email = $modelEmail->getOne('params', array('email_id' => $email_id));
40
- $params = $email['params'];
41
-
42
- if($key === null) {
43
- return $params;
44
- } else {
45
- if(!is_array($params) or array_key_exists($key, $params) === false) {
46
- return false;
47
- } else {
48
- return $params[$key];
49
- }
50
- }
51
- }
 
 
52
  }
1
  <?php
 
 
 
 
 
 
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_help_campaigns extends WYSIJA_object{
4
+
5
+
6
+ function WYSIJA_help_campaigns(){
7
+
8
+ }
9
+
10
+ function saveParameters($email_id, $key, $value)
11
+ {
12
+ // 1. get params field for given campaign
13
+ $modelEmail = WYSIJA::get('email', 'model');
14
+ $email = $modelEmail->getOne('params', array('email_id' => $email_id));
15
+ $params = $email['params'];
16
+
17
+ if(!is_array($params)) {
18
+ $params = array();
19
+ }
20
+
21
+ // 2 update data for given key
22
+ if(array_key_exists($key, $params)) {
23
+ $params[$key] = $value;
24
+ } else {
25
+ $params = array_merge($params, array($key => $value));
26
+ }
27
+
28
+ // 3. update campaign
29
+ return $modelEmail->update(array('params' => $params), array('email_id' => $email_id));
30
+ }
31
+
32
+ function getParameters($email_id, $key = null) {
33
+ // 1. get params field for given campaign
34
+ $modelEmail = WYSIJA::get('email', 'model');
35
+ $email = $modelEmail->getOne('params', array('email_id' => $email_id));
36
+ $params = $email['params'];
37
+
38
+ if($key === null) {
39
+ return $params;
40
+ } else {
41
+ if(!is_array($params) or array_key_exists($key, $params) === false) {
42
+ return false;
43
+ } else {
44
+ return $params[$key];
45
+ }
46
+ }
47
+ }
48
  }
helpers/email.php CHANGED
@@ -103,9 +103,9 @@ class WYSIJA_help_email extends WYSIJA_object{
103
  $this->error(__('The PHP Extension openssl is not enabled on your server. Ask your host to enable it if you want to use an SSL connection.',WYSIJA));
104
  }elseif(!empty($bounce) AND !in_array($config->getValue('sending_method'),array('smtp_com','elasticemail'))){
105
  $this->error(sprintf(__('The bounce email address "%1$s" might actually cause the problem. Leave the field empty and try again.',WYSIJA),$bounce));
106
- //Case 2 : you are using SMTP but you didn't add an authentication
107
  }elseif(in_array($config->getValue('sending_method'),array('smtp','gmail')) AND !$config->getValue('smtp_auth') AND strlen($config->getValue('smtp_password')) > 1){
108
- $this->error(__('You specified an SMTP password but you don\'t require an authentication, you might want to turn the SMTP authentication ON.',WYSIJA));
109
  //Case 3 : you are on localhost!
110
  }elseif((strpos(WYSIJA_URL,'localhost') || strpos(WYSIJA_URL,'127.0.0.1')) && in_array($config->getValue('sending_method'),array('sendmail','qmail','mail'))){
111
  $this->error(__('Your localhost may not have a mail server. To verify, please log out and click on the "Lost your password?" link on the login page. Do you receive the reset password email from your WordPress?',WYSIJA));
103
  $this->error(__('The PHP Extension openssl is not enabled on your server. Ask your host to enable it if you want to use an SSL connection.',WYSIJA));
104
  }elseif(!empty($bounce) AND !in_array($config->getValue('sending_method'),array('smtp_com','elasticemail'))){
105
  $this->error(sprintf(__('The bounce email address "%1$s" might actually cause the problem. Leave the field empty and try again.',WYSIJA),$bounce));
106
+ //Case 2 : you are using SMTP but you didn't add an authentification
107
  }elseif(in_array($config->getValue('sending_method'),array('smtp','gmail')) AND !$config->getValue('smtp_auth') AND strlen($config->getValue('smtp_password')) > 1){
108
+ $this->error(__('You specified an SMTP password but you don\'t require an authentification, you might want to turn the SMTP authentification ON.',WYSIJA));
109
  //Case 3 : you are on localhost!
110
  }elseif((strpos(WYSIJA_URL,'localhost') || strpos(WYSIJA_URL,'127.0.0.1')) && in_array($config->getValue('sending_method'),array('sendmail','qmail','mail'))){
111
  $this->error(__('Your localhost may not have a mail server. To verify, please log out and click on the "Lost your password?" link on the login page. Do you receive the reset password email from your WordPress?',WYSIJA));
helpers/licence.php CHANGED
@@ -111,7 +111,7 @@ class WYSIJA_help_licence extends WYSIJA_help{
111
  case 1: //Domain \'%1$s\' does not exist.
112
  //$error_msg=__('\'%1$s\' does not exist!',WYSIJA);
113
 
114
- $error_msg=__('Your website doesn\'t seem to have a license! Log into your [link]account manager[/link] to add a license for this website.',WYSIJA);
115
  break;
116
  case 2: //'Licence (id: %d) does not exist for domain "%s"
117
  $error_msg=__('There\'s no license for "%1$s". If you\'re Premium, add this domain in your [link]account manager[/link].',WYSIJA);
111
  case 1: //Domain \'%1$s\' does not exist.
112
  //$error_msg=__('\'%1$s\' does not exist!',WYSIJA);
113
 
114
+ $error_msg=__('Your website doesn\'t seem to have a license! Log in to your [link]account manager[/link] to add a license for this website.',WYSIJA);
115
  break;
116
  case 2: //'Licence (id: %d) does not exist for domain "%s"
117
  $error_msg=__('There\'s no license for "%1$s". If you\'re Premium, add this domain in your [link]account manager[/link].',WYSIJA);
helpers/render_engine.php CHANGED
@@ -751,25 +751,6 @@ class WYSIJA_help_render_engine extends WYSIJA_object {
751
  }
752
  $value = $ratio;
753
  break;
754
- case 'format_line_height':
755
- // if value in px, don't modify
756
- if($value !== '0' && strpos($value, 'px') === FALSE && strpos($value, '%') === FALSE) {
757
- // if number value, convert to percent
758
- $percentage = ((float)$value * 100);
759
- $value = $percentage.'%';
760
- }
761
- break;
762
-
763
- case 'format_font_size_value':
764
- if(strpos($value, 'em') !== FALSE) {
765
- // if number value, convert to percent
766
- $percentage = ((float)$value * 100);
767
- $value = $percentage.'%';
768
- } else if(strpos($value, '%') === FALSE) {
769
- $value = $value.'px';
770
- }
771
- break;
772
-
773
  case 'inc':
774
  if (!isset ($arguments[0])) {
775
  $value++;
@@ -780,7 +761,7 @@ class WYSIJA_help_render_engine extends WYSIJA_object {
780
 
781
  case 'mult':
782
  if ($arguments) {
783
- $value = (float)$value * (float)$arguments[0];
784
  }
785
  break;
786
 
751
  }
752
  $value = $ratio;
753
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
754
  case 'inc':
755
  if (!isset ($arguments[0])) {
756
  $value++;
761
 
762
  case 'mult':
763
  if ($arguments) {
764
+ $value = $value * $arguments[0];
765
  }
766
  break;
767
 
helpers/user.php CHANGED
@@ -265,12 +265,9 @@ class WYSIJA_help_user extends WYSIJA_object {
265
  if (!empty($message_success))
266
  $this->notice($message_success);
267
  }else {
268
- if ($backend) {
269
- $this->notice(__('Subscriber has not been saved.', WYSIJA));
270
- } else {
271
- $this->notice(__('Oops! We could not add you!', WYSIJA));
272
- }
273
- return false;
274
  }
275
 
276
  $subscribe_to_list = $subscriber_status = 0;
@@ -925,16 +922,20 @@ class WYSIJA_help_user extends WYSIJA_object {
925
  */
926
  function cleanWordpressUsersList() {
927
  // update the screwed up wpuser_id
928
- $model_list = WYSIJA::get('list', 'model');
929
- $query = 'UPDATE [wysija]user as A JOIN [wp]users as B on A.email=B.user_email SET A.wpuser_id = B.ID WHERE A.wpuser_id = 0';
930
- $model_list->query($query);
 
931
 
932
  // get all the wysija user with a wpuser_id >0 and insert them into the WordPress user list
933
- $model_config = WYSIJA::get('config', 'model');
934
- $selectuserCreated = 'SELECT [wysija]user.user_id, ' . $model_config->getValue('importwp_list_id') . ', ' . time() . ' FROM [wysija]user WHERE wpuser_id > 0';
 
 
 
935
  $query = 'INSERT IGNORE INTO `[wysija]user_list` (`user_id`,`list_id`,`sub_date`) ' . $selectuserCreated;
936
- $model_list->reset();
937
- $model_list->query($query);
938
  return true;
939
  }
940
 
265
  if (!empty($message_success))
266
  $this->notice($message_success);
267
  }else {
268
+ $this->notice(__('Subscriber has not been saved.', WYSIJA));
269
+ if ($backend)
270
+ return false;
 
 
 
271
  }
272
 
273
  $subscribe_to_list = $subscriber_status = 0;
922
  */
923
  function cleanWordpressUsersList() {
924
  // update the screwed up wpuser_id
925
+ $model = WYSIJA::get('list', 'model');
926
+ $query = 'UPDATE [wysija]user as A LEFT JOIN [wp]users as B on A.email=B.user_email SET A.wpuser_id = B.ID WHERE A.wpuser_id=0';
927
+ $model->query($query);
928
+
929
 
930
  // get all the wysija user with a wpuser_id >0 and insert them into the WordPress user list
931
+ $model->reset();
932
+ $model->query($query);
933
+
934
+ $mConfig = WYSIJA::get('config', 'model');
935
+ $selectuserCreated = 'SELECT [wysija]user.user_id, ' . $mConfig->getValue('importwp_list_id') . ', ' . time() . ' FROM [wysija]user WHERE wpuser_id>0';
936
  $query = 'INSERT IGNORE INTO `[wysija]user_list` (`user_id`,`list_id`,`sub_date`) ' . $selectuserCreated;
937
+ $model->reset();
938
+ $model->query($query);
939
  return true;
940
  }
941
 
helpers/wj_engine.php CHANGED
@@ -4,1624 +4,1461 @@ defined('WYSIJA') or die('Restricted access');
4
  * @class Wysija Engine Helper (PHP4 version)
5
  */
6
  class WYSIJA_help_wj_engine extends WYSIJA_object {
7
- // debug mode
8
- var $_debug = false;
9
-
10
- // contains email data
11
- var $_email_data = null;
12
-
13
- // rendering context (editor, email)
14
- var $_context = 'editor';
15
-
16
- // toggles for vib & unsub
17
- var $_hide_viewbrowser = false;
18
- var $_hide_unsubscribe = false;
19
-
20
- // data holders
21
- var $_data = null;
22
- var $_styles = null;
23
-
24
- // styles: defaults
25
- var $VIEWBROWSER_SIZES = array(7, 8, 9, 10, 11, 12, 13, 14);
26
- var $TEXT_SIZES = array(8, 9, 10, 11, 12, 13, 14, 16, 18, 24, 36, 48, 72);
27
- var $TITLE_SIZES = array(16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 40, 44, 48, 54, 60, 66, 72);
28
- var $FONTS = array("Arial", "Arial Black", "Comic Sans MS", "Courier New", "Georgia", "Impact", "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana");
29
-
30
- /* Constructor */
31
- function WYSIJA_help_wj_engine() { }
32
-
33
- /* i18n methods */
34
- function getTranslations() {
35
- return array(
36
- 'dropHeaderNotice' => __('Drop your logo in this header.',WYSIJA),
37
- 'dropFooterNotice' => __('Drop your footer image here.',WYSIJA),
38
- 'dropBannerNotice' => __('If you leave this area empty, it will not display once you send your email',WYSIJA),
39
- 'clickToEditText' => __('Click here to add a title or text.', WYSIJA),
40
- 'alignmentLeft' => __('Align left',WYSIJA),
41
- 'alignmentCenter' => __('Align center',WYSIJA),
42
- 'alignmentRight' => __('Align right',WYSIJA),
43
- 'addImageLink' => __('Add link / Alternative text',WYSIJA),
44
- 'removeImageLink' => __('Remove link',WYSIJA),
45
- 'removeImage' => __('Remove image',WYSIJA),
46
- 'remove' => __('Remove', WYSIJA),
47
- 'editText' => __( 'Edit text',WYSIJA),
48
- 'removeText' => __('Remove text',WYSIJA),
49
- 'textLabel' => __('Titles & text',WYSIJA),
50
- 'dividerLabel' => __('Horizontal line',WYSIJA),
51
- 'customDividerLabel' => __('Custom horizontal line',WYSIJA),
52
- 'postLabel' => __('WordPress post',WYSIJA),
53
- 'styleBodyLabel' => __('Text',WYSIJA),
54
- 'styleViewbrowserLabel' => __('"View in browser"', WYSIJA),
55
- 'styleH1Label' => __('Heading 1',WYSIJA),
56
- 'styleH2Label' => __('Heading 2',WYSIJA),
57
- 'styleH3Label' => __('Heading 3',WYSIJA),
58
- 'styleLinksLabel' => __('Links',WYSIJA),
59
- 'styleLinksDecorationLabel' => __('underline',WYSIJA),
60
- 'styleFooterLabel' => __('Footer text',WYSIJA),
61
- 'styleFooterBackgroundLabel' => __('Footer background',WYSIJA),
62
- 'styleBodyBackgroundLabel' => __('Newsletter',WYSIJA),
63
- 'styleHtmlBackgroundLabel' => __('Background', WYSIJA),
64
- 'styleHeaderBackgroundLabel' => __('Header background', WYSIJA),
65
- 'styleDividerLabel' => __('Horizontal line',WYSIJA),
66
- 'styleUnsubscribeColorLabel' => __('Unsubscribe',WYSIJA),
67
- 'articleSelectionTitle' => __('Post Selection', WYSIJA),
68
- 'bookmarkSelectionTitle' => __('Social Bookmark Selection', WYSIJA),
69
- 'dividerSelectionTitle' => __('Divider Selection', WYSIJA),
70
- 'abouttodeletetheme' => __('You are about to delete the theme : %1$s. Do you really want to do that?', WYSIJA),
71
- 'addLinkTitle' => __('Add Link & Alternative text', WYSIJA),
72
- 'styleTransparent' => __('Check this box if you want transparency', WYSIJA),
73
- 'ajaxLoading' => __('Loading...', WYSIJA),
74
- 'customFieldsLabel' => __('Insert dynamic data about your subscribers, the newsletter, today\'s date, etc...', WYSIJA),
75
- 'autoPostSettingsTitle' => __('Selection options', WYSIJA),
76
- 'autoPostEditSettings' => __('Edit Automatic latest content', WYSIJA),
77
- 'autoPostImmediateNotice' => __('You can only add one widget when designing a post notification sent immediately after an article is published', WYSIJA),
78
- 'toggleImagesTitle' => __('Preview without images', WYSIJA),
79
- // Tags labels
80
- 'tags_user' => __('Subscriber', WYSIJA),
81
- 'tags_user_firstname' => __('First Name', WYSIJA),
82
- 'tags_user_lastname' => __('Last Name', WYSIJA),
83
- 'tags_user_email' => __('Email Address', WYSIJA),
84
- 'tags_user_displayname' => __('WordPress user display name', WYSIJA),
85
- 'tags_user_count' => __('Total of subscribers', WYSIJA),
86
- 'tags_newsletter' => __('Newsletter', WYSIJA),
87
- 'tags_newsletter_subject' => __('Newsletter Subject', WYSIJA),
88
- 'tags_newsletter_autonl' => __('Post Notifications', WYSIJA),
89
- 'tags_newsletter_total' => __('Total number of posts or pages', WYSIJA),
90
- 'tags_newsletter_post_title' => __('Latest post title', WYSIJA),
91
- 'tags_newsletter_number' => __('Issue number', WYSIJA),
92
- 'tags_date' => __('Date', WYSIJA),
93
- 'tags_date_d' => __('Current day of the month number', WYSIJA),
94
- 'tags_date_dordinal' => __('Current day of the month in ordinal, ie. 2nd, 3rd, etc.', WYSIJA),
95
- 'tags_date_dtext' => __('Full name of current day', WYSIJA),
96
- 'tags_date_m' => __('Current month number', WYSIJA),
97
- 'tags_date_mtext' => __('Full name of current month', WYSIJA),
98
- 'tags_date_y' => __('Year', WYSIJA),
99
- 'tags_global' => __('Links', WYSIJA),
100
- 'tags_global_unsubscribe' => __('Unsubscribe link', WYSIJA),
101
- 'tags_global_manage' => __('Edit subscription page link', WYSIJA),
102
- 'tags_global_browser' => __('View in browser link', WYSIJA),
103
- 'custom_fields_title' => __('Custom Fields', WYSIJA),
104
- 'custom_fields_list' => WJ_Field::get_all_names(),
105
- // Themes specific labels
106
- 'theme_setting_default' => __('Saving default style...', WYSIJA),
107
- 'theme_saved_default' => __('Default style saved.', WYSIJA),
108
- 'theme_save_as_default' => __('Set as default style.', WYSIJA),
109
- // Placeholders
110
- 'drop_block_here' => __('Insert block here', WYSIJA)
111
- );
112
- }
113
-
114
- /* Data methods */
115
- function getData($type = null) {
116
- if($type !== null) {
117
- if(array_key_exists($type, $this->_data)) {
118
- return $this->_data[$type];
119
- } else {
120
- // return default value
121
- $defaults = $this->getDefaultData();
122
- return $defaults[$type];
123
- }
124
- }
125
- return $this->_data;
126
- }
127
-
128
- function setData($value = null, $decode = false) {
129
- if(!$value) {
130
- $this->_data = $this->getDefaultData();
131
- } else {
132
- $this->_data = $value;
133
- if($decode) {
134
- $this->_data = $this->getDecoded('data');
135
- }
136
- }
137
- }
138
-
139
- function getEmailData($key = null) {
140
- if($key === null) {
141
- return $this->_email_data;
142
- } else {
143
- if(array_key_exists($key, $this->_email_data)) {
144
- return $this->_email_data[$key];
145
- }
146
- }
147
- return null;
148
- }
149
-
150
- function setEmailData($value = null) {
151
- if($value !== null) {
152
- $this->_email_data = $value;
153
- }
154
- }
155
-
156
- function getDefaultData() {
157
- $dividersHelper = WYSIJA::get('dividers', 'helper');
158
- return array(
159
- 'header' => array(
160
- 'alignment' => 'center',
161
- 'type' => 'header',
162
- 'static' => '1',
163
- 'text' => null,
164
- 'image' => array(
165
- 'src' => null,
166
- 'width' => 600,
167
- 'height' => 86,
168
- 'url' => null,
169
- 'alignment' => 'center',
170
- 'static' => '1'
171
- )
172
- ),
173
- 'body' => array(),
174
- 'footer' => array(
175
- 'alignment' => 'center',
176
- 'type' => 'footer',
177
- 'static' => '1',
178
- 'text' => null,
179
- 'image' => array(
180
- 'src' => null,
181
- 'width' => 600,
182
- 'height' => 86,
183
- 'url' => null,
184
- 'alignment' => 'center',
185
- 'static' => '1'
186
- )
187
- ),
188
- 'widgets' => array(
189
- 'divider' => array_merge($dividersHelper->getDefault(), array('type' => 'divider'))
190
- )
191
- );
192
- }
193
-
194
- /* Styles methods */
195
- function getStyles($keys = null) {
196
- if($keys === null) return $this->_styles;
197
-
198
- if(!is_array($keys)) {
199
- $keys = array($keys);
200
- }
201
- $output = array();
202
- for($i=0; $i<count($keys);$i++) {
203
- if(isset($this->_styles[$keys[$i]])) {
204
- $output = array_merge($output, $this->_styles[$keys[$i]]);
205
- }
206
- }
207
- return $output;
208
- }
209
-
210
- function getStyle($key, $subkey) {
211
- $styles = $this->getStyles($key);
212
- return $styles[$subkey];
213
- }
214
-
215
- function setStyles($value = null, $decode = false) {
216
- if(!$value) {
217
- $this->_styles = $this->getDefaultStyles();
218
- } else {
219
- $this->_styles = $value;
220
- if($decode) {
221
- $this->_styles = $this->getDecoded('styles');
222
- }
223
- }
224
- }
225
-
226
- function getDefaultStyles() {
227
-
228
- $defaults = array(
229
- 'html' => array(
230
- 'background' => 'FFFFFF'
231
- ),
232
- 'header' => array(
233
- 'background' => 'FFFFFF'
234
- ),
235
- 'body' => array(
236
- 'color' => '000000',
237
- 'family' => 'Arial',
238
- 'size' => $this->TEXT_SIZES[5],
239
- 'background' => 'FFFFFF'
240
- ),
241
- 'footer' => array(
242
- 'color' => '000000',
243
- 'family' => 'Arial',
244
- 'size' => $this->TEXT_SIZES[5],
245
- 'background' => 'cccccc'
246
- ),
247
- 'h1' => array(
248
- 'color' => '000000',
249
- 'family' => 'Arial',
250
- 'size' => $this->TITLE_SIZES[6]
251
- ),
252
- 'h2' => array(
253
- 'color' => '424242',
254
- 'family' => 'Arial',
255
- 'size' => $this->TITLE_SIZES[5]
256
- ),
257
- 'h3' => array(
258
- 'color' => '424242',
259
- 'family' => 'Arial',
260
- 'size' => $this->TITLE_SIZES[4]
261
- ),
262
- 'a' => array(
263
- 'color' => '4a91b0',
264
- 'underline' => false
265
- ),
266
- 'unsubscribe' => array(
267
- 'color' => '000000'
268
- ),
269
- 'viewbrowser' => array(
270
- 'color' => '000000',
271
- 'family' => 'Arial',
272
- 'size' => $this->VIEWBROWSER_SIZES[4]
273
- )
274
- );
275
-
276
- // get default selected theme
277
- $model_config = WYSIJA::get('config', 'model');
278
- $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
279
-
280
- if($default_theme === 'default') {
281
- return $defaults;
282
- } else {
283
- $helper_themes = WYSIJA::get('themes', 'helper');
284
- $stylesheet = $helper_themes->getStylesheet($default_theme);
285
-
286
- $styles = array();
287
- // look for each tags
288
- foreach($defaults as $tag => $values) {
289
- // look for css rules
290
- preg_match('/\.?'.$tag.'\s?{(.+)}/Ui', $stylesheet, $matches);
291
- if(isset($matches[1])) {
292
- // extract styles
293
- $styles[$tag] = $this->extractStyles($matches[1]);
294
- } else {
295
- // fallback to default
296
- $styles[$tag] = $defaults[$tag];
297
- }
298
- }
299
-
300
- return $styles;
301
- }
302
- }
303
-
304
- function getApplicationData() {
305
- $app = array();
306
-
307
- $app['domain'] = WJ_Utils::get_domain();
308
-
309
- return $app;
310
- }
311
-
312
- /* Editor methods */
313
- function renderEditor() {
314
- $this->setContext('editor');
315
-
316
- if($this->isDataValid() === false) {
317
- throw new Exception('data is not valid');
318
- } else {
319
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
320
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
321
-
322
- // get company addressfrom settings
323
- $config=WYSIJA::get("config","model");
324
-
325
- $data = array(
326
- 'header' => $this->renderEditorHeader(),
327
- 'body' => $this->renderEditorBody(),
328
- 'footer' => $this->renderEditorFooter(),
329
- 'unsubscribe' => $config->emailFooterLinks(true),
330
- 'company_address' => nl2br($config->getValue('company_address')),
331
- 'is_debug' => $this->isDebug(),
332
- 'i18n' => $this->getTranslations()
333
- );
334
-
335
- $viewbrowser = $config->viewInBrowserLink(true);
336
- if($viewbrowser) {
337
- $data['viewbrowser'] = $viewbrowser;
338
- }
339
-
340
- return $helper_render_engine->render($data, 'templates/newsletter/editor/editor_template.html');
341
- }
342
- }
343
-
344
- function renderEditorHeader($data = null) {
345
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
346
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
347
- $helper_render_engine->setStripSpecialchars(true);
348
-
349
- if($data !== null) {
350
- $block = $data;
351
- } else {
352
- $block = $this->getData('header');
353
- }
354
-
355
- $data = array_merge($block, array('i18n' => $this->getTranslations()));
356
- return $helper_render_engine->render($data, 'templates/newsletter/editor/header_template.html');
357
- }
358
-
359
- function renderEditorBody() {
360
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
361
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
362
-
363
- $blocks = $this->getData('body');
364
- if(empty($blocks)) return '';
365
-
366
- $body = '';
367
- foreach($blocks as $key => $block) {
368
- // generate block template
369
- $data = array_merge($block, array('i18n' => $this->getTranslations()));
370
- $body .= $helper_render_engine->render($data, 'templates/newsletter/editor/block_template.html');
371
- }
372
-
373
- return $body;
374
- }
375
-
376
- function renderEditorFooter($data = null)
377
- {
378
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
379
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
380
-
381
- if($data !== null) {
382
- $block = $data;
383
- } else {
384
- $block = $this->getData('footer');
385
- }
386
-
387
- $data = array_merge($block, array('i18n' => $this->getTranslations()));
388
-
389
- return $helper_render_engine->render($data, 'templates/newsletter/editor/footer_template.html');
390
- }
391
-
392
- function renderEditorBlock($block = array()) {
393
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
394
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
395
- $helper_render_engine->setStripSpecialchars(true);
396
-
397
- $block['i18n'] = $this->getTranslations();
398
-
399
- return $helper_render_engine->render($block, 'templates/newsletter/editor/block_'.$block['type'].'.html');
400
- }
401
-
402
- /* render auto post */
403
- function renderEditorAutoPost($posts = array(), $params = array()) {
404
- $output = '';
405
- if(isset($params['post_ids'])) {
406
- $output .= '<input type="hidden" name="post_ids" value="'.$params['post_ids'].'" />';
407
- }
408
-
409
- // check if there are posts to display
410
- if(empty($posts)) {
411
- // set background color
412
- $background_color = '';
413
- if(isset($params['bgcolor1'])) {
414
- $background_color = $params['bgcolor1'];
415
- }
416
-
417
- // display a message stating that the latest content has been sent
418
- $block = array(
419
- 'no-block' => true,
420
- 'type' => 'content',
421
- 'alignment' => 'center',
422
- 'background_color' => $background_color,
423
- 'image' => null,
424
- 'text' => array('value' => base64_encode(__('Latest content already sent.', WYSIJA)))
425
- );
426
- $output .= $this->renderEditorBlock($block);
427
- } else {
428
- // otherwise, render all posts into blocks
429
- $output .= $this->renderPostsToBlocks($posts, $params, 'autopost');
430
- }
431
-
432
- return $output;
433
- }
434
-
435
- function renderEmailAutoPost($posts = array(), $params = array()) {
436
- if(empty($posts)) {
437
- return '';
438
- } else {
439
- return $this->renderPostsToBlocks($posts, $params, 'autopost');
440
- }
441
- }
442
-
443
- function renderEmailBlock($block = array()) {
444
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
445
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
446
- $helper_render_engine->setStripSpecialchars(true);
447
-
448
- // set block background color
449
- $background_color = null;
450
- if(isset($block['background_color'])) {
451
- $background_color = $block['background_color'];
452
- }
453
-
454
- return $this->applyInlineStyles(
455
- 'body',
456
- //$helper_render_engine->render($block, 'templates/email_v3/block_'.$block['type'].'.html'),
457
- $helper_render_engine->render($block, 'templates/newsletter/email/block_template.html'),
458
- array('background_color' => $background_color)
459
- );
460
- }
461
-
462
- function renderPostsToBlocks($posts = array(), $params = array(), $mode = 'post') {
463
- $html = '';
464
- $context = $this->getContext();
465
-
466
- $helper_articles = WYSIJA::get('articles', 'helper');
467
-
468
- if($params['title_tag'] === 'list') {
469
- $list = '<ul class="align-'.$params['title_alignment'].'">';
470
- }
471
-
472
- // make sure empty bgcolors are set to transparent
473
- if(!isset($params['bgcolor1']) || (isset($params['bgcolor1']) && strlen($params['bgcolor1']) === 0)) {
474
- $params['bgcolor1'] = '';
475
- }
476
- if(!isset($params['bgcolor2']) || (isset($params['bgcolor2']) && strlen($params['bgcolor2']) === 0)) {
477
- $params['bgcolor2'] = '';
478
- }
479
-
480
- // BEGIN - posts
481
- for($i = 0, $count = count($posts); $i < $count; $i++) {
482
- $post = $posts[$i];
483
- $is_odd = (bool)($i % 2);
484
- $is_last = (bool)($i === ($count - 1));
485
-
486
- // set default background color to transparent
487
- $background_color = '';
488
-
489
- // set background color for each post
490
- if($is_odd === false) $background_color = $params['bgcolor1'];
491
- if($is_odd === true) $background_color = $params['bgcolor2'];
492
-
493
- if($params['image_alignment'] === 'alternate') {
494
- $image_alignment = ($is_odd === false) ? 'left' : 'right';
495
- } else if($params['image_alignment'] === 'none') {
496
- $image_alignment = 'left';
497
- $post['post_image'] = null;
498
- } else {
499
- $image_alignment = $params['image_alignment'];
500
- }
501
-
502
- // build basic block data
503
- $block = array(
504
- 'position' => $i,
505
- 'type' => 'content',
506
- 'alignment' => $image_alignment,
507
- 'background_color' => $background_color,
508
- 'image' => null,
509
- 'text' => null
510
- );
511
-
512
- // in case of autopost, we need to remove the "block" container because each block will be rendered within the autopost block
513
- if($mode === 'autopost') {
514
- $block['no-block'] = true;
515
- }
516
-
517
- // get title
518
- $title = $helper_articles->getPostTitle($post, $params);
519
-
520
- if(!isset($params['title_position'])) {
521
- $params['title_position'] = 'inside';
522
- }
523
-
524
- // if post content is title, force title position inside
525
- if($params['post_content'] === 'title') {
526
- $params['title_position'] = 'inside';
527
- }
528
-
529
- // only display titles as a list
530
- if($params['title_tag'] === 'list') {
531
- $list .= $title;
532
- continue;
533
- }
534
-
535
- // if the title is outside, generate its own block
536
- if($params['title_position'] === 'outside') {
537
- // generate title
538
- $title_block = array_merge($block, array(
539
- 'alignment' => 'left',
540
- 'text' => array(
541
- 'value' => base64_encode($title)
542
- )
543
- ));
544
-
545
- if($context === 'editor') {
546
- $html .= $this->renderEditorBlock($title_block);
547
- } else if($context === 'email') {
548
- $html .= $this->renderEmailBlock($title_block);
549
- }
550
- }
551
-
552
- // generate content
553
- $content_block = array_merge($block, $helper_articles->convertPostToBlock($post, array_merge($params, array('image_alignment' => $image_alignment))));
554
-
555
- if($context === 'editor') {
556
- $html .= $this->renderEditorBlock($content_block);
557
- } else if($context === 'email') {
558
- $html .= $this->renderEmailBlock($content_block);
559
- }
560
-
561
- // display divider if required
562
- if(isset($params['divider']) && ($params['divider'] !== null && $is_last === false)) {
563
- // display divider only if there is one and if it's not the last post
564
- $divider_block = array_merge(
565
- array(
566
- 'type' => 'divider',
567
- 'no-block' => ($mode === 'autopost')
568
- ),
569
- $params['divider']
570
- );
571
-
572
- if($context === 'editor') {
573
- $html .= $this->renderEditorBlock($divider_block);
574
- } else if($context === 'email') {
575
- $html .= $this->renderEmailBlock($divider_block);
576
- }
577
- }
578
- }
579
- // END - Posts
580
-
581
- if($params['title_tag'] === 'list') {
582
- $list .= '</ul>';
583
- $list_block = array_merge($block, array(
584
- 'alignment' => 'center',
585
- 'type' => 'content',
586
- 'text' => array(
587
- 'value' => base64_encode($list)
588
- )
589
- ));
590
- $html .= $this->renderEditorBlock($list_block);
591
- }
592
-
593
- return $html;
594
- }
595
-
596
- /* render draggable images list */
597
- function renderImages($data = array()) {
598
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
599
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
600
-
601
- return $helper_render_engine->render(array('images' => $data), 'templates/newsletter/editor/toolbar/images.html');
602
- }
603
-
604
- /* render themes list */
605
- function renderThemes() {
606
- $themes = array();
607
- $hThemes = WYSIJA::get('themes', 'helper');
608
-
609
- $installed = $hThemes->getInstalled();
610
-
611
- // get default selected theme
612
- $model_config = WYSIJA::get('config', 'model');
613
- $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
614
-
615
- if(empty($installed)) {
616
- return '';
617
- } else {
618
- foreach($installed as $theme) {
619
- $theme_info = $hThemes->getInformation($theme);
620
- $theme_info['is_selected'] = (bool)($default_theme === $theme);
621
- $themes[] = $theme_info;
622
- }
623
- }
624
-
625
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
626
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
627
-
628
- return $helper_render_engine->render(array('themes' => $themes, 'i18n' => $this->getTranslations()), 'templates/newsletter/editor/toolbar/themes.html');
629
- }
630
-
631
- function renderThemeStyles($theme = 'default') {
632
- $this->setContext('editor');
633
-
634
- $hThemes = WYSIJA::get('themes', 'helper');
635
- $stylesheet = $hThemes->getStylesheet($theme);
636
-
637
- if($stylesheet === NULL) {
638
- // load default settings
639
- $this->setStyles(null);
640
- } else {
641
- // a stylesheet has been found, let's extract styles
642
- $styles = array();
643
- $defaults = $this->getDefaultStyles();
644
- // look for each tags
645
- foreach($defaults as $tag => $values) {
646
- // look for css rules
647
- preg_match('/\.?'.$tag.'\s?{(.+)}/Ui', $stylesheet, $matches);
648
- if(isset($matches[1])) {
649
- // extract styles
650
- $styles[$tag] = $this->extractStyles($matches[1]);
651
- } else {
652
- // fallback to default
653
- $styles[$tag] = $defaults[$tag];
654
- }
655
- }
656
- $this->setStyles($styles);
657
- }
658
-
659
- return array(
660
- 'css' => $this->renderStyles(),
661
- 'form' => $this->renderStylesBar()
662
- );
663
- }
664
-
665
- function extractStyles($raw) {
666
- $rules = explode(';', $raw);
667
- $output = array();
668
- foreach($rules as $rule) {
669
- $sub_property = false;
670
- $combo = explode(':', $rule);
671
- if(count($combo) === 2) {
672
- list($property, $value) = $combo;
673
- // remove leading and trailing space
674
- $property = trim($property);
675
- $value = trim($value);
676
- } else {
677
- continue;
678
- }
679
-
680
- switch($property) {
681
- case 'background':
682
- case 'background-color':
683
- $property = 'background';
684
- case 'color':
685
- // remove # from color
686
- $value = str_replace('#', '', $value);
687
- // check if its a 3 chars color
688
- if(strlen($value) === 3) {
689
- $value = sprintf('%s%s%s%s%s%s', substr($value, 0, 1), substr($value, 0, 1), substr($value, 1, 1), substr($value, 1, 1), substr($value, 2, 1), substr($value, 2, 1));
690
- }
691
- break;
692
- case 'font-family':
693
- $property = 'family';
694
- $fonts = explode(',', $value);
695
- $value = array_shift($fonts);
696
- break;
697
- case 'font-size':
698
- $property = 'size';
699
- case 'height':
700
- $value = (int)$value;
701
- break;
702
- case 'text-decoration':
703
- $property = 'underline';
704
- $value = ($value === 'none') ? '-1' : '1';
705
- break;
706
- case 'border-color':
707
- // remove # from color
708
- $value = str_replace('#', '', $value);
709
- // check if its a 3 chars color
710
- if(strlen($value) === 3) {
711
- $value = sprintf('%s%s%s%s%s%s', substr($value, 0, 1), substr($value, 0, 1), substr($value, 1, 1), substr($value, 1, 1), substr($value, 2, 1), substr($value, 2, 1));
712
- }
713
- list($property, $sub_property) = explode('-', $property);
714
- break;
715
- case 'border-size':
716
- $value = (int)$value;
717
- list($property, $sub_property) = explode('-', $property);
718
- break;
719
- case 'border-style':
720
- list($property, $sub_property) = explode('-', $property);
721
- break;
722
- }
723
-
724
- if($sub_property !== FALSE) {
725
- $output[$property][$sub_property] = $value;
726
- } else {
727
- $output[$property] = $value;
728
- }
729
- }
730
- return $output;
731
- }
732
-
733
- function renderTheme($theme = 'default') {
734
- $output = array(
735
- 'header' => null,
736
- 'footer' => null,
737
- 'divider' => null
738
- );
739
-
740
- $hThemes = WYSIJA::get('themes', 'helper');
741
- $data = $hThemes->getData($theme);
742
-
743
- if($data['header'] !== NULL) {
744
- $output['header'] = $this->renderEditorHeader($data['header']);
745
- }
746
-
747
- if($data['footer'] !== NULL) {
748
- $output['footer'] = $this->renderEditorFooter($data['footer']);
749
- }
750
-
751
- if($data['divider'] !== NULL) {
752
- $output['divider'] = $this->renderEditorBlock(array_merge(array('no-block' => true), $data['divider']));
753
- $output['divider_options'] = $data['divider'];
754
- }
755
-
756
- return $output;
757
- }
758
-
759
- /* render styles bar */
760
- function renderStylesBar() {
761
- $this->setContext('editor');
762
-
763
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
764
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
765
- $helper_render_engine->setStripSpecialchars(true);
766
-
767
- $data = $this->getStyles();
768
- $data['i18n'] = $this->getTranslations();
769
- $data['TEXT_SIZES'] = $this->TEXT_SIZES;
770
- $data['VIEWBROWSER_SIZES'] = $this->VIEWBROWSER_SIZES;
771
- $data['TITLE_SIZES'] = $this->TITLE_SIZES;
772
- $data['FONTS'] = $this->FONTS;
773
-
774
- return $helper_render_engine->render($data, 'templates/newsletter/editor/toolbar/styles.html');
775
- }
776
-
777
- function formatStyles($styles = array()) {
778
- if(empty($styles)) return;
779
-
780
- $data = array();
781
- foreach($styles as $style => $value) {
782
- $stylesArray = explode('-', $style);
783
- if(count($stylesArray) === 2) {
784
- $data[$stylesArray[0]][$stylesArray[1]] = $value;
785
- } else if(count($stylesArray) === 3) {
786
- // handle transparent colors
787
- if($stylesArray[2] === 'transparent') {
788
- $data[$stylesArray[0]][$stylesArray[1]] = $stylesArray[2];
789
- } else {
790
- $data[$stylesArray[0]][$stylesArray[1]][$stylesArray[2]] = $value;
791
- }
792
- }
793
- }
794
-
795
- return $data;
796
- }
797
-
798
- function getContext() {
799
- return $this->_context;
800
- }
801
-
802
- function setContext($value = null) {
803
- if($value !== null) $this->_context = $value;
804
- }
805
-
806
- function isDebug() {
807
- return ($this->_debug === true);
808
- }
809
-
810
- function getEncoded($type = 'data') {
811
- return base64_encode(serialize($this->{'get'.ucfirst($type)}()));
812
- }
813
-
814
- function getDecoded($type = 'data') {
815
- return unserialize(base64_decode($this->{'get'.ucfirst($type)}()));
816
- }
817
-
818
- /* methods */
819
- function isDataValid() {
820
- return ($this->getData() !== null);
821
- }
822
-
823
- /* Styles methods */
824
- function renderStyles() {
825
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
826
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
827
- $helper_render_engine->setStripSpecialchars(true);
828
- $helper_render_engine->setInline(true);
829
-
830
- $data = $this->getStyles();
831
- $data['context'] = $this->getContext();
832
-
833
- // right to left language property
834
- if(function_exists('is_rtl')) {
835
- $data['is_rtl'] = is_rtl();
836
- } else {
837
- $data['is_rtl'] = false;
838
- }
839
-
840
- switch($data['context']) {
841
- case 'editor':
842
- $helper_render_engine->setStripSpecialchars(false);
843
- $data['viewbrowser_container'] = '#wysija_viewbrowser';
844
- $data['wysija_container'] = '#wysija_wrapper';
845
- $data['header_container'] = '#wysija_header';
846
- $data['body_container'] = '#wysija_body';
847
- $data['text_container'] = '.editable';
848
- $data['footer_container'] = '#wysija_footer';
849
- $data['placeholder_container'] = '#wysija_block_placeholder';
850
- $data['unsubscribe_container'] = '#wysija_unsubscribe';
851
- return $helper_render_engine->render($data, 'styles/css-'.$data['context'].'.html');
852
- break;
853
-
854
- case 'email':
855
- $helper_render_engine->setStripSpecialchars(true);
856
- $data['wysija_container'] = '#wysija_wrapper';
857
- $data['viewbrowser_container'] = '.wysija_viewbrowser_container';
858
- $data['header'] = '.wysija_header';
859
- $data['header_container'] = '.wysija_header_container';
860
- $data['body_container'] = '.wysija_block';
861
- $data['text_container'] = '.wysija_text_container';
862
- $data['image_container'] = '.wysija_image_container';
863
- $data['image_placeholder'] = '.wysija_image_placeholder';
864
- $data['title_1'] = '.wysija_title_1';
865
- $data['title_2'] = '.wysija_title_2';
866
- $data['title_3'] = '.wysija_title_3';
867
-
868
- $data['footer'] = '.wysija_footer';
869
- $data['footer_container'] = '.wysija_footer_container';
870
- $data['unsubscribe_container'] = '.wysija_unsubscribe_container';
871
- //right to left language property
872
- if(function_exists('is_rtl')) {
873
- $data['is_rtl'] = is_rtl();
874
- } else {
875
- $data['is_rtl'] = false;
876
- }
877
- return $helper_render_engine->render($data, 'templates/newsletter/email/css.html');
878
- break;
879
- }
880
- }
881
-
882
- /* Email methods */
883
- function renderNotification($email = NULL) {
884
- $this->_hide_viewbrowser = true;
885
- $this->_hide_unsubscribe = true;
886
- return $this->renderEmail($email);
887
- }
888
-
889
- function renderEmail($email = NULL) {
890
-
891
- // fixes issue with pcre functions
892
- @ini_set('pcre.backtrack_limit', 1000000);
893
-
894
- $this->setContext('email');
895
-
896
- if($this->isDataValid() === false) {
897
- throw new Exception('data is not valid');
898
- } else {
899
- // set email data for later use
900
- $this->setEmailData($email);
901
-
902
- // render header
903
- $data = array(
904
- 'viewbrowser' => $this->renderEmailViewBrowser(),
905
- 'header' => $this->renderEmailHeader(),
906
- 'body' => $this->renderEmailBody(),
907
- 'footer' => $this->renderEmailFooter(),
908
- 'unsubscribe' => $this->renderEmailUnsubscribe(),
909
- 'css' => $this->renderStyles(),
910
- 'styles' => $this->getStyles(),
911
- 'hide_viewbrowser' => $this->_hide_viewbrowser,
912
- 'hide_unsubscribe' => $this->_hide_unsubscribe
913
- );
914
-
915
- //right to left language property
916
- if(function_exists('is_rtl')) {
917
- $data['is_rtl'] = is_rtl();
918
- } else {
919
- $data['is_rtl'] = false;
920
- }
921
-
922
- // set email subject if specified
923
- $data['subject'] = $this->getEmailData('subject');
924
-
925
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
926
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
927
- $helper_render_engine->setStripSpecialchars(true);
928
- $helper_render_engine->setInline(true);
929
-
930
- try {
931
- $template = $helper_render_engine->render($data, 'templates/newsletter/email/email_template.html');
932
-
933
- return $template;
934
- } catch(Exception $e) {
935
- return '';
936
- }
937
- }
938
- }
939
-
940
- function renderEmailViewBrowser() {
941
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
942
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
943
- $helper_render_engine->setStripSpecialchars(true);
944
-
945
- $config=WYSIJA::get('config','model');
946
- $data = $config->viewInBrowserLink();
947
- if(!isset($data['link'])) {
948
- return '';
949
- } else {
950
- // generate block template
951
- $viewbrowser = $helper_render_engine->render($data, 'templates/newsletter/email/viewbrowser_template.html');
952
-
953
- // apply inline styles
954
- $viewbrowser = $this->applyInlineStyles('viewbrowser', $viewbrowser);
955
-
956
- return $viewbrowser;
957
- }
958
- }
959
-
960
- function renderEmailUnsubscribe() {
961
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
962
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
963
- $helper_render_engine->setStripSpecialchars(true);
964
-
965
- $config = WYSIJA::get('config','model');
966
-
967
- $data = array(
968
- 'unsubscribe' => $config->emailFooterLinks(),
969
- 'company_address' => nl2br($config->getValue('company_address'))
970
- );
971
-
972
- // generate block template
973
- $unsubscribe = $helper_render_engine->render($data, 'templates/newsletter/email/unsubscribe_template.html');
974
-
975
- // apply inline styles
976
- $unsubscribe = $this->applyInlineStyles('unsubscribe', $unsubscribe);
977
-
978
- return $unsubscribe;
979
- }
980
-
981
- function renderEmailHeader() {
982
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
983
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
984
- $helper_render_engine->setStripSpecialchars(true);
985
-
986
- $data = $this->getData('header');
987
- $data['styles'] = array('header' => $this->getStyles('header'));
988
-
989
- // check for emptyness
990
- if($data['text'] === NULL and $data['image']['static'] === TRUE) {
991
- return NULL;
992
- }
993
-
994
- // set header content width
995
- $data['block_width'] = 600;
996
-
997
- // generate block template
998
- $header = $helper_render_engine->render($data, 'templates/newsletter/email/header_template.html');
999
-
1000
- // apply inline styles
1001
- $header = $this->applyInlineStyles('header', $header);
1002
-
1003
- return $header;
1004
- }
1005
-
1006
- function encodeParameters($params = array()) {
1007
- // encode string parameters
1008
- $keys_to_encode = array('author_label', 'category_label', 'readmore');
1009
- foreach($keys_to_encode as $key) {
1010
- if(isset($params[$key]) && strlen(trim($params[$key])) > 0) {
1011
- $params[$key] = base64_encode(stripslashes($params[$key]));
1012
- }
1013
- }
1014
- return $params;
1015
  }
1016
 
1017
  function decodeParameters($params = array()) {
1018
- // decode string parameters
1019
- $keys_to_decode = array('author_label', 'category_label', 'readmore');
1020
- foreach($keys_to_decode as $key) {
1021
- if(isset($params[$key]) && strlen(trim($params[$key])) > 0) {
1022
- $params[$key] = base64_decode($params[$key]);
1023
- }
1024
- }
1025
- return $params;
1026
  }
1027
 
1028
- function renderEmailBody() {
1029
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1030
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1031
- $helper_render_engine->setStripSpecialchars(true);
1032
-
1033
- $blocks = $this->getData('body');
1034
- $styles = array('body' => $this->getStyles('body'));
1035
-
1036
- // default newsletter type
1037
- $newsletter_type = 'default';
1038
-
1039
- // check if we need to interpret shortcodes
1040
- $model_config = WYSIJA::get('config', 'model');
1041
- $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
1042
-
1043
- $body = '';
1044
-
1045
- // check if we are dealing with an auto newsletter
1046
- $email = $this->getEmailData();
1047
- if(isset($email['params']['autonl']) && !empty($email['params']['autonl'])) {
1048
- // set newsletter type to automattic newsletter
1049
- $newsletter_type = 'automatic';
1050
-
1051
- // posts data
1052
- $first_subject = null;
1053
- $post_count = 0;
1054
- $post_ids = array();
1055
-
1056
- }
1057
-
1058
- foreach($blocks as $key => $block) {
1059
- // reset block HTML so as to avoid duplicates
1060
- $blockHTML = '';
1061
-
1062
- // reset category_ids
1063
- $include_category_ids = array();
1064
- $exclude_category_ids = array();
1065
- $category_ids = array();
1066
-
1067
- // specific background color
1068
- $block_background_color = null;
1069
-
1070
- // get background color if specified
1071
- if(isset($block['background_color']) && strlen($block['background_color']) === 6) {
1072
- $block_background_color = $block['background_color'];
1073
- }
1074
-
1075
- // block width
1076
- $block['block_width'] = 600;
1077
-
1078
- if($block['type'] === 'auto-post') {
1079
- // special case for auto post, we need to fetch posts, taking previously sent posts into account
1080
-
1081
- // get email data
1082
- //$email = $this->getEmailData();
1083
-
1084
- // get block params
1085
- $blockParams = $block['params'];
1086
-
1087
- // format parameters
1088
- $params = array();
1089
-
1090
- $category_ids = array();
1091
- $category_condition = 'include';
1092
-
1093
- foreach($blockParams as $pairs) {
1094
- // store category_ids in email for better performance on immediate sending of WP Posts.
1095
- if($pairs['key'] === 'category_ids') {
1096
- $pair_value = trim($pairs['value']);
1097
- if(!empty($pair_value)) {
1098
- $category_ids = array_map('intval', explode(',', trim($pairs['value'])));
1099
- }
1100
- }
1101
- // store category condition (include / exclude) for same above reason.
1102
- if($pairs['key'] === 'category_condition') {
1103
- $category_condition = (in_array(trim($pairs['value']), array('include', 'exclude'))) ? trim($pairs['value']) : 'include';
1104
- }
1105
- $params[$pairs['key']] = $pairs['value'];
1106
- }
1107
-
1108
- // make sure we store category_ids
1109
- if(!empty($category_ids)) {
1110
- if($category_condition === 'include') {
1111
- $include_category_ids = array_unique($category_ids);
1112
- }
1113
- if($category_condition === 'exclude') {
1114
- $exclude_category_ids = array_unique($category_ids);
1115
- }
1116
- }
1117
-
1118
- // make sure empty bgcolors are set to transparent
1119
- if(isset($params['bgcolor1']) && strlen($params['bgcolor1']) === 0) {
1120
- $params['bgcolor1'] = 'transparent';
1121
- }
1122
- if(isset($params['bgcolor2']) && strlen($params['bgcolor2']) === 0) {
1123
- $params['bgcolor2'] = 'transparent';
1124
- }
1125
-
1126
- // make sure the default params are set
1127
- if(array_key_exists('autonl', $email['params']) === false) {
1128
- $email['params']['autonl'] = array();
1129
- }
1130
- if(array_key_exists('articles', $email['params']['autonl']) === false) {
1131
- $email['params']['autonl']['articles'] = array(
1132
- 'ids' => array(),
1133
- 'count' => 0,
1134
- 'first_subject' => ''
1135
- );
1136
- }
1137
-
1138
- // exclude already sent post ids from selection
1139
- if(!empty($email['params']['autonl']['articles']['ids'])) {
1140
- $params['exclude'] = $email['params']['autonl']['articles']['ids'];
1141
- } else {
1142
- $email['params']['autonl']['articles']['ids'] = array();
1143
- }
1144
-
1145
- //we set the post_date to filter articles only older than that one
1146
- if(isset($email['params']['autonl']['firstSend'])){
1147
- $params['post_date'] = $email['params']['autonl']['firstSend'];
1148
- }
1149
-
1150
- // if immediate let it know to the get post
1151
- if(isset($email['params']['autonl']['articles']['immediatepostid'])){
1152
- $params['include'] = (int)$email['params']['autonl']['articles']['immediatepostid'];
1153
- $params['post_limit'] = 1;
1154
- }else{
1155
- //we set the post_date to filter articles only older than the last time we sent articles
1156
- if(isset($email['params']['autonl']['lastSend'])){
1157
- $params['post_date'] = $email['params']['autonl']['lastSend'];
1158
- }else{
1159
- //get the latest child newsletter sent_at value
1160
- $mEmail=WYSIJA::get('email','model');
1161
- $mEmail->reset();
1162
- $mEmail->orderBy('email_id','DESC');
1163
- $lastEmailSent=$mEmail->getOne(false,array('campaign_id'=>$email['campaign_id'],'type'=>'1'));
1164
-
1165
- if(!empty($lastEmailSent)) $params['post_date'] = $lastEmailSent['sent_at'];
1166
- }
1167
- }
1168
-
1169
- // decode specific keys
1170
- $params = $this->decodeParameters($params);
1171
-
1172
- // include/exclude category_ids
1173
- $params['include_category_ids'] = $include_category_ids;
1174
- $params['exclude_category_ids'] = $exclude_category_ids;
1175
-
1176
- // check for already inserted posts
1177
- if(!empty($post_ids)) {
1178
- $params['exclude'] = $post_ids;
1179
- }
1180
-
1181
- // get posts for this block
1182
- $model_wp_posts = WYSIJA::get('wp_posts','model');
1183
- $posts = $model_wp_posts->get_posts($params);
1184
-
1185
- // check if we have posts to display
1186
- if(!empty($posts)) {
1187
- // get divider if necessary
1188
- if(isset($params['show_divider']) && $params['show_divider'] === 'yes') {
1189
- if(isset($email['params']['divider'])) {
1190
- // either from the email params
1191
- $params['divider'] = $email['params']['divider'];
1192
- } else {
1193
- // get default divider otherwise
1194
- $helper_dividers = WYSIJA::get('dividers', 'helper');
1195
- $params['divider'] = $helper_dividers->getDefault();
1196
- }
1197
- }
1198
-
1199
- $helper_articles = WYSIJA::get('articles', 'helper');
1200
-
1201
- foreach($posts as $key => $post) {
1202
- // assign first post title to autonl parameters (this is used to display the [newsletter:post_title] shortcode in the subject)
1203
- if($first_subject === null && strlen(trim($posts[$key]['post_title'])) > 0) {
1204
- $first_subject = trim($posts[$key]['post_title']);
1205
- }
1206
-
1207
- // check if shortcodes should be interpreted (value comes from WP options)
1208
- if($interpret_shortcode === true) {
1209
- // interpret shortcodes
1210
- $posts[$key]['post_content'] = apply_filters('the_content', $post['post_content']);
1211
- }
1212
- if($params['image_alignment'] !== 'none') {
1213
- // get thumbnail
1214
- $posts[$key]['post_image'] = $helper_articles->getImage($post);
1215
- }
1216
- $post_ids[] = (int)$post['ID'];
1217
- $post_count++;
1218
- }
1219
- // render html from post data and params
1220
- $blockHTML = $this->renderEmailAutoPost($posts, $params);
1221
- }
1222
-
1223
- $this->setEmailData($email);
1224
- } else {
1225
- // set styles
1226
- $block['styles'] = $styles;
1227
- // generate block template
1228
- $blockHTML = $helper_render_engine->render($block, 'templates/newsletter/email/block_template.html');
1229
-
1230
- if($block['type'] !== 'raw') {
1231
- // convert lists in block
1232
- $blockHTML = $this->convertLists($blockHTML);
1233
-
1234
- // apply specific classes on titles and children (strong, em, a)
1235
- $blockHTML = $this->applyTitleClasses($blockHTML);
1236
-
1237
- // apply inline styles
1238
- $blockHTML = $this->applyInlineStyles('body', $blockHTML, array('background_color' => $block_background_color));
1239
-
1240
- // convert titles in block
1241
- $blockHTML = $this->convertTitles($blockHTML);
1242
- }
1243
- }
1244
-
1245
- // append generated html to body
1246
- if($blockHTML !== '') {
1247
- // render each block
1248
- $body .= $blockHTML;
1249
- }
1250
- }
1251
-
1252
- if($newsletter_type === 'automatic') {
1253
- $email = $this->getEmailData();
1254
- // set auto newsletter parameters
1255
- $email['params']['autonl']['articles']['count'] = $post_count;
1256
- $email['params']['autonl']['articles']['first_subject'] = $first_subject;
1257
- $email['params']['autonl']['articles']['ids'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $post_ids));
1258
-
1259
- $this->setEmailData($email);
1260
- }
1261
-
1262
- return $body;
1263
- }
1264
-
1265
- function renderEmailFooter() {
1266
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1267
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1268
- $helper_render_engine->setStripSpecialchars(true);
1269
-
1270
- $data = $this->getData('footer');
1271
- $data['styles'] = array('footer' => $this->getStyles('footer'));
1272
-
1273
- // check for emptyness
1274
- if($data['text'] === NULL and $data['image']['static'] === TRUE) {
1275
- return NULL;
1276
- }
1277
-
1278
- // set footer content width
1279
- $data['block_width'] = 600;
1280
-
1281
- // generate block template
1282
- $footer = $helper_render_engine->render($data, 'templates/newsletter/email/footer_template.html');
1283
-
1284
- // apply inline styles
1285
- $footer = $this->applyInlineStyles('footer', $footer);
1286
-
1287
- return $footer;
1288
- }
1289
-
1290
- /**
1291
- * area : header, body, footer, unsubscribe, viewbrowser
1292
- * block : raw html
1293
- */
1294
- function applyInlineStyles($area, $block, $extra = array()) {
1295
- $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1296
- $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1297
- $helper_render_engine->setInline(true);
1298
-
1299
- // common tags
1300
- $tags = array(
1301
- 'table' => array(
1302
- 'border-collapse' => 'collapse',
1303
- 'mso-table-space' => '0pt',
1304
- 'clear' => 'both'
1305
- ),
1306
- 'td' => array(
1307
- 'border-collapse' => 'collapse'
1308
- )
1309
- );
1310
- // common classes
1311
- $classes = array();
1312
-
1313
- // set block background color
1314
- if(array_key_exists('background_color', $extra) and $extra['background_color'] !== null) {
1315
- $background_color = $extra['background_color'];
1316
- } else {
1317
- switch ($area) {
1318
- case 'header':
1319
- case 'footer':
1320
- case 'body':
1321
- $background_color = $this->getStyle($area, 'background');
1322
- break;
1323
- case 'unsubscribe':
1324
- $background_color = $this->getStyle('html', 'background');
1325
- break;
1326
- default:
1327
- $background_color = $this->getStyle('html', 'background');
1328
- break;
1329
- }
1330
- }
1331
-
1332
- // set common styles
1333
- $styles = array(
1334
- 'titles' => array(
1335
- 'word-wrap' => true,
1336
- 'padding' => '0',
1337
- 'margin' => '3px 0 10px 0',
1338
- 'font-weight' => 'normal',
1339
- 'line-height' => '1.25em'
1340
- ),
1341
- 'images' => array(
1342
- 'margin' => '0',
1343
- 'padding' => '0',
1344
- 'display' => 'block',
1345
- 'border' => array(
1346
- 'size' => '1px',
1347
- 'style' => 'solid',
1348
- 'color' => $this->formatColor($background_color)
1349
- )
1350
- )
1351
- );
1352
-
1353
- // area specific classes/tags
1354
- switch($area) {
1355
- case 'header':
1356
- case 'footer':
1357
- $classes = array(
1358
- 'wysija_'.$area => array('min-width' => '100%'),
1359
- 'wysija_'.$area.'_container' => $this->getStyles($area),
1360
- 'wysija_content_container' => array_merge($this->getStyles($area), array('padding' => '0')),
1361
- // images alignments
1362
- 'wysija_image_container center' => array_merge($styles['images'], array('margin' => '0 auto 0 auto', 'text-align' => 'center', 'border' => '0')),
1363
- 'wysija_image_container left' => array_merge($styles['images'], array('border' => '0')),
1364
- 'wysija_image_container right' => array_merge($styles['images'], array('border' => '0')),
1365
- // image placeholder
1366
- 'wysija_image_placeholder' => array('padding' => '0 0 0 0', 'margin' => '0 0 0 0', 'display' => 'block'),
1367
-
1368
- // links around images
1369
- 'wysija_image_link' => array('outline' => '0', 'border' => '0', 'margin' => '0', 'padding' => '0', 'display' => 'block'),
1370
-
1371
- // images
1372
- 'image_fix' => array('display' => 'block', 'outline' => '0', 'text-decoration' => 'none', 'interpolation' => 'bicubic')
1373
- );
1374
- break;
1375
-
1376
- case 'body':
1377
- $tags = array_merge($tags, array(
1378
- 'h1' => array_merge($styles['titles'], $this->getStyles('h1')),
1379
- 'h2' => array_merge($styles['titles'], $this->getStyles('h2')),
1380
- 'h3' => array_merge($styles['titles'], $this->getStyles('h3')),
1381
- 'p' => array_merge($this->getStyles('body'), array('word-wrap' => true, 'padding' => '0', 'margin' => '1em 0', 'line-height' => '1.5em', 'vertical-align' => 'top')),
1382
- 'a' => array_merge($this->getStyles('body'), $this->getStyles('a'), array('word-wrap' => true))
1383
- ));
1384
-
1385
- $classes = array(
1386
- // blocks
1387
- 'wysija_block' => array('min-width' => '100%'),
1388
- 'wysija_content_container' => array('padding' => '10px 17px 10px 17px'),
1389
- 'wysija_divider_container' => array('padding' => '15px 17px 15px 17px'),
1390
- 'wysija_gallery_container' => array('padding' => '10px 17px 10px 17px'),
1391
-
1392
- // text
1393
- 'wysija_text_container' => array('margin' => '1em 0'),
1394
- 'align-left' => array('text-align' => 'left'),
1395
- 'align-center' => array('text-align' => 'center'),
1396
- 'align-right' => array('text-align' => 'right'),
1397
- 'align-justify' => array('text-align' => 'justify'),
1398
-
1399
- // links in titles
1400
- 'wysija_title_1_link' => array_merge($styles['titles'], $this->getStyles('h1'), $this->getStyles('a')),
1401
- 'wysija_title_2_link' => array_merge($styles['titles'], $this->getStyles('h2'), $this->getStyles('a')),
1402
- 'wysija_title_3_link' => array_merge($styles['titles'], $this->getStyles('h3'), $this->getStyles('a')),
1403
- // strong tags in titles
1404
- 'wysija_title_1_strong' => array_merge($styles['titles'], $this->getStyles('h1'), array('font-weight' => 'bold')),
1405
- 'wysija_title_2_strong' => array_merge($styles['titles'], $this->getStyles('h2'), array('font-weight' => 'bold')),
1406
- 'wysija_title_3_strong' => array_merge($styles['titles'], $this->getStyles('h3'), array('font-weight' => 'bold')),
1407
- // italic tags in titles
1408
- 'wysija_title_1_italic' => array_merge($styles['titles'], $this->getStyles('h1'), array('font-style' => 'italic')),
1409
- 'wysija_title_2_italic' => array_merge($styles['titles'], $this->getStyles('h2'), array('font-style' => 'italic')),
1410
- 'wysija_title_3_italic' => array_merge($styles['titles'], $this->getStyles('h3'), array('font-style' => 'italic')),
1411
-
1412
- // links around images
1413
- 'wysija_image_link' => array('outline' => '0', 'border' => '0', 'margin' => '0', 'padding' => '0', 'display' => 'block'),
1414
-
1415
- // images
1416
- 'image_fix' => array('display' => 'block', 'outline' => '0', 'text-decoration' => 'none', 'interpolation' => 'bicubic'),
1417
-
1418
- // images alignments
1419
- 'wysija_image_table center' => array('margin' => '0 auto 0 auto', 'text-align' => 'center'),
1420
-
1421
- 'wysija_image_container center' => array_merge($styles['images'], array('padding' => '1em 0 0 0', 'margin' => '0 auto 0 auto', 'text-align' => 'left')),
1422
- 'wysija_image_container left' => array_merge($styles['images'], array('padding' => '1em 10px 1em 0')),
1423
- 'wysija_image_container right' => array_merge($styles['images'], array('padding' => '1em 0 1em 10px')),
1424
-
1425
- 'wysija_image_placeholder left' => array('padding' => '0 0 0 0', 'margin' => '3px 10px 1em 0', 'display' => 'block'),
1426
- 'wysija_image_placeholder right' => array('padding' => '0 0 0 0', 'margin' => '3px 0 1em 10px', 'display' => 'block'),
1427
-
1428
- // gallery
1429
- 'wysija_gallery_table center' => array('margin' => '0 auto 0 auto', 'text-align' => 'center'),
1430
- 'wysija_cell_container' => array('border' => $styles['images']['border'])
1431
- );
1432
- break;
1433
-
1434
- case 'viewbrowser':
1435
- $tags = array_merge($tags, array(
1436
- 'a' => $this->getStyles('viewbrowser')
1437
- ));
1438
-
1439
- $classes = array(
1440
- 'wysija_viewbrowser_container' => array_merge(
1441
- $this->getStyles('html'),
1442
- $this->getStyles('viewbrowser'),
1443
- array(
1444
- 'text-align' => 'center',
1445
- 'padding' => '8px'
1446
- )
1447
- )
1448
- );
1449
- break;
1450
-
1451
- case 'unsubscribe':
1452
- $tags = array_merge($tags, array(
1453
- 'a' => $this->getStyles('unsubscribe')
1454
- ));
1455
-
1456
- $classes = array(
1457
- 'wysija_unsubscribe_container' => array_merge(
1458
- $this->getStyles('html'),
1459
- $this->getStyles('unsubscribe'),
1460
- array(
1461
- 'family' => 'Verdana',
1462
- 'size' => '12',
1463
- 'text-align' => 'center',
1464
- 'padding' => '8px'
1465
- )
1466
- )
1467
- );
1468
- break;
1469
- }
1470
-
1471
- $tags_to_check = array('p', 'a', 'ul', 'li', 'h2');
1472
- $classes_to_check = array('wysija_content_container', 'wysija_image_container', 'wysija_divider_container', 'wysija_gallery_container', 'wysija_cell_container', 'wysija_list_bullet', 'wysija_list_value');
1473
-
1474
- // check tags and set custom background color
1475
- foreach($tags_to_check as $tag) {
1476
- if(isset($tags[$tag])) {
1477
- $tags[$tag]['background'] = $background_color;
1478
- }
1479
- }
1480
-
1481
- // check classes and set custom background color
1482
- foreach($classes_to_check as $class) {
1483
- if(isset($classes[$class])) {
1484
- $classes[$class]['background'] = $background_color;
1485
- }
1486
- }
1487
-
1488
- if(empty($tags) === FALSE) {
1489
-
1490
- foreach($tags as $tag => $styles) {
1491
- $styles = $this->splitSpacing($styles);
1492
- $inlineStyles = $helper_render_engine->render(array_merge($styles, array('tag' => $tag)), 'styles/inline.html');
1493
- $inlineStyles = preg_replace('/(\n*)/', '', $inlineStyles);
1494
- $tags['#< *'.$tag.'((?:(?!style).)*)>#Ui'] = '<'.$tag.' style="'.$inlineStyles.'"$1>';
1495
- unset($tags[$tag]);
1496
- }
1497
-
1498
- $block = preg_replace(array_keys($tags), $tags, $block);
1499
- }
1500
-
1501
- if(empty($classes) === FALSE) {
1502
- foreach($classes as $class => $styles) {
1503
- // split spacing styles
1504
- $styles = $this->splitSpacing($styles);
1505
- $inlineStyles = $helper_render_engine->render($styles, 'styles/inline.html');
1506
- $inlineStyles = preg_replace('/(\n*)/', '', $inlineStyles);
1507
-
1508
- // build regexp for this class
1509
- $classes['#<([^ /]+) ((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)class="([^"]*)'.$class.'([^"]*)"((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)>#Ui'] = '<$1 $2$4$7 class="$5'.$class.'$6" style="$3$8'.$inlineStyles.'" $9>';
1510
-
1511
- unset($classes[$class]);
1512
- }
1513
-
1514
- $styledBlock = preg_replace(array_keys($classes), $classes, $block);
1515
- // Check if the preg_replace worked. Otherwise we simply return the original block
1516
- if(strlen(trim($styledBlock)) > 0) {
1517
- $block = $styledBlock;
1518
- }
1519
- }
1520
-
1521
- return $block;
1522
- }
1523
-
1524
- function splitSpacing($styles) {
1525
- foreach($styles as $property => $value) {
1526
- if($property === 'margin' or $property === 'padding') {
1527
- // extract multi-values
1528
- $values = explode(' ', $value);
1529
-
1530
- // split values depending on values count
1531
- switch(count($values)) {
1532
- case 1:
1533
- $styles[$property.'-top'] = $values[0];
1534
- $styles[$property.'-right'] = $values[0];
1535
- $styles[$property.'-bottom'] = $values[0];
1536
- $styles[$property.'-left'] = $values[0];
1537
- break;
1538
- case 2:
1539
- $styles[$property.'-top'] = $values[0];
1540
- $styles[$property.'-right'] = $values[1];
1541
- $styles[$property.'-bottom'] = $values[0];
1542
- $styles[$property.'-left'] = $values[1];
1543
- break;
1544
- case 4:
1545
- $styles[$property.'-top'] = $values[0];
1546
- $styles[$property.'-right'] = $values[1];
1547
- $styles[$property.'-bottom'] = $values[2];
1548
- $styles[$property.'-left'] = $values[3];
1549
- break;
1550
- }
1551
-
1552
- // unset original value
1553
- unset($styles[$property]);
1554
- }
1555
- }
1556
- return $styles;
1557
- }
1558
-
1559
- function formatColor($color) {
1560
- if(strlen(trim($color)) === 0 or $color === 'transparent') {
1561
- return 'transparent';
1562
- } else {
1563
- return '#'.$color;
1564
- }
1565
- }
1566
-
1567
- function convertTitles($html) {
1568
- $patterns = array(
1569
- '/<h[1|2|3](.*?)>/',
1570
- '/<\/h[1|2|3]>/',
1571
- );
1572
-
1573
- $replacements = array(
1574
- '<p$1>',
1575
- '</p>'
1576
- );
1577
-
1578
- return preg_replace($patterns, $replacements, $html);
1579
- }
1580
-
1581
- // apply
1582
- function applyTitleClasses($html) {
1583
-
1584
- // set class for links in titles
1585
- $html = preg_replace_callback('#(<h([1|2|3]) ?((?:(?!>|class).)*)(?:class="([^"]*)")?((?:(?!>|class).)*)>(.*)<\/h[1|2|3]>)#Ui',
1586
- create_function('$matches',
1587
- '$output = $matches[0];'.
1588
- '$title_class = \'wysija_title_\'.(int)$matches[2];'.
1589
- '$link_class = $title_class.\'_link\';'.
1590
- '$strong_class = $title_class.\'_strong\';'.
1591
- '$italic_class = $title_class.\'_italic\';'.
1592
- '$output = str_replace(\'<a\', \'<a class="\'.$link_class.\'"\', $output);'.
1593
- '$output = str_replace(\'<strong\', \'<strong class="\'.$strong_class.\'"\', $output);'.
1594
- '$output = str_replace(\'<em\', \'<em class="\'.$italic_class.\'"\', $output);'.
1595
- '$output = str_replace(\'<h\'.(int)$matches[2], \'<h\'.(int)$matches[2].\' class="\'.$title_class.\'"\', $output);'.
1596
- 'return $output;'
1597
- ),
1598
- $html
1599
- );
1600
-
1601
- return $html;
1602
- }
1603
-
1604
- // converts lists (ul, ol, li) into paragraphs for email compatibility
1605
- function convertLists($html) {
1606
- $patterns = array(
1607
- '/<ul.*?>/',
1608
- '/<ol.*?>/',
1609
- '/<\/ul>/',
1610
- '/<\/ol>/',
1611
- '/<li ?((?:(?!>|class).)*)(?:class="([^"]*)")?((?:(?!>|class).)*)>/',
1612
- '/<\/li>/'
1613
- );
1614
-
1615
- $replacements = array(
1616
- '',
1617
- '',
1618
- '',
1619
- '',
1620
- '<p class="wysija_list_item $2">&bull;&nbsp;',
1621
- '</p>'
1622
- );
1623
-
1624
- return preg_replace($patterns, $replacements, $html);
1625
-
1626
- }
1627
  }
4
  * @class Wysija Engine Helper (PHP4 version)
5
  */
6
  class WYSIJA_help_wj_engine extends WYSIJA_object {
7
+ // debug mode
8
+ var $_debug = false;
9
+
10
+ // contains email data
11
+ var $_email_data = null;
12
+
13
+ // rendering context (editor, email)
14
+ var $_context = 'editor';
15
+
16
+ // toggles for vib & unsub
17
+ var $_hide_viewbrowser = false;
18
+ var $_hide_unsubscribe = false;
19
+
20
+ // data holders
21
+ var $_data = null;
22
+ var $_styles = null;
23
+
24
+ // styles: defaults
25
+ var $VIEWBROWSER_SIZES = array(7, 8, 9, 10, 11, 12, 13, 14);
26
+ var $TEXT_SIZES = array(8, 9, 10, 11, 12, 13, 14, 16, 18, 24, 36, 48, 72);
27
+ var $TITLE_SIZES = array(16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 40, 44, 48, 54, 60, 66, 72);
28
+ var $FONTS = array("Arial", "Arial Black", "Comic Sans MS", "Courier New", "Georgia", "Impact", "Tahoma", "Times New Roman", "Trebuchet MS", "Verdana");
29
+
30
+ /* Constructor */
31
+ function WYSIJA_help_wj_engine() { }
32
+
33
+ /* i18n methods */
34
+ function getTranslations() {
35
+ return array(
36
+ 'dropHeaderNotice' => __('Drop your logo in this header.',WYSIJA),
37
+ 'dropFooterNotice' => __('Drop your footer image here.',WYSIJA),
38
+ 'dropBannerNotice' => __('If you leave this area empty, it will not display once you send your email',WYSIJA),
39
+ 'clickToEditText' => __('Click here to add a title or text.', WYSIJA),
40
+ 'alignmentLeft' => __('Align left',WYSIJA),
41
+ 'alignmentCenter' => __('Align center',WYSIJA),
42
+ 'alignmentRight' => __('Align right',WYSIJA),
43
+ 'addImageLink' => __('Add link / Alternative text',WYSIJA),
44
+ 'removeImageLink' => __('Remove link',WYSIJA),
45
+ 'removeImage' => __('Remove image',WYSIJA),
46
+ 'remove' => __('Remove', WYSIJA),
47
+ 'editText' => __( 'Edit text',WYSIJA),
48
+ 'removeText' => __('Remove text',WYSIJA),
49
+ 'textLabel' => __('Titles & text',WYSIJA),
50
+ 'dividerLabel' => __('Horizontal line',WYSIJA),
51
+ 'customDividerLabel' => __('Custom horizontal line',WYSIJA),
52
+ 'postLabel' => __('WordPress post',WYSIJA),
53
+ 'styleBodyLabel' => __('Text',WYSIJA),
54
+ 'styleViewbrowserLabel' => __('"View in browser"', WYSIJA),
55
+ 'styleH1Label' => __('Heading 1',WYSIJA),
56
+ 'styleH2Label' => __('Heading 2',WYSIJA),
57
+ 'styleH3Label' => __('Heading 3',WYSIJA),
58
+ 'styleLinksLabel' => __('Links',WYSIJA),
59
+ 'styleLinksDecorationLabel' => __('underline',WYSIJA),
60
+ 'styleFooterLabel' => __('Footer text',WYSIJA),
61
+ 'styleFooterBackgroundLabel' => __('Footer background',WYSIJA),
62
+ 'styleBodyBackgroundLabel' => __('Newsletter',WYSIJA),
63
+ 'styleHtmlBackgroundLabel' => __('Background', WYSIJA),
64
+ 'styleHeaderBackgroundLabel' => __('Header background', WYSIJA),
65
+ 'styleDividerLabel' => __('Horizontal line',WYSIJA),
66
+ 'styleUnsubscribeColorLabel' => __('Unsubscribe',WYSIJA),
67
+ 'articleSelectionTitle' => __('Post Selection', WYSIJA),
68
+ 'bookmarkSelectionTitle' => __('Social Bookmark Selection', WYSIJA),
69
+ 'dividerSelectionTitle' => __('Divider Selection', WYSIJA),
70
+ 'abouttodeletetheme' => __('You are about to delete the theme : %1$s. Do you really want to do that?', WYSIJA),
71
+ 'addLinkTitle' => __('Add Link & Alternative text', WYSIJA),
72
+ 'styleTransparent' => __('Check this box if you want transparency', WYSIJA),
73
+ 'ajaxLoading' => __('Loading...', WYSIJA),
74
+ 'customFieldsLabel' => __('Insert dynamic data about your subscribers, the newsletter, today\'s date, etc...', WYSIJA),
75
+ 'autoPostSettingsTitle' => __('Selection options', WYSIJA),
76
+ 'autoPostEditSettings' => __('Edit Automatic latest content', WYSIJA),
77
+ 'autoPostImmediateNotice' => __('You can only add one widget when designing a post notification sent immediately after an article is published', WYSIJA),
78
+ 'toggleImagesTitle' => __('Preview without images', WYSIJA),
79
+ // Tags labels
80
+ 'tags_user' => __('Subscriber', WYSIJA),
81
+ 'tags_user_firstname' => __('First Name', WYSIJA),
82
+ 'tags_user_lastname' => __('Last Name', WYSIJA),
83
+ 'tags_user_email' => __('Email Address', WYSIJA),
84
+ 'tags_user_displayname' => __('WordPress user display name', WYSIJA),
85
+ 'tags_user_count' => __('Total of subscribers', WYSIJA),
86
+ 'tags_newsletter' => __('Newsletter', WYSIJA),
87
+ 'tags_newsletter_subject' => __('Newsletter Subject', WYSIJA),
88
+ 'tags_newsletter_autonl' => __('Post Notifications', WYSIJA),
89
+ 'tags_newsletter_total' => __('Total number of posts or pages', WYSIJA),
90
+ 'tags_newsletter_post_title' => __('Latest post title', WYSIJA),
91
+ 'tags_newsletter_number' => __('Issue number', WYSIJA),
92
+ 'tags_date' => __('Date', WYSIJA),
93
+ 'tags_date_d' => __('Current day of the month number', WYSIJA),
94
+ 'tags_date_dordinal' => __('Current day of the month in ordinal, ie. 2nd, 3rd, etc.', WYSIJA),
95
+ 'tags_date_dtext' => __('Full name of current day', WYSIJA),
96
+ 'tags_date_m' => __('Current month number', WYSIJA),
97
+ 'tags_date_mtext' => __('Full name of current month', WYSIJA),
98
+ 'tags_date_y' => __('Year', WYSIJA),
99
+ 'tags_global' => __('Links', WYSIJA),
100
+ 'tags_global_unsubscribe' => __('Unsubscribe link', WYSIJA),
101
+ 'tags_global_manage' => __('Edit subscription page link', WYSIJA),
102
+ 'tags_global_browser' => __('View in browser link', WYSIJA),
103
+ 'custom_fields_title' => __('Custom Fields', WYSIJA),
104
+ 'custom_fields_list' => WJ_Field::get_all_names(),
105
+ // Themes specific labels
106
+ 'theme_setting_default' => __('Saving default style...', WYSIJA),
107
+ 'theme_saved_default' => __('Default style saved.', WYSIJA),
108
+ 'theme_save_as_default' => __('Set as default style.', WYSIJA)
109
+ );
110
+ }
111
+
112
+ /* Data methods */
113
+ function getData($type = null) {
114
+ if($type !== null) {
115
+ if(array_key_exists($type, $this->_data)) {
116
+ return $this->_data[$type];
117
+ } else {
118
+ // return default value
119
+ $defaults = $this->getDefaultData();
120
+ return $defaults[$type];
121
+ }
122
+ }
123
+ return $this->_data;
124
+ }
125
+
126
+ function setData($value = null, $decode = false) {
127
+ if(!$value) {
128
+ $this->_data = $this->getDefaultData();
129
+ } else {
130
+ $this->_data = $value;
131
+ if($decode) {
132
+ $this->_data = $this->getDecoded('data');
133
+ }
134
+ }
135
+ }
136
+
137
+ function getEmailData($key = null) {
138
+ if($key === null) {
139
+ return $this->_email_data;
140
+ } else {
141
+ if(array_key_exists($key, $this->_email_data)) {
142
+ return $this->_email_data[$key];
143
+ }
144
+ }
145
+ return null;
146
+ }
147
+
148
+ function setEmailData($value = null) {
149
+ if($value !== null) {
150
+ $this->_email_data = $value;
151
+ }
152
+ }
153
+
154
+ function getDefaultData() {
155
+ $dividersHelper = WYSIJA::get('dividers', 'helper');
156
+ return array(
157
+ 'header' => array(
158
+ 'alignment' => 'center',
159
+ 'type' => 'header',
160
+ 'static' => '1',
161
+ 'text' => null,
162
+ 'image' => array(
163
+ 'src' => null,
164
+ 'width' => 600,
165
+ 'height' => 86,
166
+ 'url' => null,
167
+ 'alignment' => 'center',
168
+ 'static' => '1'
169
+ )
170
+ ),
171
+ 'body' => array(),
172
+ 'footer' => array(
173
+ 'alignment' => 'center',
174
+ 'type' => 'footer',
175
+ 'static' => '1',
176
+ 'text' => null,
177
+ 'image' => array(
178
+ 'src' => null,
179
+ 'width' => 600,
180
+ 'height' => 86,
181
+ 'url' => null,
182
+ 'alignment' => 'center',
183
+ 'static' => '1'
184
+ )
185
+ ),
186
+ 'widgets' => array(
187
+ 'divider' => array_merge($dividersHelper->getDefault(), array('type' => 'divider'))
188
+ )
189
+ );
190
+ }
191
+
192
+ /* Styles methods */
193
+ function getStyles($keys = null) {
194
+ if($keys === null) return $this->_styles;
195
+
196
+ if(!is_array($keys)) {
197
+ $keys = array($keys);
198
+ }
199
+ $output = array();
200
+ for($i=0; $i<count($keys);$i++) {
201
+ if(isset($this->_styles[$keys[$i]])) {
202
+ $output = array_merge($output, $this->_styles[$keys[$i]]);
203
+ }
204
+ }
205
+ return $output;
206
+ }
207
+
208
+ function getStyle($key, $subkey) {
209
+ $styles = $this->getStyles($key);
210
+ return $styles[$subkey];
211
+ }
212
+
213
+ function setStyles($value = null, $decode = false) {
214
+ if(!$value) {
215
+ $this->_styles = $this->getDefaultStyles();
216
+ } else {
217
+ $this->_styles = $value;
218
+ if($decode) {
219
+ $this->_styles = $this->getDecoded('styles');
220
+ }
221
+ }
222
+ }
223
+
224
+ function getDefaultStyles() {
225
+
226
+ $defaults = array(
227
+ 'html' => array(
228
+ 'background' => 'FFFFFF'
229
+ ),
230
+ 'header' => array(
231
+ 'background' => 'FFFFFF'
232
+ ),
233
+ 'body' => array(
234
+ 'color' => '000000',
235
+ 'family' => 'Arial',
236
+ 'size' => $this->TEXT_SIZES[5],
237
+ 'background' => 'FFFFFF'
238
+ ),
239
+ 'footer' => array(
240
+ 'color' => '000000',
241
+ 'family' => 'Arial',
242
+ 'size' => $this->TEXT_SIZES[5],
243
+ 'background' => 'cccccc'
244
+ ),
245
+ 'h1' => array(
246
+ 'color' => '000000',
247
+ 'family' => 'Arial',
248
+ 'size' => $this->TITLE_SIZES[6]
249
+ ),
250
+ 'h2' => array(
251
+ 'color' => '424242',
252
+ 'family' => 'Arial',
253
+ 'size' => $this->TITLE_SIZES[5]
254
+ ),
255
+ 'h3' => array(
256
+ 'color' => '424242',
257
+ 'family' => 'Arial',
258
+ 'size' => $this->TITLE_SIZES[4]
259
+ ),
260
+ 'a' => array(
261
+ 'color' => '4a91b0',
262
+ 'underline' => false
263
+ ),
264
+ 'unsubscribe' => array(
265
+ 'color' => '000000'
266
+ ),
267
+ 'viewbrowser' => array(
268
+ 'color' => '000000',
269
+ 'family' => 'Arial',
270
+ 'size' => $this->VIEWBROWSER_SIZES[4]
271
+ )
272
+ );
273
+
274
+ // get default selected theme
275
+ $model_config = WYSIJA::get('config', 'model');
276
+ $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
277
+
278
+ if($default_theme === 'default') {
279
+ return $defaults;
280
+ } else {
281
+ $helper_themes = WYSIJA::get('themes', 'helper');
282
+ $stylesheet = $helper_themes->getStylesheet($default_theme);
283
+
284
+ $styles = array();
285
+ // look for each tags
286
+ foreach($defaults as $tag => $values) {
287
+ // look for css rules
288
+ preg_match('/\.?'.$tag.'\s?{(.+)}/Ui', $stylesheet, $matches);
289
+ if(isset($matches[1])) {
290
+ // extract styles
291
+ $styles[$tag] = $this->extractStyles($matches[1]);
292
+ } else {
293
+ // fallback to default
294
+ $styles[$tag] = $defaults[$tag];
295
+ }
296
+ }
297
+
298
+ return $styles;
299
+ }
300
+ }
301
+
302
+ function getApplicationData() {
303
+ $app = array();
304
+
305
+ $app['domain'] = WJ_Utils::get_domain();
306
+
307
+ return $app;
308
+ }
309
+
310
+ /* Editor methods */
311
+ function renderEditor() {
312
+ $this->setContext('editor');
313
+
314
+ if($this->isDataValid() === false) {
315
+ throw new Exception('data is not valid');
316
+ } else {
317
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
318
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
319
+
320
+ // get company addressfrom settings
321
+ $config=WYSIJA::get("config","model");
322
+
323
+ $data = array(
324
+ 'header' => $this->renderEditorHeader(),
325
+ 'body' => $this->renderEditorBody(),
326
+ 'footer' => $this->renderEditorFooter(),
327
+ 'unsubscribe' => $config->emailFooterLinks(true),
328
+ 'company_address' => nl2br($config->getValue('company_address')),
329
+ 'is_debug' => $this->isDebug(),
330
+ 'i18n' => $this->getTranslations()
331
+ );
332
+
333
+ $viewbrowser = $config->viewInBrowserLink(true);
334
+ if($viewbrowser) {
335
+ $data['viewbrowser'] = $viewbrowser;
336
+ }
337
+
338
+ return $helper_render_engine->render($data, 'templates/editor/editor_template.html');
339
+ }
340
+ }
341
+
342
+ function renderEditorHeader($data = null) {
343
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
344
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
345
+ $helper_render_engine->setStripSpecialchars(true);
346
+
347
+ if($data !== null) {
348
+ $block = $data;
349
+ } else {
350
+ $block = $this->getData('header');
351
+ }
352
+
353
+ $data = array_merge($block, array('i18n' => $this->getTranslations()));
354
+ return $helper_render_engine->render($data, 'templates/editor/header_template.html');
355
+ }
356
+
357
+ function renderEditorBody() {
358
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
359
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
360
+
361
+ $blocks = $this->getData('body');
362
+ if(empty($blocks)) return '';
363
+
364
+ $body = '';
365
+ foreach($blocks as $key => $block) {
366
+ // generate block template
367
+ $data = array_merge($block, array('i18n' => $this->getTranslations()));
368
+ $body .= $helper_render_engine->render($data, 'templates/editor/block_template.html');
369
+ }
370
+
371
+ return $body;
372
+ }
373
+
374
+ function renderEditorFooter($data = null)
375
+ {
376
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
377
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
378
+
379
+ if($data !== null) {
380
+ $block = $data;
381
+ } else {
382
+ $block = $this->getData('footer');
383
+ }
384
+
385
+ $data = array_merge($block, array('i18n' => $this->getTranslations()));
386
+
387
+ return $helper_render_engine->render($data, 'templates/editor/footer_template.html');
388
+ }
389
+
390
+ function renderEditorBlock($block = array()) {
391
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
392
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
393
+ $helper_render_engine->setStripSpecialchars(true);
394
+
395
+ $block['i18n'] = $this->getTranslations();
396
+
397
+ return $helper_render_engine->render($block, 'templates/editor/block_'.$block['type'].'.html');
398
+ }
399
+
400
+ /* render auto post */
401
+ function renderEditorAutoPost($posts = array(), $params = array()) {
402
+ $output = '';
403
+ if(isset($params['post_ids'])) {
404
+ $output .= '<input type="hidden" name="post_ids" value="'.$params['post_ids'].'" />';
405
+ }
406
+
407
+ // check if there are posts to display
408
+ if(empty($posts)) {
409
+ // set background color
410
+ $background_color = '';
411
+ if(isset($params['bgcolor1'])) {
412
+ $background_color = $params['bgcolor1'];
413
+ }
414
+
415
+ // display a message stating that the latest content has been sent
416
+ $block = array(
417
+ 'no-block' => true,
418
+ 'type' => 'content',
419
+ 'alignment' => 'center',
420
+ 'background_color' => $background_color,
421
+ 'image' => null,
422
+ 'text' => array('value' => base64_encode(__('Latest content already sent.', WYSIJA)))
423
+ );
424
+ $output .= $this->renderEditorBlock($block);
425
+ } else {
426
+ // otherwise, render all posts into blocks
427
+ $output .= $this->renderPostsToBlocks($posts, $params, 'autopost');
428
+ }
429
+
430
+ return $output;
431
+ }
432
+
433
+ function renderEmailAutoPost($posts = array(), $params = array()) {
434
+ if(empty($posts)) {
435
+ return '';
436
+ } else {
437
+ return $this->renderPostsToBlocks($posts, $params, 'autopost');
438
+ }
439
+ }
440
+
441
+ function renderEmailBlock($block = array()) {
442
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
443
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
444
+ $helper_render_engine->setStripSpecialchars(true);
445
+
446
+ // set block background color
447
+ $background_color = null;
448
+ if(isset($block['background_color'])) {
449
+ $background_color = $block['background_color'];
450
+ }
451
+
452
+ return $this->applyInlineStyles(
453
+ 'body',
454
+ $helper_render_engine->render($block, 'templates/email_v3/block_'.$block['type'].'.html'),
455
+ array('background_color' => $background_color)
456
+ );
457
+ }
458
+
459
+ function renderPostsToBlocks($posts = array(), $params = array(), $mode = 'post') {
460
+ $html = '';
461
+ $context = $this->getContext();
462
+
463
+ $helper_articles = WYSIJA::get('articles', 'helper');
464
+
465
+ if($params['title_tag'] === 'list') {
466
+ $list = '<ul class="align-'.$params['title_alignment'].'">';
467
+ }
468
+
469
+ // make sure empty bgcolors are set to transparent
470
+ if(!isset($params['bgcolor1']) || (isset($params['bgcolor1']) && strlen($params['bgcolor1']) === 0)) {
471
+ $params['bgcolor1'] = '';
472
+ }
473
+ if(!isset($params['bgcolor2']) || (isset($params['bgcolor2']) && strlen($params['bgcolor2']) === 0)) {
474
+ $params['bgcolor2'] = '';
475
+ }
476
+
477
+ // BEGIN - posts
478
+ for($i = 0, $count = count($posts); $i < $count; $i++) {
479
+ $post = $posts[$i];
480
+ $is_odd = (bool)($i % 2);
481
+ $is_last = (bool)($i === ($count - 1));
482
+
483
+ // set default background color to transparent
484
+ $background_color = '';
485
+
486
+ // set background color for each post
487
+ if($is_odd === false) $background_color = $params['bgcolor1'];
488
+ if($is_odd === true) $background_color = $params['bgcolor2'];
489
+
490
+ if($params['image_alignment'] === 'alternate') {
491
+ $image_alignment = ($is_odd === false) ? 'left' : 'right';
492
+ } else if($params['image_alignment'] === 'none') {
493
+ $image_alignment = 'left';
494
+ $post['post_image'] = null;
495
+ } else {
496
+ $image_alignment = $params['image_alignment'];
497
+ }
498
+
499
+ // build basic block data
500
+ $block = array(
501
+ 'position' => $i,
502
+ 'type' => 'content',
503
+ 'alignment' => $image_alignment,
504
+ 'background_color' => $background_color,
505
+ 'image' => null,
506
+ 'text' => null
507
+ );
508
+
509
+ // in case of autopost, we need to remove the "block" container because each block will be rendered within the autopost block
510
+ if($mode === 'autopost') {
511
+ $block['no-block'] = true;
512
+ }
513
+
514
+ // get title
515
+ $title = $helper_articles->getPostTitle($post, $params);
516
+
517
+ if(!isset($params['title_position'])) {
518
+ $params['title_position'] = 'inside';
519
+ }
520
+
521
+ // if post content is title, force title position inside
522
+ if($params['post_content'] === 'title') {
523
+ $params['title_position'] = 'inside';
524
+ }
525
+
526
+ // only display titles as a list
527
+ if($params['title_tag'] === 'list') {
528
+ $list .= $title;
529
+ continue;
530
+ }
531
+
532
+ // if the title is outside, generate its own block
533
+ if($params['title_position'] === 'outside') {
534
+ // generate title
535
+ $title_block = array_merge($block, array(
536
+ 'alignment' => 'left',
537
+ 'text' => array(
538
+ 'value' => base64_encode($title)
539
+ )
540
+ ));
541
+
542
+ if($context === 'editor') {
543
+ $html .= $this->renderEditorBlock($title_block);
544
+ } else if($context === 'email') {
545
+ $html .= $this->renderEmailBlock($title_block);
546
+ }
547
+ }
548
+
549
+ // generate content
550
+ $content_block = array_merge($block, $helper_articles->convertPostToBlock($post, array_merge($params, array('image_alignment' => $image_alignment))));
551
+
552
+ if($context === 'editor') {
553
+ $html .= $this->renderEditorBlock($content_block);
554
+ } else if($context === 'email') {
555
+ $html .= $this->renderEmailBlock($content_block);
556
+ }
557
+
558
+ // display divider if required
559
+ if(isset($params['divider']) && ($params['divider'] !== null && $is_last === false)) {
560
+ // display divider only if there is one and if it's not the last post
561
+ $divider_block = array_merge(
562
+ array(
563
+ 'type' => 'divider',
564
+ 'no-block' => ($mode === 'autopost')
565
+ ),
566
+ $params['divider']
567
+ );
568
+
569
+ if($context === 'editor') {
570
+ $html .= $this->renderEditorBlock($divider_block);
571
+ } else if($context === 'email') {
572
+ $html .= $this->renderEmailBlock($divider_block);
573
+ }
574
+ }
575
+ }
576
+ // END - Posts
577
+
578
+ if($params['title_tag'] === 'list') {
579
+ $list .= '</ul>';
580
+ $list_block = array_merge($block, array(
581
+ 'alignment' => 'center',
582
+ 'type' => 'content',
583
+ 'text' => array(
584
+ 'value' => base64_encode($list)
585
+ )
586
+ ));
587
+ $html .= $this->renderEditorBlock($list_block);
588
+ }
589
+
590
+ return $html;
591
+ }
592
+
593
+ /* render draggable images list */
594
+ function renderImages($data = array()) {
595
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
596
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
597
+
598
+ return $helper_render_engine->render(array('images' => $data), 'templates/toolbar/images.html');
599
+ }
600
+
601
+ /* render themes list */
602
+ function renderThemes() {
603
+ $themes = array();
604
+ $hThemes = WYSIJA::get('themes', 'helper');
605
+
606
+ $installed = $hThemes->getInstalled();
607
+
608
+ // get default selected theme
609
+ $model_config = WYSIJA::get('config', 'model');
610
+ $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
611
+
612
+ if(empty($installed)) {
613
+ return '';
614
+ } else {
615
+ foreach($installed as $theme) {
616
+ $theme_info = $hThemes->getInformation($theme);
617
+ $theme_info['is_selected'] = (bool)($default_theme === $theme);
618
+ $themes[] = $theme_info;
619
+ }
620
+ }
621
+
622
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
623
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
624
+
625
+ return $helper_render_engine->render(array('themes' => $themes, 'i18n' => $this->getTranslations()), 'templates/toolbar/themes.html');
626
+ }
627
+
628
+ function renderThemeStyles($theme = 'default') {
629
+ $this->setContext('editor');
630
+
631
+ $hThemes = WYSIJA::get('themes', 'helper');
632
+ $stylesheet = $hThemes->getStylesheet($theme);
633
+
634
+ if($stylesheet === NULL) {
635
+ // load default settings
636
+ $this->setStyles(null);
637
+ } else {
638
+ // a stylesheet has been found, let's extract styles
639
+ $styles = array();
640
+ $defaults = $this->getDefaultStyles();
641
+ // look for each tags
642
+ foreach($defaults as $tag => $values) {
643
+ // look for css rules
644
+ preg_match('/\.?'.$tag.'\s?{(.+)}/Ui', $stylesheet, $matches);
645
+ if(isset($matches[1])) {
646
+ // extract styles
647
+ $styles[$tag] = $this->extractStyles($matches[1]);
648
+ } else {
649
+ // fallback to default
650
+ $styles[$tag] = $defaults[$tag];
651
+ }
652
+ }
653
+ $this->setStyles($styles);
654
+ }
655
+
656
+ return array(
657
+ 'css' => $this->renderStyles(),
658
+ 'form' => $this->renderStylesBar()
659
+ );
660
+ }
661
+
662
+ function extractStyles($raw) {
663
+ $rules = explode(';', $raw);
664
+ $output = array();
665
+ foreach($rules as $rule) {
666
+ $sub_property = false;
667
+ $combo = explode(':', $rule);
668
+ if(count($combo) === 2) {
669
+ list($property, $value) = $combo;
670
+ // remove leading and trailing space
671
+ $property = trim($property);
672
+ $value = trim($value);
673
+ } else {
674
+ continue;
675
+ }
676
+
677
+ switch($property) {
678
+ case 'background':
679
+ case 'background-color':
680
+ $property = 'background';
681
+ case 'color':
682
+ // remove # from color
683
+ $value = str_replace('#', '', $value);
684
+ // check if its a 3 chars color
685
+ if(strlen($value) === 3) {
686
+ $value = sprintf('%s%s%s%s%s%s', substr($value, 0, 1), substr($value, 0, 1), substr($value, 1, 1), substr($value, 1, 1), substr($value, 2, 1), substr($value, 2, 1));
687
+ }
688
+ break;
689
+ case 'font-family':
690
+ $property = 'family';
691
+ $fonts = explode(',', $value);
692
+ $value = array_shift($fonts);
693
+ break;
694
+ case 'font-size':
695
+ $property = 'size';
696
+ case 'height':
697
+ $value = (int)$value;
698
+ break;
699
+ case 'text-decoration':
700
+ $property = 'underline';
701
+ $value = ($value === 'none') ? '-1' : '1';
702
+ break;
703
+ case 'border-color':
704
+ // remove # from color
705
+ $value = str_replace('#', '', $value);
706
+ // check if its a 3 chars color
707
+ if(strlen($value) === 3) {
708
+ $value = sprintf('%s%s%s%s%s%s', substr($value, 0, 1), substr($value, 0, 1), substr($value, 1, 1), substr($value, 1, 1), substr($value, 2, 1), substr($value, 2, 1));
709
+ }
710
+ list($property, $sub_property) = explode('-', $property);
711
+ break;
712
+ case 'border-size':
713
+ $value = (int)$value;
714
+ list($property, $sub_property) = explode('-', $property);
715
+ break;
716
+ case 'border-style':
717
+ list($property, $sub_property) = explode('-', $property);
718
+ break;
719
+ }
720
+
721
+ if($sub_property !== FALSE) {
722
+ $output[$property][$sub_property] = $value;
723
+ } else {
724
+ $output[$property] = $value;
725
+ }
726
+ }
727
+ return $output;
728
+ }
729
+
730
+ function renderTheme($theme = 'default') {
731
+ $output = array(
732
+ 'header' => null,
733
+ 'footer' => null,
734
+ 'divider' => null
735
+ );
736
+
737
+ $hThemes = WYSIJA::get('themes', 'helper');
738
+ $data = $hThemes->getData($theme);
739
+
740
+ if($data['header'] !== NULL) {
741
+ $output['header'] = $this->renderEditorHeader($data['header']);
742
+ }
743
+
744
+ if($data['footer'] !== NULL) {
745
+ $output['footer'] = $this->renderEditorFooter($data['footer']);
746
+ }
747
+
748
+ if($data['divider'] !== NULL) {
749
+ $output['divider'] = $this->renderEditorBlock(array_merge(array('no-block' => true), $data['divider']));
750
+ $output['divider_options'] = $data['divider'];
751
+ }
752
+
753
+ return $output;
754
+ }
755
+
756
+ /* render styles bar */
757
+ function renderStylesBar() {
758
+ $this->setContext('editor');
759
+
760
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
761
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
762
+ $helper_render_engine->setStripSpecialchars(true);
763
+
764
+ $data = $this->getStyles();
765
+ $data['i18n'] = $this->getTranslations();
766
+ $data['TEXT_SIZES'] = $this->TEXT_SIZES;
767
+ $data['VIEWBROWSER_SIZES'] = $this->VIEWBROWSER_SIZES;
768
+ $data['TITLE_SIZES'] = $this->TITLE_SIZES;
769
+ $data['FONTS'] = $this->FONTS;
770
+
771
+ return $helper_render_engine->render($data, 'templates/toolbar/styles.html');
772
+ }
773
+
774
+ function formatStyles($styles = array()) {
775
+ if(empty($styles)) return;
776
+
777
+ $data = array();
778
+ foreach($styles as $style => $value) {
779
+ $stylesArray = explode('-', $style);
780
+ if(count($stylesArray) === 2) {
781
+ $data[$stylesArray[0]][$stylesArray[1]] = $value;
782
+ } else if(count($stylesArray) === 3) {
783
+ // handle transparent colors
784
+ if($stylesArray[2] === 'transparent') {
785
+ $data[$stylesArray[0]][$stylesArray[1]] = $stylesArray[2];
786
+ } else {
787
+ $data[$stylesArray[0]][$stylesArray[1]][$stylesArray[2]] = $value;
788
+ }
789
+ }
790
+ }
791
+
792
+ return $data;
793
+ }
794
+
795
+ function getContext() {
796
+ return $this->_context;
797
+ }
798
+
799
+ function setContext($value = null) {
800
+ if($value !== null) $this->_context = $value;
801
+ }
802
+
803
+ function isDebug() {
804
+ return ($this->_debug === true);
805
+ }
806
+
807
+ function getEncoded($type = 'data') {
808
+ return base64_encode(serialize($this->{'get'.ucfirst($type)}()));
809
+ }
810
+
811
+ function getDecoded($type = 'data') {
812
+ return unserialize(base64_decode($this->{'get'.ucfirst($type)}()));
813
+ }
814
+
815
+ /* methods */
816
+ function isDataValid() {
817
+ return ($this->getData() !== null);
818
+ }
819
+
820
+ /* Styles methods */
821
+ function renderStyles() {
822
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
823
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
824
+ $helper_render_engine->setStripSpecialchars(true);
825
+ $helper_render_engine->setInline(true);
826
+
827
+ $data = $this->getStyles();
828
+ $data['context'] = $this->getContext();
829
+
830
+ // right to left language property
831
+ if(function_exists('is_rtl')) {
832
+ $data['is_rtl'] = is_rtl();
833
+ } else {
834
+ $data['is_rtl'] = false;
835
+ }
836
+
837
+ switch($data['context']) {
838
+ case 'editor':
839
+ $helper_render_engine->setStripSpecialchars(false);
840
+ $data['viewbrowser_container'] = '#wysija_viewbrowser';
841
+ $data['wysija_container'] = '#wysija_wrapper';
842
+ $data['header_container'] = '#wysija_header';
843
+ $data['body_container'] = '#wysija_body';
844
+ $data['text_container'] = '.editable';
845
+ $data['footer_container'] = '#wysija_footer';
846
+ $data['placeholder_container'] = '#wysija_block_placeholder';
847
+ $data['unsubscribe_container'] = '#wysija_unsubscribe';
848
+ return $helper_render_engine->render($data, 'styles/css-'.$data['context'].'.html');
849
+ break;
850
+
851
+ case 'email':
852
+ $helper_render_engine->setStripSpecialchars(true);
853
+ $data['viewbrowser_container'] = '#wysija_viewbrowser';
854
+ $data['wysija_container'] = '#wysija_wrapper';
855
+ $data['header_container'] = '#wysija_header_content';
856
+ $data['body_container'] = '#wysija_body_content';
857
+ $data['footer_container'] = '#wysija_footer_content';
858
+ $data['text_container'] = '.wysija-text-container';
859
+ $data['unsubscribe_container'] = '#wysija_unsubscribe';
860
+
861
+ return $helper_render_engine->render($data, 'templates/email_v3/css.html');
862
+ break;
863
+ }
864
+ }
865
+
866
+ /* Email methods */
867
+ function renderNotification($email = NULL) {
868
+ $this->_hide_viewbrowser = true;
869
+ $this->_hide_unsubscribe = true;
870
+ return $this->renderEmail($email);
871
+ }
872
+
873
+ function renderEmail($email = NULL) {
874
+
875
+ // fixes issue with pcre functions
876
+ @ini_set('pcre.backtrack_limit', 1000000);
877
+
878
+ $this->setContext('email');
879
+
880
+ if($this->isDataValid() === false) {
881
+ throw new Exception('data is not valid');
882
+ } else {
883
+ // set email data for later use
884
+ $this->setEmailData($email);
885
+
886
+ // render header
887
+ $data = array(
888
+ 'viewbrowser' => $this->renderEmailViewBrowser(),
889
+ 'header' => $this->renderEmailHeader(),
890
+ 'body' => $this->renderEmailBody(),
891
+ 'footer' => $this->renderEmailFooter(),
892
+ 'unsubscribe' => $this->renderEmailUnsubscribe(),
893
+ 'css' => $this->renderStyles(),
894
+ 'styles' => $this->getStyles(),
895
+ 'hide_viewbrowser' => $this->_hide_viewbrowser,
896
+ 'hide_unsubscribe' => $this->_hide_unsubscribe
897
+ );
898
+
899
+ //right to left language property
900
+ if(function_exists('is_rtl')) {
901
+ $data['is_rtl'] = is_rtl();
902
+ } else {
903
+ $data['is_rtl'] = false;
904
+ }
905
+
906
+ // set email subject if specified
907
+ $data['subject'] = $this->getEmailData('subject');
908
+
909
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
910
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
911
+ $helper_render_engine->setStripSpecialchars(true);
912
+ $helper_render_engine->setInline(true);
913
+
914
+ try {
915
+ $template = $helper_render_engine->render($data, 'templates/email_v3/email_template.html');
916
+ return $template;
917
+ } catch(Exception $e) {
918
+ return '';
919
+ }
920
+ }
921
+ }
922
+
923
+ function renderEmailViewBrowser() {
924
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
925
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
926
+ $helper_render_engine->setStripSpecialchars(true);
927
+
928
+ $config=WYSIJA::get('config','model');
929
+ $data = $config->viewInBrowserLink();
930
+ if(!isset($data['link'])) {
931
+ return '';
932
+ } else {
933
+ // generate block template
934
+ $viewbrowser = $helper_render_engine->render($data, 'templates/email_v3/viewbrowser_template.html');
935
+
936
+ // apply inline styles
937
+ $viewbrowser = $this->applyInlineStyles('viewbrowser', $viewbrowser);
938
+
939
+ return $viewbrowser;
940
+ }
941
+ }
942
+
943
+ function renderEmailUnsubscribe() {
944
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
945
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
946
+ $helper_render_engine->setStripSpecialchars(true);
947
+
948
+ $config = WYSIJA::get('config','model');
949
+
950
+ $data = array(
951
+ 'unsubscribe' => $config->emailFooterLinks(),
952
+ 'company_address' => nl2br($config->getValue('company_address'))
953
+ );
954
+
955
+ // generate block template
956
+ $unsubscribe = $helper_render_engine->render($data, 'templates/email_v3/unsubscribe_template.html');
957
+
958
+ // apply inline styles
959
+ $unsubscribe = $this->applyInlineStyles('unsubscribe', $unsubscribe);
960
+
961
+ return $unsubscribe;
962
+ }
963
+
964
+ function renderEmailHeader() {
965
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
966
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
967
+ $helper_render_engine->setStripSpecialchars(true);
968
+
969
+ $data = $this->getData('header');
970
+ $data['styles'] = array('header' => $this->getStyles('header'));
971
+
972
+ // check for emptyness
973
+ if($data['text'] === NULL and $data['image']['static'] === TRUE) {
974
+ return NULL;
975
+ }
976
+
977
+ // set header content width
978
+ $data['block_width'] = 600;
979
+
980
+ // generate block template
981
+ $header = $helper_render_engine->render($data, 'templates/email_v3/header_template.html');
982
+
983
+ // apply inline styles
984
+ $header = $this->applyInlineStyles('header', $header);
985
+
986
+ return $header;
987
+ }
988
+
989
+ function encodeParameters($params = array()) {
990
+ // encode string parameters
991
+ $keys_to_encode = array('author_label', 'category_label', 'readmore');
992
+ foreach($keys_to_encode as $key) {
993
+ if(isset($params[$key]) && strlen(trim($params[$key])) > 0) {
994
+ $params[$key] = base64_encode(stripslashes($params[$key]));
995
+ }
996
+ }
997
+ return $params;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
998
  }
999
 
1000
  function decodeParameters($params = array()) {
1001
+ // decode string parameters
1002
+ $keys_to_decode = array('author_label', 'category_label', 'readmore');
1003
+ foreach($keys_to_decode as $key) {
1004
+ if(isset($params[$key]) && strlen(trim($params[$key])) > 0) {
1005
+ $params[$key] = base64_decode($params[$key]);
1006
+ }
1007
+ }
1008
+ return $params;
1009
  }
1010
 
1011
+ function renderEmailBody() {
1012
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1013
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1014
+ $helper_render_engine->setStripSpecialchars(true);
1015
+
1016
+ $blocks = $this->getData('body');
1017
+ $styles = array('body' => $this->getStyles('body'));
1018
+
1019
+ // default newsletter type
1020
+ $newsletter_type = 'default';
1021
+
1022
+ // check if we need to interpret shortcodes
1023
+ $model_config = WYSIJA::get('config', 'model');
1024
+ $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
1025
+
1026
+ $body = '';
1027
+
1028
+ // check if we are dealing with an auto newsletter
1029
+ $email = $this->getEmailData();
1030
+ if(isset($email['params']['autonl']) && !empty($email['params']['autonl'])) {
1031
+ // set newsletter type to automattic newsletter
1032
+ $newsletter_type = 'automatic';
1033
+ // reset category_ids
1034
+ $include_category_ids = array();
1035
+ $exclude_category_ids = array();
1036
+
1037
+ // posts data
1038
+ $first_subject = null;
1039
+ $post_count = 0;
1040
+ $post_ids = array();
1041
+
1042
+ }
1043
+
1044
+ foreach($blocks as $key => $block) {
1045
+ // reset block HTML so as to avoid duplicates
1046
+ $blockHTML = '';
1047
+
1048
+ // specific background color
1049
+ $block_background_color = null;
1050
+
1051
+ // get background color if specified
1052
+ if(isset($block['background_color']) && strlen($block['background_color']) === 6) {
1053
+ $block_background_color = $block['background_color'];
1054
+ }
1055
+
1056
+ // block width
1057
+ $block['block_width'] = 600;
1058
+
1059
+ if($block['type'] === 'auto-post') {
1060
+ // special case for auto post, we need to fetch posts, taking previously sent posts into account
1061
+
1062
+ // get email data
1063
+ //$email = $this->getEmailData();
1064
+
1065
+ // get block params
1066
+ $blockParams = $block['params'];
1067
+
1068
+ // format parameters
1069
+ $params = array();
1070
+
1071
+ $category_ids = array();
1072
+ $category_condition = 'include';
1073
+
1074
+ foreach($blockParams as $pairs) {
1075
+ // store category_ids in email for better performance on immediate sending of WP Posts.
1076
+ if($pairs['key'] === 'category_ids') {
1077
+ $pair_value = trim($pairs['value']);
1078
+ if(!empty($pair_value)) {
1079
+ $category_ids = array_map('intval', explode(',', trim($pairs['value'])));
1080
+ }
1081
+ }
1082
+ // store category condition (include / exclude) for same above reason.
1083
+ if($pairs['key'] === 'category_condition') {
1084
+ $category_condition = (in_array(trim($pairs['value']), array('include', 'exclude'))) ? trim($pairs['value']) : 'include';
1085
+ }
1086
+ $params[$pairs['key']] = $pairs['value'];
1087
+ }
1088
+
1089
+ // make sure we store category_ids
1090
+ if(!empty($category_ids)) {
1091
+ if($category_condition === 'include') {
1092
+ $include_category_ids = array_unique($category_ids);
1093
+ }
1094
+ if($category_condition === 'exclude') {
1095
+ $exclude_category_ids = array_unique($category_ids);
1096
+ }
1097
+ }
1098
+
1099
+ // make sure empty bgcolors are set to transparent
1100
+ if(isset($params['bgcolor1']) && strlen($params['bgcolor1']) === 0) {
1101
+ $params['bgcolor1'] = 'transparent';
1102
+ }
1103
+ if(isset($params['bgcolor2']) && strlen($params['bgcolor2']) === 0) {
1104
+ $params['bgcolor2'] = 'transparent';
1105
+ }
1106
+
1107
+ // make sure the default params are set
1108
+ if(array_key_exists('autonl', $email['params']) === false) {
1109
+ $email['params']['autonl'] = array();
1110
+ }
1111
+ if(array_key_exists('articles', $email['params']['autonl']) === false) {
1112
+ $email['params']['autonl']['articles'] = array(
1113
+ 'ids' => array(),
1114
+ 'count' => 0,
1115
+ 'first_subject' => ''
1116
+ );
1117
+ }
1118
+
1119
+ // exclude already sent post ids from selection
1120
+ if(!empty($email['params']['autonl']['articles']['ids'])) {
1121
+ $params['exclude'] = $email['params']['autonl']['articles']['ids'];
1122
+ } else {
1123
+ $email['params']['autonl']['articles']['ids'] = array();
1124
+ }
1125
+
1126
+ //we set the post_date to filter articles only older than that one
1127
+ if(isset($email['params']['autonl']['firstSend'])){
1128
+ $params['post_date'] = $email['params']['autonl']['firstSend'];
1129
+ }
1130
+
1131
+ // if immediate let it know to the get post
1132
+ if(isset($email['params']['autonl']['articles']['immediatepostid'])){
1133
+ $params['include'] = (int)$email['params']['autonl']['articles']['immediatepostid'];
1134
+ $params['post_limit'] = 1;
1135
+ }else{
1136
+ //we set the post_date to filter articles only older than the last time we sent articles
1137
+ if(isset($email['params']['autonl']['lastSend'])){
1138
+ $params['post_date'] = $email['params']['autonl']['lastSend'];
1139
+ }else{
1140
+ //get the latest child newsletter sent_at value
1141
+ $mEmail=WYSIJA::get('email','model');
1142
+ $mEmail->reset();
1143
+ $mEmail->orderBy('email_id','DESC');
1144
+ $lastEmailSent=$mEmail->getOne(false,array('campaign_id'=>$email['campaign_id'],'type'=>'1'));
1145
+
1146
+ if(!empty($lastEmailSent)) $params['post_date'] = $lastEmailSent['sent_at'];
1147
+ }
1148
+ }
1149
+
1150
+ // decode specific keys
1151
+ $params = $this->decodeParameters($params);
1152
+
1153
+ // include/exclude category_ids
1154
+ $params['include_category_ids'] = $include_category_ids;
1155
+ $params['exclude_category_ids'] = $exclude_category_ids;
1156
+
1157
+ // check for already inserted posts
1158
+ if(!empty($post_ids)) {
1159
+ $params['exclude'] = $post_ids;
1160
+ }
1161
+
1162
+ // get posts for this block
1163
+ $model_wp_posts = WYSIJA::get('wp_posts','model');
1164
+ $posts = $model_wp_posts->get_posts($params);
1165
+
1166
+ // check if we have posts to display
1167
+ if(!empty($posts)) {
1168
+ // get divider if necessary
1169
+ if(isset($params['show_divider']) && $params['show_divider'] === 'yes') {
1170
+ if(isset($email['params']['divider'])) {
1171
+ // either from the email params
1172
+ $params['divider'] = $email['params']['divider'];
1173
+ } else {
1174
+ // get default divider otherwise
1175
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
1176
+ $params['divider'] = $helper_dividers->getDefault();
1177
+ }
1178
+ }
1179
+
1180
+ $helper_articles = WYSIJA::get('articles', 'helper');
1181
+
1182
+ foreach($posts as $key => $post) {
1183
+ // assign first post title to autonl parameters (this is used to display the [newsletter:post_title] shortcode in the subject)
1184
+ if($first_subject === null && strlen(trim($posts[$key]['post_title'])) > 0) {
1185
+ $first_subject = trim($posts[$key]['post_title']);
1186
+ }
1187
+
1188
+ // check if shortcodes should be interpreted (value comes from WP options)
1189
+ if($interpret_shortcode === true) {
1190
+ // interpret shortcodes
1191
+ $posts[$key]['post_content'] = apply_filters('the_content', $post['post_content']);
1192
+ }
1193
+ if($params['image_alignment'] !== 'none') {
1194
+ // get thumbnail
1195
+ $posts[$key]['post_image'] = $helper_articles->getImage($post);
1196
+ }
1197
+
1198
+ $post_ids[] = (int)$post['ID'];
1199
+ $post_count++;
1200
+ }
1201
+ // render html from post data and params
1202
+ $blockHTML = $this->renderEmailAutoPost($posts, $params);
1203
+ }
1204
+
1205
+ $this->setEmailData($email);
1206
+ } else {
1207
+ // set styles
1208
+ $block['styles'] = $styles;
1209
+ // generate block template
1210
+ $blockHTML = $helper_render_engine->render($block, 'templates/email_v3/block_template.html');
1211
+
1212
+ if($block['type'] !== 'raw') {
1213
+ // apply inline styles
1214
+ $blockHTML = $this->applyInlineStyles('body', $blockHTML, array('background_color' => $block_background_color));
1215
+ }
1216
+ }
1217
+
1218
+ // append generated html to body
1219
+ if($blockHTML !== '') {
1220
+ // render each block
1221
+ $body .= $blockHTML;
1222
+ }
1223
+ }
1224
+
1225
+ if($newsletter_type === 'automatic') {
1226
+ $email = $this->getEmailData();
1227
+ // set auto newsletter parameters
1228
+ $email['params']['autonl']['articles']['count'] = $post_count;
1229
+ $email['params']['autonl']['articles']['first_subject'] = $first_subject;
1230
+ $email['params']['autonl']['articles']['ids'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $post_ids));
1231
+
1232
+ $this->setEmailData($email);
1233
+ }
1234
+
1235
+ return $body;
1236
+ }
1237
+
1238
+ function renderEmailFooter() {
1239
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1240
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1241
+ $helper_render_engine->setStripSpecialchars(true);
1242
+
1243
+ $data = $this->getData('footer');
1244
+ $data['styles'] = array('footer' => $this->getStyles('footer'));
1245
+
1246
+ // check for emptyness
1247
+ if($data['text'] === NULL and $data['image']['static'] === TRUE) {
1248
+ return NULL;
1249
+ }
1250
+
1251
+ // set footer content width
1252
+ $data['block_width'] = 600;
1253
+
1254
+ // generate block template
1255
+ $footer = $helper_render_engine->render($data, 'templates/email_v3/footer_template.html');
1256
+
1257
+ // apply inline styles
1258
+ $footer = $this->applyInlineStyles('footer', $footer);
1259
+
1260
+ return $footer;
1261
+ }
1262
+
1263
+ /**
1264
+ * area : header, body, footer, unsubscribe, viewbrowser
1265
+ * block : raw html
1266
+ */
1267
+ function applyInlineStyles($area, $block, $extra = array()) {
1268
+ $helper_render_engine = WYSIJA::get('render_engine', 'helper');
1269
+ $helper_render_engine->setTemplatePath(WYSIJA_EDITOR_TOOLS);
1270
+ $helper_render_engine->setInline(true);
1271
+
1272
+ $tags = array();
1273
+ $classes = array();
1274
+
1275
+ switch($area) {
1276
+ case 'header':
1277
+ case 'footer':
1278
+ $classes = array(
1279
+ 'wysija-image-container alone-left' => array('margin' => '0', 'padding' => '0'),
1280
+ 'wysija-image-container alone-center' => array('margin' => '0 auto 0 auto', 'padding' => '0', 'text-align' => 'center'),
1281
+ 'wysija-image-container alone-right' => array('margin' => '0', 'padding' => '0')
1282
+ );
1283
+ break;
1284
+
1285
+ case 'body':
1286
+ // set class for links in titles
1287
+ $block = preg_replace_callback('#(<h([1|2|3])[^>]*>(.*)<\/h[1|2|3]>)#Ui',
1288
+ create_function('$matches', '$class = \'h\'.(int)$matches[2].\'-link\'; return str_replace(\'<a\', \'<a class="\'.$class.\'"\', $matches[0]);'),
1289
+ $block);
1290
+
1291
+ $tags = array(
1292
+ 'h1' => array_merge($this->getStyles('h1'), array('word-wrap' => true, 'padding' => '0', 'margin' => '0 0 10px 0', 'font-weight' => 'normal', 'line-height' => '1.3em')),
1293
+ 'h2' => array_merge($this->getStyles('h2'), array('word-wrap' => true, 'padding' => '0', 'margin' => '0 0 10px 0', 'font-weight' => 'normal', 'line-height' => '1.2em')),
1294
+ 'h3' => array_merge($this->getStyles('h3'), array('word-wrap' => true, 'padding' => '0', 'margin' => '0 0 10px 0', 'font-weight' => 'normal', 'line-height' => '1.1em')),
1295
+ 'p' => array_merge($this->getStyles('body'), array('word-wrap' => true, 'padding' => '3px 0 0 0', 'margin' => '0 0 1em 0', 'line-height' => '1.5em', 'vertical-align' => 'top')),
1296
+ 'a' => array_merge($this->getStyles('body'), $this->getStyles('a')),
1297
+ 'ul' => array('line-height' => '1.5em', 'margin' => '0 0 1em 0', 'padding' => '0'),
1298
+ 'ol' => array('line-height' => '1.5em', 'margin' => '0 0 1em 0', 'padding' => '0'),
1299
+ 'li' => array_merge($this->getStyles('body'), array('font-weight' => 'normal', 'list-type' => 'none', 'list-style-type' => 'disc', 'margin' => '0 0 0.7em 30px', 'padding' => '0'))
1300
+ );
1301
+
1302
+ $classes = array(
1303
+ 'wysija-image-container alone-left' => array('margin' => '0', 'padding' => '0'),
1304
+ 'wysija-image-container alone-center' => array('margin' => '1em auto 1em auto', 'padding' => '0', 'text-align' => 'center'),
1305
+ 'wysija-image-container alone-right' => array('margin' => '0', 'padding' => '0'),
1306
+ 'wysija-image-left' => array('vertical-align' => 'top'),
1307
+ 'wysija-image-center' => array('margin' => '0 auto 0 auto', 'vertical-align' => 'top'),
1308
+ 'wysija-image-right' => array('vertical-align' => 'top'),
1309
+ 'wysija-image-container align-left' => array('float' => 'left', 'margin' => '0', 'padding' => '0'),
1310
+ 'wysija-image-container align-center' => array('margin' => '0 auto 0 auto', 'text-align' => 'center', 'padding' => '0'),
1311
+ 'wysija-image-container align-right' => array('float' => 'right', 'margin' => '0', 'padding' => '0'),
1312
+ 'wysija-divider-container' => array('margin' => '0 auto 0 auto', 'padding' => '0', 'text-align' => 'center'),
1313
+ 'h1-link' => array_merge($this->getStyles('h1'), $this->getStyles('a')),
1314
+ 'h2-link' => array_merge($this->getStyles('h2'), $this->getStyles('a')),
1315
+ 'h3-link' => array_merge($this->getStyles('h3'), $this->getStyles('a')),
1316
+ 'align-left' => array('text-align' => 'left'),
1317
+ 'align-center' => array('text-align' => 'center'),
1318
+ 'align-right' => array('text-align' => 'right'),
1319
+ 'align-justify' => array('text-align' => 'justify')
1320
+ );
1321
+
1322
+ // when an extra background_color is specified, apply it to paragraphs & links
1323
+ if(array_key_exists('background_color', $extra) and $extra['background_color'] !== null) {
1324
+ $tags['p']['background'] = $extra['background_color'];
1325
+ $tags['a']['background'] = $extra['background_color'];
1326
+ $tags['ul']['background'] = $extra['background_color'];
1327
+ $tags['li']['background'] = $extra['background_color'];
1328
+ // fixes issue on Outlook.com Mobile where h2 have a white background
1329
+ $tags['h2']['background'] = $extra['background_color'];
1330
+ $tags['p']['background'] = $extra['background_color'];
1331
+ } else {
1332
+ // default newsletter background
1333
+ // fixes issue on Outlook.com Mobile where h2 have a white background
1334
+ $tags['h2']['background'] = $this->getStyle('body', 'background');
1335
+ }
1336
+ break;
1337
+
1338
+ case 'unsubscribe':
1339
+ $tags = array(
1340
+ 'a' => $this->getStyles('unsubscribe')
1341
+ );
1342
+ break;
1343
+ case 'viewbrowser':
1344
+ $tags = array(
1345
+ 'a' => $this->getStyles('viewbrowser')
1346
+ );
1347
+ break;
1348
+ }
1349
+
1350
+ if(empty($tags) === FALSE) {
1351
+
1352
+ foreach($tags as $tag => $styles) {
1353
+ $styles = $this->splitSpacing($styles);
1354
+ $inlineStyles = $helper_render_engine->render(array_merge($styles, array('tag' => $tag)), 'styles/inline.html');
1355
+ $inlineStyles = preg_replace('/(\n*)/', '', $inlineStyles);
1356
+ $tags['#< *'.$tag.'((?:(?!style).)*)>#Ui'] = '<'.$tag.' style="'.$inlineStyles.'"$1>';
1357
+ unset($tags[$tag]);
1358
+ }
1359
+
1360
+ $block = preg_replace(array_keys($tags), $tags, $block);
1361
+ }
1362
+
1363
+ if(empty($classes) === FALSE) {
1364
+ foreach($classes as $class => $styles) {
1365
+ // split spacing styles
1366
+ $styles = $this->splitSpacing($styles);
1367
+ $inlineStyles = $helper_render_engine->render($styles, 'styles/inline.html');
1368
+ $inlineStyles = preg_replace('/(\n*)/', '', $inlineStyles);
1369
+
1370
+ if(in_array($class, array('h1-link', 'h2-link', 'h3-link'))) {
1371
+ $classes['#<([^ /]+) ((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)class="[^"]*'.$class.'[^"]*"((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)>#Ui'] = '<$1 $2$4$5$7 style="'.$inlineStyles.'">';
1372
+ } else {
1373
+ $classes['#<([^ /]+) ((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)class="[^"]*'.$class.'[^"]*"((?:(?!>|style).)*)(?:style="([^"]*)")?((?:(?!>|style).)*)>#Ui'] = '<$1 $2$4$5$7 style="$3$6'.$inlineStyles.'">';
1374
+ }
1375
+ unset($classes[$class]);
1376
+ }
1377
+
1378
+ $styledBlock = preg_replace(array_keys($classes), $classes, $block);
1379
+ // Check if the preg_replace worked. Otherwise we simply return the original block
1380
+ if(strlen(trim($styledBlock)) > 0) {
1381
+ $block = $styledBlock;
1382
+ }
1383
+ }
1384
+
1385
+ // body
1386
+ if($area === 'body' && strlen($block) > 0) {
1387
+ // Outlook fixes
1388
+ // paragraph
1389
+ /*$block = preg_replace('#<\/p>#Ui', "<!--[if gte mso 9]></p><![endif]--></p>", $block);
1390
+ $block = preg_replace('#<p(.*)>#Ui', "\n<p$1><!--[if gte mso 9]></p><p class=\"wysija-fix-paragraph\"><![endif]-->", $block);
1391
+ // h2 titles
1392
+ $block = preg_replace('#<\/h2>#Ui', "<!--[if gte mso 9]></h2><![endif]--></h2>", $block);
1393
+ $block = preg_replace('#<h2(.*)>#Ui', "<h2$1><!--[if gte mso 9]></h2><h2 class=\"wysija-fix-h2\"><![endif]-->", $block);
1394
+ // h3 titles
1395
+ $block = preg_replace('#<\/h3>#Ui', "<!--[if gte mso 9]></h3><![endif]--></h3>", $block);
1396
+ $block = preg_replace('#<h3(.*)>#Ui', "<h3$1><!--[if gte mso 9]></h3><h3 class=\"wysija-fix-h3\"><![endif]-->", $block);
1397
+
1398
+ // lists
1399
+ $block = preg_replace('#<ol(.*)>#Ui', "\n<ul$1>", $block);
1400
+ $block = preg_replace('#<ul(.*)>#Ui', "\n<ul$1>", $block);
1401
+ $block = preg_replace('#<li(.*)>#Ui', "\n<li$1>", $block);
1402
+
1403
+ $pFixStyles = $this->splitSpacing(array_merge($this->getStyles('body'), array('padding' => '3px 0 0 0', 'margin' => '0 0 1.3em 0', 'line-height' => '1em', 'vertical-align' => 'top')));
1404
+ $h2FixStyles = $this->splitSpacing(array_merge($this->getStyles('h2'), array('padding' => '0', 'margin' => '0 0 10px 0', 'font-weight' => 'normal', 'line-height' => '1em')));
1405
+ $h3FixStyles = $this->splitSpacing(array_merge($this->getStyles('h3'), array('padding' => '0', 'margin' => '0 0 10px 0', 'font-weight' => 'normal', 'line-height' => '1em')));
1406
+
1407
+ // apply block background color to elements if specified
1408
+ if(array_key_exists('background_color', $extra) and $extra['background_color'] !== null) {
1409
+ $pFixStyles['background'] = $extra['background_color'];
1410
+ $h2FixStyles['background'] = $extra['background_color'];
1411
+ $h3FixStyles['background'] = $extra['background_color'];
1412
+ }
1413
+
1414
+ $block = str_replace('class="wysija-fix-paragraph"', 'style="'.$helper_render_engine->render($pFixStyles, 'styles/inline.html').'"', $block);
1415
+ $block = str_replace('class="wysija-fix-h2"', 'style="'.$helper_render_engine->render($h2FixStyles, 'styles/inline.html').'"', $block);
1416
+ $block = str_replace('class="wysija-fix-h3"', 'style="'.$helper_render_engine->render($h3FixStyles, 'styles/inline.html').'"', $block);*/
1417
+ }
1418
+
1419
+ return $block;
1420
+ }
1421
+
1422
+ function splitSpacing($styles) {
1423
+ foreach($styles as $property => $value) {
1424
+ if($property === 'margin' or $property === 'padding') {
1425
+ // extract multi-values
1426
+ $values = explode(' ', $value);
1427
+
1428
+ // split values depending on values count
1429
+ switch(count($values)) {
1430
+ case 1:
1431
+ $styles[$property.'-top'] = $values[0];
1432
+ $styles[$property.'-right'] = $values[0];
1433
+ $styles[$property.'-bottom'] = $values[0];
1434
+ $styles[$property.'-left'] = $values[0];
1435
+ break;
1436
+ case 2:
1437
+ $styles[$property.'-top'] = $values[0];
1438
+ $styles[$property.'-right'] = $values[1];
1439
+ $styles[$property.'-bottom'] = $values[0];
1440
+ $styles[$property.'-left'] = $values[1];
1441
+ break;
1442
+ case 4:
1443
+ $styles[$property.'-top'] = $values[0];
1444
+ $styles[$property.'-right'] = $values[1];
1445
+ $styles[$property.'-bottom'] = $values[2];
1446
+ $styles[$property.'-left'] = $values[3];
1447
+ break;
1448
+ }
1449
+
1450
+ // unset original value
1451
+ unset($styles[$property]);
1452
+ }
1453
+ }
1454
+ return $styles;
1455
+ }
1456
+
1457
+ function formatColor($color) {
1458
+ if(strlen(trim($color)) === 0 or $color === 'transparent') {
1459
+ return 'transparent';
1460
+ } else {
1461
+ return '#'.$color;
1462
+ }
1463
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1464
  }
img/controls/image-placeholder.png DELETED
Binary file
index.php CHANGED
@@ -3,8 +3,8 @@
3
  Plugin Name: MailPoet Newsletters
4
  Plugin URI: http://www.mailpoet.com/
5
  Description: Create and send newsletters. Import and manage your lists. Add subscription forms in widgets, articles and pages. MailPoet (formerly Wysija) is a freemium plugin updated regularly with new features.
6
- Version: 2.6.8
7
- Author: MailPoet
8
  Author URI: http://www.mailpoet.com/
9
  License: GPLv2 or later
10
  Text Domain: wysija-newsletters
@@ -28,4 +28,4 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
28
  */
29
  /*require vital parts*/
30
 
31
- require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'base.php');
3
  Plugin Name: MailPoet Newsletters
4
  Plugin URI: http://www.mailpoet.com/
5
  Description: Create and send newsletters. Import and manage your lists. Add subscription forms in widgets, articles and pages. MailPoet (formerly Wysija) is a freemium plugin updated regularly with new features.
6
+ Version: 2.6.5
7
+ Author: Wysija
8
  Author URI: http://www.mailpoet.com/
9
  License: GPLv2 or later
10
  Text Domain: wysija-newsletters
28
  */
29
  /*require vital parts*/
30
 
31
+ require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'core'.DIRECTORY_SEPARATOR.'base.php');
js/admin-campaigns-autopost.js CHANGED
@@ -1 +1 @@
1
- var colorpicker=null;jQuery(function(e){function t(){e("#title_position_block")["title"===e('input[name="post_content"]:checked').val()?"hide":"show"](),e("#title_tag_list")["title"===e('input[name="post_content"]:checked').val()?"show":"hide"](),e("#advanced:visible").length>0&&(e("#title_tag_list:hidden").length>0&&"list"===e('input[name="title_tag"]:checked').val()&&e('input[name="title_tag"][value="h2"]').attr("checked","checked"),"list"===e('input[name="title_tag"]:checked').val()?a(["image","author","category","readmore","divider","bgcolor"]):i(["image","author","category","readmore","divider","bgcolor"]))}function a(t){e.each(t,function(t,a){e("#"+a+"-block").hide()})}function i(t){e.each(t,function(t,a){e("#"+a+"-block").show()})}function n(){e("#image_block")[e('input[name="title_tag"][value="list"]:checked').length>0?"hide":"show"]()}function o(t){t===!0&&e(".category_ids").val("").trigger("change");var a=e("#post_type").val();e(".category_ids").select2({width:"400px",multiple:!0,data:{results:[]},initSelection:function(e,t){t(e.data("selected"))},allowClear:!0,ajax:{url:ajaxurl,data:function(e,t){return{action:"wysija_ajax",controller:"campaigns",task:"search_terms",search:e,page_limit:10,page:t,post_type:a}},results:function(t){var a=t.result;return e.each(a.results,function(e,t){t.text=_.template("<%= tax %>: <%= term %>")({tax:a.taxonomies[t.taxonomy].labels.singular_name,term:t.name}),t.id=t.term_id}),a}}}).trigger("change").on({change:function(t){var a=e(this).data("selected");t.added?a.push(t.added):a=_.without(a,t.removed),e(this).data("selected",a).attr("data-selected",JSON.stringify(a))}})}function l(){var t=e('input[name="image_alignment"]:checked').val(),a=!0,i=32,n=325;"center"===t?n=564:"none"===t&&(a=!1),a===!0?(e("#image_width_block").show(),c(),slider.range=$R(i,n),slider.setValue(slider.value)):e("#image_width_block").hide()}function c(){var t=32,a=564,i=Math.min(Math.max(t,parseInt(e("#slider_info span").html())),a);slider=new Control.Slider("slider_handle","image_width_slider",{range:$R(t,a),slideValue:i,axis:"horizontal",onSlide:function(t){var a=parseInt(t,10);e("#slider_info").find("span").html(a),e("#image_width").val(a)},onChange:function(t){var a=parseInt(t,10);e("#slider_info").find("span").html(a),e("#image_width").val(a)}}),slider.setValue(i)}function r(){null===colorpicker&&(colorpicker=!0,e("input.color").modcoder_excolor({hue_bar:1,border_color:"#969696",anim_speed:"fast",round_corners:!1,shadow_size:2,shadow_color:"#f0f0f0",background_color:"#ececec",backlight:!1,label_color:"#333333",effect:"fade",show_input:!1,z_index:2e4,callback_on_open:function(){e("html, body").animate({scrollTop:e("#modcoder_colorpicker_wrapper:visible").offset().top},200)}}))}e("#toggle-advanced").toggle(function(){return e(this).html(wysijatrans.hide_advanced),e("#advanced").show(),c(),t(),l(),n(),r(),e(this).blur(),window.parent.WysijaPopup.setDimensions(),!1},function(){return e(this).html(wysijatrans.show_advanced),e("#advanced").hide(),e(this).blur(),window.parent.WysijaPopup.setDimensions(),!1}),e("#autopost-submit").click(function(){var t=[],a=["readmore","author_label","category_label"];return e("#autopost-form").serializeArray().each(function(e){a.include(e.name)&&(e.value=window.parent.Wysija.encodeHtmlValue(e.value)),t.push(e)}),wysijaAJAX.task="generate_auto_post",wysijaAJAX.wysijaData=t,jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(e){void 0!==e.result&&""!==e.result?window.parent.WysijaPopup.success(e.result):window.parent.WysijaPopup.cancel()}}),!1}),e('input[name="image_alignment"]').click(function(){l()}),e('input[name="post_content"]').click(function(){t(),n(),l()}),e('input[name="title_tag"]').click(function(){t(),n(),l()}),e("#post_type").change(function(){return o(!0),!1}),e(function(){c(),t(),l(),n(),o()})});
1
+ var colorpicker=null;jQuery(function(e){function t(){e("#title_position_block")["title"===e('input[name="post_content"]:checked').val()?"hide":"show"](),e("#title_tag_list")["title"===e('input[name="post_content"]:checked').val()?"show":"hide"](),e("#advanced:visible").length>0&&(e("#title_tag_list:hidden").length>0&&"list"===e('input[name="title_tag"]:checked').val()&&e('input[name="title_tag"][value="h2"]').attr("checked","checked"),"list"===e('input[name="title_tag"]:checked').val()?i(["image","author","category","readmore","divider","bgcolor"]):a(["image","author","category","readmore","divider","bgcolor"]))}function i(t){e.each(t,function(t,i){e("#"+i+"-block").hide()})}function a(t){e.each(t,function(t,i){e("#"+i+"-block").show()})}function n(){e("#image_block")[e('input[name="title_tag"][value="list"]:checked').length>0?"hide":"show"]()}function o(t){var i=e(".category_select"),a=e("#categories_filters");i.hide(),i.find("select").prop("disabled",!0),t===!0&&e(".category_ids").val("").trigger("change");var n=e("#post_type").val(),o=i.filter('[data-post-type="'+n+'"]');o.length>0?(o.show(),o.find("select").prop("disabled",!1),a.show()):a.hide()}function l(){var t=e('input[name="image_alignment"]:checked').val(),i=!0,a=32,n=325;"center"===t?n=564:"none"===t&&(i=!1),i===!0?(e("#image_width_block").show(),c(),slider.range=$R(a,n),slider.setValue(slider.value)):e("#image_width_block").hide()}function c(){var t=32,i=564,a=Math.min(Math.max(t,parseInt(e("#slider_info span").html())),i);slider=new Control.Slider("slider_handle","image_width_slider",{range:$R(t,i),slideValue:a,axis:"horizontal",onSlide:function(t){var i=parseInt(t,10);e("#slider_info").find("span").html(i),e("#image_width").val(i)},onChange:function(t){var i=parseInt(t,10);e("#slider_info").find("span").html(i),e("#image_width").val(i)}}),slider.setValue(a)}function r(){null===colorpicker&&(colorpicker=!0,e("input.color").modcoder_excolor({hue_bar:1,border_color:"#969696",anim_speed:"fast",round_corners:!1,shadow_size:2,shadow_color:"#f0f0f0",background_color:"#ececec",backlight:!1,label_color:"#333333",effect:"fade",show_input:!1,z_index:2e4,callback_on_open:function(){e("html, body").animate({scrollTop:e("#modcoder_colorpicker_wrapper:visible").offset().top},200)}}))}e("#toggle-advanced").toggle(function(){return e(this).html(wysijatrans.hide_advanced),e("#advanced").show(),c(),t(),l(),n(),r(),e(this).blur(),window.parent.WysijaPopup.setDimensions(),!1},function(){return e(this).html(wysijatrans.show_advanced),e("#advanced").hide(),e(this).blur(),window.parent.WysijaPopup.setDimensions(),!1}),e("#autopost-submit").click(function(){var t=[],i=["readmore","author_label","category_label"];return e("#autopost-form").serializeArray().each(function(e){i.include(e.name)&&(e.value=window.parent.Wysija.encodeHtmlValue(e.value)),t.push(e)}),wysijaAJAX.task="generate_auto_post",wysijaAJAX.wysijaData=t,jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(e){void 0!==e.result&&""!==e.result?window.parent.WysijaPopup.success(e.result):window.parent.WysijaPopup.cancel()}}),!1}),e('input[name="image_alignment"]').click(function(){l()}),e('input[name="post_content"]').click(function(){t(),n(),l()}),e('input[name="title_tag"]').click(function(){t(),n(),l()}),e("#post_type").change(function(){return o(!0),!1}),e(function(){e(".category_ids").select2({width:"400px"}),c(),t(),l(),n(),o()})});
js/admin-global.js CHANGED
@@ -1 +1 @@
1
- (function(e){"use strict";e(document).ready(function(){e(".mp-select-sort").on({sort:function(){e(this).each(function(t,n){var r=e(n),o=r.children("option");o.detach().sort(function(t,n){return 0===parseInt(e(t).data("sort"),10)||0===parseInt(e(n).data("skip"),10)?0:"NA"===t.innerHTML?1:"NA"===n.innerHTML?-1:t.innerHTML.toLowerCase()>n.innerHTML.toLowerCase()?1:-1}).appendTo(r),o.filter("[selected]").eq(0).prop("selected",!0)})}}).trigger("sort")})})(jQuery.noConflict(),_);
1
+ (function(n){"use strict";n(document).ready(function(){n(".mp-select-sort").on({sort:function(){n(this).each(function(t,e){var o=n(e),r=o.children("option");r.detach().sort(function(n,t){return"NA"===n.innerHTML?1:"NA"===t.innerHTML?-1:n.innerHTML.toLowerCase()>t.innerHTML.toLowerCase()?1:-1}).appendTo(o)})}}).trigger("sort")})})(jQuery.noConflict(),_);
js/jquery/pluploadHandler.js CHANGED
@@ -41,7 +41,7 @@ function fileUploading(up, file) {
41
  setTimeout(function(){
42
  var done;
43
 
44
- if ( file.status < 3 && file.loaded === 0 ) { // not uploading
45
  wpFileError(file, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'));
46
  up.stop(); // stops the whole queue
47
  up.removeFile(file);
@@ -109,9 +109,6 @@ function WYSIJAprepareMediaItem(fileObj, serverData) {
109
  jQuery('.bar', item).remove();
110
  jQuery('.progress', item).hide();
111
 
112
- // trim the attachement_id
113
- serverData = serverData.trim();
114
-
115
  // Old style: Append the HTML returned by the server -- thumbnail and form inputs
116
  if ( isNaN(serverData) || !serverData ) {
117
  item.append(serverData);
@@ -155,8 +152,6 @@ function WYSIJAsetParams(result,fileObj){
155
  var imgdimensions=null;
156
 
157
  wpid=jQuery('#media-item-'+fileObj.id).attr('alt');
158
- // trim the attachment id
159
- wpid = wpid.trim();
160
  dims=jQuery('#media-dims-'+wpid).html();
161
  imgdimensions=dims.split('&nbsp;×&nbsp;');
162
 
@@ -217,11 +212,10 @@ function WYSIJAsetParams(result,fileObj){
217
 
218
  function setResize(arg) {
219
  if ( arg ) {
220
- if ( uploader.features.jpgresize ){
221
  uploader.settings['resize'] = { width: resize_width, height: resize_height, quality: 100 };
222
- } else {
223
  uploader.settings.multipart_params.image_resize = true;
224
- }
225
  } else {
226
  delete(uploader.settings.resize);
227
  delete(uploader.settings.multipart_params.image_resize);
@@ -445,13 +439,6 @@ jQuery(document).ready(function($){
445
  fileQueued(file);
446
  });
447
 
448
- // Ok, this is a fix; Not the best solution for
449
- // We have to keep our heads looking for Plupload changes
450
- // at the WordPress Core
451
- up.settings.resize = {
452
- resize: true
453
- };
454
-
455
  up.refresh();
456
  up.start();
457
  });
41
  setTimeout(function(){
42
  var done;
43
 
44
+ if ( file.status < 3 && file.loaded == 0 ) { // not uploading
45
  wpFileError(file, pluploadL10n.big_upload_failed.replace('%1$s', '<a class="uploader-html" href="#">').replace('%2$s', '</a>'));
46
  up.stop(); // stops the whole queue
47
  up.removeFile(file);
109
  jQuery('.bar', item).remove();
110
  jQuery('.progress', item).hide();
111
 
 
 
 
112
  // Old style: Append the HTML returned by the server -- thumbnail and form inputs
113
  if ( isNaN(serverData) || !serverData ) {
114
  item.append(serverData);
152
  var imgdimensions=null;
153
 
154
  wpid=jQuery('#media-item-'+fileObj.id).attr('alt');
 
 
155
  dims=jQuery('#media-dims-'+wpid).html();
156
  imgdimensions=dims.split('&nbsp;×&nbsp;');
157
 
212
 
213
  function setResize(arg) {
214
  if ( arg ) {
215
+ if ( uploader.features.jpgresize )
216
  uploader.settings['resize'] = { width: resize_width, height: resize_height, quality: 100 };
217
+ else
218
  uploader.settings.multipart_params.image_resize = true;
 
219
  } else {
220
  delete(uploader.settings.resize);
221
  delete(uploader.settings.multipart_params.image_resize);
439
  fileQueued(file);
440
  });
441
 
 
 
 
 
 
 
 
442
  up.refresh();
443
  up.start();
444
  });
js/jquery/uploadHandlers.js CHANGED
@@ -1,4 +1,5 @@
1
 
 
2
  function WYSIJAprepareMediaItem(fileObj, serverData) {
3
  var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery('#media-item-' + fileObj.id);
4
  // Move the progress bar to 100%
1
 
2
+
3
  function WYSIJAprepareMediaItem(fileObj, serverData) {
4
  var f = ( typeof shortform == 'undefined' ) ? 1 : 2, item = jQuery('#media-item-' + fileObj.id);
5
  // Move the progress bar to 100%
js/qtip2/jquery.qtip.min.js ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ /* qTip2 v2.2.0 tips modal viewport svg imagemap ie6 | qtip2.com | Licensed MIT, GPL | Fri Nov 29 2013 13:08:34 */
2
+
3
+ !function(a,b,c){!function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery"],a):jQuery&&!jQuery.fn.qtip&&a(jQuery)}(function(d){"use strict";function e(a,b,c,e){this.id=c,this.target=a,this.tooltip=G,this.elements={target:a},this._id=T+"-"+c,this.timers={img:{}},this.options=b,this.plugins={},this.cache={event:{},target:d(),disabled:F,attr:e,onTooltip:F,lastClass:""},this.rendered=this.destroyed=this.disabled=this.waiting=this.hiddenDuringWait=this.positioning=this.triggering=F}function f(a){return a===G||"object"!==d.type(a)}function g(a){return!(d.isFunction(a)||a&&a.attr||a.length||"object"===d.type(a)&&(a.jquery||a.then))}function h(a){var b,c,e,h;return f(a)?F:(f(a.metadata)&&(a.metadata={type:a.metadata}),"content"in a&&(b=a.content,f(b)||b.jquery||b.done?b=a.content={text:c=g(b)?F:b}:c=b.text,"ajax"in b&&(e=b.ajax,h=e&&e.once!==F,delete b.ajax,b.text=function(a,b){var f=c||d(this).attr(b.options.content.attr)||"Loading...",g=d.ajax(d.extend({},e,{context:b})).then(e.success,G,e.error).then(function(a){return a&&h&&b.set("content.text",a),a},function(a,c,d){b.destroyed||0===a.status||b.set("content.text",c+": "+d)});return h?f:(b.set("content.text",f),g)}),"title"in b&&(f(b.title)||(b.button=b.title.button,b.title=b.title.text),g(b.title||F)&&(b.title=F))),"position"in a&&f(a.position)&&(a.position={my:a.position,at:a.position}),"show"in a&&f(a.show)&&(a.show=a.show.jquery?{target:a.show}:a.show===E?{ready:E}:{event:a.show}),"hide"in a&&f(a.hide)&&(a.hide=a.hide.jquery?{target:a.hide}:{event:a.hide}),"style"in a&&f(a.style)&&(a.style={classes:a.style}),d.each(S,function(){this.sanitize&&this.sanitize(a)}),a)}function i(a,b){for(var c,d=0,e=a,f=b.split(".");e=e[f[d++]];)d<f.length&&(c=e);return[c||a,f.pop()]}function j(a,b){var c,d,e;for(c in this.checks)for(d in this.checks[c])(e=new RegExp(d,"i").exec(a))&&(b.push(e),("builtin"===c||this.plugins[c])&&this.checks[c][d].apply(this.plugins[c]||this,b))}function k(a){return W.concat("").join(a?"-"+a+" ":" ")}function l(c){return c&&{type:c.type,pageX:c.pageX,pageY:c.pageY,target:c.target,relatedTarget:c.relatedTarget,scrollX:c.scrollX||a.pageXOffset||b.body.scrollLeft||b.documentElement.scrollLeft,scrollY:c.scrollY||a.pageYOffset||b.body.scrollTop||b.documentElement.scrollTop}||{}}function m(a,b){return b>0?setTimeout(d.proxy(a,this),b):(a.call(this),void 0)}function n(a){return this.tooltip.hasClass(bb)?F:(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this.timers.show=m.call(this,function(){this.toggle(E,a)},this.options.show.delay),void 0)}function o(a){if(this.tooltip.hasClass(bb))return F;var b=d(a.relatedTarget),c=b.closest(X)[0]===this.tooltip[0],e=b[0]===this.options.show.target[0];if(clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this!==b[0]&&"mouse"===this.options.position.target&&c||this.options.hide.fixed&&/mouse(out|leave|move)/.test(a.type)&&(c||e))try{a.preventDefault(),a.stopImmediatePropagation()}catch(f){}else this.timers.hide=m.call(this,function(){this.toggle(F,a)},this.options.hide.delay,this)}function p(a){return this.tooltip.hasClass(bb)||!this.options.hide.inactive?F:(clearTimeout(this.timers.inactive),this.timers.inactive=m.call(this,function(){this.hide(a)},this.options.hide.inactive),void 0)}function q(a){this.rendered&&this.tooltip[0].offsetWidth>0&&this.reposition(a)}function r(a,c,e){d(b.body).delegate(a,(c.split?c:c.join(ib+" "))+ib,function(){var a=z.api[d.attr(this,V)];a&&!a.disabled&&e.apply(a,arguments)})}function s(a,c,f){var g,i,j,k,l,m=d(b.body),n=a[0]===b?m:a,o=a.metadata?a.metadata(f.metadata):G,p="html5"===f.metadata.type&&o?o[f.metadata.name]:G,q=a.data(f.metadata.name||"qtipopts");try{q="string"==typeof q?d.parseJSON(q):q}catch(r){}if(k=d.extend(E,{},z.defaults,f,"object"==typeof q?h(q):G,h(p||o)),i=k.position,k.id=c,"boolean"==typeof k.content.text){if(j=a.attr(k.content.attr),k.content.attr===F||!j)return F;k.content.text=j}if(i.container.length||(i.container=m),i.target===F&&(i.target=n),k.show.target===F&&(k.show.target=n),k.show.solo===E&&(k.show.solo=i.container.closest("body")),k.hide.target===F&&(k.hide.target=n),k.position.viewport===E&&(k.position.viewport=i.container),i.container=i.container.eq(0),i.at=new B(i.at,E),i.my=new B(i.my),a.data(T))if(k.overwrite)a.qtip("destroy",!0);else if(k.overwrite===F)return F;return a.attr(U,c),k.suppress&&(l=a.attr("title"))&&a.removeAttr("title").attr(db,l).attr("title",""),g=new e(a,k,c,!!j),a.data(T,g),a.one("remove.qtip-"+c+" removeqtip.qtip-"+c,function(){var a;(a=d(this).data(T))&&a.destroy(!0)}),g}function t(a){return a.charAt(0).toUpperCase()+a.slice(1)}function u(a,b){var d,e,f=b.charAt(0).toUpperCase()+b.slice(1),g=(b+" "+tb.join(f+" ")+f).split(" "),h=0;if(sb[b])return a.css(sb[b]);for(;d=g[h++];)if((e=a.css(d))!==c)return sb[b]=d,e}function v(a,b){return Math.ceil(parseFloat(u(a,b)))}function w(a,b){this._ns="tip",this.options=b,this.offset=b.offset,this.size=[b.width,b.height],this.init(this.qtip=a)}function x(a,b){this.options=b,this._ns="-modal",this.init(this.qtip=a)}function y(a){this._ns="ie6",this.init(this.qtip=a)}var z,A,B,C,D,E=!0,F=!1,G=null,H="x",I="y",J="width",K="height",L="top",M="left",N="bottom",O="right",P="center",Q="flipinvert",R="shift",S={},T="qtip",U="data-hasqtip",V="data-qtip-id",W=["ui-widget","ui-tooltip"],X="."+T,Y="click dblclick mousedown mouseup mousemove mouseleave mouseenter".split(" "),Z=T+"-fixed",$=T+"-default",_=T+"-focus",ab=T+"-hover",bb=T+"-disabled",cb="_replacedByqTip",db="oldtitle",eb={ie:function(){for(var a=3,c=b.createElement("div");(c.innerHTML="<!--[if gt IE "+ ++a+"]><i></i><![endif]-->")&&c.getElementsByTagName("i")[0];);return a>4?a:0/0}(),iOS:parseFloat((""+(/CPU.*OS ([0-9_]{1,5})|(CPU like).*AppleWebKit.*Mobile/i.exec(navigator.userAgent)||[0,""])[1]).replace("undefined","3_2").replace("_",".").replace("_",""))||F};A=e.prototype,A._when=function(a){return d.when.apply(d,a)},A.render=function(a){if(this.rendered||this.destroyed)return this;var b,c=this,e=this.options,f=this.cache,g=this.elements,h=e.content.text,i=e.content.title,j=e.content.button,k=e.position,l=("."+this._id+" ",[]);return d.attr(this.target[0],"aria-describedby",this._id),this.tooltip=g.tooltip=b=d("<div/>",{id:this._id,"class":[T,$,e.style.classes,T+"-pos-"+e.position.my.abbrev()].join(" "),width:e.style.width||"",height:e.style.height||"",tracking:"mouse"===k.target&&k.adjust.mouse,role:"alert","aria-live":"polite","aria-atomic":F,"aria-describedby":this._id+"-content","aria-hidden":E}).toggleClass(bb,this.disabled).attr(V,this.id).data(T,this).appendTo(k.container).append(g.content=d("<div />",{"class":T+"-content",id:this._id+"-content","aria-atomic":E})),this.rendered=-1,this.positioning=E,i&&(this._createTitle(),d.isFunction(i)||l.push(this._updateTitle(i,F))),j&&this._createButton(),d.isFunction(h)||l.push(this._updateContent(h,F)),this.rendered=E,this._setWidget(),d.each(S,function(a){var b;"render"===this.initialize&&(b=this(c))&&(c.plugins[a]=b)}),this._unassignEvents(),this._assignEvents(),this._when(l).then(function(){c._trigger("render"),c.positioning=F,c.hiddenDuringWait||!e.show.ready&&!a||c.toggle(E,f.event,F),c.hiddenDuringWait=F}),z.api[this.id]=this,this},A.destroy=function(a){function b(){if(!this.destroyed){this.destroyed=E;var a=this.target,b=a.attr(db);this.rendered&&this.tooltip.stop(1,0).find("*").remove().end().remove(),d.each(this.plugins,function(){this.destroy&&this.destroy()}),clearTimeout(this.timers.show),clearTimeout(this.timers.hide),this._unassignEvents(),a.removeData(T).removeAttr(V).removeAttr(U).removeAttr("aria-describedby"),this.options.suppress&&b&&a.attr("title",b).removeAttr(db),this._unbind(a),this.options=this.elements=this.cache=this.timers=this.plugins=this.mouse=G,delete z.api[this.id]}}return this.destroyed?this.target:(a===E&&"hide"!==this.triggering||!this.rendered?b.call(this):(this.tooltip.one("tooltiphidden",d.proxy(b,this)),!this.triggering&&this.hide()),this.target)},C=A.checks={builtin:{"^id$":function(a,b,c,e){var f=c===E?z.nextid:c,g=T+"-"+f;f!==F&&f.length>0&&!d("#"+g).length?(this._id=g,this.rendered&&(this.tooltip[0].id=this._id,this.elements.content[0].id=this._id+"-content",this.elements.title[0].id=this._id+"-title")):a[b]=e},"^prerender":function(a,b,c){c&&!this.rendered&&this.render(this.options.show.ready)},"^content.text$":function(a,b,c){this._updateContent(c)},"^content.attr$":function(a,b,c,d){this.options.content.text===this.target.attr(d)&&this._updateContent(this.target.attr(c))},"^content.title$":function(a,b,c){return c?(c&&!this.elements.title&&this._createTitle(),this._updateTitle(c),void 0):this._removeTitle()},"^content.button$":function(a,b,c){this._updateButton(c)},"^content.title.(text|button)$":function(a,b,c){this.set("content."+b,c)},"^position.(my|at)$":function(a,b,c){"string"==typeof c&&(a[b]=new B(c,"at"===b))},"^position.container$":function(a,b,c){this.rendered&&this.tooltip.appendTo(c)},"^show.ready$":function(a,b,c){c&&(!this.rendered&&this.render(E)||this.toggle(E))},"^style.classes$":function(a,b,c,d){this.rendered&&this.tooltip.removeClass(d).addClass(c)},"^style.(width|height)":function(a,b,c){this.rendered&&this.tooltip.css(b,c)},"^style.widget|content.title":function(){this.rendered&&this._setWidget()},"^style.def":function(a,b,c){this.rendered&&this.tooltip.toggleClass($,!!c)},"^events.(render|show|move|hide|focus|blur)$":function(a,b,c){this.rendered&&this.tooltip[(d.isFunction(c)?"":"un")+"bind"]("tooltip"+b,c)},"^(show|hide|position).(event|target|fixed|inactive|leave|distance|viewport|adjust)":function(){if(this.rendered){var a=this.options.position;this.tooltip.attr("tracking","mouse"===a.target&&a.adjust.mouse),this._unassignEvents(),this._assignEvents()}}}},A.get=function(a){if(this.destroyed)return this;var b=i(this.options,a.toLowerCase()),c=b[0][b[1]];return c.precedance?c.string():c};var fb=/^position\.(my|at|adjust|target|container|viewport)|style|content|show\.ready/i,gb=/^prerender|show\.ready/i;A.set=function(a,b){if(this.destroyed)return this;{var c,e=this.rendered,f=F,g=this.options;this.checks}return"string"==typeof a?(c=a,a={},a[c]=b):a=d.extend({},a),d.each(a,function(b,c){if(e&&gb.test(b))return delete a[b],void 0;var h,j=i(g,b.toLowerCase());h=j[0][j[1]],j[0][j[1]]=c&&c.nodeType?d(c):c,f=fb.test(b)||f,a[b]=[j[0],j[1],c,h]}),h(g),this.positioning=E,d.each(a,d.proxy(j,this)),this.positioning=F,this.rendered&&this.tooltip[0].offsetWidth>0&&f&&this.reposition("mouse"===g.position.target?G:this.cache.event),this},A._update=function(a,b){var c=this,e=this.cache;return this.rendered&&a?(d.isFunction(a)&&(a=a.call(this.elements.target,e.event,this)||""),d.isFunction(a.then)?(e.waiting=E,a.then(function(a){return e.waiting=F,c._update(a,b)},G,function(a){return c._update(a,b)})):a===F||!a&&""!==a?F:(a.jquery&&a.length>0?b.empty().append(a.css({display:"block",visibility:"visible"})):b.html(a),this._waitForContent(b).then(function(a){a.images&&a.images.length&&c.rendered&&c.tooltip[0].offsetWidth>0&&c.reposition(e.event,!a.length)}))):F},A._waitForContent=function(a){var b=this.cache;return b.waiting=E,(d.fn.imagesLoaded?a.imagesLoaded():d.Deferred().resolve([])).done(function(){b.waiting=F}).promise()},A._updateContent=function(a,b){this._update(a,this.elements.content,b)},A._updateTitle=function(a,b){this._update(a,this.elements.title,b)===F&&this._removeTitle(F)},A._createTitle=function(){var a=this.elements,b=this._id+"-title";a.titlebar&&this._removeTitle(),a.titlebar=d("<div />",{"class":T+"-titlebar "+(this.options.style.widget?k("header"):"")}).append(a.title=d("<div />",{id:b,"class":T+"-title","aria-atomic":E})).insertBefore(a.content).delegate(".qtip-close","mousedown keydown mouseup keyup mouseout",function(a){d(this).toggleClass("ui-state-active ui-state-focus","down"===a.type.substr(-4))}).delegate(".qtip-close","mouseover mouseout",function(a){d(this).toggleClass("ui-state-hover","mouseover"===a.type)}),this.options.content.button&&this._createButton()},A._removeTitle=function(a){var b=this.elements;b.title&&(b.titlebar.remove(),b.titlebar=b.title=b.button=G,a!==F&&this.reposition())},A.reposition=function(c,e){if(!this.rendered||this.positioning||this.destroyed)return this;this.positioning=E;var f,g,h=this.cache,i=this.tooltip,j=this.options.position,k=j.target,l=j.my,m=j.at,n=j.viewport,o=j.container,p=j.adjust,q=p.method.split(" "),r=i.outerWidth(F),s=i.outerHeight(F),t=0,u=0,v=i.css("position"),w={left:0,top:0},x=i[0].offsetWidth>0,y=c&&"scroll"===c.type,z=d(a),A=o[0].ownerDocument,B=this.mouse;if(d.isArray(k)&&2===k.length)m={x:M,y:L},w={left:k[0],top:k[1]};else if("mouse"===k)m={x:M,y:L},!B||!B.pageX||!p.mouse&&c&&c.pageX?c&&c.pageX||((!p.mouse||this.options.show.distance)&&h.origin&&h.origin.pageX?c=h.origin:(!c||c&&("resize"===c.type||"scroll"===c.type))&&(c=h.event)):c=B,"static"!==v&&(w=o.offset()),A.body.offsetWidth!==(a.innerWidth||A.documentElement.clientWidth)&&(g=d(b.body).offset()),w={left:c.pageX-w.left+(g&&g.left||0),top:c.pageY-w.top+(g&&g.top||0)},p.mouse&&y&&B&&(w.left-=(B.scrollX||0)-z.scrollLeft(),w.top-=(B.scrollY||0)-z.scrollTop());else{if("event"===k?c&&c.target&&"scroll"!==c.type&&"resize"!==c.type?h.target=d(c.target):c.target||(h.target=this.elements.target):"event"!==k&&(h.target=d(k.jquery?k:this.elements.target)),k=h.target,k=d(k).eq(0),0===k.length)return this;k[0]===b||k[0]===a?(t=eb.iOS?a.innerWidth:k.width(),u=eb.iOS?a.innerHeight:k.height(),k[0]===a&&(w={top:(n||k).scrollTop(),left:(n||k).scrollLeft()})):S.imagemap&&k.is("area")?f=S.imagemap(this,k,m,S.viewport?q:F):S.svg&&k&&k[0].ownerSVGElement?f=S.svg(this,k,m,S.viewport?q:F):(t=k.outerWidth(F),u=k.outerHeight(F),w=k.offset()),f&&(t=f.width,u=f.height,g=f.offset,w=f.position),w=this.reposition.offset(k,w,o),(eb.iOS>3.1&&eb.iOS<4.1||eb.iOS>=4.3&&eb.iOS<4.33||!eb.iOS&&"fixed"===v)&&(w.left-=z.scrollLeft(),w.top-=z.scrollTop()),(!f||f&&f.adjustable!==F)&&(w.left+=m.x===O?t:m.x===P?t/2:0,w.top+=m.y===N?u:m.y===P?u/2:0)}return w.left+=p.x+(l.x===O?-r:l.x===P?-r/2:0),w.top+=p.y+(l.y===N?-s:l.y===P?-s/2:0),S.viewport?(w.adjusted=S.viewport(this,w,j,t,u,r,s),g&&w.adjusted.left&&(w.left+=g.left),g&&w.adjusted.top&&(w.top+=g.top)):w.adjusted={left:0,top:0},this._trigger("move",[w,n.elem||n],c)?(delete w.adjusted,e===F||!x||isNaN(w.left)||isNaN(w.top)||"mouse"===k||!d.isFunction(j.effect)?i.css(w):d.isFunction(j.effect)&&(j.effect.call(i,this,d.extend({},w)),i.queue(function(a){d(this).css({opacity:"",height:""}),eb.ie&&this.style.removeAttribute("filter"),a()})),this.positioning=F,this):this},A.reposition.offset=function(a,c,e){function f(a,b){c.left+=b*a.scrollLeft(),c.top+=b*a.scrollTop()}if(!e[0])return c;var g,h,i,j,k=d(a[0].ownerDocument),l=!!eb.ie&&"CSS1Compat"!==b.compatMode,m=e[0];do"static"!==(h=d.css(m,"position"))&&("fixed"===h?(i=m.getBoundingClientRect(),f(k,-1)):(i=d(m).position(),i.left+=parseFloat(d.css(m,"borderLeftWidth"))||0,i.top+=parseFloat(d.css(m,"borderTopWidth"))||0),c.left-=i.left+(parseFloat(d.css(m,"marginLeft"))||0),c.top-=i.top+(parseFloat(d.css(m,"marginTop"))||0),g||"hidden"===(j=d.css(m,"overflow"))||"visible"===j||(g=d(m)));while(m=m.offsetParent);return g&&(g[0]!==k[0]||l)&&f(g,1),c};var hb=(B=A.reposition.Corner=function(a,b){a=(""+a).replace(/([A-Z])/," $1").replace(/middle/gi,P).toLowerCase(),this.x=(a.match(/left|right/i)||a.match(/center/)||["inherit"])[0].toLowerCase(),this.y=(a.match(/top|bottom|center/i)||["inherit"])[0].toLowerCase(),this.forceY=!!b;var c=a.charAt(0);this.precedance="t"===c||"b"===c?I:H}).prototype;hb.invert=function(a,b){this[a]=this[a]===M?O:this[a]===O?M:b||this[a]},hb.string=function(){var a=this.x,b=this.y;return a===b?a:this.precedance===I||this.forceY&&"center"!==b?b+" "+a:a+" "+b},hb.abbrev=function(){var a=this.string().split(" ");return a[0].charAt(0)+(a[1]&&a[1].charAt(0)||"")},hb.clone=function(){return new B(this.string(),this.forceY)},A.toggle=function(a,c){var e=this.cache,f=this.options,g=this.tooltip;if(c){if(/over|enter/.test(c.type)&&/out|leave/.test(e.event.type)&&f.show.target.add(c.target).length===f.show.target.length&&g.has(c.relatedTarget).length)return this;e.event=l(c)}if(this.waiting&&!a&&(this.hiddenDuringWait=E),!this.rendered)return a?this.render(1):this;if(this.destroyed||this.disabled)return this;var h,i,j,k=a?"show":"hide",m=this.options[k],n=(this.options[a?"hide":"show"],this.options.position),o=this.options.content,p=this.tooltip.css("width"),q=this.tooltip.is(":visible"),r=a||1===m.target.length,s=!c||m.target.length<2||e.target[0]===c.target;return(typeof a).search("boolean|number")&&(a=!q),h=!g.is(":animated")&&q===a&&s,i=h?G:!!this._trigger(k,[90]),this.destroyed?this:(i!==F&&a&&this.focus(c),!i||h?this:(d.attr(g[0],"aria-hidden",!a),a?(e.origin=l(this.mouse),d.isFunction(o.text)&&this._updateContent(o.text,F),d.isFunction(o.title)&&this._updateTitle(o.title,F),!D&&"mouse"===n.target&&n.adjust.mouse&&(d(b).bind("mousemove."+T,this._storeMouse),D=E),p||g.css("width",g.outerWidth(F)),this.reposition(c,arguments[2]),p||g.css("width",""),m.solo&&("string"==typeof m.solo?d(m.solo):d(X,m.solo)).not(g).not(m.target).qtip("hide",d.Event("tooltipsolo"))):(clearTimeout(this.timers.show),delete e.origin,D&&!d(X+'[tracking="true"]:visible',m.solo).not(g).length&&(d(b).unbind("mousemove."+T),D=F),this.blur(c)),j=d.proxy(function(){a?(eb.ie&&g[0].style.removeAttribute("filter"),g.css("overflow",""),"string"==typeof m.autofocus&&d(this.options.show.autofocus,g).focus(),this.options.show.target.trigger("qtip-"+this.id+"-inactive")):g.css({display:"",visibility:"",opacity:"",left:"",top:""}),this._trigger(a?"visible":"hidden")},this),m.effect===F||r===F?(g[k](),j()):d.isFunction(m.effect)?(g.stop(1,1),m.effect.call(g,this),g.queue("fx",function(a){j(),a()})):g.fadeTo(90,a?1:0,j),a&&m.target.trigger("qtip-"+this.id+"-inactive"),this))},A.show=function(a){return this.toggle(E,a)},A.hide=function(a){return this.toggle(F,a)},A.focus=function(a){if(!this.rendered||this.destroyed)return this;var b=d(X),c=this.tooltip,e=parseInt(c[0].style.zIndex,10),f=z.zindex+b.length;return c.hasClass(_)||this._trigger("focus",[f],a)&&(e!==f&&(b.each(function(){this.style.zIndex>e&&(this.style.zIndex=this.style.zIndex-1)}),b.filter("."+_).qtip("blur",a)),c.addClass(_)[0].style.zIndex=f),this},A.blur=function(a){return!this.rendered||this.destroyed?this:(this.tooltip.removeClass(_),this._trigger("blur",[this.tooltip.css("zIndex")],a),this)},A.disable=function(a){return this.destroyed?this:("toggle"===a?a=!(this.rendered?this.tooltip.hasClass(bb):this.disabled):"boolean"!=typeof a&&(a=E),this.rendered&&this.tooltip.toggleClass(bb,a).attr("aria-disabled",a),this.disabled=!!a,this)},A.enable=function(){return this.disable(F)},A._createButton=function(){var a=this,b=this.elements,c=b.tooltip,e=this.options.content.button,f="string"==typeof e,g=f?e:"Close tooltip";b.button&&b.button.remove(),b.button=e.jquery?e:d("<a />",{"class":"qtip-close "+(this.options.style.widget?"":T+"-icon"),title:g,"aria-label":g}).prepend(d("<span />",{"class":"ui-icon ui-icon-close",html:"&times;"})),b.button.appendTo(b.titlebar||c).attr("role","button").click(function(b){return c.hasClass(bb)||a.hide(b),F})},A._updateButton=function(a){if(!this.rendered)return F;var b=this.elements.button;a?this._createButton():b.remove()},A._setWidget=function(){var a=this.options.style.widget,b=this.elements,c=b.tooltip,d=c.hasClass(bb);c.removeClass(bb),bb=a?"ui-state-disabled":"qtip-disabled",c.toggleClass(bb,d),c.toggleClass("ui-helper-reset "+k(),a).toggleClass($,this.options.style.def&&!a),b.content&&b.content.toggleClass(k("content"),a),b.titlebar&&b.titlebar.toggleClass(k("header"),a),b.button&&b.button.toggleClass(T+"-icon",!a)},A._storeMouse=function(a){(this.mouse=l(a)).type="mousemove"},A._bind=function(a,b,c,e,f){var g="."+this._id+(e?"-"+e:"");b.length&&d(a).bind((b.split?b:b.join(g+" "))+g,d.proxy(c,f||this))},A._unbind=function(a,b){d(a).unbind("."+this._id+(b?"-"+b:""))};var ib="."+T;d(function(){r(X,["mouseenter","mouseleave"],function(a){var b="mouseenter"===a.type,c=d(a.currentTarget),e=d(a.relatedTarget||a.target),f=this.options;b?(this.focus(a),c.hasClass(Z)&&!c.hasClass(bb)&&clearTimeout(this.timers.hide)):"mouse"===f.position.target&&f.hide.event&&f.show.target&&!e.closest(f.show.target[0]).length&&this.hide(a),c.toggleClass(ab,b)}),r("["+V+"]",Y,p)}),A._trigger=function(a,b,c){var e=d.Event("tooltip"+a);return e.originalEvent=c&&d.extend({},c)||this.cache.event||G,this.triggering=a,this.tooltip.trigger(e,[this].concat(b||[])),this.triggering=F,!e.isDefaultPrevented()},A._bindEvents=function(a,b,c,e,f,g){if(e.add(c).length===e.length){var h=[];b=d.map(b,function(b){var c=d.inArray(b,a);return c>-1?(h.push(a.splice(c,1)[0]),void 0):b}),h.length&&this._bind(c,h,function(a){var b=this.rendered?this.tooltip[0].offsetWidth>0:!1;(b?g:f).call(this,a)})}this._bind(c,a,f),this._bind(e,b,g)},A._assignInitialEvents=function(a){function b(a){return this.disabled||this.destroyed?F:(this.cache.event=l(a),this.cache.target=a?d(a.target):[c],clearTimeout(this.timers.show),this.timers.show=m.call(this,function(){this.render("object"==typeof a||e.show.ready)},e.show.delay),void 0)}var e=this.options,f=e.show.target,g=e.hide.target,h=e.show.event?d.trim(""+e.show.event).split(" "):[],i=e.hide.event?d.trim(""+e.hide.event).split(" "):[];/mouse(over|enter)/i.test(e.show.event)&&!/mouse(out|leave)/i.test(e.hide.event)&&i.push("mouseleave"),this._bind(f,"mousemove",function(a){this._storeMouse(a),this.cache.onTarget=E}),this._bindEvents(h,i,f,g,b,function(){clearTimeout(this.timers.show)}),(e.show.ready||e.prerender)&&b.call(this,a)},A._assignEvents=function(){var c=this,e=this.options,f=e.position,g=this.tooltip,h=e.show.target,i=e.hide.target,j=f.container,k=f.viewport,l=d(b),m=(d(b.body),d(a)),r=e.show.event?d.trim(""+e.show.event).split(" "):[],s=e.hide.event?d.trim(""+e.hide.event).split(" "):[];d.each(e.events,function(a,b){c._bind(g,"toggle"===a?["tooltipshow","tooltiphide"]:["tooltip"+a],b,null,g)}),/mouse(out|leave)/i.test(e.hide.event)&&"window"===e.hide.leave&&this._bind(l,["mouseout","blur"],function(a){/select|option/.test(a.target.nodeName)||a.relatedTarget||this.hide(a)}),e.hide.fixed?i=i.add(g.addClass(Z)):/mouse(over|enter)/i.test(e.show.event)&&this._bind(i,"mouseleave",function(){clearTimeout(this.timers.show)}),(""+e.hide.event).indexOf("unfocus")>-1&&this._bind(j.closest("html"),["mousedown","touchstart"],function(a){var b=d(a.target),c=this.rendered&&!this.tooltip.hasClass(bb)&&this.tooltip[0].offsetWidth>0,e=b.parents(X).filter(this.tooltip[0]).length>0;b[0]===this.target[0]||b[0]===this.tooltip[0]||e||this.target.has(b[0]).length||!c||this.hide(a)}),"number"==typeof e.hide.inactive&&(this._bind(h,"qtip-"+this.id+"-inactive",p),this._bind(i.add(g),z.inactiveEvents,p,"-inactive")),this._bindEvents(r,s,h,i,n,o),this._bind(h.add(g),"mousemove",function(a){if("number"==typeof e.hide.distance){var b=this.cache.origin||{},c=this.options.hide.distance,d=Math.abs;(d(a.pageX-b.pageX)>=c||d(a.pageY-b.pageY)>=c)&&this.hide(a)}this._storeMouse(a)}),"mouse"===f.target&&f.adjust.mouse&&(e.hide.event&&this._bind(h,["mouseenter","mouseleave"],function(a){this.cache.onTarget="mouseenter"===a.type}),this._bind(l,"mousemove",function(a){this.rendered&&this.cache.onTarget&&!this.tooltip.hasClass(bb)&&this.tooltip[0].offsetWidth>0&&this.reposition(a)})),(f.adjust.resize||k.length)&&this._bind(d.event.special.resize?k:m,"resize",q),f.adjust.scroll&&this._bind(m.add(f.container),"scroll",q)},A._unassignEvents=function(){var c=[this.options.show.target[0],this.options.hide.target[0],this.rendered&&this.tooltip[0],this.options.position.container[0],this.options.position.viewport[0],this.options.position.container.closest("html")[0],a,b];this._unbind(d([]).pushStack(d.grep(c,function(a){return"object"==typeof a})))},z=d.fn.qtip=function(a,b,e){var f=(""+a).toLowerCase(),g=G,i=d.makeArray(arguments).slice(1),j=i[i.length-1],k=this[0]?d.data(this[0],T):G;return!arguments.length&&k||"api"===f?k:"string"==typeof a?(this.each(function(){var a=d.data(this,T);if(!a)return E;if(j&&j.timeStamp&&(a.cache.event=j),!b||"option"!==f&&"options"!==f)a[f]&&a[f].apply(a,i);else{if(e===c&&!d.isPlainObject(b))return g=a.get(b),F;a.set(b,e)}}),g!==G?g:this):"object"!=typeof a&&arguments.length?void 0:(k=h(d.extend(E,{},a)),this.each(function(a){var b,c;return c=d.isArray(k.id)?k.id[a]:k.id,c=!c||c===F||c.length<1||z.api[c]?z.nextid++:c,b=s(d(this),c,k),b===F?E:(z.api[c]=b,d.each(S,function(){"initialize"===this.initialize&&this(b)}),b._assignInitialEvents(j),void 0)}))},d.qtip=e,z.api={},d.each({attr:function(a,b){if(this.length){var c=this[0],e="title",f=d.data(c,"qtip");if(a===e&&f&&"object"==typeof f&&f.options.suppress)return arguments.length<2?d.attr(c,db):(f&&f.options.content.attr===e&&f.cache.attr&&f.set("content.text",b),this.attr(db,b))}return d.fn["attr"+cb].apply(this,arguments)},clone:function(a){var b=(d([]),d.fn["clone"+cb].apply(this,arguments));return a||b.filter("["+db+"]").attr("title",function(){return d.attr(this,db)}).removeAttr(db),b}},function(a,b){if(!b||d.fn[a+cb])return E;var c=d.fn[a+cb]=d.fn[a];d.fn[a]=function(){return b.apply(this,arguments)||c.apply(this,arguments)}}),d.ui||(d["cleanData"+cb]=d.cleanData,d.cleanData=function(a){for(var b,c=0;(b=d(a[c])).length;c++)if(b.attr(U))try{b.triggerHandler("removeqtip")}catch(e){}d["cleanData"+cb].apply(this,arguments)}),z.version="2.2.0",z.nextid=0,z.inactiveEvents=Y,z.zindex=15e3,z.defaults={prerender:F,id:F,overwrite:E,suppress:E,content:{text:E,attr:"title",title:F,button:F},position:{my:"top left",at:"bottom right",target:F,container:F,viewport:F,adjust:{x:0,y:0,mouse:E,scroll:E,resize:E,method:"flipinvert flipinvert"},effect:function(a,b){d(this).animate(b,{duration:200,queue:F})}},show:{target:F,event:"mouseenter",effect:E,delay:90,solo:F,ready:F,autofocus:F},hide:{target:F,event:"mouseleave",effect:E,delay:0,fixed:F,inactive:F,leave:"window",distance:F},style:{classes:"",widget:F,width:F,height:F,def:E},events:{render:G,move:G,show:G,hide:G,toggle:G,visible:G,hidden:G,focus:G,blur:G}};var jb,kb="margin",lb="border",mb="color",nb="background-color",ob="transparent",pb=" !important",qb=!!b.createElement("canvas").getContext,rb=/rgba?\(0, 0, 0(, 0)?\)|transparent|#123456/i,sb={},tb=["Webkit","O","Moz","ms"];if(qb)var ub=a.devicePixelRatio||1,vb=function(){var a=b.createElement("canvas").getContext("2d");return a.backingStorePixelRatio||a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||1}(),wb=ub/vb;else var xb=function(a,b,c){return"<qtipvml:"+a+' xmlns="urn:schemas-microsoft.com:vml" class="qtip-vml" '+(b||"")+' style="behavior: url(#default#VML); '+(c||"")+'" />'};d.extend(w.prototype,{init:function(a){var b,c;c=this.element=a.elements.tip=d("<div />",{"class":T+"-tip"}).prependTo(a.tooltip),qb?(b=d("<canvas />").appendTo(this.element)[0].getContext("2d"),b.lineJoin="miter",b.miterLimit=1e5,b.save()):(b=xb("shape",'coordorigin="0,0"',"position:absolute;"),this.element.html(b+b),a._bind(d("*",c).add(c),["click","mousedown"],function(a){a.stopPropagation()},this._ns)),a._bind(a.tooltip,"tooltipmove",this.reposition,this._ns,this),this.create()},_swapDimensions:function(){this.size[0]=this.options.height,this.size[1]=this.options.width},_resetDimensions:function(){this.size[0]=this.options.width,this.size[1]=this.options.height},_useTitle:function(a){var b=this.qtip.elements.titlebar;return b&&(a.y===L||a.y===P&&this.element.position().top+this.size[1]/2+this.options.offset<b.outerHeight(E))},_parseCorner:function(a){var b=this.qtip.options.position.my;return a===F||b===F?a=F:a===E?a=new B(b.string()):a.string||(a=new B(a),a.fixed=E),a},_parseWidth:function(a,b,c){var d=this.qtip.elements,e=lb+t(b)+"Width";return(c?v(c,e):v(d.content,e)||v(this._useTitle(a)&&d.titlebar||d.content,e)||v(d.tooltip,e))||0},_parseRadius:function(a){var b=this.qtip.elements,c=lb+t(a.y)+t(a.x)+"Radius";return eb.ie<9?0:v(this._useTitle(a)&&b.titlebar||b.content,c)||v(b.tooltip,c)||0},_invalidColour:function(a,b,c){var d=a.css(b);return!d||c&&d===a.css(c)||rb.test(d)?F:d},_parseColours:function(a){var b=this.qtip.elements,c=this.element.css("cssText",""),e=lb+t(a[a.precedance])+t(mb),f=this._useTitle(a)&&b.titlebar||b.content,g=this._invalidColour,h=[];return h[0]=g(c,nb)||g(f,nb)||g(b.content,nb)||g(b.tooltip,nb)||c.css(nb),h[1]=g(c,e,mb)||g(f,e,mb)||g(b.content,e,mb)||g(b.tooltip,e,mb)||b.tooltip.css(e),d("*",c).add(c).css("cssText",nb+":"+ob+pb+";"+lb+":0"+pb+";"),h},_calculateSize:function(a){var b,c,d,e=a.precedance===I,f=this.options.width,g=this.options.height,h="c"===a.abbrev(),i=(e?f:g)*(h?.5:1),j=Math.pow,k=Math.round,l=Math.sqrt(j(i,2)+j(g,2)),m=[this.border/i*l,this.border/g*l];return m[2]=Math.sqrt(j(m[0],2)-j(this.border,2)),m[3]=Math.sqrt(j(m[1],2)-j(this.border,2)),b=l+m[2]+m[3]+(h?0:m[0]),c=b/l,d=[k(c*f),k(c*g)],e?d:d.reverse()},_calculateTip:function(a,b,c){c=c||1,b=b||this.size;var d=b[0]*c,e=b[1]*c,f=Math.ceil(d/2),g=Math.ceil(e/2),h={br:[0,0,d,e,d,0],bl:[0,0,d,0,0,e],tr:[0,e,d,0,d,e],tl:[0,0,0,e,d,e],tc:[0,e,f,0,d,e],bc:[0,0,d,0,f,e],rc:[0,0,d,g,0,e],lc:[d,0,d,e,0,g]};return h.lt=h.br,h.rt=h.bl,h.lb=h.tr,h.rb=h.tl,h[a.abbrev()]},_drawCoords:function(a,b){a.beginPath(),a.moveTo(b[0],b[1]),a.lineTo(b[2],b[3]),a.lineTo(b[4],b[5]),a.closePath()},create:function(){var a=this.corner=(qb||eb.ie)&&this._parseCorner(this.options.corner);return(this.enabled=!!this.corner&&"c"!==this.corner.abbrev())&&(this.qtip.cache.corner=a.clone(),this.update()),this.element.toggle(this.enabled),this.corner},update:function(b,c){if(!this.enabled)return this;var e,f,g,h,i,j,k,l,m=this.qtip.elements,n=this.element,o=n.children(),p=this.options,q=this.size,r=p.mimic,s=Math.round;b||(b=this.qtip.cache.corner||this.corner),r===F?r=b:(r=new B(r),r.precedance=b.precedance,"inherit"===r.x?r.x=b.x:"inherit"===r.y?r.y=b.y:r.x===r.y&&(r[b.precedance]=b[b.precedance])),f=r.precedance,b.precedance===H?this._swapDimensions():this._resetDimensions(),e=this.color=this._parseColours(b),e[1]!==ob?(l=this.border=this._parseWidth(b,b[b.precedance]),p.border&&1>l&&!rb.test(e[1])&&(e[0]=e[1]),this.border=l=p.border!==E?p.border:l):this.border=l=0,k=this.size=this._calculateSize(b),n.css({width:k[0],height:k[1],lineHeight:k[1]+"px"}),j=b.precedance===I?[s(r.x===M?l:r.x===O?k[0]-q[0]-l:(k[0]-q[0])/2),s(r.y===L?k[1]-q[1]:0)]:[s(r.x===M?k[0]-q[0]:0),s(r.y===L?l:r.y===N?k[1]-q[1]-l:(k[1]-q[1])/2)],qb?(g=o[0].getContext("2d"),g.restore(),g.save(),g.clearRect(0,0,6e3,6e3),h=this._calculateTip(r,q,wb),i=this._calculateTip(r,this.size,wb),o.attr(J,k[0]*wb).attr(K,k[1]*wb),o.css(J,k[0]).css(K,k[1]),this._drawCoords(g,i),g.fillStyle=e[1],g.fill(),g.translate(j[0]*wb,j[1]*wb),this._drawCoords(g,h),g.fillStyle=e[0],g.fill()):(h=this._calculateTip(r),h="m"+h[0]+","+h[1]+" l"+h[2]+","+h[3]+" "+h[4]+","+h[5]+" xe",j[2]=l&&/^(r|b)/i.test(b.string())?8===eb.ie?2:1:0,o.css({coordsize:k[0]+l+" "+(k[1]+l),antialias:""+(r.string().indexOf(P)>-1),left:j[0]-j[2]*Number(f===H),top:j[1]-j[2]*Number(f===I),width:k[0]+l,height:k[1]+l}).each(function(a){var b=d(this);b[b.prop?"prop":"attr"]({coordsize:k[0]+l+" "+(k[1]+l),path:h,fillcolor:e[0],filled:!!a,stroked:!a}).toggle(!(!l&&!a)),!a&&b.html(xb("stroke",'weight="'+2*l+'px" color="'+e[1]+'" miterlimit="1000" joinstyle="miter"'))})),a.opera&&setTimeout(function(){m.tip.css({display:"inline-block",visibility:"visible"})},1),c!==F&&this.calculate(b,k)},calculate:function(a,b){if(!this.enabled)return F;var c,e,f=this,g=this.qtip.elements,h=this.element,i=this.options.offset,j=(g.tooltip.hasClass("ui-widget"),{});return a=a||this.corner,c=a.precedance,b=b||this._calculateSize(a),e=[a.x,a.y],c===H&&e.reverse(),d.each(e,function(d,e){var h,k,l;e===P?(h=c===I?M:L,j[h]="50%",j[kb+"-"+h]=-Math.round(b[c===I?0:1]/2)+i):(h=f._parseWidth(a,e,g.tooltip),k=f._parseWidth(a,e,g.content),l=f._parseRadius(a),j[e]=Math.max(-f.border,d?k:i+(l>h?l:-h)))
4
+ }),j[a[c]]-=b[c===H?0:1],h.css({margin:"",top:"",bottom:"",left:"",right:""}).css(j),j},reposition:function(a,b,d){function e(a,b,c,d,e){a===R&&j.precedance===b&&k[d]&&j[c]!==P?j.precedance=j.precedance===H?I:H:a!==R&&k[d]&&(j[b]=j[b]===P?k[d]>0?d:e:j[b]===d?e:d)}function f(a,b,e){j[a]===P?p[kb+"-"+b]=o[a]=g[kb+"-"+b]-k[b]:(h=g[e]!==c?[k[b],-g[b]]:[-k[b],g[b]],(o[a]=Math.max(h[0],h[1]))>h[0]&&(d[b]-=k[b],o[b]=F),p[g[e]!==c?e:b]=o[a])}if(this.enabled){var g,h,i=b.cache,j=this.corner.clone(),k=d.adjusted,l=b.options.position.adjust.method.split(" "),m=l[0],n=l[1]||l[0],o={left:F,top:F,x:0,y:0},p={};this.corner.fixed!==E&&(e(m,H,I,M,O),e(n,I,H,L,N),j.string()===i.corner.string()||i.cornerTop===k.top&&i.cornerLeft===k.left||this.update(j,F)),g=this.calculate(j),g.right!==c&&(g.left=-g.right),g.bottom!==c&&(g.top=-g.bottom),g.user=this.offset,(o.left=m===R&&!!k.left)&&f(H,M,O),(o.top=n===R&&!!k.top)&&f(I,L,N),this.element.css(p).toggle(!(o.x&&o.y||j.x===P&&o.y||j.y===P&&o.x)),d.left-=g.left.charAt?g.user:m!==R||o.top||!o.left&&!o.top?g.left+this.border:0,d.top-=g.top.charAt?g.user:n!==R||o.left||!o.left&&!o.top?g.top+this.border:0,i.cornerLeft=k.left,i.cornerTop=k.top,i.corner=j.clone()}},destroy:function(){this.qtip._unbind(this.qtip.tooltip,this._ns),this.qtip.elements.tip&&this.qtip.elements.tip.find("*").remove().end().remove()}}),jb=S.tip=function(a){return new w(a,a.options.style.tip)},jb.initialize="render",jb.sanitize=function(a){if(a.style&&"tip"in a.style){var b=a.style.tip;"object"!=typeof b&&(b=a.style.tip={corner:b}),/string|boolean/i.test(typeof b.corner)||(b.corner=E)}},C.tip={"^position.my|style.tip.(corner|mimic|border)$":function(){this.create(),this.qtip.reposition()},"^style.tip.(height|width)$":function(a){this.size=[a.width,a.height],this.update(),this.qtip.reposition()},"^content.title|style.(classes|widget)$":function(){this.update()}},d.extend(E,z.defaults,{style:{tip:{corner:E,mimic:F,width:6,height:6,border:E,offset:0}}});var yb,zb,Ab="qtip-modal",Bb="."+Ab;zb=function(){function a(a){if(d.expr[":"].focusable)return d.expr[":"].focusable;var b,c,e,f=!isNaN(d.attr(a,"tabindex")),g=a.nodeName&&a.nodeName.toLowerCase();return"area"===g?(b=a.parentNode,c=b.name,a.href&&c&&"map"===b.nodeName.toLowerCase()?(e=d("img[usemap=#"+c+"]")[0],!!e&&e.is(":visible")):!1):/input|select|textarea|button|object/.test(g)?!a.disabled:"a"===g?a.href||f:f}function c(a){k.length<1&&a.length?a.not("body").blur():k.first().focus()}function e(a){if(i.is(":visible")){var b,e=d(a.target),h=f.tooltip,j=e.closest(X);b=j.length<1?F:parseInt(j[0].style.zIndex,10)>parseInt(h[0].style.zIndex,10),b||e.closest(X)[0]===h[0]||c(e),g=a.target===k[k.length-1]}}var f,g,h,i,j=this,k={};d.extend(j,{init:function(){return i=j.elem=d("<div />",{id:"qtip-overlay",html:"<div></div>",mousedown:function(){return F}}).hide(),d(b.body).bind("focusin"+Bb,e),d(b).bind("keydown"+Bb,function(a){f&&f.options.show.modal.escape&&27===a.keyCode&&f.hide(a)}),i.bind("click"+Bb,function(a){f&&f.options.show.modal.blur&&f.hide(a)}),j},update:function(b){f=b,k=b.options.show.modal.stealfocus!==F?b.tooltip.find("*").filter(function(){return a(this)}):[]},toggle:function(a,e,g){var k=(d(b.body),a.tooltip),l=a.options.show.modal,m=l.effect,n=e?"show":"hide",o=i.is(":visible"),p=d(Bb).filter(":visible:not(:animated)").not(k);return j.update(a),e&&l.stealfocus!==F&&c(d(":focus")),i.toggleClass("blurs",l.blur),e&&i.appendTo(b.body),i.is(":animated")&&o===e&&h!==F||!e&&p.length?j:(i.stop(E,F),d.isFunction(m)?m.call(i,e):m===F?i[n]():i.fadeTo(parseInt(g,10)||90,e?1:0,function(){e||i.hide()}),e||i.queue(function(a){i.css({left:"",top:""}),d(Bb).length||i.detach(),a()}),h=e,f.destroyed&&(f=G),j)}}),j.init()},zb=new zb,d.extend(x.prototype,{init:function(a){var b=a.tooltip;return this.options.on?(a.elements.overlay=zb.elem,b.addClass(Ab).css("z-index",z.modal_zindex+d(Bb).length),a._bind(b,["tooltipshow","tooltiphide"],function(a,c,e){var f=a.originalEvent;if(a.target===b[0])if(f&&"tooltiphide"===a.type&&/mouse(leave|enter)/.test(f.type)&&d(f.relatedTarget).closest(zb.elem[0]).length)try{a.preventDefault()}catch(g){}else(!f||f&&"tooltipsolo"!==f.type)&&this.toggle(a,"tooltipshow"===a.type,e)},this._ns,this),a._bind(b,"tooltipfocus",function(a,c){if(!a.isDefaultPrevented()&&a.target===b[0]){var e=d(Bb),f=z.modal_zindex+e.length,g=parseInt(b[0].style.zIndex,10);zb.elem[0].style.zIndex=f-1,e.each(function(){this.style.zIndex>g&&(this.style.zIndex-=1)}),e.filter("."+_).qtip("blur",a.originalEvent),b.addClass(_)[0].style.zIndex=f,zb.update(c);try{a.preventDefault()}catch(h){}}},this._ns,this),a._bind(b,"tooltiphide",function(a){a.target===b[0]&&d(Bb).filter(":visible").not(b).last().qtip("focus",a)},this._ns,this),void 0):this},toggle:function(a,b,c){return a&&a.isDefaultPrevented()?this:(zb.toggle(this.qtip,!!b,c),void 0)},destroy:function(){this.qtip.tooltip.removeClass(Ab),this.qtip._unbind(this.qtip.tooltip,this._ns),zb.toggle(this.qtip,F),delete this.qtip.elements.overlay}}),yb=S.modal=function(a){return new x(a,a.options.show.modal)},yb.sanitize=function(a){a.show&&("object"!=typeof a.show.modal?a.show.modal={on:!!a.show.modal}:"undefined"==typeof a.show.modal.on&&(a.show.modal.on=E))},z.modal_zindex=z.zindex-200,yb.initialize="render",C.modal={"^show.modal.(on|blur)$":function(){this.destroy(),this.init(),this.qtip.elems.overlay.toggle(this.qtip.tooltip[0].offsetWidth>0)}},d.extend(E,z.defaults,{show:{modal:{on:F,effect:E,blur:E,stealfocus:E,escape:E}}}),S.viewport=function(c,d,e,f,g,h,i){function j(a,b,c,e,f,g,h,i,j){var k=d[f],m=v[a],t=w[a],u=c===R,x=m===f?j:m===g?-j:-j/2,y=t===f?i:t===g?-i:-i/2,z=r[f]+s[f]-(o?0:n[f]),A=z-k,B=k+j-(h===J?p:q)-z,C=x-(v.precedance===a||m===v[b]?y:0)-(t===P?i/2:0);return u?(C=(m===f?1:-1)*x,d[f]+=A>0?A:B>0?-B:0,d[f]=Math.max(-n[f]+s[f],k-C,Math.min(Math.max(-n[f]+s[f]+(h===J?p:q),k+C),d[f],"center"===m?k-x:1e9))):(e*=c===Q?2:0,A>0&&(m!==f||B>0)?(d[f]-=C+e,l.invert(a,f)):B>0&&(m!==g||A>0)&&(d[f]-=(m===P?-C:C)+e,l.invert(a,g)),d[f]<r&&-d[f]>B&&(d[f]=k,l=v.clone())),d[f]-k}var k,l,m,n,o,p,q,r,s,t=e.target,u=c.elements.tooltip,v=e.my,w=e.at,x=e.adjust,y=x.method.split(" "),z=y[0],A=y[1]||y[0],B=e.viewport,C=e.container,D=c.cache,E={left:0,top:0};return B.jquery&&t[0]!==a&&t[0]!==b.body&&"none"!==x.method?(n=C.offset()||E,o="static"===C.css("position"),k="fixed"===u.css("position"),p=B[0]===a?B.width():B.outerWidth(F),q=B[0]===a?B.height():B.outerHeight(F),r={left:k?0:B.scrollLeft(),top:k?0:B.scrollTop()},s=B.offset()||E,("shift"!==z||"shift"!==A)&&(l=v.clone()),E={left:"none"!==z?j(H,I,z,x.x,M,O,J,f,h):0,top:"none"!==A?j(I,H,A,x.y,L,N,K,g,i):0},l&&D.lastClass!==(m=T+"-pos-"+l.abbrev())&&u.removeClass(c.cache.lastClass).addClass(c.cache.lastClass=m),E):E},S.polys={polygon:function(a,b){var c,d,e,f={width:0,height:0,position:{top:1e10,right:0,bottom:0,left:1e10},adjustable:F},g=0,h=[],i=1,j=1,k=0,l=0;for(g=a.length;g--;)c=[parseInt(a[--g],10),parseInt(a[g+1],10)],c[0]>f.position.right&&(f.position.right=c[0]),c[0]<f.position.left&&(f.position.left=c[0]),c[1]>f.position.bottom&&(f.position.bottom=c[1]),c[1]<f.position.top&&(f.position.top=c[1]),h.push(c);if(d=f.width=Math.abs(f.position.right-f.position.left),e=f.height=Math.abs(f.position.bottom-f.position.top),"c"===b.abbrev())f.position={left:f.position.left+f.width/2,top:f.position.top+f.height/2};else{for(;d>0&&e>0&&i>0&&j>0;)for(d=Math.floor(d/2),e=Math.floor(e/2),b.x===M?i=d:b.x===O?i=f.width-d:i+=Math.floor(d/2),b.y===L?j=e:b.y===N?j=f.height-e:j+=Math.floor(e/2),g=h.length;g--&&!(h.length<2);)k=h[g][0]-f.position.left,l=h[g][1]-f.position.top,(b.x===M&&k>=i||b.x===O&&i>=k||b.x===P&&(i>k||k>f.width-i)||b.y===L&&l>=j||b.y===N&&j>=l||b.y===P&&(j>l||l>f.height-j))&&h.splice(g,1);f.position={left:h[0][0],top:h[0][1]}}return f},rect:function(a,b,c,d){return{width:Math.abs(c-a),height:Math.abs(d-b),position:{left:Math.min(a,c),top:Math.min(b,d)}}},_angles:{tc:1.5,tr:7/4,tl:5/4,bc:.5,br:.25,bl:.75,rc:2,lc:1,c:0},ellipse:function(a,b,c,d,e){var f=S.polys._angles[e.abbrev()],g=0===f?0:c*Math.cos(f*Math.PI),h=d*Math.sin(f*Math.PI);return{width:2*c-Math.abs(g),height:2*d-Math.abs(h),position:{left:a+g,top:b+h},adjustable:F}},circle:function(a,b,c,d){return S.polys.ellipse(a,b,c,c,d)}},S.svg=function(a,c,e){for(var f,g,h,i,j,k,l,m,n,o,p,q=d(b),r=c[0],s=d(r.ownerSVGElement),t=1,u=1,v=!0;!r.getBBox;)r=r.parentNode;if(!r.getBBox||!r.parentNode)return F;f=s.attr("width")||s.width()||parseInt(s.css("width"),10),g=s.attr("height")||s.height()||parseInt(s.css("height"),10);var w=(parseInt(c.css("stroke-width"),10)||0)/2;switch(w&&(t+=w/f,u+=w/g),r.nodeName){case"ellipse":case"circle":o=S.polys.ellipse(r.cx.baseVal.value,r.cy.baseVal.value,(r.rx||r.r).baseVal.value+w,(r.ry||r.r).baseVal.value+w,e);break;case"line":case"polygon":case"polyline":for(n=r.points||[{x:r.x1.baseVal.value,y:r.y1.baseVal.value},{x:r.x2.baseVal.value,y:r.y2.baseVal.value}],o=[],m=-1,k=n.numberOfItems||n.length;++m<k;)l=n.getItem?n.getItem(m):n[m],o.push.apply(o,[l.x,l.y]);o=S.polys.polygon(o,e);break;default:o=r.getBoundingClientRect(),o={width:o.width,height:o.height,position:{left:o.left,top:o.top}},v=!1}return p=o.position,s=s[0],v&&(s.createSVGPoint&&(h=r.getScreenCTM(),n=s.createSVGPoint(),n.x=p.left,n.y=p.top,i=n.matrixTransform(h),p.left=i.x,p.top=i.y),s.viewBox&&(j=s.viewBox.baseVal)&&j.width&&j.height&&(t*=f/j.width,u*=g/j.height)),p.left+=q.scrollLeft(),p.top+=q.scrollTop(),o},S.imagemap=function(a,b,c){b.jquery||(b=d(b));var e,f,g,h,i,j=b.attr("shape").toLowerCase().replace("poly","polygon"),k=d('img[usemap="#'+b.parent("map").attr("name")+'"]'),l=d.trim(b.attr("coords")),m=l.replace(/,$/,"").split(",");if(!k.length)return F;if("polygon"===j)h=S.polys.polygon(m,c);else{if(!S.polys[j])return F;for(g=-1,i=m.length,f=[];++g<i;)f.push(parseInt(m[g],10));h=S.polys[j].apply(this,f.concat(c))}return e=k.offset(),e.left+=Math.ceil((k.outerWidth(F)-k.width())/2),e.top+=Math.ceil((k.outerHeight(F)-k.height())/2),h.position.left+=e.left,h.position.top+=e.top,h};var Cb,Db='<iframe class="qtip-bgiframe" frameborder="0" tabindex="-1" src="javascript:\'\';" style="display:block; position:absolute; z-index:-1; filter:alpha(opacity=0); -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";"></iframe>';d.extend(y.prototype,{_scroll:function(){var b=this.qtip.elements.overlay;b&&(b[0].style.top=d(a).scrollTop()+"px")},init:function(c){var e=c.tooltip;d("select, object").length<1&&(this.bgiframe=c.elements.bgiframe=d(Db).appendTo(e),c._bind(e,"tooltipmove",this.adjustBGIFrame,this._ns,this)),this.redrawContainer=d("<div/>",{id:T+"-rcontainer"}).appendTo(b.body),c.elements.overlay&&c.elements.overlay.addClass("qtipmodal-ie6fix")&&(c._bind(a,["scroll","resize"],this._scroll,this._ns,this),c._bind(e,["tooltipshow"],this._scroll,this._ns,this)),this.redraw()},adjustBGIFrame:function(){var a,b,c=this.qtip.tooltip,d={height:c.outerHeight(F),width:c.outerWidth(F)},e=this.qtip.plugins.tip,f=this.qtip.elements.tip;b=parseInt(c.css("borderLeftWidth"),10)||0,b={left:-b,top:-b},e&&f&&(a="x"===e.corner.precedance?[J,M]:[K,L],b[a[1]]-=f[a[0]]()),this.bgiframe.css(b).css(d)},redraw:function(){if(this.qtip.rendered<1||this.drawing)return this;var a,b,c,d,e=this.qtip.tooltip,f=this.qtip.options.style,g=this.qtip.options.position.container;return this.qtip.drawing=1,f.height&&e.css(K,f.height),f.width?e.css(J,f.width):(e.css(J,"").appendTo(this.redrawContainer),b=e.width(),1>b%2&&(b+=1),c=e.css("maxWidth")||"",d=e.css("minWidth")||"",a=(c+d).indexOf("%")>-1?g.width()/100:0,c=(c.indexOf("%")>-1?a:1)*parseInt(c,10)||b,d=(d.indexOf("%")>-1?a:1)*parseInt(d,10)||0,b=c+d?Math.min(Math.max(b,d),c):b,e.css(J,Math.round(b)).appendTo(g)),this.drawing=0,this},destroy:function(){this.bgiframe&&this.bgiframe.remove(),this.qtip._unbind([a,this.qtip.tooltip],this._ns)}}),Cb=S.ie6=function(a){return 6===eb.ie?new y(a):F},Cb.initialize="render",C.ie6={"^content|style$":function(){this.redraw()}}})}(window,document);
5
+ //# sourceMappingURL=http://cdnjs.cloudflare.com/ajax/libs/qtip2/2.2.0//var/www/qtip2/build/archive/2.2.0/jquery.qtip.min.map
js/tinymce/tiny_mce.js CHANGED
@@ -1 +1 @@
1
- (function(e){var a=/^\s*|\s*$/g,b,d="B".replace(/A(.)|B/,"$1")==="$1";var c={majorVersion:"3",minorVersion:"5.11",releaseDate:"2014-05-08",_init:function(){var s=this,q=document,o=navigator,g=o.userAgent,m,f,l,k,j,r;s.isIE11=g.indexOf("Trident/")!=-1&&(g.indexOf("rv:")!=-1||o.appName.indexOf("Netscape")!=-1);s.isOpera=e.opera&&opera.buildNumber;s.isWebKit=/WebKit/.test(g);s.isIE=!s.isWebKit&&!s.isOpera&&(/MSIE/gi).test(g)&&(/Explorer/gi).test(o.appName)||s.isIE11;s.isIE6=s.isIE&&/MSIE [56]/.test(g);s.isIE7=s.isIE&&/MSIE [7]/.test(g);s.isIE8=s.isIE&&/MSIE [8]/.test(g);s.isIE9=s.isIE&&/MSIE [9]/.test(g);s.isGecko=!s.isWebKit&&!s.isIE11&&/Gecko/.test(g);s.isMac=g.indexOf("Mac")!=-1;s.isAir=/adobeair/i.test(g);s.isIDevice=/(iPad|iPhone)/.test(g);s.isIOS5=s.isIDevice&&g.match(/AppleWebKit\/(\d*)/)[1]>=534;if(e.tinyMCEPreInit){s.suffix=tinyMCEPreInit.suffix;s.baseURL=tinyMCEPreInit.base;s.query=tinyMCEPreInit.query;return}s.suffix="";f=q.getElementsByTagName("base");for(m=0;m<f.length;m++){r=f[m].href;if(r){if(/^https?:\/\/[^\/]+$/.test(r)){r+="/"}k=r?r.match(/.*\//)[0]:""}}function h(i){if(i.src&&/tiny_mce(|_gzip|_jquery|_prototype|_full)(_dev|_src)?.js/.test(i.src)){if(/_(src|dev)\.js/g.test(i.src)){s.suffix="_src"}if((j=i.src.indexOf("?"))!=-1){s.query=i.src.substring(j+1)}s.baseURL=i.src.substring(0,i.src.lastIndexOf("/"));if(k&&s.baseURL.indexOf("://")==-1&&s.baseURL.indexOf("/")!==0){s.baseURL=k+s.baseURL}return s.baseURL}return null}f=q.getElementsByTagName("script");for(m=0;m<f.length;m++){if(h(f[m])){return}}l=q.getElementsByTagName("head")[0];if(l){f=l.getElementsByTagName("script");for(m=0;m<f.length;m++){if(h(f[m])){return}}}return},is:function(g,f){if(!f){return g!==b}if(f=="array"&&c.isArray(g)){return true}return typeof(g)==f},isArray:Array.isArray||function(f){return Object.prototype.toString.call(f)==="[object Array]"},makeMap:function(f,j,h){var g;f=f||[];j=j||",";if(typeof(f)=="string"){f=f.split(j)}h=h||{};g=f.length;while(g--){h[f[g]]={}}return h},each:function(i,f,h){var j,g;if(!i){return 0}h=h||i;if(i.length!==b){for(j=0,g=i.length;j<g;j++){if(f.call(h,i[j],j,i)===false){return 0}}}else{for(j in i){if(i.hasOwnProperty(j)){if(f.call(h,i[j],j,i)===false){return 0}}}}return 1},map:function(g,h){var i=[];c.each(g,function(f){i.push(h(f))});return i},grep:function(g,h){var i=[];c.each(g,function(f){if(!h||h(f)){i.push(f)}});return i},inArray:function(g,h){var j,f;if(g){for(j=0,f=g.length;j<f;j++){if(g[j]===h){return j}}}return -1},extend:function(n,k){var j,f,h,g=arguments,m;for(j=1,f=g.length;j<f;j++){k=g[j];for(h in k){if(k.hasOwnProperty(h)){m=k[h];if(m!==b){n[h]=m}}}}return n},trim:function(f){return(f?""+f:"").replace(a,"")},create:function(o,f,j){var n=this,g,i,k,l,h,m=0;o=/^((static) )?([\w.]+)(:([\w.]+))?/.exec(o);k=o[3].match(/(^|\.)(\w+)$/i)[2];i=n.createNS(o[3].replace(/\.\w+$/,""),j);if(i[k]){return}if(o[2]=="static"){i[k]=f;if(this.onCreate){this.onCreate(o[2],o[3],i[k])}return}if(!f[k]){f[k]=function(){};m=1}i[k]=f[k];n.extend(i[k].prototype,f);if(o[5]){g=n.resolve(o[5]).prototype;l=o[5].match(/\.(\w+)$/i)[1];h=i[k];if(m){i[k]=function(){return g[l].apply(this,arguments)}}else{i[k]=function(){this.parent=g[l];return h.apply(this,arguments)}}i[k].prototype[k]=i[k];n.each(g,function(p,q){i[k].prototype[q]=g[q]});n.each(f,function(p,q){if(g[q]){i[k].prototype[q]=function(){this.parent=g[q];return p.apply(this,arguments)}}else{if(q!=k){i[k].prototype[q]=p}}})}n.each(f["static"],function(p,q){i[k][q]=p});if(this.onCreate){this.onCreate(o[2],o[3],i[k].prototype)}},walk:function(i,h,j,g){g=g||this;if(i){if(j){i=i[j]}c.each(i,function(k,f){if(h.call(g,k,f,j)===false){return false}c.walk(k,h,j,g)})}},createNS:function(j,h){var g,f;h=h||e;j=j.split(".");for(g=0;g<j.length;g++){f=j[g];if(!h[f]){h[f]={}}h=h[f]}return h},resolve:function(j,h){var g,f;h=h||e;j=j.split(".");for(g=0,f=j.length;g<f;g++){h=h[j[g]];if(!h){break}}return h},addUnload:function(j,i){var h=this,g;g=function(){var f=h.unloads,l,m;if(f){for(m in f){l=f[m];if(l&&l.func){l.func.call(l.scope,1)}}if(e.detachEvent){e.detachEvent("onbeforeunload",k);e.detachEvent("onunload",g)}else{if(e.removeEventListener){e.removeEventListener("unload",g,false)}}h.unloads=l=f=w=g=0;if(e.CollectGarbage){CollectGarbage()}}};function k(){var l=document;function f(){l.detachEvent("onstop",f);if(g){g()}l=0}if(l.readyState=="interactive"){if(l){l.attachEvent("onstop",f)}e.setTimeout(function(){if(l){l.detachEvent("onstop",f)}},0)}}j={func:j,scope:i||this};if(!h.unloads){if(e.attachEvent){e.attachEvent("onunload",g);e.attachEvent("onbeforeunload",k)}else{if(e.addEventListener){e.addEventListener("unload",g,false)}}h.unloads=[j]}else{h.unloads.push(j)}return j},removeUnload:function(i){var g=this.unloads,h=null;c.each(g,function(j,f){if(j&&j.func==i){g.splice(f,1);h=i;return false}});return h},explode:function(f,g){if(!f||c.is(f,"array")){return f}return c.map(f.split(g||","),c.trim)},_addVer:function(g){var f;if(!this.query){return g}f=(g.indexOf("?")==-1?"?":"&")+this.query;if(g.indexOf("#")==-1){return g+f}return g.replace("#",f+"#")},_replace:function(h,f,g){if(d){return g.replace(h,function(){var l=f,j=arguments,k;for(k=0;k<j.length-2;k++){if(j[k]===b){l=l.replace(new RegExp("\\$"+k,"g"),"")}else{l=l.replace(new RegExp("\\$"+k,"g"),j[k])}}return l})}return g.replace(h,f)}};c._init();e.tinymce=e.tinyMCE=c})(window);tinymce.create("tinymce.util.Dispatcher",{scope:null,listeners:null,inDispatch:false,Dispatcher:function(a){this.scope=a||this;this.listeners=[]},add:function(b,a){this.listeners.push({cb:b,scope:a||this.scope});return b},addToTop:function(d,b){var a=this,c={cb:d,scope:b||a.scope};if(a.inDispatch){a.listeners=[c].concat(a.listeners)}else{a.listeners.unshift(c)}return d},remove:function(c){var b=this.listeners,a=null;tinymce.each(b,function(e,d){if(c==e.cb){a=e;b.splice(d,1);return false}});return a},dispatch:function(){var a=this,e,b=arguments,c,d=a.listeners,f;a.inDispatch=true;for(c=0;c<d.length;c++){f=d[c];e=f.cb.apply(f.scope,b.length>0?b:[f.scope]);if(e===false){break}}a.inDispatch=false;return e}});(function(){var a=tinymce.each;tinymce.create("tinymce.util.URI",{URI:function(e,g){var f=this,i,d,c,h;e=tinymce.trim(e);g=f.settings=g||{};if(/^([\w\-]+):([^\/]{2})/i.test(e)||/^\s*#/.test(e)){f.source=e;return}if(e.indexOf("/")===0&&e.indexOf("//")!==0){e=(g.base_uri?g.base_uri.protocol||"http":"http")+"://mce_host"+e}if(!/^[\w\-]*:?\/\//.test(e)){h=g.base_uri?g.base_uri.path:new tinymce.util.URI(location.href).directory;e=((g.base_uri&&g.base_uri.protocol)||"http")+"://mce_host"+f.toAbsPath(h,e)}e=e.replace(/@@/g,"(mce_at)");e=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(e);a(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],function(b,j){var k=e[j];if(k){k=k.replace(/\(mce_at\)/g,"@@")}f[b]=k});c=g.base_uri;if(c){if(!f.protocol){f.protocol=c.protocol}if(!f.userInfo){f.userInfo=c.userInfo}if(!f.port&&f.host==="mce_host"){f.port=c.port}if(!f.host||f.host==="mce_host"){f.host=c.host}f.source=""}},setPath:function(c){var b=this;c=/^(.*?)\/?(\w+)?$/.exec(c);b.path=c[0];b.directory=c[1];b.file=c[2];b.source="";b.getURI()},toRelative:function(b){var d=this,f;if(b==="./"){return b}b=new tinymce.util.URI(b,{base_uri:d});if((b.host!="mce_host"&&d.host!=b.host&&b.host)||d.port!=b.port||d.protocol!=b.protocol){return b.getURI()}var c=d.getURI(),e=b.getURI();if(c==e||(c.charAt(c.length-1)=="/"&&c.substr(0,c.length-1)==e)){return c}f=d.toRelPath(d.path,b.path);if(b.query){f+="?"+b.query}if(b.anchor){f+="#"+b.anchor}return f},toAbsolute:function(b,c){b=new tinymce.util.URI(b,{base_uri:this});return b.getURI(this.host==b.host&&this.protocol==b.protocol?c:0)},toRelPath:function(g,h){var c,f=0,d="",e,b;g=g.substring(0,g.lastIndexOf("/"));g=g.split("/");c=h.split("/");if(g.length>=c.length){for(e=0,b=g.length;e<b;e++){if(e>=c.length||g[e]!=c[e]){f=e+1;break}}}if(g.length<c.length){for(e=0,b=c.length;e<b;e++){if(e>=g.length||g[e]!=c[e]){f=e+1;break}}}if(f===1){return h}for(e=0,b=g.length-(f-1);e<b;e++){d+="../"}for(e=f-1,b=c.length;e<b;e++){if(e!=f-1){d+="/"+c[e]}else{d+=c[e]}}return d},toAbsPath:function(e,f){var c,b=0,h=[],d,g;d=/\/$/.test(f)?"/":"";e=e.split("/");f=f.split("/");a(e,function(i){if(i){h.push(i)}});e=h;for(c=f.length-1,h=[];c>=0;c--){if(f[c].length===0||f[c]==="."){continue}if(f[c]===".."){b++;continue}if(b>0){b--;continue}h.push(f[c])}c=e.length-b;if(c<=0){g=h.reverse().join("/")}else{g=e.slice(0,c).join("/")+"/"+h.reverse().join("/")}if(g.indexOf("/")!==0){g="/"+g}if(d&&g.lastIndexOf("/")!==g.length-1){g+=d}return g},getURI:function(d){var c,b=this;if(!b.source||d){c="";if(!d){if(b.protocol){c+=b.protocol+"://"}if(b.userInfo){c+=b.userInfo+"@"}if(b.host){c+=b.host}if(b.port){c+=":"+b.port}}if(b.path){c+=b.path}if(b.query){c+="?"+b.query}if(b.anchor){c+="#"+b.anchor}b.source=c}return b.source}})})();(function(){var a=tinymce.each;tinymce.create("static tinymce.util.Cookie",{getHash:function(d){var b=this.get(d),c;if(b){a(b.split("&"),function(e){e=e.split("=");c=c||{};c[unescape(e[0])]=unescape(e[1])})}return c},setHash:function(j,b,g,f,i,c){var h="";a(b,function(e,d){h+=(!h?"":"&")+escape(d)+"="+escape(e)});this.set(j,h,g,f,i,c)},get:function(i){var h=document.cookie,g,f=i+"=",d;if(!h){return}d=h.indexOf("; "+f);if(d==-1){d=h.indexOf(f);if(d!==0){return null}}else{d+=2}g=h.indexOf(";",d);if(g==-1){g=h.length}return unescape(h.substring(d+f.length,g))},set:function(i,b,g,f,h,c){document.cookie=i+"="+escape(b)+((g)?"; expires="+g.toGMTString():"")+((f)?"; path="+escape(f):"")+((h)?"; domain="+h:"")+((c)?"; secure":"")},remove:function(c,e,d){var b=new Date();b.setTime(b.getTime()-1000);this.set(c,"",b,e,d)}})})();(function(){function serialize(o,quote){var i,v,t,name;quote=quote||'"';if(o==null){return"null"}t=typeof o;if(t=="string"){v="\bb\tt\nn\ff\rr\"\"''\\\\";return quote+o.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g,function(a,b){if(quote==='"'&&a==="'"){return a}i=v.indexOf(b);if(i+1){return"\\"+v.charAt(i+1)}a=b.charCodeAt().toString(16);return"\\u"+"0000".substring(a.length)+a})+quote}if(t=="object"){if(o.hasOwnProperty&&Object.prototype.toString.call(o)==="[object Array]"){for(i=0,v="[";i<o.length;i++){v+=(i>0?",":"")+serialize(o[i],quote)}return v+"]"}v="{";for(name in o){if(o.hasOwnProperty(name)){v+=typeof o[name]!="function"?(v.length>1?","+quote:quote)+name+quote+":"+serialize(o[name],quote):""}}return v+"}"}return""+o}tinymce.util.JSON={serialize:serialize,parse:function(s){try{return eval("("+s+")")}catch(ex){}}}})();tinymce.create("static tinymce.util.XHR",{send:function(g){var a,e,b=window,h=0;function f(){if(!g.async||a.readyState==4||h++>10000){if(g.success&&h<10000&&a.status==200){g.success.call(g.success_scope,""+a.responseText,a,g)}else{if(g.error){g.error.call(g.error_scope,h>10000?"TIMED_OUT":"GENERAL",a,g)}}a=null}else{b.setTimeout(f,10)}}g.scope=g.scope||this;g.success_scope=g.success_scope||g.scope;g.error_scope=g.error_scope||g.scope;g.async=g.async===false?false:true;g.data=g.data||"";function d(i){a=0;try{a=new ActiveXObject(i)}catch(c){}return a}a=b.XMLHttpRequest?new XMLHttpRequest():d("Microsoft.XMLHTTP")||d("Msxml2.XMLHTTP");if(a){if(a.overrideMimeType){a.overrideMimeType(g.content_type)}a.open(g.type||(g.data?"POST":"GET"),g.url,g.async);if(g.content_type){a.setRequestHeader("Content-Type",g.content_type)}a.setRequestHeader("X-Requested-With","XMLHttpRequest");a.send(g.data);if(!g.async){return f()}e=b.setTimeout(f,10)}}});(function(){var c=tinymce.extend,b=tinymce.util.JSON,a=tinymce.util.XHR;tinymce.create("tinymce.util.JSONRequest",{JSONRequest:function(d){this.settings=c({},d);this.count=0},send:function(f){var e=f.error,d=f.success;f=c(this.settings,f);f.success=function(h,g){h=b.parse(h);if(typeof(h)=="undefined"){h={error:"JSON Parse error."}}if(h.error){e.call(f.error_scope||f.scope,h.error,g)}else{d.call(f.success_scope||f.scope,h.result)}};f.error=function(h,g){if(e){e.call(f.error_scope||f.scope,h,g)}};f.data=b.serialize({id:f.id||"c"+(this.count++),method:f.method,params:f.params});f.content_type="application/json";a.send(f)},"static":{sendRPC:function(d){return new tinymce.util.JSONRequest().send(d)}}})}());(function(a){a.VK={BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,modifierPressed:function(b){return b.shiftKey||b.ctrlKey||b.altKey},metaKeyPressed:function(b){return a.isMac?b.metaKey:b.ctrlKey&&!b.altKey}}})(tinymce);tinymce.util.Quirks=function(a){var j=tinymce.VK,f=j.BACKSPACE,l=j.DELETE,e=a.dom,n=a.selection,J=a.settings,y=a.parser,q=a.serializer,G=tinymce.each;function C(P,O){try{a.getDoc().execCommand(P,false,O)}catch(N){}}function p(){var N=a.getDoc().documentMode;return N?N:6}function B(N){return N.isDefaultPrevented()}function L(){function N(T){var P,R,O,U,Q,S,V;function W(){if(Q.nodeType==3){if(T&&S==Q.length){return true}if(!T&&S===0){return true}}}P=n.getRng();var X=[P.startContainer,P.startOffset,P.endContainer,P.endOffset];if(!P.collapsed){T=true}Q=P[(T?"start":"end")+"Container"];S=P[(T?"start":"end")+"Offset"];if(Q.nodeType==3){R=e.getParent(P.startContainer,e.isBlock);if(T){R=e.getNext(R,e.isBlock)}if(R&&(W()||!P.collapsed)){O=e.create("em",{id:"__mceDel"});G(tinymce.grep(R.childNodes),function(Y){O.appendChild(Y)});R.appendChild(O)}}P=e.createRng();P.setStart(X[0],X[1]);P.setEnd(X[2],X[3]);n.setRng(P);a.getDoc().execCommand(T?"ForwardDelete":"Delete",false,null);if(O){U=n.getBookmark();while(V=e.get("__mceDel")){e.remove(V,true)}n.moveToBookmark(U)}}a.onKeyDown.add(function(O,Q){var P;P=Q.keyCode==l;if(!B(Q)&&(P||Q.keyCode==f)&&!j.modifierPressed(Q)){Q.preventDefault();N(P)}});a.addCommand("Delete",function(){N()})}function s(){function N(Q){var P=e.create("body");var R=Q.cloneContents();P.appendChild(R);return n.serializer.serialize(P,{format:"html"})}function O(P){var R=N(P);var S=e.createRng();S.selectNode(a.getBody());var Q=N(S);return R===Q}a.onKeyDown.add(function(Q,S){var R=S.keyCode,P;if(!B(S)&&(R==l||R==f)){P=Q.selection.isCollapsed();if(P&&!e.isEmpty(Q.getBody())){return}if(tinymce.isIE&&!P){return}if(!P&&!O(Q.selection.getRng())){return}Q.setContent("");Q.selection.setCursorLocation(Q.getBody(),0);Q.nodeChanged()}})}function K(){a.onKeyDown.add(function(N,O){if(!B(O)&&O.keyCode==65&&j.metaKeyPressed(O)){O.preventDefault();N.execCommand("SelectAll")}})}function M(){if(!a.settings.content_editable){e.bind(a.getDoc(),"focusin",function(N){n.setRng(n.getRng())});e.bind(a.getDoc(),"mousedown",function(N){if(N.target==a.getDoc().documentElement){a.getWin().focus();n.setRng(n.getRng())}})}}function D(){a.onKeyDown.add(function(N,Q){if(!B(Q)&&Q.keyCode===f){if(n.isCollapsed()&&n.getRng(true).startOffset===0){var P=n.getNode();var O=P.previousSibling;if(O&&O.nodeName&&O.nodeName.toLowerCase()==="hr"){e.remove(O);tinymce.dom.Event.cancel(Q)}}}})}function A(){if(!Range.prototype.getClientRects){a.onMouseDown.add(function(O,P){if(!B(P)&&P.target.nodeName==="HTML"){var N=O.getBody();N.blur();setTimeout(function(){N.focus()},0)}})}}function h(){a.onClick.add(function(N,O){O=O.target;if(/^(IMG|HR)$/.test(O.nodeName)){n.getSel().setBaseAndExtent(O,0,O,1)}if(O.nodeName=="A"&&e.hasClass(O,"mceItemAnchor")){n.select(O)}N.nodeChanged()})}function c(){function O(){var Q=e.getAttribs(n.getStart().cloneNode(false));return function(){var R=n.getStart();if(R!==a.getBody()){e.setAttrib(R,"style",null);G(Q,function(S){R.setAttributeNode(S.cloneNode(true))})}}}function N(){return !n.isCollapsed()&&e.getParent(n.getStart(),e.isBlock)!=e.getParent(n.getEnd(),e.isBlock)}function P(Q,R){R.preventDefault();return false}a.onKeyPress.add(function(Q,S){var R;if(!B(S)&&(S.keyCode==8||S.keyCode==46)&&N()){R=O();Q.getDoc().execCommand("delete",false,null);R();S.preventDefault();return false}});e.bind(a.getDoc(),"cut",function(R){var Q;if(!B(R)&&N()){Q=O();a.onKeyUp.addToTop(P);setTimeout(function(){Q();a.onKeyUp.remove(P)},0)}})}function b(){var O,N;e.bind(a.getDoc(),"selectionchange",function(){if(N){clearTimeout(N);N=0}N=window.setTimeout(function(){var P=n.getRng();if(!O||!tinymce.dom.RangeUtils.compareRanges(P,O)){a.nodeChanged();O=P}},50)})}function z(){document.body.setAttribute("role","application")}function v(){a.onKeyDown.add(function(N,P){if(!B(P)&&P.keyCode===f){if(n.isCollapsed()&&n.getRng(true).startOffset===0){var O=n.getNode().previousSibling;if(O&&O.nodeName&&O.nodeName.toLowerCase()==="table"){return tinymce.dom.Event.cancel(P)}}}})}function E(){if(p()>7){return}C("RespectVisibilityInDesign",true);a.contentStyles.push(".mceHideBrInPre pre br {display: none}");e.addClass(a.getBody(),"mceHideBrInPre");y.addNodeFilter("pre",function(N,P){var Q=N.length,S,O,T,R;while(Q--){S=N[Q].getAll("br");O=S.length;while(O--){T=S[O];R=T.prev;if(R&&R.type===3&&R.value.charAt(R.value-1)!="\n"){R.value+="\n"}else{T.parent.insert(new tinymce.html.Node("#text",3),T,true).value="\n"}}}});q.addNodeFilter("pre",function(N,P){var Q=N.length,S,O,T,R;while(Q--){S=N[Q].getAll("br");O=S.length;while(O--){T=S[O];R=T.prev;if(R&&R.type==3){R.value=R.value.replace(/\r?\n$/,"")}}}})}function g(){e.bind(a.getBody(),"mouseup",function(P){var O,N=n.getNode();if(N.nodeName=="IMG"){if(O=e.getStyle(N,"width")){e.setAttrib(N,"width",O.replace(/[^0-9%]+/g,""));e.setStyle(N,"width","")}if(O=e.getStyle(N,"height")){e.setAttrib(N,"height",O.replace(/[^0-9%]+/g,""));e.setStyle(N,"height","")}}})}function d(){a.onKeyDown.add(function(T,U){var S,N,O,Q,R,V,P;S=U.keyCode==l;if(!B(U)&&(S||U.keyCode==f)&&!j.modifierPressed(U)){N=n.getRng();O=N.startContainer;Q=N.startOffset;P=N.collapsed;if(O.nodeType==3&&O.nodeValue.length>0&&((Q===0&&!P)||(P&&Q===(S?0:1)))){V=O.previousSibling;if(V&&V.nodeName=="IMG"){return}nonEmptyElements=T.schema.getNonEmptyElements();U.preventDefault();R=e.create("br",{id:"__tmp"});O.parentNode.insertBefore(R,O);T.getDoc().execCommand(S?"ForwardDelete":"Delete",false,null);O=n.getRng().startContainer;V=O.previousSibling;if(V&&V.nodeType==1&&!e.isBlock(V)&&e.isEmpty(V)&&!nonEmptyElements[V.nodeName.toLowerCase()]){e.remove(V)}e.remove("__tmp")}}})}function I(){a.onKeyDown.add(function(R,S){var P,O,T,N,Q;if(B(S)||S.keyCode!=j.BACKSPACE){return}P=n.getRng();O=P.startContainer;T=P.startOffset;N=e.getRoot();Q=O;if(!P.collapsed||T!==0){return}while(Q&&Q.parentNode&&Q.parentNode.firstChild==Q&&Q.parentNode!=N){Q=Q.parentNode}if(Q.tagName==="BLOCKQUOTE"){R.formatter.toggle("blockquote",null,Q);P=e.createRng();P.setStart(O,0);P.setEnd(O,0);n.setRng(P)}})}function H(){function N(){a._refreshContentEditable();C("StyleWithCSS",false);C("enableInlineTableEditing",false);if(!J.object_resizing){C("enableObjectResizing",false)}}if(!J.readonly){a.onBeforeExecCommand.add(N);a.onMouseDown.add(N)}}function u(){function N(O,P){G(e.select("a"),function(S){var Q=S.parentNode,R=e.getRoot();if(Q.lastChild===S){while(Q&&!e.isBlock(Q)){if(Q.parentNode.lastChild!==Q||Q===R){return}Q=Q.parentNode}e.add(Q,"br",{"data-mce-bogus":1})}})}a.onExecCommand.add(function(O,P){if(P==="CreateLink"){N(O)}});a.onSetContent.add(n.onSetContent.add(N))}function o(){if(J.forced_root_block){a.onInit.add(function(){C("DefaultParagraphSeparator",J.forced_root_block)})}}function r(){function N(P,O){if(!P||!O.initial){a.execCommand("mceRepaint")}}a.onUndo.add(N);a.onRedo.add(N);a.onSetContent.add(N)}function i(){a.onKeyDown.add(function(O,P){var N;if(!B(P)&&P.keyCode==f){N=O.getDoc().selection.createRange();if(N&&N.item){P.preventDefault();O.undoManager.beforeChange();e.remove(N.item(0));O.undoManager.add()}}})}function t(){var N;if(p()>=10){N="";G("p div h1 h2 h3 h4 h5 h6".split(" "),function(O,P){N+=(P>0?",":"")+O+":empty"});a.contentStyles.push(N+"{padding-right: 1px !important}")}}function x(){var P,O,af,N,aa,ad,ab,ae,Q,R,ac,Y,X,Z=document,V=a.getDoc();if(!J.object_resizing||J.webkit_fake_resize===false){return}C("enableObjectResizing",false);ac={n:[0.5,0,0,-1],e:[1,0.5,1,0],s:[0.5,1,0,1],w:[0,0.5,-1,0],nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]};function T(aj){var ai,ah;ai=aj.screenX-ad;ah=aj.screenY-ab;Y=ai*aa[2]+ae;X=ah*aa[3]+Q;Y=Y<5?5:Y;X=X<5?5:X;if(j.modifierPressed(aj)||(af.nodeName=="IMG"&&aa[2]*aa[3]!==0)){Y=Math.round(X/R);X=Math.round(Y*R)}e.setStyles(N,{width:Y,height:X});if(aa[2]<0&&N.clientWidth<=Y){e.setStyle(N,"left",P+(ae-Y))}if(aa[3]<0&&N.clientHeight<=X){e.setStyle(N,"top",O+(Q-X))}}function ag(){function ah(ai,aj){if(aj){if(af.style[ai]||!a.schema.isValid(af.nodeName.toLowerCase(),ai)){e.setStyle(af,ai,aj)}else{e.setAttrib(af,ai,aj)}}}ah("width",Y);ah("height",X);e.unbind(V,"mousemove",T);e.unbind(V,"mouseup",ag);if(Z!=V){e.unbind(Z,"mousemove",T);e.unbind(Z,"mouseup",ag)}e.remove(N);S(af)}function S(ak){var ai,aj,ah;U();ai=e.getPos(ak);P=ai.x;O=ai.y;aj=ak.offsetWidth;ah=ak.offsetHeight;if(af!=ak){af=ak;Y=X=0}G(ac,function(an,al){var am;am=e.get("mceResizeHandle"+al);if(!am){am=e.add(V.documentElement,"div",{id:"mceResizeHandle"+al,"class":"mceResizeHandle",style:"cursor:"+al+"-resize; margin:0; padding:0"});e.bind(am,"mousedown",function(ao){ao.preventDefault();ag();ad=ao.screenX;ab=ao.screenY;ae=af.clientWidth;Q=af.clientHeight;R=Q/ae;aa=an;N=af.cloneNode(true);e.addClass(N,"mceClonedResizable");e.setStyles(N,{left:P,top:O,margin:0});V.documentElement.appendChild(N);e.bind(V,"mousemove",T);e.bind(V,"mouseup",ag);if(Z!=V){e.bind(Z,"mousemove",T);e.bind(Z,"mouseup",ag)}})}else{e.show(am)}e.setStyles(am,{left:(aj*an[0]+P)-(am.offsetWidth/2),top:(ah*an[1]+O)-(am.offsetHeight/2)})});if(!tinymce.isOpera&&af.nodeName=="IMG"){af.setAttribute("data-mce-selected","1")}}function U(){if(af){af.removeAttribute("data-mce-selected")}for(var ah in ac){e.hide("mceResizeHandle"+ah)}}a.contentStyles.push(".mceResizeHandle {position: absolute;border: 1px solid black;background: #FFF;width: 5px;height: 5px;z-index: 10000}.mceResizeHandle:hover {background: #000}img[data-mce-selected] {outline: 1px solid black}img.mceClonedResizable, table.mceClonedResizable {position: absolute;outline: 1px dashed black;opacity: .5;z-index: 10000}");function W(){var ah=e.getParent(n.getNode(),"table,img");G(e.select("img[data-mce-selected]"),function(ai){ai.removeAttribute("data-mce-selected")});if(ah){S(ah)}else{U()}}a.onNodeChange.add(W);e.bind(V,"selectionchange",W);a.serializer.addAttributeFilter("data-mce-selected",function(ah,ai){var aj=ah.length;while(aj--){ah[aj].attr(ai,null)}})}function F(){if(p()<9){y.addNodeFilter("noscript",function(N){var O=N.length,P,Q;while(O--){P=N[O];Q=P.firstChild;if(Q){P.attr("data-mce-innertext",Q.value)}}});q.addNodeFilter("noscript",function(N){var O=N.length,P,R,Q;while(O--){P=N[O];R=N[O].firstChild;if(R){R.value=tinymce.html.Entities.decode(R.value)}else{Q=P.attributes.map["data-mce-innertext"];if(Q){P.attr("data-mce-innertext",null);R=new tinymce.html.Node("#text",3);R.value=Q;R.raw=true;P.append(R)}}}})}}function m(){a.contentStyles.push("body {min-height: 100px}");a.onClick.add(function(N,O){if(O.target.nodeName=="HTML"){a.execCommand("SelectAll");a.selection.collapse(true);a.nodeChanged()}})}function k(){a.onInit.add(function(){var N;a.getBody().addEventListener("mscontrolselect",function(O){setTimeout(function(){if(a.selection.getNode()!=O.target){N=a.selection.getRng();n.fakeRng=a.dom.createRng();n.fakeRng.setStartBefore(O.target);n.fakeRng.setEndAfter(O.target)}},0)},false);a.getDoc().addEventListener("selectionchange",function(O){if(N&&!tinymce.dom.RangeUtils.compareRanges(a.selection.getRng(),N)){n.fakeRng=N=null}},false)})}v();I();s();if(tinymce.isWebKit){d();L();M();h();o();if(tinymce.isIDevice){b()}else{x();K()}}if(tinymce.isIE&&!tinymce.isIE11){D();z();E();g();i();t();F()}if(tinymce.isIE11){m();k()}if(tinymce.isGecko&&!tinymce.isIE11){D();A();c();H();u();r()}if(tinymce.isOpera){x()}};(function(j){var a,g,d,k=/[&<>\"\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,b=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,f=/[<>&\"\']/g,c=/&(#x|#)?([\w]+);/g,i={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"};g={'"':"&quot;","'":"&#39;","<":"&lt;",">":"&gt;","&":"&amp;"};d={"&lt;":"<","&gt;":">","&amp;":"&","&quot;":'"',"&apos;":"'"};function h(l){var m;m=document.createElement("div");m.innerHTML=l;return m.textContent||m.innerText||l}function e(m,p){var n,o,l,q={};if(m){m=m.split(",");p=p||10;for(n=0;n<m.length;n+=2){o=String.fromCharCode(parseInt(m[n],p));if(!g[o]){l="&"+m[n+1]+";";q[o]=l;q[l]=o}}return q}}a=e("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32);j.html=j.html||{};j.html.Entities={encodeRaw:function(m,l){return m.replace(l?k:b,function(n){return g[n]||n})},encodeAllRaw:function(l){return(""+l).replace(f,function(m){return g[m]||m})},encodeNumeric:function(m,l){return m.replace(l?k:b,function(n){if(n.length>1){return"&#"+(((n.charCodeAt(0)-55296)*1024)+(n.charCodeAt(1)-56320)+65536)+";"}return g[n]||"&#"+n.charCodeAt(0)+";"})},encodeNamed:function(n,l,m){m=m||a;return n.replace(l?k:b,function(o){return g[o]||m[o]||o})},getEncodeFunc:function(l,o){var p=j.html.Entities;o=e(o)||a;function m(r,q){return r.replace(q?k:b,function(s){return g[s]||o[s]||"&#"+s.charCodeAt(0)+";"||s})}function n(r,q){return p.encodeNamed(r,q,o)}l=j.makeMap(l.replace(/\+/g,","));if(l.named&&l.numeric){return m}if(l.named){if(o){return n}return p.encodeNamed}if(l.numeric){return p.encodeNumeric}return p.encodeRaw},decode:function(l){return l.replace(c,function(n,m,o){if(m){o=parseInt(o,m.length===2?16:10);if(o>65535){o-=65536;return String.fromCharCode(55296+(o>>10),56320+(o&1023))}else{return i[o]||String.fromCharCode(o)}}return d[n]||a[n]||h(n)})}}})(tinymce);tinymce.html.Styles=function(d,f){var k=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/gi,h=/(?:url(?:(?:\(\s*\"([^\"]+)\"\s*\))|(?:\(\s*\'([^\']+)\'\s*\))|(?:\(\s*([^)\s]+)\s*\))))|(?:\'([^\']+)\')|(?:\"([^\"]+)\")/gi,b=/\s*([^:]+):\s*([^;]+);?/g,l=/\s+$/,m=/rgb/,e,g,a={},j;d=d||{};j="\\\" \\' \\; \\: ; : \uFEFF".split(" ");for(g=0;g<j.length;g++){a[j[g]]="\uFEFF"+g;a["\uFEFF"+g]=j[g]}function c(n,q,p,i){function o(r){r=parseInt(r).toString(16);return r.length>1?r:"0"+r}return"#"+o(q)+o(p)+o(i)}return{toHex:function(i){return i.replace(k,c)},parse:function(s){var z={},q,n,x,r,v=d.url_converter,y=d.url_converter_scope||this;function p(D,G){var F,C,B,E;if(z["border-image"]==="none"){delete z["border-image"]}F=z[D+"-top"+G];if(!F){return}C=z[D+"-right"+G];if(F!=C){return}B=z[D+"-bottom"+G];if(C!=B){return}E=z[D+"-left"+G];if(B!=E){return}z[D+G]=E;delete z[D+"-top"+G];delete z[D+"-right"+G];delete z[D+"-bottom"+G];delete z[D+"-left"+G]}function u(C){var D=z[C],B;if(!D||D.indexOf(" ")<0){return}D=D.split(" ");B=D.length;while(B--){if(D[B]!==D[0]){return false}}z[C]=D[0];return true}function A(D,C,B,E){if(!u(C)){return}if(!u(B)){return}if(!u(E)){return}z[D]=z[C]+" "+z[B]+" "+z[E];delete z[C];delete z[B];delete z[E]}function t(B){r=true;return a[B]}function i(C,B){if(r){C=C.replace(/\uFEFF[0-9]/g,function(D){return a[D]})}if(!B){C=C.replace(/\\([\'\";:])/g,"$1")}return C}function o(C,B,F,E,G,D){G=G||D;if(G){G=i(G);return"'"+G.replace(/\'/g,"\\'")+"'"}B=i(B||F||E);if(v){B=v.call(y,B,"style")}return"url('"+B.replace(/\'/g,"\\'")+"')"}if(s){s=s.replace(/\\[\"\';:\uFEFF]/g,t).replace(/\"[^\"]+\"|\'[^\']+\'/g,function(B){return B.replace(/[;:]/g,t)});while(q=b.exec(s)){n=q[1].replace(l,"").toLowerCase();x=q[2].replace(l,"");if(n&&x.length>0){if(n==="font-weight"&&x==="700"){x="bold"}else{if(n==="color"||n==="background-color"){x=x.toLowerCase()}}x=x.replace(k,c);x=x.replace(h,o);z[n]=r?i(x,true):x}b.lastIndex=q.index+q[0].length}p("border","");p("border","-width");p("border","-color");p("border","-style");p("padding","");p("margin","");A("border","border-width","border-style","border-color");if(z.border==="medium none"){delete z.border}}return z},serialize:function(p,r){var o="",n,q;function i(t){var x,u,s,v;x=f.styles[t];if(x){for(u=0,s=x.length;u<s;u++){t=x[u];v=p[t];if(v!==e&&v.length>0){o+=(o.length>0?" ":"")+t+": "+v+";"}}}}if(r&&f&&f.styles){i("*");i(r)}else{for(n in p){q=p[n];if(q!==e&&q.length>0){o+=(o.length>0?" ":"")+n+": "+q+";"}}}return o}}};(function(f){var a={},e=f.makeMap,g=f.each;function d(j,i){return j.split(i||",")}function h(m,l){var j,k={};function i(n){return n.replace(/[A-Z]+/g,function(o){return i(m[o])})}for(j in m){if(m.hasOwnProperty(j)){m[j]=i(m[j])}}i(l).replace(/#/g,"#text").replace(/(\w+)\[([^\]]+)\]\[([^\]]*)\]/g,function(q,o,n,p){n=d(n,"|");k[o]={attributes:e(n),attributesOrder:n,children:e(p,"|",{"#comment":{}})}});return k}function b(){var i=a.html5;if(!i){i=a.html5=h({A:"id|accesskey|class|dir|draggable|item|hidden|itemprop|role|spellcheck|style|subject|title|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup",B:"#|a|abbr|area|audio|b|bdo|br|button|canvas|cite|code|command|datalist|del|dfn|em|embed|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|meta|meter|noscript|object|output|progress|q|ruby|samp|script|select|small|span|strong|sub|sup|svg|textarea|time|var|video|wbr",C:"#|a|abbr|area|address|article|aside|audio|b|bdo|blockquote|br|button|canvas|cite|code|command|datalist|del|details|dfn|dialog|div|dl|em|embed|fieldset|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|menu|meta|meter|nav|noscript|ol|object|output|p|pre|progress|q|ruby|samp|script|section|select|small|span|strong|style|sub|sup|svg|table|textarea|time|ul|var|video"},"html[A|manifest][body|head]head[A][base|command|link|meta|noscript|script|style|title]title[A][#]base[A|href|target][]link[A|href|rel|media|type|sizes][]meta[A|http-equiv|name|content|charset][]style[A|type|media|scoped][#]script[A|charset|type|src|defer|async][#]noscript[A][C]body[A][C]section[A][C]nav[A][C]article[A][C]aside[A][C]h1[A][B]h2[A][B]h3[A][B]h4[A][B]h5[A][B]h6[A][B]hgroup[A][h1|h2|h3|h4|h5|h6]header[A][C]footer[A][C]address[A][C]p[A][B]br[A][]pre[A][B]dialog[A][dd|dt]blockquote[A|cite][C]ol[A|start|reversed][li]ul[A][li]li[A|value][C]dl[A][dd|dt]dt[A][B]dd[A][C]a[A|href|target|ping|rel|media|type][B]em[A][B]strong[A][B]small[A][B]cite[A][B]q[A|cite][B]dfn[A][B]abbr[A][B]code[A][B]var[A][B]samp[A][B]kbd[A][B]sub[A][B]sup[A][B]i[A][B]b[A][B]mark[A][B]progress[A|value|max][B]meter[A|value|min|max|low|high|optimum][B]time[A|datetime][B]ruby[A][B|rt|rp]rt[A][B]rp[A][B]bdo[A][B]span[A][B]ins[A|cite|datetime][B]del[A|cite|datetime][B]figure[A][C|legend|figcaption]figcaption[A][C]img[A|alt|src|height|width|usemap|ismap][]iframe[A|name|src|height|width|sandbox|seamless][]embed[A|src|height|width|type][]object[A|data|type|height|width|usemap|name|form|classid][param]param[A|name|value][]details[A|open][C|legend]command[A|type|label|icon|disabled|checked|radiogroup][]menu[A|type|label][C|li]legend[A][C|B]div[A][C]source[A|src|type|media][]audio[A|src|autobuffer|autoplay|loop|controls][source]video[A|src|autobuffer|autoplay|loop|controls|width|height|poster][source]hr[A][]form[A|accept-charset|action|autocomplete|enctype|method|name|novalidate|target][C]fieldset[A|disabled|form|name][C|legend]label[A|form|for][B]input[A|type|accept|alt|autocomplete|autofocus|checked|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|height|list|max|maxlength|min|multiple|pattern|placeholder|readonly|required|size|src|step|width|files|value|name][]button[A|autofocus|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|name|value|type][B]select[A|autofocus|disabled|form|multiple|name|size][option|optgroup]datalist[A][B|option]optgroup[A|disabled|label][option]option[A|disabled|selected|label|value][]textarea[A|autofocus|disabled|form|maxlength|name|placeholder|readonly|required|rows|cols|wrap][]keygen[A|autofocus|challenge|disabled|form|keytype|name][]output[A|for|form|name][B]canvas[A|width|height][]map[A|name][B|C]area[A|shape|coords|href|alt|target|media|rel|ping|type][]mathml[A][]svg[A][]table[A|border][caption|colgroup|thead|tfoot|tbody|tr]caption[A][C]colgroup[A|span][col]col[A|span][]thead[A][tr]tfoot[A][tr]tbody[A][tr]tr[A][th|td]th[A|headers|rowspan|colspan|scope][B]td[A|headers|rowspan|colspan][C]wbr[A][]")}return i}function c(){var i=a.html4;if(!i){i=a.html4=h({Z:"H|K|N|O|P",Y:"X|form|R|Q",ZG:"E|span|width|align|char|charoff|valign",X:"p|T|div|U|W|isindex|fieldset|table",ZF:"E|align|char|charoff|valign",W:"pre|hr|blockquote|address|center|noframes",ZE:"abbr|axis|headers|scope|rowspan|colspan|align|char|charoff|valign|nowrap|bgcolor|width|height",ZD:"[E][S]",U:"ul|ol|dl|menu|dir",ZC:"p|Y|div|U|W|table|br|span|bdo|object|applet|img|map|K|N|Q",T:"h1|h2|h3|h4|h5|h6",ZB:"X|S|Q",S:"R|P",ZA:"a|G|J|M|O|P",R:"a|H|K|N|O",Q:"noscript|P",P:"ins|del|script",O:"input|select|textarea|label|button",N:"M|L",M:"em|strong|dfn|code|q|samp|kbd|var|cite|abbr|acronym",L:"sub|sup",K:"J|I",J:"tt|i|b|u|s|strike",I:"big|small|font|basefont",H:"G|F",G:"br|span|bdo",F:"object|applet|img|map|iframe",E:"A|B|C",D:"accesskey|tabindex|onfocus|onblur",C:"onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup",B:"lang|xml:lang|dir",A:"id|class|style|title"},"script[id|charset|type|language|src|defer|xml:space][]style[B|id|type|media|title|xml:space][]object[E|declare|classid|codebase|data|type|codetype|archive|standby|width|height|usemap|name|tabindex|align|border|hspace|vspace][#|param|Y]param[id|name|value|valuetype|type][]p[E|align][#|S]a[E|D|charset|type|name|href|hreflang|rel|rev|shape|coords|target][#|Z]br[A|clear][]span[E][#|S]bdo[A|C|B][#|S]applet[A|codebase|archive|code|object|alt|name|width|height|align|hspace|vspace][#|param|Y]h1[E|align][#|S]img[E|src|alt|name|longdesc|width|height|usemap|ismap|align|border|hspace|vspace][]map[B|C|A|name][X|form|Q|area]h2[E|align][#|S]iframe[A|longdesc|name|src|frameborder|marginwidth|marginheight|scrolling|align|width|height][#|Y]h3[E|align][#|S]tt[E][#|S]i[E][#|S]b[E][#|S]u[E][#|S]s[E][#|S]strike[E][#|S]big[E][#|S]small[E][#|S]font[A|B|size|color|face][#|S]basefont[id|size|color|face][]em[E][#|S]strong[E][#|S]dfn[E][#|S]code[E][#|S]q[E|cite][#|S]samp[E][#|S]kbd[E][#|S]var[E][#|S]cite[E][#|S]abbr[E][#|S]acronym[E][#|S]sub[E][#|S]sup[E][#|S]input[E|D|type|name|value|checked|disabled|readonly|size|maxlength|src|alt|usemap|onselect|onchange|accept|align][]select[E|name|size|multiple|disabled|tabindex|onfocus|onblur|onchange][optgroup|option]optgroup[E|disabled|label][option]option[E|selected|disabled|label|value][]textarea[E|D|name|rows|cols|disabled|readonly|onselect|onchange][]label[E|for|accesskey|onfocus|onblur][#|S]button[E|D|name|value|type|disabled][#|p|T|div|U|W|table|G|object|applet|img|map|K|N|Q]h4[E|align][#|S]ins[E|cite|datetime][#|Y]h5[E|align][#|S]del[E|cite|datetime][#|Y]h6[E|align][#|S]div[E|align][#|Y]ul[E|type|compact][li]li[E|type|value][#|Y]ol[E|type|compact|start][li]dl[E|compact][dt|dd]dt[E][#|S]dd[E][#|Y]menu[E|compact][li]dir[E|compact][li]pre[E|width|xml:space][#|ZA]hr[E|align|noshade|size|width][]blockquote[E|cite][#|Y]address[E][#|S|p]center[E][#|Y]noframes[E][#|Y]isindex[A|B|prompt][]fieldset[E][#|legend|Y]legend[E|accesskey|align][#|S]table[E|summary|width|border|frame|rules|cellspacing|cellpadding|align|bgcolor][caption|col|colgroup|thead|tfoot|tbody|tr]caption[E|align][#|S]col[ZG][]colgroup[ZG][col]thead[ZF][tr]tr[ZF|bgcolor][th|td]th[E|ZE][#|Y]form[E|action|method|name|enctype|onsubmit|onreset|accept|accept-charset|target][#|X|R|Q]noscript[E][#|Y]td[E|ZE][#|Y]tfoot[ZF][tr]tbody[ZF][tr]area[E|D|shape|coords|href|nohref|alt|target][]base[id|href|target][]body[E|onload|onunload|background|bgcolor|text|link|vlink|alink][#|Y]")}return i}f.html.Schema=function(A){var u=this,s={},k={},j=[],D,y;var o,q,z,r,v,n,p={};function m(F,E,H){var G=A[F];if(!G){G=a[F];if(!G){G=e(E," ",e(E.toUpperCase()," "));G=f.extend(G,H);a[F]=G}}else{G=e(G,",",e(G.toUpperCase()," "))}return G}A=A||{};y=A.schema=="html5"?b():c();if(A.verify_html===false){A.valid_elements="*[*]"}if(A.valid_styles){D={};g(A.valid_styles,function(F,E){D[E]=f.explode(F)})}o=m("whitespace_elements","pre script noscript style textarea");q=m("self_closing_elements","colgroup dd dt li option p td tfoot th thead tr");z=m("short_ended_elements","area base basefont br col frame hr img input isindex link meta param embed source wbr");r=m("boolean_attributes","checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls");n=m("non_empty_elements","td th iframe video audio object script",z);textBlockElementsMap=m("text_block_elements","h1 h2 h3 h4 h5 h6 p div address pre form blockquote center dir fieldset header footer article section hgroup aside nav figure");v=m("block_elements","hr table tbody thead tfoot th tr td li ol ul caption dl dt dd noscript menu isindex samp option datalist select optgroup",textBlockElementsMap);function i(E){return new RegExp("^"+E.replace(/([?+*])/g,".$1")+"$")}function C(L){var K,G,Z,V,aa,F,I,U,X,Q,Y,ac,O,J,W,E,S,H,ab,ad,P,T,N=/^([#+\-])?([^\[\/]+)(?:\/([^\[]+))?(?:\[([^\]]+)\])?$/,R=/^([!\-])?(\w+::\w+|[^=:<]+)?(?:([=:<])(.*))?$/,M=/[*?+]/;if(L){L=d(L);if(s["@"]){S=s["@"].attributes;H=s["@"].attributesOrder}for(K=0,G=L.length;K<G;K++){F=N.exec(L[K]);if(F){W=F[1];Q=F[2];E=F[3];X=F[4];O={};J=[];I={attributes:O,attributesOrder:J};if(W==="#"){I.paddEmpty=true}if(W==="-"){I.removeEmpty=true}if(S){for(ad in S){O[ad]=S[ad]}J.push.apply(J,H)}if(X){X=d(X,"|");for(Z=0,V=X.length;Z<V;Z++){F=R.exec(X[Z]);if(F){U={};ac=F[1];Y=F[2].replace(/::/g,":");W=F[3];T=F[4];if(ac==="!"){I.attributesRequired=I.attributesRequired||[];I.attributesRequired.push(Y);U.required=true}if(ac==="-"){delete O[Y];J.splice(f.inArray(J,Y),1);continue}if(W){if(W==="="){I.attributesDefault=I.attributesDefault||[];I.attributesDefault.push({name:Y,value:T});U.defaultValue=T}if(W===":"){I.attributesForced=I.attributesForced||[];I.attributesForced.push({name:Y,value:T});U.forcedValue=T}if(W==="<"){U.validValues=e(T,"?")}}if(M.test(Y)){I.attributePatterns=I.attributePatterns||[];U.pattern=i(Y);I.attributePatterns.push(U)}else{if(!O[Y]){J.push(Y)}O[Y]=U}}}}if(!S&&Q=="@"){S=O;H=J}if(E){I.outputName=Q;s[E]=I}if(M.test(Q)){I.pattern=i(Q);j.push(I)}else{s[Q]=I}}}}}function t(E){s={};j=[];C(E);g(y,function(G,F){k[F]=G.children})}function l(F){var E=/^(~)?(.+)$/;if(F){g(d(F),function(J){var H=E.exec(J),I=H[1]==="~",K=I?"span":"div",G=H[2];k[G]=k[K];p[G]=K;if(!I){v[G.toUpperCase()]={};v[G]={}}if(!s[G]){s[G]=s[K]}g(k,function(L,M){if(L[K]){L[G]=L[K]}})})}}function x(F){var E=/^([+\-]?)(\w+)\[([^\]]+)\]$/;if(F){g(d(F),function(J){var I=E.exec(J),G,H;if(I){H=I[1];if(H){G=k[I[2]]}else{G=k[I[2]]={"#comment":{}}}G=k[I[2]];g(d(I[3],"|"),function(K){if(H==="-"){delete G[K]}else{G[K]={}}})}})}}function B(E){var G=s[E],F;if(G){return G}F=j.length;while(F--){G=j[F];if(G.pattern.test(E)){return G}}}if(!A.valid_elements){g(y,function(F,E){s[E]={attributes:F.attributes,attributesOrder:F.attributesOrder};k[E]=F.children});if(A.schema!="html5"){g(d("strong/b,em/i"),function(E){E=d(E,"/");s[E[1]].outputName=E[0]})}s.img.attributesDefault=[{name:"alt",value:""}];g(d("ol,ul,sub,sup,blockquote,span,font,a,table,tbody,tr,strong,em,b,i"),function(E){if(s[E]){s[E].removeEmpty=true}});g(d("p,h1,h2,h3,h4,h5,h6,th,td,pre,div,address,caption"),function(E){s[E].paddEmpty=true})}else{t(A.valid_elements)}l(A.custom_elements);x(A.valid_children);C(A.extended_valid_elements);x("+ol[ul|ol],+ul[ul|ol]");if(A.invalid_elements){f.each(f.explode(A.invalid_elements),function(E){if(s[E]){delete s[E]}})}if(!B("span")){C("span[!data-mce-type|*]")}u.children=k;u.styles=D;u.getBoolAttrs=function(){return r};u.getBlockElements=function(){return v};u.getTextBlockElements=function(){return textBlockElementsMap};u.getShortEndedElements=function(){return z};u.getSelfClosingElements=function(){return q};u.getNonEmptyElements=function(){return n};u.getWhiteSpaceElements=function(){return o};u.isValidChild=function(E,G){var F=k[E];return !!(F&&F[G])};u.isValid=function(F,E){var H,G,I=B(F);if(I){if(E){if(I.attributes[E]){return true}H=I.attributePatterns;if(H){G=H.length;while(G--){if(H[G].pattern.test(F)){return true}}}}else{return true}}return false};u.getElementRule=B;u.getCustomElements=function(){return p};u.addValidElements=C;u.setValidElements=t;u.addCustomElements=l;u.addValidChildren=x;u.elements=s}})(tinymce);(function(a){a.html.SaxParser=function(c,e){var b=this,d=function(){};c=c||{};b.schema=e=e||new a.html.Schema();if(c.fix_self_closing!==false){c.fix_self_closing=true}a.each("comment cdata text start end pi doctype".split(" "),function(f){if(f){b[f]=c[f]||d}});b.parse=function(E){var n=this,g,G=0,I,B,A=[],N,Q,C,r,z,s,M,H,O,v,m,k,t,R,o,P,F,S,L,f,J,l,D,K,h,x=0,j=a.html.Entities.decode,y,q;function u(T){var V,U;V=A.length;while(V--){if(A[V].name===T){break}}if(V>=0){for(U=A.length-1;U>=V;U--){T=A[U];if(T.valid){n.end(T.name)}}A.length=V}}function p(U,T,Y,X,W){var Z,V;T=T.toLowerCase();Y=T in H?T:j(Y||X||W||"");if(v&&!z&&T.indexOf("data-")!==0){Z=P[T];if(!Z&&F){V=F.length;while(V--){Z=F[V];if(Z.pattern.test(T)){break}}if(V===-1){Z=null}}if(!Z){return}if(Z.validValues&&!(Y in Z.validValues)){return}}N.map[T]=Y;N.push({name:T,value:Y})}l=new RegExp("<(?:(?:!--([\\w\\W]*?)-->)|(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|(?:!DOCTYPE([\\w\\W]*?)>)|(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|(?:\\/([^>]+)>)|(?:([A-Za-z0-9\\-\\:\\.]+)((?:\\s+[^\"'>]+(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>]*))*|\\/|\\s+)>))","g");D=/([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:[^\"])*)\")|(?:\'((?:[^\'])*)\')|([^>\s]+)))?/g;K={script:/<\/script[^>]*>/gi,style:/<\/style[^>]*>/gi,noscript:/<\/noscript[^>]*>/gi};M=e.getShortEndedElements();J=c.self_closing_elements||e.getSelfClosingElements();H=e.getBoolAttrs();v=c.validate;s=c.remove_internals;y=c.fix_self_closing;q=a.isIE;o=/^:/;while(g=l.exec(E)){if(G<g.index){n.text(j(E.substr(G,g.index-G)))}if(I=g[6]){I=I.toLowerCase();if(q&&o.test(I)){I=I.substr(1)}u(I)}else{if(I=g[7]){I=I.toLowerCase();if(q&&o.test(I)){I=I.substr(1)}O=I in M;if(y&&J[I]&&A.length>0&&A[A.length-1].name===I){u(I)}if(!v||(m=e.getElementRule(I))){k=true;if(v){P=m.attributes;F=m.attributePatterns}if(R=g[8]){z=R.indexOf("data-mce-type")!==-1;if(z&&s){k=false}N=[];N.map={};R.replace(D,p)}else{N=[];N.map={}}if(v&&!z){S=m.attributesRequired;L=m.attributesDefault;f=m.attributesForced;if(f){Q=f.length;while(Q--){t=f[Q];r=t.name;h=t.value;if(h==="{$uid}"){h="mce_"+x++}N.map[r]=h;N.push({name:r,value:h})}}if(L){Q=L.length;while(Q--){t=L[Q];r=t.name;if(!(r in N.map)){h=t.value;if(h==="{$uid}"){h="mce_"+x++}N.map[r]=h;N.push({name:r,value:h})}}}if(S){Q=S.length;while(Q--){if(S[Q] in N.map){break}}if(Q===-1){k=false}}if(N.map["data-mce-bogus"]){k=false}}if(k){n.start(I,N,O)}}else{k=false}if(B=K[I]){B.lastIndex=G=g.index+g[0].length;if(g=B.exec(E)){if(k){C=E.substr(G,g.index-G)}G=g.index+g[0].length}else{C=E.substr(G);G=E.length}if(k&&C.length>0){n.text(C,true)}if(k){n.end(I)}l.lastIndex=G;continue}if(!O){if(!R||R.indexOf("/")!=R.length-1){A.push({name:I,valid:k})}else{if(k){n.end(I)}}}}else{if(I=g[1]){n.comment(I)}else{if(I=g[2]){n.cdata(I)}else{if(I=g[3]){n.doctype(I)}else{if(I=g[4]){n.pi(I,g[5])}}}}}}G=g.index+g[0].length}if(G<E.length){n.text(j(E.substr(G)))}for(Q=A.length-1;Q>=0;Q--){I=A[Q];if(I.valid){n.end(I.name)}}}}})(tinymce);(function(d){var c=/^[ \t\r\n]*$/,e={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11};function a(k,l,j){var i,h,f=j?"lastChild":"firstChild",g=j?"prev":"next";if(k[f]){return k[f]}if(k!==l){i=k[g];if(i){return i}for(h=k.parent;h&&h!==l;h=h.parent){i=h[g];if(i){return i}}}}function b(f,g){this.name=f;this.type=g;if(g===1){this.attributes=[];this.attributes.map={}}}d.extend(b.prototype,{replace:function(g){var f=this;if(g.parent){g.remove()}f.insert(g,f);f.remove();return f},attr:function(h,l){var f=this,g,j,k;if(typeof h!=="string"){for(j in h){f.attr(j,h[j])}return f}if(g=f.attributes){if(l!==k){if(l===null){if(h in g.map){delete g.map[h];j=g.length;while(j--){if(g[j].name===h){g=g.splice(j,1);return f}}}return f}if(h in g.map){j=g.length;while(j--){if(g[j].name===h){g[j].value=l;break}}}else{g.push({name:h,value:l})}g.map[h]=l;return f}else{return g.map[h]}}},clone:function(){var g=this,n=new b(g.name,g.type),h,f,m,j,k;if(m=g.attributes){k=[];k.map={};for(h=0,f=m.length;h<f;h++){j=m[h];if(j.name!=="id"){k[k.length]={name:j.name,value:j.value};k.map[j.name]=j.value}}n.attributes=k}n.value=g.value;n.shortEnded=g.shortEnded;return n},wrap:function(g){var f=this;f.parent.insert(g,f);g.append(f);return f},unwrap:function(){var f=this,h,g;for(h=f.firstChild;h;){g=h.next;f.insert(h,f,true);h=g}f.remove()},remove:function(){var f=this,h=f.parent,g=f.next,i=f.prev;if(h){if(h.firstChild===f){h.firstChild=g;if(g){g.prev=null}}else{i.next=g}if(h.lastChild===f){h.lastChild=i;if(i){i.next=null}}else{g.prev=i}f.parent=f.next=f.prev=null}return f},append:function(h){var f=this,g;if(h.parent){h.remove()}g=f.lastChild;if(g){g.next=h;h.prev=g;f.lastChild=h}else{f.lastChild=f.firstChild=h}h.parent=f;return h},insert:function(h,f,i){var g;if(h.parent){h.remove()}g=f.parent||this;if(i){if(f===g.firstChild){g.firstChild=h}else{f.prev.next=h}h.prev=f.prev;h.next=f;f.prev=h}else{if(f===g.lastChild){g.lastChild=h}else{f.next.prev=h}h.next=f.next;h.prev=f;f.next=h}h.parent=g;return h},getAll:function(g){var f=this,h,i=[];for(h=f.firstChild;h;h=a(h,f)){if(h.name===g){i.push(h)}}return i},empty:function(){var g=this,f,h,j;if(g.firstChild){f=[];for(j=g.firstChild;j;j=a(j,g)){f.push(j)}h=f.length;while(h--){j=f[h];j.parent=j.firstChild=j.lastChild=j.next=j.prev=null}}g.firstChild=g.lastChild=null;return g},isEmpty:function(k){var f=this,j=f.firstChild,h,g;if(j){do{if(j.type===1){if(j.attributes.map["data-mce-bogus"]){continue}if(k[j.name]){return false}h=j.attributes.length;while(h--){g=j.attributes[h].name;if(g==="name"||g.indexOf("data-mce-")===0){return false}}}if(j.type===8){return false}if((j.type===3&&!c.test(j.value))){return false}}while(j=a(j,f))}return true},walk:function(f){return a(this,null,f)}});d.extend(b,{create:function(g,f){var i,h;i=new b(g,e[g]||1);if(f){for(h in f){i.attr(h,f[h])}}return i}});d.html.Node=b})(tinymce);(function(b){var a=b.html.Node;b.html.DomParser=function(g,h){var f=this,e={},d=[],i={},c={};g=g||{};g.validate="validate" in g?g.validate:true;g.root_name=g.root_name||"body";f.schema=h=h||new b.html.Schema();function j(n){var p,q,y,x,A,o,r,l,u,v,k,t,m,z,s;t=b.makeMap("tr,td,th,tbody,thead,tfoot,table");k=h.getNonEmptyElements();m=h.getTextBlockElements();for(p=0;p<n.length;p++){q=n[p];if(!q.parent||q.fixed){continue}if(m[q.name]&&q.parent.name=="li"){z=q.next;while(z){if(m[z.name]){z.name="li";z.fixed=true;q.parent.insert(z,q.parent)}else{break}z=z.next}q.unwrap(q);continue}x=[q];for(y=q.parent;y&&!h.isValidChild(y.name,q.name)&&!t[y.name];y=y.parent){x.push(y)}if(y&&x.length>1){x.reverse();A=o=f.filterNode(x[0].clone());for(u=0;u<x.length-1;u++){if(h.isValidChild(o.name,x[u].name)){r=f.filterNode(x[u].clone());o.append(r)}else{r=o}for(l=x[u].firstChild;l&&l!=x[u+1];){s=l.next;r.append(l);l=s}o=r}if(!A.isEmpty(k)){y.insert(A,x[0],true);y.insert(q,A)}else{y.insert(q,x[0],true)}y=x[0];if(y.isEmpty(k)||y.firstChild===y.lastChild&&y.firstChild.name==="br"){y.empty().remove()}}else{if(q.parent){if(q.name==="li"){z=q.prev;if(z&&(z.name==="ul"||z.name==="ul")){z.append(q);continue}z=q.next;if(z&&(z.name==="ul"||z.name==="ul")){z.insert(q,z.firstChild,true);continue}q.wrap(f.filterNode(new a("ul",1)));continue}if(h.isValidChild(q.parent.name,"div")&&h.isValidChild("div",q.name)){q.wrap(f.filterNode(new a("div",1)))}else{if(q.name==="style"||q.name==="script"){q.empty().remove()}else{q.unwrap()}}}}}}f.filterNode=function(m){var l,k,n;if(k in e){n=i[k];if(n){n.push(m)}else{i[k]=[m]}}l=d.length;while(l--){k=d[l].name;if(k in m.attributes.map){n=c[k];if(n){n.push(m)}else{c[k]=[m]}}}return m};f.addNodeFilter=function(k,l){b.each(b.explode(k),function(m){var n=e[m];if(!n){e[m]=n=[]}n.push(l)})};f.addAttributeFilter=function(k,l){b.each(b.explode(k),function(m){var n;for(n=0;n<d.length;n++){if(d[n].name===m){d[n].callbacks.push(l);return}}d.push({name:m,callbacks:[l]})})};f.parse=function(v,m){var n,J,B,A,D,C,x,r,F,N,z,o,E,M=[],L,t,k,y,s,p,u,q;m=m||{};i={};c={};o=b.extend(b.makeMap("script,style,head,html,body,title,meta,param"),h.getBlockElements());u=h.getNonEmptyElements();p=h.children;z=g.validate;q="forced_root_block" in m?m.forced_root_block:g.forced_root_block;s=h.getWhiteSpaceElements();E=/^[ \t\r\n]+/;t=/[ \t\r\n]+$/;k=/[ \t\r\n]+/g;y=/^[ \t\r\n]+$/;function G(){var O=J.firstChild,l,P;while(O){l=O.next;if(O.type==3||(O.type==1&&O.name!=="p"&&!o[O.name]&&!O.attr("data-mce-type"))){if(!P){P=K(q,1);J.insert(P,O);P.append(O)}else{P.append(O)}}else{P=null}O=l}}function K(l,O){var P=new a(l,O),Q;if(l in e){Q=i[l];if(Q){Q.push(P)}else{i[l]=[P]}}return P}function I(P){var Q,l,O;for(Q=P.prev;Q&&Q.type===3;){l=Q.value.replace(t,"");if(l.length>0){Q.value=l;Q=Q.prev}else{O=Q.prev;Q.remove();Q=O}}}function H(O){var P,l={};for(P in O){if(P!=="li"&&P!="p"){l[P]=O[P]}}return l}n=new b.html.SaxParser({validate:z,self_closing_elements:H(h.getSelfClosingElements()),cdata:function(l){B.append(K("#cdata",4)).value=l},text:function(P,l){var O;if(!L){P=P.replace(k," ");if(B.lastChild&&o[B.lastChild.name]){P=P.replace(E,"")}}if(P.length!==0){O=K("#text",3);O.raw=!!l;B.append(O).value=P}},comment:function(l){B.append(K("#comment",8)).value=l},pi:function(l,O){B.append(K(l,7)).value=O;I(B)},doctype:function(O){var l;l=B.append(K("#doctype",10));l.value=O;I(B)},start:function(l,W,P){var U,R,Q,O,S,X,V,T;Q=z?h.getElementRule(l):{};if(Q){U=K(Q.outputName||l,1);U.attributes=W;U.shortEnded=P;B.append(U);T=p[B.name];if(T&&p[U.name]&&!T[U.name]){M.push(U)}R=d.length;while(R--){S=d[R].name;if(S in W.map){F=c[S];if(F){F.push(U)}else{c[S]=[U]}}}if(o[l]){I(U)}if(!P){B=U}if(!L&&s[l]){L=true}}},end:function(l){var S,P,R,O,Q;P=z?h.getElementRule(l):{};if(P){if(o[l]){if(!L){S=B.firstChild;if(S&&S.type===3){R=S.value.replace(E,"");if(R.length>0){S.value=R;S=S.next}else{O=S.next;S.remove();S=O}while(S&&S.type===3){R=S.value;O=S.next;if(R.length===0||y.test(R)){S.remove();S=O}S=O}}S=B.lastChild;if(S&&S.type===3){R=S.value.replace(t,"");if(R.length>0){S.value=R;S=S.prev}else{O=S.prev;S.remove();S=O}while(S&&S.type===3){R=S.value;O=S.prev;if(R.length===0||y.test(R)){S.remove();S=O}S=O}}}}if(L&&s[l]){L=false}if(P.removeEmpty||P.paddEmpty){if(B.isEmpty(u)){if(P.paddEmpty){B.empty().append(new a("#text","3")).value="\u00a0"}else{if(!B.attributes.map.name&&!B.attributes.map.id){Q=B.parent;B.empty().remove();B=Q;return}}}}B=B.parent}}},h);J=B=new a(m.context||g.root_name,11);n.parse(v);if(z&&M.length){if(!m.context){j(M)}else{m.invalid=true}}if(q&&J.name=="body"){G()}if(!m.invalid){for(N in i){F=e[N];A=i[N];x=A.length;while(x--){if(!A[x].parent){A.splice(x,1)}}for(D=0,C=F.length;D<C;D++){F[D](A,N,m)}}for(D=0,C=d.length;D<C;D++){F=d[D];if(F.name in c){A=c[F.name];x=A.length;while(x--){if(!A[x].parent){A.splice(x,1)}}for(x=0,r=F.callbacks.length;x<r;x++){F.callbacks[x](A,F.name,m)}}}}return J};if(g.remove_trailing_brs){f.addNodeFilter("br",function(n,m){var r,q=n.length,o,v=b.extend({},h.getBlockElements()),k=h.getNonEmptyElements(),t,s,p,u;v.body=1;for(r=0;r<q;r++){o=n[r];t=o.parent;if(v[o.parent.name]&&o===t.lastChild){p=o.prev;while(p){u=p.name;if(u!=="span"||p.attr("data-mce-type")!=="bookmark"){if(u!=="br"){break}if(u==="br"){o=null;break}}p=p.prev}if(o){o.remove();if(t.isEmpty(k)){elementRule=h.getElementRule(t.name);if(elementRule){if(elementRule.removeEmpty){t.remove()}else{if(elementRule.paddEmpty){t.empty().append(new b.html.Node("#text",3)).value="\u00a0"}}}}}}else{s=o;while(t.firstChild===s&&t.lastChild===s){s=t;if(v[t.name]){break}t=t.parent}if(s===t){textNode=new b.html.Node("#text",3);textNode.value="\u00a0";o.replace(textNode)}}}})}if(!g.allow_html_in_named_anchor){f.addAttributeFilter("id,name",function(k,l){var n=k.length,p,m,o,q;while(n--){q=k[n];if(q.name==="a"&&q.firstChild&&!q.attr("href")){o=q.parent;p=q.lastChild;do{m=p.prev;o.insert(p,q);p=m}while(p)}}})}}})(tinymce);tinymce.html.Writer=function(e){var c=[],a,b,d,f,g;e=e||{};a=e.indent;b=tinymce.makeMap(e.indent_before||"");d=tinymce.makeMap(e.indent_after||"");f=tinymce.html.Entities.getEncodeFunc(e.entity_encoding||"raw",e.entities);g=e.element_format=="html";return{start:function(m,k,p){var n,j,h,o;if(a&&b[m]&&c.length>0){o=c[c.length-1];if(o.length>0&&o!=="\n"){c.push("\n")}}c.push("<",m);if(k){for(n=0,j=k.length;n<j;n++){h=k[n];c.push(" ",h.name,'="',f(h.value,true),'"')}}if(!p||g){c[c.length]=">"}else{c[c.length]=" />"}if(p&&a&&d[m]&&c.length>0){o=c[c.length-1];if(o.length>0&&o!=="\n"){c.push("\n")}}},end:function(h){var i;c.push("</",h,">");if(a&&d[h]&&c.length>0){i=c[c.length-1];if(i.length>0&&i!=="\n"){c.push("\n")}}},text:function(i,h){if(i.length>0){c[c.length]=h?i:f(i)}},cdata:function(h){c.push("<![CDATA[",h,"]]>")},comment:function(h){c.push("<!--",h,"-->")},pi:function(h,i){if(i){c.push("<?",h," ",i,"?>")}else{c.push("<?",h,"?>")}if(a){c.push("\n")}},doctype:function(h){c.push("<!DOCTYPE",h,">",a?"\n":"")},reset:function(){c.length=0},getContent:function(){return c.join("").replace(/\n$/,"")}}};(function(a){a.html.Serializer=function(c,d){var b=this,e=new a.html.Writer(c);c=c||{};c.validate="validate" in c?c.validate:true;b.schema=d=d||new a.html.Schema();b.writer=e;b.serialize=function(h){var g,i;i=c.validate;g={3:function(k,j){e.text(k.value,k.raw)},8:function(j){e.comment(j.value)},7:function(j){e.pi(j.name,j.value)},10:function(j){e.doctype(j.value)},4:function(j){e.cdata(j.value)},11:function(j){if((j=j.firstChild)){do{f(j)}while(j=j.next)}}};e.reset();function f(k){var t=g[k.type],j,o,s,r,p,u,n,m,q;if(!t){j=k.name;o=k.shortEnded;s=k.attributes;if(i&&s&&s.length>1){u=[];u.map={};q=d.getElementRule(k.name);for(n=0,m=q.attributesOrder.length;n<m;n++){r=q.attributesOrder[n];if(r in s.map){p=s.map[r];u.map[r]=p;u.push({name:r,value:p})}}for(n=0,m=s.length;n<m;n++){r=s[n].name;if(!(r in u.map)){p=s.map[r];u.map[r]=p;u.push({name:r,value:p})}}s=u}e.start(k.name,s,o);if(!o){if((k=k.firstChild)){do{f(k)}while(k=k.next)}e.end(j)}}else{t(k)}}if(h.type==1&&!c.inner){f(h)}else{g[11](h)}return e.getContent()}}})(tinymce);tinymce.dom={};(function(b,h){var g=!!document.addEventListener;function c(k,j,l,i){if(k.addEventListener){k.addEventListener(j,l,i||false)}else{if(k.attachEvent){k.attachEvent("on"+j,l)}}}function e(k,j,l,i){if(k.removeEventListener){k.removeEventListener(j,l,i||false)}else{if(k.detachEvent){k.detachEvent("on"+j,l)}}}function a(n,l){var i,k=l||{};function j(){return false}function m(){return true}for(i in n){if(i!=="layerX"&&i!=="layerY"){k[i]=n[i]}}if(!k.target){k.target=k.srcElement||document}k.preventDefault=function(){k.isDefaultPrevented=m;if(n){if(n.preventDefault){n.preventDefault()}else{n.returnValue=false}}};k.stopPropagation=function(){k.isPropagationStopped=m;if(n){if(n.stopPropagation){n.stopPropagation()}else{n.cancelBubble=true}}};k.stopImmediatePropagation=function(){k.isImmediatePropagationStopped=m;k.stopPropagation()};if(!k.isDefaultPrevented){k.isDefaultPrevented=j;k.isPropagationStopped=j;k.isImmediatePropagationStopped=j}return k}function d(m,n,l){var k=m.document,j={type:"ready"};function i(){if(!l.domLoaded){l.domLoaded=true;n(j)}}if(k.readyState=="complete"){i();return}if(g){c(m,"DOMContentLoaded",i)}else{c(k,"readystatechange",function(){if(k.readyState==="complete"){e(k,"readystatechange",arguments.callee);i()}});if(k.documentElement.doScroll&&m===m.top){(function(){try{k.documentElement.doScroll("left")}catch(o){setTimeout(arguments.callee,0);return}i()})()}}c(m,"load",i)}function f(k){var q=this,p={},i,o,n,m,l;m="onmouseenter" in document.documentElement;n="onfocusin" in document.documentElement;l={mouseenter:"mouseover",mouseleave:"mouseout"};i=1;q.domLoaded=false;q.events=p;function j(t,x){var s,u,r,v;s=p[x][t.type];if(s){for(u=0,r=s.length;u<r;u++){v=s[u];if(v&&v.func.call(v.scope,t)===false){t.preventDefault()}if(t.isImmediatePropagationStopped()){return}}}}q.bind=function(x,A,D,E){var s,t,u,r,B,z,C,v=window;function y(F){j(a(F||v.event),s)}if(!x||x.nodeType===3||x.nodeType===8){return}if(!x[h]){s=i++;x[h]=s;p[s]={}}else{s=x[h];if(!p[s]){p[s]={}}}E=E||x;A=A.split(" ");u=A.length;while(u--){r=A[u];z=y;B=C=false;if(r==="DOMContentLoaded"){r="ready"}if((q.domLoaded||x.readyState=="complete")&&r==="ready"){q.domLoaded=true;D.call(E,a({type:r}));continue}if(!m){B=l[r];if(B){z=function(F){var H,G;H=F.currentTarget;G=F.relatedTarget;if(G&&H.contains){G=H.contains(G)}else{while(G&&G!==H){G=G.parentNode}}if(!G){F=a(F||v.event);F.type=F.type==="mouseout"?"mouseleave":"mouseenter";F.target=H;j(F,s)}}}}if(!n&&(r==="focusin"||r==="focusout")){C=true;B=r==="focusin"?"focus":"blur";z=function(F){F=a(F||v.event);F.type=F.type==="focus"?"focusin":"focusout";j(F,s)}}t=p[s][r];if(!t){p[s][r]=t=[{func:D,scope:E}];t.fakeName=B;t.capture=C;t.nativeHandler=z;if(!g){t.proxyHandler=k(s)}if(r==="ready"){d(x,z,q)}else{c(x,B||r,g?z:t.proxyHandler,C)}}else{t.push({func:D,scope:E})}}x=t=0;return D};q.unbind=function(x,z,A){var s,u,v,B,r,t;if(!x||x.nodeType===3||x.nodeType===8){return q}s=x[h];if(s){t=p[s];if(z){z=z.split(" ");v=z.length;while(v--){r=z[v];u=t[r];if(u){if(A){B=u.length;while(B--){if(u[B].func===A){u.splice(B,1)}}}if(!A||u.length===0){delete t[r];e(x,u.fakeName||r,g?u.nativeHandler:u.proxyHandler,u.capture)}}}}else{for(r in t){u=t[r];e(x,u.fakeName||r,g?u.nativeHandler:u.proxyHandler,u.capture)}t={}}for(r in t){return q}delete p[s];try{delete x[h]}catch(y){x[h]=null}}return q};q.fire=function(u,s,r){var v,t;if(!u||u.nodeType===3||u.nodeType===8){return q}t=a(null,r);t.type=s;do{v=u[h];if(v){j(t,v)}u=u.parentNode||u.ownerDocument||u.defaultView||u.parentWindow}while(u&&!t.isPropagationStopped());return q};q.clean=function(u){var s,r,t=q.unbind;if(!u||u.nodeType===3||u.nodeType===8){return q}if(u[h]){t(u)}if(!u.getElementsByTagName){u=u.document}if(u&&u.getElementsByTagName){t(u);r=u.getElementsByTagName("*");s=r.length;while(s--){u=r[s];if(u[h]){t(u)}}}return q};q.callNativeHandler=function(s,r){if(p){p[s][r.type].nativeHandler(r)}};q.destory=function(){p={}};q.add=function(v,s,u,t){if(typeof(v)==="string"){v=document.getElementById(v)}if(v&&v instanceof Array){var r=v.length;while(r--){q.add(v[r],s,u,t)}return}if(s==="init"){s="ready"}return q.bind(v,s instanceof Array?s.join(" "):s,u,t)};q.remove=function(v,s,u,t){if(!v){return q}if(typeof(v)==="string"){v=document.getElementById(v)}if(v instanceof Array){var r=v.length;while(r--){q.remove(v[r],s,u,t)}return q}return q.unbind(v,s instanceof Array?s.join(" "):s,u)};q.clear=function(r){if(typeof(r)==="string"){r=document.getElementById(r)}return q.clean(r)};q.cancel=function(r){if(r){q.prevent(r);q.stop(r)}return false};q.prevent=function(r){if(!r.preventDefault){r=a(r)}r.preventDefault();return false};q.stop=function(r){if(!r.stopPropagation){r=a(r)}r.stopPropagation();return false}}b.EventUtils=f;b.Event=new f(function(i){return function(j){tinymce.dom.Event.callNativeHandler(i,j)}});b.Event.bind(window,"ready",function(){});b=0})(tinymce.dom,"data-mce-expando");tinymce.dom.TreeWalker=function(a,c){var b=a;function d(i,f,e,j){var h,g;if(i){if(!j&&i[f]){return i[f]}if(i!=c){h=i[e];if(h){return h}for(g=i.parentNode;g&&g!=c;g=g.parentNode){h=g[e];if(h){return h}}}}}this.current=function(){return b};this.next=function(e){return(b=d(b,"firstChild","nextSibling",e))};this.prev=function(e){return(b=d(b,"lastChild","previousSibling",e))}};(function(e){var g=e.each,d=e.is,f=e.isWebKit,b=e.isIE,h=e.html.Entities,c=/^([a-z0-9],?)+$/i,a=/^[ \t\r\n]*$/;e.create("tinymce.dom.DOMUtils",{doc:null,root:null,files:null,pixelStyles:/^(top|left|bottom|right|width|height|borderWidth)$/,props:{"for":"htmlFor","class":"className",className:"className",checked:"checked",disabled:"disabled",maxlength:"maxLength",readonly:"readOnly",selected:"selected",value:"value",id:"id",name:"name",type:"type"},DOMUtils:function(o,l){var k=this,i,j,n;k.doc=o;k.win=window;k.files={};k.cssFlicker=false;k.counter=0;k.stdMode=!e.isIE||o.documentMode>=8;k.boxModel=!e.isIE||o.compatMode=="CSS1Compat"||k.stdMode;k.hasOuterHTML="outerHTML" in o.createElement("a");k.settings=l=e.extend({keep_values:false,hex_colors:1},l);k.schema=l.schema;k.styles=new e.html.Styles({url_converter:l.url_converter,url_converter_scope:l.url_converter_scope},l.schema);if(e.isIE6){try{o.execCommand("BackgroundImageCache",false,true)}catch(m){k.cssFlicker=true}}k.fixDoc(o);k.events=l.ownEvents?new e.dom.EventUtils(l.proxy):e.dom.Event;e.addUnload(k.destroy,k);n=l.schema?l.schema.getBlockElements():{};k.isBlock=function(q){if(!q){return false}var p=q.nodeType;if(p){return !!(p===1&&n[q.nodeName])}return !!n[q]}},fixDoc:function(k){var j=this.settings,i;if(b&&!e.isIE11&&j.schema){("abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video").replace(/\w+/g,function(l){k.createElement(l)});for(i in j.schema.getCustomElements()){k.createElement(i)}}},clone:function(k,i){var j=this,m,l;if(!b||e.isIE11||k.nodeType!==1||i){return k.cloneNode(i)}l=j.doc;if(!i){m=l.createElement(k.nodeName);g(j.getAttribs(k),function(n){j.setAttrib(m,n.nodeName,j.getAttrib(k,n.nodeName))});return m}return m.firstChild},getRoot:function(){var i=this,j=i.settings;return(j&&i.get(j.root_element))||i.doc.body},getViewPort:function(j){var k,i;j=!j?this.win:j;k=j.document;i=this.boxModel?k.documentElement:k.body;return{x:j.pageXOffset||i.scrollLeft,y:j.pageYOffset||i.scrollTop,w:j.innerWidth||i.clientWidth,h:j.innerHeight||i.clientHeight}},getRect:function(l){var k,i=this,j;l=i.get(l);k=i.getPos(l);j=i.getSize(l);return{x:k.x,y:k.y,w:j.w,h:j.h}},getSize:function(l){var j=this,i,k;l=j.get(l);i=j.getStyle(l,"width");k=j.getStyle(l,"height");if(i.indexOf("px")===-1){i=0}if(k.indexOf("px")===-1){k=0}return{w:parseInt(i,10)||l.offsetWidth||l.clientWidth,h:parseInt(k,10)||l.offsetHeight||l.clientHeight}},getParent:function(k,j,i){return this.getParents(k,j,i,false)},getParents:function(s,m,k,q){var j=this,i,l=j.settings,p=[];s=j.get(s);q=q===undefined;if(l.strict_root){k=k||j.getRoot()}if(d(m,"string")){i=m;if(m==="*"){m=function(o){return o.nodeType==1}}else{m=function(o){return j.is(o,i)}}}while(s){if(s==k||!s.nodeType||s.nodeType===9){break}if(!m||m(s)){if(q){p.push(s)}else{return s}}s=s.parentNode}return q?p:null},get:function(i){var j;if(i&&this.doc&&typeof(i)=="string"){j=i;i=this.doc.getElementById(i);if(i&&i.id!==j){return this.doc.getElementsByName(j)[1]}}return i},getNext:function(j,i){return this._findSib(j,i,"nextSibling")},getPrev:function(j,i){return this._findSib(j,i,"previousSibling")},select:function(k,j){var i=this;return e.dom.Sizzle(k,i.get(j)||i.get(i.settings.root_element)||i.doc,[])},is:function(l,j){var k;if(l.length===undefined){if(j==="*"){return l.nodeType==1}if(c.test(j)){j=j.toLowerCase().split(/,/);l=l.nodeName.toLowerCase();for(k=j.length-1;k>=0;k--){if(j[k]==l){return true}}return false}}return e.dom.Sizzle.matches(j,l.nodeType?[l]:l).length>0},add:function(l,o,i,k,m){var j=this;return this.run(l,function(r){var q,n;q=d(o,"string")?j.doc.createElement(o):o;j.setAttribs(q,i);if(k){if(k.nodeType){q.appendChild(k)}else{j.setHTML(q,k)}}return !m?r.appendChild(q):q})},create:function(k,i,j){return this.add(this.doc.createElement(k),k,i,j,1)},createHTML:function(q,i,m){var p="",l=this,j;p+="<"+q;for(j in i){if(i.hasOwnProperty(j)){p+=" "+j+'="'+l.encode(i[j])+'"'}}if(typeof(m)!="undefined"){return p+">"+m+"</"+q+">"}return p+" />"},remove:function(i,j){return this.run(i,function(l){var m,k=l.parentNode;if(!k){return null}if(j){while(m=l.firstChild){if(!e.isIE||m.nodeType!==3||m.nodeValue){k.insertBefore(m,l)}else{l.removeChild(m)}}}return k.removeChild(l)})},setStyle:function(l,i,j){var k=this;return k.run(l,function(o){var n,m;n=o.style;i=i.replace(/-(\D)/g,function(q,p){return p.toUpperCase()});if(k.pixelStyles.test(i)&&(e.is(j,"number")||/^[\-0-9\.]+$/.test(j))){j+="px"}switch(i){case"opacity":if(b&&!e.isIE11){n.filter=j===""?"":"alpha(opacity="+(j*100)+")";if(!l.currentStyle||!l.currentStyle.hasLayout){n.display="inline-block"}}n[i]=n["-moz-opacity"]=n["-khtml-opacity"]=j||"";break;case"float":(b&&!e.isIE11)?n.styleFloat=j:n.cssFloat=j;break;default:n[i]=j||""}if(k.settings.update_styles){k.setAttrib(o,"data-mce-style")}})},getStyle:function(l,i,k){l=this.get(l);if(!l){return}if(this.doc.defaultView&&k){i=i.replace(/[A-Z]/g,function(m){return"-"+m});try{return this.doc.defaultView.getComputedStyle(l,null).getPropertyValue(i)}catch(j){return null}}i=i.replace(/-(\D)/g,function(n,m){return m.toUpperCase()});if(i=="float"){i=b?"styleFloat":"cssFloat"}if(l.currentStyle&&k){return l.currentStyle[i]}return l.style?l.style[i]:undefined},setStyles:function(l,m){var j=this,k=j.settings,i;i=k.update_styles;k.update_styles=0;g(m,function(o,p){j.setStyle(l,p,o)});k.update_styles=i;if(k.update_styles){j.setAttrib(l,k.cssText)}},removeAllAttribs:function(i){return this.run(i,function(l){var k,j=l.attributes;for(k=j.length-1;k>=0;k--){l.removeAttributeNode(j.item(k))}})},setAttrib:function(k,l,i){var j=this;if(!k||!l){return}if(j.settings.strict){l=l.toLowerCase()}return this.run(k,function(p){var o=j.settings;var m=p.getAttribute(l);if(i!==null){switch(l){case"style":if(!d(i,"string")){g(i,function(q,r){j.setStyle(p,r,q)});return}if(o.keep_values){if(i&&!j._isRes(i)){p.setAttribute("data-mce-style",i,2)}else{p.removeAttribute("data-mce-style",2)}}p.style.cssText=i;break;case"class":p.className=i||"";break;case"src":case"href":if(o.keep_values){if(o.url_converter){i=o.url_converter.call(o.url_converter_scope||j,i,l,p)}j.setAttrib(p,"data-mce-"+l,i,2)}break;case"shape":p.setAttribute("data-mce-style",i);break}}if(d(i)&&i!==null&&i.length!==0){p.setAttribute(l,""+i,2)}else{p.removeAttribute(l,2)}if(tinyMCE.activeEditor&&m!=i){var n=tinyMCE.activeEditor;n.onSetAttrib.dispatch(n,p,l,i)}})},setAttribs:function(j,k){var i=this;return this.run(j,function(l){g(k,function(m,o){i.setAttrib(l,o,m)})})},getAttrib:function(m,o,k){var i,j=this,l;m=j.get(m);if(!m||m.nodeType!==1){return k===l?false:k}if(!d(k)){k=""}if(/^(src|href|style|coords|shape)$/.test(o)){i=m.getAttribute("data-mce-"+o);if(i){return i}}if(b&&j.props[o]){i=m[j.props[o]];i=i&&i.nodeValue?i.nodeValue:i}if(!i){i=m.getAttribute(o,2)}if(/^(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)$/.test(o)){if(m[j.props[o]]===true&&i===""){return o}return i?o:""}if(m.nodeName==="FORM"&&m.getAttributeNode(o)){return m.getAttributeNode(o).nodeValue}if(o==="style"){i=i||m.style.cssText;if(i){i=j.serializeStyle(j.parseStyle(i),m.nodeName);if(j.settings.keep_values&&!j._isRes(i)){m.setAttribute("data-mce-style",i)}}}if(f&&o==="class"&&i){i=i.replace(/(apple|webkit)\-[a-z\-]+/gi,"")}if(b){switch(o){case"rowspan":case"colspan":if(i===1){i=""}break;case"size":if(i==="+0"||i===20||i===0){i=""}break;case"width":case"height":case"vspace":case"checked":case"disabled":case"readonly":if(i===0){i=""}break;case"hspace":if(i===-1){i=""}break;case"maxlength":case"tabindex":if(i===32768||i===2147483647||i==="32768"){i=""}break;case"multiple":case"compact":case"noshade":case"nowrap":if(i===65535){return o}return k;case"shape":i=i.toLowerCase();break;default:if(o.indexOf("on")===0&&i){i=e._replace(/^function\s+\w+\(\)\s+\{\s+(.*)\s+\}$/,"$1",""+i)}}}return(i!==l&&i!==null&&i!=="")?""+i:k},getPos:function(q,l){var j=this,i=0,p=0,m,o=j.doc,k;q=j.get(q);l=l||o.body;if(q){if(q.getBoundingClientRect){q=q.getBoundingClientRect();m=j.boxModel?o.documentElement:o.body;i=q.left+(o.documentElement.scrollLeft||o.body.scrollLeft)-m.clientTop;p=q.top+(o.documentElement.scrollTop||o.body.scrollTop)-m.clientLeft;return{x:i,y:p}}k=q;while(k&&k!=l&&k.nodeType){i+=k.offsetLeft||0;p+=k.offsetTop||0;k=k.offsetParent}k=q.parentNode;while(k&&k!=l&&k.nodeType){i-=k.scrollLeft||0;p-=k.scrollTop||0;k=k.parentNode}}return{x:i,y:p}},parseStyle:function(i){return this.styles.parse(i)},serializeStyle:function(j,i){return this.styles.serialize(j,i)},addStyle:function(j){var k=this.doc,i;styleElm=k.getElementById("mceDefaultStyles");if(!styleElm){styleElm=k.createElement("style"),styleElm.id="mceDefaultStyles";styleElm.type="text/css";i=k.getElementsByTagName("head")[0];if(i.firstChild){i.insertBefore(styleElm,i.firstChild)}else{i.appendChild(styleElm)}}if(styleElm.styleSheet){styleElm.styleSheet.cssText+=j}else{styleElm.appendChild(k.createTextNode(j))}},loadCSS:function(i){var k=this,l=k.doc,j;if(!i){i=""}j=l.getElementsByTagName("head")[0];g(i.split(","),function(m){var n;if(k.files[m]){return}k.files[m]=true;n=k.create("link",{rel:"stylesheet",href:e._addVer(m)});if(b&&!e.isIE11&&l.documentMode&&l.recalc){n.onload=function(){if(l.recalc){l.recalc()}n.onload=null}}j.appendChild(n)})},addClass:function(i,j){return this.run(i,function(k){var l;if(!j){return 0}if(this.hasClass(k,j)){return k.className}l=this.removeClass(k,j);return k.className=(l!=""?(l+" "):"")+j})},removeClass:function(k,l){var i=this,j;return i.run(k,function(n){var m;if(i.hasClass(n,l)){if(!j){j=new RegExp("(^|\\s+)"+l+"(\\s+|$)","g")}m=n.className.replace(j," ");m=e.trim(m!=" "?m:"");n.className=m;if(!m){n.removeAttribute("class");n.removeAttribute("className")}return m}return n.className})},hasClass:function(j,i){j=this.get(j);if(!j||!i){return false}return(" "+j.className+" ").indexOf(" "+i+" ")!==-1},show:function(i){return this.setStyle(i,"display","block")},hide:function(i){return this.setStyle(i,"display","none")},isHidden:function(i){i=this.get(i);return !i||i.style.display=="none"||this.getStyle(i,"display")=="none"},uniqueId:function(i){return(!i?"mce_":i)+(this.counter++)},setHTML:function(k,j){var i=this;return i.run(k,function(m){if(b){while(m.firstChild){m.removeChild(m.firstChild)}try{m.innerHTML="<br />"+j;m.removeChild(m.firstChild)}catch(l){var n=i.create("div");n.innerHTML="<br />"+j;g(e.grep(n.childNodes),function(p,o){if(o&&m.canHaveHTML){m.appendChild(p)}})}}else{m.innerHTML=j}return j})},getOuterHTML:function(k){var j,i=this;k=i.get(k);if(!k){return null}if(k.nodeType===1&&i.hasOuterHTML){return k.outerHTML}j=(k.ownerDocument||i.doc).createElement("body");j.appendChild(k.cloneNode(true));return j.innerHTML},setOuterHTML:function(l,j,m){var i=this;function k(p,o,r){var s,q;q=r.createElement("body");q.innerHTML=o;s=q.lastChild;while(s){i.insertAfter(s.cloneNode(true),p);s=s.previousSibling}i.remove(p)}return this.run(l,function(o){o=i.get(o);if(o.nodeType==1){m=m||o.ownerDocument||i.doc;if(b){try{if(b&&o.nodeType==1){o.outerHTML=j}else{k(o,j,m)}}catch(n){k(o,j,m)}}else{k(o,j,m)}}})},decode:h.decode,encode:h.encodeAllRaw,insertAfter:function(i,j){j=this.get(j);return this.run(i,function(l){var k,m;k=j.parentNode;m=j.nextSibling;if(m){k.insertBefore(l,m)}else{k.appendChild(l)}return l})},replace:function(m,l,i){var j=this;if(d(l,"array")){m=m.cloneNode(true)}return j.run(l,function(k){if(i){g(e.grep(k.childNodes),function(n){m.appendChild(n)})}return k.parentNode.replaceChild(m,k)})},rename:function(l,i){var k=this,j;if(l.nodeName!=i.toUpperCase()){j=k.create(i);g(k.getAttribs(l),function(m){k.setAttrib(j,m.nodeName,k.getAttrib(l,m.nodeName))});k.replace(j,l,1)}return j||l},findCommonAncestor:function(k,i){var l=k,j;while(l){j=i;while(j&&l!=j){j=j.parentNode}if(l==j){break}l=l.parentNode}if(!l&&k.ownerDocument){return k.ownerDocument.documentElement}return l},toHex:function(i){var k=/^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(i);function j(l){l=parseInt(l,10).toString(16);return l.length>1?l:"0"+l}if(k){i="#"+j(k[1])+j(k[2])+j(k[3]);return i}return i},getClasses:function(){var n=this,j=[],m,o={},p=n.settings.class_filter,l;if(n.classes){return n.classes}function q(i){g(i.imports,function(s){q(s)});g(i.cssRules||i.rules,function(t){switch(t.type||1){case 1:if(t.selectorText){g(t.selectorText.split(","),function(r){r=r.replace(/^\s*|\s*$|^\s\./g,"");if(/\.mce/.test(r)||!/\.[\w\-]+$/.test(r)){return}l=r;r=e._replace(/.*\.([a-z0-9_\-]+).*/i,"$1",r);if(p&&!(r=p(r,l))){return}if(!o[r]){j.push({"class":r});o[r]=1}})}break;case 3:try{q(t.styleSheet)}catch(s){}break}})}try{g(n.doc.styleSheets,q)}catch(k){}if(j.length>0){n.classes=j}return j},run:function(l,k,j){var i=this,m;if(i.doc&&typeof(l)==="string"){l=i.get(l)}if(!l){return false}j=j||this;if(!l.nodeType&&(l.length||l.length===0)){m=[];g(l,function(o,n){if(o){if(typeof(o)=="string"){o=i.doc.getElementById(o)}m.push(k.call(j,o,n))}});return m}return k.call(j,l)},getAttribs:function(j){var i;j=this.get(j);if(!j){return[]}if(b){i=[];if(j.nodeName=="OBJECT"){return j.attributes}if(j.nodeName==="OPTION"&&this.getAttrib(j,"selected")){i.push({specified:1,nodeName:"selected"})}j.cloneNode(false).outerHTML.replace(/<\/?[\w:\-]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=[\w\-]+|>/gi,"").replace(/[\w:\-]+/gi,function(k){i.push({specified:1,nodeName:k})});return i}return j.attributes},isEmpty:function(m,k){var r=this,o,n,q,j,l,p=0;m=m.firstChild;if(m){j=new e.dom.TreeWalker(m,m.parentNode);k=k||r.schema?r.schema.getNonEmptyElements():null;do{q=m.nodeType;if(q===1){if(m.getAttribute("data-mce-bogus")){continue}l=m.nodeName.toLowerCase();if(k&&k[l]){if(l==="br"){p++;continue}return false}n=r.getAttribs(m);o=m.attributes.length;while(o--){l=m.attributes[o].nodeName;if(l==="name"||l==="data-mce-bookmark"){return false}}}if(q==8){return false}if((q===3&&!a.test(m.nodeValue))){return false}}while(m=j.next())}return p<=1},destroy:function(j){var i=this;i.win=i.doc=i.root=i.events=i.frag=null;if(!j){e.removeUnload(i.destroy)}},createRng:function(){var i=this.doc;return i.createRange?i.createRange():new e.dom.Range(this)},nodeIndex:function(m,n){var i=0,k,l,j;if(m){for(k=m.nodeType,m=m.previousSibling,l=m;m;m=m.previousSibling){j=m.nodeType;if(n&&j==3){if(j==k||!m.nodeValue.length){continue}}i++;k=j}}return i},split:function(m,l,p){var q=this,i=q.createRng(),n,k,o;function j(v){var t,s=v.childNodes,u=v.nodeType;function x(A){var z=A.previousSibling&&A.previousSibling.nodeName=="SPAN";var y=A.nextSibling&&A.nextSibling.nodeName=="SPAN";return z&&y}if(u==1&&v.getAttribute("data-mce-type")=="bookmark"){return}for(t=s.length-1;t>=0;t--){j(s[t])}if(u!=9){if(u==3&&v.nodeValue.length>0){var r=e.trim(v.nodeValue).length;if(!q.isBlock(v.parentNode)||r>0||r===0&&x(v)){return}}else{if(u==1){s=v.childNodes;if(s.length==1&&s[0]&&s[0].nodeType==1&&s[0].getAttribute("data-mce-type")=="bookmark"){v.parentNode.insertBefore(s[0],v)}if(s.length||/^(br|hr|input|img)$/i.test(v.nodeName)){return}}}q.remove(v)}return v}if(m&&l){i.setStart(m.parentNode,q.nodeIndex(m));i.setEnd(l.parentNode,q.nodeIndex(l));n=i.extractContents();i=q.createRng();i.setStart(l.parentNode,q.nodeIndex(l)+1);i.setEnd(m.parentNode,q.nodeIndex(m)+1);k=i.extractContents();o=m.parentNode;o.insertBefore(j(n),m);if(p){o.replaceChild(p,l)}else{o.insertBefore(l,m)}o.insertBefore(j(k),m);q.remove(m);return p||l}},bind:function(l,i,k,j){return this.events.add(l,i,k,j||this)},unbind:function(k,i,j){return this.events.remove(k,i,j)},fire:function(k,j,i){return this.events.fire(k,j,i)},getContentEditable:function(j){var i;if(j.nodeType!=1){return null}i=j.getAttribute("data-mce-contenteditable");if(i&&i!=="inherit"){return i}return j.contentEditable!=="inherit"?j.contentEditable:null},_findSib:function(l,i,j){var k=this,m=i;if(l){if(d(m,"string")){m=function(n){return k.is(n,i)}}for(l=l[j];l;l=l[j]){if(m(l)){return l}}}return null},_isRes:function(i){return/^(top|left|bottom|right|width|height)/i.test(i)||/;\s*(top|left|bottom|right|width|height)/i.test(i)}});e.DOM=new e.dom.DOMUtils(document,{process_html:0})})(tinymce);(function(a){function b(c){var O=this,e=c.doc,U=0,F=1,j=2,E=true,S=false,W="startOffset",h="startContainer",Q="endContainer",A="endOffset",k=tinymce.extend,n=c.nodeIndex;k(O,{startContainer:e,startOffset:0,endContainer:e,endOffset:0,collapsed:E,commonAncestorContainer:e,START_TO_START:0,START_TO_END:1,END_TO_END:2,END_TO_START:3,setStart:q,setEnd:s,setStartBefore:g,setStartAfter:J,setEndBefore:K,setEndAfter:u,collapse:B,selectNode:y,selectNodeContents:G,compareBoundaryPoints:v,deleteContents:p,extractContents:I,cloneContents:d,insertNode:D,surroundContents:N,cloneRange:L,toStringIE:T});function x(){return e.createDocumentFragment()}function q(X,t){C(E,X,t)}function s(X,t){C(S,X,t)}function g(t){q(t.parentNode,n(t))}function J(t){q(t.parentNode,n(t)+1)}function K(t){s(t.parentNode,n(t))}function u(t){s(t.parentNode,n(t)+1)}function B(t){if(t){O[Q]=O[h];O[A]=O[W]}else{O[h]=O[Q];O[W]=O[A]}O.collapsed=E}function y(t){g(t);u(t)}function G(t){q(t,0);s(t,t.nodeType===1?t.childNodes.length:t.nodeValue.length)}function v(aa,t){var ad=O[h],Y=O[W],ac=O[Q],X=O[A],ab=t.startContainer,af=t.startOffset,Z=t.endContainer,ae=t.endOffset;if(aa===0){return H(ad,Y,ab,af)}if(aa===1){return H(ac,X,ab,af)}if(aa===2){return H(ac,X,Z,ae)}if(aa===3){return H(ad,Y,Z,ae)}}function p(){l(j)}function I(){return l(U)}function d(){return l(F)}function D(aa){var X=this[h],t=this[W],Z,Y;if((X.nodeType===3||X.nodeType===4)&&X.nodeValue){if(!t){X.parentNode.insertBefore(aa,X)}else{if(t>=X.nodeValue.length){c.insertAfter(aa,X)}else{Z=X.splitText(t);X.parentNode.insertBefore(aa,Z)}}}else{if(X.childNodes.length>0){Y=X.childNodes[t]}if(Y){X.insertBefore(aa,Y)}else{X.appendChild(aa)}}}function N(X){var t=O.extractContents();O.insertNode(X);X.appendChild(t);O.selectNode(X)}function L(){return k(new b(c),{startContainer:O[h],startOffset:O[W],endContainer:O[Q],endOffset:O[A],collapsed:O.collapsed,commonAncestorContainer:O.commonAncestorContainer})}function P(t,X){var Y;if(t.nodeType==3){return t}if(X<0){return t}Y=t.firstChild;while(Y&&X>0){--X;Y=Y.nextSibling}if(Y){return Y}return t}function m(){return(O[h]==O[Q]&&O[W]==O[A])}function H(Z,ab,X,aa){var ac,Y,t,ad,af,ae;if(Z==X){if(ab==aa){return 0}if(ab<aa){return -1}return 1}ac=X;while(ac&&ac.parentNode!=Z){ac=ac.parentNode}if(ac){Y=0;t=Z.firstChild;while(t!=ac&&Y<ab){Y++;t=t.nextSibling}if(ab<=Y){return -1}return 1}ac=Z;while(ac&&ac.parentNode!=X){ac=ac.parentNode}if(ac){Y=0;t=X.firstChild;while(t!=ac&&Y<aa){Y++;t=t.nextSibling}if(Y<aa){return -1}return 1}ad=c.findCommonAncestor(Z,X);af=Z;while(af&&af.parentNode!=ad){af=af.parentNode}if(!af){af=ad}ae=X;while(ae&&ae.parentNode!=ad){ae=ae.parentNode}if(!ae){ae=ad}if(af==ae){return 0}t=ad.firstChild;while(t){if(t==af){return -1}if(t==ae){return 1}t=t.nextSibling}}function C(X,aa,Z){var t,Y;if(X){O[h]=aa;O[W]=Z}else{O[Q]=aa;O[A]=Z}t=O[Q];while(t.parentNode){t=t.parentNode}Y=O[h];while(Y.parentNode){Y=Y.parentNode}if(Y==t){if(H(O[h],O[W],O[Q],O[A])>0){O.collapse(X)}}else{O.collapse(X)}O.collapsed=m();O.commonAncestorContainer=c.findCommonAncestor(O[h],O[Q])}function l(ad){var ac,Z=0,af=0,X,ab,Y,aa,t,ae;if(O[h]==O[Q]){return f(ad)}for(ac=O[Q],X=ac.parentNode;X;ac=X,X=X.parentNode){if(X==O[h]){return r(ac,ad)}++Z}for(ac=O[h],X=ac.parentNode;X;ac=X,X=X.parentNode){if(X==O[Q]){return V(ac,ad)}++af}ab=af-Z;Y=O[h];while(ab>0){Y=Y.parentNode;ab--}aa=O[Q];while(ab<0){aa=aa.parentNode;ab++}for(t=Y.parentNode,ae=aa.parentNode;t!=ae;t=t.parentNode,ae=ae.parentNode){Y=t;aa=ae}return o(Y,aa,ad)}function f(ac){var ae,af,t,Y,Z,ad,aa,X,ab;if(ac!=j){ae=x()}if(O[W]==O[A]){return ae}if(O[h].nodeType==3){af=O[h].nodeValue;t=af.substring(O[W],O[A]);if(ac!=F){Y=O[h];X=O[W];ab=O[A]-O[W];if(X===0&&ab>=Y.nodeValue.length-1){Y.parentNode.removeChild(Y)}else{Y.deleteData(X,ab)}O.collapse(E)}if(ac==j){return}if(t.length>0){ae.appendChild(e.createTextNode(t))}return ae}Y=P(O[h],O[W]);Z=O[A]-O[W];while(Y&&Z>0){ad=Y.nextSibling;aa=z(Y,ac);if(ae){ae.appendChild(aa)}--Z;Y=ad}if(ac!=F){O.collapse(E)}return ae}function r(ad,aa){var ac,ab,X,t,Z,Y;if(aa!=j){ac=x()}ab=i(ad,aa);if(ac){ac.appendChild(ab)}X=n(ad);t=X-O[W];if(t<=0){if(aa!=F){O.setEndBefore(ad);O.collapse(S)}return ac}ab=ad.previousSibling;while(t>0){Z=ab.previousSibling;Y=z(ab,aa);if(ac){ac.insertBefore(Y,ac.firstChild)}--t;ab=Z}if(aa!=F){O.setEndBefore(ad);O.collapse(S)}return ac}function V(ab,aa){var ad,X,ac,t,Z,Y;if(aa!=j){ad=x()}ac=R(ab,aa);if(ad){ad.appendChild(ac)}X=n(ab);++X;t=O[A]-X;ac=ab.nextSibling;while(ac&&t>0){Z=ac.nextSibling;Y=z(ac,aa);if(ad){ad.appendChild(Y)}--t;ac=Z}if(aa!=F){O.setStartAfter(ab);O.collapse(E)}return ad}function o(ab,t,ae){var Y,ag,aa,ac,ad,X,af,Z;if(ae!=j){ag=x()}Y=R(ab,ae);if(ag){ag.appendChild(Y)}aa=ab.parentNode;ac=n(ab);ad=n(t);++ac;X=ad-ac;af=ab.nextSibling;while(X>0){Z=af.nextSibling;Y=z(af,ae);if(ag){ag.appendChild(Y)}af=Z;--X}Y=i(t,ae);if(ag){ag.appendChild(Y)}if(ae!=F){O.setStartAfter(ab);O.collapse(E)}return ag}function i(ac,ad){var Y=P(O[Q],O[A]-1),ae,ab,aa,t,X,Z=Y!=O[Q];if(Y==ac){return M(Y,Z,S,ad)}ae=Y.parentNode;ab=M(ae,S,S,ad);while(ae){while(Y){aa=Y.previousSibling;t=M(Y,Z,S,ad);if(ad!=j){ab.insertBefore(t,ab.firstChild)}Z=E;Y=aa}if(ae==ac){return ab}Y=ae.previousSibling;ae=ae.parentNode;X=M(ae,S,S,ad);if(ad!=j){X.appendChild(ab)}ab=X}}function R(ac,ad){var Z=P(O[h],O[W]),aa=Z!=O[h],ae,ab,Y,t,X;if(Z==ac){return M(Z,aa,E,ad)}ae=Z.parentNode;ab=M(ae,S,E,ad);while(ae){while(Z){Y=Z.nextSibling;t=M(Z,aa,E,ad);if(ad!=j){ab.appendChild(t)}aa=E;Z=Y}if(ae==ac){return ab}Z=ae.nextSibling;ae=ae.parentNode;X=M(ae,S,E,ad);if(ad!=j){X.appendChild(ab)}ab=X}}function M(t,aa,ad,ae){var Z,Y,ab,X,ac;if(aa){return z(t,ae)}if(t.nodeType==3){Z=t.nodeValue;if(ad){X=O[W];Y=Z.substring(X);ab=Z.substring(0,X)}else{X=O[A];Y=Z.substring(0,X);ab=Z.substring(X)}if(ae!=F){t.nodeValue=ab}if(ae==j){return}ac=c.clone(t,S);ac.nodeValue=Y;return ac}if(ae==j){return}return c.clone(t,S)}function z(X,t){if(t!=j){return t==F?c.clone(X,E):X}X.parentNode.removeChild(X)}function T(){return c.create("body",null,d()).outerText}return O}a.Range=b;b.prototype.toString=function(){return this.toStringIE()}})(tinymce.dom);(function(){function a(d){var b=this,h=d.dom,c=true,f=false;function e(i,j){var k,t=0,q,n,m,l,o,r,p=-1,s;k=i.duplicate();k.collapse(j);s=k.parentElement();if(s.ownerDocument!==d.dom.doc){return}while(s.contentEditable==="false"){s=s.parentNode}if(!s.hasChildNodes()){return{node:s,inside:1}}m=s.children;q=m.length-1;while(t<=q){r=Math.floor((t+q)/2);l=m[r];k.moveToElementText(l);p=k.compareEndPoints(j?"StartToStart":"EndToEnd",i);if(p>0){q=r-1}else{if(p<0){t=r+1}else{return{node:l}}}}if(p<0){if(!l){k.moveToElementText(s);k.collapse(true);l=s;n=true}else{k.collapse(false)}o=0;while(k.compareEndPoints(j?"StartToStart":"StartToEnd",i)!==0){if(k.move("character",1)===0||s!=k.parentElement()){break}o++}}else{k.collapse(true);o=0;while(k.compareEndPoints(j?"StartToStart":"StartToEnd",i)!==0){if(k.move("character",-1)===0||s!=k.parentElement()){break}o++}}return{node:l,position:p,offset:o,inside:n}}function g(){var i=d.getRng(),r=h.createRng(),l,k,p,q,m,j;l=i.item?i.item(0):i.parentElement();if(l.ownerDocument!=h.doc){return r}k=d.isCollapsed();if(i.item){r.setStart(l.parentNode,h.nodeIndex(l));r.setEnd(r.startContainer,r.startOffset+1);return r}function o(A){var u=e(i,A),s,y,z=0,x,v,t;s=u.node;y=u.offset;if(u.inside&&!s.hasChildNodes()){r[A?"setStart":"setEnd"](s,0);return}if(y===v){r[A?"setStartBefore":"setEndAfter"](s);return}if(u.position<0){x=u.inside?s.firstChild:s.nextSibling;if(!x){r[A?"setStartAfter":"setEndAfter"](s);return}if(!y){if(x.nodeType==3){r[A?"setStart":"setEnd"](x,0)}else{r[A?"setStartBefore":"setEndBefore"](x)}return}while(x){t=x.nodeValue;z+=t.length;if(z>=y){s=x;z-=y;z=t.length-z;break}x=x.nextSibling}}else{x=s.previousSibling;if(!x){return r[A?"setStartBefore":"setEndBefore"](s)}if(!y){if(s.nodeType==3){r[A?"setStart":"setEnd"](x,s.nodeValue.length)}else{r[A?"setStartAfter":"setEndAfter"](x)}return}while(x){z+=x.nodeValue.length;if(z>=y){s=x;z-=y;break}x=x.previousSibling}}r[A?"setStart":"setEnd"](s,z)}try{o(true);if(!k){o()}}catch(n){if(n.number==-2147024809){m=b.getBookmark(2);p=i.duplicate();p.collapse(true);l=p.parentElement();if(!k){p=i.duplicate();p.collapse(false);q=p.parentElement();q.innerHTML=q.innerHTML}l.innerHTML=l.innerHTML;b.moveToBookmark(m);i=d.getRng();o(true);if(!k){o()}}else{throw n}}return r}this.getBookmark=function(m){var j=d.getRng(),o,i,l={};function n(u){var t,p,s,r,q=[];t=u.parentNode;p=h.getRoot().parentNode;while(t!=p&&t.nodeType!==9){s=t.children;r=s.length;while(r--){if(u===s[r]){q.push(r);break}}u=t;t=t.parentNode}return q}function k(q){var p;p=e(j,q);if(p){return{position:p.position,offset:p.offset,indexes:n(p.node),inside:p.inside}}}if(m===2){if(!j.item){l.start=k(true);if(!d.isCollapsed()){l.end=k()}}else{l.start={ctrl:true,indexes:n(j.item(0))}}}return l};this.moveToBookmark=function(k){var j,i=h.doc.body;function m(o){var r,q,n,p;r=h.getRoot();for(q=o.length-1;q>=0;q--){p=r.children;n=o[q];if(n<=p.length-1){r=p[n]}}return r}function l(r){var n=k[r?"start":"end"],q,p,o;if(n){q=n.position>0;p=i.createTextRange();p.moveToElementText(m(n.indexes));offset=n.offset;if(offset!==o){p.collapse(n.inside||q);p.moveStart("character",q?-offset:offset)}else{p.collapse(r)}j.setEndPoint(r?"StartToStart":"EndToStart",p);if(r){j.collapse(true)}}}if(k.start){if(k.start.ctrl){j=i.createControlRange();j.addElement(m(k.start.indexes));j.select()}else{j=i.createTextRange();l(true);l();j.select()}}};this.addRange=function(i){var n,l,k,p,v,q,t,s=d.dom.doc,m=s.body,r,u;function j(C){var y,B,x,A,z;x=h.create("a");y=C?k:v;B=C?p:q;A=n.duplicate();if(y==s||y==s.documentElement){y=m;B=0}if(y.nodeType==3){y.parentNode.insertBefore(x,y);A.moveToElementText(x);A.moveStart("character",B);h.remove(x);n.setEndPoint(C?"StartToStart":"EndToEnd",A)}else{z=y.childNodes;if(z.length){if(B>=z.length){h.insertAfter(x,z[z.length-1])}else{y.insertBefore(x,z[B])}A.moveToElementText(x)}else{if(y.canHaveHTML){y.innerHTML="<span>\uFEFF</span>";x=y.firstChild;A.moveToElementText(x);A.collapse(f)}}n.setEndPoint(C?"StartToStart":"EndToEnd",A);h.remove(x)}}k=i.startContainer;p=i.startOffset;v=i.endContainer;q=i.endOffset;n=m.createTextRange();if(k==v&&k.nodeType==1){if(p==q&&!k.hasChildNodes()){if(k.canHaveHTML){t=k.previousSibling;if(t&&!t.hasChildNodes()&&h.isBlock(t)){t.innerHTML="\uFEFF"}else{t=null}k.innerHTML="<span>\uFEFF</span><span>\uFEFF</span>";n.moveToElementText(k.lastChild);n.select();h.doc.selection.clear();k.innerHTML="";if(t){t.innerHTML=""}return}else{p=h.nodeIndex(k);k=k.parentNode}}if(p==q-1){try{u=k.childNodes[p];l=m.createControlRange();l.addElement(u);l.select();r=d.getRng();if(r.item&&u===r.item(0)){return}}catch(o){}}}j(true);j();n.select()};this.getRangeAt=g}tinymce.dom.TridentSelection=a})();(function(){var n=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,i="sizcache",o=0,r=Object.prototype.toString,h=false,g=true,q=/\\/g,u=/\r\n/g,x=/\W/;[0,0].sort(function(){g=false;return 0});var d=function(C,e,F,G){F=F||[];e=e||document;var I=e;if(e.nodeType!==1&&e.nodeType!==9){return[]}if(!C||typeof C!=="string"){return F}var z,K,N,y,J,M,L,E,B=true,A=d.isXML(e),D=[],H=C;do{n.exec("");z=n.exec(H);if(z){H=z[3];D.push(z[1]);if(z[2]){y=z[3];break}}}while(z);if(D.length>1&&j.exec(C)){if(D.length===2&&k.relative[D[0]]){K=s(D[0]+D[1],e,G)}else{K=k.relative[D[0]]?[e]:d(D.shift(),e);while(D.length){C=D.shift();if(k.relative[C]){C+=D.shift()}K=s(C,K,G)}}}else{if(!G&&D.length>1&&e.nodeType===9&&!A&&k.match.ID.test(D[0])&&!k.match.ID.test(D[D.length-1])){J=d.find(D.shift(),e,A);e=J.expr?d.filter(J.expr,J.set)[0]:J.set[0]}if(e){J=G?{expr:D.pop(),set:l(G)}:d.find(D.pop(),D.length===1&&(D[0]==="~"||D[0]==="+")&&e.parentNode?e.parentNode:e,A);K=J.expr?d.filter(J.expr,J.set):J.set;if(D.length>0){N=l(K)}else{B=false}while(D.length){M=D.pop();L=M;if(!k.relative[M]){M=""}else{L=D.pop()}if(L==null){L=e}k.relative[M](N,L,A)}}else{N=D=[]}}if(!N){N=K}if(!N){d.error(M||C)}if(r.call(N)==="[object Array]"){if(!B){F.push.apply(F,N)}else{if(e&&e.nodeType===1){for(E=0;N[E]!=null;E++){if(N[E]&&(N[E]===true||N[E].nodeType===1&&d.contains(e,N[E]))){F.push(K[E])}}}else{for(E=0;N[E]!=null;E++){if(N[E]&&N[E].nodeType===1){F.push(K[E])}}}}}else{l(N,F)}if(y){d(y,I,F,G);d.uniqueSort(F)}return F};d.uniqueSort=function(y){if(p){h=g;y.sort(p);if(h){for(var e=1;e<y.length;e++){if(y[e]===y[e-1]){y.splice(e--,1)}}}}return y};d.matches=function(e,y){return d(e,null,null,y)};d.matchesSelector=function(e,y){return d(y,null,null,[e]).length>0};d.find=function(E,e,F){var D,z,B,A,C,y;if(!E){return[]}for(z=0,B=k.order.length;z<B;z++){C=k.order[z];if((A=k.leftMatch[C].exec(E))){y=A[1];A.splice(1,1);if(y.substr(y.length-1)!=="\\"){A[1]=(A[1]||"").replace(q,"");D=k.find[C](A,e,F);if(D!=null){E=E.replace(k.match[C],"");break}}}}if(!D){D=typeof e.getElementsByTagName!=="undefined"?e.getElementsByTagName("*"):[]}return{set:D,expr:E}};d.filter=function(I,H,L,B){var D,e,G,N,K,y,A,C,J,z=I,M=[],F=H,E=H&&H[0]&&d.isXML(H[0]);while(I&&H.length){for(G in k.filter){if((D=k.leftMatch[G].exec(I))!=null&&D[2]){y=k.filter[G];A=D[1];e=false;D.splice(1,1);if(A.substr(A.length-1)==="\\"){continue}if(F===M){M=[]}if(k.preFilter[G]){D=k.preFilter[G](D,F,L,M,B,E);if(!D){e=N=true}else{if(D===true){continue}}}if(D){for(C=0;(K=F[C])!=null;C++){if(K){N=y(K,D,C,F);J=B^N;if(L&&N!=null){if(J){e=true}else{F[C]=false}}else{if(J){M.push(K);e=true}}}}}if(N!==undefined){if(!L){F=M}I=I.replace(k.match[G],"");if(!e){return[]}break}}}if(I===z){if(e==null){d.error(I)}else{break}}z=I}return F};d.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)};var b=d.getText=function(B){var z,A,e=B.nodeType,y="";if(e){if(e===1||e===9||e===11){if(typeof B.textContent==="string"){return B.textContent}else{if(typeof B.innerText==="string"){return B.innerText.replace(u,"")}else{for(B=B.firstChild;B;B=B.nextSibling){y+=b(B)}}}}else{if(e===3||e===4){return B.nodeValue}}}else{for(z=0;(A=B[z]);z++){if(A.nodeType!==8){y+=b(A)}}}return y};var k=d.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(e){return e.getAttribute("href")},type:function(e){return e.getAttribute("type")}},relative:{"+":function(D,y){var A=typeof y==="string",C=A&&!x.test(y),E=A&&!C;if(C){y=y.toLowerCase()}for(var z=0,e=D.length,B;z<e;z++){if((B=D[z])){while((B=B.previousSibling)&&B.nodeType!==1){}D[z]=E||B&&B.nodeName.toLowerCase()===y?B||false:B===y}}if(E){d.filter(y,D,true)}},">":function(D,y){var C,B=typeof y==="string",z=0,e=D.length;if(B&&!x.test(y)){y=y.toLowerCase();for(;z<e;z++){C=D[z];if(C){var A=C.parentNode;D[z]=A.nodeName.toLowerCase()===y?A:false}}}else{for(;z<e;z++){C=D[z];if(C){D[z]=B?C.parentNode:C.parentNode===y}}if(B){d.filter(y,D,true)}}},"":function(A,y,C){var B,z=o++,e=t;if(typeof y==="string"&&!x.test(y)){y=y.toLowerCase();B=y;e=a}e("parentNode",y,z,A,B,C)},"~":function(A,y,C){var B,z=o++,e=t;if(typeof y==="string"&&!x.test(y)){y=y.toLowerCase();B=y;e=a}e("previousSibling",y,z,A,B,C)}},find:{ID:function(y,z,A){if(typeof z.getElementById!=="undefined"&&!A){var e=z.getElementById(y[1]);return e&&e.parentNode?[e]:[]}},NAME:function(z,C){if(typeof C.getElementsByName!=="undefined"){var y=[],B=C.getElementsByName(z[1]);for(var A=0,e=B.length;A<e;A++){if(B[A].getAttribute("name")===z[1]){y.push(B[A])}}return y.length===0?null:y}},TAG:function(e,y){if(typeof y.getElementsByTagName!=="undefined"){return y.getElementsByTagName(e[1])}}},preFilter:{CLASS:function(A,y,z,e,D,E){A=" "+A[1].replace(q,"")+" ";if(E){return A}for(var B=0,C;(C=y[B])!=null;B++){if(C){if(D^(C.className&&(" "+C.className+" ").replace(/[\t\n\r]/g," ").indexOf(A)>=0)){if(!z){e.push(C)}}else{if(z){y[B]=false}}}}return false},ID:function(e){return e[1].replace(q,"")},TAG:function(y,e){return y[1].replace(q,"").toLowerCase()},CHILD:function(e){if(e[1]==="nth"){if(!e[2]){d.error(e[0])}e[2]=e[2].replace(/^\+|\s*/g,"");var y=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(e[2]==="even"&&"2n"||e[2]==="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(y[1]+(y[2]||1))-0;e[3]=y[3]-0}else{if(e[2]){d.error(e[0])}}e[0]=o++;return e},ATTR:function(B,y,z,e,C,D){var A=B[1]=B[1].replace(q,"");if(!D&&k.attrMap[A]){B[1]=k.attrMap[A]}B[4]=(B[4]||B[5]||"").replace(q,"");if(B[2]==="~="){B[4]=" "+B[4]+" "}return B},PSEUDO:function(B,y,z,e,C){if(B[1]==="not"){if((n.exec(B[3])||"").length>1||/^\w/.test(B[3])){B[3]=d(B[3],null,null,y)}else{var A=d.filter(B[3],y,z,true^C);if(!z){e.push.apply(e,A)}return false}}else{if(k.match.POS.test(B[0])||k.match.CHILD.test(B[0])){return true}}return B},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){if(e.parentNode){e.parentNode.selectedIndex}return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(z,y,e){return !!d(e[3],z).length},header:function(e){return(/h\d/i).test(e.nodeName)},text:function(z){var e=z.getAttribute("type"),y=z.type;return z.nodeName.toLowerCase()==="input"&&"text"===y&&(e===y||e===null)},radio:function(e){return e.nodeName.toLowerCase()==="input"&&"radio"===e.type},checkbox:function(e){return e.nodeName.toLowerCase()==="input"&&"checkbox"===e.type},file:function(e){return e.nodeName.toLowerCase()==="input"&&"file"===e.type},password:function(e){return e.nodeName.toLowerCase()==="input"&&"password"===e.type},submit:function(y){var e=y.nodeName.toLowerCase();return(e==="input"||e==="button")&&"submit"===y.type},image:function(e){return e.nodeName.toLowerCase()==="input"&&"image"===e.type},reset:function(y){var e=y.nodeName.toLowerCase();return(e==="input"||e==="button")&&"reset"===y.type},button:function(y){var e=y.nodeName.toLowerCase();return e==="input"&&"button"===y.type||e==="button"},input:function(e){return(/input|select|textarea|button/i).test(e.nodeName)},focus:function(e){return e===e.ownerDocument.activeElement}},setFilters:{first:function(y,e){return e===0},last:function(z,y,e,A){return y===A.length-1},even:function(y,e){return e%2===0},odd:function(y,e){return e%2===1},lt:function(z,y,e){return y<e[3]-0},gt:function(z,y,e){return y>e[3]-0},nth:function(z,y,e){return e[3]-0===y},eq:function(z,y,e){return e[3]-0===y}},filter:{PSEUDO:function(z,E,D,F){var e=E[1],y=k.filters[e];if(y){return y(z,D,E,F)}else{if(e==="contains"){return(z.textContent||z.innerText||b([z])||"").indexOf(E[3])>=0}else{if(e==="not"){var A=E[3];for(var C=0,B=A.length;C<B;C++){if(A[C]===z){return false}}return true}else{d.error(e)}}}},CHILD:function(z,B){var A,H,D,G,e,C,F,E=B[1],y=z;switch(E){case"only":case"first":while((y=y.previousSibling)){if(y.nodeType===1){return false}}if(E==="first"){return true}y=z;case"last":while((y=y.nextSibling)){if(y.nodeType===1){return false}}return true;case"nth":A=B[2];H=B[3];if(A===1&&H===0){return true}D=B[0];G=z.parentNode;if(G&&(G[i]!==D||!z.nodeIndex)){C=0;for(y=G.firstChild;y;y=y.nextSibling){if(y.nodeType===1){y.nodeIndex=++C}}G[i]=D}F=z.nodeIndex-H;if(A===0){return F===0}else{return(F%A===0&&F/A>=0)}}},ID:function(y,e){return y.nodeType===1&&y.getAttribute("id")===e},TAG:function(y,e){return(e==="*"&&y.nodeType===1)||!!y.nodeName&&y.nodeName.toLowerCase()===e},CLASS:function(y,e){return(" "+(y.className||y.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(C,A){var z=A[1],e=d.attr?d.attr(C,z):k.attrHandle[z]?k.attrHandle[z](C):C[z]!=null?C[z]:C.getAttribute(z),D=e+"",B=A[2],y=A[4];return e==null?B==="!=":!B&&d.attr?e!=null:B==="="?D===y:B==="*="?D.indexOf(y)>=0:B==="~="?(" "+D+" ").indexOf(y)>=0:!y?D&&e!==false:B==="!="?D!==y:B==="^="?D.indexOf(y)===0:B==="$="?D.substr(D.length-y.length)===y:B==="|="?D===y||D.substr(0,y.length+1)===y+"-":false},POS:function(B,y,z,C){var e=y[2],A=k.setFilters[e];if(A){return A(B,z,y,C)}}}};var j=k.match.POS,c=function(y,e){return"\\"+(e-0+1)};for(var f in k.match){k.match[f]=new RegExp(k.match[f].source+(/(?![^\[]*\])(?![^\(]*\))/.source));k.leftMatch[f]=new RegExp(/(^(?:.|\r|\n)*?)/.source+k.match[f].source.replace(/\\(\d+)/g,c))}k.match.globalPOS=j;var l=function(y,e){y=Array.prototype.slice.call(y,0);if(e){e.push.apply(e,y);return e}return y};try{Array.prototype.slice.call(document.documentElement.childNodes,0)[0].nodeType}catch(v){l=function(B,A){var z=0,y=A||[];if(r.call(B)==="[object Array]"){Array.prototype.push.apply(y,B)}else{if(typeof B.length==="number"){for(var e=B.length;z<e;z++){y.push(B[z])}}else{for(;B[z];z++){y.push(B[z])}}}return y}}var p,m;if(document.documentElement.compareDocumentPosition){p=function(y,e){if(y===e){h=true;return 0}if(!y.compareDocumentPosition||!e.compareDocumentPosition){return y.compareDocumentPosition?-1:1}return y.compareDocumentPosition(e)&4?-1:1}}else{p=function(F,E){if(F===E){h=true;return 0}else{if(F.sourceIndex&&E.sourceIndex){return F.sourceIndex-E.sourceIndex}}var C,y,z=[],e=[],B=F.parentNode,D=E.parentNode,G=B;if(B===D){return m(F,E)}else{if(!B){return -1}else{if(!D){return 1}}}while(G){z.unshift(G);G=G.parentNode}G=D;while(G){e.unshift(G);G=G.parentNode}C=z.length;y=e.length;for(var A=0;A<C&&A<y;A++){if(z[A]!==e[A]){return m(z[A],e[A])}}return A===C?m(F,e[A],-1):m(z[A],E,1)};m=function(y,e,z){if(y===e){return z}var A=y.nextSibling;while(A){if(A===e){return -1}A=A.nextSibling}return 1}}(function(){var y=document.createElement("div"),z="script"+(new Date()).getTime(),e=document.documentElement;y.innerHTML="<a name='"+z+"'/>";e.insertBefore(y,e.firstChild);if(document.getElementById(z)){k.find.ID=function(B,C,D){if(typeof C.getElementById!=="undefined"&&!D){var A=C.getElementById(B[1]);return A?A.id===B[1]||typeof A.getAttributeNode!=="undefined"&&A.getAttributeNode("id").nodeValue===B[1]?[A]:undefined:[]}};k.filter.ID=function(C,A){var B=typeof C.getAttributeNode!=="undefined"&&C.getAttributeNode("id");return C.nodeType===1&&B&&B.nodeValue===A}}e.removeChild(y);e=y=null})();(function(){var e=document.createElement("div");e.appendChild(document.createComment(""));if(e.getElementsByTagName("*").length>0){k.find.TAG=function(y,C){var B=C.getElementsByTagName(y[1]);if(y[1]==="*"){var A=[];for(var z=0;B[z];z++){if(B[z].nodeType===1){A.push(B[z])}}B=A}return B}}e.innerHTML="<a href='#'></a>";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){k.attrHandle.href=function(y){return y.getAttribute("href",2)}}e=null})();if(document.querySelectorAll){(function(){var e=d,A=document.createElement("div"),z="__sizzle__";A.innerHTML="<p class='TEST'></p>";if(A.querySelectorAll&&A.querySelectorAll(".TEST").length===0){return}d=function(L,C,G,K){C=C||document;if(!K&&!d.isXML(C)){var J=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(L);if(J&&(C.nodeType===1||C.nodeType===9)){if(J[1]){return l(C.getElementsByTagName(L),G)}else{if(J[2]&&k.find.CLASS&&C.getElementsByClassName){return l(C.getElementsByClassName(J[2]),G)}}}if(C.nodeType===9){if(L==="body"&&C.body){return l([C.body],G)}else{if(J&&J[3]){var F=C.getElementById(J[3]);if(F&&F.parentNode){if(F.id===J[3]){return l([F],G)}}else{return l([],G)}}}try{return l(C.querySelectorAll(L),G)}catch(H){}}else{if(C.nodeType===1&&C.nodeName.toLowerCase()!=="object"){var D=C,E=C.getAttribute("id"),B=E||z,N=C.parentNode,M=/^\s*[+~]/.test(L);if(!E){C.setAttribute("id",B)}else{B=B.replace(/'/g,"\\$&")}if(M&&N){C=C.parentNode}try{if(!M||N){return l(C.querySelectorAll("[id='"+B+"'] "+L),G)}}catch(I){}finally{if(!E){D.removeAttribute("id")}}}}}return e(L,C,G,K)};for(var y in e){d[y]=e[y]}A=null})()}(function(){var e=document.documentElement,z=e.matchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.msMatchesSelector;if(z){var B=!z.call(document.createElement("div"),"div"),y=false;try{z.call(document.documentElement,"[test!='']:sizzle")}catch(A){y=true}d.matchesSelector=function(D,F){F=F.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!d.isXML(D)){try{if(y||!k.match.PSEUDO.test(F)&&!/!=/.test(F)){var C=z.call(D,F);if(C||!B||D.document&&D.document.nodeType!==11){return C}}}catch(E){}}return d(F,null,null,[D]).length>0}}})();(function(){var e=document.createElement("div");e.innerHTML="<div class='test e'></div><div class='test'></div>";if(!e.getElementsByClassName||e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}k.order.splice(1,0,"CLASS");k.find.CLASS=function(y,z,A){if(typeof z.getElementsByClassName!=="undefined"&&!A){return z.getElementsByClassName(y[1])}};e=null})();function a(y,D,C,G,E,F){for(var A=0,z=G.length;A<z;A++){var e=G[A];if(e){var B=false;e=e[y];while(e){if(e[i]===C){B=G[e.sizset];break}if(e.nodeType===1&&!F){e[i]=C;e.sizset=A}if(e.nodeName.toLowerCase()===D){B=e;break}e=e[y]}G[A]=B}}}function t(y,D,C,G,E,F){for(var A=0,z=G.length;A<z;A++){var e=G[A];if(e){var B=false;e=e[y];while(e){if(e[i]===C){B=G[e.sizset];break}if(e.nodeType===1){if(!F){e[i]=C;e.sizset=A}if(typeof D!=="string"){if(e===D){B=true;break}}else{if(d.filter(D,[e]).length>0){B=e;break}}}e=e[y]}G[A]=B}}}if(document.documentElement.contains){d.contains=function(y,e){return y!==e&&(y.contains?y.contains(e):true)}}else{if(document.documentElement.compareDocumentPosition){d.contains=function(y,e){return !!(y.compareDocumentPosition(e)&16)}}else{d.contains=function(){return false}}}d.isXML=function(e){var y=(e?e.ownerDocument||e:0).documentElement;return y?y.nodeName!=="HTML":false};var s=function(z,e,D){var C,E=[],B="",F=e.nodeType?[e]:e;while((C=k.match.PSEUDO.exec(z))){B+=C[0];z=z.replace(k.match.PSEUDO,"")}z=k.relative[z]?z+"*":z;for(var A=0,y=F.length;A<y;A++){d(z,F[A],E,D)}return d.filter(B,E)};window.tinymce.dom.Sizzle=d})();(function(a){a.dom.Element=function(f,d){var b=this,e,c;b.settings=d=d||{};b.id=f;b.dom=e=d.dom||a.DOM;if(!a.isIE){c=e.get(b.id)}a.each(("getPos,getRect,getParent,add,setStyle,getStyle,setStyles,setAttrib,setAttribs,getAttrib,addClass,removeClass,hasClass,getOuterHTML,setOuterHTML,remove,show,hide,isHidden,setHTML,get").split(/,/),function(g){b[g]=function(){var h=[f],j;for(j=0;j<arguments.length;j++){h.push(arguments[j])}h=e[g].apply(e,h);b.update(g);return h}});a.extend(b,{on:function(i,h,g){return a.dom.Event.add(b.id,i,h,g)},getXY:function(){return{x:parseInt(b.getStyle("left")),y:parseInt(b.getStyle("top"))}},getSize:function(){var g=e.get(b.id);return{w:parseInt(b.getStyle("width")||g.clientWidth),h:parseInt(b.getStyle("height")||g.clientHeight)}},moveTo:function(g,h){b.setStyles({left:g,top:h})},moveBy:function(g,i){var h=b.getXY();b.moveTo(h.x+g,h.y+i)},resizeTo:function(g,i){b.setStyles({width:g,height:i})},resizeBy:function(g,j){var i=b.getSize();b.resizeTo(i.w+g,i.h+j)},update:function(h){var g;if(a.isIE6&&d.blocker){h=h||"";if(h.indexOf("get")===0||h.indexOf("has")===0||h.indexOf("is")===0){return}if(h=="remove"){e.remove(b.blocker);return}if(!b.blocker){b.blocker=e.uniqueId();g=e.add(d.container||e.getRoot(),"iframe",{id:b.blocker,style:"position:absolute;",frameBorder:0,src:'javascript:""'});e.setStyle(g,"opacity",0)}else{g=e.get(b.blocker)}e.setStyles(g,{left:b.getStyle("left",1),top:b.getStyle("top",1),width:b.getStyle("width",1),height:b.getStyle("height",1),display:b.getStyle("display",1),zIndex:parseInt(b.getStyle("zIndex",1)||0)-1})}}})}})(tinymce);(function(d){function f(g){return g.replace(/[\n\r]+/g,"")}var c=d.is,b=d.isIE,e=d.each,a=d.dom.TreeWalker;d.create("tinymce.dom.Selection",{Selection:function(k,j,i,h){var g=this;g.dom=k;g.win=j;g.serializer=i;g.editor=h;e(["onBeforeSetContent","onBeforeGetContent","onSetContent","onGetContent"],function(l){g[l]=new d.util.Dispatcher(g)});if(!g.win.getSelection){g.tridentSel=new d.dom.TridentSelection(g)}if(d.isIE&&!d.isIE11&&k.boxModel){this._fixIESelection()}d.addUnload(g.destroy,g)},setCursorLocation:function(i,j){var g=this;var h=g.dom.createRng();h.setStart(i,j);h.setEnd(i,j);g.setRng(h);g.collapse(false)},getContent:function(h){var g=this,i=g.getRng(),m=g.dom.create("body"),k=g.getSel(),j,l,o;h=h||{};j=l="";h.get=true;h.format=h.format||"html";h.forced_root_block="";g.onBeforeGetContent.dispatch(g,h);if(h.format=="text"){return g.isCollapsed()?"":(i.text||(k.toString?k.toString():""))}if(i.cloneContents){o=i.cloneContents();if(o){m.appendChild(o)}}else{if(c(i.item)||c(i.htmlText)){m.innerHTML="<br>"+(i.item?i.item(0).outerHTML:i.htmlText);m.removeChild(m.firstChild)}else{m.innerHTML=i.toString()}}if(/^\s/.test(m.innerHTML)){j=" "}if(/\s+$/.test(m.innerHTML)){l=" "}h.getInner=true;h.content=g.isCollapsed()?"":j+g.serializer.serialize(m,h)+l;g.onGetContent.dispatch(g,h);return h.content},setContent:function(h,j){var o=this,g=o.getRng(),k,l=o.win.document,n,m;j=j||{format:"html"};j.set=true;h=j.content=h;if(!j.no_events){o.onBeforeSetContent.dispatch(o,j)}h=j.content;if(g.insertNode){h+='<span id="__caret">_</span>';if(g.startContainer==l&&g.endContainer==l){l.body.innerHTML=h}else{g.deleteContents();if(l.body.childNodes.length===0){l.body.innerHTML=h}else{if(g.createContextualFragment){g.insertNode(g.createContextualFragment(h))}else{n=l.createDocumentFragment();m=l.createElement("div");n.appendChild(m);m.outerHTML=h;g.insertNode(n)}}}k=o.dom.get("__caret");g=l.createRange();g.setStartBefore(k);g.setEndBefore(k);o.setRng(g);o.dom.remove("__caret");try{o.setRng(g)}catch(i){}}else{if(g.item){l.execCommand("Delete",false,null);g=o.getRng()}if(/^\s+/.test(h)){g.pasteHTML('<span id="__mce_tmp">_</span>'+h);o.dom.remove("__mce_tmp")}else{g.pasteHTML(h)}}if(!j.no_events){o.onSetContent.dispatch(o,j)}},getStart:function(){var i=this,h=i.getRng(),j,g,l,k;if(h.duplicate||h.item){if(h.item){return h.item(0)}l=h.duplicate();l.collapse(1);j=l.parentElement();if(j.ownerDocument!==i.dom.doc){j=i.dom.getRoot()}g=k=h.parentElement();while(k=k.parentNode){if(k==j){j=g;break}}return j}else{j=h.startContainer;if(j.nodeType==1&&j.hasChildNodes()){j=j.childNodes[Math.min(j.childNodes.length-1,h.startOffset)]}if(j&&j.nodeType==3){return j.parentNode}return j}},getEnd:function(){var h=this,g=h.getRng(),j,i;if(g.duplicate||g.item){if(g.item){return g.item(0)}g=g.duplicate();g.collapse(0);j=g.parentElement();if(j.ownerDocument!==h.dom.doc){j=h.dom.getRoot()}if(j&&j.nodeName=="BODY"){return j.lastChild||j}return j}else{j=g.endContainer;i=g.endOffset;if(j.nodeType==1&&j.hasChildNodes()){j=j.childNodes[i>0?i-1:i]}if(j&&j.nodeType==3){return j.parentNode}return j}},getBookmark:function(s,v){var y=this,n=y.dom,h,k,j,o,i,p,q,m="\uFEFF",x;function g(z,A){var t=0;e(n.select(z),function(C,B){if(C==A){t=B}});return t}function u(t){function z(E){var A,D,C,B=E?"start":"end";A=t[B+"Container"];D=t[B+"Offset"];if(A.nodeType==1&&A.nodeName=="TR"){C=A.childNodes;A=C[Math.min(E?D:D-1,C.length-1)];if(A){D=E?0:A.childNodes.length;t["set"+(E?"Start":"End")](A,D)}}}z(true);z();return t}function l(){var z=y.getRng(true),t=n.getRoot(),A={};function B(E,J){var D=E[J?"startContainer":"endContainer"],I=E[J?"startOffset":"endOffset"],C=[],F,H,G=0;if(D.nodeType==3){if(v){for(F=D.previousSibling;F&&F.nodeType==3;F=F.previousSibling){I+=F.nodeValue.length}}C.push(I)}else{H=D.childNodes;if(I>=H.length&&H.length){G=1;I=Math.max(0,H.length-1)}C.push(y.dom.nodeIndex(H[I],v)+G)}for(;D&&D!=t;D=D.parentNode){C.push(y.dom.nodeIndex(D,v))}return C}A.start=B(z,true);if(!y.isCollapsed()){A.end=B(z)}return A}if(s==2){if(y.tridentSel){return y.tridentSel.getBookmark(s)}return l()}if(s){h=y.getRng();if(h.setStart){h={startContainer:h.startContainer,startOffset:h.startOffset,endContainer:h.endContainer,endOffset:h.endOffset}}return{rng:h}}h=y.getRng();j=n.uniqueId();o=tinyMCE.activeEditor.selection.isCollapsed();x="overflow:hidden;line-height:0px";if(h.duplicate||h.item){if(!h.item){k=h.duplicate();try{h.collapse();h.pasteHTML('<span data-mce-type="bookmark" id="'+j+'_start" style="'+x+'">'+m+"</span>");if(!o){k.collapse(false);h.moveToElementText(k.parentElement());if(h.compareEndPoints("StartToEnd",k)===0){k.move("character",-1)}k.pasteHTML('<span data-mce-type="bookmark" id="'+j+'_end" style="'+x+'">'+m+"</span>")}}catch(r){return null}}else{p=h.item(0);i=p.nodeName;return{name:i,index:g(i,p)}}}else{p=y.getNode();i=p.nodeName;if(i=="IMG"){return{name:i,index:g(i,p)}}k=u(h.cloneRange());if(!o){k.collapse(false);k.insertNode(n.create("span",{"data-mce-type":"bookmark",id:j+"_end",style:x},m))}h=u(h);h.collapse(true);h.insertNode(n.create("span",{"data-mce-type":"bookmark",id:j+"_start",style:x},m))}y.moveToBookmark({id:j,keep:1});return{id:j}},moveToBookmark:function(q){var v=this,n=v.dom,l,j,g,i,u,k,x,r,s;function h(C){var t=q[C?"start":"end"],z,A,B,y;if(t){B=t[0];for(A=u,z=t.length-1;z>=1;z--){y=A.childNodes;if(t[z]>y.length-1){return}A=y[t[z]]}if(A.nodeType===3){B=Math.min(t[0],A.nodeValue.length)}if(A.nodeType===1){B=Math.min(t[0],A.childNodes.length)}if(C){g.setStart(A,B)}else{g.setEnd(A,B)}}return true}function m(D){var y=n.get(q.id+"_"+D),C,t,A,B,z=q.keep;if(y){C=y.parentNode;if(D=="start"){if(!z){t=n.nodeIndex(y)}else{C=y.firstChild;t=1}k=x=C;r=s=t}else{if(!z){t=n.nodeIndex(y)}else{C=y.firstChild;t=1}x=C;s=t}if(!z){B=y.previousSibling;A=y.nextSibling;e(d.grep(y.childNodes),function(E){if(E.nodeType==3){E.nodeValue=E.nodeValue.replace(/\uFEFF/g,"")}});while(y=n.get(q.id+"_"+D)){n.remove(y,1)}if(B&&A&&B.nodeType==A.nodeType&&B.nodeType==3&&!d.isOpera){t=B.nodeValue.length;B.appendData(A.nodeValue);n.remove(A);if(D=="start"){k=x=B;r=s=t}else{x=B;s=t}}}}}function o(t){if(n.isBlock(t)&&!t.innerHTML&&!b){t.innerHTML='<br data-mce-bogus="1" />'}return t}if(q){if(q.start){g=n.createRng();u=n.getRoot();if(v.tridentSel){return v.tridentSel.moveToBookmark(q)}if(h(true)&&h()){v.setRng(g)}}else{if(q.id){m("start");m("end");if(k){g=n.createRng();g.setStart(o(k),r);g.setEnd(o(x),s);v.setRng(g)}}else{if(q.name){v.select(n.select(q.name)[q.index])}else{if(q.rng){g=q.rng;if(g.startContainer){i=v.dom.createRng();try{i.setStart(g.startContainer,g.startOffset);i.setEnd(g.endContainer,g.endOffset)}catch(p){}g=i}v.setRng(g)}}}}}},select:function(l,k){var j=this,m=j.dom,h=m.createRng(),g;function i(n,p){var o=new a(n,n);do{if(n.nodeType==3&&d.trim(n.nodeValue).length!==0){if(p){h.setStart(n,0)}else{h.setEnd(n,n.nodeValue.length)}return}if(n.nodeName=="BR"){if(p){h.setStartBefore(n)}else{h.setEndBefore(n)}return}}while(n=(p?o.next():o.prev()))}if(l){g=m.nodeIndex(l);h.setStart(l.parentNode,g);h.setEnd(l.parentNode,g+1);if(k){i(l,1);i(l)}j.setRng(h)}return l},isCollapsed:function(){var g=this,i=g.getRng(),h=g.getSel();if(!i||i.item){return false}if(i.compareEndPoints){return i.compareEndPoints("StartToEnd",i)===0}return !h||i.collapsed},collapse:function(g){var i=this,h=i.getRng(),j;if(h.item){j=h.item(0);h=i.win.document.body.createTextRange();h.moveToElementText(j)}h.collapse(!!g);i.setRng(h)},getSel:function(){var h=this,g=this.win;return g.getSelection?g.getSelection():g.document.selection},getRng:function(m){var h=this,j,g,l,k=h.win.document;if(h.fakeRng){return h.fakeRng}if(m&&h.tridentSel){return h.tridentSel.getRangeAt(0)}try{if(j=h.getSel()){g=j.rangeCount>0?j.getRangeAt(0):(j.createRange?j.createRange():k.createRange())}}catch(i){}if(d.isIE&&!d.isIE11&&g&&g.setStart&&k.selection.createRange().item){l=k.selection.createRange().item(0);g=k.createRange();g.setStartBefore(l);g.setEndAfter(l)}if(!g){g=k.createRange?k.createRange():k.body.createTextRange()}if(g.setStart&&g.startContainer.nodeType===9&&g.collapsed){l=h.dom.getRoot();g.setStart(l,0);g.setEnd(l,0)}if(h.selectedRange&&h.explicitRange){if(g.compareBoundaryPoints(g.START_TO_START,h.selectedRange)===0&&g.compareBoundaryPoints(g.END_TO_END,h.selectedRange)===0){g=h.explicitRange}else{h.selectedRange=null;h.explicitRange=null}}return g},setRng:function(k,g){var j,i=this;if(!i.tridentSel){j=i.getSel();if(j){i.explicitRange=k;try{j.removeAllRanges()}catch(h){}j.addRange(k);if(g===false&&j.extend){j.collapse(k.endContainer,k.endOffset);j.extend(k.startContainer,k.startOffset)}i.selectedRange=j.rangeCount>0?j.getRangeAt(0):null}}else{if(k.cloneRange){try{i.tridentSel.addRange(k);return}catch(h){}}try{k.select()}catch(h){}}},setNode:function(h){var g=this;g.setContent(g.dom.getOuterHTML(h));return h},getNode:function(){var i=this,h=i.getRng(),j=i.getSel(),m,l=h.startContainer,g=h.endContainer;function k(q,o){var p=q;while(q&&q.nodeType===3&&q.length===0){q=o?q.nextSibling:q.previousSibling}return q||p}if(!h){return i.dom.getRoot()}if(h.setStart){m=h.commonAncestorContainer;if(!h.collapsed){if(h.startContainer==h.endContainer){if(h.endOffset-h.startOffset<2){if(h.startContainer.hasChildNodes()){m=h.startContainer.childNodes[h.startOffset]}}}if(l.nodeType===3&&g.nodeType===3){if(l.length===h.startOffset){l=k(l.nextSibling,true)}else{l=l.parentNode}if(h.endOffset===0){g=k(g.previousSibling,false)}else{g=g.parentNode}if(l&&l===g){return l}}}if(m&&m.nodeType==3){return m.parentNode}return m}return h.item?h.item(0):h.parentElement()},getSelectedBlocks:function(p,h){var o=this,k=o.dom,m,l,i,j=[];m=k.getParent(p||o.getStart(),k.isBlock);l=k.getParent(h||o.getEnd(),k.isBlock);if(m){j.push(m)}if(m&&l&&m!=l){i=m;var g=new a(m,k.getRoot());while((i=g.next())&&i!=l){if(k.isBlock(i)){j.push(i)}}}if(l&&m!=l){j.push(l)}return j},isForward:function(){var i=this.dom,g=this.getSel(),j,h;if(!g||g.anchorNode==null||g.focusNode==null){return true}j=i.createRng();j.setStart(g.anchorNode,g.anchorOffset);j.collapse(true);h=i.createRng();h.setStart(g.focusNode,g.focusOffset);h.collapse(true);return j.compareBoundaryPoints(j.START_TO_START,h)<=0},normalize:function(){var h=this,g,m,l,j,i;function k(p){var o,r,n,s=h.dom,u=s.getRoot(),q,t,v;function y(z,A){var B=new a(z,s.getParent(z.parentNode,s.isBlock)||u);while(z=B[A?"prev":"next"]()){if(z.nodeName==="BR"){return true}}}function x(B,z){var C,A;z=z||o;C=new a(z,s.getParent(z.parentNode,s.isBlock)||u);while(q=C[B?"prev":"next"]()){if(q.nodeType===3&&q.nodeValue.length>0){o=q;r=B?q.nodeValue.length:0;m=true;return}if(s.isBlock(q)||t[q.nodeName.toLowerCase()]){return}A=q}if(l&&A){o=A;m=true;r=0}}o=g[(p?"start":"end")+"Container"];r=g[(p?"start":"end")+"Offset"];t=s.schema.getNonEmptyElements();if(o.nodeType===9){o=s.getRoot();r=0}if(o===u){if(p){q=o.childNodes[r>0?r-1:0];if(q){v=q.nodeName.toLowerCase();if(t[q.nodeName]||q.nodeName=="TABLE"){return}}}if(o.hasChildNodes()){o=o.childNodes[Math.min(!p&&r>0?r-1:r,o.childNodes.length-1)];r=0;if(o.hasChildNodes()&&!/TABLE/.test(o.nodeName)){q=o;n=new a(o,u);do{if(q.nodeType===3&&q.nodeValue.length>0){r=p?0:q.nodeValue.length;o=q;m=true;break}if(t[q.nodeName.toLowerCase()]){r=s.nodeIndex(q);o=q.parentNode;if(q.nodeName=="IMG"&&!p){r++}m=true;break}}while(q=(p?n.next():n.prev()))}}}if(l){if(o.nodeType===3&&r===0){x(true)}if(o.nodeType===1){q=o.childNodes[r];if(q&&q.nodeName==="BR"&&!y(q)&&!y(q,true)){x(true,o.childNodes[r])}}}if(p&&!l&&o.nodeType===3&&r===o.nodeValue.length){x(false)}if(m){g["set"+(p?"Start":"End")](o,r)}}if(d.isIE){return}g=h.getRng();l=g.collapsed;k(true);if(!l){k()}if(m){if(l){g.collapse(true)}h.setRng(g,h.isForward())}},selectorChanged:function(g,j){var h=this,i;if(!h.selectorChangedData){h.selectorChangedData={};i={};h.editor.onNodeChange.addToTop(function(l,k,o){var p=h.dom,m=p.getParents(o,null,p.getRoot()),n={};e(h.selectorChangedData,function(r,q){e(m,function(s){if(p.is(s,q)){if(!i[q]){e(r,function(t){t(true,{node:s,selector:q,parents:m})});i[q]=r}n[q]=r;return false}})});e(i,function(r,q){if(!n[q]){delete i[q];e(r,function(s){s(false,{node:o,selector:q,parents:m})})}})})}if(!h.selectorChangedData[g]){h.selectorChangedData[g]=[]}h.selectorChangedData[g].push(j);return h},scrollIntoView:function(k){var j,h,g=this,i=g.dom;h=i.getViewPort(g.editor.getWin());j=i.getPos(k).y;if(j<h.y||j+25>h.y+h.h){g.editor.getWin().scrollTo(0,j<h.y?j:j-h.h+25)}},destroy:function(h){var g=this;g.win=null;if(!h){d.removeUnload(g.destroy)}},_fixIESelection:function(){var h=this.dom,n=h.doc,i=n.body,k,o,g;function j(p,s){var q=i.createTextRange();try{q.moveToPoint(p,s)}catch(r){q=null}return q}function m(q){var p;if(q.button){p=j(q.x,q.y);if(p){if(p.compareEndPoints("StartToStart",o)>0){p.setEndPoint("StartToStart",o)}else{p.setEndPoint("EndToEnd",o)}p.select()}}else{l()}}function l(){var p=n.selection.createRange();if(o&&!p.item&&p.compareEndPoints("StartToEnd",p)===0){o.select()}h.unbind(n,"mouseup",l);h.unbind(n,"mousemove",m);o=k=0}n.documentElement.unselectable=true;h.bind(n,["mousedown","contextmenu"],function(p){if(p.target.nodeName==="HTML"){if(k){l()}g=n.documentElement;if(g.scrollHeight>g.clientHeight){return}k=1;o=j(p.x,p.y);if(o){h.bind(n,"mouseup",l);h.bind(n,"mousemove",m);h.win.focus();o.select()}}})}})})(tinymce);(function(a){a.dom.Serializer=function(e,i,f){var h,b,d=a.isIE,g=a.each,c;if(!e.apply_source_formatting){e.indent=false}i=i||a.DOM;f=f||new a.html.Schema(e);e.entity_encoding=e.entity_encoding||"named";e.remove_trailing_brs="remove_trailing_brs" in e?e.remove_trailing_brs:true;h=new a.util.Dispatcher(self);b=new a.util.Dispatcher(self);c=new a.html.DomParser(e,f);c.addAttributeFilter("src,href,style",function(k,j){var o=k.length,l,q,n="data-mce-"+j,p=e.url_converter,r=e.url_converter_scope,m;while(o--){l=k[o];q=l.attributes.map[n];if(q!==m){l.attr(j,q.length>0?q:null);l.attr(n,null)}else{q=l.attributes.map[j];if(j==="style"){q=i.serializeStyle(i.parseStyle(q),l.name)}else{if(p){q=p.call(r,q,j,l.name)}}l.attr(j,q.length>0?q:null)}}});c.addAttributeFilter("class",function(j,k){var l=j.length,m,n;while(l--){m=j[l];n=m.attr("class").replace(/(?:^|\s)mce(Item\w+|Selected)(?!\S)/g,"");m.attr("class",n.length>0?n:null)}});c.addAttributeFilter("data-mce-type",function(j,l,k){var m=j.length,n;while(m--){n=j[m];if(n.attributes.map["data-mce-type"]==="bookmark"&&!k.cleanup){n.remove()}}});c.addAttributeFilter("data-mce-expando",function(j,l,k){var m=j.length;while(m--){j[m].attr(l,null)}});c.addNodeFilter("noscript",function(j){var k=j.length,l;while(k--){l=j[k].firstChild;if(l){l.value=a.html.Entities.decode(l.value)}}});c.addNodeFilter("script,style",function(k,l){var m=k.length,n,o;function j(p){return p.replace(/(<!--\[CDATA\[|\]\]-->)/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*((<!--)?(\s*\/\/)?\s*<!\[CDATA\[|(<!--\s*)?\/\*\s*<!\[CDATA\[\s*\*\/|(\/\/)?\s*<!--|\/\*\s*<!--\s*\*\/)\s*[\r\n]*/gi,"").replace(/\s*(\/\*\s*\]\]>\s*\*\/(-->)?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"")}while(m--){n=k[m];o=n.firstChild?n.firstChild.value:"";if(l==="script"){n.attr("type",(n.attr("type")||"text/javascript").replace(/^mce\-/,""));if(o.length>0){n.firstChild.value="// <![CDATA[\n"+j(o)+"\n// ]]>"}}else{if(o.length>0){n.firstChild.value="<!--\n"+j(o)+"\n-->"}}}});c.addNodeFilter("#comment",function(j,k){var l=j.length,m;while(l--){m=j[l];if(m.value.indexOf("[CDATA[")===0){m.name="#cdata";m.type=4;m.value=m.value.replace(/^\[CDATA\[|\]\]$/g,"")}else{if(m.value.indexOf("mce:protected ")===0){m.name="#text";m.type=3;m.raw=true;m.value=unescape(m.value).substr(14)}}}});c.addNodeFilter("xml:namespace,input",function(j,k){var l=j.length,m;while(l--){m=j[l];if(m.type===7){m.remove()}else{if(m.type===1){if(k==="input"&&!("type" in m.attributes.map)){m.attr("type","text")}}}}});if(e.fix_list_elements){c.addNodeFilter("ul,ol",function(k,l){var m=k.length,n,j;while(m--){n=k[m];j=n.parent;if(j.name==="ul"||j.name==="ol"){if(n.prev&&n.prev.name==="li"){n.prev.append(n)}}}})}c.addAttributeFilter("data-mce-src,data-mce-href,data-mce-style",function(j,k){var l=j.length;while(l--){j[l].attr(k,null)}});return{schema:f,addNodeFilter:c.addNodeFilter,addAttributeFilter:c.addAttributeFilter,onPreProcess:h,onPostProcess:b,serialize:function(o,m){var l,p,k,j,n;if(d&&i.select("script,style,select,map").length>0){n=o.innerHTML;o=o.cloneNode(false);i.setHTML(o,n)}else{o=o.cloneNode(true)}l=o.ownerDocument.implementation;if(l.createHTMLDocument){p=l.createHTMLDocument("");g(o.nodeName=="BODY"?o.childNodes:[o],function(q){p.body.appendChild(p.importNode(q,true))});if(o.nodeName!="BODY"){o=p.body.firstChild}else{o=p.body}k=i.doc;i.doc=p}m=m||{};m.format=m.format||"html";if(!m.no_events){m.node=o;h.dispatch(self,m)}j=new a.html.Serializer(e,f);m.content=j.serialize(c.parse(a.trim(m.getInner?o.innerHTML:i.getOuterHTML(o)),m));if(!m.cleanup){m.content=m.content.replace(/\uFEFF/g,"")}if(!m.no_events){b.dispatch(self,m)}if(k){i.doc=k}m.node=null;return m.content},addRules:function(j){f.addValidElements(j)},setRules:function(j){f.setValidElements(j)}}}})(tinymce);(function(a){a.dom.ScriptLoader=function(h){var c=0,k=1,i=2,l={},j=[],e={},d=[],g=0,f;function b(m,v){var x=this,q=a.DOM,s,o,r,n;function p(){q.remove(n);if(s){s.onreadystatechange=s.onload=s=null}v()}function u(){if(typeof(console)!=="undefined"&&console.log){console.log("Failed to load: "+m)}}n=q.uniqueId();if(a.isIE6){o=new a.util.URI(m);r=location;if(o.host==r.hostname&&o.port==r.port&&(o.protocol+":")==r.protocol&&o.protocol.toLowerCase()!="file"){a.util.XHR.send({url:a._addVer(o.getURI()),success:function(y){var t=q.create("script",{type:"text/javascript"});t.text=y;document.getElementsByTagName("head")[0].appendChild(t);q.remove(t);p()},error:u});return}}s=document.createElement("script");s.id=n;s.type="text/javascript";s.src=a._addVer(m);if(!a.isIE||a.isIE11){s.onload=p}s.onerror=u;if(!a.isOpera){s.onreadystatechange=function(){var t=s.readyState;if(t=="complete"||t=="loaded"){p()}}}(document.getElementsByTagName("head")[0]||document.body).appendChild(s)}this.isDone=function(m){return l[m]==i};this.markDone=function(m){l[m]=i};this.add=this.load=function(m,q,n){var o,p=l[m];if(p==f){j.push(m);l[m]=c}if(q){if(!e[m]){e[m]=[]}e[m].push({func:q,scope:n||this})}};this.loadQueue=function(n,m){this.loadScripts(j,n,m)};this.loadScripts=function(m,q,p){var o;function n(r){a.each(e[r],function(s){s.func.call(s.scope)});e[r]=f}d.push({func:q,scope:p||this});o=function(){var r=a.grep(m);m.length=0;a.each(r,function(s){if(l[s]==i){n(s);return}if(l[s]!=k){l[s]=k;g++;b(s,function(){l[s]=i;g--;n(s);o()})}});if(!g){a.each(d,function(s){s.func.call(s.scope)});d.length=0}};o()}};a.ScriptLoader=new a.dom.ScriptLoader()})(tinymce);(function(a){a.dom.RangeUtils=function(c){var b="\uFEFF";this.walk=function(d,s){var i=d.startContainer,l=d.startOffset,t=d.endContainer,m=d.endOffset,j,g,o,h,r,q,e;e=c.select("td.mceSelected,th.mceSelected");if(e.length>0){a.each(e,function(u){s([u])});return}function f(u){var v;v=u[0];if(v.nodeType===3&&v===i&&l>=v.nodeValue.length){u.splice(0,1)}v=u[u.length-1];if(m===0&&u.length>0&&v===t&&v.nodeType===3){u.splice(u.length-1,1)}return u}function p(x,v,u){var y=[];for(;x&&x!=u;x=x[v]){y.push(x)}return y}function n(v,u){do{if(v.parentNode==u){return v}v=v.parentNode}while(v)}function k(x,v,y){var u=y?"nextSibling":"previousSibling";for(h=x,r=h.parentNode;h&&h!=v;h=r){r=h.parentNode;q=p(h==x?h:h[u],u);if(q.length){if(!y){q.reverse()}s(f(q))}}}if(i.nodeType==1&&i.hasChildNodes()){i=i.childNodes[l]}if(t.nodeType==1&&t.hasChildNodes()){t=t.childNodes[Math.min(m-1,t.childNodes.length-1)]}if(i==t){return s(f([i]))}j=c.findCommonAncestor(i,t);for(h=i;h;h=h.parentNode){if(h===t){return k(i,j,true)}if(h===j){break}}for(h=t;h;h=h.parentNode){if(h===i){return k(t,j)}if(h===j){break}}g=n(i,j)||i;o=n(t,j)||t;k(i,g,true);q=p(g==i?g:g.nextSibling,"nextSibling",o==t?o.nextSibling:o);if(q.length){s(f(q))}k(t,o)};this.split=function(e){var h=e.startContainer,d=e.startOffset,i=e.endContainer,g=e.endOffset;function f(j,k){return j.splitText(k)}if(h==i&&h.nodeType==3){if(d>0&&d<h.nodeValue.length){i=f(h,d);h=i.previousSibling;if(g>d){g=g-d;h=i=f(i,g).previousSibling;g=i.nodeValue.length;d=0}else{g=0}}}else{if(h.nodeType==3&&d>0&&d<h.nodeValue.length){h=f(h,d);d=0}if(i.nodeType==3&&g>0&&g<i.nodeValue.length){i=f(i,g).previousSibling;g=i.nodeValue.length}}return{startContainer:h,startOffset:d,endContainer:i,endOffset:g}}};a.dom.RangeUtils.compareRanges=function(c,b){if(c&&b){if(c.item||c.duplicate){if(c.item&&b.item&&c.item(0)===b.item(0)){return true}if(c.isEqual&&b.isEqual&&b.isEqual(c)){return true}}else{return c.startContainer==b.startContainer&&c.startOffset==b.startOffset}}return false}})(tinymce);(function(b){var a=b.dom.Event,c=b.each;b.create("tinymce.ui.KeyboardNavigation",{KeyboardNavigation:function(e,f){var q=this,n=e.root,m=e.items,o=e.enableUpDown,i=e.enableLeftRight||!e.enableUpDown,l=e.excludeFromTabOrder,k,h,p,d,g;f=f||b.DOM;k=function(r){g=r.target.id};h=function(r){f.setAttrib(r.target.id,"tabindex","-1")};d=function(r){var s=f.get(g);f.setAttrib(s,"tabindex","0");s.focus()};q.focus=function(){f.get(g).focus()};q.destroy=function(){c(m,function(s){var t=f.get(s.id);f.unbind(t,"focus",k);f.unbind(t,"blur",h)});var r=f.get(n);f.unbind(r,"focus",d);f.unbind(r,"keydown",p);m=f=n=q.focus=k=h=p=d=null;q.destroy=function(){}};q.moveFocus=function(v,s){var r=-1,u=q.controls,t;if(!g){return}c(m,function(y,x){if(y.id===g){r=x;return false}});r+=v;if(r<0){r=m.length-1}else{if(r>=m.length){r=0}}t=m[r];f.setAttrib(g,"tabindex","-1");f.setAttrib(t.id,"tabindex","0");f.get(t.id).focus();if(e.actOnFocus){e.onAction(t.id)}if(s){a.cancel(s)}};p=function(z){var v=37,u=39,y=38,A=40,r=27,t=14,s=13,x=32;switch(z.keyCode){case v:if(i){q.moveFocus(-1)}a.cancel(z);break;case u:if(i){q.moveFocus(1)}a.cancel(z);break;case y:if(o){q.moveFocus(-1)}a.cancel(z);break;case A:if(o){q.moveFocus(1)}a.cancel(z);break;case r:if(e.onCancel){e.onCancel();a.cancel(z)}break;case t:case s:case x:if(e.onAction){e.onAction(g);a.cancel(z)}break}};c(m,function(t,r){var s,u;if(!t.id){t.id=f.uniqueId("_mce_item_")}u=f.get(t.id);if(l){f.bind(u,"blur",h);s="-1"}else{s=(r===0?"0":"-1")}u.setAttribute("tabindex",s);f.bind(u,"focus",k)});if(m[0]){g=m[0].id}f.setAttrib(n,"tabindex","-1");var j=f.get(n);f.bind(j,"focus",d);f.bind(j,"keydown",p)}})})(tinymce);(function(c){var b=c.DOM,a=c.is;c.create("tinymce.ui.Control",{Control:function(f,e,d){this.id=f;this.settings=e=e||{};this.rendered=false;this.onRender=new c.util.Dispatcher(this);this.classPrefix="";this.scope=e.scope||this;this.disabled=0;this.active=0;this.editor=d},setAriaProperty:function(f,e){var d=b.get(this.id+"_aria")||b.get(this.id);if(d){b.setAttrib(d,"aria-"+f,!!e)}},focus:function(){b.get(this.id).focus()},setDisabled:function(d){if(d!=this.disabled){this.setAriaProperty("disabled",d);this.setState("Disabled",d);this.setState("Enabled",!d);this.disabled=d}},isDisabled:function(){return this.disabled},setActive:function(d){if(d!=this.active){this.setState("Active",d);this.active=d;this.setAriaProperty("pressed",d)}},isActive:function(){return this.active},setState:function(f,d){var e=b.get(this.id);f=this.classPrefix+f;if(d){b.addClass(e,f)}else{b.removeClass(e,f)}},isRendered:function(){return this.rendered},renderHTML:function(){},renderTo:function(d){b.setHTML(d,this.renderHTML())},postRender:function(){var e=this,d;if(a(e.disabled)){d=e.disabled;e.disabled=-1;e.setDisabled(d)}if(a(e.active)){d=e.active;e.active=-1;e.setActive(d)}},remove:function(){b.remove(this.id);this.destroy()},destroy:function(){c.dom.Event.clear(this.id)}})})(tinymce);tinymce.create("tinymce.ui.Container:tinymce.ui.Control",{Container:function(c,b,a){this.parent(c,b,a);this.controls=[];this.lookup={}},add:function(a){this.lookup[a.id]=a;this.controls.push(a);return a},get:function(a){return this.lookup[a]}});tinymce.create("tinymce.ui.Separator:tinymce.ui.Control",{Separator:function(b,a){this.parent(b,a);this.classPrefix="mceSeparator";this.setDisabled(true)},renderHTML:function(){return tinymce.DOM.createHTML("span",{"class":this.classPrefix,role:"separator","aria-orientation":"vertical",tabindex:"-1"})}});(function(d){var c=d.is,b=d.DOM,e=d.each,a=d.walk;d.create("tinymce.ui.MenuItem:tinymce.ui.Control",{MenuItem:function(g,f){this.parent(g,f);this.classPrefix="mceMenuItem"},setSelected:function(f){this.setState("Selected",f);this.setAriaProperty("checked",!!f);this.selected=f},isSelected:function(){return this.selected},postRender:function(){var f=this;f.parent();if(c(f.selected)){f.setSelected(f.selected)}}})})(tinymce);(function(d){var c=d.is,b=d.DOM,e=d.each,a=d.walk;d.create("tinymce.ui.Menu:tinymce.ui.MenuItem",{Menu:function(h,g){var f=this;f.parent(h,g);f.items={};f.collapsed=false;f.menuCount=0;f.onAddItem=new d.util.Dispatcher(this)},expand:function(g){var f=this;if(g){a(f,function(h){if(h.expand){h.expand()}},"items",f)}f.collapsed=false},collapse:function(g){var f=this;if(g){a(f,function(h){if(h.collapse){h.collapse()}},"items",f)}f.collapsed=true},isCollapsed:function(){return this.collapsed},add:function(f){if(!f.settings){f=new d.ui.MenuItem(f.id||b.uniqueId(),f)}this.onAddItem.dispatch(this,f);return this.items[f.id]=f},addSeparator:function(){return this.add({separator:true})},addMenu:function(f){if(!f.collapse){f=this.createMenu(f)}this.menuCount++;return this.add(f)},hasMenus:function(){return this.menuCount!==0},remove:function(f){delete this.items[f.id]},removeAll:function(){var f=this;a(f,function(g){if(g.removeAll){g.removeAll()}else{g.remove()}g.destroy()},"items",f);f.items={}},createMenu:function(g){var f=new d.ui.Menu(g.id||b.uniqueId(),g);f.onAddItem.add(this.onAddItem.dispatch,this.onAddItem);return f}})})(tinymce);(function(e){var d=e.is,c=e.DOM,f=e.each,a=e.dom.Event,b=e.dom.Element;e.create("tinymce.ui.DropMenu:tinymce.ui.Menu",{DropMenu:function(h,g){g=g||{};g.container=g.container||c.doc.body;g.offset_x=g.offset_x||0;g.offset_y=g.offset_y||0;g.vp_offset_x=g.vp_offset_x||0;g.vp_offset_y=g.vp_offset_y||0;if(d(g.icons)&&!g.icons){g["class"]+=" mceNoIcons"}this.parent(h,g);this.onShowMenu=new e.util.Dispatcher(this);this.onHideMenu=new e.util.Dispatcher(this);this.classPrefix="mceMenu"},createMenu:function(j){var h=this,i=h.settings,g;j.container=j.container||i.container;j.parent=h;j.constrain=j.constrain||i.constrain;j["class"]=j["class"]||i["class"];j.vp_offset_x=j.vp_offset_x||i.vp_offset_x;j.vp_offset_y=j.vp_offset_y||i.vp_offset_y;j.keyboard_focus=i.keyboard_focus;g=new e.ui.DropMenu(j.id||c.uniqueId(),j);g.onAddItem.add(h.onAddItem.dispatch,h.onAddItem);return g},focus:function(){var g=this;if(g.keyboardNav){g.keyboardNav.focus()}},update:function(){var i=this,j=i.settings,g=c.get("menu_"+i.id+"_tbl"),l=c.get("menu_"+i.id+"_co"),h,k;h=j.max_width?Math.min(g.offsetWidth,j.max_width):g.offsetWidth;k=j.max_height?Math.min(g.offsetHeight,j.max_height):g.offsetHeight;if(!c.boxModel){i.element.setStyles({width:h+2,height:k+2})}else{i.element.setStyles({width:h,height:k})}if(j.max_width){c.setStyle(l,"width",h)}if(j.max_height){c.setStyle(l,"height",k);if(g.clientHeight<j.max_height){c.setStyle(l,"overflow","hidden")}}},showMenu:function(p,n,r){var z=this,A=z.settings,o,g=c.getViewPort(),u,l,v,q,i=2,k,j,m=z.classPrefix;z.collapse(1);if(z.isMenuVisible){return}if(!z.rendered){o=c.add(z.settings.container,z.renderNode());f(z.items,function(h){h.postRender()});z.element=new b("menu_"+z.id,{blocker:1,container:A.container})}else{o=c.get("menu_"+z.id)}if(!e.isOpera){c.setStyles(o,{left:-65535,top:-65535})}c.show(o);z.update();p+=A.offset_x||0;n+=A.offset_y||0;g.w-=4;g.h-=4;if(A.constrain){u=o.clientWidth-i;l=o.clientHeight-i;v=g.x+g.w;q=g.y+g.h;if((p+A.vp_offset_x+u)>v){p=r?r-u:Math.max(0,(v-A.vp_offset_x)-u)}if((n+A.vp_offset_y+l)>q){n=Math.max(0,(q-A.vp_offset_y)-l)}}c.setStyles(o,{left:p,top:n});z.element.update();z.isMenuVisible=1;z.mouseClickFunc=a.add(o,"click",function(s){var h;s=s.target;if(s&&(s=c.getParent(s,"tr"))&&!c.hasClass(s,m+"ItemSub")){h=z.items[s.id];if(h.isDisabled()){return}k=z;while(k){if(k.hideMenu){k.hideMenu()}k=k.settings.parent}if(h.settings.onclick){h.settings.onclick(s)}return false}});if(z.hasMenus()){z.mouseOverFunc=a.add(o,"mouseover",function(x){var h,t,s;x=x.target;if(x&&(x=c.getParent(x,"tr"))){h=z.items[x.id];if(z.lastMenu){z.lastMenu.collapse(1)}if(h.isDisabled()){return}if(x&&c.hasClass(x,m+"ItemSub")){t=c.getRect(x);h.showMenu((t.x+t.w-i),t.y-i,t.x);z.lastMenu=h;c.addClass(c.get(h.id).firstChild,m+"ItemActive")}}})}a.add(o,"keydown",z._keyHandler,z);z.onShowMenu.dispatch(z);if(A.keyboard_focus){z._setupKeyboardNav()}},hideMenu:function(j){var g=this,i=c.get("menu_"+g.id),h;if(!g.isMenuVisible){return}if(g.keyboardNav){g.keyboardNav.destroy()}a.remove(i,"mouseover",g.mouseOverFunc);a.remove(i,"click",g.mouseClickFunc);a.remove(i,"keydown",g._keyHandler);c.hide(i);g.isMenuVisible=0;if(!j){g.collapse(1)}if(g.element){g.element.hide()}if(h=c.get(g.id)){c.removeClass(h.firstChild,g.classPrefix+"ItemActive")}g.onHideMenu.dispatch(g)},add:function(i){var g=this,h;i=g.parent(i);if(g.isRendered&&(h=c.get("menu_"+g.id))){g._add(c.select("tbody",h)[0],i)}return i},collapse:function(g){this.parent(g);this.hideMenu(1)},remove:function(g){c.remove(g.id);this.destroy();return this.parent(g)},destroy:function(){var g=this,h=c.get("menu_"+g.id);if(g.keyboardNav){g.keyboardNav.destroy()}a.remove(h,"mouseover",g.mouseOverFunc);a.remove(c.select("a",h),"focus",g.mouseOverFunc);a.remove(h,"click",g.mouseClickFunc);a.remove(h,"keydown",g._keyHandler);if(g.element){g.element.remove()}c.remove(h)},renderNode:function(){var i=this,j=i.settings,l,h,k,g;g=c.create("div",{role:"listbox",id:"menu_"+i.id,"class":j["class"],style:"position:absolute;left:0;top:0;z-index:200000;outline:0"});if(i.settings.parent){c.setAttrib(g,"aria-parent","menu_"+i.settings.parent.id)}k=c.add(g,"div",{role:"presentation",id:"menu_"+i.id+"_co","class":i.classPrefix+(j["class"]?" "+j["class"]:"")});i.element=new b("menu_"+i.id,{blocker:1,container:j.container});if(j.menu_line){c.add(k,"span",{"class":i.classPrefix+"Line"})}l=c.add(k,"table",{role:"presentation",id:"menu_"+i.id+"_tbl",border:0,cellPadding:0,cellSpacing:0});h=c.add(l,"tbody");f(i.items,function(m){i._add(h,m)});i.rendered=true;return g},_setupKeyboardNav:function(){var i,h,g=this;i=c.get("menu_"+g.id);h=c.select("a[role=option]","menu_"+g.id);h.splice(0,0,i);g.keyboardNav=new e.ui.KeyboardNavigation({root:"menu_"+g.id,items:h,onCancel:function(){g.hideMenu()},enableUpDown:true});i.focus()},_keyHandler:function(g){var h=this,i;switch(g.keyCode){case 37:if(h.settings.parent){h.hideMenu();h.settings.parent.focus();a.cancel(g)}break;case 39:if(h.mouseOverFunc){h.mouseOverFunc(g)}break}},_add:function(j,h){var i,q=h.settings,p,l,k,m=this.classPrefix,g;if(q.separator){l=c.add(j,"tr",{id:h.id,"class":m+"ItemSeparator"});c.add(l,"td",{"class":m+"ItemSeparator"});if(i=l.previousSibling){c.addClass(i,"mceLast")}return}i=l=c.add(j,"tr",{id:h.id,"class":m+"Item "+m+"ItemEnabled"});i=k=c.add(i,q.titleItem?"th":"td");i=p=c.add(i,"a",{id:h.id+"_aria",role:q.titleItem?"presentation":"option",href:"javascript:;",onclick:"return false;",onmousedown:"return false;"});if(q.parent){c.setAttrib(p,"aria-haspopup","true");c.setAttrib(p,"aria-owns","menu_"+h.id)}c.addClass(k,q["class"]);g=c.add(i,"span",{"class":"mceIcon"+(q.icon?" mce_"+q.icon:"")});if(q.icon_src){c.add(g,"img",{src:q.icon_src})}i=c.add(i,q.element||"span",{"class":"mceText",title:h.settings.title},h.settings.title);if(h.settings.style){if(typeof h.settings.style=="function"){h.settings.style=h.settings.style()}c.setAttrib(i,"style",h.settings.style)}if(j.childNodes.length==1){c.addClass(l,"mceFirst")}if((i=l.previousSibling)&&c.hasClass(i,m+"ItemSeparator")){c.addClass(l,"mceFirst")}if(h.collapse){c.addClass(l,m+"ItemSub")}if(i=l.previousSibling){c.removeClass(i,"mceLast")}c.addClass(l,"mceLast")}})})(tinymce);(function(b){var a=b.DOM;b.create("tinymce.ui.Button:tinymce.ui.Control",{Button:function(e,d,c){this.parent(e,d,c);this.classPrefix="mceButton"},renderHTML:function(){var f=this.classPrefix,e=this.settings,d,c;c=a.encode(e.label||"");d='<a role="button" id="'+this.id+'" href="javascript:;" class="'+f+" "+f+"Enabled "+e["class"]+(c?" "+f+"Labeled":"")+'" onmousedown="return false;" onclick="return false;" aria-labelledby="'+this.id+'_voice" title="'+a.encode(e.title)+'">';if(e.image&&!(this.editor&&this.editor.forcedHighContrastMode)){d+='<span class="mceIcon '+e["class"]+'"><img class="mceIcon" src="'+e.image+'" alt="'+a.encode(e.title)+'" /></span>'+(c?'<span class="'+f+'Label">'+c+"</span>":"")}else{d+='<span class="mceIcon '+e["class"]+'"></span>'+(c?'<span class="'+f+'Label">'+c+"</span>":"")}d+='<span class="mceVoiceLabel mceIconOnly" style="display: none;" id="'+this.id+'_voice">'+e.title+"</span>";d+="</a>";return d},postRender:function(){var d=this,e=d.settings,c;if(b.isIE&&d.editor){b.dom.Event.add(d.id,"mousedown",function(f){var g=d.editor.selection.getNode().nodeName;c=g==="IMG"?d.editor.selection.getBookmark():null})}b.dom.Event.add(d.id,"click",function(f){if(!d.isDisabled()){if(b.isIE&&d.editor&&c!==null){d.editor.selection.moveToBookmark(c)}return e.onclick.call(e.scope,f)}});b.dom.Event.add(d.id,"keydown",function(f){if(!d.isDisabled()&&f.keyCode==b.VK.SPACEBAR){b.dom.Event.cancel(f);return e.onclick.call(e.scope,f)}})}})})(tinymce);(function(e){var d=e.DOM,b=e.dom.Event,f=e.each,a=e.util.Dispatcher,c;e.create("tinymce.ui.ListBox:tinymce.ui.Control",{ListBox:function(j,i,g){var h=this;h.parent(j,i,g);h.items=[];h.onChange=new a(h);h.onPostRender=new a(h);h.onAdd=new a(h);h.onRenderMenu=new e.util.Dispatcher(this);h.classPrefix="mceListBox";h.marked={}},select:function(h){var g=this,j,i;g.marked={};if(h==c){return g.selectByIndex(-1)}if(h&&typeof(h)=="function"){i=h}else{i=function(k){return k==h}}if(h!=g.selectedValue){f(g.items,function(l,k){if(i(l.value)){j=1;g.selectByIndex(k);return false}});if(!j){g.selectByIndex(-1)}}},selectByIndex:function(g){var i=this,j,k,h;i.marked={};if(g!=i.selectedIndex){j=d.get(i.id+"_text");h=d.get(i.id+"_voiceDesc");k=i.items[g];if(k){i.selectedValue=k.value;i.selectedIndex=g;d.setHTML(j,d.encode(k.title));d.setHTML(h,i.settings.title+" - "+k.title);d.removeClass(j,"mceTitle");d.setAttrib(i.id,"aria-valuenow",k.title)}else{d.setHTML(j,d.encode(i.settings.title));d.setHTML(h,d.encode(i.settings.title));d.addClass(j,"mceTitle");i.selectedValue=i.selectedIndex=null;d.setAttrib(i.id,"aria-valuenow",i.settings.title)}j=0}},mark:function(g){this.marked[g]=true},add:function(j,g,i){var h=this;i=i||{};i=e.extend(i,{title:j,value:g});h.items.push(i);h.onAdd.dispatch(h,i)},getLength:function(){return this.items.length},renderHTML:function(){var j="",g=this,i=g.settings,k=g.classPrefix;j='<span role="listbox" aria-haspopup="true" aria-labelledby="'+g.id+'_voiceDesc" aria-describedby="'+g.id+'_voiceDesc"><table role="presentation" tabindex="0" id="'+g.id+'" cellpadding="0" cellspacing="0" class="'+k+" "+k+"Enabled"+(i["class"]?(" "+i["class"]):"")+'"><tbody><tr>';j+="<td>"+d.createHTML("span",{id:g.id+"_voiceDesc","class":"voiceLabel",style:"display:none;"},g.settings.title);j+=d.createHTML("a",{id:g.id+"_text",tabindex:-1,href:"javascript:;","class":"mceText",onclick:"return false;",onmousedown:"return false;"},d.encode(g.settings.title))+"</td>";j+="<td>"+d.createHTML("a",{id:g.id+"_open",tabindex:-1,href:"javascript:;","class":"mceOpen",onclick:"return false;",onmousedown:"return false;"},'<span><span style="display:none;" class="mceIconOnly" aria-hidden="true">\u25BC</span></span>')+"</td>";j+="</tr></tbody></table></span>";return j},showMenu:function(){var h=this,j,i=d.get(this.id),g;if(h.isDisabled()||h.items.length===0){return}if(h.menu&&h.menu.isMenuVisible){return h.hideMenu()}if(!h.isMenuRendered){h.renderMenu();h.isMenuRendered=true}j=d.getPos(i);g=h.menu;g.settings.offset_x=j.x;g.settings.offset_y=j.y;g.settings.keyboard_focus=!e.isOpera;f(h.items,function(k){if(g.items[k.id]){g.items[k.id].setSelected(0)}});f(h.items,function(k){if(g.items[k.id]&&h.marked[k.value]){g.items[k.id].setSelected(1)}if(k.value===h.selectedValue){g.items[k.id].setSelected(1)}});g.showMenu(0,i.clientHeight);b.add(d.doc,"mousedown",h.hideMenu,h);d.addClass(h.id,h.classPrefix+"Selected")},hideMenu:function(h){var g=this;if(g.menu&&g.menu.isMenuVisible){d.removeClass(g.id,g.classPrefix+"Selected");if(h&&h.type=="mousedown"&&(h.target.id==g.id+"_text"||h.target.id==g.id+"_open")){return}if(!h||!d.getParent(h.target,".mceMenu")){d.removeClass(g.id,g.classPrefix+"Selected");b.remove(d.doc,"mousedown",g.hideMenu,g);g.menu.hideMenu()}}},renderMenu:function(){var h=this,g;g=h.settings.control_manager.createDropMenu(h.id+"_menu",{menu_line:1,"class":h.classPrefix+"Menu mceNoIcons",max_width:250,max_height:150});g.onHideMenu.add(function(){h.hideMenu();h.focus()});g.add({title:h.settings.title,"class":"mceMenuItemTitle",onclick:function(){if(h.settings.onselect("")!==false){h.select("")}}});f(h.items,function(i){if(i.value===c){g.add({title:i.title,role:"option","class":"mceMenuItemTitle",onclick:function(){if(h.settings.onselect("")!==false){h.select("")}}})}else{i.id=d.uniqueId();i.role="option";i.onclick=function(){if(h.settings.onselect(i.value)!==false){h.select(i.value)}};g.add(i)}});h.onRenderMenu.dispatch(h,g);h.menu=g},postRender:function(){var g=this,h=g.classPrefix;b.add(g.id,"click",g.showMenu,g);b.add(g.id,"keydown",function(i){if(i.keyCode==32){g.showMenu(i);b.cancel(i)}});b.add(g.id,"focus",function(){if(!g._focused){g.keyDownHandler=b.add(g.id,"keydown",function(i){if(i.keyCode==40){g.showMenu();b.cancel(i)}});g.keyPressHandler=b.add(g.id,"keypress",function(j){var i;if(j.keyCode==13){i=g.selectedValue;g.selectedValue=null;b.cancel(j);g.settings.onselect(i)}})}g._focused=1});b.add(g.id,"blur",function(){b.remove(g.id,"keydown",g.keyDownHandler);b.remove(g.id,"keypress",g.keyPressHandler);g._focused=0});if(e.isIE6||!d.boxModel){b.add(g.id,"mouseover",function(){if(!d.hasClass(g.id,h+"Disabled")){d.addClass(g.id,h+"Hover")}});b.add(g.id,"mouseout",function(){if(!d.hasClass(g.id,h+"Disabled")){d.removeClass(g.id,h+"Hover")}})}g.onPostRender.dispatch(g,d.get(g.id))},destroy:function(){this.parent();b.clear(this.id+"_text");b.clear(this.id+"_open")}})})(tinymce);(function(e){var d=e.DOM,b=e.dom.Event,f=e.each,a=e.util.Dispatcher,c;e.create("tinymce.ui.NativeListBox:tinymce.ui.ListBox",{NativeListBox:function(h,g){this.parent(h,g);this.classPrefix="mceNativeListBox"},setDisabled:function(g){d.get(this.id).disabled=g;this.setAriaProperty("disabled",g)},isDisabled:function(){return d.get(this.id).disabled},select:function(h){var g=this,j,i;if(h==c){return g.selectByIndex(-1)}if(h&&typeof(h)=="function"){i=h}else{i=function(k){return k==h}}if(h!=g.selectedValue){f(g.items,function(l,k){if(i(l.value)){j=1;g.selectByIndex(k);return false}});if(!j){g.selectByIndex(-1)}}},selectByIndex:function(g){d.get(this.id).selectedIndex=g+1;this.selectedValue=this.items[g]?this.items[g].value:null},add:function(k,h,g){var j,i=this;g=g||{};g.value=h;if(i.isRendered()){d.add(d.get(this.id),"option",g,k)}j={title:k,value:h,attribs:g};i.items.push(j);i.onAdd.dispatch(i,j)},getLength:function(){return this.items.length},renderHTML:function(){var i,g=this;i=d.createHTML("option",{value:""},"-- "+g.settings.title+" --");f(g.items,function(h){i+=d.createHTML("option",{value:h.value},h.title)});i=d.createHTML("select",{id:g.id,"class":"mceNativeListBox","aria-labelledby":g.id+"_aria"},i);i+=d.createHTML("span",{id:g.id+"_aria",style:"display: none"},g.settings.title);return i},postRender:function(){var h=this,i,j=true;h.rendered=true;function g(l){var k=h.items[l.target.selectedIndex-1];if(k&&(k=k.value)){h.onChange.dispatch(h,k);if(h.settings.onselect){h.settings.onselect(k)}}}b.add(h.id,"change",g);b.add(h.id,"keydown",function(q){var n,p=37,m=39,l=38,r=40,k=13,o=32;b.remove(h.id,"change",i);j=false;n=b.add(h.id,"blur",function(){if(j){return}j=true;b.add(h.id,"change",g);b.remove(h.id,"blur",n)});if(q.keyCode==k||q.keyCode==o){g(q);return b.cancel(q)}else{if(q.keyCode==r||q.keyCode==l){q.stopImmediatePropagation()}}});h.onPostRender.dispatch(h,d.get(h.id))}})})(tinymce);(function(c){var b=c.DOM,a=c.dom.Event,d=c.each;c.create("tinymce.ui.MenuButton:tinymce.ui.Button",{MenuButton:function(g,f,e){this.parent(g,f,e);this.onRenderMenu=new c.util.Dispatcher(this);f.menu_container=f.menu_container||b.doc.body},showMenu:function(){var g=this,j,i,h=b.get(g.id),f;if(g.isDisabled()){return}if(!g.isMenuRendered){g.renderMenu();g.isMenuRendered=true}if(g.isMenuVisible){return g.hideMenu()}j=b.getPos(g.settings.menu_container);i=b.getPos(h);f=g.menu;f.settings.offset_x=i.x;f.settings.offset_y=i.y;f.settings.vp_offset_x=i.x;f.settings.vp_offset_y=i.y;f.settings.keyboard_focus=g._focused;f.showMenu(0,h.firstChild.clientHeight);a.add(b.doc,"mousedown",g.hideMenu,g);g.setState("Selected",1);g.isMenuVisible=1},renderMenu:function(){var f=this,e;e=f.settings.control_manager.createDropMenu(f.id+"_menu",{menu_line:1,"class":this.classPrefix+"Menu",icons:f.settings.icons});e.onHideMenu.add(function(){f.hideMenu();f.focus()});f.onRenderMenu.dispatch(f,e);f.menu=e},hideMenu:function(g){var f=this;if(g&&g.type=="mousedown"&&b.getParent(g.target,function(h){return h.id===f.id||h.id===f.id+"_open"})){return}if(!g||!b.getParent(g.target,".mceMenu")){f.setState("Selected",0);a.remove(b.doc,"mousedown",f.hideMenu,f);if(f.menu){f.menu.hideMenu()}}f.isMenuVisible=0},postRender:function(){var e=this,f=e.settings;a.add(e.id,"click",function(){if(!e.isDisabled()){if(f.onclick){f.onclick(e.value)}e.showMenu()}})}})})(tinymce);(function(c){var b=c.DOM,a=c.dom.Event,d=c.each;c.create("tinymce.ui.SplitButton:tinymce.ui.MenuButton",{SplitButton:function(g,f,e){this.parent(g,f,e);this.classPrefix="mceSplitButton"},renderHTML:function(){var i,f=this,g=f.settings,e;i="<tbody><tr>";if(g.image){e=b.createHTML("img ",{src:g.image,role:"presentation","class":"mceAction "+g["class"]})}else{e=b.createHTML("span",{"class":"mceAction "+g["class"]},"")}e+=b.createHTML("span",{"class":"mceVoiceLabel mceIconOnly",id:f.id+"_voice",style:"display:none;"},g.title);i+="<td >"+b.createHTML("a",{role:"button",id:f.id+"_action",tabindex:"-1",href:"javascript:;","class":"mceAction "+g["class"],onclick:"return false;",onmousedown:"return false;",title:g.title},e)+"</td>";e=b.createHTML("span",{"class":"mceOpen "+g["class"]},'<span style="display:none;" class="mceIconOnly" aria-hidden="true">\u25BC</span>');i+="<td >"+b.createHTML("a",{role:"button",id:f.id+"_open",tabindex:"-1",href:"javascript:;","class":"mceOpen "+g["class"],onclick:"return false;",onmousedown:"return false;",title:g.title},e)+"</td>";i+="</tr></tbody>";i=b.createHTML("table",{role:"presentation","class":"mceSplitButton mceSplitButtonEnabled "+g["class"],cellpadding:"0",cellspacing:"0",title:g.title},i);return b.createHTML("div",{id:f.id,role:"button",tabindex:"0","aria-labelledby":f.id+"_voice","aria-haspopup":"true"},i)},postRender:function(){var e=this,g=e.settings,f;if(g.onclick){f=function(h){if(!e.isDisabled()){g.onclick(e.value);a.cancel(h)}};a.add(e.id+"_action","click",f);a.add(e.id,["click","keydown"],function(h){var k=32,m=14,i=13,j=38,l=40;if((h.keyCode===32||h.keyCode===13||h.keyCode===14)&&!h.altKey&&!h.ctrlKey&&!h.metaKey){f();a.cancel(h)}else{if(h.type==="click"||h.keyCode===l){e.showMenu();a.cancel(h)}}})}a.add(e.id+"_open","click",function(h){e.showMenu();a.cancel(h)});a.add([e.id,e.id+"_open"],"focus",function(){e._focused=1});a.add([e.id,e.id+"_open"],"blur",function(){e._focused=0});if(c.isIE6||!b.boxModel){a.add(e.id,"mouseover",function(){if(!b.hasClass(e.id,"mceSplitButtonDisabled")){b.addClass(e.id,"mceSplitButtonHover")}});a.add(e.id,"mouseout",function(){if(!b.hasClass(e.id,"mceSplitButtonDisabled")){b.removeClass(e.id,"mceSplitButtonHover")}})}},destroy:function(){this.parent();a.clear(this.id+"_action");a.clear(this.id+"_open");a.clear(this.id)}})})(tinymce);(function(d){var c=d.DOM,a=d.dom.Event,b=d.is,e=d.each;d.create("tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton",{ColorSplitButton:function(i,h,f){var g=this;g.parent(i,h,f);g.settings=h=d.extend({colors:"000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF",grid_width:8,default_color:"#888888"},g.settings);g.onShowMenu=new d.util.Dispatcher(g);g.onHideMenu=new d.util.Dispatcher(g);g.value=h.default_color},showMenu:function(){var f=this,g,j,i,h;if(f.isDisabled()){return}if(!f.isMenuRendered){f.renderMenu();f.isMenuRendered=true}if(f.isMenuVisible){return f.hideMenu()}i=c.get(f.id);c.show(f.id+"_menu");c.addClass(i,"mceSplitButtonSelected");h=c.getPos(i);c.setStyles(f.id+"_menu",{left:h.x,top:h.y+i.firstChild.clientHeight,zIndex:200000});i=0;a.add(c.doc,"mousedown",f.hideMenu,f);f.onShowMenu.dispatch(f);if(f._focused){f._keyHandler=a.add(f.id+"_menu","keydown",function(k){if(k.keyCode==27){f.hideMenu()}});c.select("a",f.id+"_menu")[0].focus()}f.keyboardNav=new d.ui.KeyboardNavigation({root:f.id+"_menu",items:c.select("a",f.id+"_menu"),onCancel:function(){f.hideMenu();f.focus()}});f.keyboardNav.focus();f.isMenuVisible=1},hideMenu:function(g){var f=this;if(f.isMenuVisible){if(g&&g.type=="mousedown"&&c.getParent(g.target,function(h){return h.id===f.id+"_open"})){return}if(!g||!c.getParent(g.target,".mceSplitButtonMenu")){c.removeClass(f.id,"mceSplitButtonSelected");a.remove(c.doc,"mousedown",f.hideMenu,f);a.remove(f.id+"_menu","keydown",f._keyHandler);c.hide(f.id+"_menu")}f.isMenuVisible=0;f.onHideMenu.dispatch();f.keyboardNav.destroy()}},renderMenu:function(){var p=this,h,k=0,q=p.settings,g,j,l,o,f;o=c.add(q.menu_container,"div",{role:"listbox",id:p.id+"_menu","class":q.menu_class+" "+q["class"],style:"position:absolute;left:0;top:-1000px;"});h=c.add(o,"div",{"class":q["class"]+" mceSplitButtonMenu"});c.add(h,"span",{"class":"mceMenuLine"});g=c.add(h,"table",{role:"presentation","class":"mceColorSplitMenu"});j=c.add(g,"tbody");k=0;e(b(q.colors,"array")?q.colors:q.colors.split(","),function(m){m=m.replace(/^#/,"");if(!k--){l=c.add(j,"tr");k=q.grid_width-1}g=c.add(l,"td");var i={href:"javascript:;",style:{backgroundColor:"#"+m},title:p.editor.getLang("colors."+m,m),"data-mce-color":"#"+m};if(!d.isIE){i.role="option"}g=c.add(g,"a",i);if(p.editor.forcedHighContrastMode){g=c.add(g,"canvas",{width:16,height:16,"aria-hidden":"true"});if(g.getContext&&(f=g.getContext("2d"))){f.fillStyle="#"+m;f.fillRect(0,0,16,16)}else{c.remove(g)}}});if(q.more_colors_func){g=c.add(j,"tr");g=c.add(g,"td",{colspan:q.grid_width,"class":"mceMoreColors"});g=c.add(g,"a",{role:"option",id:p.id+"_more",href:"javascript:;",onclick:"return false;","class":"mceMoreColors"},q.more_colors_title);a.add(g,"click",function(i){q.more_colors_func.call(q.more_colors_scope||this);return a.cancel(i)})}c.addClass(h,"mceColorSplitMenu");a.add(p.id+"_menu","mousedown",function(i){return a.cancel(i)});a.add(p.id+"_menu","click",function(i){var m;i=c.getParent(i.target,"a",j);if(i&&i.nodeName.toLowerCase()=="a"&&(m=i.getAttribute("data-mce-color"))){p.setColor(m)}return false});return o},setColor:function(f){this.displayColor(f);this.hideMenu();this.settings.onselect(f)},displayColor:function(g){var f=this;c.setStyle(f.id+"_preview","backgroundColor",g);f.value=g},postRender:function(){var f=this,g=f.id;f.parent();c.add(g+"_action","div",{id:g+"_preview","class":"mceColorPreview"});c.setStyle(f.id+"_preview","backgroundColor",f.value)},destroy:function(){var f=this;f.parent();a.clear(f.id+"_menu");a.clear(f.id+"_more");c.remove(f.id+"_menu");if(f.keyboardNav){f.keyboardNav.destroy()}}})})(tinymce);(function(b){var d=b.DOM,c=b.each,a=b.dom.Event;b.create("tinymce.ui.ToolbarGroup:tinymce.ui.Container",{renderHTML:function(){var f=this,i=[],e=f.controls,j=b.each,g=f.settings;i.push('<div id="'+f.id+'" role="group" aria-labelledby="'+f.id+'_voice">');i.push("<span role='application'>");i.push('<span id="'+f.id+'_voice" class="mceVoiceLabel" style="display:none;">'+d.encode(g.name)+"</span>");j(e,function(h){i.push(h.renderHTML())});i.push("</span>");i.push("</div>");return i.join("")},focus:function(){var e=this;d.get(e.id).focus()},postRender:function(){var f=this,e=[];c(f.controls,function(g){c(g.controls,function(h){if(h.id){e.push(h)}})});f.keyNav=new b.ui.KeyboardNavigation({root:f.id,items:e,onCancel:function(){if(b.isWebKit){d.get(f.editor.id+"_ifr").focus()}f.editor.focus()},excludeFromTabOrder:!f.settings.tab_focus_toolbar})},destroy:function(){var e=this;e.parent();e.keyNav.destroy();a.clear(e.id)}})})(tinymce);(function(a){var c=a.DOM,b=a.each;a.create("tinymce.ui.Toolbar:tinymce.ui.Container",{renderHTML:function(){var m=this,f="",j,k,n=m.settings,e,d,g,l;l=m.controls;for(e=0;e<l.length;e++){k=l[e];d=l[e-1];g=l[e+1];if(e===0){j="mceToolbarStart";if(k.Button){j+=" mceToolbarStartButton"}else{if(k.SplitButton){j+=" mceToolbarStartSplitButton"}else{if(k.ListBox){j+=" mceToolbarStartListBox"}}}f+=c.createHTML("td",{"class":j},c.createHTML("span",null,"<!-- IE -->"))}if(d&&k.ListBox){if(d.Button||d.SplitButton){f+=c.createHTML("td",{"class":"mceToolbarEnd"},c.createHTML("span",null,"<!-- IE -->"))}}if(c.stdMode){f+='<td style="position: relative">'+k.renderHTML()+"</td>"}else{f+="<td>"+k.renderHTML()+"</td>"}if(g&&k.ListBox){if(g.Button||g.SplitButton){f+=c.createHTML("td",{"class":"mceToolbarStart"},c.createHTML("span",null,"<!-- IE -->"))}}}j="mceToolbarEnd";if(k.Button){j+=" mceToolbarEndButton"}else{if(k.SplitButton){j+=" mceToolbarEndSplitButton"}else{if(k.ListBox){j+=" mceToolbarEndListBox"}}}f+=c.createHTML("td",{"class":j},c.createHTML("span",null,"<!-- IE -->"));return c.createHTML("table",{id:m.id,"class":"mceToolbar"+(n["class"]?" "+n["class"]:""),cellpadding:"0",cellspacing:"0",align:m.settings.align||"",role:"presentation",tabindex:"-1"},"<tbody><tr>"+f+"</tr></tbody>")}})})(tinymce);(function(b){var a=b.util.Dispatcher,c=b.each;b.create("tinymce.AddOnManager",{AddOnManager:function(){var d=this;d.items=[];d.urls={};d.lookup={};d.onAdd=new a(d)},get:function(d){if(this.lookup[d]){return this.lookup[d].instance}else{return undefined}},dependencies:function(e){var d;if(this.lookup[e]){d=this.lookup[e].dependencies}return d||[]},requireLangPack:function(e){var d=b.settings;if(d&&d.language&&d.language_load!==false){b.ScriptLoader.add(this.urls[e]+"/langs/"+d.language+".js")}},add:function(f,e,d){this.items.push(e);this.lookup[f]={instance:e,dependencies:d};this.onAdd.dispatch(this,f,e);return e},createUrl:function(d,e){if(typeof e==="object"){return e}else{return{prefix:d.prefix,resource:e,suffix:d.suffix}}},addComponents:function(f,d){var e=this.urls[f];b.each(d,function(g){b.ScriptLoader.add(e+"/"+g)})},load:function(j,f,d,h){var g=this,e=f;function i(){var k=g.dependencies(j);b.each(k,function(m){var l=g.createUrl(f,m);g.load(l.resource,l,undefined,undefined)});if(d){if(h){d.call(h)}else{d.call(b.ScriptLoader)}}}if(g.urls[j]){return}if(typeof f==="object"){e=f.prefix+f.resource+f.suffix}if(e.indexOf("/")!==0&&e.indexOf("://")==-1){e=b.baseURL+"/"+e}g.urls[j]=e.substring(0,e.lastIndexOf("/"));if(g.lookup[j]){i()}else{b.ScriptLoader.add(e,i,h)}}});b.PluginManager=new b.AddOnManager();b.ThemeManager=new b.AddOnManager()}(tinymce));(function(j){var g=j.each,d=j.extend,k=j.DOM,i=j.dom.Event,f=j.ThemeManager,b=j.PluginManager,e=j.explode,h=j.util.Dispatcher,a,c=0;j.documentBaseURL=window.location.href.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,"");if(!/[\/\\]$/.test(j.documentBaseURL)){j.documentBaseURL+="/"}j.baseURL=new j.util.URI(j.documentBaseURL).toAbsolute(j.baseURL);j.baseURI=new j.util.URI(j.baseURL);j.onBeforeUnload=new h(j);i.add(window,"beforeunload",function(l){j.onBeforeUnload.dispatch(j,l)});j.onAddEditor=new h(j);j.onRemoveEditor=new h(j);j.EditorManager=d(j,{editors:[],i18n:{},activeEditor:null,init:function(x){var v=this,o,n=j.ScriptLoader,u,l=[],r;function q(t){var s=t.id;if(!s){s=t.name;if(s&&!k.get(s)){s=t.name}else{s=k.uniqueId()}t.setAttribute("id",s)}return s}function m(z,A,t){var y=z[A];if(!y){return}if(j.is(y,"string")){t=y.replace(/\.\w+$/,"");t=t?j.resolve(t):0;y=j.resolve(y)}return y.apply(t||this,Array.prototype.slice.call(arguments,2))}function p(t,s){return s.constructor===RegExp?s.test(t.className):k.hasClass(t,s)}v.settings=x;i.bind(window,"ready",function(){var s,t;m(x,"onpageload");switch(x.mode){case"exact":s=x.elements||"";if(s.length>0){g(e(s),function(y){if(k.get(y)){r=new j.Editor(y,x);l.push(r);r.render(1)}else{g(document.forms,function(z){g(z.elements,function(A){if(A.name===y){y="mce_editor_"+c++;k.setAttrib(A,"id",y);r=new j.Editor(y,x);l.push(r);r.render(1)}})})}})}break;case"textareas":case"specific_textareas":g(k.select("textarea"),function(y){if(x.editor_deselector&&p(y,x.editor_deselector)){return}if(!x.editor_selector||p(y,x.editor_selector)){r=new j.Editor(q(y),x);l.push(r);r.render(1)}});break;default:if(x.types){g(x.types,function(y){g(k.select(y.selector),function(A){var z=new j.Editor(q(A),j.extend({},x,y));l.push(z);z.render(1)})})}else{if(x.selector){g(k.select(x.selector),function(z){var y=new j.Editor(q(z),x);l.push(y);y.render(1)})}}}if(x.oninit){s=t=0;g(l,function(y){t++;if(!y.initialized){y.onInit.add(function(){s++;if(s==t){m(x,"oninit")}})}else{s++}if(s==t){m(x,"oninit")}})}})},get:function(l){if(l===a){return this.editors}if(!this.editors.hasOwnProperty(l)){return a}return this.editors[l]},getInstanceById:function(l){return this.get(l)},add:function(m){var l=this,n=l.editors;n[m.id]=m;n.push(m);l._setActive(m);l.onAddEditor.dispatch(l,m);return m},remove:function(n){var m=this,l,o=m.editors;if(!o[n.id]){return null}delete o[n.id];for(l=0;l<o.length;l++){if(o[l]==n){o.splice(l,1);break}}if(m.activeEditor==n){m._setActive(o[0])}n.destroy();m.onRemoveEditor.dispatch(m,n);return n},execCommand:function(r,p,o){var q=this,n=q.get(o),l;function m(){n.destroy();l.detachEvent("onunload",m);l=l.tinyMCE=l.tinymce=null}switch(r){case"mceFocus":n.focus();return true;case"mceAddEditor":case"mceAddControl":if(!q.get(o)){new j.Editor(o,q.settings).render()}return true;case"mceAddFrameControl":l=o.window;l.tinyMCE=tinyMCE;l.tinymce=j;j.DOM.doc=l.document;j.DOM.win=l;n=new j.Editor(o.element_id,o);n.render();if(j.isIE&&!j.isIE11){l.attachEvent("onunload",m)}o.page_window=null;return true;case"mceRemoveEditor":case"mceRemoveControl":if(n){n.remove()}return true;case"mceToggleEditor":if(!n){q.execCommand("mceAddControl",0,o);return true}if(n.isHidden()){n.show()}else{n.hide()}return true}if(q.activeEditor){return q.activeEditor.execCommand(r,p,o)}return false},execInstanceCommand:function(p,o,n,m){var l=this.get(p);if(l){return l.execCommand(o,n,m)}return false},triggerSave:function(){g(this.editors,function(l){l.save()})},addI18n:function(n,q){var l,m=this.i18n;if(!j.is(n,"string")){g(n,function(r,p){g(r,function(t,s){g(t,function(v,u){if(s==="common"){m[p+"."+u]=v}else{m[p+"."+s+"."+u]=v}})})})}else{g(q,function(r,p){m[n+"."+p]=r})}},_setActive:function(l){this.selectedInstance=this.activeEditor=l}})})(tinymce);(function(k){var l=k.DOM,j=k.dom.Event,f=k.extend,i=k.each,a=k.isGecko,b=k.isIE,e=k.isWebKit,d=k.is,h=k.ThemeManager,c=k.PluginManager,g=k.explode;k.create("tinymce.Editor",{Editor:function(p,o){var m=this,n=true;m.settings=o=f({id:p,language:"en",theme:"advanced",skin:"default",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:k.documentBaseURL,add_form_submit_trigger:n,submit_patch:n,add_unload_trigger:n,convert_urls:n,relative_urls:n,remove_script_host:n,table_inline_editing:false,object_resizing:n,accessibility_focus:n,doctype:k.isIE6?'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">':"<!DOCTYPE>",visual:n,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",font_size_legacy_values:"xx-small,small,medium,large,x-large,xx-large,300%",apply_source_formatting:n,directionality:"ltr",forced_root_block:"p",hidden_input:n,padd_empty_editor:n,render_ui:n,indentation:"30px",fix_table_elements:n,inline_styles:n,convert_fonts_to_spans:n,indent:"simple",indent_before:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,ul,li,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist",indent_after:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,ul,li,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist",validate:n,entity_encoding:"named",url_converter:m.convertURL,url_converter_scope:m,ie7_compat:n},o);m.id=m.editorId=p;m.isNotDirty=false;m.plugins={};m.documentBaseURI=new k.util.URI(o.document_base_url||k.documentBaseURL,{base_uri:tinyMCE.baseURI});m.baseURI=k.baseURI;m.contentCSS=[];m.contentStyles=[];m.setupEvents();m.execCommands={};m.queryStateCommands={};m.queryValueCommands={};m.execCallback("setup",m)},render:function(o){var p=this,q=p.settings,r=p.id,m=k.ScriptLoader;if(!j.domLoaded){j.add(window,"ready",function(){p.render()});return}tinyMCE.settings=q;if(!p.getElement()){return}if(k.isIDevice&&!k.isIOS5){return}if(!/TEXTAREA|INPUT/i.test(p.getElement().nodeName)&&q.hidden_input&&l.getParent(r,"form")){l.insertAfter(l.create("input",{type:"hidden",name:r}),r)}if(!q.content_editable){p.orgVisibility=p.getElement().style.visibility;p.getElement().style.visibility="hidden"}if(k.WindowManager){p.windowManager=new k.WindowManager(p)}if(q.encoding=="xml"){p.onGetContent.add(function(s,t){if(t.save){t.content=l.encode(t.content)}})}if(q.add_form_submit_trigger){p.onSubmit.addToTop(function(){if(p.initialized){p.save();p.isNotDirty=1}})}if(q.add_unload_trigger){p._beforeUnload=tinyMCE.onBeforeUnload.add(function(){if(p.initialized&&!p.destroyed&&!p.isHidden()){p.save({format:"raw",no_events:true})}})}k.addUnload(p.destroy,p);if(q.submit_patch){p.onBeforeRenderUI.add(function(){var s=p.getElement().form;if(!s){return}if(s._mceOldSubmit){return}if(!s.submit.nodeType&&!s.submit.length){p.formElement=s;s._mceOldSubmit=s.submit;s.submit=function(){k.triggerSave();p.isNotDirty=1;return p.formElement._mceOldSubmit(p.formElement)}}s=null})}function n(){if(q.language&&q.language_load!==false){m.add(k.baseURL+"/langs/"+q.language+".js")}if(q.theme&&typeof q.theme!="function"&&q.theme.charAt(0)!="-"&&!h.urls[q.theme]){h.load(q.theme,"themes/"+q.theme+"/editor_template"+k.suffix+".js")}i(g(q.plugins),function(t){if(t&&!c.urls[t]){if(t.charAt(0)=="-"){t=t.substr(1,t.length);var s=c.dependencies(t);i(s,function(v){var u={prefix:"plugins/",resource:v,suffix:"/editor_plugin"+k.suffix+".js"};v=c.createUrl(u,v);c.load(v.resource,v)})}else{if(t=="safari"){return}c.load(t,{prefix:"plugins/",resource:t,suffix:"/editor_plugin"+k.suffix+".js"})}}});m.loadQueue(function(){if(!p.removed){p.init()}})}n()},init:function(){var q,G=this,H=G.settings,D,y,z,C=G.getElement(),p,m,E,v,B,F,x,r=[];k.add(G);H.aria_label=H.aria_label||l.getAttrib(C,"aria-label",G.getLang("aria.rich_text_area"));if(H.theme){if(typeof H.theme!="function"){H.theme=H.theme.replace(/-/,"");p=h.get(H.theme);G.theme=new p();if(G.theme.init){G.theme.init(G,h.urls[H.theme]||k.documentBaseURL.replace(/\/$/,""))}}else{G.theme=H.theme}}function A(s){var t=c.get(s),o=c.urls[s]||k.documentBaseURL.replace(/\/$/,""),n;if(t&&k.inArray(r,s)===-1){i(c.dependencies(s),function(u){A(u)});n=new t(G,o);G.plugins[s]=n;if(n.init){n.init(G,o);r.push(s)}}}i(g(H.plugins.replace(/\-/g,"")),A);if(H.popup_css!==false){if(H.popup_css){H.popup_css=G.documentBaseURI.toAbsolute(H.popup_css)}else{H.popup_css=G.baseURI.toAbsolute("themes/"+H.theme+"/skins/"+H.skin+"/dialog.css")}}if(H.popup_css_add){H.popup_css+=","+G.documentBaseURI.toAbsolute(H.popup_css_add)}G.controlManager=new k.ControlManager(G);G.onBeforeRenderUI.dispatch(G,G.controlManager);if(H.render_ui&&G.theme){G.orgDisplay=C.style.display;if(typeof H.theme!="function"){D=H.width||C.style.width||C.offsetWidth;y=H.height||C.style.height||C.offsetHeight;z=H.min_height||100;F=/^[0-9\.]+(|px)$/i;if(F.test(""+D)){D=Math.max(parseInt(D,10)+(p.deltaWidth||0),100)}if(F.test(""+y)){y=Math.max(parseInt(y,10)+(p.deltaHeight||0),z)}p=G.theme.renderUI({targetNode:C,width:D,height:y,deltaWidth:H.delta_width,deltaHeight:H.delta_height});l.setStyles(p.sizeContainer||p.editorContainer,{width:D,height:y});y=(p.iframeHeight||y)+(typeof(y)=="number"?(p.deltaHeight||0):"");if(y<z){y=z}}else{p=H.theme(G,C);if(p.editorContainer.nodeType){p.editorContainer=p.editorContainer.id=p.editorContainer.id||G.id+"_parent"}if(p.iframeContainer.nodeType){p.iframeContainer=p.iframeContainer.id=p.iframeContainer.id||G.id+"_iframecontainer"}y=p.iframeHeight||C.offsetHeight;if(b){G.onInit.add(function(n){n.dom.bind(n.getBody(),"beforedeactivate keydown keyup",function(){n.bookmark=n.selection.getBookmark(1)})});G.onNodeChange.add(function(n){if(document.activeElement.id==n.id+"_ifr"){n.bookmark=n.selection.getBookmark(1)}})}}G.editorContainer=p.editorContainer}if(H.content_css){i(g(H.content_css),function(n){G.contentCSS.push(G.documentBaseURI.toAbsolute(n))})}if(H.content_style){G.contentStyles.push(H.content_style)}if(H.content_editable){C=q=p=null;return G.initContentBody()}if(document.domain&&location.hostname!=document.domain){k.relaxedDomain=document.domain}G.iframeHTML=H.doctype+'<html><head xmlns="http://www.w3.org/1999/xhtml">';if(H.document_base_url!=k.documentBaseURL){G.iframeHTML+='<base href="'+G.documentBaseURI.getURI()+'" />'}if(k.isIE8){if(H.ie7_compat){G.iframeHTML+='<meta http-equiv="X-UA-Compatible" content="IE=7" />'}else{G.iframeHTML+='<meta http-equiv="X-UA-Compatible" content="IE=edge" />'}}G.iframeHTML+='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';for(x=0;x<G.contentCSS.length;x++){G.iframeHTML+='<link type="text/css" rel="stylesheet" href="'+G.contentCSS[x]+'" />'}G.contentCSS=[];v=H.body_id||"tinymce";if(v.indexOf("=")!=-1){v=G.getParam("body_id","","hash");v=v[G.id]||v}B=H.body_class||"";if(B.indexOf("=")!=-1){B=G.getParam("body_class","","hash");B=B[G.id]||""}G.iframeHTML+='</head><body id="'+v+'" class="mceContentBody '+B+'" onload="window.parent.tinyMCE.get(\''+G.id+"').onLoad.dispatch();\"><br></body></html>";if(k.relaxedDomain&&(b||(k.isOpera&&parseFloat(opera.version())<11))){E='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinyMCE.get("'+G.id+'");document.write(ed.iframeHTML);document.close();ed.initContentBody();})()'}q=l.add(p.iframeContainer,"iframe",{id:G.id+"_ifr",src:E||'javascript:""',frameBorder:"0",allowTransparency:"true",title:H.aria_label,style:{width:"100%",height:y,display:"block"}});G.contentAreaContainer=p.iframeContainer;if(p.editorContainer){l.get(p.editorContainer).style.display=G.orgDisplay}C.style.visibility=G.orgVisibility;l.get(G.id).style.display="none";l.setAttrib(G.id,"aria-hidden",true);if(!k.relaxedDomain||!E){G.initContentBody()}C=q=p=null},initContentBody:function(){var n=this,p=n.settings,q=l.get(n.id),r=n.getDoc(),o,m,s;if((!b||!k.relaxedDomain)&&!p.content_editable){r.open();r.write(n.iframeHTML);r.close();if(k.relaxedDomain){r.domain=k.relaxedDomain}}if(p.content_editable){l.addClass(q,"mceContentBody");n.contentDocument=r=p.content_document||document;n.contentWindow=p.content_window||window;n.bodyElement=q;p.content_document=p.content_window=null}m=n.getBody();m.disabled=true;if(!p.readonly){m.contentEditable=n.getParam("content_editable_state",true)}m.disabled=false;n.schema=new k.html.Schema(p);n.dom=new k.dom.DOMUtils(r,{keep_values:true,url_converter:n.convertURL,url_converter_scope:n,hex_colors:p.force_hex_style_colors,class_filter:p.class_filter,update_styles:true,root_element:p.content_editable?n.id:null,schema:n.schema});n.parser=new k.html.DomParser(p,n.schema);n.parser.addAttributeFilter("src,href,style",function(t,u){var v=t.length,y,A=n.dom,z,x;while(v--){y=t[v];z=y.attr(u);x="data-mce-"+u;if(!y.attributes.map[x]){if(u==="style"){y.attr(x,A.serializeStyle(A.parseStyle(z),y.name))}else{y.attr(x,n.convertURL(z,u,y.name))}}}});n.parser.addNodeFilter("script",function(t,u){var v=t.length,x;while(v--){x=t[v];x.attr("type","mce-"+(x.attr("type")||"text/javascript"))}});n.parser.addNodeFilter("#cdata",function(t,u){var v=t.length,x;while(v--){x=t[v];x.type=8;x.name="#comment";x.value="[CDATA["+x.value+"]]"}});n.parser.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",function(u,v){var x=u.length,y,t=n.schema.getNonEmptyElements();while(x--){y=u[x];if(y.isEmpty(t)){y.empty().append(new k.html.Node("br",1)).shortEnded=true}}});n.serializer=new k.dom.Serializer(p,n.dom,n.schema);n.selection=new k.dom.Selection(n.dom,n.getWin(),n.serializer,n);n.formatter=new k.Formatter(n);n.undoManager=new k.UndoManager(n);n.forceBlocks=new k.ForceBlocks(n);n.enterKey=new k.EnterKey(n);n.editorCommands=new k.EditorCommands(n);n.onExecCommand.add(function(t,u){if(!/^(FontName|FontSize)$/.test(u)){n.nodeChanged()}});n.serializer.onPreProcess.add(function(t,u){return n.onPreProcess.dispatch(n,u,t)});n.serializer.onPostProcess.add(function(t,u){return n.onPostProcess.dispatch(n,u,t)});n.onPreInit.dispatch(n);if(!p.browser_spellcheck&&!p.gecko_spellcheck){r.body.spellcheck=false}if(!p.readonly){n.bindNativeEvents()}n.controlManager.onPostRender.dispatch(n,n.controlManager);n.onPostRender.dispatch(n);n.quirks=k.util.Quirks(n);if(p.directionality){m.dir=p.directionality}if(p.nowrap){m.style.whiteSpace="nowrap"}if(p.protect){n.onBeforeSetContent.add(function(t,u){i(p.protect,function(v){u.content=u.content.replace(v,function(x){return"<!--mce:protected "+escape(x)+"-->"})})})}n.onSetContent.add(function(){n.addVisual(n.getBody())});if(p.padd_empty_editor){n.onPostProcess.add(function(t,u){u.content=u.content.replace(/^(<p[^>]*>(&nbsp;|&#160;|\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/,"")})}n.load({initial:true,format:"html"});n.startContent=n.getContent({format:"raw"});n.initialized=true;n.onInit.dispatch(n);n.execCallback("setupcontent_callback",n.id,m,r);n.execCallback("init_instance_callback",n);n.focus(true);n.nodeChanged({initial:true});if(n.contentStyles.length>0){s="";i(n.contentStyles,function(t){s+=t+"\r\n"});n.dom.addStyle(s)}i(n.contentCSS,function(t){n.dom.loadCSS(t)});if(p.auto_focus){setTimeout(function(){var t=k.get(p.auto_focus);t.selection.select(t.getBody(),1);t.selection.collapse(1);t.getBody().focus();t.getWin().focus()},100)}q=r=m=null},focus:function(p){var o,u=this,t=u.selection,q=u.settings.content_editable,n,r,s=u.getDoc(),m;if(!p){if(u.bookmark){t.moveToBookmark(u.bookmark);u.bookmark=null}n=t.getRng();if(n.item){r=n.item(0)}u._refreshContentEditable();if(!q){u.getWin().focus()}if(k.isGecko||q){m=u.getBody();if(m.setActive&&!k.isIE11){m.setActive()}else{m.focus()}if(q){t.normalize()}}if(r&&r.ownerDocument==s){n=s.body.createControlRange();n.addElement(r);n.select()}}if(k.activeEditor!=u){if((o=k.activeEditor)!=null){o.onDeactivate.dispatch(o,u)}u.onActivate.dispatch(u,o)}k._setActive(u)},execCallback:function(q){var m=this,p=m.settings[q],o;if(!p){return}if(m.callbackLookup&&(o=m.callbackLookup[q])){p=o.func;o=o.scope}if(d(p,"string")){o=p.replace(/\.\w+$/,"");o=o?k.resolve(o):0;p=k.resolve(p);m.callbackLookup=m.callbackLookup||{};m.callbackLookup[q]={func:p,scope:o}}return p.apply(o||m,Array.prototype.slice.call(arguments,1))},translate:function(m){var o=this.settings.language||"en",n=k.i18n;if(!m){return""}return n[o+"."+m]||m.replace(/\{\#([^\}]+)\}/g,function(q,p){return n[o+"."+p]||"{#"+p+"}"})},getLang:function(o,m){return k.i18n[(this.settings.language||"en")+"."+o]||(d(m)?m:"{#"+o+"}")},getParam:function(t,q,m){var r=k.trim,p=d(this.settings[t])?this.settings[t]:q,s;if(m==="hash"){s={};if(d(p,"string")){i(p.indexOf("=")>0?p.split(/[;,](?![^=;,]*(?:[;,]|$))/):p.split(","),function(n){n=n.split("=");if(n.length>1){s[r(n[0])]=r(n[1])}else{s[r(n[0])]=r(n)}})}else{s=p}return s}return p},nodeChanged:function(q){var m=this,n=m.selection,p;if(m.initialized){q=q||{};p=n.getStart()||m.getBody();p=b&&p.ownerDocument!=m.getDoc()?m.getBody():p;q.parents=[];m.dom.getParent(p,function(o){if(o.nodeName=="BODY"){return true}q.parents.push(o)});m.onNodeChange.dispatch(m,q?q.controlManager||m.controlManager:m.controlManager,p,n.isCollapsed(),q)}},addButton:function(n,o){var m=this;m.buttons=m.buttons||{};m.buttons[n]=o},addCommand:function(m,o,n){this.execCommands[m]={func:o,scope:n||this}},addQueryStateHandler:function(m,o,n){this.queryStateCommands[m]={func:o,scope:n||this}},addQueryValueHandler:function(m,o,n){this.queryValueCommands[m]={func:o,scope:n||this}},addShortcut:function(o,q,m,p){var n=this,r;if(n.settings.custom_shortcuts===false){return false}n.shortcuts=n.shortcuts||{};if(d(m,"string")){r=m;m=function(){n.execCommand(r,false,null)}}if(d(m,"object")){r=m;m=function(){n.execCommand(r[0],r[1],r[2])}}i(g(o),function(s){var t={func:m,scope:p||this,desc:n.translate(q),alt:false,ctrl:false,shift:false};i(g(s,"+"),function(u){switch(u){case"alt":case"ctrl":case"shift":t[u]=true;break;default:t.charCode=u.charCodeAt(0);t.keyCode=u.toUpperCase().charCodeAt(0)}});n.shortcuts[(t.ctrl?"ctrl":"")+","+(t.alt?"alt":"")+","+(t.shift?"shift":"")+","+t.keyCode]=t});return true},execCommand:function(u,r,x,m){var p=this,q=0,v,n;if(!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(u)&&(!m||!m.skip_focus)){p.focus()}m=f({},m);p.onBeforeExecCommand.dispatch(p,u,r,x,m);if(m.terminate){return false}if(p.execCallback("execcommand_callback",p.id,p.selection.getNode(),u,r,x)){p.onExecCommand.dispatch(p,u,r,x,m);return true}if(v=p.execCommands[u]){n=v.func.call(v.scope,r,x);if(n!==true){p.onExecCommand.dispatch(p,u,r,x,m);return n}}i(p.plugins,function(o){if(o.execCommand&&o.execCommand(u,r,x)){p.onExecCommand.dispatch(p,u,r,x,m);q=1;return false}});if(q){return true}if(p.theme&&p.theme.execCommand&&p.theme.execCommand(u,r,x)){p.onExecCommand.dispatch(p,u,r,x,m);return true}if(p.editorCommands.execCommand(u,r,x)){p.onExecCommand.dispatch(p,u,r,x,m);return true}p.getDoc().execCommand(u,r,x);p.onExecCommand.dispatch(p,u,r,x,m)},queryCommandState:function(q){var n=this,r,p;if(n._isHidden()){return}if(r=n.queryStateCommands[q]){p=r.func.call(r.scope);if(p!==true){return p}}r=n.editorCommands.queryCommandState(q);if(r!==-1){return r}try{return this.getDoc().queryCommandState(q)}catch(m){}},queryCommandValue:function(r){var n=this,q,p;if(n._isHidden()){return}if(q=n.queryValueCommands[r]){p=q.func.call(q.scope);if(p!==true){return p}}q=n.editorCommands.queryCommandValue(r);if(d(q)){return q}try{return this.getDoc().queryCommandValue(r)}catch(m){}},show:function(){var m=this;l.show(m.getContainer());l.hide(m.id);m.load()},hide:function(){var m=this,n=m.getDoc();if(b&&n){n.execCommand("SelectAll")}m.save();l.hide(m.getContainer());l.setStyle(m.id,"display",m.orgDisplay)},isHidden:function(){return !l.isHidden(this.id)},setProgressState:function(m,n,p){this.onSetProgressState.dispatch(this,m,n,p);return m},load:function(q){var m=this,p=m.getElement(),n;if(p){q=q||{};q.load=true;n=m.setContent(d(p.value)?p.value:p.innerHTML,q);q.element=p;if(!q.no_events){m.onLoadContent.dispatch(m,q)}q.element=p=null;return n}},save:function(r){var m=this,q=m.getElement(),n,p;if(!q||!m.initialized){return}r=r||{};r.save=true;r.element=q;n=r.content=m.getContent(r);if(!r.no_events){m.onSaveContent.dispatch(m,r)}n=r.content;if(!/TEXTAREA|INPUT/i.test(q.nodeName)){q.innerHTML=n;if(p=l.getParent(m.id,"form")){i(p.elements,function(o){if(o.name==m.id){o.value=n;return false}})}}else{q.value=n}r.element=q=null;return n},setContent:function(r,p){var o=this,n,m=o.getBody(),q;p=p||{};p.format=p.format||"html";p.set=true;p.content=r;if(!p.no_events){o.onBeforeSetContent.dispatch(o,p)}r=p.content;if(!k.isIE&&(r.length===0||/^\s+$/.test(r))){q=o.settings.forced_root_block;if(q){r="<"+q+'><br data-mce-bogus="1"></'+q+">"}else{r='<br data-mce-bogus="1">'}m.innerHTML=r;o.selection.select(m,true);o.selection.collapse(true);return}if(p.format!=="raw"){r=new k.html.Serializer({},o.schema).serialize(o.parser.parse(r))}p.content=k.trim(r);o.dom.setHTML(m,p.content);if(!p.no_events){o.onSetContent.dispatch(o,p)}if(!o.settings.content_editable||document.activeElement===o.getBody()){o.selection.normalize()}return p.content},getContent:function(o){var n=this,p,m=n.getBody();o=o||{};o.format=o.format||"html";o.get=true;o.getInner=true;if(!o.no_events){n.onBeforeGetContent.dispatch(n,o)}if(o.format=="raw"){p=m.innerHTML}else{if(o.format=="text"){p=m.innerText||m.textContent}else{p=n.serializer.serialize(m,o)}}if(o.format!="text"){o.content=k.trim(p)}else{o.content=p}if(!o.no_events){n.onGetContent.dispatch(n,o)}return o.content},isDirty:function(){var m=this;return k.trim(m.startContent)!=k.trim(m.getContent({format:"raw",no_events:1}))&&!m.isNotDirty},getContainer:function(){var m=this;if(!m.container){m.container=l.get(m.editorContainer||m.id+"_parent")}return m.container},getContentAreaContainer:function(){return this.contentAreaContainer},getElement:function(){return l.get(this.settings.content_element||this.id)},getWin:function(){var m=this,n;if(!m.contentWindow){n=l.get(m.id+"_ifr");if(n){m.contentWindow=n.contentWindow}}return m.contentWindow},getDoc:function(){var m=this,n;if(!m.contentDocument){n=m.getWin();if(n){m.contentDocument=n.document}}return m.contentDocument},getBody:function(){return this.bodyElement||this.getDoc().body},convertURL:function(o,n,q){var m=this,p=m.settings;if(p.urlconverter_callback){return m.execCallback("urlconverter_callback",o,q,true,n)}if(!p.convert_urls||(q&&q.nodeName=="LINK")||o.indexOf("file:")===0){return o}if(p.relative_urls){return m.documentBaseURI.toRelative(o)}o=m.documentBaseURI.toAbsolute(o,p.remove_script_host);return o},addVisual:function(q){var n=this,o=n.settings,p=n.dom,m;q=q||n.getBody();if(!d(n.hasVisual)){n.hasVisual=o.visual}i(p.select("table,a",q),function(s){var r;switch(s.nodeName){case"TABLE":m=o.visual_table_class||"mceItemTable";r=p.getAttrib(s,"border");if(!r||r=="0"){if(n.hasVisual){p.addClass(s,m)}else{p.removeClass(s,m)}}return;case"A":if(!p.getAttrib(s,"href",false)){r=p.getAttrib(s,"name")||s.id;m="mceItemAnchor";if(r){if(n.hasVisual){p.addClass(s,m)}else{p.removeClass(s,m)}}}return}});n.onVisualAid.dispatch(n,q,n.hasVisual)},remove:function(){var m=this,o=m.getContainer(),n=m.getDoc();if(!m.removed){m.removed=1;if(b&&n){n.execCommand("SelectAll")}m.save();l.setStyle(m.id,"display",m.orgDisplay);if(!m.settings.content_editable){j.unbind(m.getWin());j.unbind(m.getDoc())}j.unbind(m.getBody());j.clear(o);m.execCallback("remove_instance_callback",m);m.onRemove.dispatch(m);m.onExecCommand.listeners=[];k.remove(m);l.remove(o)}},destroy:function(n){var m=this;if(m.destroyed){return}if(a){j.unbind(m.getDoc());j.unbind(m.getWin());j.unbind(m.getBody())}if(!n){k.removeUnload(m.destroy);tinyMCE.onBeforeUnload.remove(m._beforeUnload);if(m.theme&&m.theme.destroy){m.theme.destroy()}m.controlManager.destroy();m.selection.destroy();m.dom.destroy()}if(m.formElement){m.formElement.submit=m.formElement._mceOldSubmit;m.formElement._mceOldSubmit=null}m.contentAreaContainer=m.formElement=m.container=m.settings.content_element=m.bodyElement=m.contentDocument=m.contentWindow=null;if(m.selection){m.selection=m.selection.win=m.selection.dom=m.selection.dom.doc=null}m.destroyed=1},_refreshContentEditable:function(){var n=this,m,o;if(n._isHidden()){m=n.getBody();o=m.parentNode;o.removeChild(m);o.appendChild(m);m.focus()}},_isHidden:function(){var m;if(!a){return 0}m=this.selection.getSel();return(!m||!m.rangeCount||m.rangeCount===0)}})})(tinymce);(function(a){var b=a.each;a.Editor.prototype.setupEvents=function(){var c=this,d=c.settings;b(["onPreInit","onBeforeRenderUI","onPostRender","onLoad","onInit","onRemove","onActivate","onDeactivate","onClick","onEvent","onMouseUp","onMouseDown","onDblClick","onKeyDown","onKeyUp","onKeyPress","onContextMenu","onSubmit","onReset","onPaste","onPreProcess","onPostProcess","onBeforeSetContent","onBeforeGetContent","onSetContent","onGetContent","onLoadContent","onSaveContent","onNodeChange","onChange","onBeforeExecCommand","onExecCommand","onUndo","onRedo","onVisualAid","onSetProgressState","onSetAttrib"],function(e){c[e]=new a.util.Dispatcher(c)});if(d.cleanup_callback){c.onBeforeSetContent.add(function(e,f){f.content=e.execCallback("cleanup_callback","insert_to_editor",f.content,f)});c.onPreProcess.add(function(e,f){if(f.set){e.execCallback("cleanup_callback","insert_to_editor_dom",f.node,f)}if(f.get){e.execCallback("cleanup_callback","get_from_editor_dom",f.node,f)}});c.onPostProcess.add(function(e,f){if(f.set){f.content=e.execCallback("cleanup_callback","insert_to_editor",f.content,f)}if(f.get){f.content=e.execCallback("cleanup_callback","get_from_editor",f.content,f)}})}if(d.save_callback){c.onGetContent.add(function(e,f){if(f.save){f.content=e.execCallback("save_callback",e.id,f.content,e.getBody())}})}if(d.handle_event_callback){c.onEvent.add(function(f,g,h){if(c.execCallback("handle_event_callback",g,f,h)===false){g.preventDefault();g.stopPropagation()}})}if(d.handle_node_change_callback){c.onNodeChange.add(function(f,e,g){f.execCallback("handle_node_change_callback",f.id,g,-1,-1,true,f.selection.isCollapsed())})}if(d.save_callback){c.onSaveContent.add(function(e,g){var f=e.execCallback("save_callback",e.id,g.content,e.getBody());if(f){g.content=f}})}if(d.onchange_callback){c.onChange.add(function(f,e){f.execCallback("onchange_callback",f,e)})}};a.Editor.prototype.bindNativeEvents=function(){var l=this,f,d=l.settings,e=l.dom,h;h={mouseup:"onMouseUp",mousedown:"onMouseDown",click:"onClick",keyup:"onKeyUp",keydown:"onKeyDown",keypress:"onKeyPress",submit:"onSubmit",reset:"onReset",contextmenu:"onContextMenu",dblclick:"onDblClick",paste:"onPaste"};function c(i,m){var n=i.type;if(l.removed){return}if(l.onEvent.dispatch(l,i,m)!==false){l[h[i.fakeType||i.type]].dispatch(l,i,m)}}function j(i){l.focus(true)}function k(i,m){if(m.keyCode!=65||!a.VK.metaKeyPressed(m)){l.selection.normalize()}l.nodeChanged()}b(h,function(m,n){var i=d.content_editable?l.getBody():l.getDoc();switch(n){case"contextmenu":e.bind(i,n,c);break;case"paste":e.bind(l.getBody(),n,c);break;case"submit":case"reset":e.bind(l.getElement().form||a.DOM.getParent(l.id,"form"),n,c);break;default:e.bind(i,n,c)}});e.bind(d.content_editable?l.getBody():(a.isGecko?l.getDoc():l.getWin()),"focus",function(i){l.focus(true)});if(d.content_editable&&a.isOpera){e.bind(l.getBody(),"click",j);e.bind(l.getBody(),"keydown",j)}l.onMouseUp.add(k);l.onKeyUp.add(function(i,n){var m=n.keyCode;if((m>=33&&m<=36)||(m>=37&&m<=40)||m==13||m==45||m==46||m==8||(a.isMac&&(m==91||m==93))||n.ctrlKey){k(i,n)}});l.onReset.add(function(){l.setContent(l.startContent,{format:"raw"})});function g(m,i){if(m.altKey||m.ctrlKey||m.metaKey){b(l.shortcuts,function(n){var o=a.isMac?m.metaKey:m.ctrlKey;if(n.ctrl!=o||n.alt!=m.altKey||n.shift!=m.shiftKey){return}if(m.keyCode==n.keyCode||(m.charCode&&m.charCode==n.charCode)){m.preventDefault();if(i){n.func.call(n.scope)}return true}})}}l.onKeyUp.add(function(i,m){g(m)});l.onKeyPress.add(function(i,m){g(m)});l.onKeyDown.add(function(i,m){g(m,true)});if(a.isOpera){l.onClick.add(function(i,m){m.preventDefault()})}}})(tinymce);(function(d){var e=d.each,b,a=true,c=false;d.EditorCommands=function(n){var m=n.dom,p=n.selection,j={state:{},exec:{},value:{}},k=n.settings,q=n.formatter,o;function r(z,y,x){var v;z=z.toLowerCase();if(v=j.exec[z]){v(z,y,x);return a}return c}function l(x){var v;x=x.toLowerCase();if(v=j.state[x]){return v(x)}return -1}function h(x){var v;x=x.toLowerCase();if(v=j.value[x]){return v(x)}return c}function u(v,x){x=x||"exec";e(v,function(z,y){e(y.toLowerCase().split(","),function(A){j[x][A]=z})})}d.extend(this,{execCommand:r,queryCommandState:l,queryCommandValue:h,addCommands:u});function f(y,x,v){if(x===b){x=c}if(v===b){v=null}return n.getDoc().execCommand(y,x,v)}function t(v){return q.match(v)}function s(v,x){q.toggle(v,x?{value:x}:b)}function i(v){o=p.getBookmark(v)}function g(){p.moveToBookmark(o)}u({"mceResetDesignMode,mceBeginUndoLevel":function(){},"mceEndUndoLevel,mceAddUndoLevel":function(){n.undoManager.add()},"Cut,Copy,Paste":function(z){var y=n.getDoc(),v;try{f(z)}catch(x){v=a}if(v||!y.queryCommandSupported(z)){if(d.isGecko){n.windowManager.confirm(n.getLang("clipboard_msg"),function(A){if(A){open("http://www.mozilla.org/editor/midasdemo/securityprefs.html","_blank")}})}else{n.windowManager.alert(n.getLang("clipboard_no_support"))}}},unlink:function(v){if(p.isCollapsed()){p.select(p.getNode())}f(v);p.collapse(c)},"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(v){var x=v.substring(7);e("left,center,right,full".split(","),function(y){if(x!=y){q.remove("align"+y)}});s("align"+x);r("mceRepaint")},"InsertUnorderedList,InsertOrderedList":function(y){var v,x;f(y);v=m.getParent(p.getNode(),"ol,ul");if(v){x=v.parentNode;if(/^(H[1-6]|P|ADDRESS|PRE)$/.test(x.nodeName)){i();m.split(x,v);g()}}},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(v){s(v)},"ForeColor,HiliteColor,FontName":function(y,x,v){s(y,v)},FontSize:function(z,y,x){var v,A;if(x>=1&&x<=7){A=d.explode(k.font_size_style_values);v=d.explode(k.font_size_classes);if(v){x=v[x-1]||x}else{x=A[x-1]||x}}s(z,x)},RemoveFormat:function(v){q.remove(v)},mceBlockQuote:function(v){s("blockquote")},FormatBlock:function(y,x,v){return s(v||"p")},mceCleanup:function(){var v=p.getBookmark();n.setContent(n.getContent({cleanup:a}),{cleanup:a});p.moveToBookmark(v)},mceRemoveNode:function(z,y,x){var v=x||p.getNode();if(v!=n.getBody()){i();n.dom.remove(v,a);g()}},mceSelectNodeDepth:function(z,y,x){var v=0;m.getParent(p.getNode(),function(A){if(A.nodeType==1&&v++==x){p.select(A);return c}},n.getBody())},mceSelectNode:function(y,x,v){p.select(v)},mceInsertContent:function(B,I,K){var y,J,E,z,F,G,D,C,L,x,A,M,v,H;y=n.parser;J=new d.html.Serializer({},n.schema);v='<span id="mce_marker" data-mce-type="bookmark">\uFEFF</span>';G={content:K,format:"html"};p.onBeforeSetContent.dispatch(p,G);K=G.content;if(K.indexOf("{$caret}")==-1){K+="{$caret}"}K=K.replace(/\{\$caret\}/,v);if(!p.isCollapsed()){n.getDoc().execCommand("Delete",false,null)}E=p.getNode();G={context:E.nodeName.toLowerCase()};F=y.parse(K,G);A=F.lastChild;if(A.attr("id")=="mce_marker"){D=A;for(A=A.prev;A;A=A.walk(true)){if(A.type==3||!m.isBlock(A.name)){A.parent.insert(D,A,A.name==="br");break}}}if(!G.invalid){K=J.serialize(F);A=E.firstChild;M=E.lastChild;if(!A||(A===M&&A.nodeName==="BR")){m.setHTML(E,K)}else{p.setContent(K)}}else{p.setContent(v);E=p.getNode();z=n.getBody();if(E.nodeType==9){E=A=z}else{A=E}while(A!==z){E=A;A=A.parentNode}K=E==z?z.innerHTML:m.getOuterHTML(E);K=J.serialize(y.parse(K.replace(/<span (id="mce_marker"|id=mce_marker).+?<\/span>/i,function(){return J.serialize(F)})));if(E==z){m.setHTML(z,K)}else{m.setOuterHTML(E,K)}}D=m.get("mce_marker");C=m.getRect(D);L=m.getViewPort(n.getWin());if((C.y+C.h>L.y+L.h||C.y<L.y)||(C.x>L.x+L.w||C.x<L.x)){H=d.isIE?n.getDoc().documentElement:n.getBody();H.scrollLeft=C.x;H.scrollTop=C.y-L.h+25}x=m.createRng();A=D.previousSibling;if(A&&A.nodeType==3){x.setStart(A,A.nodeValue.length)}else{x.setStartBefore(D);x.setEndBefore(D)}m.remove(D);p.setRng(x);p.onSetContent.dispatch(p,G);n.addVisual()},mceInsertRawHTML:function(y,x,v){p.setContent("tiny_mce_marker");n.setContent(n.getContent().replace(/tiny_mce_marker/g,function(){return v}))},mceToggleFormat:function(y,x,v){s(v)},mceSetContent:function(y,x,v){n.setContent(v)},"Indent,Outdent":function(z){var x,v,y;x=k.indentation;v=/[a-z%]+$/i.exec(x);x=parseInt(x);if(!l("InsertUnorderedList")&&!l("InsertOrderedList")){if(!k.forced_root_block&&!m.getParent(p.getNode(),m.isBlock)){q.apply("div")}e(p.getSelectedBlocks(),function(A){if(z=="outdent"){y=Math.max(0,parseInt(A.style.paddingLeft||0)-x);m.setStyle(A,"paddingLeft",y?y+v:"")}else{m.setStyle(A,"paddingLeft",(parseInt(A.style.paddingLeft||0)+x)+v)}})}else{f(z)}},mceRepaint:function(){var x;if(d.isGecko){try{i(a);if(p.getSel()){p.getSel().selectAllChildren(n.getBody())}p.collapse(a);g()}catch(v){}}},mceToggleFormat:function(y,x,v){q.toggle(v)},InsertHorizontalRule:function(){n.execCommand("mceInsertContent",false,"<hr />")},mceToggleVisualAid:function(){n.hasVisual=!n.hasVisual;n.addVisual()},mceReplaceContent:function(y,x,v){n.execCommand("mceInsertContent",false,v.replace(/\{\$selection\}/g,p.getContent({format:"text"})))},mceInsertLink:function(z,y,x){var v;if(typeof(x)=="string"){x={href:x}}v=m.getParent(p.getNode(),"a");x.href=x.href.replace(" ","%20");if(!v||!x.href){q.remove("link")}if(x.href){q.apply("link",x,v)}},selectAll:function(){var x=m.getRoot(),v=m.createRng();if(p.getRng().setStart){v.setStart(x,0);v.setEnd(x,x.childNodes.length);p.setRng(v)}else{f("SelectAll")}}});u({"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(z){var x="align"+z.substring(7);var v=p.isCollapsed()?[m.getParent(p.getNode(),m.isBlock)]:p.getSelectedBlocks();var y=d.map(v,function(A){return !!q.matchNode(A,x)});return d.inArray(y,a)!==-1},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(v){return t(v)},mceBlockQuote:function(){return t("blockquote")},Outdent:function(){var v;if(k.inline_styles){if((v=m.getParent(p.getStart(),m.isBlock))&&parseInt(v.style.paddingLeft)>0){return a}if((v=m.getParent(p.getEnd(),m.isBlock))&&parseInt(v.style.paddingLeft)>0){return a}}return l("InsertUnorderedList")||l("InsertOrderedList")||(!k.inline_styles&&!!m.getParent(p.getNode(),"BLOCKQUOTE"))},"InsertUnorderedList,InsertOrderedList":function(x){var v=m.getParent(p.getNode(),"ul,ol");return v&&(x==="insertunorderedlist"&&v.tagName==="UL"||x==="insertorderedlist"&&v.tagName==="OL")}},"state");u({"FontSize,FontName":function(y){var x=0,v;if(v=m.getParent(p.getNode(),"span")){if(y=="fontsize"){x=v.style.fontSize}else{x=v.style.fontFamily.replace(/, /g,",").replace(/[\'\"]/g,"").toLowerCase()}}return x}},"value");u({Undo:function(){n.undoManager.undo()},Redo:function(){n.undoManager.redo()}})}})(tinymce);(function(b){var a=b.util.Dispatcher;b.UndoManager=function(h){var l,i=0,e=[],g,k,j,f;function c(){return b.trim(h.getContent({format:"raw",no_events:1}).replace(/<span[^>]+data-mce-bogus[^>]+>[\u200B\uFEFF]+<\/span>/g,""))}function d(){l.typing=false;l.add()}onBeforeAdd=new a(l);k=new a(l);j=new a(l);f=new a(l);k.add(function(m,n){if(m.hasUndo()){return h.onChange.dispatch(h,n,m)}});j.add(function(m,n){return h.onUndo.dispatch(h,n,m)});f.add(function(m,n){return h.onRedo.dispatch(h,n,m)});h.onInit.add(function(){l.add()});h.onBeforeExecCommand.add(function(m,p,o,q,n){if(p!="Undo"&&p!="Redo"&&p!="mceRepaint"&&(!n||!n.skip_undo)){l.beforeChange()}});h.onExecCommand.add(function(m,p,o,q,n){if(p!="Undo"&&p!="Redo"&&p!="mceRepaint"&&(!n||!n.skip_undo)){l.add()}});h.onSaveContent.add(d);h.dom.bind(h.dom.getRoot(),"dragend",d);h.dom.bind(h.getBody(),"focusout",function(m){if(!h.removed&&l.typing){d()}});h.onKeyUp.add(function(m,o){var n=o.keyCode;if((n>=33&&n<=36)||(n>=37&&n<=40)||n==45||n==13||o.ctrlKey){d()}});h.onKeyDown.add(function(m,o){var n=o.keyCode;if((n>=33&&n<=36)||(n>=37&&n<=40)||n==45){if(l.typing){d()}return}if((n<16||n>20)&&n!=224&&n!=91&&!l.typing){l.beforeChange();l.typing=true;l.add()}});h.onMouseDown.add(function(m,n){if(l.typing){d()}});h.addShortcut("ctrl+z","undo_desc","Undo");h.addShortcut("ctrl+y","redo_desc","Redo");l={data:e,typing:false,onBeforeAdd:onBeforeAdd,onAdd:k,onUndo:j,onRedo:f,beforeChange:function(){g=h.selection.getBookmark(2,true)},add:function(p){var m,n=h.settings,o;p=p||{};p.content=c();l.onBeforeAdd.dispatch(l,p);o=e[i];if(o&&o.content==p.content){return null}if(e[i]){e[i].beforeBookmark=g}if(n.custom_undo_redo_levels){if(e.length>n.custom_undo_redo_levels){for(m=0;m<e.length-1;m++){e[m]=e[m+1]}e.length--;i=e.length}}p.bookmark=h.selection.getBookmark(2,true);if(i<e.length-1){e.length=i+1}e.push(p);i=e.length-1;l.onAdd.dispatch(l,p);h.isNotDirty=0;return p},undo:function(){var n,m;if(l.typing){l.add();l.typing=false}if(i>0){n=e[--i];h.setContent(n.content,{format:"raw"});h.selection.moveToBookmark(n.beforeBookmark);l.onUndo.dispatch(l,n)}return n},redo:function(){var m;if(i<e.length-1){m=e[++i];h.setContent(m.content,{format:"raw"});h.selection.moveToBookmark(m.bookmark);l.onRedo.dispatch(l,m)}return m},clear:function(){e=[];i=0;l.typing=false},hasUndo:function(){return i>0||this.typing},hasRedo:function(){return i<e.length-1&&!this.typing}};return l}})(tinymce);tinymce.ForceBlocks=function(c){var b=c.settings,e=c.dom,a=c.selection,d=c.schema.getBlockElements();function f(){var j=a.getStart(),h=c.getBody(),g,k,o,s,q,i,l,m=-16777215,p,r;if(!j||j.nodeType!==1||!b.forced_root_block){return}while(j&&j!=h){if(d[j.nodeName]){return}j=j.parentNode}g=a.getRng();if(g.setStart){k=g.startContainer;o=g.startOffset;s=g.endContainer;q=g.endOffset}else{if(g.item){j=g.item(0);g=c.getDoc().body.createTextRange();g.moveToElementText(j)}r=g.parentElement().ownerDocument===c.getDoc();tmpRng=g.duplicate();tmpRng.collapse(true);o=tmpRng.move("character",m)*-1;if(!tmpRng.collapsed){tmpRng=g.duplicate();tmpRng.collapse(false);q=(tmpRng.move("character",m)*-1)-o}}j=h.firstChild;while(j){if(j.nodeType===3||(j.nodeType==1&&!d[j.nodeName])){if(j.nodeType===3&&j.nodeValue.length==0){l=j;j=j.nextSibling;e.remove(l);continue}if(!i){i=e.create(b.forced_root_block);j.parentNode.insertBefore(i,j);p=true}l=j;j=j.nextSibling;i.appendChild(l)}else{i=null;j=j.nextSibling}}if(p){if(g.setStart){g.setStart(k,o);g.setEnd(s,q);a.setRng(g)}else{if(r){try{g=c.getDoc().body.createTextRange();g.moveToElementText(h);g.collapse(true);g.moveStart("character",o);if(q>0){g.moveEnd("character",q)}g.select()}catch(n){}}}c.nodeChanged()}}if(b.forced_root_block){c.onKeyUp.add(f);c.onNodeChange.add(f)}};(function(c){var b=c.DOM,a=c.dom.Event,d=c.each,e=c.extend;c.create("tinymce.ControlManager",{ControlManager:function(f,j){var h=this,g;j=j||{};h.editor=f;h.controls={};h.onAdd=new c.util.Dispatcher(h);h.onPostRender=new c.util.Dispatcher(h);h.prefix=j.prefix||f.id+"_";h._cls={};h.onPostRender.add(function(){d(h.controls,function(i){i.postRender()})})},get:function(f){return this.controls[this.prefix+f]||this.controls[f]},setActive:function(h,f){var g=null;if(g=this.get(h)){g.setActive(f)}return g},setDisabled:function(h,f){var g=null;if(g=this.get(h)){g.setDisabled(f)}return g},add:function(g){var f=this;if(g){f.controls[g.id]=g;f.onAdd.dispatch(g,f)}return g},createControl:function(j){var o,k,g,h=this,m=h.editor,n,f;if(!h.controlFactories){h.controlFactories=[];d(m.plugins,function(i){if(i.createControl){h.controlFactories.push(i)}})}n=h.controlFactories;for(k=0,g=n.length;k<g;k++){o=n[k].createControl(j,h);if(o){return h.add(o)}}if(j==="|"||j==="separator"){return h.createSeparator()}if(m.buttons&&(o=m.buttons[j])){return h.createButton(j,o)}return h.add(o)},createDropMenu:function(f,n,h){var m=this,i=m.editor,j,g,k,l;n=e({"class":"mceDropDown",constrain:i.settings.constrain_menus},n);n["class"]=n["class"]+" "+i.getParam("skin")+"Skin";if(k=i.getParam("skin_variant")){n["class"]+=" "+i.getParam("skin")+"Skin"+k.substring(0,1).toUpperCase()+k.substring(1)}n["class"]+=i.settings.directionality=="rtl"?" mceRtl":"";f=m.prefix+f;l=h||m._cls.dropmenu||c.ui.DropMenu;j=m.controls[f]=new l(f,n);j.onAddItem.add(function(r,q){var p=q.settings;p.title=i.getLang(p.title,p.title);if(!p.onclick){p.onclick=function(o){if(p.cmd){i.execCommand(p.cmd,p.ui||false,p.value)}}}});i.onRemove.add(function(){j.destroy()});if(c.isIE){j.onShowMenu.add(function(){i.focus();g=i.selection.getBookmark(1)});j.onHideMenu.add(function(){if(g){i.selection.moveToBookmark(g);g=0}})}return m.add(j)},createListBox:function(f,n,h){var l=this,j=l.editor,i,k,m;if(l.get(f)){return null}n.title=j.translate(n.title);n.scope=n.scope||j;if(!n.onselect){n.onselect=function(o){j.execCommand(n.cmd,n.ui||false,o||n.value)}}n=e({title:n.title,"class":"mce_"+f,scope:n.scope,control_manager:l},n);f=l.prefix+f;function g(o){return o.settings.use_accessible_selects&&!c.isGecko}if(j.settings.use_native_selects||g(j)){k=new c.ui.NativeListBox(f,n)}else{m=h||l._cls.listbox||c.ui.ListBox;k=new m(f,n,j)}l.controls[f]=k;if(c.isWebKit){k.onPostRender.add(function(p,o){a.add(o,"mousedown",function(){j.bookmark=j.selection.getBookmark(1)});a.add(o,"focus",function(){j.selection.moveToBookmark(j.bookmark);j.bookmark=null})})}if(k.hideMenu){j.onMouseDown.add(k.hideMenu,k)}return l.add(k)},createButton:function(m,i,l){var h=this,g=h.editor,j,k,f;if(h.get(m)){return null}i.title=g.translate(i.title);i.label=g.translate(i.label);i.scope=i.scope||g;if(!i.onclick&&!i.menu_button){i.onclick=function(){g.execCommand(i.cmd,i.ui||false,i.value)}}i=e({title:i.title,"class":"mce_"+m,unavailable_prefix:g.getLang("unavailable",""),scope:i.scope,control_manager:h},i);m=h.prefix+m;if(i.menu_button){f=l||h._cls.menubutton||c.ui.MenuButton;k=new f(m,i,g);g.onMouseDown.add(k.hideMenu,k)}else{f=h._cls.button||c.ui.Button;k=new f(m,i,g)}return h.add(k)},createMenuButton:function(h,f,g){f=f||{};f.menu_button=1;return this.createButton(h,f,g)},createSplitButton:function(m,i,l){var h=this,g=h.editor,j,k,f;if(h.get(m)){return null}i.title=g.translate(i.title);i.scope=i.scope||g;if(!i.onclick){i.onclick=function(n){g.execCommand(i.cmd,i.ui||false,n||i.value)}}if(!i.onselect){i.onselect=function(n){g.execCommand(i.cmd,i.ui||false,n||i.value)}}i=e({title:i.title,"class":"mce_"+m,scope:i.scope,control_manager:h},i);m=h.prefix+m;f=l||h._cls.splitbutton||c.ui.SplitButton;k=h.add(new f(m,i,g));g.onMouseDown.add(k.hideMenu,k);return k},createColorSplitButton:function(f,n,h){var l=this,j=l.editor,i,k,m,g;if(l.get(f)){return null}n.title=j.translate(n.title);n.scope=n.scope||j;if(!n.onclick){n.onclick=function(o){if(c.isIE){g=j.selection.getBookmark(1)}j.execCommand(n.cmd,n.ui||false,o||n.value)}}if(!n.onselect){n.onselect=function(o){j.execCommand(n.cmd,n.ui||false,o||n.value)}}n=e({title:n.title,"class":"mce_"+f,menu_class:j.getParam("skin")+"Skin",scope:n.scope,more_colors_title:j.getLang("more_colors")},n);f=l.prefix+f;m=h||l._cls.colorsplitbutton||c.ui.ColorSplitButton;k=new m(f,n,j);j.onMouseDown.add(k.hideMenu,k);j.onRemove.add(function(){k.destroy()});if(c.isIE){k.onShowMenu.add(function(){j.focus();g=j.selection.getBookmark(1)});k.onHideMenu.add(function(){if(g){j.selection.moveToBookmark(g);g=0}})}return l.add(k)},createToolbar:function(k,h,j){var i,g=this,f;k=g.prefix+k;f=j||g._cls.toolbar||c.ui.Toolbar;i=new f(k,h,g.editor);if(g.get(k)){return null}return g.add(i)},createToolbarGroup:function(k,h,j){var i,g=this,f;k=g.prefix+k;f=j||this._cls.toolbarGroup||c.ui.ToolbarGroup;i=new f(k,h,g.editor);if(g.get(k)){return null}return g.add(i)},createSeparator:function(g){var f=g||this._cls.separator||c.ui.Separator;return new f()},setControlType:function(g,f){return this._cls[g.toLowerCase()]=f},destroy:function(){d(this.controls,function(f){f.destroy()});this.controls=null}})})(tinymce);(function(d){var a=d.util.Dispatcher,e=d.each,c=d.isIE,b=d.isOpera;d.create("tinymce.WindowManager",{WindowManager:function(f){var g=this;g.editor=f;g.onOpen=new a(g);g.onClose=new a(g);g.params={};g.features={}},open:function(z,h){var v=this,k="",n,m,i=v.editor.settings.dialog_type=="modal",q,o,j,g=d.DOM.getViewPort(),r;z=z||{};h=h||{};o=b?g.w:screen.width;j=b?g.h:screen.height;z.name=z.name||"mc_"+new Date().getTime();z.width=parseInt(z.width||320);z.height=parseInt(z.height||240);z.resizable=true;z.left=z.left||parseInt(o/2)-(z.width/2);z.top=z.top||parseInt(j/2)-(z.height/2);h.inline=false;h.mce_width=z.width;h.mce_height=z.height;h.mce_auto_focus=z.auto_focus;if(i){if(c){z.center=true;z.help=false;z.dialogWidth=z.width+"px";z.dialogHeight=z.height+"px";z.scroll=z.scrollbars||false}}e(z,function(p,f){if(d.is(p,"boolean")){p=p?"yes":"no"}if(!/^(name|url)$/.test(f)){if(c&&i){k+=(k?";":"")+f+":"+p}else{k+=(k?",":"")+f+"="+p}}});v.features=z;v.params=h;v.onOpen.dispatch(v,z,h);r=z.url||z.file;r=d._addVer(r);try{if(c&&i){q=1;window.showModalDialog(r,window,k)}else{q=window.open(r,z.name,k)}}catch(l){}if(!q){alert(v.editor.getLang("popup_blocked"))}},close:function(f){f.close();this.onClose.dispatch(this)},createInstance:function(i,h,g,m,l,k){var j=d.resolve(i);return new j(h,g,m,l,k)},confirm:function(h,f,i,g){g=g||window;f.call(i||this,g.confirm(this._decode(this.editor.getLang(h,h))))},alert:function(h,f,j,g){var i=this;g=g||window;g.alert(i._decode(i.editor.getLang(h,h)));if(f){f.call(j||i)}},resizeBy:function(f,g,h){h.resizeBy(f,g)},_decode:function(f){return d.DOM.decode(f).replace(/\\n/g,"\n")}})}(tinymce));(function(a){a.Formatter=function(aa){var Q={},T=a.each,c=aa.dom,r=aa.selection,t=a.dom.TreeWalker,N=new a.dom.RangeUtils(c),d=aa.schema.isValidChild,A=a.isArray,H=c.isBlock,m=aa.settings.forced_root_block,s=c.nodeIndex,G="\uFEFF",e=/^(src|href|style)$/,X=false,C=true,P,D,x=c.getContentEditable;function I(ab){if(ab.nodeType){ab=ab.nodeName}return !!aa.schema.getTextBlockElements()[ab.toLowerCase()]}function n(ac,ab){return c.getParents(ac,ab,c.getRoot())}function b(ab){return ab.nodeType===1&&ab.id==="_mce_caret"}function j(){l({alignleft:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"left"},defaultBlock:"div"},{selector:"img,table",collapsed:false,styles:{"float":"left"}}],aligncenter:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"center"},defaultBlock:"div"},{selector:"img",collapsed:false,styles:{display:"block",marginLeft:"auto",marginRight:"auto"}},{selector:"table",collapsed:false,styles:{marginLeft:"auto",marginRight:"auto"}}],alignright:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"right"},defaultBlock:"div"},{selector:"img,table",collapsed:false,styles:{"float":"right"}}],alignfull:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"justify"},defaultBlock:"div"}],bold:[{inline:"strong",remove:"all"},{inline:"span",styles:{fontWeight:"bold"}},{inline:"b",remove:"all"}],italic:[{inline:"em",remove:"all"},{inline:"span",styles:{fontStyle:"italic"}},{inline:"i",remove:"all"}],underline:[{inline:"span",styles:{textDecoration:"underline"},exact:true},{inline:"u",remove:"all"}],strikethrough:[{inline:"span",styles:{textDecoration:"line-through"},exact:true},{inline:"strike",remove:"all"}],forecolor:{inline:"span",styles:{color:"%value"},wrap_links:false},hilitecolor:{inline:"span",styles:{backgroundColor:"%value"},wrap_links:false},fontname:{inline:"span",styles:{fontFamily:"%value"}},fontsize:{inline:"span",styles:{fontSize:"%value"}},fontsize_class:{inline:"span",attributes:{"class":"%value"}},blockquote:{block:"blockquote",wrapper:1,remove:"all"},subscript:{inline:"sub"},superscript:{inline:"sup"},link:{inline:"a",selector:"a",remove:"all",split:true,deep:true,onmatch:function(ab){return true},onformat:function(ad,ab,ac){T(ac,function(af,ae){c.setAttrib(ad,ae,af)})}},removeformat:[{selector:"b,strong,em,i,font,u,strike",remove:"all",split:true,expand:false,block_expand:true,deep:true},{selector:"span",attributes:["style","class"],remove:"empty",split:true,expand:false,deep:true},{selector:"*",attributes:["style","class"],split:false,expand:false,deep:true}]});T("p h1 h2 h3 h4 h5 h6 div address pre div code dt dd samp".split(/\s/),function(ab){l(ab,{block:ab,remove:"all"})});l(aa.settings.formats)}function W(){aa.addShortcut("ctrl+b","bold_desc","Bold");aa.addShortcut("ctrl+i","italic_desc","Italic");aa.addShortcut("ctrl+u","underline_desc","Underline");for(var ab=1;ab<=6;ab++){aa.addShortcut("ctrl+"+ab,"",["FormatBlock",false,"h"+ab])}aa.addShortcut("ctrl+7","",["FormatBlock",false,"p"]);aa.addShortcut("ctrl+8","",["FormatBlock",false,"div"]);aa.addShortcut("ctrl+9","",["FormatBlock",false,"address"])}function V(ab){return ab?Q[ab]:Q}function l(ab,ac){if(ab){if(typeof(ab)!=="string"){T(ab,function(ae,ad){l(ad,ae)})}else{ac=ac.length?ac:[ac];T(ac,function(ad){if(ad.deep===D){ad.deep=!ad.selector}if(ad.split===D){ad.split=!ad.selector||ad.inline}if(ad.remove===D&&ad.selector&&!ad.inline){ad.remove="none"}if(ad.selector&&ad.inline){ad.mixed=true;ad.block_expand=true}if(typeof(ad.classes)==="string"){ad.classes=ad.classes.split(/\s+/)}});Q[ab]=ac}}}var i=function(ac){var ab;aa.dom.getParent(ac,function(ad){ab=aa.dom.getStyle(ad,"text-decoration");return ab&&ab!=="none"});return ab};var L=function(ab){var ac;if(ab.nodeType===1&&ab.parentNode&&ab.parentNode.nodeType===1){ac=i(ab.parentNode);if(aa.dom.getStyle(ab,"color")&&ac){aa.dom.setStyle(ab,"text-decoration",ac)}else{if(aa.dom.getStyle(ab,"textdecoration")===ac){aa.dom.setStyle(ab,"text-decoration",null)}}}};function Y(ae,al,ag){var ah=V(ae),am=ah[0],ak,ac,aj,ai=r.isCollapsed();function ab(aq,ap){ap=ap||am;if(aq){if(ap.onformat){ap.onformat(aq,ap,al,ag)}T(ap.styles,function(at,ar){c.setStyle(aq,ar,q(at,al))});T(ap.attributes,function(at,ar){c.setAttrib(aq,ar,q(at,al))});T(ap.classes,function(ar){ar=q(ar,al);if(!c.hasClass(aq,ar)){c.addClass(aq,ar)}})}}function af(){function ar(ay,aw){var ax=new t(aw);for(ag=ax.current();ag;ag=ax.prev()){if(ag.childNodes.length>1||ag==ay||ag.tagName=="BR"){return ag}}}var aq=aa.selection.getRng();var av=aq.startContainer;var ap=aq.endContainer;if(av!=ap&&aq.endOffset===0){var au=ar(av,ap);var at=au.nodeType==3?au.length:au.childNodes.length;aq.setEnd(au,at)}return aq}function ad(at,ay,aw,av,aq){var ap=[],ar=-1,ax,aA=-1,au=-1,az;T(at.childNodes,function(aC,aB){if(aC.nodeName==="UL"||aC.nodeName==="OL"){ar=aB;ax=aC;return false}});T(at.childNodes,function(aC,aB){if(aC.nodeName==="SPAN"&&c.getAttrib(aC,"data-mce-type")=="bookmark"){if(aC.id==ay.id+"_start"){aA=aB}else{if(aC.id==ay.id+"_end"){au=aB}}}});if(ar<=0||(aA<ar&&au>ar)){T(a.grep(at.childNodes),aq);return 0}else{az=c.clone(aw,X);T(a.grep(at.childNodes),function(aC,aB){if((aA<ar&&aB<ar)||(aA>ar&&aB>ar)){ap.push(aC);aC.parentNode.removeChild(aC)}});if(aA<ar){at.insertBefore(az,ax)}else{if(aA>ar){at.insertBefore(az,ax.nextSibling)}}av.push(az);T(ap,function(aB){az.appendChild(aB)});return az}}function an(aq,at,aw){var ap=[],av,ar,au=true;av=am.inline||am.block;ar=c.create(av);ab(ar);N.walk(aq,function(ax){var ay;function az(aA){var aF,aD,aB,aC,aE;aE=au;aF=aA.nodeName.toLowerCase();aD=aA.parentNode.nodeName.toLowerCase();if(aA.nodeType===1&&x(aA)){aE=au;au=x(aA)==="true";aC=true}if(g(aF,"br")){ay=0;if(am.block){c.remove(aA)}return}if(am.wrapper&&y(aA,ae,al)){ay=0;return}if(au&&!aC&&am.block&&!am.wrapper&&I(aF)){aA=c.rename(aA,av);ab(aA);ap.push(aA);ay=0;return}if(am.selector){T(ah,function(aG){if("collapsed" in aG&&aG.collapsed!==ai){return}if(c.is(aA,aG.selector)&&!b(aA)){ab(aA,aG);aB=true}});if(!am.inline||aB){ay=0;return}}if(au&&!aC&&d(av,aF)&&d(aD,av)&&!(!aw&&aA.nodeType===3&&aA.nodeValue.length===1&&aA.nodeValue.charCodeAt(0)===65279)&&!b(aA)&&(!am.inline||!H(aA))){if(!ay){ay=c.clone(ar,X);aA.parentNode.insertBefore(ay,aA);ap.push(ay)}ay.appendChild(aA)}else{if(aF=="li"&&at){ay=ad(aA,at,ar,ap,az)}else{ay=0;T(a.grep(aA.childNodes),az);if(aC){au=aE}ay=0}}}T(ax,az)});if(am.wrap_links===false){T(ap,function(ax){function ay(aC){var aB,aA,az;if(aC.nodeName==="A"){aA=c.clone(ar,X);ap.push(aA);az=a.grep(aC.childNodes);for(aB=0;aB<az.length;aB++){aA.appendChild(az[aB])}aC.appendChild(aA)}T(a.grep(aC.childNodes),ay)}ay(ax)})}T(ap,function(az){var ax;function aA(aC){var aB=0;T(aC.childNodes,function(aD){if(!f(aD)&&!K(aD)){aB++}});return aB}function ay(aB){var aD,aC;T(aB.childNodes,function(aE){if(aE.nodeType==1&&!K(aE)&&!b(aE)){aD=aE;return X}});if(aD&&h(aD,am)){aC=c.clone(aD,X);ab(aC);c.replace(aC,aB,C);c.remove(aD,1)}return aC||aB}ax=aA(az);if((ap.length>1||!H(az))&&ax===0){c.remove(az,1);return}if(am.inline||am.wrapper){if(!am.exact&&ax===1){az=ay(az)}T(ah,function(aB){T(c.select(aB.inline,az),function(aD){var aC;if(aB.wrap_links===false){aC=aD.parentNode;do{if(aC.nodeName==="A"){return}}while(aC=aC.parentNode)}Z(aB,al,aD,aB.exact?aD:null)})});if(y(az.parentNode,ae,al)){c.remove(az,1);az=0;return C}if(am.merge_with_parents){c.getParent(az.parentNode,function(aB){if(y(aB,ae,al)){c.remove(az,1);az=0;return C}})}if(az&&am.merge_siblings!==false){az=u(E(az),az);az=u(az,E(az,C))}}})}if(am){if(ag){if(ag.nodeType){ac=c.createRng();ac.setStartBefore(ag);ac.setEndAfter(ag);an(p(ac,ah),null,true)}else{an(ag,null,true)}}else{if(!ai||!am.inline||c.select("td.mceSelected,th.mceSelected").length){var ao=aa.selection.getNode();if(!m&&ah[0].defaultBlock&&!c.getParent(ao,c.isBlock)){Y(ah[0].defaultBlock)}aa.selection.setRng(af());ak=r.getBookmark();an(p(r.getRng(C),ah),ak);if(am.styles&&(am.styles.color||am.styles.textDecoration)){a.walk(ao,L,"childNodes");L(ao)}r.moveToBookmark(ak);R(r.getRng(C));aa.nodeChanged()}else{U("apply",ae,al)}}}}function B(ad,am,af){var ag=V(ad),ao=ag[0],ak,aj,ac,al=true;function ae(av){var au,at,ar,aq,ax,aw;if(av.nodeType===3){return}if(av.nodeType===1&&x(av)){ax=al;al=x(av)==="true";aw=true}au=a.grep(av.childNodes);if(al&&!aw){for(at=0,ar=ag.length;at<ar;at++){if(Z(ag[at],am,av,av)){break}}}if(ao.deep){if(au.length){for(at=0,ar=au.length;at<ar;at++){ae(au[at])}if(aw){al=ax}}}}function ah(aq){var ar;T(n(aq.parentNode).reverse(),function(at){var au;if(!ar&&at.id!="_start"&&at.id!="_end"){au=y(at,ad,am);if(au&&au.split!==false){ar=at}}});return ar}function ab(au,aq,aw,az){var aA,ay,ax,at,av,ar;if(au){ar=au.parentNode;for(aA=aq.parentNode;aA&&aA!=ar;aA=aA.parentNode){ay=c.clone(aA,X);for(av=0;av<ag.length;av++){if(Z(ag[av],am,ay,ay)){ay=0;break}}if(ay){if(ax){ay.appendChild(ax)}if(!at){at=ay}ax=ay}}if(az&&(!ao.mixed||!H(au))){aq=c.split(au,aq)}if(ax){aw.parentNode.insertBefore(ax,aw);at.appendChild(aw)}}return aq}function an(aq){return ab(ah(aq),aq,aq,true)}function ai(at){var ar=c.get(at?"_start":"_end"),aq=ar[at?"firstChild":"lastChild"];if(K(aq)){aq=aq[at?"firstChild":"lastChild"]}c.remove(ar,true);return aq}function ap(aq){var at,au,ar;aq=p(aq,ag,C);if(ao.split){at=M(aq,C);au=M(aq);if(at!=au){if(/^(TR|TD)$/.test(at.nodeName)&&at.firstChild){at=(at.nodeName=="TD"?at.firstChild:at.firstChild.firstChild)||at}at=S(at,"span",{id:"_start","data-mce-type":"bookmark"});au=S(au,"span",{id:"_end","data-mce-type":"bookmark"});an(at);an(au);at=ai(C);au=ai()}else{at=au=an(at)}aq.startContainer=at.parentNode;aq.startOffset=s(at);aq.endContainer=au.parentNode;aq.endOffset=s(au)+1}N.walk(aq,function(av){T(av,function(aw){ae(aw);if(aw.nodeType===1&&aa.dom.getStyle(aw,"text-decoration")==="underline"&&aw.parentNode&&i(aw.parentNode)==="underline"){Z({deep:false,exact:true,inline:"span",styles:{textDecoration:"underline"}},null,aw)}})})}if(af){if(af.nodeType){ac=c.createRng();ac.setStartBefore(af);ac.setEndAfter(af);ap(ac)}else{ap(af)}return}if(!r.isCollapsed()||!ao.inline||c.select("td.mceSelected,th.mceSelected").length){ak=r.getBookmark();ap(r.getRng(C));r.moveToBookmark(ak);if(ao.inline&&k(ad,am,r.getStart())){R(r.getRng(true))}aa.nodeChanged()}else{U("remove",ad,am)}}function F(ac,ae,ad){var ab=V(ac);if(k(ac,ae,ad)&&(!("toggle" in ab[0])||ab[0].toggle)){B(ac,ae,ad)}else{Y(ac,ae,ad)}}function y(ac,ab,ah,af){var ad=V(ab),ai,ag,ae;function aj(an,ap,aq){var am,ao,ak=ap[aq],al;if(ap.onmatch){return ap.onmatch(an,ap,aq)}if(ak){if(ak.length===D){for(am in ak){if(ak.hasOwnProperty(am)){if(aq==="attributes"){ao=c.getAttrib(an,am)}else{ao=O(an,am)}if(af&&!ao&&!ap.exact){return}if((!af||ap.exact)&&!g(ao,q(ak[am],ah))){return}}}}else{for(al=0;al<ak.length;al++){if(aq==="attributes"?c.getAttrib(an,ak[al]):O(an,ak[al])){return ap}}}}return ap}if(ad&&ac){for(ag=0;ag<ad.length;ag++){ai=ad[ag];if(h(ac,ai)&&aj(ac,ai,"attributes")&&aj(ac,ai,"styles")){if(ae=ai.classes){for(ag=0;ag<ae.length;ag++){if(!c.hasClass(ac,ae[ag])){return}}}return ai}}}}function k(ad,af,ae){var ac;function ab(ag){ag=c.getParent(ag,function(ah){return !!y(ah,ad,af,true)});return y(ag,ad,af)}if(ae){return ab(ae)}ae=r.getNode();if(ab(ae)){return C}ac=r.getStart();if(ac!=ae){if(ab(ac)){return C}}return X}function v(ai,ah){var af,ag=[],ae={},ad,ac,ab;af=r.getStart();c.getParent(af,function(al){var ak,aj;for(ak=0;ak<ai.length;ak++){aj=ai[ak];if(!ae[aj]&&y(al,aj,ah)){ae[aj]=true;ag.push(aj)}}},c.getRoot());return ag}function z(af){var ah=V(af),ae,ad,ag,ac,ab;if(ah){ae=r.getStart();ad=n(ae);for(ac=ah.length-1;ac>=0;ac--){ab=ah[ac].selector;if(!ab){return C}for(ag=ad.length-1;ag>=0;ag--){if(c.is(ad[ag],ab)){return C}}}}return X}function J(ab,ae,ac){var ad;if(!P){P={};ad={};aa.onNodeChange.addToTop(function(ag,af,ai){var ah=n(ai),aj={};T(P,function(ak,al){T(ah,function(am){if(y(am,al,{},ak.similar)){if(!ad[al]){T(ak,function(an){an(true,{node:am,format:al,parents:ah})});ad[al]=ak}aj[al]=ak;return false}})});T(ad,function(ak,al){if(!aj[al]){delete ad[al];T(ak,function(am){am(false,{node:ai,format:al,parents:ah})})}})})}T(ab.split(","),function(af){if(!P[af]){P[af]=[];P[af].similar=ac}P[af].push(ae)});return this}a.extend(this,{get:V,register:l,apply:Y,remove:B,toggle:F,match:k,matchAll:v,matchNode:y,canApply:z,formatChanged:J});j();W();function h(ab,ac){if(g(ab,ac.inline)){return C}if(g(ab,ac.block)){return C}if(ac.selector){return c.is(ab,ac.selector)}}function g(ac,ab){ac=ac||"";ab=ab||"";ac=""+(ac.nodeName||ac);ab=""+(ab.nodeName||ab);return ac.toLowerCase()==ab.toLowerCase()}function O(ac,ab){var ad=c.getStyle(ac,ab);if(ab=="color"||ab=="backgroundColor"){ad=c.toHex(ad)}if(ab=="fontWeight"&&ad==700){ad="bold"}return""+ad}function q(ab,ac){if(typeof(ab)!="string"){ab=ab(ac)}else{if(ac){ab=ab.replace(/%(\w+)/g,function(ae,ad){return ac[ad]||ae})}}return ab}function f(ab){return ab&&ab.nodeType===3&&/^([\t \r\n]+|)$/.test(ab.nodeValue)}function S(ad,ac,ab){var ae=c.create(ac,ab);ad.parentNode.insertBefore(ae,ad);ae.appendChild(ad);return ae}function p(ab,am,ae){var ap,an,ah,al,ad=ab.startContainer,ai=ab.startOffset,ar=ab.endContainer,ak=ab.endOffset;function ao(aA){var au,ax,az,aw,av,at;au=ax=aA?ad:ar;av=aA?"previousSibling":"nextSibling";at=c.getRoot();function ay(aB){return aB.nodeName=="BR"&&aB.getAttribute("data-mce-bogus")&&!aB.nextSibling}if(au.nodeType==3&&!f(au)){if(aA?ai>0:ak<au.nodeValue.length){return au}}for(;;){if(!am[0].block_expand&&H(ax)){return ax}for(aw=ax[av];aw;aw=aw[av]){if(!K(aw)&&!f(aw)&&!ay(aw)){return ax}}if(ax.parentNode==at){au=ax;break}ax=ax.parentNode}return au}function ag(at,au){if(au===D){au=at.nodeType===3?at.length:at.childNodes.length}while(at&&at.hasChildNodes()){at=at.childNodes[au];if(at){au=at.nodeType===3?at.length:at.childNodes.length}}return{node:at,offset:au}}if(ad.nodeType==1&&ad.hasChildNodes()){an=ad.childNodes.length-1;ad=ad.childNodes[ai>an?an:ai];if(ad.nodeType==3){ai=0}}if(ar.nodeType==1&&ar.hasChildNodes()){an=ar.childNodes.length-1;ar=ar.childNodes[ak>an?an:ak-1];if(ar.nodeType==3){ak=ar.nodeValue.length}}function aq(au){var at=au;while(at){if(at.nodeType===1&&x(at)){return x(at)==="false"?at:au}at=at.parentNode}return au}function aj(au,ay,aA){var ax,av,az,at;function aw(aC,aE){var aF,aB,aD=aC.nodeValue;if(typeof(aE)=="undefined"){aE=aA?aD.length:0}if(aA){aF=aD.lastIndexOf(" ",aE);aB=aD.lastIndexOf("\u00a0",aE);aF=aF>aB?aF:aB;if(aF!==-1&&!ae){aF++}}else{aF=aD.indexOf(" ",aE);aB=aD.indexOf("\u00a0",aE);aF=aF!==-1&&(aB===-1||aF<aB)?aF:aB}return aF}if(au.nodeType===3){az=aw(au,ay);if(az!==-1){return{container:au,offset:az}}at=au}ax=new t(au,c.getParent(au,H)||aa.getBody());while(av=ax[aA?"prev":"next"]()){if(av.nodeType===3){at=av;az=aw(av);if(az!==-1){return{container:av,offset:az}}}else{if(H(av)){break}}}if(at){if(aA){ay=0}else{ay=at.length}return{container:at,offset:ay}}}function af(au,at){var av,aw,ay,ax;if(au.nodeType==3&&au.nodeValue.length===0&&au[at]){au=au[at]}av=n(au);for(aw=0;aw<av.length;aw++){for(ay=0;ay<am.length;ay++){ax=am[ay];if("collapsed" in ax&&ax.collapsed!==ab.collapsed){continue}if(c.is(av[aw],ax.selector)){return av[aw]}}}return au}function ac(au,at,aw){var av;if(!am[0].wrapper){av=c.getParent(au,am[0].block)}if(!av){av=c.getParent(au.nodeType==3?au.parentNode:au,I)}if(av&&am[0].wrapper){av=n(av,"ul,ol").reverse()[0]||av}if(!av){av=au;while(av[at]&&!H(av[at])){av=av[at];if(g(av,"br")){break}}}return av||au}ad=aq(ad);ar=aq(ar);if(K(ad.parentNode)||K(ad)){ad=K(ad)?ad:ad.parentNode;ad=ad.nextSibling||ad;if(ad.nodeType==3){ai=0}}if(K(ar.parentNode)||K(ar)){ar=K(ar)?ar:ar.parentNode;ar=ar.previousSibling||ar;if(ar.nodeType==3){ak=ar.length}}if(am[0].inline){if(ab.collapsed){al=aj(ad,ai,true);if(al){ad=al.container;ai=al.offset}al=aj(ar,ak);if(al){ar=al.container;ak=al.offset}}ah=ag(ar,ak);if(ah.node){while(ah.node&&ah.offset===0&&ah.node.previousSibling){ah=ag(ah.node.previousSibling)}if(ah.node&&ah.offset>0&&ah.node.nodeType===3&&ah.node.nodeValue.charAt(ah.offset-1)===" "){if(ah.offset>1){ar=ah.node;ar.splitText(ah.offset-1)}}}}if(am[0].inline||am[0].block_expand){if(!am[0].inline||(ad.nodeType!=3||ai===0)){ad=ao(true)}if(!am[0].inline||(ar.nodeType!=3||ak===ar.nodeValue.length)){ar=ao()}}if(am[0].selector&&am[0].expand!==X&&!am[0].inline){ad=af(ad,"previousSibling");ar=af(ar,"nextSibling")}if(am[0].block||am[0].selector){ad=ac(ad,"previousSibling");ar=ac(ar,"nextSibling");if(am[0].block){if(!H(ad)){ad=ao(true)}if(!H(ar)){ar=ao()}}}if(ad.nodeType==1){ai=s(ad);ad=ad.parentNode}if(ar.nodeType==1){ak=s(ar)+1;ar=ar.parentNode}return{startContainer:ad,startOffset:ai,endContainer:ar,endOffset:ak}}function Z(ah,ag,ae,ab){var ad,ac,af;if(!h(ae,ah)){return X}if(ah.remove!="all"){T(ah.styles,function(aj,ai){aj=q(aj,ag);if(typeof(ai)==="number"){ai=aj;ab=0}if(!ab||g(O(ab,ai),aj)){c.setStyle(ae,ai,"")}af=1});if(af&&c.getAttrib(ae,"style")==""){ae.removeAttribute("style");ae.removeAttribute("data-mce-style")}T(ah.attributes,function(ak,ai){var aj;ak=q(ak,ag);if(typeof(ai)==="number"){ai=ak;ab=0}if(!ab||g(c.getAttrib(ab,ai),ak)){if(ai=="class"){ak=c.getAttrib(ae,ai);if(ak){aj="";T(ak.split(/\s+/),function(al){if(/mce\w+/.test(al)){aj+=(aj?" ":"")+al}});if(aj){c.setAttrib(ae,ai,aj);return}}}if(ai=="class"){ae.removeAttribute("className")}if(e.test(ai)){ae.removeAttribute("data-mce-"+ai)}ae.removeAttribute(ai)}});T(ah.classes,function(ai){ai=q(ai,ag);if(!ab||c.hasClass(ab,ai)){c.removeClass(ae,ai)}});ac=c.getAttribs(ae);for(ad=0;ad<ac.length;ad++){if(ac[ad].nodeName.indexOf("_")!==0){return X}}}if(ah.remove!="none"){o(ae,ah);return C}}function o(ad,ae){var ab=ad.parentNode,ac;function af(ah,ag,ai){ah=E(ah,ag,ai);return !ah||(ah.nodeName=="BR"||H(ah))}if(ae.block){if(!m){if(H(ad)&&!H(ab)){if(!af(ad,X)&&!af(ad.firstChild,C,1)){ad.insertBefore(c.create("br"),ad.firstChild)}if(!af(ad,C)&&!af(ad.lastChild,X,1)){ad.appendChild(c.create("br"))}}}else{if(ab==c.getRoot()){if(!ae.list_block||!g(ad,ae.list_block)){T(a.grep(ad.childNodes),function(ag){if(d(m,ag.nodeName.toLowerCase())){if(!ac){ac=S(ag,m)}else{ac.appendChild(ag)}}else{ac=0}})}}}}if(ae.selector&&ae.inline&&!g(ae.inline,ad)){return}c.remove(ad,1)}function E(ac,ab,ad){if(ac){ab=ab?"nextSibling":"previousSibling";for(ac=ad?ac:ac[ab];ac;ac=ac[ab]){if(ac.nodeType==1||!f(ac)){return ac}}}}function K(ab){return ab&&ab.nodeType==1&&ab.getAttribute("data-mce-type")=="bookmark"}function u(af,ae){var ab,ad,ac;function ah(ak,aj){if(ak.nodeName!=aj.nodeName){return X}function ai(am){var an={};T(c.getAttribs(am),function(ao){var ap=ao.nodeName.toLowerCase();if(ap.indexOf("_")!==0&&ap!=="style"){an[ap]=c.getAttrib(am,ap)}});return an}function al(ap,ao){var an,am;for(am in ap){if(ap.hasOwnProperty(am)){an=ao[am];if(an===D){return X}if(ap[am]!=an){return X}delete ao[am]}}for(am in ao){if(ao.hasOwnProperty(am)){return X}}return C}if(!al(ai(ak),ai(aj))){return X}if(!al(c.parseStyle(c.getAttrib(ak,"style")),c.parseStyle(c.getAttrib(aj,"style")))){return X}return C}function ag(aj,ai){for(ad=aj;ad;ad=ad[ai]){if(ad.nodeType==3&&ad.nodeValue.length!==0){return aj}if(ad.nodeType==1&&!K(ad)){return ad}}return aj}if(af&&ae){af=ag(af,"previousSibling");ae=ag(ae,"nextSibling");if(ah(af,ae)){for(ad=af.nextSibling;ad&&ad!=ae;){ac=ad;ad=ad.nextSibling;af.appendChild(ac)}c.remove(ae);T(a.grep(ae.childNodes),function(ai){af.appendChild(ai)});return af}}return ae}function M(ac,ag){var ab,af,ad,ae;ab=ac[ag?"startContainer":"endContainer"];af=ac[ag?"startOffset":"endOffset"];if(ab.nodeType==1){ad=ab.childNodes.length-1;if(!ag&&af){af--}ab=ab.childNodes[af>ad?ad:af]}if(ab.nodeType===3&&ag&&af>=ab.nodeValue.length){ab=new t(ab,aa.getBody()).next()||ab}if(ab.nodeType===3&&!ag&&af===0){ab=new t(ab,aa.getBody()).prev()||ab}return ab}function U(ak,ab,ai){var al="_mce_caret",ac=aa.settings.caret_debug;function ad(ap){var ao=c.create("span",{id:al,"data-mce-bogus":true,style:ac?"color:red":""});if(ap){ao.appendChild(aa.getDoc().createTextNode(G))}return ao}function aj(ap,ao){while(ap){if((ap.nodeType===3&&ap.nodeValue!==G)||ap.childNodes.length>1){return false}if(ao&&ap.nodeType===1){ao.push(ap)}ap=ap.firstChild}return true}function ag(ao){while(ao){if(ao.id===al){return ao}ao=ao.parentNode}}function af(ao){var ap;if(ao){ap=new t(ao,ao);for(ao=ap.current();ao;ao=ap.next()){if(ao.nodeType===3){return ao}}}}function ae(aq,ap){var ar,ao;if(!aq){aq=ag(r.getStart());if(!aq){while(aq=c.get(al)){ae(aq,false)}}}else{ao=r.getRng(true);if(aj(aq)){if(ap!==false){ao.setStartBefore(aq);ao.setEndBefore(aq)}c.remove(aq)}else{ar=af(aq);if(ar.nodeValue.charAt(0)===G){ar=ar.deleteData(0,1)}c.remove(aq,1)}r.setRng(ao)}}function ah(){var aq,ao,av,au,ar,ap,at;aq=r.getRng(true);au=aq.startOffset;ap=aq.startContainer;at=ap.nodeValue;ao=ag(r.getStart());if(ao){av=af(ao)}if(at&&au>0&&au<at.length&&/\w/.test(at.charAt(au))&&/\w/.test(at.charAt(au-1))){ar=r.getBookmark();aq.collapse(true);aq=p(aq,V(ab));aq=N.split(aq);Y(ab,ai,aq);r.moveToBookmark(ar)}else{if(!ao||av.nodeValue!==G){ao=ad(true);av=ao.firstChild;aq.insertNode(ao);au=1;Y(ab,ai,ao)}else{Y(ab,ai,ao)}r.setCursorLocation(av,au)}}function am(){var ao=r.getRng(true),ap,at,aw,av,aq,az,ay=[],au,ax;ap=ao.startContainer;at=ao.startOffset;aq=ap;if(ap.nodeType==3){if(at!=ap.nodeValue.length||ap.nodeValue===G){av=true}aq=aq.parentNode}while(aq){if(y(aq,ab,ai)){az=aq;break}if(aq.nextSibling){av=true}ay.push(aq);aq=aq.parentNode}if(!az){return}if(av){aw=r.getBookmark();ao.collapse(true);ao=p(ao,V(ab),true);ao=N.split(ao);B(ab,ai,ao);r.moveToBookmark(aw)}else{ax=ad();aq=ax;for(au=ay.length-1;au>=0;au--){aq.appendChild(c.clone(ay[au],false));aq=aq.firstChild}aq.appendChild(c.doc.createTextNode(G));aq=aq.firstChild;var ar=c.getParent(az,I);if(ar&&c.isEmpty(ar)){az.parentNode.replaceChild(ax,az)}else{c.insertAfter(ax,az)}r.setCursorLocation(aq,1);if(c.isEmpty(az)){c.remove(az)}}}function an(){var ap,ao,aq;ao=ag(r.getStart());if(ao&&!c.isEmpty(ao)){a.walk(ao,function(ar){if(ar.nodeType==1&&ar.id!==al&&!c.isEmpty(ar)){c.setAttrib(ar,"data-mce-bogus",null)}},"childNodes")}}if(!self._hasCaretEvents){aa.onBeforeGetContent.addToTop(function(){var ao=[],ap;if(aj(ag(r.getStart()),ao)){ap=ao.length;while(ap--){c.setAttrib(ao[ap],"data-mce-bogus","1")}}});a.each("onMouseUp onKeyUp".split(" "),function(ao){aa[ao].addToTop(function(){ae();an()})});aa.onKeyDown.addToTop(function(ao,aq){var ap=aq.keyCode;if(ap==8||ap==37||ap==39){ae(ag(r.getStart()))}an()});r.onSetContent.add(an);self._hasCaretEvents=true}if(ak=="apply"){ah()}else{am()}}function R(ac){var ab=ac.startContainer,ai=ac.startOffset,ae,ah,ag,ad,af;if(ab.nodeType==3&&ai>=ab.nodeValue.length){ai=s(ab);ab=ab.parentNode;ae=true}if(ab.nodeType==1){ad=ab.childNodes;ab=ad[Math.min(ai,ad.length-1)];ah=new t(ab,c.getParent(ab,c.isBlock));if(ai>ad.length-1||ae){ah.next()}for(ag=ah.current();ag;ag=ah.next()){if(ag.nodeType==3&&!f(ag)){af=c.create("a",null,G);ag.parentNode.insertBefore(af,ag);ac.setStart(ag,0);r.setRng(ac);c.remove(af);return}}}}}})(tinymce);tinymce.onAddEditor.add(function(e,a){var d,h,g,c=a.settings;function b(j,i){e.each(i,function(l,k){if(l){g.setStyle(j,k,l)}});g.rename(j,"span")}function f(i,j){g=i.dom;if(c.convert_fonts_to_spans){e.each(g.select("font,u,strike",j.node),function(k){d[k.nodeName.toLowerCase()](a.dom,k)})}}if(c.inline_styles){h=e.explode(c.font_size_legacy_values);d={font:function(j,i){b(i,{backgroundColor:i.style.backgroundColor,color:i.color,fontFamily:i.face,fontSize:h[parseInt(i.size,10)-1]})},u:function(j,i){b(i,{textDecoration:"underline"})},strike:function(j,i){b(i,{textDecoration:"line-through"})}};a.onPreProcess.add(f);a.onSetContent.add(f);a.onInit.add(function(){a.selection.onSetContent.add(f)})}});(function(b){var a=b.dom.TreeWalker;b.EnterKey=function(f){var i=f.dom,e=f.selection,d=f.settings,h=f.undoManager,c=f.schema.getNonEmptyElements();function g(B){var v=e.getRng(true),G,j,A,u,p,M,C,o,k,n,t,J,x,D;function E(N){return N&&i.isBlock(N)&&!/^(TD|TH|CAPTION|FORM)$/.test(N.nodeName)&&!/^(fixed|absolute)/i.test(N.style.position)&&i.getContentEditable(N)!=="true"}function F(O){var N;if(b.isIE&&!b.isIE11&&i.isBlock(O)){N=e.getRng();O.appendChild(i.create("span",null,"\u00a0"));e.select(O);O.lastChild.outerHTML="";e.setRng(N)}}function z(P){var O=P,Q=[],N;while(O=O.firstChild){if(i.isBlock(O)){return}if(O.nodeType==1&&!c[O.nodeName.toLowerCase()]){Q.push(O)}}N=Q.length;while(N--){O=Q[N];if(!O.hasChildNodes()||(O.firstChild==O.lastChild&&O.firstChild.nodeValue==="")){i.remove(O)}else{if(O.nodeName=="A"&&(O.innerText||O.textContent)===" "){i.remove(O)}}}}function m(O){var T,R,N,U,S,Q=O,P;N=i.createRng();if(O.hasChildNodes()){T=new a(O,O);while(R=T.current()){if(R.nodeType==3){N.setStart(R,0);N.setEnd(R,0);break}if(c[R.nodeName.toLowerCase()]){N.setStartBefore(R);N.setEndBefore(R);break}Q=R;R=T.next()}if(!R){N.setStart(Q,0);N.setEnd(Q,0)}}else{if(O.nodeName=="BR"){if(O.nextSibling&&i.isBlock(O.nextSibling)){if(!M||M<9){P=i.create("br");O.parentNode.insertBefore(P,O)}N.setStartBefore(O);N.setEndBefore(O)}else{N.setStartAfter(O);N.setEndAfter(O)}}else{N.setStart(O,0);N.setEnd(O,0)}}e.setRng(N);i.remove(P);S=i.getViewPort(f.getWin());U=i.getPos(O).y;if(U<S.y||U+25>S.y+S.h){f.getWin().scrollTo(0,U<S.y?U:U-S.h+25)}}function r(O){var P=A,R,Q,N;R=O||t=="TABLE"?i.create(O||x):p.cloneNode(false);N=R;if(d.keep_styles!==false){do{if(/^(SPAN|STRONG|B|EM|I|FONT|STRIKE|U)$/.test(P.nodeName)){if(P.id=="_mce_caret"){continue}Q=P.cloneNode(false);i.setAttrib(Q,"id","");if(R.hasChildNodes()){Q.appendChild(R.firstChild);R.appendChild(Q)}else{N=Q;R.appendChild(Q)}}}while(P=P.parentNode)}if(!b.isIE||b.isIE11){N.innerHTML='<br data-mce-bogus="1">'}return R}function q(Q){var P,O,N;if(A.nodeType==3&&(Q?u>0:u<A.nodeValue.length)){return false}if(A.parentNode==p&&D&&!Q){return true}if(Q&&A.nodeType==1&&A==p.firstChild){return true}if(A.nodeName==="TABLE"||(A.previousSibling&&A.previousSibling.nodeName=="TABLE")){return(D&&!Q)||(!D&&Q)}P=new a(A,p);if(A.nodeType==3){if(Q&&u==0){P.prev()}else{if(!Q&&u==A.nodeValue.length){P.next()}}}while(O=P.current()){if(O.nodeType===1){if(!O.getAttribute("data-mce-bogus")){N=O.nodeName.toLowerCase();if(c[N]&&N!=="br"){return false}}}else{if(O.nodeType===3&&!/^[ \t\r\n]*$/.test(O.nodeValue)){return false}}if(Q){P.prev()}else{P.next()}}return true}function l(N,T){var U,S,P,R,Q,O=x||"P";S=i.getParent(N,i.isBlock);if(!S||!E(S)){S=S||j;if(!S.hasChildNodes()){U=i.create(O);S.appendChild(U);v.setStart(U,0);v.setEnd(U,0);return U}R=N;while(R.parentNode!=S){R=R.parentNode}while(R&&!i.isBlock(R)){P=R;R=R.previousSibling}if(P){U=i.create(O);P.parentNode.insertBefore(U,P);R=P;while(R&&!i.isBlock(R)){Q=R.nextSibling;U.appendChild(R);R=Q}v.setStart(N,T);v.setEnd(N,T)}}return N}function H(){function N(P){var O=n[P?"firstChild":"lastChild"];while(O){if(O.nodeType==1){break}O=O[P?"nextSibling":"previousSibling"]}return O===p}o=x?r(x):i.create("BR");if(N(true)&&N()){i.replace(o,n)}else{if(N(true)){n.parentNode.insertBefore(o,n)}else{if(N()){i.insertAfter(o,n);F(o)}else{G=v.cloneRange();G.setStartAfter(p);G.setEndAfter(n);k=G.extractContents();i.insertAfter(k,n);i.insertAfter(o,n)}}}i.remove(p);m(o);h.add()}function y(){var O=new a(A,p),N;while(N=O.next()){if(c[N.nodeName.toLowerCase()]||N.length>0){return true}}}function L(){var P,O,N;if(A&&A.nodeType==3&&u>=A.nodeValue.length){if((!b.isIE||b.isIE11)&&!y()){P=i.create("br");v.insertNode(P);v.setStartAfter(P);v.setEndAfter(P);O=true}}P=i.create("br");v.insertNode(P);if((b.isIE&&!b.isIE11)&&t=="PRE"&&(!M||M<8)){P.parentNode.insertBefore(i.doc.createTextNode("\r"),P)}N=i.create("span",{},"&nbsp;");P.parentNode.insertBefore(N,P);e.scrollIntoView(N);i.remove(N);if(!O){v.setStartAfter(P);v.setEndAfter(P)}else{v.setStartBefore(P);v.setEndBefore(P)}e.setRng(v);h.add()}function s(N){do{if(N.nodeType===3){N.nodeValue=N.nodeValue.replace(/^[\r\n]+/,"")}N=N.firstChild}while(N)}function K(P){var N=i.getRoot(),O,Q;O=P;while(O!==N&&i.getContentEditable(O)!=="false"){if(i.getContentEditable(O)==="true"){Q=O}O=O.parentNode}return O!==N?Q:N}function I(O){var N;if(!b.isIE||b.isIE11){O.normalize();N=O.lastChild;if(!N||(/^(left|right)$/gi.test(i.getStyle(N,"float",true)))){i.add(O,"br")}}}if(!v.collapsed){f.execCommand("Delete");return}if(B.isDefaultPrevented()){return}A=v.startContainer;u=v.startOffset;x=(d.force_p_newlines?"p":"")||d.forced_root_block;x=x?x.toUpperCase():"";M=i.doc.documentMode;C=B.shiftKey;if(A.nodeType==1&&A.hasChildNodes()){D=u>A.childNodes.length-1;A=A.childNodes[Math.min(u,A.childNodes.length-1)]||A;if(D&&A.nodeType==3){u=A.nodeValue.length}else{u=0}}j=K(A);if(!j){return}h.beforeChange();if(!i.isBlock(j)&&j!=i.getRoot()){if(!x||C){L()}return}if((x&&!C)||(!x&&C)){A=l(A,u)}p=i.getParent(A,i.isBlock);n=p?i.getParent(p.parentNode,i.isBlock):null;t=p?p.nodeName.toUpperCase():"";J=n?n.nodeName.toUpperCase():"";if(J=="LI"&&!B.ctrlKey){p=n;t=J}if(t=="LI"){if(!x&&C){L();return}if(i.isEmpty(p)){if(/^(UL|OL|LI)$/.test(n.parentNode.nodeName)){return false}H();return}}if(t=="PRE"&&d.br_in_pre!==false){if(!C){L();return}}else{if((!x&&!C&&t!="LI")||(x&&C)){L();return}}x=x||"P";if(q()){if(/^(H[1-6]|PRE)$/.test(t)&&J!="HGROUP"){o=r(x)}else{o=r()}if(d.end_container_on_empty_block&&E(n)&&i.isEmpty(p)){o=i.split(n,p)}else{i.insertAfter(o,p)}m(o)}else{if(q(true)){o=p.parentNode.insertBefore(r(),p);F(o)}else{G=v.cloneRange();G.setEndAfter(p);k=G.extractContents();s(k);o=k.firstChild;i.insertAfter(k,p);z(o);I(p);m(o)}}i.setAttrib(o,"id","");h.add()}f.onKeyDown.add(function(k,j){if(j.keyCode==13){if(g(j)!==false){j.preventDefault()}}})}})(tinymce);
1
+ (function(e){var a=/^\s*|\s*$/g,b,d="B".replace(/A(.)|B/,"$1")==="$1";var c={majorVersion:"3",minorVersion:"5.5",releaseDate:"2012-07-19",_init:function(){var s=this,q=document,o=navigator,g=o.userAgent,m,f,l,k,j,r;s.isOpera=e.opera&&opera.buildNumber;s.isWebKit=/WebKit/.test(g);s.isIE=!s.isWebKit&&!s.isOpera&&(/MSIE/gi).test(g)&&(/Explorer/gi).test(o.appName);s.isIE6=s.isIE&&/MSIE [56]/.test(g);s.isIE7=s.isIE&&/MSIE [7]/.test(g);s.isIE8=s.isIE&&/MSIE [8]/.test(g);s.isIE9=s.isIE&&/MSIE [9]/.test(g);s.isGecko=!s.isWebKit&&/Gecko/.test(g);s.isMac=g.indexOf("Mac")!=-1;s.isAir=/adobeair/i.test(g);s.isIDevice=/(iPad|iPhone)/.test(g);s.isIOS5=s.isIDevice&&g.match(/AppleWebKit\/(\d*)/)[1]>=534;if(e.tinyMCEPreInit){s.suffix=tinyMCEPreInit.suffix;s.baseURL=tinyMCEPreInit.base;s.query=tinyMCEPreInit.query;return}s.suffix="";f=q.getElementsByTagName("base");for(m=0;m<f.length;m++){r=f[m].href;if(r){if(/^https?:\/\/[^\/]+$/.test(r)){r+="/"}k=r?r.match(/.*\//)[0]:""}}function h(i){if(i.src&&/tiny_mce(|_gzip|_jquery|_prototype|_full)(_dev|_src)?.js/.test(i.src)){if(/_(src|dev)\.js/g.test(i.src)){s.suffix="_src"}if((j=i.src.indexOf("?"))!=-1){s.query=i.src.substring(j+1)}s.baseURL=i.src.substring(0,i.src.lastIndexOf("/"));if(k&&s.baseURL.indexOf("://")==-1&&s.baseURL.indexOf("/")!==0){s.baseURL=k+s.baseURL}return s.baseURL}return null}f=q.getElementsByTagName("script");for(m=0;m<f.length;m++){if(h(f[m])){return}}l=q.getElementsByTagName("head")[0];if(l){f=l.getElementsByTagName("script");for(m=0;m<f.length;m++){if(h(f[m])){return}}}return},is:function(g,f){if(!f){return g!==b}if(f=="array"&&(g.hasOwnProperty&&g instanceof Array)){return true}return typeof(g)==f},makeMap:function(f,j,h){var g;f=f||[];j=j||",";if(typeof(f)=="string"){f=f.split(j)}h=h||{};g=f.length;while(g--){h[f[g]]={}}return h},each:function(i,f,h){var j,g;if(!i){return 0}h=h||i;if(i.length!==b){for(j=0,g=i.length;j<g;j++){if(f.call(h,i[j],j,i)===false){return 0}}}else{for(j in i){if(i.hasOwnProperty(j)){if(f.call(h,i[j],j,i)===false){return 0}}}}return 1},map:function(g,h){var i=[];c.each(g,function(f){i.push(h(f))});return i},grep:function(g,h){var i=[];c.each(g,function(f){if(!h||h(f)){i.push(f)}});return i},inArray:function(g,h){var j,f;if(g){for(j=0,f=g.length;j<f;j++){if(g[j]===h){return j}}}return -1},extend:function(n,k){var j,f,h,g=arguments,m;for(j=1,f=g.length;j<f;j++){k=g[j];for(h in k){if(k.hasOwnProperty(h)){m=k[h];if(m!==b){n[h]=m}}}}return n},trim:function(f){return(f?""+f:"").replace(a,"")},create:function(o,f,j){var n=this,g,i,k,l,h,m=0;o=/^((static) )?([\w.]+)(:([\w.]+))?/.exec(o);k=o[3].match(/(^|\.)(\w+)$/i)[2];i=n.createNS(o[3].replace(/\.\w+$/,""),j);if(i[k]){return}if(o[2]=="static"){i[k]=f;if(this.onCreate){this.onCreate(o[2],o[3],i[k])}return}if(!f[k]){f[k]=function(){};m=1}i[k]=f[k];n.extend(i[k].prototype,f);if(o[5]){g=n.resolve(o[5]).prototype;l=o[5].match(/\.(\w+)$/i)[1];h=i[k];if(m){i[k]=function(){return g[l].apply(this,arguments)}}else{i[k]=function(){this.parent=g[l];return h.apply(this,arguments)}}i[k].prototype[k]=i[k];n.each(g,function(p,q){i[k].prototype[q]=g[q]});n.each(f,function(p,q){if(g[q]){i[k].prototype[q]=function(){this.parent=g[q];return p.apply(this,arguments)}}else{if(q!=k){i[k].prototype[q]=p}}})}n.each(f["static"],function(p,q){i[k][q]=p});if(this.onCreate){this.onCreate(o[2],o[3],i[k].prototype)}},walk:function(i,h,j,g){g=g||this;if(i){if(j){i=i[j]}c.each(i,function(k,f){if(h.call(g,k,f,j)===false){return false}c.walk(k,h,j,g)})}},createNS:function(j,h){var g,f;h=h||e;j=j.split(".");for(g=0;g<j.length;g++){f=j[g];if(!h[f]){h[f]={}}h=h[f]}return h},resolve:function(j,h){var g,f;h=h||e;j=j.split(".");for(g=0,f=j.length;g<f;g++){h=h[j[g]];if(!h){break}}return h},addUnload:function(j,i){var h=this,g;g=function(){var f=h.unloads,l,m;if(f){for(m in f){l=f[m];if(l&&l.func){l.func.call(l.scope,1)}}if(e.detachEvent){e.detachEvent("onbeforeunload",k);e.detachEvent("onunload",g)}else{if(e.removeEventListener){e.removeEventListener("unload",g,false)}}h.unloads=l=f=w=g=0;if(e.CollectGarbage){CollectGarbage()}}};function k(){var l=document;function f(){l.detachEvent("onstop",f);if(g){g()}l=0}if(l.readyState=="interactive"){if(l){l.attachEvent("onstop",f)}e.setTimeout(function(){if(l){l.detachEvent("onstop",f)}},0)}}j={func:j,scope:i||this};if(!h.unloads){if(e.attachEvent){e.attachEvent("onunload",g);e.attachEvent("onbeforeunload",k)}else{if(e.addEventListener){e.addEventListener("unload",g,false)}}h.unloads=[j]}else{h.unloads.push(j)}return j},removeUnload:function(i){var g=this.unloads,h=null;c.each(g,function(j,f){if(j&&j.func==i){g.splice(f,1);h=i;return false}});return h},explode:function(f,g){if(!f||c.is(f,"array")){return f}return c.map(f.split(g||","),c.trim)},_addVer:function(g){var f;if(!this.query){return g}f=(g.indexOf("?")==-1?"?":"&")+this.query;if(g.indexOf("#")==-1){return g+f}return g.replace("#",f+"#")},_replace:function(h,f,g){if(d){return g.replace(h,function(){var l=f,j=arguments,k;for(k=0;k<j.length-2;k++){if(j[k]===b){l=l.replace(new RegExp("\\$"+k,"g"),"")}else{l=l.replace(new RegExp("\\$"+k,"g"),j[k])}}return l})}return g.replace(h,f)}};c._init();e.tinymce=e.tinyMCE=c})(window);tinymce.create("tinymce.util.Dispatcher",{scope:null,listeners:null,inDispatch:false,Dispatcher:function(a){this.scope=a||this;this.listeners=[]},add:function(b,a){this.listeners.push({cb:b,scope:a||this.scope});return b},addToTop:function(d,b){var a=this,c={cb:d,scope:b||a.scope};if(a.inDispatch){a.listeners=[c].concat(a.listeners)}else{a.listeners.unshift(c)}return d},remove:function(c){var b=this.listeners,a=null;tinymce.each(b,function(e,d){if(c==e.cb){a=e;b.splice(d,1);return false}});return a},dispatch:function(){var a=this,e,b=arguments,c,d=a.listeners,f;a.inDispatch=true;for(c=0;c<d.length;c++){f=d[c];e=f.cb.apply(f.scope,b.length>0?b:[f.scope]);if(e===false){break}}a.inDispatch=false;return e}});(function(){var a=tinymce.each;tinymce.create("tinymce.util.URI",{URI:function(e,g){var f=this,i,d,c,h;e=tinymce.trim(e);g=f.settings=g||{};if(/^([\w\-]+):([^\/]{2})/i.test(e)||/^\s*#/.test(e)){f.source=e;return}if(e.indexOf("/")===0&&e.indexOf("//")!==0){e=(g.base_uri?g.base_uri.protocol||"http":"http")+"://mce_host"+e}if(!/^[\w\-]*:?\/\//.test(e)){h=g.base_uri?g.base_uri.path:new tinymce.util.URI(location.href).directory;e=((g.base_uri&&g.base_uri.protocol)||"http")+"://mce_host"+f.toAbsPath(h,e)}e=e.replace(/@@/g,"(mce_at)");e=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@\/]*):?([^:@\/]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(e);a(["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],function(b,j){var k=e[j];if(k){k=k.replace(/\(mce_at\)/g,"@@")}f[b]=k});c=g.base_uri;if(c){if(!f.protocol){f.protocol=c.protocol}if(!f.userInfo){f.userInfo=c.userInfo}if(!f.port&&f.host==="mce_host"){f.port=c.port}if(!f.host||f.host==="mce_host"){f.host=c.host}f.source=""}},setPath:function(c){var b=this;c=/^(.*?)\/?(\w+)?$/.exec(c);b.path=c[0];b.directory=c[1];b.file=c[2];b.source="";b.getURI()},toRelative:function(b){var d=this,f;if(b==="./"){return b}b=new tinymce.util.URI(b,{base_uri:d});if((b.host!="mce_host"&&d.host!=b.host&&b.host)||d.port!=b.port||d.protocol!=b.protocol){return b.getURI()}var c=d.getURI(),e=b.getURI();if(c==e||(c.charAt(c.length-1)=="/"&&c.substr(0,c.length-1)==e)){return c}f=d.toRelPath(d.path,b.path);if(b.query){f+="?"+b.query}if(b.anchor){f+="#"+b.anchor}return f},toAbsolute:function(b,c){b=new tinymce.util.URI(b,{base_uri:this});return b.getURI(this.host==b.host&&this.protocol==b.protocol?c:0)},toRelPath:function(g,h){var c,f=0,d="",e,b;g=g.substring(0,g.lastIndexOf("/"));g=g.split("/");c=h.split("/");if(g.length>=c.length){for(e=0,b=g.length;e<b;e++){if(e>=c.length||g[e]!=c[e]){f=e+1;break}}}if(g.length<c.length){for(e=0,b=c.length;e<b;e++){if(e>=g.length||g[e]!=c[e]){f=e+1;break}}}if(f===1){return h}for(e=0,b=g.length-(f-1);e<b;e++){d+="../"}for(e=f-1,b=c.length;e<b;e++){if(e!=f-1){d+="/"+c[e]}else{d+=c[e]}}return d},toAbsPath:function(e,f){var c,b=0,h=[],d,g;d=/\/$/.test(f)?"/":"";e=e.split("/");f=f.split("/");a(e,function(i){if(i){h.push(i)}});e=h;for(c=f.length-1,h=[];c>=0;c--){if(f[c].length===0||f[c]==="."){continue}if(f[c]===".."){b++;continue}if(b>0){b--;continue}h.push(f[c])}c=e.length-b;if(c<=0){g=h.reverse().join("/")}else{g=e.slice(0,c).join("/")+"/"+h.reverse().join("/")}if(g.indexOf("/")!==0){g="/"+g}if(d&&g.lastIndexOf("/")!==g.length-1){g+=d}return g},getURI:function(d){var c,b=this;if(!b.source||d){c="";if(!d){if(b.protocol){c+=b.protocol+"://"}if(b.userInfo){c+=b.userInfo+"@"}if(b.host){c+=b.host}if(b.port){c+=":"+b.port}}if(b.path){c+=b.path}if(b.query){c+="?"+b.query}if(b.anchor){c+="#"+b.anchor}b.source=c}return b.source}})})();(function(){var a=tinymce.each;tinymce.create("static tinymce.util.Cookie",{getHash:function(d){var b=this.get(d),c;if(b){a(b.split("&"),function(e){e=e.split("=");c=c||{};c[unescape(e[0])]=unescape(e[1])})}return c},setHash:function(j,b,g,f,i,c){var h="";a(b,function(e,d){h+=(!h?"":"&")+escape(d)+"="+escape(e)});this.set(j,h,g,f,i,c)},get:function(i){var h=document.cookie,g,f=i+"=",d;if(!h){return}d=h.indexOf("; "+f);if(d==-1){d=h.indexOf(f);if(d!==0){return null}}else{d+=2}g=h.indexOf(";",d);if(g==-1){g=h.length}return unescape(h.substring(d+f.length,g))},set:function(i,b,g,f,h,c){document.cookie=i+"="+escape(b)+((g)?"; expires="+g.toGMTString():"")+((f)?"; path="+escape(f):"")+((h)?"; domain="+h:"")+((c)?"; secure":"")},remove:function(c,e,d){var b=new Date();b.setTime(b.getTime()-1000);this.set(c,"",b,e,d)}})})();(function(){function serialize(o,quote){var i,v,t,name;quote=quote||'"';if(o==null){return"null"}t=typeof o;if(t=="string"){v="\bb\tt\nn\ff\rr\"\"''\\\\";return quote+o.replace(/([\u0080-\uFFFF\x00-\x1f\"\'\\])/g,function(a,b){if(quote==='"'&&a==="'"){return a}i=v.indexOf(b);if(i+1){return"\\"+v.charAt(i+1)}a=b.charCodeAt().toString(16);return"\\u"+"0000".substring(a.length)+a})+quote}if(t=="object"){if(o.hasOwnProperty&&o instanceof Array){for(i=0,v="[";i<o.length;i++){v+=(i>0?",":"")+serialize(o[i],quote)}return v+"]"}v="{";for(name in o){if(o.hasOwnProperty(name)){v+=typeof o[name]!="function"?(v.length>1?","+quote:quote)+name+quote+":"+serialize(o[name],quote):""}}return v+"}"}return""+o}tinymce.util.JSON={serialize:serialize,parse:function(s){try{return eval("("+s+")")}catch(ex){}}}})();tinymce.create("static tinymce.util.XHR",{send:function(g){var a,e,b=window,h=0;function f(){if(!g.async||a.readyState==4||h++>10000){if(g.success&&h<10000&&a.status==200){g.success.call(g.success_scope,""+a.responseText,a,g)}else{if(g.error){g.error.call(g.error_scope,h>10000?"TIMED_OUT":"GENERAL",a,g)}}a=null}else{b.setTimeout(f,10)}}g.scope=g.scope||this;g.success_scope=g.success_scope||g.scope;g.error_scope=g.error_scope||g.scope;g.async=g.async===false?false:true;g.data=g.data||"";function d(i){a=0;try{a=new ActiveXObject(i)}catch(c){}return a}a=b.XMLHttpRequest?new XMLHttpRequest():d("Microsoft.XMLHTTP")||d("Msxml2.XMLHTTP");if(a){if(a.overrideMimeType){a.overrideMimeType(g.content_type)}a.open(g.type||(g.data?"POST":"GET"),g.url,g.async);if(g.content_type){a.setRequestHeader("Content-Type",g.content_type)}a.setRequestHeader("X-Requested-With","XMLHttpRequest");a.send(g.data);if(!g.async){return f()}e=b.setTimeout(f,10)}}});(function(){var c=tinymce.extend,b=tinymce.util.JSON,a=tinymce.util.XHR;tinymce.create("tinymce.util.JSONRequest",{JSONRequest:function(d){this.settings=c({},d);this.count=0},send:function(f){var e=f.error,d=f.success;f=c(this.settings,f);f.success=function(h,g){h=b.parse(h);if(typeof(h)=="undefined"){h={error:"JSON Parse error."}}if(h.error){e.call(f.error_scope||f.scope,h.error,g)}else{d.call(f.success_scope||f.scope,h.result)}};f.error=function(h,g){if(e){e.call(f.error_scope||f.scope,h,g)}};f.data=b.serialize({id:f.id||"c"+(this.count++),method:f.method,params:f.params});f.content_type="application/json";a.send(f)},"static":{sendRPC:function(d){return new tinymce.util.JSONRequest().send(d)}}})}());(function(a){a.VK={BACKSPACE:8,DELETE:46,DOWN:40,ENTER:13,LEFT:37,RIGHT:39,SPACEBAR:32,TAB:9,UP:38,modifierPressed:function(b){return b.shiftKey||b.ctrlKey||b.altKey},metaKeyPressed:function(b){return a.isMac?b.metaKey:b.ctrlKey&&!b.altKey}}})(tinymce);tinymce.util.Quirks=function(d){var m=tinymce.VK,t=m.BACKSPACE,u=m.DELETE,p=d.dom,E=d.selection,s=d.settings;function c(I,H){try{d.getDoc().execCommand(I,false,H)}catch(G){}}function z(){var G=d.getDoc().documentMode;return G?G:6}function j(){function G(J){var H,L,I,K;H=E.getRng();L=p.getParent(H.startContainer,p.isBlock);if(J){L=p.getNext(L,p.isBlock)}if(L){I=L.firstChild;while(I&&I.nodeType==3&&I.nodeValue.length===0){I=I.nextSibling}if(I&&I.nodeName==="SPAN"){K=I.cloneNode(false)}}d.getDoc().execCommand(J?"ForwardDelete":"Delete",false,null);L=p.getParent(H.startContainer,p.isBlock);tinymce.each(p.select("span.Apple-style-span,font.Apple-style-span",L),function(M){var N=E.getBookmark();if(K){p.replace(K.cloneNode(false),M,true)}else{p.remove(M,true)}E.moveToBookmark(N)})}d.onKeyDown.add(function(H,J){var I;I=J.keyCode==u;if(!J.isDefaultPrevented()&&(I||J.keyCode==t)&&!m.modifierPressed(J)){J.preventDefault();G(I)}});d.addCommand("Delete",function(){G()})}function F(){function G(J){var I=p.create("body");var K=J.cloneContents();I.appendChild(K);return E.serializer.serialize(I,{format:"html"})}function H(I){var K=G(I);var L=p.createRng();L.selectNode(d.getBody());var J=G(L);return K===J}d.onKeyDown.add(function(J,L){var K=L.keyCode,I;if(!L.isDefaultPrevented()&&(K==u||K==t)){I=J.selection.isCollapsed();if(I&&!p.isEmpty(J.getBody())){return}if(tinymce.isIE&&!I){return}if(!I&&!H(J.selection.getRng())){return}J.setContent("");J.selection.setCursorLocation(J.getBody(),0);J.nodeChanged()}})}function x(){d.onKeyDown.add(function(G,H){if(H.keyCode==65&&m.metaKeyPressed(H)){H.preventDefault();G.execCommand("SelectAll")}})}function y(){if(!d.settings.content_editable){p.bind(d.getDoc(),"focusin",function(G){E.setRng(E.getRng())});p.bind(d.getDoc(),"mousedown",function(G){if(G.target==d.getDoc().documentElement){d.getWin().focus();E.setRng(E.getRng())}})}}function n(){d.onKeyDown.add(function(G,J){if(!J.isDefaultPrevented()&&J.keyCode===t){if(E.isCollapsed()&&E.getRng(true).startOffset===0){var I=E.getNode();var H=I.previousSibling;if(H&&H.nodeName&&H.nodeName.toLowerCase()==="hr"){p.remove(H);tinymce.dom.Event.cancel(J)}}}})}function b(){if(!Range.prototype.getClientRects){d.onMouseDown.add(function(H,I){if(I.target.nodeName==="HTML"){var G=H.getBody();G.blur();setTimeout(function(){G.focus()},0)}})}}function B(){d.onClick.add(function(G,H){H=H.target;if(/^(IMG|HR)$/.test(H.nodeName)){E.getSel().setBaseAndExtent(H,0,H,1)}if(H.nodeName=="A"&&p.hasClass(H,"mceItemAnchor")){E.select(H)}G.nodeChanged()})}function C(){function H(){var J=p.getAttribs(E.getStart().cloneNode(false));return function(){var K=E.getStart();if(K!==d.getBody()){p.setAttrib(K,"style",null);tinymce.each(J,function(L){K.setAttributeNode(L.cloneNode(true))})}}}function G(){return !E.isCollapsed()&&E.getStart()!=E.getEnd()}function I(J,K){K.preventDefault();return false}d.onKeyPress.add(function(J,L){var K;if((L.keyCode==8||L.keyCode==46)&&G()){K=H();J.getDoc().execCommand("delete",false,null);K();L.preventDefault();return false}});p.bind(d.getDoc(),"cut",function(K){var J;if(G()){J=H();d.onKeyUp.addToTop(I);setTimeout(function(){J();d.onKeyUp.remove(I)},0)}})}function k(){var H,G;p.bind(d.getDoc(),"selectionchange",function(){if(G){clearTimeout(G);G=0}G=window.setTimeout(function(){var I=E.getRng();if(!H||!tinymce.dom.RangeUtils.compareRanges(I,H)){d.nodeChanged();H=I}},50)})}function D(){document.body.setAttribute("role","application")}function A(){d.onKeyDown.add(function(G,I){if(!I.isDefaultPrevented()&&I.keyCode===t){if(E.isCollapsed()&&E.getRng(true).startOffset===0){var H=E.getNode().previousSibling;if(H&&H.nodeName&&H.nodeName.toLowerCase()==="table"){return tinymce.dom.Event.cancel(I)}}}})}function h(){if(z()>7){return}c("RespectVisibilityInDesign",true);d.contentStyles.push(".mceHideBrInPre pre br {display: none}");p.addClass(d.getBody(),"mceHideBrInPre");d.parser.addNodeFilter("pre",function(G,I){var J=G.length,L,H,M,K;while(J--){L=G[J].getAll("br");H=L.length;while(H--){M=L[H];K=M.prev;if(K&&K.type===3&&K.value.charAt(K.value-1)!="\n"){K.value+="\n"}else{M.parent.insert(new tinymce.html.Node("#text",3),M,true).value="\n"}}}});d.serializer.addNodeFilter("pre",function(G,I){var J=G.length,L,H,M,K;while(J--){L=G[J].getAll("br");H=L.length;while(H--){M=L[H];K=M.prev;if(K&&K.type==3){K.value=K.value.replace(/\r?\n$/,"")}}}})}function f(){p.bind(d.getBody(),"mouseup",function(I){var H,G=E.getNode();if(G.nodeName=="IMG"){if(H=p.getStyle(G,"width")){p.setAttrib(G,"width",H.replace(/[^0-9%]+/g,""));p.setStyle(G,"width","")}if(H=p.getStyle(G,"height")){p.setAttrib(G,"height",H.replace(/[^0-9%]+/g,""));p.setStyle(G,"height","")}}})}function r(){d.onKeyDown.add(function(M,N){var L,G,H,J,K,O,I;L=N.keyCode==u;if(!N.isDefaultPrevented()&&(L||N.keyCode==t)&&!m.modifierPressed(N)){G=E.getRng();H=G.startContainer;J=G.startOffset;I=G.collapsed;if(H.nodeType==3&&H.nodeValue.length>0&&((J===0&&!I)||(I&&J===(L?0:1)))){nonEmptyElements=M.schema.getNonEmptyElements();N.preventDefault();K=p.create("br",{id:"__tmp"});H.parentNode.insertBefore(K,H);M.getDoc().execCommand(L?"ForwardDelete":"Delete",false,null);H=E.getRng().startContainer;O=H.previousSibling;if(O&&O.nodeType==1&&!p.isBlock(O)&&p.isEmpty(O)&&!nonEmptyElements[O.nodeName.toLowerCase()]){p.remove(O)}p.remove("__tmp")}}})}function e(){d.onKeyDown.add(function(K,L){var I,H,M,G,J;if(L.isDefaultPrevented()||L.keyCode!=m.BACKSPACE){return}I=E.getRng();H=I.startContainer;M=I.startOffset;G=p.getRoot();J=H;if(!I.collapsed||M!==0){return}while(J&&J.parentNode&&J.parentNode.firstChild==J&&J.parentNode!=G){J=J.parentNode}if(J.tagName==="BLOCKQUOTE"){K.formatter.toggle("blockquote",null,J);I.setStart(H,0);I.setEnd(H,0);E.setRng(I);E.collapse(false)}})}function l(){function G(){d._refreshContentEditable();c("StyleWithCSS",false);c("enableInlineTableEditing",false);if(!s.object_resizing){c("enableObjectResizing",false)}}if(!s.readonly){d.onBeforeExecCommand.add(G);d.onMouseDown.add(G)}}function o(){function G(H,I){tinymce.each(p.select("a"),function(L){var J=L.parentNode,K=p.getRoot();if(J.lastChild===L){while(J&&!p.isBlock(J)){if(J.parentNode.lastChild!==J||J===K){return}J=J.parentNode}p.add(J,"br",{"data-mce-bogus":1})}})}d.onExecCommand.add(function(H,I){if(I==="CreateLink"){G(H)}});d.onSetContent.add(E.onSetContent.add(G))}function v(){if(s.forced_root_block){d.onInit.add(function(){c("DefaultParagraphSeparator",s.forced_root_block)})}}function a(){function G(I,H){if(!I||!H.initial){d.execCommand("mceRepaint")}}d.onUndo.add(G);d.onRedo.add(G);d.onSetContent.add(G)}function q(){d.onKeyDown.add(function(H,I){var G;if(!I.isDefaultPrevented()&&I.keyCode==t){G=H.getDoc().selection.createRange();if(G&&G.item){I.preventDefault();H.undoManager.beforeChange();p.remove(G.item(0));H.undoManager.add()}}})}function i(){var G;if(z()>=10){G="";tinymce.each("p div h1 h2 h3 h4 h5 h6".split(" "),function(H,I){G+=(I>0?",":"")+H+":empty"});d.contentStyles.push(G+"{padding-right: 1px !important}")}}function g(){var I,H,X,G,S,V,T,W,J,U,Q,P,R=document,N=d.getDoc();if(!s.object_resizing||s.webkit_fake_resize===false){return}c("enableObjectResizing",false);U={n:[0.5,0,0,-1],e:[1,0.5,1,0],s:[0.5,1,0,1],w:[0,0.5,-1,0],nw:[0,0,-1,-1],ne:[1,0,1,-1],se:[1,1,1,1],sw:[0,1,-1,1]};function L(ac){var aa,Z,ab;aa=ac.screenX-V;Z=ac.screenY-T;ab=Math.max((W+aa)/W,(J+Z)/J);if(m.modifierPressed(ac)){Q=Math.round(W*ab);P=Math.round(J*ab)}else{Q=aa*S[2]+W;P=Z*S[3]+J}Q=Q<5?5:Q;P=P<5?5:P;p.setStyles(G,{width:Q,height:P});if(S[2]<0&&G.clientWidth<=Q){p.setStyle(G,"left",I+aa)}if(S[3]<0&&G.clientHeight<=P){p.setStyle(G,"top",H+Z)}}function Y(){function Z(aa,ab){if(ab){if(X.style[aa]||!d.schema.isValid(X.nodeName.toLowerCase(),aa)){p.setStyle(X,aa,ab)}else{p.setAttrib(X,aa,ab)}}}Z("width",Q);Z("height",P);p.unbind(N,"mousemove",L);p.unbind(N,"mouseup",Y);if(R!=N){p.unbind(R,"mousemove",L);p.unbind(R,"mouseup",Y)}p.remove(G);K(X)}function K(ac){var aa,ab,Z;M();aa=p.getPos(ac);I=aa.x;H=aa.y;ab=ac.offsetWidth;Z=ac.offsetHeight;if(X!=ac){X=ac;Q=P=0}tinymce.each(U,function(af,ad){var ae;ae=p.get("mceResizeHandle"+ad);if(!ae){ae=p.add(N.documentElement,"div",{id:"mceResizeHandle"+ad,"class":"mceResizeHandle",style:"cursor:"+ad+"-resize; margin:0; padding:0"});p.bind(ae,"mousedown",function(ag){ag.preventDefault();Y();V=ag.screenX;T=ag.screenY;W=X.clientWidth;J=X.clientHeight;S=af;G=X.cloneNode(true);p.addClass(G,"mceClonedResizable");p.setStyles(G,{left:I,top:H,margin:0});N.documentElement.appendChild(G);p.bind(N,"mousemove",L);p.bind(N,"mouseup",Y);if(R!=N){p.bind(R,"mousemove",L);p.bind(R,"mouseup",Y)}})}else{p.show(ae)}p.setStyles(ae,{left:(ab*af[0]+I)-(ae.offsetWidth/2),top:(Z*af[1]+H)-(ae.offsetHeight/2)})});if(!tinymce.isOpera&&X.nodeName=="IMG"){X.setAttribute("data-mce-selected","1")}}function M(){if(X){X.removeAttribute("data-mce-selected")}for(var Z in U){p.hide("mceResizeHandle"+Z)}}d.contentStyles.push(".mceResizeHandle {position: absolute;border: 1px solid black;background: #FFF;width: 5px;height: 5px;z-index: 10000}.mceResizeHandle:hover {background: #000}img[data-mce-selected] {outline: 1px solid black}img.mceClonedResizable, table.mceClonedResizable {position: absolute;outline: 1px dashed black;opacity: .5;z-index: 10000}");function O(){var Z=p.getParent(E.getNode(),"table,img");tinymce.each(p.select("img[data-mce-selected]"),function(aa){aa.removeAttribute("data-mce-selected")});if(Z){K(Z)}else{M()}}d.onNodeChange.add(O);p.bind(N,"selectionchange",O);d.serializer.addAttributeFilter("data-mce-selected",function(Z,aa){var ab=Z.length;while(ab--){Z[ab].attr(aa,null)}})}A();e();F();if(tinymce.isWebKit){r();j();y();B();v();if(tinymce.isIDevice){k()}else{g();x()}}if(tinymce.isIE){n();D();h();f();q();i()}if(tinymce.isGecko){n();b();C();l();o();a()}if(tinymce.isOpera){g()}};(function(j){var a,g,d,k=/[&<>\"\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,b=/[<>&\u007E-\uD7FF\uE000-\uFFEF]|[\uD800-\uDBFF][\uDC00-\uDFFF]/g,f=/[<>&\"\']/g,c=/&(#x|#)?([\w]+);/g,i={128:"\u20AC",130:"\u201A",131:"\u0192",132:"\u201E",133:"\u2026",134:"\u2020",135:"\u2021",136:"\u02C6",137:"\u2030",138:"\u0160",139:"\u2039",140:"\u0152",142:"\u017D",145:"\u2018",146:"\u2019",147:"\u201C",148:"\u201D",149:"\u2022",150:"\u2013",151:"\u2014",152:"\u02DC",153:"\u2122",154:"\u0161",155:"\u203A",156:"\u0153",158:"\u017E",159:"\u0178"};g={'"':"&quot;","'":"&#39;","<":"&lt;",">":"&gt;","&":"&amp;"};d={"&lt;":"<","&gt;":">","&amp;":"&","&quot;":'"',"&apos;":"'"};function h(l){var m;m=document.createElement("div");m.innerHTML=l;return m.textContent||m.innerText||l}function e(m,p){var n,o,l,q={};if(m){m=m.split(",");p=p||10;for(n=0;n<m.length;n+=2){o=String.fromCharCode(parseInt(m[n],p));if(!g[o]){l="&"+m[n+1]+";";q[o]=l;q[l]=o}}return q}}a=e("50,nbsp,51,iexcl,52,cent,53,pound,54,curren,55,yen,56,brvbar,57,sect,58,uml,59,copy,5a,ordf,5b,laquo,5c,not,5d,shy,5e,reg,5f,macr,5g,deg,5h,plusmn,5i,sup2,5j,sup3,5k,acute,5l,micro,5m,para,5n,middot,5o,cedil,5p,sup1,5q,ordm,5r,raquo,5s,frac14,5t,frac12,5u,frac34,5v,iquest,60,Agrave,61,Aacute,62,Acirc,63,Atilde,64,Auml,65,Aring,66,AElig,67,Ccedil,68,Egrave,69,Eacute,6a,Ecirc,6b,Euml,6c,Igrave,6d,Iacute,6e,Icirc,6f,Iuml,6g,ETH,6h,Ntilde,6i,Ograve,6j,Oacute,6k,Ocirc,6l,Otilde,6m,Ouml,6n,times,6o,Oslash,6p,Ugrave,6q,Uacute,6r,Ucirc,6s,Uuml,6t,Yacute,6u,THORN,6v,szlig,70,agrave,71,aacute,72,acirc,73,atilde,74,auml,75,aring,76,aelig,77,ccedil,78,egrave,79,eacute,7a,ecirc,7b,euml,7c,igrave,7d,iacute,7e,icirc,7f,iuml,7g,eth,7h,ntilde,7i,ograve,7j,oacute,7k,ocirc,7l,otilde,7m,ouml,7n,divide,7o,oslash,7p,ugrave,7q,uacute,7r,ucirc,7s,uuml,7t,yacute,7u,thorn,7v,yuml,ci,fnof,sh,Alpha,si,Beta,sj,Gamma,sk,Delta,sl,Epsilon,sm,Zeta,sn,Eta,so,Theta,sp,Iota,sq,Kappa,sr,Lambda,ss,Mu,st,Nu,su,Xi,sv,Omicron,t0,Pi,t1,Rho,t3,Sigma,t4,Tau,t5,Upsilon,t6,Phi,t7,Chi,t8,Psi,t9,Omega,th,alpha,ti,beta,tj,gamma,tk,delta,tl,epsilon,tm,zeta,tn,eta,to,theta,tp,iota,tq,kappa,tr,lambda,ts,mu,tt,nu,tu,xi,tv,omicron,u0,pi,u1,rho,u2,sigmaf,u3,sigma,u4,tau,u5,upsilon,u6,phi,u7,chi,u8,psi,u9,omega,uh,thetasym,ui,upsih,um,piv,812,bull,816,hellip,81i,prime,81j,Prime,81u,oline,824,frasl,88o,weierp,88h,image,88s,real,892,trade,89l,alefsym,8cg,larr,8ch,uarr,8ci,rarr,8cj,darr,8ck,harr,8dl,crarr,8eg,lArr,8eh,uArr,8ei,rArr,8ej,dArr,8ek,hArr,8g0,forall,8g2,part,8g3,exist,8g5,empty,8g7,nabla,8g8,isin,8g9,notin,8gb,ni,8gf,prod,8gh,sum,8gi,minus,8gn,lowast,8gq,radic,8gt,prop,8gu,infin,8h0,ang,8h7,and,8h8,or,8h9,cap,8ha,cup,8hb,int,8hk,there4,8hs,sim,8i5,cong,8i8,asymp,8j0,ne,8j1,equiv,8j4,le,8j5,ge,8k2,sub,8k3,sup,8k4,nsub,8k6,sube,8k7,supe,8kl,oplus,8kn,otimes,8l5,perp,8m5,sdot,8o8,lceil,8o9,rceil,8oa,lfloor,8ob,rfloor,8p9,lang,8pa,rang,9ea,loz,9j0,spades,9j3,clubs,9j5,hearts,9j6,diams,ai,OElig,aj,oelig,b0,Scaron,b1,scaron,bo,Yuml,m6,circ,ms,tilde,802,ensp,803,emsp,809,thinsp,80c,zwnj,80d,zwj,80e,lrm,80f,rlm,80j,ndash,80k,mdash,80o,lsquo,80p,rsquo,80q,sbquo,80s,ldquo,80t,rdquo,80u,bdquo,810,dagger,811,Dagger,81g,permil,81p,lsaquo,81q,rsaquo,85c,euro",32);j.html=j.html||{};j.html.Entities={encodeRaw:function(m,l){return m.replace(l?k:b,function(n){return g[n]||n})},encodeAllRaw:function(l){return(""+l).replace(f,function(m){return g[m]||m})},encodeNumeric:function(m,l){return m.replace(l?k:b,function(n){if(n.length>1){return"&#"+(((n.charCodeAt(0)-55296)*1024)+(n.charCodeAt(1)-56320)+65536)+";"}return g[n]||"&#"+n.charCodeAt(0)+";"})},encodeNamed:function(n,l,m){m=m||a;return n.replace(l?k:b,function(o){return g[o]||m[o]||o})},getEncodeFunc:function(l,o){var p=j.html.Entities;o=e(o)||a;function m(r,q){return r.replace(q?k:b,function(s){return g[s]||o[s]||"&#"+s.charCodeAt(0)+";"||s})}function n(r,q){return p.encodeNamed(r,q,o)}l=j.makeMap(l.replace(/\+/g,","));if(l.named&&l.numeric){return m}if(l.named){if(o){return n}return p.encodeNamed}if(l.numeric){return p.encodeNumeric}return p.encodeRaw},decode:function(l){return l.replace(c,function(n,m,o){if(m){o=parseInt(o,m.length===2?16:10);if(o>65535){o-=65536;return String.fromCharCode(55296+(o>>10),56320+(o&1023))}else{return i[o]||String.fromCharCode(o)}}return d[n]||a[n]||h(n)})}}})(tinymce);tinymce.html.Styles=function(d,f){var k=/rgb\s*\(\s*([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\s*\)/gi,h=/(?:url(?:(?:\(\s*\"([^\"]+)\"\s*\))|(?:\(\s*\'([^\']+)\'\s*\))|(?:\(\s*([^)\s]+)\s*\))))|(?:\'([^\']+)\')|(?:\"([^\"]+)\")/gi,b=/\s*([^:]+):\s*([^;]+);?/g,l=/\s+$/,m=/rgb/,e,g,a={},j;d=d||{};j="\\\" \\' \\; \\: ; : \uFEFF".split(" ");for(g=0;g<j.length;g++){a[j[g]]="\uFEFF"+g;a["\uFEFF"+g]=j[g]}function c(n,q,p,i){function o(r){r=parseInt(r).toString(16);return r.length>1?r:"0"+r}return"#"+o(q)+o(p)+o(i)}return{toHex:function(i){return i.replace(k,c)},parse:function(s){var z={},q,n,x,r,v=d.url_converter,y=d.url_converter_scope||this;function p(D,G){var F,C,B,E;F=z[D+"-top"+G];if(!F){return}C=z[D+"-right"+G];if(F!=C){return}B=z[D+"-bottom"+G];if(C!=B){return}E=z[D+"-left"+G];if(B!=E){return}z[D+G]=E;delete z[D+"-top"+G];delete z[D+"-right"+G];delete z[D+"-bottom"+G];delete z[D+"-left"+G]}function u(C){var D=z[C],B;if(!D||D.indexOf(" ")<0){return}D=D.split(" ");B=D.length;while(B--){if(D[B]!==D[0]){return false}}z[C]=D[0];return true}function A(D,C,B,E){if(!u(C)){return}if(!u(B)){return}if(!u(E)){return}z[D]=z[C]+" "+z[B]+" "+z[E];delete z[C];delete z[B];delete z[E]}function t(B){r=true;return a[B]}function i(C,B){if(r){C=C.replace(/\uFEFF[0-9]/g,function(D){return a[D]})}if(!B){C=C.replace(/\\([\'\";:])/g,"$1")}return C}function o(C,B,F,E,G,D){G=G||D;if(G){G=i(G);return"'"+G.replace(/\'/g,"\\'")+"'"}B=i(B||F||E);if(v){B=v.call(y,B,"style")}return"url('"+B.replace(/\'/g,"\\'")+"')"}if(s){s=s.replace(/\\[\"\';:\uFEFF]/g,t).replace(/\"[^\"]+\"|\'[^\']+\'/g,function(B){return B.replace(/[;:]/g,t)});while(q=b.exec(s)){n=q[1].replace(l,"").toLowerCase();x=q[2].replace(l,"");if(n&&x.length>0){if(n==="font-weight"&&x==="700"){x="bold"}else{if(n==="color"||n==="background-color"){x=x.toLowerCase()}}x=x.replace(k,c);x=x.replace(h,o);z[n]=r?i(x,true):x}b.lastIndex=q.index+q[0].length}p("border","");p("border","-width");p("border","-color");p("border","-style");p("padding","");p("margin","");A("border","border-width","border-style","border-color");if(z.border==="medium none"){delete z.border}}return z},serialize:function(p,r){var o="",n,q;function i(t){var x,u,s,v;x=f.styles[t];if(x){for(u=0,s=x.length;u<s;u++){t=x[u];v=p[t];if(v!==e&&v.length>0){o+=(o.length>0?" ":"")+t+": "+v+";"}}}}if(r&&f&&f.styles){i("*");i(r)}else{for(n in p){q=p[n];if(q!==e&&q.length>0){o+=(o.length>0?" ":"")+n+": "+q+";"}}}return o}}};(function(f){var a={},e=f.makeMap,g=f.each;function d(j,i){return j.split(i||",")}function h(m,l){var j,k={};function i(n){return n.replace(/[A-Z]+/g,function(o){return i(m[o])})}for(j in m){if(m.hasOwnProperty(j)){m[j]=i(m[j])}}i(l).replace(/#/g,"#text").replace(/(\w+)\[([^\]]+)\]\[([^\]]*)\]/g,function(q,o,n,p){n=d(n,"|");k[o]={attributes:e(n),attributesOrder:n,children:e(p,"|",{"#comment":{}})}});return k}function b(){var i=a.html5;if(!i){i=a.html5=h({A:"id|accesskey|class|dir|draggable|item|hidden|itemprop|role|spellcheck|style|subject|title|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup",B:"#|a|abbr|area|audio|b|bdo|br|button|canvas|cite|code|command|datalist|del|dfn|em|embed|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|meta|meter|noscript|object|output|progress|q|ruby|samp|script|select|small|span|strong|sub|sup|svg|textarea|time|var|video|wbr",C:"#|a|abbr|area|address|article|aside|audio|b|bdo|blockquote|br|button|canvas|cite|code|command|datalist|del|details|dfn|dialog|div|dl|em|embed|fieldset|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hgroup|hr|i|iframe|img|input|ins|kbd|keygen|label|link|map|mark|menu|meta|meter|nav|noscript|ol|object|output|p|pre|progress|q|ruby|samp|script|section|select|small|span|strong|style|sub|sup|svg|table|textarea|time|ul|var|video"},"html[A|manifest][body|head]head[A][base|command|link|meta|noscript|script|style|title]title[A][#]base[A|href|target][]link[A|href|rel|media|type|sizes][]meta[A|http-equiv|name|content|charset][]style[A|type|media|scoped][#]script[A|charset|type|src|defer|async][#]noscript[A][C]body[A][C]section[A][C]nav[A][C]article[A][C]aside[A][C]h1[A][B]h2[A][B]h3[A][B]h4[A][B]h5[A][B]h6[A][B]hgroup[A][h1|h2|h3|h4|h5|h6]header[A][C]footer[A][C]address[A][C]p[A][B]br[A][]pre[A][B]dialog[A][dd|dt]blockquote[A|cite][C]ol[A|start|reversed][li]ul[A][li]li[A|value][C]dl[A][dd|dt]dt[A][B]dd[A][C]a[A|href|target|ping|rel|media|type][B]em[A][B]strong[A][B]small[A][B]cite[A][B]q[A|cite][B]dfn[A][B]abbr[A][B]code[A][B]var[A][B]samp[A][B]kbd[A][B]sub[A][B]sup[A][B]i[A][B]b[A][B]mark[A][B]progress[A|value|max][B]meter[A|value|min|max|low|high|optimum][B]time[A|datetime][B]ruby[A][B|rt|rp]rt[A][B]rp[A][B]bdo[A][B]span[A][B]ins[A|cite|datetime][B]del[A|cite|datetime][B]figure[A][C|legend|figcaption]figcaption[A][C]img[A|alt|src|height|width|usemap|ismap][]iframe[A|name|src|height|width|sandbox|seamless][]embed[A|src|height|width|type][]object[A|data|type|height|width|usemap|name|form|classid][param]param[A|name|value][]details[A|open][C|legend]command[A|type|label|icon|disabled|checked|radiogroup][]menu[A|type|label][C|li]legend[A][C|B]div[A][C]source[A|src|type|media][]audio[A|src|autobuffer|autoplay|loop|controls][source]video[A|src|autobuffer|autoplay|loop|controls|width|height|poster][source]hr[A][]form[A|accept-charset|action|autocomplete|enctype|method|name|novalidate|target][C]fieldset[A|disabled|form|name][C|legend]label[A|form|for][B]input[A|type|accept|alt|autocomplete|checked|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|height|list|max|maxlength|min|multiple|pattern|placeholder|readonly|required|size|src|step|width|files|value|name][]button[A|autofocus|disabled|form|formaction|formenctype|formmethod|formnovalidate|formtarget|name|value|type][B]select[A|autofocus|disabled|form|multiple|name|size][option|optgroup]datalist[A][B|option]optgroup[A|disabled|label][option]option[A|disabled|selected|label|value][]textarea[A|autofocus|disabled|form|maxlength|name|placeholder|readonly|required|rows|cols|wrap][]keygen[A|autofocus|challenge|disabled|form|keytype|name][]output[A|for|form|name][B]canvas[A|width|height][]map[A|name][B|C]area[A|shape|coords|href|alt|target|media|rel|ping|type][]mathml[A][]svg[A][]table[A|border][caption|colgroup|thead|tfoot|tbody|tr]caption[A][C]colgroup[A|span][col]col[A|span][]thead[A][tr]tfoot[A][tr]tbody[A][tr]tr[A][th|td]th[A|headers|rowspan|colspan|scope][B]td[A|headers|rowspan|colspan][C]wbr[A][]")}return i}function c(){var i=a.html4;if(!i){i=a.html4=h({Z:"H|K|N|O|P",Y:"X|form|R|Q",ZG:"E|span|width|align|char|charoff|valign",X:"p|T|div|U|W|isindex|fieldset|table",ZF:"E|align|char|charoff|valign",W:"pre|hr|blockquote|address|center|noframes",ZE:"abbr|axis|headers|scope|rowspan|colspan|align|char|charoff|valign|nowrap|bgcolor|width|height",ZD:"[E][S]",U:"ul|ol|dl|menu|dir",ZC:"p|Y|div|U|W|table|br|span|bdo|object|applet|img|map|K|N|Q",T:"h1|h2|h3|h4|h5|h6",ZB:"X|S|Q",S:"R|P",ZA:"a|G|J|M|O|P",R:"a|H|K|N|O",Q:"noscript|P",P:"ins|del|script",O:"input|select|textarea|label|button",N:"M|L",M:"em|strong|dfn|code|q|samp|kbd|var|cite|abbr|acronym",L:"sub|sup",K:"J|I",J:"tt|i|b|u|s|strike",I:"big|small|font|basefont",H:"G|F",G:"br|span|bdo",F:"object|applet|img|map|iframe",E:"A|B|C",D:"accesskey|tabindex|onfocus|onblur",C:"onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup",B:"lang|xml:lang|dir",A:"id|class|style|title"},"script[id|charset|type|language|src|defer|xml:space][]style[B|id|type|media|title|xml:space][]object[E|declare|classid|codebase|data|type|codetype|archive|standby|width|height|usemap|name|tabindex|align|border|hspace|vspace][#|param|Y]param[id|name|value|valuetype|type][]p[E|align][#|S]a[E|D|charset|type|name|href|hreflang|rel|rev|shape|coords|target][#|Z]br[A|clear][]span[E][#|S]bdo[A|C|B][#|S]applet[A|codebase|archive|code|object|alt|name|width|height|align|hspace|vspace][#|param|Y]h1[E|align][#|S]img[E|src|alt|name|longdesc|width|height|usemap|ismap|align|border|hspace|vspace][]map[B|C|A|name][X|form|Q|area]h2[E|align][#|S]iframe[A|longdesc|name|src|frameborder|marginwidth|marginheight|scrolling|align|width|height][#|Y]h3[E|align][#|S]tt[E][#|S]i[E][#|S]b[E][#|S]u[E][#|S]s[E][#|S]strike[E][#|S]big[E][#|S]small[E][#|S]font[A|B|size|color|face][#|S]basefont[id|size|color|face][]em[E][#|S]strong[E][#|S]dfn[E][#|S]code[E][#|S]q[E|cite][#|S]samp[E][#|S]kbd[E][#|S]var[E][#|S]cite[E][#|S]abbr[E][#|S]acronym[E][#|S]sub[E][#|S]sup[E][#|S]input[E|D|type|name|value|checked|disabled|readonly|size|maxlength|src|alt|usemap|onselect|onchange|accept|align][]select[E|name|size|multiple|disabled|tabindex|onfocus|onblur|onchange][optgroup|option]optgroup[E|disabled|label][option]option[E|selected|disabled|label|value][]textarea[E|D|name|rows|cols|disabled|readonly|onselect|onchange][]label[E|for|accesskey|onfocus|onblur][#|S]button[E|D|name|value|type|disabled][#|p|T|div|U|W|table|G|object|applet|img|map|K|N|Q]h4[E|align][#|S]ins[E|cite|datetime][#|Y]h5[E|align][#|S]del[E|cite|datetime][#|Y]h6[E|align][#|S]div[E|align][#|Y]ul[E|type|compact][li]li[E|type|value][#|Y]ol[E|type|compact|start][li]dl[E|compact][dt|dd]dt[E][#|S]dd[E][#|Y]menu[E|compact][li]dir[E|compact][li]pre[E|width|xml:space][#|ZA]hr[E|align|noshade|size|width][]blockquote[E|cite][#|Y]address[E][#|S|p]center[E][#|Y]noframes[E][#|Y]isindex[A|B|prompt][]fieldset[E][#|legend|Y]legend[E|accesskey|align][#|S]table[E|summary|width|border|frame|rules|cellspacing|cellpadding|align|bgcolor][caption|col|colgroup|thead|tfoot|tbody|tr]caption[E|align][#|S]col[ZG][]colgroup[ZG][col]thead[ZF][tr]tr[ZF|bgcolor][th|td]th[E|ZE][#|Y]form[E|action|method|name|enctype|onsubmit|onreset|accept|accept-charset|target][#|X|R|Q]noscript[E][#|Y]td[E|ZE][#|Y]tfoot[ZF][tr]tbody[ZF][tr]area[E|D|shape|coords|href|nohref|alt|target][]base[id|href|target][]body[E|onload|onunload|background|bgcolor|text|link|vlink|alink][#|Y]")}return i}f.html.Schema=function(A){var u=this,s={},k={},j=[],D,y;var o,q,z,r,v,n,p={};function m(F,E,H){var G=A[F];if(!G){G=a[F];if(!G){G=e(E," ",e(E.toUpperCase()," "));G=f.extend(G,H);a[F]=G}}else{G=e(G,",",e(G.toUpperCase()," "))}return G}A=A||{};y=A.schema=="html5"?b():c();if(A.verify_html===false){A.valid_elements="*[*]"}if(A.valid_styles){D={};g(A.valid_styles,function(F,E){D[E]=f.explode(F)})}o=m("whitespace_elements","pre script style textarea");q=m("self_closing_elements","colgroup dd dt li option p td tfoot th thead tr");z=m("short_ended_elements","area base basefont br col frame hr img input isindex link meta param embed source wbr");r=m("boolean_attributes","checked compact declare defer disabled ismap multiple nohref noresize noshade nowrap readonly selected autoplay loop controls");n=m("non_empty_elements","td th iframe video audio object",z);v=m("block_elements","h1 h2 h3 h4 h5 h6 hr p div address pre form table tbody thead tfoot th tr td li ol ul caption blockquote center dl dt dd dir fieldset noscript menu isindex samp header footer article section hgroup aside nav figure option datalist select optgroup");function i(E){return new RegExp("^"+E.replace(/([?+*])/g,".$1")+"$")}function C(L){var K,G,Z,V,aa,F,I,U,X,Q,Y,ac,O,J,W,E,S,H,ab,ad,P,T,N=/^([#+\-])?([^\[\/]+)(?:\/([^\[]+))?(?:\[([^\]]+)\])?$/,R=/^([!\-])?(\w+::\w+|[^=:<]+)?(?:([=:<])(.*))?$/,M=/[*?+]/;if(L){L=d(L);if(s["@"]){S=s["@"].attributes;H=s["@"].attributesOrder}for(K=0,G=L.length;K<G;K++){F=N.exec(L[K]);if(F){W=F[1];Q=F[2];E=F[3];X=F[4];O={};J=[];I={attributes:O,attributesOrder:J};if(W==="#"){I.paddEmpty=true}if(W==="-"){I.removeEmpty=true}if(S){for(ad in S){O[ad]=S[ad]}J.push.apply(J,H)}if(X){X=d(X,"|");for(Z=0,V=X.length;Z<V;Z++){F=R.exec(X[Z]);if(F){U={};ac=F[1];Y=F[2].replace(/::/g,":");W=F[3];T=F[4];if(ac==="!"){I.attributesRequired=I.attributesRequired||[];I.attributesRequired.push(Y);U.required=true}if(ac==="-"){delete O[Y];J.splice(f.inArray(J,Y),1);continue}if(W){if(W==="="){I.attributesDefault=I.attributesDefault||[];I.attributesDefault.push({name:Y,value:T});U.defaultValue=T}if(W===":"){I.attributesForced=I.attributesForced||[];I.attributesForced.push({name:Y,value:T});U.forcedValue=T}if(W==="<"){U.validValues=e(T,"?")}}if(M.test(Y)){I.attributePatterns=I.attributePatterns||[];U.pattern=i(Y);I.attributePatterns.push(U)}else{if(!O[Y]){J.push(Y)}O[Y]=U}}}}if(!S&&Q=="@"){S=O;H=J}if(E){I.outputName=Q;s[E]=I}if(M.test(Q)){I.pattern=i(Q);j.push(I)}else{s[Q]=I}}}}}function t(E){s={};j=[];C(E);g(y,function(G,F){k[F]=G.children})}function l(F){var E=/^(~)?(.+)$/;if(F){g(d(F),function(J){var H=E.exec(J),I=H[1]==="~",K=I?"span":"div",G=H[2];k[G]=k[K];p[G]=K;if(!I){v[G]={}}g(k,function(L,M){if(L[K]){L[G]=L[K]}})})}}function x(F){var E=/^([+\-]?)(\w+)\[([^\]]+)\]$/;if(F){g(d(F),function(J){var I=E.exec(J),G,H;if(I){H=I[1];if(H){G=k[I[2]]}else{G=k[I[2]]={"#comment":{}}}G=k[I[2]];g(d(I[3],"|"),function(K){if(H==="-"){delete G[K]}else{G[K]={}}})}})}}function B(E){var G=s[E],F;if(G){return G}F=j.length;while(F--){G=j[F];if(G.pattern.test(E)){return G}}}if(!A.valid_elements){g(y,function(F,E){s[E]={attributes:F.attributes,attributesOrder:F.attributesOrder};k[E]=F.children});if(A.schema!="html5"){g(d("strong/b,em/i"),function(E){E=d(E,"/");s[E[1]].outputName=E[0]})}s.img.attributesDefault=[{name:"alt",value:""}];g(d("ol,ul,sub,sup,blockquote,span,font,a,table,tbody,tr,strong,em,b,i"),function(E){if(s[E]){s[E].removeEmpty=true}});g(d("p,h1,h2,h3,h4,h5,h6,th,td,pre,div,address,caption"),function(E){s[E].paddEmpty=true})}else{t(A.valid_elements)}l(A.custom_elements);x(A.valid_children);C(A.extended_valid_elements);x("+ol[ul|ol],+ul[ul|ol]");if(A.invalid_elements){f.each(f.explode(A.invalid_elements),function(E){if(s[E]){delete s[E]}})}if(!B("span")){C("span[!data-mce-type|*]")}u.children=k;u.styles=D;u.getBoolAttrs=function(){return r};u.getBlockElements=function(){return v};u.getShortEndedElements=function(){return z};u.getSelfClosingElements=function(){return q};u.getNonEmptyElements=function(){return n};u.getWhiteSpaceElements=function(){return o};u.isValidChild=function(E,G){var F=k[E];return !!(F&&F[G])};u.isValid=function(F,E){var H,G,I=B(F);if(I){if(E){if(I.attributes[E]){return true}H=I.attributePatterns;if(H){G=H.length;while(G--){if(H[G].pattern.test(F)){return true}}}}else{return true}}return false};u.getElementRule=B;u.getCustomElements=function(){return p};u.addValidElements=C;u.setValidElements=t;u.addCustomElements=l;u.addValidChildren=x}})(tinymce);(function(a){a.html.SaxParser=function(c,e){var b=this,d=function(){};c=c||{};b.schema=e=e||new a.html.Schema();if(c.fix_self_closing!==false){c.fix_self_closing=true}a.each("comment cdata text start end pi doctype".split(" "),function(f){if(f){b[f]=c[f]||d}});b.parse=function(E){var n=this,g,G=0,I,B,A=[],N,Q,C,r,z,s,M,H,O,v,m,k,t,R,o,P,F,S,L,f,J,l,D,K,h,x=0,j=a.html.Entities.decode,y,q;function u(T){var V,U;V=A.length;while(V--){if(A[V].name===T){break}}if(V>=0){for(U=A.length-1;U>=V;U--){T=A[U];if(T.valid){n.end(T.name)}}A.length=V}}function p(U,T,Y,X,W){var Z,V;T=T.toLowerCase();Y=T in H?T:j(Y||X||W||"");if(v&&!z&&T.indexOf("data-")!==0){Z=P[T];if(!Z&&F){V=F.length;while(V--){Z=F[V];if(Z.pattern.test(T)){break}}if(V===-1){Z=null}}if(!Z){return}if(Z.validValues&&!(Y in Z.validValues)){return}}N.map[T]=Y;N.push({name:T,value:Y})}l=new RegExp("<(?:(?:!--([\\w\\W]*?)-->)|(?:!\\[CDATA\\[([\\w\\W]*?)\\]\\]>)|(?:!DOCTYPE([\\w\\W]*?)>)|(?:\\?([^\\s\\/<>]+) ?([\\w\\W]*?)[?/]>)|(?:\\/([^>]+)>)|(?:([A-Za-z0-9\\-\\:]+)((?:\\s+[^\"'>]+(?:(?:\"[^\"]*\")|(?:'[^']*')|[^>]*))*|\\/|\\s+)>))","g");D=/([\w:\-]+)(?:\s*=\s*(?:(?:\"((?:\\.|[^\"])*)\")|(?:\'((?:\\.|[^\'])*)\')|([^>\s]+)))?/g;K={script:/<\/script[^>]*>/gi,style:/<\/style[^>]*>/gi,noscript:/<\/noscript[^>]*>/gi};M=e.getShortEndedElements();J=c.self_closing_elements||e.getSelfClosingElements();H=e.getBoolAttrs();v=c.validate;s=c.remove_internals;y=c.fix_self_closing;q=a.isIE;o=/^:/;while(g=l.exec(E)){if(G<g.index){n.text(j(E.substr(G,g.index-G)))}if(I=g[6]){I=I.toLowerCase();if(q&&o.test(I)){I=I.substr(1)}u(I)}else{if(I=g[7]){I=I.toLowerCase();if(q&&o.test(I)){I=I.substr(1)}O=I in M;if(y&&J[I]&&A.length>0&&A[A.length-1].name===I){u(I)}if(!v||(m=e.getElementRule(I))){k=true;if(v){P=m.attributes;F=m.attributePatterns}if(R=g[8]){z=R.indexOf("data-mce-type")!==-1;if(z&&s){k=false}N=[];N.map={};R.replace(D,p)}else{N=[];N.map={}}if(v&&!z){S=m.attributesRequired;L=m.attributesDefault;f=m.attributesForced;if(f){Q=f.length;while(Q--){t=f[Q];r=t.name;h=t.value;if(h==="{$uid}"){h="mce_"+x++}N.map[r]=h;N.push({name:r,value:h})}}if(L){Q=L.length;while(Q--){t=L[Q];r=t.name;if(!(r in N.map)){h=t.value;if(h==="{$uid}"){h="mce_"+x++}N.map[r]=h;N.push({name:r,value:h})}}}if(S){Q=S.length;while(Q--){if(S[Q] in N.map){break}}if(Q===-1){k=false}}if(N.map["data-mce-bogus"]){k=false}}if(k){n.start(I,N,O)}}else{k=false}if(B=K[I]){B.lastIndex=G=g.index+g[0].length;if(g=B.exec(E)){if(k){C=E.substr(G,g.index-G)}G=g.index+g[0].length}else{C=E.substr(G);G=E.length}if(k&&C.length>0){n.text(C,true)}if(k){n.end(I)}l.lastIndex=G;continue}if(!O){if(!R||R.indexOf("/")!=R.length-1){A.push({name:I,valid:k})}else{if(k){n.end(I)}}}}else{if(I=g[1]){n.comment(I)}else{if(I=g[2]){n.cdata(I)}else{if(I=g[3]){n.doctype(I)}else{if(I=g[4]){n.pi(I,g[5])}}}}}}G=g.index+g[0].length}if(G<E.length){n.text(j(E.substr(G)))}for(Q=A.length-1;Q>=0;Q--){I=A[Q];if(I.valid){n.end(I.name)}}}}})(tinymce);(function(d){var c=/^[ \t\r\n]*$/,e={"#text":3,"#comment":8,"#cdata":4,"#pi":7,"#doctype":10,"#document-fragment":11};function a(k,l,j){var i,h,f=j?"lastChild":"firstChild",g=j?"prev":"next";if(k[f]){return k[f]}if(k!==l){i=k[g];if(i){return i}for(h=k.parent;h&&h!==l;h=h.parent){i=h[g];if(i){return i}}}}function b(f,g){this.name=f;this.type=g;if(g===1){this.attributes=[];this.attributes.map={}}}d.extend(b.prototype,{replace:function(g){var f=this;if(g.parent){g.remove()}f.insert(g,f);f.remove();return f},attr:function(h,l){var f=this,g,j,k;if(typeof h!=="string"){for(j in h){f.attr(j,h[j])}return f}if(g=f.attributes){if(l!==k){if(l===null){if(h in g.map){delete g.map[h];j=g.length;while(j--){if(g[j].name===h){g=g.splice(j,1);return f}}}return f}if(h in g.map){j=g.length;while(j--){if(g[j].name===h){g[j].value=l;break}}}else{g.push({name:h,value:l})}g.map[h]=l;return f}else{return g.map[h]}}},clone:function(){var g=this,n=new b(g.name,g.type),h,f,m,j,k;if(m=g.attributes){k=[];k.map={};for(h=0,f=m.length;h<f;h++){j=m[h];if(j.name!=="id"){k[k.length]={name:j.name,value:j.value};k.map[j.name]=j.value}}n.attributes=k}n.value=g.value;n.shortEnded=g.shortEnded;return n},wrap:function(g){var f=this;f.parent.insert(g,f);g.append(f);return f},unwrap:function(){var f=this,h,g;for(h=f.firstChild;h;){g=h.next;f.insert(h,f,true);h=g}f.remove()},remove:function(){var f=this,h=f.parent,g=f.next,i=f.prev;if(h){if(h.firstChild===f){h.firstChild=g;if(g){g.prev=null}}else{i.next=g}if(h.lastChild===f){h.lastChild=i;if(i){i.next=null}}else{g.prev=i}f.parent=f.next=f.prev=null}return f},append:function(h){var f=this,g;if(h.parent){h.remove()}g=f.lastChild;if(g){g.next=h;h.prev=g;f.lastChild=h}else{f.lastChild=f.firstChild=h}h.parent=f;return h},insert:function(h,f,i){var g;if(h.parent){h.remove()}g=f.parent||this;if(i){if(f===g.firstChild){g.firstChild=h}else{f.prev.next=h}h.prev=f.prev;h.next=f;f.prev=h}else{if(f===g.lastChild){g.lastChild=h}else{f.next.prev=h}h.next=f.next;h.prev=f;f.next=h}h.parent=g;return h},getAll:function(g){var f=this,h,i=[];for(h=f.firstChild;h;h=a(h,f)){if(h.name===g){i.push(h)}}return i},empty:function(){var g=this,f,h,j;if(g.firstChild){f=[];for(j=g.firstChild;j;j=a(j,g)){f.push(j)}h=f.length;while(h--){j=f[h];j.parent=j.firstChild=j.lastChild=j.next=j.prev=null}}g.firstChild=g.lastChild=null;return g},isEmpty:function(k){var f=this,j=f.firstChild,h,g;if(j){do{if(j.type===1){if(j.attributes.map["data-mce-bogus"]){continue}if(k[j.name]){return false}h=j.attributes.length;while(h--){g=j.attributes[h].name;if(g==="name"||g.indexOf("data-")===0){return false}}}if(j.type===8){return false}if((j.type===3&&!c.test(j.value))){return false}}while(j=a(j,f))}return true},walk:function(f){return a(this,null,f)}});d.extend(b,{create:function(g,f){var i,h;i=new b(g,e[g]||1);if(f){for(h in f){i.attr(h,f[h])}}return i}});d.html.Node=b})(tinymce);(function(b){var a=b.html.Node;b.html.DomParser=function(g,h){var f=this,e={},d=[],i={},c={};g=g||{};g.validate="validate" in g?g.validate:true;g.root_name=g.root_name||"body";f.schema=h=h||new b.html.Schema();function j(m){var o,p,x,v,z,n,q,l,t,u,k,s,y,r;s=b.makeMap("tr,td,th,tbody,thead,tfoot,table");k=h.getNonEmptyElements();for(o=0;o<m.length;o++){p=m[o];if(!p.parent){continue}v=[p];for(x=p.parent;x&&!h.isValidChild(x.name,p.name)&&!s[x.name];x=x.parent){v.push(x)}if(x&&v.length>1){v.reverse();z=n=f.filterNode(v[0].clone());for(t=0;t<v.length-1;t++){if(h.isValidChild(n.name,v[t].name)){q=f.filterNode(v[t].clone());n.append(q)}else{q=n}for(l=v[t].firstChild;l&&l!=v[t+1];){r=l.next;q.append(l);l=r}n=q}if(!z.isEmpty(k)){x.insert(z,v[0],true);x.insert(p,z)}else{x.insert(p,v[0],true)}x=v[0];if(x.isEmpty(k)||x.firstChild===x.lastChild&&x.firstChild.name==="br"){x.empty().remove()}}else{if(p.parent){if(p.name==="li"){y=p.prev;if(y&&(y.name==="ul"||y.name==="ul")){y.append(p);continue}y=p.next;if(y&&(y.name==="ul"||y.name==="ul")){y.insert(p,y.firstChild,true);continue}p.wrap(f.filterNode(new a("ul",1)));continue}if(h.isValidChild(p.parent.name,"div")&&h.isValidChild("div",p.name)){p.wrap(f.filterNode(new a("div",1)))}else{if(p.name==="style"||p.name==="script"){p.empty().remove()}else{p.unwrap()}}}}}}f.filterNode=function(m){var l,k,n;if(k in e){n=i[k];if(n){n.push(m)}else{i[k]=[m]}}l=d.length;while(l--){k=d[l].name;if(k in m.attributes.map){n=c[k];if(n){n.push(m)}else{c[k]=[m]}}}return m};f.addNodeFilter=function(k,l){b.each(b.explode(k),function(m){var n=e[m];if(!n){e[m]=n=[]}n.push(l)})};f.addAttributeFilter=function(k,l){b.each(b.explode(k),function(m){var n;for(n=0;n<d.length;n++){if(d[n].name===m){d[n].callbacks.push(l);return}}d.push({name:m,callbacks:[l]})})};f.parse=function(v,m){var n,J,B,A,D,C,x,r,F,N,z,o,E,M=[],L,t,k,y,s,p,u,q;m=m||{};i={};c={};o=b.extend(b.makeMap("script,style,head,html,body,title,meta,param"),h.getBlockElements());u=h.getNonEmptyElements();p=h.children;z=g.validate;q="forced_root_block" in m?m.forced_root_block:g.forced_root_block;s=h.getWhiteSpaceElements();E=/^[ \t\r\n]+/;t=/[ \t\r\n]+$/;k=/[ \t\r\n]+/g;y=/^[ \t\r\n]+$/;function G(){var O=J.firstChild,l,P;while(O){l=O.next;if(O.type==3||(O.type==1&&O.name!=="p"&&!o[O.name]&&!O.attr("data-mce-type"))){if(!P){P=K(q,1);J.insert(P,O);P.append(O)}else{P.append(O)}}else{P=null}O=l}}function K(l,O){var P=new a(l,O),Q;if(l in e){Q=i[l];if(Q){Q.push(P)}else{i[l]=[P]}}return P}function I(P){var Q,l,O;for(Q=P.prev;Q&&Q.type===3;){l=Q.value.replace(t,"");if(l.length>0){Q.value=l;Q=Q.prev}else{O=Q.prev;Q.remove();Q=O}}}function H(O){var P,l={};for(P in O){if(P!=="li"&&P!="p"){l[P]=O[P]}}return l}n=new b.html.SaxParser({validate:z,self_closing_elements:H(h.getSelfClosingElements()),cdata:function(l){B.append(K("#cdata",4)).value=l},text:function(P,l){var O;if(!L){P=P.replace(k," ");if(B.lastChild&&o[B.lastChild.name]){P=P.replace(E,"")}}if(P.length!==0){O=K("#text",3);O.raw=!!l;B.append(O).value=P}},comment:function(l){B.append(K("#comment",8)).value=l},pi:function(l,O){B.append(K(l,7)).value=O;I(B)},doctype:function(O){var l;l=B.append(K("#doctype",10));l.value=O;I(B)},start:function(l,W,P){var U,R,Q,O,S,X,V,T;Q=z?h.getElementRule(l):{};if(Q){U=K(Q.outputName||l,1);U.attributes=W;U.shortEnded=P;B.append(U);T=p[B.name];if(T&&p[U.name]&&!T[U.name]){M.push(U)}R=d.length;while(R--){S=d[R].name;if(S in W.map){F=c[S];if(F){F.push(U)}else{c[S]=[U]}}}if(o[l]){I(U)}if(!P){B=U}if(!L&&s[l]){L=true}}},end:function(l){var S,P,R,O,Q;P=z?h.getElementRule(l):{};if(P){if(o[l]){if(!L){S=B.firstChild;if(S&&S.type===3){R=S.value.replace(E,"");if(R.length>0){S.value=R;S=S.next}else{O=S.next;S.remove();S=O}while(S&&S.type===3){R=S.value;O=S.next;if(R.length===0||y.test(R)){S.remove();S=O}S=O}}S=B.lastChild;if(S&&S.type===3){R=S.value.replace(t,"");if(R.length>0){S.value=R;S=S.prev}else{O=S.prev;S.remove();S=O}while(S&&S.type===3){R=S.value;O=S.prev;if(R.length===0||y.test(R)){S.remove();S=O}S=O}}}S=B.prev;if(S&&S.type===3){R=S.value.replace(E,"");if(R.length>0){S.value=R}else{S.remove()}}}if(L&&s[l]){L=false}if(P.removeEmpty||P.paddEmpty){if(B.isEmpty(u)){if(P.paddEmpty){B.empty().append(new a("#text","3")).value="\u00a0"}else{if(!B.attributes.map.name&&!B.attributes.map.id){Q=B.parent;B.empty().remove();B=Q;return}}}}B=B.parent}}},h);J=B=new a(m.context||g.root_name,11);n.parse(v);if(z&&M.length){if(!m.context){j(M)}else{m.invalid=true}}if(q&&J.name=="body"){G()}if(!m.invalid){for(N in i){F=e[N];A=i[N];x=A.length;while(x--){if(!A[x].parent){A.splice(x,1)}}for(D=0,C=F.length;D<C;D++){F[D](A,N,m)}}for(D=0,C=d.length;D<C;D++){F=d[D];if(F.name in c){A=c[F.name];x=A.length;while(x--){if(!A[x].parent){A.splice(x,1)}}for(x=0,r=F.callbacks.length;x<r;x++){F.callbacks[x](A,F.name,m)}}}}return J};if(g.remove_trailing_brs){f.addNodeFilter("br",function(n,m){var r,q=n.length,o,v=b.extend({},h.getBlockElements()),k=h.getNonEmptyElements(),t,s,p,u;v.body=1;for(r=0;r<q;r++){o=n[r];t=o.parent;if(v[o.parent.name]&&o===t.lastChild){p=o.prev;while(p){u=p.name;if(u!=="span"||p.attr("data-mce-type")!=="bookmark"){if(u!=="br"){break}if(u==="br"){o=null;break}}p=p.prev}if(o){o.remove();if(t.isEmpty(k)){elementRule=h.getElementRule(t.name);if(elementRule){if(elementRule.removeEmpty){t.remove()}else{if(elementRule.paddEmpty){t.empty().append(new b.html.Node("#text",3)).value="\u00a0"}}}}}}else{s=o;while(t.firstChild===s&&t.lastChild===s){s=t;if(v[t.name]){break}t=t.parent}if(s===t){textNode=new b.html.Node("#text",3);textNode.value="\u00a0";o.replace(textNode)}}}})}if(!g.allow_html_in_named_anchor){f.addAttributeFilter("id,name",function(k,l){var n=k.length,p,m,o,q;while(n--){q=k[n];if(q.name==="a"&&q.firstChild&&!q.attr("href")){o=q.parent;p=q.lastChild;do{m=p.prev;o.insert(p,q);p=m}while(p)}}})}}})(tinymce);tinymce.html.Writer=function(e){var c=[],a,b,d,f,g;e=e||{};a=e.indent;b=tinymce.makeMap(e.indent_before||"");d=tinymce.makeMap(e.indent_after||"");f=tinymce.html.Entities.getEncodeFunc(e.entity_encoding||"raw",e.entities);g=e.element_format=="html";return{start:function(m,k,p){var n,j,h,o;if(a&&b[m]&&c.length>0){o=c[c.length-1];if(o.length>0&&o!=="\n"){c.push("\n")}}c.push("<",m);if(k){for(n=0,j=k.length;n<j;n++){h=k[n];c.push(" ",h.name,'="',f(h.value,true),'"')}}if(!p||g){c[c.length]=">"}else{c[c.length]=" />"}if(p&&a&&d[m]&&c.length>0){o=c[c.length-1];if(o.length>0&&o!=="\n"){c.push("\n")}}},end:function(h){var i;c.push("</",h,">");if(a&&d[h]&&c.length>0){i=c[c.length-1];if(i.length>0&&i!=="\n"){c.push("\n")}}},text:function(i,h){if(i.length>0){c[c.length]=h?i:f(i)}},cdata:function(h){c.push("<![CDATA[",h,"]]>")},comment:function(h){c.push("<!--",h,"-->")},pi:function(h,i){if(i){c.push("<?",h," ",i,"?>")}else{c.push("<?",h,"?>")}if(a){c.push("\n")}},doctype:function(h){c.push("<!DOCTYPE",h,">",a?"\n":"")},reset:function(){c.length=0},getContent:function(){return c.join("").replace(/\n$/,"")}}};(function(a){a.html.Serializer=function(c,d){var b=this,e=new a.html.Writer(c);c=c||{};c.validate="validate" in c?c.validate:true;b.schema=d=d||new a.html.Schema();b.writer=e;b.serialize=function(h){var g,i;i=c.validate;g={3:function(k,j){e.text(k.value,k.raw)},8:function(j){e.comment(j.value)},7:function(j){e.pi(j.name,j.value)},10:function(j){e.doctype(j.value)},4:function(j){e.cdata(j.value)},11:function(j){if((j=j.firstChild)){do{f(j)}while(j=j.next)}}};e.reset();function f(k){var t=g[k.type],j,o,s,r,p,u,n,m,q;if(!t){j=k.name;o=k.shortEnded;s=k.attributes;if(i&&s&&s.length>1){u=[];u.map={};q=d.getElementRule(k.name);for(n=0,m=q.attributesOrder.length;n<m;n++){r=q.attributesOrder[n];if(r in s.map){p=s.map[r];u.map[r]=p;u.push({name:r,value:p})}}for(n=0,m=s.length;n<m;n++){r=s[n].name;if(!(r in u.map)){p=s.map[r];u.map[r]=p;u.push({name:r,value:p})}}s=u}e.start(k.name,s,o);if(!o){if((k=k.firstChild)){do{f(k)}while(k=k.next)}e.end(j)}}else{t(k)}}if(h.type==1&&!c.inner){f(h)}else{g[11](h)}return e.getContent()}}})(tinymce);tinymce.dom={};(function(b,h){var g=!!document.addEventListener;function c(k,j,l,i){if(k.addEventListener){k.addEventListener(j,l,i||false)}else{if(k.attachEvent){k.attachEvent("on"+j,l)}}}function e(k,j,l,i){if(k.removeEventListener){k.removeEventListener(j,l,i||false)}else{if(k.detachEvent){k.detachEvent("on"+j,l)}}}function a(n,l){var i,k=l||{};function j(){return false}function m(){return true}for(i in n){if(i!=="layerX"&&i!=="layerY"){k[i]=n[i]}}if(!k.target){k.target=k.srcElement||document}k.preventDefault=function(){k.isDefaultPrevented=m;if(n){if(n.preventDefault){n.preventDefault()}else{n.returnValue=false}}};k.stopPropagation=function(){k.isPropagationStopped=m;if(n){if(n.stopPropagation){n.stopPropagation()}else{n.cancelBubble=true}}};k.stopImmediatePropagation=function(){k.isImmediatePropagationStopped=m;k.stopPropagation()};if(!k.isDefaultPrevented){k.isDefaultPrevented=j;k.isPropagationStopped=j;k.isImmediatePropagationStopped=j}return k}function d(m,n,l){var k=m.document,j={type:"ready"};function i(){if(!l.domLoaded){l.domLoaded=true;n(j)}}if(g){c(m,"DOMContentLoaded",i)}else{c(k,"readystatechange",function(){if(k.readyState==="complete"){e(k,"readystatechange",arguments.callee);i()}});if(k.documentElement.doScroll&&m===m.top){(function(){try{k.documentElement.doScroll("left")}catch(o){setTimeout(arguments.callee,0);return}i()})()}}c(m,"load",i)}function f(k){var q=this,p={},i,o,n,m,l;m="onmouseenter" in document.documentElement;n="onfocusin" in document.documentElement;l={mouseenter:"mouseover",mouseleave:"mouseout"};i=1;q.domLoaded=false;q.events=p;function j(t,x){var s,u,r,v;s=p[x][t.type];if(s){for(u=0,r=s.length;u<r;u++){v=s[u];if(v&&v.func.call(v.scope,t)===false){t.preventDefault()}if(t.isImmediatePropagationStopped()){return}}}}q.bind=function(x,A,D,E){var s,t,u,r,B,z,C,v=window;function y(F){j(a(F||v.event),s)}if(!x||x.nodeType===3||x.nodeType===8){return}if(!x[h]){s=i++;x[h]=s;p[s]={}}else{s=x[h];if(!p[s]){p[s]={}}}E=E||x;A=A.split(" ");u=A.length;while(u--){r=A[u];z=y;B=C=false;if(r==="DOMContentLoaded"){r="ready"}if((q.domLoaded||x.readyState=="complete")&&r==="ready"){q.domLoaded=true;D.call(E,a({type:r}));continue}if(!m){B=l[r];if(B){z=function(F){var H,G;H=F.currentTarget;G=F.relatedTarget;if(G&&H.contains){G=H.contains(G)}else{while(G&&G!==H){G=G.parentNode}}if(!G){F=a(F||v.event);F.type=F.type==="mouseout"?"mouseleave":"mouseenter";F.target=H;j(F,s)}}}}if(!n&&(r==="focusin"||r==="focusout")){C=true;B=r==="focusin"?"focus":"blur";z=function(F){F=a(F||v.event);F.type=F.type==="focus"?"focusin":"focusout";j(F,s)}}t=p[s][r];if(!t){p[s][r]=t=[{func:D,scope:E}];t.fakeName=B;t.capture=C;t.nativeHandler=z;if(!g){t.proxyHandler=k(s)}if(r==="ready"){d(x,z,q)}else{c(x,B||r,g?z:t.proxyHandler,C)}}else{t.push({func:D,scope:E})}}x=t=0;return D};q.unbind=function(x,z,A){var s,u,v,B,r,t;if(!x||x.nodeType===3||x.nodeType===8){return q}s=x[h];if(s){t=p[s];if(z){z=z.split(" ");v=z.length;while(v--){r=z[v];u=t[r];if(u){if(A){B=u.length;while(B--){if(u[B].func===A){u.splice(B,1)}}}if(!A||u.length===0){delete t[r];e(x,u.fakeName||r,g?u.nativeHandler:u.proxyHandler,u.capture)}}}}else{for(r in t){u=t[r];e(x,u.fakeName||r,g?u.nativeHandler:u.proxyHandler,u.capture)}t={}}for(r in t){return q}delete p[s];try{delete x[h]}catch(y){x[h]=null}}return q};q.fire=function(u,s,r){var v,t;if(!u||u.nodeType===3||u.nodeType===8){return q}t=a(null,r);t.type=s;do{v=u[h];if(v){j(t,v)}u=u.parentNode||u.ownerDocument||u.defaultView||u.parentWindow}while(u&&!t.isPropagationStopped());return q};q.clean=function(u){var s,r,t=q.unbind;if(!u||u.nodeType===3||u.nodeType===8){return q}if(u[h]){t(u)}if(!u.getElementsByTagName){u=u.document}if(u&&u.getElementsByTagName){t(u);r=u.getElementsByTagName("*");s=r.length;while(s--){u=r[s];if(u[h]){t(u)}}}return q};q.callNativeHandler=function(s,r){if(p){p[s][r.type].nativeHandler(r)}};q.destory=function(){p={}};q.add=function(v,s,u,t){if(typeof(v)==="string"){v=document.getElementById(v)}if(v&&v instanceof Array){var r=v.length;while(r--){q.add(v[r],s,u,t)}return}if(s==="init"){s="ready"}return q.bind(v,s instanceof Array?s.join(" "):s,u,t)};q.remove=function(v,s,u,t){if(!v){return q}if(typeof(v)==="string"){v=document.getElementById(v)}if(v instanceof Array){var r=v.length;while(r--){q.remove(v[r],s,u,t)}return q}return q.unbind(v,s instanceof Array?s.join(" "):s,u)};q.clear=function(r){if(typeof(r)==="string"){r=document.getElementById(r)}return q.clean(r)};q.cancel=function(r){if(r){q.prevent(r);q.stop(r)}return false};q.prevent=function(r){if(!r.preventDefault){r=a(r)}r.preventDefault();return false};q.stop=function(r){if(!r.stopPropagation){r=a(r)}r.stopPropagation();return false}}b.EventUtils=f;b.Event=new f(function(i){return function(j){tinymce.dom.Event.callNativeHandler(i,j)}});b.Event.bind(window,"ready",function(){});b=0})(tinymce.dom,"data-mce-expando");tinymce.dom.TreeWalker=function(a,c){var b=a;function d(i,f,e,j){var h,g;if(i){if(!j&&i[f]){return i[f]}if(i!=c){h=i[e];if(h){return h}for(g=i.parentNode;g&&g!=c;g=g.parentNode){h=g[e];if(h){return h}}}}}this.current=function(){return b};this.next=function(e){return(b=d(b,"firstChild","nextSibling",e))};this.prev=function(e){return(b=d(b,"lastChild","previousSibling",e))}};(function(e){var g=e.each,d=e.is,f=e.isWebKit,b=e.isIE,h=e.html.Entities,c=/^([a-z0-9],?)+$/i,a=/^[ \t\r\n]*$/;e.create("tinymce.dom.DOMUtils",{doc:null,root:null,files:null,pixelStyles:/^(top|left|bottom|right|width|height|borderWidth)$/,props:{"for":"htmlFor","class":"className",className:"className",checked:"checked",disabled:"disabled",maxlength:"maxLength",readonly:"readOnly",selected:"selected",value:"value",id:"id",name:"name",type:"type"},DOMUtils:function(o,l){var k=this,i,j,n;k.doc=o;k.win=window;k.files={};k.cssFlicker=false;k.counter=0;k.stdMode=!e.isIE||o.documentMode>=8;k.boxModel=!e.isIE||o.compatMode=="CSS1Compat"||k.stdMode;k.hasOuterHTML="outerHTML" in o.createElement("a");k.settings=l=e.extend({keep_values:false,hex_colors:1},l);k.schema=l.schema;k.styles=new e.html.Styles({url_converter:l.url_converter,url_converter_scope:l.url_converter_scope},l.schema);if(e.isIE6){try{o.execCommand("BackgroundImageCache",false,true)}catch(m){k.cssFlicker=true}}k.fixDoc(o);k.events=l.ownEvents?new e.dom.EventUtils(l.proxy):e.dom.Event;e.addUnload(k.destroy,k);n=l.schema?l.schema.getBlockElements():{};k.isBlock=function(q){var p=q.nodeType;if(p){return !!(p===1&&n[q.nodeName])}return !!n[q]}},fixDoc:function(k){var j=this.settings,i;if(b&&j.schema){("abbr article aside audio canvas details figcaption figure footer header hgroup mark menu meter nav output progress section summary time video").replace(/\w+/g,function(l){k.createElement(l)});for(i in j.schema.getCustomElements()){k.createElement(i)}}},clone:function(k,i){var j=this,m,l;if(!b||k.nodeType!==1||i){return k.cloneNode(i)}l=j.doc;if(!i){m=l.createElement(k.nodeName);g(j.getAttribs(k),function(n){j.setAttrib(m,n.nodeName,j.getAttrib(k,n.nodeName))});return m}return m.firstChild},getRoot:function(){var i=this,j=i.settings;return(j&&i.get(j.root_element))||i.doc.body},getViewPort:function(j){var k,i;j=!j?this.win:j;k=j.document;i=this.boxModel?k.documentElement:k.body;return{x:j.pageXOffset||i.scrollLeft,y:j.pageYOffset||i.scrollTop,w:j.innerWidth||i.clientWidth,h:j.innerHeight||i.clientHeight}},getRect:function(l){var k,i=this,j;l=i.get(l);k=i.getPos(l);j=i.getSize(l);return{x:k.x,y:k.y,w:j.w,h:j.h}},getSize:function(l){var j=this,i,k;l=j.get(l);i=j.getStyle(l,"width");k=j.getStyle(l,"height");if(i.indexOf("px")===-1){i=0}if(k.indexOf("px")===-1){k=0}return{w:parseInt(i,10)||l.offsetWidth||l.clientWidth,h:parseInt(k,10)||l.offsetHeight||l.clientHeight}},getParent:function(k,j,i){return this.getParents(k,j,i,false)},getParents:function(s,m,k,q){var j=this,i,l=j.settings,p=[];s=j.get(s);q=q===undefined;if(l.strict_root){k=k||j.getRoot()}if(d(m,"string")){i=m;if(m==="*"){m=function(o){return o.nodeType==1}}else{m=function(o){return j.is(o,i)}}}while(s){if(s==k||!s.nodeType||s.nodeType===9){break}if(!m||m(s)){if(q){p.push(s)}else{return s}}s=s.parentNode}return q?p:null},get:function(i){var j;if(i&&this.doc&&typeof(i)=="string"){j=i;i=this.doc.getElementById(i);if(i&&i.id!==j){return this.doc.getElementsByName(j)[1]}}return i},getNext:function(j,i){return this._findSib(j,i,"nextSibling")},getPrev:function(j,i){return this._findSib(j,i,"previousSibling")},select:function(k,j){var i=this;return e.dom.Sizzle(k,i.get(j)||i.get(i.settings.root_element)||i.doc,[])},is:function(l,j){var k;if(l.length===undefined){if(j==="*"){return l.nodeType==1}if(c.test(j)){j=j.toLowerCase().split(/,/);l=l.nodeName.toLowerCase();for(k=j.length-1;k>=0;k--){if(j[k]==l){return true}}return false}}return e.dom.Sizzle.matches(j,l.nodeType?[l]:l).length>0},add:function(l,o,i,k,m){var j=this;return this.run(l,function(r){var q,n;q=d(o,"string")?j.doc.createElement(o):o;j.setAttribs(q,i);if(k){if(k.nodeType){q.appendChild(k)}else{j.setHTML(q,k)}}return !m?r.appendChild(q):q})},create:function(k,i,j){return this.add(this.doc.createElement(k),k,i,j,1)},createHTML:function(q,i,m){var p="",l=this,j;p+="<"+q;for(j in i){if(i.hasOwnProperty(j)){p+=" "+j+'="'+l.encode(i[j])+'"'}}if(typeof(m)!="undefined"){return p+">"+m+"</"+q+">"}return p+" />"},remove:function(i,j){return this.run(i,function(l){var m,k=l.parentNode;if(!k){return null}if(j){while(m=l.firstChild){if(!e.isIE||m.nodeType!==3||m.nodeValue){k.insertBefore(m,l)}else{l.removeChild(m)}}}return k.removeChild(l)})},setStyle:function(l,i,j){var k=this;return k.run(l,function(o){var n,m;n=o.style;i=i.replace(/-(\D)/g,function(q,p){return p.toUpperCase()});if(k.pixelStyles.test(i)&&(e.is(j,"number")||/^[\-0-9\.]+$/.test(j))){j+="px"}switch(i){case"opacity":if(b){n.filter=j===""?"":"alpha(opacity="+(j*100)+")";if(!l.currentStyle||!l.currentStyle.hasLayout){n.display="inline-block"}}n[i]=n["-moz-opacity"]=n["-khtml-opacity"]=j||"";break;case"float":b?n.styleFloat=j:n.cssFloat=j;break;default:n[i]=j||""}if(k.settings.update_styles){k.setAttrib(o,"data-mce-style")}})},getStyle:function(l,i,k){l=this.get(l);if(!l){return}if(this.doc.defaultView&&k){i=i.replace(/[A-Z]/g,function(m){return"-"+m});try{return this.doc.defaultView.getComputedStyle(l,null).getPropertyValue(i)}catch(j){return null}}i=i.replace(/-(\D)/g,function(n,m){return m.toUpperCase()});if(i=="float"){i=b?"styleFloat":"cssFloat"}if(l.currentStyle&&k){return l.currentStyle[i]}return l.style?l.style[i]:undefined},setStyles:function(l,m){var j=this,k=j.settings,i;i=k.update_styles;k.update_styles=0;g(m,function(o,p){j.setStyle(l,p,o)});k.update_styles=i;if(k.update_styles){j.setAttrib(l,k.cssText)}},removeAllAttribs:function(i){return this.run(i,function(l){var k,j=l.attributes;for(k=j.length-1;k>=0;k--){l.removeAttributeNode(j.item(k))}})},setAttrib:function(k,l,i){var j=this;if(!k||!l){return}if(j.settings.strict){l=l.toLowerCase()}return this.run(k,function(p){var o=j.settings;var m=p.getAttribute(l);if(i!==null){switch(l){case"style":if(!d(i,"string")){g(i,function(q,r){j.setStyle(p,r,q)});return}if(o.keep_values){if(i&&!j._isRes(i)){p.setAttribute("data-mce-style",i,2)}else{p.removeAttribute("data-mce-style",2)}}p.style.cssText=i;break;case"class":p.className=i||"";break;case"src":case"href":if(o.keep_values){if(o.url_converter){i=o.url_converter.call(o.url_converter_scope||j,i,l,p)}j.setAttrib(p,"data-mce-"+l,i,2)}break;case"shape":p.setAttribute("data-mce-style",i);break}}if(d(i)&&i!==null&&i.length!==0){p.setAttribute(l,""+i,2)}else{p.removeAttribute(l,2)}if(tinyMCE.activeEditor&&m!=i){var n=tinyMCE.activeEditor;n.onSetAttrib.dispatch(n,p,l,i)}})},setAttribs:function(j,k){var i=this;return this.run(j,function(l){g(k,function(m,o){i.setAttrib(l,o,m)})})},getAttrib:function(m,o,k){var i,j=this,l;m=j.get(m);if(!m||m.nodeType!==1){return k===l?false:k}if(!d(k)){k=""}if(/^(src|href|style|coords|shape)$/.test(o)){i=m.getAttribute("data-mce-"+o);if(i){return i}}if(b&&j.props[o]){i=m[j.props[o]];i=i&&i.nodeValue?i.nodeValue:i}if(!i){i=m.getAttribute(o,2)}if(/^(checked|compact|declare|defer|disabled|ismap|multiple|nohref|noshade|nowrap|readonly|selected)$/.test(o)){if(m[j.props[o]]===true&&i===""){return o}return i?o:""}if(m.nodeName==="FORM"&&m.getAttributeNode(o)){return m.getAttributeNode(o).nodeValue}if(o==="style"){i=i||m.style.cssText;if(i){i=j.serializeStyle(j.parseStyle(i),m.nodeName);if(j.settings.keep_values&&!j._isRes(i)){m.setAttribute("data-mce-style",i)}}}if(f&&o==="class"&&i){i=i.replace(/(apple|webkit)\-[a-z\-]+/gi,"")}if(b){switch(o){case"rowspan":case"colspan":if(i===1){i=""}break;case"size":if(i==="+0"||i===20||i===0){i=""}break;case"width":case"height":case"vspace":case"checked":case"disabled":case"readonly":if(i===0){i=""}break;case"hspace":if(i===-1){i=""}break;case"maxlength":case"tabindex":if(i===32768||i===2147483647||i==="32768"){i=""}break;case"multiple":case"compact":case"noshade":case"nowrap":if(i===65535){return o}return k;case"shape":i=i.toLowerCase();break;default:if(o.indexOf("on")===0&&i){i=e._replace(/^function\s+\w+\(\)\s+\{\s+(.*)\s+\}$/,"$1",""+i)}}}return(i!==l&&i!==null&&i!=="")?""+i:k},getPos:function(q,l){var j=this,i=0,p=0,m,o=j.doc,k;q=j.get(q);l=l||o.body;if(q){if(q.getBoundingClientRect){q=q.getBoundingClientRect();m=j.boxModel?o.documentElement:o.body;i=q.left+(o.documentElement.scrollLeft||o.body.scrollLeft)-m.clientTop;p=q.top+(o.documentElement.scrollTop||o.body.scrollTop)-m.clientLeft;return{x:i,y:p}}k=q;while(k&&k!=l&&k.nodeType){i+=k.offsetLeft||0;p+=k.offsetTop||0;k=k.offsetParent}k=q.parentNode;while(k&&k!=l&&k.nodeType){i-=k.scrollLeft||0;p-=k.scrollTop||0;k=k.parentNode}}return{x:i,y:p}},parseStyle:function(i){return this.styles.parse(i)},serializeStyle:function(j,i){return this.styles.serialize(j,i)},addStyle:function(j){var k=this.doc,i;styleElm=k.getElementById("mceDefaultStyles");if(!styleElm){styleElm=k.createElement("style"),styleElm.id="mceDefaultStyles";styleElm.type="text/css";i=k.getElementsByTagName("head")[0];if(i.firstChild){i.insertBefore(styleElm,i.firstChild)}else{i.appendChild(styleElm)}}if(styleElm.styleSheet){styleElm.styleSheet.cssText+=j}else{styleElm.appendChild(k.createTextNode(j))}},loadCSS:function(i){var k=this,l=k.doc,j;if(!i){i=""}j=l.getElementsByTagName("head")[0];g(i.split(","),function(m){var n;if(k.files[m]){return}k.files[m]=true;n=k.create("link",{rel:"stylesheet",href:e._addVer(m)});if(b&&l.documentMode&&l.recalc){n.onload=function(){if(l.recalc){l.recalc()}n.onload=null}}j.appendChild(n)})},addClass:function(i,j){return this.run(i,function(k){var l;if(!j){return 0}if(this.hasClass(k,j)){return k.className}l=this.removeClass(k,j);return k.className=(l!=""?(l+" "):"")+j})},removeClass:function(k,l){var i=this,j;return i.run(k,function(n){var m;if(i.hasClass(n,l)){if(!j){j=new RegExp("(^|\\s+)"+l+"(\\s+|$)","g")}m=n.className.replace(j," ");m=e.trim(m!=" "?m:"");n.className=m;if(!m){n.removeAttribute("class");n.removeAttribute("className")}return m}return n.className})},hasClass:function(j,i){j=this.get(j);if(!j||!i){return false}return(" "+j.className+" ").indexOf(" "+i+" ")!==-1},show:function(i){return this.setStyle(i,"display","block")},hide:function(i){return this.setStyle(i,"display","none")},isHidden:function(i){i=this.get(i);return !i||i.style.display=="none"||this.getStyle(i,"display")=="none"},uniqueId:function(i){return(!i?"mce_":i)+(this.counter++)},setHTML:function(k,j){var i=this;return i.run(k,function(m){if(b){while(m.firstChild){m.removeChild(m.firstChild)}try{m.innerHTML="<br />"+j;m.removeChild(m.firstChild)}catch(l){var n=i.create("div");n.innerHTML="<br />"+j;g(e.grep(n.childNodes),function(p,o){if(o&&m.canHaveHTML){m.appendChild(p)}})}}else{m.innerHTML=j}return j})},getOuterHTML:function(k){var j,i=this;k=i.get(k);if(!k){return null}if(k.nodeType===1&&i.hasOuterHTML){return k.outerHTML}j=(k.ownerDocument||i.doc).createElement("body");j.appendChild(k.cloneNode(true));return j.innerHTML},setOuterHTML:function(l,j,m){var i=this;function k(p,o,r){var s,q;q=r.createElement("body");q.innerHTML=o;s=q.lastChild;while(s){i.insertAfter(s.cloneNode(true),p);s=s.previousSibling}i.remove(p)}return this.run(l,function(o){o=i.get(o);if(o.nodeType==1){m=m||o.ownerDocument||i.doc;if(b){try{if(b&&o.nodeType==1){o.outerHTML=j}else{k(o,j,m)}}catch(n){k(o,j,m)}}else{k(o,j,m)}}})},decode:h.decode,encode:h.encodeAllRaw,insertAfter:function(i,j){j=this.get(j);return this.run(i,function(l){var k,m;k=j.parentNode;m=j.nextSibling;if(m){k.insertBefore(l,m)}else{k.appendChild(l)}return l})},replace:function(m,l,i){var j=this;if(d(l,"array")){m=m.cloneNode(true)}return j.run(l,function(k){if(i){g(e.grep(k.childNodes),function(n){m.appendChild(n)})}return k.parentNode.replaceChild(m,k)})},rename:function(l,i){var k=this,j;if(l.nodeName!=i.toUpperCase()){j=k.create(i);g(k.getAttribs(l),function(m){k.setAttrib(j,m.nodeName,k.getAttrib(l,m.nodeName))});k.replace(j,l,1)}return j||l},findCommonAncestor:function(k,i){var l=k,j;while(l){j=i;while(j&&l!=j){j=j.parentNode}if(l==j){break}l=l.parentNode}if(!l&&k.ownerDocument){return k.ownerDocument.documentElement}return l},toHex:function(i){var k=/^\s*rgb\s*?\(\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?,\s*?([0-9]+)\s*?\)\s*$/i.exec(i);function j(l){l=parseInt(l,10).toString(16);return l.length>1?l:"0"+l}if(k){i="#"+j(k[1])+j(k[2])+j(k[3]);return i}return i},getClasses:function(){var n=this,j=[],m,o={},p=n.settings.class_filter,l;if(n.classes){return n.classes}function q(i){g(i.imports,function(s){q(s)});g(i.cssRules||i.rules,function(s){switch(s.type||1){case 1:if(s.selectorText){g(s.selectorText.split(","),function(r){r=r.replace(/^\s*|\s*$|^\s\./g,"");if(/\.mce/.test(r)||!/\.[\w\-]+$/.test(r)){return}l=r;r=e._replace(/.*\.([a-z0-9_\-]+).*/i,"$1",r);if(p&&!(r=p(r,l))){return}if(!o[r]){j.push({"class":r});o[r]=1}})}break;case 3:q(s.styleSheet);break}})}try{g(n.doc.styleSheets,q)}catch(k){}if(j.length>0){n.classes=j}return j},run:function(l,k,j){var i=this,m;if(i.doc&&typeof(l)==="string"){l=i.get(l)}if(!l){return false}j=j||this;if(!l.nodeType&&(l.length||l.length===0)){m=[];g(l,function(o,n){if(o){if(typeof(o)=="string"){o=i.doc.getElementById(o)}m.push(k.call(j,o,n))}});return m}return k.call(j,l)},getAttribs:function(j){var i;j=this.get(j);if(!j){return[]}if(b){i=[];if(j.nodeName=="OBJECT"){return j.attributes}if(j.nodeName==="OPTION"&&this.getAttrib(j,"selected")){i.push({specified:1,nodeName:"selected"})}j.cloneNode(false).outerHTML.replace(/<\/?[\w:\-]+ ?|=[\"][^\"]+\"|=\'[^\']+\'|=[\w\-]+|>/gi,"").replace(/[\w:\-]+/gi,function(k){i.push({specified:1,nodeName:k})});return i}return j.attributes},isEmpty:function(m,k){var r=this,o,n,q,j,l,p=0;m=m.firstChild;if(m){j=new e.dom.TreeWalker(m,m.parentNode);k=k||r.schema?r.schema.getNonEmptyElements():null;do{q=m.nodeType;if(q===1){if(m.getAttribute("data-mce-bogus")){continue}l=m.nodeName.toLowerCase();if(k&&k[l]){if(l==="br"){p++;continue}return false}n=r.getAttribs(m);o=m.attributes.length;while(o--){l=m.attributes[o].nodeName;if(l==="name"||l==="data-mce-bookmark"){return false}}}if(q==8){return false}if((q===3&&!a.test(m.nodeValue))){return false}}while(m=j.next())}return p<=1},destroy:function(j){var i=this;i.win=i.doc=i.root=i.events=i.frag=null;if(!j){e.removeUnload(i.destroy)}},createRng:function(){var i=this.doc;return i.createRange?i.createRange():new e.dom.Range(this)},nodeIndex:function(m,n){var i=0,k,l,j;if(m){for(k=m.nodeType,m=m.previousSibling,l=m;m;m=m.previousSibling){j=m.nodeType;if(n&&j==3){if(j==k||!m.nodeValue.length){continue}}i++;k=j}}return i},split:function(m,l,p){var q=this,i=q.createRng(),n,k,o;function j(v){var t,s=v.childNodes,u=v.nodeType;function x(A){var z=A.previousSibling&&A.previousSibling.nodeName=="SPAN";var y=A.nextSibling&&A.nextSibling.nodeName=="SPAN";return z&&y}if(u==1&&v.getAttribute("data-mce-type")=="bookmark"){return}for(t=s.length-1;t>=0;t--){j(s[t])}if(u!=9){if(u==3&&v.nodeValue.length>0){var r=e.trim(v.nodeValue).length;if(!q.isBlock(v.parentNode)||r>0||r===0&&x(v)){return}}else{if(u==1){s=v.childNodes;if(s.length==1&&s[0]&&s[0].nodeType==1&&s[0].getAttribute("data-mce-type")=="bookmark"){v.parentNode.insertBefore(s[0],v)}if(s.length||/^(br|hr|input|img)$/i.test(v.nodeName)){return}}}q.remove(v)}return v}if(m&&l){i.setStart(m.parentNode,q.nodeIndex(m));i.setEnd(l.parentNode,q.nodeIndex(l));n=i.extractContents();i=q.createRng();i.setStart(l.parentNode,q.nodeIndex(l)+1);i.setEnd(m.parentNode,q.nodeIndex(m)+1);k=i.extractContents();o=m.parentNode;o.insertBefore(j(n),m);if(p){o.replaceChild(p,l)}else{o.insertBefore(l,m)}o.insertBefore(j(k),m);q.remove(m);return p||l}},bind:function(l,i,k,j){return this.events.add(l,i,k,j||this)},unbind:function(k,i,j){return this.events.remove(k,i,j)},fire:function(k,j,i){return this.events.fire(k,j,i)},getContentEditable:function(j){var i;if(j.nodeType!=1){return null}i=j.getAttribute("data-mce-contenteditable");if(i&&i!=="inherit"){return i}return j.contentEditable!=="inherit"?j.contentEditable:null},_findSib:function(l,i,j){var k=this,m=i;if(l){if(d(m,"string")){m=function(n){return k.is(n,i)}}for(l=l[j];l;l=l[j]){if(m(l)){return l}}}return null},_isRes:function(i){return/^(top|left|bottom|right|width|height)/i.test(i)||/;\s*(top|left|bottom|right|width|height)/i.test(i)}});e.DOM=new e.dom.DOMUtils(document,{process_html:0})})(tinymce);(function(a){function b(c){var O=this,e=c.doc,U=0,F=1,j=2,E=true,S=false,W="startOffset",h="startContainer",Q="endContainer",A="endOffset",k=tinymce.extend,n=c.nodeIndex;k(O,{startContainer:e,startOffset:0,endContainer:e,endOffset:0,collapsed:E,commonAncestorContainer:e,START_TO_START:0,START_TO_END:1,END_TO_END:2,END_TO_START:3,setStart:q,setEnd:s,setStartBefore:g,setStartAfter:J,setEndBefore:K,setEndAfter:u,collapse:B,selectNode:y,selectNodeContents:G,compareBoundaryPoints:v,deleteContents:p,extractContents:I,cloneContents:d,insertNode:D,surroundContents:N,cloneRange:L,toStringIE:T});function x(){return e.createDocumentFragment()}function q(X,t){C(E,X,t)}function s(X,t){C(S,X,t)}function g(t){q(t.parentNode,n(t))}function J(t){q(t.parentNode,n(t)+1)}function K(t){s(t.parentNode,n(t))}function u(t){s(t.parentNode,n(t)+1)}function B(t){if(t){O[Q]=O[h];O[A]=O[W]}else{O[h]=O[Q];O[W]=O[A]}O.collapsed=E}function y(t){g(t);u(t)}function G(t){q(t,0);s(t,t.nodeType===1?t.childNodes.length:t.nodeValue.length)}function v(aa,t){var ad=O[h],Y=O[W],ac=O[Q],X=O[A],ab=t.startContainer,af=t.startOffset,Z=t.endContainer,ae=t.endOffset;if(aa===0){return H(ad,Y,ab,af)}if(aa===1){return H(ac,X,ab,af)}if(aa===2){return H(ac,X,Z,ae)}if(aa===3){return H(ad,Y,Z,ae)}}function p(){l(j)}function I(){return l(U)}function d(){return l(F)}function D(aa){var X=this[h],t=this[W],Z,Y;if((X.nodeType===3||X.nodeType===4)&&X.nodeValue){if(!t){X.parentNode.insertBefore(aa,X)}else{if(t>=X.nodeValue.length){c.insertAfter(aa,X)}else{Z=X.splitText(t);X.parentNode.insertBefore(aa,Z)}}}else{if(X.childNodes.length>0){Y=X.childNodes[t]}if(Y){X.insertBefore(aa,Y)}else{X.appendChild(aa)}}}function N(X){var t=O.extractContents();O.insertNode(X);X.appendChild(t);O.selectNode(X)}function L(){return k(new b(c),{startContainer:O[h],startOffset:O[W],endContainer:O[Q],endOffset:O[A],collapsed:O.collapsed,commonAncestorContainer:O.commonAncestorContainer})}function P(t,X){var Y;if(t.nodeType==3){return t}if(X<0){return t}Y=t.firstChild;while(Y&&X>0){--X;Y=Y.nextSibling}if(Y){return Y}return t}function m(){return(O[h]==O[Q]&&O[W]==O[A])}function H(Z,ab,X,aa){var ac,Y,t,ad,af,ae;if(Z==X){if(ab==aa){return 0}if(ab<aa){return -1}return 1}ac=X;while(ac&&ac.parentNode!=Z){ac=ac.parentNode}if(ac){Y=0;t=Z.firstChild;while(t!=ac&&Y<ab){Y++;t=t.nextSibling}if(ab<=Y){return -1}return 1}ac=Z;while(ac&&ac.parentNode!=X){ac=ac.parentNode}if(ac){Y=0;t=X.firstChild;while(t!=ac&&Y<aa){Y++;t=t.nextSibling}if(Y<aa){return -1}return 1}ad=c.findCommonAncestor(Z,X);af=Z;while(af&&af.parentNode!=ad){af=af.parentNode}if(!af){af=ad}ae=X;while(ae&&ae.parentNode!=ad){ae=ae.parentNode}if(!ae){ae=ad}if(af==ae){return 0}t=ad.firstChild;while(t){if(t==af){return -1}if(t==ae){return 1}t=t.nextSibling}}function C(X,aa,Z){var t,Y;if(X){O[h]=aa;O[W]=Z}else{O[Q]=aa;O[A]=Z}t=O[Q];while(t.parentNode){t=t.parentNode}Y=O[h];while(Y.parentNode){Y=Y.parentNode}if(Y==t){if(H(O[h],O[W],O[Q],O[A])>0){O.collapse(X)}}else{O.collapse(X)}O.collapsed=m();O.commonAncestorContainer=c.findCommonAncestor(O[h],O[Q])}function l(ad){var ac,Z=0,af=0,X,ab,Y,aa,t,ae;if(O[h]==O[Q]){return f(ad)}for(ac=O[Q],X=ac.parentNode;X;ac=X,X=X.parentNode){if(X==O[h]){return r(ac,ad)}++Z}for(ac=O[h],X=ac.parentNode;X;ac=X,X=X.parentNode){if(X==O[Q]){return V(ac,ad)}++af}ab=af-Z;Y=O[h];while(ab>0){Y=Y.parentNode;ab--}aa=O[Q];while(ab<0){aa=aa.parentNode;ab++}for(t=Y.parentNode,ae=aa.parentNode;t!=ae;t=t.parentNode,ae=ae.parentNode){Y=t;aa=ae}return o(Y,aa,ad)}function f(ac){var ae,af,t,Y,Z,ad,aa,X,ab;if(ac!=j){ae=x()}if(O[W]==O[A]){return ae}if(O[h].nodeType==3){af=O[h].nodeValue;t=af.substring(O[W],O[A]);if(ac!=F){Y=O[h];X=O[W];ab=O[A]-O[W];if(X===0&&ab>=Y.nodeValue.length-1){Y.parentNode.removeChild(Y)}else{Y.deleteData(X,ab)}O.collapse(E)}if(ac==j){return}if(t.length>0){ae.appendChild(e.createTextNode(t))}return ae}Y=P(O[h],O[W]);Z=O[A]-O[W];while(Y&&Z>0){ad=Y.nextSibling;aa=z(Y,ac);if(ae){ae.appendChild(aa)}--Z;Y=ad}if(ac!=F){O.collapse(E)}return ae}function r(ad,aa){var ac,ab,X,t,Z,Y;if(aa!=j){ac=x()}ab=i(ad,aa);if(ac){ac.appendChild(ab)}X=n(ad);t=X-O[W];if(t<=0){if(aa!=F){O.setEndBefore(ad);O.collapse(S)}return ac}ab=ad.previousSibling;while(t>0){Z=ab.previousSibling;Y=z(ab,aa);if(ac){ac.insertBefore(Y,ac.firstChild)}--t;ab=Z}if(aa!=F){O.setEndBefore(ad);O.collapse(S)}return ac}function V(ab,aa){var ad,X,ac,t,Z,Y;if(aa!=j){ad=x()}ac=R(ab,aa);if(ad){ad.appendChild(ac)}X=n(ab);++X;t=O[A]-X;ac=ab.nextSibling;while(ac&&t>0){Z=ac.nextSibling;Y=z(ac,aa);if(ad){ad.appendChild(Y)}--t;ac=Z}if(aa!=F){O.setStartAfter(ab);O.collapse(E)}return ad}function o(ab,t,ae){var Y,ag,aa,ac,ad,X,af,Z;if(ae!=j){ag=x()}Y=R(ab,ae);if(ag){ag.appendChild(Y)}aa=ab.parentNode;ac=n(ab);ad=n(t);++ac;X=ad-ac;af=ab.nextSibling;while(X>0){Z=af.nextSibling;Y=z(af,ae);if(ag){ag.appendChild(Y)}af=Z;--X}Y=i(t,ae);if(ag){ag.appendChild(Y)}if(ae!=F){O.setStartAfter(ab);O.collapse(E)}return ag}function i(ac,ad){var Y=P(O[Q],O[A]-1),ae,ab,aa,t,X,Z=Y!=O[Q];if(Y==ac){return M(Y,Z,S,ad)}ae=Y.parentNode;ab=M(ae,S,S,ad);while(ae){while(Y){aa=Y.previousSibling;t=M(Y,Z,S,ad);if(ad!=j){ab.insertBefore(t,ab.firstChild)}Z=E;Y=aa}if(ae==ac){return ab}Y=ae.previousSibling;ae=ae.parentNode;X=M(ae,S,S,ad);if(ad!=j){X.appendChild(ab)}ab=X}}function R(ac,ad){var Z=P(O[h],O[W]),aa=Z!=O[h],ae,ab,Y,t,X;if(Z==ac){return M(Z,aa,E,ad)}ae=Z.parentNode;ab=M(ae,S,E,ad);while(ae){while(Z){Y=Z.nextSibling;t=M(Z,aa,E,ad);if(ad!=j){ab.appendChild(t)}aa=E;Z=Y}if(ae==ac){return ab}Z=ae.nextSibling;ae=ae.parentNode;X=M(ae,S,E,ad);if(ad!=j){X.appendChild(ab)}ab=X}}function M(t,aa,ad,ae){var Z,Y,ab,X,ac;if(aa){return z(t,ae)}if(t.nodeType==3){Z=t.nodeValue;if(ad){X=O[W];Y=Z.substring(X);ab=Z.substring(0,X)}else{X=O[A];Y=Z.substring(0,X);ab=Z.substring(X)}if(ae!=F){t.nodeValue=ab}if(ae==j){return}ac=c.clone(t,S);ac.nodeValue=Y;return ac}if(ae==j){return}return c.clone(t,S)}function z(X,t){if(t!=j){return t==F?c.clone(X,E):X}X.parentNode.removeChild(X)}function T(){return c.create("body",null,d()).outerText}return O}a.Range=b;b.prototype.toString=function(){return this.toStringIE()}})(tinymce.dom);(function(){function a(d){var b=this,h=d.dom,c=true,f=false;function e(i,j){var k,t=0,q,n,m,l,o,r,p=-1,s;k=i.duplicate();k.collapse(j);s=k.parentElement();if(s.ownerDocument!==d.dom.doc){return}while(s.contentEditable==="false"){s=s.parentNode}if(!s.hasChildNodes()){return{node:s,inside:1}}m=s.children;q=m.length-1;while(t<=q){r=Math.floor((t+q)/2);l=m[r];k.moveToElementText(l);p=k.compareEndPoints(j?"StartToStart":"EndToEnd",i);if(p>0){q=r-1}else{if(p<0){t=r+1}else{return{node:l}}}}if(p<0){if(!l){k.moveToElementText(s);k.collapse(true);l=s;n=true}else{k.collapse(false)}o=0;while(k.compareEndPoints(j?"StartToStart":"StartToEnd",i)!==0){if(k.move("character",1)===0||s!=k.parentElement()){break}o++}}else{k.collapse(true);o=0;while(k.compareEndPoints(j?"StartToStart":"StartToEnd",i)!==0){if(k.move("character",-1)===0||s!=k.parentElement()){break}o++}}return{node:l,position:p,offset:o,inside:n}}function g(){var i=d.getRng(),r=h.createRng(),l,k,p,q,m,j;l=i.item?i.item(0):i.parentElement();if(l.ownerDocument!=h.doc){return r}k=d.isCollapsed();if(i.item){r.setStart(l.parentNode,h.nodeIndex(l));r.setEnd(r.startContainer,r.startOffset+1);return r}function o(A){var u=e(i,A),s,y,z=0,x,v,t;s=u.node;y=u.offset;if(u.inside&&!s.hasChildNodes()){r[A?"setStart":"setEnd"](s,0);return}if(y===v){r[A?"setStartBefore":"setEndAfter"](s);return}if(u.position<0){x=u.inside?s.firstChild:s.nextSibling;if(!x){r[A?"setStartAfter":"setEndAfter"](s);return}if(!y){if(x.nodeType==3){r[A?"setStart":"setEnd"](x,0)}else{r[A?"setStartBefore":"setEndBefore"](x)}return}while(x){t=x.nodeValue;z+=t.length;if(z>=y){s=x;z-=y;z=t.length-z;break}x=x.nextSibling}}else{x=s.previousSibling;if(!x){return r[A?"setStartBefore":"setEndBefore"](s)}if(!y){if(s.nodeType==3){r[A?"setStart":"setEnd"](x,s.nodeValue.length)}else{r[A?"setStartAfter":"setEndAfter"](x)}return}while(x){z+=x.nodeValue.length;if(z>=y){s=x;z-=y;break}x=x.previousSibling}}r[A?"setStart":"setEnd"](s,z)}try{o(true);if(!k){o()}}catch(n){if(n.number==-2147024809){m=b.getBookmark(2);p=i.duplicate();p.collapse(true);l=p.parentElement();if(!k){p=i.duplicate();p.collapse(false);q=p.parentElement();q.innerHTML=q.innerHTML}l.innerHTML=l.innerHTML;b.moveToBookmark(m);i=d.getRng();o(true);if(!k){o()}}else{throw n}}return r}this.getBookmark=function(m){var j=d.getRng(),o,i,l={};function n(u){var t,p,s,r,q=[];t=u.parentNode;p=h.getRoot().parentNode;while(t!=p&&t.nodeType!==9){s=t.children;r=s.length;while(r--){if(u===s[r]){q.push(r);break}}u=t;t=t.parentNode}return q}function k(q){var p;p=e(j,q);if(p){return{position:p.position,offset:p.offset,indexes:n(p.node),inside:p.inside}}}if(m===2){if(!j.item){l.start=k(true);if(!d.isCollapsed()){l.end=k()}}else{l.start={ctrl:true,indexes:n(j.item(0))}}}return l};this.moveToBookmark=function(k){var j,i=h.doc.body;function m(o){var r,q,n,p;r=h.getRoot();for(q=o.length-1;q>=0;q--){p=r.children;n=o[q];if(n<=p.length-1){r=p[n]}}return r}function l(r){var n=k[r?"start":"end"],q,p,o;if(n){q=n.position>0;p=i.createTextRange();p.moveToElementText(m(n.indexes));offset=n.offset;if(offset!==o){p.collapse(n.inside||q);p.moveStart("character",q?-offset:offset)}else{p.collapse(r)}j.setEndPoint(r?"StartToStart":"EndToStart",p);if(r){j.collapse(true)}}}if(k.start){if(k.start.ctrl){j=i.createControlRange();j.addElement(m(k.start.indexes));j.select()}else{j=i.createTextRange();l(true);l();j.select()}}};this.addRange=function(i){var n,l,k,p,v,q,t,s=d.dom.doc,m=s.body,r,u;function j(C){var y,B,x,A,z;x=h.create("a");y=C?k:v;B=C?p:q;A=n.duplicate();if(y==s||y==s.documentElement){y=m;B=0}if(y.nodeType==3){y.parentNode.insertBefore(x,y);A.moveToElementText(x);A.moveStart("character",B);h.remove(x);n.setEndPoint(C?"StartToStart":"EndToEnd",A)}else{z=y.childNodes;if(z.length){if(B>=z.length){h.insertAfter(x,z[z.length-1])}else{y.insertBefore(x,z[B])}A.moveToElementText(x)}else{if(y.canHaveHTML){y.innerHTML="<span>\uFEFF</span>";x=y.firstChild;A.moveToElementText(x);A.collapse(f)}}n.setEndPoint(C?"StartToStart":"EndToEnd",A);h.remove(x)}}k=i.startContainer;p=i.startOffset;v=i.endContainer;q=i.endOffset;n=m.createTextRange();if(k==v&&k.nodeType==1){if(p==q&&!k.hasChildNodes()){if(k.canHaveHTML){t=k.previousSibling;if(t&&!t.hasChildNodes()&&h.isBlock(t)){t.innerHTML="\uFEFF"}else{t=null}k.innerHTML="<span>\uFEFF</span><span>\uFEFF</span>";n.moveToElementText(k.lastChild);n.select();h.doc.selection.clear();k.innerHTML="";if(t){t.innerHTML=""}return}else{p=h.nodeIndex(k);k=k.parentNode}}if(p==q-1){try{u=k.childNodes[p];l=m.createControlRange();l.addElement(u);l.select();r=d.getRng();if(r.item&&u===r.item(0)){return}}catch(o){}}}j(true);j();n.select()};this.getRangeAt=g}tinymce.dom.TridentSelection=a})();(function(){var n=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,i="sizcache",o=0,r=Object.prototype.toString,h=false,g=true,q=/\\/g,u=/\r\n/g,x=/\W/;[0,0].sort(function(){g=false;return 0});var d=function(C,e,F,G){F=F||[];e=e||document;var I=e;if(e.nodeType!==1&&e.nodeType!==9){return[]}if(!C||typeof C!=="string"){return F}var z,K,N,y,J,M,L,E,B=true,A=d.isXML(e),D=[],H=C;do{n.exec("");z=n.exec(H);if(z){H=z[3];D.push(z[1]);if(z[2]){y=z[3];break}}}while(z);if(D.length>1&&j.exec(C)){if(D.length===2&&k.relative[D[0]]){K=s(D[0]+D[1],e,G)}else{K=k.relative[D[0]]?[e]:d(D.shift(),e);while(D.length){C=D.shift();if(k.relative[C]){C+=D.shift()}K=s(C,K,G)}}}else{if(!G&&D.length>1&&e.nodeType===9&&!A&&k.match.ID.test(D[0])&&!k.match.ID.test(D[D.length-1])){J=d.find(D.shift(),e,A);e=J.expr?d.filter(J.expr,J.set)[0]:J.set[0]}if(e){J=G?{expr:D.pop(),set:l(G)}:d.find(D.pop(),D.length===1&&(D[0]==="~"||D[0]==="+")&&e.parentNode?e.parentNode:e,A);K=J.expr?d.filter(J.expr,J.set):J.set;if(D.length>0){N=l(K)}else{B=false}while(D.length){M=D.pop();L=M;if(!k.relative[M]){M=""}else{L=D.pop()}if(L==null){L=e}k.relative[M](N,L,A)}}else{N=D=[]}}if(!N){N=K}if(!N){d.error(M||C)}if(r.call(N)==="[object Array]"){if(!B){F.push.apply(F,N)}else{if(e&&e.nodeType===1){for(E=0;N[E]!=null;E++){if(N[E]&&(N[E]===true||N[E].nodeType===1&&d.contains(e,N[E]))){F.push(K[E])}}}else{for(E=0;N[E]!=null;E++){if(N[E]&&N[E].nodeType===1){F.push(K[E])}}}}}else{l(N,F)}if(y){d(y,I,F,G);d.uniqueSort(F)}return F};d.uniqueSort=function(y){if(p){h=g;y.sort(p);if(h){for(var e=1;e<y.length;e++){if(y[e]===y[e-1]){y.splice(e--,1)}}}}return y};d.matches=function(e,y){return d(e,null,null,y)};d.matchesSelector=function(e,y){return d(y,null,null,[e]).length>0};d.find=function(E,e,F){var D,z,B,A,C,y;if(!E){return[]}for(z=0,B=k.order.length;z<B;z++){C=k.order[z];if((A=k.leftMatch[C].exec(E))){y=A[1];A.splice(1,1);if(y.substr(y.length-1)!=="\\"){A[1]=(A[1]||"").replace(q,"");D=k.find[C](A,e,F);if(D!=null){E=E.replace(k.match[C],"");break}}}}if(!D){D=typeof e.getElementsByTagName!=="undefined"?e.getElementsByTagName("*"):[]}return{set:D,expr:E}};d.filter=function(I,H,L,B){var D,e,G,N,K,y,A,C,J,z=I,M=[],F=H,E=H&&H[0]&&d.isXML(H[0]);while(I&&H.length){for(G in k.filter){if((D=k.leftMatch[G].exec(I))!=null&&D[2]){y=k.filter[G];A=D[1];e=false;D.splice(1,1);if(A.substr(A.length-1)==="\\"){continue}if(F===M){M=[]}if(k.preFilter[G]){D=k.preFilter[G](D,F,L,M,B,E);if(!D){e=N=true}else{if(D===true){continue}}}if(D){for(C=0;(K=F[C])!=null;C++){if(K){N=y(K,D,C,F);J=B^N;if(L&&N!=null){if(J){e=true}else{F[C]=false}}else{if(J){M.push(K);e=true}}}}}if(N!==undefined){if(!L){F=M}I=I.replace(k.match[G],"");if(!e){return[]}break}}}if(I===z){if(e==null){d.error(I)}else{break}}z=I}return F};d.error=function(e){throw new Error("Syntax error, unrecognized expression: "+e)};var b=d.getText=function(B){var z,A,e=B.nodeType,y="";if(e){if(e===1||e===9||e===11){if(typeof B.textContent==="string"){return B.textContent}else{if(typeof B.innerText==="string"){return B.innerText.replace(u,"")}else{for(B=B.firstChild;B;B=B.nextSibling){y+=b(B)}}}}else{if(e===3||e===4){return B.nodeValue}}}else{for(z=0;(A=B[z]);z++){if(A.nodeType!==8){y+=b(A)}}}return y};var k=d.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(e){return e.getAttribute("href")},type:function(e){return e.getAttribute("type")}},relative:{"+":function(D,y){var A=typeof y==="string",C=A&&!x.test(y),E=A&&!C;if(C){y=y.toLowerCase()}for(var z=0,e=D.length,B;z<e;z++){if((B=D[z])){while((B=B.previousSibling)&&B.nodeType!==1){}D[z]=E||B&&B.nodeName.toLowerCase()===y?B||false:B===y}}if(E){d.filter(y,D,true)}},">":function(D,y){var C,B=typeof y==="string",z=0,e=D.length;if(B&&!x.test(y)){y=y.toLowerCase();for(;z<e;z++){C=D[z];if(C){var A=C.parentNode;D[z]=A.nodeName.toLowerCase()===y?A:false}}}else{for(;z<e;z++){C=D[z];if(C){D[z]=B?C.parentNode:C.parentNode===y}}if(B){d.filter(y,D,true)}}},"":function(A,y,C){var B,z=o++,e=t;if(typeof y==="string"&&!x.test(y)){y=y.toLowerCase();B=y;e=a}e("parentNode",y,z,A,B,C)},"~":function(A,y,C){var B,z=o++,e=t;if(typeof y==="string"&&!x.test(y)){y=y.toLowerCase();B=y;e=a}e("previousSibling",y,z,A,B,C)}},find:{ID:function(y,z,A){if(typeof z.getElementById!=="undefined"&&!A){var e=z.getElementById(y[1]);return e&&e.parentNode?[e]:[]}},NAME:function(z,C){if(typeof C.getElementsByName!=="undefined"){var y=[],B=C.getElementsByName(z[1]);for(var A=0,e=B.length;A<e;A++){if(B[A].getAttribute("name")===z[1]){y.push(B[A])}}return y.length===0?null:y}},TAG:function(e,y){if(typeof y.getElementsByTagName!=="undefined"){return y.getElementsByTagName(e[1])}}},preFilter:{CLASS:function(A,y,z,e,D,E){A=" "+A[1].replace(q,"")+" ";if(E){return A}for(var B=0,C;(C=y[B])!=null;B++){if(C){if(D^(C.className&&(" "+C.className+" ").replace(/[\t\n\r]/g," ").indexOf(A)>=0)){if(!z){e.push(C)}}else{if(z){y[B]=false}}}}return false},ID:function(e){return e[1].replace(q,"")},TAG:function(y,e){return y[1].replace(q,"").toLowerCase()},CHILD:function(e){if(e[1]==="nth"){if(!e[2]){d.error(e[0])}e[2]=e[2].replace(/^\+|\s*/g,"");var y=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(e[2]==="even"&&"2n"||e[2]==="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(y[1]+(y[2]||1))-0;e[3]=y[3]-0}else{if(e[2]){d.error(e[0])}}e[0]=o++;return e},ATTR:function(B,y,z,e,C,D){var A=B[1]=B[1].replace(q,"");if(!D&&k.attrMap[A]){B[1]=k.attrMap[A]}B[4]=(B[4]||B[5]||"").replace(q,"");if(B[2]==="~="){B[4]=" "+B[4]+" "}return B},PSEUDO:function(B,y,z,e,C){if(B[1]==="not"){if((n.exec(B[3])||"").length>1||/^\w/.test(B[3])){B[3]=d(B[3],null,null,y)}else{var A=d.filter(B[3],y,z,true^C);if(!z){e.push.apply(e,A)}return false}}else{if(k.match.POS.test(B[0])||k.match.CHILD.test(B[0])){return true}}return B},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){if(e.parentNode){e.parentNode.selectedIndex}return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(z,y,e){return !!d(e[3],z).length},header:function(e){return(/h\d/i).test(e.nodeName)},text:function(z){var e=z.getAttribute("type"),y=z.type;return z.nodeName.toLowerCase()==="input"&&"text"===y&&(e===y||e===null)},radio:function(e){return e.nodeName.toLowerCase()==="input"&&"radio"===e.type},checkbox:function(e){return e.nodeName.toLowerCase()==="input"&&"checkbox"===e.type},file:function(e){return e.nodeName.toLowerCase()==="input"&&"file"===e.type},password:function(e){return e.nodeName.toLowerCase()==="input"&&"password"===e.type},submit:function(y){var e=y.nodeName.toLowerCase();return(e==="input"||e==="button")&&"submit"===y.type},image:function(e){return e.nodeName.toLowerCase()==="input"&&"image"===e.type},reset:function(y){var e=y.nodeName.toLowerCase();return(e==="input"||e==="button")&&"reset"===y.type},button:function(y){var e=y.nodeName.toLowerCase();return e==="input"&&"button"===y.type||e==="button"},input:function(e){return(/input|select|textarea|button/i).test(e.nodeName)},focus:function(e){return e===e.ownerDocument.activeElement}},setFilters:{first:function(y,e){return e===0},last:function(z,y,e,A){return y===A.length-1},even:function(y,e){return e%2===0},odd:function(y,e){return e%2===1},lt:function(z,y,e){return y<e[3]-0},gt:function(z,y,e){return y>e[3]-0},nth:function(z,y,e){return e[3]-0===y},eq:function(z,y,e){return e[3]-0===y}},filter:{PSEUDO:function(z,E,D,F){var e=E[1],y=k.filters[e];if(y){return y(z,D,E,F)}else{if(e==="contains"){return(z.textContent||z.innerText||b([z])||"").indexOf(E[3])>=0}else{if(e==="not"){var A=E[3];for(var C=0,B=A.length;C<B;C++){if(A[C]===z){return false}}return true}else{d.error(e)}}}},CHILD:function(z,B){var A,H,D,G,e,C,F,E=B[1],y=z;switch(E){case"only":case"first":while((y=y.previousSibling)){if(y.nodeType===1){return false}}if(E==="first"){return true}y=z;case"last":while((y=y.nextSibling)){if(y.nodeType===1){return false}}return true;case"nth":A=B[2];H=B[3];if(A===1&&H===0){return true}D=B[0];G=z.parentNode;if(G&&(G[i]!==D||!z.nodeIndex)){C=0;for(y=G.firstChild;y;y=y.nextSibling){if(y.nodeType===1){y.nodeIndex=++C}}G[i]=D}F=z.nodeIndex-H;if(A===0){return F===0}else{return(F%A===0&&F/A>=0)}}},ID:function(y,e){return y.nodeType===1&&y.getAttribute("id")===e},TAG:function(y,e){return(e==="*"&&y.nodeType===1)||!!y.nodeName&&y.nodeName.toLowerCase()===e},CLASS:function(y,e){return(" "+(y.className||y.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(C,A){var z=A[1],e=d.attr?d.attr(C,z):k.attrHandle[z]?k.attrHandle[z](C):C[z]!=null?C[z]:C.getAttribute(z),D=e+"",B=A[2],y=A[4];return e==null?B==="!=":!B&&d.attr?e!=null:B==="="?D===y:B==="*="?D.indexOf(y)>=0:B==="~="?(" "+D+" ").indexOf(y)>=0:!y?D&&e!==false:B==="!="?D!==y:B==="^="?D.indexOf(y)===0:B==="$="?D.substr(D.length-y.length)===y:B==="|="?D===y||D.substr(0,y.length+1)===y+"-":false},POS:function(B,y,z,C){var e=y[2],A=k.setFilters[e];if(A){return A(B,z,y,C)}}}};var j=k.match.POS,c=function(y,e){return"\\"+(e-0+1)};for(var f in k.match){k.match[f]=new RegExp(k.match[f].source+(/(?![^\[]*\])(?![^\(]*\))/.source));k.leftMatch[f]=new RegExp(/(^(?:.|\r|\n)*?)/.source+k.match[f].source.replace(/\\(\d+)/g,c))}k.match.globalPOS=j;var l=function(y,e){y=Array.prototype.slice.call(y,0);if(e){e.push.apply(e,y);return e}return y};try{Array.prototype.slice.call(document.documentElement.childNodes,0)[0].nodeType}catch(v){l=function(B,A){var z=0,y=A||[];if(r.call(B)==="[object Array]"){Array.prototype.push.apply(y,B)}else{if(typeof B.length==="number"){for(var e=B.length;z<e;z++){y.push(B[z])}}else{for(;B[z];z++){y.push(B[z])}}}return y}}var p,m;if(document.documentElement.compareDocumentPosition){p=function(y,e){if(y===e){h=true;return 0}if(!y.compareDocumentPosition||!e.compareDocumentPosition){return y.compareDocumentPosition?-1:1}return y.compareDocumentPosition(e)&4?-1:1}}else{p=function(F,E){if(F===E){h=true;return 0}else{if(F.sourceIndex&&E.sourceIndex){return F.sourceIndex-E.sourceIndex}}var C,y,z=[],e=[],B=F.parentNode,D=E.parentNode,G=B;if(B===D){return m(F,E)}else{if(!B){return -1}else{if(!D){return 1}}}while(G){z.unshift(G);G=G.parentNode}G=D;while(G){e.unshift(G);G=G.parentNode}C=z.length;y=e.length;for(var A=0;A<C&&A<y;A++){if(z[A]!==e[A]){return m(z[A],e[A])}}return A===C?m(F,e[A],-1):m(z[A],E,1)};m=function(y,e,z){if(y===e){return z}var A=y.nextSibling;while(A){if(A===e){return -1}A=A.nextSibling}return 1}}(function(){var y=document.createElement("div"),z="script"+(new Date()).getTime(),e=document.documentElement;y.innerHTML="<a name='"+z+"'/>";e.insertBefore(y,e.firstChild);if(document.getElementById(z)){k.find.ID=function(B,C,D){if(typeof C.getElementById!=="undefined"&&!D){var A=C.getElementById(B[1]);return A?A.id===B[1]||typeof A.getAttributeNode!=="undefined"&&A.getAttributeNode("id").nodeValue===B[1]?[A]:undefined:[]}};k.filter.ID=function(C,A){var B=typeof C.getAttributeNode!=="undefined"&&C.getAttributeNode("id");return C.nodeType===1&&B&&B.nodeValue===A}}e.removeChild(y);e=y=null})();(function(){var e=document.createElement("div");e.appendChild(document.createComment(""));if(e.getElementsByTagName("*").length>0){k.find.TAG=function(y,C){var B=C.getElementsByTagName(y[1]);if(y[1]==="*"){var A=[];for(var z=0;B[z];z++){if(B[z].nodeType===1){A.push(B[z])}}B=A}return B}}e.innerHTML="<a href='#'></a>";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){k.attrHandle.href=function(y){return y.getAttribute("href",2)}}e=null})();if(document.querySelectorAll){(function(){var e=d,A=document.createElement("div"),z="__sizzle__";A.innerHTML="<p class='TEST'></p>";if(A.querySelectorAll&&A.querySelectorAll(".TEST").length===0){return}d=function(L,C,G,K){C=C||document;if(!K&&!d.isXML(C)){var J=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(L);if(J&&(C.nodeType===1||C.nodeType===9)){if(J[1]){return l(C.getElementsByTagName(L),G)}else{if(J[2]&&k.find.CLASS&&C.getElementsByClassName){return l(C.getElementsByClassName(J[2]),G)}}}if(C.nodeType===9){if(L==="body"&&C.body){return l([C.body],G)}else{if(J&&J[3]){var F=C.getElementById(J[3]);if(F&&F.parentNode){if(F.id===J[3]){return l([F],G)}}else{return l([],G)}}}try{return l(C.querySelectorAll(L),G)}catch(H){}}else{if(C.nodeType===1&&C.nodeName.toLowerCase()!=="object"){var D=C,E=C.getAttribute("id"),B=E||z,N=C.parentNode,M=/^\s*[+~]/.test(L);if(!E){C.setAttribute("id",B)}else{B=B.replace(/'/g,"\\$&")}if(M&&N){C=C.parentNode}try{if(!M||N){return l(C.querySelectorAll("[id='"+B+"'] "+L),G)}}catch(I){}finally{if(!E){D.removeAttribute("id")}}}}}return e(L,C,G,K)};for(var y in e){d[y]=e[y]}A=null})()}(function(){var e=document.documentElement,z=e.matchesSelector||e.mozMatchesSelector||e.webkitMatchesSelector||e.msMatchesSelector;if(z){var B=!z.call(document.createElement("div"),"div"),y=false;try{z.call(document.documentElement,"[test!='']:sizzle")}catch(A){y=true}d.matchesSelector=function(D,F){F=F.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!d.isXML(D)){try{if(y||!k.match.PSEUDO.test(F)&&!/!=/.test(F)){var C=z.call(D,F);if(C||!B||D.document&&D.document.nodeType!==11){return C}}}catch(E){}}return d(F,null,null,[D]).length>0}}})();(function(){var e=document.createElement("div");e.innerHTML="<div class='test e'></div><div class='test'></div>";if(!e.getElementsByClassName||e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}k.order.splice(1,0,"CLASS");k.find.CLASS=function(y,z,A){if(typeof z.getElementsByClassName!=="undefined"&&!A){return z.getElementsByClassName(y[1])}};e=null})();function a(y,D,C,G,E,F){for(var A=0,z=G.length;A<z;A++){var e=G[A];if(e){var B=false;e=e[y];while(e){if(e[i]===C){B=G[e.sizset];break}if(e.nodeType===1&&!F){e[i]=C;e.sizset=A}if(e.nodeName.toLowerCase()===D){B=e;break}e=e[y]}G[A]=B}}}function t(y,D,C,G,E,F){for(var A=0,z=G.length;A<z;A++){var e=G[A];if(e){var B=false;e=e[y];while(e){if(e[i]===C){B=G[e.sizset];break}if(e.nodeType===1){if(!F){e[i]=C;e.sizset=A}if(typeof D!=="string"){if(e===D){B=true;break}}else{if(d.filter(D,[e]).length>0){B=e;break}}}e=e[y]}G[A]=B}}}if(document.documentElement.contains){d.contains=function(y,e){return y!==e&&(y.contains?y.contains(e):true)}}else{if(document.documentElement.compareDocumentPosition){d.contains=function(y,e){return !!(y.compareDocumentPosition(e)&16)}}else{d.contains=function(){return false}}}d.isXML=function(e){var y=(e?e.ownerDocument||e:0).documentElement;return y?y.nodeName!=="HTML":false};var s=function(z,e,D){var C,E=[],B="",F=e.nodeType?[e]:e;while((C=k.match.PSEUDO.exec(z))){B+=C[0];z=z.replace(k.match.PSEUDO,"")}z=k.relative[z]?z+"*":z;for(var A=0,y=F.length;A<y;A++){d(z,F[A],E,D)}return d.filter(B,E)};window.tinymce.dom.Sizzle=d})();(function(a){a.dom.Element=function(f,d){var b=this,e,c;b.settings=d=d||{};b.id=f;b.dom=e=d.dom||a.DOM;if(!a.isIE){c=e.get(b.id)}a.each(("getPos,getRect,getParent,add,setStyle,getStyle,setStyles,setAttrib,setAttribs,getAttrib,addClass,removeClass,hasClass,getOuterHTML,setOuterHTML,remove,show,hide,isHidden,setHTML,get").split(/,/),function(g){b[g]=function(){var h=[f],j;for(j=0;j<arguments.length;j++){h.push(arguments[j])}h=e[g].apply(e,h);b.update(g);return h}});a.extend(b,{on:function(i,h,g){return a.dom.Event.add(b.id,i,h,g)},getXY:function(){return{x:parseInt(b.getStyle("left")),y:parseInt(b.getStyle("top"))}},getSize:function(){var g=e.get(b.id);return{w:parseInt(b.getStyle("width")||g.clientWidth),h:parseInt(b.getStyle("height")||g.clientHeight)}},moveTo:function(g,h){b.setStyles({left:g,top:h})},moveBy:function(g,i){var h=b.getXY();b.moveTo(h.x+g,h.y+i)},resizeTo:function(g,i){b.setStyles({width:g,height:i})},resizeBy:function(g,j){var i=b.getSize();b.resizeTo(i.w+g,i.h+j)},update:function(h){var g;if(a.isIE6&&d.blocker){h=h||"";if(h.indexOf("get")===0||h.indexOf("has")===0||h.indexOf("is")===0){return}if(h=="remove"){e.remove(b.blocker);return}if(!b.blocker){b.blocker=e.uniqueId();g=e.add(d.container||e.getRoot(),"iframe",{id:b.blocker,style:"position:absolute;",frameBorder:0,src:'javascript:""'});e.setStyle(g,"opacity",0)}else{g=e.get(b.blocker)}e.setStyles(g,{left:b.getStyle("left",1),top:b.getStyle("top",1),width:b.getStyle("width",1),height:b.getStyle("height",1),display:b.getStyle("display",1),zIndex:parseInt(b.getStyle("zIndex",1)||0)-1})}}})}})(tinymce);(function(d){function f(g){return g.replace(/[\n\r]+/g,"")}var c=d.is,b=d.isIE,e=d.each,a=d.dom.TreeWalker;d.create("tinymce.dom.Selection",{Selection:function(k,j,i,h){var g=this;g.dom=k;g.win=j;g.serializer=i;g.editor=h;e(["onBeforeSetContent","onBeforeGetContent","onSetContent","onGetContent"],function(l){g[l]=new d.util.Dispatcher(g)});if(!g.win.getSelection){g.tridentSel=new d.dom.TridentSelection(g)}if(d.isIE&&k.boxModel){this._fixIESelection()}d.addUnload(g.destroy,g)},setCursorLocation:function(i,j){var g=this;var h=g.dom.createRng();h.setStart(i,j);h.setEnd(i,j);g.setRng(h);g.collapse(false)},getContent:function(h){var g=this,i=g.getRng(),m=g.dom.create("body"),k=g.getSel(),j,l,o;h=h||{};j=l="";h.get=true;h.format=h.format||"html";h.forced_root_block="";g.onBeforeGetContent.dispatch(g,h);if(h.format=="text"){return g.isCollapsed()?"":(i.text||(k.toString?k.toString():""))}if(i.cloneContents){o=i.cloneContents();if(o){m.appendChild(o)}}else{if(c(i.item)||c(i.htmlText)){m.innerHTML="<br>"+(i.item?i.item(0).outerHTML:i.htmlText);m.removeChild(m.firstChild)}else{m.innerHTML=i.toString()}}if(/^\s/.test(m.innerHTML)){j=" "}if(/\s+$/.test(m.innerHTML)){l=" "}h.getInner=true;h.content=g.isCollapsed()?"":j+g.serializer.serialize(m,h)+l;g.onGetContent.dispatch(g,h);return h.content},setContent:function(h,j){var o=this,g=o.getRng(),k,l=o.win.document,n,m;j=j||{format:"html"};j.set=true;h=j.content=h;if(!j.no_events){o.onBeforeSetContent.dispatch(o,j)}h=j.content;if(g.insertNode){h+='<span id="__caret">_</span>';if(g.startContainer==l&&g.endContainer==l){l.body.innerHTML=h}else{g.deleteContents();if(l.body.childNodes.length===0){l.body.innerHTML=h}else{if(g.createContextualFragment){g.insertNode(g.createContextualFragment(h))}else{n=l.createDocumentFragment();m=l.createElement("div");n.appendChild(m);m.outerHTML=h;g.insertNode(n)}}}k=o.dom.get("__caret");g=l.createRange();g.setStartBefore(k);g.setEndBefore(k);o.setRng(g);o.dom.remove("__caret");try{o.setRng(g)}catch(i){}}else{if(g.item){l.execCommand("Delete",false,null);g=o.getRng()}if(/^\s+/.test(h)){g.pasteHTML('<span id="__mce_tmp">_</span>'+h);o.dom.remove("__mce_tmp")}else{g.pasteHTML(h)}}if(!j.no_events){o.onSetContent.dispatch(o,j)}},getStart:function(){var i=this,h=i.getRng(),j,g,l,k;if(h.duplicate||h.item){if(h.item){return h.item(0)}l=h.duplicate();l.collapse(1);j=l.parentElement();if(j.ownerDocument!==i.dom.doc){j=i.dom.getRoot()}g=k=h.parentElement();while(k=k.parentNode){if(k==j){j=g;break}}return j}else{j=h.startContainer;if(j.nodeType==1&&j.hasChildNodes()){j=j.childNodes[Math.min(j.childNodes.length-1,h.startOffset)]}if(j&&j.nodeType==3){return j.parentNode}return j}},getEnd:function(){var h=this,g=h.getRng(),j,i;if(g.duplicate||g.item){if(g.item){return g.item(0)}g=g.duplicate();g.collapse(0);j=g.parentElement();if(j.ownerDocument!==h.dom.doc){j=h.dom.getRoot()}if(j&&j.nodeName=="BODY"){return j.lastChild||j}return j}else{j=g.endContainer;i=g.endOffset;if(j.nodeType==1&&j.hasChildNodes()){j=j.childNodes[i>0?i-1:i]}if(j&&j.nodeType==3){return j.parentNode}return j}},getBookmark:function(s,v){var y=this,n=y.dom,h,k,j,o,i,p,q,m="\uFEFF",x;function g(z,A){var t=0;e(n.select(z),function(C,B){if(C==A){t=B}});return t}function u(t){function z(E){var A,D,C,B=E?"start":"end";A=t[B+"Container"];D=t[B+"Offset"];if(A.nodeType==1&&A.nodeName=="TR"){C=A.childNodes;A=C[Math.min(E?D:D-1,C.length-1)];if(A){D=E?0:A.childNodes.length;t["set"+(E?"Start":"End")](A,D)}}}z(true);z();return t}function l(){var z=y.getRng(true),t=n.getRoot(),A={};function B(E,J){var D=E[J?"startContainer":"endContainer"],I=E[J?"startOffset":"endOffset"],C=[],F,H,G=0;if(D.nodeType==3){if(v){for(F=D.previousSibling;F&&F.nodeType==3;F=F.previousSibling){I+=F.nodeValue.length}}C.push(I)}else{H=D.childNodes;if(I>=H.length&&H.length){G=1;I=Math.max(0,H.length-1)}C.push(y.dom.nodeIndex(H[I],v)+G)}for(;D&&D!=t;D=D.parentNode){C.push(y.dom.nodeIndex(D,v))}return C}A.start=B(z,true);if(!y.isCollapsed()){A.end=B(z)}return A}if(s==2){if(y.tridentSel){return y.tridentSel.getBookmark(s)}return l()}if(s){return{rng:y.getRng()}}h=y.getRng();j=n.uniqueId();o=tinyMCE.activeEditor.selection.isCollapsed();x="overflow:hidden;line-height:0px";if(h.duplicate||h.item){if(!h.item){k=h.duplicate();try{h.collapse();h.pasteHTML('<span data-mce-type="bookmark" id="'+j+'_start" style="'+x+'">'+m+"</span>");if(!o){k.collapse(false);h.moveToElementText(k.parentElement());if(h.compareEndPoints("StartToEnd",k)===0){k.move("character",-1)}k.pasteHTML('<span data-mce-type="bookmark" id="'+j+'_end" style="'+x+'">'+m+"</span>")}}catch(r){return null}}else{p=h.item(0);i=p.nodeName;return{name:i,index:g(i,p)}}}else{p=y.getNode();i=p.nodeName;if(i=="IMG"){return{name:i,index:g(i,p)}}k=u(h.cloneRange());if(!o){k.collapse(false);k.insertNode(n.create("span",{"data-mce-type":"bookmark",id:j+"_end",style:x},m))}h=u(h);h.collapse(true);h.insertNode(n.create("span",{"data-mce-type":"bookmark",id:j+"_start",style:x},m))}y.moveToBookmark({id:j,keep:1});return{id:j}},moveToBookmark:function(o){var s=this,m=s.dom,j,i,g,r,k,u,p,q;function h(A){var t=o[A?"start":"end"],x,y,z,v;if(t){z=t[0];for(y=r,x=t.length-1;x>=1;x--){v=y.childNodes;if(t[x]>v.length-1){return}y=v[t[x]]}if(y.nodeType===3){z=Math.min(t[0],y.nodeValue.length)}if(y.nodeType===1){z=Math.min(t[0],y.childNodes.length)}if(A){g.setStart(y,z)}else{g.setEnd(y,z)}}return true}function l(B){var v=m.get(o.id+"_"+B),A,t,y,z,x=o.keep;if(v){A=v.parentNode;if(B=="start"){if(!x){t=m.nodeIndex(v)}else{A=v.firstChild;t=1}k=u=A;p=q=t}else{if(!x){t=m.nodeIndex(v)}else{A=v.firstChild;t=1}u=A;q=t}if(!x){z=v.previousSibling;y=v.nextSibling;e(d.grep(v.childNodes),function(C){if(C.nodeType==3){C.nodeValue=C.nodeValue.replace(/\uFEFF/g,"")}});while(v=m.get(o.id+"_"+B)){m.remove(v,1)}if(z&&y&&z.nodeType==y.nodeType&&z.nodeType==3&&!d.isOpera){t=z.nodeValue.length;z.appendData(y.nodeValue);m.remove(y);if(B=="start"){k=u=z;p=q=t}else{u=z;q=t}}}}}function n(t){if(m.isBlock(t)&&!t.innerHTML&&!b){t.innerHTML='<br data-mce-bogus="1" />'}return t}if(o){if(o.start){g=m.createRng();r=m.getRoot();if(s.tridentSel){return s.tridentSel.moveToBookmark(o)}if(h(true)&&h()){s.setRng(g)}}else{if(o.id){l("start");l("end");if(k){g=m.createRng();g.setStart(n(k),p);g.setEnd(n(u),q);s.setRng(g)}}else{if(o.name){s.select(m.select(o.name)[o.index])}else{if(o.rng){s.setRng(o.rng)}}}}}},select:function(l,k){var j=this,m=j.dom,h=m.createRng(),g;function i(n,p){var o=new a(n,n);do{if(n.nodeType==3&&d.trim(n.nodeValue).length!==0){if(p){h.setStart(n,0)}else{h.setEnd(n,n.nodeValue.length)}return}if(n.nodeName=="BR"){if(p){h.setStartBefore(n)}else{h.setEndBefore(n)}return}}while(n=(p?o.next():o.prev()))}if(l){g=m.nodeIndex(l);h.setStart(l.parentNode,g);h.setEnd(l.parentNode,g+1);if(k){i(l,1);i(l)}j.setRng(h)}return l},isCollapsed:function(){var g=this,i=g.getRng(),h=g.getSel();if(!i||i.item){return false}if(i.compareEndPoints){return i.compareEndPoints("StartToEnd",i)===0}return !h||i.collapsed},collapse:function(g){var i=this,h=i.getRng(),j;if(h.item){j=h.item(0);h=i.win.document.body.createTextRange();h.moveToElementText(j)}h.collapse(!!g);i.setRng(h)},getSel:function(){var h=this,g=this.win;return g.getSelection?g.getSelection():g.document.selection},getRng:function(m){var h=this,j,g,l,k=h.win.document;if(m&&h.tridentSel){return h.tridentSel.getRangeAt(0)}try{if(j=h.getSel()){g=j.rangeCount>0?j.getRangeAt(0):(j.createRange?j.createRange():k.createRange())}}catch(i){}if(d.isIE&&g&&g.setStart&&k.selection.createRange().item){l=k.selection.createRange().item(0);g=k.createRange();g.setStartBefore(l);g.setEndAfter(l)}if(!g){g=k.createRange?k.createRange():k.body.createTextRange()}if(g.setStart&&g.startContainer.nodeType===9&&g.collapsed){l=h.dom.getRoot();g.setStart(l,0);g.setEnd(l,0)}if(h.selectedRange&&h.explicitRange){if(g.compareBoundaryPoints(g.START_TO_START,h.selectedRange)===0&&g.compareBoundaryPoints(g.END_TO_END,h.selectedRange)===0){g=h.explicitRange}else{h.selectedRange=null;h.explicitRange=null}}return g},setRng:function(k,g){var j,i=this;if(!i.tridentSel){j=i.getSel();if(j){i.explicitRange=k;try{j.removeAllRanges()}catch(h){}j.addRange(k);if(g===false&&j.extend){j.collapse(k.endContainer,k.endOffset);j.extend(k.startContainer,k.startOffset)}i.selectedRange=j.rangeCount>0?j.getRangeAt(0):null}}else{if(k.cloneRange){try{i.tridentSel.addRange(k);return}catch(h){}}try{k.select()}catch(h){}}},setNode:function(h){var g=this;g.setContent(g.dom.getOuterHTML(h));return h},getNode:function(){var i=this,h=i.getRng(),j=i.getSel(),m,l=h.startContainer,g=h.endContainer;function k(q,o){var p=q;while(q&&q.nodeType===3&&q.length===0){q=o?q.nextSibling:q.previousSibling}return q||p}if(!h){return i.dom.getRoot()}if(h.setStart){m=h.commonAncestorContainer;if(!h.collapsed){if(h.startContainer==h.endContainer){if(h.endOffset-h.startOffset<2){if(h.startContainer.hasChildNodes()){m=h.startContainer.childNodes[h.startOffset]}}}if(l.nodeType===3&&g.nodeType===3){if(l.length===h.startOffset){l=k(l.nextSibling,true)}else{l=l.parentNode}if(h.endOffset===0){g=k(g.previousSibling,false)}else{g=g.parentNode}if(l&&l===g){return l}}}if(m&&m.nodeType==3){return m.parentNode}return m}return h.item?h.item(0):h.parentElement()},getSelectedBlocks:function(p,h){var o=this,k=o.dom,m,l,i,j=[];m=k.getParent(p||o.getStart(),k.isBlock);l=k.getParent(h||o.getEnd(),k.isBlock);if(m){j.push(m)}if(m&&l&&m!=l){i=m;var g=new a(m,k.getRoot());while((i=g.next())&&i!=l){if(k.isBlock(i)){j.push(i)}}}if(l&&m!=l){j.push(l)}return j},isForward:function(){var i=this.dom,g=this.getSel(),j,h;if(!g||g.anchorNode==null||g.focusNode==null){return true}j=i.createRng();j.setStart(g.anchorNode,g.anchorOffset);j.collapse(true);h=i.createRng();h.setStart(g.focusNode,g.focusOffset);h.collapse(true);return j.compareBoundaryPoints(j.START_TO_START,h)<=0},normalize:function(){var h=this,g,m,l,j,i;function k(p){var o,r,n,s=h.dom,u=s.getRoot(),q,t,v;function y(z,A){var B=new a(z,s.getParent(z.parentNode,s.isBlock)||u);while(z=B[A?"prev":"next"]()){if(z.nodeName==="BR"){return true}}}function x(B,z){var C,A;z=z||o;C=new a(z,s.getParent(z.parentNode,s.isBlock)||u);while(q=C[B?"prev":"next"]()){if(q.nodeType===3&&q.nodeValue.length>0){o=q;r=B?q.nodeValue.length:0;m=true;return}if(s.isBlock(q)||t[q.nodeName.toLowerCase()]){return}A=q}if(l&&A){o=A;m=true;r=0}}o=g[(p?"start":"end")+"Container"];r=g[(p?"start":"end")+"Offset"];t=s.schema.getNonEmptyElements();if(o.nodeType===9){o=s.getRoot();r=0}if(o===u){if(p){q=o.childNodes[r>0?r-1:0];if(q){v=q.nodeName.toLowerCase();if(t[q.nodeName]||q.nodeName=="TABLE"){return}}}if(o.hasChildNodes()){o=o.childNodes[Math.min(!p&&r>0?r-1:r,o.childNodes.length-1)];r=0;if(o.hasChildNodes()&&!/TABLE/.test(o.nodeName)){q=o;n=new a(o,u);do{if(q.nodeType===3&&q.nodeValue.length>0){r=p?0:q.nodeValue.length;o=q;m=true;break}if(t[q.nodeName.toLowerCase()]){r=s.nodeIndex(q);o=q.parentNode;if(q.nodeName=="IMG"&&!p){r++}m=true;break}}while(q=(p?n.next():n.prev()))}}}if(l){if(o.nodeType===3&&r===0){x(true)}if(o.nodeType===1){q=o.childNodes[r];if(q&&q.nodeName==="BR"&&!y(q)&&!y(q,true)){x(true,o.childNodes[r])}}}if(p&&!l&&o.nodeType===3&&r===o.nodeValue.length){x(false)}if(m){g["set"+(p?"Start":"End")](o,r)}}if(d.isIE){return}g=h.getRng();l=g.collapsed;k(true);if(!l){k()}if(m){if(l){g.collapse(true)}h.setRng(g,h.isForward())}},selectorChanged:function(g,j){var h=this,i;if(!h.selectorChangedData){h.selectorChangedData={};i={};h.editor.onNodeChange.addToTop(function(l,k,o){var p=h.dom,m=p.getParents(o,null,p.getRoot()),n={};e(h.selectorChangedData,function(r,q){e(m,function(s){if(p.is(s,q)){if(!i[q]){e(r,function(t){t(true,{node:s,selector:q,parents:m})});i[q]=r}n[q]=r;return false}})});e(i,function(r,q){if(!n[q]){delete i[q];e(r,function(s){s(false,{node:o,selector:q,parents:m})})}})})}if(!h.selectorChangedData[g]){h.selectorChangedData[g]=[]}h.selectorChangedData[g].push(j);return h},destroy:function(h){var g=this;g.win=null;if(!h){d.removeUnload(g.destroy)}},_fixIESelection:function(){var h=this.dom,n=h.doc,i=n.body,k,o,g;function j(p,s){var q=i.createTextRange();try{q.moveToPoint(p,s)}catch(r){q=null}return q}function m(q){var p;if(q.button){p=j(q.x,q.y);if(p){if(p.compareEndPoints("StartToStart",o)>0){p.setEndPoint("StartToStart",o)}else{p.setEndPoint("EndToEnd",o)}p.select()}}else{l()}}function l(){var p=n.selection.createRange();if(o&&!p.item&&p.compareEndPoints("StartToEnd",p)===0){o.select()}h.unbind(n,"mouseup",l);h.unbind(n,"mousemove",m);o=k=0}n.documentElement.unselectable=true;h.bind(n,["mousedown","contextmenu"],function(p){if(p.target.nodeName==="HTML"){if(k){l()}g=n.documentElement;if(g.scrollHeight>g.clientHeight){return}k=1;o=j(p.x,p.y);if(o){h.bind(n,"mouseup",l);h.bind(n,"mousemove",m);h.win.focus();o.select()}}})}})})(tinymce);(function(a){a.dom.Serializer=function(e,i,f){var h,b,d=a.isIE,g=a.each,c;if(!e.apply_source_formatting){e.indent=false}i=i||a.DOM;f=f||new a.html.Schema(e);e.entity_encoding=e.entity_encoding||"named";e.remove_trailing_brs="remove_trailing_brs" in e?e.remove_trailing_brs:true;h=new a.util.Dispatcher(self);b=new a.util.Dispatcher(self);c=new a.html.DomParser(e,f);c.addAttributeFilter("src,href,style",function(k,j){var o=k.length,l,q,n="data-mce-"+j,p=e.url_converter,r=e.url_converter_scope,m;while(o--){l=k[o];q=l.attributes.map[n];if(q!==m){l.attr(j,q.length>0?q:null);l.attr(n,null)}else{q=l.attributes.map[j];if(j==="style"){q=i.serializeStyle(i.parseStyle(q),l.name)}else{if(p){q=p.call(r,q,j,l.name)}}l.attr(j,q.length>0?q:null)}}});c.addAttributeFilter("class",function(j,k){var l=j.length,m,n;while(l--){m=j[l];n=m.attr("class").replace(/(?:^|\s)mce(Item\w+|Selected)(?!\S)/g,"");m.attr("class",n.length>0?n:null)}});c.addAttributeFilter("data-mce-type",function(j,l,k){var m=j.length,n;while(m--){n=j[m];if(n.attributes.map["data-mce-type"]==="bookmark"&&!k.cleanup){n.remove()}}});c.addAttributeFilter("data-mce-expando",function(j,l,k){var m=j.length;while(m--){j[m].attr(l,null)}});c.addNodeFilter("script,style",function(k,l){var m=k.length,n,o;function j(p){return p.replace(/(<!--\[CDATA\[|\]\]-->)/g,"\n").replace(/^[\r\n]*|[\r\n]*$/g,"").replace(/^\s*((<!--)?(\s*\/\/)?\s*<!\[CDATA\[|(<!--\s*)?\/\*\s*<!\[CDATA\[\s*\*\/|(\/\/)?\s*<!--|\/\*\s*<!--\s*\*\/)\s*[\r\n]*/gi,"").replace(/\s*(\/\*\s*\]\]>\s*\*\/(-->)?|\s*\/\/\s*\]\]>(-->)?|\/\/\s*(-->)?|\]\]>|\/\*\s*-->\s*\*\/|\s*-->\s*)\s*$/g,"")}while(m--){n=k[m];o=n.firstChild?n.firstChild.value:"";if(l==="script"){n.attr("type",(n.attr("type")||"text/javascript").replace(/^mce\-/,""));if(o.length>0){n.firstChild.value="// <![CDATA[\n"+j(o)+"\n// ]]>"}}else{if(o.length>0){n.firstChild.value="<!--\n"+j(o)+"\n-->"}}}});c.addNodeFilter("#comment",function(j,k){var l=j.length,m;while(l--){m=j[l];if(m.value.indexOf("[CDATA[")===0){m.name="#cdata";m.type=4;m.value=m.value.replace(/^\[CDATA\[|\]\]$/g,"")}else{if(m.value.indexOf("mce:protected ")===0){m.name="#text";m.type=3;m.raw=true;m.value=unescape(m.value).substr(14)}}}});c.addNodeFilter("xml:namespace,input",function(j,k){var l=j.length,m;while(l--){m=j[l];if(m.type===7){m.remove()}else{if(m.type===1){if(k==="input"&&!("type" in m.attributes.map)){m.attr("type","text")}}}}});if(e.fix_list_elements){c.addNodeFilter("ul,ol",function(k,l){var m=k.length,n,j;while(m--){n=k[m];j=n.parent;if(j.name==="ul"||j.name==="ol"){if(n.prev&&n.prev.name==="li"){n.prev.append(n)}}}})}c.addAttributeFilter("data-mce-src,data-mce-href,data-mce-style",function(j,k){var l=j.length;while(l--){j[l].attr(k,null)}});return{schema:f,addNodeFilter:c.addNodeFilter,addAttributeFilter:c.addAttributeFilter,onPreProcess:h,onPostProcess:b,serialize:function(o,m){var l,p,k,j,n;if(d&&i.select("script,style,select,map").length>0){n=o.innerHTML;o=o.cloneNode(false);i.setHTML(o,n)}else{o=o.cloneNode(true)}l=o.ownerDocument.implementation;if(l.createHTMLDocument){p=l.createHTMLDocument("");g(o.nodeName=="BODY"?o.childNodes:[o],function(q){p.body.appendChild(p.importNode(q,true))});if(o.nodeName!="BODY"){o=p.body.firstChild}else{o=p.body}k=i.doc;i.doc=p}m=m||{};m.format=m.format||"html";if(!m.no_events){m.node=o;h.dispatch(self,m)}j=new a.html.Serializer(e,f);m.content=j.serialize(c.parse(a.trim(m.getInner?o.innerHTML:i.getOuterHTML(o)),m));if(!m.cleanup){m.content=m.content.replace(/\uFEFF/g,"")}if(!m.no_events){b.dispatch(self,m)}if(k){i.doc=k}m.node=null;return m.content},addRules:function(j){f.addValidElements(j)},setRules:function(j){f.setValidElements(j)}}}})(tinymce);(function(a){a.dom.ScriptLoader=function(h){var c=0,k=1,i=2,l={},j=[],e={},d=[],g=0,f;function b(m,v){var x=this,q=a.DOM,s,o,r,n;function p(){q.remove(n);if(s){s.onreadystatechange=s.onload=s=null}v()}function u(){if(typeof(console)!=="undefined"&&console.log){console.log("Failed to load: "+m)}}n=q.uniqueId();if(a.isIE6){o=new a.util.URI(m);r=location;if(o.host==r.hostname&&o.port==r.port&&(o.protocol+":")==r.protocol&&o.protocol.toLowerCase()!="file"){a.util.XHR.send({url:a._addVer(o.getURI()),success:function(y){var t=q.create("script",{type:"text/javascript"});t.text=y;document.getElementsByTagName("head")[0].appendChild(t);q.remove(t);p()},error:u});return}}s=document.createElement("script");s.id=n;s.type="text/javascript";s.src=a._addVer(m);if(!a.isIE){s.onload=p}s.onerror=u;if(!a.isOpera){s.onreadystatechange=function(){var t=s.readyState;if(t=="complete"||t=="loaded"){p()}}}(document.getElementsByTagName("head")[0]||document.body).appendChild(s)}this.isDone=function(m){return l[m]==i};this.markDone=function(m){l[m]=i};this.add=this.load=function(m,q,n){var o,p=l[m];if(p==f){j.push(m);l[m]=c}if(q){if(!e[m]){e[m]=[]}e[m].push({func:q,scope:n||this})}};this.loadQueue=function(n,m){this.loadScripts(j,n,m)};this.loadScripts=function(m,q,p){var o;function n(r){a.each(e[r],function(s){s.func.call(s.scope)});e[r]=f}d.push({func:q,scope:p||this});o=function(){var r=a.grep(m);m.length=0;a.each(r,function(s){if(l[s]==i){n(s);return}if(l[s]!=k){l[s]=k;g++;b(s,function(){l[s]=i;g--;n(s);o()})}});if(!g){a.each(d,function(s){s.func.call(s.scope)});d.length=0}};o()}};a.ScriptLoader=new a.dom.ScriptLoader()})(tinymce);(function(a){a.dom.RangeUtils=function(c){var b="\uFEFF";this.walk=function(d,s){var i=d.startContainer,l=d.startOffset,t=d.endContainer,m=d.endOffset,j,g,o,h,r,q,e;e=c.select("td.mceSelected,th.mceSelected");if(e.length>0){a.each(e,function(u){s([u])});return}function f(u){var v;v=u[0];if(v.nodeType===3&&v===i&&l>=v.nodeValue.length){u.splice(0,1)}v=u[u.length-1];if(m===0&&u.length>0&&v===t&&v.nodeType===3){u.splice(u.length-1,1)}return u}function p(x,v,u){var y=[];for(;x&&x!=u;x=x[v]){y.push(x)}return y}function n(v,u){do{if(v.parentNode==u){return v}v=v.parentNode}while(v)}function k(x,v,y){var u=y?"nextSibling":"previousSibling";for(h=x,r=h.parentNode;h&&h!=v;h=r){r=h.parentNode;q=p(h==x?h:h[u],u);if(q.length){if(!y){q.reverse()}s(f(q))}}}if(i.nodeType==1&&i.hasChildNodes()){i=i.childNodes[l]}if(t.nodeType==1&&t.hasChildNodes()){t=t.childNodes[Math.min(m-1,t.childNodes.length-1)]}if(i==t){return s(f([i]))}j=c.findCommonAncestor(i,t);for(h=i;h;h=h.parentNode){if(h===t){return k(i,j,true)}if(h===j){break}}for(h=t;h;h=h.parentNode){if(h===i){return k(t,j)}if(h===j){break}}g=n(i,j)||i;o=n(t,j)||t;k(i,g,true);q=p(g==i?g:g.nextSibling,"nextSibling",o==t?o.nextSibling:o);if(q.length){s(f(q))}k(t,o)};this.split=function(e){var h=e.startContainer,d=e.startOffset,i=e.endContainer,g=e.endOffset;function f(j,k){return j.splitText(k)}if(h==i&&h.nodeType==3){if(d>0&&d<h.nodeValue.length){i=f(h,d);h=i.previousSibling;if(g>d){g=g-d;h=i=f(i,g).previousSibling;g=i.nodeValue.length;d=0}else{g=0}}}else{if(h.nodeType==3&&d>0&&d<h.nodeValue.length){h=f(h,d);d=0}if(i.nodeType==3&&g>0&&g<i.nodeValue.length){i=f(i,g).previousSibling;g=i.nodeValue.length}}return{startContainer:h,startOffset:d,endContainer:i,endOffset:g}}};a.dom.RangeUtils.compareRanges=function(c,b){if(c&&b){if(c.item||c.duplicate){if(c.item&&b.item&&c.item(0)===b.item(0)){return true}if(c.isEqual&&b.isEqual&&b.isEqual(c)){return true}}else{return c.startContainer==b.startContainer&&c.startOffset==b.startOffset}}return false}})(tinymce);(function(b){var a=b.dom.Event,c=b.each;b.create("tinymce.ui.KeyboardNavigation",{KeyboardNavigation:function(e,f){var q=this,n=e.root,m=e.items,o=e.enableUpDown,i=e.enableLeftRight||!e.enableUpDown,l=e.excludeFromTabOrder,k,h,p,d,g;f=f||b.DOM;k=function(r){g=r.target.id};h=function(r){f.setAttrib(r.target.id,"tabindex","-1")};d=function(r){var s=f.get(g);f.setAttrib(s,"tabindex","0");s.focus()};q.focus=function(){f.get(g).focus()};q.destroy=function(){c(m,function(s){var t=f.get(s.id);f.unbind(t,"focus",k);f.unbind(t,"blur",h)});var r=f.get(n);f.unbind(r,"focus",d);f.unbind(r,"keydown",p);m=f=n=q.focus=k=h=p=d=null;q.destroy=function(){}};q.moveFocus=function(v,s){var r=-1,u=q.controls,t;if(!g){return}c(m,function(y,x){if(y.id===g){r=x;return false}});r+=v;if(r<0){r=m.length-1}else{if(r>=m.length){r=0}}t=m[r];f.setAttrib(g,"tabindex","-1");f.setAttrib(t.id,"tabindex","0");f.get(t.id).focus();if(e.actOnFocus){e.onAction(t.id)}if(s){a.cancel(s)}};p=function(z){var v=37,u=39,y=38,A=40,r=27,t=14,s=13,x=32;switch(z.keyCode){case v:if(i){q.moveFocus(-1)}break;case u:if(i){q.moveFocus(1)}break;case y:if(o){q.moveFocus(-1)}break;case A:if(o){q.moveFocus(1)}break;case r:if(e.onCancel){e.onCancel();a.cancel(z)}break;case t:case s:case x:if(e.onAction){e.onAction(g);a.cancel(z)}break}};c(m,function(t,r){var s,u;if(!t.id){t.id=f.uniqueId("_mce_item_")}u=f.get(t.id);if(l){f.bind(u,"blur",h);s="-1"}else{s=(r===0?"0":"-1")}u.setAttribute("tabindex",s);f.bind(u,"focus",k)});if(m[0]){g=m[0].id}f.setAttrib(n,"tabindex","-1");var j=f.get(n);f.bind(j,"focus",d);f.bind(j,"keydown",p)}})})(tinymce);(function(c){var b=c.DOM,a=c.is;c.create("tinymce.ui.Control",{Control:function(f,e,d){this.id=f;this.settings=e=e||{};this.rendered=false;this.onRender=new c.util.Dispatcher(this);this.classPrefix="";this.scope=e.scope||this;this.disabled=0;this.active=0;this.editor=d},setAriaProperty:function(f,e){var d=b.get(this.id+"_aria")||b.get(this.id);if(d){b.setAttrib(d,"aria-"+f,!!e)}},focus:function(){b.get(this.id).focus()},setDisabled:function(d){if(d!=this.disabled){this.setAriaProperty("disabled",d);this.setState("Disabled",d);this.setState("Enabled",!d);this.disabled=d}},isDisabled:function(){return this.disabled},setActive:function(d){if(d!=this.active){this.setState("Active",d);this.active=d;this.setAriaProperty("pressed",d)}},isActive:function(){return this.active},setState:function(f,d){var e=b.get(this.id);f=this.classPrefix+f;if(d){b.addClass(e,f)}else{b.removeClass(e,f)}},isRendered:function(){return this.rendered},renderHTML:function(){},renderTo:function(d){b.setHTML(d,this.renderHTML())},postRender:function(){var e=this,d;if(a(e.disabled)){d=e.disabled;e.disabled=-1;e.setDisabled(d)}if(a(e.active)){d=e.active;e.active=-1;e.setActive(d)}},remove:function(){b.remove(this.id);this.destroy()},destroy:function(){c.dom.Event.clear(this.id)}})})(tinymce);tinymce.create("tinymce.ui.Container:tinymce.ui.Control",{Container:function(c,b,a){this.parent(c,b,a);this.controls=[];this.lookup={}},add:function(a){this.lookup[a.id]=a;this.controls.push(a);return a},get:function(a){return this.lookup[a]}});tinymce.create("tinymce.ui.Separator:tinymce.ui.Control",{Separator:function(b,a){this.parent(b,a);this.classPrefix="mceSeparator";this.setDisabled(true)},renderHTML:function(){return tinymce.DOM.createHTML("span",{"class":this.classPrefix,role:"separator","aria-orientation":"vertical",tabindex:"-1"})}});(function(d){var c=d.is,b=d.DOM,e=d.each,a=d.walk;d.create("tinymce.ui.MenuItem:tinymce.ui.Control",{MenuItem:function(g,f){this.parent(g,f);this.classPrefix="mceMenuItem"},setSelected:function(f){this.setState("Selected",f);this.setAriaProperty("checked",!!f);this.selected=f},isSelected:function(){return this.selected},postRender:function(){var f=this;f.parent();if(c(f.selected)){f.setSelected(f.selected)}}})})(tinymce);(function(d){var c=d.is,b=d.DOM,e=d.each,a=d.walk;d.create("tinymce.ui.Menu:tinymce.ui.MenuItem",{Menu:function(h,g){var f=this;f.parent(h,g);f.items={};f.collapsed=false;f.menuCount=0;f.onAddItem=new d.util.Dispatcher(this)},expand:function(g){var f=this;if(g){a(f,function(h){if(h.expand){h.expand()}},"items",f)}f.collapsed=false},collapse:function(g){var f=this;if(g){a(f,function(h){if(h.collapse){h.collapse()}},"items",f)}f.collapsed=true},isCollapsed:function(){return this.collapsed},add:function(f){if(!f.settings){f=new d.ui.MenuItem(f.id||b.uniqueId(),f)}this.onAddItem.dispatch(this,f);return this.items[f.id]=f},addSeparator:function(){return this.add({separator:true})},addMenu:function(f){if(!f.collapse){f=this.createMenu(f)}this.menuCount++;return this.add(f)},hasMenus:function(){return this.menuCount!==0},remove:function(f){delete this.items[f.id]},removeAll:function(){var f=this;a(f,function(g){if(g.removeAll){g.removeAll()}else{g.remove()}g.destroy()},"items",f);f.items={}},createMenu:function(g){var f=new d.ui.Menu(g.id||b.uniqueId(),g);f.onAddItem.add(this.onAddItem.dispatch,this.onAddItem);return f}})})(tinymce);(function(e){var d=e.is,c=e.DOM,f=e.each,a=e.dom.Event,b=e.dom.Element;e.create("tinymce.ui.DropMenu:tinymce.ui.Menu",{DropMenu:function(h,g){g=g||{};g.container=g.container||c.doc.body;g.offset_x=g.offset_x||0;g.offset_y=g.offset_y||0;g.vp_offset_x=g.vp_offset_x||0;g.vp_offset_y=g.vp_offset_y||0;if(d(g.icons)&&!g.icons){g["class"]+=" mceNoIcons"}this.parent(h,g);this.onShowMenu=new e.util.Dispatcher(this);this.onHideMenu=new e.util.Dispatcher(this);this.classPrefix="mceMenu"},createMenu:function(j){var h=this,i=h.settings,g;j.container=j.container||i.container;j.parent=h;j.constrain=j.constrain||i.constrain;j["class"]=j["class"]||i["class"];j.vp_offset_x=j.vp_offset_x||i.vp_offset_x;j.vp_offset_y=j.vp_offset_y||i.vp_offset_y;j.keyboard_focus=i.keyboard_focus;g=new e.ui.DropMenu(j.id||c.uniqueId(),j);g.onAddItem.add(h.onAddItem.dispatch,h.onAddItem);return g},focus:function(){var g=this;if(g.keyboardNav){g.keyboardNav.focus()}},update:function(){var i=this,j=i.settings,g=c.get("menu_"+i.id+"_tbl"),l=c.get("menu_"+i.id+"_co"),h,k;h=j.max_width?Math.min(g.offsetWidth,j.max_width):g.offsetWidth;k=j.max_height?Math.min(g.offsetHeight,j.max_height):g.offsetHeight;if(!c.boxModel){i.element.setStyles({width:h+2,height:k+2})}else{i.element.setStyles({width:h,height:k})}if(j.max_width){c.setStyle(l,"width",h)}if(j.max_height){c.setStyle(l,"height",k);if(g.clientHeight<j.max_height){c.setStyle(l,"overflow","hidden")}}},showMenu:function(p,n,r){var z=this,A=z.settings,o,g=c.getViewPort(),u,l,v,q,i=2,k,j,m=z.classPrefix;z.collapse(1);if(z.isMenuVisible){return}if(!z.rendered){o=c.add(z.settings.container,z.renderNode());f(z.items,function(h){h.postRender()});z.element=new b("menu_"+z.id,{blocker:1,container:A.container})}else{o=c.get("menu_"+z.id)}if(!e.isOpera){c.setStyles(o,{left:-65535,top:-65535})}c.show(o);z.update();p+=A.offset_x||0;n+=A.offset_y||0;g.w-=4;g.h-=4;if(A.constrain){u=o.clientWidth-i;l=o.clientHeight-i;v=g.x+g.w;q=g.y+g.h;if((p+A.vp_offset_x+u)>v){p=r?r-u:Math.max(0,(v-A.vp_offset_x)-u)}if((n+A.vp_offset_y+l)>q){n=Math.max(0,(q-A.vp_offset_y)-l)}}c.setStyles(o,{left:p,top:n});z.element.update();z.isMenuVisible=1;z.mouseClickFunc=a.add(o,"click",function(s){var h;s=s.target;if(s&&(s=c.getParent(s,"tr"))&&!c.hasClass(s,m+"ItemSub")){h=z.items[s.id];if(h.isDisabled()){return}k=z;while(k){if(k.hideMenu){k.hideMenu()}k=k.settings.parent}if(h.settings.onclick){h.settings.onclick(s)}return false}});if(z.hasMenus()){z.mouseOverFunc=a.add(o,"mouseover",function(x){var h,t,s;x=x.target;if(x&&(x=c.getParent(x,"tr"))){h=z.items[x.id];if(z.lastMenu){z.lastMenu.collapse(1)}if(h.isDisabled()){return}if(x&&c.hasClass(x,m+"ItemSub")){t=c.getRect(x);h.showMenu((t.x+t.w-i),t.y-i,t.x);z.lastMenu=h;c.addClass(c.get(h.id).firstChild,m+"ItemActive")}}})}a.add(o,"keydown",z._keyHandler,z);z.onShowMenu.dispatch(z);if(A.keyboard_focus){z._setupKeyboardNav()}},hideMenu:function(j){var g=this,i=c.get("menu_"+g.id),h;if(!g.isMenuVisible){return}if(g.keyboardNav){g.keyboardNav.destroy()}a.remove(i,"mouseover",g.mouseOverFunc);a.remove(i,"click",g.mouseClickFunc);a.remove(i,"keydown",g._keyHandler);c.hide(i);g.isMenuVisible=0;if(!j){g.collapse(1)}if(g.element){g.element.hide()}if(h=c.get(g.id)){c.removeClass(h.firstChild,g.classPrefix+"ItemActive")}g.onHideMenu.dispatch(g)},add:function(i){var g=this,h;i=g.parent(i);if(g.isRendered&&(h=c.get("menu_"+g.id))){g._add(c.select("tbody",h)[0],i)}return i},collapse:function(g){this.parent(g);this.hideMenu(1)},remove:function(g){c.remove(g.id);this.destroy();return this.parent(g)},destroy:function(){var g=this,h=c.get("menu_"+g.id);if(g.keyboardNav){g.keyboardNav.destroy()}a.remove(h,"mouseover",g.mouseOverFunc);a.remove(c.select("a",h),"focus",g.mouseOverFunc);a.remove(h,"click",g.mouseClickFunc);a.remove(h,"keydown",g._keyHandler);if(g.element){g.element.remove()}c.remove(h)},renderNode:function(){var i=this,j=i.settings,l,h,k,g;g=c.create("div",{role:"listbox",id:"menu_"+i.id,"class":j["class"],style:"position:absolute;left:0;top:0;z-index:200000;outline:0"});if(i.settings.parent){c.setAttrib(g,"aria-parent","menu_"+i.settings.parent.id)}k=c.add(g,"div",{role:"presentation",id:"menu_"+i.id+"_co","class":i.classPrefix+(j["class"]?" "+j["class"]:"")});i.element=new b("menu_"+i.id,{blocker:1,container:j.container});if(j.menu_line){c.add(k,"span",{"class":i.classPrefix+"Line"})}l=c.add(k,"table",{role:"presentation",id:"menu_"+i.id+"_tbl",border:0,cellPadding:0,cellSpacing:0});h=c.add(l,"tbody");f(i.items,function(m){i._add(h,m)});i.rendered=true;return g},_setupKeyboardNav:function(){var i,h,g=this;i=c.get("menu_"+g.id);h=c.select("a[role=option]","menu_"+g.id);h.splice(0,0,i);g.keyboardNav=new e.ui.KeyboardNavigation({root:"menu_"+g.id,items:h,onCancel:function(){g.hideMenu()},enableUpDown:true});i.focus()},_keyHandler:function(g){var h=this,i;switch(g.keyCode){case 37:if(h.settings.parent){h.hideMenu();h.settings.parent.focus();a.cancel(g)}break;case 39:if(h.mouseOverFunc){h.mouseOverFunc(g)}break}},_add:function(j,h){var i,q=h.settings,p,l,k,m=this.classPrefix,g;if(q.separator){l=c.add(j,"tr",{id:h.id,"class":m+"ItemSeparator"});c.add(l,"td",{"class":m+"ItemSeparator"});if(i=l.previousSibling){c.addClass(i,"mceLast")}return}i=l=c.add(j,"tr",{id:h.id,"class":m+"Item "+m+"ItemEnabled"});i=k=c.add(i,q.titleItem?"th":"td");i=p=c.add(i,"a",{id:h.id+"_aria",role:q.titleItem?"presentation":"option",href:"javascript:;",onclick:"return false;",onmousedown:"return false;"});if(q.parent){c.setAttrib(p,"aria-haspopup","true");c.setAttrib(p,"aria-owns","menu_"+h.id)}c.addClass(k,q["class"]);g=c.add(i,"span",{"class":"mceIcon"+(q.icon?" mce_"+q.icon:"")});if(q.icon_src){c.add(g,"img",{src:q.icon_src})}i=c.add(i,q.element||"span",{"class":"mceText",title:h.settings.title},h.settings.title);if(h.settings.style){if(typeof h.settings.style=="function"){h.settings.style=h.settings.style()}c.setAttrib(i,"style",h.settings.style)}if(j.childNodes.length==1){c.addClass(l,"mceFirst")}if((i=l.previousSibling)&&c.hasClass(i,m+"ItemSeparator")){c.addClass(l,"mceFirst")}if(h.collapse){c.addClass(l,m+"ItemSub")}if(i=l.previousSibling){c.removeClass(i,"mceLast")}c.addClass(l,"mceLast")}})})(tinymce);(function(b){var a=b.DOM;b.create("tinymce.ui.Button:tinymce.ui.Control",{Button:function(e,d,c){this.parent(e,d,c);this.classPrefix="mceButton"},renderHTML:function(){var f=this.classPrefix,e=this.settings,d,c;c=a.encode(e.label||"");d='<a role="button" id="'+this.id+'" href="javascript:;" class="'+f+" "+f+"Enabled "+e["class"]+(c?" "+f+"Labeled":"")+'" onmousedown="return false;" onclick="return false;" aria-labelledby="'+this.id+'_voice" title="'+a.encode(e.title)+'">';if(e.image&&!(this.editor&&this.editor.forcedHighContrastMode)){d+='<span class="mceIcon '+e["class"]+'"><img class="mceIcon" src="'+e.image+'" alt="'+a.encode(e.title)+'" /></span>'+(c?'<span class="'+f+'Label">'+c+"</span>":"")}else{d+='<span class="mceIcon '+e["class"]+'"></span>'+(c?'<span class="'+f+'Label">'+c+"</span>":"")}d+='<span class="mceVoiceLabel mceIconOnly" style="display: none;" id="'+this.id+'_voice">'+e.title+"</span>";d+="</a>";return d},postRender:function(){var d=this,e=d.settings,c;if(b.isIE&&d.editor){b.dom.Event.add(d.id,"mousedown",function(f){var g=d.editor.selection.getNode().nodeName;c=g==="IMG"?d.editor.selection.getBookmark():null})}b.dom.Event.add(d.id,"click",function(f){if(!d.isDisabled()){if(b.isIE&&d.editor&&c!==null){d.editor.selection.moveToBookmark(c)}return e.onclick.call(e.scope,f)}});b.dom.Event.add(d.id,"keyup",function(f){if(!d.isDisabled()&&f.keyCode==b.VK.SPACEBAR){return e.onclick.call(e.scope,f)}})}})})(tinymce);(function(e){var d=e.DOM,b=e.dom.Event,f=e.each,a=e.util.Dispatcher,c;e.create("tinymce.ui.ListBox:tinymce.ui.Control",{ListBox:function(j,i,g){var h=this;h.parent(j,i,g);h.items=[];h.onChange=new a(h);h.onPostRender=new a(h);h.onAdd=new a(h);h.onRenderMenu=new e.util.Dispatcher(this);h.classPrefix="mceListBox";h.marked={}},select:function(h){var g=this,j,i;g.marked={};if(h==c){return g.selectByIndex(-1)}if(h&&typeof(h)=="function"){i=h}else{i=function(k){return k==h}}if(h!=g.selectedValue){f(g.items,function(l,k){if(i(l.value)){j=1;g.selectByIndex(k);return false}});if(!j){g.selectByIndex(-1)}}},selectByIndex:function(g){var i=this,j,k,h;i.marked={};if(g!=i.selectedIndex){j=d.get(i.id+"_text");h=d.get(i.id+"_voiceDesc");k=i.items[g];if(k){i.selectedValue=k.value;i.selectedIndex=g;d.setHTML(j,d.encode(k.title));d.setHTML(h,i.settings.title+" - "+k.title);d.removeClass(j,"mceTitle");d.setAttrib(i.id,"aria-valuenow",k.title)}else{d.setHTML(j,d.encode(i.settings.title));d.setHTML(h,d.encode(i.settings.title));d.addClass(j,"mceTitle");i.selectedValue=i.selectedIndex=null;d.setAttrib(i.id,"aria-valuenow",i.settings.title)}j=0}},mark:function(g){this.marked[g]=true},add:function(j,g,i){var h=this;i=i||{};i=e.extend(i,{title:j,value:g});h.items.push(i);h.onAdd.dispatch(h,i)},getLength:function(){return this.items.length},renderHTML:function(){var j="",g=this,i=g.settings,k=g.classPrefix;j='<span role="listbox" aria-haspopup="true" aria-labelledby="'+g.id+'_voiceDesc" aria-describedby="'+g.id+'_voiceDesc"><table role="presentation" tabindex="0" id="'+g.id+'" cellpadding="0" cellspacing="0" class="'+k+" "+k+"Enabled"+(i["class"]?(" "+i["class"]):"")+'"><tbody><tr>';j+="<td>"+d.createHTML("span",{id:g.id+"_voiceDesc","class":"voiceLabel",style:"display:none;"},g.settings.title);j+=d.createHTML("a",{id:g.id+"_text",tabindex:-1,href:"javascript:;","class":"mceText",onclick:"return false;",onmousedown:"return false;"},d.encode(g.settings.title))+"</td>";j+="<td>"+d.createHTML("a",{id:g.id+"_open",tabindex:-1,href:"javascript:;","class":"mceOpen",onclick:"return false;",onmousedown:"return false;"},'<span><span style="display:none;" class="mceIconOnly" aria-hidden="true">\u25BC</span></span>')+"</td>";j+="</tr></tbody></table></span>";return j},showMenu:function(){var h=this,j,i=d.get(this.id),g;if(h.isDisabled()||h.items.length===0){return}if(h.menu&&h.menu.isMenuVisible){return h.hideMenu()}if(!h.isMenuRendered){h.renderMenu();h.isMenuRendered=true}j=d.getPos(i);g=h.menu;g.settings.offset_x=j.x;g.settings.offset_y=j.y;g.settings.keyboard_focus=!e.isOpera;f(h.items,function(k){if(g.items[k.id]){g.items[k.id].setSelected(0)}});f(h.items,function(k){if(g.items[k.id]&&h.marked[k.value]){g.items[k.id].setSelected(1)}if(k.value===h.selectedValue){g.items[k.id].setSelected(1)}});g.showMenu(0,i.clientHeight);b.add(d.doc,"mousedown",h.hideMenu,h);d.addClass(h.id,h.classPrefix+"Selected")},hideMenu:function(h){var g=this;if(g.menu&&g.menu.isMenuVisible){d.removeClass(g.id,g.classPrefix+"Selected");if(h&&h.type=="mousedown"&&(h.target.id==g.id+"_text"||h.target.id==g.id+"_open")){return}if(!h||!d.getParent(h.target,".mceMenu")){d.removeClass(g.id,g.classPrefix+"Selected");b.remove(d.doc,"mousedown",g.hideMenu,g);g.menu.hideMenu()}}},renderMenu:function(){var h=this,g;g=h.settings.control_manager.createDropMenu(h.id+"_menu",{menu_line:1,"class":h.classPrefix+"Menu mceNoIcons",max_width:250,max_height:150});g.onHideMenu.add(function(){h.hideMenu();h.focus()});g.add({title:h.settings.title,"class":"mceMenuItemTitle",onclick:function(){if(h.settings.onselect("")!==false){h.select("")}}});f(h.items,function(i){if(i.value===c){g.add({title:i.title,role:"option","class":"mceMenuItemTitle",onclick:function(){if(h.settings.onselect("")!==false){h.select("")}}})}else{i.id=d.uniqueId();i.role="option";i.onclick=function(){if(h.settings.onselect(i.value)!==false){h.select(i.value)}};g.add(i)}});h.onRenderMenu.dispatch(h,g);h.menu=g},postRender:function(){var g=this,h=g.classPrefix;b.add(g.id,"click",g.showMenu,g);b.add(g.id,"keydown",function(i){if(i.keyCode==32){g.showMenu(i);b.cancel(i)}});b.add(g.id,"focus",function(){if(!g._focused){g.keyDownHandler=b.add(g.id,"keydown",function(i){if(i.keyCode==40){g.showMenu();b.cancel(i)}});g.keyPressHandler=b.add(g.id,"keypress",function(j){var i;if(j.keyCode==13){i=g.selectedValue;g.selectedValue=null;b.cancel(j);g.settings.onselect(i)}})}g._focused=1});b.add(g.id,"blur",function(){b.remove(g.id,"keydown",g.keyDownHandler);b.remove(g.id,"keypress",g.keyPressHandler);g._focused=0});if(e.isIE6||!d.boxModel){b.add(g.id,"mouseover",function(){if(!d.hasClass(g.id,h+"Disabled")){d.addClass(g.id,h+"Hover")}});b.add(g.id,"mouseout",function(){if(!d.hasClass(g.id,h+"Disabled")){d.removeClass(g.id,h+"Hover")}})}g.onPostRender.dispatch(g,d.get(g.id))},destroy:function(){this.parent();b.clear(this.id+"_text");b.clear(this.id+"_open")}})})(tinymce);(function(e){var d=e.DOM,b=e.dom.Event,f=e.each,a=e.util.Dispatcher,c;e.create("tinymce.ui.NativeListBox:tinymce.ui.ListBox",{NativeListBox:function(h,g){this.parent(h,g);this.classPrefix="mceNativeListBox"},setDisabled:function(g){d.get(this.id).disabled=g;this.setAriaProperty("disabled",g)},isDisabled:function(){return d.get(this.id).disabled},select:function(h){var g=this,j,i;if(h==c){return g.selectByIndex(-1)}if(h&&typeof(h)=="function"){i=h}else{i=function(k){return k==h}}if(h!=g.selectedValue){f(g.items,function(l,k){if(i(l.value)){j=1;g.selectByIndex(k);return false}});if(!j){g.selectByIndex(-1)}}},selectByIndex:function(g){d.get(this.id).selectedIndex=g+1;this.selectedValue=this.items[g]?this.items[g].value:null},add:function(k,h,g){var j,i=this;g=g||{};g.value=h;if(i.isRendered()){d.add(d.get(this.id),"option",g,k)}j={title:k,value:h,attribs:g};i.items.push(j);i.onAdd.dispatch(i,j)},getLength:function(){return this.items.length},renderHTML:function(){var i,g=this;i=d.createHTML("option",{value:""},"-- "+g.settings.title+" --");f(g.items,function(h){i+=d.createHTML("option",{value:h.value},h.title)});i=d.createHTML("select",{id:g.id,"class":"mceNativeListBox","aria-labelledby":g.id+"_aria"},i);i+=d.createHTML("span",{id:g.id+"_aria",style:"display: none"},g.settings.title);return i},postRender:function(){var h=this,i,j=true;h.rendered=true;function g(l){var k=h.items[l.target.selectedIndex-1];if(k&&(k=k.value)){h.onChange.dispatch(h,k);if(h.settings.onselect){h.settings.onselect(k)}}}b.add(h.id,"change",g);b.add(h.id,"keydown",function(l){var k;b.remove(h.id,"change",i);j=false;k=b.add(h.id,"blur",function(){if(j){return}j=true;b.add(h.id,"change",g);b.remove(h.id,"blur",k)});if(e.isWebKit&&(l.keyCode==37||l.keyCode==39)){return b.prevent(l)}if(l.keyCode==13||l.keyCode==32){g(l);return b.cancel(l)}});h.onPostRender.dispatch(h,d.get(h.id))}})})(tinymce);(function(c){var b=c.DOM,a=c.dom.Event,d=c.each;c.create("tinymce.ui.MenuButton:tinymce.ui.Button",{MenuButton:function(g,f,e){this.parent(g,f,e);this.onRenderMenu=new c.util.Dispatcher(this);f.menu_container=f.menu_container||b.doc.body},showMenu:function(){var g=this,j,i,h=b.get(g.id),f;if(g.isDisabled()){return}if(!g.isMenuRendered){g.renderMenu();g.isMenuRendered=true}if(g.isMenuVisible){return g.hideMenu()}j=b.getPos(g.settings.menu_container);i=b.getPos(h);f=g.menu;f.settings.offset_x=i.x;f.settings.offset_y=i.y;f.settings.vp_offset_x=i.x;f.settings.vp_offset_y=i.y;f.settings.keyboard_focus=g._focused;f.showMenu(0,h.firstChild.clientHeight);a.add(b.doc,"mousedown",g.hideMenu,g);g.setState("Selected",1);g.isMenuVisible=1},renderMenu:function(){var f=this,e;e=f.settings.control_manager.createDropMenu(f.id+"_menu",{menu_line:1,"class":this.classPrefix+"Menu",icons:f.settings.icons});e.onHideMenu.add(function(){f.hideMenu();f.focus()});f.onRenderMenu.dispatch(f,e);f.menu=e},hideMenu:function(g){var f=this;if(g&&g.type=="mousedown"&&b.getParent(g.target,function(h){return h.id===f.id||h.id===f.id+"_open"})){return}if(!g||!b.getParent(g.target,".mceMenu")){f.setState("Selected",0);a.remove(b.doc,"mousedown",f.hideMenu,f);if(f.menu){f.menu.hideMenu()}}f.isMenuVisible=0},postRender:function(){var e=this,f=e.settings;a.add(e.id,"click",function(){if(!e.isDisabled()){if(f.onclick){f.onclick(e.value)}e.showMenu()}})}})})(tinymce);(function(c){var b=c.DOM,a=c.dom.Event,d=c.each;c.create("tinymce.ui.SplitButton:tinymce.ui.MenuButton",{SplitButton:function(g,f,e){this.parent(g,f,e);this.classPrefix="mceSplitButton"},renderHTML:function(){var i,f=this,g=f.settings,e;i="<tbody><tr>";if(g.image){e=b.createHTML("img ",{src:g.image,role:"presentation","class":"mceAction "+g["class"]})}else{e=b.createHTML("span",{"class":"mceAction "+g["class"]},"")}e+=b.createHTML("span",{"class":"mceVoiceLabel mceIconOnly",id:f.id+"_voice",style:"display:none;"},g.title);i+="<td >"+b.createHTML("a",{role:"button",id:f.id+"_action",tabindex:"-1",href:"javascript:;","class":"mceAction "+g["class"],onclick:"return false;",onmousedown:"return false;",title:g.title},e)+"</td>";e=b.createHTML("span",{"class":"mceOpen "+g["class"]},'<span style="display:none;" class="mceIconOnly" aria-hidden="true">\u25BC</span>');i+="<td >"+b.createHTML("a",{role:"button",id:f.id+"_open",tabindex:"-1",href:"javascript:;","class":"mceOpen "+g["class"],onclick:"return false;",onmousedown:"return false;",title:g.title},e)+"</td>";i+="</tr></tbody>";i=b.createHTML("table",{role:"presentation","class":"mceSplitButton mceSplitButtonEnabled "+g["class"],cellpadding:"0",cellspacing:"0",title:g.title},i);return b.createHTML("div",{id:f.id,role:"button",tabindex:"0","aria-labelledby":f.id+"_voice","aria-haspopup":"true"},i)},postRender:function(){var e=this,g=e.settings,f;if(g.onclick){f=function(h){if(!e.isDisabled()){g.onclick(e.value);a.cancel(h)}};a.add(e.id+"_action","click",f);a.add(e.id,["click","keydown"],function(h){var k=32,m=14,i=13,j=38,l=40;if((h.keyCode===32||h.keyCode===13||h.keyCode===14)&&!h.altKey&&!h.ctrlKey&&!h.metaKey){f();a.cancel(h)}else{if(h.type==="click"||h.keyCode===l){e.showMenu();a.cancel(h)}}})}a.add(e.id+"_open","click",function(h){e.showMenu();a.cancel(h)});a.add([e.id,e.id+"_open"],"focus",function(){e._focused=1});a.add([e.id,e.id+"_open"],"blur",function(){e._focused=0});if(c.isIE6||!b.boxModel){a.add(e.id,"mouseover",function(){if(!b.hasClass(e.id,"mceSplitButtonDisabled")){b.addClass(e.id,"mceSplitButtonHover")}});a.add(e.id,"mouseout",function(){if(!b.hasClass(e.id,"mceSplitButtonDisabled")){b.removeClass(e.id,"mceSplitButtonHover")}})}},destroy:function(){this.parent();a.clear(this.id+"_action");a.clear(this.id+"_open");a.clear(this.id)}})})(tinymce);(function(d){var c=d.DOM,a=d.dom.Event,b=d.is,e=d.each;d.create("tinymce.ui.ColorSplitButton:tinymce.ui.SplitButton",{ColorSplitButton:function(i,h,f){var g=this;g.parent(i,h,f);g.settings=h=d.extend({colors:"000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,008000,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF",grid_width:8,default_color:"#888888"},g.settings);g.onShowMenu=new d.util.Dispatcher(g);g.onHideMenu=new d.util.Dispatcher(g);g.value=h.default_color},showMenu:function(){var f=this,g,j,i,h;if(f.isDisabled()){return}if(!f.isMenuRendered){f.renderMenu();f.isMenuRendered=true}if(f.isMenuVisible){return f.hideMenu()}i=c.get(f.id);c.show(f.id+"_menu");c.addClass(i,"mceSplitButtonSelected");h=c.getPos(i);c.setStyles(f.id+"_menu",{left:h.x,top:h.y+i.firstChild.clientHeight,zIndex:200000});i=0;a.add(c.doc,"mousedown",f.hideMenu,f);f.onShowMenu.dispatch(f);if(f._focused){f._keyHandler=a.add(f.id+"_menu","keydown",function(k){if(k.keyCode==27){f.hideMenu()}});c.select("a",f.id+"_menu")[0].focus()}f.keyboardNav=new d.ui.KeyboardNavigation({root:f.id+"_menu",items:c.select("a",f.id+"_menu"),onCancel:function(){f.hideMenu();f.focus()}});f.keyboardNav.focus();f.isMenuVisible=1},hideMenu:function(g){var f=this;if(f.isMenuVisible){if(g&&g.type=="mousedown"&&c.getParent(g.target,function(h){return h.id===f.id+"_open"})){return}if(!g||!c.getParent(g.target,".mceSplitButtonMenu")){c.removeClass(f.id,"mceSplitButtonSelected");a.remove(c.doc,"mousedown",f.hideMenu,f);a.remove(f.id+"_menu","keydown",f._keyHandler);c.hide(f.id+"_menu")}f.isMenuVisible=0;f.onHideMenu.dispatch();f.keyboardNav.destroy()}},renderMenu:function(){var p=this,h,k=0,q=p.settings,g,j,l,o,f;o=c.add(q.menu_container,"div",{role:"listbox",id:p.id+"_menu","class":q.menu_class+" "+q["class"],style:"position:absolute;left:0;top:-1000px;"});h=c.add(o,"div",{"class":q["class"]+" mceSplitButtonMenu"});c.add(h,"span",{"class":"mceMenuLine"});g=c.add(h,"table",{role:"presentation","class":"mceColorSplitMenu"});j=c.add(g,"tbody");k=0;e(b(q.colors,"array")?q.colors:q.colors.split(","),function(m){m=m.replace(/^#/,"");if(!k--){l=c.add(j,"tr");k=q.grid_width-1}g=c.add(l,"td");var i={href:"javascript:;",style:{backgroundColor:"#"+m},title:p.editor.getLang("colors."+m,m),"data-mce-color":"#"+m};if(!d.isIE){i.role="option"}g=c.add(g,"a",i);if(p.editor.forcedHighContrastMode){g=c.add(g,"canvas",{width:16,height:16,"aria-hidden":"true"});if(g.getContext&&(f=g.getContext("2d"))){f.fillStyle="#"+m;f.fillRect(0,0,16,16)}else{c.remove(g)}}});if(q.more_colors_func){g=c.add(j,"tr");g=c.add(g,"td",{colspan:q.grid_width,"class":"mceMoreColors"});g=c.add(g,"a",{role:"option",id:p.id+"_more",href:"javascript:;",onclick:"return false;","class":"mceMoreColors"},q.more_colors_title);a.add(g,"click",function(i){q.more_colors_func.call(q.more_colors_scope||this);return a.cancel(i)})}c.addClass(h,"mceColorSplitMenu");a.add(p.id+"_menu","mousedown",function(i){return a.cancel(i)});a.add(p.id+"_menu","click",function(i){var m;i=c.getParent(i.target,"a",j);if(i&&i.nodeName.toLowerCase()=="a"&&(m=i.getAttribute("data-mce-color"))){p.setColor(m)}return false});return o},setColor:function(f){this.displayColor(f);this.hideMenu();this.settings.onselect(f)},displayColor:function(g){var f=this;c.setStyle(f.id+"_preview","backgroundColor",g);f.value=g},postRender:function(){var f=this,g=f.id;f.parent();c.add(g+"_action","div",{id:g+"_preview","class":"mceColorPreview"});c.setStyle(f.id+"_preview","backgroundColor",f.value)},destroy:function(){var f=this;f.parent();a.clear(f.id+"_menu");a.clear(f.id+"_more");c.remove(f.id+"_menu");if(f.keyboardNav){f.keyboardNav.destroy()}}})})(tinymce);(function(b){var d=b.DOM,c=b.each,a=b.dom.Event;b.create("tinymce.ui.ToolbarGroup:tinymce.ui.Container",{renderHTML:function(){var f=this,i=[],e=f.controls,j=b.each,g=f.settings;i.push('<div id="'+f.id+'" role="group" aria-labelledby="'+f.id+'_voice">');i.push("<span role='application'>");i.push('<span id="'+f.id+'_voice" class="mceVoiceLabel" style="display:none;">'+d.encode(g.name)+"</span>");j(e,function(h){i.push(h.renderHTML())});i.push("</span>");i.push("</div>");return i.join("")},focus:function(){var e=this;d.get(e.id).focus()},postRender:function(){var f=this,e=[];c(f.controls,function(g){c(g.controls,function(h){if(h.id){e.push(h)}})});f.keyNav=new b.ui.KeyboardNavigation({root:f.id,items:e,onCancel:function(){if(b.isWebKit){d.get(f.editor.id+"_ifr").focus()}f.editor.focus()},excludeFromTabOrder:!f.settings.tab_focus_toolbar})},destroy:function(){var e=this;e.parent();e.keyNav.destroy();a.clear(e.id)}})})(tinymce);(function(a){var c=a.DOM,b=a.each;a.create("tinymce.ui.Toolbar:tinymce.ui.Container",{renderHTML:function(){var m=this,f="",j,k,n=m.settings,e,d,g,l;l=m.controls;for(e=0;e<l.length;e++){k=l[e];d=l[e-1];g=l[e+1];if(e===0){j="mceToolbarStart";if(k.Button){j+=" mceToolbarStartButton"}else{if(k.SplitButton){j+=" mceToolbarStartSplitButton"}else{if(k.ListBox){j+=" mceToolbarStartListBox"}}}f+=c.createHTML("td",{"class":j},c.createHTML("span",null,"<!-- IE -->"))}if(d&&k.ListBox){if(d.Button||d.SplitButton){f+=c.createHTML("td",{"class":"mceToolbarEnd"},c.createHTML("span",null,"<!-- IE -->"))}}if(c.stdMode){f+='<td style="position: relative">'+k.renderHTML()+"</td>"}else{f+="<td>"+k.renderHTML()+"</td>"}if(g&&k.ListBox){if(g.Button||g.SplitButton){f+=c.createHTML("td",{"class":"mceToolbarStart"},c.createHTML("span",null,"<!-- IE -->"))}}}j="mceToolbarEnd";if(k.Button){j+=" mceToolbarEndButton"}else{if(k.SplitButton){j+=" mceToolbarEndSplitButton"}else{if(k.ListBox){j+=" mceToolbarEndListBox"}}}f+=c.createHTML("td",{"class":j},c.createHTML("span",null,"<!-- IE -->"));return c.createHTML("table",{id:m.id,"class":"mceToolbar"+(n["class"]?" "+n["class"]:""),cellpadding:"0",cellspacing:"0",align:m.settings.align||"",role:"presentation",tabindex:"-1"},"<tbody><tr>"+f+"</tr></tbody>")}})})(tinymce);(function(b){var a=b.util.Dispatcher,c=b.each;b.create("tinymce.AddOnManager",{AddOnManager:function(){var d=this;d.items=[];d.urls={};d.lookup={};d.onAdd=new a(d)},get:function(d){if(this.lookup[d]){return this.lookup[d].instance}else{return undefined}},dependencies:function(e){var d;if(this.lookup[e]){d=this.lookup[e].dependencies}return d||[]},requireLangPack:function(e){var d=b.settings;if(d&&d.language&&d.language_load!==false){b.ScriptLoader.add(this.urls[e]+"/langs/"+d.language+".js")}},add:function(f,e,d){this.items.push(e);this.lookup[f]={instance:e,dependencies:d};this.onAdd.dispatch(this,f,e);return e},createUrl:function(d,e){if(typeof e==="object"){return e}else{return{prefix:d.prefix,resource:e,suffix:d.suffix}}},addComponents:function(f,d){var e=this.urls[f];b.each(d,function(g){b.ScriptLoader.add(e+"/"+g)})},load:function(j,f,d,h){var g=this,e=f;function i(){var k=g.dependencies(j);b.each(k,function(m){var l=g.createUrl(f,m);g.load(l.resource,l,undefined,undefined)});if(d){if(h){d.call(h)}else{d.call(b.ScriptLoader)}}}if(g.urls[j]){return}if(typeof f==="object"){e=f.prefix+f.resource+f.suffix}if(e.indexOf("/")!==0&&e.indexOf("://")==-1){e=b.baseURL+"/"+e}g.urls[j]=e.substring(0,e.lastIndexOf("/"));if(g.lookup[j]){i()}else{b.ScriptLoader.add(e,i,h)}}});b.PluginManager=new b.AddOnManager();b.ThemeManager=new b.AddOnManager()}(tinymce));(function(j){var g=j.each,d=j.extend,k=j.DOM,i=j.dom.Event,f=j.ThemeManager,b=j.PluginManager,e=j.explode,h=j.util.Dispatcher,a,c=0;j.documentBaseURL=window.location.href.replace(/[\?#].*$/,"").replace(/[\/\\][^\/]+$/,"");if(!/[\/\\]$/.test(j.documentBaseURL)){j.documentBaseURL+="/"}j.baseURL=new j.util.URI(j.documentBaseURL).toAbsolute(j.baseURL);j.baseURI=new j.util.URI(j.baseURL);j.onBeforeUnload=new h(j);i.add(window,"beforeunload",function(l){j.onBeforeUnload.dispatch(j,l)});j.onAddEditor=new h(j);j.onRemoveEditor=new h(j);j.EditorManager=d(j,{editors:[],i18n:{},activeEditor:null,init:function(x){var v=this,o,n=j.ScriptLoader,u,l=[],r;function q(t){var s=t.id;if(!s){s=t.name;if(s&&!k.get(s)){s=t.name}else{s=k.uniqueId()}t.setAttribute("id",s)}return s}function m(z,A,t){var y=z[A];if(!y){return}if(j.is(y,"string")){t=y.replace(/\.\w+$/,"");t=t?j.resolve(t):0;y=j.resolve(y)}return y.apply(t||this,Array.prototype.slice.call(arguments,2))}function p(t,s){return s.constructor===RegExp?s.test(t.className):k.hasClass(t,s)}v.settings=x;i.bind(window,"ready",function(){var s,t;m(x,"onpageload");switch(x.mode){case"exact":s=x.elements||"";if(s.length>0){g(e(s),function(y){if(k.get(y)){r=new j.Editor(y,x);l.push(r);r.render(1)}else{g(document.forms,function(z){g(z.elements,function(A){if(A.name===y){y="mce_editor_"+c++;k.setAttrib(A,"id",y);r=new j.Editor(y,x);l.push(r);r.render(1)}})})}})}break;case"textareas":case"specific_textareas":g(k.select("textarea"),function(y){if(x.editor_deselector&&p(y,x.editor_deselector)){return}if(!x.editor_selector||p(y,x.editor_selector)){r=new j.Editor(q(y),x);l.push(r);r.render(1)}});break;default:if(x.types){g(x.types,function(y){g(k.select(y.selector),function(A){var z=new j.Editor(q(A),j.extend({},x,y));l.push(z);z.render(1)})})}else{if(x.selector){g(k.select(x.selector),function(z){var y=new j.Editor(q(z),x);l.push(y);y.render(1)})}}}if(x.oninit){s=t=0;g(l,function(y){t++;if(!y.initialized){y.onInit.add(function(){s++;if(s==t){m(x,"oninit")}})}else{s++}if(s==t){m(x,"oninit")}})}})},get:function(l){if(l===a){return this.editors}return this.editors[l]},getInstanceById:function(l){return this.get(l)},add:function(m){var l=this,n=l.editors;n[m.id]=m;n.push(m);l._setActive(m);l.onAddEditor.dispatch(l,m);return m},remove:function(n){var m=this,l,o=m.editors;if(!o[n.id]){return null}delete o[n.id];for(l=0;l<o.length;l++){if(o[l]==n){o.splice(l,1);break}}if(m.activeEditor==n){m._setActive(o[0])}n.destroy();m.onRemoveEditor.dispatch(m,n);return n},execCommand:function(r,p,o){var q=this,n=q.get(o),l;function m(){n.destroy();l.detachEvent("onunload",m);l=l.tinyMCE=l.tinymce=null}switch(r){case"mceFocus":n.focus();return true;case"mceAddEditor":case"mceAddControl":if(!q.get(o)){new j.Editor(o,q.settings).render()}return true;case"mceAddFrameControl":l=o.window;l.tinyMCE=tinyMCE;l.tinymce=j;j.DOM.doc=l.document;j.DOM.win=l;n=new j.Editor(o.element_id,o);n.render();if(j.isIE){l.attachEvent("onunload",m)}o.page_window=null;return true;case"mceRemoveEditor":case"mceRemoveControl":if(n){n.remove()}return true;case"mceToggleEditor":if(!n){q.execCommand("mceAddControl",0,o);return true}if(n.isHidden()){n.show()}else{n.hide()}return true}if(q.activeEditor){return q.activeEditor.execCommand(r,p,o)}return false},execInstanceCommand:function(p,o,n,m){var l=this.get(p);if(l){return l.execCommand(o,n,m)}return false},triggerSave:function(){g(this.editors,function(l){l.save()})},addI18n:function(n,q){var l,m=this.i18n;if(!j.is(n,"string")){g(n,function(r,p){g(r,function(t,s){g(t,function(v,u){if(s==="common"){m[p+"."+u]=v}else{m[p+"."+s+"."+u]=v}})})})}else{g(q,function(r,p){m[n+"."+p]=r})}},_setActive:function(l){this.selectedInstance=this.activeEditor=l}})})(tinymce);(function(k){var l=k.DOM,j=k.dom.Event,f=k.extend,i=k.each,a=k.isGecko,b=k.isIE,e=k.isWebKit,d=k.is,h=k.ThemeManager,c=k.PluginManager,g=k.explode;k.create("tinymce.Editor",{Editor:function(p,o){var m=this,n=true;m.settings=o=f({id:p,language:"en",theme:"advanced",skin:"default",delta_width:0,delta_height:0,popup_css:"",plugins:"",document_base_url:k.documentBaseURL,add_form_submit_trigger:n,submit_patch:n,add_unload_trigger:n,convert_urls:n,relative_urls:n,remove_script_host:n,table_inline_editing:false,object_resizing:n,accessibility_focus:n,doctype:k.isIE6?'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">':"<!DOCTYPE>",visual:n,font_size_style_values:"xx-small,x-small,small,medium,large,x-large,xx-large",font_size_legacy_values:"xx-small,small,medium,large,x-large,xx-large,300%",apply_source_formatting:n,directionality:"ltr",forced_root_block:"p",hidden_input:n,padd_empty_editor:n,render_ui:n,indentation:"30px",fix_table_elements:n,inline_styles:n,convert_fonts_to_spans:n,indent:"simple",indent_before:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,ul,li,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist",indent_after:"p,h1,h2,h3,h4,h5,h6,blockquote,div,title,style,pre,script,td,ul,li,area,table,thead,tfoot,tbody,tr,section,article,hgroup,aside,figure,option,optgroup,datalist",validate:n,entity_encoding:"named",url_converter:m.convertURL,url_converter_scope:m,ie7_compat:n},o);m.id=m.editorId=p;m.isNotDirty=false;m.plugins={};m.documentBaseURI=new k.util.URI(o.document_base_url||k.documentBaseURL,{base_uri:tinyMCE.baseURI});m.baseURI=k.baseURI;m.contentCSS=[];m.contentStyles=[];m.setupEvents();m.execCommands={};m.queryStateCommands={};m.queryValueCommands={};m.execCallback("setup",m)},render:function(o){var p=this,q=p.settings,r=p.id,m=k.ScriptLoader;if(!j.domLoaded){j.add(window,"ready",function(){p.render()});return}tinyMCE.settings=q;if(!p.getElement()){return}if(k.isIDevice&&!k.isIOS5){return}if(!/TEXTAREA|INPUT/i.test(p.getElement().nodeName)&&q.hidden_input&&l.getParent(r,"form")){l.insertAfter(l.create("input",{type:"hidden",name:r}),r)}if(!q.content_editable){p.orgVisibility=p.getElement().style.visibility;p.getElement().style.visibility="hidden"}if(k.WindowManager){p.windowManager=new k.WindowManager(p)}if(q.encoding=="xml"){p.onGetContent.add(function(s,t){if(t.save){t.content=l.encode(t.content)}})}if(q.add_form_submit_trigger){p.onSubmit.addToTop(function(){if(p.initialized){p.save();p.isNotDirty=1}})}if(q.add_unload_trigger){p._beforeUnload=tinyMCE.onBeforeUnload.add(function(){if(p.initialized&&!p.destroyed&&!p.isHidden()){p.save({format:"raw",no_events:true})}})}k.addUnload(p.destroy,p);if(q.submit_patch){p.onBeforeRenderUI.add(function(){var s=p.getElement().form;if(!s){return}if(s._mceOldSubmit){return}if(!s.submit.nodeType&&!s.submit.length){p.formElement=s;s._mceOldSubmit=s.submit;s.submit=function(){k.triggerSave();p.isNotDirty=1;return p.formElement._mceOldSubmit(p.formElement)}}s=null})}function n(){if(q.language&&q.language_load!==false){m.add(k.baseURL+"/langs/"+q.language+".js")}if(q.theme&&typeof q.theme!="function"&&q.theme.charAt(0)!="-"&&!h.urls[q.theme]){h.load(q.theme,"themes/"+q.theme+"/editor_template"+k.suffix+".js")}i(g(q.plugins),function(t){if(t&&!c.urls[t]){if(t.charAt(0)=="-"){t=t.substr(1,t.length);var s=c.dependencies(t);i(s,function(v){var u={prefix:"plugins/",resource:v,suffix:"/editor_plugin"+k.suffix+".js"};v=c.createUrl(u,v);c.load(v.resource,v)})}else{if(t=="safari"){return}c.load(t,{prefix:"plugins/",resource:t,suffix:"/editor_plugin"+k.suffix+".js"})}}});m.loadQueue(function(){if(!p.removed){p.init()}})}n()},init:function(){var q,G=this,H=G.settings,D,y,z,C=G.getElement(),p,m,E,v,B,F,x,r=[];k.add(G);H.aria_label=H.aria_label||l.getAttrib(C,"aria-label",G.getLang("aria.rich_text_area"));if(H.theme){if(typeof H.theme!="function"){H.theme=H.theme.replace(/-/,"");p=h.get(H.theme);G.theme=new p();if(G.theme.init){G.theme.init(G,h.urls[H.theme]||k.documentBaseURL.replace(/\/$/,""))}}else{G.theme=H.theme}}function A(s){var t=c.get(s),o=c.urls[s]||k.documentBaseURL.replace(/\/$/,""),n;if(t&&k.inArray(r,s)===-1){i(c.dependencies(s),function(u){A(u)});n=new t(G,o);G.plugins[s]=n;if(n.init){n.init(G,o);r.push(s)}}}i(g(H.plugins.replace(/\-/g,"")),A);if(H.popup_css!==false){if(H.popup_css){H.popup_css=G.documentBaseURI.toAbsolute(H.popup_css)}else{H.popup_css=G.baseURI.toAbsolute("themes/"+H.theme+"/skins/"+H.skin+"/dialog.css")}}if(H.popup_css_add){H.popup_css+=","+G.documentBaseURI.toAbsolute(H.popup_css_add)}G.controlManager=new k.ControlManager(G);G.onBeforeRenderUI.dispatch(G,G.controlManager);if(H.render_ui&&G.theme){G.orgDisplay=C.style.display;if(typeof H.theme!="function"){D=H.width||C.style.width||C.offsetWidth;y=H.height||C.style.height||C.offsetHeight;z=H.min_height||100;F=/^[0-9\.]+(|px)$/i;if(F.test(""+D)){D=Math.max(parseInt(D,10)+(p.deltaWidth||0),100)}if(F.test(""+y)){y=Math.max(parseInt(y,10)+(p.deltaHeight||0),z)}p=G.theme.renderUI({targetNode:C,width:D,height:y,deltaWidth:H.delta_width,deltaHeight:H.delta_height});l.setStyles(p.sizeContainer||p.editorContainer,{width:D,height:y});y=(p.iframeHeight||y)+(typeof(y)=="number"?(p.deltaHeight||0):"");if(y<z){y=z}}else{p=H.theme(G,C);if(p.editorContainer.nodeType){p.editorContainer=p.editorContainer.id=p.editorContainer.id||G.id+"_parent"}if(p.iframeContainer.nodeType){p.iframeContainer=p.iframeContainer.id=p.iframeContainer.id||G.id+"_iframecontainer"}y=p.iframeHeight||C.offsetHeight;if(b){G.onInit.add(function(n){n.dom.bind(n.getBody(),"beforedeactivate keydown",function(){n.lastIERng=n.selection.getRng()})})}}G.editorContainer=p.editorContainer}if(H.content_css){i(g(H.content_css),function(n){G.contentCSS.push(G.documentBaseURI.toAbsolute(n))})}if(H.content_style){G.contentStyles.push(H.content_style)}if(H.content_editable){C=q=p=null;return G.initContentBody()}if(document.domain&&location.hostname!=document.domain){k.relaxedDomain=document.domain}G.iframeHTML=H.doctype+'<html><head xmlns="http://www.w3.org/1999/xhtml">';if(H.document_base_url!=k.documentBaseURL){G.iframeHTML+='<base href="'+G.documentBaseURI.getURI()+'" />'}if(H.ie7_compat){G.iframeHTML+='<meta http-equiv="X-UA-Compatible" content="IE=7" />'}else{G.iframeHTML+='<meta http-equiv="X-UA-Compatible" content="IE=edge" />'}G.iframeHTML+='<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';for(x=0;x<G.contentCSS.length;x++){G.iframeHTML+='<link type="text/css" rel="stylesheet" href="'+G.contentCSS[x]+'" />'}G.contentCSS=[];v=H.body_id||"tinymce";if(v.indexOf("=")!=-1){v=G.getParam("body_id","","hash");v=v[G.id]||v}B=H.body_class||"";if(B.indexOf("=")!=-1){B=G.getParam("body_class","","hash");B=B[G.id]||""}G.iframeHTML+='</head><body id="'+v+'" class="mceContentBody '+B+'" onload="window.parent.tinyMCE.get(\''+G.id+"').onLoad.dispatch();\"><br></body></html>";if(k.relaxedDomain&&(b||(k.isOpera&&parseFloat(opera.version())<11))){E='javascript:(function(){document.open();document.domain="'+document.domain+'";var ed = window.parent.tinyMCE.get("'+G.id+'");document.write(ed.iframeHTML);document.close();ed.initContentBody();})()'}q=l.add(p.iframeContainer,"iframe",{id:G.id+"_ifr",src:E||'javascript:""',frameBorder:"0",allowTransparency:"true",title:H.aria_label,style:{width:"100%",height:y,display:"block"}});G.contentAreaContainer=p.iframeContainer;if(p.editorContainer){l.get(p.editorContainer).style.display=G.orgDisplay}C.style.visibility=G.orgVisibility;l.get(G.id).style.display="none";l.setAttrib(G.id,"aria-hidden",true);if(!k.relaxedDomain||!E){G.initContentBody()}C=q=p=null},initContentBody:function(){var n=this,p=n.settings,q=l.get(n.id),r=n.getDoc(),o,m,s;if((!b||!k.relaxedDomain)&&!p.content_editable){r.open();r.write(n.iframeHTML);r.close();if(k.relaxedDomain){r.domain=k.relaxedDomain}}if(p.content_editable){l.addClass(q,"mceContentBody");n.contentDocument=r=p.content_document||document;n.contentWindow=p.content_window||window;n.bodyElement=q;p.content_document=p.content_window=null}m=n.getBody();m.disabled=true;if(!p.readonly){m.contentEditable=n.getParam("content_editable_state",true)}m.disabled=false;n.schema=new k.html.Schema(p);n.dom=new k.dom.DOMUtils(r,{keep_values:true,url_converter:n.convertURL,url_converter_scope:n,hex_colors:p.force_hex_style_colors,class_filter:p.class_filter,update_styles:true,root_element:p.content_editable?n.id:null,schema:n.schema});n.parser=new k.html.DomParser(p,n.schema);n.parser.addAttributeFilter("src,href,style",function(t,u){var v=t.length,y,A=n.dom,z,x;while(v--){y=t[v];z=y.attr(u);x="data-mce-"+u;if(!y.attributes.map[x]){if(u==="style"){y.attr(x,A.serializeStyle(A.parseStyle(z),y.name))}else{y.attr(x,n.convertURL(z,u,y.name))}}}});n.parser.addNodeFilter("script",function(t,u){var v=t.length,x;while(v--){x=t[v];x.attr("type","mce-"+(x.attr("type")||"text/javascript"))}});n.parser.addNodeFilter("#cdata",function(t,u){var v=t.length,x;while(v--){x=t[v];x.type=8;x.name="#comment";x.value="[CDATA["+x.value+"]]"}});n.parser.addNodeFilter("p,h1,h2,h3,h4,h5,h6,div",function(u,v){var x=u.length,y,t=n.schema.getNonEmptyElements();while(x--){y=u[x];if(y.isEmpty(t)){y.empty().append(new k.html.Node("br",1)).shortEnded=true}}});n.serializer=new k.dom.Serializer(p,n.dom,n.schema);n.selection=new k.dom.Selection(n.dom,n.getWin(),n.serializer,n);n.formatter=new k.Formatter(n);n.undoManager=new k.UndoManager(n);n.forceBlocks=new k.ForceBlocks(n);n.enterKey=new k.EnterKey(n);n.editorCommands=new k.EditorCommands(n);n.onExecCommand.add(function(t,u){if(!/^(FontName|FontSize)$/.test(u)){n.nodeChanged()}});n.serializer.onPreProcess.add(function(t,u){return n.onPreProcess.dispatch(n,u,t)});n.serializer.onPostProcess.add(function(t,u){return n.onPostProcess.dispatch(n,u,t)});n.onPreInit.dispatch(n);if(!p.browser_spellcheck&&!p.gecko_spellcheck){r.body.spellcheck=false}if(!p.readonly){n.bindNativeEvents()}n.controlManager.onPostRender.dispatch(n,n.controlManager);n.onPostRender.dispatch(n);n.quirks=k.util.Quirks(n);if(p.directionality){m.dir=p.directionality}if(p.nowrap){m.style.whiteSpace="nowrap"}if(p.protect){n.onBeforeSetContent.add(function(t,u){i(p.protect,function(v){u.content=u.content.replace(v,function(x){return"<!--mce:protected "+escape(x)+"-->"})})})}n.onSetContent.add(function(){n.addVisual(n.getBody())});if(p.padd_empty_editor){n.onPostProcess.add(function(t,u){u.content=u.content.replace(/^(<p[^>]*>(&nbsp;|&#160;|\s|\u00a0|)<\/p>[\r\n]*|<br \/>[\r\n]*)$/,"")})}n.load({initial:true,format:"html"});n.startContent=n.getContent({format:"raw"});n.initialized=true;n.onInit.dispatch(n);n.execCallback("setupcontent_callback",n.id,m,r);n.execCallback("init_instance_callback",n);n.focus(true);n.nodeChanged({initial:true});if(n.contentStyles.length>0){s="";i(n.contentStyles,function(t){s+=t+"\r\n"});n.dom.addStyle(s)}i(n.contentCSS,function(t){n.dom.loadCSS(t)});if(p.auto_focus){setTimeout(function(){var t=k.get(p.auto_focus);t.selection.select(t.getBody(),1);t.selection.collapse(1);t.getBody().focus();t.getWin().focus()},100)}q=r=m=null},focus:function(p){var o,u=this,t=u.selection,q=u.settings.content_editable,n,r,s=u.getDoc(),m;if(!p){if(u.lastIERng){t.setRng(u.lastIERng)}n=t.getRng();if(n.item){r=n.item(0)}u._refreshContentEditable();if(!q){u.getWin().focus()}if(k.isGecko||q){m=u.getBody();if(m.setActive){m.setActive()}else{m.focus()}if(q){t.normalize()}}if(r&&r.ownerDocument==s){n=s.body.createControlRange();n.addElement(r);n.select()}}if(k.activeEditor!=u){if((o=k.activeEditor)!=null){o.onDeactivate.dispatch(o,u)}u.onActivate.dispatch(u,o)}k._setActive(u)},execCallback:function(q){var m=this,p=m.settings[q],o;if(!p){return}if(m.callbackLookup&&(o=m.callbackLookup[q])){p=o.func;o=o.scope}if(d(p,"string")){o=p.replace(/\.\w+$/,"");o=o?k.resolve(o):0;p=k.resolve(p);m.callbackLookup=m.callbackLookup||{};m.callbackLookup[q]={func:p,scope:o}}return p.apply(o||m,Array.prototype.slice.call(arguments,1))},translate:function(m){var o=this.settings.language||"en",n=k.i18n;if(!m){return""}return n[o+"."+m]||m.replace(/\{\#([^\}]+)\}/g,function(q,p){return n[o+"."+p]||"{#"+p+"}"})},getLang:function(o,m){return k.i18n[(this.settings.language||"en")+"."+o]||(d(m)?m:"{#"+o+"}")},getParam:function(t,q,m){var r=k.trim,p=d(this.settings[t])?this.settings[t]:q,s;if(m==="hash"){s={};if(d(p,"string")){i(p.indexOf("=")>0?p.split(/[;,](?![^=;,]*(?:[;,]|$))/):p.split(","),function(n){n=n.split("=");if(n.length>1){s[r(n[0])]=r(n[1])}else{s[r(n[0])]=r(n)}})}else{s=p}return s}return p},nodeChanged:function(q){var m=this,n=m.selection,p;if(m.initialized){q=q||{};p=n.getStart()||m.getBody();p=b&&p.ownerDocument!=m.getDoc()?m.getBody():p;q.parents=[];m.dom.getParent(p,function(o){if(o.nodeName=="BODY"){return true}q.parents.push(o)});m.onNodeChange.dispatch(m,q?q.controlManager||m.controlManager:m.controlManager,p,n.isCollapsed(),q)}},addButton:function(n,o){var m=this;m.buttons=m.buttons||{};m.buttons[n]=o},addCommand:function(m,o,n){this.execCommands[m]={func:o,scope:n||this}},addQueryStateHandler:function(m,o,n){this.queryStateCommands[m]={func:o,scope:n||this}},addQueryValueHandler:function(m,o,n){this.queryValueCommands[m]={func:o,scope:n||this}},addShortcut:function(o,q,m,p){var n=this,r;if(n.settings.custom_shortcuts===false){return false}n.shortcuts=n.shortcuts||{};if(d(m,"string")){r=m;m=function(){n.execCommand(r,false,null)}}if(d(m,"object")){r=m;m=function(){n.execCommand(r[0],r[1],r[2])}}i(g(o),function(s){var t={func:m,scope:p||this,desc:n.translate(q),alt:false,ctrl:false,shift:false};i(g(s,"+"),function(u){switch(u){case"alt":case"ctrl":case"shift":t[u]=true;break;default:t.charCode=u.charCodeAt(0);t.keyCode=u.toUpperCase().charCodeAt(0)}});n.shortcuts[(t.ctrl?"ctrl":"")+","+(t.alt?"alt":"")+","+(t.shift?"shift":"")+","+t.keyCode]=t});return true},execCommand:function(u,r,x,m){var p=this,q=0,v,n;if(!/^(mceAddUndoLevel|mceEndUndoLevel|mceBeginUndoLevel|mceRepaint|SelectAll)$/.test(u)&&(!m||!m.skip_focus)){p.focus()}m=f({},m);p.onBeforeExecCommand.dispatch(p,u,r,x,m);if(m.terminate){return false}if(p.execCallback("execcommand_callback",p.id,p.selection.getNode(),u,r,x)){p.onExecCommand.dispatch(p,u,r,x,m);return true}if(v=p.execCommands[u]){n=v.func.call(v.scope,r,x);if(n!==true){p.onExecCommand.dispatch(p,u,r,x,m);return n}}i(p.plugins,function(o){if(o.execCommand&&o.execCommand(u,r,x)){p.onExecCommand.dispatch(p,u,r,x,m);q=1;return false}});if(q){return true}if(p.theme&&p.theme.execCommand&&p.theme.execCommand(u,r,x)){p.onExecCommand.dispatch(p,u,r,x,m);return true}if(p.editorCommands.execCommand(u,r,x)){p.onExecCommand.dispatch(p,u,r,x,m);return true}p.getDoc().execCommand(u,r,x);p.onExecCommand.dispatch(p,u,r,x,m)},queryCommandState:function(q){var n=this,r,p;if(n._isHidden()){return}if(r=n.queryStateCommands[q]){p=r.func.call(r.scope);if(p!==true){return p}}r=n.editorCommands.queryCommandState(q);if(r!==-1){return r}try{return this.getDoc().queryCommandState(q)}catch(m){}},queryCommandValue:function(r){var n=this,q,p;if(n._isHidden()){return}if(q=n.queryValueCommands[r]){p=q.func.call(q.scope);if(p!==true){return p}}q=n.editorCommands.queryCommandValue(r);if(d(q)){return q}try{return this.getDoc().queryCommandValue(r)}catch(m){}},show:function(){var m=this;l.show(m.getContainer());l.hide(m.id);m.load()},hide:function(){var m=this,n=m.getDoc();if(b&&n){n.execCommand("SelectAll")}m.save();l.hide(m.getContainer());l.setStyle(m.id,"display",m.orgDisplay)},isHidden:function(){return !l.isHidden(this.id)},setProgressState:function(m,n,p){this.onSetProgressState.dispatch(this,m,n,p);return m},load:function(q){var m=this,p=m.getElement(),n;if(p){q=q||{};q.load=true;n=m.setContent(d(p.value)?p.value:p.innerHTML,q);q.element=p;if(!q.no_events){m.onLoadContent.dispatch(m,q)}q.element=p=null;return n}},save:function(r){var m=this,q=m.getElement(),n,p;if(!q||!m.initialized){return}r=r||{};r.save=true;r.element=q;n=r.content=m.getContent(r);if(!r.no_events){m.onSaveContent.dispatch(m,r)}n=r.content;if(!/TEXTAREA|INPUT/i.test(q.nodeName)){q.innerHTML=n;if(p=l.getParent(m.id,"form")){i(p.elements,function(o){if(o.name==m.id){o.value=n;return false}})}}else{q.value=n}r.element=q=null;return n},setContent:function(r,p){var o=this,n,m=o.getBody(),q;p=p||{};p.format=p.format||"html";p.set=true;p.content=r;if(!p.no_events){o.onBeforeSetContent.dispatch(o,p)}r=p.content;if(!k.isIE&&(r.length===0||/^\s+$/.test(r))){q=o.settings.forced_root_block;if(q){r="<"+q+'><br data-mce-bogus="1"></'+q+">"}else{r='<br data-mce-bogus="1">'}m.innerHTML=r;o.selection.select(m,true);o.selection.collapse(true);return}if(p.format!=="raw"){r=new k.html.Serializer({},o.schema).serialize(o.parser.parse(r))}p.content=k.trim(r);o.dom.setHTML(m,p.content);if(!p.no_events){o.onSetContent.dispatch(o,p)}if(!o.settings.content_editable||document.activeElement===o.getBody()){o.selection.normalize()}return p.content},getContent:function(n){var m=this,o;n=n||{};n.format=n.format||"html";n.get=true;n.getInner=true;if(!n.no_events){m.onBeforeGetContent.dispatch(m,n)}if(n.format=="raw"){o=m.getBody().innerHTML}else{o=m.serializer.serialize(m.getBody(),n)}n.content=k.trim(o);if(!n.no_events){m.onGetContent.dispatch(m,n)}return n.content},isDirty:function(){var m=this;return k.trim(m.startContent)!=k.trim(m.getContent({format:"raw",no_events:1}))&&!m.isNotDirty},getContainer:function(){var m=this;if(!m.container){m.container=l.get(m.editorContainer||m.id+"_parent")}return m.container},getContentAreaContainer:function(){return this.contentAreaContainer},getElement:function(){return l.get(this.settings.content_element||this.id)},getWin:function(){var m=this,n;if(!m.contentWindow){n=l.get(m.id+"_ifr");if(n){m.contentWindow=n.contentWindow}}return m.contentWindow},getDoc:function(){var m=this,n;if(!m.contentDocument){n=m.getWin();if(n){m.contentDocument=n.document}}return m.contentDocument},getBody:function(){return this.bodyElement||this.getDoc().body},convertURL:function(o,n,q){var m=this,p=m.settings;if(p.urlconverter_callback){return m.execCallback("urlconverter_callback",o,q,true,n)}if(!p.convert_urls||(q&&q.nodeName=="LINK")||o.indexOf("file:")===0){return o}if(p.relative_urls){return m.documentBaseURI.toRelative(o)}o=m.documentBaseURI.toAbsolute(o,p.remove_script_host);return o},addVisual:function(q){var n=this,o=n.settings,p=n.dom,m;q=q||n.getBody();if(!d(n.hasVisual)){n.hasVisual=o.visual}i(p.select("table,a",q),function(s){var r;switch(s.nodeName){case"TABLE":m=o.visual_table_class||"mceItemTable";r=p.getAttrib(s,"border");if(!r||r=="0"){if(n.hasVisual){p.addClass(s,m)}else{p.removeClass(s,m)}}return;case"A":if(!p.getAttrib(s,"href",false)){r=p.getAttrib(s,"name")||s.id;m="mceItemAnchor";if(r){if(n.hasVisual){p.addClass(s,m)}else{p.removeClass(s,m)}}}return}});n.onVisualAid.dispatch(n,q,n.hasVisual)},remove:function(){var m=this,n=m.getContainer();if(!m.removed){m.removed=1;m.hide();if(!m.settings.content_editable){j.unbind(m.getWin());j.unbind(m.getDoc())}j.unbind(m.getBody());j.clear(n);m.execCallback("remove_instance_callback",m);m.onRemove.dispatch(m);m.onExecCommand.listeners=[];k.remove(m);l.remove(n)}},destroy:function(n){var m=this;if(m.destroyed){return}if(a){j.unbind(m.getDoc());j.unbind(m.getWin());j.unbind(m.getBody())}if(!n){k.removeUnload(m.destroy);tinyMCE.onBeforeUnload.remove(m._beforeUnload);if(m.theme&&m.theme.destroy){m.theme.destroy()}m.controlManager.destroy();m.selection.destroy();m.dom.destroy()}if(m.formElement){m.formElement.submit=m.formElement._mceOldSubmit;m.formElement._mceOldSubmit=null}m.contentAreaContainer=m.formElement=m.container=m.settings.content_element=m.bodyElement=m.contentDocument=m.contentWindow=null;if(m.selection){m.selection=m.selection.win=m.selection.dom=m.selection.dom.doc=null}m.destroyed=1},_refreshContentEditable:function(){var n=this,m,o;if(n._isHidden()){m=n.getBody();o=m.parentNode;o.removeChild(m);o.appendChild(m);m.focus()}},_isHidden:function(){var m;if(!a){return 0}m=this.selection.getSel();return(!m||!m.rangeCount||m.rangeCount===0)}})})(tinymce);(function(a){var b=a.each;a.Editor.prototype.setupEvents=function(){var c=this,d=c.settings;b(["onPreInit","onBeforeRenderUI","onPostRender","onLoad","onInit","onRemove","onActivate","onDeactivate","onClick","onEvent","onMouseUp","onMouseDown","onDblClick","onKeyDown","onKeyUp","onKeyPress","onContextMenu","onSubmit","onReset","onPaste","onPreProcess","onPostProcess","onBeforeSetContent","onBeforeGetContent","onSetContent","onGetContent","onLoadContent","onSaveContent","onNodeChange","onChange","onBeforeExecCommand","onExecCommand","onUndo","onRedo","onVisualAid","onSetProgressState","onSetAttrib"],function(e){c[e]=new a.util.Dispatcher(c)});if(d.cleanup_callback){c.onBeforeSetContent.add(function(e,f){f.content=e.execCallback("cleanup_callback","insert_to_editor",f.content,f)});c.onPreProcess.add(function(e,f){if(f.set){e.execCallback("cleanup_callback","insert_to_editor_dom",f.node,f)}if(f.get){e.execCallback("cleanup_callback","get_from_editor_dom",f.node,f)}});c.onPostProcess.add(function(e,f){if(f.set){f.content=e.execCallback("cleanup_callback","insert_to_editor",f.content,f)}if(f.get){f.content=e.execCallback("cleanup_callback","get_from_editor",f.content,f)}})}if(d.save_callback){c.onGetContent.add(function(e,f){if(f.save){f.content=e.execCallback("save_callback",e.id,f.content,e.getBody())}})}if(d.handle_event_callback){c.onEvent.add(function(f,g,h){if(c.execCallback("handle_event_callback",g,f,h)===false){g.preventDefault();g.stopPropagation()}})}if(d.handle_node_change_callback){c.onNodeChange.add(function(f,e,g){f.execCallback("handle_node_change_callback",f.id,g,-1,-1,true,f.selection.isCollapsed())})}if(d.save_callback){c.onSaveContent.add(function(e,g){var f=e.execCallback("save_callback",e.id,g.content,e.getBody());if(f){g.content=f}})}if(d.onchange_callback){c.onChange.add(function(f,e){f.execCallback("onchange_callback",f,e)})}};a.Editor.prototype.bindNativeEvents=function(){var l=this,f,d=l.settings,e=l.dom,h;h={mouseup:"onMouseUp",mousedown:"onMouseDown",click:"onClick",keyup:"onKeyUp",keydown:"onKeyDown",keypress:"onKeyPress",submit:"onSubmit",reset:"onReset",contextmenu:"onContextMenu",dblclick:"onDblClick",paste:"onPaste"};function c(i,m){var n=i.type;if(l.removed){return}if(l.onEvent.dispatch(l,i,m)!==false){l[h[i.fakeType||i.type]].dispatch(l,i,m)}}function j(i){l.focus(true)}function k(i,m){if(m.keyCode!=65||!a.VK.metaKeyPressed(m)){l.selection.normalize()}l.nodeChanged()}b(h,function(m,n){var i=d.content_editable?l.getBody():l.getDoc();switch(n){case"contextmenu":e.bind(i,n,c);break;case"paste":e.bind(l.getBody(),n,c);break;case"submit":case"reset":e.bind(l.getElement().form||a.DOM.getParent(l.id,"form"),n,c);break;default:e.bind(i,n,c)}});e.bind(d.content_editable?l.getBody():(a.isGecko?l.getDoc():l.getWin()),"focus",function(i){l.focus(true)});if(d.content_editable&&a.isOpera){e.bind(l.getBody(),"click",j);e.bind(l.getBody(),"keydown",j)}l.onMouseUp.add(k);l.onKeyUp.add(function(i,n){var m=n.keyCode;if((m>=33&&m<=36)||(m>=37&&m<=40)||m==13||m==45||m==46||m==8||(a.isMac&&(m==91||m==93))||n.ctrlKey){k(i,n)}});l.onReset.add(function(){l.setContent(l.startContent,{format:"raw"})});function g(m,i){if(m.altKey||m.ctrlKey||m.metaKey){b(l.shortcuts,function(n){var o=a.isMac?m.metaKey:m.ctrlKey;if(n.ctrl!=o||n.alt!=m.altKey||n.shift!=m.shiftKey){return}if(m.keyCode==n.keyCode||(m.charCode&&m.charCode==n.charCode)){m.preventDefault();if(i){n.func.call(n.scope)}return true}})}}l.onKeyUp.add(function(i,m){g(m)});l.onKeyPress.add(function(i,m){g(m)});l.onKeyDown.add(function(i,m){g(m,true)});if(a.isOpera){l.onClick.add(function(i,m){m.preventDefault()})}}})(tinymce);(function(d){var e=d.each,b,a=true,c=false;d.EditorCommands=function(n){var m=n.dom,p=n.selection,j={state:{},exec:{},value:{}},k=n.settings,q=n.formatter,o;function r(z,y,x){var v;z=z.toLowerCase();if(v=j.exec[z]){v(z,y,x);return a}return c}function l(x){var v;x=x.toLowerCase();if(v=j.state[x]){return v(x)}return -1}function h(x){var v;x=x.toLowerCase();if(v=j.value[x]){return v(x)}return c}function u(v,x){x=x||"exec";e(v,function(z,y){e(y.toLowerCase().split(","),function(A){j[x][A]=z})})}d.extend(this,{execCommand:r,queryCommandState:l,queryCommandValue:h,addCommands:u});function f(y,x,v){if(x===b){x=c}if(v===b){v=null}return n.getDoc().execCommand(y,x,v)}function t(v){return q.match(v)}function s(v,x){q.toggle(v,x?{value:x}:b)}function i(v){o=p.getBookmark(v)}function g(){p.moveToBookmark(o)}u({"mceResetDesignMode,mceBeginUndoLevel":function(){},"mceEndUndoLevel,mceAddUndoLevel":function(){n.undoManager.add()},"Cut,Copy,Paste":function(z){var y=n.getDoc(),v;try{f(z)}catch(x){v=a}if(v||!y.queryCommandSupported(z)){if(d.isGecko){n.windowManager.confirm(n.getLang("clipboard_msg"),function(A){if(A){open("http://www.mozilla.org/editor/midasdemo/securityprefs.html","_blank")}})}else{n.windowManager.alert(n.getLang("clipboard_no_support"))}}},unlink:function(v){if(p.isCollapsed()){p.select(p.getNode())}f(v);p.collapse(c)},"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(v){var x=v.substring(7);e("left,center,right,full".split(","),function(y){if(x!=y){q.remove("align"+y)}});s("align"+x);r("mceRepaint")},"InsertUnorderedList,InsertOrderedList":function(y){var v,x;f(y);v=m.getParent(p.getNode(),"ol,ul");if(v){x=v.parentNode;if(/^(H[1-6]|P|ADDRESS|PRE)$/.test(x.nodeName)){i();m.split(x,v);g()}}},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(v){s(v)},"ForeColor,HiliteColor,FontName":function(y,x,v){s(y,v)},FontSize:function(z,y,x){var v,A;if(x>=1&&x<=7){A=d.explode(k.font_size_style_values);v=d.explode(k.font_size_classes);if(v){x=v[x-1]||x}else{x=A[x-1]||x}}s(z,x)},RemoveFormat:function(v){q.remove(v)},mceBlockQuote:function(v){s("blockquote")},FormatBlock:function(y,x,v){return s(v||"p")},mceCleanup:function(){var v=p.getBookmark();n.setContent(n.getContent({cleanup:a}),{cleanup:a});p.moveToBookmark(v)},mceRemoveNode:function(z,y,x){var v=x||p.getNode();if(v!=n.getBody()){i();n.dom.remove(v,a);g()}},mceSelectNodeDepth:function(z,y,x){var v=0;m.getParent(p.getNode(),function(A){if(A.nodeType==1&&v++==x){p.select(A);return c}},n.getBody())},mceSelectNode:function(y,x,v){p.select(v)},mceInsertContent:function(B,I,K){var y,J,E,z,F,G,D,C,L,x,A,M,v,H;y=n.parser;J=new d.html.Serializer({},n.schema);v='<span id="mce_marker" data-mce-type="bookmark">\uFEFF</span>';G={content:K,format:"html"};p.onBeforeSetContent.dispatch(p,G);K=G.content;if(K.indexOf("{$caret}")==-1){K+="{$caret}"}K=K.replace(/\{\$caret\}/,v);if(!p.isCollapsed()){n.getDoc().execCommand("Delete",false,null)}E=p.getNode();G={context:E.nodeName.toLowerCase()};F=y.parse(K,G);A=F.lastChild;if(A.attr("id")=="mce_marker"){D=A;for(A=A.prev;A;A=A.walk(true)){if(A.type==3||!m.isBlock(A.name)){A.parent.insert(D,A,A.name==="br");break}}}if(!G.invalid){K=J.serialize(F);A=E.firstChild;M=E.lastChild;if(!A||(A===M&&A.nodeName==="BR")){m.setHTML(E,K)}else{p.setContent(K)}}else{p.setContent(v);E=p.getNode();z=n.getBody();if(E.nodeType==9){E=A=z}else{A=E}while(A!==z){E=A;A=A.parentNode}K=E==z?z.innerHTML:m.getOuterHTML(E);K=J.serialize(y.parse(K.replace(/<span (id="mce_marker"|id=mce_marker).+?<\/span>/i,function(){return J.serialize(F)})));if(E==z){m.setHTML(z,K)}else{m.setOuterHTML(E,K)}}D=m.get("mce_marker");C=m.getRect(D);L=m.getViewPort(n.getWin());if((C.y+C.h>L.y+L.h||C.y<L.y)||(C.x>L.x+L.w||C.x<L.x)){H=d.isIE?n.getDoc().documentElement:n.getBody();H.scrollLeft=C.x;H.scrollTop=C.y-L.h+25}x=m.createRng();A=D.previousSibling;if(A&&A.nodeType==3){x.setStart(A,A.nodeValue.length)}else{x.setStartBefore(D);x.setEndBefore(D)}m.remove(D);p.setRng(x);p.onSetContent.dispatch(p,G);n.addVisual()},mceInsertRawHTML:function(y,x,v){p.setContent("tiny_mce_marker");n.setContent(n.getContent().replace(/tiny_mce_marker/g,function(){return v}))},mceToggleFormat:function(y,x,v){s(v)},mceSetContent:function(y,x,v){n.setContent(v)},"Indent,Outdent":function(z){var x,v,y;x=k.indentation;v=/[a-z%]+$/i.exec(x);x=parseInt(x);if(!l("InsertUnorderedList")&&!l("InsertOrderedList")){if(!k.forced_root_block&&!m.getParent(p.getNode(),m.isBlock)){q.apply("div")}e(p.getSelectedBlocks(),function(A){if(z=="outdent"){y=Math.max(0,parseInt(A.style.paddingLeft||0)-x);m.setStyle(A,"paddingLeft",y?y+v:"")}else{m.setStyle(A,"paddingLeft",(parseInt(A.style.paddingLeft||0)+x)+v)}})}else{f(z)}},mceRepaint:function(){var x;if(d.isGecko){try{i(a);if(p.getSel()){p.getSel().selectAllChildren(n.getBody())}p.collapse(a);g()}catch(v){}}},mceToggleFormat:function(y,x,v){q.toggle(v)},InsertHorizontalRule:function(){n.execCommand("mceInsertContent",false,"<hr />")},mceToggleVisualAid:function(){n.hasVisual=!n.hasVisual;n.addVisual()},mceReplaceContent:function(y,x,v){n.execCommand("mceInsertContent",false,v.replace(/\{\$selection\}/g,p.getContent({format:"text"})))},mceInsertLink:function(z,y,x){var v;if(typeof(x)=="string"){x={href:x}}v=m.getParent(p.getNode(),"a");x.href=x.href.replace(" ","%20");if(!v||!x.href){q.remove("link")}if(x.href){q.apply("link",x,v)}},selectAll:function(){var x=m.getRoot(),v=m.createRng();if(p.getRng().setStart){v.setStart(x,0);v.setEnd(x,x.childNodes.length);p.setRng(v)}else{f("SelectAll")}}});u({"JustifyLeft,JustifyCenter,JustifyRight,JustifyFull":function(z){var x="align"+z.substring(7);var v=p.isCollapsed()?[m.getParent(p.getNode(),m.isBlock)]:p.getSelectedBlocks();var y=d.map(v,function(A){return !!q.matchNode(A,x)});return d.inArray(y,a)!==-1},"Bold,Italic,Underline,Strikethrough,Superscript,Subscript":function(v){return t(v)},mceBlockQuote:function(){return t("blockquote")},Outdent:function(){var v;if(k.inline_styles){if((v=m.getParent(p.getStart(),m.isBlock))&&parseInt(v.style.paddingLeft)>0){return a}if((v=m.getParent(p.getEnd(),m.isBlock))&&parseInt(v.style.paddingLeft)>0){return a}}return l("InsertUnorderedList")||l("InsertOrderedList")||(!k.inline_styles&&!!m.getParent(p.getNode(),"BLOCKQUOTE"))},"InsertUnorderedList,InsertOrderedList":function(x){var v=m.getParent(p.getNode(),"ul,ol");return v&&(x==="insertunorderedlist"&&v.tagName==="UL"||x==="insertorderedlist"&&v.tagName==="OL")}},"state");u({"FontSize,FontName":function(y){var x=0,v;if(v=m.getParent(p.getNode(),"span")){if(y=="fontsize"){x=v.style.fontSize}else{x=v.style.fontFamily.replace(/, /g,",").replace(/[\'\"]/g,"").toLowerCase()}}return x}},"value");u({Undo:function(){n.undoManager.undo()},Redo:function(){n.undoManager.redo()}})}})(tinymce);(function(b){var a=b.util.Dispatcher;b.UndoManager=function(h){var l,i=0,e=[],g,k,j,f;function c(){return b.trim(h.getContent({format:"raw",no_events:1}).replace(/<span[^>]+data-mce-bogus[^>]+>[\u200B\uFEFF]+<\/span>/g,""))}function d(){l.typing=false;l.add()}onBeforeAdd=new a(l);k=new a(l);j=new a(l);f=new a(l);k.add(function(m,n){if(m.hasUndo()){return h.onChange.dispatch(h,n,m)}});j.add(function(m,n){return h.onUndo.dispatch(h,n,m)});f.add(function(m,n){return h.onRedo.dispatch(h,n,m)});h.onInit.add(function(){l.add()});h.onBeforeExecCommand.add(function(m,p,o,q,n){if(p!="Undo"&&p!="Redo"&&p!="mceRepaint"&&(!n||!n.skip_undo)){l.beforeChange()}});h.onExecCommand.add(function(m,p,o,q,n){if(p!="Undo"&&p!="Redo"&&p!="mceRepaint"&&(!n||!n.skip_undo)){l.add()}});h.onSaveContent.add(d);h.dom.bind(h.dom.getRoot(),"dragend",d);h.dom.bind(h.getDoc(),b.isGecko?"blur":"focusout",function(m){if(!h.removed&&l.typing){d()}});h.onKeyUp.add(function(m,o){var n=o.keyCode;if((n>=33&&n<=36)||(n>=37&&n<=40)||n==45||n==13||o.ctrlKey){d()}});h.onKeyDown.add(function(m,o){var n=o.keyCode;if((n>=33&&n<=36)||(n>=37&&n<=40)||n==45){if(l.typing){d()}return}if((n<16||n>20)&&n!=224&&n!=91&&!l.typing){l.beforeChange();l.typing=true;l.add()}});h.onMouseDown.add(function(m,n){if(l.typing){d()}});h.addShortcut("ctrl+z","undo_desc","Undo");h.addShortcut("ctrl+y","redo_desc","Redo");l={data:e,typing:false,onBeforeAdd:onBeforeAdd,onAdd:k,onUndo:j,onRedo:f,beforeChange:function(){g=h.selection.getBookmark(2,true)},add:function(p){var m,n=h.settings,o;p=p||{};p.content=c();l.onBeforeAdd.dispatch(l,p);o=e[i];if(o&&o.content==p.content){return null}if(e[i]){e[i].beforeBookmark=g}if(n.custom_undo_redo_levels){if(e.length>n.custom_undo_redo_levels){for(m=0;m<e.length-1;m++){e[m]=e[m+1]}e.length--;i=e.length}}p.bookmark=h.selection.getBookmark(2,true);if(i<e.length-1){e.length=i+1}e.push(p);i=e.length-1;l.onAdd.dispatch(l,p);h.isNotDirty=0;return p},undo:function(){var n,m;if(l.typing){l.add();l.typing=false}if(i>0){n=e[--i];h.setContent(n.content,{format:"raw"});h.selection.moveToBookmark(n.beforeBookmark);l.onUndo.dispatch(l,n)}return n},redo:function(){var m;if(i<e.length-1){m=e[++i];h.setContent(m.content,{format:"raw"});h.selection.moveToBookmark(m.bookmark);l.onRedo.dispatch(l,m)}return m},clear:function(){e=[];i=0;l.typing=false},hasUndo:function(){return i>0||this.typing},hasRedo:function(){return i<e.length-1&&!this.typing}};return l}})(tinymce);tinymce.ForceBlocks=function(c){var b=c.settings,e=c.dom,a=c.selection,d=c.schema.getBlockElements();function f(){var j=a.getStart(),h=c.getBody(),g,k,o,s,q,i,l,m=-16777215,p,r;if(!j||j.nodeType!==1||!b.forced_root_block){return}while(j&&j!=h){if(d[j.nodeName]){return}j=j.parentNode}g=a.getRng();if(g.setStart){k=g.startContainer;o=g.startOffset;s=g.endContainer;q=g.endOffset}else{if(g.item){j=g.item(0);g=c.getDoc().body.createTextRange();g.moveToElementText(j)}r=g.parentElement().ownerDocument===c.getDoc();tmpRng=g.duplicate();tmpRng.collapse(true);o=tmpRng.move("character",m)*-1;if(!tmpRng.collapsed){tmpRng=g.duplicate();tmpRng.collapse(false);q=(tmpRng.move("character",m)*-1)-o}}j=h.firstChild;while(j){if(j.nodeType===3||(j.nodeType==1&&!d[j.nodeName])){if(!i){i=e.create(b.forced_root_block);j.parentNode.insertBefore(i,j);p=true}l=j;j=j.nextSibling;i.appendChild(l)}else{i=null;j=j.nextSibling}}if(p){if(g.setStart){g.setStart(k,o);g.setEnd(s,q);a.setRng(g)}else{if(r){try{g=c.getDoc().body.createTextRange();g.moveToElementText(h);g.collapse(true);g.moveStart("character",o);if(q>0){g.moveEnd("character",q)}g.select()}catch(n){}}}c.nodeChanged()}}if(b.forced_root_block){c.onKeyUp.add(f);c.onNodeChange.add(f)}};(function(c){var b=c.DOM,a=c.dom.Event,d=c.each,e=c.extend;c.create("tinymce.ControlManager",{ControlManager:function(f,j){var h=this,g;j=j||{};h.editor=f;h.controls={};h.onAdd=new c.util.Dispatcher(h);h.onPostRender=new c.util.Dispatcher(h);h.prefix=j.prefix||f.id+"_";h._cls={};h.onPostRender.add(function(){d(h.controls,function(i){i.postRender()})})},get:function(f){return this.controls[this.prefix+f]||this.controls[f]},setActive:function(h,f){var g=null;if(g=this.get(h)){g.setActive(f)}return g},setDisabled:function(h,f){var g=null;if(g=this.get(h)){g.setDisabled(f)}return g},add:function(g){var f=this;if(g){f.controls[g.id]=g;f.onAdd.dispatch(g,f)}return g},createControl:function(j){var o,k,g,h=this,m=h.editor,n,f;if(!h.controlFactories){h.controlFactories=[];d(m.plugins,function(i){if(i.createControl){h.controlFactories.push(i)}})}n=h.controlFactories;for(k=0,g=n.length;k<g;k++){o=n[k].createControl(j,h);if(o){return h.add(o)}}if(j==="|"||j==="separator"){return h.createSeparator()}if(m.buttons&&(o=m.buttons[j])){return h.createButton(j,o)}return h.add(o)},createDropMenu:function(f,n,h){var m=this,i=m.editor,j,g,k,l;n=e({"class":"mceDropDown",constrain:i.settings.constrain_menus},n);n["class"]=n["class"]+" "+i.getParam("skin")+"Skin";if(k=i.getParam("skin_variant")){n["class"]+=" "+i.getParam("skin")+"Skin"+k.substring(0,1).toUpperCase()+k.substring(1)}n["class"]+=i.settings.directionality=="rtl"?" mceRtl":"";f=m.prefix+f;l=h||m._cls.dropmenu||c.ui.DropMenu;j=m.controls[f]=new l(f,n);j.onAddItem.add(function(r,q){var p=q.settings;p.title=i.getLang(p.title,p.title);if(!p.onclick){p.onclick=function(o){if(p.cmd){i.execCommand(p.cmd,p.ui||false,p.value)}}}});i.onRemove.add(function(){j.destroy()});if(c.isIE){j.onShowMenu.add(function(){i.focus();g=i.selection.getBookmark(1)});j.onHideMenu.add(function(){if(g){i.selection.moveToBookmark(g);g=0}})}return m.add(j)},createListBox:function(f,n,h){var l=this,j=l.editor,i,k,m;if(l.get(f)){return null}n.title=j.translate(n.title);n.scope=n.scope||j;if(!n.onselect){n.onselect=function(o){j.execCommand(n.cmd,n.ui||false,o||n.value)}}n=e({title:n.title,"class":"mce_"+f,scope:n.scope,control_manager:l},n);f=l.prefix+f;function g(o){return o.settings.use_accessible_selects&&!c.isGecko}if(j.settings.use_native_selects||g(j)){k=new c.ui.NativeListBox(f,n)}else{m=h||l._cls.listbox||c.ui.ListBox;k=new m(f,n,j)}l.controls[f]=k;if(c.isWebKit){k.onPostRender.add(function(p,o){a.add(o,"mousedown",function(){j.bookmark=j.selection.getBookmark(1)});a.add(o,"focus",function(){j.selection.moveToBookmark(j.bookmark);j.bookmark=null})})}if(k.hideMenu){j.onMouseDown.add(k.hideMenu,k)}return l.add(k)},createButton:function(m,i,l){var h=this,g=h.editor,j,k,f;if(h.get(m)){return null}i.title=g.translate(i.title);i.label=g.translate(i.label);i.scope=i.scope||g;if(!i.onclick&&!i.menu_button){i.onclick=function(){g.execCommand(i.cmd,i.ui||false,i.value)}}i=e({title:i.title,"class":"mce_"+m,unavailable_prefix:g.getLang("unavailable",""),scope:i.scope,control_manager:h},i);m=h.prefix+m;if(i.menu_button){f=l||h._cls.menubutton||c.ui.MenuButton;k=new f(m,i,g);g.onMouseDown.add(k.hideMenu,k)}else{f=h._cls.button||c.ui.Button;k=new f(m,i,g)}return h.add(k)},createMenuButton:function(h,f,g){f=f||{};f.menu_button=1;return this.createButton(h,f,g)},createSplitButton:function(m,i,l){var h=this,g=h.editor,j,k,f;if(h.get(m)){return null}i.title=g.translate(i.title);i.scope=i.scope||g;if(!i.onclick){i.onclick=function(n){g.execCommand(i.cmd,i.ui||false,n||i.value)}}if(!i.onselect){i.onselect=function(n){g.execCommand(i.cmd,i.ui||false,n||i.value)}}i=e({title:i.title,"class":"mce_"+m,scope:i.scope,control_manager:h},i);m=h.prefix+m;f=l||h._cls.splitbutton||c.ui.SplitButton;k=h.add(new f(m,i,g));g.onMouseDown.add(k.hideMenu,k);return k},createColorSplitButton:function(f,n,h){var l=this,j=l.editor,i,k,m,g;if(l.get(f)){return null}n.title=j.translate(n.title);n.scope=n.scope||j;if(!n.onclick){n.onclick=function(o){if(c.isIE){g=j.selection.getBookmark(1)}j.execCommand(n.cmd,n.ui||false,o||n.value)}}if(!n.onselect){n.onselect=function(o){j.execCommand(n.cmd,n.ui||false,o||n.value)}}n=e({title:n.title,"class":"mce_"+f,menu_class:j.getParam("skin")+"Skin",scope:n.scope,more_colors_title:j.getLang("more_colors")},n);f=l.prefix+f;m=h||l._cls.colorsplitbutton||c.ui.ColorSplitButton;k=new m(f,n,j);j.onMouseDown.add(k.hideMenu,k);j.onRemove.add(function(){k.destroy()});if(c.isIE){k.onShowMenu.add(function(){j.focus();g=j.selection.getBookmark(1)});k.onHideMenu.add(function(){if(g){j.selection.moveToBookmark(g);g=0}})}return l.add(k)},createToolbar:function(k,h,j){var i,g=this,f;k=g.prefix+k;f=j||g._cls.toolbar||c.ui.Toolbar;i=new f(k,h,g.editor);if(g.get(k)){return null}return g.add(i)},createToolbarGroup:function(k,h,j){var i,g=this,f;k=g.prefix+k;f=j||this._cls.toolbarGroup||c.ui.ToolbarGroup;i=new f(k,h,g.editor);if(g.get(k)){return null}return g.add(i)},createSeparator:function(g){var f=g||this._cls.separator||c.ui.Separator;return new f()},setControlType:function(g,f){return this._cls[g.toLowerCase()]=f},destroy:function(){d(this.controls,function(f){f.destroy()});this.controls=null}})})(tinymce);(function(d){var a=d.util.Dispatcher,e=d.each,c=d.isIE,b=d.isOpera;d.create("tinymce.WindowManager",{WindowManager:function(f){var g=this;g.editor=f;g.onOpen=new a(g);g.onClose=new a(g);g.params={};g.features={}},open:function(z,h){var v=this,k="",n,m,i=v.editor.settings.dialog_type=="modal",q,o,j,g=d.DOM.getViewPort(),r;z=z||{};h=h||{};o=b?g.w:screen.width;j=b?g.h:screen.height;z.name=z.name||"mc_"+new Date().getTime();z.width=parseInt(z.width||320);z.height=parseInt(z.height||240);z.resizable=true;z.left=z.left||parseInt(o/2)-(z.width/2);z.top=z.top||parseInt(j/2)-(z.height/2);h.inline=false;h.mce_width=z.width;h.mce_height=z.height;h.mce_auto_focus=z.auto_focus;if(i){if(c){z.center=true;z.help=false;z.dialogWidth=z.width+"px";z.dialogHeight=z.height+"px";z.scroll=z.scrollbars||false}}e(z,function(p,f){if(d.is(p,"boolean")){p=p?"yes":"no"}if(!/^(name|url)$/.test(f)){if(c&&i){k+=(k?";":"")+f+":"+p}else{k+=(k?",":"")+f+"="+p}}});v.features=z;v.params=h;v.onOpen.dispatch(v,z,h);r=z.url||z.file;r=d._addVer(r);try{if(c&&i){q=1;window.showModalDialog(r,window,k)}else{q=window.open(r,z.name,k)}}catch(l){}if(!q){alert(v.editor.getLang("popup_blocked"))}},close:function(f){f.close();this.onClose.dispatch(this)},createInstance:function(i,h,g,m,l,k){var j=d.resolve(i);return new j(h,g,m,l,k)},confirm:function(h,f,i,g){g=g||window;f.call(i||this,g.confirm(this._decode(this.editor.getLang(h,h))))},alert:function(h,f,j,g){var i=this;g=g||window;g.alert(i._decode(i.editor.getLang(h,h)));if(f){f.call(j||i)}},resizeBy:function(f,g,h){h.resizeBy(f,g)},_decode:function(f){return d.DOM.decode(f).replace(/\\n/g,"\n")}})}(tinymce));(function(a){a.Formatter=function(aa){var Q={},T=a.each,c=aa.dom,r=aa.selection,t=a.dom.TreeWalker,N=new a.dom.RangeUtils(c),d=aa.schema.isValidChild,H=c.isBlock,m=aa.settings.forced_root_block,s=c.nodeIndex,G="\uFEFF",e=/^(src|href|style)$/,X=false,C=true,P,D,x=c.getContentEditable;function A(ab){return ab instanceof Array}function n(ac,ab){return c.getParents(ac,ab,c.getRoot())}function b(ab){return ab.nodeType===1&&ab.id==="_mce_caret"}function j(){l({alignleft:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"left"},defaultBlock:"div"},{selector:"img,table",collapsed:false,styles:{"float":"left"}}],aligncenter:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"center"},defaultBlock:"div"},{selector:"img",collapsed:false,styles:{display:"block",marginLeft:"auto",marginRight:"auto"}},{selector:"table",collapsed:false,styles:{marginLeft:"auto",marginRight:"auto"}}],alignright:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"right"},defaultBlock:"div"},{selector:"img,table",collapsed:false,styles:{"float":"right"}}],alignfull:[{selector:"figure,p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li",styles:{textAlign:"justify"},defaultBlock:"div"}],bold:[{inline:"strong",remove:"all"},{inline:"span",styles:{fontW