MailPoet Newsletters (Previous) - Version 2.6.10

Version Description

  • 2014-08-04 =
  • Improved protection of themes upload, unsubscribe links, file access and statistics.
  • Improved the "Send a test email" function.
  • Fixed never ending process while sending previews on certain servers.
  • Fixed a few regular expressions for a better rendering in Outlook.
  • Fixed memory issue when dropping the "WordPress Post" widget on sites with thousands of taxonomies.
  • Fixed wrong subscribers count in the subscribers' listing.
  • Old code Spring cleaning, removed unused rusty pieces.
Download this release

Release Info

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

Code changes from version 2.6.9 to 2.6.10

Files changed (133) hide show
  1. add-ons/add-ons-list.php +1 -0
  2. classes/WJ_Analytics.php +1 -1
  3. classes/WJ_Export.php +1 -1
  4. classes/WJ_Field.php +59 -35
  5. classes/WJ_FieldHandler.php +1 -1
  6. classes/WJ_FieldRender.php +250 -237
  7. classes/WJ_FieldUser.php +1 -1
  8. classes/WJ_Import.php +811 -814
  9. classes/WJ_Migrator.php +1 -1
  10. classes/WJ_Option.php +2 -2
  11. classes/WJ_Settings.php +3 -3
  12. classes/WJ_Stats.php +1 -1
  13. classes/WJ_Upgrade.php +1 -0
  14. classes/WJ_Utils.php +73 -53
  15. controllers/ajax/config.php +0 -11
  16. controllers/ajax/statistics.php +12 -18
  17. controllers/back/campaigns.php +43 -22
  18. controllers/back/config.php +0 -7
  19. controllers/back/statistics.php +17 -28
  20. controllers/back/subscribers.php +7 -1
  21. controllers/front/confirm.php +10 -6
  22. controllers/front/email.php +1 -13
  23. core/autoloader.php +2 -2
  24. core/base.php +1 -6
  25. core/constants.php +0 -1
  26. css/wysija-editor.css +1 -1
  27. helpers/articles.php +411 -427
  28. helpers/backloader.php +15 -0
  29. helpers/email.php +6 -0
  30. helpers/mailer.php +4 -10
  31. helpers/render_engine.php +0 -5
  32. helpers/themes.php +20 -3
  33. helpers/wj_engine.php +9 -1
  34. inc/dBug.php +548 -548
  35. inc/debug.php +1 -1
  36. inc/phpmailer/class.elasticemail.php +1 -0
  37. inc/phpmailer/class.sendgrid.php +1 -0
  38. index.php +1 -1
  39. js/admin-campaigns-articles.js +1 -1
  40. js/admin-campaigns-autopost.js +1 -1
  41. js/admin-campaigns-editTemplate.js +1 -1
  42. js/admin-config-settings.js +1 -1
  43. js/admin-subscribers-importmatch.js +1 -1
  44. js/admin-wysija.js +1 -1
  45. js/fields/select2-simple.js +21 -0
  46. js/fields/select2-terms.js +67 -0
  47. js/jquery/jquery.matchColumn.js +89 -76
  48. js/jquery/jquery.userStatusMapping.js +64 -0
  49. js/wysija-editor.js +3 -3
  50. languages/wysija-newsletters-ach.mo +0 -0
  51. languages/wysija-newsletters-af.mo +0 -0
  52. languages/wysija-newsletters-ar.mo +0 -0
  53. languages/wysija-newsletters-bg_BG.mo +0 -0
  54. languages/wysija-newsletters-bn_BD.mo +0 -0
  55. languages/wysija-newsletters-bs_BA.mo +0 -0
  56. languages/wysija-newsletters-ca.mo +0 -0
  57. languages/wysija-newsletters-ca@valencia.mo +0 -0
  58. languages/wysija-newsletters-ca_ES.mo +0 -0
  59. languages/wysija-newsletters-cs_CZ.mo +0 -0
  60. languages/wysija-newsletters-da_DK.mo +0 -0
  61. languages/wysija-newsletters-de_AT.mo +0 -0
  62. languages/wysija-newsletters-de_DE.mo +0 -0
  63. languages/wysija-newsletters-el.mo +0 -0
  64. languages/wysija-newsletters-en_GB.mo +0 -0
  65. languages/wysija-newsletters-en_US.mo +0 -0
  66. languages/wysija-newsletters-es.mo +0 -0
  67. languages/wysija-newsletters-es_419.mo +0 -0
  68. languages/wysija-newsletters-es_AR.mo +0 -0
  69. languages/wysija-newsletters-es_ES.mo +0 -0
  70. languages/wysija-newsletters-et.mo +0 -0
  71. languages/wysija-newsletters-eu.mo +0 -0
  72. languages/wysija-newsletters-eu_ES.mo +0 -0
  73. languages/wysija-newsletters-fa.mo +0 -0
  74. languages/wysija-newsletters-fa_IR.mo +0 -0
  75. languages/wysija-newsletters-fi.mo +0 -0
  76. languages/wysija-newsletters-fr_FR.mo +0 -0
  77. languages/wysija-newsletters-ga.mo +0 -0
  78. languages/wysija-newsletters-gl_ES.mo +0 -0
  79. languages/wysija-newsletters-he_IL.mo +0 -0
  80. languages/wysija-newsletters-hi_IN.mo +0 -0
  81. languages/wysija-newsletters-hr_HR.mo +0 -0
  82. languages/wysija-newsletters-hu_HU.mo +0 -0
  83. languages/wysija-newsletters-hy_AM.mo +0 -0
  84. languages/wysija-newsletters-id.mo +0 -0
  85. languages/wysija-newsletters-it_IT.mo +0 -0
  86. languages/wysija-newsletters-ja.mo +0 -0
  87. languages/wysija-newsletters-ko_KR.mo +0 -0
  88. languages/wysija-newsletters-lt_LT.mo +0 -0
  89. languages/wysija-newsletters-lv.mo +0 -0
  90. languages/wysija-newsletters-lv_LV.mo +0 -0
  91. languages/wysija-newsletters-mk_MK.mo +0 -0
  92. languages/wysija-newsletters-my_MM.mo +0 -0
  93. languages/wysija-newsletters-nb_NO.mo +0 -0
  94. languages/wysija-newsletters-nl_NL.mo +0 -0
  95. languages/wysija-newsletters-oc.mo +0 -0
  96. languages/wysija-newsletters-pl_PL.mo +0 -0
  97. languages/wysija-newsletters-pt_BR.mo +0 -0
  98. languages/wysija-newsletters-pt_PT.mo +0 -0
  99. languages/wysija-newsletters-ro_RO.mo +0 -0
  100. languages/wysija-newsletters-ru_RU.mo +0 -0
  101. languages/wysija-newsletters-sk_SK.mo +0 -0
  102. languages/wysija-newsletters-sl_SI.mo +0 -0
  103. languages/wysija-newsletters-sq.mo +0 -0
  104. languages/wysija-newsletters-sr@latin.mo +0 -0
  105. languages/wysija-newsletters-sr_RS.mo +0 -0
  106. languages/wysija-newsletters-sr_RS@latin.mo +0 -0
  107. languages/wysija-newsletters-sv_SE.mo +0 -0
  108. languages/wysija-newsletters-tr_TR.mo +0 -0
  109. languages/wysija-newsletters-uk.mo +0 -0
  110. languages/wysija-newsletters-ur_PK.mo +0 -0
  111. languages/wysija-newsletters-vi.mo +0 -0
  112. languages/wysija-newsletters-zh_CN.mo +0 -0
  113. languages/wysija-newsletters-zh_HK.mo +0 -0
  114. languages/wysija-newsletters-zh_TW.mo +0 -0
  115. models/user.php +11 -5
  116. modules/archive_std/archive_std.php +77 -76
  117. modules/archive_std/archive_std_model.php +78 -78
  118. modules/archive_std/archive_std_view.php +151 -151
  119. modules/stats_newsletter_std/stats_newsletter_std.php +218 -217
  120. modules/stats_newsletter_std/stats_newsletter_std_model.php +81 -80
  121. modules/stats_newsletter_std/stats_newsletter_std_view.php +197 -196
  122. modules/stats_reportcards_std/stats_reportcards_std.php +168 -167
  123. modules/stats_reportcards_std/stats_reportcards_std_model.php +111 -103
  124. modules/stats_reportcards_std/stats_reportcards_std_view.php +18 -17
  125. modules/stats_subscribers_std/stats_subscribers_std.php +102 -100
  126. modules/stats_subscribers_std/stats_subscribers_std_model.php +74 -73
  127. modules/stats_subscribers_std/stats_subscribers_std_view.php +101 -97
  128. readme.txt +10 -1
  129. tools/templates/newsletter/email/css.html +4 -11
  130. tools/templates/newsletter/email/email_template.html +0 -4
  131. views/back/campaigns.php +6 -6
  132. views/back/config.php +65 -47
  133. widgets/wysija_nl.php +20 -13
add-ons/add-ons-list.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * List of all add-ons available for MailPoet
4
  */
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /**
4
  * List of all add-ons available for MailPoet
5
  */
classes/WJ_Analytics.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  /*
4
  Class Analytics.
5
  It's a sort of useful stats and numbers generator about MailPoet usage.
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /*
4
  Class Analytics.
5
  It's a sort of useful stats and numbers generator about MailPoet usage.
classes/WJ_Export.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  /**
4
  * Class Export.
5
  *
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /**
4
  * Class Export.
5
  *
classes/WJ_Field.php CHANGED
@@ -1,23 +1,24 @@
1
  <?php
2
-
3
  /*
4
  A custom field.
5
  It represents a custom field that
6
  can be added to a form.
7
  Example:
8
- $custom_field = new WJ_Field();
9
- $custom_field->set(array(
10
- 'name' => 'Fruits',
11
- 'type' => 'select',
12
- 'required' => false,
13
- 'settings' => array(
14
- 'label' => 'Select a fruit:',
15
- 'values' => array(
16
- 'Apple', 'Orange', 'Banana'
17
- ),
18
- 'default_value' => 'Orange'
 
19
  )
20
- ));
21
  $custom_field->save();
22
  */
23
 
@@ -38,13 +39,37 @@ class WJ_Field {
38
  // Settings.
39
  public $settings = array();
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  /*
42
  Just set the correct tables on creation.
43
  $custom_field = new WJ_Field();
44
  */
45
- function __construct() {
46
- $this->table = WJ_Settings::db_prefix( 'custom_field' );
47
- $this->user_table = WJ_Settings::db_prefix( 'user' );
 
 
 
 
48
  }
49
 
50
  /*
@@ -62,14 +87,10 @@ class WJ_Field {
62
  # => WJCustomField Object
63
  */
64
  public static function get( $id ) {
65
- $object = new self();
66
  global $wpdb;
67
- $result = $wpdb->get_row( $wpdb->prepare( "SELECT * from {$object->table} WHERE id = %d", $id ), ARRAY_A );
68
  if ( $result != null ) {
69
- $result['settings'] = unserialize( $result['settings'] );
70
- $result['required'] = WJ_Utils::to_bool( $result['required'] );
71
- $object->set( $result );
72
- return $object;
73
  } else {
74
  return null;
75
  }
@@ -81,26 +102,21 @@ class WJ_Field {
81
  # => Array of WJ_Field
82
  */
83
  public static function get_all( $options = array() ) {
84
- $object = new self();
85
  global $wpdb;
86
 
87
  // default order by
88
  $order_by = 'id ASC';
89
- if ( isset($options['order_by'] ) ){
90
  $order_by = $options['order_by'];
91
  }
92
 
93
  // fetch rows from db
94
- $results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$object->table} ORDER BY %s", $order_by ), ARRAY_A );
95
 
96
- if ( $results != null ) {
97
  $collection = array();
98
  foreach ( $results as $result ) {
99
- $result['settings'] = unserialize( $result['settings'] );
100
- $result['required'] = WJ_Utils::to_bool( $result['required'] );
101
- $field = new self();
102
- $field->set( $result );
103
- $collection[] = $field;
104
  }
105
  return $collection;
106
  } else {
@@ -119,7 +135,7 @@ class WJ_Field {
119
  $fields_list = array();
120
  if ( isset( $fields ) ) {
121
  foreach ( $fields as $field ) {
122
- $fields_list[$field->id] = $field->name;
123
  }
124
  }
125
  return $fields_list;
@@ -139,8 +155,16 @@ class WJ_Field {
139
  }
140
  $this->name = $args['name'];
141
  $this->type = $args['type'];
142
- $this->required = $args['required'];
143
- $this->settings = $args['settings'];
 
 
 
 
 
 
 
 
144
  }
145
 
146
  /*
@@ -214,7 +238,7 @@ class WJ_Field {
214
  'name' => $this->name,
215
  'type' => $this->type,
216
  'required' => $required,
217
- 'settings' => serialize( $this->settings ),
218
  ),
219
  array( 'id' => $this->id ),
220
  array( '%s', '%s', '%d' ),
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /*
4
  A custom field.
5
  It represents a custom field that
6
  can be added to a form.
7
  Example:
8
+ $custom_field = new WJ_Field(
9
+ array(
10
+ 'name' => 'Fruits',
11
+ 'type' => 'select',
12
+ 'required' => false,
13
+ 'settings' => array(
14
+ 'label' => 'Select a fruit:',
15
+ 'values' => array(
16
+ 'Apple', 'Orange', 'Banana'
17
+ ),
18
+ 'default_value' => 'Orange'
19
+ )
20
  )
21
+ );
22
  $custom_field->save();
23
  */
24
 
39
  // Settings.
40
  public $settings = array();
41
 
42
+ static $_table = 'custom_field';
43
+ static $_user_table = 'user';
44
+
45
+ static $defaults = array(
46
+ 'date' => array(
47
+ 'date_type' => 'year_month_day',
48
+ 'is_default_today' => 0,
49
+ 'date_order' => 'mm/dd/yyyy',
50
+ ),
51
+ 'radio' => array(
52
+ 'values' => array(),
53
+ ),
54
+ 'checkbox' => array(
55
+ 'values' => array(),
56
+ ),
57
+ 'select' => array(
58
+ 'values' => array(),
59
+ )
60
+ );
61
+
62
  /*
63
  Just set the correct tables on creation.
64
  $custom_field = new WJ_Field();
65
  */
66
+ function __construct( $args = null ) {
67
+ $this->table = WJ_Settings::db_prefix( self::$_table );
68
+ $this->user_table = WJ_Settings::db_prefix( self::$_user_table );
69
+
70
+ if ( ! is_null( $args ) ){
71
+ $this->set( $args );
72
+ }
73
  }
74
 
75
  /*
87
  # => WJCustomField Object
88
  */
89
  public static function get( $id ) {
 
90
  global $wpdb;
91
+ $result = $wpdb->get_row( $wpdb->prepare( 'SELECT * from ' . WJ_Settings::db_prefix( self::$_table ) . ' WHERE id = %d', $id ), ARRAY_A );
92
  if ( $result != null ) {
93
+ return new self( $result );
 
 
 
94
  } else {
95
  return null;
96
  }
102
  # => Array of WJ_Field
103
  */
104
  public static function get_all( $options = array() ) {
 
105
  global $wpdb;
106
 
107
  // default order by
108
  $order_by = 'id ASC';
109
+ if ( isset( $options['order_by'] ) ){
110
  $order_by = $options['order_by'];
111
  }
112
 
113
  // fetch rows from db
114
+ $results = $wpdb->get_results( $wpdb->prepare( 'SELECT * from ' . WJ_Settings::db_prefix( self::$_table ) . ' ORDER BY %s', $order_by ), ARRAY_A );
115
 
116
+ if ( ! is_null( $results ) ) {
117
  $collection = array();
118
  foreach ( $results as $result ) {
119
+ $collection[] = new self( $result );
 
 
 
 
120
  }
121
  return $collection;
122
  } else {
135
  $fields_list = array();
136
  if ( isset( $fields ) ) {
137
  foreach ( $fields as $field ) {
138
+ $fields_list[ $field->id ] = $field->name;
139
  }
140
  }
141
  return $fields_list;
155
  }
156
  $this->name = $args['name'];
157
  $this->type = $args['type'];
158
+ $this->required = WJ_Utils::to_bool( $args['required'] );
159
+ $this->settings = maybe_unserialize( $args['settings'] );
160
+
161
+ if ( ! is_array( $this->settings ) ){
162
+ $this->settings = array();
163
+ }
164
+
165
+ if ( isset( self::$defaults[ $this->type ] ) && is_array( self::$defaults[ $this->type ] ) ) {
166
+ $this->settings = wp_parse_args( (array) $this->settings, (array) self::$defaults[ $this->type ] );
167
+ }
168
  }
169
 
170
  /*
238
  'name' => $this->name,
239
  'type' => $this->type,
240
  'required' => $required,
241
+ 'settings' => maybe_serialize( $this->settings ),
242
  ),
243
  array( 'id' => $this->id ),
244
  array( '%s', '%s', '%d' ),
classes/WJ_FieldHandler.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  /*
4
  Class WJ_FieldHandler
5
  It handles the custom fields in a controller.
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /*
4
  Class WJ_FieldHandler
5
  It handles the custom fields in a controller.
classes/WJ_FieldRender.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  /*
4
  Class WJ_FieldRender
5
  It is able to render Custom Fields in a form.
@@ -7,242 +7,255 @@ It is able to render Custom Fields in a form.
7
 
8
  class WJ_FieldRender {
9
 
10
- // WJ_FieldUser Object.
11
- private $field_user;
12
- // The column, like 'cf_1'
13
- private $identifier;
14
- // Name of the field.
15
- private $name;
16
- // Value of the field.
17
- private $value;
18
-
19
- public function __construct($field_user) {
20
- $this->field_user = $field_user;
21
- $this->identifier = $field_user->column_name();
22
- $this->name = esc_attr($field_user->field->name);
23
- $this->value = esc_attr($field_user->value());
24
- }
25
-
26
- public function validation() {
27
- $rules = array();
28
- $validation_class = '';
29
-
30
- // If there are any validations, add correct class names.
31
- if (!empty($this->field_user->field->settings['validate'])) {
32
- $validation_value = $this->field_user->field->settings['validate'];
33
- $rules[] = 'custom[' . $validation_value . ']';
34
- }
35
-
36
- // If there's any validation, join all classes.
37
- if (!empty($rules)) {
38
- $validation_class = 'class="validate[' . join(',', $rules) . ']"';
39
- }
40
-
41
- return $validation_class;
42
- }
43
-
44
- /*
45
- Returns the HTML label for this field, to be used
46
- in a form.
47
- $field_render->label();
48
- # => '<label ...>Address</label>'
49
- */
50
- public function label() {
51
- $form_field_name = $this->identifier;
52
- $label =
53
- '<label for="' . $form_field_name . '">' .
54
- $this->name .
55
- '</label>';
56
- return $label;
57
- }
58
-
59
- /*
60
- Returns the input related to the type of the field,
61
- to be used in a form.
62
- $field_render->input();
63
- # => '<input type=..../>
64
- */
65
- public function input() {
66
- $input = '';
67
-
68
- switch ($this->field_user->field->type) {
69
- case 'input':
70
- $input =
71
- '<input type="text" size="40" id="'. $this->identifier . '"' .
72
- 'value="' . $this->value .
73
- '" name="wysija[field][' . $this->identifier . ']" ' .
74
- $this->validation() .
75
- ' />';
76
- break;
77
- case 'textarea':
78
- $input =
79
- '<textarea id="'. $this->identifier . '"' .
80
- 'name="wysija[field][' . $this->identifier . ']" ' .
81
- $this->validation() .
82
- ' />' .
83
- $this->value .
84
- '</textarea>';
85
- break;
86
- case 'checkbox':
87
- $check_value = '';
88
- $label = $this->field_user->field->settings['values'][0]['value'];
89
- if ($this->value == 1) {
90
- $check_value = ' checked="checked"';
91
- }
92
- $input =
93
- '<label for="' . $this->identifier . '">' .
94
- '<input type="hidden" '.
95
- $check_value .
96
- ' name="wysija[field][' . $this->identifier . ']"' .
97
- ' value="0" ' .
98
- ' />' .
99
- '<input type="checkbox" id="'. $this->identifier . '"' .
100
- $check_value .
101
- ' name="wysija[field][' . $this->identifier . ']"' .
102
- ' value="1" ' .
103
- $this->validation() .
104
- ' />' . $label . '</label>';
105
- break;
106
- case 'radio':
107
- $field = $this->field_user->field;
108
- foreach ($field->settings['values'] as $index => $content) {
109
- $check_value = '';
110
- if ($this->value == $content['value']) {
111
- $check_value = 'checked="checked"';
112
- }
113
- $local_identifier = $this->identifier . '_' . $content['value'];
114
- $input .=
115
- '<label for="' . $local_identifier . '">' .
116
- '<input type="radio" id="'. $local_identifier . '"' .
117
- $check_value .
118
- ' name="wysija[field][' . $this->identifier . ']"' .
119
- ' value="' . $content['value'] . '" />' .
120
- $content['value'] .
121
- '</label>';
122
- }
123
- break;
124
- case 'select':
125
- $input = '<select id="' . $this->identifier . '"' .
126
- ' name="wysija[field][' . $this->identifier . ']" ' .
127
- $this->validation() .
128
- ' />';
129
- $field = $this->field_user->field;
130
- foreach ($field->settings['values'] as $index => $content) {
131
- $check_value = '';
132
- if ($this->value == $content['value']) {
133
- $check_value = 'selected="selected"';
134
- }
135
- $input .=
136
- '<option ' . $check_value .
137
- ' value="' . $content['value'] . '" >' .
138
- $content['value'] .
139
- '</option>';
140
- }
141
- $input .= '</select>';
142
- break;
143
-
144
- case 'date':
145
- // get date format from field settings
146
- $field = $this->field_user->field;
147
-
148
- // get timestamp value
149
- $value = ((int)$this->value > 0) ? (int)$this->value : null;
150
-
151
- // get date type (defaults to year + month + day)
152
- $date_type = (isset($field->settings['date_type'])) ? $field->settings['date_type'] : 'year_month_day';
153
- // get an array of all required date components (year, month, day)
154
- $display_date_fields = explode('_', $date_type);
155
- // form engine to get date data
156
- $helper_form_engine = WYSIJA::get('form_engine', 'helper');
157
-
158
- // year selection
159
- if(in_array('year', $display_date_fields)) {
160
- $years = $helper_form_engine->get_years();
161
-
162
- $selected_year = null;
163
- if($value !== null) {
164
- $selected_year = (int)strftime('%Y', $value);
165
- }
166
-
167
- // select
168
- $input .= '<select name="wysija[field]['.$this->identifier.'][year]">';
169
- $input .= '<option value="">'.__('Year').'</option>';
170
- foreach($years as $year) {
171
- $is_selected = ((int)$year['year'] === $selected_year) ? ' selected="selected"' : '';
172
- $input .= '<option value="'.$year['year'].'"'.$is_selected.'>'.$year['year'].'</option>';
173
- }
174
- $input .= '</select>';
175
- }
176
-
177
- // month selection
178
- if(in_array('month', $display_date_fields)) {
179
- $months = $helper_form_engine->get_months();
180
-
181
- $selected_month = null;
182
- if($value !== null) {
183
- $selected_month = (int)strftime('%m', $value);
184
- }
185
-
186
- // select
187
- $input .= '<select name="wysija[field]['.$this->identifier.'][month]">';
188
- $input .= '<option value="">'.__('Month').'</option>';
189
- foreach($months as $month) {
190
- $is_selected = ((int)$month['month'] === $selected_month) ? ' selected="selected"' : '';
191
- $input .= '<option value="'.$month['month'].'"'.$is_selected.'>'.$month['month_name'].'</option>';
192
- }
193
- $input .= '</select>';
194
- }
195
-
196
- // day selection
197
- if(in_array('day', $display_date_fields)) {
198
- $days = $helper_form_engine->get_days();
199
-
200
- $selected_day = null;
201
- if($value !== null) {
202
- $selected_day = (int)strftime('%d', $value);
203
- }
204
-
205
- // select
206
- $input .= '<select name="wysija[field]['.$this->identifier.'][day]">';
207
- $input .= '<option value="">'.__('Day').'</option>';
208
- foreach($days as $day) {
209
- $is_selected = ((int)$day['day'] === $selected_day) ? ' selected="selected"' : '';
210
- $input .= '<option value="'.$day['day'].'"'.$is_selected.'>'.$day['day'].'</option>';
211
- }
212
- $input .= '</select>';
213
- }
214
- break;
215
- default:
216
- $input = '';
217
- break;
218
- }
219
- return $input;
220
- }
221
-
222
- /*
223
- Render all custom fields in a table, given the user id.
224
- $field_render::render_all(1);
225
- # => '<tr><th><label...<input...</td></tr>'
226
- */
227
- public static function render_all($user_id) {
228
- $fields = WJ_FieldUser::get_all($user_id);
229
- if (isset($fields)) {
230
- $output = '';
231
- foreach ($fields as $field) {
232
- $field_render = new self($field);
233
- $output .=
234
- '<tr>' .
235
- '<th scope="row">' .
236
- $field_render->label() .
237
- '</th><td>' .
238
- $field_render->input() .
239
- '</td></tr>';
240
- }
241
- return $output;
242
- } else {
243
- return null;
244
- }
245
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
246
 
247
 
248
  }
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /*
4
  Class WJ_FieldRender
5
  It is able to render Custom Fields in a form.
7
 
8
  class WJ_FieldRender {
9
 
10
+ // WJ_FieldUser Object.
11
+ private $field_user;
12
+ // The column, like 'cf_1'
13
+ private $identifier;
14
+ // Name of the field.
15
+ private $name;
16
+ // Value of the field.
17
+ private $value;
18
+
19
+ public function __construct( $field_user ) {
20
+ $this->field_user = $field_user;
21
+ $this->identifier = $field_user->column_name();
22
+ $this->name = esc_attr( $field_user->field->name );
23
+ $this->value = esc_attr( $field_user->value() );
24
+ }
25
+
26
+ public function validation() {
27
+ $rules = array();
28
+ $validation_class = '';
29
+
30
+ // If there are any validations, add correct class names.
31
+ if ( ! empty( $this->field_user->field->settings['validate'] ) ) {
32
+ $validation_value = $this->field_user->field->settings['validate'];
33
+ $rules[] = 'custom[' . $validation_value . ']';
34
+ }
35
+
36
+ // If there's any validation, join all classes.
37
+ if ( ! empty( $rules ) ) {
38
+ $validation_class = 'class="validate[' . join( ',', $rules ) . ']"';
39
+ }
40
+
41
+ return $validation_class;
42
+ }
43
+
44
+ /*
45
+ Returns the HTML label for this field, to be used
46
+ in a form.
47
+ $field_render->label();
48
+ # => '<label ...>Address</label>'
49
+ */
50
+ public function label() {
51
+ $form_field_name = $this->identifier;
52
+ $label =
53
+ '<label for="' . $form_field_name . '">' .
54
+ $this->name .
55
+ '</label>';
56
+ return $label;
57
+ }
58
+
59
+ /*
60
+ Returns the input related to the type of the field,
61
+ to be used in a form.
62
+ $field_render->input();
63
+ # => '<input type=..../>
64
+ */
65
+ public function input() {
66
+ $input = '';
67
+
68
+ switch ( $this->field_user->field->type ) {
69
+ case 'input':
70
+ $input =
71
+ '<input type="text" size="40" id="'. $this->identifier . '"' .
72
+ 'value="' . $this->value .
73
+ '" name="wysija[field][' . $this->identifier . ']" ' .
74
+ $this->validation() .
75
+ ' />';
76
+ break;
77
+ case 'textarea':
78
+ $input =
79
+ '<textarea id="'. $this->identifier . '"' .
80
+ 'name="wysija[field][' . $this->identifier . ']" ' .
81
+ $this->validation() .
82
+ ' />' .
83
+ $this->value .
84
+ '</textarea>';
85
+ break;
86
+ case 'checkbox':
87
+ if ( empty( $this->field_user->field->settings['values'] ) ){
88
+ $input = esc_attr__( 'This field contains no values', WYSIJA );
89
+ break;
90
+ }
91
+ $check_value = '';
92
+ $label = $this->field_user->field->settings['values'][0]['value'];
93
+ if ( $this->value == 1 ) {
94
+ $check_value = ' checked="checked"';
95
+ }
96
+ $input =
97
+ '<label for="' . $this->identifier . '">' .
98
+ '<input type="hidden" '.
99
+ $check_value .
100
+ ' name="wysija[field][' . $this->identifier . ']"' .
101
+ ' value="0" ' .
102
+ ' />' .
103
+ '<input type="checkbox" id="'. $this->identifier . '"' .
104
+ $check_value .
105
+ ' name="wysija[field][' . $this->identifier . ']"' .
106
+ ' value="1" ' .
107
+ $this->validation() .
108
+ ' />' . $label . '</label>';
109
+ break;
110
+ case 'radio':
111
+ $field = $this->field_user->field;
112
+ if ( empty( $this->field_user->field->settings['values'] ) ){
113
+ $input = esc_attr__( 'This field contains no values', WYSIJA );
114
+ break;
115
+ }
116
+ foreach ( $field->settings['values'] as $index => $content ) {
117
+ $check_value = '';
118
+ if ( $this->value == $content['value'] ) {
119
+ $check_value = 'checked="checked"';
120
+ }
121
+ $local_identifier = $this->identifier . '_' . $content['value'];
122
+ $input .=
123
+ '<label for="' . $local_identifier . '">' .
124
+ '<input type="radio" id="'. $local_identifier . '"' .
125
+ $check_value .
126
+ ' name="wysija[field][' . $this->identifier . ']"' .
127
+ ' value="' . $content['value'] . '" />' .
128
+ $content['value'] .
129
+ '</label>';
130
+ }
131
+ break;
132
+ case 'select':
133
+ if ( empty( $this->field_user->field->settings['values'] ) ){
134
+ $input = esc_attr__( 'This field contains no values', WYSIJA );
135
+ break;
136
+ }
137
+
138
+ $input = '<select id="' . $this->identifier . '"' .
139
+ ' name="wysija[field][' . $this->identifier . ']" ' .
140
+ $this->validation() .
141
+ ' />';
142
+ $field = $this->field_user->field;
143
+ foreach ( $field->settings['values'] as $index => $content ) {
144
+ $check_value = '';
145
+ if ( $this->value == $content['value'] ) {
146
+ $check_value = 'selected="selected"';
147
+ }
148
+ $input .=
149
+ '<option ' . $check_value .
150
+ ' value="' . $content['value'] . '" >' .
151
+ $content['value'] .
152
+ '</option>';
153
+ }
154
+ $input .= '</select>';
155
+ break;
156
+
157
+ case 'date':
158
+ // get date format from field settings
159
+ $field = $this->field_user->field;
160
+
161
+ // get timestamp value
162
+ $value = ((int) $this->value > 0) ? (int) $this->value : null;
163
+
164
+ // get date type (defaults to year + month + day)
165
+ $date_type = ( isset( $field->settings['date_type'] ) ) ? $field->settings['date_type'] : 'year_month_day';
166
+ // get an array of all required date components (year, month, day)
167
+ $display_date_fields = explode( '_', $date_type );
168
+ // form engine to get date data
169
+ $helper_form_engine = WYSIJA::get( 'form_engine', 'helper' );
170
+
171
+ // year selection
172
+ if ( in_array( 'year', $display_date_fields ) ) {
173
+ $years = $helper_form_engine->get_years();
174
+
175
+ $selected_year = null;
176
+ if ( $value !== null ) {
177
+ $selected_year = (int) strftime( '%Y', $value );
178
+ }
179
+
180
+ // select
181
+ $input .= '<select name="wysija[field]['.$this->identifier.'][year]">';
182
+ $input .= '<option value="">' . __( 'Year' ) .'</option>';
183
+ foreach ( $years as $year ) {
184
+ $is_selected = ((int)$year['year'] === $selected_year) ? ' selected="selected"' : '';
185
+ $input .= '<option value="'.$year['year'].'"'.$is_selected.'>'.$year['year'].'</option>';
186
+ }
187
+ $input .= '</select>';
188
+ }
189
+
190
+ // month selection
191
+ if ( in_array( 'month', $display_date_fields ) ) {
192
+ $months = $helper_form_engine->get_months();
193
+
194
+ $selected_month = null;
195
+ if ( $value !== null ) {
196
+ $selected_month = (int) strftime( '%m', $value );
197
+ }
198
+
199
+ // select
200
+ $input .= '<select name="wysija[field]['.$this->identifier.'][month]">';
201
+ $input .= '<option value="">' . __( 'Month' ) . '</option>';
202
+ foreach ( $months as $month ) {
203
+ $is_selected = ((int)$month['month'] === $selected_month) ? ' selected="selected"' : '';
204
+ $input .= '<option value="'.$month['month'].'"'.$is_selected.'>'.$month['month_name'].'</option>';
205
+ }
206
+ $input .= '</select>';
207
+ }
208
+
209
+ // day selection
210
+ if ( in_array( 'day', $display_date_fields ) ) {
211
+ $days = $helper_form_engine->get_days();
212
+
213
+ $selected_day = null;
214
+ if ( $value !== null ) {
215
+ $selected_day = (int) strftime( '%d', $value );
216
+ }
217
+
218
+ // select
219
+ $input .= '<select name="wysija[field]['.$this->identifier.'][day]">';
220
+ $input .= '<option value="">' . __( 'Day' ) . '</option>';
221
+ foreach ( $days as $day ) {
222
+ $is_selected = ((int)$day['day'] === $selected_day) ? ' selected="selected"' : '';
223
+ $input .= '<option value="'.$day['day'].'"'.$is_selected.'>'.$day['day'].'</option>';
224
+ }
225
+ $input .= '</select>';
226
+ }
227
+ break;
228
+ default:
229
+ $input = '';
230
+ break;
231
+ }
232
+ return $input;
233
+ }
234
+
235
+ /*
236
+ Render all custom fields in a table, given the user id.
237
+ $field_render::render_all(1);
238
+ # => '<tr><th><label...<input...</td></tr>'
239
+ */
240
+ public static function render_all( $user_id ) {
241
+ $fields = WJ_FieldUser::get_all( $user_id );
242
+ if ( isset( $fields ) ) {
243
+ $output = '';
244
+ foreach ( $fields as $field ) {
245
+ $field_render = new self($field);
246
+ $output .=
247
+ '<tr>' .
248
+ '<th scope="row">' .
249
+ $field_render->label() .
250
+ '</th><td>' .
251
+ $field_render->input() .
252
+ '</td></tr>';
253
+ }
254
+ return $output;
255
+ } else {
256
+ return null;
257
+ }
258
+ }
259
 
260
 
261
  }
classes/WJ_FieldUser.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  /*
4
  An user field is a custom field identified by ID,
5
  linked to a particular user, identified by ID.
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /*
4
  An user field is a custom field identified by ID,
5
  linked to a particular user, identified by ID.
classes/WJ_Import.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  /**
4
  * Class Import.
5
  *
@@ -7,822 +7,819 @@
7
  */
8
  class WJ_Import extends WYSIJA_object {
9
 
10
- private $_header_row = array();
11
- private $_csv_data = array();
12
- private $_match = array();
13
- private $_ignore_invalid_date = array(); // specific for date fields
14
- private $_custom_fields = array();
15
- private $_email_key = '';
16
- private $_data_to_insert = array();
17
- private $_number_list = 0;
18
- private $_data_numbers = array();
19
- private $_line_delimiter = "\n";
20
- private $_duplicate_emails_count = array(); // detect the emails that are duplicates in the import file
21
- private $_csv_array = array(); // containing the csv into an array
22
- private $_ignored_row_count = 0; // the count of rows we ignore because there was no valid email present
23
- private $_lines_count = 0; // count the number of valid lines inserted in the DB
24
- private $_chunks_count = 0; // number of chunks we chopped from the csv
25
- private $_first_row_is_data = false; // means that there is no header on that csv file
26
- private $_emails_inserted_in_current_chunk = array(); // array of emails
27
- private $_csv_file_string = '';
28
- private $_data_result = array(); // used for importmatch refactor
29
- private $_regex_new_field = "/^new_field\|([^\|]+)\|(.+)$/i";
30
-
31
- function __construct() {
32
- if (!empty($_POST['wysija']['match']))
33
- $this->_match = $_POST['wysija']['match'];
34
- if (!empty($_POST['wysija']['ignore_invalid_date']))
35
- $this->_ignore_invalid_date = $_POST['wysija']['ignore_invalid_date'];
36
- if (!empty($_REQUEST['wysija']['user_list']['list']))
37
- $this->_number_list = count($_REQUEST['wysija']['user_list']['list']);
38
- if (!empty($_POST['firstrowisdata']))
39
- $this->_first_row_is_data = true;
40
- $this->_data_numbers = array('invalid' => array(), 'inserted' => 0, 'valid_email_processed' => 0, 'list_added' => 0, 'list_user_ids' => 0, 'list_list_ids' => $this->_number_list, 'emails_queued' => 0);
41
- }
42
-
43
- /**
44
- * loading file data passed in a global variable
45
- * @return type
46
- */
47
- private function _get_temp_file_info() {
48
- if (!empty($_REQUEST['wysija']['dataImport']))
49
- return unserialize(base64_decode($_REQUEST['wysija']['dataImport']));
50
- }
51
-
52
- /**
53
- * loading the file based on global parameters
54
- * @return string
55
- */
56
- private function _loading_file_content() {
57
- // try to access the temporary file created in the previous step
58
- $this->_csv_data = $this->_get_temp_file_info();
59
-
60
- $helper_file = WYSIJA::get('file', 'helper');
61
- $result_file = $helper_file->get($this->_csv_data['csv'], 'import');
62
-
63
- if (!$result_file) {
64
- $upload_dir = wp_upload_dir();
65
- $this->error(sprintf(__('Cannot access CSV file. Verify access rights to this directory "%1$s"', WYSIJA), $upload_dir['basedir']), true);
66
- return false;
67
- }
68
-
69
- // get the temp csv file
70
- $this->_csv_file_string = file_get_contents($result_file);
71
- }
72
-
73
- private function _set_custom_fields(){
74
- $WJ_Field = new WJ_Field();
75
- $_custom_fields = $WJ_Field->get_all();
76
-
77
- if(!empty($_custom_fields)){
78
- foreach($_custom_fields as $key => &$row){
79
- $this->_custom_fields['cf_'.$row->id] = $row;
80
- }
81
- }
82
- }
83
-
84
- /**
85
- * Validate if a column is already matched previously
86
- * @param string $column_name
87
- * @return boolean
88
- */
89
- private function _is_column_matched($column_name) {
90
  if (empty($this->_data_to_insert)) {
91
- return false;
92
  }
93
  $column_names = array_values($this->_data_to_insert);
94
  return in_array(trim($column_name), $column_names);
95
- }
96
- /**
97
- * match columns together with the csv data based on the data passed
98
- */
99
- private function _match_columns_to_insert() {
100
-
101
- // we're going through all of the selected value in each dropdown when importing
102
- foreach($this->_match as $csv_column_number => $column_in_user_table){
103
- // Reduce matching twice the same column
104
- if ($this->_is_column_matched($column_in_user_table))
105
- continue;
106
-
107
- // Ignore `nomatch` columns
108
- if ($column_in_user_table == 'nomatch')
109
- continue;
110
-
111
- // Check if maybe it's a new field
112
- preg_match($this->_regex_new_field, $column_in_user_table, $maybe_newfield);
113
- if ( !empty($maybe_newfield) && in_array($maybe_newfield[1], array('date', 'input')) ){
114
- // TODO need to change to WJ_Field I guess when Marco is done moving the files
115
- // saving a new custom field
116
- $custom_field = new WJ_Field();
117
-
118
- $custom_field->set(array(
119
- 'name' => $maybe_newfield[2],
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
-
130
- $custom_field->save();
131
-
132
- // this is the column name in the database so this is where we need to import that field
133
- $column_in_user_table = $custom_field->user_column_name();
134
- $this->_match[$csv_column_number] = $column_in_user_table;
135
- }
136
-
137
- // keep the match of CSV column number to column key in our database
138
- // not sure why do we trim the column key ...
139
- $this->_data_to_insert[$csv_column_number] = trim($column_in_user_table);
140
-
141
- // this column is the email column, let's keep track of it for later validation etc..
142
- if($column_in_user_table == 'email'){
143
- $this->_email_key = $csv_column_number;
144
- }
145
- }
146
-
147
- $this->_set_custom_fields();
148
-
149
- // if the status column is not matched, we make sure that we have an entry for the status column so that we default it to some value on import
150
- if(!in_array('status',$this->_data_to_insert)){
151
- $this->_data_to_insert['status'] = 'status';
152
- }
153
- }
154
-
155
- /**
156
- * build the header of the import query
157
- * @return type
158
- */
159
- private function _get_import_query_header() {
160
- return 'INSERT IGNORE INTO [wysija]user (`' . implode('` ,`', $this->_data_to_insert) . '`,`created_at`) VALUES ';
161
- }
162
-
163
- /**
164
- *
165
- * @param type $array_csv
166
- */
167
- private function _check_duplicate_emails($array_csv) {
168
- // look for duplicate emails
169
- foreach ($array_csv as $keyline => $csv_line) {
170
- if (isset($csv_line[$this->_email_key])) {
171
- if (isset($this->_duplicate_emails_count[$csv_line[$this->_email_key]])) {
172
- $this->_duplicate_emails_count[$csv_line[$this->_email_key]]++;
173
- //$arra[$keyline]
174
- } else {
175
- $this->_duplicate_emails_count[$csv_line[$this->_email_key]] = 1;
176
- }
177
- } else {
178
- //if the record doesn't have the attribute email then we just ignore it
179
- $this->_ignored_row_count++;
180
- unset($array_csv[$keyline]);
181
- }
182
- }
183
- }
184
-
185
- /**
186
- * save new column/field match to improve usability the next time our admin
187
- * import a field with similar headers/columns names
188
- * @return boolean
189
- */
190
- private function _smart_column_match_recording() {
191
- if ($this->_first_row_is_data === false) {
192
- //save the importing fields to be able to match them the next time
193
- $import_fields = get_option('wysija_import_fields');
194
-
195
- foreach($this->_match as $csv_column_number => $column_in_user_table){
196
- if($column_in_user_table != 'nomatch') {
197
-
198
- // make a column name key
199
- $column_name_key = str_replace(array(' ','-','_'),'',strtolower($this->_header_row[$csv_column_number]));
200
- // fill in the array of "csv column name" / "user table column" matches
201
- $import_fields[$column_name_key] = $column_in_user_table;
202
-
203
- }
204
- }
205
-
206
- WYSIJA::update_option('wysija_import_fields' , $import_fields);
207
- return true;
208
- }
209
- return false;
210
- }
211
-
212
- /**
213
- * import a csv type into wysija's subscribers' table
214
- * @return type
215
- */
216
- public function import_subscribers() {
217
-
218
- // import the contacts
219
- // 1-check that a list is selected and that there is a csv file pasted
220
- // 2-save the list if necessary
221
- // 3-save the contacts and record them for each list selected
222
- $this->_loading_file_content();
223
- // convert the csv file to an array of lines
224
- $this->_csv_array = $this->_csv_to_array( $this->_csv_file_string , 0 , $this->_csv_data['fsep'] , $this->_csv_data['fenc']);
225
-
226
- // check what columns of the csv have been matched together with our subscribers' table
227
- $this->_match_columns_to_insert();
228
-
229
- $this->_header_row = array_map('trim', $this->_csv_array[0]);
230
-
231
- // we process the sql insertion 200 by 200 so that we are safe with the server's memory and cpu
232
- $csv_chunks = array_chunk($this->_csv_array, 200);
233
- $this->_csv_array = null;
234
- $this->_chunks_count = 0;
235
- $this->_lines_count = 0;
236
-
237
- // setting up a timeout value on the sql side to avoid timeout when importing a lot of data apparently.
238
- global $wpdb;
239
- $wpdb->query('set session wait_timeout=600');
240
-
241
- // loop and insert the data chunks by chunks
242
- foreach ($csv_chunks as $key_chunk => $csv_chunk) {
243
-
244
- $this->_check_duplicate_emails($csv_chunk);
245
-
246
- $result = $this->_import_rows($csv_chunk);
247
-
248
- if ($result !== false)
249
- $this->_chunks_count++;
250
- else {
251
- // there was an error we try 3 more times the same chunk and se how it goes
252
- $try = 0;
253
- while ($result === false && $try < 3) {
254
- $result = $this->_import_rows($csv_chunk);
255
- if ($result !== false) {
256
- $this->_chunks_count++;
257
- break;
258
- }
259
- $try++;
260
- }
261
-
262
- if ($result === false) {
263
- $this->error(__('There seems to be an error with the list you\'re trying to import.', WYSIJA), true);
264
- return false;
265
- }
266
- }
267
- // increment the lines count
268
- $this->_lines_count += $result;
269
- // free up some memory
270
- unset($csv_chunks[$key_chunk]);
271
- }
272
-
273
- // useful the next time we import a file with the same format
274
- $this->_smart_column_match_recording();
275
-
276
- // refresh the total count of users in wysija
277
- $helper_user = WYSIJA::get('user','helper');
278
- $helper_user->refreshUsers();
279
-
280
- // keep only the real duplicate emails unset the unique ones
281
- // TODO check that this email duplicate function could be a memory sink hole
282
- // especially that right now we don't use its value
283
- foreach ($this->_duplicate_emails_count as $email_address => $times_email_in_csv) {
284
- if ($times_email_in_csv == 1)
285
- unset($this->_duplicate_emails_count[$email_address]);
286
- }
287
-
288
- // how come we need to do that sometimes? how a lines count could become negative?
289
- if ($this->_lines_count < 0)
290
- $this->_lines_count = 0;
291
-
292
- // all of these numbers were useful at some point when we were showing more information after an import
293
- $this->_data_numbers['ignored'] = ($this->_data_numbers['valid_email_processed'] - $this->_data_numbers['inserted']);
294
- $this->_data_numbers['ignored_list'] = ( ($this->_data_numbers['list_user_ids'] * $this->_data_numbers['list_list_ids']) - $this->_data_numbers['list_added'] );
295
-
296
-
297
- return $this->_data_numbers;
298
- }
299
-
300
- public function get_duplicate_emails_count() {
301
- return $this->_duplicate_emails_count;
302
- }
303
-
304
- /**
305
- * convert a csv string to an array
306
- * @param type $csv_file_content
307
- * @param type $rows_to_read
308
- * @param type $delimiter
309
- * @param type $enclosure
310
- * @return array
311
- */
312
- private function _csv_to_array($csv_file_content, $rows_to_read = 0, $delimiter = ',', $enclosure = '') {
313
- $data = array();
314
-
315
- // the new way for splitting a string into an array of lines
316
- $csv_data_array = explode( $this->_line_delimiter, $csv_file_content );
317
-
318
- $i=1;
319
- foreach($csv_data_array as $csv_line){
320
- if($rows_to_read!=0 && $i> $rows_to_read) return $data;
321
-
322
- // str_getcsv only exists in php5 and is a faster and cleaner function than our csv_explode
323
- if (!function_exists('str_getcsv')) {
324
- $data[] = $this->_lines_explode($csv_line, $delimiter, $enclosure);
325
- } else {
326
- $data[] = str_getcsv($csv_line, $delimiter, $enclosure);
327
- }
328
-
329
- $i++;
330
- }
331
-
332
- return $data;
333
- }
334
-
335
- /**
336
- * explode lines to columns
337
- * @param type $csv_line
338
- * @param type $delimiter
339
- * @param type $enclose
340
- * @param type $preserve
341
- * @return type
342
- */
343
- private function _lines_explode($csv_line, $delimiter, $enclose, $preserve = false) {
344
- $resArr = array();
345
- $n = 0;
346
- if (empty($enclose)) {
347
- $resArr = explode($delimiter, $csv_line);
348
- } else {
349
- $expEncArr = explode($enclose, $csv_line);
350
- foreach ($expEncArr as $EncItem) {
351
- if ($n++ % 2) {
352
- array_push($resArr, array_pop($resArr) . ($preserve ? $enclose : '') . $EncItem . ( $preserve ? $enclose : ''));
353
- } else {
354
- $expDelArr = explode($delimiter, $EncItem);
355
- array_push($resArr, array_pop($resArr) . array_shift($expDelArr));
356
- $resArr = array_merge($resArr, $expDelArr);
357
- }
358
- }
359
- }
360
-
361
- return $resArr;
362
- }
363
-
364
- /**
365
- * function processing a chunk of a csv array to import it in the DB
366
- * @global object $wpdb
367
- * @param array $csv_chunk
368
- * @return boolean|string
369
- */
370
- private function _import_rows($csv_chunk) {
371
-
372
- global $wpdb;
373
-
374
- $this->_emails_inserted_in_current_chunk = array();
375
- $time = time();
376
- $lines = array();
377
- $lines_count = count($csv_chunk);
378
- $columns_count = count($this->_data_to_insert);
379
-
380
- $query = $this->_get_import_query_header();
381
-
382
- // make sure that each line has the right numbers of columns if it doesn't then we can skip it
383
- foreach ($csv_chunk as $k => $line) {
384
- if (!(count($line) >= (count($this->_data_to_insert) - 1))) {
385
- unset($csv_chunk[$k]);
386
- $lines_count--;
387
- }
388
- }
389
-
390
- $valid_email_processed = 0;
391
- $j = 1;
392
-
393
- foreach ($csv_chunk as $key_line => $line) {
394
-
395
- // if first row is not data but header then we just skip it only on the first chunk
396
- if ($this->_first_row_is_data === false && $j == 1 && $this->_chunks_count == 0) {
397
- $j++;
398
- continue;
399
- }
400
-
401
- $i = 1;
402
- $values = array();
403
-
404
- // TODO maybe we should check the value of the status column so that if we export a wysija's subscribers' list
405
- // and import it again in another site then we keep the status
406
- if (isset($this->_data_to_insert['status']))
407
- $line['status'] = 1;
408
-
409
- foreach ($line as $key_column => &$value_column) {
410
-
411
- // make sure this column is a column we want to insert in our DB
412
- if (isset($this->_data_to_insert[$key_column])) {
413
- $column_name = $this->_data_to_insert[$key_column];
414
- $original_value_column = $value_column;
415
- $value_column = $this->_validate_value($column_name, $value_column);
416
-
417
- // if it is a a date column, we convert it as a unixtimestamp
418
- if(isset($this->_custom_fields[$column_name]) && $this->_custom_fields[$column_name]->type == 'date'){
419
- $value_column = strtotime($value_column);
420
- }
421
-
422
- // this kind of result invalidates the whole row
423
- if ($value_column === false) {
424
- // record the invalid row and continue with the loop
425
- $this->_data_numbers['invalid'][] = $original_value_column;
426
- unset($csv_chunk[$key_line]);
427
- $lines_count--;
428
- continue 2;
429
- } else {
430
- // only if this is the email row we record an entry in the recorded emails and the email processed count
431
- if ($this->_email_key === $key_column) {
432
- $this->_emails_inserted_in_current_chunk[] = $value_column;
433
- $valid_email_processed++;
434
- }
435
- }
436
-
437
- // prepare the query
438
- $values[] = "'" . esc_sql($value_column, $wpdb->dbh) . "'";
439
- }
440
- }
441
-
442
- $values[] = $time;
443
- $lines[] .= "(" . implode(', ', $values) . ")";
444
- }
445
-
446
- $query .= implode(', ', $lines);
447
-
448
- // replace query to import the subscribers
449
- $model_wysija = new WYSIJA_model();
450
- $import_query = $model_wysija->query($query);
451
-
452
- $lines_count = $wpdb->rows_affected;
453
- $this->_data_numbers['inserted'] += $wpdb->rows_affected;
454
- $this->_data_numbers['valid_email_processed'] += $valid_email_processed;
455
-
456
- if ($import_query === false) {
457
- $this->error(__('Error when inserting emails.', WYSIJA), true);
458
- return false;
459
- }
460
- $time_now = time();
461
- $result_query_import_list = $this->_import_new_users_into_lists($time_now);
462
-
463
- $this->_trigger_active_autoresponders($time_now);
464
-
465
- if ($result_query_import_list === false) {
466
- $this->error(__('Error when inserting list.', WYSIJA), true);
467
- return false;
468
- }
469
-
470
- if ($import_query == 0)
471
- return '0';
472
-
473
- return $lines_count;
474
- }
475
-
476
- /**
477
- * used to validate or cast values before importing
478
- * TODO should we add a type for import of custom fields ?
479
- * Comment : Marco, feel free to modify entirely
480
- * @param type $column_name
481
- * @param type $value
482
- */
483
- function _validate_value($column_name, $value) {
484
- $value = trim($value);
485
-
486
- switch ($column_name) {
487
- case 'email':
488
- return is_email($value);
489
- break;
490
- case 'status':
491
-
492
- if (in_array(strtolower($value), array('subscribed', 'confirmed', 1, '1', 'true'))) {
493
- return 1;
494
- } elseif (in_array(strtolower($value), array('unsubscribed', -1, '-1', 'false'))) {
495
- return -1;
496
- } elseif (in_array(strtolower($value), array('unconfirmed', 0, '0'))) {
497
- return 0;
498
- }
499
- else
500
- return 1;
501
- break;
502
- default :
503
- return $value;
504
- }
505
- }
506
-
507
- /**
508
- * take care of active autoresponders retro-activity
509
- * @param type $time_now
510
- * @return boolean
511
- */
512
- private function _trigger_active_autoresponders($time_now) {
513
- $helper_email = WYSIJA::get('email', 'helper');
514
- $model_wysija = new WYSIJA_model();
515
-
516
- // list the active auto responders emails
517
- $active_autoresponders_per_list = $helper_email->get_active_follow_ups(array('email_id', 'params'), true);
518
-
519
- if (!empty($active_autoresponders_per_list)) {
520
- foreach ($_REQUEST['wysija']['user_list']['list'] as $list_id) {
521
- // checking if this list has a list of follow ups
522
- if (isset($active_autoresponders_per_list[$list_id])) {
523
- // for each follow up of that list we queu an email
524
- foreach ($active_autoresponders_per_list[$list_id] as $key_queue => $follow_up) {
525
- // insert query per active followup
526
- $query_queue = 'INSERT IGNORE INTO [wysija]queue (`email_id` ,`user_id`,`send_at`) ';
527
- $query_queue .= ' SELECT ' . $follow_up['email_id'] . ' , B.user_id , ' . ($time_now + $follow_up['delay']);
528
- $query_queue .= ' FROM [wysija]user_list as B';
529
- $query_queue .= ' WHERE B.list_id=' . (int) $list_id . ' AND sub_date=' . $time_now;
530
-
531
- $model_wysija->query($query_queue);
532
-
533
- $this->_data_numbers['emails_queued'] += $wpdb->rows_affected;
534
- }
535
- }
536
- }
537
- return true;
538
- }
539
- return false;
540
- }
541
-
542
- /**
543
- *
544
- * @global type $wpdb
545
- * @param type $time_now
546
- * @return type
547
- */
548
- private function _import_new_users_into_lists($time_now) {
549
- global $wpdb;
550
- $wpdb->rows_affected = 0;
551
- $model_wysija = new WYSIJA_model();
552
-
553
- $user_ids = $this->_get_imported_user_ids();
554
-
555
- // insert query per list
556
- $query = 'INSERT IGNORE INTO [wysija]user_list (`list_id` ,`user_id`,`sub_date`) VALUES ';
557
-
558
- foreach ($_REQUEST['wysija']['user_list']['list'] as $keyl => $list_id) {
559
- if (empty($list_id))
560
- continue;
561
- // for each list pre selected go through that process
562
- foreach ($user_ids as $key => $user_data) {
563
-
564
- // inserting each user id to this list
565
- $query.='(' . $list_id . ' , ' . $user_data['user_id'] . ' , ' . $time_now . ')';
566
-
567
- // if this is not the last row we put a comma for the next row
568
- if (count($user_ids) > ($key + 1)) {
569
- $query.=' , ';
570
- }
571
- }
572
-
573
- // if this is not the last row we put a comma for the next row
574
- if (count($_REQUEST['wysija']['user_list']['list']) > ($keyl + 1)) {
575
- $query.=',';
576
- }
577
- }
578
-
579
- $result_query = $model_wysija->query($query);
580
-
581
- $this->_data_numbers['list_added']+=$wpdb->rows_affected;
582
- $this->_data_numbers['list_user_ids']+=count($user_ids);
583
- return $result_query;
584
- }
585
-
586
- /**
587
- * get a list of user_ids freshly imported
588
- * @return type
589
- */
590
- private function _get_imported_user_ids() {
591
- $model_user = WYSIJA::get('user', 'model');
592
- // select query to get all of the ids of the emails that have just been inserted
593
- return $model_user->get(array('user_id'), array('email' => $this->_emails_inserted_in_current_chunk));
594
- }
595
-
596
-
597
- /**
598
- * this save a default list of column matching to ease the import process, this is done only the first time when the
599
- * field is not populated yet
600
- */
601
- private function _save_default_import_field_match(){
602
- $import_fields = get_option('wysija_import_fields');
603
- if (!$import_fields) {
604
- $import_fields = array(
605
- 'fname' => 'firstname',
606
- 'firstname' => 'firstname',
607
- 'prenom' => 'firstname',
608
- 'nom' => 'lastname',
609
- 'name' => 'lastname',
610
- 'lastname' => 'lastname',
611
- 'lname' => 'lastname',
612
- 'ipaddress' => 'ip',
613
- 'ip' => 'ip',
614
- 'addresseip' => 'ip',
615
- );
616
- WYSIJA::update_option('wysija_import_fields', $import_fields);
617
- }
618
- }
619
-
620
-
621
- /**
622
- * put the whole file or posted string into one string and clean up the string that may cause trouble during import
623
- * @return boolean
624
- */
625
- private function _get_csv_file_cleaned_up(){
626
- // is it a text import or a file import?
627
- if($_POST['wysija']['import']['type'] == 'copy'){
628
- if(!isset($_POST['wysija']['user_list']['csv'])){
629
- // memory limit has been reached
630
- $this->error(__('The list you\'ve pasted is too big for the browser. <strong>Upload the file</strong> instead.', WYSIJA), true);
631
- return false;
632
- }
633
- $this->_csv_file_string = trim(stripslashes($_POST['wysija']['user_list']['csv']));
634
-
635
- }else{
636
- // move_uploaded_file($_importfile, $destination);
637
- $this->_csv_file_string = trim(file_get_contents($_FILES['importfile']['tmp_name']));
638
- }
639
-
640
- $this->_csv_file_string = str_replace(array("\r", "\n\n", "\n\t\t\n\t\n\t\n\t\n", "\n\t\t\n\t\n\t\n", "\xEF\xBB\xBF", "\n\t\n", "\n(+1)"), array("\n", "\n", "\n ;", "\n", '', ';', ''), $this->_csv_file_string);
641
-
642
-
643
- // this might be gmail recipients(copy-paste from a gmail account) rare paste ...
644
- if(!preg_match_all('/<([a-z0-9_\'&\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,10})+>/i' , $this->_csv_file_string , $matches)){
645
- //return false;
646
- }else{
647
-
648
- if (substr($this->_csv_file_string, -1) != ",")
649
- $this->_csv_file_string = trim($this->_csv_file_string) . ',';
650
-
651
-
652
- if (count($matches[0]) == count($matches)) {
653
- //this is gmail simple paste
654
- $this->_csv_file_string = str_replace(array('>,', '<'), array("\n", ','), $this->_csv_file_string);
655
- }
656
- $this->_csv_file_string = trim($this->_csv_file_string);
657
- }
658
- }
659
-
660
-
661
- /**
662
- * try to figure out the format of that CSV file, which separators and enclosure strings does it use
663
- * @return boolean
664
- */
665
- private function _run_test_on_csv_file(){
666
- // try different set of enclosure and separator for the csv which can have different look depending on the data carried
667
- $field_separators_to_test = array( ',', ';', "\t" );
668
- $field_enclosers_to_test = array( '"', '' );
669
- $this->_csv_data['fsep'] = false;
670
- $this->_csv_data['fenc'] = '';
671
- $helper_user = WYSIJA::get('user','helper');
672
-
673
- foreach($field_enclosers_to_test as $enclosure){
674
- foreach($field_separators_to_test as $fsep){
675
-
676
- // testing different combinations of separator and enclosers
677
- $this->_csv_array = $this->_csv_to_array( $this->_csv_file_string, 10, $fsep, $enclosure );
678
-
679
- // make sure that our CSV has more than one row and that it has the same number of values in the first row and the second row
680
- if ( ( count( $this->_csv_array ) > 1 && count( $this->_csv_array[0] ) == count( $this->_csv_array[1] ) ) ) {
681
- if ( count( $this->_csv_array[0] ) > 1 || $helper_user->validEmail( trim( $this->_csv_array[0][0] ) ) || $helper_user->validEmail( trim( $this->_csv_array[1][0] ) ) ) {
682
- $this->_csv_data['fsep'] = $fsep;
683
- $this->_csv_data['fenc'] = $enclosure;
684
- break(2);
685
- }
686
- }
687
- }
688
- }
689
-
690
- // if we didn't manage to find a separator in that file then it is not a csv file and we come out
691
- if(empty($this->_csv_data['fsep'])){
692
- $this->notice( sprintf(
693
- "%s <a href='http://support.mailpoet.com/knowledgebase/importing-subscribers-with-a-csv-file/' target='_blank'>%s</a>",
694
- __("The data you are trying to import doesn't appear to be in the CSV format (Comma Separated Values).", WYSIJA),
695
- __("Read More", WYSIJA)
696
- ) );
697
- $this->notice(__('The first line of a CSV file should be the column headers : "email","lastname","firstname".',WYSIJA));
698
- $this->notice(__('The second line of a CSV file should be a set of values : "joeeg@example.com","Average","Joe".',WYSIJA));
699
-
700
- $this->notice(__('The two first lines of the file you\'ve uploaded are as follow:', WYSIJA));
701
-
702
- $arraylines = explode("\n", $this->_csv_file_string);
703
-
704
- if (empty($arraylines[0]))
705
- $text = __('Line is empty', WYSIJA);
706
- else
707
- $text = $arraylines[0];
708
- $this->notice('<strong>' . $text . '</strong>');
709
-
710
- if (empty($arraylines[1]))
711
- $text = __('Line is empty', WYSIJA);
712
- else
713
- $text = $arraylines[1];
714
- $this->notice('<strong>' . $text . '</strong>');
715
-
716
- return false;
717
- }
718
-
719
- // test the size of the file
720
- $temp_csv_array = $this->_csv_to_array($this->_csv_file_string, 0, $this->_csv_data['fsep'], $this->_csv_data['fenc']);
721
-
722
- $this->_data_result['totalrows'] = count($temp_csv_array);
723
- end($temp_csv_array);
724
- $this->_data_result['lastrow'] = current($temp_csv_array);
725
- }
726
-
727
-
728
- /**
729
- * save the CSV string into a file so that we can use it later in the next step of the process
730
- * @return boolean|string
731
- */
732
- private function _save_csv_file(){
733
- // try to make a wysija dir to save the import file
734
- $helper_file = WYSIJA::get('file', 'helper');
735
- $result_dir = $helper_file->makeDir('import');
736
- if (!$result_dir) {
737
- return false;
738
- }
739
-
740
- $file_name = 'import-' . time() . '.csv';
741
- $handle = fopen($result_dir . $file_name, 'w');
742
- fwrite($handle, $this->_csv_file_string);
743
- fclose($handle);
744
-
745
- return $file_name;
746
- }
747
-
748
-
749
- /**
750
- * detect which column is an email one
751
- */
752
- private function _test_csv_emails(){
753
- $found_email = 0;
754
- $this->_email_key = array();
755
- $helper_user = WYSIJA::get('user', 'helper');
756
- foreach ($this->_csv_array as $csv_row) {
757
- foreach ($csv_row as $key_column => $value_column) {
758
- if ($helper_user->validEmail(trim($value_column))) {
759
- $found_email++;
760
-
761
- $this->_email_key[$key_column] = $this->_csv_array[0][$key_column];
762
- }
763
- }
764
- }
765
-
766
- $this->_data_result['errormatch'] = false;
767
- $check_again = __('Check again what you\'re trying to import.',WYSIJA);
768
- if (($found_email < 1)) {
769
- $this->error(__('We couldn\'t find any valid addresses in the first 10 rows.', WYSIJA).' '.$check_again, true);
770
- }
771
-
772
- if ((count($this->_csv_array) < 2)) {
773
- $this->error(__('You\'re import file is not valid.', WYSIJA).' '.$check_again, true);
774
- }
775
- }
776
-
777
-
778
- /**
779
- * function used to scan the CSV before trying to match each column with our own fields
780
- * @return boolean
781
- */
782
- public function scan_csv_file(){
783
- $this->_data_result = array();
784
-
785
- // make sure the import match will be as easy as possible with default matches
786
- if( $this->_save_default_import_field_match() === false) return false;
787
- // get the csv into a string and check for messy email address etc
788
- if( $this->_get_csv_file_cleaned_up() === false) return false;
789
- // find out the format of that CSV file comma semi colon etc ..
790
- if( $this->_run_test_on_csv_file() === false) return false;
791
-
792
- // save the string into a file for later use
793
- $file_name = $this->_save_csv_file();
794
- if ($file_name === false)
795
- return false;
796
-
797
- // look for the email column
798
- $this->_test_csv_emails();
799
-
800
- // stock the data we will use in the next page
801
- $this->_data_result['csv'] = $this->_csv_array;
802
-
803
- $data_import = array(
804
- 'csv' => $file_name,
805
- 'fsep' => $this->_csv_data['fsep'],
806
- 'fenc' => $this->_csv_data['fenc']);
807
- $this->_data_result['dataImport'] = base64_encode(serialize($data_import));
808
-
809
- $this->_data_result['keyemail'] = $this->_email_key;
810
-
811
- //test if the first row is data or not
812
- //test the email column
813
- foreach ($this->_data_result['keyemail'] as $k)
814
- $this->_email_key = $k;
815
-
816
-
817
- // test whether the first row is a data row or is a descriptive header row
818
- $helper_user = WYSIJA::get('user','helper');
819
- if($helper_user->validEmail( $this->_email_key )){
820
- $this->_data_result['firstrowisdata']=true;
821
- }else{
822
- $this->_data_result['totalrows']--;
823
- }
824
-
825
- return $this->_data_result;
826
- }
827
 
828
  }
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /**
4
  * Class Import.
5
  *
7
  */
8
  class WJ_Import extends WYSIJA_object {
9
 
10
+ private $_header_row = array();
11
+ private $_csv_data = array();
12
+ private $_match = array();
13
+ private $_ignore_invalid_date = array(); // specific for date fields
14
+ private $_custom_fields = array();
15
+ private $_email_key = '';
16
+ private $_data_to_insert = array();
17
+ private $_number_list = 0;
18
+ private $_data_numbers = array();
19
+ private $_line_delimiter = "\n";
20
+ private $_duplicate_emails_count = array(); // detect the emails that are duplicates in the import file
21
+ private $_csv_array = array(); // containing the csv into an array
22
+ private $_ignored_row_count = 0; // the count of rows we ignore because there was no valid email present
23
+ private $_lines_count = 0; // count the number of valid lines inserted in the DB
24
+ private $_chunks_count = 0; // number of chunks we chopped from the csv
25
+ private $_first_row_is_data = false; // means that there is no header on that csv file
26
+ private $_emails_inserted_in_current_chunk = array(); // array of emails
27
+ private $_csv_file_string = '';
28
+ private $_data_result = array(); // used for importmatch refactor
29
+ private $_regex_new_field = "/^new_field\|([^\|]+)\|(.+)$/i";
30
+
31
+ function __construct() {
32
+ if (!empty($_POST['wysija']['match']))
33
+ $this->_match = $_POST['wysija']['match'];
34
+ if (!empty($_POST['wysija']['ignore_invalid_date']))
35
+ $this->_ignore_invalid_date = $_POST['wysija']['ignore_invalid_date'];
36
+ if (!empty($_REQUEST['wysija']['user_list']['list']))
37
+ $this->_number_list = count($_REQUEST['wysija']['user_list']['list']);
38
+ if (!empty($_POST['firstrowisdata']))
39
+ $this->_first_row_is_data = true;
40
+ $this->_data_numbers = array('invalid' => array(), 'inserted' => 0, 'valid_email_processed' => 0, 'list_added' => 0, 'list_user_ids' => 0, 'list_list_ids' => $this->_number_list, 'emails_queued' => 0);
41
+ }
42
+
43
+ /**
44
+ * loading file data passed in a global variable
45
+ * @return type
46
+ */
47
+ private function _get_temp_file_info() {
48
+ if (!empty($_REQUEST['wysija']['dataImport']))
49
+ return unserialize(base64_decode($_REQUEST['wysija']['dataImport']));
50
+ }
51
+
52
+ /**
53
+ * loading the file based on global parameters
54
+ * @return string
55
+ */
56
+ private function _loading_file_content() {
57
+ // try to access the temporary file created in the previous step
58
+ $this->_csv_data = $this->_get_temp_file_info();
59
+
60
+ $helper_file = WYSIJA::get('file', 'helper');
61
+ $result_file = $helper_file->get($this->_csv_data['csv'], 'import');
62
+
63
+ if (!$result_file) {
64
+ $upload_dir = wp_upload_dir();
65
+ $this->error(sprintf(__('Cannot access CSV file. Verify access rights to this directory "%1$s"', WYSIJA), $upload_dir['basedir']), true);
66
+ return false;
67
+ }
68
+
69
+ // get the temp csv file
70
+ $this->_csv_file_string = file_get_contents($result_file);
71
+ }
72
+
73
+ private function _set_custom_fields(){
74
+ $WJ_Field = new WJ_Field();
75
+ $_custom_fields = $WJ_Field->get_all();
76
+
77
+ if(!empty($_custom_fields)){
78
+ foreach($_custom_fields as $key => &$row){
79
+ $this->_custom_fields['cf_'.$row->id] = $row;
80
+ }
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Validate if a column is already matched previously
86
+ * @param string $column_name
87
+ * @return boolean
88
+ */
89
+ private function _is_column_matched($column_name) {
90
  if (empty($this->_data_to_insert)) {
91
+ return false;
92
  }
93
  $column_names = array_values($this->_data_to_insert);
94
  return in_array(trim($column_name), $column_names);
95
+ }
96
+ /**
97
+ * match columns together with the csv data based on the data passed
98
+ */
99
+ private function _match_columns_to_insert() {
100
+
101
+ // we're going through all of the selected value in each dropdown when importing
102
+ foreach($this->_match as $csv_column_number => $column_in_user_table){
103
+ // Reduce matching twice the same column
104
+ if ($this->_is_column_matched($column_in_user_table))
105
+ continue;
106
+
107
+ // Ignore `nomatch` columns
108
+ if ($column_in_user_table == 'nomatch')
109
+ continue;
110
+
111
+ // Check if maybe it's a new field
112
+ preg_match($this->_regex_new_field, $column_in_user_table, $maybe_newfield);
113
+ if ( !empty($maybe_newfield) && in_array($maybe_newfield[1], array('date', 'input')) ){
114
+ // TODO need to change to WJ_Field I guess when Marco is done moving the files
115
+ // saving a new custom field
116
+ $custom_field = new WJ_Field();
117
+
118
+ $custom_field->set(array(
119
+ 'name' => $maybe_newfield[2],
120
+ 'type' => $maybe_newfield[1],
121
+ 'required' => false,
122
+ 'settings' => array(
123
+ 'label' => $maybe_newfield[2],
124
+ )
125
+ ));
126
+
127
+ $custom_field->save();
128
+
129
+ // this is the column name in the database so this is where we need to import that field
130
+ $column_in_user_table = $custom_field->user_column_name();
131
+ $this->_match[$csv_column_number] = $column_in_user_table;
132
+ }
133
+
134
+ // keep the match of CSV column number to column key in our database
135
+ // not sure why do we trim the column key ...
136
+ $this->_data_to_insert[$csv_column_number] = trim($column_in_user_table);
137
+
138
+ // this column is the email column, let's keep track of it for later validation etc..
139
+ if($column_in_user_table == 'email'){
140
+ $this->_email_key = $csv_column_number;
141
+ }
142
+ }
143
+
144
+ $this->_set_custom_fields();
145
+
146
+ // if the status column is not matched, we make sure that we have an entry for the status column so that we default it to some value on import
147
+ if(!in_array('status',$this->_data_to_insert)){
148
+ $this->_data_to_insert['status'] = 'status';
149
+ }
150
+ }
151
+
152
+ /**
153
+ * build the header of the import query
154
+ * @return type
155
+ */
156
+ private function _get_import_query_header() {
157
+ return 'INSERT IGNORE INTO [wysija]user (`' . implode('` ,`', $this->_data_to_insert) . '`,`created_at`) VALUES ';
158
+ }
159
+
160
+ /**
161
+ *
162
+ * @param type $array_csv
163
+ */
164
+ private function _check_duplicate_emails($array_csv) {
165
+ // look for duplicate emails
166
+ foreach ($array_csv as $keyline => $csv_line) {
167
+ if (isset($csv_line[$this->_email_key])) {
168
+ if (isset($this->_duplicate_emails_count[$csv_line[$this->_email_key]])) {
169
+ $this->_duplicate_emails_count[$csv_line[$this->_email_key]]++;
170
+ //$arra[$keyline]
171
+ } else {
172
+ $this->_duplicate_emails_count[$csv_line[$this->_email_key]] = 1;
173
+ }
174
+ } else {
175
+ //if the record doesn't have the attribute email then we just ignore it
176
+ $this->_ignored_row_count++;
177
+ unset($array_csv[$keyline]);
178
+ }
179
+ }
180
+ }
181
+
182
+ /**
183
+ * save new column/field match to improve usability the next time our admin
184
+ * import a field with similar headers/columns names
185
+ * @return boolean
186
+ */
187
+ private function _smart_column_match_recording() {
188
+ if ($this->_first_row_is_data === false) {
189
+ //save the importing fields to be able to match them the next time
190
+ $import_fields = get_option('wysija_import_fields');
191
+
192
+ foreach($this->_match as $csv_column_number => $column_in_user_table){
193
+ if($column_in_user_table != 'nomatch') {
194
+
195
+ // make a column name key
196
+ $column_name_key = str_replace(array(' ','-','_'),'',strtolower($this->_header_row[$csv_column_number]));
197
+ // fill in the array of "csv column name" / "user table column" matches
198
+ $import_fields[$column_name_key] = $column_in_user_table;
199
+
200
+ }
201
+ }
202
+
203
+ WYSIJA::update_option('wysija_import_fields' , $import_fields);
204
+ return true;
205
+ }
206
+ return false;
207
+ }
208
+
209
+ /**
210
+ * import a csv type into wysija's subscribers' table
211
+ * @return type
212
+ */
213
+ public function import_subscribers() {
214
+
215
+ // import the contacts
216
+ // 1-check that a list is selected and that there is a csv file pasted
217
+ // 2-save the list if necessary
218
+ // 3-save the contacts and record them for each list selected
219
+ $this->_loading_file_content();
220
+ // convert the csv file to an array of lines
221
+ $this->_csv_array = $this->_csv_to_array( $this->_csv_file_string , 0 , $this->_csv_data['fsep'] , $this->_csv_data['fenc']);
222
+
223
+ // check what columns of the csv have been matched together with our subscribers' table
224
+ $this->_match_columns_to_insert();
225
+
226
+ $this->_header_row = array_map('trim', $this->_csv_array[0]);
227
+
228
+ // we process the sql insertion 200 by 200 so that we are safe with the server's memory and cpu
229
+ $csv_chunks = array_chunk($this->_csv_array, 200);
230
+ $this->_csv_array = null;
231
+ $this->_chunks_count = 0;
232
+ $this->_lines_count = 0;
233
+
234
+ // setting up a timeout value on the sql side to avoid timeout when importing a lot of data apparently.
235
+ global $wpdb;
236
+ $wpdb->query('set session wait_timeout=600');
237
+
238
+ // loop and insert the data chunks by chunks
239
+ foreach ($csv_chunks as $key_chunk => $csv_chunk) {
240
+
241
+ $this->_check_duplicate_emails($csv_chunk);
242
+
243
+ $result = $this->_import_rows($csv_chunk);
244
+
245
+ if ($result !== false)
246
+ $this->_chunks_count++;
247
+ else {
248
+ // there was an error we try 3 more times the same chunk and se how it goes
249
+ $try = 0;
250
+ while ($result === false && $try < 3) {
251
+ $result = $this->_import_rows($csv_chunk);
252
+ if ($result !== false) {
253
+ $this->_chunks_count++;
254
+ break;
255
+ }
256
+ $try++;
257
+ }
258
+
259
+ if ($result === false) {
260
+ $this->error(__('There seems to be an error with the list you\'re trying to import.', WYSIJA), true);
261
+ return false;
262
+ }
263
+ }
264
+ // increment the lines count
265
+ $this->_lines_count += $result;
266
+ // free up some memory
267
+ unset($csv_chunks[$key_chunk]);
268
+ }
269
+
270
+ // useful the next time we import a file with the same format
271
+ $this->_smart_column_match_recording();
272
+
273
+ // refresh the total count of users in wysija
274
+ $helper_user = WYSIJA::get('user','helper');
275
+ $helper_user->refreshUsers();
276
+
277
+ // keep only the real duplicate emails unset the unique ones
278
+ // TODO check that this email duplicate function could be a memory sink hole
279
+ // especially that right now we don't use its value
280
+ foreach ($this->_duplicate_emails_count as $email_address => $times_email_in_csv) {
281
+ if ($times_email_in_csv == 1)
282
+ unset($this->_duplicate_emails_count[$email_address]);
283
+ }
284
+
285
+ // how come we need to do that sometimes? how a lines count could become negative?
286
+ if ($this->_lines_count < 0)
287
+ $this->_lines_count = 0;
288
+
289
+ // all of these numbers were useful at some point when we were showing more information after an import
290
+ $this->_data_numbers['ignored'] = ($this->_data_numbers['valid_email_processed'] - $this->_data_numbers['inserted']);
291
+ $this->_data_numbers['ignored_list'] = ( ($this->_data_numbers['list_user_ids'] * $this->_data_numbers['list_list_ids']) - $this->_data_numbers['list_added'] );
292
+
293
+
294
+ return $this->_data_numbers;
295
+ }
296
+
297
+ public function get_duplicate_emails_count() {
298
+ return $this->_duplicate_emails_count;
299
+ }
300
+
301
+ /**
302
+ * convert a csv string to an array
303
+ * @param type $csv_file_content
304
+ * @param type $rows_to_read
305
+ * @param type $delimiter
306
+ * @param type $enclosure
307
+ * @return array
308
+ */
309
+ private function _csv_to_array($csv_file_content, $rows_to_read = 0, $delimiter = ',', $enclosure = '') {
310
+ $data = array();
311
+
312
+ // the new way for splitting a string into an array of lines
313
+ $csv_data_array = explode( $this->_line_delimiter, $csv_file_content );
314
+
315
+ $i=1;
316
+ foreach($csv_data_array as $csv_line){
317
+ if($rows_to_read!=0 && $i> $rows_to_read) return $data;
318
+
319
+ // str_getcsv only exists in php5 and is a faster and cleaner function than our csv_explode
320
+ if (!function_exists('str_getcsv')) {
321
+ $data[] = $this->_lines_explode($csv_line, $delimiter, $enclosure);
322
+ } else {
323
+ $data[] = str_getcsv($csv_line, $delimiter, $enclosure);
324
+ }
325
+
326
+ $i++;
327
+ }
328
+
329
+ return $data;
330
+ }
331
+
332
+ /**
333
+ * explode lines to columns
334
+ * @param type $csv_line
335
+ * @param type $delimiter
336
+ * @param type $enclose
337
+ * @param type $preserve
338
+ * @return type
339
+ */
340
+ private function _lines_explode($csv_line, $delimiter, $enclose, $preserve = false) {
341
+ $resArr = array();
342
+ $n = 0;
343
+ if (empty($enclose)) {
344
+ $resArr = explode($delimiter, $csv_line);
345
+ } else {
346
+ $expEncArr = explode($enclose, $csv_line);
347
+ foreach ($expEncArr as $EncItem) {
348
+ if ($n++ % 2) {
349
+ array_push($resArr, array_pop($resArr) . ($preserve ? $enclose : '') . $EncItem . ( $preserve ? $enclose : ''));
350
+ } else {
351
+ $expDelArr = explode($delimiter, $EncItem);
352
+ array_push($resArr, array_pop($resArr) . array_shift($expDelArr));
353
+ $resArr = array_merge($resArr, $expDelArr);
354
+ }
355
+ }
356
+ }
357
+
358
+ return $resArr;
359
+ }
360
+
361
+ /**
362
+ * function processing a chunk of a csv array to import it in the DB
363
+ * @global object $wpdb
364
+ * @param array $csv_chunk
365
+ * @return boolean|string
366
+ */
367
+ private function _import_rows($csv_chunk) {
368
+
369
+ global $wpdb;
370
+
371
+ $this->_emails_inserted_in_current_chunk = array();
372
+ $time = time();
373
+ $lines = array();
374
+ $lines_count = count($csv_chunk);
375
+ $columns_count = count($this->_data_to_insert);
376
+
377
+ $query = $this->_get_import_query_header();
378
+
379
+ // make sure that each line has the right numbers of columns if it doesn't then we can skip it
380
+ foreach ($csv_chunk as $k => $line) {
381
+ if (!(count($line) >= (count($this->_data_to_insert) - 1))) {
382
+ unset($csv_chunk[$k]);
383
+ $lines_count--;
384
+ }
385
+ }
386
+
387
+ $valid_email_processed = 0;
388
+ $j = 1;
389
+
390
+ foreach ($csv_chunk as $key_line => $line) {
391
+
392
+ // if first row is not data but header then we just skip it only on the first chunk
393
+ if ($this->_first_row_is_data === false && $j == 1 && $this->_chunks_count == 0) {
394
+ $j++;
395
+ continue;
396
+ }
397
+
398
+ $i = 1;
399
+ $values = array();
400
+
401
+ // TODO maybe we should check the value of the status column so that if we export a wysija's subscribers' list
402
+ // and import it again in another site then we keep the status
403
+ if (isset($this->_data_to_insert['status']))
404
+ $line['status'] = 1;
405
+
406
+ foreach ($line as $key_column => &$value_column) {
407
+
408
+ // make sure this column is a column we want to insert in our DB
409
+ if (isset($this->_data_to_insert[$key_column])) {
410
+ $column_name = $this->_data_to_insert[$key_column];
411
+ $original_value_column = $value_column;
412
+ $value_column = $this->_validate_value($column_name, $value_column);
413
+
414
+ // if it is a a date column, we convert it as a unixtimestamp
415
+ if(isset($this->_custom_fields[$column_name]) && $this->_custom_fields[$column_name]->type == 'date'){
416
+ $value_column = strtotime($value_column);
417
+ }
418
+
419
+ // this kind of result invalidates the whole row
420
+ if ($value_column === false) {
421
+ // record the invalid row and continue with the loop
422
+ $this->_data_numbers['invalid'][] = $original_value_column;
423
+ unset($csv_chunk[$key_line]);
424
+ $lines_count--;
425
+ continue 2;
426
+ } else {
427
+ // only if this is the email row we record an entry in the recorded emails and the email processed count
428
+ if ($this->_email_key === $key_column) {
429
+ $this->_emails_inserted_in_current_chunk[] = $value_column;
430
+ $valid_email_processed++;
431
+ }
432
+ }
433
+
434
+ // prepare the query
435
+ $values[] = "'" . esc_sql($value_column, $wpdb->dbh) . "'";
436
+ }
437
+ }
438
+
439
+ $values[] = $time;
440
+ $lines[] .= "(" . implode(', ', $values) . ")";
441
+ }
442
+
443
+ $query .= implode(', ', $lines);
444
+
445
+ // replace query to import the subscribers
446
+ $model_wysija = new WYSIJA_model();
447
+ $import_query = $model_wysija->query($query);
448
+
449
+ $lines_count = $wpdb->rows_affected;
450
+ $this->_data_numbers['inserted'] += $wpdb->rows_affected;
451
+ $this->_data_numbers['valid_email_processed'] += $valid_email_processed;
452
+
453
+ if ($import_query === false) {
454
+ $this->error(__('Error when inserting emails.', WYSIJA), true);
455
+ return false;
456
+ }
457
+ $time_now = time();
458
+ $result_query_import_list = $this->_import_new_users_into_lists($time_now);
459
+
460
+ $this->_trigger_active_autoresponders($time_now);
461
+
462
+ if ($result_query_import_list === false) {
463
+ $this->error(__('Error when inserting list.', WYSIJA), true);
464
+ return false;
465
+ }
466
+
467
+ if ($import_query == 0)
468
+ return '0';
469
+
470
+ return $lines_count;
471
+ }
472
+
473
+ /**
474
+ * used to validate or cast values before importing
475
+ * TODO should we add a type for import of custom fields ?
476
+ * Comment : Marco, feel free to modify entirely
477
+ * @param type $column_name
478
+ * @param type $value
479
+ */
480
+ function _validate_value($column_name, $value) {
481
+ $value = trim($value);
482
+
483
+ switch ($column_name) {
484
+ case 'email':
485
+ return is_email($value);
486
+ break;
487
+ case 'status':
488
+
489
+ if (in_array(strtolower($value), array('subscribed', 'confirmed', 1, '1', 'true'))) {
490
+ return 1;
491
+ } elseif (in_array(strtolower($value), array('unsubscribed', -1, '-1', 'false'))) {
492
+ return -1;
493
+ } elseif (in_array(strtolower($value), array('unconfirmed', 0, '0'))) {
494
+ return 0;
495
+ }
496
+ else
497
+ return 1;
498
+ break;
499
+ default :
500
+ return $value;
501
+ }
502
+ }
503
+
504
+ /**
505
+ * take care of active autoresponders retro-activity
506
+ * @param type $time_now
507
+ * @return boolean
508
+ */
509
+ private function _trigger_active_autoresponders($time_now) {
510
+ $helper_email = WYSIJA::get('email', 'helper');
511
+ $model_wysija = new WYSIJA_model();
512
+
513
+ // list the active auto responders emails
514
+ $active_autoresponders_per_list = $helper_email->get_active_follow_ups(array('email_id', 'params'), true);
515
+
516
+ if (!empty($active_autoresponders_per_list)) {
517
+ foreach ($_REQUEST['wysija']['user_list']['list'] as $list_id) {
518
+ // checking if this list has a list of follow ups
519
+ if (isset($active_autoresponders_per_list[$list_id])) {
520
+ // for each follow up of that list we queu an email
521
+ foreach ($active_autoresponders_per_list[$list_id] as $key_queue => $follow_up) {
522
+ // insert query per active followup
523
+ $query_queue = 'INSERT IGNORE INTO [wysija]queue (`email_id` ,`user_id`,`send_at`) ';
524
+ $query_queue .= ' SELECT ' . $follow_up['email_id'] . ' , B.user_id , ' . ($time_now + $follow_up['delay']);
525
+ $query_queue .= ' FROM [wysija]user_list as B';
526
+ $query_queue .= ' WHERE B.list_id=' . (int) $list_id . ' AND sub_date=' . $time_now;
527
+
528
+ $model_wysija->query($query_queue);
529
+
530
+ $this->_data_numbers['emails_queued'] += $wpdb->rows_affected;
531
+ }
532
+ }
533
+ }
534
+ return true;
535
+ }
536
+ return false;
537
+ }
538
+
539
+ /**
540
+ *
541
+ * @global type $wpdb
542
+ * @param type $time_now
543
+ * @return type
544
+ */
545
+ private function _import_new_users_into_lists($time_now) {
546
+ global $wpdb;
547
+ $wpdb->rows_affected = 0;
548
+ $model_wysija = new WYSIJA_model();
549
+
550
+ $user_ids = $this->_get_imported_user_ids();
551
+
552
+ // insert query per list
553
+ $query = 'INSERT IGNORE INTO [wysija]user_list (`list_id` ,`user_id`,`sub_date`) VALUES ';
554
+
555
+ foreach ($_REQUEST['wysija']['user_list']['list'] as $keyl => $list_id) {
556
+ if (empty($list_id))
557
+ continue;
558
+ // for each list pre selected go through that process
559
+ foreach ($user_ids as $key => $user_data) {
560
+
561
+ // inserting each user id to this list
562
+ $query.='(' . $list_id . ' , ' . $user_data['user_id'] . ' , ' . $time_now . ')';
563
+
564
+ // if this is not the last row we put a comma for the next row
565
+ if (count($user_ids) > ($key + 1)) {
566
+ $query.=' , ';
567
+ }
568
+ }
569
+
570
+ // if this is not the last row we put a comma for the next row
571
+ if (count($_REQUEST['wysija']['user_list']['list']) > ($keyl + 1)) {
572
+ $query.=',';
573
+ }
574
+ }
575
+
576
+ $result_query = $model_wysija->query($query);
577
+
578
+ $this->_data_numbers['list_added']+=$wpdb->rows_affected;
579
+ $this->_data_numbers['list_user_ids']+=count($user_ids);
580
+ return $result_query;
581
+ }
582
+
583
+ /**
584
+ * get a list of user_ids freshly imported
585
+ * @return type
586
+ */
587
+ private function _get_imported_user_ids() {
588
+ $model_user = WYSIJA::get('user', 'model');
589
+ // select query to get all of the ids of the emails that have just been inserted
590
+ return $model_user->get(array('user_id'), array('email' => $this->_emails_inserted_in_current_chunk));
591
+ }
592
+
593
+
594
+ /**
595
+ * this save a default list of column matching to ease the import process, this is done only the first time when the
596
+ * field is not populated yet
597
+ */
598
+ private function _save_default_import_field_match(){
599
+ $import_fields = get_option('wysija_import_fields');
600
+ if (!$import_fields) {
601
+ $import_fields = array(
602
+ 'fname' => 'firstname',
603
+ 'firstname' => 'firstname',
604
+ 'prenom' => 'firstname',
605
+ 'nom' => 'lastname',
606
+ 'name' => 'lastname',
607
+ 'lastname' => 'lastname',
608
+ 'lname' => 'lastname',
609
+ 'ipaddress' => 'ip',
610
+ 'ip' => 'ip',
611
+ 'addresseip' => 'ip',
612
+ );
613
+ WYSIJA::update_option('wysija_import_fields', $import_fields);
614
+ }
615
+ }
616
+
617
+
618
+ /**
619
+ * put the whole file or posted string into one string and clean up the string that may cause trouble during import
620
+ * @return boolean
621
+ */
622
+ private function _get_csv_file_cleaned_up(){
623
+ // is it a text import or a file import?
624
+ if($_POST['wysija']['import']['type'] == 'copy'){
625
+ if(!isset($_POST['wysija']['user_list']['csv'])){
626
+ // memory limit has been reached
627
+ $this->error(__('The list you\'ve pasted is too big for the browser. <strong>Upload the file</strong> instead.', WYSIJA), true);
628
+ return false;
629
+ }
630
+ $this->_csv_file_string = trim(stripslashes($_POST['wysija']['user_list']['csv']));
631
+
632
+ }else{
633
+ // move_uploaded_file($_importfile, $destination);
634
+ $this->_csv_file_string = trim(file_get_contents($_FILES['importfile']['tmp_name']));
635
+ }
636
+
637
+ $this->_csv_file_string = str_replace(array("\r", "\n\n", "\n\t\t\n\t\n\t\n\t\n", "\n\t\t\n\t\n\t\n", "\xEF\xBB\xBF", "\n\t\n", "\n(+1)"), array("\n", "\n", "\n ;", "\n", '', ';', ''), $this->_csv_file_string);
638
+
639
+
640
+ // this might be gmail recipients(copy-paste from a gmail account) rare paste ...
641
+ if(!preg_match_all('/<([a-z0-9_\'&\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,10})+>/i' , $this->_csv_file_string , $matches)){
642
+ //return false;
643
+ }else{
644
+
645
+ if (substr($this->_csv_file_string, -1) != ",")
646
+ $this->_csv_file_string = trim($this->_csv_file_string) . ',';
647
+
648
+
649
+ if (count($matches[0]) == count($matches)) {
650
+ //this is gmail simple paste
651
+ $this->_csv_file_string = str_replace(array('>,', '<'), array("\n", ','), $this->_csv_file_string);
652
+ }
653
+ $this->_csv_file_string = trim($this->_csv_file_string);
654
+ }
655
+ }
656
+
657
+
658
+ /**
659
+ * try to figure out the format of that CSV file, which separators and enclosure strings does it use
660
+ * @return boolean
661
+ */
662
+ private function _run_test_on_csv_file(){
663
+ // try different set of enclosure and separator for the csv which can have different look depending on the data carried
664
+ $field_separators_to_test = array( ',', ';', "\t" );
665
+ $field_enclosers_to_test = array( '"', '' );
666
+ $this->_csv_data['fsep'] = false;
667
+ $this->_csv_data['fenc'] = '';
668
+ $helper_user = WYSIJA::get('user','helper');
669
+
670
+ foreach($field_enclosers_to_test as $enclosure){
671
+ foreach($field_separators_to_test as $fsep){
672
+
673
+ // testing different combinations of separator and enclosers
674
+ $this->_csv_array = $this->_csv_to_array( $this->_csv_file_string, 10, $fsep, $enclosure );
675
+
676
+ // make sure that our CSV has more than one row and that it has the same number of values in the first row and the second row
677
+ if ( ( count( $this->_csv_array ) > 1 && count( $this->_csv_array[0] ) == count( $this->_csv_array[1] ) ) ) {
678
+ if ( count( $this->_csv_array[0] ) > 1 || $helper_user->validEmail( trim( $this->_csv_array[0][0] ) ) || $helper_user->validEmail( trim( $this->_csv_array[1][0] ) ) ) {
679
+ $this->_csv_data['fsep'] = $fsep;
680
+ $this->_csv_data['fenc'] = $enclosure;
681
+ break(2);
682
+ }
683
+ }
684
+ }
685
+ }
686
+
687
+ // if we didn't manage to find a separator in that file then it is not a csv file and we come out
688
+ if(empty($this->_csv_data['fsep'])){
689
+ $this->notice( sprintf(
690
+ "%s <a href='http://support.mailpoet.com/knowledgebase/importing-subscribers-with-a-csv-file/' target='_blank'>%s</a>",
691
+ __("The data you are trying to import doesn't appear to be in the CSV format (Comma Separated Values).", WYSIJA),
692
+ __("Read More", WYSIJA)
693
+ ) );
694
+ $this->notice(__('The first line of a CSV file should be the column headers : "email","lastname","firstname".',WYSIJA));
695
+ $this->notice(__('The second line of a CSV file should be a set of values : "joeeg@example.com","Average","Joe".',WYSIJA));
696
+
697
+ $this->notice(__('The two first lines of the file you\'ve uploaded are as follow:', WYSIJA));
698
+
699
+ $arraylines = explode("\n", $this->_csv_file_string);
700
+
701
+ if (empty($arraylines[0]))
702
+ $text = __('Line is empty', WYSIJA);
703
+ else
704
+ $text = $arraylines[0];
705
+ $this->notice('<strong>' . $text . '</strong>');
706
+
707
+ if (empty($arraylines[1]))
708
+ $text = __('Line is empty', WYSIJA);
709
+ else
710
+ $text = $arraylines[1];
711
+ $this->notice('<strong>' . $text . '</strong>');
712
+
713
+ return false;
714
+ }
715
+
716
+ // test the size of the file
717
+ $temp_csv_array = $this->_csv_to_array($this->_csv_file_string, 0, $this->_csv_data['fsep'], $this->_csv_data['fenc']);
718
+
719
+ $this->_data_result['totalrows'] = count($temp_csv_array);
720
+ end($temp_csv_array);
721
+ $this->_data_result['lastrow'] = current($temp_csv_array);
722
+ }
723
+
724
+
725
+ /**
726
+ * save the CSV string into a file so that we can use it later in the next step of the process
727
+ * @return boolean|string
728
+ */
729
+ private function _save_csv_file(){
730
+ // try to make a wysija dir to save the import file
731
+ $helper_file = WYSIJA::get('file', 'helper');
732
+ $result_dir = $helper_file->makeDir('import');
733
+ if (!$result_dir) {
734
+ return false;
735
+ }
736
+
737
+ $file_name = 'import-' . time() . '.csv';
738
+ $handle = fopen($result_dir . $file_name, 'w');
739
+ fwrite($handle, $this->_csv_file_string);
740
+ fclose($handle);
741
+
742
+ return $file_name;
743
+ }
744
+
745
+
746
+ /**
747
+ * detect which column is an email one
748
+ */
749
+ private function _test_csv_emails(){
750
+ $found_email = 0;
751
+ $this->_email_key = array();
752
+ $helper_user = WYSIJA::get('user', 'helper');
753
+ foreach ($this->_csv_array as $csv_row) {
754
+ foreach ($csv_row as $key_column => $value_column) {
755
+ if ($helper_user->validEmail(trim($value_column))) {
756
+ $found_email++;
757
+
758
+ $this->_email_key[$key_column] = $this->_csv_array[0][$key_column];
759
+ }
760
+ }
761
+ }
762
+
763
+ $this->_data_result['errormatch'] = false;
764
+ $check_again = __('Check again what you\'re trying to import.',WYSIJA);
765
+ if (($found_email < 1)) {
766
+ $this->error(__('We couldn\'t find any valid addresses in the first 10 rows.', WYSIJA).' '.$check_again, true);
767
+ }
768
+
769
+ if ((count($this->_csv_array) < 2)) {
770
+ $this->error(__('You\'re import file is not valid.', WYSIJA).' '.$check_again, true);
771
+ }
772
+ }
773
+
774
+
775
+ /**
776
+ * function used to scan the CSV before trying to match each column with our own fields
777
+ * @return boolean
778
+ */
779
+ public function scan_csv_file(){
780
+ $this->_data_result = array();
781
+
782
+ // make sure the import match will be as easy as possible with default matches
783
+ if( $this->_save_default_import_field_match() === false) return false;
784
+ // get the csv into a string and check for messy email address etc
785
+ if( $this->_get_csv_file_cleaned_up() === false) return false;
786
+ // find out the format of that CSV file comma semi colon etc ..
787
+ if( $this->_run_test_on_csv_file() === false) return false;
788
+
789
+ // save the string into a file for later use
790
+ $file_name = $this->_save_csv_file();
791
+ if ($file_name === false)
792
+ return false;
793
+
794
+ // look for the email column
795
+ $this->_test_csv_emails();
796
+
797
+ // stock the data we will use in the next page
798
+ $this->_data_result['csv'] = $this->_csv_array;
799
+
800
+ $data_import = array(
801
+ 'csv' => $file_name,
802
+ 'fsep' => $this->_csv_data['fsep'],
803
+ 'fenc' => $this->_csv_data['fenc']);
804
+ $this->_data_result['dataImport'] = base64_encode(serialize($data_import));
805
+
806
+ $this->_data_result['keyemail'] = $this->_email_key;
807
+
808
+ //test if the first row is data or not
809
+ //test the email column
810
+ foreach ($this->_data_result['keyemail'] as $k)
811
+ $this->_email_key = $k;
812
+
813
+
814
+ // test whether the first row is a data row or is a descriptive header row
815
+ $helper_user = WYSIJA::get('user','helper');
816
+ if($helper_user->validEmail( $this->_email_key )){
817
+ $this->_data_result['firstrowisdata']=true;
818
+ }else{
819
+ $this->_data_result['totalrows']--;
820
+ }
821
+
822
+ return $this->_data_result;
823
+ }
 
 
 
824
 
825
  }
classes/WJ_Migrator.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  // We need the dbDelta migrator from Wordpress.
4
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
5
 
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  // We need the dbDelta migrator from Wordpress.
4
  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
5
 
classes/WJ_Option.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  /**
4
  * Option.
5
  * It creates and modifies Wordpress options.
@@ -10,7 +10,7 @@
10
  * # => 'my_value'
11
  */
12
  class WJ_Option {
13
-
14
  private $prefix = 'wysija_premium_';
15
  private $option_name;
16
 
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /**
4
  * Option.
5
  * It creates and modifies Wordpress options.
10
  * # => 'my_value'
11
  */
12
  class WJ_Option {
13
+
14
  private $prefix = 'wysija_premium_';
15
  private $option_name;
16
 
classes/WJ_Settings.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
-
3
  /**
4
  * Settings.
5
  * Global Wysija Premium settings singleton.
6
  */
7
  class WJ_Settings {
8
-
9
  static private $db_prefix;
10
  static private $name = 'wysija';
11
 
1
+ <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /**
4
  * Settings.
5
  * Global Wysija Premium settings singleton.
6
  */
7
  class WJ_Settings {
8
+
9
  static private $db_prefix;
10
  static private $name = 'wysija';
11
 
classes/WJ_Stats.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  /**
4
  * Class Stats.
5
  *
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /**
4
  * Class Stats.
5
  *
classes/WJ_Upgrade.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  class WJ_Upgrade extends WYSIJA_object {
3
  /**
4
  * A static variable that holds a dinamic instance of the class
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  class WJ_Upgrade extends WYSIJA_object {
4
  /**
5
  * A static variable that holds a dinamic instance of the class
classes/WJ_Utils.php CHANGED
@@ -1,69 +1,89 @@
1
  <?php
2
-
3
  /**
4
  * Wysija Premium Utils.
5
  * Utilities singleton not related to a specific model.
6
  */
7
  class WJ_Utils {
8
 
9
- private function __construct() {
10
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
- public static function to_int($value) {
13
- $boolean = (bool) $value;
14
- if ($boolean) {
15
- $int = 1;
16
- } else {
17
- $int = 0;
18
- }
19
- return $int;
20
- }
21
 
22
- public static function to_bool($value) {
23
- $int = (int) $value;
24
- if ($int == 0) {
25
- $boolean = false;
26
- } else {
27
- $boolean = true;
28
- }
29
- return $boolean;
30
- }
31
 
32
- /**
33
- * Retuns plain domain name.
34
- *
35
- * @return string $domain
36
- */
37
- public static function get_domain() {
38
- if(isset($_SERVER['SERVER_NAME']) && strlen(trim($_SERVER['SERVER_NAME'])) > 0) {
39
- $domain = strtolower($_SERVER['SERVER_NAME']);
40
- } else {
41
- $domain = preg_replace('@http[s]?:\/\/@', '', get_site_url());
42
- }
43
 
44
- return preg_replace('@^www\.@', '', $domain);
45
- }
 
 
 
 
46
 
47
- /**
48
- * Reruns necessary data for tooltip.
49
- *
50
- * @return array $data
51
- */
52
- public static function get_tip_data() {
53
- $model_config = WYSIJA::get('config', 'model');
54
- $is_gmail = 'false';
55
 
56
- if ('gmail' === $model_config->getValue('sending_method')) {
57
- $is_gmail = 'true';
58
- }
 
 
 
 
 
 
 
 
 
 
 
 
59
 
60
- $data = array(
61
- 'text' => sprintf(__('Use an email from your domain, like <strong>info@%s</strong> to avoid the spam folder, or even be blocked.', WYSIJA), self::get_domain()),
62
- 'gmailText' => sprintf(__('If you want to use a Gmail address, you need to send with Gmail. Check <a id="tip-send-with" href="%s">sending settings</a>.', WYSIJA), admin_url('admin.php?page=wysija_config#tab-sendingmethod')),
63
- 'domain' => self::get_domain(),
64
- 'isGmail' => $is_gmail
65
- );
66
 
67
- return $data;
68
- }
69
  }
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /**
4
  * Wysija Premium Utils.
5
  * Utilities singleton not related to a specific model.
6
  */
7
  class WJ_Utils {
8
 
9
+ private function __construct() {
10
+ }
11
+
12
+ public static function to_int( $value ) {
13
+ $boolean = (bool) $value;
14
+ if ( $boolean ) {
15
+ $int = 1;
16
+ } else {
17
+ $int = 0;
18
+ }
19
+ return $int;
20
+ }
21
+
22
+ public static function to_bool( $value ) {
23
+ $int = (int) $value;
24
+ if ( $int == 0 ) {
25
+ $boolean = false;
26
+ } else {
27
+ $boolean = true;
28
+ }
29
+ return $boolean;
30
+ }
31
+
32
+ /**
33
+ * Retuns plain domain name.
34
+ *
35
+ * @return string $domain
36
+ */
37
+ public static function get_domain() {
38
+ if ( isset($_SERVER['SERVER_NAME'] ) && strlen( trim( $_SERVER['SERVER_NAME'] ) ) > 0 ) {
39
+ $domain = strtolower( $_SERVER['SERVER_NAME'] );
40
+ } else {
41
+ $domain = preg_replace( '@http[s]?:\/\/@', '', get_site_url() );
42
+ }
43
 
44
+ return preg_replace( '@^www\.@', '', $domain );
45
+ }
 
 
 
 
 
 
 
46
 
47
+ /**
48
+ * Reruns necessary data for tooltip.
49
+ *
50
+ * @return array $data
51
+ */
52
+ public static function get_tip_data() {
53
+ $model_config = WYSIJA::get( 'config', 'model' );
54
+ $is_gmail = 'false';
 
55
 
56
+ if ( 'gmail' === $model_config->getValue( 'sending_method' ) ) {
57
+ $is_gmail = 'true';
58
+ }
 
 
 
 
 
 
 
 
59
 
60
+ $data = array(
61
+ 'text' => sprintf( __( 'Use an email from your domain, like <strong>info@%s</strong> to avoid the spam folder, or even be blocked.', WYSIJA ), self::get_domain() ),
62
+ 'gmailText' => sprintf( __( 'If you want to use a Gmail address, you need to send with Gmail. Check <a id="tip-send-with" href="%s">sending settings</a>.', WYSIJA ), admin_url( 'admin.php?page=wysija_config#tab-sendingmethod' ) ),
63
+ 'domain' => self::get_domain(),
64
+ 'isGmail' => $is_gmail,
65
+ );
66
 
67
+ return $data;
68
+ }
 
 
 
 
 
 
69
 
70
+ public static function esc_json_attr( $json ){
71
+ $search = array(
72
+ '\"',
73
+ '\'',
74
+ '<',
75
+ '>',
76
+ '&',
77
+ );
78
+ $replace = array(
79
+ '\\u0022',
80
+ '\\u0027',
81
+ '\\u003C',
82
+ '\\u003E',
83
+ '\\u0026',
84
+ );
85
 
86
+ return str_replace( $search, $replace, json_encode( $json ) );
87
+ }
 
 
 
 
88
 
 
 
89
  }
controllers/ajax/config.php CHANGED
@@ -147,17 +147,6 @@ class WYSIJA_control_back_config extends WYSIJA_control{
147
  return $res;
148
  }
149
 
150
- function devalidate(){
151
-
152
- $modelCOnfig=WYSIJA::get('config','model');
153
- $res=$modelCOnfig->save(array('premium_key'=>false));
154
-
155
- if(!isset($res['result'])) $res['result']=false;
156
- return $res;
157
- }
158
-
159
-
160
-
161
  function _convertPostedInarray(){
162
  $_POST = stripslashes_deep($_POST);
163
  $dataTemp=$_POST['data'];
147
  return $res;
148
  }
149
 
 
 
 
 
 
 
 
 
 
 
 
150
  function _convertPostedInarray(){
151
  $_POST = stripslashes_deep($_POST);
152
  $dataTemp=$_POST['data'];
controllers/ajax/statistics.php CHANGED
@@ -3,8 +3,7 @@ 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
@@ -28,8 +27,10 @@ class WYSIJA_control_back_statistics extends WYSIJA_control
28
  * Render a hook of a specific module
29
  * @return string
30
  */
31
- public function get_block()
32
- {
 
 
33
  if (empty($_REQUEST['block']))
34
  return '';
35
  $module = $_REQUEST['block'];
@@ -37,12 +38,10 @@ class WYSIJA_control_back_statistics extends WYSIJA_control
37
  return apply_filters('custom_module_hook', '', $module, $hook_name, $this->get_post_params());
38
  }
39
 
40
- protected function get_post_params()
41
- {
42
  $params = array( );
43
  $order_by = !empty($_REQUEST['filter']['orderBy']) ? $_REQUEST['filter']['orderBy'] : null;
44
- switch (strtolower($order_by))
45
- {
46
  case 'sent':
47
  $order_by = WYSIJA_module_statistics::ORDER_BY_SENT;
48
  break;
@@ -60,8 +59,7 @@ class WYSIJA_control_back_statistics extends WYSIJA_control
60
  break;
61
  }
62
  $order_direction = !empty($_REQUEST['filter']['orderDirection']) ? $_REQUEST['filter']['orderDirection'] : null;
63
- switch (strtolower($order_direction))
64
- {
65
  case 'asc':
66
  $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_ASC;
67
  break;
@@ -78,12 +76,10 @@ class WYSIJA_control_back_statistics extends WYSIJA_control
78
 
79
  // 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
80
  // we cannot use functions from php 5.3
81
- if (function_exists('date_diff'))
82
- {
83
  $this->data['date_interval'] = date_diff(date_create($params['from']), date_create($params['to']));
84
  }
85
- else
86
- {
87
  $duration = strtotime($params['to']) - strtotime($params['from']);
88
  $helper_toolbox = WYSIJA::get('toolbox', 'helper');
89
  $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration, false);
@@ -91,12 +87,10 @@ class WYSIJA_control_back_statistics extends WYSIJA_control
91
  $params['group_by'] = ( $this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
92
  WYSIJA_module_statistics::GROUP_BY_MONTH :
93
  WYSIJA_module_statistics::GROUP_BY_DATE; // $date_interval->days == 0, means, no begin date, no end date
94
-
95
  // Hack!
96
- $_REQUEST['limit_pp'] = $params['top'];// Pagination, mark current selected value
97
-
98
  // Modify TO date to make sure we always count 23:59:59 of that day
99
- $to = new DateTime($params['to']);
100
  $to->modify('+1 day');
101
  $params['to'] = $to->format($this->date_format);
102
 
3
 
4
  require_once(WYSIJA_CORE.'module'.DS.'statistics.php'); // @todo
5
 
6
+ class WYSIJA_control_back_statistics extends WYSIJA_control {
 
7
 
8
  /**
9
  * Main model of this controller
27
  * Render a hook of a specific module
28
  * @return string
29
  */
30
+ public function get_block() {
31
+ if (!WYSIJA::current_user_can('wysija_stats_dashboard'))
32
+ die('Action is forbidden.');
33
+
34
  if (empty($_REQUEST['block']))
35
  return '';
36
  $module = $_REQUEST['block'];
38
  return apply_filters('custom_module_hook', '', $module, $hook_name, $this->get_post_params());
39
  }
40
 
41
+ protected function get_post_params() {
 
42
  $params = array( );
43
  $order_by = !empty($_REQUEST['filter']['orderBy']) ? $_REQUEST['filter']['orderBy'] : null;
44
+ switch (strtolower($order_by)) {
 
45
  case 'sent':
46
  $order_by = WYSIJA_module_statistics::ORDER_BY_SENT;
47
  break;
59
  break;
60
  }
61
  $order_direction = !empty($_REQUEST['filter']['orderDirection']) ? $_REQUEST['filter']['orderDirection'] : null;
62
+ switch (strtolower($order_direction)) {
 
63
  case 'asc':
64
  $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_ASC;
65
  break;
76
 
77
  // 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
78
  // we cannot use functions from php 5.3
79
+ if (function_exists('date_diff')) {
 
80
  $this->data['date_interval'] = date_diff(date_create($params['from']), date_create($params['to']));
81
  }
82
+ else {
 
83
  $duration = strtotime($params['to']) - strtotime($params['from']);
84
  $helper_toolbox = WYSIJA::get('toolbox', 'helper');
85
  $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration, false);
87
  $params['group_by'] = ( $this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
88
  WYSIJA_module_statistics::GROUP_BY_MONTH :
89
  WYSIJA_module_statistics::GROUP_BY_DATE; // $date_interval->days == 0, means, no begin date, no end date
 
90
  // Hack!
91
+ $_REQUEST['limit_pp'] = $params['top']; // Pagination, mark current selected value
 
92
  // Modify TO date to make sure we always count 23:59:59 of that day
93
+ $to = new DateTime($params['to']);
94
  $to->modify('+1 day');
95
  $params['to'] = $to->format($this->date_format);
96
 
controllers/back/campaigns.php CHANGED
@@ -574,51 +574,68 @@ class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
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() {
@@ -2251,6 +2268,9 @@ class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
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);
@@ -2522,6 +2542,7 @@ class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
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);
574
  }
575
 
576
  function duplicate() {
 
577
  /* 1 - copy the campaign entry */
578
+ $model = WYSIJA::get( 'campaign', 'model' );
 
579
  $query = 'INSERT INTO `[wysija]campaign` (`name`,`description`)
580
+ SELECT concat("' . stripslashes( __( 'Copy of ', WYSIJA ) ) . '",`name`),`description` FROM [wysija]campaign
581
  WHERE campaign_id=' . (int) $_REQUEST['id'];
582
+ $campaignid = $model->query( $query );
583
 
584
  /* 2 - copy the email entry */
585
  $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`)
586
+ 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
587
  WHERE email_id=' . (int) $_REQUEST['email_id'];
588
+ $emailid = $model->query( $query );
589
 
590
  //let's reset the count of total childs for auto newsletter
591
+ $mEmail = WYSIJA::get( 'email', 'model' );
592
+ $emailData = $mEmail->getOne( false, array( 'email_id' => $emailid ) );
593
+
594
+ if ( $emailData['type'] == 1 ){
595
+ $params = $emailData['params'];
596
 
597
+ if ( isset( $params['schedule'] ) ){
598
+ $date_scheduled = strtotime( $params['schedule']['day'] . ' ' . $params['schedule']['time'] );
599
+
600
+ if ( $date_scheduled === false || $date_scheduled < time() ){
601
+ unset( $params['schedule'] );
602
+ }
603
+ }
604
+ $mEmail->update( array( 'params' => $params ), array( 'email_id' => $emailid ) );
605
+ } elseif ( $emailData['type'] == 2 ) {
606
  $paramsReseted = $emailData['params'];
607
+ if ( isset( $paramsReseted['autonl']['total_child'] ) ){
608
  $paramsReseted['autonl']['total_child'] = 0;
609
+ }
610
+
611
+ if ( isset( $paramsReseted['autonl']['nextSend'] ) ){
612
  $paramsReseted['autonl']['nextSend'] = 0;
613
+ }
 
 
 
 
 
614
 
615
+ if ( isset( $paramsReseted['autonl']['firstSend'] ) ){
616
+ unset( $paramsReseted['autonl']['firstSend'] );
617
+ }
618
 
619
+ if ( isset( $paramsReseted['autonl']['lastSend'] ) ){
620
+ unset( $paramsReseted['autonl']['lastSend'] );
621
+ }
622
+
623
+ if ( isset( $paramsReseted['autonl']['articles']['ids'] ) ){
624
+ unset( $paramsReseted['autonl']['articles']['ids'] );
625
+ }
626
+
627
+ $mEmail->update( array( 'params' => $paramsReseted ), array( 'email_id' => $emailid ) );
628
  }
629
 
630
  /* 3 - copy the campaign_list entry */
631
  $query = "INSERT INTO `[wysija]campaign_list` (`campaign_id`,`list_id`,`filter`)
632
  SELECT $campaignid,`list_id`,`filter` FROM [wysija]campaign_list
633
  WHERE campaign_id=" . (int) $_REQUEST['id'];
634
+ $model->query( $query );
635
 
636
+ $this->notice( __( 'The newsletter has been duplicated.', WYSIJA ) );
637
 
638
+ $this->redirect( 'admin.php?page=wysija_campaigns&id=' . $emailid . '&action=edit' );
639
  }
640
 
641
  function duplicateEmail() {
2268
  $this->js[] = 'wysija-base-script-64';
2269
  $this->js[] = 'wysija-scriptaculous';
2270
  $this->js[] = 'wysija-colorpicker';
2271
+ $this->js[] = 'mailpoet-select2';
2272
+ $this->js[] = 'mailpoet-field-select2-terms';
2273
+ $this->js[] = 'mailpoet-field-select2-simple';
2274
 
2275
  // translations
2276
  $this->jsTrans['show_advanced'] = __('Display and insert options', WYSIJA);
2542
  $this->js[] = 'wysija-scriptaculous';
2543
  $this->js[] = 'wysija-colorpicker';
2544
  $this->js[] = 'mailpoet-select2';
2545
+ $this->js[] = 'mailpoet-field-select2-terms';
2546
 
2547
  // translations
2548
  $this->jsTrans['show_advanced'] = __('Show display options', WYSIJA);
controllers/back/config.php CHANGED
@@ -125,13 +125,6 @@ class WYSIJA_control_back_config extends WYSIJA_control_back{
125
  return true;
126
  }
127
 
128
- function changeMode(){
129
- $helperFile=WYSIJA::get('file','helper');
130
- $helperFile->chmodr(WYSIJA_UPLOADS_DIR, 0666, 0777);
131
- $this->redirect('admin.php?page=wysija_config');
132
- return true;
133
- }
134
-
135
  function doreinstall(){
136
 
137
  if(isset($_REQUEST['postedfrom']) && $_REQUEST['postedfrom'] === 'reinstall') {
125
  return true;
126
  }
127
 
 
 
 
 
 
 
 
128
  function doreinstall(){
129
 
130
  if(isset($_REQUEST['postedfrom']) && $_REQUEST['postedfrom'] === 'reinstall') {
controllers/back/statistics.php CHANGED
@@ -2,8 +2,7 @@
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
@@ -42,13 +41,13 @@ class WYSIJA_control_back_statistics extends WYSIJA_control_back
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';
@@ -61,12 +60,10 @@ class WYSIJA_control_back_statistics extends WYSIJA_control_back
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);
@@ -87,27 +84,22 @@ class WYSIJA_control_back_statistics extends WYSIJA_control_back
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
  // Hack!
90
- $_REQUEST['limit_pp'] = $hook_params['top']; // Pagination, mark current selected value
91
-
92
-
93
  // Modify TO date to make sure we always count 23:59:59 of that day
94
- $to = new DateTime($hook_params['to']);
95
  $to->modify('+1 day');
96
  $hook_params['to'] = $to->format($this->date_format);
97
-
98
  $modules = WYSIJA_module::get_modules_from_hook($hook_name);
99
  $this->data['modules'] = $modules;
100
  $this->data['lazy_load_modules'] = array( );
101
  $this->data['first_module'] = '';
102
 
103
- if (!$this->lazy_load)
104
- {
105
  $this->data['hooks'][$hook_name] = apply_filters('hook_stats', '', $hook_params);
106
  }
107
- else
108
- {
109
- if (!empty($modules))
110
- {
111
  $first_module = array_shift($modules);
112
  // List of lazy loaded modules
113
  $this->data['lazy_load_modules'] = $modules;
@@ -122,8 +114,7 @@ class WYSIJA_control_back_statistics extends WYSIJA_control_back
122
  * get pre defined dates (duration)
123
  * @return type
124
  */
125
- protected function get_pre_defined_dates()
126
- {
127
  return array(
128
  array(
129
  'value' => 7,
@@ -181,16 +172,14 @@ class WYSIJA_control_back_statistics extends WYSIJA_control_back
181
  * Get default duration of stats
182
  * @return int
183
  */
184
- protected function get_default_duration()
185
- {
186
  foreach ($this->pre_defined_dates as $duration)
187
  if (isset($duration['selected']) && $duration['selected'])
188
  return $duration;
189
  return end($this->pre_defined_dates);
190
  }
191
 
192
- function date_diff($time_start, $time_end)
193
- {
194
  $result = null;
195
  $duration = $time_end - $time_start;
196
  $result->days = floor($duration / (60 * 60 * 24));
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
  * Main model of this controller
41
  /**
42
  * Constructor
43
  */
44
+ function WYSIJA_control_back_statistics() {
 
 
45
  }
46
 
47
+ public function defaultDisplay() {
48
+ if (!WYSIJA::current_user_can('wysija_stats_dashboard'))
49
+ die('Action is forbidden.');
50
+
51
  $this->pre_defined_dates = $this->get_pre_defined_dates();
52
  // Define view
53
  $this->viewShow = $this->action = 'main';
60
 
61
  // date filter
62
  $default_duration = $this->get_default_duration();
63
+ if (function_exists('date_diff')) {
 
64
  $this->data['date_interval'] = date_diff(date_create($default_duration['from']), date_create($default_duration['to']));
65
  }
66
+ else {
 
67
  $duration = strtotime($default_duration['to']) - strtotime($default_duration['from']);
68
  $helper_toolbox = WYSIJA::get('toolbox', 'helper');
69
  $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration, false);
84
  WYSIJA_module_statistics::GROUP_BY_MONTH :
85
  WYSIJA_module_statistics::GROUP_BY_DATE; // $this->data['date_interval']->days == 0, means, no begin date, no end date
86
  // Hack!
87
+ $_REQUEST['limit_pp'] = $hook_params['top']; // Pagination, mark current selected value
 
 
88
  // Modify TO date to make sure we always count 23:59:59 of that day
89
+ $to = new DateTime($hook_params['to']);
90
  $to->modify('+1 day');
91
  $hook_params['to'] = $to->format($this->date_format);
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
  $this->data['hooks'][$hook_name] = apply_filters('hook_stats', '', $hook_params);
100
  }
101
+ else {
102
+ if (!empty($modules)) {
 
 
103
  $first_module = array_shift($modules);
104
  // List of lazy loaded modules
105
  $this->data['lazy_load_modules'] = $modules;
114
  * get pre defined dates (duration)
115
  * @return type
116
  */
117
+ protected function get_pre_defined_dates() {
 
118
  return array(
119
  array(
120
  'value' => 7,
172
  * Get default duration of stats
173
  * @return int
174
  */
175
+ protected function get_default_duration() {
 
176
  foreach ($this->pre_defined_dates as $duration)
177
  if (isset($duration['selected']) && $duration['selected'])
178
  return $duration;
179
  return end($this->pre_defined_dates);
180
  }
181
 
182
+ function date_diff($time_start, $time_end) {
 
183
  $result = null;
184
  $duration = $time_end - $time_start;
185
  $result->days = floor($duration / (60 * 60 * 24));
controllers/back/subscribers.php CHANGED
@@ -750,7 +750,6 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
750
  $this->jsTrans['subscribers_import_match_confirmation_1'] = __('The selected value is already matched to another column.', WYSIJA);
751
  $this->jsTrans['subscribers_import_match_confirmation_2'] = __('Can you confirm that this column is corresponding to that field?', WYSIJA);
752
  $this->js[] = 'wysija-validator';
753
- wp_enqueue_script('jquery-matchColumn', WYSIJA_URL.'js/jquery/jquery.matchColumn.js', array('jquery'), WYSIJA::get_version());
754
  $helper_numbers = WYSIJA::get('numbers','helper');
755
  $bytes = $helper_numbers->get_max_file_upload();
756
 
@@ -771,6 +770,13 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
771
 
772
  if($this->data === false) $this->redirect('admin.php?page=wysija_subscribers&action=import');
773
 
 
 
 
 
 
 
 
774
  $this->viewObj->title=__('Import Subscribers',WYSIJA);
775
  $this->viewShow='importmatch';
776
 
750
  $this->jsTrans['subscribers_import_match_confirmation_1'] = __('The selected value is already matched to another column.', WYSIJA);
751
  $this->jsTrans['subscribers_import_match_confirmation_2'] = __('Can you confirm that this column is corresponding to that field?', WYSIJA);
752
  $this->js[] = 'wysija-validator';
 
753
  $helper_numbers = WYSIJA::get('numbers','helper');
754
  $bytes = $helper_numbers->get_max_file_upload();
755
 
770
 
771
  if($this->data === false) $this->redirect('admin.php?page=wysija_subscribers&action=import');
772
 
773
+ $model_config = WYSIJA::get('config', 'model');
774
+ $this->jsTrans['userStatuses'] = array(
775
+ -1 => __('Unsubscribed', WYSIJA),
776
+ 0 => $model_config->getValue('confirm_dbleoptin') ? __('Unconfirmed',WYSIJA) : __('Subscribed',WYSIJA),
777
+ 1 => __('Subscribed',WYSIJA)
778
+ );
779
+ $this->js[] = 'wysija-import-match';
780
  $this->viewObj->title=__('Import Subscribers',WYSIJA);
781
  $this->viewShow='importmatch';
782
 
controllers/front/confirm.php CHANGED
@@ -60,14 +60,18 @@ class WYSIJA_control_front_confirm extends WYSIJA_control_front{
60
  $this->optional_subtitle = $model_config->getValue('unsubscribed_subtitle');
61
  if(!isset($model_config->values['unsubscribed_subtitle'])) $this->optional_subtitle = __("Great, you'll never hear from us again!",WYSIJA);
62
 
 
 
 
 
63
  $undo_paramsurl = array(
64
- 'wysija-page'=>1,
65
- 'controller'=>'confirm',
66
- 'action'=>'undounsubscribe',
67
- 'wysija-key'=>$_REQUEST['wysija-key']
68
  );
69
 
70
- if(!isset($_REQUEST['demo'])){
71
  if($this->_testKeyuser()){
72
  $statusint=(int)$this->userData['details']['status'];
73
  if( ($model_config->getValue('confirm_dbleoptin') && $statusint>0) || (!$model_config->getValue('confirm_dbleoptin') && $statusint>=0)){
@@ -212,7 +216,7 @@ class WYSIJA_control_front_confirm extends WYSIJA_control_front{
212
  $modelUL->backSave=true;
213
  /* list of core list */
214
  $modelLIST=WYSIJA::get('list','model');
215
-
216
  // Using "like" condition in order to force sql query to OR (instead of AND). It'll be incorrct if status contains other values than 0/1.
217
  $results=$modelLIST->get(array('list_id'),array('like' => array('is_enabled'=>0, 'is_public' => 0)));
218
  $static_listids=array();
60
  $this->optional_subtitle = $model_config->getValue('unsubscribed_subtitle');
61
  if(!isset($model_config->values['unsubscribed_subtitle'])) $this->optional_subtitle = __("Great, you'll never hear from us again!",WYSIJA);
62
 
63
+ $wysija_key = '';
64
+ if(isset( $_GET['wysija-key'] )){
65
+ $wysija_key = $_GET['wysija-key'];
66
+ }
67
  $undo_paramsurl = array(
68
+ 'wysija-page' => 1,
69
+ 'controller' => 'confirm',
70
+ 'action' => 'undounsubscribe',
71
+ 'wysija-key' => $wysija_key
72
  );
73
 
74
+ if(! isset($_GET['demo']) ){
75
  if($this->_testKeyuser()){
76
  $statusint=(int)$this->userData['details']['status'];
77
  if( ($model_config->getValue('confirm_dbleoptin') && $statusint>0) || (!$model_config->getValue('confirm_dbleoptin') && $statusint>=0)){
216
  $modelUL->backSave=true;
217
  /* list of core list */
218
  $modelLIST=WYSIJA::get('list','model');
219
+
220
  // Using "like" condition in order to force sql query to OR (instead of AND). It'll be incorrct if status contains other values than 0/1.
221
  $results=$modelLIST->get(array('list_id'),array('like' => array('is_enabled'=>0, 'is_public' => 0)));
222
  $static_listids=array();
controllers/front/email.php CHANGED
@@ -38,25 +38,13 @@ class WYSIJA_control_front_email extends WYSIJA_control_front{
38
  $current_email = $emailM->getOne($email_id);
39
  }
40
 
41
-
42
-
43
-
44
  // Get current user object if possible
45
  $current_user = null;
46
- if(isset($_REQUEST['user_id']) && (int)$_REQUEST['user_id'] > 0 ){
47
- // Get User Model
48
- $userM = WYSIJA::get('user','model');
49
- $userM->getFormat = OBJECT;
50
- $current_user = $userM->getOne((int)$_REQUEST['user_id']);
51
- }
52
  // Parse and replace user tags.
53
  $mailerH->parseUserTags($current_email);
54
  $mailerH->parseSubjectUserTags($current_email);
55
  $mailerH->replaceusertags($current_email, $current_user);
56
- // Start tracking if this preview is opened from a newsletter
57
- if ($current_user !== null) {
58
- $mailerH->tracker_replaceusertags($current_email, $current_user);
59
- }
60
 
61
  // Set Body
62
  $email_render = $current_email->body;
38
  $current_email = $emailM->getOne($email_id);
39
  }
40
 
 
 
 
41
  // Get current user object if possible
42
  $current_user = null;
43
+
 
 
 
 
 
44
  // Parse and replace user tags.
45
  $mailerH->parseUserTags($current_email);
46
  $mailerH->parseSubjectUserTags($current_email);
47
  $mailerH->replaceusertags($current_email, $current_user);
 
 
 
 
48
 
49
  // Set Body
50
  $email_render = $current_email->body;
core/autoloader.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
-
3
  /**
4
  * Classes Autoloader.
5
  * It loads automatically the right class on class instantation.
6
  * Since we still can't use namespaces, we use 'WJ_' as a prefix for our classes.
7
  * @param Class $class Class name
8
- * @return
9
  */
10
  function wysija_classes_autoloader($class) {
11
  // Check if the class name has our prefix.
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /**
4
  * Classes Autoloader.
5
  * It loads automatically the right class on class instantation.
6
  * Since we still can't use namespaces, we use 'WJ_' as a prefix for our classes.
7
  * @param Class $class Class name
8
+ * @return
9
  */
10
  function wysija_classes_autoloader($class) {
11
  // Check if the class name has our prefix.
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.9';
23
 
24
  function WYSIJA_object(){
25
 
@@ -1564,11 +1564,6 @@ if($modelConf->getValue('installed_time')){
1564
  add_filter('load_textdomain_mofile', array( 'WYSIJA', 'load_textdomain_mofile' ), 10, 2);
1565
  }
1566
 
1567
- // not yet used but the purpose is to override any notification sent through wp_mail
1568
- if($modelConf->getValue('wp_notifications')){
1569
- $hWPnotif=WYSIJA::get('wp_notifications','helper');
1570
- }
1571
-
1572
  register_deactivation_hook(WYSIJA_FILE, array( 'WYSIJA', 'deactivate' ));
1573
  register_activation_hook(WYSIJA_FILE, array( 'WYSIJA', 'activate' ));
1574
  add_action( 'init', array('WYSIJA','create_post_type') );
19
  * Static variable holding core MailPoet's version
20
  * @var array
21
  */
22
+ static $version = '2.6.10';
23
 
24
  function WYSIJA_object(){
25
 
1564
  add_filter('load_textdomain_mofile', array( 'WYSIJA', 'load_textdomain_mofile' ), 10, 2);
1565
  }
1566
 
 
 
 
 
 
1567
  register_deactivation_hook(WYSIJA_FILE, array( 'WYSIJA', 'deactivate' ));
1568
  register_activation_hook(WYSIJA_FILE, array( 'WYSIJA', 'activate' ));
1569
  add_action( 'init', array('WYSIJA','create_post_type') );
core/constants.php CHANGED
@@ -13,7 +13,6 @@ $current_folder=dirname(dirname(__FILE__));
13
 
14
  if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
15
  define('WYSIJA', $plugin_name);
16
- define('WYSIJAFUTURE','wysija-future');
17
  if(!defined('WYSIJA_PLG_DIR')) define('WYSIJA_PLG_DIR', dirname($current_folder).DS);
18
  define('WYSIJA_DIR', $current_folder.DS);
19
  define('WYSIJA_DATA_DIR', WYSIJA_DIR.'data'.DS);
13
 
14
  if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);
15
  define('WYSIJA', $plugin_name);
 
16
  if(!defined('WYSIJA_PLG_DIR')) define('WYSIJA_PLG_DIR', dirname($current_folder).DS);
17
  define('WYSIJA_DIR', $current_folder.DS);
18
  define('WYSIJA_DATA_DIR', WYSIJA_DIR.'data'.DS);
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;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{min-height:200px;max-height:600px;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}
helpers/articles.php CHANGED
@@ -2,431 +2,415 @@
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_help_articles extends WYSIJA_object {
4
 
5
- function WYSIJA_help_articles() {
6
-
7
- }
8
-
9
- function stripShortcodes($content) {
10
- if(strlen(trim($content)) === 0) {
11
- return '';
12
- }
13
- // remove captions
14
- $content = preg_replace("/\[caption.*?\](.*<\/a>)(.*?)\[\/caption\]/", '$1', $content);
15
-
16
- // remove other shortcodes
17
- $content = preg_replace('/\[[^\[\]]*\]/', '', $content);
18
-
19
- return $content;
20
- }
21
-
22
- function convertPostToBlock($post, $params = array()) {
23
-
24
- // defaults
25
- $defaults = array(
26
- 'title_tag' => 'h1',
27
- 'title_alignment' => 'left',
28
- 'title_position' => 'inside',
29
- 'image_alignment' => 'left',
30
- 'image_width' => 325,
31
- 'readmore' => __('Read online.', WYSIJA),
32
- 'post_content' => 'full',
33
- 'author_show' => 'no',
34
- 'author_label' => '',
35
- 'category_show' => 'no',
36
- 'category_label' => ''
37
- );
38
-
39
- // merge params with default params
40
- $params = array_merge($defaults, $params);
41
-
42
- if($params['post_content'] === 'full') {
43
- $content = $post['post_content'];
44
- } else if($params['post_content'] === 'title') {
45
- $content = $this->getPostTitle($post, $params);
46
- } else {
47
- // get excerpt
48
- if(!empty($post['post_excerpt'])) {
49
- $content = $post['post_excerpt'];
50
- } else {
51
- // strip shortcodes before getting the excerpt
52
- $post['post_content'] = $this->stripShortcodes($post['post_content']);
53
-
54
- // if excerpt is empty then try to find the "more" tag
55
- $excerpts = explode('<!--more-->', $post['post_content']);
56
- if(count($excerpts) > 1){
57
- $content = $excerpts[0];
58
- }else{
59
- // finally get a made up excerpt if there is no other choice
60
- $helper_toolbox = WYSIJA::get('toolbox', 'helper');
61
- $content = $helper_toolbox->excerpt($post['post_content'], apply_filters('mpoet_excerpt_length', 60));
62
- }
63
- }
64
- // strip title tags from excerpt
65
- $content = preg_replace('/<([\/])?h[123456](.*?)>/', '<$1p$2>', $content);
66
- }
67
-
68
- // convert new lines into <p>
69
- $content = wpautop($content);
70
-
71
- // remove images
72
- $content = preg_replace('/<img[^>]+./','', $content);
73
-
74
- // strip shortcodes
75
- $content = $this->stripShortcodes($content);
76
-
77
- // remove wysija nl shortcode
78
- $content= preg_replace('/\<div class="wysija-register">(.*?)\<\/div>/','',$content);
79
-
80
- // convert embedded content if necessary
81
- $content = $this->convertEmbeddedContent($content);
82
-
83
- // convert h4 h5 h6 to h3
84
- $content = preg_replace('/<([\/])?h[456](.*?)>/', '<$1h3$2>', $content);
85
-
86
- // convert ol to ul
87
- $content = preg_replace('/<([\/])?ol(.*?)>/', '<$1ul$2>', $content);
88
-
89
- // convert currency signs
90
- $content = str_replace(array('$', '€', '£', '¥'), array('&#36;', '&euro;', '&pound;', '&#165;'), $content);
91
-
92
- // strip useless tags
93
- // TODO should we add table, tr, td and th into that list it could create issues in some cases
94
- $tags_not_being_stripped = array('<p>','<em>','<span>','<b>','<strong>','<i>','<h1>','<h2>','<h3>','<a>','<ul>','<ol>','<li>','<br>');
95
-
96
- // filter to modify that list
97
- $tags_not_being_stripped = apply_filters('mpoet_strip_tags_ignored',$tags_not_being_stripped);
98
-
99
- $content = strip_tags($content, implode('',$tags_not_being_stripped));
100
-
101
- // post meta (author, categories)
102
- $post_meta_above = '';
103
- // if the author or categories are displayed, open a new paragraph
104
- if($params['author_show'] === 'above' || $params['category_show'] === 'above') {
105
- $post_meta_above .= '<p>';
106
- }
107
-
108
- // author above
109
- if($params['author_show'] === 'above') {
110
- $post_meta_above .= $this->getPostAuthor($post, $params);
111
- }
112
- // categories above
113
- if($params['category_show'] === 'above') {
114
- // if there is an author already, we need to add an extra break
115
- if($params['author_show'] === 'above') {
116
- $post_meta_above .= '<br />';
117
- }
118
- // display post categories
119
- $post_meta_above .= $this->getPostCategories($post, $params);
120
- }
121
-
122
- // close the paragraph around author and categories
123
- if($params['author_show'] === 'above' || $params['category_show'] === 'above') {
124
- $post_meta_above .= '</p>';
125
- }
126
-
127
- if($params['post_content'] !== 'title') {
128
- if($params['title_position'] === 'inside') {
129
- // add title
130
- $content = $this->getPostTitle($post, $params).$post_meta_above.$content;
131
- } else {
132
- $content = $post_meta_above.$content;
133
- }
134
- } else {
135
- $content = $post_meta_above.$content;
136
- }
137
-
138
- if($params['post_content'] !== 'title') {
139
- // add read online link
140
- $content .= '<p><a href="'.get_permalink($post['ID']).'" target="_blank">'.stripslashes($params['readmore']).'</a></p>';
141
- }
142
-
143
- // post meta (author, categories) below
144
- $post_meta_below = '';
145
-
146
- // if the author or categories are displayed, open a new paragraph
147
- if($params['author_show'] === 'below' || $params['category_show'] === 'below') {
148
- $post_meta_below .= '<p>';
149
- }
150
-
151
- // author below
152
- if($params['author_show'] === 'below') {
153
- $post_meta_below .= $this->getPostAuthor($post, $params);
154
- }
155
-
156
- // categories below
157
- if($params['category_show'] === 'below') {
158
- // if there is an author already, we need to add an extra break
159
- if($params['author_show'] === 'below') {
160
- $post_meta_below .= '<br />';
161
- }
162
- $post_meta_below .= $this->getPostCategories($post, $params);
163
- }
164
-
165
- // close the paragraph around author and categories
166
- if($params['author_show'] === 'below' || $params['category_show'] === 'below') {
167
- $post_meta_below .= '</p>';
168
- }
169
-
170
- if($post_meta_below !== '') $content .= $post_meta_below;
171
-
172
- // set image/text alignment based on present data
173
- $post_image = null;
174
-
175
- if(($params['title_tag'] !== 'list') && isset($post['post_image'])) {
176
- $post_image = $post['post_image'];
177
-
178
- // set image alignment to match block's
179
- $post_image['alignment'] = $params['image_alignment'];
180
-
181
- // constrain size depending on alignment
182
- if(empty($post_image['height']) or $post_image['height'] === 0) {
183
- $post_image = null;
184
- } else {
185
- $ratio = round(($post_image['width'] / $post_image['height']) * 1000) / 1000;
186
- switch($params['image_alignment']) {
187
- case 'alternate':
188
- case 'left':
189
- case 'right':
190
- // constrain width to 325px max
191
- $post_image['width'] = min($params['image_width'], 325);
192
- break;
193
- case 'center':
194
- // constrain width to 564px max
195
- $post_image['width'] = min($params['image_width'], 564);
196
- break;
197
- }
198
-
199
- if($ratio > 0) {
200
- // if ratio has been calculated, deduce image height
201
- $post_image['height'] = (int)($post_image['width'] / $ratio);
202
- } else {
203
- // otherwise skip the image
204
- $post_image = null;
205
- }
206
- }
207
- }
208
-
209
- $position = 0;
210
- if(isset($params['position']) && (int)$params['position'] > 0) {
211
- $position = (int)$params['position'];
212
- }
213
-
214
- $block = array(
215
- 'position' => $position,
216
- 'type' => 'content',
217
- 'text' => array(
218
- 'value' => base64_encode($content)
219
- ),
220
- 'image' => $post_image,
221
- 'alignment' => $params['image_alignment']
222
- );
223
-
224
- return $block;
225
- }
226
-
227
- public function getPostAuthor($post = array(), $params = array()) {
228
- $content = '';
229
-
230
- if(isset($post['post_author'])) {
231
- $author_name = get_the_author_meta('display_name', (int)$post['post_author']);
232
-
233
- // check if the user specified a label to be displayed before the author's name
234
- if(strlen(trim($params['author_label'])) > 0) {
235
- $author_name = stripslashes(trim($params['author_label'])).' '.$author_name;
236
- }
237
- $content .= $author_name;
238
- }
239
-
240
- return $content;
241
- }
242
-
243
- public function getPostCategories($post = array(), $params = array()) {
244
- $content = '';
245
-
246
- // get categories
247
- //$categories = get_the_category($post['ID']);
248
- $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
249
- $categories = $helper_wp_tools->get_post_categories($post);
250
-
251
- if(empty($categories) === false) {
252
- // check if the user specified a label to be displayed before the author's name
253
- if(strlen(trim($params['category_label'])) > 0) {
254
- $content = stripslashes($params['category_label']).' ';
255
- }
256
-
257
- $content .= join(', ', $categories);
258
- }
259
-
260
- return $content;
261
- }
262
-
263
- public function getPostTitle($post = array(), $params = array()) {
264
- $content = '';
265
-
266
- if(strlen(trim($post['post_title'])) > 0) {
267
- // cleanup post title and convert currency signs
268
- $post_title = trim(str_replace(array('$', '€', '£', '¥'), array('&#36;', '&euro;', '&pound;', '&#165;'), strip_tags($post['post_title'])));
269
-
270
- // open title tag
271
- if($params['title_tag'] === 'list') {
272
- $params['title_tag'] = 'li';
273
- }
274
-
275
- $content .= '<'.$params['title_tag'].' class="align-'.$params['title_alignment'].'">';
276
- // set title link
277
- $content .= '<a href="'.get_permalink($post['ID']).'" target="_blank">';
278
- // set title
279
- $content .= $post_title;
280
- // close title link
281
- $content .= '</a>';
282
- // close title tag
283
- $content .= '</'.$params['title_tag'].'>';
284
-
285
- }
286
-
287
- return $content;
288
- }
289
-
290
- function getImage($post) {
291
- $image_info = null;
292
- $post_image = null;
293
-
294
- // check if has_post_thumbnail function exists, if not, include wordpress class
295
- if(!function_exists('has_post_thumbnail')) {
296
- require_once(ABSPATH.WPINC.'/post-thumbnail-template.php');
297
- }
298
-
299
- // check for post thumbnail
300
- if(has_post_thumbnail($post['ID'])) {
301
- $post_thumbnail = get_post_thumbnail_id($post['ID']);
302
-
303
- // get attachment data (src, width, height)
304
- $image_info = wp_get_attachment_image_src($post_thumbnail, 'single-post-thumbnail');
305
-
306
- // get alt text
307
- $altText = trim(strip_tags(get_post_meta($post_thumbnail, '_wp_attachment_image_alt', true)));
308
- if(strlen($altText) === 0) {
309
- // if the alt text is empty then use the post title
310
- $altText = trim(strip_tags($post['post_title']));
311
- }
312
- }
313
-
314
- if($image_info !== null) {
315
- $post_image = array(
316
- 'src' => $image_info[0],
317
- 'width' => $image_info[1],
318
- 'height' => $image_info[2],
319
- 'alt' => urlencode($altText)
320
- );
321
- } else {
322
- $matches = $matches2 = array();
323
-
324
- $output = preg_match_all('/<img.+src=['."'".'"]([^'."'".'"]+)['."'".'"].*>/i', $post['post_content'], $matches);
325
-
326
- if(isset($matches[0][0])){
327
- preg_match_all('/(src|height|width|alt)="([^"]*)"/i', $matches[0][0], $matches2);
328
-
329
- if(isset($matches2[1])){
330
- foreach($matches2[1] as $k2 => $v2) {
331
- if(in_array($v2, array('src', 'width', 'height', 'alt'))) {
332
- if($post_image === null) $post_image = array();
333
-
334
- if($v2 === 'alt') {
335
- // special case for alt text as it requireds url encoding
336
- $post_image[$v2] = urlencode($matches2[2][$k2]);
337
- } else {
338
- // otherwise simply get the value
339
- $post_image[$v2] = $matches2[2][$k2];
340
- }
341
- }
342
- }
343
- }
344
- }
345
- }
346
-
347
- $helper_images = WYSIJA::get('image','helper');
348
- $post_image = $helper_images->valid_image($post_image);
349
-
350
- if($post_image===null) return $post_image;
351
- return array_merge($post_image, array('url' => get_permalink($post['ID'])));
352
- }
353
-
354
-
355
-
356
- function convertEmbeddedContent($content = '') {
357
- // remove embedded video and replace with links
358
- $content = preg_replace('#<iframe.*?src=\"(.+?)\".*><\/iframe>#', '<a href="$1">'.__('Click here to view media.', WYSIJA).'</a>', $content);
359
-
360
- // replace youtube links
361
- $content = preg_replace('#http://www.youtube.com/embed/([a-zA-Z0-9_-]*)#Ui', 'http://www.youtube.com/watch?v=$1', $content);
362
-
363
- return $content;
364
- }
365
-
366
- function getFilterByType($params = array()) {
367
- if(array_key_exists('value', $params)) {
368
- $value = $params['value'];
369
- } else {
370
- return;
371
- }
372
-
373
- // make sure value is null if it's an empty string
374
- if($value !== null and strlen(trim($value)) === 0) $value = null;
375
-
376
- // get all post types
377
- $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
378
- $post_types = $helper_wp_tools->get_post_types();
379
-
380
- // build post type selection
381
- $output = '<select name="post_type" id="post_type">';
382
-
383
- if(isset($params['label'])) {
384
- $output .= '<option value=""'.(($value === null) ? ' selected="selected"' : '').'>'.$params['label'].'</option>';
385
- }
386
- $output .= '<option value="post"'.(($value === 'post') ? ' selected="selected"' : '').'>'.__('Posts',WYSIJA).'</option>';
387
- $output .= '<option value="page"'.(($value === 'page') ? ' selected="selected"' : '').'>'.__('Pages',WYSIJA).'</option>';
388
-
389
- foreach($post_types as $key=> $object_post_type) {
390
- $selected = ($value === $key) ? ' selected="selected"' : '';
391
- $output .= '<option value="'.$key.'"'.$selected.'>'.$object_post_type->labels->name.'</option>';
392
- }
393
- $output .= '</select>';
394
- return $output;
395
- }
396
-
397
- function getFilterByCategory($value = null, $post_type = 'post') {
398
- // make sure value is null if it's an empty string
399
- if($value !== null and strlen(trim($value)) === 0) $value = null;
400
-
401
- $helper_wp_tools = WYSIJA::get('wp_tools','helper');
402
- $categories = $helper_wp_tools->get_categories();
403
-
404
- $output = '';
405
- foreach($categories as $cpt => $categories_of_cpt){
406
- $output .= '<select id="post_category_'.$cpt.'" name="category_ids" class="post_category">';
407
- $output .= '<option value="">'.__('Filter by category', WYSIJA).'</option>';
408
- foreach($categories_of_cpt as $category) {
409
- $output .= '<option value="'.$category['id'].'">'.$category['name'].'</option>';
410
- }
411
- $output .= '</select>';
412
- }
413
- return $output;
414
- }
415
-
416
-
417
- function getFilterByStatus($current_status = 'publish') {
418
- $output = '';
419
-
420
- $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
421
- $statuses = $helper_wp_tools->get_post_statuses();
422
-
423
- $output .= '<select id="post_status" name="post_status" class="post_status">';
424
- $output .= '<option value="">'.__('Filter by status', WYSIJA).'</option>';
425
- foreach($statuses as $key => $label) {
426
- $is_selected = ($current_status === $key) ? 'selected="selected"' : '';
427
- $output .= '<option value="'.$key.'" '.$is_selected.'>'.$label.'</option>';
428
- }
429
- $output .= '</select>';
430
- return $output;
431
- }
432
  }
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_help_articles extends WYSIJA_object {
4
 
5
+ function WYSIJA_help_articles() {
6
+
7
+ }
8
+
9
+ function stripShortcodes($content) {
10
+ if(strlen(trim($content)) === 0) {
11
+ return '';
12
+ }
13
+ // remove captions
14
+ $content = preg_replace("/\[caption.*?\](.*<\/a>)(.*?)\[\/caption\]/", '$1', $content);
15
+
16
+ // remove other shortcodes
17
+ $content = preg_replace('/\[[^\[\]]*\]/', '', $content);
18
+
19
+ return $content;
20
+ }
21
+
22
+ function convertPostToBlock($post, $params = array()) {
23
+
24
+ // defaults
25
+ $defaults = array(
26
+ 'title_tag' => 'h1',
27
+ 'title_alignment' => 'left',
28
+ 'title_position' => 'inside',
29
+ 'image_alignment' => 'left',
30
+ 'image_width' => 325,
31
+ 'readmore' => __('Read online.', WYSIJA),
32
+ 'post_content' => 'full',
33
+ 'author_show' => 'no',
34
+ 'author_label' => '',
35
+ 'category_show' => 'no',
36
+ 'category_label' => ''
37
+ );
38
+
39
+ // merge params with default params
40
+ $params = array_merge($defaults, $params);
41
+
42
+ if($params['post_content'] === 'full') {
43
+ $content = $post['post_content'];
44
+ } else if($params['post_content'] === 'title') {
45
+ $content = $this->getPostTitle($post, $params);
46
+ } else {
47
+ // get excerpt
48
+ if(!empty($post['post_excerpt'])) {
49
+ $content = $post['post_excerpt'];
50
+ } else {
51
+ // strip shortcodes before getting the excerpt
52
+ $post['post_content'] = $this->stripShortcodes($post['post_content']);
53
+
54
+ // if excerpt is empty then try to find the "more" tag
55
+ $excerpts = explode('<!--more-->', $post['post_content']);
56
+ if(count($excerpts) > 1){
57
+ $content = $excerpts[0];
58
+ }else{
59
+ // finally get a made up excerpt if there is no other choice
60
+ $helper_toolbox = WYSIJA::get('toolbox', 'helper');
61
+ $content = $helper_toolbox->excerpt($post['post_content'], apply_filters('mpoet_excerpt_length', 60));
62
+ }
63
+ }
64
+ // strip title tags from excerpt
65
+ $content = preg_replace('/<([\/])?h[123456](.*?)>/', '<$1p$2>', $content);
66
+ }
67
+
68
+ // convert new lines into <p>
69
+ $content = wpautop($content);
70
+
71
+ // remove images
72
+ $content = preg_replace('/<img[^>]+./','', $content);
73
+
74
+ // strip shortcodes
75
+ $content = $this->stripShortcodes($content);
76
+
77
+ // remove wysija nl shortcode
78
+ $content= preg_replace('/\<div class="wysija-register">(.*?)\<\/div>/','',$content);
79
+
80
+ // convert embedded content if necessary
81
+ $content = $this->convertEmbeddedContent($content);
82
+
83
+ // convert h4 h5 h6 to h3
84
+ $content = preg_replace('/<([\/])?h[456](.*?)>/', '<$1h3$2>', $content);
85
+
86
+ // convert ol to ul
87
+ $content = preg_replace('/<([\/])?ol(.*?)>/', '<$1ul$2>', $content);
88
+
89
+ // convert currency signs
90
+ $content = str_replace(array('$', '€', '£', '¥'), array('&#36;', '&euro;', '&pound;', '&#165;'), $content);
91
+
92
+ // strip useless tags
93
+ // TODO should we add table, tr, td and th into that list it could create issues in some cases
94
+ $tags_not_being_stripped = array('<p>','<em>','<span>','<b>','<strong>','<i>','<h1>','<h2>','<h3>','<a>','<ul>','<ol>','<li>','<br>');
95
+
96
+ // filter to modify that list
97
+ $tags_not_being_stripped = apply_filters('mpoet_strip_tags_ignored',$tags_not_being_stripped);
98
+
99
+ $content = strip_tags($content, implode('',$tags_not_being_stripped));
100
+
101
+ // post meta (author, categories)
102
+ $post_meta_above = '';
103
+ // if the author or categories are displayed, open a new paragraph
104
+ if($params['author_show'] === 'above' || $params['category_show'] === 'above') {
105
+ $post_meta_above .= '<p>';
106
+ }
107
+
108
+ // author above
109
+ if($params['author_show'] === 'above') {
110
+ $post_meta_above .= $this->getPostAuthor($post, $params);
111
+ }
112
+ // categories above
113
+ if($params['category_show'] === 'above') {
114
+ // if there is an author already, we need to add an extra break
115
+ if($params['author_show'] === 'above') {
116
+ $post_meta_above .= '<br />';
117
+ }
118
+ // display post categories
119
+ $post_meta_above .= $this->getPostCategories($post, $params);
120
+ }
121
+
122
+ // close the paragraph around author and categories
123
+ if($params['author_show'] === 'above' || $params['category_show'] === 'above') {
124
+ $post_meta_above .= '</p>';
125
+ }
126
+
127
+ if($params['post_content'] !== 'title') {
128
+ if($params['title_position'] === 'inside') {
129
+ // add title
130
+ $content = $this->getPostTitle($post, $params).$post_meta_above.$content;
131
+ } else {
132
+ $content = $post_meta_above.$content;
133
+ }
134
+ } else {
135
+ $content = $post_meta_above.$content;
136
+ }
137
+
138
+ if($params['post_content'] !== 'title') {
139
+ // add read online link
140
+ $content .= '<p><a href="'.get_permalink($post['ID']).'" target="_blank">'.stripslashes($params['readmore']).'</a></p>';
141
+ }
142
+
143
+ // post meta (author, categories) below
144
+ $post_meta_below = '';
145
+
146
+ // if the author or categories are displayed, open a new paragraph
147
+ if($params['author_show'] === 'below' || $params['category_show'] === 'below') {
148
+ $post_meta_below .= '<p>';
149
+ }
150
+
151
+ // author below
152
+ if($params['author_show'] === 'below') {
153
+ $post_meta_below .= $this->getPostAuthor($post, $params);
154
+ }
155
+
156
+ // categories below
157
+ if($params['category_show'] === 'below') {
158
+ // if there is an author already, we need to add an extra break
159
+ if($params['author_show'] === 'below') {
160
+ $post_meta_below .= '<br />';
161
+ }
162
+ $post_meta_below .= $this->getPostCategories($post, $params);
163
+ }
164
+
165
+ // close the paragraph around author and categories
166
+ if($params['author_show'] === 'below' || $params['category_show'] === 'below') {
167
+ $post_meta_below .= '</p>';
168
+ }
169
+
170
+ if($post_meta_below !== '') $content .= $post_meta_below;
171
+
172
+ // set image/text alignment based on present data
173
+ $post_image = null;
174
+
175
+ if(($params['title_tag'] !== 'list') && isset($post['post_image'])) {
176
+ $post_image = $post['post_image'];
177
+
178
+ // set image alignment to match block's
179
+ $post_image['alignment'] = $params['image_alignment'];
180
+
181
+ // constrain size depending on alignment
182
+ if(empty($post_image['height']) or $post_image['height'] === 0) {
183
+ $post_image = null;
184
+ } else {
185
+ $ratio = round(($post_image['width'] / $post_image['height']) * 1000) / 1000;
186
+ switch($params['image_alignment']) {
187
+ case 'alternate':
188
+ case 'left':
189
+ case 'right':
190
+ // constrain width to 325px max
191
+ $post_image['width'] = min($params['image_width'], 325);
192
+ break;
193
+ case 'center':
194
+ // constrain width to 564px max
195
+ $post_image['width'] = min($params['image_width'], 564);
196
+ break;
197
+ }
198
+
199
+ if($ratio > 0) {
200
+ // if ratio has been calculated, deduce image height
201
+ $post_image['height'] = (int)($post_image['width'] / $ratio);
202
+ } else {
203
+ // otherwise skip the image
204
+ $post_image = null;
205
+ }
206
+ }
207
+ }
208
+
209
+ $position = 0;
210
+ if(isset($params['position']) && (int)$params['position'] > 0) {
211
+ $position = (int)$params['position'];
212
+ }
213
+
214
+ $block = array(
215
+ 'position' => $position,
216
+ 'type' => 'content',
217
+ 'text' => array(
218
+ 'value' => base64_encode($content)
219
+ ),
220
+ 'image' => $post_image,
221
+ 'alignment' => $params['image_alignment']
222
+ );
223
+
224
+ return $block;
225
+ }
226
+
227
+ public function getPostAuthor($post = array(), $params = array()) {
228
+ $content = '';
229
+
230
+ if(isset($post['post_author'])) {
231
+ $author_name = get_the_author_meta('display_name', (int)$post['post_author']);
232
+
233
+ // check if the user specified a label to be displayed before the author's name
234
+ if(strlen(trim($params['author_label'])) > 0) {
235
+ $author_name = stripslashes(trim($params['author_label'])).' '.$author_name;
236
+ }
237
+ $content .= $author_name;
238
+ }
239
+
240
+ return $content;
241
+ }
242
+
243
+ public function getPostCategories($post = array(), $params = array()) {
244
+ $content = '';
245
+
246
+ // get categories
247
+ //$categories = get_the_category($post['ID']);
248
+ $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
249
+ $categories = $helper_wp_tools->get_post_categories($post);
250
+
251
+ if(empty($categories) === false) {
252
+ // check if the user specified a label to be displayed before the author's name
253
+ if(strlen(trim($params['category_label'])) > 0) {
254
+ $content = stripslashes($params['category_label']).' ';
255
+ }
256
+
257
+ $content .= join(', ', $categories);
258
+ }
259
+
260
+ return $content;
261
+ }
262
+
263
+ public function getPostTitle($post = array(), $params = array()) {
264
+ $content = '';
265
+
266
+ if(strlen(trim($post['post_title'])) > 0) {
267
+ // cleanup post title and convert currency signs
268
+ $post_title = trim(str_replace(array('$', '€', '£', '¥'), array('&#36;', '&euro;', '&pound;', '&#165;'), strip_tags($post['post_title'])));
269
+
270
+ // open title tag
271
+ if($params['title_tag'] === 'list') {
272
+ $params['title_tag'] = 'li';
273
+ }
274
+
275
+ $content .= '<'.$params['title_tag'].' class="align-'.$params['title_alignment'].'">';
276
+ // set title link
277
+ $content .= '<a href="'.get_permalink($post['ID']).'" target="_blank">';
278
+ // set title
279
+ $content .= $post_title;
280
+ // close title link
281
+ $content .= '</a>';
282
+ // close title tag
283
+ $content .= '</'.$params['title_tag'].'>';
284
+
285
+ }
286
+
287
+ return $content;
288
+ }
289
+
290
+ function getImage($post) {
291
+ $image_info = null;
292
+ $post_image = null;
293
+
294
+ // check if has_post_thumbnail function exists, if not, include wordpress class
295
+ if(!function_exists('has_post_thumbnail')) {
296
+ require_once(ABSPATH.WPINC.'/post-thumbnail-template.php');
297
+ }
298
+
299
+ // check for post thumbnail
300
+ if(has_post_thumbnail($post['ID'])) {
301
+ $post_thumbnail = get_post_thumbnail_id($post['ID']);
302
+
303
+ // get attachment data (src, width, height)
304
+ $image_info = wp_get_attachment_image_src($post_thumbnail, 'single-post-thumbnail');
305
+
306
+ // get alt text
307
+ $altText = trim(strip_tags(get_post_meta($post_thumbnail, '_wp_attachment_image_alt', true)));
308
+ if(strlen($altText) === 0) {
309
+ // if the alt text is empty then use the post title
310
+ $altText = trim(strip_tags($post['post_title']));
311
+ }
312
+ }
313
+
314
+ if($image_info !== null) {
315
+ $post_image = array(
316
+ 'src' => $image_info[0],
317
+ 'width' => $image_info[1],
318
+ 'height' => $image_info[2],
319
+ 'alt' => urlencode($altText)
320
+ );
321
+ } else {
322
+ $matches = $matches2 = array();
323
+
324
+ $output = preg_match_all('/<img.+src=['."'".'"]([^'."'".'"]+)['."'".'"].*>/i', $post['post_content'], $matches);
325
+
326
+ if(isset($matches[0][0])){
327
+ preg_match_all('/(src|height|width|alt)="([^"]*)"/i', $matches[0][0], $matches2);
328
+
329
+ if(isset($matches2[1])){
330
+ foreach($matches2[1] as $k2 => $v2) {
331
+ if(in_array($v2, array('src', 'width', 'height', 'alt'))) {
332
+ if($post_image === null) $post_image = array();
333
+
334
+ if($v2 === 'alt') {
335
+ // special case for alt text as it requireds url encoding
336
+ $post_image[$v2] = urlencode($matches2[2][$k2]);
337
+ } else {
338
+ // otherwise simply get the value
339
+ $post_image[$v2] = $matches2[2][$k2];
340
+ }
341
+ }
342
+ }
343
+ }
344
+ }
345
+ }
346
+
347
+ $helper_images = WYSIJA::get('image','helper');
348
+ $post_image = $helper_images->valid_image($post_image);
349
+
350
+ if($post_image===null) return $post_image;
351
+ return array_merge($post_image, array('url' => get_permalink($post['ID'])));
352
+ }
353
+
354
+
355
+
356
+ function convertEmbeddedContent($content = '') {
357
+ // remove embedded video and replace with links
358
+ $content = preg_replace('#<iframe.*?src=\"(.+?)\".*><\/iframe>#', '<a href="$1">'.__('Click here to view media.', WYSIJA).'</a>', $content);
359
+
360
+ // replace youtube links
361
+ $content = preg_replace('#http://www.youtube.com/embed/([a-zA-Z0-9_-]*)#Ui', 'http://www.youtube.com/watch?v=$1', $content);
362
+
363
+ return $content;
364
+ }
365
+
366
+ function field_select_post_type( $params = array() ) {
367
+ if ( array_key_exists( 'value', $params ) ) {
368
+ $value = $params['value'];
369
+ } else {
370
+ return;
371
+ }
372
+
373
+ // make sure value is null if it's an empty string
374
+ if ( $value !== null && strlen( trim( $value ) ) === 0 ){
375
+ $value = null;
376
+ }
377
+
378
+ // get all post types
379
+ $helper_wp_tools = WYSIJA::get( 'wp_tools', 'helper' );
380
+ $post_types = $helper_wp_tools->get_post_types();
381
+
382
+ // build post type selection
383
+ $output = '<select name="post_type" data-placeholder="' . esc_attr__( 'Filter by type', WYSIJA ) . '" class="mailpoet-field-select2-simple" data-minimum-results-for-search="-1" style="margin-right: 5px;" width="150" id="post_type">';
384
+ $output .= '<option></option>'; // This is require because of Select2 placeholding structure
385
+ $output .= '<option value="post"' . ( ( $value === 'post' ) ? ' selected="selected"' : '' ) . '>' . __( 'Posts', WYSIJA ) . '</option>';
386
+ $output .= '<option value="page"' . ( ( $value === 'page' ) ? ' selected="selected"' : '' ) . '>' . __( 'Pages', WYSIJA ) . '</option>';
387
+
388
+ foreach ( $post_types as $key => $object_post_type ) {
389
+ $selected = ($value === $key) ? ' selected="selected"' : '';
390
+ $output .= '<option value="'.$key.'"'.$selected.'>'.$object_post_type->labels->name.'</option>';
391
+ }
392
+ $output .= '</select>';
393
+ return $output;
394
+ }
395
+
396
+ function field_select_terms() {
397
+ return '<input name="post_category" data-placeholder="' . esc_attr__( 'Categories and tags', WYSIJA ) . '" class="mailpoet-field-select2-terms post_category" style="margin-right: 5px; width: 180px" width="180" value="" data-multilple="false" type="hidden">';
398
+ }
399
+
400
+
401
+ function field_select_status( $current_status = 'publish' ) {
402
+ $output = '';
403
+
404
+ $helper_wp_tools = WYSIJA::get( 'wp_tools', 'helper' );
405
+ $statuses = $helper_wp_tools->get_post_statuses();
406
+
407
+ $output .= '<select data-placeholder="' . esc_attr__( 'Filter by status', WYSIJA ) . '" class="mailpoet-field-select2-simple post_status" data-minimum-results-for-search="-1" id="post_status" name="post_status" width="150">';
408
+ $output .= '<option></option>'; // This is require because of Select2 placeholding structure
409
+ foreach ( $statuses as $key => $label ) {
410
+ $is_selected = ( $current_status === $key ) ? 'selected="selected"' : '';
411
+ $output .= '<option value="' . $key . '" ' . $is_selected . '>' . $label . '</option>';
412
+ }
413
+ $output .= '</select>';
414
+ return $output;
415
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  }
helpers/backloader.php CHANGED
@@ -239,6 +239,16 @@ class WYSIJA_help_backloader extends WYSIJA_help{
239
 
240
  break;
241
 
 
 
 
 
 
 
 
 
 
 
242
  case 'wysija-form-editor':
243
  wp_enqueue_script( 'wysija-prototype', WYSIJA_URL . 'js/prototype/prototype.js', array(), WYSIJA::get_version() );
244
  wp_enqueue_script( 'wysija-proto-scriptaculous', WYSIJA_URL . 'js/prototype/scriptaculous.js', array( 'wysija-prototype' ), WYSIJA::get_version() );
@@ -312,6 +322,11 @@ class WYSIJA_help_backloader extends WYSIJA_help{
312
  wp_enqueue_style( 'mailpoet.tooltip', WYSIJA_URL . 'css/vendor/bootstrap.tooltip.css', array(), WYSIJA::get_version(), 'screen' );
313
  break;
314
 
 
 
 
 
 
315
  default:
316
  if ( is_string( $kjs ) ) {
317
  // check if there's a trailing slash in the urlbase
239
 
240
  break;
241
 
242
+ case 'mailpoet-field-select2-terms':
243
+ wp_enqueue_script( 'mailpoet-field-select2-terms', WYSIJA_URL . 'js/fields/select2-terms.js', array( 'jquery', 'underscore', 'mailpoet-select2' ), WYSIJA::get_version() );
244
+
245
+ break;
246
+
247
+ case 'mailpoet-field-select2-simple':
248
+ wp_enqueue_script( 'mailpoet-field-select2-simple', WYSIJA_URL . 'js/fields/select2-simple.js', array( 'jquery', 'underscore', 'mailpoet-select2' ), WYSIJA::get_version() );
249
+
250
+ break;
251
+
252
  case 'wysija-form-editor':
253
  wp_enqueue_script( 'wysija-prototype', WYSIJA_URL . 'js/prototype/prototype.js', array(), WYSIJA::get_version() );
254
  wp_enqueue_script( 'wysija-proto-scriptaculous', WYSIJA_URL . 'js/prototype/scriptaculous.js', array( 'wysija-prototype' ), WYSIJA::get_version() );
322
  wp_enqueue_style( 'mailpoet.tooltip', WYSIJA_URL . 'css/vendor/bootstrap.tooltip.css', array(), WYSIJA::get_version(), 'screen' );
323
  break;
324
 
325
+ case 'wysija-import-match':
326
+ wp_enqueue_script('jquery-matchColumn', WYSIJA_URL.'js/jquery/jquery.matchColumn.js', array('jquery'), WYSIJA::get_version());
327
+ wp_enqueue_script('jquery-userStatusMapping', WYSIJA_URL.'js/jquery/jquery.userStatusMapping.js', array('jquery'), WYSIJA::get_version());
328
+ break;
329
+
330
  default:
331
  if ( is_string( $kjs ) ) {
332
  // check if there's a trailing slash in the urlbase
helpers/email.php CHANGED
@@ -16,9 +16,11 @@ class WYSIJA_help_email extends WYSIJA_object{
16
 
17
  //delete the view in browser span
18
  $content = preg_replace('#<td id="wysija_viewbrowser_content"[^>]*>(.*)</td>#Uis','',$content);
 
19
 
20
  //delete the unsubscribe td
21
  $content = preg_replace('#<td id="wysija_unsubscribe_content"[^>]*>(.*)</td>#Uis','',$content);
 
22
 
23
  return $content;
24
 
@@ -90,6 +92,10 @@ class WYSIJA_help_email extends WYSIJA_object{
90
  $current_user=WYSIJA::wp_get_userdata();
91
  $mailer->testemail=true;
92
  $mailer->wp_user=&$current_user->data;
 
 
 
 
93
 
94
  $res=$mailer->sendSimple($current_user->data->user_email,str_replace('[send_method]',$send_method,__('[send_method] works with MailPoet',WYSIJA)),$content_email);
95
 
16
 
17
  //delete the view in browser span
18
  $content = preg_replace('#<td id="wysija_viewbrowser_content"[^>]*>(.*)</td>#Uis','',$content);
19
+ $content = preg_replace('#<p *class="wysija_viewbrowser_container"[^>]*>(.*)</p>#Uis','',$content);
20
 
21
  //delete the unsubscribe td
22
  $content = preg_replace('#<td id="wysija_unsubscribe_content"[^>]*>(.*)</td>#Uis','',$content);
23
+ $content = preg_replace('#<p *class="wysija_unsubscribe_container"[^>]*>(.*)</p>#Uis','',$content);
24
 
25
  return $content;
26
 
92
  $current_user=WYSIJA::wp_get_userdata();
93
  $mailer->testemail=true;
94
  $mailer->wp_user=&$current_user->data;
95
+ // If users enter a custom email, let's send to that address
96
+ if (isset($values['test_mails']) && trim($values['test_mails']) != '') {
97
+ $current_user->data->user_email = $values['test_mails'];
98
+ }
99
 
100
  $res=$mailer->sendSimple($current_user->data->user_email,str_replace('[send_method]',$send_method,__('[send_method] works with MailPoet',WYSIJA)),$content_email);
101
 
helpers/mailer.php CHANGED
@@ -191,11 +191,11 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
191
 
192
  function send(){
193
  // prevent user/script details being exposed in X-PHP-Script header
194
- $oldphpself = $_SERVER['PHP_SELF'];
195
- $oldremoteaddr = $_SERVER['REMOTE_ADDR'];
196
 
197
  $_SERVER['PHP_SELF'] = "/";
198
- $_SERVER['REMOTE_ADDR'] = $_SERVER['SERVER_ADDR'];
199
 
200
  if(!empty($this->sendHTML)){
201
  $this->AltBody = $this->textVersion($this->Body,true);
@@ -1091,10 +1091,4 @@ class WYSIJA_help_mailer extends acymailingPHPMailer {
1091
  $this->sendHTML = $ishtml;
1092
  }
1093
 
1094
- }
1095
-
1096
- class WYSIJA_sendfalse {
1097
- function send(){
1098
- return true;
1099
- }
1100
- }
191
 
192
  function send(){
193
  // prevent user/script details being exposed in X-PHP-Script header
194
+ $oldphpself = ( isset( $_SERVER['PHP_SELF'] ) ? $_SERVER['PHP_SELF'] : '' );
195
+ $oldremoteaddr = ( isset( $_SERVER['PHP_SELF'] ) ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1' );
196
 
197
  $_SERVER['PHP_SELF'] = "/";
198
+ $_SERVER['REMOTE_ADDR'] = ( isset( $_SERVER['PHP_SELF'] ) ? $_SERVER['SERVER_ADDR'] : '127.0.0.1' );
199
 
200
  if(!empty($this->sendHTML)){
201
  $this->AltBody = $this->textVersion($this->Body,true);
1091
  $this->sendHTML = $ishtml;
1092
  }
1093
 
1094
+ }
 
 
 
 
 
 
helpers/render_engine.php CHANGED
@@ -85,11 +85,6 @@ class WYSIJA_help_render_engine extends WYSIJA_object {
85
  $this->_vars = $vars;
86
 
87
  if($this->_inline) {
88
- // remove html comments
89
- $string = preg_replace("#\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>#", '', $string);
90
- // remove multiline comments
91
- $string = preg_replace("#(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/)#", '', $string);
92
-
93
  // inline mode (removes any tabs, carriage return, line breaks)
94
  $string = preg_replace("#(\t|\r|\n)#UiS", '', trim($string));
95
  $string = preg_replace("#> +<#UiS", '><', $string);
85
  $this->_vars = $vars;
86
 
87
  if($this->_inline) {
 
 
 
 
 
88
  // inline mode (removes any tabs, carriage return, line breaks)
89
  $string = preg_replace("#(\t|\r|\n)#UiS", '', trim($string));
90
  $string = preg_replace("#> +<#UiS", '><', $string);
helpers/themes.php CHANGED
@@ -257,8 +257,9 @@ class WYSIJA_help_themes extends WYSIJA_object{
257
  return false;
258
  }
259
 
260
- $timecreated=time();
261
- $dirthemetemp=$helperF->makeDir('temp'.DS.'temp_'.$timecreated,0777);
 
262
 
263
  $zipclass=WYSIJA::get('zip','helper');
264
  if(!$zipclass->unzip_wp($tempzipfile,$dirthemetemp)) {
@@ -276,13 +277,28 @@ class WYSIJA_help_themes extends WYSIJA_object{
276
  $helperF->rrmdir($dirthemetemp);
277
  return false;
278
  }else{
279
-
280
  if(!in_array($filename, array('.','..','.DS_Store','Thumbs.db'))) $theme_key=$filename;
281
  }
282
  }
283
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  if(!$theme_key){
285
  $this->error('There was an error while unzipping the file :'.$tempzipfile.' to the folder: '.$dirthemetemp);
 
286
  return false;
287
  }
288
 
@@ -291,6 +307,7 @@ class WYSIJA_help_themes extends WYSIJA_object{
291
  //make sure we don't overwrite existing folder
292
  if($manual && !isset($_REQUEST['overwriteexistingtheme']) && file_exists($dirtheme.DS.$theme_key)){
293
  $this->error(sprintf(__('A theme called %1$s exists already. To overwrite it, tick the corresponding checkbox before uploading.',WYSIJA),'<strong>'.$theme_key.'</strong>'),1);
 
294
  return false;
295
  }
296
 
257
  return false;
258
  }
259
 
260
+ //$timecreated=time();
261
+ $timecreated = substr( md5(rand()), 0, 20);
262
+ $dirthemetemp=$helperF->makeDir('temp'.DS.'temp_'.$timecreated,0755);
263
 
264
  $zipclass=WYSIJA::get('zip','helper');
265
  if(!$zipclass->unzip_wp($tempzipfile,$dirthemetemp)) {
277
  $helperF->rrmdir($dirthemetemp);
278
  return false;
279
  }else{
 
280
  if(!in_array($filename, array('.','..','.DS_Store','Thumbs.db'))) $theme_key=$filename;
281
  }
282
  }
283
 
284
+ // making sure this theme only has allowed files in its folders and subfolders
285
+ $dir_iterator = new RecursiveDirectoryIterator($dirthemetemp);
286
+ $iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
287
+
288
+ $allowed_extensions = array('png', 'jpg', 'jpeg', 'gif', 'css', 'txt');
289
+
290
+ foreach ($iterator as $file) {
291
+
292
+ if( !$file->isDir() && !in_array( pathinfo( $file->getBasename(), PATHINFO_EXTENSION ), $allowed_extensions)) {
293
+ $this->error(sprintf('Your theme is not valid. It can only contain files that have the following extensions: "%s"', join('", "', $allowed_extensions)));
294
+ $helperF->rrmdir($dirthemetemp);
295
+ return false;
296
+ }
297
+ }
298
+
299
  if(!$theme_key){
300
  $this->error('There was an error while unzipping the file :'.$tempzipfile.' to the folder: '.$dirthemetemp);
301
+ $helperF->rrmdir($dirthemetemp);
302
  return false;
303
  }
304
 
307
  //make sure we don't overwrite existing folder
308
  if($manual && !isset($_REQUEST['overwriteexistingtheme']) && file_exists($dirtheme.DS.$theme_key)){
309
  $this->error(sprintf(__('A theme called %1$s exists already. To overwrite it, tick the corresponding checkbox before uploading.',WYSIJA),'<strong>'.$theme_key.'</strong>'),1);
310
+ $helperF->rrmdir($dirthemetemp);
311
  return false;
312
  }
313
 
helpers/wj_engine.php CHANGED
@@ -942,6 +942,7 @@ class WYSIJA_help_wj_engine extends WYSIJA_object {
942
 
943
  try {
944
  $template = $helper_render_engine->render($data, 'templates/newsletter/email/email_template.html');
 
945
 
946
  return $template;
947
  } catch(Exception $e) {
@@ -1267,7 +1268,14 @@ class WYSIJA_help_wj_engine extends WYSIJA_object {
1267
  // set auto newsletter parameters
1268
  $email['params']['autonl']['articles']['count'] = $post_count;
1269
  $email['params']['autonl']['articles']['first_subject'] = $first_subject;
1270
- $email['params']['autonl']['articles']['ids'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $post_ids));
 
 
 
 
 
 
 
1271
 
1272
  $this->setEmailData($email);
1273
  }
942
 
943
  try {
944
  $template = $helper_render_engine->render($data, 'templates/newsletter/email/email_template.html');
945
+ $template = preg_replace('/\s*(?!<\")\/\*[^\*]+\*\/(?!\")\s*/', '', $template);
946
 
947
  return $template;
948
  } catch(Exception $e) {
1268
  // set auto newsletter parameters
1269
  $email['params']['autonl']['articles']['count'] = $post_count;
1270
  $email['params']['autonl']['articles']['first_subject'] = $first_subject;
1271
+ // merge post ids
1272
+ if(!isset( $email['params']['autonl']['articles']['ids'])) {
1273
+ $email['params']['autonl']['articles']['ids'] = array();
1274
+ }
1275
+ $email['params']['autonl']['articles']['ids'] = array_unique(array_merge(
1276
+ (array)$email['params']['autonl']['articles']['ids'],
1277
+ (array)$post_ids
1278
+ ));
1279
 
1280
  $this->setEmailData($email);
1281
  }
inc/dBug.php CHANGED
@@ -1,549 +1,549 @@
1
- <?php
2
- /*********************************************************************************************************************\
3
- * LAST UPDATE
4
- * ============
5
- * March 22, 2007
6
- *
7
- *
8
- * AUTHOR
9
- * =============
10
- * Kwaku Otchere
11
- * ospinto@hotmail.com
12
- *
13
- * Thanks to Andrew Hewitt (rudebwoy@hotmail.com) for the idea and suggestion
14
- *
15
- * All the credit goes to ColdFusion's brilliant cfdump tag
16
- * Hope the next version of PHP can implement this or have something similar
17
- * I love PHP, but var_dump BLOWS!!!
18
- *
19
- * FOR DOCUMENTATION AND MORE EXAMPLES: VISIT http://dbug.ospinto.com
20
- *
21
- *
22
- * PURPOSE
23
- * =============
24
- * Dumps/Displays the contents of a variable in a colored tabular format
25
- * Based on the idea, javascript and css code of Macromedia's ColdFusion cfdump tag
26
- * A much better presentation of a variable's contents than PHP's var_dump and print_r functions
27
- *
28
- *
29
- * USAGE
30
- * =============
31
- * new dBug ( variable [,forceType] );
32
- * example:
33
- * new dBug ( $myVariable );
34
- *
35
- *
36
- * if the optional "forceType" string is given, the variable supplied to the
37
- * function is forced to have that forceType type.
38
- * example: new dBug( $myVariable , "array" );
39
- * will force $myVariable to be treated and dumped as an array type,
40
- * even though it might originally have been a string type, etc.
41
- *
42
- * NOTE!
43
- * ==============
44
- * forceType is REQUIRED for dumping an xml string or xml file
45
- * new dBug ( $strXml, "xml" );
46
- *
47
- \*********************************************************************************************************************/
48
-
49
- class dBug {
50
-
51
- var $xmlDepth=array();
52
- var $xmlCData;
53
- var $xmlSData;
54
- var $xmlDData;
55
- var $xmlCount=0;
56
- var $xmlAttrib;
57
- var $xmlName;
58
- var $arrType=array("array","object","resource","boolean","NULL");
59
- var $bInitialized = false;
60
- var $bCollapsed = false;
61
- var $arrHistory = array();
62
-
63
- //constructor
64
- function dBug($var,$forceType="",$bCollapsed=false) {
65
- //include js and css scripts
66
- if(!defined('BDBUGINIT')) {
67
- define("BDBUGINIT", TRUE);
68
- $this->initJSandCSS();
69
- }
70
- $arrAccept=array("array","object","xml"); //array of variable types that can be "forced"
71
- $this->bCollapsed = $bCollapsed;
72
- if(in_array($forceType,$arrAccept))
73
- $this->{"varIs".ucfirst($forceType)}($var);
74
- else
75
- $this->checkType($var);
76
- }
77
-
78
- //get variable name
79
- function getVariableName() {
80
- $arrBacktrace = debug_backtrace();
81
-
82
- //possible 'included' functions
83
- $arrInclude = array("include","include_once","require","require_once");
84
-
85
- //check for any included/required files. if found, get array of the last included file (they contain the right line numbers)
86
- for($i=count($arrBacktrace)-1; $i>=0; $i--) {
87
- $arrCurrent = $arrBacktrace[$i];
88
- if(array_key_exists("function", $arrCurrent) &&
89
- (in_array($arrCurrent["function"], $arrInclude) || (0 != strcasecmp($arrCurrent["function"], "dbug"))))
90
- continue;
91
-
92
- $arrFile = $arrCurrent;
93
-
94
- break;
95
- }
96
-
97
- if(isset($arrFile)) {
98
- $arrLines = file($arrFile["file"]);
99
- $code = $arrLines[($arrFile["line"]-1)];
100
-
101
- //find call to dBug class
102
- preg_match('/\bnew dBug\s*\(\s*(.+)\s*\);/i', $code, $arrMatches);
103
-
104
- return $arrMatches[1];
105
- }
106
- return "";
107
- }
108
-
109
- //create the main table header
110
- function makeTableHeader($type,$header,$colspan=2) {
111
- if(!$this->bInitialized) {
112
- $header = $this->getVariableName() . " (" . $header . ")";
113
- $this->bInitialized = true;
114
- }
115
- $str_i = ($this->bCollapsed) ? "style=\"font-style:italic\" " : "";
116
-
117
- echo "<table cellspacing=2 cellpadding=3 class=\"dBug_".$type."\">
118
- <tr>
119
- <td ".$str_i."class=\"dBug_".$type."Header\" colspan=".$colspan." onClick='dBug_toggleTable(this)'>".$header."</td>
120
- </tr>";
121
- }
122
-
123
- //create the table row header
124
- function makeTDHeader($type,$header) {
125
- $str_d = ($this->bCollapsed) ? " style=\"display:none\"" : "";
126
- echo "<tr".$str_d.">
127
- <td valign=\"top\" onClick='dBug_toggleRow(this)' class=\"dBug_".$type."Key\">".$header."</td>
128
- <td>";
129
- }
130
-
131
- //close table row
132
- function closeTDRow() {
133
- return "</td></tr>\n";
134
- }
135
-
136
- //error
137
- function error($type) {
138
- $error="Error: Variable cannot be a";
139
- // this just checks if the type starts with a vowel or "x" and displays either "a" or "an"
140
- if(in_array(substr($type,0,1),array("a","e","i","o","u","x")))
141
- $error.="n";
142
- return ($error." ".$type." type");
143
- }
144
-
145
- //check variable type
146
- function checkType($var) {
147
- switch(gettype($var)) {
148
- case "resource":
149
- $this->varIsResource($var);
150
- break;
151
- case "object":
152
- $this->varIsObject($var);
153
- break;
154
- case "array":
155
- $this->varIsArray($var);
156
- break;
157
- case "NULL":
158
- $this->varIsNULL();
159
- break;
160
- case "boolean":
161
- $this->varIsBoolean($var);
162
- break;
163
- default:
164
- $var=($var=="") ? "[empty string]" : $var;
165
- $var=$this->convertTimeStampToDate($var);
166
- echo "<table cellspacing=0><tr>\n<td>".$var."</td>\n</tr>\n</table>\n";
167
- break;
168
- }
169
- }
170
-
171
- function convertTimeStampToDate($var){
172
- if($this->varIsValidTimeStamp((string)$var)){
173
- $helper_toolbox=WYSIJA::get('toolbox','helper');
174
- $var=date('d-m-y h:i:s A', $helper_toolbox->servertime_to_localtime($var)).' <small>('.$var.')</small>';
175
- }
176
- return $var;
177
- }
178
-
179
- function varIsValidTimeStamp($timestamp){
180
- return ((string) (int) $timestamp === $timestamp)
181
- && ($timestamp <= PHP_INT_MAX)
182
- && ($timestamp > 100000000)
183
- && ($timestamp >= ~PHP_INT_MAX);
184
- }
185
-
186
- //if variable is a NULL type
187
- function varIsNULL() {
188
- echo "NULL";
189
- }
190
-
191
- //if variable is a boolean type
192
- function varIsBoolean($var) {
193
- $var=($var==1) ? "TRUE" : "FALSE";
194
- echo $var;
195
- }
196
-
197
- //if variable is an array type
198
- function varIsArray($var) {
199
- $var_ser = serialize($var);
200
- array_push($this->arrHistory, $var_ser);
201
-
202
- $this->makeTableHeader("array","array");
203
- if(is_array($var)) {
204
- foreach($var as $key=>$value) {
205
- $this->makeTDHeader("array",$key);
206
-
207
- //check for recursion
208
- if(is_array($value)) {
209
- $var_ser = serialize($value);
210
- if(in_array($var_ser, $this->arrHistory, TRUE))
211
- $value = "*RECURSION*";
212
- }
213
-
214
- if(in_array(gettype($value),$this->arrType))
215
- $this->checkType($value);
216
- else {
217
- $value=(trim($value)=="") ? "[empty string]" : $value;
218
- $value=$this->convertTimeStampToDate($value);
219
-
220
- echo $value;
221
- }
222
- echo $this->closeTDRow();
223
- }
224
- }
225
- else echo "<tr><td>".$this->error("array").$this->closeTDRow();
226
- array_pop($this->arrHistory);
227
- echo "</table>";
228
- }
229
-
230
- //if variable is an object type
231
- function varIsObject($var) {
232
- $var_ser = serialize($var);
233
- array_push($this->arrHistory, $var_ser);
234
- $this->makeTableHeader("object","object");
235
-
236
- //condition modified by BEN used to be : if(is_object($var)) {
237
- if(!empty($var)) {
238
- $arrObjVars=get_object_vars($var);
239
- foreach($arrObjVars as $key=>$value) {
240
-
241
- $value=(!is_object($value) && !is_array($value) && @trim($value)=="") ? "[empty string]" : $value;
242
- $this->makeTDHeader("object",$key);
243
-
244
- //check for recursion
245
- if(is_object($value)||is_array($value)) {
246
- $var_ser = serialize($value);
247
- if(in_array($var_ser, $this->arrHistory, TRUE)) {
248
- $value = (is_object($value)) ? "*RECURSION* -> $".get_class($value) : "*RECURSION*";
249
-
250
- }
251
- }
252
- if(in_array(gettype($value),$this->arrType))
253
- $this->checkType($value);
254
- else echo $value;
255
- echo $this->closeTDRow();
256
- }
257
- $arrObjMethods=get_class_methods(get_class($var));
258
- foreach($arrObjMethods as $key=>$value) {
259
- $this->makeTDHeader("object",$value);
260
- echo "[function]".$this->closeTDRow();
261
- }
262
- }
263
- else echo "<tr><td>".$this->error("object").$this->closeTDRow();
264
- array_pop($this->arrHistory);
265
- echo "</table>";
266
- }
267
-
268
- //if variable is a resource type
269
- function varIsResource($var) {
270
- $this->makeTableHeader("resourceC","resource",1);
271
- echo "<tr>\n<td>\n";
272
- switch(get_resource_type($var)) {
273
- case "fbsql result":
274
- case "mssql result":
275
- case "msql query":
276
- case "pgsql result":
277
- case "sybase-db result":
278
- case "sybase-ct result":
279
- case "mysql result":
280
- $db=current(explode(" ",get_resource_type($var)));
281
- $this->varIsDBResource($var,$db);
282
- break;
283
- case "gd":
284
- $this->varIsGDResource($var);
285
- break;
286
- case "xml":
287
- $this->varIsXmlResource($var);
288
- break;
289
- default:
290
- echo get_resource_type($var).$this->closeTDRow();
291
- break;
292
- }
293
- echo $this->closeTDRow()."</table>\n";
294
- }
295
-
296
- //if variable is a database resource type
297
- function varIsDBResource($var,$db="mysql") {
298
- if($db == "pgsql")
299
- $db = "pg";
300
- if($db == "sybase-db" || $db == "sybase-ct")
301
- $db = "sybase";
302
- $arrFields = array("name","type","flags");
303
- $numrows=call_user_func($db."_num_rows",$var);
304
- $numfields=call_user_func($db."_num_fields",$var);
305
- $this->makeTableHeader("resource",$db." result",$numfields+1);
306
- echo "<tr><td class=\"dBug_resourceKey\">&nbsp;</td>";
307
- for($i=0;$i<$numfields;$i++) {
308
- $field_header = "";
309
- for($j=0; $j<count($arrFields); $j++) {
310
- $db_func = $db."_field_".$arrFields[$j];
311
- if(function_exists($db_func)) {
312
- $fheader = call_user_func($db_func, $var, $i). " ";
313
- if($j==0)
314
- $field_name = $fheader;
315
- else
316
- $field_header .= $fheader;
317
- }
318
- }
319
- $field[$i]=call_user_func($db."_fetch_field",$var,$i);
320
- echo "<td class=\"dBug_resourceKey\" title=\"".$field_header."\">".$field_name."</td>";
321
- }
322
- echo "</tr>";
323
- for($i=0;$i<$numrows;$i++) {
324
- $row=call_user_func($db."_fetch_array",$var,constant(strtoupper($db)."_ASSOC"));
325
- echo "<tr>\n";
326
- echo "<td class=\"dBug_resourceKey\">".($i+1)."</td>";
327
- for($k=0;$k<$numfields;$k++) {
328
- $tempField=$field[$k]->name;
329
- $fieldrow=$row[($field[$k]->name)];
330
- $fieldrow=($fieldrow=="") ? "[empty string]" : $fieldrow;
331
- echo "<td>".$fieldrow."</td>\n";
332
- }
333
- echo "</tr>\n";
334
- }
335
- echo "</table>";
336
- if($numrows>0)
337
- call_user_func($db."_data_seek",$var,0);
338
- }
339
-
340
- //if variable is an image/gd resource type
341
- function varIsGDResource($var) {
342
- $this->makeTableHeader("resource","gd",2);
343
- $this->makeTDHeader("resource","Width");
344
- echo imagesx($var).$this->closeTDRow();
345
- $this->makeTDHeader("resource","Height");
346
- echo imagesy($var).$this->closeTDRow();
347
- $this->makeTDHeader("resource","Colors");
348
- echo imagecolorstotal($var).$this->closeTDRow();
349
- echo "</table>";
350
- }
351
-
352
- //if variable is an xml type
353
- function varIsXml($var) {
354
- $this->varIsXmlResource($var);
355
- }
356
-
357
- //if variable is an xml resource type
358
- function varIsXmlResource($var) {
359
- $xml_parser=xml_parser_create();
360
- xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
361
- xml_set_element_handler($xml_parser,array(&$this,"xmlStartElement"),array(&$this,"xmlEndElement"));
362
- xml_set_character_data_handler($xml_parser,array(&$this,"xmlCharacterData"));
363
- xml_set_default_handler($xml_parser,array(&$this,"xmlDefaultHandler"));
364
-
365
- $this->makeTableHeader("xml","xml document",2);
366
- $this->makeTDHeader("xml","xmlRoot");
367
-
368
- //attempt to open xml file
369
- $bFile=(!($fp=@fopen($var,"r"))) ? false : true;
370
-
371
- //read xml file
372
- if($bFile) {
373
- while($data=str_replace("\n","",fread($fp,4096)))
374
- $this->xmlParse($xml_parser,$data,feof($fp));
375
- }
376
- //if xml is not a file, attempt to read it as a string
377
- else {
378
- if(!is_string($var)) {
379
- echo $this->error("xml").$this->closeTDRow()."</table>\n";
380
- return;
381
- }
382
- $data=$var;
383
- $this->xmlParse($xml_parser,$data,1);
384
- }
385
-
386
- echo $this->closeTDRow()."</table>\n";
387
-
388
- }
389
-
390
- //parse xml
391
- function xmlParse($xml_parser,$data,$bFinal) {
392
- if (!xml_parse($xml_parser,$data,$bFinal)) {
393
- die(sprintf("XML error: %s at line %d\n",
394
- xml_error_string(xml_get_error_code($xml_parser)),
395
- xml_get_current_line_number($xml_parser)));
396
- }
397
- }
398
-
399
- //xml: inititiated when a start tag is encountered
400
- function xmlStartElement($parser,$name,$attribs) {
401
- $this->xmlAttrib[$this->xmlCount]=$attribs;
402
- $this->xmlName[$this->xmlCount]=$name;
403
- $this->xmlSData[$this->xmlCount]='$this->makeTableHeader("xml","xml element",2);';
404
- $this->xmlSData[$this->xmlCount].='$this->makeTDHeader("xml","xmlName");';
405
- $this->xmlSData[$this->xmlCount].='echo "<strong>'.$this->xmlName[$this->xmlCount].'</strong>".$this->closeTDRow();';
406
- $this->xmlSData[$this->xmlCount].='$this->makeTDHeader("xml","xmlAttributes");';
407
- if(count($attribs)>0)
408
- $this->xmlSData[$this->xmlCount].='$this->varIsArray($this->xmlAttrib['.$this->xmlCount.']);';
409
- else
410
- $this->xmlSData[$this->xmlCount].='echo "&nbsp;";';
411
- $this->xmlSData[$this->xmlCount].='echo $this->closeTDRow();';
412
- $this->xmlCount++;
413
- }
414
-
415
- //xml: initiated when an end tag is encountered
416
- function xmlEndElement($parser,$name) {
417
- for($i=0;$i<$this->xmlCount;$i++) {
418
- eval($this->xmlSData[$i]);
419
- $this->makeTDHeader("xml","xmlText");
420
- echo (!empty($this->xmlCData[$i])) ? $this->xmlCData[$i] : "&nbsp;";
421
- echo $this->closeTDRow();
422
- $this->makeTDHeader("xml","xmlComment");
423
- echo (!empty($this->xmlDData[$i])) ? $this->xmlDData[$i] : "&nbsp;";
424
- echo $this->closeTDRow();
425
- $this->makeTDHeader("xml","xmlChildren");
426
- unset($this->xmlCData[$i],$this->xmlDData[$i]);
427
- }
428
- echo $this->closeTDRow();
429
- echo "</table>";
430
- $this->xmlCount=0;
431
- }
432
-
433
- //xml: initiated when text between tags is encountered
434
- function xmlCharacterData($parser,$data) {
435
- $count=$this->xmlCount-1;
436
- if(!empty($this->xmlCData[$count]))
437
- $this->xmlCData[$count].=$data;
438
- else
439
- $this->xmlCData[$count]=$data;
440
- }
441
-
442
- //xml: initiated when a comment or other miscellaneous texts is encountered
443
- function xmlDefaultHandler($parser,$data) {
444
- //strip '<!--' and '-->' off comments
445
- $data=str_replace(array("&lt;!--","--&gt;"),"",htmlspecialchars($data));
446
- $count=$this->xmlCount-1;
447
- if(!empty($this->xmlDData[$count]))
448
- $this->xmlDData[$count].=$data;
449
- else
450
- $this->xmlDData[$count]=$data;
451
- }
452
-
453
- function initJSandCSS() {
454
- echo <<<SCRIPTS
455
- <script language="JavaScript">
456
- /* code modified from ColdFusion's cfdump code */
457
- function dBug_toggleRow(source) {
458
- var target = (document.all) ? source.parentElement.cells[1] : source.parentNode.lastChild;
459
- dBug_toggleTarget(target,dBug_toggleSource(source));
460
- }
461
-
462
- function dBug_toggleSource(source) {
463
- if (source.style.fontStyle=='italic') {
464
- source.style.fontStyle='normal';
465
- source.title='click to collapse';
466
- return 'open';
467
- } else {
468
- source.style.fontStyle='italic';
469
- source.title='click to expand';
470
- return 'closed';
471
- }
472
- }
473
-
474
- function dBug_toggleTarget(target,switchToState) {
475
- target.style.display = (switchToState=='open') ? '' : 'none';
476
- }
477
-
478
- function dBug_toggleTable(source) {
479
- var switchToState=dBug_toggleSource(source);
480
- if(document.all) {
481
- var table=source.parentElement.parentElement;
482
- for(var i=1;i<table.rows.length;i++) {
483
- target=table.rows[i];
484
- dBug_toggleTarget(target,switchToState);
485
- }
486
- }
487
- else {
488
- var table=source.parentNode.parentNode;
489
- for (var i=1;i<table.childNodes.length;i++) {
490
- target=table.childNodes[i];
491
- if(target.style) {
492
- dBug_toggleTarget(target,switchToState);
493
- }
494
- }
495
- }
496
- }
497
- </script>
498
-
499
- <style type="text/css">
500
- table.dBug_array,table.dBug_object,table.dBug_resource,table.dBug_resourceC,table.dBug_xml {
501
- font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000; font-size:12px;
502
- }
503
-
504
- .dBug_arrayHeader,
505
- .dBug_objectHeader,
506
- .dBug_resourceHeader,
507
- .dBug_resourceCHeader,
508
- .dBug_xmlHeader
509
- { font-weight:bold; color:#FFFFFF; cursor:pointer; }
510
-
511
- .dBug_arrayKey,
512
- .dBug_objectKey,
513
- .dBug_xmlKey
514
- { cursor:pointer; }
515
-
516
- /* array */
517
- table.dBug_array { background-color:#006600; }
518
- table.dBug_array td { background-color:#FFFFFF; }
519
- table.dBug_array td.dBug_arrayHeader { background-color:#009900; }
520
- table.dBug_array td.dBug_arrayKey { background-color:#CCFFCC; }
521
-
522
- /* object */
523
- table.dBug_object { background-color:#0000CC; }
524
- table.dBug_object td { background-color:#FFFFFF; }
525
- table.dBug_object td.dBug_objectHeader { background-color:#4444CC; }
526
- table.dBug_object td.dBug_objectKey { background-color:#CCDDFF; }
527
-
528
- /* resource */
529
- table.dBug_resourceC { background-color:#884488; }
530
- table.dBug_resourceC td { background-color:#FFFFFF; }
531
- table.dBug_resourceC td.dBug_resourceCHeader { background-color:#AA66AA; }
532
- table.dBug_resourceC td.dBug_resourceCKey { background-color:#FFDDFF; }
533
-
534
- /* resource */
535
- table.dBug_resource { background-color:#884488; }
536
- table.dBug_resource td { background-color:#FFFFFF; }
537
- table.dBug_resource td.dBug_resourceHeader { background-color:#AA66AA; }
538
- table.dBug_resource td.dBug_resourceKey { background-color:#FFDDFF; }
539
-
540
- /* xml */
541
- table.dBug_xml { background-color:#888888; }
542
- table.dBug_xml td { background-color:#FFFFFF; }
543
- table.dBug_xml td.dBug_xmlHeader { background-color:#AAAAAA; }
544
- table.dBug_xml td.dBug_xmlKey { background-color:#DDDDDD; }
545
- </style>
546
- SCRIPTS;
547
- }
548
-
549
  }
1
+ <?php
2
+ /*********************************************************************************************************************\
3
+ * LAST UPDATE
4
+ * ============
5
+ * March 22, 2007
6
+ *
7
+ *
8
+ * AUTHOR
9
+ * =============
10
+ * Kwaku Otchere
11
+ * ospinto@hotmail.com
12
+ *
13
+ * Thanks to Andrew Hewitt (rudebwoy@hotmail.com) for the idea and suggestion
14
+ *
15
+ * All the credit goes to ColdFusion's brilliant cfdump tag
16
+ * Hope the next version of PHP can implement this or have something similar
17
+ * I love PHP, but var_dump BLOWS!!!
18
+ *
19
+ * FOR DOCUMENTATION AND MORE EXAMPLES: VISIT http://dbug.ospinto.com
20
+ *
21
+ *
22
+ * PURPOSE
23
+ * =============
24
+ * Dumps/Displays the contents of a variable in a colored tabular format
25
+ * Based on the idea, javascript and css code of Macromedia's ColdFusion cfdump tag
26
+ * A much better presentation of a variable's contents than PHP's var_dump and print_r functions
27
+ *
28
+ *
29
+ * USAGE
30
+ * =============
31
+ * new dBug ( variable [,forceType] );
32
+ * example:
33
+ * new dBug ( $myVariable );
34
+ *
35
+ *
36
+ * if the optional "forceType" string is given, the variable supplied to the
37
+ * function is forced to have that forceType type.
38
+ * example: new dBug( $myVariable , "array" );
39
+ * will force $myVariable to be treated and dumped as an array type,
40
+ * even though it might originally have been a string type, etc.
41
+ *
42
+ * NOTE!
43
+ * ==============
44
+ * forceType is REQUIRED for dumping an xml string or xml file
45
+ * new dBug ( $strXml, "xml" );
46
+ *
47
+ \*********************************************************************************************************************/
48
+ defined('WYSIJA') or die('Restricted access');
49
+ class dBug {
50
+
51
+ var $xmlDepth=array();
52
+ var $xmlCData;
53
+ var $xmlSData;
54
+ var $xmlDData;
55
+ var $xmlCount=0;
56
+ var $xmlAttrib;
57
+ var $xmlName;
58
+ var $arrType=array("array","object","resource","boolean","NULL");
59
+ var $bInitialized = false;
60
+ var $bCollapsed = false;
61
+ var $arrHistory = array();
62
+
63
+ //constructor
64
+ function dBug($var,$forceType="",$bCollapsed=false) {
65
+ //include js and css scripts
66
+ if(!defined('BDBUGINIT')) {
67
+ define("BDBUGINIT", TRUE);
68
+ $this->initJSandCSS();
69
+ }
70
+ $arrAccept=array("array","object","xml"); //array of variable types that can be "forced"
71
+ $this->bCollapsed = $bCollapsed;
72
+ if(in_array($forceType,$arrAccept))
73
+ $this->{"varIs".ucfirst($forceType)}($var);
74
+ else
75
+ $this->checkType($var);
76
+ }
77
+
78
+ //get variable name
79
+ function getVariableName() {
80
+ $arrBacktrace = debug_backtrace();
81
+
82
+ //possible 'included' functions
83
+ $arrInclude = array("include","include_once","require","require_once");
84
+
85
+ //check for any included/required files. if found, get array of the last included file (they contain the right line numbers)
86
+ for($i=count($arrBacktrace)-1; $i>=0; $i--) {
87
+ $arrCurrent = $arrBacktrace[$i];
88
+ if(array_key_exists("function", $arrCurrent) &&
89
+ (in_array($arrCurrent["function"], $arrInclude) || (0 != strcasecmp($arrCurrent["function"], "dbug"))))
90
+ continue;
91
+
92
+ $arrFile = $arrCurrent;
93
+
94
+ break;
95
+ }
96
+
97
+ if(isset($arrFile)) {
98
+ $arrLines = file($arrFile["file"]);
99
+ $code = $arrLines[($arrFile["line"]-1)];
100
+
101
+ //find call to dBug class
102
+ preg_match('/\bnew dBug\s*\(\s*(.+)\s*\);/i', $code, $arrMatches);
103
+
104
+ return $arrMatches[1];
105
+ }
106
+ return "";
107
+ }
108
+
109
+ //create the main table header
110
+ function makeTableHeader($type,$header,$colspan=2) {
111
+ if(!$this->bInitialized) {
112
+ $header = $this->getVariableName() . " (" . $header . ")";
113
+ $this->bInitialized = true;
114
+ }
115
+ $str_i = ($this->bCollapsed) ? "style=\"font-style:italic\" " : "";
116
+
117
+ echo "<table cellspacing=2 cellpadding=3 class=\"dBug_".$type."\">
118
+ <tr>
119
+ <td ".$str_i."class=\"dBug_".$type."Header\" colspan=".$colspan." onClick='dBug_toggleTable(this)'>".$header."</td>
120
+ </tr>";
121
+ }
122
+
123
+ //create the table row header
124
+ function makeTDHeader($type,$header) {
125
+ $str_d = ($this->bCollapsed) ? " style=\"display:none\"" : "";
126
+ echo "<tr".$str_d.">
127
+ <td valign=\"top\" onClick='dBug_toggleRow(this)' class=\"dBug_".$type."Key\">".$header."</td>
128
+ <td>";
129
+ }
130
+
131
+ //close table row
132
+ function closeTDRow() {
133
+ return "</td></tr>\n";
134
+ }
135
+
136
+ //error
137
+ function error($type) {
138
+ $error="Error: Variable cannot be a";
139
+ // this just checks if the type starts with a vowel or "x" and displays either "a" or "an"
140
+ if(in_array(substr($type,0,1),array("a","e","i","o","u","x")))
141
+ $error.="n";
142
+ return ($error." ".$type." type");
143
+ }
144
+
145
+ //check variable type
146
+ function checkType($var) {
147
+ switch(gettype($var)) {
148
+ case "resource":
149
+ $this->varIsResource($var);
150
+ break;
151
+ case "object":
152
+ $this->varIsObject($var);
153
+ break;
154
+ case "array":
155
+ $this->varIsArray($var);
156
+ break;
157
+ case "NULL":
158
+ $this->varIsNULL();
159
+ break;
160
+ case "boolean":
161
+ $this->varIsBoolean($var);
162
+ break;
163
+ default:
164
+ $var=($var=="") ? "[empty string]" : $var;
165
+ $var=$this->convertTimeStampToDate($var);
166
+ echo "<table cellspacing=0><tr>\n<td>".$var."</td>\n</tr>\n</table>\n";
167
+ break;
168
+ }
169
+ }
170
+
171
+ function convertTimeStampToDate($var){
172
+ if($this->varIsValidTimeStamp((string)$var)){
173
+ $helper_toolbox=WYSIJA::get('toolbox','helper');
174
+ $var=date('d-m-y h:i:s A', $helper_toolbox->servertime_to_localtime($var)).' <small>('.$var.')</small>';
175
+ }
176
+ return $var;
177
+ }
178
+
179
+ function varIsValidTimeStamp($timestamp){
180
+ return ((string) (int) $timestamp === $timestamp)
181
+ && ($timestamp <= PHP_INT_MAX)
182
+ && ($timestamp > 100000000)
183
+ && ($timestamp >= ~PHP_INT_MAX);
184
+ }
185
+
186
+ //if variable is a NULL type
187
+ function varIsNULL() {
188
+ echo "NULL";
189
+ }
190
+
191
+ //if variable is a boolean type
192
+ function varIsBoolean($var) {
193
+ $var=($var==1) ? "TRUE" : "FALSE";
194
+ echo $var;
195
+ }
196
+
197
+ //if variable is an array type
198
+ function varIsArray($var) {
199
+ $var_ser = serialize($var);
200
+ array_push($this->arrHistory, $var_ser);
201
+
202
+ $this->makeTableHeader("array","array");
203
+ if(is_array($var)) {
204
+ foreach($var as $key=>$value) {
205
+ $this->makeTDHeader("array",$key);
206
+
207
+ //check for recursion
208
+ if(is_array($value)) {
209
+ $var_ser = serialize($value);
210
+ if(in_array($var_ser, $this->arrHistory, TRUE))
211
+ $value = "*RECURSION*";
212
+ }
213
+
214
+ if(in_array(gettype($value),$this->arrType))
215
+ $this->checkType($value);
216
+ else {
217
+ $value=(trim($value)=="") ? "[empty string]" : $value;
218
+ $value=$this->convertTimeStampToDate($value);
219
+
220
+ echo $value;
221
+ }
222
+ echo $this->closeTDRow();
223
+ }
224
+ }
225
+ else echo "<tr><td>".$this->error("array").$this->closeTDRow();
226
+ array_pop($this->arrHistory);
227
+ echo "</table>";
228
+ }
229
+
230
+ //if variable is an object type
231
+ function varIsObject($var) {
232
+ $var_ser = serialize($var);
233
+ array_push($this->arrHistory, $var_ser);
234
+ $this->makeTableHeader("object","object");
235
+
236
+ //condition modified by BEN used to be : if(is_object($var)) {
237
+ if(!empty($var)) {
238
+ $arrObjVars=get_object_vars($var);
239
+ foreach($arrObjVars as $key=>$value) {
240
+
241
+ $value=(!is_object($value) && !is_array($value) && @trim($value)=="") ? "[empty string]" : $value;
242
+ $this->makeTDHeader("object",$key);
243
+
244
+ //check for recursion
245
+ if(is_object($value)||is_array($value)) {
246
+ $var_ser = serialize($value);
247
+ if(in_array($var_ser, $this->arrHistory, TRUE)) {
248
+ $value = (is_object($value)) ? "*RECURSION* -> $".get_class($value) : "*RECURSION*";
249
+
250
+ }
251
+ }
252
+ if(in_array(gettype($value),$this->arrType))
253
+ $this->checkType($value);
254
+ else echo $value;
255
+ echo $this->closeTDRow();
256
+ }
257
+ $arrObjMethods=get_class_methods(get_class($var));
258
+ foreach($arrObjMethods as $key=>$value) {
259
+ $this->makeTDHeader("object",$value);
260
+ echo "[function]".$this->closeTDRow();
261
+ }
262
+ }
263
+ else echo "<tr><td>".$this->error("object").$this->closeTDRow();
264
+ array_pop($this->arrHistory);
265
+ echo "</table>";
266
+ }
267
+
268
+ //if variable is a resource type
269
+ function varIsResource($var) {
270
+ $this->makeTableHeader("resourceC","resource",1);
271
+ echo "<tr>\n<td>\n";
272
+ switch(get_resource_type($var)) {
273
+ case "fbsql result":
274
+ case "mssql result":
275
+ case "msql query":
276
+ case "pgsql result":
277
+ case "sybase-db result":
278
+ case "sybase-ct result":
279
+ case "mysql result":
280
+ $db=current(explode(" ",get_resource_type($var)));
281
+ $this->varIsDBResource($var,$db);
282
+ break;
283
+ case "gd":
284
+ $this->varIsGDResource($var);
285
+ break;
286
+ case "xml":
287
+ $this->varIsXmlResource($var);
288
+ break;
289
+ default:
290
+ echo get_resource_type($var).$this->closeTDRow();
291
+ break;
292
+ }
293
+ echo $this->closeTDRow()."</table>\n";
294
+ }
295
+
296
+ //if variable is a database resource type
297
+ function varIsDBResource($var,$db="mysql") {
298
+ if($db == "pgsql")
299
+ $db = "pg";
300
+ if($db == "sybase-db" || $db == "sybase-ct")
301
+ $db = "sybase";
302
+ $arrFields = array("name","type","flags");
303
+ $numrows=call_user_func($db."_num_rows",$var);
304
+ $numfields=call_user_func($db."_num_fields",$var);
305
+ $this->makeTableHeader("resource",$db." result",$numfields+1);
306
+ echo "<tr><td class=\"dBug_resourceKey\">&nbsp;</td>";
307
+ for($i=0;$i<$numfields;$i++) {
308
+ $field_header = "";
309
+ for($j=0; $j<count($arrFields); $j++) {
310
+ $db_func = $db."_field_".$arrFields[$j];
311
+ if(function_exists($db_func)) {
312
+ $fheader = call_user_func($db_func, $var, $i). " ";
313
+ if($j==0)
314
+ $field_name = $fheader;
315
+ else
316
+ $field_header .= $fheader;
317
+ }
318
+ }
319
+ $field[$i]=call_user_func($db."_fetch_field",$var,$i);
320
+ echo "<td class=\"dBug_resourceKey\" title=\"".$field_header."\">".$field_name."</td>";
321
+ }
322
+ echo "</tr>";
323
+ for($i=0;$i<$numrows;$i++) {
324
+ $row=call_user_func($db."_fetch_array",$var,constant(strtoupper($db)."_ASSOC"));
325
+ echo "<tr>\n";
326
+ echo "<td class=\"dBug_resourceKey\">".($i+1)."</td>";
327
+ for($k=0;$k<$numfields;$k++) {
328
+ $tempField=$field[$k]->name;
329
+ $fieldrow=$row[($field[$k]->name)];
330
+ $fieldrow=($fieldrow=="") ? "[empty string]" : $fieldrow;
331
+ echo "<td>".$fieldrow."</td>\n";
332
+ }
333
+ echo "</tr>\n";
334
+ }
335
+ echo "</table>";
336
+ if($numrows>0)
337
+ call_user_func($db."_data_seek",$var,0);
338
+ }
339
+
340
+ //if variable is an image/gd resource type
341
+ function varIsGDResource($var) {
342
+ $this->makeTableHeader("resource","gd",2);
343
+ $this->makeTDHeader("resource","Width");
344
+ echo imagesx($var).$this->closeTDRow();
345
+ $this->makeTDHeader("resource","Height");
346
+ echo imagesy($var).$this->closeTDRow();
347
+ $this->makeTDHeader("resource","Colors");
348
+ echo imagecolorstotal($var).$this->closeTDRow();
349
+ echo "</table>";
350
+ }
351
+
352
+ //if variable is an xml type
353
+ function varIsXml($var) {
354
+ $this->varIsXmlResource($var);
355
+ }
356
+
357
+ //if variable is an xml resource type
358
+ function varIsXmlResource($var) {
359
+ $xml_parser=xml_parser_create();
360
+ xml_parser_set_option($xml_parser,XML_OPTION_CASE_FOLDING,0);
361
+ xml_set_element_handler($xml_parser,array(&$this,"xmlStartElement"),array(&$this,"xmlEndElement"));
362
+ xml_set_character_data_handler($xml_parser,array(&$this,"xmlCharacterData"));
363
+ xml_set_default_handler($xml_parser,array(&$this,"xmlDefaultHandler"));
364
+
365
+ $this->makeTableHeader("xml","xml document",2);
366
+ $this->makeTDHeader("xml","xmlRoot");
367
+
368
+ //attempt to open xml file
369
+ $bFile=(!($fp=@fopen($var,"r"))) ? false : true;
370
+
371
+ //read xml file
372
+ if($bFile) {
373
+ while($data=str_replace("\n","",fread($fp,4096)))
374
+ $this->xmlParse($xml_parser,$data,feof($fp));
375
+ }
376
+ //if xml is not a file, attempt to read it as a string
377
+ else {
378
+ if(!is_string($var)) {
379
+ echo $this->error("xml").$this->closeTDRow()."</table>\n";
380
+ return;
381
+ }
382
+ $data=$var;
383
+ $this->xmlParse($xml_parser,$data,1);
384
+ }
385
+
386
+ echo $this->closeTDRow()."</table>\n";
387
+
388
+ }
389
+
390
+ //parse xml
391
+ function xmlParse($xml_parser,$data,$bFinal) {
392
+ if (!xml_parse($xml_parser,$data,$bFinal)) {
393
+ die(sprintf("XML error: %s at line %d\n",
394
+ xml_error_string(xml_get_error_code($xml_parser)),
395
+ xml_get_current_line_number($xml_parser)));
396
+ }
397
+ }
398
+
399
+ //xml: inititiated when a start tag is encountered
400
+ function xmlStartElement($parser,$name,$attribs) {
401
+ $this->xmlAttrib[$this->xmlCount]=$attribs;
402
+ $this->xmlName[$this->xmlCount]=$name;
403
+ $this->xmlSData[$this->xmlCount]='$this->makeTableHeader("xml","xml element",2);';
404
+ $this->xmlSData[$this->xmlCount].='$this->makeTDHeader("xml","xmlName");';
405
+ $this->xmlSData[$this->xmlCount].='echo "<strong>'.$this->xmlName[$this->xmlCount].'</strong>".$this->closeTDRow();';
406
+ $this->xmlSData[$this->xmlCount].='$this->makeTDHeader("xml","xmlAttributes");';
407
+ if(count($attribs)>0)
408
+ $this->xmlSData[$this->xmlCount].='$this->varIsArray($this->xmlAttrib['.$this->xmlCount.']);';
409
+ else
410
+ $this->xmlSData[$this->xmlCount].='echo "&nbsp;";';
411
+ $this->xmlSData[$this->xmlCount].='echo $this->closeTDRow();';
412
+ $this->xmlCount++;
413
+ }
414
+
415
+ //xml: initiated when an end tag is encountered
416
+ function xmlEndElement($parser,$name) {
417
+ for($i=0;$i<$this->xmlCount;$i++) {
418
+ eval($this->xmlSData[$i]);
419
+ $this->makeTDHeader("xml","xmlText");
420
+ echo (!empty($this->xmlCData[$i])) ? $this->xmlCData[$i] : "&nbsp;";
421
+ echo $this->closeTDRow();
422
+ $this->makeTDHeader("xml","xmlComment");
423
+ echo (!empty($this->xmlDData[$i])) ? $this->xmlDData[$i] : "&nbsp;";
424
+ echo $this->closeTDRow();
425
+ $this->makeTDHeader("xml","xmlChildren");
426
+ unset($this->xmlCData[$i],$this->xmlDData[$i]);
427
+ }
428
+ echo $this->closeTDRow();
429
+ echo "</table>";
430
+ $this->xmlCount=0;
431
+ }
432
+
433
+ //xml: initiated when text between tags is encountered
434
+ function xmlCharacterData($parser,$data) {
435
+ $count=$this->xmlCount-1;
436
+ if(!empty($this->xmlCData[$count]))
437
+ $this->xmlCData[$count].=$data;
438
+ else
439
+ $this->xmlCData[$count]=$data;
440
+ }
441
+
442
+ //xml: initiated when a comment or other miscellaneous texts is encountered
443
+ function xmlDefaultHandler($parser,$data) {
444
+ //strip '<!--' and '-->' off comments
445
+ $data=str_replace(array("&lt;!--","--&gt;"),"",htmlspecialchars($data));
446
+ $count=$this->xmlCount-1;
447
+ if(!empty($this->xmlDData[$count]))
448
+ $this->xmlDData[$count].=$data;
449
+ else
450
+ $this->xmlDData[$count]=$data;
451
+ }
452
+
453
+ function initJSandCSS() {
454
+ echo <<<SCRIPTS
455
+ <script language="JavaScript">
456
+ /* code modified from ColdFusion's cfdump code */
457
+ function dBug_toggleRow(source) {
458
+ var target = (document.all) ? source.parentElement.cells[1] : source.parentNode.lastChild;
459
+ dBug_toggleTarget(target,dBug_toggleSource(source));
460
+ }
461
+
462
+ function dBug_toggleSource(source) {
463
+ if (source.style.fontStyle=='italic') {
464
+ source.style.fontStyle='normal';
465
+ source.title='click to collapse';
466
+ return 'open';
467
+ } else {
468
+ source.style.fontStyle='italic';
469
+ source.title='click to expand';
470
+ return 'closed';
471
+ }
472
+ }
473
+
474
+ function dBug_toggleTarget(target,switchToState) {
475
+ target.style.display = (switchToState=='open') ? '' : 'none';
476
+ }
477
+
478
+ function dBug_toggleTable(source) {
479
+ var switchToState=dBug_toggleSource(source);
480
+ if(document.all) {
481
+ var table=source.parentElement.parentElement;
482
+ for(var i=1;i<table.rows.length;i++) {
483
+ target=table.rows[i];
484
+ dBug_toggleTarget(target,switchToState);
485
+ }
486
+ }
487
+ else {
488
+ var table=source.parentNode.parentNode;
489
+ for (var i=1;i<table.childNodes.length;i++) {
490
+ target=table.childNodes[i];
491
+ if(target.style) {
492
+ dBug_toggleTarget(target,switchToState);
493
+ }
494
+ }
495
+ }
496
+ }
497
+ </script>
498
+
499
+ <style type="text/css">
500
+ table.dBug_array,table.dBug_object,table.dBug_resource,table.dBug_resourceC,table.dBug_xml {
501
+ font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000; font-size:12px;
502
+ }
503
+
504
+ .dBug_arrayHeader,
505
+ .dBug_objectHeader,
506
+ .dBug_resourceHeader,
507
+ .dBug_resourceCHeader,
508
+ .dBug_xmlHeader
509
+ { font-weight:bold; color:#FFFFFF; cursor:pointer; }
510
+
511
+ .dBug_arrayKey,
512
+ .dBug_objectKey,
513
+ .dBug_xmlKey
514
+ { cursor:pointer; }
515
+
516
+ /* array */
517
+ table.dBug_array { background-color:#006600; }
518
+ table.dBug_array td { background-color:#FFFFFF; }
519
+ table.dBug_array td.dBug_arrayHeader { background-color:#009900; }
520
+ table.dBug_array td.dBug_arrayKey { background-color:#CCFFCC; }
521
+
522
+ /* object */
523
+ table.dBug_object { background-color:#0000CC; }
524
+ table.dBug_object td { background-color:#FFFFFF; }
525
+ table.dBug_object td.dBug_objectHeader { background-color:#4444CC; }
526
+ table.dBug_object td.dBug_objectKey { background-color:#CCDDFF; }
527
+
528
+ /* resource */
529
+ table.dBug_resourceC { background-color:#884488; }
530
+ table.dBug_resourceC td { background-color:#FFFFFF; }
531
+ table.dBug_resourceC td.dBug_resourceCHeader { background-color:#AA66AA; }
532
+ table.dBug_resourceC td.dBug_resourceCKey { background-color:#FFDDFF; }
533
+
534
+ /* resource */
535
+ table.dBug_resource { background-color:#884488; }
536
+ table.dBug_resource td { background-color:#FFFFFF; }
537
+ table.dBug_resource td.dBug_resourceHeader { background-color:#AA66AA; }
538
+ table.dBug_resource td.dBug_resourceKey { background-color:#FFDDFF; }
539
+
540
+ /* xml */
541
+ table.dBug_xml { background-color:#888888; }
542
+ table.dBug_xml td { background-color:#FFFFFF; }
543
+ table.dBug_xml td.dBug_xmlHeader { background-color:#AAAAAA; }
544
+ table.dBug_xml td.dBug_xmlKey { background-color:#DDDDDD; }
545
+ </style>
546
+ SCRIPTS;
547
+ }
548
+
549
  }
inc/debug.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
-
3
  global $wysija_queries;
4
  $wysija_queries=array();
5
 
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  global $wysija_queries;
4
  $wysija_queries=array();
5
 
inc/phpmailer/class.elasticemail.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * @copyright Copyright (C) 2009-2011 ACYBA SARL - All rights reserved.
4
  * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /**
4
  * @copyright Copyright (C) 2009-2011 ACYBA SARL - All rights reserved.
5
  * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
inc/phpmailer/class.sendgrid.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * @copyright Copyright (C) 2009-2011 ACYBA SARL - All rights reserved.
4
  * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
  /**
4
  * @copyright Copyright (C) 2009-2011 ACYBA SARL - All rights reserved.
5
  * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
index.php CHANGED
@@ -3,7 +3,7 @@
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.9
7
  Author: MailPoet
8
  Author URI: http://www.mailpoet.com/
9
  License: GPLv2 or later
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.10
7
  Author: MailPoet
8
  Author URI: http://www.mailpoet.com/
9
  License: GPLv2 or later
js/admin-campaigns-articles.js CHANGED
@@ -1 +1 @@
1
- var query_offset=0,wysappend=0,totalReached=!1,searchRunning=!1,slider=null,colorpicker=null;jQuery(function(e){function t(){e(".submit-box").addClass("counting");var t=parseInt(e(".search_results .checkbox:checked").length,10);0===t?a():c(t+" "+wysijatrans.post_selected)}function a(){e(".submit-box").removeClass("counting"),r()}function i(){e(".post_category").attr("disabled","disabled").hide();var t=e("#post_type").val();e("#post_category_"+t).length>0&&e("#post_category_"+t).removeAttr("disabled").show()}function n(){return query_offset=0,wysappend=0,l(),!1}function s(){if(null===slider){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 l(){var t="";wysappend||e("#results").html(t),wysijaAJAX.task="get_articles",wysijaAJAX.data=e("#articles-form").serializeArray(),wysijaAJAX.query_offset=query_offset,o(wysijatrans.loading_results),wysijaAJAX._wpnonce=e("#wysijax").val(),jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:f,error:m,dataType:"json"})}function o(t){a(),e(".submit-box").addClass("loading"),c(t)}function c(t){void 0!==t&&e("#loading-message").html(t)}function r(){e("#loading-message").html("")}function d(){e(".submit-box").removeClass("loading"),r(),t()}function u(){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()?h(["image","author","category","readmore","divider","bgcolor"]):p(["image","author","category","readmore","divider","bgcolor"]))}function h(t){e.each(t,function(t,a){e("#"+a+"-block").hide()})}function p(t){e.each(t,function(t,a){e("#"+a+"-block").show()})}function _(){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)}}))}function g(){e("#image_block")[e('input[name="title_tag"][value="list"]:checked').length>0?"hide":"show"]()}function w(){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(),s(),slider.range=$R(i,n),slider.setValue(slider.value)):e("#image_width_block").hide()}function f(t){var a="",i=null;t.result.result?(a='<ul class="search_results">',e.each(t.result.posts,function(e,t){i={src:null,alt:"",title:""},null!==t.post_image&&(i.src=t.post_image.src,i.alt=t.post_image.alt,i.title=t.post_title);var n=query_offset+e;a+='<li id="post-'+n+'" class="clearfix">',a+='<div class="checkbox_container">',a+='<input id="post-checkbox-'+n+'" data-post-id="'+n+'" type="checkbox" class="checkbox" value="'+t.ID+'" name="post_selection" />',a+="</div>",null!==i.src?(a+='<div class="thumbnail"><img width="60" title="'+i.title+'" src="'+i.src+'" alt="'+i.alt+'" /></div>',a+='<label class="with_thumbnail" for="post-checkbox-'+n+'">'+t.post_title+"</label>"):a+='<label for="post-checkbox-'+n+'">'+t.post_title+"</label>",a+='<span class="cpt-type">'+t.post_type+" - <small>"+t.post_status+"</small></span>",a+="</li>"}),a+="</ul>"):a=t.result.append?"":'<p class="message"><strong>'+t.result.msg+"</strong></p>",t.result.append?""!==a&&e("#results").append("<hr />"+a):e("#results").html(a),wysappend=0,searchRunning=!1,totalReached=parseInt(t.result.total)===e("ul.search_results li").length?!0:!1,d()}function m(){searchRunning=!1,wysappend=0}function y(){0!==e("#advanced:hidden").length&&searchRunning!==!0&&(searchRunning=!0,query_offset+=10,wysappend=1,l())}e("#toggle-advanced").toggle(function(){return e(this).html(wysijatrans.hide_advanced),e("#advanced").show(),e("#basic").hide(),s(),u(),w(),g(),_(),e(this).blur(),!1},function(){return e(this).html(wysijatrans.show_advanced),e("#basic").show(),e("#advanced").hide(),e(this).blur(),!1}),e("#back-selection").click(function(){return e("#toggle-advanced").trigger("click"),!1}),e("#insert-selection").click(function(){var t=[],a=e('#results input[name="post_selection"]:checked'),i=[],n=["readmore","author_label","category_label"];return 0===a.length?!1:(e.each(a,function(a,i){t.push(e(i).val())}),e("#articles-form").serializeArray().each(function(e){n.include(e.name)&&(e.value=window.parent.Wysija.encodeHtmlValue(e.value)),i.push(e)}),wysijaAJAX.task="insert_articles",wysijaAJAX.post_ids=t.join(","),wysijaAJAX.data=i,wysijaAJAX._wpnonce=e("#wysijax").val(),wysijaAJAX.divider={src:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_src"),width:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_width"),height:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_height")},o(wysijatrans.inserting_selection),jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(e){window.parent.WysijaPopup.success(e.result.posts),d()},error:m,dataType:"json"}),!1)}),e(document).on("click",".search_results .checkbox",function(){e(this).is(":checked")===!0?e("#post-"+e(this).data("post-id")).addClass("selected"):e("#post-"+e(this).data("post-id")).removeClass("selected"),t()}),e(document).on("change","#post_type",function(){i(),n()}),e(".post_category").change(function(){n()}),e("#post_status").change(function(){n()}),e(document).on("click","#search-submit",function(){return l(),!1}),e('input[name="image_alignment"]').click(function(){w()}),e('input[name="post_content"]').click(function(){u(),g(),w()}),e('input[name="title_tag"]').click(function(){u(),g(),w()}),e(function(){i(),l()}),e(window).scroll(function(){totalReached===!1&&e("#results li").length>=10&&!wysappend&&e(window).scrollTop()===e(document).height()-e(window).height()&&y()})});
1
+ var query_offset=0,wysappend=0,totalReached=!1,searchRunning=!1,slider=null,colorpicker=null;jQuery(function(e){function t(){e(".submit-box").addClass("counting");var t=parseInt(e(".search_results .checkbox:checked").length,10);0===t?a():o(t+" "+wysijatrans.post_selected)}function a(){e(".submit-box").removeClass("counting"),c()}function i(){return query_offset=0,wysappend=0,s(),!1}function n(){if(null===slider){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 s(){var t="";wysappend||e("#results").html(t),wysijaAJAX.task="get_articles",wysijaAJAX.data=e("#articles-form").serializeArray(),wysijaAJAX.query_offset=query_offset,l(wysijatrans.loading_results),wysijaAJAX._wpnonce=e("#wysijax").val(),jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:w,error:f,dataType:"json"})}function l(t){a(),e(".submit-box").addClass("loading"),o(t)}function o(t){void 0!==t&&e("#loading-message").html(t)}function c(){e("#loading-message").html("")}function r(){e(".submit-box").removeClass("loading"),c(),t()}function d(){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()?u(["image","author","category","readmore","divider","bgcolor"]):h(["image","author","category","readmore","divider","bgcolor"]))}function u(t){e.each(t,function(t,a){e("#"+a+"-block").hide()})}function h(t){e.each(t,function(t,a){e("#"+a+"-block").show()})}function p(){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)}}))}function _(){e("#image_block")[e('input[name="title_tag"][value="list"]:checked').length>0?"hide":"show"]()}function g(){var t=e('input[name="image_alignment"]:checked').val(),a=!0,i=32,s=325;"center"===t?s=564:"none"===t&&(a=!1),a===!0?(e("#image_width_block").show(),n(),slider.range=$R(i,s),slider.setValue(slider.value)):e("#image_width_block").hide()}function w(t){var a="",i=null;t.result.result?(a='<ul class="search_results">',e.each(t.result.posts,function(e,t){i={src:null,alt:"",title:""},null!==t.post_image&&(i.src=t.post_image.src,i.alt=t.post_image.alt,i.title=t.post_title);var n=query_offset+e;a+='<li id="post-'+n+'" class="clearfix">',a+='<div class="checkbox_container">',a+='<input id="post-checkbox-'+n+'" data-post-id="'+n+'" type="checkbox" class="checkbox" value="'+t.ID+'" name="post_selection" />',a+="</div>",null!==i.src?(a+='<div class="thumbnail"><img width="60" title="'+i.title+'" src="'+i.src+'" alt="'+i.alt+'" /></div>',a+='<label class="with_thumbnail" for="post-checkbox-'+n+'">'+t.post_title+"</label>"):a+='<label for="post-checkbox-'+n+'">'+t.post_title+"</label>",a+='<span class="cpt-type">'+t.post_type+" - <small>"+t.post_status+"</small></span>",a+="</li>"}),a+="</ul>"):a=t.result.append?"":'<p class="message"><strong>'+t.result.msg+"</strong></p>",t.result.append?""!==a&&e("#results").append("<hr />"+a):e("#results").html(a),wysappend=0,searchRunning=!1,totalReached=parseInt(t.result.total)===e("ul.search_results li").length?!0:!1,r()}function f(){searchRunning=!1,wysappend=0}function m(){0!==e("#advanced:hidden").length&&searchRunning!==!0&&(searchRunning=!0,query_offset+=10,wysappend=1,s())}e("#toggle-advanced").toggle(function(){return e(this).html(wysijatrans.hide_advanced),e("#advanced").show(),e("#basic").hide(),n(),d(),g(),_(),p(),e(this).blur(),!1},function(){return e(this).html(wysijatrans.show_advanced),e("#basic").show(),e("#advanced").hide(),e(this).blur(),!1}),e("#back-selection").click(function(){return e("#toggle-advanced").trigger("click"),!1}),e("#insert-selection").click(function(){var t=[],a=e('#results input[name="post_selection"]:checked'),i=[],n=["readmore","author_label","category_label"];return 0===a.length?!1:(e.each(a,function(a,i){t.push(e(i).val())}),e("#articles-form").serializeArray().each(function(e){n.include(e.name)&&(e.value=window.parent.Wysija.encodeHtmlValue(e.value)),i.push(e)}),wysijaAJAX.task="insert_articles",wysijaAJAX.post_ids=t.join(","),wysijaAJAX.data=i,wysijaAJAX._wpnonce=e("#wysijax").val(),wysijaAJAX.divider={src:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_src"),width:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_width"),height:window.parent.$$('.wysija_item[wysija_type="divider"]')[0].readAttribute("wysija_height")},l(wysijatrans.inserting_selection),jQuery.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(e){window.parent.WysijaPopup.success(e.result.posts),r()},error:f,dataType:"json"}),!1)}),e(document).on("click",".search_results .checkbox",function(){e(this).is(":checked")===!0?e("#post-"+e(this).data("post-id")).addClass("selected"):e("#post-"+e(this).data("post-id")).removeClass("selected"),t()}),e(document).on("change","#post_type",function(){i()}),e(".post_category").change(function(){i()}),e("#post_status").change(function(){i()}),e(document).on("click","#search-submit",function(){return s(),!1}),e('input[name="image_alignment"]').click(function(){g()}),e('input[name="post_content"]').click(function(){d(),_(),g()}),e('input[name="title_tag"]').click(function(){d(),_(),g()}),e(function(){s()}),e(window).scroll(function(){totalReached===!1&&e("#results li").length>=10&&!wysappend&&e(window).scrollTop()===e(document).height()-e(window).height()&&m()})});
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"]):n(["image","author","category","readmore","divider","bgcolor"]))}function i(t){e.each(t,function(t,i){e("#"+i+"-block").hide()})}function n(t){e.each(t,function(t,i){e("#"+i+"-block").show()})}function a(){e("#image_block")[e('input[name="title_tag"][value="list"]:checked').length>0?"hide":"show"]()}function o(){var t=e('input[name="image_alignment"]:checked').val(),i=!0,n=32,a=325;"center"===t?a=564:"none"===t&&(i=!1),i===!0?(e("#image_width_block").show(),l(),slider.range=$R(n,a),slider.setValue(slider.value)):e("#image_width_block").hide()}function l(){var t=32,i=564,n=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:n,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(n)}function c(){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(),l(),t(),o(),a(),c(),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(){o()}),e('input[name="post_content"]').click(function(){t(),a(),o()}),e('input[name="title_tag"]').click(function(){t(),a(),o()}),e("#post_type").change(function(){return e(".category_ids").val("").trigger("change"),!1}),e(function(){l(),t(),o(),a()})});
js/admin-campaigns-editTemplate.js CHANGED
@@ -1 +1 @@
1
- function handleRemoveImage(){$$(".wj_images li").invoke("stopObserving","mouseover"),$$(".wj_images li").invoke("stopObserving","mouseout"),$$(".wj_images li").invoke("observe","mouseover",function(){$(this).select("span.delete-wrap").first().show()}),$$(".wj_images li").invoke("observe","mouseout",function(){$(this).select("span.delete-wrap").first().hide()}),$$(".wj_images li .delete").invoke("observe","click",function(){removeImage($(this).innerHTML),$(this).stopObserving("click")})}function setDefaultTheme(e){var s=e.up().previous(".wysija_theme").readAttribute("rel");return wysijaAJAX.task="setDefaultTheme",wysijaAJAX.theme=s,WYSIJA_AJAX_POST({success:function(){$$(".wj_themes .default").invoke("removeClassName","selected"),$(e).addClassName("selected")},loading_message:wysijatrans.theme_setting_default,success_message:wysijatrans.theme_saved_default}),!1}function handleRemoveTheme(){$$(".wj_themes li").invoke("stopObserving","mouseover"),$$(".wj_themes li").invoke("stopObserving","mouseout"),$$(".wj_themes li").invoke("observe","mouseover",function(){$(this).down("span.delete-wrap").show(),$(this).down("span.default-wrap").show()}),$$(".wj_themes li").invoke("observe","mouseout",function(){$(this).down("span.delete-wrap").hide(),$(this).down(".default-wrap").hide()}),$$(".wj_themes li .delete").invoke("observe","click",function(){removeTheme($(this).innerHTML),$(this).stopObserving("click")})}function handleDefaultTheme(){$$(".wj_themes li .default").invoke("observe","click",function(){$$(".wj_themes li .default.selected").length>0&&$$(".wj_themes li .default.selected").first().up().hide(),setDefaultTheme(this)})}function handleSwitchTheme(){$$("a.wysija_theme").invoke("observe","click",function(e){switchThemeWYSIJA(e)})}function removeTheme(e){return confirm(wysijatrans.abouttodeletetheme.replace("%1$s",e))&&($("wysija-theme-"+e).remove(),wysijaAJAX.task="deleteTheme",wysijaAJAX.themekey=e,WYSIJA_AJAX_POST()),!0}function removeImage(e){var s=wysijaIMG.unset(e);return void 0!==s&&$("wysija-img-"+e).remove(),saveIQS(),!0}function addImage(e){var s=new Element("img",{width:80,height:80,wysija_height:e.height,wysija_width:e.width,wysija_src:e.url,src:e.thumb_url}),i=new Element("a",{wysija_type:"image","class":"wysija_item"}).update(s),t=new Element("li",{id:"wysija-img-"+e.identifier,"class":"new"}).update(i);return t.insert('<span class="delete-wrap" style="display:none;"><span class="delete">'+e.identifier+"</span></span>"),t.insert('<span class="default-wrap" style="display:none;"><span class="default">'+e.identifier+"</span></span>"),$("wj-images-quick").insert({top:t}),handleRemoveImage(),wysijaIMG.set(e.identifier,e),saveIQS(),!0}var wysijaIMG=$H(),ajaxOver=!0;document.observe("dom:loaded",function(){void 0!=$("wysija-upload-browse")&&$("wysija-upload-browse").observe("click",function(){return WysijaPopup.open($(this).innerHTML,$(this).readAttribute("href2")),!1}),void 0!=$("wysija-themes-browse")&&$("wysija-themes-browse").observe("click",function(){return WysijaPopup.open($(this).innerHTML,$(this).readAttribute("href2")),!1}),void 0!=$("wysija_divider_settings")&&$("wysija_divider_settings").observe("click",function(){return WysijaPopup.open(wysijatrans.dividerSelectionTitle,$(this).readAttribute("href2")),!1}),handleRemoveImage(),handleRemoveTheme(),handleSwitchTheme(),handleDefaultTheme(),$$(".wysija_toolbar_tabs a").invoke("observe","click",function(){return $$(".wysija_toolbar_tabs a").invoke("removeClassName","selected"),$$(".wj_images, .wj_content, .wj_styles, .wj_themes").invoke("hide"),$$(".wj_"+$(this).readAttribute("rel"))[0].show(),$(this).addClassName("selected"),!1})});
1
+ function handleRemoveImage(){$$(".wj_images li").invoke("stopObserving","mouseover"),$$(".wj_images li").invoke("stopObserving","mouseout"),$$(".wj_images li").invoke("observe","mouseover",function(){$(this).select("span.delete-wrap").first().show()}),$$(".wj_images li").invoke("observe","mouseout",function(){$(this).select("span.delete-wrap").first().hide()}),$$(".wj_images li .delete").invoke("observe","click",function(){removeImage($(this).innerHTML),$(this).stopObserving("click")})}function setDefaultTheme(e){var t=e.up().previous(".wysija_theme").readAttribute("rel");return wysijaAJAX.task="setDefaultTheme",wysijaAJAX.theme=t,WYSIJA_AJAX_POST({success:function(){$$(".wj_themes .default").invoke("removeClassName","selected"),$(e).addClassName("selected")},loading_message:wysijatrans.theme_setting_default,success_message:wysijatrans.theme_saved_default}),!1}function handleRemoveTheme(){$$(".wj_themes li").invoke("stopObserving","mouseover"),$$(".wj_themes li").invoke("stopObserving","mouseout"),$$(".wj_themes li").invoke("observe","mouseover",function(){$(this).down("span.delete-wrap").show(),$(this).down("span.default-wrap").show()}),$$(".wj_themes li").invoke("observe","mouseout",function(){$(this).down("span.delete-wrap").hide(),$(this).down(".default-wrap").hide()}),$$(".wj_themes li .delete").invoke("observe","click",function(){removeTheme($(this).innerHTML),$(this).stopObserving("click")})}function handleDefaultTheme(){$$(".wj_themes li .default").invoke("observe","click",function(){$$(".wj_themes li .default.selected").length>0&&$$(".wj_themes li .default.selected").first().up().hide(),setDefaultTheme(this)})}function handleSwitchTheme(){$$("a.wysija_theme").invoke("observe","click",function(e){switchThemeWYSIJA(e)})}function removeTheme(e){return confirm(wysijatrans.abouttodeletetheme.replace("%1$s",e))&&($("wysija-theme-"+e).remove(),wysijaAJAX.task="deleteTheme",wysijaAJAX.themekey=e,WYSIJA_AJAX_POST()),!0}function removeImage(e){var t=wysijaIMG.unset(e);return void 0!==t&&$("wysija-img-"+e).remove(),saveIQS(),!0}function addImage(e){var t=new Element("img",{width:80,height:80,wysija_height:e.height,wysija_width:e.width,wysija_src:e.url,src:e.thumb_url}),i=new Element("a",{wysija_type:"image","class":"wysija_item"}).update(t),s=new Element("li",{id:"wysija-img-"+e.identifier,"class":"new"}).update(i);return s.insert('<span class="delete-wrap" style="display:none;"><span class="delete">'+e.identifier+"</span></span>"),s.insert('<span class="default-wrap" style="display:none;"><span class="default">'+e.identifier+"</span></span>"),$("wj-images-quick").insert({top:s}),handleRemoveImage(),wysijaIMG.set(e.identifier,e),saveIQS(),!0}function imagesTabPostHandler(){return updateImagesToolbarSize()}function updateImagesToolbarSize(){var e=document.viewport.getDimensions().height,t=$("wpadminbar").getLayout().get("margin-box-height"),i=$("wpfooter").getLayout().get("margin-box-height"),s=$("wj-images-quick"),a=s.getLayout(),n=$("wysija_toolbar").getLayout().get("margin-box-height")-a.get("margin-box-height"),o=$("wysija-app").getLayout(),r=o.get("margin-box-height")-o.get("height"),h=$("wpbody-content").getLayout().get("height")-o.get("margin-box-height"),l=e-t-i-n-r-h;s.setStyle({height:l+"px"})}var wysijaIMG=$H(),ajaxOver=!0;document.observe("dom:loaded",function(){void 0!=$("wysija-upload-browse")&&$("wysija-upload-browse").observe("click",function(){return WysijaPopup.open($(this).innerHTML,$(this).readAttribute("href2")),!1}),void 0!=$("wysija-themes-browse")&&$("wysija-themes-browse").observe("click",function(){return WysijaPopup.open($(this).innerHTML,$(this).readAttribute("href2")),!1}),void 0!=$("wysija_divider_settings")&&$("wysija_divider_settings").observe("click",function(){return WysijaPopup.open(wysijatrans.dividerSelectionTitle,$(this).readAttribute("href2")),!1}),handleRemoveImage(),handleRemoveTheme(),handleSwitchTheme(),handleDefaultTheme(),$$(".wysija_toolbar_tabs a").invoke("observe","click",function(){$$(".wysija_toolbar_tabs a").invoke("removeClassName","selected"),$$(".wj_images, .wj_content, .wj_styles, .wj_themes").invoke("hide"),$$(".wj_"+$(this).readAttribute("rel"))[0].show(),$(this).addClassName("selected");var e=window[$(this).readAttribute("rel")+"TabPostHandler"];return"function"==typeof e&&e(),!1}),Event.observe(window,"resize",function(){updateImagesToolbarSize()})});
js/admin-config-settings.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){function i(){e("#manage_subscriptions").attr("checked")?e(".manage_subscriptions").fadeIn():e(".manage_subscriptions").fadeOut()}function n(i){null===i?e.each(e(".page_select"),function(){e("#"+e(this).attr("id")+"-links-"+e(this).val()).fadeIn()}):(id_section="#"+e(i).attr("id")+"-links",e(id_section+" span").hide(),e(id_section+"-"+e(i).val()).fadeIn())}function t(){switch(e("#restapipossible").hide(),e("#smtp-host").val()){case"smtp.gmail.com":""==_&&(e("#smtp-port").val("465"),e("#smtp-secure").val("ssl"),e("#smtp-login").val("your_username@gmail.com"));break;case"smtp.sendgrid.net":e("#restapipossible").show();break;case"":""==_&&(e("#smtp-port").val("25"),e("#smtp-secure").val("0"),e("#smtp-login").val(""))}""==_&&e("#smtp-secure").change()}function a(){"smtp"==e('input[name="wysija[config][sending_method]"]:checked').val()&&("none"!=e("#restapipossible").css("display")&&e("#smtp-rest").attr("checked")?e(".choice-no-restapi").hide():e(".choice-no-restapi").show())}function s(){1===parseInt(e('input[name="wysija[config][confirm_dbleoptin]"]:checked').attr("value"))?e(".confirmemail").fadeIn():e(".confirmemail").fadeOut()}function o(){var i=e(".mailpoet-frequency_warning"),n=e("#sending-emails-each"),t=["one_min","two_min","five_min","ten_min"];-1!==e.inArray(n.val(),t)?i.removeClass("hidden"):i.addClass("hidden")}function c(){return"gmail"==e('input[name="wysija[config][sending_method]"]:checked').val()}function r(){c()?e('select[name="wysija[config][sending_emails_each]"] option[value="hourly"]').length>0&&(e("#sending-emails-number").val("20"),e('select[name="wysija[config][sending_emails_each]"]').val("hourly"),e("#sending-emails-number").attr("readonly","readonly"),e('select[name="wysija[config][sending_emails_each]"]').attr("disabled","disabled")):(e('select[name="wysija[config][sending_emails_each]"]').removeAttr("disabled"),e("#sending-emails-number").removeAttr("readonly"))}function d(){return wysijaAJAX.task="send_test_mail",wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.testemail,wysijaAJAX.dataType="json",e.WYSIJA_SEND(),!1}function l(){return wysijaAJAX.task="bounce_connect",wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.bounceconnect,wysijaAJAX.dataType="json",wysijaAJAXcallback.onSuccess=function(i){var n="";return i.result.result&&(n='<a class="bounce-submit button-secondary" href2="admin.php?page=wysija_campaigns&action=test_bounce">'+wysijatrans.processbounce+"</a>"),displaychange?e(".allmsgs.ui-dialog-content.ui-widget-content").append(n):e("#bounce-connector").after(n),!0},e.WYSIJA_SEND(),!1}function m(){return wysijaAJAX.task="bounce_process",wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.processbounceT,wysijaAJAX.dataType="html",e(".allmsgs").dialog(),e.WYSIJA_SEND(),!1}function h(){"undefined"!=typeof this?e.each(e(".activateInput"),function(){u(this)}):u(this)}function u(i){e(i).attr("checked")?e("#"+e(i).attr("id")+"_linkname").fadeIn():e("#"+e(i).attr("id")+"_linkname").fadeOut()}function f(){subscribersCountList=[],e(".subscribers-count-list").each(function(){e(this).is(":checked")&&subscribersCountList.push(e(this).val())}),shortCode="[",shortCode+="wysija_subscribers_count",subscribersCountList.length>0&&(shortCode+=' list_id="'+subscribersCountList.join()+'" '),shortCode+="]",e(".subscribers-count-shortcode").val(shortCode)}function g(){switch(e("#ms-restapipossible").hide(),e("#ms-smtp-host").val()){case"smtp.gmail.com":""==v&&(e("#ms-smtp-port").val("465"),e("#ms-smtp-secure").val("ssl"),e("#ms-smtp-login").val("your_username@gmail.com"));break;case"smtp.sendgrid.net":e("#ms-restapipossible").show();break;case"":""==v&&(e("#ms-smtp-port").val("25"),e("#ms-smtp-secure").val("0"),e("#ms-smtp-login").val(""))}""==v&&e("#ms-smtp-secure").change()}function p(){"smtp"==e('input[name="wysija[config][ms_sending_method]"]:checked').val()&&("none"!=e("#ms-restapipossible").css("display")&&e("#ms-smtp-rest").attr("checked")?e(".ms-choice-no-restapi").hide():e(".ms-choice-no-restapi").show())}function y(){-1!==e.inArray(e("#ms-sending-emails-each").val(),["one_min","two_min","five_min","ten_min"])?e(".ms-choice-under15").show():e(".ms-choice-under15").hide()}function w(){"one-for-all"==e('input[name="wysija[config][ms_sending_config]"]:checked').val()?e(".choice-one-for-all").show():e(".choice-one-for-all").hide()}function b(){return wysijaAJAX.task="send_test_mail_ms",wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.testemail,wysijaAJAX.dataType="json",e.WYSIJA_SEND(),!1}var _=e("#smtp-login").val();e(".hidechoice").hide(),e(".choice-sending-method-"+e('input[name="wysija[config][sending_method]"]:checked').val()).show(),e('input[name="wysija[config][sending_method]"]').change(function(){e(".hidechoice").hide(),e(".choice-sending-method-"+this.value).show(),r()}),e("#sending-emails-each").change(function(){o()}),e("#linksendingmethod").click(function(){e("#tabs").tabs("select",e(this).attr("href"))}),e("#mainmenu li a").click(function(){e("#redirecttab").val(e(this).attr("href"))}),e('input[name="wysija[config][confirm_dbleoptin]"]').change(s),e("#confirm_dbleoptin-1").click(function(){return confirm(wysijatrans.doubleoptinon)}),e("#confirm_dbleoptin-0").click(function(){return confirm(wysijatrans.doubleoptinoff)}),e('input[name="wysija[config][sending_emails_site_method]"]').change(function(){"sendmail"==e('input[name="wysija[config][sending_emails_site_method]"]:checked').val()?e("#p-sending-emails-site-method-sendmail-path").show():e("#p-sending-emails-site-method-sendmail-path").hide()}),e('input[name="wysija[config][sending_emails_site_method]"]').change(),e(".page_select").change(function(){n(this)}),e("#manage_subscriptions").change(function(){i()}),e("#smtp-host").keyup(t),e("#smtp-rest").change(a),e("#button-regenerate-dkim").click(function(){return e("#sending-emails-site-method-phpmail").attr("checked","checked"),e("#dkim_regenerate").val("regenerate"),e("#wysija-settings").submit(),!1}),e("#send-test-mail-phpmail").click(function(){return e("#sending-emails-site-method-phpmail").attr("checked","checked"),d(),!1}),e("#send-test-mail-sendmail").click(function(){return e("#sending-emails-site-method-sendmail").attr("checked","checked"),d(),!1}),e("#send-test-mail-wpmail").click(function(){return e("#sending-emails-site-method-wpmail").attr("checked","checked"),d(),!1}),e("#send-test-mail-smtp").click(function(){return d(),!1}),e("#bounce-connector").click(l),e(document).on("click",".bounce-submit",function(){return m(),e(".allmsgs").dialog("close"),tb_show(wysijatrans.processbounceT,e(this).attr("href2")+"&KeepThis=true&TB_iframe=true&height=400&width=600",null),tb_showIframe(),!1}),e(".forwardto").change(function(){e(this).attr("checked")?e("#"+e(this).attr("id")+"_input").show():e("#"+e(this).attr("id")+"_input").hide()}),e.each(e(".hideifnovalue"),function(){""==e(this).find("input").val()&&e(this).hide()}),e("#wysija-settings").submit(function(){var i=!1;return e(".bounce-forward-email").each(function(){var n=trim(e(this).val());""!==n&&n==e("#bounce_email").val()&&(e('#wysija-tabs a[href="#bounce"]').trigger("click"),e('#wysija-innertabs a[href="#actions"]').trigger("click"),e(this).css("border","1px solid #CC0000"),e("#bounce-msg-error").addClass("error"),e("#bounce-msg-error").html(wysijatrans.errorbounceforward),i=!0)}),i?!1:(e('select[name="wysija[config][sending_emails_each]"]').removeAttr("disabled"),void 0)}),e("#bounce-process-auto").attr("checked")?e("#bounce-frequency").show():e("#bounce-frequency").hide(),e("#bounce-process-auto").change(function(){e(this).attr("checked")?e("#bounce-frequency").show():e("#bounce-frequency").hide()}),e(".activateInput").change(h),e(document).on("click","#wysija-innertabs .nav-tab",function(i,n){var t,a=e(".wysija-innerpanel"),s=e("#wysija-innertabs").children(".nav-tab"),o=e(this),c=o.attr("href").replace("#",""),r={};return"undefined"==typeof n&&(n=!0),a.each(function(i,n){var t=e(n);r[t.attr("id")]=t}),t=r[c],s.removeClass("nav-tab-active"),o.addClass("nav-tab-active"),a.not(".hidden").addClass("hidden"),t.removeClass("hidden"),n&&(window.location.hash="inner-tab-"+c),t.trigger("shown.innertab.mailpoet"),!1}),e(document).on("click","#wysija-tabs .nav-tab",function(i,n){var t,a=e(".wysija-panel"),s=e("#wysija-tabs").children(".nav-tab"),o=e(this),c=o.attr("href").replace("#",""),r={};return"undefined"==typeof n&&(n=!0),a.each(function(i,n){var t=e(n);r[t.attr("id")]=t}),t=r[c],s.removeClass("nav-tab-active"),o.addClass("nav-tab-active"),a.not(".hidden").addClass("hidden"),t.removeClass("hidden"),n&&(window.location.hash="tab-"+c),t.trigger("shown.tab.mailpoet"),!1}),e(document).on("click","#tip-send-with",function(i){e('.nav-tab[href="#sendingmethod"]').trigger("click"),i.preventDefault()}),e(window).load(function(){if(window.location.hash.length>0){var i=window.location.hash.replace("tab-","");e('#wysija-tabs .nav-tab[href="'+i+'"]').trigger("click")}else e("#wysija-tabs .nav-tab").first().trigger("click",!1);if(1===window.location.hash.indexOf("inner-tab")){var n=e('#wysija-innertabs .nav-tab[href="'+window.location.hash.replace("inner-tab-","")+'"]').trigger("click");e('#wysija-tabs .nav-tab[href="#'+n.parents(".wysija-panel").attr("id")+'"]').trigger("click",!1)}else e("#wysija-innertabs .nav-tab-active").trigger("click",!1)}),e(document).ready(function(){r(),o(),s(),h(),t(),a(),n(null),i(),e(".subscribers-count-list").change(f),e("#analytics-0").is(":checked")&&e("#advanced .industry").hide(),e("#analytics-1").change(function(){"1"==e(this).val()&&e("#advanced .industry").show()}),e("#analytics-0").change(function(){"0"==e(this).val()&&e("#advanced .industry").hide()}),e("#"+getURLParameter("scroll_to")).length>0&&(e("html,body").animate({scrollTop:e("#"+getURLParameter("scroll_to")).offset().top-e("#wpadminbar").height()},500),e("#"+getURLParameter("scroll_to")).css({"background-color":"#f8fcff","font-size":"16px","font-weight":"bold"}))}),e("#dkimpub, #domainrecord, .subscribers-count-shortcode").click(function(){this.select()});var v=e("#ms-smtp-login").val();e(".ms-hidechoice").hide(),e(".ms-choice-sending-method-"+e('input[name="wysija[config][ms_sending_method]"]:checked').val()).show(),e('input[name="wysija[config][ms_sending_method]"]').change(function(){e(".ms-hidechoice").hide(),e(".ms-choice-sending-method-"+this.value).show()}),e("#ms-sending-emails-each").change(function(){y()}),e('input[name="wysija[config][ms_sending_config]"]').change(function(){w()}),e('input[name="wysija[config][ms_sending_emails_site_method]"]').change(function(){"sendmail"==e('input[name="wysija[config][ms_sending_emails_site_method]"]:checked').val()?e("#ms_p-sending-emails-site-method-sendmail-path").show():e("#ms_p-sending-emails-site-method-sendmail-path").hide()}),e('input[name="wysija[config][ms_sending_emails_site_method]"]').change(),e("#ms-smtp-host").keyup(g),e("#ms-smtp-rest").change(p),e("#ms-send-test-mail-phpmail").click(function(){return e("#ms-sending-emails-site-method-phpmail").attr("checked","checked"),b(),!1}),e("#ms-send-test-mail-sendmail").click(function(){return e("#ms-sending-emails-site-method-sendmail").attr("checked","checked"),b(),!1}),e("#ms-send-test-mail-smtp").click(function(){return b(),!1}),e.each(e(".hideifnovalue"),function(){""===e(this).find("input").val()&&e(this).hide()}),e("table.capabilities_form .view_all").click(function(){e("table.capabilities_form tr.hidden").removeClass("hidden"),objTr=e(this).parents("tr")[0],e(objTr).remove()}),e(document).ready(function(){w(),y(),g(),p()})}),window.mailpoet="object"==typeof window.mailpoet?window.mailpoet:{$:{}},function(e,i){"use strict";var n=i.mailpoet,t=n.fn={};t.getSendingMethod=function(){return n.$.sending_method instanceof jQuery||(n.$.sending_method=e('input[name="wysija[config][sending_method]"]')),n.$.sending_method.filter(":checked").val()},t.isGoodFromAddress=function(e){var n=e.split("@")[1];return"undefined"==typeof n||""===n?!1:n.toLowerCase()!==i.location.host.toLowerCase()?!1:!0},t.isGmailAddress=function(e){var i=e.split("@")[1];return"undefined"==typeof i||""===i?!1:"gmail.com"!==i.toLowerCase()?!1:!0}}(jQuery,window),function(e,i){"use strict";var n=i.mailpoet;e(document).ready(function(){"object"==typeof e.fn.tooltip&&(n.$.from_email=e("#from_email"),n.$.from_email.tooltip({animation:!0,placement:"bottom",trigger:"manual",html:!0,title:function(){return n.$.from_email.data("message")}}).on({"verifyEmail.mailpoet":function(){if(n.fn.isGoodFromAddress(n.$.from_email.val()))return n.$.from_email.data("message","").tooltip("hide");if("gmail"===n.fn.getSendingMethod())return n.$.from_email.data("message","").tooltip("hide");var e="";return e=n.fn.isGmailAddress(n.$.from_email.val())?mpEmailCheck.gmailText:mpEmailCheck.text,n.$.from_email.is(":visible")?n.$.from_email.data("message",e).tooltip("show"):n.$.from_email.tooltip("hide")},keyup:function(){n.$.from_email.trigger("verifyEmail.mailpoet")}}).trigger("verifyEmail.mailpoet"),n.$.panels=e(".wysija-panel"),n.$.panels.filter("#basics").on({"shown.tab.mailpoet":function(){n.$.from_email.trigger("verifyEmail.mailpoet")}}))})}(jQuery,window),function(e,i){"use strict";var n=i.mailpoet;e(document).on({ready:function(){n.$.geeky=e(".mailpoet-geeky-toggle"),n.$.geeky.data("l18n",{hide:n.$.geeky.data("hide"),show:n.$.geeky.text()}),n.$.geeky_rows=e(".super-advanced"),n.$.geeky.on({click:function(i){i.preventDefault();var t=n.$.geeky.data("l18n");n.$.geeky.hasClass("is_toggled")?(n.$.geeky.removeClass("is_toggled").text(t.hide),n.$.geeky_rows.removeClass("hidden"),void 0!==i.originalEvent&&e.cookie("geeky_option",1)):(n.$.geeky.addClass("is_toggled").text(t.show),n.$.geeky_rows.addClass("hidden"),void 0!==i.originalEvent&&e.cookie("geeky_option",0))}}),1==e.cookie("geeky_option")?n.$.geeky.trigger("click"):n.$.geeky_rows.addClass("hidden")}})}(jQuery,window);
1
+ jQuery(function(e){function i(){e("#manage_subscriptions").attr("checked")?e(".manage_subscriptions").fadeIn():e(".manage_subscriptions").fadeOut()}function n(i){null===i?e.each(e(".page_select"),function(){e("#"+e(this).attr("id")+"-links-"+e(this).val()).fadeIn()}):(id_section="#"+e(i).attr("id")+"-links",e(id_section+" span").hide(),e(id_section+"-"+e(i).val()).fadeIn())}function t(){switch(e("#restapipossible").hide(),e("#smtp-host").val()){case"smtp.gmail.com":""==w&&(e("#smtp-port").val("465"),e("#smtp-secure").val("ssl"),e("#smtp-login").val("your_username@gmail.com"));break;case"smtp.sendgrid.net":e("#restapipossible").show();break;case"":""==w&&(e("#smtp-port").val("25"),e("#smtp-secure").val("0"),e("#smtp-login").val(""))}""==w&&e("#smtp-secure").change()}function a(){"smtp"==e('input[name="wysija[config][sending_method]"]:checked').val()&&("none"!=e("#restapipossible").css("display")&&e("#smtp-rest").attr("checked")?e(".choice-no-restapi").hide():e(".choice-no-restapi").show())}function s(){1===parseInt(e('input[name="wysija[config][confirm_dbleoptin]"]:checked').attr("value"))?e(".confirmemail").fadeIn():e(".confirmemail").fadeOut()}function o(){var i=e(".mailpoet-frequency_warning"),n=e("#sending-emails-each"),t=["one_min","two_min","five_min","ten_min"];-1!==e.inArray(n.val(),t)?i.removeClass("hidden"):i.addClass("hidden")}function c(){return"gmail"==e('input[name="wysija[config][sending_method]"]:checked').val()}function r(){c()?e('select[name="wysija[config][sending_emails_each]"] option[value="hourly"]').length>0&&(e("#sending-emails-number").val("20"),e('select[name="wysija[config][sending_emails_each]"]').val("hourly"),e("#sending-emails-number").attr("readonly","readonly"),e('select[name="wysija[config][sending_emails_each]"]').attr("disabled","disabled")):(e('select[name="wysija[config][sending_emails_each]"]').removeAttr("disabled"),e("#sending-emails-number").removeAttr("readonly"))}function d(){return wysijaAJAX.task="bounce_connect",wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.bounceconnect,wysijaAJAX.dataType="json",wysijaAJAXcallback.onSuccess=function(i){var n="";return i.result.result&&(n='<a class="bounce-submit button-secondary" href2="admin.php?page=wysija_campaigns&action=test_bounce">'+wysijatrans.processbounce+"</a>"),displaychange?e(".allmsgs.ui-dialog-content.ui-widget-content").append(n):e("#bounce-connector").after(n),!0},e.WYSIJA_SEND(),!1}function l(){return wysijaAJAX.task="bounce_process",wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.processbounceT,wysijaAJAX.dataType="html",e(".allmsgs").dialog(),e.WYSIJA_SEND(),!1}function m(){"undefined"!=typeof this?e.each(e(".activateInput"),function(){h(this)}):h(this)}function h(i){e(i).attr("checked")?e("#"+e(i).attr("id")+"_linkname").fadeIn():e("#"+e(i).attr("id")+"_linkname").fadeOut()}function u(){subscribersCountList=[],e(".subscribers-count-list").each(function(){e(this).is(":checked")&&subscribersCountList.push(e(this).val())}),shortCode="[",shortCode+="wysija_subscribers_count",subscribersCountList.length>0&&(shortCode+=' list_id="'+subscribersCountList.join()+'" '),shortCode+="]",e(".subscribers-count-shortcode").val(shortCode)}function g(){switch(e("#ms-restapipossible").hide(),e("#ms-smtp-host").val()){case"smtp.gmail.com":""==b&&(e("#ms-smtp-port").val("465"),e("#ms-smtp-secure").val("ssl"),e("#ms-smtp-login").val("your_username@gmail.com"));break;case"smtp.sendgrid.net":e("#ms-restapipossible").show();break;case"":""==b&&(e("#ms-smtp-port").val("25"),e("#ms-smtp-secure").val("0"),e("#ms-smtp-login").val(""))}""==b&&e("#ms-smtp-secure").change()}function f(){"smtp"==e('input[name="wysija[config][ms_sending_method]"]:checked').val()&&("none"!=e("#ms-restapipossible").css("display")&&e("#ms-smtp-rest").attr("checked")?e(".ms-choice-no-restapi").hide():e(".ms-choice-no-restapi").show())}function p(){-1!==e.inArray(e("#ms-sending-emails-each").val(),["one_min","two_min","five_min","ten_min"])?e(".ms-choice-under15").show():e(".ms-choice-under15").hide()}function y(){"one-for-all"==e('input[name="wysija[config][ms_sending_config]"]:checked').val()?e(".choice-one-for-all").show():e(".choice-one-for-all").hide()}var w=e("#smtp-login").val();e(".hidechoice").hide(),e(".choice-sending-method-"+e('input[name="wysija[config][sending_method]"]:checked').val()).show(),e('input[name="wysija[config][sending_method]"]').change(function(){e(".hidechoice").hide(),e(".choice-sending-method-"+this.value).show(),r()}),e("#sending-emails-each").change(function(){o()}),e("#linksendingmethod").click(function(){e("#tabs").tabs("select",e(this).attr("href"))}),e("#mainmenu li a").click(function(){e("#redirecttab").val(e(this).attr("href"))}),e('input[name="wysija[config][confirm_dbleoptin]"]').change(s),e("#confirm_dbleoptin-1").click(function(){return confirm(wysijatrans.doubleoptinon)}),e("#confirm_dbleoptin-0").click(function(){return confirm(wysijatrans.doubleoptinoff)}),e('input[name="wysija[config][sending_emails_site_method]"]').change(function(){"sendmail"==e('input[name="wysija[config][sending_emails_site_method]"]:checked').val()?e("#p-sending-emails-site-method-sendmail-path").show():e("#p-sending-emails-site-method-sendmail-path").hide()}),e('input[name="wysija[config][sending_emails_site_method]"]').change(),e(".page_select").change(function(){n(this)}),e("#manage_subscriptions").change(function(){i()}),e("#smtp-host").keyup(t),e("#smtp-rest").change(a),e("#button-regenerate-dkim").click(function(){return e("#sending-emails-site-method-phpmail").attr("checked","checked"),e("#dkim_regenerate").val("regenerate"),e("#wysija-settings").submit(),!1}),e("#bounce-connector").click(d),e(document).on("click",".bounce-submit",function(){return l(),e(".allmsgs").dialog("close"),tb_show(wysijatrans.processbounceT,e(this).attr("href2")+"&KeepThis=true&TB_iframe=true&height=400&width=600",null),tb_showIframe(),!1}),e(".forwardto").change(function(){e(this).attr("checked")?e("#"+e(this).attr("id")+"_input").show():e("#"+e(this).attr("id")+"_input").hide()}),e.each(e(".hideifnovalue"),function(){""==e(this).find("input").val()&&e(this).hide()}),e("#wysija-settings").submit(function(){var i=!1;return e(".bounce-forward-email").each(function(){var n=trim(e(this).val());""!==n&&n==e("#bounce_email").val()&&(e('#wysija-tabs a[href="#bounce"]').trigger("click"),e('#wysija-innertabs a[href="#actions"]').trigger("click"),e(this).css("border","1px solid #CC0000"),e("#bounce-msg-error").addClass("error"),e("#bounce-msg-error").html(wysijatrans.errorbounceforward),i=!0)}),i?!1:(e('select[name="wysija[config][sending_emails_each]"]').removeAttr("disabled"),void 0)}),e("#bounce-process-auto").attr("checked")?e("#bounce-frequency").show():e("#bounce-frequency").hide(),e("#bounce-process-auto").change(function(){e(this).attr("checked")?e("#bounce-frequency").show():e("#bounce-frequency").hide()}),e(".activateInput").change(m),e(document).on("click","#wysija-innertabs .nav-tab",function(i,n){var t,a=e(".wysija-innerpanel"),s=e("#wysija-innertabs").children(".nav-tab"),o=e(this),c=o.attr("href").replace("#",""),r={};return"undefined"==typeof n&&(n=!0),a.each(function(i,n){var t=e(n);r[t.attr("id")]=t}),t=r[c],s.removeClass("nav-tab-active"),o.addClass("nav-tab-active"),a.not(".hidden").addClass("hidden"),t.removeClass("hidden"),n&&(window.location.hash="inner-tab-"+c),t.trigger("shown.innertab.mailpoet"),!1}),e(document).on("click","#wysija-tabs .nav-tab",function(i,n){var t,a=e(".wysija-panel"),s=e("#wysija-tabs").children(".nav-tab"),o=e(this),c=o.attr("href").replace("#",""),r={};return"undefined"==typeof n&&(n=!0),a.each(function(i,n){var t=e(n);r[t.attr("id")]=t}),t=r[c],s.removeClass("nav-tab-active"),o.addClass("nav-tab-active"),a.not(".hidden").addClass("hidden"),t.removeClass("hidden"),n&&(window.location.hash="tab-"+c),t.trigger("shown.tab.mailpoet"),!1}),e(document).on("click","#tip-send-with",function(i){e('.nav-tab[href="#sendingmethod"]').trigger("click"),i.preventDefault()}),e(window).load(function(){if(window.location.hash.length>0){var i=window.location.hash.replace("tab-","");e('#wysija-tabs .nav-tab[href="'+i+'"]').trigger("click")}else e("#wysija-tabs .nav-tab").first().trigger("click",!1);if(1===window.location.hash.indexOf("inner-tab")){var n=e('#wysija-innertabs .nav-tab[href="'+window.location.hash.replace("inner-tab-","")+'"]').trigger("click");e('#wysija-tabs .nav-tab[href="#'+n.parents(".wysija-panel").attr("id")+'"]').trigger("click",!1)}else e("#wysija-innertabs .nav-tab-active").trigger("click",!1)}),e(document).ready(function(){r(),o(),s(),m(),t(),a(),n(null),i(),e(".subscribers-count-list").change(u),e("#analytics-0").is(":checked")&&e("#advanced .industry").hide(),e("#analytics-1").change(function(){"1"==e(this).val()&&e("#advanced .industry").show()}),e("#analytics-0").change(function(){"0"==e(this).val()&&e("#advanced .industry").hide()}),e("#"+getURLParameter("scroll_to")).length>0&&(e("html,body").animate({scrollTop:e("#"+getURLParameter("scroll_to")).offset().top-e("#wpadminbar").height()},500),e("#"+getURLParameter("scroll_to")).css({"background-color":"#f8fcff","font-size":"16px","font-weight":"bold"}))}),e("#dkimpub, #domainrecord, .subscribers-count-shortcode").click(function(){this.select()});var b=e("#ms-smtp-login").val();e(".ms-hidechoice").hide(),e(".ms-choice-sending-method-"+e('input[name="wysija[config][ms_sending_method]"]:checked').val()).show(),e('input[name="wysija[config][ms_sending_method]"]').change(function(){e(".ms-hidechoice").hide(),e(".ms-choice-sending-method-"+this.value).show()}),e("#ms-sending-emails-each").change(function(){p()}),e('input[name="wysija[config][ms_sending_config]"]').change(function(){y()}),e('input[name="wysija[config][ms_sending_emails_site_method]"]').change(function(){"sendmail"==e('input[name="wysija[config][ms_sending_emails_site_method]"]:checked').val()?e("#ms_p-sending-emails-site-method-sendmail-path").show():e("#ms_p-sending-emails-site-method-sendmail-path").hide()}),e('input[name="wysija[config][ms_sending_emails_site_method]"]').change(),e("#ms-smtp-host").keyup(g),e("#ms-smtp-rest").change(f),e.each(e(".hideifnovalue"),function(){""===e(this).find("input").val()&&e(this).hide()}),e("table.capabilities_form .view_all").click(function(){e("table.capabilities_form tr.hidden").removeClass("hidden"),objTr=e(this).parents("tr")[0],e(objTr).remove()}),e(".mailpoet-test-delivery").on({click:function(i){i.preventDefault();var n="network"===e(".mailpoet-delivery-method:checked").val()||e(this).data("multisite");return wysijaAJAX.task=n?"send_test_mail_ms":"send_test_mail",wysijaAJAX.data=e("form").serializeArray(),wysijaAJAX.popTitle=wysijatrans.testemail,wysijaAJAX.dataType="json",e.WYSIJA_SEND(),!1}}),e(document).ready(function(){y(),p(),g(),f()})}),window.mailpoet="object"==typeof window.mailpoet?window.mailpoet:{$:{}},function(e,i){"use strict";var n=i.mailpoet,t=n.fn={};t.getSendingMethod=function(){return n.$.sending_method instanceof jQuery||(n.$.sending_method=e('input[name="wysija[config][sending_method]"]')),n.$.sending_method.filter(":checked").val()},t.isGoodFromAddress=function(e){var n=e.split("@")[1];return"undefined"==typeof n||""===n?!1:n.toLowerCase()!==i.location.host.toLowerCase()?!1:!0},t.isGmailAddress=function(e){var i=e.split("@")[1];return"undefined"==typeof i||""===i?!1:"gmail.com"!==i.toLowerCase()?!1:!0}}(jQuery,window),function(e,i){"use strict";var n=i.mailpoet;e(document).ready(function(){"object"==typeof e.fn.tooltip&&(n.$.from_email=e("#from_email"),n.$.from_email.tooltip({animation:!0,placement:"bottom",trigger:"manual",html:!0,title:function(){return n.$.from_email.data("message")}}).on({"verifyEmail.mailpoet":function(){if(n.fn.isGoodFromAddress(n.$.from_email.val()))return n.$.from_email.data("message","").tooltip("hide");if("gmail"===n.fn.getSendingMethod())return n.$.from_email.data("message","").tooltip("hide");var e="";return e=n.fn.isGmailAddress(n.$.from_email.val())?mpEmailCheck.gmailText:mpEmailCheck.text,n.$.from_email.is(":visible")?n.$.from_email.data("message",e).tooltip("show"):n.$.from_email.tooltip("hide")},keyup:function(){n.$.from_email.trigger("verifyEmail.mailpoet")}}).trigger("verifyEmail.mailpoet"),n.$.panels=e(".wysija-panel"),n.$.panels.filter("#basics").on({"shown.tab.mailpoet":function(){n.$.from_email.trigger("verifyEmail.mailpoet")}}))})}(jQuery,window),function(e,i){"use strict";var n=i.mailpoet;e(document).on({ready:function(){n.$.geeky=e(".mailpoet-geeky-toggle"),n.$.geeky.data("l18n",{hide:n.$.geeky.data("hide"),show:n.$.geeky.text()}),n.$.geeky_rows=e(".super-advanced"),n.$.geeky.on({click:function(i){i.preventDefault();var t=n.$.geeky.data("l18n");n.$.geeky.hasClass("is_toggled")?(n.$.geeky.removeClass("is_toggled").text(t.hide),n.$.geeky_rows.removeClass("hidden"),void 0!==i.originalEvent&&e.cookie("geeky_option",1)):(n.$.geeky.addClass("is_toggled").text(t.show),n.$.geeky_rows.addClass("hidden"),void 0!==i.originalEvent&&e.cookie("geeky_option",0))}}),1==e.cookie("geeky_option")?n.$.geeky.trigger("click"):n.$.geeky_rows.addClass("hidden")}})}(jQuery,window);
js/admin-subscribers-importmatch.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(t){t("#namenewlist").attr("disabled","disabled"),t("#blocknewlist").hide(),t("#namenewlist").focus(function(){this.value==this.defaultValue&&(this.value="")}).blur(function(){this.value.length||(this.value=this.defaultValue)}),t("#list0").click(function(){this.checked?(t("#namenewlist").removeAttr("disabled"),t("#blocknewlist").fadeIn().prev().find("span").hide()):(t("#namenewlist").attr("disabled","disabled"),t("#blocknewlist").fadeOut().prev().find("span").show())}),t(".create_extra").change(function(){var e=t(this).attr("id").replace("column-match-","column-match-date-wrap-");-1!=this.value.indexOf("new_field|date")?(t(t(this).attr("class").split(" ")).each(function(){""!==this&&-1!=this.indexOf("row-")&&t("span."+this).fadeIn()}),t("#"+e).fadeIn()):null!=t("#"+e)&&(t(t(this).attr("class").split(" ")).each(function(){""!==this&&-1!=this.indexOf("row-")&&t("span."+this).fadeOut()}),t("#"+e).fadeOut())}),jQuery(".match-dropdown select").matchColumn({defaultValue:"nomatch",showConfirmation:!0,confirmationMessage:wysijatrans.subscribers_import_match_confirmation_1+"\n"+wysijatrans.subscribers_import_match_confirmation_2})});
1
+ jQuery(function(t){t("#namenewlist").attr("disabled","disabled"),t("#blocknewlist").hide(),t("#namenewlist").focus(function(){this.value==this.defaultValue&&(this.value="")}).blur(function(){this.value.length||(this.value=this.defaultValue)}),t("#list0").click(function(){this.checked?(t("#namenewlist").removeAttr("disabled"),t("#blocknewlist").fadeIn().prev().find("span").hide()):(t("#namenewlist").attr("disabled","disabled"),t("#blocknewlist").fadeOut().prev().find("span").show())}),t(".create_extra").change(function(){var e=t(this).attr("id").replace("column-match-","column-match-date-wrap-");-1!=this.value.indexOf("new_field|date")?(t(t(this).attr("class").split(" ")).each(function(){""!==this&&-1!=this.indexOf("row-")&&t("span."+this).fadeIn()}),t("#"+e).fadeIn()):null!=t("#"+e)&&(t(t(this).attr("class").split(" ")).each(function(){""!==this&&-1!=this.indexOf("row-")&&t("span."+this).fadeOut()}),t("#"+e).fadeOut())}),jQuery(".match-dropdown select").matchColumn({defaultValue:"nomatch",showConfirmation:!0,confirmationMessage:wysijatrans.subscribers_import_match_confirmation_1+"\n"+wysijatrans.subscribers_import_match_confirmation_2,beforeResetColumn:function(t,e){"undefined"!=typeof jQuery.userStatusMapping&&"status"===t&&jQuery.userStatusMapping.changeFromUserStatus(e)},beforeChange:function(t,e){"undefined"!=typeof jQuery.userStatusMapping&&"status"===t&&jQuery.userStatusMapping.changeFromUserStatus(e)}}),"undefined"!=typeof wysijatrans.userStatuses&&jQuery(".match-dropdown select").userStatusMapping({defaultValue:"status",dataElement:".imported-field",statuses:wysijatrans.userStatuses})});
js/admin-wysija.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(a){function i(i){i?(a(".wysija-premium-activate").addClass("wysija-button-loading"),a(".wysija-premium-activate").html(wysijatrans.premium_activating+"<span>.</span><span>.</span><span>.</span>")):(a(".wysija-premium-activate").removeClass("wysija-button-loading"),a(".wysija-premium-activate").html(wysijatrans.premium_activate))}a("#wysija-app .submitdelete").click(function(){return confirm(wysijatrans.suredelete)}),a("#wysija-app .linkignore, .wysija-version .linkignore").click(function(){var i=this;return wysijaAJAX.controller="config",wysijaAJAX.task="linkignore",wysijaAJAX.ignorewhat=a.trim(a(this).attr("class").replace(/linkignore/g,"")),wysijaAJAX._wpnonce=a("#wysijax").val(),a.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(){a(i).parents(".removeme").length>0?a(i).parents(".removeme").fadeOut():a(i).parents("li").siblings().size()>0?a(i).parents("li").fadeOut():a(i).parents("div.updated").fadeOut()},error:function(a){alert("Request error not JSON:"+a.responseText),wysijaAJAXcallback.onSuccess=""},dataType:"json"}),!0}),a(document).on("click","#wysija-app .premium-tab, .wysija-msg .premium-tab, #theme-view .premium-tab",function(){a("#wysija-app .wysija-premium img").hide(),a(this).hasClass("ispopup")?(window.parent.tb_remove(),window.parent.location.href=wysijatrans.urlpremium):a("#wysija-tabs").length>0?a('#wysija-tabs a[href="#premium"]').trigger("click"):window.location.href=wysijatrans.urlpremium}),a(".wysija-premium-activate").click(function(){wysijaAJAX.controller="config",wysijaAJAX.task="validate",wysijaAJAX._wpnonce=a("#wysijax").val(),i(!0);var e=this;return a.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(s){s.result.result?window.location.href="admin.php?page=wysija_campaigns&sp=1":(s.result.nocontact?window.location.href="admin.php?page=wysija_campaigns&nocontact=1":(displaychange=0,a.WYSIJA_HANDLE_RESPONSE(s)),i(!1)),a(e).removeClass("wysija-button-loading")},error:function(a){alert(a.responseText),delete wysijaAJAXcallback.onSuccess,i(!1)},dataType:"json"}),!1}),a("#premium-deactivate").click(function(){return wysijaAJAX.controller="config",wysijaAJAX.task="devalidate",a("#wysija-app .wysija-premium img").hide(),wysijaAJAX._wpnonce=a("#wysijax").val(),a.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(){a("#wysija-app .wysija-premium img").hide(),window.location.reload()},error:function(i){a("#wysija-app .wysija-premium img").hide(),alert("Request error not JSON:"+i.responseText),wysijaAJAXcallback.onSuccess=""},dataType:"json"}),!0}),a("#install-wjp,#switch_to_package").click(function(){return confirm(a(this).data("warn"))?(tb_show(a(this).attr("title"),a(this).attr("href")+"&KeepThis=true&TB_iframe=true&height=400&width=600",null),tb_showIframe(),!1):!1}),a("#share_analytics").click(function(){var i=this;return wysijaAJAX.controller="config",wysijaAJAX.task="share_analytics",wysijaAJAX._wpnonce=a("#wysijax").val(),a.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(){a(i).text("Thanks!").contents().unwrap()},error:function(a){alert("Request error not JSON:"+a.responseText),wysijaAJAXcallback.onSuccess=""},dataType:"json"}),!0})});
1
+ jQuery(function(a){function i(i){i?(a(".wysija-premium-activate").addClass("wysija-button-loading"),a(".wysija-premium-activate").html(wysijatrans.premium_activating+"<span>.</span><span>.</span><span>.</span>")):(a(".wysija-premium-activate").removeClass("wysija-button-loading"),a(".wysija-premium-activate").html(wysijatrans.premium_activate))}a("#wysija-app .submitdelete").click(function(){return confirm(wysijatrans.suredelete)}),a("#wysija-app .linkignore, .wysija-version .linkignore").click(function(){var i=this;return wysijaAJAX.controller="config",wysijaAJAX.task="linkignore",wysijaAJAX.ignorewhat=a.trim(a(this).attr("class").replace(/linkignore/g,"")),wysijaAJAX._wpnonce=a("#wysijax").val(),a.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(){a(i).parents(".removeme").length>0?a(i).parents(".removeme").fadeOut():a(i).parents("li").siblings().size()>0?a(i).parents("li").fadeOut():a(i).parents("div.updated").fadeOut()},error:function(a){alert("Request error not JSON:"+a.responseText),wysijaAJAXcallback.onSuccess=""},dataType:"json"}),!0}),a(document).on("click","#wysija-app .premium-tab, .wysija-msg .premium-tab, #theme-view .premium-tab",function(){a("#wysija-app .wysija-premium img").hide(),a(this).hasClass("ispopup")?(window.parent.tb_remove(),window.parent.location.href=wysijatrans.urlpremium):a("#wysija-tabs").length>0?a('#wysija-tabs a[href="#premium"]').trigger("click"):window.location.href=wysijatrans.urlpremium}),a(".wysija-premium-activate").click(function(){wysijaAJAX.controller="config",wysijaAJAX.task="validate",wysijaAJAX._wpnonce=a("#wysijax").val(),i(!0);var t=this;return a.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(e){e.result.result?window.location.href="admin.php?page=wysija_campaigns&sp=1":(e.result.nocontact?window.location.href="admin.php?page=wysija_campaigns&nocontact=1":(displaychange=0,a.WYSIJA_HANDLE_RESPONSE(e)),i(!1)),a(t).removeClass("wysija-button-loading")},error:function(a){alert(a.responseText),delete wysijaAJAXcallback.onSuccess,i(!1)},dataType:"json"}),!1}),a("#install-wjp,#switch_to_package").click(function(){return confirm(a(this).data("warn"))?(tb_show(a(this).attr("title"),a(this).attr("href")+"&KeepThis=true&TB_iframe=true&height=400&width=600",null),tb_showIframe(),!1):!1}),a("#share_analytics").click(function(){var i=this;return wysijaAJAX.controller="config",wysijaAJAX.task="share_analytics",wysijaAJAX._wpnonce=a("#wysijax").val(),a.ajax({type:"POST",url:wysijaAJAX.ajaxurl,data:wysijaAJAX,success:function(){a(i).text("Thanks!").contents().unwrap()},error:function(a){alert("Request error not JSON:"+a.responseText),wysijaAJAXcallback.onSuccess=""},dataType:"json"}),!0})});
js/fields/select2-simple.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function( $, _ ){
2
+ 'use strict';
3
+
4
+ $( document ).ready(function(){
5
+ var $fields = $( '.mailpoet-field-select2-simple' );
6
+
7
+ // Setup Select2
8
+ $fields.each(function( k, field ){
9
+ var $field = $( field );
10
+
11
+ $field.select2({
12
+ placeholder: $field.data( 'placeholder' ),
13
+ allowClear: true,
14
+ multiple: $field.data( 'multiple' ),
15
+ minimumResultsForSearch: $field.data( 'minimumResultsForSearch' ),
16
+ width: $field.width()
17
+ });
18
+ });
19
+ });
20
+
21
+ }( jQuery, _ ));
js/fields/select2-terms.js ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function( $, _ ){
2
+ 'use strict';
3
+
4
+ $( document ).ready(function(){
5
+ var $fields = $( '.mailpoet-field-select2-terms' );
6
+
7
+ // Setup Select2
8
+ $fields.each(function( k, field ){
9
+ var $field = $( field );
10
+
11
+ $field.select2( {
12
+ width: $field.width(),
13
+ multiple: $field.data( 'multiple' ),
14
+ data: { results: [] },
15
+ initSelection : function (element, callback) {
16
+ callback( element.data( 'value' ) );
17
+ },
18
+ allowClear: true,
19
+ ajax: { // instead of writing the function to execute the request we use Select2's convenient helper
20
+ url: ajaxurl,
21
+ data: function (term, page) {
22
+ return {
23
+ action: 'wysija_ajax',
24
+ controller: 'campaigns',
25
+ task: 'search_terms',
26
+ search: term, // search term
27
+ page_limit: 10,
28
+ page: page,
29
+ post_type: $( '#post_type' ).val()
30
+ };
31
+ },
32
+ results: function (data, page) { // parse the results into the format expected by Select2.
33
+ var information = data.result;
34
+ $.each( information.results, function( k, result ){
35
+ result.text = _.template('<%= tax %>: <%= term %>')( { tax: information.taxonomies[result.taxonomy].labels.singular_name, term: result.name } );
36
+ result.id = result.term_id;
37
+ } );
38
+ return information;
39
+ }
40
+ },
41
+ } );
42
+ })
43
+ .trigger( 'change' )
44
+ .on({
45
+ 'change': function(e){
46
+ var data = $( this ).data( 'value' );
47
+
48
+ if ( e.added ){
49
+ if ( _.isArray( data ) ) {
50
+ data.push( e.added );
51
+ } else {
52
+ data = e.added;
53
+ }
54
+ } else {
55
+ if ( _.isArray( data ) ) {
56
+ data = _.without( data, e.removed );
57
+ } else {
58
+ data = '';
59
+ }
60
+ }
61
+ $( this ).data( 'value', data ).attr( 'data-value', JSON.stringify( data ) );
62
+ }
63
+ });
64
+
65
+ });
66
+
67
+ }( jQuery, _ ));
js/jquery/jquery.matchColumn.js CHANGED
@@ -1,88 +1,101 @@
1
  (function($) {
2
- $.fn.matchColumn = function(options) {
3
- var settings = $.extend({
4
- showAlert: false,
5
- alertMessage: '',
6
- showConfirmation: false,
7
- confirmationMessage:'',
8
- defaultValue: 'nomatch',
9
- }, options);
 
 
10
 
11
- var previousValue;
12
-
13
- /**
14
  * List of dom elements which are in scope
15
  */
16
- var objects = new Array();
17
-
18
- this.each(function() {
19
- objects.push(this);
20
- });
21
 
22
- /**
23
  * reset Columns which were matched previously with a same value
24
  * @param {dom} currentObject current dom
25
  * @param {boolean} onInit is invoked on load?
26
  */
27
- var resetColumns = function(currentObject, onInit) {
28
- if (typeof onInit === undefined) {
29
- onInit = false;
30
- }
31
- isMatchedColumn = false;
32
- for (i = 0; i < objects.length; i++) {
33
- if (
34
- !isMatchedColumn
35
- && $(currentObject).val() !== settings.defaultValue
36
- && !$(objects[i]).is(currentObject)
37
- && $(objects[i]).val() === $(currentObject).val()
38
- ) {
39
- isMatchedColumn = true;
40
- }
41
- }
42
- if (isMatchedColumn) {
43
- if (
44
- !onInit
45
- && settings.showConfirmation
46
- && typeof settings.confirmationMessage !== undefined
47
- && settings.confirmationMessage !== ''
48
- && settings.defaultValue !== undefined) {
49
- yes = confirm(settings.confirmationMessage);
50
- if (!yes) {
51
- $(currentObject).val($(currentObject).data('lastValue'));
52
- return;
53
- }
54
- }
55
- else if (
56
- !onInit
57
- && settings.showAlert
58
- && typeof settings.alertMessage !== undefined
59
- && settings.alertMessage !== ''
60
- && settings.defaultValue !== undefined) {
61
- alert(settings.alertMessage);
62
- }
63
- for (i = 0; i < objects.length; i++) {
64
- if (
65
- !$(objects[i]).is(currentObject)
66
- && $(currentObject).val() !== settings.defaultValue
67
- && $(objects[i]).val() === $(currentObject).val()
68
- ) {
69
- $(objects[i]).val(settings.defaultValue).data('lastValue',settings.defaultValue);
70
- }
71
- }
72
- }
73
- };
74
-
75
- this.each(function() {
76
- previousValue = $(this).val();
77
- resetColumns(this, true);
78
- $(this).data('lastValue',$(this).val());
79
- });
80
-
81
- $(this)
 
 
 
 
 
 
 
82
  .change(function() {
83
- resetColumns(this);
84
- $(this).data('lastValue',$(this).val());
 
 
 
85
  });
86
- return this;
87
- };
88
  }(jQuery));
 
1
  (function($) {
2
+ $.fn.matchColumn = function(options) {
3
+ var settings = $.extend({
4
+ showAlert: false,
5
+ alertMessage: '',
6
+ showConfirmation: false,
7
+ confirmationMessage:'',
8
+ defaultValue: 'nomatch',
9
+ beforeResetColumn: function(currentValue, obj){},
10
+ beforeChange: function(currentValue, obj){}
11
+ }, options);
12
 
13
+ var previousValue;
14
+
15
+ /**
16
  * List of dom elements which are in scope
17
  */
18
+ var objects = new Array();
19
+
20
+ this.each(function() {
21
+ objects.push(this);
22
+ });
23
 
24
+ /**
25
  * reset Columns which were matched previously with a same value
26
  * @param {dom} currentObject current dom
27
  * @param {boolean} onInit is invoked on load?
28
  */
29
+ var resetColumns = function(currentObject, onInit) {
30
+ if (typeof onInit === undefined) {
31
+ onInit = false;
32
+ }
33
+
34
+ isMatchedColumn = false;// if there is at least 1 column matched with a same filed
35
+ for (i = 0; i < objects.length; i++) {
36
+ if (
37
+ !isMatchedColumn
38
+ && $(currentObject).val() !== settings.defaultValue
39
+ && !$(objects[i]).is(currentObject)
40
+ && $(objects[i]).val() === $(currentObject).val()
41
+ ) {
42
+ isMatchedColumn = true;
43
+ }
44
+ }
45
+ if (isMatchedColumn) {
46
+ if (
47
+ !onInit
48
+ && settings.showConfirmation
49
+ && typeof settings.confirmationMessage !== undefined
50
+ && settings.confirmationMessage !== ''
51
+ && settings.defaultValue !== undefined) {// if we want to show a confirmation message
52
+ yes = confirm(settings.confirmationMessage);
53
+ if (!yes) {// if users do not want to make changes
54
+ $(currentObject).val($(currentObject).data('lastValue'));
55
+ return;
56
+ }
57
+ }
58
+ else if (// if we want to show an alert instead and stop
59
+ !onInit
60
+ && settings.showAlert
61
+ && typeof settings.alertMessage !== undefined
62
+ && settings.alertMessage !== ''
63
+ && settings.defaultValue !== undefined) {
64
+ alert(settings.alertMessage);
65
+ }
66
+
67
+ // once jumping here, it's clear to proceed with changes
68
+ for (i = 0; i < objects.length; i++) {
69
+ if (
70
+ !$(objects[i]).is(currentObject)
71
+ && $(currentObject).val() !== settings.defaultValue
72
+ && $(objects[i]).val() === $(currentObject).val()
73
+ ) {
74
+ if (typeof settings.beforeResetColumn === 'function') {
75
+ settings.beforeResetColumn($(objects[i]).val(), objects[i]);
76
+ }
77
+ $(objects[i]).val(settings.defaultValue).data('lastValue',settings.defaultValue);
78
+ // start something here!
79
+ }
80
+ }
81
+ }
82
+ };
83
+
84
+ this.each(function() {
85
+ previousValue = $(this).val();
86
+ resetColumns(this, true);
87
+ $(this).data('lastValue',$(this).val());
88
+ });
89
+
90
+ $(this)
91
  .change(function() {
92
+ resetColumns(this);
93
+ if (typeof settings.beforeChange === 'function') {
94
+ settings.beforeChange($(this).data('lastValue'), this);
95
+ }
96
+ $(this).data('lastValue',$(this).val());
97
  });
98
+ return this;
99
+ };
100
  }(jQuery));
101
+
js/jquery/jquery.userStatusMapping.js ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($) {
2
+ $.fn.userStatusMapping = function(options) {
3
+ var settings = $.extend({
4
+ defaultValue: 'status',
5
+ dataElement: '.imported-field',
6
+ statuses: new Array()
7
+ }, options);
8
+
9
+ var changeToUserStatus = function(obj){
10
+ cellsInScope = getCellsInScope(obj);
11
+ $.each(cellsInScope, function(index, element){
12
+ _dataElement = ($(element).find(settings.dataElement).length <= 0) ? element : $(element).find(settings.dataElement);
13
+ currentValue = parseInt($(_dataElement).html());
14
+ if (!isNaN(currentValue) && typeof settings.statuses[currentValue] !== 'undefined') {
15
+ $(_dataElement).data('lastValue',currentValue).html(settings.statuses[currentValue]);
16
+ }
17
+ });
18
+ };
19
+
20
+ var changeFromUserStatus = function(obj){
21
+ cellsInScope = getCellsInScope(obj);
22
+ $.each(cellsInScope, function(index, element){
23
+ _dataElement = ($(element).find(settings.dataElement).length <= 0) ? element : $(element).find(settings.dataElement);
24
+ if (typeof $(_dataElement).data('lastValue') !== 'undefined') {
25
+ $(_dataElement).html($(_dataElement).data('lastValue'));
26
+ $(_dataElement).data('lastValue', undefined);
27
+ }
28
+ });
29
+ };
30
+
31
+ // Return a list of cells of the current column
32
+ var getCellsInScope = function(obj){
33
+ columnPostion = getColumnPosition(obj);
34
+ cells = new Array();
35
+ $(obj).parents('table').children('tbody').children('tr').each(function(index, element){
36
+ cells.push($(this).children('td')[columnPostion]);
37
+ });
38
+ return cells;
39
+ };
40
+
41
+ var getColumnPosition = function(obj) {
42
+ return $(obj).parents('th').index();
43
+ }
44
+
45
+ var getRowPosition = function(obj) {
46
+ return $(obj).parents('th').parent().index();
47
+ }
48
+
49
+ $(this)
50
+ .change(function() {
51
+ if ($(this).val() === settings.defaultValue) {
52
+ changeToUserStatus(this);
53
+ }
54
+ });
55
+
56
+ // Utilities
57
+ $.userStatusMapping = {
58
+ changeFromUserStatus : function(obj){changeFromUserStatus(obj);},
59
+ changeToUserStatus : function(obj){changeToUserStatus(obj);}
60
+ };
61
+
62
+ return this;
63
+ };
64
+ }(jQuery));
js/wysija-editor.js CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";function info(t){if(Wysija.options.verbose!==!1){window.console&&console.log||function(){for(var t=function(){},e=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","markTimeline","table","time","timeEnd","timeStamp","trace","warn"],i=e.length,s=window.console={};i--;)s[e[i]]=t}();try{console.log("[INFO] "+t)}catch(e){}}}Object.extend(Prototype.Browser,{ie6:/MSIE (\d+\.\d+);/.test(navigator.userAgent)?6===Number(RegExp.$1)?!0:!1:!1,ie7:/MSIE (\d+\.\d+);/.test(navigator.userAgent)?7===Number(RegExp.$1)?!0:!1:!1,ie8:/MSIE (\d+\.\d+);/.test(navigator.userAgent)?8===Number(RegExp.$1)?!0:!1:!1,ie9:/MSIE (\d+\.\d+);/.test(navigator.userAgent)?9===Number(RegExp.$1)?!0:!1:!1}),Event.cacheDelegated={},Object.extend(document,function(){function t(t){return o[t]=o[t]||{}}function e(e,i){var s=t(e);return s[i]=s[i]||[]}function i(t,i,s){var n=e(t,i);return n.find(function(t){return t.handler===s})}function s(e,s,n){var o=t(e);if(!o[s])return!1;var a=i(e,s,n);return o[s]=o[s].without(a),a}function n(t,i,s,n){var o,a=e(t,i);return a.pluck("handler").include(s)?!1:(o=function(e){var i=e.findElement(t);i&&s.call(n||i,e,i)},o.handler=s,a.push(o),o)}var o=Event.cacheDelegated;return{delegate:function(t,e){var i=n.apply(null,arguments);return i&&document.observe(e,i),document},stopDelegating:function(i,n){var a=arguments.length;switch(a){case 2:e(i,n).each(function(t){document.stopDelegating(i,n,t.handler)});break;case 1:Object.keys(t(i)).each(function(t){document.stopDelegating(i,t)});break;case 0:Object.keys(o).each(function(t){document.stopDelegating(t)});break;default:var r=s.apply(null,arguments);r&&document.stopObserving(n,r)}return document}}}());var Observable=function(){function t(t,e){return t=t.substring(2),e&&(t=e+":"+t),t.underscore().split("_").join(":")}function e(e){var s=e.prototype,n=s.namespace;return Object.keys(s).grep(/^on/).inject($H(),function(o,a){return"onDomLoaded"===a?o:(o.set(t(a,n),i(s[a],e)),o)})}function i(t,e){return function(i){return t.call(new e(this),i,i.memo)}}function s(t,e){$$(t).each(function(t){new e(t).onDomLoaded()})}return{observe:function(t){if(this.handlers||(this.handlers={}),!this.handlers[t]){var i=this;this.prototype.onDomLoaded&&(document.loaded?s(t,i):document.observe("dom:loaded",s.curry(t,i))),this.handlers[t]=e(i).each(function(e){document.delegate(t,e.key,e.value)})}},stopObserving:function(t){this.handlers&&this.handlers[t]&&(this.handlers[t].each(function(e){document.stopDelegating(t,e.key,e.value)}),delete this.handlers[t])}}}();Object.extend(Droppables,{deactivate:Droppables.deactivate.wrap(function(t,e,i){return e.onLeave&&e.onLeave(i,e.element),t(e)}),activate:Droppables.activate.wrap(function(t,e,i){return e.onEnter&&e.onEnter(i,e.element),t(e)}),togglePlaceholders:function(t,e){if(0!==this.drops.length&&!($$(".block_placeholder.hover, .text_placeholder.hover, .image_placeholder.hover").length>0)){var i=document.viewport.getDimensions(),s=document.viewport.getScrollOffsets();this.drops.each(function(n){if(void 0===n.overlap){var o=!1,a=n.element.cumulativeOffset(),r=Math.max(30,n.element.getHeight()),l=t.element.hasClassName("image"),h=t.element.hasClassName("text");if(a.top>s.top+i.height)return;if(a.top<s.top&&a.top+r<s.top)return;if(l===!1&&-1!==n.accept.indexOf("image"))return;if(h===!1&&-1!==n.accept.indexOf("text"))return;if(l===!0){if(-1!==n.accept.indexOf("text"))return;if(t.element.readAttribute("wysija_src")===n.element.readAttribute("wysija_src"))return}var c=a.top-2*Wysija.options.blockDropTreshold,m=a.top+r+Wysija.options.blockDropTreshold;e.pageY>c&&m>e.pageY&&(o=!0);var d=n.element.up();o===!0?(d&&d.addClassName("active"),n.element.addClassName("active")):(d&&d.removeClassName("active"),n.element.removeClassName("active"))}})}},hidePlaceholders:function(){0!==this.drops.length&&$$(".block_placeholder.active, .text_placeholder.active, .image_placeholder.active, .wysija_image.active").invoke("removeClassName","active")}});var Wysija={version:"2.3",options:{debug:!1,verbose:!1,css:"wj_css",toolbar:"wysija_toolbar",notices:"wysija_notices",wrapper:"wysija_wrapper",container:"wysija_container",header:"wysija_header",body:"wysija_body",footer:"wysija_footer",blockDropTreshold:30,imageDropTreshold:30,minTextPlaceholderWidth:45},toolbar:{effect:null,x:null,y:null,top:null,left:null},scroll:{top:0,left:0},locks:{dragging:!1,selectingColor:!1,showingTools:!1},flags:{displayImages:!0,doSave:!1},defaults:{contentAlignment:"left",imageAlignment:"center",galleryAlignment:"center"},autoSave:function(){Wysija.flags.doSave===!1&&(Wysija.flags.doSave=!0)},save:function(){var t,e=1,i={},s=$H();s.set("version",Wysija.version);var n=Wysija.getHeader();i=n.block.save(),i.type="header",s.set("header",i);var o=$H();Wysija.getBlocks().each(function(s){t=s.block,t.save&&(i=t.save(),null!==i&&(i.position=e,i.type=s.elementType,i.background_color=t.element.readAttribute("wysija_bg_color"),o.set("block-"+e,i),e++))}),s.set("body",o);var a=Wysija.getFooter();return i=a.block.save(),i.type="footer",s.set("footer",i),Object.toJSON(s).gsub('\\"','"').gsub('"[{',"[{").gsub('}]"',"}]")},blockDropOptions:{accept:$w("wysija_widget"),onEnter:function(t,e){$(e).addClassName("hover")},onLeave:function(t,e){$(e).removeClassName("hover")},onDrop:function(t,e){var i={},s=null;i.elementType=t.readAttribute("wysija_type"),i.element=t,"image"===i.elementType?(i.elementRatio=t.readAttribute("elementRatio"),i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height"),i.elementClass=null,s=t.readAttribute("wysija_parent")):"divider"===i.elementType?(i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height")):"text"===i.elementType&&(i.elementText=Wysija_i18n.clickToEditText),e.fire("item:drop",i),$(e).removeClassName("hover"),null!==$(s)&&(s=Wysija.get($(s)),s.block.image.removeImage())}},imageDropOptions:{accept:$w("image"),onEnter:function(t,e){$(e).addClassName("hover"),($(e).up(".wysija_block")||$(e).up(".wysija_header")||$(e).up(".wysija_footer")).addClassName("image_hover")},onLeave:function(t,e){$(e).removeClassName("hover"),$$(".image_hover").invoke("removeClassName","image_hover")},onDrop:function(t,e){if(e.readAttribute("wysija_src")===t.readAttribute("wysija_src"))return Wysija.hideTools(),!1;var i={};i.elementType=t.readAttribute("wysija_type"),i.element=t,i.elementRatio=t.readAttribute("elementRatio"),i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height"),i.elementClass=null;var s=t.readAttribute("wysija_parent");null!==$(s)&&(s=Wysija.get($(s)),s.block.image.removeImage()),e.fire("image:drop",i),$(e).removeClassName("hover")}},textDropOptions:{accept:$w("text"),onEnter:function(t,e){$(e).addClassName("hover")},onLeave:function(t,e){$(e).removeClassName("hover")},onDrop:function(t,e){var i={};i.elementType=t.readAttribute("wysija_type"),i.element=t,i.elementText=Wysija_i18n.clickToEditText,e.fire("text:drop",i),$(e).removeClassName("hover")}},instances:{},get:function(t,e){void 0===e&&(e="block");var i=t.identify(),s=Wysija.instances[i]||new(Wysija[e.capitalize().camelize()])(i);return Wysija.instances[i]=s,s},getTheme:function(){var t=$("wysija_widgets_settings").down(".theme");return void 0!==t&&t.innerHTML.length>0?t.innerHTML:"default"},getHeader:function(){return Wysija.get(Wysija.getHeaderElement(),"header")},getHeaderElement:function(){return $$("div.wysija_header")[0]},getFooter:function(){return Wysija.get(Wysija.getFooterElement(),"footer")},getFooterElement:function(){return $$("div.wysija_footer")[0]},getBlocks:function(){return Wysija.getBlockElements().map(function(t){return Wysija.get(t)})},getBlockElements:function(){return $$("div.wysija_block")},startBlockPositions:function(t,e){e.element.hasClassName("wysija_block")&&(Wysija.locks.dragging=!0,Wysija.hideEditors())},setScrollOffsets:function(){Wysija.scroll=document.viewport.getScrollOffsets()},setBlockPositions:function(t,e){Wysija.locks.dragging=!1;var i=1;Wysija.getBlocks().each(function(t){t.setPosition(i++),t.block.element.setStyle({zIndex:""});var e=$$(".block_placeholder[data-parent="+t.block.element.identify()+"]").first();void 0!==e&&t.block.element.insert({before:e})}),void 0!==e&&$$(".wysija_auto-post").length>1&&"auto-post"===e.element.readAttribute("wysija_type")&&(Wysija.initAutoPost(),Wysija.setBackgroundColors()),Wysija.autoSave()},init:function(){Wysija.setScrollOffsets(),Wysija.getHeader(),Wysija.getFooter(),Wysija.makeDroppable(),Wysija.makeSortable(),Wysija.hideControls(),Wysija.hideTools(),Wysija.hideSettings(),Wysija.setSettingsPosition(),Wysija.initSettings(),Wysija.initAutoPost(),Wysija.setBackgroundColors(),Wysija.setToolbarPosition(),Wysija.setImagesDisplay()},initToolbarPosition:function(){null===Wysija.toolbar.top&&(Wysija.toolbar.top=parseInt($(Wysija.options.wrapper).positionedOffset().top)),null===Wysija.toolbar.left&&(Wysija.toolbar.left=parseInt($(Wysija.options.wrapper).positionedOffset().left)),null===Wysija.toolbar.x&&(Wysija.toolbar.x=parseInt(Wysija.toolbar.left+$(Wysija.options.wrapper).getDimensions().width+15)),Wysija.toolbar.y=Wysija.scroll.top>=Wysija.toolbar.top-20?parseInt(20+Wysija.scroll.top):parseInt(Wysija.toolbar.top+Wysija.scroll.top)},setToolbarPosition:function(){Wysija.initToolbarPosition(),$(Wysija.options.toolbar).setStyle({top:Wysija.toolbar.y+"px",left:Wysija.toolbar.x+"px",opacity:0}).appear({duration:.5}),$(Wysija.options.notices).hide()},updateToolbarPosition:function(){Wysija.initToolbarPosition(),null!==Wysija.toolbar.effect&&Wysija.toolbar.effect.cancel(),Wysija.scroll.top>=Wysija.toolbar.top-20?(Wysija.toolbar.y=parseInt(20+Wysija.scroll.top),Wysija.toolbar.effect=new Effect.Move(Wysija.options.toolbar,{x:Wysija.toolbar.x,y:Wysija.toolbar.y,mode:"absolute",duration:.2})):$(Wysija.options.toolbar).setStyle({left:Wysija.toolbar.x+"px",top:Wysija.toolbar.top+"px"})},editorCleanup:function(t,e){switch(t){case"get_from_editor":e=e.gsub("<p></p>","<p>&nbsp;</p>");break;case"insert_to_editor":break;case"submit_content":break;case"get_from_editor_dom":break;case"insert_to_editor_dom":break;case"setup_content_dom":break;case"submit_content_dom":}return e},updateCSSColor:function(t,e){var i=[],s="color",n=$(Wysija.options.css).innerHTML.strip();switch(t.endsWith("BgColorInput")&&(s="background-color"),e=""===e?"transparent":"#"+e,t){case"bodyColorInput":i.push("editable"),i.push("editable ul li"),i.push("editable ol li");break;case"h1ColorInput":i.push("editable h1");break;case"h2ColorInput":i.push("editable h2");break;case"h3ColorInput":i.push("editable h3");break;case"linksColorInput":i.push("editable a"),i.push("editable h1 a"),i.push("editable h2 a"),i.push("editable h3 a");break;case"unsubscribeColorInput":i.push("wysija_unsubscribe p");break;case"viewbrowserColorInput":i.push("wysija_viewbrowser p");break;case"htmlBgColorInput":i.push("wysija_wrapper");break;case"headerBgColorInput":i.push("wysija_header");break;case"bodyBgColorInput":i.push("wysija_body");break;case"footerBgColorInput":i.push("wysija_footer")}i.length>0&&null!==s&&(i.each(function(t){var i=new RegExp("([\\.|#]"+t+".*?{.*?"+s+":\\s*)(#?[a-z0-9]*)*(.*?})","i");n=n.replace(i,"$1"+e+"$3")}),n.length>0&&Wysija.updateCSS(n))},updateCSS:function(t){void 0!==$(Wysija.options.css)&&$(Wysija.options.css).remove();var e=document.getElementsByTagName("head")[0],i=document.createElement("style");i.id=Wysija.options.css,i.type="text/css",i.styleSheet?i.innerHTML=t:i.appendChild(document.createTextNode(t)),e.appendChild(i)},setTextStyles:function(t){var e=t.editorId+"_ifr",i=$(e);if(null!==i&&(i.doc=null,i.contentDocument?i.doc=i.contentDocument:i.contentWindow?i.doc=i.contentWindow.document:i.document&&(i.doc=i.document),null!==i.doc)){var s=i.doc.getElementsByTagName("head")[0],n=i.doc.createElement("style"),o=$(Wysija.options.css).innerHTML.strip();n.type="text/css",n.id="wj_iframe_css",n.styleSheet?n.innerHTML=o:n.appendChild(document.createTextNode(o)),s.appendChild(n)}},setBackgroundColors:function(){Wysija.getBlocks().invoke("setBackgroundColor"),$$(".wysija_auto-post .wysija_content, .wysija_auto-post .wysija_divider .wysija_raw").each(function(t){var e=t.readAttribute("wysija_bg_color");""===e?t.setStyle({backgroundColor:"transparent"}):null!==e&&t.setStyle({backgroundColor:"#"+e})})},hideBlockControls:function(){$$(".wysija_controls").invoke("hide"),this.getBlockElements().invoke("removeClassName","hover")},hideEditors:function(){tinymce.editors.length>0&&Wysija.getBlocks().each(function(t){"content"===t.elementType&&null!==t.block.contents&&t.block.contents.disableEditor()})},hideControls:function(){return Wysija.getBlocks().invoke("hideControls")},hideTools:function(){$$(".resize-controls").invoke("hide"),$$(".wysija_tools").invoke("hide"),Wysija.locks.showingTools=!1},makeDroppable:function(){Droppables.add("block_placeholder",Wysija.blockDropOptions)},makeSortable:function(){var t=$(Wysija.options.body);Sortable.create(t,{tag:"div",only:"wysija_block",scroll:window,handle:"handle",constraint:"vertical"}),Draggables.removeObserver(t),Draggables.addObserver({element:t,onStart:Wysija.startBlockPositions,onEnd:Wysija.setBlockPositions})},setDivider:function(t,e){$("wysija_widgets_settings").down(".divider").update(t),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_src",e.src),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_width",e.width),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_height",e.height)},replaceDividers:function(){$$(".wysija_block .wysija_divider").invoke("replace",$("wysija_widgets_settings").down(".divider").innerHTML)},toggleImages:function(){return Wysija.flags.displayImages=!Wysija.flags.displayImages,this.setImagesDisplay()},setImagesDisplay:function(){return Wysija.flags.displayImages===!0?($$(".wysija_image img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_cell img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_divider img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_raw img").invoke("setStyle",{visibility:"visible"}),!0):($$(".wysija_image img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_cell img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_divider img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_raw img").invoke("setStyle",{visibility:"hidden"}),!1)},flyToTheMoon:function(){if($("wysija-konami")){var t=document.viewport.getDimensions(),e=t.width;$("wysija-konami-overlay").show(),$("wysija-konami-bird").show(),$("wysija-konami-bird").setStyle({left:"-1000px",top:"100px"}),new Effect.Morph("wysija-konami-bird",{style:{left:e+"px"},duration:5,beforeStart:function(){},afterFinish:function(){$("wysija-konami-bird").writeAttribute("style","z-index:99999;position:absolute;top:300px;left:"+e+'px;-moz-transform: scaleX(-1);-o-transform: scaleX(-1);-webkit-transform: scaleX(-1);transform: scaleX(-1);filter: FlipH;-ms-filter: "FlipH";')}}),new Effect.Morph("wysija-konami-bird",{queue:"end",style:{left:"-1000px"},duration:5,afterFinish:function(){$("wysija-konami-bird").writeAttribute("style","z-index:99999;position:absolute;top:100px;left:-1000px;"),$("wysija-konami-overlay").hide(),$("wysija-konami-bird").hide()}})}},hideSettings:function(){$$(".wysija_settings").invoke("hide")},initSettings:function(){Event.stopObserving("scroll"),Event.observe(window,"scroll",function(){Wysija.setScrollOffsets(),Wysija.setSettingsPosition(),Wysija.updateToolbarPosition(),WysijaPopup.setPosition()}),Event.stopObserving("resize"),Event.observe(window,"resize",function(){WysijaPopup.setPosition()})},setSettingsPosition:function(){var t=document.viewport.getHeight(),e=25;$$(".wysija_settings").each(function(i){var s=i.up(".wysija_block").getDimensions(),n=i.up(".wysija_block").cumulativeOffset(),o=n.top<=Wysija.scroll.top+t?!0:!1,a=100;if(o){var r=parseInt(Wysija.scroll.top+(t/2-i.getHeight()/2)),l=parseInt(n.top-e),h=parseInt(n.top+s.height-e);a=200>parseInt(s.height)?parseInt(s.height/2-i.getHeight()/2):r+100>h+e?parseInt(s.height-100):l+e>r-100?100:parseInt(r-n.top)}new Effect.Move(i,{x:parseInt(s.width/2-i.getWidth()/2),y:a,mode:"absolute",duration:.2})})},initAutoPost:function(){var t=$("wysija_widgets_settings").down(".autopost").innerHTML,e=$$(".wysija_auto-post").length;"single"===t&&(e>0?($("wysija-widget-autopost").addClassName("disabled"),$("wysija-widget-autopost").writeAttribute("title",Wysija_i18n.autoPostImmediateNotice)):($("wysija-widget-autopost").removeClassName("disabled"),$("wysija-widget-autopost").writeAttribute("title",""))),Wysija.getBlocks().each(function(t){"auto-post"===t.elementType&&t.block.loadContent()})},encodeHtmlValue:function(t){return t.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;")},encodeURIComponent:function(t){var e=new RegExp(/^http[s]?:\/\//),i=e.exec(t);return null===i?encodeURIComponent(t).replace(/[!'()*]/g,escape):1===i.length?encodeURI(t).replace(/[!'()*]/g,escape):void 0}};document.observe("dom:loaded",Wysija.init),Wysija.Block=Class.create({initialize:function(t){return info("block -> init"),this.element=$(t),this.elementType=this.element.readAttribute("wysija_type"),this.block=new(Wysija[this.elementType.capitalize().camelize()])(this.element),1===parseInt(this.element.readAttribute("wysija_new"))&&(this.block.draw(),this.element.writeAttribute("wysija_new",0)),this.block.makeBlockDroppable(),void 0!==this.block.setup&&this.block.setup(),this},getCustomData:function(t){return void 0!==this.element.down(".wysija_options."+t)?(info("got options for "+t),this.element.down(".wysija_options."+t).innerHTML.toQueryParams("&amp;")):(info("no options to get for "+t),null)},getOptions:function(){return this.options},setOptions:function(t){return void 0===t&&(t={}),void 0===this.options&&(this.options=new Hash),this.options=this.options.update(t),this},setPosition:function(t){this.element.writeAttribute("wysija_position",t)},hideControls:function(){this.getControls&&(this.element.removeClassName("hover"),this.getControls().hide())},showControls:function(){this.getControls&&(this.element.addClassName("hover"),this.getControls().show())},makeBlockDroppable:function(){if(this.isBlockDroppableEnabled()===!1){var t=this.getBlockDroppable();Droppables.add(t.identify(),Wysija.blockDropOptions),t.addClassName("enabled")}},removeBlockDroppable:function(){if(this.isBlockDroppableEnabled()){var t=this.getBlockDroppable();Droppables.remove(t.identify()),t.removeClassName("enabled"),t.remove()}},isBlockDroppableEnabled:function(){return this.element.hasClassName("static")?!0:this.getBlockDroppable().hasClassName("enabled")},createBlockDroppable:function(){return this.element.insert({before:'<div class="block_placeholder" data-parent="'+this.element.identify()+'">'+Wysija_i18n.drop_block_here+"</div>"})},getBlockDroppable:function(){var t=this.element.identify();return 0===$$('.block_placeholder[data-parent="'+t+'"]').length&&this.createBlockDroppable(),$$('.block_placeholder[data-parent="'+t+'"]').first()},getControls:function(){return this.element.down(".wysija_controls")},setupControls:function(){if(this.controls=this.getControls(),this.controls){this.element.observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.element.addClassName("hover"),this.showControls())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&this.hideControls()}.bind(this)),this.removeButton=this.controls.down(".remove"),this.removeButton.observe("click",function(){this.removeBlock(),this.removeButton.stopObserving("click")}.bind(this)),this.bgColorButton=this.controls.down(".bgcolor");var t=this;jQuery(this.bgColorButton).modcoder_excolor({default_color:t.element.readAttribute("wysija_bg_color"),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_init:function(){Wysija.locks.selectingColor=!0},callback_on_select:function(e){t.setBackgroundColor(e)},callback_on_ok:function(e,i){i===!0&&t.setBackgroundColor(e),Wysija.locks.selectingColor=!1,t.hideControls()}})}return this},setBackgroundColor:function(t){void 0!==t&&this.element.writeAttribute("wysija_bg_color",t);var e=this.element.readAttribute("wysija_bg_color");""===e?this.element.setStyle({backgroundColor:"transparent"}):null!==e&&this.element.setStyle({backgroundColor:"#"+e}),Wysija.autoSave()},replaceBlock:function(t){return this.removeBlockDroppable(),this.element.replace(t)},removeBlock:function(t){info("block -> removeBlock"),this.removeBlockDroppable(),Effect.Fade(this.element.identify(),{duration:.2,afterFinish:function(){void 0!==this.element.next(".wysija_block")&&t!==!1&&Wysija.get(this.element.next(".wysija_block")).block.showControls(),this.element.remove(),Wysija.setBlockPositions(),void 0!==t&&"function"==typeof t&&t(),delete Wysija.instances[this.element.identify()]}.bind(this)})}}),document.observe("item:drop",function(t){Wysija.Block.create(t.memo,t.target),Wysija.hideBlockControls(),Wysija.setImagesDisplay()}),Wysija.Block.create=function(t,e){var i='<li class="handle_container"><a class="handle" href="javascript:;"><span></span></a></li><li><a class="bgcolor" href="javascript:;"><span></span></a></li><li><a class="remove" href="javascript:;"><span></span></a></li>';"image"===t.elementType&&(t.elementOptions='<span class="wysija_options image">#{options}</span>'.interpolate({options:Object.toQueryString(t)}),t.elementType="content",t.blockAlignment=Wysija.defaults.imageAlignment),"text"===t.elementType&&(t.elementOptions='<span class="wysija_options text">#{options}</span>'.interpolate({options:Object.toQueryString(t)}),t.elementType="content",t.blockAlignment=Wysija.defaults.contentAlignment),"divider"===t.elementType&&(t.elementOptions='<span class="wysija_options divider">#{options}</span>'.interpolate({options:Object.toQueryString(t)}));var s,n=$(Wysija.options.body),o=new Template('<div class="wysija_block" wysija_type="#{elementType}" wysija_new="1"><ul class="wysija_controls">'+i+"</ul>"+"#{elementOptions}"+'<div class="wysija_#{elementType} #{blockAlignment}" wysija_align="#{blockAlignment}"></div>'+"</div>");"block_placeholder"===e.identify()?(n.insert(o.evaluate(t)),s=n.childElements().last()):(e.insert({before:o.evaluate(t)}),s=e.previous(".wysija_block")),Wysija.makeSortable(),Wysija.setBlockPositions();var a=Wysija.get(s);a.element.fire("block:insert"),void 0!==a.block.contents&&a.block.contents.isEmpty()===!1&&a.block.contents.setFocus()},Wysija.Header=Class.create({initialize:function(t){return this.element=$(t),this.block=new Wysija.Banner(this.element),this.block.setup(),this}}),Wysija.Footer=Class.create({initialize:function(t){return this.element=$(t),this.block=new Wysija.Banner(this.element),this.block.setup(),this}}),Wysija.Banner=Class.create(Wysija.Block,{image:null,constraints:{left:{minHeight:20,minWidth:20,maxWidth:600},right:{minHeight:20,minWidth:20,maxWidth:600},center:{minHeight:20,minWidth:20,maxWidth:600},full:{minHeight:20,minWidth:20,maxWidth:600}},initialize:function(t){return this.element=$(t),this.elementArea=this.element.readAttribute("wysija_type"),this.getImageContainer()&&(this.image=new Wysija.BannerImage(this.getImageContainer(),this.elementArea)),this},save:function(){var t={};return t.text=null,null!==this.image&&(t.image=this.image.save(),t.alignment=this.image.isEmpty()===!1?t.image.alignment:"center",t["static"]=this.element.hasClassName("static")),t},draw:function(){return null===this.image&&(this.element.childElements().last().insert(this.drawContainer("image")),this.image=new Wysija.BannerImage(this.getImageContainer(),this.elementArea),this.image.setOptions(this.getCustomData("image")),this.getImageContainer().insert(this.image.draw())),this},drawContainer:function(t){return'<div class="wysija_'+t+'"></div>'},getImageContainer:function(){return this.element.down(".wysija_image")},getContainer:function(){return this.element.down(".wysija_content")},minWidth:function(){return this.constraints[this.alignment].minWidth},maxWidth:function(){return this.constraints[this.alignment].maxWidth},fullWidth:function(){return this.constraints.full.maxWidth},setup:function(){null!==this.image&&this.image.setup(),this.constrainSize()},getControls:function(){return this.element.down(".wysija_controls")},remove:function(){this.image.isEmpty()&&($("wysija_"+this.elementArea).innerHTML=$("wysija_default_"+this.elementArea).innerHTML,Wysija.init())},setBlockAlignment:function(t){return info("content -> set block alignment"),this.getContainer().removeClassName("left").removeClassName("center").removeClassName("right"),this.getContainer().writeAttribute("wysija_align",t),this.getContainer().addClassName(t),null!==this.image&&(this.image.setAlignment(t),this.image.setInformation()),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("banner -> constrain size"),this.image.ratio=this.image.getRatio();var t=this.image.minSize(),e=this.image.maxSize(),i=this.image.getImageElement();i.width>e.width||i.height>e.height?(this.image.getImageContainer().writeAttribute("style",""),i.writeAttribute({width:e.width,height:e.height})):(i.width<t.width||i.height<t.height)&&(this.image.getImageContainer().writeAttribute("style",""),i.writeAttribute({width:t.width,height:t.height})),"center"===this.image.alignment?this.image.getImageContainer().setStyle({width:i.readAttribute("width")+"px"}):this.image.getImageContainer().setStyle({width:"auto"}),this.image.isEmpty()===!1&&this.image.setInformation()},getBlock:function(){return this.element.up(".wysija_"+this.elementArea)}}),Wysija.Gallery=Class.create(Wysija.Block,{items:$H(),constraints:{left:{minWidth:20,maxWidth:562},right:{minWidth:20,maxWidth:562},center:{minWidth:20,maxWidth:562}},initialize:function(t){info("gallery -> init"),this.element=$(t),this.alignment=this.getDefaultAlignment();for(var e=this.getCells(),i=this.element.identify(),s=[],n=0;e.length>n;n++)s[n]=new Wysija.GalleryImage(e[n]);return this.items.set(i,s),this},getDefaultAlignment:function(){return this.getGalleryElement().readAttribute("wysija_align")||Wysija.defaults.galleryAlignment},draw:function(){info("gallery -> draw")},setup:function(){info("gallery -> setup"),this.createResizeControls(),this.setupResizeControls(),this.setupControls(),this.setupTools(),this.setBlockAlignment(this.getDefaultAlignment()),this.items.get(this.element.id).each(function(t){t.setup()},this)},save:function(){info("gallery -> save");var t={};return t.width=this.getGalleryElement().getWidth(),t.alignment=this.alignment,t.items=[],this.items.get(this.element.id).each(function(e){t.items.push(e.save())},this),t},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.getGalleryElement().observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.showTools(),this.getResizeControls().show())}.bind(this)),this.getGalleryElement().observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideTools(),void 0!==this.getResizeControls()&&this.getResizeControls().hide())}.bind(this)),this.leftButton=this.tools.down(".alignment-left"),this.leftButton.observe("click",function(){this.setBlockAlignment("left")}.bind(this)),this.centerButton=this.tools.down(".alignment-center"),this.centerButton.observe("click",function(){this.setBlockAlignment("center")}.bind(this)),this.rightButton=this.tools.down(".alignment-right"),this.rightButton.observe("click",function(){this.setBlockAlignment("right")}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},remove:function(){this.items.unset(this.element.id),this.removeBlock()},getTools:function(){return this.getGalleryElement().down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide(),Wysija.locks.showingTools=!1,void 0!==this.information&&this.information.hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show(),Wysija.locks.showingTools=!0,void 0!==this.information&&this.information.show()},setBlockAlignment:function(t){return info("gallery -> setBlockAlignment"),this.getGalleryElement().removeClassName("left").removeClassName("center").removeClassName("right"),this.getGalleryElement().writeAttribute("wysija_align",t),this.getGalleryElement().addClassName(t),this.alignment=t,this.leftButton.removeClassName("active"),this.centerButton.removeClassName("active"),this.rightButton.removeClassName("active"),this[t+"Button"].addClassName("active"),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("gallery -> constrainSize");var t=this.getGalleryElement().getDimensions(),e=this.getCells(0).length,i=t.width-this.minWidth();this.getCells().each(function(t){t.setStyle({width:t.down("img").getWidth()+Math.floor(i/e)+"px"})})},getCells:function(t){return t=0|t,this.getGalleryElement().select(".wysija_row")[t].select(".wysija_cell")},minWidth:function(){return info("gallery -> minWidth"),this.getCells(0).inject(0,function(t,e){return t+e.down("img").getWidth()})},maxWidth:function(){return this.constraints[this.alignment].maxWidth},maxHeight:function(){return this.getCells(0).first().getHeight()},setupResizeControls:function(){return this.handle=this.getResizeControls().down(".resize-handle"),this.information=this.getResizeControls().down(".resize-info"),this.handleSize=this.handle.getDimensions(),this.draggable=new Draggable(this.handle,{onStart:this.dragStart.bind(this),snap:this.dragSnap.bind(this),change:this.dragChange.bind(this),onEnd:this.dragEnd.bind(this),starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}),this},dragStart:function(){Wysija.hideEditors(),this.dragging=!0,Wysija.locks.dragging=!0,$$("body")[0].setStyle({cursor:this.handle.getStyle("cursor")}),"right"===this.alignment&&this.getGalleryElement().insert(this.handle)},dragSnap:function(t,e){var i=this.minWidth(),s=this.maxWidth();if("right"===this.alignment){var n=this.getGalleryElement().getWidth(),o=n-t;o>s&&(t=n-s,o=s),i>o&&(t=n-i,o=i),e=Math.floor(this.maxHeight()-this.handleSize.height+this.borderWidth())}else{var o=t+this.handleSize.width;o>s&&(t=s-this.handleSize.width,o=s),i>o&&(t=i-this.handleSize.width,o=i),e=Math.floor(this.maxHeight()-this.handleSize.height+this.borderWidth())}return[t,e]},dragChange:function(){if("right"===this.alignment){var t=this.handle.positionedOffset(),e=this.getGalleryElement().getDimensions();t.left=e.width-t.left+this.borderWidth(),t.top+=this.handleSize.height+this.borderWidth(),this.getResizeControls().setStyle({left:e.width-t.left+this.borderWidth()+"px",width:t.left-2*this.borderWidth()+"px",height:t.top-2*this.borderWidth()+"px"})}else if("left"===this.alignment){var t=this.handle.positionedOffset();t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.getResizeControls().setStyle({width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})}else if("center"===this.alignment){var t=this.handle.positionedOffset(),e=this.getGalleryElement().getDimensions();t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.getResizeControls().setStyle({left:(e.width-t.left+this.borderWidth())/2+"px",width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})}},dragEnd:function(){this.dragging=!1,Wysija.locks.dragging=!1,$$("body")[0].setStyle({cursor:""});var t=this.minWidth(),e=this.getResizeControls().getWidth();t>e&&(e=t),this.setDimensions(e),this.handle.writeAttribute("style",""),"right"===this.alignment?(this.getResizeControls().insert(this.handle),this.getResizeControls().writeAttribute("style","")):"center"===this.alignment&&this.getResizeControls().writeAttribute("style",""),Wysija.hideTools(),this.getGalleryElement().fire("drag:end")},setDimensions:function(t){var t=void 0===t?this.maxWidth():t,e=this.maxHeight();this.getGalleryElement().setStyle({width:t+"px",height:e+"px"}),this.getResizeControls().setStyle({width:t+"px",height:e+"px"}),this.getResizeControls().writeAttribute("style","")},borderWidth:function(){return 2},createResizeControls:function(){void 0===this.getResizeControls()&&this.getGalleryElement().insert('<div class="resize-controls"><span class="resize-handle"></span><span class="resize-info"></span></div>')
2
- },getResizeControls:function(){return this.getGalleryElement().down(".resize-controls")},getGalleryElement:function(){return this.element.down(".wysija_gallery")}}),Wysija.Content=Class.create(Wysija.Block,{contents:null,image:null,constraints:{left:{minHeight:20,minWidth:32,maxWidth:325},right:{minHeight:20,minWidth:32,maxWidth:325},center:{minHeight:20,minWidth:32,maxWidth:562},full:{minHeight:20,minWidth:32,maxWidth:562}},initialize:function(t){return this.element=$(t),this.getTextContainer()&&(this.contents=new Wysija.Text(this.getTextContainer())),this.getImageContainer()&&(this.image=new Wysija.Image(this.getImageContainer())),this},save:function(){var t={};return null!==this.contents&&(t.text=this.contents.save()),null!==this.image&&(t.image=this.image.save(),t.alignment=this.image.isEmpty()===!1?t.image.alignment:"center",t["static"]=this.element.hasClassName("static")),t},draw:function(){return null===this.image&&(this.element.childElements().last().insert(this.drawContainer("image")),this.image=new Wysija.Image(this.getImageContainer()),this.image.setOptions(this.getCustomData("image")),this.getImageContainer().insert(this.image.draw())),null===this.contents&&(this.element.childElements().last().insert(this.drawContainer("text")),this.contents=new Wysija.Text(this.getTextContainer()),this.contents.setOptions(this.getCustomData("text")),this.getTextContainer().insert(this.contents.draw())),this},drawContainer:function(t){return'<div class="wysija_'+t+'"></div>'},getImageContainer:function(){return this.element.down(".wysija_image")},getTextContainer:function(){return this.element.down(".wysija_text")},getContainer:function(){return this.element.down(".wysija_content")},minWidth:function(){return this.constraints[this.alignment].minWidth},maxWidth:function(){return this.isAlone()?this.constraints.full.maxWidth:this.constraints[this.alignment].maxWidth},fullWidth:function(){return this.constraints.full.maxWidth},setup:function(){info("content -> setup"),this.setupControls(),null!==this.contents&&this.contents.setup(),null!==this.image&&this.image.setup(),this.constrainSize()},getControls:function(){return this.element.down(".wysija_controls")},remove:function(){this.image.isEmpty()&&this.contents.isEmpty()&&this.removeBlock()},setBlockAlignment:function(t){return info("content -> set block alignment"),this.getContainer().removeClassName("left").removeClassName("center").removeClassName("right"),this.getContainer().writeAttribute("wysija_align",t),this.getContainer().addClassName(t),this.alignment=t,null!==this.image&&(this.image.setAlignment(t),this.image.setInformation()),null!==this.contents&&this.contents.setAlignment(t),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("content -> constrain size"),this.image.ratio=this.image.getRatio();var t=this.image.minSize(),e=this.image.maxSize(),i=this.image.getImageElement();if(this.image.getImageContainer().writeAttribute("style",""),i.width>e.width||i.height>e.height?i.writeAttribute({width:e.width,height:e.height}):(i.width<t.width||i.height<t.height)&&i.writeAttribute({width:t.width,height:t.height}),this.image.isEmpty()===!1&&this.image.getImageContainer().setStyle({width:i.readAttribute("width")+"px",height:null}),this.image.isEmpty()||this.contents.isEmpty()){if(this.contents.isEmpty()){this.contents.getTextContainer().writeAttribute("style","");var s=this.image.getImageElement().getDimensions(),n=this.constraints[this.contents.alignment].maxWidth;if("center"!==this.contents.alignment&&s.width>n)this.contents.getTextPlaceholder().setStyle({width:s.width-2+"px","float":this.contents.alignment,lineHeight:null});else switch(this.contents.alignment){case"left":case"right":this.contents.getTextPlaceholder().setStyle({width:this.contents.fullWidth()-s.width-15-2+"px",height:s.height-2+"px",lineHeight:s.height-2+"px","float":"left"===this.contents.alignment?"right":"none"});break;case"center":this.contents.getTextPlaceholder().setStyle({width:this.contents.fullWidth()-2+"px",height:null,lineHeight:null})}}else this.image.isEmpty()&&(this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-2+"px",height:"auto","float":"none"}),this.image.getImageContainer().setStyle({width:"auto"}),"center"===this.contents.alignment&&i.writeAttribute("width",e.width));this.contents.getTools()&&this.contents.getTools().setStyle({right:0})}else if(this.contents.isEditing()){switch(this.contents.getTextContainer().setStyle({width:"auto","float":"none"}),this.contents.getTools()&&this.contents.getTools().setStyle({right:0}),this.contents.alignment){case"left":var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-o-15-2+"px","float":"right"});break;case"right":var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-o-15-2+"px"});break;case"center":this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-2+"px"})}this.contents.getTextContainer().setStyle({height:"auto"})}else{if(this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()+"px","float":"none"}),this.contents.getTools()&&this.contents.getTools().setStyle({right:0}),"right"===this.contents.alignment&&this.contents.getTools()&&Prototype.Browser.ie7===!1){var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTools().setStyle({right:o+15+2+"px"})}if(this.contents.isEmpty()===!1){var a=this.contents.getTextArea().getHeight(),r=parseInt(this.image.getImageElement().readAttribute("height"));"right"===this.contents.alignment||"left"===this.contents.alignment?r>a?this.contents.getTextContainer().setStyle({height:r+"px"}):this.contents.getTextContainer().setStyle({height:"auto"}):20>a?this.contents.getTextContainer().setStyle({height:"20px"}):this.contents.getTextContainer().setStyle({height:"auto"})}}this.image.isEmpty()===!1&&this.image.setInformation()},getBlock:function(){return this.element.up(".wysija_block")}});var WysijaImageAbstract={initialize:function(t,e){return info("image abstract -> init"),this.element=$(t),this.elementArea=void 0===e?"block":e,this.alignment=this.getDefaultAlignment(),this.params=new Hash,this},save:function(){return this.isEmpty()?null:{src:this.getImageElement().readAttribute("src"),width:parseInt(this.getImageElement().readAttribute("width")),height:parseInt(this.getImageElement().readAttribute("height")),url:this.params.get("url"),alt:this.params.get("alt"),alignment:this.alignment,"static":this.getImageElement().hasClassName("static")}},draw:function(){return this.customDraw()+this.customTools()},customDraw:function(){void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:$("wysija_widgets_settings").down(".image").innerHTML,elementRatio:1,elementClass:"empty",elementWidth:106,elementHeight:80});var t=this.getOptions();return this.setRatio(t.get("elementRatio")||1),void 0!==this.getImageElement()&&t.set("elementId",this.getImageElement().identify()),'<img class="image_placeholder #{elementClass}" id="#{elementId}" src="#{elementSrc}" wysija_src="#{elementSrc}" height="#{elementHeight}" wysija_height="#{elementHeight}" width="#{elementWidth}" wysija_width="#{elementWidth}" alt="" />'.interpolate(t)},customTools:function(){return"empty"===this.getOptions().get("elementClass")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.alignmentLeft+'" class="alignment-left"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.alignmentCenter+'" class="alignment-center"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.alignmentRight+'" class="alignment-right"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.addImageLink+'" class="add-link"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.removeImageLink+'" class="remove-link"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.removeImage+'" class="remove"><span></span></a></li>'+"</ul>"},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.element.observe("mouseover",function(){this.isEmpty()!==!0&&Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.showTools(),this.getResizeControls().show())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideTools(),void 0!==this.getResizeControls()&&this.getResizeControls().hide())}.bind(this)),this.leftButton=this.tools.down(".alignment-left"),this.leftButton.observe("click",function(){this.setBlockAlignment("left")}.bind(this)),this.centerButton=this.tools.down(".alignment-center"),this.centerButton.observe("click",function(){this.setBlockAlignment("center")}.bind(this)),this.rightButton=this.tools.down(".alignment-right"),this.rightButton.observe("click",function(){this.setBlockAlignment("right")}.bind(this)),this.addLinkButton=this.tools.down(".add-link"),this.addLinkButton.observe("click",function(){this.addLink()}.bind(this)),this.removeLinkButton=this.tools.down(".remove-link"),this.removeLinkButton.observe("click",function(){this.removeLink()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.removeImage(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide(),Wysija.locks.showingTools=!1,void 0!==this.information&&this.information.hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show(),Wysija.locks.showingTools=!0,void 0!==this.information&&this.information.show()},addLink:function(){var t=wysijaAJAX.adminurl+"?page=wysija_campaigns&action=image_data";void 0!==this.params.get("url")&&null!==this.params.get("url")&&(t+="&url="+Wysija.encodeURIComponent(this.params.get("url"))),void 0!==this.params.get("alt")&&(t+="&alt="+Wysija.encodeURIComponent(this.params.get("alt"))),WysijaPopup.open(Wysija_i18n.addLinkTitle,t,this.setData.bind(this))},setData:function(t){this.params.set("url",t.url),this.params.set("alt",t.alt),void 0!==this.params.get("url")&&null!==this.params.get("url")?this.showLink():this.hideLink(),Wysija.autoSave(),Wysija.init()},removeLink:function(){this.params.set("url",null),this.hideLink()},showLink:function(){this.addLinkButton.writeAttribute("title",decodeURIComponent(this.params.get("url"))),this.addLinkButton.addClassName("active")},hideLink:function(){this.addLinkButton.writeAttribute("title",Wysija_i18n.addImageLink),this.addLinkButton.removeClassName("active")},setBlockAlignment:function(t){info("image -> set block alignment to : "+t);var e=Wysija.get(this.getBlock());e.block.setBlockAlignment(t)},removeImage:function(){info("image -> remove"),this.element.fire("image:remove")},makeDroppable:function(){info("image -> make droppable"),Droppables.add(this.getImageElement().identify(),Wysija.imageDropOptions)},removeDroppable:function(){info("image -> remove droppable"),Droppables.remove(this.getImageElement().identify())},setup:function(){return info("image -> setup"),this.createControls(),this.setupControls(),this.setupTools(),this.makeDroppable(),this.getParameters(),this[this.alignment+"Button"]&&this[this.alignment+"Button"].addClassName("active"),this},getParameters:function(){info("image -> get parameters");var t=this.element.down(".wysija_params");if(void 0!==t&&0===this.params.keys().length){var e=$F(t.down('input[name="url"]'));""!==e&&(this.params.set("url",e),this.showLink());var i=$F(t.down('input[name="alt"]'));""!==i&&this.params.set("alt",i)}return this},createControls:function(){this.getImageElement().hasClassName("empty")||this.getImageElement().hasClassName("static")||void 0!==this.getResizeControls()||this.element.insert('<div class="resize-controls"><span class="resize-handle"></span><span class="resize-info"></span></div>')},setupControls:function(){return this.getImageElement().hasClassName("empty")||this.getImageElement().hasClassName("static")?void 0:(this.ratio=this.getRatio(),this.controls=this.getControls(),this.handle=this.controls.down(".resize-handle"),this.information=this.controls.down(".resize-info"),this.handleSize=this.handle.getDimensions(),this.draggable=new Draggable(this.handle,{onStart:this.dragStart.bind(this),snap:this.dragSnap.bind(this),change:this.dragChange.bind(this),onEnd:this.dragEnd.bind(this),starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}),this)},getImageContainer:function(){return this.element},getImageElement:function(){return this.element.down("img")},getResizeControls:function(){return this.element.down(".resize-controls")},minSize:function(){var t=this.minWidth();return{width:t,height:Math.floor(t/this.ratio)}},maxSize:function(){var t=this.maxWidth();return{width:t,height:Math.floor(t/this.ratio)}},getRatio:function(){return this.getImageContainer().readAttribute("wysija_ratio")||(1e3*(this.getImageElement().width/this.getImageElement().height)).round()/1e3},setRatio:function(t){return this.element.writeAttribute("wysija_ratio",t),this},isEmpty:function(){return this.getImageElement().hasClassName("empty")},setEmpty:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("empty")},isAlone:function(){return this.getImageContainer().hasClassName("alone")},setAlone:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("alone")},setAlignment:function(t){return this.isEmpty()?void 0:(info("image -> setAlignment = "+t),this.alignment=t,this.leftButton.removeClassName("active"),this.centerButton.removeClassName("active"),this.rightButton.removeClassName("active"),this.getResizeControls().writeAttribute("style",""),this[t+"Button"].addClassName("active"),this)},getDefaultAlignment:function(){return this.element.up(".wysija_content").readAttribute("wysija_align")||Wysija.defaults.imageAlignment},dragStart:function(){Wysija.hideEditors(),this.dragging=!0,Wysija.locks.dragging=!0,$$("body")[0].setStyle({cursor:this.handle.getStyle("cursor")}),this.imageDimensions=this.getImageElement().getDimensions(),this.controls.setStyle({width:this.imageDimensions.width+"px",height:this.imageDimensions.height+"px"});var t=Wysija.get(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer"));t.block.element.addClassName("dragging"),"right"===this.alignment&&this.element.insert(this.handle)},dragSnap:function(t,e){var i=this.constraints[this.alignment].minWidth,s=this.constraints[this.alignment].maxWidth,n=this.constraints[this.alignment].minHeight;if(this.isAlone()&&(s=this.constraints.full.maxWidth),"right"===this.alignment){var o=this.imageDimensions.width,a=o-t;a>s&&(t=o-s,a=s),i>a&&(t=o-i,a=i),e=Math.max(n,Math.floor(a/this.ratio)),e===n&&(t=o-Math.floor(n*this.ratio)),e-=this.handleSize.height}else{var a=t+this.handleSize.width;a>s&&(t=s-this.handleSize.width,a=s),i>a&&(t=i-this.handleSize.width,a=i),e=Math.max(n,Math.floor(a/this.ratio)),e===n&&(t=Math.floor(n*this.ratio)-this.handleSize.height),e-=this.handleSize.height}return[t-this.borderWidth(),e-this.borderWidth()]},dragChange:function(){var t=this.handle.positionedOffset();"right"===this.alignment?(t.left=this.imageDimensions.width-t.left,t.top+=this.handleSize.height,this.controls.setStyle({left:Math.floor(this.imageDimensions.width-t.left)+this.borderWidth()+"px",width:t.left-2*this.borderWidth()+"px",height:t.top+"px"}),this.handle.setStyle({left:parseInt(this.handle.getStyle("left"))+this.borderWidth()+"px",top:parseInt(this.handle.getStyle("top"))+this.borderWidth()+"px"})):"left"===this.alignment?(t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.controls.setStyle({width:t.left+"px",height:t.top+"px"})):"center"===this.alignment&&(t.left+=this.handleSize.width+this.borderWidth(),t.top+=this.handleSize.height+this.borderWidth(),this.controls.setStyle({left:Math.floor((this.imageDimensions.width-t.left)/2)+"px",width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})),this.setInformation(!0)},dragEnd:function(){this.dragging=!1,Wysija.locks.dragging=!1;var t=Wysija.get(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer"));t.block.element.removeClassName("dragging"),void 0!==t.block.contents&&t.block.contents.isEmpty()&&t.block.contents.getTextArea().setStyle({height:""}),$$("body")[0].setStyle({cursor:""});var e=this.constraints[this.alignment].minWidth,i=(this.constraints[this.alignment].minHeight,this.controls.getWidth()),s=this.controls.getHeight();e>i&&(i=e),this.setDimensions(i,s),this.handle.writeAttribute("style",""),"right"===this.alignment?(this.controls.insert(this.handle),this.controls.writeAttribute("style",""),this.element.writeAttribute("style",""),this.element.setStyle({height:s+"px"})):"center"===this.alignment?(this.controls.writeAttribute("style",""),this.element.setStyle({width:i+"px",height:s+"px"})):(this.element.writeAttribute("style",""),this.element.setStyle({height:s+"px"})),Wysija.hideTools(),this.element.fire("drag:end")},setDimensions:function(t,e){var t=void 0===t?this.maxWidth():parseInt(t,10),e=void 0===e?(1e3*(t/this.ratio)).round()/1e3:parseInt(e,10),i=this.getImageElement();i.writeAttribute("width",t),i.writeAttribute("height",e),this.controls.setStyle({width:t-this.borderWidth()+"px",height:e-this.borderWidth()+"px"})},borderWidth:function(){return 2},getControls:function(){return this.element.down(".resize-controls")},getInformation:function(){return this.controls.down(".resize-info")},setInformation:function(t){if(void 0===t&&(t=!1),this.controls=this.getControls(),void 0!==this.controls&&(this.information=this.getInformation(),void 0!==this.information)){if(t)var e=this.controls.getDimensions();else var e=this.element.getDimensions();void 0!==this.information&&this.information.update("#{width} x #{height}".interpolate(e))}}};Wysija.Image=Class.create(Wysija.Content,WysijaImageAbstract),Wysija.BannerImage=Class.create(Wysija.Banner,WysijaImageAbstract);var WysijaGalleryItemAbstract={initialize:function(t){return info("gallery item -> init"),this.element=$(t),this.params=new Hash,this},save:function(){return this.isEmpty()?null:{src:this.getImageElement().readAttribute("src"),width:parseInt(this.getImageElement().readAttribute("width")),height:parseInt(this.getImageElement().readAttribute("height")),url:this.params.get("url"),alt:this.params.get("alt"),cellWidth:parseInt(this.getImageContainer().getWidth()),cellHeight:parseInt(this.getImageContainer().getHeight())}},draw:function(){return this.customDraw()+this.customTools()},customDraw:function(){void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:"",elementRatio:1.48,elementClass:"empty",elementHeight:135,elementWidth:200});var t=this.getOptions();return void 0!==this.getImageElement()&&t.set("elementId",this.getImageElement().identify()),'<img class="image_placeholder #{elementClass}" id="#{elementId}" src="#{elementSrc}" height="#{elementHeight}" width="#{elementWidth}" />'.interpolate(t)},customTools:function(){return"empty"===this.getOptions().get("elementClass")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.addImageLink+'" class="add-link"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.removeImageLink+'" class="remove-link"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.removeImage+'" class="remove"><span></span></a></li>'+"</ul>"},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.addLinkButton=this.tools.down(".add-link"),this.addLinkButton.observe("click",function(){this.addLink()}.bind(this)),this.removeLinkButton=this.tools.down(".remove-link"),this.removeLinkButton.observe("click",function(){this.removeLink()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){this.getTools().hide(),Wysija.locks.showingTools=!1},showTools:function(){this.getTools().show(),Wysija.locks.showingTools=!0},remove:function(){info("gallery item -> remove"),this.element.fire("image:remove")},setup:function(){return info("gallery item -> setup"),this.setupControls(),this.setupTools(),this.getParameters(),this},getParameters:function(){info("gallery item -> get parameters");var t=this.element.down(".wysija_params");if(void 0!==t&&0===this.params.keys().length){var e=$F(t.down('input[name="url"]'));""!=e&&this.params.set("url",e);var i=$F(t.down('input[name="alt"]'));""!=i&&this.params.set("alt",i)}return this},getImageContainer:function(){return this.element},getImageElement:function(){return this.element.down("img")},isEmpty:function(){return this.getImageElement().hasClassName("empty")},setEmpty:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("empty")},setPosition:function(t){this.element.writeAttribute("wysija_position",t)}};Wysija.GalleryImage=Class.create(Wysija.Gallery,WysijaGalleryItemAbstract);var WysijaTextAbstract={initialize:function(t){return this.element=$(t),this.alignment=this.getDefaultAlignment(),this},save:function(){return this.isEmpty()?null:{value:Base64.encode(this.getTextArea().innerHTML)}},draw:function(){return info("text -> draw"),this.customDraw()+this.customTools()},customDraw:function(){info("text -> custom draw");var t=this.getOptions();return void 0!==this.getTextArea()&&t.set("elementId",this.getTextArea().identify()),void 0===t.get("elementText")?(t.set("placeholderText",Wysija_i18n.drop_block_here),'<div class="text_placeholder empty" id="#{elementId}">#{placeholderText}</div>'.interpolate(this.getOptions())):'<div class="editable" id="#{elementId}">#{elementText}</div>'.interpolate(this.getOptions())},makeDroppable:function(){this.isDroppable()&&Droppables.add(this.getTextArea().identify(),Wysija.textDropOptions)},removeDroppable:function(){Droppables.remove(this.getTextArea().identify())},hasContent:function(){return void 0!==this.getTextArea()},isDroppable:function(){return this.getTextArea().hasClassName("text_placeholder")},isEmpty:function(){return this.getTextArea().hasClassName("empty")},isEditing:function(){return this.element.hasClassName("editing")},setup:function(){info("text -> setup"),this.setupEditor(),this.setAlignment(this.getDefaultAlignment()),this.setupTools(),this.makeDroppable()},setAlignment:function(t){return info("text -> setAlignment = "+t),this.alignment=t,this.isEmpty()===!1&&this.disableEditor(),this},getDefaultAlignment:function(){return this.element.up(".wysija_content").readAttribute("wysija_align")||Wysija.defaults.contentAlignment},setBlockAlignment:function(t){info("text -> set block alignment to : "+t);var e=Wysija.get(this.getBlock());e.block.setBlockAlignment(t)},setupEditor:function(){info("text -> setupEditor"),this.getTextContainer().observe("click",this.enableEditor.bind(this))},customTools:function(){return void 0===this.getOptions().get("elementText")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.removeText+'" class="remove"><span></span></a></li>'+"</ul>"},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.element.observe("mouseover",function(){this.isEditing()!==!0&&Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&this.showTools()}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.selectingColor!==!0&&this.hideTools()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show()},remove:function(){info("text -> remove"),this.element.fire("text:remove")},enableEditor:function(){this.isEditing()||(info("text -> enableEditor"),Wysija.hideEditors(),this.element.addClassName("editing"),tinyMCE.execCommand("mceAddControl",!1,this.getTextArea().identify()),this.element.fire("editor:enable"))},disableEditor:function(){this.isEditing()!==!1&&(info("text -> disableEditor"),this.element.removeClassName("editing"),tinyMCE.execCommand("mceRemoveControl",!1,this.getTextArea().identify()),this.element.fire("editor:disable"))},setFocus:function(){info("text -> setFocus"),this.enableEditor()},getTextContainer:function(){return this.element},getTextArea:function(){return this.element.down(".editable")||this.getTextPlaceholder()},getTextPlaceholder:function(){return this.element.down(".text_placeholder")},getTextEditor:function(){return tinymce.get(this.getTextArea().identify())},isAlone:function(){return this.getTextContainer().hasClassName("alone")},setAlone:function(t){this.getTextContainer()[t?"addClassName":"removeClassName"]("alone")}};Wysija.Text=Class.create(Wysija.Content,WysijaTextAbstract),Wysija.Divider=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this.setOptions(this.getCustomData("divider")),this},save:function(){return void 0===this.getDivider()?null:{src:this.getDivider().readAttribute("src"),width:parseInt(this.getDivider().readAttribute("width")),height:parseInt(this.getDivider().readAttribute("height"))}},draw:function(){this.element.childElements().last().insert(this.customDraw())},customDraw:function(){return info("divider -> custom draw"),void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:"",elementHeight:1,elementWidth:564}),'<img class="divider" src="#{elementSrc}" height="#{elementHeight}" width="#{elementWidth}" />'.interpolate(this.getOptions())},customControls:function(){return""},setup:function(){this.setupControls()},getContainer:function(){return this.element.down(".wysija_divider")},getDivider:function(){return this.getContainer().down("img")}}),Wysija.Raw=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this.setOptions({elementRaw:""}),this},save:function(){return void 0===this.getRaw()?null:{raw:Base64.encode(this.getRaw().innerHTML)}},draw:function(){this.element.childElements().last().insert(this.customDraw())},customDraw:function(){info("raw -> custom draw");var t=this.getOptions();return void 0!==this.getRaw()&&t.set("elementId",this.getRaw().identify()),void 0===t.get("elementRaw")?'<div class="raw empty" id="#{elementId}"></div>'.interpolate(this.getOptions()):'<div class="raw" id="#{elementId}">#{elementRaw}</div>'.interpolate(this.getOptions())},customControls:function(){return""},setup:function(){this.setupControls()},getContainer:function(){return this.element.down(".wysija_raw")},getRaw:function(){return this.getContainer().down(".raw")}}),Wysija.Post=Class.create(Wysija.Block,{initialize:function(t){return info("post -> init"),this.element=$(t),this},draw:function(){WysijaPopup.open(Wysija_i18n.articleSelectionTitle,WysijaPopup.formatURI(wysijaAJAX.adminurl,"page=wysija_campaigns&action=articles"),this.success.bind(this),this.cancel.bind(this))},success:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}}),Wysija.AutoPost=Class.create(Wysija.Block,{initialize:function(t){return info("autopost -> init"),this.element=$(t),this},draw:function(){info("autopost -> draw")},setup:function(){info("autopost -> setup"),this.setupControls()},save:function(){info("autopost -> save");var t={};return this.getParameters(),t.params=this.params,t},getParameters:function(){info("autopost -> get parameters"),this.params=[];var t=this.element.down(".wysija_params");return void 0!==t&&t.select("input").each(function(t){this.params.push($H({key:t.name,value:t.value}))}.bind(this)),this},getControls:function(){return this.element.down(".wysija_controls")},setupControls:function(){return this.controls=this.getControls(),this.controls&&(this.element.observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.element.addClassName("hover"),this.showControls(),this.element.down(".wysija_settings").show())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideControls(),this.element.down(".wysija_settings").hide())}.bind(this)),this.removeButton=this.controls.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)),this.settingsButton=this.element.down(".settings"),this.settingsButton.observe("click",function(){this.editSettings()}.bind(this))),this},editSettings:function(){this.getParameters();var t=this.formatParameters();WysijaPopup.open(Wysija_i18n.autoPostSettingsTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=autopost&"+t,this.callback.bind(this))},callback:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},formatParameters:function(){var t=["autopost_count="+$$(".wysija_auto-post").length,"autopost_type="+$("wysija_widgets_settings").down(".autopost").innerHTML];return void 0!==this.params&&this.params.length>0&&(this.params.each(function(e){t.push(e.get("key")+"="+e.get("value"))}),t=t.join("&")),t},loadContent:function(){var t=this.element.previousSiblings();if(t.length>0){var e=[];t.each(function(t){"auto-post"===t.readAttribute("wysija_type")&&void 0!==t.down('input[name="post_ids"]')&&e.push(t.down('input[name="post_ids"]').value)}),e.length>0&&(e=e.join(","))}this.getParameters();var i=this.formatParameters();void 0!==e&&e.length>0&&(i+="&exclude="+e);var s=this;wysijaAJAX.task="load_auto_post",wysijaAJAX.wysijaData=i,new Ajax.Request(wysijaAJAX.ajaxurl,{method:"post",asynchronous:!1,parameters:wysijaAJAX,onSuccess:function(t){s.getAutoPostElement().update(Base64.decode(t.responseJSON.result)),Wysija.setSettingsPosition.delay(1)},onFailure:function(){}})},remove:function(){info("autopost remove"),this.removeBlock(function(){Wysija.initAutoPost(),Wysija.setBackgroundColors()})},getAutoPostElement:function(){return this.element.down(".wysija_auto-post")},getSettings:function(){return this.element.down(".wysija_settings")}}),Wysija.PopupAutoPost=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this},draw:function(){var t=["autopost_count="+parseInt($$(".wysija_auto-post").length+1),"autopost_type="+$("wysija_widgets_settings").down(".autopost").innerHTML].join("&");WysijaPopup.open(Wysija_i18n.autoPostSettingsTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=autopost&"+t,this.success.bind(this),this.cancel.bind(this))},success:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}}),Wysija.PopupBookmark=Class.create(Wysija.Block,{initialize:function(t){return info("popup bookmark -> init"),this.element=$(t),this},draw:function(){var t="theme="+$("wysija_widgets_settings").down(".theme").innerHTML;WysijaPopup.open(Wysija_i18n.bookmarkSelectionTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=bookmarks&"+t,this.success.bind(this),this.cancel.bind(this))},success:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}});var WysijaPopup={initialized:!1,opened:!1,locked:!1,title:null,url:null,popupWidth:null,popupHeight:null,onSuccess:null,onCancel:null,setSize:function(t,e){return WysijaPopup.popupWidth=t,WysijaPopup.popupHeight=e,this},formatURI:function(t,e){return-1===t.indexOf("?")?t+"?"+e:t+"&"+e},init:function(){if(WysijaPopup.initialized===!1){info("init popup");var t='<div id="wysija_popup_overlay"></div><div id="wysija_popup"><div id="wysija_popup_title"><h3></h3><a id="wysija_popup_close" href="javascript:;"></a></div><div id="wysija_popup_content" class="clearfix"><iframe id="wysija_popup_iframe" marginheight="0" marginwidth="0" frameborder="0"></iframe></div></div>';$$("body")[0].insert(t),$("wysija_popup").setStyle({visibility:"hidden"}),WysijaPopup.hideLoading(),WysijaPopup.hideOverlay(),$("wysija_popup_close").observe("click",WysijaPopup.cancel),$("wysija_popup_overlay").observe("click",function(t){"wysija_popup_overlay"===t.target.id&&WysijaPopup.cancel()}),WysijaPopup.initialized=!0,$("wysija_popup_iframe").observe("load",function(){null!==$(this).readAttribute("src")&&setTimeout(function(){WysijaPopup.opened=!0,WysijaPopup.setDimensions(),WysijaPopup.hideLoading(),WysijaPopup.showOverlay(),setTimeout(function(){$("wysija_popup").setStyle({visibility:"visible"})
3
- },101)},0)})}},lock:function(){WysijaPopup.locked=!0},unlock:function(){WysijaPopup.locked=!1},isLocked:function(){return WysijaPopup.locked},setPosition:function(){if(WysijaPopup.init(),WysijaPopup.opened!==!1){var t=$("wysija_popup").getDimensions(),e=document.viewport.getDimensions(),i=parseInt(Wysija.scroll.top+e.height/2-t.height/2-15,10),s=parseInt(Wysija.scroll.left+e.width/2-t.width/2,10);Wysija.scroll.top>i&&(i=parseInt(Wysija.scroll.top,10)),Wysija.scroll.left>s&&(s=parseInt(Wysija.scroll.left,10)),$("wysija_popup").setStyle({top:i+"px",left:s+"px"})}},setDimensions:function(){if(WysijaPopup.opened!==!1){var t=$("wysija_popup_iframe");if(null!==t){t.doc=null,t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document);var e=0,i=0,s=document.viewport.getDimensions();setTimeout(function(){if($("wysija_popup_iframe").writeAttribute("width",null),$("wysija_popup_iframe").writeAttribute("height",null),null===WysijaPopup.popupWidth||null===WysijaPopup.popupHeight){var n=null;n=t.doc.querySelectorAll(".popup_content").length>0?WysijaPopup.getElementSize(t.doc.querySelectorAll(".popup_content")[0]):WysijaPopup.getElementSize(t.doc.getElementsByClassName(".popup_content")[0]),i=n.width,e=n.height}else i=WysijaPopup.popupWidth,e=WysijaPopup.popupHeight;e+50>s.height&&(e=s.height-50),$("wysija_popup").setStyle({width:i+"px",height:e+20+"px"}),$("wysija_popup_iframe").writeAttribute("width",i),$("wysija_popup_iframe").writeAttribute("height",e+20),WysijaPopup.setPosition()},100)}}},getElementSize:function(t){var e=t.currentStyle||window.getComputedStyle(t),i=t.offsetWidth;i+=parseInt(e.marginLeft),i+=parseInt(e.marginRight);var s=t.offsetHeight;return s+=parseInt(e.marginTop),s+=parseInt(e.marginBottom),{width:i,height:s}},loadContent:function(t,e){$("wysija_popup_iframe").writeAttribute("src",e),$("wysija_popup_title").down("h3").update(t)},showOverlay:function(){$("wysija_popup_overlay").setStyle({visibility:"visible"})},showLoading:function(){$("wysija_popup_overlay").addClassName("loading")},hideOverlay:function(){$("wysija_popup_overlay").setStyle({visibility:"hidden"})},hideLoading:function(){$("wysija_popup_overlay").removeClassName("loading")},open:function(t,e,i,s){WysijaPopup.init(),WysijaPopup.showLoading(),WysijaPopup.showOverlay(),void 0!==i&&(WysijaPopup.onSuccess=i),void 0!==s&&(WysijaPopup.onCancel=s),WysijaPopup.loadContent(t,e)},success:function(t){null!==WysijaPopup.onSuccess&&WysijaPopup.onSuccess(t),WysijaPopup.close()},cancel:function(t){null!==WysijaPopup.onCancel&&WysijaPopup.onCancel(t),WysijaPopup.close()},close:function(){return WysijaPopup.isLocked()===!0?!1:($("wysija_popup").writeAttribute("style",""),$("wysija_popup").setStyle({visibility:"hidden"}),WysijaPopup.hideLoading(),WysijaPopup.hideOverlay(),$("wysija_popup_iframe").writeAttribute("src",null),$("wysija_popup_iframe").writeAttribute("height",null),$("wysija_popup_iframe").writeAttribute("width",null),WysijaPopup.onSuccess=null,WysijaPopup.onCancel=null,WysijaPopup.popupWidth=null,WysijaPopup.popupHeight=null,WysijaPopup.opened=!1,!1)}};Wysija.DraggableItem=Class.create({initialize:function(t){this.elementType=$(t).readAttribute("wysija_type"),this.element=$(t).down()||$(t),this.clone=null,t.hasClassName("wysija_item")===!1&&(this.elementType="block_image")},STYLES:new Template("position: absolute; top: #{top}px; left: #{left}px;"),cloneElement:function(){var t=this.element.clone(),e=this.element.cumulativeOffset();if(this.element.hasClassName("wysija_item")){var i=this.getList(),s=this.STYLES.evaluate({top:e.top-i.scrollTop,left:e.left-i.scrollLeft});t.addClassName("wysija_widget"),t.addClassName(this.elementType)}else{var s=this.STYLES.evaluate({top:e.top,left:e.left,width:this.element.getWidth()+"px",height:this.element.getHeight()+"px"});t.writeAttribute("wysija_height",this.element.readAttribute("wysija_height")),t.writeAttribute("wysija_width",this.element.readAttribute("wysija_width")),t.writeAttribute("wysija_src",this.element.readAttribute("wysija_src")),this.element.hasClassName("image_placeholder")&&t.writeAttribute("wysija_parent",(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer")).identify()),t.addClassName("wysija_widget image")}return t.setStyle(s),"image"===this.elementType||"block_image"===this.elementType?t.writeAttribute({elementRatio:this.calculateRatio(),wysija_type:"image"}):t.innerHTML=this.element.innerHTML,t},getOffset:function(){return this.element.offsetTop-this.getList().scrollTop},getList:function(){return this.element.up("ul")},insert:function(){$$("body")[0].insert(this.clone)},onMousedown:function(t){if("block_image"!==this.elementType||"img"===this.element.tagName.toLowerCase()&&"span"!==t.target.tagName.toLowerCase()){null===this.clone&&(this.clone=this.cloneElement(),this.insert());var e=new Draggable(this.clone,{scroll:window,isImage:!1,onStart:function(t,e){this.isImage=t.element.hasClassName("wysija_widget image"),this.isImage===!0&&t.element.setStyle({left:e.pageX+"px",top:e.pageY+"px"}),Wysija.locks.dragging=!0,Wysija.hideTools(),Wysija.hideBlockControls(),Droppables.togglePlaceholders(t,e)},onDrag:function(t,e){Droppables.togglePlaceholders(t,e)},snap:function(t,e,i){return this.isImage===!0?[t+i.offset[0],e+i.offset[1]]:[t,e]},onEnd:function(t){t.destroy(),t.element.remove(),Wysija.locks.dragging=!1,Droppables.hidePlaceholders()},starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction});return e.initDrag(t),e.startDrag(t),e}},calculateRatio:function(){return(1e3*(this.element.readAttribute("wysija_width")/this.element.readAttribute("wysija_height"))).round()/1e3}}),Object.extend(Wysija.DraggableItem,Observable).observe('a[class="wysija_item"], .wysija_image'),Wysija.ImagePreview=Class.create({initialize:function(t){this.element=$(t)},onMouseover:function(){if(Wysija.locks.dragging!==!0){var t=this.element.down("img").clone();if(""!==t.readAttribute("wysija_src")){var e=parseInt(t.readAttribute("wysija_height"),10),i=parseInt(t.readAttribute("wysija_width"),10),s=(1e3*(i/e)).round()/1e3;i>275&&(i=275),e=(i/s).round(),t.writeAttribute("src",t.readAttribute("wysija_src")),$("wj_images_preview").insert(t),$("wj_images_preview").down("img").writeAttribute({width:i,height:e}),$("wj_images_preview").show()}}},onMouseout:function(){$("wj_images_preview").update(""),$("wj_images_preview").hide()}}),Wysija.ThemePreview=Class.create({initialize:function(t){this.element=$(t)},onMouseover:function(){if(Wysija.locks.dragging!==!0){var t=this.element.down("img").clone();if(""!==t.readAttribute("wysija_src")){var e=t.readAttribute("wysija_height"),i=t.readAttribute("wysija_width"),s=(1e3*(i/e)).round()/1e3;i>275&&(i=275),e=(i/s).round(),t.writeAttribute("src",t.readAttribute("wysija_src")),$("wj_themes_preview").insert(t),$("wj_themes_preview").down("img").writeAttribute("width",i),$("wj_themes_preview").down("img").writeAttribute("height",e),$("wj_themes_preview").show()}}},onMouseout:function(){$("wj_themes_preview").update(""),$("wj_themes_preview").hide()}}),Object.extend(Wysija.ThemePreview,Observable).observe(".wj_themes li a"),Wysija.TextLinks=Class.create({initialize:function(t){this.element=$(t)},onClick:function(t){return t.stop(),!1}}),Object.extend(Wysija.TextLinks,Observable).observe(".editable a"),window.document.observe("mousedown",function(t){if(tinymce.editors.length>0){if("mceModalBlocker"===t.target.id)return;if(t.target.hasClassName("mceClose"))return;void 0===t.target.up(".wysija_text")&&void 0===t.target.up(".editable")&&t.target.hasClassName("mceText")===!1&&(Wysija.hideEditors(),Wysija.autoSave())}}),document.on("image:drop",function(t,e){var i=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i.block.image.removeDroppable(),i.block.image.setOptions(t.memo),i.block.getImageContainer().writeAttribute("style",""),i.block.getImageContainer().update(i.block.image.draw()),i.block.image.setup(),void 0===i.block.contents?i.block.image.setAlone(!0):(i.block.contents.setAlone(i.block.image.isEmpty()),i.block.image.setAlone(i.block.contents.isEmpty()),i.block.setBlockAlignment(i.block.contents.getDefaultAlignment())),Wysija.hideTools(),i.block.image.setEmpty(!1),i.block.constrainSize(),Wysija.hideTools(),Wysija.autoSave()}),document.on("text:drop",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.contents.removeDroppable(),i.block.contents.setOptions(t.memo),i.block.getTextContainer().update(i.block.contents.draw()),i.block.contents.setup(),i.block.image.isEmpty()===!1?(i.block.image.setAlone(!1),i.block.setBlockAlignment(i.block.image.alignment)):i.block.contents.setAlone(!0),i.block.constrainSize(),i.block.contents.setFocus(),Wysija.hideControls(),Wysija.hideTools(),Wysija.autoSave()}),document.on("image:remove",function(t,e){var i=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i.block.image.hideTools(),i.block.image.removeDroppable(),i.block.image.setOptions({elementSrc:void 0}),i.block.image.element.update(i.block.image.draw()),i.block.image.makeDroppable(),i.block.image.setEmpty(!0),void 0!==i.block.contents&&i.block.contents.isEmpty()===!1&&i.block.contents.setAlone(!0),i.block.constrainSize(),i.block.remove()}),document.on("text:remove",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.contents.getTextContainer().stopObserving("click"),i.block.contents.removeDroppable(),i.block.contents.setOptions({elementText:void 0}),i.block.contents.element.update(i.block.contents.draw()),i.block.contents.makeDroppable(),i.block.image.isEmpty()===!1&&i.block.image.setAlone(!0),i.block.constrainSize(),i.block.remove()}),document.on("editor:enable",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.constrainSize()}),document.on("editor:disable",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.constrainSize()}),document.on("block:insert",function(t,e){var i=Wysija.get(e);"content"===i.elementType&&(i.block.image.setAlone(i.block.contents.isEmpty()),i.block.contents.setAlone(i.block.image.isEmpty()),i.block.image.setEmpty(i.block.image.isEmpty()),i.block.constrainSize(),Wysija.hideTools())}),document.on("drag:end",function(t,e){var i=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i.block.constrainSize()}),document.observe("dom:loaded",function(){$("wysija_toggle_images").observe("click",function(){return Wysija.toggleImages()===!0?this.addClassName("on").removeClassName("off"):this.addClassName("off").removeClassName("on"),!1})});
1
+ "use strict";function info(t){if(Wysija.options.verbose!==!1){window.console&&console.log||function(){for(var t=function(){},e=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","markTimeline","table","time","timeEnd","timeStamp","trace","warn"],i=e.length,s=window.console={};i--;)s[e[i]]=t}();try{console.log("[INFO] "+t)}catch(e){}}}Object.extend(Prototype.Browser,{ie6:/MSIE (\d+\.\d+);/.test(navigator.userAgent)?6===Number(RegExp.$1)?!0:!1:!1,ie7:/MSIE (\d+\.\d+);/.test(navigator.userAgent)?7===Number(RegExp.$1)?!0:!1:!1,ie8:/MSIE (\d+\.\d+);/.test(navigator.userAgent)?8===Number(RegExp.$1)?!0:!1:!1,ie9:/MSIE (\d+\.\d+);/.test(navigator.userAgent)?9===Number(RegExp.$1)?!0:!1:!1}),Event.cacheDelegated={},Object.extend(document,function(){function t(t){return o[t]=o[t]||{}}function e(e,i){var s=t(e);return s[i]=s[i]||[]}function i(t,i,s){var n=e(t,i);return n.find(function(t){return t.handler===s})}function s(e,s,n){var o=t(e);if(!o[s])return!1;var a=i(e,s,n);return o[s]=o[s].without(a),a}function n(t,i,s,n){var o,a=e(t,i);return a.pluck("handler").include(s)?!1:(o=function(e){var i=e.findElement(t);i&&s.call(n||i,e,i)},o.handler=s,a.push(o),o)}var o=Event.cacheDelegated;return{delegate:function(t,e){var i=n.apply(null,arguments);return i&&document.observe(e,i),document},stopDelegating:function(i,n){var a=arguments.length;switch(a){case 2:e(i,n).each(function(t){document.stopDelegating(i,n,t.handler)});break;case 1:Object.keys(t(i)).each(function(t){document.stopDelegating(i,t)});break;case 0:Object.keys(o).each(function(t){document.stopDelegating(t)});break;default:var r=s.apply(null,arguments);r&&document.stopObserving(n,r)}return document}}}());var Observable=function(){function t(t,e){return t=t.substring(2),e&&(t=e+":"+t),t.underscore().split("_").join(":")}function e(e){var s=e.prototype,n=s.namespace;return Object.keys(s).grep(/^on/).inject($H(),function(o,a){return"onDomLoaded"===a?o:(o.set(t(a,n),i(s[a],e)),o)})}function i(t,e){return function(i){return t.call(new e(this),i,i.memo)}}function s(t,e){$$(t).each(function(t){new e(t).onDomLoaded()})}return{observe:function(t){if(this.handlers||(this.handlers={}),!this.handlers[t]){var i=this;this.prototype.onDomLoaded&&(document.loaded?s(t,i):document.observe("dom:loaded",s.curry(t,i))),this.handlers[t]=e(i).each(function(e){document.delegate(t,e.key,e.value)})}},stopObserving:function(t){this.handlers&&this.handlers[t]&&(this.handlers[t].each(function(e){document.stopDelegating(t,e.key,e.value)}),delete this.handlers[t])}}}();Object.extend(Droppables,{deactivate:Droppables.deactivate.wrap(function(t,e,i){return e.onLeave&&e.onLeave(i,e.element),t(e)}),activate:Droppables.activate.wrap(function(t,e,i){return e.onEnter&&e.onEnter(i,e.element),t(e)}),togglePlaceholders:function(t,e){if(0!==this.drops.length&&!($$(".block_placeholder.hover, .text_placeholder.hover, .image_placeholder.hover").length>0)){var i=document.viewport.getDimensions(),s=document.viewport.getScrollOffsets();this.drops.each(function(n){if(void 0===n.overlap){var o=!1,a=n.element.cumulativeOffset(),r=Math.max(30,n.element.getHeight()),l=t.element.hasClassName("image"),h=t.element.hasClassName("text");if(a.top>s.top+i.height)return;if(a.top<s.top&&a.top+r<s.top)return;if(l===!1&&-1!==n.accept.indexOf("image"))return;if(h===!1&&-1!==n.accept.indexOf("text"))return;if(l===!0){if(-1!==n.accept.indexOf("text"))return;if(t.element.readAttribute("wysija_src")===n.element.readAttribute("wysija_src"))return}var c=a.top-2*Wysija.options.blockDropTreshold,m=a.top+r+Wysija.options.blockDropTreshold;e.pageY>c&&m>e.pageY&&(o=!0);var d=n.element.up();o===!0?(d&&d.addClassName("active"),n.element.addClassName("active")):(d&&d.removeClassName("active"),n.element.removeClassName("active"))}})}},hidePlaceholders:function(){0!==this.drops.length&&$$(".block_placeholder.active, .text_placeholder.active, .image_placeholder.active, .wysija_image.active").invoke("removeClassName","active")}});var Wysija={version:"2.3",options:{debug:!1,verbose:!1,css:"wj_css",toolbar:"wysija_toolbar",notices:"wysija_notices",wrapper:"wysija_wrapper",container:"wysija_container",header:"wysija_header",body:"wysija_body",footer:"wysija_footer",blockDropTreshold:30,imageDropTreshold:30,minTextPlaceholderWidth:45},toolbar:{effect:null,x:null,y:null,top:null,left:null},scroll:{top:0,left:0},locks:{dragging:!1,selectingColor:!1,showingTools:!1},flags:{displayImages:!0,doSave:!1},defaults:{contentAlignment:"left",imageAlignment:"center",galleryAlignment:"center"},autoSave:function(){Wysija.flags.doSave===!1&&(Wysija.flags.doSave=!0)},save:function(){var t,e=1,i={},s=$H();s.set("version",Wysija.version);var n=Wysija.getHeader();i=n.block.save(),i.type="header",s.set("header",i);var o=$H();Wysija.getBlocks().each(function(s){t=s.block,t.save&&(i=t.save(),null!==i&&(i.position=e,i.type=s.elementType,i.background_color=t.element.readAttribute("wysija_bg_color"),o.set("block-"+e,i),e++))}),s.set("body",o);var a=Wysija.getFooter();return i=a.block.save(),i.type="footer",s.set("footer",i),Object.toJSON(s).gsub('\\"','"').gsub('"[{',"[{").gsub('}]"',"}]")},blockDropOptions:{accept:$w("wysija_widget"),onEnter:function(t,e){$(e).addClassName("hover")},onLeave:function(t,e){$(e).removeClassName("hover")},onDrop:function(t,e){var i={},s=null;i.elementType=t.readAttribute("wysija_type"),i.element=t,"image"===i.elementType?(i.elementRatio=t.readAttribute("elementRatio"),i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height"),i.elementClass=null,s=t.readAttribute("wysija_parent"),null!==$(s)&&(i.elementData=Wysija.get($(s)).block.image.getData())):"divider"===i.elementType?(i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height")):"text"===i.elementType&&(i.elementText=Wysija_i18n.clickToEditText),e.fire("item:drop",i),$(e).removeClassName("hover"),null!==$(s)&&(s=Wysija.get($(s)),s.block.image.removeImage())}},imageDropOptions:{accept:$w("image"),onEnter:function(t,e){$(e).addClassName("hover"),($(e).up(".wysija_block")||$(e).up(".wysija_header")||$(e).up(".wysija_footer")).addClassName("image_hover")},onLeave:function(t,e){$(e).removeClassName("hover"),$$(".image_hover").invoke("removeClassName","image_hover")},onDrop:function(t,e){if(e.readAttribute("wysija_src")===t.readAttribute("wysija_src"))return Wysija.hideTools(),!1;var i={},s=t.readAttribute("wysija_parent");i.elementType=t.readAttribute("wysija_type"),i.element=t,i.elementRatio=t.readAttribute("elementRatio"),i.elementSrc=t.readAttribute("wysija_src"),i.elementWidth=t.readAttribute("wysija_width"),i.elementHeight=t.readAttribute("wysija_height"),i.elementClass=null,null!==$(s)&&(s=Wysija.get($(s)),i.elementData=s.block.image.getData()),e.fire("image:drop",i),$(e).removeClassName("hover"),null!==$(s)&&s.block.image.removeImage()}},textDropOptions:{accept:$w("text"),onEnter:function(t,e){$(e).addClassName("hover")},onLeave:function(t,e){$(e).removeClassName("hover")},onDrop:function(t,e){var i={};i.elementType=t.readAttribute("wysija_type"),i.element=t,i.elementText=Wysija_i18n.clickToEditText,e.fire("text:drop",i),$(e).removeClassName("hover")}},instances:{},get:function(t,e){void 0===e&&(e="block");var i=t.identify(),s=Wysija.instances[i]||new(Wysija[e.capitalize().camelize()])(i);return Wysija.instances[i]=s,s},getTheme:function(){var t=$("wysija_widgets_settings").down(".theme");return void 0!==t&&t.innerHTML.length>0?t.innerHTML:"default"},getHeader:function(){return Wysija.get(Wysija.getHeaderElement(),"header")},getHeaderElement:function(){return $$("div.wysija_header")[0]},getFooter:function(){return Wysija.get(Wysija.getFooterElement(),"footer")},getFooterElement:function(){return $$("div.wysija_footer")[0]},getBlocks:function(){return Wysija.getBlockElements().map(function(t){return Wysija.get(t)})},getBlockElements:function(){return $$("div.wysija_block")},startBlockPositions:function(t,e){e.element.hasClassName("wysija_block")&&(Wysija.locks.dragging=!0,Wysija.hideEditors())},setScrollOffsets:function(){Wysija.scroll=document.viewport.getScrollOffsets()},setBlockPositions:function(t,e){Wysija.locks.dragging=!1;var i=1;Wysija.getBlocks().each(function(t){t.setPosition(i++),t.block.element.setStyle({zIndex:""});var e=$$(".block_placeholder[data-parent="+t.block.element.identify()+"]").first();void 0!==e&&t.block.element.insert({before:e})}),void 0!==e&&$$(".wysija_auto-post").length>1&&"auto-post"===e.element.readAttribute("wysija_type")&&(Wysija.initAutoPost(),Wysija.setBackgroundColors()),Wysija.autoSave()},init:function(){Wysija.setScrollOffsets(),Wysija.getHeader(),Wysija.getFooter(),Wysija.makeDroppable(),Wysija.makeSortable(),Wysija.hideControls(),Wysija.hideTools(),Wysija.hideSettings(),Wysija.setSettingsPosition(),Wysija.initSettings(),Wysija.initAutoPost(),Wysija.setBackgroundColors(),Wysija.setToolbarPosition(),Wysija.setImagesDisplay()},initToolbarPosition:function(){null===Wysija.toolbar.top&&(Wysija.toolbar.top=parseInt($(Wysija.options.wrapper).positionedOffset().top)),null===Wysija.toolbar.left&&(Wysija.toolbar.left=parseInt($(Wysija.options.wrapper).positionedOffset().left)),null===Wysija.toolbar.x&&(Wysija.toolbar.x=parseInt(Wysija.toolbar.left+$(Wysija.options.wrapper).getDimensions().width+15)),Wysija.toolbar.y=Wysija.scroll.top>=Wysija.toolbar.top-20?parseInt(20+Wysija.scroll.top):parseInt(Wysija.toolbar.top+Wysija.scroll.top)},setToolbarPosition:function(){Wysija.initToolbarPosition(),$(Wysija.options.toolbar).setStyle({top:Wysija.toolbar.y+"px",left:Wysija.toolbar.x+"px",opacity:0}).appear({duration:.5}),$(Wysija.options.notices).hide()},updateToolbarPosition:function(){Wysija.initToolbarPosition(),null!==Wysija.toolbar.effect&&Wysija.toolbar.effect.cancel(),Wysija.scroll.top>=Wysija.toolbar.top-20?(Wysija.toolbar.y=parseInt(20+Wysija.scroll.top),Wysija.toolbar.effect=new Effect.Move(Wysija.options.toolbar,{x:Wysija.toolbar.x,y:Wysija.toolbar.y,mode:"absolute",duration:.2})):$(Wysija.options.toolbar).setStyle({left:Wysija.toolbar.x+"px",top:Wysija.toolbar.top+"px"})},editorCleanup:function(t,e){switch(t){case"get_from_editor":e=e.gsub("<p></p>","<p>&nbsp;</p>");break;case"insert_to_editor":break;case"submit_content":break;case"get_from_editor_dom":break;case"insert_to_editor_dom":break;case"setup_content_dom":break;case"submit_content_dom":}return e},updateCSSColor:function(t,e){var i=[],s="color",n=$(Wysija.options.css).innerHTML.strip();switch(t.endsWith("BgColorInput")&&(s="background-color"),e=""===e?"transparent":"#"+e,t){case"bodyColorInput":i.push("editable"),i.push("editable ul li"),i.push("editable ol li");break;case"h1ColorInput":i.push("editable h1");break;case"h2ColorInput":i.push("editable h2");break;case"h3ColorInput":i.push("editable h3");break;case"linksColorInput":i.push("editable a"),i.push("editable h1 a"),i.push("editable h2 a"),i.push("editable h3 a");break;case"unsubscribeColorInput":i.push("wysija_unsubscribe p");break;case"viewbrowserColorInput":i.push("wysija_viewbrowser p");break;case"htmlBgColorInput":i.push("wysija_wrapper");break;case"headerBgColorInput":i.push("wysija_header");break;case"bodyBgColorInput":i.push("wysija_body");break;case"footerBgColorInput":i.push("wysija_footer")}i.length>0&&null!==s&&(i.each(function(t){var i=new RegExp("([\\.|#]"+t+".*?{.*?"+s+":\\s*)(#?[a-z0-9]*)*(.*?})","i");n=n.replace(i,"$1"+e+"$3")}),n.length>0&&Wysija.updateCSS(n))},updateCSS:function(t){void 0!==$(Wysija.options.css)&&$(Wysija.options.css).remove();var e=document.getElementsByTagName("head")[0],i=document.createElement("style");i.id=Wysija.options.css,i.type="text/css",i.styleSheet?i.innerHTML=t:i.appendChild(document.createTextNode(t)),e.appendChild(i)},setTextStyles:function(t){var e=t.editorId+"_ifr",i=$(e);if(null!==i&&(i.doc=null,i.contentDocument?i.doc=i.contentDocument:i.contentWindow?i.doc=i.contentWindow.document:i.document&&(i.doc=i.document),null!==i.doc)){var s=i.doc.getElementsByTagName("head")[0],n=i.doc.createElement("style"),o=$(Wysija.options.css).innerHTML.strip();n.type="text/css",n.id="wj_iframe_css",n.styleSheet?n.innerHTML=o:n.appendChild(document.createTextNode(o)),s.appendChild(n)}},setBackgroundColors:function(){Wysija.getBlocks().invoke("setBackgroundColor"),$$(".wysija_auto-post .wysija_content, .wysija_auto-post .wysija_divider .wysija_raw").each(function(t){var e=t.readAttribute("wysija_bg_color");""===e?t.setStyle({backgroundColor:"transparent"}):null!==e&&t.setStyle({backgroundColor:"#"+e})})},hideBlockControls:function(){$$(".wysija_controls").invoke("hide"),this.getBlockElements().invoke("removeClassName","hover")},hideEditors:function(){tinymce.editors.length>0&&Wysija.getBlocks().each(function(t){"content"===t.elementType&&null!==t.block.contents&&t.block.contents.disableEditor()})},hideControls:function(){return Wysija.getBlocks().invoke("hideControls")},hideTools:function(){$$(".resize-controls").invoke("hide"),$$(".wysija_tools").invoke("hide"),Wysija.locks.showingTools=!1},makeDroppable:function(){Droppables.add("block_placeholder",Wysija.blockDropOptions)},makeSortable:function(){var t=$(Wysija.options.body);Sortable.create(t,{tag:"div",only:"wysija_block",scroll:window,handle:"handle",constraint:"vertical"}),Draggables.removeObserver(t),Draggables.addObserver({element:t,onStart:Wysija.startBlockPositions,onEnd:Wysija.setBlockPositions})},setDivider:function(t,e){$("wysija_widgets_settings").down(".divider").update(t),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_src",e.src),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_width",e.width),$$('.wysija_item[wysija_type="divider"]')[0].writeAttribute("wysija_height",e.height)},replaceDividers:function(){$$(".wysija_block .wysija_divider").invoke("replace",$("wysija_widgets_settings").down(".divider").innerHTML)},toggleImages:function(){return Wysija.flags.displayImages=!Wysija.flags.displayImages,this.setImagesDisplay()},setImagesDisplay:function(){return Wysija.flags.displayImages===!0?($$(".wysija_image img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_cell img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_divider img").invoke("setStyle",{visibility:"visible"}),$$(".wysija_raw img").invoke("setStyle",{visibility:"visible"}),!0):($$(".wysija_image img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_cell img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_divider img").invoke("setStyle",{visibility:"hidden"}),$$(".wysija_raw img").invoke("setStyle",{visibility:"hidden"}),!1)},flyToTheMoon:function(){if($("wysija-konami")){var t=document.viewport.getDimensions(),e=t.width;$("wysija-konami-overlay").show(),$("wysija-konami-bird").show(),$("wysija-konami-bird").setStyle({left:"-1000px",top:"100px"}),new Effect.Morph("wysija-konami-bird",{style:{left:e+"px"},duration:5,beforeStart:function(){},afterFinish:function(){$("wysija-konami-bird").writeAttribute("style","z-index:99999;position:absolute;top:300px;left:"+e+'px;-moz-transform: scaleX(-1);-o-transform: scaleX(-1);-webkit-transform: scaleX(-1);transform: scaleX(-1);filter: FlipH;-ms-filter: "FlipH";')}}),new Effect.Morph("wysija-konami-bird",{queue:"end",style:{left:"-1000px"},duration:5,afterFinish:function(){$("wysija-konami-bird").writeAttribute("style","z-index:99999;position:absolute;top:100px;left:-1000px;"),$("wysija-konami-overlay").hide(),$("wysija-konami-bird").hide()}})}},hideSettings:function(){$$(".wysija_settings").invoke("hide")},initSettings:function(){Event.stopObserving("scroll"),Event.observe(window,"scroll",function(){Wysija.setScrollOffsets(),Wysija.setSettingsPosition(),Wysija.updateToolbarPosition(),WysijaPopup.setPosition()}),Event.stopObserving("resize"),Event.observe(window,"resize",function(){WysijaPopup.setPosition()})},setSettingsPosition:function(){var t=document.viewport.getHeight(),e=25;$$(".wysija_settings").each(function(i){var s=i.up(".wysija_block").getDimensions(),n=i.up(".wysija_block").cumulativeOffset(),o=n.top<=Wysija.scroll.top+t?!0:!1,a=100;if(o){var r=parseInt(Wysija.scroll.top+(t/2-i.getHeight()/2)),l=parseInt(n.top-e),h=parseInt(n.top+s.height-e);a=200>parseInt(s.height)?parseInt(s.height/2-i.getHeight()/2):r+100>h+e?parseInt(s.height-100):l+e>r-100?100:parseInt(r-n.top)}new Effect.Move(i,{x:parseInt(s.width/2-i.getWidth()/2),y:a,mode:"absolute",duration:.2})})},initAutoPost:function(){var t=$("wysija_widgets_settings").down(".autopost").innerHTML,e=$$(".wysija_auto-post").length;"single"===t&&(e>0?($("wysija-widget-autopost").addClassName("disabled"),$("wysija-widget-autopost").writeAttribute("title",Wysija_i18n.autoPostImmediateNotice)):($("wysija-widget-autopost").removeClassName("disabled"),$("wysija-widget-autopost").writeAttribute("title",""))),Wysija.getBlocks().each(function(t){"auto-post"===t.elementType&&t.block.loadContent()})},encodeHtmlValue:function(t){return t.replace(/&/g,"&amp;").replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/"/g,"&quot;")},encodeURIComponent:function(t){var e=new RegExp(/^http[s]?:\/\//),i=e.exec(t);return null===i?encodeURIComponent(t).replace(/[!'()*]/g,escape):1===i.length?encodeURI(t).replace(/[!'()*]/g,escape):void 0}};document.observe("dom:loaded",Wysija.init),Wysija.Block=Class.create({initialize:function(t){return info("block -> init"),this.element=$(t),this.elementType=this.element.readAttribute("wysija_type"),this.block=new(Wysija[this.elementType.capitalize().camelize()])(this.element),1===parseInt(this.element.readAttribute("wysija_new"))&&(this.block.draw(),this.element.writeAttribute("wysija_new",0)),this.block.makeBlockDroppable(),void 0!==this.block.setup&&this.block.setup(),this},getCustomData:function(t){return void 0!==this.element.down(".wysija_options."+t)?(info("got options for "+t),this.element.down(".wysija_options."+t).innerHTML.toQueryParams("&amp;")):(info("no options to get for "+t),null)},getOptions:function(){return this.options},setOptions:function(t){return void 0===t&&(t={}),void 0===this.options&&(this.options=new Hash),this.options=this.options.update(t),this},setPosition:function(t){this.element.writeAttribute("wysija_position",t)},hideControls:function(){this.getControls&&(this.element.removeClassName("hover"),this.getControls().hide())},showControls:function(){this.getControls&&(this.element.addClassName("hover"),this.getControls().show())},makeBlockDroppable:function(){if(this.isBlockDroppableEnabled()===!1){var t=this.getBlockDroppable();Droppables.add(t.identify(),Wysija.blockDropOptions),t.addClassName("enabled")}},removeBlockDroppable:function(){if(this.isBlockDroppableEnabled()){var t=this.getBlockDroppable();Droppables.remove(t.identify()),t.removeClassName("enabled"),t.remove()}},isBlockDroppableEnabled:function(){return this.element.hasClassName("static")?!0:this.getBlockDroppable().hasClassName("enabled")},createBlockDroppable:function(){return this.element.insert({before:'<div class="block_placeholder" data-parent="'+this.element.identify()+'">'+Wysija_i18n.drop_block_here+"</div>"})},getBlockDroppable:function(){var t=this.element.identify();return 0===$$('.block_placeholder[data-parent="'+t+'"]').length&&this.createBlockDroppable(),$$('.block_placeholder[data-parent="'+t+'"]').first()},getControls:function(){return this.element.down(".wysija_controls")},setupControls:function(){if(this.controls=this.getControls(),this.controls){this.element.observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.element.addClassName("hover"),this.showControls())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&this.hideControls()}.bind(this)),this.removeButton=this.controls.down(".remove"),this.removeButton.observe("click",function(){this.removeBlock(),this.removeButton.stopObserving("click")}.bind(this)),this.bgColorButton=this.controls.down(".bgcolor");var t=this;jQuery(this.bgColorButton).modcoder_excolor({default_color:t.element.readAttribute("wysija_bg_color"),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_init:function(){Wysija.locks.selectingColor=!0},callback_on_select:function(e){t.setBackgroundColor(e)},callback_on_ok:function(e,i){i===!0&&t.setBackgroundColor(e),Wysija.locks.selectingColor=!1,t.hideControls()}})}return this},setBackgroundColor:function(t){void 0!==t&&this.element.writeAttribute("wysija_bg_color",t);var e=this.element.readAttribute("wysija_bg_color");""===e?this.element.setStyle({backgroundColor:"transparent"}):null!==e&&this.element.setStyle({backgroundColor:"#"+e}),Wysija.autoSave()},replaceBlock:function(t){return this.removeBlockDroppable(),this.element.replace(t)},removeBlock:function(t){info("block -> removeBlock"),this.removeBlockDroppable(),Effect.Fade(this.element.identify(),{duration:.2,afterFinish:function(){void 0!==this.element.next(".wysija_block")&&t!==!1&&Wysija.get(this.element.next(".wysija_block")).block.showControls(),this.element.remove(),Wysija.setBlockPositions(),void 0!==t&&"function"==typeof t&&t(),delete Wysija.instances[this.element.identify()]}.bind(this)})}}),document.observe("item:drop",function(t){Wysija.Block.create(t.memo,t.target),Wysija.hideBlockControls(),Wysija.setImagesDisplay()}),Wysija.Block.create=function(t,e){var i='<li class="handle_container"><a class="handle" href="javascript:;"><span></span></a></li><li><a class="bgcolor" href="javascript:;"><span></span></a></li><li><a class="remove" href="javascript:;"><span></span></a></li>';"image"===t.elementType&&(t.elementOptions='<span class="wysija_options image">#{options}</span>'.interpolate({options:Object.toQueryString(t)}),t.elementType="content",t.blockAlignment=Wysija.defaults.imageAlignment),"text"===t.elementType&&(t.elementOptions='<span class="wysija_options text">#{options}</span>'.interpolate({options:Object.toQueryString(t)}),t.elementType="content",t.blockAlignment=Wysija.defaults.contentAlignment),"divider"===t.elementType&&(t.elementOptions='<span class="wysija_options divider">#{options}</span>'.interpolate({options:Object.toQueryString(t)}));var s,n=$(Wysija.options.body),o=new Template('<div class="wysija_block" wysija_type="#{elementType}" wysija_new="1"><ul class="wysija_controls">'+i+"</ul>"+"#{elementOptions}"+'<div class="wysija_#{elementType} #{blockAlignment}" wysija_align="#{blockAlignment}"></div>'+"</div>");"block_placeholder"===e.identify()?(n.insert(o.evaluate(t)),s=n.childElements().last()):(e.insert({before:o.evaluate(t)}),s=e.previous(".wysija_block")),Wysija.makeSortable(),Wysija.setBlockPositions();var a=Wysija.get(s);"object"==typeof t.elementData&&a.block.image.setData(t.elementData),a.element.fire("block:insert"),void 0!==a.block.contents&&a.block.contents.isEmpty()===!1&&a.block.contents.setFocus()},Wysija.Header=Class.create({initialize:function(t){return this.element=$(t),this.block=new Wysija.Banner(this.element),this.block.setup(),this}}),Wysija.Footer=Class.create({initialize:function(t){return this.element=$(t),this.block=new Wysija.Banner(this.element),this.block.setup(),this}}),Wysija.Banner=Class.create(Wysija.Block,{image:null,constraints:{left:{minHeight:20,minWidth:20,maxWidth:600},right:{minHeight:20,minWidth:20,maxWidth:600},center:{minHeight:20,minWidth:20,maxWidth:600},full:{minHeight:20,minWidth:20,maxWidth:600}},initialize:function(t){return this.element=$(t),this.elementArea=this.element.readAttribute("wysija_type"),this.getImageContainer()&&(this.image=new Wysija.BannerImage(this.getImageContainer(),this.elementArea)),this},save:function(){var t={};return t.text=null,null!==this.image&&(t.image=this.image.save(),t.alignment=this.image.isEmpty()===!1?t.image.alignment:"center",t["static"]=this.element.hasClassName("static")),t},draw:function(){return null===this.image&&(this.element.childElements().last().insert(this.drawContainer("image")),this.image=new Wysija.BannerImage(this.getImageContainer(),this.elementArea),this.image.setOptions(this.getCustomData("image")),this.getImageContainer().insert(this.image.draw())),this},drawContainer:function(t){return'<div class="wysija_'+t+'"></div>'},getImageContainer:function(){return this.element.down(".wysija_image")},getContainer:function(){return this.element.down(".wysija_content")},minWidth:function(){return this.constraints[this.alignment].minWidth},maxWidth:function(){return this.constraints[this.alignment].maxWidth},fullWidth:function(){return this.constraints.full.maxWidth},setup:function(){null!==this.image&&this.image.setup(),this.constrainSize()},getControls:function(){return this.element.down(".wysija_controls")},remove:function(){this.image.isEmpty()&&($("wysija_"+this.elementArea).innerHTML=$("wysija_default_"+this.elementArea).innerHTML,Wysija.init())},setBlockAlignment:function(t){return info("content -> set block alignment"),this.getContainer().removeClassName("left").removeClassName("center").removeClassName("right"),this.getContainer().writeAttribute("wysija_align",t),this.getContainer().addClassName(t),null!==this.image&&(this.image.setAlignment(t),this.image.setInformation()),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("banner -> constrain size"),this.image.ratio=this.image.getRatio();var t=this.image.minSize(),e=this.image.maxSize(),i=this.image.getImageElement();i.width>e.width||i.height>e.height?(this.image.getImageContainer().writeAttribute("style",""),i.writeAttribute({width:e.width,height:e.height})):(i.width<t.width||i.height<t.height)&&(this.image.getImageContainer().writeAttribute("style",""),i.writeAttribute({width:t.width,height:t.height})),"center"===this.image.alignment?this.image.getImageContainer().setStyle({width:i.readAttribute("width")+"px"}):this.image.getImageContainer().setStyle({width:"auto"}),this.image.isEmpty()===!1&&this.image.setInformation()},getBlock:function(){return this.element.up(".wysija_"+this.elementArea)}}),Wysija.Gallery=Class.create(Wysija.Block,{items:$H(),constraints:{left:{minWidth:20,maxWidth:562},right:{minWidth:20,maxWidth:562},center:{minWidth:20,maxWidth:562}},initialize:function(t){info("gallery -> init"),this.element=$(t),this.alignment=this.getDefaultAlignment();for(var e=this.getCells(),i=this.element.identify(),s=[],n=0;e.length>n;n++)s[n]=new Wysija.GalleryImage(e[n]);return this.items.set(i,s),this},getDefaultAlignment:function(){return this.getGalleryElement().readAttribute("wysija_align")||Wysija.defaults.galleryAlignment},draw:function(){info("gallery -> draw")},setup:function(){info("gallery -> setup"),this.createResizeControls(),this.setupResizeControls(),this.setupControls(),this.setupTools(),this.setBlockAlignment(this.getDefaultAlignment()),this.items.get(this.element.id).each(function(t){t.setup()},this)},save:function(){info("gallery -> save");var t={};return t.width=this.getGalleryElement().getWidth(),t.alignment=this.alignment,t.items=[],this.items.get(this.element.id).each(function(e){t.items.push(e.save())},this),t},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.getGalleryElement().observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.showTools(),this.getResizeControls().show())}.bind(this)),this.getGalleryElement().observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideTools(),void 0!==this.getResizeControls()&&this.getResizeControls().hide())}.bind(this)),this.leftButton=this.tools.down(".alignment-left"),this.leftButton.observe("click",function(){this.setBlockAlignment("left")}.bind(this)),this.centerButton=this.tools.down(".alignment-center"),this.centerButton.observe("click",function(){this.setBlockAlignment("center")}.bind(this)),this.rightButton=this.tools.down(".alignment-right"),this.rightButton.observe("click",function(){this.setBlockAlignment("right")}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},remove:function(){this.items.unset(this.element.id),this.removeBlock()},getTools:function(){return this.getGalleryElement().down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide(),Wysija.locks.showingTools=!1,void 0!==this.information&&this.information.hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show(),Wysija.locks.showingTools=!0,void 0!==this.information&&this.information.show()},setBlockAlignment:function(t){return info("gallery -> setBlockAlignment"),this.getGalleryElement().removeClassName("left").removeClassName("center").removeClassName("right"),this.getGalleryElement().writeAttribute("wysija_align",t),this.getGalleryElement().addClassName(t),this.alignment=t,this.leftButton.removeClassName("active"),this.centerButton.removeClassName("active"),this.rightButton.removeClassName("active"),this[t+"Button"].addClassName("active"),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("gallery -> constrainSize");var t=this.getGalleryElement().getDimensions(),e=this.getCells(0).length,i=t.width-this.minWidth();this.getCells().each(function(t){t.setStyle({width:t.down("img").getWidth()+Math.floor(i/e)+"px"})})},getCells:function(t){return t=0|t,this.getGalleryElement().select(".wysija_row")[t].select(".wysija_cell")},minWidth:function(){return info("gallery -> minWidth"),this.getCells(0).inject(0,function(t,e){return t+e.down("img").getWidth()})},maxWidth:function(){return this.constraints[this.alignment].maxWidth},maxHeight:function(){return this.getCells(0).first().getHeight()},setupResizeControls:function(){return this.handle=this.getResizeControls().down(".resize-handle"),this.information=this.getResizeControls().down(".resize-info"),this.handleSize=this.handle.getDimensions(),this.draggable=new Draggable(this.handle,{onStart:this.dragStart.bind(this),snap:this.dragSnap.bind(this),change:this.dragChange.bind(this),onEnd:this.dragEnd.bind(this),starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}),this},dragStart:function(){Wysija.hideEditors(),this.dragging=!0,Wysija.locks.dragging=!0,$$("body")[0].setStyle({cursor:this.handle.getStyle("cursor")}),"right"===this.alignment&&this.getGalleryElement().insert(this.handle)},dragSnap:function(t,e){var i=this.minWidth(),s=this.maxWidth();if("right"===this.alignment){var n=this.getGalleryElement().getWidth(),o=n-t;o>s&&(t=n-s,o=s),i>o&&(t=n-i,o=i),e=Math.floor(this.maxHeight()-this.handleSize.height+this.borderWidth())}else{var o=t+this.handleSize.width;o>s&&(t=s-this.handleSize.width,o=s),i>o&&(t=i-this.handleSize.width,o=i),e=Math.floor(this.maxHeight()-this.handleSize.height+this.borderWidth())}return[t,e]},dragChange:function(){if("right"===this.alignment){var t=this.handle.positionedOffset(),e=this.getGalleryElement().getDimensions();t.left=e.width-t.left+this.borderWidth(),t.top+=this.handleSize.height+this.borderWidth(),this.getResizeControls().setStyle({left:e.width-t.left+this.borderWidth()+"px",width:t.left-2*this.borderWidth()+"px",height:t.top-2*this.borderWidth()+"px"})}else if("left"===this.alignment){var t=this.handle.positionedOffset();t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.getResizeControls().setStyle({width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})}else if("center"===this.alignment){var t=this.handle.positionedOffset(),e=this.getGalleryElement().getDimensions();t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.getResizeControls().setStyle({left:(e.width-t.left+this.borderWidth())/2+"px",width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})}},dragEnd:function(){this.dragging=!1,Wysija.locks.dragging=!1,$$("body")[0].setStyle({cursor:""});var t=this.minWidth(),e=this.getResizeControls().getWidth();t>e&&(e=t),this.setDimensions(e),this.handle.writeAttribute("style",""),"right"===this.alignment?(this.getResizeControls().insert(this.handle),this.getResizeControls().writeAttribute("style","")):"center"===this.alignment&&this.getResizeControls().writeAttribute("style",""),Wysija.hideTools(),this.getGalleryElement().fire("drag:end")},setDimensions:function(t){var t=void 0===t?this.maxWidth():t,e=this.maxHeight();this.getGalleryElement().setStyle({width:t+"px",height:e+"px"}),this.getResizeControls().setStyle({width:t+"px",height:e+"px"}),this.getResizeControls().writeAttribute("style","")
2
+ },borderWidth:function(){return 2},createResizeControls:function(){void 0===this.getResizeControls()&&this.getGalleryElement().insert('<div class="resize-controls"><span class="resize-handle"></span><span class="resize-info"></span></div>')},getResizeControls:function(){return this.getGalleryElement().down(".resize-controls")},getGalleryElement:function(){return this.element.down(".wysija_gallery")}}),Wysija.Content=Class.create(Wysija.Block,{contents:null,image:null,constraints:{left:{minHeight:20,minWidth:32,maxWidth:325},right:{minHeight:20,minWidth:32,maxWidth:325},center:{minHeight:20,minWidth:32,maxWidth:562},full:{minHeight:20,minWidth:32,maxWidth:562}},initialize:function(t){return this.element=$(t),this.getTextContainer()&&(this.contents=new Wysija.Text(this.getTextContainer())),this.getImageContainer()&&(this.image=new Wysija.Image(this.getImageContainer())),this},save:function(){var t={};return null!==this.contents&&(t.text=this.contents.save()),null!==this.image&&(t.image=this.image.save(),t.alignment=this.image.isEmpty()===!1?t.image.alignment:"center",t["static"]=this.element.hasClassName("static")),t},draw:function(){return null===this.image&&(this.element.childElements().last().insert(this.drawContainer("image")),this.image=new Wysija.Image(this.getImageContainer()),this.image.setOptions(this.getCustomData("image")),this.getImageContainer().insert(this.image.draw())),null===this.contents&&(this.element.childElements().last().insert(this.drawContainer("text")),this.contents=new Wysija.Text(this.getTextContainer()),this.contents.setOptions(this.getCustomData("text")),this.getTextContainer().insert(this.contents.draw())),this},drawContainer:function(t){return'<div class="wysija_'+t+'"></div>'},getImageContainer:function(){return this.element.down(".wysija_image")},getTextContainer:function(){return this.element.down(".wysija_text")},getContainer:function(){return this.element.down(".wysija_content")},minWidth:function(){return this.constraints[this.alignment].minWidth},maxWidth:function(){return this.isAlone()?this.constraints.full.maxWidth:this.constraints[this.alignment].maxWidth},fullWidth:function(){return this.constraints.full.maxWidth},setup:function(){info("content -> setup"),this.setupControls(),null!==this.contents&&this.contents.setup(),null!==this.image&&this.image.setup(),this.constrainSize()},getControls:function(){return this.element.down(".wysija_controls")},remove:function(){this.image.isEmpty()&&this.contents.isEmpty()&&this.removeBlock()},setBlockAlignment:function(t){return info("content -> set block alignment"),this.getContainer().removeClassName("left").removeClassName("center").removeClassName("right"),this.getContainer().writeAttribute("wysija_align",t),this.getContainer().addClassName(t),this.alignment=t,null!==this.image&&(this.image.setAlignment(t),this.image.setInformation()),null!==this.contents&&this.contents.setAlignment(t),this.constrainSize(),Wysija.autoSave(),this},constrainSize:function(){info("content -> constrain size"),this.image.ratio=this.image.getRatio();var t=this.image.minSize(),e=this.image.maxSize(),i=this.image.getImageElement();if(this.image.getImageContainer().writeAttribute("style",""),i.width>e.width||i.height>e.height?i.writeAttribute({width:e.width,height:e.height}):(i.width<t.width||i.height<t.height)&&i.writeAttribute({width:t.width,height:t.height}),this.image.isEmpty()===!1&&this.image.getImageContainer().setStyle({width:i.readAttribute("width")+"px",height:null}),this.image.isEmpty()||this.contents.isEmpty()){if(this.contents.isEmpty()){this.contents.getTextContainer().writeAttribute("style","");var s=this.image.getImageElement().getDimensions(),n=this.constraints[this.contents.alignment].maxWidth;if("center"!==this.contents.alignment&&s.width>n)this.contents.getTextPlaceholder().setStyle({width:s.width-2+"px","float":this.contents.alignment,lineHeight:null});else switch(this.contents.alignment){case"left":case"right":this.contents.getTextPlaceholder().setStyle({width:this.contents.fullWidth()-s.width-15-2+"px",height:s.height-2+"px",lineHeight:s.height-2+"px","float":"left"===this.contents.alignment?"right":"none"});break;case"center":this.contents.getTextPlaceholder().setStyle({width:this.contents.fullWidth()-2+"px",height:null,lineHeight:null})}}else this.image.isEmpty()&&(this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-2+"px",height:"auto","float":"none"}),this.image.getImageContainer().setStyle({width:"auto"}),"center"===this.contents.alignment&&i.writeAttribute("width",e.width));this.contents.getTools()&&this.contents.getTools().setStyle({right:0})}else if(this.contents.isEditing()){switch(this.contents.getTextContainer().setStyle({width:"auto","float":"none"}),this.contents.getTools()&&this.contents.getTools().setStyle({right:0}),this.contents.alignment){case"left":var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-o-15-2+"px","float":"right"});break;case"right":var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-o-15-2+"px"});break;case"center":this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()-2+"px"})}this.contents.getTextContainer().setStyle({height:"auto"})}else{if(this.contents.getTextContainer().setStyle({width:this.contents.fullWidth()+"px","float":"none"}),this.contents.getTools()&&this.contents.getTools().setStyle({right:0}),"right"===this.contents.alignment&&this.contents.getTools()&&Prototype.Browser.ie7===!1){var o=parseInt(this.image.getImageElement().readAttribute("width"));this.contents.getTools().setStyle({right:o+15+2+"px"})}if(this.contents.isEmpty()===!1){var a=this.contents.getTextArea().getHeight(),r=parseInt(this.image.getImageElement().readAttribute("height"));"right"===this.contents.alignment||"left"===this.contents.alignment?r>a?this.contents.getTextContainer().setStyle({height:r+"px"}):this.contents.getTextContainer().setStyle({height:"auto"}):20>a?this.contents.getTextContainer().setStyle({height:"20px"}):this.contents.getTextContainer().setStyle({height:"auto"})}}this.image.isEmpty()===!1&&this.image.setInformation()},getBlock:function(){return this.element.up(".wysija_block")}});var WysijaImageAbstract={initialize:function(t,e){return info("image abstract -> init"),this.element=$(t),this.elementArea=void 0===e?"block":e,this.alignment=this.getDefaultAlignment(),this.params=new Hash,this},save:function(){return this.isEmpty()?null:{src:this.getImageElement().readAttribute("src"),width:parseInt(this.getImageElement().readAttribute("width")),height:parseInt(this.getImageElement().readAttribute("height")),url:this.params.get("url"),alt:this.params.get("alt"),alignment:this.alignment,"static":this.getImageElement().hasClassName("static")}},draw:function(){return this.customDraw()+this.customTools()},customDraw:function(){void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:$("wysija_widgets_settings").down(".image").innerHTML,elementRatio:1,elementClass:"empty",elementWidth:106,elementHeight:80});var t=this.getOptions();return this.setRatio(t.get("elementRatio")||1),void 0!==this.getImageElement()&&t.set("elementId",this.getImageElement().identify()),'<img class="image_placeholder #{elementClass}" id="#{elementId}" src="#{elementSrc}" wysija_src="#{elementSrc}" height="#{elementHeight}" wysija_height="#{elementHeight}" width="#{elementWidth}" wysija_width="#{elementWidth}" alt="" />'.interpolate(t)},customTools:function(){return"empty"===this.getOptions().get("elementClass")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.alignmentLeft+'" class="alignment-left"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.alignmentCenter+'" class="alignment-center"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.alignmentRight+'" class="alignment-right"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.addImageLink+'" class="add-link"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.removeImageLink+'" class="remove-link"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.removeImage+'" class="remove"><span></span></a></li>'+"</ul>"},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.element.observe("mouseover",function(){this.isEmpty()!==!0&&Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.showTools(),this.getResizeControls().show())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideTools(),void 0!==this.getResizeControls()&&this.getResizeControls().hide())}.bind(this)),this.leftButton=this.tools.down(".alignment-left"),this.leftButton.observe("click",function(){this.setBlockAlignment("left")}.bind(this)),this.centerButton=this.tools.down(".alignment-center"),this.centerButton.observe("click",function(){this.setBlockAlignment("center")}.bind(this)),this.rightButton=this.tools.down(".alignment-right"),this.rightButton.observe("click",function(){this.setBlockAlignment("right")}.bind(this)),this.addLinkButton=this.tools.down(".add-link"),this.addLinkButton.observe("click",function(){this.addLink()}.bind(this)),this.removeLinkButton=this.tools.down(".remove-link"),this.removeLinkButton.observe("click",function(){this.removeLink()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.removeImage(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide(),Wysija.locks.showingTools=!1,void 0!==this.information&&this.information.hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show(),Wysija.locks.showingTools=!0,void 0!==this.information&&this.information.show()},addLink:function(){var t=wysijaAJAX.adminurl+"?page=wysija_campaigns&action=image_data";void 0!==this.params.get("url")&&null!==this.params.get("url")&&(t+="&url="+Wysija.encodeURIComponent(this.params.get("url"))),void 0!==this.params.get("alt")&&(t+="&alt="+Wysija.encodeURIComponent(this.params.get("alt"))),WysijaPopup.open(Wysija_i18n.addLinkTitle,t,this.setData.bind(this))},setData:function(t){"undefined"!=typeof t.url&&this.params.set("url",t.url),"undefined"!=typeof t.alt&&this.params.set("alt",t.alt),void 0!==this.params.get("url")&&null!==this.params.get("url")?this.showLink():this.hideLink(),Wysija.autoSave(),Wysija.init()},getData:function(){return{url:this.params.get("url"),alt:this.params.get("alt")}},removeLink:function(){this.params.set("url",null),this.hideLink()},showLink:function(){this.addLinkButton.writeAttribute("title",decodeURIComponent(this.params.get("url"))),this.addLinkButton.addClassName("active")},hideLink:function(){this.addLinkButton.writeAttribute("title",Wysija_i18n.addImageLink),this.addLinkButton.removeClassName("active")},setBlockAlignment:function(t){info("image -> set block alignment to : "+t);var e=Wysija.get(this.getBlock());e.block.setBlockAlignment(t)},removeImage:function(){info("image -> remove"),this.params=new Hash,this.element.fire("image:remove")},makeDroppable:function(){info("image -> make droppable"),Droppables.add(this.getImageElement().identify(),Wysija.imageDropOptions)},removeDroppable:function(){info("image -> remove droppable"),Droppables.remove(this.getImageElement().identify())},setup:function(){return info("image -> setup"),this.createControls(),this.setupControls(),this.setupTools(),this.makeDroppable(),this.getParameters(),this[this.alignment+"Button"]&&this[this.alignment+"Button"].addClassName("active"),this},getParameters:function(){info("image -> get parameters");var t=this.element.down(".wysija_params");if(void 0!==t&&0===this.params.keys().length){var e=$F(t.down('input[name="url"]'));""!==e&&(this.params.set("url",e),this.showLink());var i=$F(t.down('input[name="alt"]'));""!==i&&this.params.set("alt",i)}return this},createControls:function(){this.getImageElement().hasClassName("empty")||this.getImageElement().hasClassName("static")||void 0!==this.getResizeControls()||this.element.insert('<div class="resize-controls"><span class="resize-handle"></span><span class="resize-info"></span></div>')},setupControls:function(){return this.getImageElement().hasClassName("empty")||this.getImageElement().hasClassName("static")?void 0:(this.ratio=this.getRatio(),this.controls=this.getControls(),this.handle=this.controls.down(".resize-handle"),this.information=this.controls.down(".resize-info"),this.handleSize=this.handle.getDimensions(),this.draggable=new Draggable(this.handle,{onStart:this.dragStart.bind(this),snap:this.dragSnap.bind(this),change:this.dragChange.bind(this),onEnd:this.dragEnd.bind(this),starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}),this)},getImageContainer:function(){return this.element},getImageElement:function(){return this.element.down("img")},getResizeControls:function(){return this.element.down(".resize-controls")},minSize:function(){var t=this.minWidth();return{width:t,height:Math.floor(t/this.ratio)}},maxSize:function(){var t=this.maxWidth();return{width:t,height:Math.floor(t/this.ratio)}},getRatio:function(){return this.getImageContainer().readAttribute("wysija_ratio")||(1e3*(this.getImageElement().width/this.getImageElement().height)).round()/1e3},setRatio:function(t){return this.element.writeAttribute("wysija_ratio",t),this},isEmpty:function(){return this.getImageElement().hasClassName("empty")},setEmpty:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("empty")},isAlone:function(){return this.getImageContainer().hasClassName("alone")},setAlone:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("alone")},setAlignment:function(t){return this.isEmpty()?void 0:(info("image -> setAlignment = "+t),this.alignment=t,this.leftButton.removeClassName("active"),this.centerButton.removeClassName("active"),this.rightButton.removeClassName("active"),this.getResizeControls().writeAttribute("style",""),this[t+"Button"].addClassName("active"),this)},getDefaultAlignment:function(){return this.element.up(".wysija_content").readAttribute("wysija_align")||Wysija.defaults.imageAlignment},dragStart:function(){Wysija.hideEditors(),this.dragging=!0,Wysija.locks.dragging=!0,$$("body")[0].setStyle({cursor:this.handle.getStyle("cursor")}),this.imageDimensions=this.getImageElement().getDimensions(),this.controls.setStyle({width:this.imageDimensions.width+"px",height:this.imageDimensions.height+"px"});var t=Wysija.get(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer"));t.block.element.addClassName("dragging"),"right"===this.alignment&&this.element.insert(this.handle)},dragSnap:function(t,e){var i=this.constraints[this.alignment].minWidth,s=this.constraints[this.alignment].maxWidth,n=this.constraints[this.alignment].minHeight;if(this.isAlone()&&(s=this.constraints.full.maxWidth),"right"===this.alignment){var o=this.imageDimensions.width,a=o-t;a>s&&(t=o-s,a=s),i>a&&(t=o-i,a=i),e=Math.max(n,Math.floor(a/this.ratio)),e===n&&(t=o-Math.floor(n*this.ratio)),e-=this.handleSize.height}else{var a=t+this.handleSize.width;a>s&&(t=s-this.handleSize.width,a=s),i>a&&(t=i-this.handleSize.width,a=i),e=Math.max(n,Math.floor(a/this.ratio)),e===n&&(t=Math.floor(n*this.ratio)-this.handleSize.height),e-=this.handleSize.height}return[t-this.borderWidth(),e-this.borderWidth()]},dragChange:function(){var t=this.handle.positionedOffset();"right"===this.alignment?(t.left=this.imageDimensions.width-t.left,t.top+=this.handleSize.height,this.controls.setStyle({left:Math.floor(this.imageDimensions.width-t.left)+this.borderWidth()+"px",width:t.left-2*this.borderWidth()+"px",height:t.top+"px"}),this.handle.setStyle({left:parseInt(this.handle.getStyle("left"))+this.borderWidth()+"px",top:parseInt(this.handle.getStyle("top"))+this.borderWidth()+"px"})):"left"===this.alignment?(t.left+=this.handleSize.width,t.top+=this.handleSize.height,this.controls.setStyle({width:t.left+"px",height:t.top+"px"})):"center"===this.alignment&&(t.left+=this.handleSize.width+this.borderWidth(),t.top+=this.handleSize.height+this.borderWidth(),this.controls.setStyle({left:Math.floor((this.imageDimensions.width-t.left)/2)+"px",width:t.left-this.borderWidth()+"px",height:t.top-this.borderWidth()+"px"})),this.setInformation(!0)},dragEnd:function(){this.dragging=!1,Wysija.locks.dragging=!1;var t=Wysija.get(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer"));t.block.element.removeClassName("dragging"),void 0!==t.block.contents&&t.block.contents.isEmpty()&&t.block.contents.getTextArea().setStyle({height:""}),$$("body")[0].setStyle({cursor:""});var e=this.constraints[this.alignment].minWidth,i=(this.constraints[this.alignment].minHeight,this.controls.getWidth()),s=this.controls.getHeight();e>i&&(i=e),this.setDimensions(i,s),this.handle.writeAttribute("style",""),"right"===this.alignment?(this.controls.insert(this.handle),this.controls.writeAttribute("style",""),this.element.writeAttribute("style",""),this.element.setStyle({height:s+"px"})):"center"===this.alignment?(this.controls.writeAttribute("style",""),this.element.setStyle({width:i+"px",height:s+"px"})):(this.element.writeAttribute("style",""),this.element.setStyle({height:s+"px"})),Wysija.hideTools(),this.element.fire("drag:end")},setDimensions:function(t,e){var t=void 0===t?this.maxWidth():parseInt(t,10),e=void 0===e?(1e3*(t/this.ratio)).round()/1e3:parseInt(e,10),i=this.getImageElement();i.writeAttribute("width",t),i.writeAttribute("height",e),this.controls.setStyle({width:t-this.borderWidth()+"px",height:e-this.borderWidth()+"px"})},borderWidth:function(){return 2},getControls:function(){return this.element.down(".resize-controls")},getInformation:function(){return this.controls.down(".resize-info")},setInformation:function(t){if(void 0===t&&(t=!1),this.controls=this.getControls(),void 0!==this.controls&&(this.information=this.getInformation(),void 0!==this.information)){if(t)var e=this.controls.getDimensions();else var e=this.element.getDimensions();void 0!==this.information&&this.information.update("#{width} x #{height}".interpolate(e))}}};Wysija.Image=Class.create(Wysija.Content,WysijaImageAbstract),Wysija.BannerImage=Class.create(Wysija.Banner,WysijaImageAbstract);var WysijaGalleryItemAbstract={initialize:function(t){return info("gallery item -> init"),this.element=$(t),this.params=new Hash,this},save:function(){return this.isEmpty()?null:{src:this.getImageElement().readAttribute("src"),width:parseInt(this.getImageElement().readAttribute("width")),height:parseInt(this.getImageElement().readAttribute("height")),url:this.params.get("url"),alt:this.params.get("alt"),cellWidth:parseInt(this.getImageContainer().getWidth()),cellHeight:parseInt(this.getImageContainer().getHeight())}},draw:function(){return this.customDraw()+this.customTools()},customDraw:function(){void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:"",elementRatio:1.48,elementClass:"empty",elementHeight:135,elementWidth:200});var t=this.getOptions();return void 0!==this.getImageElement()&&t.set("elementId",this.getImageElement().identify()),'<img class="image_placeholder #{elementClass}" id="#{elementId}" src="#{elementSrc}" height="#{elementHeight}" width="#{elementWidth}" />'.interpolate(t)},customTools:function(){return"empty"===this.getOptions().get("elementClass")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.addImageLink+'" class="add-link"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.removeImageLink+'" class="remove-link"><span></span></a></li>'+'<li><a href="javascript:;" title="'+Wysija_i18n.removeImage+'" class="remove"><span></span></a></li>'+"</ul>"},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.addLinkButton=this.tools.down(".add-link"),this.addLinkButton.observe("click",function(){this.addLink()}.bind(this)),this.removeLinkButton=this.tools.down(".remove-link"),this.removeLinkButton.observe("click",function(){this.removeLink()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){this.getTools().hide(),Wysija.locks.showingTools=!1},showTools:function(){this.getTools().show(),Wysija.locks.showingTools=!0},remove:function(){info("gallery item -> remove"),this.element.fire("image:remove")},setup:function(){return info("gallery item -> setup"),this.setupControls(),this.setupTools(),this.getParameters(),this},getParameters:function(){info("gallery item -> get parameters");var t=this.element.down(".wysija_params");if(void 0!==t&&0===this.params.keys().length){var e=$F(t.down('input[name="url"]'));""!=e&&this.params.set("url",e);var i=$F(t.down('input[name="alt"]'));""!=i&&this.params.set("alt",i)}return this},getImageContainer:function(){return this.element},getImageElement:function(){return this.element.down("img")},isEmpty:function(){return this.getImageElement().hasClassName("empty")},setEmpty:function(t){this.getImageContainer()[t?"addClassName":"removeClassName"]("empty")},setPosition:function(t){this.element.writeAttribute("wysija_position",t)}};Wysija.GalleryImage=Class.create(Wysija.Gallery,WysijaGalleryItemAbstract);var WysijaTextAbstract={initialize:function(t){return this.element=$(t),this.alignment=this.getDefaultAlignment(),this},save:function(){return this.isEmpty()?null:{value:Base64.encode(this.getTextArea().innerHTML)}},draw:function(){return info("text -> draw"),this.customDraw()+this.customTools()},customDraw:function(){info("text -> custom draw");var t=this.getOptions();return void 0!==this.getTextArea()&&t.set("elementId",this.getTextArea().identify()),void 0===t.get("elementText")?(t.set("placeholderText",Wysija_i18n.drop_block_here),'<div class="text_placeholder empty" id="#{elementId}">#{placeholderText}</div>'.interpolate(this.getOptions())):'<div class="editable" id="#{elementId}">#{elementText}</div>'.interpolate(this.getOptions())},makeDroppable:function(){this.isDroppable()&&Droppables.add(this.getTextArea().identify(),Wysija.textDropOptions)},removeDroppable:function(){Droppables.remove(this.getTextArea().identify())},hasContent:function(){return void 0!==this.getTextArea()},isDroppable:function(){return this.getTextArea().hasClassName("text_placeholder")},isEmpty:function(){return this.getTextArea().hasClassName("empty")},isEditing:function(){return this.element.hasClassName("editing")},setup:function(){info("text -> setup"),this.setupEditor(),this.setAlignment(this.getDefaultAlignment()),this.setupTools(),this.makeDroppable()},setAlignment:function(t){return info("text -> setAlignment = "+t),this.alignment=t,this.isEmpty()===!1&&this.disableEditor(),this},getDefaultAlignment:function(){return this.element.up(".wysija_content").readAttribute("wysija_align")||Wysija.defaults.contentAlignment},setBlockAlignment:function(t){info("text -> set block alignment to : "+t);var e=Wysija.get(this.getBlock());e.block.setBlockAlignment(t)},setupEditor:function(){info("text -> setupEditor"),this.getTextContainer().observe("click",this.enableEditor.bind(this))},customTools:function(){return void 0===this.getOptions().get("elementText")?"":'<ul class="wysija_tools"><li><a href="javascript:;" title="'+Wysija_i18n.removeText+'" class="remove"><span></span></a></li>'+"</ul>"},setupTools:function(){this.tools=this.getTools(),this.tools&&(this.element.observe("mouseover",function(){this.isEditing()!==!0&&Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&this.showTools()}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.selectingColor!==!0&&this.hideTools()}.bind(this)),this.removeButton=this.tools.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)))},getTools:function(){return this.element.down(".wysija_tools")},hideTools:function(){void 0!==this.getTools()&&this.getTools().hide()},showTools:function(){void 0!==this.getTools()&&this.getTools().show()},remove:function(){info("text -> remove"),this.element.fire("text:remove")},enableEditor:function(){this.isEditing()||(info("text -> enableEditor"),Wysija.hideEditors(),this.element.addClassName("editing"),tinyMCE.execCommand("mceAddControl",!1,this.getTextArea().identify()),this.element.fire("editor:enable"))},disableEditor:function(){this.isEditing()!==!1&&(info("text -> disableEditor"),this.element.removeClassName("editing"),tinyMCE.execCommand("mceRemoveControl",!1,this.getTextArea().identify()),this.element.fire("editor:disable"))},setFocus:function(){info("text -> setFocus"),this.enableEditor()},getTextContainer:function(){return this.element},getTextArea:function(){return this.element.down(".editable")||this.getTextPlaceholder()},getTextPlaceholder:function(){return this.element.down(".text_placeholder")},getTextEditor:function(){return tinymce.get(this.getTextArea().identify())},isAlone:function(){return this.getTextContainer().hasClassName("alone")},setAlone:function(t){this.getTextContainer()[t?"addClassName":"removeClassName"]("alone")}};Wysija.Text=Class.create(Wysija.Content,WysijaTextAbstract),Wysija.Divider=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this.setOptions(this.getCustomData("divider")),this},save:function(){return void 0===this.getDivider()?null:{src:this.getDivider().readAttribute("src"),width:parseInt(this.getDivider().readAttribute("width")),height:parseInt(this.getDivider().readAttribute("height"))}},draw:function(){this.element.childElements().last().insert(this.customDraw())},customDraw:function(){return info("divider -> custom draw"),void 0===this.getOptions().get("elementSrc")&&this.setOptions({elementSrc:"",elementHeight:1,elementWidth:564}),'<img class="divider" src="#{elementSrc}" height="#{elementHeight}" width="#{elementWidth}" />'.interpolate(this.getOptions())},customControls:function(){return""},setup:function(){this.setupControls()},getContainer:function(){return this.element.down(".wysija_divider")},getDivider:function(){return this.getContainer().down("img")}}),Wysija.Raw=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this.setOptions({elementRaw:""}),this},save:function(){return void 0===this.getRaw()?null:{raw:Base64.encode(this.getRaw().innerHTML)}},draw:function(){this.element.childElements().last().insert(this.customDraw())},customDraw:function(){info("raw -> custom draw");var t=this.getOptions();return void 0!==this.getRaw()&&t.set("elementId",this.getRaw().identify()),void 0===t.get("elementRaw")?'<div class="raw empty" id="#{elementId}"></div>'.interpolate(this.getOptions()):'<div class="raw" id="#{elementId}">#{elementRaw}</div>'.interpolate(this.getOptions())},customControls:function(){return""},setup:function(){this.setupControls()},getContainer:function(){return this.element.down(".wysija_raw")},getRaw:function(){return this.getContainer().down(".raw")}}),Wysija.Post=Class.create(Wysija.Block,{initialize:function(t){return info("post -> init"),this.element=$(t),this},draw:function(){WysijaPopup.open(Wysija_i18n.articleSelectionTitle,WysijaPopup.formatURI(wysijaAJAX.adminurl,"page=wysija_campaigns&action=articles"),this.success.bind(this),this.cancel.bind(this))},success:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}}),Wysija.AutoPost=Class.create(Wysija.Block,{initialize:function(t){return info("autopost -> init"),this.element=$(t),this},draw:function(){info("autopost -> draw")},setup:function(){info("autopost -> setup"),this.setupControls()},save:function(){info("autopost -> save");var t={};return this.getParameters(),t.params=this.params,t},getParameters:function(){info("autopost -> get parameters"),this.params=[];var t=this.element.down(".wysija_params");return void 0!==t&&t.select("input").each(function(t){this.params.push($H({key:t.name,value:t.value}))}.bind(this)),this},getControls:function(){return this.element.down(".wysija_controls")},setupControls:function(){return this.controls=this.getControls(),this.controls&&(this.element.observe("mouseover",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&Wysija.locks.showingTools!==!0&&(this.element.addClassName("hover"),this.showControls(),this.element.down(".wysija_settings").show())}.bind(this)),this.element.observe("mouseout",function(){Wysija.locks.dragging!==!0&&Wysija.locks.selectingColor!==!0&&(this.hideControls(),this.element.down(".wysija_settings").hide())}.bind(this)),this.removeButton=this.controls.down(".remove"),this.removeButton.observe("click",function(){this.remove(),this.removeButton.stopObserving("click")}.bind(this)),this.settingsButton=this.element.down(".settings"),this.settingsButton.observe("click",function(){this.editSettings()}.bind(this))),this},editSettings:function(){this.getParameters();var t=this.formatParameters();WysijaPopup.open(Wysija_i18n.autoPostSettingsTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=autopost&"+t,this.callback.bind(this))},callback:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},formatParameters:function(){var t=["autopost_count="+$$(".wysija_auto-post").length,"autopost_type="+$("wysija_widgets_settings").down(".autopost").innerHTML];return void 0!==this.params&&this.params.length>0&&(this.params.each(function(e){t.push(e.get("key")+"="+e.get("value"))}),t=t.join("&")),t},loadContent:function(){var t=this.element.previousSiblings();if(t.length>0){var e=[];t.each(function(t){"auto-post"===t.readAttribute("wysija_type")&&void 0!==t.down('input[name="post_ids"]')&&e.push(t.down('input[name="post_ids"]').value)}),e.length>0&&(e=e.join(","))}this.getParameters();var i=this.formatParameters();void 0!==e&&e.length>0&&(i+="&exclude="+e);var s=this;wysijaAJAX.task="load_auto_post",wysijaAJAX.wysijaData=i,new Ajax.Request(wysijaAJAX.ajaxurl,{method:"post",asynchronous:!1,parameters:wysijaAJAX,onSuccess:function(t){s.getAutoPostElement().update(Base64.decode(t.responseJSON.result)),Wysija.setSettingsPosition.delay(1)},onFailure:function(){}})},remove:function(){info("autopost remove"),this.removeBlock(function(){Wysija.initAutoPost(),Wysija.setBackgroundColors()})},getAutoPostElement:function(){return this.element.down(".wysija_auto-post")},getSettings:function(){return this.element.down(".wysija_settings")}}),Wysija.PopupAutoPost=Class.create(Wysija.Block,{initialize:function(t){return this.element=$(t),this},draw:function(){var t=["autopost_count="+parseInt($$(".wysija_auto-post").length+1),"autopost_type="+$("wysija_widgets_settings").down(".autopost").innerHTML].join("&");WysijaPopup.open(Wysija_i18n.autoPostSettingsTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=autopost&"+t,this.success.bind(this),this.cancel.bind(this))},success:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}}),Wysija.PopupBookmark=Class.create(Wysija.Block,{initialize:function(t){return info("popup bookmark -> init"),this.element=$(t),this},draw:function(){var t="theme="+$("wysija_widgets_settings").down(".theme").innerHTML;WysijaPopup.open(Wysija_i18n.bookmarkSelectionTitle,wysijaAJAX.adminurl+"?page=wysija_campaigns&action=bookmarks&"+t,this.success.bind(this),this.cancel.bind(this))},success:function(t){Wysija.get(this.element).block.replaceBlock(Base64.decode(t)),Wysija.init()},cancel:function(){Wysija.get(this.element).block.removeBlock(!1)}});var WysijaPopup={initialized:!1,opened:!1,locked:!1,title:null,url:null,popupWidth:null,popupHeight:null,onSuccess:null,onCancel:null,setSize:function(t,e){return WysijaPopup.popupWidth=t,WysijaPopup.popupHeight=e,this},formatURI:function(t,e){return-1===t.indexOf("?")?t+"?"+e:t+"&"+e},init:function(){if(WysijaPopup.initialized===!1){info("init popup");var t='<div id="wysija_popup_overlay"></div><div id="wysija_popup"><div id="wysija_popup_title"><h3></h3><a id="wysija_popup_close" href="javascript:;"></a></div><div id="wysija_popup_content" class="clearfix"><iframe id="wysija_popup_iframe" marginheight="0" marginwidth="0" frameborder="0"></iframe></div></div>';
3
+ $$("body")[0].insert(t),$("wysija_popup").setStyle({visibility:"hidden"}),WysijaPopup.hideLoading(),WysijaPopup.hideOverlay(),$("wysija_popup_close").observe("click",WysijaPopup.cancel),$("wysija_popup_overlay").observe("click",function(t){"wysija_popup_overlay"===t.target.id&&WysijaPopup.cancel()}),WysijaPopup.initialized=!0,$("wysija_popup_iframe").observe("load",function(){null!==$(this).readAttribute("src")&&setTimeout(function(){WysijaPopup.opened=!0,WysijaPopup.setDimensions(),WysijaPopup.hideLoading(),WysijaPopup.showOverlay(),setTimeout(function(){$("wysija_popup").setStyle({visibility:"visible"})},101)},0)})}},lock:function(){WysijaPopup.locked=!0},unlock:function(){WysijaPopup.locked=!1},isLocked:function(){return WysijaPopup.locked},setPosition:function(){if(WysijaPopup.init(),WysijaPopup.opened!==!1){var t=$("wysija_popup").getDimensions(),e=document.viewport.getDimensions(),i=parseInt(Wysija.scroll.top+e.height/2-t.height/2-15,10),s=parseInt(Wysija.scroll.left+e.width/2-t.width/2,10);Wysija.scroll.top>i&&(i=parseInt(Wysija.scroll.top,10)),Wysija.scroll.left>s&&(s=parseInt(Wysija.scroll.left,10)),$("wysija_popup").setStyle({top:i+"px",left:s+"px"})}},setDimensions:function(){if(WysijaPopup.opened!==!1){var t=$("wysija_popup_iframe");if(null!==t){t.doc=null,t.contentDocument?t.doc=t.contentDocument:t.contentWindow?t.doc=t.contentWindow.document:t.document&&(t.doc=t.document);var e=0,i=0,s=document.viewport.getDimensions();setTimeout(function(){if($("wysija_popup_iframe").writeAttribute("width",null),$("wysija_popup_iframe").writeAttribute("height",null),null===WysijaPopup.popupWidth||null===WysijaPopup.popupHeight){var n=null;n=t.doc.querySelectorAll(".popup_content").length>0?WysijaPopup.getElementSize(t.doc.querySelectorAll(".popup_content")[0]):WysijaPopup.getElementSize(t.doc.getElementsByClassName(".popup_content")[0]),i=n.width,e=n.height}else i=WysijaPopup.popupWidth,e=WysijaPopup.popupHeight;e+50>s.height&&(e=s.height-50),$("wysija_popup").setStyle({width:i+"px",height:e+20+"px"}),$("wysija_popup_iframe").writeAttribute("width",i),$("wysija_popup_iframe").writeAttribute("height",e+20),WysijaPopup.setPosition()},100)}}},getElementSize:function(t){var e=t.currentStyle||window.getComputedStyle(t),i=t.offsetWidth;i+=parseInt(e.marginLeft),i+=parseInt(e.marginRight);var s=t.offsetHeight;return s+=parseInt(e.marginTop),s+=parseInt(e.marginBottom),{width:i,height:s}},loadContent:function(t,e){$("wysija_popup_iframe").writeAttribute("src",e),$("wysija_popup_title").down("h3").update(t)},showOverlay:function(){$("wysija_popup_overlay").setStyle({visibility:"visible"})},showLoading:function(){$("wysija_popup_overlay").addClassName("loading")},hideOverlay:function(){$("wysija_popup_overlay").setStyle({visibility:"hidden"})},hideLoading:function(){$("wysija_popup_overlay").removeClassName("loading")},open:function(t,e,i,s){WysijaPopup.init(),WysijaPopup.showLoading(),WysijaPopup.showOverlay(),void 0!==i&&(WysijaPopup.onSuccess=i),void 0!==s&&(WysijaPopup.onCancel=s),WysijaPopup.loadContent(t,e)},success:function(t){null!==WysijaPopup.onSuccess&&WysijaPopup.onSuccess(t),WysijaPopup.close()},cancel:function(t){null!==WysijaPopup.onCancel&&WysijaPopup.onCancel(t),WysijaPopup.close()},close:function(){return WysijaPopup.isLocked()===!0?!1:($("wysija_popup").writeAttribute("style",""),$("wysija_popup").setStyle({visibility:"hidden"}),WysijaPopup.hideLoading(),WysijaPopup.hideOverlay(),$("wysija_popup_iframe").writeAttribute("src",null),$("wysija_popup_iframe").writeAttribute("height",null),$("wysija_popup_iframe").writeAttribute("width",null),WysijaPopup.onSuccess=null,WysijaPopup.onCancel=null,WysijaPopup.popupWidth=null,WysijaPopup.popupHeight=null,WysijaPopup.opened=!1,!1)}};Wysija.DraggableItem=Class.create({initialize:function(t){this.elementType=$(t).readAttribute("wysija_type"),this.element=$(t).down()||$(t),this.clone=null,t.hasClassName("wysija_item")===!1&&(this.elementType="block_image")},STYLES:new Template("position: absolute; top: #{top}px; left: #{left}px;"),cloneElement:function(){var t=this.element.clone(),e=this.element.cumulativeOffset();if(this.element.hasClassName("wysija_item")){var i=this.getList(),s=this.STYLES.evaluate({top:e.top-i.scrollTop,left:e.left-i.scrollLeft});t.addClassName("wysija_widget"),t.addClassName(this.elementType)}else{var s=this.STYLES.evaluate({top:e.top,left:e.left,width:this.element.getWidth()+"px",height:this.element.getHeight()+"px"});t.writeAttribute("wysija_height",this.element.readAttribute("wysija_height")),t.writeAttribute("wysija_width",this.element.readAttribute("wysija_width")),t.writeAttribute("wysija_src",this.element.readAttribute("wysija_src")),this.element.hasClassName("image_placeholder")&&t.writeAttribute("wysija_parent",(this.element.up(".wysija_block")||this.element.up(".wysija_header")||this.element.up(".wysija_footer")).identify()),t.addClassName("wysija_widget image")}return t.setStyle(s),"image"===this.elementType||"block_image"===this.elementType?t.writeAttribute({elementRatio:this.calculateRatio(),wysija_type:"image"}):t.innerHTML=this.element.innerHTML,t},getOffset:function(){return this.element.offsetTop-this.getList().scrollTop},getList:function(){return this.element.up("ul")},insert:function(){$$("body")[0].insert(this.clone)},onMousedown:function(t){if("block_image"!==this.elementType||"img"===this.element.tagName.toLowerCase()&&"span"!==t.target.tagName.toLowerCase()){null===this.clone&&(this.clone=this.cloneElement(),this.insert());var e=new Draggable(this.clone,{scroll:window,isImage:!1,onStart:function(t,e){this.isImage=t.element.hasClassName("wysija_widget image"),this.isImage===!0&&t.element.setStyle({left:e.pageX+"px",top:e.pageY+"px"}),Wysija.locks.dragging=!0,Wysija.hideTools(),Wysija.hideBlockControls(),Droppables.togglePlaceholders(t,e)},onDrag:function(t,e){Droppables.togglePlaceholders(t,e)},snap:function(t,e,i){return this.isImage===!0?[t+i.offset[0],e+i.offset[1]]:[t,e]},onEnd:function(t){t.destroy(),t.element.remove(),Wysija.locks.dragging=!1,Droppables.hidePlaceholders()},starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction});return e.initDrag(t),e.startDrag(t),e}},calculateRatio:function(){return(1e3*(this.element.readAttribute("wysija_width")/this.element.readAttribute("wysija_height"))).round()/1e3}}),Object.extend(Wysija.DraggableItem,Observable).observe('a[class="wysija_item"], .wysija_image'),Wysija.ImagePreview=Class.create({initialize:function(t){this.element=$(t)},onMouseover:function(){if(Wysija.locks.dragging!==!0){var t=this.element.down("img").clone();if(""!==t.readAttribute("wysija_src")){var e=parseInt(t.readAttribute("wysija_height"),10),i=parseInt(t.readAttribute("wysija_width"),10),s=(1e3*(i/e)).round()/1e3;i>275&&(i=275),e=(i/s).round(),t.writeAttribute("src",t.readAttribute("wysija_src")),$("wj_images_preview").insert(t),$("wj_images_preview").down("img").writeAttribute({width:i,height:e}),$("wj_images_preview").show()}}},onMouseout:function(){$("wj_images_preview").update(""),$("wj_images_preview").hide()}}),Wysija.ThemePreview=Class.create({initialize:function(t){this.element=$(t)},onMouseover:function(){if(Wysija.locks.dragging!==!0){var t=this.element.down("img").clone();if(""!==t.readAttribute("wysija_src")){var e=t.readAttribute("wysija_height"),i=t.readAttribute("wysija_width"),s=(1e3*(i/e)).round()/1e3;i>275&&(i=275),e=(i/s).round(),t.writeAttribute("src",t.readAttribute("wysija_src")),$("wj_themes_preview").insert(t),$("wj_themes_preview").down("img").writeAttribute("width",i),$("wj_themes_preview").down("img").writeAttribute("height",e),$("wj_themes_preview").show()}}},onMouseout:function(){$("wj_themes_preview").update(""),$("wj_themes_preview").hide()}}),Object.extend(Wysija.ThemePreview,Observable).observe(".wj_themes li a"),Wysija.TextLinks=Class.create({initialize:function(t){this.element=$(t)},onClick:function(t){return t.stop(),!1}}),Object.extend(Wysija.TextLinks,Observable).observe(".editable a"),window.document.observe("mousedown",function(t){if(tinymce.editors.length>0){if("mceModalBlocker"===t.target.id)return;if(t.target.hasClassName("mceClose"))return;void 0===t.target.up(".wysija_text")&&void 0===t.target.up(".editable")&&t.target.hasClassName("mceText")===!1&&(Wysija.hideEditors(),Wysija.autoSave())}}),document.on("image:drop",function(t,e){var i,s=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i=t.memo.elementData,delete t.memo.elementData,s.block.image.removeDroppable(),s.block.image.setOptions(t.memo),s.block.getImageContainer().writeAttribute("style",""),s.block.getImageContainer().update(s.block.image.draw()),s.block.image.setup(),"object"==typeof i&&s.block.image.setData(i),void 0===s.block.contents?s.block.image.setAlone(!0):(s.block.contents.setAlone(s.block.image.isEmpty()),s.block.image.setAlone(s.block.contents.isEmpty()),s.block.setBlockAlignment(s.block.contents.getDefaultAlignment())),Wysija.hideTools(),s.block.image.setEmpty(!1),s.block.constrainSize(),Wysija.hideTools(),Wysija.autoSave()}),document.on("text:drop",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.contents.removeDroppable(),i.block.contents.setOptions(t.memo),i.block.getTextContainer().update(i.block.contents.draw()),i.block.contents.setup(),i.block.image.isEmpty()===!1?(i.block.image.setAlone(!1),i.block.setBlockAlignment(i.block.image.alignment)):i.block.contents.setAlone(!0),i.block.constrainSize(),i.block.contents.setFocus(),Wysija.hideControls(),Wysija.hideTools(),Wysija.autoSave()}),document.on("image:remove",function(t,e){var i=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i.block.image.hideTools(),i.block.image.removeDroppable(),i.block.image.setOptions({elementSrc:void 0}),i.block.image.element.update(i.block.image.draw()),i.block.image.makeDroppable(),i.block.image.setEmpty(!0),void 0!==i.block.contents&&i.block.contents.isEmpty()===!1&&i.block.contents.setAlone(!0),i.block.constrainSize(),i.block.remove()}),document.on("text:remove",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.contents.getTextContainer().stopObserving("click"),i.block.contents.removeDroppable(),i.block.contents.setOptions({elementText:void 0}),i.block.contents.element.update(i.block.contents.draw()),i.block.contents.makeDroppable(),i.block.image.isEmpty()===!1&&i.block.image.setAlone(!0),i.block.constrainSize(),i.block.remove()}),document.on("editor:enable",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.constrainSize()}),document.on("editor:disable",function(t,e){var i=Wysija.get(e.up(".wysija_block"));i.block.constrainSize()}),document.on("block:insert",function(t,e){var i=Wysija.get(e);"content"===i.elementType&&(i.block.image.setAlone(i.block.contents.isEmpty()),i.block.contents.setAlone(i.block.image.isEmpty()),i.block.image.setEmpty(i.block.image.isEmpty()),i.block.constrainSize(),Wysija.hideTools())}),document.on("drag:end",function(t,e){var i=Wysija.get(e.up(".wysija_block")||e.up(".wysija_header")||e.up(".wysija_footer"));i.block.constrainSize()}),document.observe("dom:loaded",function(){$("wysija_toggle_images").observe("click",function(){return Wysija.toggleImages()===!0?this.addClassName("on").removeClassName("off"):this.addClassName("off").removeClassName("on"),!1})});
languages/wysija-newsletters-ach.mo CHANGED
Binary file
languages/wysija-newsletters-af.mo CHANGED
Binary file
languages/wysija-newsletters-ar.mo CHANGED
Binary file
languages/wysija-newsletters-bg_BG.mo CHANGED
Binary file
languages/wysija-newsletters-bn_BD.mo CHANGED
Binary file
languages/wysija-newsletters-bs_BA.mo CHANGED
Binary file
languages/wysija-newsletters-ca.mo CHANGED
Binary file
languages/wysija-newsletters-ca@valencia.mo CHANGED
Binary file
languages/wysija-newsletters-ca_ES.mo CHANGED
Binary file
languages/wysija-newsletters-cs_CZ.mo CHANGED
Binary file
languages/wysija-newsletters-da_DK.mo CHANGED
Binary file
languages/wysija-newsletters-de_AT.mo CHANGED
Binary file
languages/wysija-newsletters-de_DE.mo CHANGED
Binary file
languages/wysija-newsletters-el.mo CHANGED
Binary file
languages/wysija-newsletters-en_GB.mo CHANGED
Binary file
languages/wysija-newsletters-en_US.mo CHANGED
Binary file
languages/wysija-newsletters-es.mo CHANGED
Binary file
languages/wysija-newsletters-es_419.mo CHANGED
Binary file
languages/wysija-newsletters-es_AR.mo CHANGED
Binary file
languages/wysija-newsletters-es_ES.mo CHANGED
Binary file
languages/wysija-newsletters-et.mo CHANGED
Binary file
languages/wysija-newsletters-eu.mo CHANGED
Binary file
languages/wysija-newsletters-eu_ES.mo CHANGED
Binary file
languages/wysija-newsletters-fa.mo CHANGED
Binary file
languages/wysija-newsletters-fa_IR.mo CHANGED
Binary file
languages/wysija-newsletters-fi.mo CHANGED
Binary file
languages/wysija-newsletters-fr_FR.mo CHANGED
Binary file
languages/wysija-newsletters-ga.mo CHANGED
Binary file
languages/wysija-newsletters-gl_ES.mo CHANGED
Binary file
languages/wysija-newsletters-he_IL.mo CHANGED
Binary file
languages/wysija-newsletters-hi_IN.mo CHANGED
Binary file
languages/wysija-newsletters-hr_HR.mo CHANGED
Binary file
languages/wysija-newsletters-hu_HU.mo CHANGED
Binary file
languages/wysija-newsletters-hy_AM.mo CHANGED
Binary file
languages/wysija-newsletters-id.mo CHANGED
Binary file
languages/wysija-newsletters-it_IT.mo CHANGED
Binary file
languages/wysija-newsletters-ja.mo CHANGED
Binary file
languages/wysija-newsletters-ko_KR.mo CHANGED
Binary file
languages/wysija-newsletters-lt_LT.mo CHANGED
Binary file
languages/wysija-newsletters-lv.mo CHANGED
Binary file
languages/wysija-newsletters-lv_LV.mo CHANGED
Binary file
languages/wysija-newsletters-mk_MK.mo CHANGED
Binary file
languages/wysija-newsletters-my_MM.mo CHANGED
Binary file
languages/wysija-newsletters-nb_NO.mo CHANGED
Binary file
languages/wysija-newsletters-nl_NL.mo CHANGED
Binary file
languages/wysija-newsletters-oc.mo CHANGED
Binary file
languages/wysija-newsletters-pl_PL.mo CHANGED
Binary file
languages/wysija-newsletters-pt_BR.mo CHANGED
Binary file
languages/wysija-newsletters-pt_PT.mo CHANGED
Binary file
languages/wysija-newsletters-ro_RO.mo CHANGED
Binary file
languages/wysija-newsletters-ru_RU.mo CHANGED
Binary file
languages/wysija-newsletters-sk_SK.mo CHANGED
Binary file
languages/wysija-newsletters-sl_SI.mo CHANGED
Binary file
languages/wysija-newsletters-sq.mo CHANGED
Binary file
languages/wysija-newsletters-sr@latin.mo CHANGED
Binary file
languages/wysija-newsletters-sr_RS.mo CHANGED
Binary file
languages/wysija-newsletters-sr_RS@latin.mo CHANGED
Binary file
languages/wysija-newsletters-sv_SE.mo CHANGED
Binary file
languages/wysija-newsletters-tr_TR.mo CHANGED
Binary file
languages/wysija-newsletters-uk.mo CHANGED
Binary file
languages/wysija-newsletters-ur_PK.mo CHANGED
Binary file
languages/wysija-newsletters-vi.mo CHANGED
Binary file
languages/wysija-newsletters-zh_CN.mo CHANGED
Binary file
languages/wysija-newsletters-zh_HK.mo CHANGED
Binary file
languages/wysija-newsletters-zh_TW.mo CHANGED
Binary file
models/user.php CHANGED
@@ -153,17 +153,22 @@ class WYSIJA_model_user extends WYSIJA_model{
153
  static $result_user;
154
  if(!empty($result_user)) return $result_user;
155
  $this->getFormat = OBJECT;
156
- $result_user = $this->getOne(false,array('wpuser_id'=>WYSIJA::wp_get_userdata('ID')));
 
 
 
 
 
157
 
158
  if(!$result_user){
159
  $this->getFormat = OBJECT;
160
  $result_user = $this->getOne(false,array('email'=>WYSIJA::wp_get_userdata('user_email')));
161
- $this->update(array('wpuser_id'=>WYSIJA::wp_get_userdata('ID')),array('email'=>WYSIJA::wp_get_userdata('user_email')));
162
  }
163
 
164
  //the subscriber doesn't seem to exist let's insert it in the DB
165
  if(!$result_user){
166
- $data = get_userdata(WYSIJA::wp_get_userdata('ID'));
167
  $firstname = $data->first_name;
168
  $lastname = $data->last_name;
169
  if(!$data->first_name && !$data->last_name) $firstname = $data->display_name;
@@ -175,7 +180,7 @@ class WYSIJA_model_user extends WYSIJA_model{
175
  'lastname'=>$lastname));
176
 
177
  $this->getFormat = OBJECT;
178
- $result_user = $this->getOne(false,array('wpuser_id'=>WYSIJA::wp_get_userdata('ID')));
179
  }
180
 
181
  return $result_user;
@@ -763,13 +768,14 @@ class WYSIJA_model_user extends WYSIJA_model{
763
 
764
  case '-99':
765
  $counts['inactive'] += $status_data['users'];
 
766
 
767
  default:
768
  break;
769
  }
770
  }
771
 
772
- $counts['all'] = array_sum(array_values($counts));
773
  return $counts;
774
  }
775
 
153
  static $result_user;
154
  if(!empty($result_user)) return $result_user;
155
  $this->getFormat = OBJECT;
156
+
157
+ $wp_user_id = (int)WYSIJA::wp_get_userdata('ID');
158
+ if( !( $wp_user_id > 0 ) ){
159
+ return $result_user;
160
+ }
161
+ $result_user = $this->getOne(false,array('wpuser_id'=>$wp_user_id));
162
 
163
  if(!$result_user){
164
  $this->getFormat = OBJECT;
165
  $result_user = $this->getOne(false,array('email'=>WYSIJA::wp_get_userdata('user_email')));
166
+ $this->update(array('wpuser_id'=>$wp_user_id),array('email'=>WYSIJA::wp_get_userdata('user_email')));
167
  }
168
 
169
  //the subscriber doesn't seem to exist let's insert it in the DB
170
  if(!$result_user){
171
+ $data = get_userdata($wp_user_id);
172
  $firstname = $data->first_name;
173
  $lastname = $data->last_name;
174
  if(!$data->first_name && !$data->last_name) $firstname = $data->display_name;
180
  'lastname'=>$lastname));
181
 
182
  $this->getFormat = OBJECT;
183
+ $result_user = $this->getOne(false,array('wpuser_id'=>$wp_user_id));
184
  }
185
 
186
  return $result_user;
768
 
769
  case '-99':
770
  $counts['inactive'] += $status_data['users'];
771
+ break;
772
 
773
  default:
774
  break;
775
  }
776
  }
777
 
778
+ $counts['all'] = array_sum(array_values($counts)) - $counts['inactive'];
779
  return $counts;
780
  }
781
 
modules/archive_std/archive_std.php CHANGED
@@ -1,90 +1,91 @@
1
  <?php
2
-
3
  defined('WYSIJA') or die('Restricted access');
4
 
5
- require_once(dirname(__FILE__) . DS . 'archive_std_model.php');
6
 
7
  class WYSIJA_module_archive_std extends WYSIJA_module {
8
 
9
- public $name = 'archive_std';
10
- public $model = 'WYSIJA_model_archive_std';
11
- public $view = 'archive_std_view';
 
 
12
 
13
- /**
14
- * hook_newsletter - page MailPoet >> Newsletters >> view detail
15
- * @param array $params
16
- * @return string
17
- */
18
- public function hook_settings_super_advanced(Array $params) {
19
- $this->view_show = 'hook_settings_super_advanced';
20
- $this->data['lists'] = $this->get_lists();
21
- return $this->render();
22
- }
23
 
24
- /**
25
- * hook: before saving settings
26
- * @param type $params = array(
27
- * 'REQUEST' =>& $_REQUEST
28
- * )
29
- */
30
- public function hook_settings_before_save(Array $params) {
31
- $config_model = WYSIJA::get('config', 'model');
32
- $archive_lists = $config_model->getValue('archive_lists');
33
- if (!empty($archive_lists))// just save for the first time only
34
- return;
35
- // save to database, useful for MixPanel
36
- $lists = $this->get_lists();
37
- if (empty($lists))
38
- return;
39
- $tmp = array();
40
- foreach ($lists as $list) {
41
- $is_checked = false;
42
- if (isset($params['REQUEST']['wysija']['config']['archive_lists']) && in_array($list['list_id'], $params['REQUEST']['wysija']['config']['archive_lists']))
43
- $is_checked = true;
44
- $tmp[$list['list_id']] = $is_checked;
45
- }
46
- $params['REQUEST']['wysija']['config']['archive_lists'] = $tmp;
47
- }
48
 
49
- /**
50
- * register shortcode, invoked by Wysija-newsletters/index.php::helper_front()
51
- */
52
- public function front_init() {
53
- add_shortcode('wysija_archive', array($this, 'scan_wysija_archive_shortcode'));
54
- }
55
 
56
- /**
57
- * scan shortcode [wysija_archive]
58
- * @param array $attributes
59
- */
60
- public function scan_wysija_archive_shortcode($attributes = array()) {
61
- $list_ids = !empty($attributes['list_id']) ? explode(',', $attributes['list_id']) : array();
62
- return $this->render_archive($list_ids);
63
- }
64
 
65
- /**
66
- * Render archive based on lists which are sent to
67
- * @param array $list_ids
68
- */
69
- protected function render_archive(Array $list_ids) {
70
- $this->data['newsletters'] = $this->model_obj->get_newsletters($list_ids);
71
- $this->view_show = 'render_archive';
72
- return $this->render();
73
- }
74
 
75
- /**
76
- * Get all available list of subscribers
77
- * @return array(
78
- * 0 => array( // first list
79
- * 'name' => string
80
- * 'list_id' => int,
81
- * 'is_public' => boolean
82
- * )
83
- * )
84
- */
85
- protected function get_lists() {
86
- $model_list = WYSIJA::get('list', 'model');
87
- return $model_list->get(array('name', 'list_id', 'is_public'), array('is_enabled' => 1));
88
- }
89
 
90
  }
1
  <?php
 
2
  defined('WYSIJA') or die('Restricted access');
3
 
4
+ require_once(dirname(__FILE__).DS.'archive_std_model.php');
5
 
6
  class WYSIJA_module_archive_std extends WYSIJA_module {
7
 
8
+ public $name = 'archive_std';
9
+
10
+ public $model = 'WYSIJA_model_archive_std';
11
+
12
+ public $view = 'archive_std_view';
13
 
14
+ /**
15
+ * hook_newsletter - page MailPoet >> Newsletters >> view detail
16
+ * @param array $params
17
+ * @return string
18
+ */
19
+ public function hook_settings_super_advanced(Array $params) {
20
+ $this->view_show = 'hook_settings_super_advanced';
21
+ $this->data['lists'] = $this->get_lists();
22
+ return $this->render();
23
+ }
24
 
25
+ /**
26
+ * hook: before saving settings
27
+ * @param type $params = array(
28
+ * 'REQUEST' =>& $_REQUEST
29
+ * )
30
+ */
31
+ public function hook_settings_before_save(Array $params) {
32
+ $config_model = WYSIJA::get('config', 'model');
33
+ $archive_lists = $config_model->getValue('archive_lists');
34
+ if (!empty($archive_lists))// just save for the first time only
35
+ return;
36
+ // save to database, useful for MixPanel
37
+ $lists = $this->get_lists();
38
+ if (empty($lists))
39
+ return;
40
+ $tmp = array( );
41
+ foreach ($lists as $list) {
42
+ $is_checked = false;
43
+ if (isset($params['REQUEST']['wysija']['config']['archive_lists']) && in_array($list['list_id'], $params['REQUEST']['wysija']['config']['archive_lists']))
44
+ $is_checked = true;
45
+ $tmp[$list['list_id']] = $is_checked;
46
+ }
47
+ $params['REQUEST']['wysija']['config']['archive_lists'] = $tmp;
48
+ }
49
 
50
+ /**
51
+ * register shortcode, invoked by Wysija-newsletters/index.php::helper_front()
52
+ */
53
+ public function front_init() {
54
+ add_shortcode('wysija_archive', array( $this, 'scan_wysija_archive_shortcode' ));
55
+ }
56
 
57
+ /**
58
+ * scan shortcode [wysija_archive]
59
+ * @param array $attributes
60
+ */
61
+ public function scan_wysija_archive_shortcode($attributes = array( )) {
62
+ $list_ids = !empty($attributes['list_id']) ? explode(',', $attributes['list_id']) : array( );
63
+ return $this->render_archive($list_ids);
64
+ }
65
 
66
+ /**
67
+ * Render archive based on lists which are sent to
68
+ * @param array $list_ids
69
+ */
70
+ protected function render_archive(Array $list_ids) {
71
+ $this->data['newsletters'] = $this->model_obj->get_newsletters($list_ids);
72
+ $this->view_show = 'render_archive';
73
+ return $this->render();
74
+ }
75
 
76
+ /**
77
+ * Get all available list of subscribers
78
+ * @return array(
79
+ * 0 => array( // first list
80
+ * 'name' => string
81
+ * 'list_id' => int,
82
+ * 'is_public' => boolean
83
+ * )
84
+ * )
85
+ */
86
+ protected function get_lists() {
87
+ $model_list = WYSIJA::get('list', 'model');
88
+ return $model_list->get(array( 'name', 'list_id', 'is_public' ), array( 'is_enabled' => 1 ));
89
+ }
90
 
91
  }
modules/archive_std/archive_std_model.php CHANGED
@@ -1,42 +1,41 @@
1
  <?php
2
-
3
  defined('WYSIJA') or die('Restricted access');
4
 
5
  class WYSIJA_model_archive_std extends WYSIJA_model {
6
 
7
- /**
8
- * allowed newsletters to be listed
9
- * @var array
10
- */
11
- protected $email_types = array(
12
- 1, // standard newsletter
13
- 2 // AutoNL (we will remove all AutoResponders, but keep Post Notification. Refer to self::remove_auto_responders()
14
- );
15
 
16
- /**
17
- * allowed newsletter's statuses
18
- * @var array
19
- */
20
- protected $email_status = array(
21
- 1, // sending
22
- 3, // sending
23
- 99, // sending
24
- 2 // sent
25
- );
26
 
27
- /**
28
- * Get newsletters, based on list ids
29
- * @param array $list_ids
30
- * @return array
31
- */
32
- public function get_newsletters(Array $list_ids = array()) {
33
- $where = array(1);
34
- $where[] = 'e.`type` IN (' . implode(',', $this->email_types) . ')';
35
- $where[] = 'e.`status` IN (' . implode(',', $this->email_status) . ')';
36
- $where_join = '';
37
- if (!empty($list_ids))
38
- $where_join = ' AND cl.`list_id` IN (' . implode(',', $list_ids) . ')';
39
- $query = '
40
  SELECT
41
  e.`email_id`,
42
  e.`type`,
@@ -46,56 +45,57 @@ class WYSIJA_model_archive_std extends WYSIJA_model {
46
  e.`params`
47
  FROM
48
  `[wysija]email` e
49
- JOIN
50
  `[wysija]campaign` c ON e.`campaign_id` = c.`campaign_id`
51
- JOIN
52
- `[wysija]campaign_list` cl ON c.`campaign_id` = cl.`campaign_id` '.$where_join.'
53
- WHERE
54
- ' . implode(' AND ', $where) . '
55
- GROUP BY
56
  e.`email_id`
57
- ORDER BY
58
- e.`sent_at` DESC
59
  ';
60
- return $this->replace_shortcodes(
61
- $this->remove_auto_responders(
62
- $this->get_results($query, OBJECT) // get in object please. We need to pass them to Shortcodes factory. Shortcodes factory accepts Object instead of Array
63
- )
64
- );
65
- }
66
 
67
- /**
68
- * Remove AutoResponders from the dataset, but keep post notification.
69
- * Refer to WYSIJA_help_autonews::getNextSend()
70
- * @param type $newsletters
71
- */
72
- protected function remove_auto_responders($newsletters) {
73
- foreach ($newsletters as $index => $newsletter) {
74
- $newsletters[$index]->params = unserialize(base64_decode($newsletter->params));
75
- if (!empty($newsletters[$index]->type) && (int) $newsletters[$index]->type === 2) {
76
- if (isset($newsletters[$index]->params['autonl']['event']) && $newsletters[$index]->params['autonl']['event'] === 'new-articles') {
77
- // keep post notification
78
- } else {
79
- unset($newsletters[$index]);
80
- }
81
- }
82
- }
83
- return $newsletters;
84
- }
 
85
 
86
- /**
87
- * Render shortcodes
88
- * @param array $newsletters a list of object Email
89
- * @return array a list of object Email, with renedered shortcodes at subject
90
- */
91
- protected function replace_shortcodes($newsletters) {
92
- $helper_mailer = WYSIJA::get('mailer', 'helper');
93
- $helper_shortcodes = WYSIJA::get('shortcodes', 'helper');
94
- foreach ($newsletters as &$newsletter) {
95
- $helper_mailer->parseSubjectUserTags($newsletter);
96
- $newsletter->subject = $helper_shortcodes->replace_subject($newsletter);
97
- }
98
- return $newsletters;
99
- }
100
 
101
  }
1
  <?php
 
2
  defined('WYSIJA') or die('Restricted access');
3
 
4
  class WYSIJA_model_archive_std extends WYSIJA_model {
5
 
6
+ /**
7
+ * allowed newsletters to be listed
8
+ * @var array
9
+ */
10
+ protected $email_types = array(
11
+ 1, // standard newsletter
12
+ 2 // AutoNL (we will remove all AutoResponders, but keep Post Notification. Refer to self::remove_auto_responders()
13
+ );
14
 
15
+ /**
16
+ * allowed newsletter's statuses
17
+ * @var array
18
+ */
19
+ protected $email_status = array(
20
+ 1, // sending
21
+ 3, // sending
22
+ 99, // sending
23
+ 2 // sent
24
+ );
25
 
26
+ /**
27
+ * Get newsletters, based on list ids
28
+ * @param array $list_ids
29
+ * @return array
30
+ */
31
+ public function get_newsletters(Array $list_ids = array( )) {
32
+ $where = array( 1 );
33
+ $where[] = 'e.`type` IN ('.implode(',', $this->email_types).')';
34
+ $where[] = 'e.`status` IN ('.implode(',', $this->email_status).')';
35
+ $where_join = '';
36
+ if (!empty($list_ids))
37
+ $where_join = ' AND cl.`list_id` IN ('.implode(',', $list_ids).')';
38
+ $query = '
39
  SELECT
40
  e.`email_id`,
41
  e.`type`,
45
  e.`params`
46
  FROM
47
  `[wysija]email` e
48
+ JOIN
49
  `[wysija]campaign` c ON e.`campaign_id` = c.`campaign_id`
50
+ JOIN
51
+ `[wysija]campaign_list` cl ON c.`campaign_id` = cl.`campaign_id` '.$where_join.'
52
+ WHERE
53
+ '.implode(' AND ', $where).'
54
+ GROUP BY
55
  e.`email_id`
56
+ ORDER BY
57
+ e.`sent_at` DESC
58
  ';
59
+ return $this->replace_shortcodes(
60
+ $this->remove_auto_responders(
61
+ $this->get_results($query, OBJECT) // get in object please. We need to pass them to Shortcodes factory. Shortcodes factory accepts Object instead of Array
62
+ )
63
+ );
64
+ }
65
 
66
+ /**
67
+ * Remove AutoResponders from the dataset, but keep post notification.
68
+ * Refer to WYSIJA_help_autonews::getNextSend()
69
+ * @param type $newsletters
70
+ */
71
+ protected function remove_auto_responders($newsletters) {
72
+ foreach ($newsletters as $index => $newsletter) {
73
+ $newsletters[$index]->params = unserialize(base64_decode($newsletter->params));
74
+ if (!empty($newsletters[$index]->type) && (int)$newsletters[$index]->type === 2) {
75
+ if (isset($newsletters[$index]->params['autonl']['event']) && $newsletters[$index]->params['autonl']['event'] === 'new-articles') {
76
+ // keep post notification
77
+ }
78
+ else {
79
+ unset($newsletters[$index]);
80
+ }
81
+ }
82
+ }
83
+ return $newsletters;
84
+ }
85
 
86
+ /**
87
+ * Render shortcodes
88
+ * @param array $newsletters a list of object Email
89
+ * @return array a list of object Email, with renedered shortcodes at subject
90
+ */
91
+ protected function replace_shortcodes($newsletters) {
92
+ $helper_mailer = WYSIJA::get('mailer', 'helper');
93
+ $helper_shortcodes = WYSIJA::get('shortcodes', 'helper');
94
+ foreach ($newsletters as &$newsletter) {
95
+ $helper_mailer->parseSubjectUserTags($newsletter);
96
+ $newsletter->subject = $helper_shortcodes->replace_subject($newsletter);
97
+ }
98
+ return $newsletters;
99
+ }
100
 
101
  }
modules/archive_std/archive_std_view.php CHANGED
@@ -3,167 +3,167 @@ defined('WYSIJA') or die('Restricted access');
3
 
4
  class WYSIJA_module_view_archive_std_view extends WYSIJA_view {
5
 
6
- public function hook_settings_super_advanced($data) {
7
- ?>
8
- <tr class="super-advanced">
9
- <th>
10
- <label><?php echo __('Archive page shortcode', WYSIJA); ?></label>
11
- <p class="description"><?php echo __('Paste this shortcode in a page to display a list of past newsletters.', WYSIJA); ?></p>
12
- </th>
13
- <td>
14
- <?php
15
- $key = 'archive';
16
- $forms_helper = WYSIJA::get('forms', 'helper');
17
- ?>
18
- <div id="<?php echo $key; ?>_linkname" class="linknamecboxes">
19
- <?php echo $forms_helper->input(array('name' => 'wysija[config][' . $key . '_linkname]', 'size' => '75', 'class' => 'archive-shortcode', 'readonly' => 'readonly'), '[wysija_archive]'); ?>
20
- <div class="clearfix">
21
- <?php
22
- foreach ($data['lists'] as $list) {
23
- ?>
24
- <p class="labelcheck">
25
- <label for="<?php echo $key; ?>list-<?php echo $list['list_id']; ?>">
26
- <?php echo $forms_helper->checkbox(array('id' => $key . 'list-' . $list['list_id'], 'name' => 'wysija[config][' . $key . '_lists][]', 'class' => $key . '-list'), $list['list_id']); ?>
27
- <?php echo $list['name']; ?>
28
- </label>
29
- </p>
30
- <?php
31
- }
32
- ?>
33
- </div>
34
- </div>
35
- </td>
36
- </tr>
37
- <script type="text/javascript">
38
- (function($) {
39
 
40
- /**
41
- * class ArchiveShortcode: Shortcode refactor
42
- * @param {string} shortcode
43
- * @param {string} targetShortcode DOM element selector
44
- * @returns {_L2.ArchiveShortcode}
45
- */
46
- var ArchiveShortcode = function(shortcode, targetShortcode) {
47
- this.shortcode = shortcode;
48
- this.targetShortcode = targetShortcode;
49
- this.lists = [];
50
- this.getLists = function() {
51
 
52
- };
53
- this.addToLists = function(id) {
54
- this.lists.push(id);
55
- };
56
 
57
- this.removeFromList = function(id) {
58
- var i = this.lists.indexOf(id);
59
- if (i !== -1) {
60
- this.lists.splice(i, 1);
61
- }
62
- };
63
 
64
- this.renderShortcode = function() {
65
- shortCode = '[' + +' ' + this.lists.join() + ']';
66
- shortCode = '[';
67
- shortCode += this.shortcode;
68
- if (this.lists.length > 0) {
69
- shortCode += ' list_id="' + this.lists.join() + '"';
70
- }
71
- shortCode += ']';
72
- $(this.targetShortcode).val(shortCode);
73
- };
74
 
75
- this.onChangeList = function(isSelected, listId) {
76
- if (isSelected)
77
- this.addToLists(listId);
78
- else
79
- this.removeFromList(listId);
80
- this.renderShortcode();
81
- };
82
 
83
- this.onClick = function() {
84
- $(this).select();
85
- };
86
 
87
- $(this.targetShortcode).click(this.onClick);
88
- };
89
- $(document).ready(function() {
90
- var achiveShortcode = new ArchiveShortcode('wysija_archive', '.archive-shortcode');
91
- $('.archive-list').change(function(e) {
92
- achiveShortcode.onChangeList($(e.target).is(':checked'), $(e.target).val());
93
- });
94
- });
95
- })(jQuery);
96
- </script>
97
- <?php
98
- }
99
-
100
- /**
101
- * Render archieve shortcode at frontend
102
- * @param array $data
103
- */
104
- public function render_archive(Array $data) {
105
- if (empty($data['newsletters'])) {
106
- echo apply_filters('mpoet_archive_no_newsletters', __('Oops! There are no newsletters to display.', WYSIJA));
107
- return;
108
  }
109
- $filter_mpoet_archive_title = apply_filters('mpoet_archive_title', '' /* __('Newsletter Archives') */);
110
- if (!empty($filter_mpoet_archive_title)) {
111
- echo '<h3 class="wysija_archive_title">' . $filter_mpoet_archive_title . '</h3>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  }
113
- echo '<ul class="wysija_archive">';
114
- foreach ($data['newsletters'] as $newsletter) {
115
- ?>
116
- <li>
117
- <span class="wysija_archive_date">
118
- <?php
119
- add_filter('mpoet_archive_date', array($this, 'filter_mpoet_archive_date'), 2);
120
- echo apply_filters('mpoet_archive_date', $newsletter->sent_at);
121
- ?>
122
- </span>
123
- <span class="wysija_archive_subject">
124
- <?php
125
- add_filter('mpoet_archive_subject', array($this, 'filter_mpoet_archive_subject'), 2);
126
- echo apply_filters('mpoet_archive_subject', $newsletter);
127
- ?>
128
- </span>
129
- </li>
130
- <?php
131
- }
132
- echo '</ul>';
133
- ?>
134
- <style type="text/css">
135
- ul.wysija_archive {
136
- list-style-type: none;
137
- }
138
- ul.wysija_archive li {
139
- padding-top: 5px;
140
- }
141
- </style>
142
- <?php
143
- }
144
 
145
- /**
146
- * Filter Wysija_archive_date
147
- * @param type $sent_at
148
- * @return type
149
- */
150
- public function filter_mpoet_archive_date($sent_at) {
151
- return $this->fieldListHTML_created_at($sent_at) . ' : ';
152
- }
153
 
154
- /**
155
- * Filter Wysija_archive_date
156
- * @param type $sent_at
157
- * @return type
158
- */
159
- public function filter_mpoet_archive_subject($newsletter) {
160
- $email_helper = WYSIJA::get('email', 'helper');
161
- $full_url = $email_helper->getVIB($newsletter);
162
- ?>
163
- <a href="<?php echo $full_url ?>" target="_blank" class="viewnews" title="<?php _e('Preview in new tab', WYSIJA) ?>">
164
- <?php echo $newsletter->subject; ?>
165
- </a>
166
- <?php
167
- }
168
 
169
  }
3
 
4
  class WYSIJA_module_view_archive_std_view extends WYSIJA_view {
5
 
6
+ public function hook_settings_super_advanced($data) {
7
+ ?>
8
+ <tr class="super-advanced">
9
+ <th>
10
+ <label><?php echo __('Archive page shortcode', WYSIJA); ?></label>
11
+ <p class="description"><?php echo __('Paste this shortcode in a page to display a list of past newsletters.', WYSIJA); ?></p>
12
+ </th>
13
+ <td>
14
+ <?php
15
+ $key = 'archive';
16
+ $forms_helper = WYSIJA::get('forms', 'helper');
17
+ ?>
18
+ <div id="<?php echo $key; ?>_linkname" class="linknamecboxes">
19
+ <?php echo $forms_helper->input(array( 'name' => 'wysija[config]['.$key.'_linkname]', 'size' => '75', 'class' => 'archive-shortcode', 'readonly' => 'readonly' ), '[wysija_archive]'); ?>
20
+ <div class="clearfix">
21
+ <?php
22
+ foreach ($data['lists'] as $list) {
23
+ ?>
24
+ <p class="labelcheck">
25
+ <label for="<?php echo $key; ?>list-<?php echo $list['list_id']; ?>">
26
+ <?php echo $forms_helper->checkbox(array( 'id' => $key.'list-'.$list['list_id'], 'name' => 'wysija[config]['.$key.'_lists][]', 'class' => $key.'-list' ), $list['list_id']); ?>
27
+ <?php echo $list['name']; ?>
28
+ </label>
29
+ </p>
30
+ <?php
31
+ }
32
+ ?>
33
+ </div>
34
+ </div>
35
+ </td>
36
+ </tr>
37
+ <script type="text/javascript">
38
+ (function($) {
39
 
40
+ /**
41
+ * class ArchiveShortcode: Shortcode refactor
42
+ * @param {string} shortcode
43
+ * @param {string} targetShortcode DOM element selector
44
+ * @returns {_L2.ArchiveShortcode}
45
+ */
46
+ var ArchiveShortcode = function(shortcode, targetShortcode) {
47
+ this.shortcode = shortcode;
48
+ this.targetShortcode = targetShortcode;
49
+ this.lists = [];
50
+ this.getLists = function() {
51
 
52
+ };
53
+ this.addToLists = function(id) {
54
+ this.lists.push(id);
55
+ };
56
 
57
+ this.removeFromList = function(id) {
58
+ var i = this.lists.indexOf(id);
59
+ if (i !== -1) {
60
+ this.lists.splice(i, 1);
61
+ }
62
+ };
63
 
64
+ this.renderShortcode = function() {
65
+ shortCode = '[' + +' ' + this.lists.join() + ']';
66
+ shortCode = '[';
67
+ shortCode += this.shortcode;
68
+ if (this.lists.length > 0) {
69
+ shortCode += ' list_id="' + this.lists.join() + '"';
70
+ }
71
+ shortCode += ']';
72
+ $(this.targetShortcode).val(shortCode);
73
+ };
74
 
75
+ this.onChangeList = function(isSelected, listId) {
76
+ if (isSelected)
77
+ this.addToLists(listId);
78
+ else
79
+ this.removeFromList(listId);
80
+ this.renderShortcode();
81
+ };
82
 
83
+ this.onClick = function() {
84
+ $(this).select();
85
+ };
86
 
87
+ $(this.targetShortcode).click(this.onClick);
88
+ };
89
+ $(document).ready(function() {
90
+ var achiveShortcode = new ArchiveShortcode('wysija_archive', '.archive-shortcode');
91
+ $('.archive-list').change(function(e) {
92
+ achiveShortcode.onChangeList($(e.target).is(':checked'), $(e.target).val());
93
+ });
94
+ });
95
+ })(jQuery);
96
+ </script>
97
+ <?php
 
 
 
 
 
 
 
 
 
 
98
  }
99
+
100
+ /**
101
+ * Render archieve shortcode at frontend
102
+ * @param array $data
103
+ */
104
+ public function render_archive(Array $data) {
105
+ if (empty($data['newsletters'])) {
106
+ echo apply_filters('mpoet_archive_no_newsletters', __('Oops! There are no newsletters to display.', WYSIJA));
107
+ return;
108
+ }
109
+ $filter_mpoet_archive_title = apply_filters('mpoet_archive_title', '' /* __('Newsletter Archives') */);
110
+ if (!empty($filter_mpoet_archive_title)) {
111
+ echo '<h3 class="wysija_archive_title">'.$filter_mpoet_archive_title.'</h3>';
112
+ }
113
+ echo '<ul class="wysija_archive">';
114
+ foreach ($data['newsletters'] as $newsletter) {
115
+ ?>
116
+ <li>
117
+ <span class="wysija_archive_date">
118
+ <?php
119
+ add_filter('mpoet_archive_date', array( $this, 'filter_mpoet_archive_date' ), 2);
120
+ echo apply_filters('mpoet_archive_date', $newsletter->sent_at);
121
+ ?>
122
+ </span>
123
+ <span class="wysija_archive_subject">
124
+ <?php
125
+ add_filter('mpoet_archive_subject', array( $this, 'filter_mpoet_archive_subject' ), 2);
126
+ echo apply_filters('mpoet_archive_subject', $newsletter);
127
+ ?>
128
+ </span>
129
+ </li>
130
+ <?php
131
+ }
132
+ echo '</ul>';
133
+ ?>
134
+ <style type="text/css">
135
+ ul.wysija_archive {
136
+ list-style-type: none;
137
+ }
138
+ ul.wysija_archive li {
139
+ padding-top: 5px;
140
+ }
141
+ </style>
142
+ <?php
143
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
 
145
+ /**
146
+ * Filter Wysija_archive_date
147
+ * @param type $sent_at
148
+ * @return type
149
+ */
150
+ public function filter_mpoet_archive_date($sent_at) {
151
+ return $this->fieldListHTML_created_at($sent_at).' : ';
152
+ }
153
 
154
+ /**
155
+ * Filter Wysija_archive_date
156
+ * @param type $sent_at
157
+ * @return type
158
+ */
159
+ public function filter_mpoet_archive_subject($newsletter) {
160
+ $email_helper = WYSIJA::get('email', 'helper');
161
+ $full_url = $email_helper->getVIB($newsletter);
162
+ ?>
163
+ <a href="<?php echo $full_url ?>" target="_blank" class="viewnews" title="<?php _e('Preview in new tab', WYSIJA) ?>">
164
+ <?php echo $newsletter->subject; ?>
165
+ </a>
166
+ <?php
167
+ }
168
 
169
  }
modules/stats_newsletter_std/stats_newsletter_std.php CHANGED
@@ -1,228 +1,229 @@
1
  <?php
2
-
3
  defined('WYSIJA') or die('Restricted access');
4
 
5
- require_once(dirname(__FILE__) . DS . 'stats_newsletter_std_model.php');
6
 
7
  class WYSIJA_module_stats_newsletter_std extends WYSIJA_module_statistics {
8
 
9
- public $name = 'stats_newsletter_std';
10
- public $model = 'WYSIJA_model_stats_newsletter_std';
11
- public $view = 'stats_newsletter_std_view';
12
-
13
- /**
14
- *
15
- * @var type define how charts are displayed
16
- */
17
- protected $chart_stytle = 2; // 1 = open rate and click rate; 2 = all status in a pie; 0: both
18
-
19
- /**
20
- * Map email status to its description
21
- * @var type
22
- */
23
- protected $emails_status = array();
24
-
25
- public function __construct() {
26
- parent::__construct();
27
- $this->emails_status = array(
28
- -3 => __('In queue', WYSIJA),
29
- -2 => __('Not sent', WYSIJA),
30
- -1 => __('Bounced', WYSIJA),
31
- 0 => __('Sent', WYSIJA),
32
- 1 => __('Opened only', WYSIJA),
33
- 2 => __('Opened & Clicked', WYSIJA),
34
- 3 => __('Opened & Unsubscribed', WYSIJA),
35
- );
36
- }
37
-
38
- /**
39
- *
40
- * @param array $params
41
- * array(
42
- * 'email_id' => int,
43
- * 'email_object' => array(
44
- * 'email_id' => int,
45
- * 'campaign_id' => int,
46
- * 'subject' => string,
47
- * 'body' => html,
48
- * 'created_at' => int,
49
- * 'modified_at' => int,
50
- * 'sent_at' => int,
51
- * 'from_email' => string,
52
- * 'from_name' => string,
53
- * 'replyto_email' => string,
54
- * 'replyto_name' => string,
55
- * 'attachments' => ?,
56
- * 'status' => int,
57
- * 'type' => int,
58
- * 'number_sent' => int,
59
- * 'number_opened' => int,
60
- * 'number_clicked' => int,
61
- * 'number_unsub' => int,
62
- * 'number_bounce' => int,
63
- * 'number_forward' => int,
64
- * 'params' => array(
65
- * 'quickselection' => array(),
66
- * 'divider' => array(),
67
- * 'googletrackingcode' => string,
68
- * 'schedule' => array(),
69
- * 'theme' => string
70
- * ),
71
- * 'wj_data' => string, (base64)
72
- * 'wj_styles' => string (base64)
73
- * )
74
- * )
75
- * @return html
76
- */
77
- public function hook_newsletter_top($params = array()) {
78
- if (empty($params['email_id']))
79
- return;
80
-
81
- if ($this->is_premium)
82
- return $this->hook_newsletter_action_buttons($params) . $this->hook_newsletter_top_links($params);
83
-
84
- // Google Pie chart is available for free users only!
85
- $this->data['emails_count'] = $this->model_obj->get_emails_count($params['email_id']);
86
- //$this->data['email_object'] = $params['email_object'];
87
- $helper_toolbox = WYSIJA::get('toolbox', 'helper');
88
- $sent_at = !empty($params['email_object']['sent_at']) ? $params['email_object']['sent_at'] : $params['email_object']['created_at'];
89
- $title_pattern = $this->data['emails_count'] > 1 ? 'Sent %1$s ago to %2$s subscribers' : 'Sent %1$s ago to %2$s subscriber';
90
- $chart_title = sprintf(__($title_pattern, WYSIJA), $helper_toolbox->duration_string($sent_at), $this->data['emails_count']);
91
-
92
- $params['chart_title'] = $chart_title;
93
- $this->data['dataset'] = array();
94
- switch ($this->chart_stytle) {
95
- case 0:
96
- $this->data['dataset'][] = $this->get_open_rate_data($params);
97
- $this->data['dataset'][] = $this->get_click_rate_data($params);
98
- $this->data['dataset'][] = $this->get_emails_stats($params);
99
- break;
100
- case 1:
101
- $this->data['dataset'][] = $this->get_open_rate_data($params);
102
- $this->data['dataset'][] = $this->get_click_rate_data($params);
103
- break;
104
-
105
- case 2:
106
- $this->data['dataset'][] = $this->get_emails_stats($params);
107
- break;
108
- }
109
-
110
- $this->view_show = 'hook_newsletter_top';
111
-
112
- // quickfix. Module does not support add js by calling $this->js[]
113
- wp_register_script('wysija-charts', 'https://www.google.com/jsapi', array('jquery'), true);
114
- wp_enqueue_script('wysija-charts');
115
- return $this->render() . $this->hook_newsletter_action_buttons($params). $this->hook_newsletter_top_links($params);
116
- }
117
-
118
- /**
119
- *
120
- * @param array $params
121
- * array(
122
- * 'email_id' => int,
123
- * 'email_object' => array(
124
- * 'email_id' => int,
125
- * 'campaign_id' => int,
126
- * 'subject' => string,
127
- * 'body' => html,
128
- * 'created_at' => int,
129
- * 'modified_at' => int,
130
- * 'sent_at' => int,
131
- * 'from_email' => string,
132
- * 'from_name' => string,
133
- * 'replyto_email' => string,
134
- * 'replyto_name' => string,
135
- * 'attachments' => ?,
136
- * 'status' => int,
137
- * 'type' => int,
138
- * 'number_sent' => int,
139
- * 'number_opened' => int,
140
- * 'number_clicked' => int,
141
- * 'number_unsub' => int,
142
- * 'number_bounce' => int,
143
- * 'number_forward' => int,
144
- * 'params' => array(
145
- * 'quickselection' => array(),
146
- * 'divider' => array(),
147
- * 'googletrackingcode' => string,
148
- * 'schedule' => array(),
149
- * 'theme' => string
150
- * ),
151
- * 'wj_data' => string, (base64)
152
- * 'wj_styles' => string (base64)
153
- * )
154
- * )
155
- * @return html
156
- */
157
- public function hook_newsletter_bottom($params = array()) {
158
- $html = '';
159
- $html .= $this->hook_newsletter_top_links($params);
160
- return $html;
161
- }
162
-
163
- protected function hook_newsletter_top_links($params = array()) {
164
- $this->data['top_links'] = $this->model_obj->get_top_links($params['email_id'],null);
 
 
165
  foreach ($this->data['top_links'] as &$top_link) {
166
  $top_link['is_viewing'] = !empty($params['url_id']) && $top_link['url_id'] == $params['url_id'];
167
  }
168
- $this->view_show = 'hook_newsletter_top_links';
169
- return $this->render();
170
- }
171
-
172
- protected function hook_newsletter_action_buttons($params = array()) {
173
- if (empty($params['email_id']) || empty($params['email_object']) || empty($params['email_object']['campaign_id']))
174
- return;
175
- $this->data = array_merge($this->data, $params);
176
- $this->data['lists'] = $this->model_obj->get_lists($params['email_object']['campaign_id']);
177
- $this->data['bounce'] = $this->get_bounce_address();
178
- $this->view_show = 'hook_newsletter_action_buttons';
179
- return $this->render();
180
- }
181
-
182
- /**
183
- * Get bounce email address
184
- * @return string
185
- */
186
- protected function get_bounce_address() {
187
- $bounce_address = null;
188
- $config_model = WYSIJA::get('config', 'model');
189
- // Test email, host, logi, password to make sure at least Bounce was fully configured
190
- if ($config_model->getValue('bounce_email')
191
- && $config_model->getValue('bounce_host')
192
- && $config_model->getValue('bounce_login')
193
- && $config_model->getValue('bounce_password')
194
- ) {
195
- $bounce_address = $config_model->getValue('bounce_email');
196
- }
197
- return $bounce_address;
198
- }
199
-
200
- /**
201
- * Get emails stats data, and prepare for Google.visualization.dataTable
202
- * @param array $params
203
- * @return array
204
- */
205
- protected function get_emails_stats($params) {
206
- $emails_stats = $this->model_obj->get_email_status($params['email_id']);
207
- $_data = array();
208
- foreach ($this->emails_status as $status => $desc) {
209
- $_data[$desc] = isset($emails_stats[$status]) ? $emails_stats[$status] : 0;
210
- }
211
-
212
- return array(
213
- 'title' => $params['chart_title'],
214
- 'columns' => array(
215
- array(
216
- 'type' => 'string',
217
- 'label' => __('Rate', WYSIJA)
218
- ),
219
- array(
220
- 'type' => 'number',
221
- 'label' => __('Rate', WYSIJA)
222
- ),
223
- ),
224
- 'data' => $_data
225
- );
226
- }
227
 
228
  }
1
  <?php
 
2
  defined('WYSIJA') or die('Restricted access');
3
 
4
+ require_once(dirname(__FILE__).DS.'stats_newsletter_std_model.php');
5
 
6
  class WYSIJA_module_stats_newsletter_std extends WYSIJA_module_statistics {
7
 
8
+ public $name = 'stats_newsletter_std';
9
+
10
+ public $model = 'WYSIJA_model_stats_newsletter_std';
11
+
12
+ public $view = 'stats_newsletter_std_view';
13
+
14
+ /**
15
+ *
16
+ * @var type define how charts are displayed
17
+ */
18
+ protected $chart_stytle = 2; // 1 = open rate and click rate; 2 = all status in a pie; 0: both
19
+
20
+ /**
21
+ * Map email status to its description
22
+ * @var type
23
+ */
24
+ protected $emails_status = array( );
25
+
26
+ public function __construct() {
27
+ parent::__construct();
28
+ $this->emails_status = array(
29
+ -3 => __('In queue', WYSIJA),
30
+ -2 => __('Not sent', WYSIJA),
31
+ -1 => __('Bounced', WYSIJA),
32
+ 0 => __('Sent', WYSIJA),
33
+ 1 => __('Opened only', WYSIJA),
34
+ 2 => __('Opened & Clicked', WYSIJA),
35
+ 3 => __('Opened & Unsubscribed', WYSIJA),
36
+ );
37
+ }
38
+
39
+ /**
40
+ *
41
+ * @param array $params
42
+ * array(
43
+ * 'email_id' => int,
44
+ * 'email_object' => array(
45
+ * 'email_id' => int,
46
+ * 'campaign_id' => int,
47
+ * 'subject' => string,
48
+ * 'body' => html,
49
+ * 'created_at' => int,
50
+ * 'modified_at' => int,
51
+ * 'sent_at' => int,
52
+ * 'from_email' => string,
53
+ * 'from_name' => string,
54
+ * 'replyto_email' => string,
55
+ * 'replyto_name' => string,
56
+ * 'attachments' => ?,
57
+ * 'status' => int,
58
+ * 'type' => int,
59
+ * 'number_sent' => int,
60
+ * 'number_opened' => int,
61
+ * 'number_clicked' => int,
62
+ * 'number_unsub' => int,
63
+ * 'number_bounce' => int,
64
+ * 'number_forward' => int,
65
+ * 'params' => array(
66
+ * 'quickselection' => array(),
67
+ * 'divider' => array(),
68
+ * 'googletrackingcode' => string,
69
+ * 'schedule' => array(),
70
+ * 'theme' => string
71
+ * ),
72
+ * 'wj_data' => string, (base64)
73
+ * 'wj_styles' => string (base64)
74
+ * )
75
+ * )
76
+ * @return html
77
+ */
78
+ public function hook_newsletter_top($params = array( )) {
79
+ if (empty($params['email_id']))
80
+ return;
81
+
82
+ if ($this->is_premium)
83
+ return $this->hook_newsletter_action_buttons($params).$this->hook_newsletter_top_links($params);
84
+
85
+ // Google Pie chart is available for free users only!
86
+ $this->data['emails_count'] = $this->model_obj->get_emails_count($params['email_id']);
87
+ //$this->data['email_object'] = $params['email_object'];
88
+ $helper_toolbox = WYSIJA::get('toolbox', 'helper');
89
+ $sent_at = !empty($params['email_object']['sent_at']) ? $params['email_object']['sent_at'] : $params['email_object']['created_at'];
90
+ $title_pattern = $this->data['emails_count'] > 1 ? 'Sent %1$s ago to %2$s subscribers' : 'Sent %1$s ago to %2$s subscriber';
91
+ $chart_title = sprintf(__($title_pattern, WYSIJA), $helper_toolbox->duration_string($sent_at), $this->data['emails_count']);
92
+
93
+ $params['chart_title'] = $chart_title;
94
+ $this->data['dataset'] = array( );
95
+ switch ($this->chart_stytle) {
96
+ case 0:
97
+ $this->data['dataset'][] = $this->get_open_rate_data($params);
98
+ $this->data['dataset'][] = $this->get_click_rate_data($params);
99
+ $this->data['dataset'][] = $this->get_emails_stats($params);
100
+ break;
101
+ case 1:
102
+ $this->data['dataset'][] = $this->get_open_rate_data($params);
103
+ $this->data['dataset'][] = $this->get_click_rate_data($params);
104
+ break;
105
+
106
+ case 2:
107
+ $this->data['dataset'][] = $this->get_emails_stats($params);
108
+ break;
109
+ }
110
+
111
+ $this->view_show = 'hook_newsletter_top';
112
+
113
+ // quickfix. Module does not support add js by calling $this->js[]
114
+ wp_register_script('wysija-charts', 'https://www.google.com/jsapi', array( 'jquery' ), true);
115
+ wp_enqueue_script('wysija-charts');
116
+ return $this->render().$this->hook_newsletter_action_buttons($params).$this->hook_newsletter_top_links($params);
117
+ }
118
+
119
+ /**
120
+ *
121
+ * @param array $params
122
+ * array(
123
+ * 'email_id' => int,
124
+ * 'email_object' => array(
125
+ * 'email_id' => int,
126
+ * 'campaign_id' => int,
127
+ * 'subject' => string,
128
+ * 'body' => html,
129
+ * 'created_at' => int,
130
+ * 'modified_at' => int,
131
+ * 'sent_at' => int,
132
+ * 'from_email' => string,
133
+ * 'from_name' => string,
134
+ * 'replyto_email' => string,
135
+ * 'replyto_name' => string,
136
+ * 'attachments' => ?,
137
+ * 'status' => int,
138
+ * 'type' => int,
139
+ * 'number_sent' => int,
140
+ * 'number_opened' => int,
141
+ * 'number_clicked' => int,
142
+ * 'number_unsub' => int,
143
+ * 'number_bounce' => int,
144
+ * 'number_forward' => int,
145
+ * 'params' => array(
146
+ * 'quickselection' => array(),
147
+ * 'divider' => array(),
148
+ * 'googletrackingcode' => string,
149
+ * 'schedule' => array(),
150
+ * 'theme' => string
151
+ * ),
152
+ * 'wj_data' => string, (base64)
153
+ * 'wj_styles' => string (base64)
154
+ * )
155
+ * )
156
+ * @return html
157
+ */
158
+ public function hook_newsletter_bottom($params = array( )) {
159
+ $html = '';
160
+ $html .= $this->hook_newsletter_top_links($params);
161
+ return $html;
162
+ }
163
+
164
+ protected function hook_newsletter_top_links($params = array( )) {
165
+ $this->data['top_links'] = $this->model_obj->get_top_links($params['email_id'], null);
166
  foreach ($this->data['top_links'] as &$top_link) {
167
  $top_link['is_viewing'] = !empty($params['url_id']) && $top_link['url_id'] == $params['url_id'];
168
  }
169
+ $this->view_show = 'hook_newsletter_top_links';
170
+ return $this->render();
171
+ }
172
+
173
+ protected function hook_newsletter_action_buttons($params = array( )) {
174
+ if (empty($params['email_id']) || empty($params['email_object']) || empty($params['email_object']['campaign_id']))
175
+ return;
176
+ $this->data = array_merge($this->data, $params);
177
+ $this->data['lists'] = $this->model_obj->get_lists($params['email_object']['campaign_id']);
178
+ $this->data['bounce'] = $this->get_bounce_address();
179
+ $this->view_show = 'hook_newsletter_action_buttons';
180
+ return $this->render();
181
+ }
182
+
183
+ /**
184
+ * Get bounce email address
185
+ * @return string
186
+ */
187
+ protected function get_bounce_address() {
188
+ $bounce_address = null;
189
+ $config_model = WYSIJA::get('config', 'model');
190
+ // Test email, host, logi, password to make sure at least Bounce was fully configured
191
+ if ($config_model->getValue('bounce_email')
192
+ && $config_model->getValue('bounce_host')
193
+ && $config_model->getValue('bounce_login')
194
+ && $config_model->getValue('bounce_password')
195
+ ) {
196
+ $bounce_address = $config_model->getValue('bounce_email');
197
+ }
198
+ return $bounce_address;
199
+ }
200
+
201
+ /**
202
+ * Get emails stats data, and prepare for Google.visualization.dataTable
203
+ * @param array $params
204
+ * @return array
205
+ */
206
+ protected function get_emails_stats($params) {
207
+ $emails_stats = $this->model_obj->get_email_status($params['email_id']);
208
+ $_data = array( );
209
+ foreach ($this->emails_status as $status => $desc) {
210
+ $_data[$desc] = isset($emails_stats[$status]) ? $emails_stats[$status] : 0;
211
+ }
212
+
213
+ return array(
214
+ 'title' => $params['chart_title'],
215
+ 'columns' => array(
216
+ array(
217
+ 'type' => 'string',
218
+ 'label' => __('Rate', WYSIJA)
219
+ ),
220
+ array(
221
+ 'type' => 'number',
222
+ 'label' => __('Rate', WYSIJA)
223
+ ),
224
+ ),
225
+ 'data' => $_data
226
+ );
227
+ }
228
 
229
  }
modules/stats_newsletter_std/stats_newsletter_std_model.php CHANGED
@@ -1,72 +1,73 @@
1
  <?php
 
2
 
3
  class WYSIJA_model_stats_newsletter_std extends WYSIJA_module_statistics_model {
4
 
5
- /**
6
- * Store email status (output of $this->get_email_status())
7
- * @var type
8
- */
9
- protected static $emails_status = array();
10
 
11
- /**
12
- * Get and group by status of a specific newsletter which was sent to subscribers
13
- * @param int $user_id
14
- * @return array list of emails, group by status. It contains an empy list, or list of one or more status
15
- * array(
16
- * status => emails count, // status: -3: inqueue, -2:notsent, -1: bounced, 0: sent, 1: open, 2: clicked, 3: unsubscribed
17
- * status => emails count,
18
- * ...
19
- * status => emails count
20
- * )
21
- */
22
- public function get_email_status($email_id) {
23
- if (!isset(self::$emails_status[$email_id])) {
24
- // get stats email status
25
- $query = '
26
  SELECT
27
  count(`email_id`) as emails,
28
  `status`
29
  FROM
30
  `[wysija]email_user_stat`
31
- WHERE `email_id` = ' . (int) $email_id . '
32
  GROUP BY `status`'
33
- ;
34
- self::$emails_status[$email_id] = $this->indexing_dataset_by_field('status', $this->get_results($query), false, 'emails');
35
- }
36
- return self::$emails_status[$email_id];
37
- }
38
 
39
- /**
40
- *
41
- * @param int $user_id
42
- * @return int a number of received / sent newsletters to a specific user
43
- */
44
- public function get_emails_count($email_id) {
45
- // get emails group by status
46
- $count = 0;
47
- $emails_status = $this->get_email_status($email_id); // we don't need to write a separated sql query here, reduce 1 sql request
48
- if (empty($emails_status))
49
- return $count;
50
- foreach ($emails_status as $emails)
51
- $count += $emails;
52
- return $count;
53
- }
54
 
55
- /**
56
- * Get top links of a newsletters
57
- * @param type $email_id
58
- * @return array
59
- * array(
60
- * 'email_id' => int, <br />
61
- * 'url_id' => int, <br />
62
- * 'url' => string, <br />
63
- * 'unique_clicks' => int, <br />
64
- * 'total_clicks' => int <br />
65
- * )
66
- */
67
- public function get_top_links($email_id, $top = 5, $order_direction = 'DESC') {
68
- $limit = !empty($top) ? 'LIMIT 0, ' . $top : '';
69
- $query = '
70
  SELECT
71
  euu.`email_id`,
72
  u.`url_id`,
@@ -78,11 +79,11 @@ class WYSIJA_model_stats_newsletter_std extends WYSIJA_module_statistics_model {
78
  JOIN
79
  [wysija]url u ON euu.url_id = u.url_id
80
  WHERE
81
- euu.email_id = ' . (int) $email_id . '
82
  GROUP BY
83
  u.`url_id`
84
- ORDER BY `total_clicks` ' . $order_direction . '
85
- ' . $limit . '
86
 
87
  ';
88
  $top_links = $this->get_results($query);
@@ -98,24 +99,23 @@ class WYSIJA_model_stats_newsletter_std extends WYSIJA_module_statistics_model {
98
  $top_link['view_subscriber_url'] = admin_url('admin.php?'.implode('&', $params));
99
  }
100
 
101
- return $top_links;
102
- }
103
-
104
 
105
- /**
106
- * Get lists which a campaign was sent to
107
- * @param int $campaign_id
108
- * @return array(
109
- * int => string (id => name),
110
- * int => string (id => name),
111
- * int => string (id => name),
112
- * )
113
- */
114
- public function get_lists($campaign_id) {
115
- $campaign_id = (int) $campaign_id;
116
- $lists = array();
117
- if (!empty($campaign_id)) {
118
- $query = '
119
  SELECT
120
  l.list_id,
121
  l.name
@@ -124,8 +124,9 @@ class WYSIJA_model_stats_newsletter_std extends WYSIJA_module_statistics_model {
124
  JOIN
125
  `[wysija]list` l ON cl.`list_id` = l.`list_id` AND `campaign_id` = '.$campaign_id.'
126
  ';
127
- $lists = $this->indexing_dataset_by_field('list_id',$this->get_results($query),null,'name');
128
- }
129
- return $lists;
130
- }
 
131
  }
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
 
4
  class WYSIJA_model_stats_newsletter_std extends WYSIJA_module_statistics_model {
5
 
6
+ /**
7
+ * Store email status (output of $this->get_email_status())
8
+ * @var type
9
+ */
10
+ protected static $emails_status = array( );
11
 
12
+ /**
13
+ * Get and group by status of a specific newsletter which was sent to subscribers
14
+ * @param int $user_id
15
+ * @return array list of emails, group by status. It contains an empy list, or list of one or more status
16
+ * array(
17
+ * status => emails count, // status: -3: inqueue, -2:notsent, -1: bounced, 0: sent, 1: open, 2: clicked, 3: unsubscribed
18
+ * status => emails count,
19
+ * ...
20
+ * status => emails count
21
+ * )
22
+ */
23
+ public function get_email_status($email_id) {
24
+ if (!isset(self::$emails_status[$email_id])) {
25
+ // get stats email status
26
+ $query = '
27
  SELECT
28
  count(`email_id`) as emails,
29
  `status`
30
  FROM
31
  `[wysija]email_user_stat`
32
+ WHERE `email_id` = '.(int)$email_id.'
33
  GROUP BY `status`'
34
+ ;
35
+ self::$emails_status[$email_id] = $this->indexing_dataset_by_field('status', $this->get_results($query), false, 'emails');
36
+ }
37
+ return self::$emails_status[$email_id];
38
+ }
39
 
40
+ /**
41
+ *
42
+ * @param int $user_id
43
+ * @return int a number of received / sent newsletters to a specific user
44
+ */
45
+ public function get_emails_count($email_id) {
46
+ // get emails group by status
47
+ $count = 0;
48
+ $emails_status = $this->get_email_status($email_id); // we don't need to write a separated sql query here, reduce 1 sql request
49
+ if (empty($emails_status))
50
+ return $count;
51
+ foreach ($emails_status as $emails)
52
+ $count += $emails;
53
+ return $count;
54
+ }
55
 
56
+ /**
57
+ * Get top links of a newsletters
58
+ * @param type $email_id
59
+ * @return array
60
+ * array(
61
+ * 'email_id' => int, <br />
62
+ * 'url_id' => int, <br />
63
+ * 'url' => string, <br />
64
+ * 'unique_clicks' => int, <br />
65
+ * 'total_clicks' => int <br />
66
+ * )
67
+ */
68
+ public function get_top_links($email_id, $top = 5, $order_direction = 'DESC') {
69
+ $limit = !empty($top) ? 'LIMIT 0, '.$top : '';
70
+ $query = '
71
  SELECT
72
  euu.`email_id`,
73
  u.`url_id`,
79
  JOIN
80
  [wysija]url u ON euu.url_id = u.url_id
81
  WHERE
82
+ euu.email_id = '.(int)$email_id.'
83
  GROUP BY
84
  u.`url_id`
85
+ ORDER BY `total_clicks` '.$order_direction.'
86
+ '.$limit.'
87
 
88
  ';
89
  $top_links = $this->get_results($query);
99
  $top_link['view_subscriber_url'] = admin_url('admin.php?'.implode('&', $params));
100
  }
101
 
102
+ return $top_links;
103
+ }
 
104
 
105
+ /**
106
+ * Get lists which a campaign was sent to
107
+ * @param int $campaign_id
108
+ * @return array(
109
+ * int => string (id => name),
110
+ * int => string (id => name),
111
+ * int => string (id => name),
112
+ * )
113
+ */
114
+ public function get_lists($campaign_id) {
115
+ $campaign_id = (int)$campaign_id;
116
+ $lists = array( );
117
+ if (!empty($campaign_id)) {
118
+ $query = '
119
  SELECT
120
  l.list_id,
121
  l.name
124
  JOIN
125
  `[wysija]list` l ON cl.`list_id` = l.`list_id` AND `campaign_id` = '.$campaign_id.'
126
  ';
127
+ $lists = $this->indexing_dataset_by_field('list_id', $this->get_results($query), null, 'name');
128
+ }
129
+ return $lists;
130
+ }
131
+
132
  }
modules/stats_newsletter_std/stats_newsletter_std_view.php CHANGED
@@ -1,100 +1,102 @@
1
  <?php
 
2
 
3
  class WYSIJA_module_view_stats_newsletter_std_view extends WYSIJA_view_back {
4
 
5
- public function hook_newsletter_top($data) {
6
- echo '<div class="stats_newsletter_std hook-column left" style="height:300px;">';
7
- if (empty($data['emails_count']))
8
- return;
9
- if (!empty($data['dataset']))
10
- foreach ($data['dataset'] as $index => $dataset) {
11
- $data['dataset'][$index]['container'] = 'chart' . md5($dataset['title'] . rand());
12
- echo '<div id="' . $data['dataset'][$index]['container'] . '" style="height: 300px; width:100%"></div>';
13
- }
14
- ?>
15
- <script type="text/javascript">
16
- // Load the Visualization API and the piechart package.
17
- google.load('visualization', '1.0', {'packages': ['corechart']});
18
- // Set a callback to run when the Google Visualization API is loaded.
19
- google.setOnLoadCallback(function() {
20
- <?php
21
- foreach ($data['dataset'] as $dataset) {
22
- ?>
23
- var dataTable = new google.visualization.DataTable();
24
- <?php
25
- foreach ($dataset['columns'] as $column) {
26
- ?>
27
- dataTable.addColumn('<?php echo $column['type']; ?>', '<?php echo $column['label']; ?>');
28
- <?php
29
- }
30
- ?>
31
- dataTable.addRows([
32
- <?php
33
- $count = 0;
34
- foreach ($dataset['data'] as $index => $value) {
35
- if ($count++ > 0)
36
- echo ',';
37
- echo '["' . $index . '",' . $value . ']';
38
- }
39
- ?>
40
- ]);
41
- var options = {
42
- title: '<?php echo $dataset['title']; ?>',
43
- is3D: false,
44
- chartArea: {left: 0},
45
- backgroundColor: 'transparent'
46
- };
47
- var chart = new google.visualization.PieChart(document.getElementById('<?php echo $dataset['container']; ?>'));
48
- chart.draw(dataTable, options);
49
- <?php
50
- }
51
- ?>
52
- });
53
- </script>
54
- <?php
55
- echo '</div>';
56
- }
57
-
58
- public function hook_newsletter_top_links($data) {
59
- ?>
60
- <div class="container-top-links container clear" rel="<?php echo $data['module_name']; ?>">
61
- <h3 class="title"><?php echo __('Top links', WYSIJA); ?></h3>
62
- <?php if (empty($data['top_links'])) { ?>
63
- <div class="notice-msg updated inline"><ul><li><?php echo $data['messages']['data_not_available']; ?></li></ul></div>
64
- <?php } else { ?>
65
- <table class="widefat fixed">
66
- <thead>
67
- <th class="check-column" style="width:40px">&nbsp;</th>
68
- <th class="link_column" style="width:40%"><?php echo __('Link', WYSIJA); ?></th>
69
- <!--th class="sortable sort-filter <?php // echo $data['order_direction']['clicks']; ?>" rel="click">
70
- <a href="" class="orderlink">
71
- <span><?php // echo __('Clicks'); ?></span><span class="sorting-indicator"></span>
72
- </a>
73
- </th-->
74
- <th class="click_column"><?php echo __('Unique clicks'); ?></th>
75
- <th class="click_column"><?php echo __('Total clicks'); ?></th>
76
- <th>&nbsp;</th>
77
- </thead>
78
- <tbody class="">
79
- <?php
80
- $i = 1;
81
- $alt = false;
 
82
  $link_helper = WYSIJA::get('links', 'helper');
83
- add_filter('wysija_link', array($link_helper, 'render_link'), 1, 6);
84
- foreach ($data['top_links'] as $url) {
85
  if ($i === 1)
86
  $wysija_link = apply_filters('wysija_link', '', $url['url'], 50, 15, true);
87
  else
88
  $wysija_link = apply_filters('wysija_link', '', $url['url'], 50, 15, true, '...');
89
-
90
-
91
- ?>
92
- <tr class="<?php echo $alt ? 'alternate' : '';
93
- $alt = !$alt; ?>">
94
- <td><?php echo $i; $i++; ?></td>
95
- <td><?php echo $wysija_link; ?></td>
96
- <td>
97
- <?php
98
  echo $url['unique_clicks'];
99
  if ($data['is_premium']) {
100
  echo ' - ';
@@ -102,117 +104,116 @@ class WYSIJA_module_view_stats_newsletter_std_view extends WYSIJA_view_back {
102
  echo __('Currently viewing', WYSIJA);
103
  else
104
  echo '<a href="'.$url['view_subscriber_url'].'">'.__('View subscribers', WYSIJA).'</a>';
105
-
106
  }
107
- ?>
108
- </td>
109
- <td><?php echo $url['total_clicks']; ?></td>
110
- <td>&nbsp;</td>
111
- </tr>
112
- <?php
113
- }
114
- ?>
115
- </tbody>
116
- </table>
117
- <?php } ?>
118
- <?php
119
- //$this->model->countRows = 103;//$data['top_subscribers']['count'];
120
  // if (empty($this->viewObj)) $this->viewObj = new stdClass();
121
  // $this->viewObj->msgPerPage = __('Show',WYSIJA).':';
122
  // $this->viewObj->title = '';
123
- //$this->limitPerPage(); // not implemented yet
124
- ?>
125
- <div class="cl"></div>
126
- </div>
127
- <?php
128
- }
129
-
130
- /**
131
- * Render actions of a newsletter
132
- * @param type $data
133
- */
134
- public function hook_newsletter_action_buttons($data) {
135
- echo '<div class="actions right">';
136
-
137
- $classes = function_exists('wp_star_rating') ? 'add-new-h2' : 'button-secondary2';
138
-
139
- // view button
140
- $email_helper = WYSIJA::get('email', 'helper');
141
- $link_view = $email_helper->getVIB($data['email_object']);
142
- echo '<a id="action-view" target="_blank" href="'.$link_view.'" class="action-view '.$classes.'">'.__('View', WYSIJA).'</a>';
143
-
144
- //duplicate button
145
- $duplicate_suffix = '';
146
- if (isset($data['email_object']['type']) && (int) $data['email_object']['type'] == 1) {
147
- $duplicate_suffix = 'Email';
148
- }
149
- $action = 'duplicate' . $duplicate_suffix;
150
- $params = array(
151
- 'page' => 'wysija_campaigns',
152
- 'action' => $action,
153
- 'id' => $data['email_id']
154
- );
155
- $link_duplicate = 'admin.php?'.http_build_query($params);
156
- echo '<a id="action-'.$action.'" href="'.$link_duplicate.'" class="action-'.$action.' '.$classes.'">'.__('Duplicate', WYSIJA).'</a>';
157
-
158
- $alternate = false;
159
- echo '<table class="newsletter-stats-block widefat fixed">';
160
- // Google tracking code
161
- if (!empty($data['email_object']['params']['googletrackingcode'])) {
162
- // echo '<div class="googletrackingcode"><span>' . __('Google Analytics', WYSIJA) . ':</span> ' . $data['email_object']['params']['googletrackingcode'] . '</div>';
163
- echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Google Analytics', WYSIJA).'</td><td>'.$data['email_object']['params']['googletrackingcode'].'</td></tr>';
164
- $alternate = !$alternate;
165
- }
166
-
167
- // Sent on:
168
- // echo '<div class="googletrackingcode"><span>' . __('Sent on', WYSIJA) . ':</span> ' . $this->fieldListHTML_created_at_time($data['email_object']['sent_at']) . '</div>';
169
- echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Sent on', WYSIJA).'</td><td>'.$this->fieldListHTML_created_at_time($data['email_object']['sent_at']).'</td></tr>';
170
- $alternate = !$alternate;
171
-
172
- // Lists:
173
- if (!empty($data['lists'])) {
174
- // echo '<div class="googletrackingcode"><span>' . __('Lists', WYSIJA) . ':</span> ' . implode(', ',$data['lists']) . '</div>';
175
- echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Lists', WYSIJA).'</td><td>'.implode(', ',$data['lists']).'</td></tr>';
176
- $alternate = !$alternate;
177
- }
178
-
179
- // From address:
180
- $_from_address = array();
181
- if (!empty($data['email_object']['from_name'])) {
182
- $_from_address[] = $data['email_object']['from_name'];
183
- }
184
- if (!empty($data['email_object']['from_email'])) {
185
- $_from_address[] = $data['email_object']['from_email'];
186
- }
187
- if (!empty($_from_address)) {
188
- // echo '<div class="googletrackingcode"><span>' . __('From', WYSIJA) . ':</span> ' . implode(', ',$_from_address) . '</div>';
189
- echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('From', WYSIJA).'</td><td>'.implode(' &lt;',$_from_address).(count($_from_address)>1 ? '&gt;' : '').'</td></tr>';
190
- $alternate = !$alternate;
191
- }
192
-
193
- // Reply-to address
194
- $_reply_to_address = array();
195
- if (!empty($data['email_object']['replyto_name'])) {
196
- $_reply_to_address[] = $data['email_object']['replyto_name'];
197
- }
198
- if (!empty($data['email_object']['replyto_email'])) {
199
- $_reply_to_address[] = $data['email_object']['replyto_email'];
200
- }
201
-
202
- if (!empty($_reply_to_address)) {
203
- // echo '<div class="googletrackingcode"><span>' . __('Reply-to', WYSIJA) . ':</span> ' . implode(', ',$_reply_to_address) . '</div>';
204
- echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Reply-to', WYSIJA).'</td><td>'.implode(' &lt;',$_reply_to_address). (count($_reply_to_address)>1 ? '&gt;' : '') . '</td></tr>';
205
- $alternate = !$alternate;
206
- }
207
-
208
- if (!empty($data['bounce'])) {
209
- // echo '<div class="googletrackingcode"><span>' . __('Bounce', WYSIJA) . ':</span> ' . $data['bounce'] . '</div>';
210
- echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Bounce', WYSIJA).'</td><td>'.$data['bounce'].'</td></tr>';
211
- $alternate = !$alternate;
212
- }
213
-
214
- echo '</table>';
215
- echo '</div>';
216
- }
217
 
218
  }
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
 
4
  class WYSIJA_module_view_stats_newsletter_std_view extends WYSIJA_view_back {
5
 
6
+ public function hook_newsletter_top($data) {
7
+ echo '<div class="stats_newsletter_std hook-column left" style="height:300px;">';
8
+ if (empty($data['emails_count']))
9
+ return;
10
+ if (!empty($data['dataset']))
11
+ foreach ($data['dataset'] as $index => $dataset) {
12
+ $data['dataset'][$index]['container'] = 'chart'.md5($dataset['title'].rand());
13
+ echo '<div id="'.$data['dataset'][$index]['container'].'" style="height: 300px; width:100%"></div>';
14
+ }
15
+ ?>
16
+ <script type="text/javascript">
17
+ // Load the Visualization API and the piechart package.
18
+ google.load('visualization', '1.0', {'packages': ['corechart']});
19
+ // Set a callback to run when the Google Visualization API is loaded.
20
+ google.setOnLoadCallback(function() {
21
+ <?php
22
+ foreach ($data['dataset'] as $dataset) {
23
+ ?>
24
+ var dataTable = new google.visualization.DataTable();
25
+ <?php
26
+ foreach ($dataset['columns'] as $column) {
27
+ ?>
28
+ dataTable.addColumn('<?php echo $column['type']; ?>', '<?php echo $column['label']; ?>');
29
+ <?php
30
+ }
31
+ ?>
32
+ dataTable.addRows([
33
+ <?php
34
+ $count = 0;
35
+ foreach ($dataset['data'] as $index => $value) {
36
+ if ($count++ > 0)
37
+ echo ',';
38
+ echo '["'.$index.'",'.$value.']';
39
+ }
40
+ ?>
41
+ ]);
42
+ var options = {
43
+ title: '<?php echo $dataset['title']; ?>',
44
+ is3D: false,
45
+ chartArea: {left: 0},
46
+ backgroundColor: 'transparent'
47
+ };
48
+ var chart = new google.visualization.PieChart(document.getElementById('<?php echo $dataset['container']; ?>'));
49
+ chart.draw(dataTable, options);
50
+ <?php
51
+ }
52
+ ?>
53
+ });
54
+ </script>
55
+ <?php
56
+ echo '</div>';
57
+ }
58
+
59
+ public function hook_newsletter_top_links($data) {
60
+ ?>
61
+ <div class="container-top-links container clear" rel="<?php echo $data['module_name']; ?>">
62
+ <h3 class="title"><?php echo __('Top links', WYSIJA); ?></h3>
63
+ <?php if (empty($data['top_links'])) { ?>
64
+ <div class="notice-msg updated inline"><ul><li><?php echo $data['messages']['data_not_available']; ?></li></ul></div>
65
+ <?php }
66
+ else { ?>
67
+ <table class="widefat fixed">
68
+ <thead>
69
+ <th class="check-column" style="width:40px">&nbsp;</th>
70
+ <th class="link_column" style="width:40%"><?php echo __('Link', WYSIJA); ?></th>
71
+ <!--th class="sortable sort-filter <?php // echo $data['order_direction']['clicks']; ?>" rel="click">
72
+ <a href="" class="orderlink">
73
+ <span><?php // echo __('Clicks'); ?></span><span class="sorting-indicator"></span>
74
+ </a>
75
+ </th-->
76
+ <th class="click_column"><?php echo __('Unique clicks'); ?></th>
77
+ <th class="click_column"><?php echo __('Total clicks'); ?></th>
78
+ <th>&nbsp;</th>
79
+ </thead>
80
+ <tbody class="">
81
+ <?php
82
+ $i = 1;
83
+ $alt = false;
84
  $link_helper = WYSIJA::get('links', 'helper');
85
+ add_filter('wysija_link', array( $link_helper, 'render_link' ), 1, 6);
86
+ foreach ($data['top_links'] as $url) {
87
  if ($i === 1)
88
  $wysija_link = apply_filters('wysija_link', '', $url['url'], 50, 15, true);
89
  else
90
  $wysija_link = apply_filters('wysija_link', '', $url['url'], 50, 15, true, '...');
91
+ ?>
92
+ <tr class="<?php echo $alt ? 'alternate' : '';
93
+ $alt = !$alt;
94
+ ?>">
95
+ <td><?php echo $i;
96
+ $i++; ?></td>
97
+ <td><?php echo $wysija_link; ?></td>
98
+ <td>
99
+ <?php
100
  echo $url['unique_clicks'];
101
  if ($data['is_premium']) {
102
  echo ' - ';
104
  echo __('Currently viewing', WYSIJA);
105
  else
106
  echo '<a href="'.$url['view_subscriber_url'].'">'.__('View subscribers', WYSIJA).'</a>';
 
107
  }
108
+ ?>
109
+ </td>
110
+ <td><?php echo $url['total_clicks']; ?></td>
111
+ <td>&nbsp;</td>
112
+ </tr>
113
+ <?php
114
+ }
115
+ ?>
116
+ </tbody>
117
+ </table>
118
+ <?php } ?>
119
+ <?php
120
+ //$this->model->countRows = 103;//$data['top_subscribers']['count'];
121
  // if (empty($this->viewObj)) $this->viewObj = new stdClass();
122
  // $this->viewObj->msgPerPage = __('Show',WYSIJA).':';
123
  // $this->viewObj->title = '';
124
+ //$this->limitPerPage(); // not implemented yet
125
+ ?>
126
+ <div class="cl"></div>
127
+ </div>
128
+ <?php
129
+ }
130
+
131
+ /**
132
+ * Render actions of a newsletter
133
+ * @param type $data
134
+ */
135
+ public function hook_newsletter_action_buttons($data) {
136
+ echo '<div class="actions right">';
137
+
138
+ $classes = function_exists('wp_star_rating') ? 'add-new-h2' : 'button-secondary2';
139
+
140
+ // view button
141
+ $email_helper = WYSIJA::get('email', 'helper');
142
+ $link_view = $email_helper->getVIB($data['email_object']);
143
+ echo '<a id="action-view" target="_blank" href="'.$link_view.'" class="action-view '.$classes.'">'.__('View', WYSIJA).'</a>';
144
+
145
+ //duplicate button
146
+ $duplicate_suffix = '';
147
+ if (isset($data['email_object']['type']) && (int)$data['email_object']['type'] == 1) {
148
+ $duplicate_suffix = 'Email';
149
+ }
150
+ $action = 'duplicate'.$duplicate_suffix;
151
+ $params = array(
152
+ 'page' => 'wysija_campaigns',
153
+ 'action' => $action,
154
+ 'id' => $data['email_id']
155
+ );
156
+ $link_duplicate = 'admin.php?'.http_build_query($params);
157
+ echo '<a id="action-'.$action.'" href="'.$link_duplicate.'" class="action-'.$action.' '.$classes.'">'.__('Duplicate', WYSIJA).'</a>';
158
+
159
+ $alternate = false;
160
+ echo '<table class="newsletter-stats-block widefat fixed">';
161
+ // Google tracking code
162
+ if (!empty($data['email_object']['params']['googletrackingcode'])) {
163
+ // echo '<div class="googletrackingcode"><span>' . __('Google Analytics', WYSIJA) . ':</span> ' . $data['email_object']['params']['googletrackingcode'] . '</div>';
164
+ echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Google Analytics', WYSIJA).'</td><td>'.$data['email_object']['params']['googletrackingcode'].'</td></tr>';
165
+ $alternate = !$alternate;
166
+ }
167
+
168
+ // Sent on:
169
+ // echo '<div class="googletrackingcode"><span>' . __('Sent on', WYSIJA) . ':</span> ' . $this->fieldListHTML_created_at_time($data['email_object']['sent_at']) . '</div>';
170
+ echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Sent on', WYSIJA).'</td><td>'.$this->fieldListHTML_created_at_time($data['email_object']['sent_at']).'</td></tr>';
171
+ $alternate = !$alternate;
172
+
173
+ // Lists:
174
+ if (!empty($data['lists'])) {
175
+ // echo '<div class="googletrackingcode"><span>' . __('Lists', WYSIJA) . ':</span> ' . implode(', ',$data['lists']) . '</div>';
176
+ echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Lists', WYSIJA).'</td><td>'.implode(', ', $data['lists']).'</td></tr>';
177
+ $alternate = !$alternate;
178
+ }
179
+
180
+ // From address:
181
+ $_from_address = array( );
182
+ if (!empty($data['email_object']['from_name'])) {
183
+ $_from_address[] = $data['email_object']['from_name'];
184
+ }
185
+ if (!empty($data['email_object']['from_email'])) {
186
+ $_from_address[] = $data['email_object']['from_email'];
187
+ }
188
+ if (!empty($_from_address)) {
189
+ // echo '<div class="googletrackingcode"><span>' . __('From', WYSIJA) . ':</span> ' . implode(', ',$_from_address) . '</div>';
190
+ echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('From', WYSIJA).'</td><td>'.implode(' &lt;', $_from_address).(count($_from_address) > 1 ? '&gt;' : '').'</td></tr>';
191
+ $alternate = !$alternate;
192
+ }
193
+
194
+ // Reply-to address
195
+ $_reply_to_address = array( );
196
+ if (!empty($data['email_object']['replyto_name'])) {
197
+ $_reply_to_address[] = $data['email_object']['replyto_name'];
198
+ }
199
+ if (!empty($data['email_object']['replyto_email'])) {
200
+ $_reply_to_address[] = $data['email_object']['replyto_email'];
201
+ }
202
+
203
+ if (!empty($_reply_to_address)) {
204
+ // echo '<div class="googletrackingcode"><span>' . __('Reply-to', WYSIJA) . ':</span> ' . implode(', ',$_reply_to_address) . '</div>';
205
+ echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Reply-to', WYSIJA).'</td><td>'.implode(' &lt;', $_reply_to_address).(count($_reply_to_address) > 1 ? '&gt;' : '').'</td></tr>';
206
+ $alternate = !$alternate;
207
+ }
208
+
209
+ if (!empty($data['bounce'])) {
210
+ // echo '<div class="googletrackingcode"><span>' . __('Bounce', WYSIJA) . ':</span> ' . $data['bounce'] . '</div>';
211
+ echo '<tr class="'.($alternate ? 'alternate' : '').'"><td class="label">'.__('Bounce', WYSIJA).'</td><td>'.$data['bounce'].'</td></tr>';
212
+ $alternate = !$alternate;
213
+ }
214
+
215
+ echo '</table>';
216
+ echo '</div>';
217
+ }
218
 
219
  }
modules/stats_reportcards_std/stats_reportcards_std.php CHANGED
@@ -1,175 +1,176 @@
1
  <?php
2
-
3
  defined('WYSIJA') or die('Restricted access');
4
 
5
- require_once(dirname(__FILE__) . DS . 'stats_reportcards_std_model.php');
6
 
7
  class WYSIJA_module_stats_reportcards_std extends WYSIJA_module_statistics {
8
 
9
- public $name = 'stats_reportcards_std';
10
- public $model = 'WYSIJA_model_stats_reportcards_std';
11
- public $view = 'stats_reportcards_std_view';
12
-
13
- /**
14
- * Pre-defined cards
15
- * Format
16
- * array(
17
- * CODE1 => array(
18
- * 'title' => 'Lorem ipsum', // (optional, but at least one of them - title or description - is declared)
19
- * 'description' => 'Lorem ipsum', // (optional, but at least one of them - title or description - is declared)
20
- * '
21
- * ),
22
- * CODE2 => array(
23
- * 'title' => 'Lorem ipsum 1',
24
- * 'description' => 'Lorem ipsum 2',
25
- * '
26
- * ),
27
- * )
28
- * @var array
29
- */
30
- protected $cards = array();
31
-
32
- /**
33
- *
34
- * @var array all possible cards for a specific newsletter
35
- * Format: same as $cards()
36
- */
37
- protected $report_cards = array();
38
-
39
- public function __construct() {
40
- parent::__construct();
41
- $this->init_cards();
42
- }
43
-
44
- public function hook_newsletter_top($params) {
45
-
46
- $report_cards = $this->get_report_cards($params);
47
- $this->data['report_cards'] = $this->populate_cards($report_cards);
48
-
49
- $this->view_show = 'hook_newsletter_top';
50
- return $this->render();
51
- }
52
-
53
- protected function get_report_cards($params) {
54
- //if case 1
55
- // if case 2
56
- $params = $params;
57
-
58
- $mail_id = $params['email_id'];
59
-
60
- // first newsletters
61
- if ($this->model_obj->is_the_first_newsletter())
62
- $this->add_card('N0001');
63
-
64
- // bounce rate
65
- $bounce_rate = $this->model_obj->get_rate($mail_id, WYSIJA_model_stats_reportcards_std::EMAIL_STATUS_BOUNCE);
66
- if ($bounce_rate !== NULL and $bounce_rate > 5.0)
67
- $this->add_card('N0006');
68
- else
69
- $this->add_card('N0007');
70
-
71
-
72
-
73
- return $this->report_cards;
74
- }
75
-
76
- protected function add_card($card_id) {
77
- $this->report_cards[] = $card_id;
78
- }
79
-
80
- /**
81
- * Combine card_ids with their content
82
- * @param type $report_cards
83
- * @return type
84
- */
85
- protected function populate_cards($report_cards) {
86
- $tmp = array();
87
- $report_cards = array_unique($report_cards);
88
- foreach ($report_cards as $card_id) {
89
- if (!empty($this->cards[$card_id]))
90
- $tmp[$card_id] = $this->cards[$card_id];
91
- }
92
- return $tmp;
93
- }
94
-
95
- protected function init_cards() {
96
- // first newsletter
97
- $this->cards['N0001'] = array(
98
- 'title' => __('This is the first newsletter. Send one more to get useful comparisons.', WYSIJA),
99
- 'description' => false
100
- );
101
-
102
- // open rate
103
- $url = '#';
104
- $this->cards['N0002'] = array(
105
- 'title' => __('Opens', WYSIJA),
106
- 'description' => str_replace(
107
- array('[link]', '[/link]'), array('<a target="_blank" href="' . $url . '">', '</a>'), sprintf(__('Over %1$s%% is excellent. %2$s%% to %3$s%% is good. Under that, it is bad. [link]Read why this stat can be unreliable on support.mailpoet.com[/link]', WYSIJA), 30, 15, 30)
108
- )
109
- );
110
-
111
- // click
112
- $url = '#';
113
- $this->cards['N0003'] = array(
114
- 'title' => __('Clicks', WYSIJA),
115
- 'description' => str_replace(
116
- array('[link]', '[/link]'), array('<a target="_blank" href="' . $url . '">', '</a>'), sprintf(__('Over %1$s%% is great. Between %2$s%% and %3$s%% is good. Under %4$s%% is poor. It is normal if you have no links.', WYSIJA), 15, 15, 30, 5)
117
- )
118
- );
119
-
120
- // unsubscribe
121
- $url = '#';
122
- $this->cards['N0004'] = array(
123
- 'title' => __('Unsubscribes', WYSIJA),
124
- 'description' => str_replace(
125
- array('[link]', '[/link]'), array('<a target="_blank" href="' . $url . '">', '</a>'), sprintf(__('Under %1$s%% is great. %2$s%% - %3$s%% is good. Over %4$s%%, we would assume you are a spammer. [link]Read more on support.mailpoet.com.[/link]', WYSIJA), 1, 1, 3, 5)
126
- )
127
- );
128
-
129
- // bounces
130
- $url = '#';
131
- $this->cards['N0004'] = array(
132
- 'title' => __('Unsubscribes', WYSIJA),
133
- 'description' => str_replace(
134
- array('[link]', '[/link]'), array('<a target="_blank" href="' . $url . '">', '</a>'), sprintf(__('Excellent under %1$s%%. Under %2$s%% is acceptable. Over that, some servers might consider blocking. [link]Read more on support.mailpoet.com.[/link]', WYSIJA), 1, 5)
135
- )
136
- );
137
-
138
- // bounces
139
- $url = '#';
140
- $this->cards['N0005'] = array(
141
- 'title' => __('Unsubscribes', WYSIJA),
142
- 'description' => str_replace(
143
- array('[link]', '[/link]'), array('<a target="_blank" href="' . $url . '">', '</a>'), sprintf(__('Excellent under %1$s%%. Under %2$s%% is acceptable. Over that, some servers might consider blocking. [link]Read more on support.mailpoet.com.[/link]', WYSIJA), 1, 5)
144
- )
145
- );
146
-
147
- // bounces
148
- $url = '#';
149
- $this->cards['N0006'] = array(
150
- 'title' => __('Bounced', WYSIJA),
151
- 'description' => str_replace(
152
- array('[link]', '[/link]'), array('<a target="_blank" href="' . $url . '">', '</a>'), sprintf(__('Ouch. You are over %1$s%%. MailPoet will unsubscribe the invalid emails, thanks to the [link]Automatic Bounce Handler[/link]', WYSIJA), 5)
153
- )
154
- );
155
-
156
- // spam score (pendding)
157
- $url = '#';
158
- $this->cards['N0007'] = array(
159
- 'title' => __('Bounced', WYSIJA),
160
- 'description' => str_replace(
161
- array('[link]', '[/link]'), array('<a target="_blank" href="' . $url . '">', '</a>'), sprintf(__('Excellent under %1$s%%. Under %2$s%% is acceptable. Over that, some servers might consider blocking. [link]Read more on support.mailpoet.com.[/link]', WYSIJA), 1, 5)
162
- )
163
- );
164
-
165
- // spam score (pendding)
166
- $url = '#';
167
- $this->cards['N0008'] = array(
168
- 'title' => __('Google campaign', WYSIJA),
169
- 'description' => str_replace(
170
- array('[link]', '[/link]'), array('<a target="_blank" href="' . $url . '">', '</a>'), sprintf(__('Excellent under %1$s%%. Under %2$s%% is acceptable. Over that, some servers might consider blocking. [link]Read more on support.mailpoet.com.[/link]', WYSIJA), 1, 5)
171
- )
172
- );
173
- }
 
 
174
 
175
  }
1
  <?php
 
2
  defined('WYSIJA') or die('Restricted access');
3
 
4
+ require_once(dirname(__FILE__).DS.'stats_reportcards_std_model.php');
5
 
6
  class WYSIJA_module_stats_reportcards_std extends WYSIJA_module_statistics {
7
 
8
+ public $name = 'stats_reportcards_std';
9
+
10
+ public $model = 'WYSIJA_model_stats_reportcards_std';
11
+
12
+ public $view = 'stats_reportcards_std_view';
13
+
14
+ /**
15
+ * Pre-defined cards
16
+ * Format
17
+ * array(
18
+ * CODE1 => array(
19
+ * 'title' => 'Lorem ipsum', // (optional, but at least one of them - title or description - is declared)
20
+ * 'description' => 'Lorem ipsum', // (optional, but at least one of them - title or description - is declared)
21
+ * '
22
+ * ),
23
+ * CODE2 => array(
24
+ * 'title' => 'Lorem ipsum 1',
25
+ * 'description' => 'Lorem ipsum 2',
26
+ * '
27
+ * ),
28
+ * )
29
+ * @var array
30
+ */
31
+ protected $cards = array( );
32
+
33
+ /**
34
+ *
35
+ * @var array all possible cards for a specific newsletter
36
+ * Format: same as $cards()
37
+ */
38
+ protected $report_cards = array( );
39
+
40
+ public function __construct() {
41
+ parent::__construct();
42
+ $this->init_cards();
43
+ }
44
+
45
+ public function hook_newsletter_top($params) {
46
+
47
+ $report_cards = $this->get_report_cards($params);
48
+ $this->data['report_cards'] = $this->populate_cards($report_cards);
49
+
50
+ $this->view_show = 'hook_newsletter_top';
51
+ return $this->render();
52
+ }
53
+
54
+ protected function get_report_cards($params) {
55
+ //if case 1
56
+ // if case 2
57
+ $params = $params;
58
+
59
+ $mail_id = $params['email_id'];
60
+
61
+ // first newsletters
62
+ if ($this->model_obj->is_the_first_newsletter())
63
+ $this->add_card('N0001');
64
+
65
+ // bounce rate
66
+ $bounce_rate = $this->model_obj->get_rate($mail_id, WYSIJA_model_stats_reportcards_std::EMAIL_STATUS_BOUNCE);
67
+ if ($bounce_rate !== NULL and $bounce_rate > 5.0)
68
+ $this->add_card('N0006');
69
+ else
70
+ $this->add_card('N0007');
71
+
72
+
73
+
74
+ return $this->report_cards;
75
+ }
76
+
77
+ protected function add_card($card_id) {
78
+ $this->report_cards[] = $card_id;
79
+ }
80
+
81
+ /**
82
+ * Combine card_ids with their content
83
+ * @param type $report_cards
84
+ * @return type
85
+ */
86
+ protected function populate_cards($report_cards) {
87
+ $tmp = array( );
88
+ $report_cards = array_unique($report_cards);
89
+ foreach ($report_cards as $card_id) {
90
+ if (!empty($this->cards[$card_id]))
91
+ $tmp[$card_id] = $this->cards[$card_id];
92
+ }
93
+ return $tmp;
94
+ }
95
+
96
+ protected function init_cards() {
97
+ // first newsletter
98
+ $this->cards['N0001'] = array(
99
+ 'title' => __('This is the first newsletter. Send one more to get useful comparisons.', WYSIJA),
100
+ 'description' => false
101
+ );
102
+
103
+ // open rate
104
+ $url = '#';
105
+ $this->cards['N0002'] = array(
106
+ 'title' => __('Opens', WYSIJA),
107
+ 'description' => str_replace(
108
+ array( '[link]', '[/link]' ), array( '<a target="_blank" href="'.$url.'">', '</a>' ), sprintf(__('Over %1$s%% is excellent. %2$s%% to %3$s%% is good. Under that, it is bad. [link]Read why this stat can be unreliable on support.mailpoet.com[/link]', WYSIJA), 30, 15, 30)
109
+ )
110
+ );
111
+
112
+ // click
113
+ $url = '#';
114
+ $this->cards['N0003'] = array(
115
+ 'title' => __('Clicks', WYSIJA),
116
+ 'description' => str_replace(
117
+ array( '[link]', '[/link]' ), array( '<a target="_blank" href="'.$url.'">', '</a>' ), sprintf(__('Over %1$s%% is great. Between %2$s%% and %3$s%% is good. Under %4$s%% is poor. It is normal if you have no links.', WYSIJA), 15, 15, 30, 5)
118
+ )
119
+ );
120
+
121
+ // unsubscribe
122
+ $url = '#';
123
+ $this->cards['N0004'] = array(
124
+ 'title' => __('Unsubscribes', WYSIJA),
125
+ 'description' => str_replace(
126
+ array( '[link]', '[/link]' ), array( '<a target="_blank" href="'.$url.'">', '</a>' ), sprintf(__('Under %1$s%% is great. %2$s%% - %3$s%% is good. Over %4$s%%, we would assume you are a spammer. [link]Read more on support.mailpoet.com.[/link]', WYSIJA), 1, 1, 3, 5)
127
+ )
128
+ );
129
+
130
+ // bounces
131
+ $url = '#';
132
+ $this->cards['N0004'] = array(
133
+ 'title' => __('Unsubscribes', WYSIJA),
134
+ 'description' => str_replace(
135
+ array( '[link]', '[/link]' ), array( '<a target="_blank" href="'.$url.'">', '</a>' ), sprintf(__('Excellent under %1$s%%. Under %2$s%% is acceptable. Over that, some servers might consider blocking. [link]Read more on support.mailpoet.com.[/link]', WYSIJA), 1, 5)
136
+ )
137
+ );
138
+
139
+ // bounces
140
+ $url = '#';
141
+ $this->cards['N0005'] = array(
142
+ 'title' => __('Unsubscribes', WYSIJA),
143
+ 'description' => str_replace(
144
+ array( '[link]', '[/link]' ), array( '<a target="_blank" href="'.$url.'">', '</a>' ), sprintf(__('Excellent under %1$s%%. Under %2$s%% is acceptable. Over that, some servers might consider blocking. [link]Read more on support.mailpoet.com.[/link]', WYSIJA), 1, 5)
145
+ )
146
+ );
147
+
148
+ // bounces
149
+ $url = '#';
150
+ $this->cards['N0006'] = array(
151
+ 'title' => __('Bounced', WYSIJA),
152
+ 'description' => str_replace(
153
+ array( '[link]', '[/link]' ), array( '<a target="_blank" href="'.$url.'">', '</a>' ), sprintf(__('Ouch. You are over %1$s%%. MailPoet will unsubscribe the invalid emails, thanks to the [link]Automatic Bounce Handler[/link]', WYSIJA), 5)
154
+ )
155
+ );
156
+
157
+ // spam score (pendding)
158
+ $url = '#';
159
+ $this->cards['N0007'] = array(
160
+ 'title' => __('Bounced', WYSIJA),
161
+ 'description' => str_replace(
162
+ array( '[link]', '[/link]' ), array( '<a target="_blank" href="'.$url.'">', '</a>' ), sprintf(__('Excellent under %1$s%%. Under %2$s%% is acceptable. Over that, some servers might consider blocking. [link]Read more on support.mailpoet.com.[/link]', WYSIJA), 1, 5)
163
+ )
164
+ );
165
+
166
+ // spam score (pendding)
167
+ $url = '#';
168
+ $this->cards['N0008'] = array(
169
+ 'title' => __('Google campaign', WYSIJA),
170
+ 'description' => str_replace(
171
+ array( '[link]', '[/link]' ), array( '<a target="_blank" href="'.$url.'">', '</a>' ), sprintf(__('Excellent under %1$s%%. Under %2$s%% is acceptable. Over that, some servers might consider blocking. [link]Read more on support.mailpoet.com.[/link]', WYSIJA), 1, 5)
172
+ )
173
+ );
174
+ }
175
 
176
  }
modules/stats_reportcards_std/stats_reportcards_std_model.php CHANGED
@@ -1,111 +1,119 @@
1
  <?php
 
2
 
3
  class WYSIJA_model_stats_reportcards_std extends WYSIJA_module_statistics_model {
4
- /**
5
- * @todo: move all kinds of these constants into a global class
6
- */
7
-
8
- const EMAIL_STATUS_QUEUE = -3;
9
- const EMAIL_STATUS_NOT_SENT = -2;
10
- const EMAIL_STATUS_BOUNCE = -1;
11
- const EMAIL_STATUS_SENT = 0;
12
- const EMAIL_STATUS_OPENED = 1;
13
- const EMAIL_STATUS_CLICKED = 2;
14
- const EMAIL_STATUS_UNSUBSCRIBED = 3;
15
-
16
- /**
17
- * Store email status (output of $this->get_email_status())
18
- * @var array
19
- */
20
- protected static $emails_status = array();
21
-
22
- /**
23
- * Store email count (output of $this->get_email_status())
24
- * @var int
25
- */
26
- protected static $emails_count;
27
-
28
- /**
29
- * Get and group by status of a specific newsletter which was sent to subscribers
30
- * @param int $user_id
31
- * @return array list of emails, group by status. It contains an empy list, or list of one or more status
32
- * array(
33
- * status => emails count, // status: -3: inqueue, -2:notsent, -1: bounced, 0: sent, 1: open, 2: clicked, 3: unsubscribed
34
- * status => emails count,
35
- * ...
36
- * status => emails count
37
- * )
38
- */
39
- public function get_email_status($email_id) {
40
- if (!isset(self::$emails_status[$email_id])) {
41
- // get stats email status
42
- $query = '
43
- SELECT
44
- count(`email_id`) as emails,
45
- `status`
46
- FROM
 
 
 
 
 
 
 
47
  `[wysija]email_user_stat`
48
- WHERE `email_id` = ' . (int) $email_id . '
49
  GROUP BY `status`'
50
- ;
51
- self::$emails_status[$email_id] = $this->indexing_dataset_by_field('status', $this->get_results($query), false, 'emails');
52
- }
53
- return self::$emails_status[$email_id];
54
- }
55
-
56
- /**
57
- *
58
- * @param int $user_id
59
- * @return int a number of received / sent newsletters to a specific user
60
- */
61
- public function get_emails_count($email_id) {
62
- if (!isset(self::$emails_count)) {
63
- // get emails group by status
64
- $count = 0;
65
- $emails_status = $this->get_email_status($email_id); // we don't need to write a separated sql query here, reduce 1 sql request
66
- if (empty($emails_status))
67
- return $count;
68
- foreach ($emails_status as $emails)
69
- $count += $emails;
70
- self::$emails_count = $count;
71
- }
72
- return self::$emails_count;
73
- }
74
-
75
- /**
76
- * Check if we are sending the first email
77
- * @return type
78
- */
79
- public function is_the_first_newsletter() {
80
- $query = '
81
- SELECT
82
- COUNT(`email_id`) as `count`
83
- FROM
84
- [wysija]email
85
- WHERE
86
  `status` > 0';
87
- $result = $this->get_results($query);
88
- return (int) $result[0]['count'] >= 1;
89
- }
90
-
91
- public function get_previous_newsletter($email_id) {
92
- $email_id;
93
- return 0;
94
- }
95
-
96
- /**
97
- * Get rate by email status
98
- * @param int $email_id
99
- * @param int $status usually we pass constants such as WYSIJA_model_stats_reportcards_std::EMAIL_STATUS_QUEUE, etc...
100
- * @return null
101
- */
102
- public function get_rate($email_id, $status) {
103
- $email_status = $this->get_email_status($email_id);
104
- $email_count = $this->get_emails_count($email_id);
105
- if (empty($email_count))
106
- return NULL;
107
- $real_emails = !empty($email_status[$status]) ? (int) $email_status[$status] : 0;
108
- return round($real_emails / $email_count, 2);
109
- }
110
 
111
  }
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
 
4
  class WYSIJA_model_stats_reportcards_std extends WYSIJA_module_statistics_model {
5
+
6
+ /**
7
+ * @todo: move all kinds of these constants into a global class
8
+ */
9
+
10
+ const EMAIL_STATUS_QUEUE = -3;
11
+
12
+ const EMAIL_STATUS_NOT_SENT = -2;
13
+
14
+ const EMAIL_STATUS_BOUNCE = -1;
15
+
16
+ const EMAIL_STATUS_SENT = 0;
17
+
18
+ const EMAIL_STATUS_OPENED = 1;
19
+
20
+ const EMAIL_STATUS_CLICKED = 2;
21
+
22
+ const EMAIL_STATUS_UNSUBSCRIBED = 3;
23
+
24
+ /**
25
+ * Store email status (output of $this->get_email_status())
26
+ * @var array
27
+ */
28
+ protected static $emails_status = array( );
29
+
30
+ /**
31
+ * Store email count (output of $this->get_email_status())
32
+ * @var int
33
+ */
34
+ protected static $emails_count;
35
+
36
+ /**
37
+ * Get and group by status of a specific newsletter which was sent to subscribers
38
+ * @param int $user_id
39
+ * @return array list of emails, group by status. It contains an empy list, or list of one or more status
40
+ * array(
41
+ * status => emails count, // status: -3: inqueue, -2:notsent, -1: bounced, 0: sent, 1: open, 2: clicked, 3: unsubscribed
42
+ * status => emails count,
43
+ * ...
44
+ * status => emails count
45
+ * )
46
+ */
47
+ public function get_email_status($email_id) {
48
+ if (!isset(self::$emails_status[$email_id])) {
49
+ // get stats email status
50
+ $query = '
51
+ SELECT
52
+ count(`email_id`) as emails,
53
+ `status`
54
+ FROM
55
  `[wysija]email_user_stat`
56
+ WHERE `email_id` = '.(int)$email_id.'
57
  GROUP BY `status`'
58
+ ;
59
+ self::$emails_status[$email_id] = $this->indexing_dataset_by_field('status', $this->get_results($query), false, 'emails');
60
+ }
61
+ return self::$emails_status[$email_id];
62
+ }
63
+
64
+ /**
65
+ *
66
+ * @param int $user_id
67
+ * @return int a number of received / sent newsletters to a specific user
68
+ */
69
+ public function get_emails_count($email_id) {
70
+ if (!isset(self::$emails_count)) {
71
+ // get emails group by status
72
+ $count = 0;
73
+ $emails_status = $this->get_email_status($email_id); // we don't need to write a separated sql query here, reduce 1 sql request
74
+ if (empty($emails_status))
75
+ return $count;
76
+ foreach ($emails_status as $emails)
77
+ $count += $emails;
78
+ self::$emails_count = $count;
79
+ }
80
+ return self::$emails_count;
81
+ }
82
+
83
+ /**
84
+ * Check if we are sending the first email
85
+ * @return type
86
+ */
87
+ public function is_the_first_newsletter() {
88
+ $query = '
89
+ SELECT
90
+ COUNT(`email_id`) as `count`
91
+ FROM
92
+ [wysija]email
93
+ WHERE
94
  `status` > 0';
95
+ $result = $this->get_results($query);
96
+ return (int)$result[0]['count'] >= 1;
97
+ }
98
+
99
+ public function get_previous_newsletter($email_id) {
100
+ $email_id;
101
+ return 0;
102
+ }
103
+
104
+ /**
105
+ * Get rate by email status
106
+ * @param int $email_id
107
+ * @param int $status usually we pass constants such as WYSIJA_model_stats_reportcards_std::EMAIL_STATUS_QUEUE, etc...
108
+ * @return null
109
+ */
110
+ public function get_rate($email_id, $status) {
111
+ $email_status = $this->get_email_status($email_id);
112
+ $email_count = $this->get_emails_count($email_id);
113
+ if (empty($email_count))
114
+ return NULL;
115
+ $real_emails = !empty($email_status[$status]) ? (int)$email_status[$status] : 0;
116
+ return round($real_emails / $email_count, 2);
117
+ }
118
 
119
  }
modules/stats_reportcards_std/stats_reportcards_std_view.php CHANGED
@@ -1,23 +1,24 @@
1
  <?php
 
2
 
3
  class WYSIJA_module_view_stats_reportcards_std_view extends WYSIJA_view_back {
4
 
5
- public function hook_newsletter_top($data) {
6
- if (empty($data['report_cards']))
7
- return;
8
- echo '<div class="stats_reportcards_std hook-column">';
9
- foreach ($data['report_cards'] as $card_id => $card) {
10
- echo '<div class="report-card">';
11
- if (!empty($card['title']))
12
- echo '<span class="card-title">' . $card['title'] . '</span>';
13
- if (!empty($card['title']) && !empty($card['description']))
14
- echo ':&nbsp;';
15
- if (!empty($card['description']))
16
- echo '<span class="card-content">' . $card['description'] . '</span>';
17
- echo '<br />';
18
- echo '</div>';
19
- }
20
- echo '</div>';
21
- }
22
 
23
  }
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
 
4
  class WYSIJA_module_view_stats_reportcards_std_view extends WYSIJA_view_back {
5
 
6
+ public function hook_newsletter_top($data) {
7
+ if (empty($data['report_cards']))
8
+ return;
9
+ echo '<div class="stats_reportcards_std hook-column">';
10
+ foreach ($data['report_cards'] as $card_id => $card) {
11
+ echo '<div class="report-card">';
12
+ if (!empty($card['title']))
13
+ echo '<span class="card-title">'.$card['title'].'</span>';
14
+ if (!empty($card['title']) && !empty($card['description']))
15
+ echo ':&nbsp;';
16
+ if (!empty($card['description']))
17
+ echo '<span class="card-content">'.$card['description'].'</span>';
18
+ echo '<br />';
19
+ echo '</div>';
20
+ }
21
+ echo '</div>';
22
+ }
23
 
24
  }
modules/stats_subscribers_std/stats_subscribers_std.php CHANGED
@@ -1,108 +1,110 @@
1
  <?php
2
-
3
  defined('WYSIJA') or die('Restricted access');
4
 
5
- require_once(dirname(__FILE__) . DS . 'stats_subscribers_std_model.php');
6
 
7
  class WYSIJA_module_stats_subscribers_std extends WYSIJA_module_statistics {
8
 
9
- public $name = 'stats_subscribers_std';
10
- public $model = 'WYSIJA_model_stats_subscribers_std';
11
- public $view = 'stats_subscribers_std_view';
12
- static protected $stats_data;
13
-
14
- public function __construct() {
15
- parent::__construct();
16
- }
17
-
18
- protected function get_order_direction($params) {
19
- $order_direction = (!empty($params['order_direction']) && $params['order_direction'] == WYSIJA_module_statistics::ORDER_DIRECTION_ASC ? 'asc' : 'desc');
20
- return array(
21
- 'sent' => !empty($params['order_by']) && $params['order_by'] == WYSIJA_module_statistics::ORDER_BY_SENT ? 'sorted ' . $order_direction : '',
22
- 'opens' => !empty($params['order_by']) && $params['order_by'] == WYSIJA_module_statistics::ORDER_BY_OPEN ? 'sorted ' . $order_direction : '',
23
- 'clicks' => !empty($params['order_by']) && $params['order_by'] == WYSIJA_module_statistics::ORDER_BY_CLICK ? 'sorted ' . $order_direction : ''
24
- );
25
- }
26
-
27
- public function hook_subscriber_bottom($params = array()) {
28
- if (empty($params['user_id']))
29
- return;
30
- $this->data['order_direction'] = $this->get_order_direction($params);
31
- $this->data['opened_newsletters'] = $this->get_opened_newsletters($params);
32
- $this->view_show = 'hook_subscriber_bottom';
33
- return $this->render();
34
- }
35
-
36
- /**
37
- * Get already opened newsletters by current user
38
- * @param array $params
39
- Array
40
- (
41
- user_id => 2
42
- )
43
- * @return array
44
- * array(
45
- * 'stats' => array(
46
- * emails_count => 123,
47
- * opened_emails_count => 12
48
- * ),
49
- * array(
50
- * 1 => array( // First email
51
- * email_id => 1,
52
- * subject => Lorem ipsum,
53
- * sent_at => 123456789
54
- * urls => array(
55
- * 1 => array( // first url in the current email
56
- * email_id => 1,
57
- * url_id => 2,
58
- * url => http://domain.com/link/to/page
59
- * number_clicked => 234
60
- * )
61
- * )
62
- * )
63
- * )
64
- * )
65
-
66
- */
67
- protected function get_opened_newsletters($params) {
68
- // get emails by user
69
- $emails = $this->model_obj->get_emails_by_user_id($params['user_id']);
70
- if (empty($emails))
71
- return;
72
-
73
- $emails_count = count($emails);
74
-
75
- // get urls by email
76
- $urls = $this->model_obj->get_urls_by_email_ids(array_keys($emails), $params['user_id']);
77
-
78
- // combine
79
- foreach ($emails as $email_id => $email) {
80
- $emails[$email_id]['urls'] = !empty($urls[$email_id]) ? $urls[$email_id] : array();
81
- }
82
-
83
- // filter emails, keep opened or clicked ones only
84
- foreach ($emails as $email_id => $email) {
85
- if ((empty($email['opened_at']) || $email['opened_at'] <= 0) AND empty($email['urls'])) {
86
- unset($emails[$email_id]);
87
- }
88
- }
89
- $opened_emails_count = count($emails);
90
- return array(
91
- 'stats' => array(
92
- 'emails_count' => $emails_count,
93
- 'opened_emails_count' => $opened_emails_count
94
- ),
95
- 'emails' => $emails
96
- );
97
- }
98
-
99
- /**
100
- * hook_newsletter - page MailPoet >> Newsletters >> view detail
101
- * @param array $params
102
- * @return string
103
- */
104
- public function hook_newsletter($params) {
105
- return $this->hook_stats($params);
106
- }
 
 
 
107
 
108
  }
1
  <?php
 
2
  defined('WYSIJA') or die('Restricted access');
3
 
4
+ require_once(dirname(__FILE__).DS.'stats_subscribers_std_model.php');
5
 
6
  class WYSIJA_module_stats_subscribers_std extends WYSIJA_module_statistics {
7
 
8
+ public $name = 'stats_subscribers_std';
9
+
10
+ public $model = 'WYSIJA_model_stats_subscribers_std';
11
+
12
+ public $view = 'stats_subscribers_std_view';
13
+
14
+ static protected $stats_data;
15
+
16
+ public function __construct() {
17
+ parent::__construct();
18
+ }
19
+
20
+ protected function get_order_direction($params) {
21
+ $order_direction = (!empty($params['order_direction']) && $params['order_direction'] == WYSIJA_module_statistics::ORDER_DIRECTION_ASC ? 'asc' : 'desc');
22
+ return array(
23
+ 'sent' => !empty($params['order_by']) && $params['order_by'] == WYSIJA_module_statistics::ORDER_BY_SENT ? 'sorted '.$order_direction : '',
24
+ 'opens' => !empty($params['order_by']) && $params['order_by'] == WYSIJA_module_statistics::ORDER_BY_OPEN ? 'sorted '.$order_direction : '',
25
+ 'clicks' => !empty($params['order_by']) && $params['order_by'] == WYSIJA_module_statistics::ORDER_BY_CLICK ? 'sorted '.$order_direction : ''
26
+ );
27
+ }
28
+
29
+ public function hook_subscriber_bottom($params = array( )) {
30
+ if (empty($params['user_id']))
31
+ return;
32
+ $this->data['order_direction'] = $this->get_order_direction($params);
33
+ $this->data['opened_newsletters'] = $this->get_opened_newsletters($params);
34
+ $this->view_show = 'hook_subscriber_bottom';
35
+ return $this->render();
36
+ }
37
+
38
+ /**
39
+ * Get already opened newsletters by current user
40
+ * @param array $params
41
+ Array
42
+ (
43
+ user_id => 2
44
+ )
45
+ * @return array
46
+ * array(
47
+ * 'stats' => array(
48
+ * emails_count => 123,
49
+ * opened_emails_count => 12
50
+ * ),
51
+ * array(
52
+ * 1 => array( // First email
53
+ * email_id => 1,
54
+ * subject => Lorem ipsum,
55
+ * sent_at => 123456789
56
+ * urls => array(
57
+ * 1 => array( // first url in the current email
58
+ * email_id => 1,
59
+ * url_id => 2,
60
+ * url => http://domain.com/link/to/page
61
+ * number_clicked => 234
62
+ * )
63
+ * )
64
+ * )
65
+ * )
66
+ * )
67
+
68
+ */
69
+ protected function get_opened_newsletters($params) {
70
+ // get emails by user
71
+ $emails = $this->model_obj->get_emails_by_user_id($params['user_id']);
72
+ if (empty($emails))
73
+ return;
74
+
75
+ $emails_count = count($emails);
76
+
77
+ // get urls by email
78
+ $urls = $this->model_obj->get_urls_by_email_ids(array_keys($emails), $params['user_id']);
79
+
80
+ // combine
81
+ foreach ($emails as $email_id => $email) {
82
+ $emails[$email_id]['urls'] = !empty($urls[$email_id]) ? $urls[$email_id] : array( );
83
+ }
84
+
85
+ // filter emails, keep opened or clicked ones only
86
+ foreach ($emails as $email_id => $email) {
87
+ if ((empty($email['opened_at']) || $email['opened_at'] <= 0) AND empty($email['urls'])) {
88
+ unset($emails[$email_id]);
89
+ }
90
+ }
91
+ $opened_emails_count = count($emails);
92
+ return array(
93
+ 'stats' => array(
94
+ 'emails_count' => $emails_count,
95
+ 'opened_emails_count' => $opened_emails_count
96
+ ),
97
+ 'emails' => $emails
98
+ );
99
+ }
100
+
101
+ /**
102
+ * hook_newsletter - page MailPoet >> Newsletters >> view detail
103
+ * @param array $params
104
+ * @return string
105
+ */
106
+ public function hook_newsletter($params) {
107
+ return $this->hook_stats($params);
108
+ }
109
 
110
  }
modules/stats_subscribers_std/stats_subscribers_std_model.php CHANGED
@@ -1,100 +1,101 @@
1
  <?php
 
2
 
3
  class WYSIJA_model_stats_subscribers_std extends WYSIJA_module_statistics_model {
4
 
5
- /**
6
- * Get all emails which were sent to a specific user
7
- * @param int $user_id
8
- * @return array list of emails
9
- * array(
10
- * 1 => array(
11
- * email_id => 1
12
- * subject => 'lorem ipsum'
13
- * sent_at => 123456789
14
- * ),
15
- * 3 => array(
16
- * email_id => 3
17
- * subject => 'lorem ipsum'
18
- * sent_at => 123456789
19
- * ),
20
- * 5 => array(
21
- * email_id => 5
22
- * subject => 'lorem ipsum'
23
- * sent_at => 123456789
24
- * )
25
- * )
26
- */
27
- public function get_emails_by_user_id($user_id, $opened_only = false) {
28
- $where = array(1);
29
- if ($opened_only) {
30
- $where[] = 'eus.`opened_at` > 0';
31
- $where[] = 'eus.`status` > 0';
32
- }
33
 
34
- $query = '
35
- SELECT
36
  e.`email_id`,
37
  e.`subject`,
38
  e.`sent_at`,
39
  eus.`opened_at`
40
  FROM
41
  `[wysija]email_user_stat` eus
42
- JOIN
43
- `[wysija]email` e ON e.`email_id` = eus.`email_id` AND eus.`user_id` = ' . (int) $user_id . '
44
- WHERE ' . implode(' AND ', $where) . '
45
  ORDER BY eus.`opened_at` DESC
46
  ';
47
- $dataset = $this->get_results($query);
48
- return $this->indexing_dataset_by_field('email_id', $dataset);
49
- }
50
 
51
- /**
52
- * Get all possible urls embebed in each email
53
- * @param array $email_ids
54
- * @return array list of urls
55
- * array(
56
- * email_id => array(
57
- * url_id => array(
58
- * 'email_id' => 1,
59
- * 'url_id' => 1,
60
- * 'url' => 'http://...',
61
- * 'number_clicked' => 2
62
- * )
63
- * )
64
- * )
65
- */
66
- public function get_urls_by_email_ids(Array $email_ids, $user_id = null) {
67
- if (empty($email_ids))
68
- return array();
69
 
70
- $where = array(1);
71
- $where[] = 'euu.`email_id` IN (' . implode(',', $email_ids) . ')';
72
- if (!empty($user_id))
73
- $where[] = 'euu.`user_id` = ' . (int) $user_id;
74
- $query = '
75
- SELECT
76
  euu.`email_id`,
77
  u.`url_id`,
78
  u.`url`,
79
  euu.`number_clicked`
80
  FROM
81
  `[wysija]email_user_url` euu
82
- JOIN
83
- `[wysija]url` u ON u.`url_id` = euu.`url_id` AND ' . implode(' AND ', $where) . '
84
  ORDER BY euu.`email_id`, u.`url`
85
-
86
  ';
87
 
88
- $dataset = $this->get_results($query);
89
 
90
- $tmp = array();
91
- foreach ($dataset as $record) {
92
- $tmp[$record['email_id']][] = $record;
93
- }
94
- foreach ($tmp as $email_id => $_dataset) {
95
- $tmp[$email_id] = $this->indexing_dataset_by_field('url_id', $_dataset);
96
- }
97
- return $tmp;
98
- }
99
 
100
  }
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
 
4
  class WYSIJA_model_stats_subscribers_std extends WYSIJA_module_statistics_model {
5
 
6
+ /**
7
+ * Get all emails which were sent to a specific user
8
+ * @param int $user_id
9
+ * @return array list of emails
10
+ * array(
11
+ * 1 => array(
12
+ * email_id => 1
13
+ * subject => 'lorem ipsum'
14
+ * sent_at => 123456789
15
+ * ),
16
+ * 3 => array(
17
+ * email_id => 3
18
+ * subject => 'lorem ipsum'
19
+ * sent_at => 123456789
20
+ * ),
21
+ * 5 => array(
22
+ * email_id => 5
23
+ * subject => 'lorem ipsum'
24
+ * sent_at => 123456789
25
+ * )
26
+ * )
27
+ */
28
+ public function get_emails_by_user_id($user_id, $opened_only = false) {
29
+ $where = array( 1 );
30
+ if ($opened_only) {
31
+ $where[] = 'eus.`opened_at` > 0';
32
+ $where[] = 'eus.`status` > 0';
33
+ }
34
 
35
+ $query = '
36
+ SELECT
37
  e.`email_id`,
38
  e.`subject`,
39
  e.`sent_at`,
40
  eus.`opened_at`
41
  FROM
42
  `[wysija]email_user_stat` eus
43
+ JOIN
44
+ `[wysija]email` e ON e.`email_id` = eus.`email_id` AND eus.`user_id` = '.(int)$user_id.'
45
+ WHERE '.implode(' AND ', $where).'
46
  ORDER BY eus.`opened_at` DESC
47
  ';
48
+ $dataset = $this->get_results($query);
49
+ return $this->indexing_dataset_by_field('email_id', $dataset);
50
+ }
51
 
52
+ /**
53
+ * Get all possible urls embebed in each email
54
+ * @param array $email_ids
55
+ * @return array list of urls
56
+ * array(
57
+ * email_id => array(
58
+ * url_id => array(
59
+ * 'email_id' => 1,
60
+ * 'url_id' => 1,
61
+ * 'url' => 'http://...',
62
+ * 'number_clicked' => 2
63
+ * )
64
+ * )
65
+ * )
66
+ */
67
+ public function get_urls_by_email_ids(Array $email_ids, $user_id = null) {
68
+ if (empty($email_ids))
69
+ return array( );
70
 
71
+ $where = array( 1 );
72
+ $where[] = 'euu.`email_id` IN ('.implode(',', $email_ids).')';
73
+ if (!empty($user_id))
74
+ $where[] = 'euu.`user_id` = '.(int)$user_id;
75
+ $query = '
76
+ SELECT
77
  euu.`email_id`,
78
  u.`url_id`,
79
  u.`url`,
80
  euu.`number_clicked`
81
  FROM
82
  `[wysija]email_user_url` euu
83
+ JOIN
84
+ `[wysija]url` u ON u.`url_id` = euu.`url_id` AND '.implode(' AND ', $where).'
85
  ORDER BY euu.`email_id`, u.`url`
86
+
87
  ';
88
 
89
+ $dataset = $this->get_results($query);
90
 
91
+ $tmp = array( );
92
+ foreach ($dataset as $record) {
93
+ $tmp[$record['email_id']][] = $record;
94
+ }
95
+ foreach ($tmp as $email_id => $_dataset) {
96
+ $tmp[$email_id] = $this->indexing_dataset_by_field('url_id', $_dataset);
97
+ }
98
+ return $tmp;
99
+ }
100
 
101
  }
modules/stats_subscribers_std/stats_subscribers_std_view.php CHANGED
@@ -1,106 +1,110 @@
1
  <?php
 
2
 
3
  class WYSIJA_module_view_stats_subscribers_std_view extends WYSIJA_view_back {
4
 
5
- public function hook_subscriber_bottom($data) {
6
- if (empty($data['opened_newsletters']['stats']))
7
- return;
8
- ?>
9
- <div class="container-stats-subscribers_std container" rel="<?php echo $data['module_name']; ?>">
10
- <h3 class="title">
11
- <?php
12
- if ($data['opened_newsletters']['stats']['emails_count'] > 1)
13
- echo sprintf(__('Subscriber opened %1$s of %2$s emails', WYSIJA),$data['opened_newsletters']['stats']['opened_emails_count'],$data['opened_newsletters']['stats']['emails_count']);
14
- else
15
- echo sprintf(__('Subscriber opened %1$s of %2$s email', WYSIJA),$data['opened_newsletters']['stats']['opened_emails_count'],$data['opened_newsletters']['stats']['emails_count']);
16
- ?>
17
- </h3>
18
- <?php if (empty($data['opened_newsletters']['emails'])) { ?>
19
- <div class="notice-msg updated inline"><ul><li><?php echo $data['messages']['data_not_available']; ?></li></ul></div>
20
- <?php } else { ?>
21
- <table class="widefat fixed">
22
- <thead>
23
- <th class="check-column">&nbsp;</th>
24
- <th class="newsletter"><?php echo __('Newsletter', WYSIJA); ?></th>
25
- <th class="link"><?php echo __('Link', WYSIJA); ?></th>
26
- <th class="click sortable sort-filter <?php echo $data['order_direction']['clicks']; ?>" rel="click"><a href="javascript:void(0);" class="orderlink"><span><?php echo __('Clicks'); ?></span><span class="sorting-indicator"></span></a></th>
27
- <!--th><?php echo __('Device', WYSIJA); ?></th-->
28
- <th class="date"><?php echo __('Date', WYSIJA); ?></th>
29
- </thead>
30
- <tbody class="list:user user-list">
31
- <?php
32
- $i = 1;
33
- $alt = false;
34
- $email_helper = WYSIJA::get('email', 'helper');
35
- foreach ($data['opened_newsletters']['emails'] as $email_id => $email) {
36
- $full_url = $email_helper->getVIB($email);
37
- if (empty($email['urls'])) {
38
- ?>
39
- <tr class="<?php
40
- echo $alt ? 'alternate' : '';
41
- $alt = !$alt;
42
- ?>">
43
- <td><?php
44
- echo $i;
45
- $i++;
46
- ?></td>
47
- <td>
48
- <a href="<?php echo $full_url ?>" target="_blank" class="viewnews" title="<?php _e('Preview in new tab', WYSIJA) ?>">
49
- <?php echo $email['subject']; ?>
50
- </a>
51
- </td>
52
- <td>&nbsp;</td>
53
- <td>&nbsp;</td>
54
- <!--td><?php echo __('N/A', WYSIJA); ?></td-->
55
- <td><?php echo $this->fieldListHTML_created_at($email['opened_at']); ?></td>
56
- </tr>
57
- <?php
58
- } else {
59
- $link_helper = WYSIJA::get('links', 'helper');
60
- add_filter('wysija_link', array($link_helper, 'render_link'), 1, 6);
61
- foreach ($email['urls'] as $url) {
62
- if ($i === 1) {
63
- $wysija_link = apply_filters('wysija_link', '', $url['url'], 50, 15, false);
64
- } else {
65
- $wysija_link = apply_filters('wysija_link', '', $url['url'], 50, 15, false, '...');
66
- }
67
- ?>
68
- <tr class="<?php
69
- echo $alt ? 'alternate' : '';
70
- $alt = !$alt;
71
- ?>">
72
- <td><?php
73
- echo $i;
74
- $i++;
75
- ?></td>
76
- <td>
77
- <a href="<?php echo $full_url ?>" target="_blank" class="viewnews" title="<?php _e('Preview in new tab', WYSIJA) ?>">
78
- <?php echo $email['subject']; ?>
79
- </a>
80
- </td>
81
- <td><?php echo $wysija_link; ?></td>
82
- <td><?php echo $url['number_clicked']; ?></td>
83
- <!--td><?php echo __('N/A', WYSIJA); ?></td-->
84
- <td><?php echo $this->fieldListHTML_created_at($email['opened_at']); ?></td>
85
- </tr>
86
- <?php
87
- }
88
- }
89
- }
90
- ?>
91
- </tbody>
92
- </table>
93
- <?php } ?>
94
- <?php
95
- //$this->model->countRows = 103;//$data['top_subscribers']['count'];
 
 
 
96
  // if (empty($this->viewObj)) $this->viewObj = new stdClass();
97
  // $this->viewObj->msgPerPage = __('Show',WYSIJA).':';
98
  // $this->viewObj->title = '';
99
- //$this->limitPerPage(); // not implemented yet
100
- ?>
101
- <div class="cl"></div>
102
- </div>
103
- <?php
104
- }
105
 
106
  }
1
  <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
 
4
  class WYSIJA_module_view_stats_subscribers_std_view extends WYSIJA_view_back {
5
 
6
+ public function hook_subscriber_bottom($data) {
7
+ if (empty($data['opened_newsletters']['stats']))
8
+ return;
9
+ ?>
10
+ <div class="container-stats-subscribers_std container" rel="<?php echo $data['module_name']; ?>">
11
+ <h3 class="title">
12
+ <?php
13
+ if ($data['opened_newsletters']['stats']['emails_count'] > 1)
14
+ echo sprintf(__('Subscriber opened %1$s of %2$s emails', WYSIJA), $data['opened_newsletters']['stats']['opened_emails_count'], $data['opened_newsletters']['stats']['emails_count']);
15
+ else
16
+ echo sprintf(__('Subscriber opened %1$s of %2$s email', WYSIJA), $data['opened_newsletters']['stats']['opened_emails_count'], $data['opened_newsletters']['stats']['emails_count']);
17
+ ?>
18
+ </h3>
19
+ <?php if (empty($data['opened_newsletters']['emails'])) { ?>
20
+ <div class="notice-msg updated inline"><ul><li><?php echo $data['messages']['data_not_available']; ?></li></ul></div>
21
+ <?php }
22
+ else { ?>
23
+ <table class="widefat fixed">
24
+ <thead>
25
+ <th class="check-column">&nbsp;</th>
26
+ <th class="newsletter"><?php echo __('Newsletter', WYSIJA); ?></th>
27
+ <th class="link"><?php echo __('Link', WYSIJA); ?></th>
28
+ <th class="click sortable sort-filter <?php echo $data['order_direction']['clicks']; ?>" rel="click"><a href="javascript:void(0);" class="orderlink"><span><?php echo __('Clicks'); ?></span><span class="sorting-indicator"></span></a></th>
29
+ <!--th><?php echo __('Device', WYSIJA); ?></th-->
30
+ <th class="date"><?php echo __('Date', WYSIJA); ?></th>
31
+ </thead>
32
+ <tbody class="list:user user-list">
33
+ <?php
34
+ $i = 1;
35
+ $alt = false;
36
+ $email_helper = WYSIJA::get('email', 'helper');
37
+ foreach ($data['opened_newsletters']['emails'] as $email_id => $email) {
38
+ $full_url = $email_helper->getVIB($email);
39
+ if (empty($email['urls'])) {
40
+ ?>
41
+ <tr class="<?php
42
+ echo $alt ? 'alternate' : '';
43
+ $alt = !$alt;
44
+ ?>">
45
+ <td><?php
46
+ echo $i;
47
+ $i++;
48
+ ?></td>
49
+ <td>
50
+ <a href="<?php echo $full_url ?>" target="_blank" class="viewnews" title="<?php _e('Preview in new tab', WYSIJA) ?>">
51
+ <?php echo $email['subject']; ?>
52
+ </a>
53
+ </td>
54
+ <td>&nbsp;</td>
55
+ <td>&nbsp;</td>
56
+ <!--td><?php echo __('N/A', WYSIJA); ?></td-->
57
+ <td><?php echo $this->fieldListHTML_created_at($email['opened_at']); ?></td>
58
+ </tr>
59
+ <?php
60
+ }
61
+ else {
62
+ $link_helper = WYSIJA::get('links', 'helper');
63
+ add_filter('wysija_link', array( $link_helper, 'render_link' ), 1, 6);
64
+ foreach ($email['urls'] as $url) {
65
+ if ($i === 1) {
66
+ $wysija_link = apply_filters('wysija_link', '', $url['url'], 50, 15, false);
67
+ }
68
+ else {
69
+ $wysija_link = apply_filters('wysija_link', '', $url['url'], 50, 15, false, '...');
70
+ }
71
+ ?>
72
+ <tr class="<?php
73
+ echo $alt ? 'alternate' : '';
74
+ $alt = !$alt;
75
+ ?>">
76
+ <td><?php
77
+ echo $i;
78
+ $i++;
79
+ ?></td>
80
+ <td>
81
+ <a href="<?php echo $full_url ?>" target="_blank" class="viewnews" title="<?php _e('Preview in new tab', WYSIJA) ?>">
82
+ <?php echo $email['subject']; ?>
83
+ </a>
84
+ </td>
85
+ <td><?php echo $wysija_link; ?></td>
86
+ <td><?php echo $url['number_clicked']; ?></td>
87
+ <!--td><?php echo __('N/A', WYSIJA); ?></td-->
88
+ <td><?php echo $this->fieldListHTML_created_at($email['opened_at']); ?></td>
89
+ </tr>
90
+ <?php
91
+ }
92
+ }
93
+ }
94
+ ?>
95
+ </tbody>
96
+ </table>
97
+ <?php } ?>
98
+ <?php
99
+ //$this->model->countRows = 103;//$data['top_subscribers']['count'];
100
  // if (empty($this->viewObj)) $this->viewObj = new stdClass();
101
  // $this->viewObj->msgPerPage = __('Show',WYSIJA).':';
102
  // $this->viewObj->title = '';
103
+ //$this->limitPerPage(); // not implemented yet
104
+ ?>
105
+ <div class="cl"></div>
106
+ </div>
107
+ <?php
108
+ }
109
 
110
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wysija, kgjerstad, benheu, JoN1oP, badshark, tung-wysija, bordoni
3
  Tags: newsletter, newsletters, wysija, newsletter signup, newsletter widget, subscribers, post notification, email subscription, email alerts, automatic newsletter, auto newsletter, autoresponder, follow up, email, marketing, emailing, subscription, mail poet, mailpoet
4
  Requires at least: 3.3
5
  Tested up to: 3.9
6
- Stable tag: 2.6.9
7
  Send newsletters, post notifications or autoresponders from WordPress easily, and beautifully.
8
 
9
  == Description ==
@@ -133,6 +133,15 @@ Our [support site](http://support.mailpoet.com/) has plenty of articles and a ti
133
 
134
  == Changelog ==
135
 
 
 
 
 
 
 
 
 
 
136
  = 2.6.9 - 2014-07-14 =
137
  * Fixed email display issues caused by responsive CSS. We're truly sorry for this.
138
  * New columns on Subscribers page: "Never opened or clicked"
3
  Tags: newsletter, newsletters, wysija, newsletter signup, newsletter widget, subscribers, post notification, email subscription, email alerts, automatic newsletter, auto newsletter, autoresponder, follow up, email, marketing, emailing, subscription, mail poet, mailpoet
4
  Requires at least: 3.3
5
  Tested up to: 3.9
6
+ Stable tag: 2.6.10
7
  Send newsletters, post notifications or autoresponders from WordPress easily, and beautifully.
8
 
9
  == Description ==
133
 
134
  == Changelog ==
135
 
136
+ = 2.6.10 - 2014-08-04 =
137
+ * Improved protection of themes upload, unsubscribe links, file access and statistics.
138
+ * Improved the "Send a test email" function.
139
+ * Fixed never ending process while sending previews on certain servers.
140
+ * Fixed a few regular expressions for a better rendering in Outlook.
141
+ * Fixed memory issue when dropping the "WordPress Post" widget on sites with thousands of taxonomies.
142
+ * Fixed wrong subscribers count in the subscribers' listing.
143
+ * Old code Spring cleaning, removed unused rusty pieces.
144
+
145
  = 2.6.9 - 2014-07-14 =
146
  * Fixed email display issues caused by responsive CSS. We're truly sorry for this.
147
  * New columns on Subscribers page: "Never opened or clicked"
tools/templates/newsletter/email/css.html CHANGED
@@ -231,11 +231,7 @@
231
  {#viewbrowser_container} a, {#unsubscribe_container} a {
232
  text-decoration:underline;
233
  }
234
- /***************************************************
235
- ****************************************************
236
- MOBILE TARGETING
237
- ****************************************************
238
- ***************************************************/
239
  @media only screen and (max-device-width: 480px), screen and (max-width: 480px) {
240
  /* Part one of controlling phone number linking for mobile. */
241
  a[href^="tel"], a[href^="sms"] {
@@ -294,18 +290,15 @@
294
  }
295
  /* end Android targeting */
296
  </style>
297
- <!-- Targeting Windows Mobile -->
 
298
  <!--[if IEMobile 7]>
299
  <style type="text/css">
300
 
301
  </style>
302
  <![endif]-->
303
 
304
- <!-- ***********************************************
305
- ****************************************************
306
- END MOBILE TARGETING
307
- ****************************************************
308
- ************************************************ -->
309
 
310
  <!--[if gte mso 9]>
311
  <style type="text/css">
231
  {#viewbrowser_container} a, {#unsubscribe_container} a {
232
  text-decoration:underline;
233
  }
234
+ /* MOBILE TARGETING */
 
 
 
 
235
  @media only screen and (max-device-width: 480px), screen and (max-width: 480px) {
236
  /* Part one of controlling phone number linking for mobile. */
237
  a[href^="tel"], a[href^="sms"] {
290
  }
291
  /* end Android targeting */
292
  </style>
293
+
294
+ /* Targeting Windows Mobile */
295
  <!--[if IEMobile 7]>
296
  <style type="text/css">
297
 
298
  </style>
299
  <![endif]-->
300
 
301
+ /* END MOBILE TARGETING */
 
 
 
 
302
 
303
  <!--[if gte mso 9]>
304
  <style type="text/css">
tools/templates/newsletter/email/email_template.html CHANGED
@@ -7,12 +7,10 @@
7
  {#css}
8
  </head>
9
  <body bgcolor="{#styles.html.background|color}" yahoo="fix" {if #is_rtl}dir="rtl"{/if}>
10
- <!-- Wrapper/Container Table: Use a wrapper table to control the width and the background color consistently of your email. Use this approach instead of setting attributes on the body tag. -->
11
  <span style="margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top: 0;display:block;background:{#styles.html.background|color};">
12
  <table width="100%" cellpadding="0" cellspacing="0" border="0" id="wysija_wrapper">
13
  <tr>
14
  <td valign="top" align="center">
15
- <!-- Tables are the most common way to format your email consistently. Set your table widths inside cells and in most cases reset cellpadding, cellspacing, and border to zero. Use nested tables as a way to space effectively in your message. -->
16
  <table width="600" cellpadding="0" cellspacing="0" border="0" align="center">
17
  {if ! #hide_viewbrowser}
18
  <tr>
@@ -44,11 +42,9 @@
44
  </tr>
45
  {/if}
46
  </table>
47
- <!-- End example table -->
48
  </td>
49
  </tr>
50
  </table>
51
  </span>
52
- <!-- End of wrapper table -->
53
  </body>
54
  </html>
7
  {#css}
8
  </head>
9
  <body bgcolor="{#styles.html.background|color}" yahoo="fix" {if #is_rtl}dir="rtl"{/if}>
 
10
  <span style="margin-bottom:0;margin-left:0;margin-right:0;margin-top:0;padding-bottom:0;padding-left:0;padding-right:0;padding-top: 0;display:block;background:{#styles.html.background|color};">
11
  <table width="100%" cellpadding="0" cellspacing="0" border="0" id="wysija_wrapper">
12
  <tr>
13
  <td valign="top" align="center">
 
14
  <table width="600" cellpadding="0" cellspacing="0" border="0" align="center">
15
  {if ! #hide_viewbrowser}
16
  <tr>
42
  </tr>
43
  {/if}
44
  </table>
 
45
  </td>
46
  </tr>
47
  </table>
48
  </span>
 
49
  </body>
50
  </html>
views/back/campaigns.php CHANGED
@@ -2016,9 +2016,9 @@ class WYSIJA_view_back_campaigns extends WYSIJA_view_back {
2016
  <div class="clearfix">
2017
  <div class="filters-box">
2018
  <?php
2019
- echo $helper_articles->getFilterByType(array('value' => $data['params']['post_type'], 'label' => __('Filter by type', WYSIJA)));
2020
- echo $helper_articles->getFilterByCategory();
2021
- echo $helper_articles->getFilterByStatus();
2022
  ?>
2023
  </div>
2024
  <div class="search-box">
@@ -2241,7 +2241,7 @@ class WYSIJA_view_back_campaigns extends WYSIJA_view_back {
2241
  $helper_articles = WYSIJA::get('articles', 'helper');
2242
  $output .= '<div class="block clearfix">';
2243
  $output .= ' <label>'.__('Post type', WYSIJA).'</label>';
2244
- $output .= $helper_articles->getFilterByType(array('value' => $data['params']['post_type']));
2245
  $output .= '</div>';
2246
 
2247
  // post limit
@@ -2280,10 +2280,10 @@ class WYSIJA_view_back_campaigns extends WYSIJA_view_back {
2280
  // categories
2281
  $output .=
2282
  '<div class="block clearfix" id="categories_filters">' .
2283
- '<label>' . __( 'Taxonomy filter', WYSIJA ) . '</label>' .
2284
  '<div class="group">' .
2285
  '<p class="category_select clearfix">' .
2286
- '<input data-placeholder="' . __( 'Select some terms', WYSIJA ) . '" name="category_ids" class="category_ids" data-selected=\'' . json_encode( $_attr_init_selection ). '\' value="' . implode( ',', $terms_selected ) . '" type="hidden">' .
2287
  '</p>' .
2288
  '</div>' .
2289
  '</div>';
2016
  <div class="clearfix">
2017
  <div class="filters-box">
2018
  <?php
2019
+ echo $helper_articles->field_select_post_type(array('value' => $data['params']['post_type'], 'label' => __('Filter by type', WYSIJA)));
2020
+ echo $helper_articles->field_select_terms();
2021
+ echo $helper_articles->field_select_status();
2022
  ?>
2023
  </div>
2024
  <div class="search-box">
2241
  $helper_articles = WYSIJA::get('articles', 'helper');
2242
  $output .= '<div class="block clearfix">';
2243
  $output .= ' <label>'.__('Post type', WYSIJA).'</label>';
2244
+ $output .= $helper_articles->field_select_post_type( array( 'value' => $data['params']['post_type'] ) );
2245
  $output .= '</div>';
2246
 
2247
  // post limit
2280
  // categories
2281
  $output .=
2282
  '<div class="block clearfix" id="categories_filters">' .
2283
+ '<label title="' . esc_attr__( 'And taxonomies as well...', WYSIJA ) . '">' . __( 'Categories and tags', WYSIJA ) . '</label>' .
2284
  '<div class="group">' .
2285
  '<p class="category_select clearfix">' .
2286
+ '<input data-placeholder="' . __( 'Select...', WYSIJA ) . '" name="category_ids" style="width: 300px" class="category_ids mailpoet-field-select2-terms" data-multiple="true" data-value=\'' . WJ_Utils::esc_json_attr( $_attr_init_selection ) . '\' value="' . esc_attr( implode( ',', $terms_selected ) ) . '" type="hidden">' .
2287
  '</p>' .
2288
  '</div>' .
2289
  '</div>';
views/back/config.php CHANGED
@@ -781,29 +781,41 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
781
  $key='sending_method';
782
  $realvalue=$this->model->getValue($key);
783
  $helper_forms=WYSIJA::get('forms','helper');
 
784
  ?>
785
  <table class="form-table" id="ms-sendingmethod">
786
  <tbody>
787
-
788
  <tr class="methods">
789
- <?php
790
- $is_multisite = is_multisite();
791
- //$is_multisite=true;//PROD comment that line
792
- if($is_multisite){
793
- $field='<th scope="row">';
794
- $checked=false;
795
- $value='network';
796
- $id=str_replace('_','-',$key).'-'.$value;
797
- if($value ==$realvalue) $checked=true;
798
- $field.='<label for="'.$id.'" class="clearfix">';
799
- $field.=$helper_forms->radio(array('id'=>$id,'name'=>'wysija[config]['.$key.']'),$value,$checked);
800
- $field.='<h3>'.__('Network\'s Method' ,WYSIJA).'</h3></label>';
801
- $field.='<p>'.__('Method set by the network admin.',WYSIJA).'</p>';
802
- if(!$this->model->getValue('ms_sending_emails_ok')) $field.='<strong'.__('Not Configured!',WYSIJA).'</strong>';
803
- $field.='</th>';
804
- echo $field;
805
- }
806
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
807
 
808
  <th scope="row">
809
  <?php
@@ -812,7 +824,7 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
812
  $id=str_replace('_','-',$key).'-'.$value;
813
  if($value ==$realvalue) $checked=true;
814
  $field='<label for="'.$id.'" class="clearfix">';
815
- $field.=$helper_forms->radio(array("id"=>$id,'name'=>'wysija[config]['.$key.']'),$value,$checked);
816
  $field.='<h3>'.__('Your own website',WYSIJA).'</h3></label>';
817
  $field.='<p>'.__('The simplest solution for small lists. Your web host sets a daily email limit.',WYSIJA).'</p>';
818
  echo $field;
@@ -825,7 +837,7 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
825
  $id=str_replace("_",'-',$key).'-'.$value;
826
  if($value ==$realvalue) $checked=true;
827
  $field='<label for="'.$id.'" class="clearfix">';
828
- $field.=$helper_forms->radio(array("id"=>$id,'name'=>'wysija[config]['.$key.']'),$value,$checked);
829
  $field.='<h3>Gmail</h3></label>';
830
  $field.='<p>'.__("Easy to setup. Limited to 500 emails a day. We recommend that you open a dedicated Gmail account for this purpose.",WYSIJA).'</p>';
831
  echo $field;
@@ -839,7 +851,7 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
839
 
840
  $id = str_replace('_', '-', $key).'-'.$value;
841
  $field ='<label for="'.$id.'" class="clearfix">';
842
- $field.= $helper_forms->radio(array('id' => $id, 'name' => 'wysija[config]['.$key.']'), $value, $checked);
843
  $field.= '<h3>'.__('Third party',WYSIJA).'</h3></label>';
844
  $field.='<p>'.__('Send with a professional SMTP provider, a great choice for big and small lists. We\'ve negotiated promotional offers with a few providers for you.',WYSIJA).' <a href="http://support.mailpoet.com/knowledgebase/send-with-smtp-when-using-a-professional-sending-provider/?utm_source=wpadmin&utm_campaign=sending method" target="_blank">'.__('Read more',WYSIJA).'</a>.</p>';
845
  echo $field;
@@ -866,7 +878,7 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
866
  $id=str_replace("_",'-',$key).'-'.$value;
867
  $field='<p class="title"><label for="'.$id.'">';
868
  $field.=$helper_forms->radio(array("id"=>$id,'name'=>'wysija[config]['.$key.']'),$value,$checked);
869
- $field.='PHP Mail</label><a class="button-secondary" id="send-test-mail-phpmail">'.__('Send a test mail',WYSIJA).'</a></p>';
870
  $field.='<p class="description">'.__('This email engine works on 95&#37; of servers',WYSIJA).'</p>';
871
 
872
 
@@ -877,8 +889,7 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
877
  $id=str_replace("_",'-',$key).'-'.$value;
878
  $field.='<p class="title"><label for="'.$id.'">';
879
  $field.=$helper_forms->radio(array("id"=>$id,'name'=>'wysija[config]['.$key.']'),$value,$checked);
880
- $field.='Sendmail</label>
881
- <a class="button-secondary" id="send-test-mail-sendmail">'.__('Send a test mail',WYSIJA).'</a></p>';
882
  $field.='<p class="description">'.__('This method works on 5&#37; of servers',WYSIJA).'</p>';
883
 
884
  $id=str_replace("_",'-',$key).'-'.$value."-path";
@@ -894,7 +905,7 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
894
  $id=str_replace('_','-',$key).'-'.$value;
895
  $field.='<p class="title"><label for="'.$id.'">';
896
  $field.=$helper_forms->radio(array("id"=>$id,'name'=>'wysija[config]['.$key.']'),$value,$checked);
897
- $field.='WP Mail</label><a class="button-secondary" id="send-test-mail-wpmail">'.__('Send a test mail',WYSIJA).'</a></p>';
898
  $field.='<p class="description">'.__('Use the same method as the one used for your WP site.',WYSIJA).'</p>';
899
  }
900
 
@@ -1074,13 +1085,13 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
1074
  </td>
1075
  </tr>
1076
 
1077
- <tr class="hidechoice choice-sending-method-smtp choice-sending-method-gmail">
1078
  <th scope="row">
1079
- <a class="button-secondary" id="send-test-mail-smtp"><?php _e("Send a test mail", WYSIJA) ?></a>
1080
  </th>
1081
- <td colspan="2">
1082
- <?php
1083
- ?>
1084
  </td>
1085
  </tr>
1086
 
@@ -1092,7 +1103,7 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
1092
  echo $field . '<p class="description">' . str_replace(array('[link]', '[/link]'), array('<a href="http://support.mailpoet.com/knowledgebase/wp-cron-batch-emails-sending-frequency/?utm_source=wpadmin&utm_campaign=choosing%20frequency" target="_blank">', '</a>'), __('Your web host has limits. We suggest 70 emails per hour to be safe. [link]Find out more[/link].', WYSIJA)) . '</p>';
1093
  ?>
1094
  </th>
1095
- <td colspan="2">
1096
 
1097
  <?php
1098
  $name='sending_emails_number';
@@ -1281,12 +1292,14 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
1281
  <table class="form-table">
1282
  <tbody>
1283
  <?php echo $this->buildMyForm($advanced_fields ,'','config'); ?>
1284
- <tr class='title_row'><td colspan="2">
1285
- <h3 class='title' alt='<?php esc_attr_e( "Do or do not. There is no try.", WYSIJA ); ?>'>
1286
- <?php _e( "Geeky Options", WYSIJA ); ?>
1287
- <a href='#geeky_options' alt='<?php esc_attr_e( "Toggle Geeky Options", WYSIJA ); ?>' data-hide='<?php esc_attr_e( "Hide", WYSIJA ); ?>' class='add-new-h2 mailpoet-geeky-toggle is_toggled'><?php esc_attr_e( "Show", WYSIJA ); ?></a>
1288
- </h3>
1289
- </td></tr>
 
 
1290
  <?php if (!empty($data['hooks']['hook_settings_super_advanced'])) echo $data['hooks']['hook_settings_super_advanced']; ?>
1291
  <?php echo $this->buildMyForm($super_advanced_fields ,'','config'); ?>
1292
  <?php if (current_user_can('delete_plugins')): ?>
@@ -1495,7 +1508,7 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
1495
  $id = str_replace('_', '-', $key) . '-' . $value;
1496
  $field = '<p class="title"><label for="' . $id . '">';
1497
  $field.=$helper_forms->radio(array("id" => $id, 'name' => 'wysija[config][' . $key . ']'), $value, $checked);
1498
- $field.='PHP Mail</label><a class="button-secondary" id="ms-send-test-mail-phpmail">' . __('Send a test mail', WYSIJA) . '</a></p>';
1499
  $field.='<p class="description">' . __('This email engine works on 95&#37; of servers', WYSIJA) . '</p>';
1500
 
1501
 
@@ -1507,7 +1520,7 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
1507
  $id=str_replace('_','-',$key).'-'.$value;
1508
  $field.='<p class="title"><label for="'.$id.'">';
1509
  $field.=$helper_forms->radio(array("id"=>$id,'name'=>'wysija[config]['.$key.']'),$value,$checked);
1510
- $field.='WP Mail</label><a class="button-secondary" id="ms-send-test-mail-wpmail">'.__('Send a test mail',WYSIJA).'</a></p>';
1511
  $field.='<p class="description">'.__('Use the same method as the one used for your WP site.',WYSIJA).'</p>';
1512
  }
1513
 
@@ -1664,13 +1677,18 @@ class WYSIJA_view_back_config extends WYSIJA_view_back {
1664
  $html_content.='</td>
1665
  </tr>';
1666
 
1667
- $html_content.='<tr class="ms-hidechoice ms-choice-sending-method-smtp">
1668
- <th scope="row">
1669
- <a class="button-secondary" id="ms-send-test-mail-smtp">' . __('Send a test mail', WYSIJA) . '</a>
1670
- </th>
1671
- <td colspan="2">
1672
- </td>
1673
- </tr>';
 
 
 
 
 
1674
 
1675
  $html_content.='<tr class="ms-hidechoice ms-choice-sending-method-smtp ms-choice-sending-method-site">
1676
  <th scope="row">';
781
  $key='sending_method';
782
  $realvalue=$this->model->getValue($key);
783
  $helper_forms=WYSIJA::get('forms','helper');
784
+ $current_user=WYSIJA::wp_get_userdata();
785
  ?>
786
  <table class="form-table" id="ms-sendingmethod">
787
  <tbody>
 
788
  <tr class="methods">
789
+ <?php
790
+ $is_multisite = is_multisite();
791
+
792
+ if ( is_multisite() ){
793
+ $field = '<th scope="row">';
794
+ $checked = false;
795
+ $value = 'network';
796
+ $id = str_replace( '_', '-', $key ) . '-' . $value;
797
+ if ( $value == $realvalue ){
798
+ $checked = true;
799
+ }
800
+ $field .= '<label for="'.$id.'" class="clearfix">';
801
+ $field .= $helper_forms->radio(
802
+ array(
803
+ 'id' => $id,
804
+ 'class' => 'mailpoet-delivery-method',
805
+ 'name' => 'wysija[config][' . $key . ']',
806
+ ),
807
+ $value,
808
+ $checked
809
+ );
810
+ $field .= '<h3>' . __( 'Network\'s Method', WYSIJA ) . '</h3></label>';
811
+ $field .= '<p>' . __( 'Method set by the network admin.', WYSIJA ) . '</p>';
812
+ if ( ! $this->model->getValue( 'ms_sending_emails_ok' ) ){
813
+ $field .= '<strong' . __( 'Not Configured!', WYSIJA ) . '</strong>';
814
+ }
815
+ $field .= '</th>';
816
+ echo $field;
817
+ }
818
+ ?>
819
 
820
  <th scope="row">
821
  <?php
824
  $id=str_replace('_','-',$key).'-'.$value;
825
  if($value ==$realvalue) $checked=true;
826
  $field='<label for="'.$id.'" class="clearfix">';
827
+ $field.=$helper_forms->radio(array("id"=>$id,'class' => 'mailpoet-delivery-method','name'=>'wysija[config]['.$key.']'),$value,$checked);
828
  $field.='<h3>'.__('Your own website',WYSIJA).'</h3></label>';
829
  $field.='<p>'.__('The simplest solution for small lists. Your web host sets a daily email limit.',WYSIJA).'</p>';
830
  echo $field;
837
  $id=str_replace("_",'-',$key).'-'.$value;
838
  if($value ==$realvalue) $checked=true;
839
  $field='<label for="'.$id.'" class="clearfix">';
840
+ $field.=$helper_forms->radio(array("id"=>$id,'class' => 'mailpoet-delivery-method','name'=>'wysija[config]['.$key.']'),$value,$checked);
841
  $field.='<h3>Gmail</h3></label>';
842
  $field.='<p>'.__("Easy to setup. Limited to 500 emails a day. We recommend that you open a dedicated Gmail account for this purpose.",WYSIJA).'</p>';
843
  echo $field;
851
 
852
  $id = str_replace('_', '-', $key).'-'.$value;
853
  $field ='<label for="'.$id.'" class="clearfix">';
854
+ $field.= $helper_forms->radio(array('id' => $id,'class' => 'mailpoet-delivery-method', 'name' => 'wysija[config]['.$key.']'), $value, $checked);
855
  $field.= '<h3>'.__('Third party',WYSIJA).'</h3></label>';
856
  $field.='<p>'.__('Send with a professional SMTP provider, a great choice for big and small lists. We\'ve negotiated promotional offers with a few providers for you.',WYSIJA).' <a href="http://support.mailpoet.com/knowledgebase/send-with-smtp-when-using-a-professional-sending-provider/?utm_source=wpadmin&utm_campaign=sending method" target="_blank">'.__('Read more',WYSIJA).'</a>.</p>';
857
  echo $field;
878
  $id=str_replace("_",'-',$key).'-'.$value;
879
  $field='<p class="title"><label for="'.$id.'">';
880
  $field.=$helper_forms->radio(array("id"=>$id,'name'=>'wysija[config]['.$key.']'),$value,$checked);
881
+ $field.='PHP Mail</label></p>';
882
  $field.='<p class="description">'.__('This email engine works on 95&#37; of servers',WYSIJA).'</p>';
883
 
884
 
889
  $id=str_replace("_",'-',$key).'-'.$value;
890
  $field.='<p class="title"><label for="'.$id.'">';
891
  $field.=$helper_forms->radio(array("id"=>$id,'name'=>'wysija[config]['.$key.']'),$value,$checked);
892
+ $field.='Sendmail</label>';
 
893
  $field.='<p class="description">'.__('This method works on 5&#37; of servers',WYSIJA).'</p>';
894
 
895
  $id=str_replace("_",'-',$key).'-'.$value."-path";
905
  $id=str_replace('_','-',$key).'-'.$value;
906
  $field.='<p class="title"><label for="'.$id.'">';
907
  $field.=$helper_forms->radio(array("id"=>$id,'name'=>'wysija[config]['.$key.']'),$value,$checked);
908
+ $field.='WP Mail</label></p>';
909
  $field.='<p class="description">'.__('Use the same method as the one used for your WP site.',WYSIJA).'</p>';
910
  }
911
 
1085
  </td>
1086
  </tr>
1087
 
1088
+ <tr class="hidechoice choice-sending-method-smtp choice-sending-method-site choice-sending-method-gmail choice-sending-method-network">
1089
  <th scope="row">
1090
+ <?php _e( 'Test method' ); ?>
1091
  </th>
1092
+ <td colspan="<?php echo ( is_multisite() ? 3 : 2 ); ?>">
1093
+ <input type="text" value="<?php echo esc_attr( $current_user->data->user_email ); ?>" class="mailpoet-test-emails" name="wysija[config][test_mails]" />
1094
+ <a class="button-secondary mailpoet-test-delivery"><?php _e( 'Send a test mail', WYSIJA ); ?></a>
1095
  </td>
1096
  </tr>
1097
 
1103
  echo $field . '<p class="description">' . str_replace(array('[link]', '[/link]'), array('<a href="http://support.mailpoet.com/knowledgebase/wp-cron-batch-emails-sending-frequency/?utm_source=wpadmin&utm_campaign=choosing%20frequency" target="_blank">', '</a>'), __('Your web host has limits. We suggest 70 emails per hour to be safe. [link]Find out more[/link].', WYSIJA)) . '</p>';
1104
  ?>
1105
  </th>
1106
+ <td colspan="<?php echo ( is_multisite() ? 3 : 2 ); ?>">
1107
 
1108
  <?php
1109
  $name='sending_emails_number';
1292
  <table class="form-table">
1293
  <tbody>
1294
  <?php echo $this->buildMyForm($advanced_fields ,'','config'); ?>
1295
+ <tr class='title_row'>
1296
+ <td colspan="2">
1297
+ <h3 class='title' alt='<?php esc_attr_e( 'Do or do not. There is no try.', WYSIJA ); ?>'>
1298
+ <?php _e( "Geeky Options", WYSIJA ); ?>
1299
+ <a href='#geeky_options' alt='<?php esc_attr_e( "Toggle Geeky Options", WYSIJA ); ?>' data-hide='<?php esc_attr_e( "Hide", WYSIJA ); ?>' class='add-new-h2 mailpoet-geeky-toggle is_toggled'><?php esc_attr_e( "Show", WYSIJA ); ?></a>
1300
+ </h3>
1301
+ </td>
1302
+ </tr>
1303
  <?php if (!empty($data['hooks']['hook_settings_super_advanced'])) echo $data['hooks']['hook_settings_super_advanced']; ?>
1304
  <?php echo $this->buildMyForm($super_advanced_fields ,'','config'); ?>
1305
  <?php if (current_user_can('delete_plugins')): ?>
1508
  $id = str_replace('_', '-', $key) . '-' . $value;
1509
  $field = '<p class="title"><label for="' . $id . '">';
1510
  $field.=$helper_forms->radio(array("id" => $id, 'name' => 'wysija[config][' . $key . ']'), $value, $checked);
1511
+ $field.='PHP Mail</label></p>';
1512
  $field.='<p class="description">' . __('This email engine works on 95&#37; of servers', WYSIJA) . '</p>';
1513
 
1514
 
1520
  $id=str_replace('_','-',$key).'-'.$value;
1521
  $field.='<p class="title"><label for="'.$id.'">';
1522
  $field.=$helper_forms->radio(array("id"=>$id,'name'=>'wysija[config]['.$key.']'),$value,$checked);
1523
+ $field.='WP Mail</label></p>';
1524
  $field.='<p class="description">'.__('Use the same method as the one used for your WP site.',WYSIJA).'</p>';
1525
  }
1526
 
1677
  $html_content.='</td>
1678
  </tr>';
1679
 
1680
+ $current_user = wp_get_current_user();
1681
+ $html_content .=
1682
+ '<tr class="ms-hidechoice ms-choice-sending-method-smtp ms-choice-sending-method-site">' .
1683
+ '<th scope="row">' .
1684
+ __( 'Test method' ) .
1685
+ '</th>' .
1686
+ '<td colspan="' . ( is_multisite() ? 3 : 2 ) . '">' .
1687
+ '<input type="text" value="' . esc_attr( $current_user->data->user_email ) . '" class="mailpoet-test-emails" name="wysija[config][test_mails]" />' .
1688
+ '<a class="button-secondary mailpoet-test-delivery" data-multisite="' . ( is_multisite() ? 'true' : 'false' ) . '">' . esc_attr__( 'Send a test mail', WYSIJA ) . '</a>' .
1689
+ '</td>' .
1690
+ '</tr>';
1691
+
1692
 
1693
  $html_content.='<tr class="ms-hidechoice ms-choice-sending-method-smtp ms-choice-sending-method-site">
1694
  <th scope="row">';
widgets/wysija_nl.php CHANGED
@@ -2,6 +2,7 @@
2
  /**
3
  * widget class for user registration
4
  */
 
5
  class WYSIJA_NL_Widget extends WP_Widget {
6
  var $classid = '';
7
 
@@ -129,7 +130,7 @@ class WYSIJA_NL_Widget extends WP_Widget {
129
 
130
  // keep all of the fields passed from the new instance
131
  foreach ( $new_instance as $key => $value ){
132
- $instance[$key] = $value;
133
  }
134
 
135
  return $instance;
@@ -168,21 +169,22 @@ class WYSIJA_NL_Widget extends WP_Widget {
168
  $extrascriptLabel = '';
169
  $value_field = '';
170
 
171
- if ( ( isset( $field_params['hidden'] ) && $field_params['hidden'] ) || ( isset( $this->core_only ) && $this->core_only && ! isset( $field_params['core'] ) ) )
172
  continue;
 
173
 
174
- if ( isset( $instance[$field] ) ) {
175
 
176
- if ( $field === 'success' && $instance[$field] == $this->successmsgsub . ' ' . $this->successmsgconf ){
177
  $config = WYSIJA::get( 'config','model' );
178
 
179
  if ( ! $config->getValue( 'confirm_dbleoptin' ) ){
180
  $value_field = $this->successmsgsub;
181
  } else {
182
- $value_field = $instance[$field];
183
  }
184
  } else {
185
- $value_field = $instance[$field];
186
  }
187
  } elseif ( isset( $field_params['default'] ) ) {
188
  $value_field = $field_params['default'];
@@ -257,16 +259,21 @@ class WYSIJA_NL_Widget extends WP_Widget {
257
 
258
  // new form editor
259
  $title = '';
260
- if ( ! isset( $this->core_only ) )
261
  $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
262
- if ( ! isset( $before_widget ) )
 
263
  $before_widget = '';
264
- if ( ! isset( $after_widget ) )
 
265
  $after_widget = '';
266
- if ( ! isset( $before_title ) )
 
267
  $before_title = '';
268
- if ( ! isset( $after_title ) )
 
269
  $after_title = '';
 
270
 
271
  if ( ! isset( $this->core_only ) ) {
272
  $title = $before_title.$title.$after_title;
@@ -295,9 +302,9 @@ class WYSIJA_NL_Widget extends WP_Widget {
295
  if ( isset( $this->core_only ) && $this->core_only && ! isset( $field_params['core'] ) ){
296
  continue;
297
  }
298
- if ( $field == 'success' && $instance[$field] == $this->successmsgsub . ' ' . $this->successmsgconf ){
299
  if ( ! $model_config->getValue( 'confirm_dbleoptin' ) ){
300
- $instance[$field] = $this->successmsgsub;
301
  }
302
  }
303
  }
2
  /**
3
  * widget class for user registration
4
  */
5
+ defined('WYSIJA') or die('Restricted access');
6
  class WYSIJA_NL_Widget extends WP_Widget {
7
  var $classid = '';
8
 
130
 
131
  // keep all of the fields passed from the new instance
132
  foreach ( $new_instance as $key => $value ){
133
+ $instance[ $key ] = $value;
134
  }
135
 
136
  return $instance;
169
  $extrascriptLabel = '';
170
  $value_field = '';
171
 
172
+ if ( ( isset( $field_params['hidden'] ) && $field_params['hidden'] ) || ( isset( $this->core_only ) && $this->core_only && ! isset( $field_params['core'] ) ) ){
173
  continue;
174
+ }
175
 
176
+ if ( isset( $instance[ $field ] ) ) {
177
 
178
+ if ( $field === 'success' && $instance[ $field ] == $this->successmsgsub . ' ' . $this->successmsgconf ){
179
  $config = WYSIJA::get( 'config','model' );
180
 
181
  if ( ! $config->getValue( 'confirm_dbleoptin' ) ){
182
  $value_field = $this->successmsgsub;
183
  } else {
184
+ $value_field = $instance[ $field ];
185
  }
186
  } else {
187
+ $value_field = $instance[ $field ];
188
  }
189
  } elseif ( isset( $field_params['default'] ) ) {
190
  $value_field = $field_params['default'];
259
 
260
  // new form editor
261
  $title = '';
262
+ if ( ! isset( $this->core_only ) ){
263
  $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
264
+ }
265
+ if ( ! isset( $before_widget ) ){
266
  $before_widget = '';
267
+ }
268
+ if ( ! isset( $after_widget ) ){
269
  $after_widget = '';
270
+ }
271
+ if ( ! isset( $before_title ) ){
272
  $before_title = '';
273
+ }
274
+ if ( ! isset( $after_title ) ){
275
  $after_title = '';
276
+ }
277
 
278
  if ( ! isset( $this->core_only ) ) {
279
  $title = $before_title.$title.$after_title;
302
  if ( isset( $this->core_only ) && $this->core_only && ! isset( $field_params['core'] ) ){
303
  continue;
304
  }
305
+ if ( $field == 'success' && $instance[ $field ] == $this->successmsgsub . ' ' . $this->successmsgconf ){
306
  if ( ! $model_config->getValue( 'confirm_dbleoptin' ) ){
307
+ $instance[ $field ] = $this->successmsgsub;
308
  }
309
  }
310
  }