Compare commits

...

124 Commits

Author SHA1 Message Date
8b96854f39 Bump up release version to 0.0.22 2016-04-01 14:57:11 +03:00
28d8600078 Merge pull request #408 from mailpoet/rendering_engine_update
Rendering engine update
2016-04-01 12:37:11 +03:00
4f30158722 - Updates button height calculation
- Removes background color when it's set to "transparent"
- Removes second line break from paragraphs
- Introduces other changes based on Becks's testing
- Updates unit tests
2016-03-31 19:19:58 -04:00
4486f9c5b0 Merge pull request #407 from mailpoet/scheduled_sending
Prevents welcome emails to be sent to unconfirmed subsribers
2016-03-31 14:53:41 +03:00
8515dcf29b Merge pull request #406 from mailpoet/rendering_engine_update
Rendering engine update
2016-03-31 14:05:18 +03:00
d16eb87782 - Prevents welcome emails to be sent to unconfirmed subscribers
- Closes #384
2016-03-30 20:59:55 -04:00
3c77e5d25e - Removes dynamic line-height based on column width
- Updates logic behind removing last element bottom padding
- Properly sets font size for H1-4 tags, header, footer and text
2016-03-30 20:09:06 -04:00
aa1a2a0da9 - Updates button padding 2016-03-30 20:09:06 -04:00
7c9029b227 Bump up release version to 0.0.21 2016-03-25 13:10:37 +02:00
1823bf606a Merge pull request #403 from mailpoet/signup_confirmation_review
Signup confirmation review
2016-03-24 14:43:36 -04:00
525b7fdd65 Merge pull request #402 from mailpoet/scheduled_sending
Scheduled sending
2016-03-24 16:10:56 +02:00
11031d2b56 Remove unused cron translations, fix start and stop button translations 2016-03-24 16:10:39 +02:00
4d45635d03 - Implements "in any role" for WP user welcome e-mails 2016-03-24 10:02:04 -04:00
b81764402b - Updates hooks used to schedule welcome email
- Simplifies cron status message
- Implements newsletter change detection between scheduled queues
- Implements detection for subscribers who unsubscribed from list
- Implements detection for WP users who changed roles
- Updates scheduler worker logic
- Various fixes
2016-03-24 10:02:04 -04:00
947e1150d8 - Removes cron worker hooks as the execution timer can't be persisted
between them
2016-03-24 10:00:52 -04:00
97f0e512af populate from/reply_to for signup confirmation
- added loading screen to reinstall process
2016-03-24 14:22:37 +01:00
f15374de43 don't replace title on custom mailpoet pages 2016-03-24 14:22:37 +01:00
f082c065d1 Confirmation email + Subscription pages
- form as an iframe: increased marginY
- fixed issue with page titles (old themes using wp_title hook)
- redirect on reinstall instead of showing a message (to avoid being able to re-save old settings)
2016-03-24 14:22:37 +01:00
72a9951125 Merge pull request #400 from mailpoet/i18n
Javascript translations
2016-03-24 13:11:51 +01:00
a82d9a63d4 Add missing unsubscribedOn translation on subscribers form 2016-03-24 14:09:35 +02:00
a7e9979781 Merge pull request #398 from mailpoet/rendering_engine_update
Updates rendering engine based on Becs's comments
2016-03-24 13:18:06 +02:00
cebd1ee7ae Merge pull request #399 from mailpoet/editor_rendering
Adapts editor rendering to Becs' feedback
2016-03-23 18:21:00 -04:00
5faa467306 - Updates merge issue with template
- Updates button width/height based on border radius
2016-03-23 18:18:21 -04:00
53eb9cd2ae Translate JS code in listings and forms 2016-03-23 18:59:01 +02:00
7f6eed6d66 Translate cron, forms, newsletters, segments and subscribers 2016-03-23 14:52:06 +02:00
74f3fa65cd Add translatiosn for newsletter creation and listings 2016-03-23 14:52:06 +02:00
8723aa4e4e Remove obsolete test file 2016-03-23 14:52:06 +02:00
ccab8b4cf3 Add MailPoet.I18n for basic translation handling, removed MailPoetI18n 2016-03-23 14:52:06 +02:00
4c4a4ab31d Reduce max button width to 288px, max button border to 10px 2016-03-23 14:09:19 +02:00
45df02b0ec Merge pull request #395 from mailpoet/many_improvements
Many improvements
2016-03-23 13:38:40 +02:00
dd7067e590 Merge pull request #397 from mailpoet/scheduled_sending
Updates scheduling logic to work with the new normalized DB time
2016-03-23 11:51:58 +02:00
1219b5ba49 Merge pull request #396 from mailpoet/timezone_fix
Normalizes time difference between WP and database
2016-03-23 11:45:42 +02:00
01496ac813 Merge branch 'scheduled_sending' of mailpoet:mailpoet/mailpoet into scheduled_sending 2016-03-22 20:55:42 -04:00
3b3ccc18ce - Updates scheduling logic to work with the new normalized DB time 2016-03-22 20:43:16 -04:00
3dce951e66 - Updates rendering engine based on Becs's comments
- Prevents removing of side padding
- Enables font size on output
- Sets line-height in footer
- Adds image height:auto
- Adds mobile styles for buttons
- Updates style sheet
2016-03-22 20:21:39 -04:00
db1dc172aa - Updates scheduling logic to work with the new normalized DB time 2016-03-22 18:26:37 -04:00
26c5cc1e43 - Normalizes time difference between WP and database 2016-03-22 13:05:41 -04:00
f91bfbf473 handle form as iframe 2016-03-22 17:25:25 +01:00
3dae0ef13f increased page input in listings 2016-03-22 17:25:25 +01:00
3281ac390e Improved segment selection errors in form editor
- improved error display to make it more obvious (added border on select2 on error)
2016-03-22 17:25:25 +01:00
d731a6b432 toggle segment selection validation on form editor 2016-03-22 17:25:25 +01:00
bb869e8ae8 Fixed setWindowTitle for WP version < 4.4
- fixed variable name Env::temp_url (instead of temp_URL)
- updated cache folder to be in the temp folder (uploads) instead of views (within plugin)
2016-03-22 17:25:25 +01:00
7331e5cabd Merge pull request #392 from mailpoet/shortcodes_update
Updates shortcodes logic
2016-03-21 17:58:38 +02:00
ba05ca35af - Implements shortcodes rendering in subject line 2016-03-21 11:45:08 -04:00
91e7bf6336 Merge branch 'shortcodes_update' of mailpoet:mailpoet/mailpoet into shortcodes_update 2016-03-21 10:12:10 -04:00
ff58067d55 Change array_column to Helpers::arrayColumn method 2016-03-21 16:07:20 +02:00
2ba6bb339e Fix newsletter options format for newsletters 2016-03-21 15:50:48 +02:00
a47afdd313 - Fixes queue worker issue 2016-03-21 09:09:43 -04:00
608b559ee1 - Minor adjustment to the shortcodes logic 2016-03-21 09:09:43 -04:00
181ed45d0b - Updates shortcodes logic
- Implements [newsletter:total] and [newsletter:number] shortcodes
- Implements shortcode replacement in subject line
- Updates unit tests
Issue #380
2016-03-21 09:09:43 -04:00
29fac8d052 Merge pull request #394 from mailpoet/scheduled_sending
Updates scheduled sending
2016-03-21 15:06:30 +02:00
a3d7d53eea - Fixes queue worker issue 2016-03-21 08:58:51 -04:00
3f6caf5fa4 - Implements scheduler worker for welcome and post notifications
- Updates sending queue worker to save rendered newsletter body
- Updates sending queue router to schedule post notification newsletters
2016-03-20 22:01:01 -04:00
42c4139ba5 - Minor adjustment to the shortcodes logic 2016-03-20 11:37:59 -04:00
ad31b143d2 - Updates scheduler worker to process queued newsletters 2016-03-19 12:29:10 -04:00
6ec15bec22 - Updates shortcodes logic
- Implements [newsletter:total] and [newsletter:number] shortcodes
- Implements shortcode replacement in subject line
- Updates unit tests
Issue #380
2016-03-19 11:19:22 -04:00
71d8fb0d93 Bump up version to 0.0.20 2016-03-18 19:40:11 +02:00
2f293da7a3 Merge pull request #391 from mailpoet/scheduled_sending
Scheduled sending
2016-03-18 18:49:47 +02:00
17b56f0160 - Fixes scheduling issues
- Fixes unit test
- Updates as per code review comments
2016-03-18 12:11:38 -04:00
bb9fce7f82 - Implements post notification scheduling 2016-03-18 11:15:31 -04:00
ad4f1f8326 Merge pull request #390 from mailpoet/newsletter_footer_links
Newsletter footer links
2016-03-18 16:10:17 +02:00
8ece62c9a6 fix tests 2016-03-18 14:58:33 +01:00
a9b9e9c631 Updated tests in order to fix WP related issues 2016-03-18 14:30:59 +01:00
6e289b6a8f - Implements welcome e-mail scheduling 2016-03-17 11:22:29 -04:00
20ced8b099 replace mailpoet_title 'hack' by checking the post type 2016-03-17 15:48:41 +01:00
f38b632707 properly handle custom subscriptions pages 2016-03-17 15:48:41 +01:00
8ce0595342 turned static values into constants 2016-03-17 15:48:06 +01:00
f11de2f1ad Updated shortcodes for unsubscribe/manage/browser links
- fixed all issues in #387 except the custom mailpoet pages
2016-03-17 15:48:06 +01:00
e28451d410 removed edit page in settings + manage subscription update 2016-03-17 15:45:05 +01:00
72882aaf2b fixed shortcodes replacement for "global:" in newsletters
- extracted "get subscription pages urls" from models\Subscriber
- added unit tests for subscription\url class (not working because of WP/Codeception issue)
2016-03-17 15:45:05 +01:00
fdf9dd0fa3 Merge pull request #386 from mailpoet/editor_refactor
Editor refactor
2016-03-17 15:19:04 +01:00
97dd0abea2 fixed makepot task
- added proper grunt module (grunt-cli)
- updated translations extract code to remove warnings when no translations are found
2016-03-17 15:08:38 +01:00
a099174226 Revert "Extract text labels from React code for translation in twig views"
This reverts commit 9aef6850c2.

Conflicts:
	views/newsletters.html
2016-03-17 15:24:07 +02:00
a054acc6e6 Merge pull request #389 from mailpoet/import_xss_update
Updates import to santize user input
2016-03-17 12:02:58 +02:00
74254d7e2a - Updates import to santize user input 2016-03-15 13:06:21 -04:00
1795964c69 - Updates composer dependencies 2016-03-15 12:10:09 -04:00
0118b2472a Fix loading of makepot task for pot translation file generation 2016-03-10 19:24:35 +02:00
5fe03f0dee Add event selection explanation to welcome email type 2016-03-10 17:49:06 +02:00
9aef6850c2 Extract text labels from React code for translation in twig views 2016-03-10 17:08:40 +02:00
f688a69f8b Fix translations to be injected at config time 2016-03-07 17:52:14 +02:00
b2682fa0b7 Remove console.log statements from newsletter editor 2016-03-07 16:57:20 +02:00
18b15c5440 Restructure JS loading to not duplicate JS asset loading 2016-03-07 16:15:26 +02:00
c3416977bb Replace editor translations with Twig localize function 2016-03-07 15:42:12 +02:00
88a00bc38c Rename editor form.html to editor.html 2016-03-07 14:42:12 +02:00
a1441dfde6 Bump up version to 0.0.19 2016-03-04 18:43:22 +02:00
8e7336d352 Merge pull request #373 from mailpoet/editor_rendering
Editor rendering (Part 2)
2016-03-04 11:11:42 -05:00
e0e2933cdf Merge pull request #379 from mailpoet/scheduled_sending
Fix mistyped method name
2016-03-04 11:06:40 -05:00
c93ec629ea Fix mistyped method name 2016-03-04 18:03:02 +02:00
d613df6558 Merge pull request #378 from mailpoet/scheduled_sending
Prepares codebase for future scheduled sending
2016-03-04 17:58:59 +02:00
01c9096543 - Rewrites hooks to not use closures 2016-03-04 10:47:55 -05:00
f120e839dd Merge pull request #375 from mailpoet/export_large_dataset_fix
Export update
2016-03-04 14:12:20 +02:00
f0ab592c04 Merge pull request #376 from mailpoet/rendering_serverside_update
Removes padding from the last column element
2016-03-04 13:30:31 +02:00
1a269d28b3 Merge pull request #374 from mailpoet/edit_subscription
edit subscription form + save
2016-03-04 12:54:56 +02:00
8d4a666bf0 added logged out handling of subscriber save request 2016-03-04 11:52:06 +01:00
4a96e483a6 edit profile rendering (missing segments list) + fallback for Url::redirectBack() 2016-03-04 11:20:17 +01:00
263a66407f - Removes mailpoet_padded class from the last element in a column 2016-03-03 19:13:50 -05:00
c4b728f4e1 - Updates Daemon to execute workers via WP's action hook
- Bootstraps Scheduler class
2016-03-03 15:42:10 -05:00
9970ad7fb6 Merge pull request #369 from mailpoet/manage_subscription
Manage subscription (part 2)
2016-03-03 15:33:56 -05:00
eb380499d9 - Rewrites export to support large datasets
- Updates unit tests
- Fixes an issue with export UI not displaying subscribers without segment
2016-03-03 14:33:10 -05:00
4b528549f5 edit subscription form + save 2016-03-03 15:57:42 +01:00
a903017bc2 Update "Please include unsubscribe link" message 2016-03-03 15:48:59 +02:00
afd25e9174 Remove old and unused editor template 2016-03-03 15:39:46 +02:00
b1bbf1b3bc Add default email for newsletter preview, disallow empty email 2016-03-03 12:59:49 +02:00
9e84e8df93 Show loading icon when loading newsletter preview 2016-03-02 16:57:04 +02:00
df775b5a07 Set font-style for paragraph and headings 2016-03-02 16:57:04 +02:00
c9c22b9b52 Switch 'Comic Sans' to 'Comic Sans MS' 2016-03-02 16:57:04 +02:00
93d20688ea Prevent heading line height and font weight from being overridden 2016-03-02 16:57:04 +02:00
9ebcddfa2a Update button defaults 2016-03-02 16:57:04 +02:00
85995bc8a6 Merge pull request #369 from mailpoet/manage_subscription
Manage subscription (part 2)
2016-03-02 16:42:12 +02:00
a8f2959bc6 added Subscriber::generateToken() 2016-03-02 15:07:37 +01:00
36242bd580 Fixed sending confirmation email to new subscribers (first time)
- fixed newsletters listing issue with queue
2016-03-02 13:11:06 +01:00
1e7dbc8449 refactor pages 2016-03-01 18:27:31 +01:00
12c159c627 bugfix + refactoring 2016-03-01 16:23:15 +01:00
82ed7e51c5 Replaced "contains" by "indexOf" (chrome issue)
- added public ajax routing (not checking permissions)
- exception handling in form subscription
2016-03-01 13:18:36 +01:00
0b3aa0d12a Merge pull request #370 from mailpoet/import_batch_update
Import batch size increase
2016-03-01 12:10:46 +02:00
4d788f69aa - Updates batch size to 2000 2016-02-29 11:41:17 -05:00
c721843c12 extracted subscription pages code from router 2016-02-29 13:34:17 +01:00
d2be407ccb rendering of edit subscription form 2016-02-29 13:34:17 +01:00
e6337216cf improved demo view of subscription pages 2016-02-29 13:34:17 +01:00
f1c396f0b0 basic implementation of confirm/edit/unsubscribe pages 2016-02-29 13:34:17 +01:00
3622bc9fcb fixed sending issue of confirmation email 2016-02-29 13:34:17 +01:00
14fe333678 Send confirmation email + page 2016-02-29 13:34:17 +01:00
cf6466197a Fixed Subscribers' bulk actions when filtering by a segment
- filter by segment is now affected by the selected group (all, trash,...)
- updated relationship methods between subscribers & segments (to account for subsegment status)
2016-02-29 13:34:17 +01:00
f56bee76f2 MailPoet.Date to handle localized dates and times 2016-02-29 13:34:17 +01:00
181 changed files with 7530 additions and 4912 deletions

View File

@ -89,14 +89,14 @@ class RoboFile extends \Robo\Tasks {
}
function makepot() {
$this->_exec('grunt makepot'.
$this->_exec('./node_modules/.bin/grunt makepot'.
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
' --base_path '.__DIR__
);
}
function pushpot() {
$this->_exec('grunt pushpot'.
$this->_exec('./node_modules/.bin/grunt pushpot'.
' --gruntfile '.__DIR__.'/tasks/makepot/makepot.js'.
' --base_path '.__DIR__
);
@ -123,7 +123,7 @@ class RoboFile extends \Robo\Tasks {
$this->compileJs();
$this->_exec(join(' ', array(
'./node_modules/mocha/bin/mocha',
'./node_modules/.bin/mocha',
'-r tests/javascript/mochaTestHelper.js',
'tests/javascript/testBundles/**/*.js'
)));

View File

@ -563,3 +563,6 @@ handle_icon = '../img/handle.png'
.CodeMirror
border: 1px solid #eee
/* Settings */
#mailpoet_form_segments.parsley-error + span .select2-selection
border: 1px solid #b94a48

View File

@ -32,5 +32,6 @@ $block-hover-highlight-color = $primary-active-color
position: relative
line-height: 1.61803398875
p
p, h1, h2, h3, h4, h5, h6
line-height: 1.61803398875
font-style: normal

View File

@ -12,9 +12,11 @@
h1, h2, h3, h4, h5, h6
padding: 0
margin: 0
font-weight: normal
p
margin-top: 0
font-weight: normal
blockquote
margin: 1em

View File

@ -2,3 +2,13 @@
@require 'parsley'
@require 'form_validation'
/* labels */
.mailpoet_text_label
.mailpoet_textarea_label
.mailpoet_select_label
.mailpoet_radio_label
.mailpoet_checkbox_label
.mailpoet_list_label
.mailpoet_date_label
display:block

View File

@ -48,28 +48,22 @@ define(
})
.done(function(response) {
if(!response.result) {
MailPoet.Notice.error(MailPoetI18n.daemonControlError);
MailPoet.Notice.error(MailPoet.I18n.t('daemonControlError'));
}
}.bind(this));
},
render: function() {
if(this.state.status === 'loading') {
return(<div>Loading daemon status...</div>);
return(<div>{MailPoet.I18n.t('loadingDaemonStatus')}</div>);
}
switch(this.state.status) {
case 'started':
return(
<div>
Cron daemon is running.
{MailPoet.I18n.t('cronDaemonIsRunning')}
<br/>
<br/>
It was started
<strong> {this.state.timeSinceStart} </strong> and last executed
<strong> {this.state.timeSinceUpdate} </strong> for a total of
<strong> {this.state.counter} </strong> times (once every 30 seconds, unless it was interrupted and restarted).
<br />
<br />
<a href="#" className="button-primary" onClick={this.controlCron.bind(null, 'stop')}>Stop</a>
<a href="#" className="button-primary" onClick={this.controlCron.bind(null, 'stop')}>{MailPoet.I18n.t('stop')}</a>
</div>
);
break;
@ -77,17 +71,17 @@ define(
case 'stopping':
return(
<div>
Daemon is {this.state.status}
{MailPoet.I18n.t('cronDaemonState').replace('%$1s', this.state.status)}
</div>
);
break;
case 'stopped':
return(
<div>
Daemon is {this.state.status}
{MailPoet.I18n.t('cronDaemonState').replace('%$1s', this.state.status)}
<br />
<br />
<a href="#" className="button-primary" onClick={this.controlCron.bind(null, 'start')}>Start</a>
<a href="#" className="button-primary" onClick={this.controlCron.bind(null, 'start')}>{MailPoet.I18n.t('start')}</a>
</div>
);
break;
@ -103,4 +97,4 @@ define(
container
);
}
});
});

136
assets/js/src/date.js Normal file
View File

@ -0,0 +1,136 @@
define('date',
[
'mailpoet',
'jquery',
'moment'
], function(
MailPoet,
jQuery,
Moment
) {
'use strict';
MailPoet.Date = {
version: 0.1,
options: {},
defaults: {
offset: 0,
format: 'F, d Y H:i:s'
},
init: function(options) {
options = options || {};
// set UTC offset
if (
options.offset === undefined
&& window.mailpoet_date_offset !== undefined
) {
options.offset = window.mailpoet_date_offset;
}
// set date format
if (
options.format === undefined
&& window.mailpoet_date_format !== undefined
) {
options.format = window.mailpoet_date_format;
}
// merge options
this.options = jQuery.extend({}, this.defaults, options);
return this;
},
format: function(date, options) {
this.init(options);
return Moment.utc(date)
.local()
.format(this.convertFormat(this.options.format));
},
short: function(date) {
return this.format(date, {
format: 'F, j Y'
});
},
full: function(date) {
return this.format(date, {
format: 'F, j Y H:i:s'
});
},
time: function(date) {
return this.format(date, {
format: 'H:i:s'
});
},
convertFormat: function(format) {
const format_mappings = {
date: {
D: 'ddd',
l: 'dddd',
d: 'DD',
j: 'D',
z: 'DDDD',
N: 'E',
S: '',
M: 'MMM',
F: 'MMMM',
m: 'MM',
n: '',
t: '',
y: 'YY',
Y: 'YYYY',
H: 'HH',
h: 'hh',
g: 'h',
A: 'A',
i: 'mm',
s: 'ss',
T: 'z',
O: 'ZZ',
w: 'd',
W: 'WW'
},
strftime: {
a: 'ddd',
A: 'dddd',
b: 'MMM',
B: 'MMMM',
d: 'DD',
e: 'D',
F: 'YYYY-MM-DD',
H: 'HH',
I: 'hh',
j: 'DDDD',
k: 'H',
l: 'h',
m: 'MM',
M: 'mm',
p: 'A',
S: 'ss',
u: 'E',
w: 'd',
W: 'WW',
y: 'YY',
Y: 'YYYY',
z: 'ZZ',
Z: 'z'
}
};
const replacements = format_mappings['date'];
let outputFormat = '';
Object.keys(replacements).forEach(function(key) {
if (format.indexOf(key) !== -1) {
format = format.replace(key, '%'+key);
}
});
outputFormat = format;
Object.keys(replacements).forEach(function(key) {
if (outputFormat.indexOf('%'+key) !== -1) {
outputFormat = outputFormat.replace('%'+key, replacements[key]);
}
});
return outputFormat;
}
};
});

View File

@ -167,7 +167,7 @@ define(
<input
className="button button-primary"
type="submit"
value="Save"
value={MailPoet.I18n.t('save')}
disabled={this.state.loading} />
);
}
@ -199,4 +199,4 @@ define(
return Form;
}
);
);

View File

@ -402,11 +402,30 @@ var WysijaForm = {
}
});
// hide list selection if a list widget has been dragged into the editor
$('mailpoet_settings_segment_selection')[
(($$('#' + WysijaForm.options.editor + ' [wysija_id="segments"]').length > 0) === true)
? 'hide' : 'show'
]();
var hasSegmentSelection = WysijaForm.hasSegmentSelection();
if(hasSegmentSelection) {
$('mailpoet_form_segments').writeAttribute('required', false).disable();
$('mailpoet_settings_segment_selection').hide();
} else {
$('mailpoet_form_segments').writeAttribute('required', true).enable();
$('mailpoet_settings_segment_selection').show();
}
},
hasSegmentSelection: function() {
return ($$('#' + WysijaForm.options.editor + ' [wysija_id="segments"]').length > 0);
},
isSegmentSelectionValid: function() {
var segment_selection = $$('#' + WysijaForm.options.editor + ' [wysija_id="segments"]')[0];
if(segment_selection !== undefined) {
var block = WysijaForm.get(segment_selection).block.getData();
return (
(block.params.values !== undefined)
&&
(block.params.values.length > 0)
);
}
return false;
},
setBlockPositions: function(event, target) {
// release dragging lock

View File

@ -8,17 +8,17 @@ import MailPoet from 'mailpoet'
const columns = [
{
name: 'name',
label: 'Name',
label: MailPoet.I18n.t('formName'),
sortable: true
},
{
name: 'segments',
label: 'Lists',
label: MailPoet.I18n.t('segments'),
sortable: false
},
{
name: 'created_at',
label: 'Created on',
label: MailPoet.I18n.t('createdOn'),
sortable: true
}
];
@ -30,11 +30,11 @@ const messages = {
if(count === 1) {
message = (
'1 form was moved to the trash.'
MailPoet.I18n.t('oneFormTrashed')
);
} else {
message = (
'%$1d forms were moved to the trash.'
MailPoet.I18n.t('multipleFormsTrashed')
).replace('%$1d', count);
}
MailPoet.Notice.success(message);
@ -45,11 +45,11 @@ const messages = {
if(count === 1) {
message = (
'1 form was permanently deleted.'
MailPoet.I18n.t('oneFormDeleted')
);
} else {
message = (
'%$1d forms were permanently deleted.'
MailPoet.I18n.t('multipleFormsDeleted')
).replace('%$1d', count);
}
MailPoet.Notice.success(message);
@ -60,11 +60,11 @@ const messages = {
if(count === 1) {
message = (
'1 form has been restored from the trash.'
MailPoet.I18n.t('oneFormRestored')
);
} else {
message = (
'%$1d forms have been restored from the trash.'
MailPoet.I18n.t('multipleFormsRestored')
).replace('%$1d', count);
}
MailPoet.Notice.success(message);
@ -74,16 +74,16 @@ const messages = {
const item_actions = [
{
name: 'edit',
label: 'Edit',
label: MailPoet.I18n.t('edit'),
link: function(item) {
return (
<a href={ `admin.php?page=mailpoet-form-editor&id=${item.id}` }>Edit</a>
<a href={ `admin.php?page=mailpoet-form-editor&id=${item.id}` }>{MailPoet.I18n.t('edit')}</a>
);
}
},
{
name: 'duplicate_form',
label: 'Duplicate',
label: MailPoet.I18n.t('duplicate'),
onClick: function(item, refresh) {
return MailPoet.Ajax.post({
endpoint: 'forms',
@ -91,7 +91,7 @@ const item_actions = [
data: item.id
}).done(function(response) {
MailPoet.Notice.success(
('Form "%$1s" has been duplicated.').replace('%$1s', response.name)
(MailPoet.I18n.t('formDuplicated')).replace('%$1s', response.name)
);
refresh();
});
@ -105,7 +105,7 @@ const item_actions = [
const bulk_actions = [
{
name: 'trash',
label: 'Trash',
label: MailPoet.I18n.t('trash'),
onSuccess: messages.onTrash
}
];
@ -142,11 +142,11 @@ const FormList = React.createClass({
</strong>
{ actions }
</td>
<td className="column-format" data-colname="Lists">
<td className="column-format" data-colname={MailPoet.I18n.t('segments')}>
{ segments }
</td>
<td className="column-date" data-colname="Created on">
<abbr>{ form.created_at }</abbr>
<td className="column-date" data-colname={MailPoet.I18n.t('createdOn')}>
<abbr>{ MailPoet.Date.full(form.created_at) }</abbr>
</td>
</div>
);
@ -155,11 +155,11 @@ const FormList = React.createClass({
return (
<div>
<h2 className="title">
Forms <a
{MailPoet.I18n.t('pageTitle')} <a
className="add-new-h2"
href="javascript:;"
onClick={ this.createForm }
>New</a>
>{MailPoet.I18n.t('new')}</a>
</h2>
<Listing
@ -179,4 +179,4 @@ const FormList = React.createClass({
}
});
module.exports = FormList;
module.exports = FormList;

25
assets/js/src/i18n.js Normal file
View File

@ -0,0 +1,25 @@
define('i18n',
[
'mailpoet',
'underscore',
], function(
MailPoet,
_
) {
'use strict';
var translations = {};
MailPoet.I18n = {
add: function(key, value) {
translations[key] = value;
},
t: function(key) {
return translations[key] || 'TRANSLATION "%$1s" NOT FOUND'.replace("%$1s", key);
},
all: function() {
return translations;
}
};
});

23
assets/js/src/iframe.js Normal file
View File

@ -0,0 +1,23 @@
define('iframe', ['mailpoet', 'jquery'], function(MailPoet, jQuery) {
'use strict';
MailPoet.Iframe = {
marginY: 20,
autoSize: function(iframe) {
if(!iframe) return;
this.setSize(
iframe,
iframe.contentWindow.document.body.scrollHeight
);
},
setSize: function(iframe, i) {
if(!iframe) return;
iframe.style.height = (
parseInt(i) + this.marginY
) + "px";
}
};
return MailPoet;
});

View File

@ -1,8 +1,10 @@
define([
'react'
'react',
'mailpoet'
],
function(
React
React,
MailPoet
) {
var ListingBulkActions = React.createClass({
getInitialState: function() {
@ -82,7 +84,7 @@ function(
<label
className="screen-reader-text"
htmlFor="bulk-action-selector-top">
Select bulk action
{MailPoet.I18n.t('selectBulkAction')}
</label>
<select
@ -91,7 +93,7 @@ function(
value={ this.state.action }
onChange={this.handleChangeAction}
>
<option value="">Bulk Actions</option>
<option value="">{MailPoet.I18n.t('bulkActions')}</option>
{ this.props.bulk_actions.map(function(action, index) {
return (
<option
@ -104,7 +106,7 @@ function(
<input
onClick={ this.handleApplyAction }
type="submit"
defaultValue="Apply"
defaultValue={MailPoet.I18n.t('apply')}
className="button action" />
{ this.state.extra }
@ -114,4 +116,4 @@ function(
});
return ListingBulkActions;
});
});

View File

@ -1,10 +1,12 @@
define([
'react',
'jquery'
'jquery',
'mailpoet'
],
function(
React,
jQuery
jQuery,
MailPoet
) {
var ListingFilters = React.createClass({
handleFilterAction: function() {
@ -69,7 +71,7 @@ function(
id="post-query-submit"
onClick={ this.handleFilterAction }
type="submit"
defaultValue="Filter"
defaultValue={MailPoet.I18n.t('filter')}
className="button" />
);
}
@ -80,7 +82,7 @@ function(
<input
onClick={ this.handleEmptyTrash }
type="submit"
value="Empty Trash"
value={MailPoet.I18n.t('emptyTrash')}
className="button"
/>
);

View File

@ -1,4 +1,12 @@
define(['react', 'classnames'], function(React, classNames) {
define([
'react',
'classnames',
'mailpoet'
], function(
React,
classNames,
MailPoet
) {
var ListingHeader = React.createClass({
handleSelectItems: function() {
@ -28,7 +36,7 @@ define(['react', 'classnames'], function(React, classNames) {
<th
className="manage-column column-cb check-column">
<label className="screen-reader-text">
{ 'Select All' }
{MailPoet.I18n.t('selectAll')}
</label>
<input
type="checkbox"
@ -87,4 +95,4 @@ define(['react', 'classnames'], function(React, classNames) {
});
return ListingHeader;
});
});

View File

@ -98,7 +98,7 @@ define(
null,
this.props.item.id
) }>
Trash
{MailPoet.I18n.t('trash')}
</a>
</span>
);
@ -145,7 +145,7 @@ define(
} else {
item_actions = (
<span className="edit">
<Link to={ `/edit/${ this.props.item.id }` }>Edit</Link>
<Link to={ `/edit/${ this.props.item.id }` }>{MailPoet.I18n.t('edit')}</Link>
</span>
);
}
@ -161,7 +161,7 @@ define(
null,
this.props.item.id
)}
>Restore</a>
>{MailPoet.I18n.t('restore')}</a>
</span>
{ ' | ' }
<span className="delete">
@ -172,13 +172,13 @@ define(
null,
this.props.item.id
)}
>Delete permanently</a>
>{MailPoet.I18n.t('deletePermanently')}</a>
</span>
</div>
<button
onClick={ this.handleToggleItem.bind(null, this.props.item.id) }
className="toggle-row" type="button">
<span className="screen-reader-text">Show more details</span>
<span className="screen-reader-text">{MailPoet.I18n.t('showMoreDetails')}</span>
</button>
</div>
);
@ -191,7 +191,7 @@ define(
<button
onClick={ this.handleToggleItem.bind(null, this.props.item.id) }
className="toggle-row" type="button">
<span className="screen-reader-text">Show more details</span>
<span className="screen-reader-text">{MailPoet.I18n.t('showMoreDetails')}</span>
</button>
</div>
);
@ -223,8 +223,8 @@ define(
className="colspanchange">
{
(this.props.loading === true)
? MailPoetI18n.loadingItems
: MailPoetI18n.noItemsFound
? MailPoet.I18n.t('loadingItems')
: MailPoet.I18n.t('noItemsFound')
}
</td>
</tr>
@ -250,8 +250,8 @@ define(
}>
{
(this.props.selection !== 'all')
? MailPoetI18n.selectAllLabel
: MailPoetI18n.selectedAllLabel.replace(
? MailPoet.I18n.t('selectAllLabel')
: MailPoet.I18n.t('selectedAllLabel').replace(
'%d',
this.props.count
)
@ -261,8 +261,8 @@ define(
onClick={ this.props.onSelectAll }
href="javascript:;">{
(this.props.selection !== 'all')
? MailPoetI18n.selectAllLink
: MailPoetI18n.clearSelection
? MailPoet.I18n.t('selectAllLink')
: MailPoet.I18n.t('clearSelection')
}</a>
</td>
</tr>
@ -519,7 +519,7 @@ define(
group: 'trash'
}, function(response) {
MailPoet.Notice.success(
MailPoetI18n.permanentlyDeleted.replace('%d', response)
MailPoet.I18n.t('permanentlyDeleted').replace('%d', response)
);
});
},
@ -678,12 +678,12 @@ define(
bulk_actions = [
{
name: 'restore',
label: 'Restore',
label: MailPoet.I18n.t('restore'),
onSuccess: this.props.messages.onRestore
},
{
name: 'delete',
label: 'Delete permanently',
label: MailPoet.I18n.t('deletePermanently'),
onSuccess: this.props.messages.onDelete
}
];

View File

@ -1,4 +1,12 @@
define(['react', 'classnames'], function(React, classNames) {
define([
'react',
'classnames',
'mailpoet'
], function(
React,
classNames,
MailPoet
) {
var ListingPages = React.createClass({
getInitialState: function() {
@ -72,7 +80,7 @@ define(['react', 'classnames'], function(React, classNames) {
<a href="javascript:;"
onClick={ this.setPreviousPage }
className="prev-page">
<span className="screen-reader-text">Previous page</span>
<span className="screen-reader-text">{MailPoet.I18n.t('previousPage')}</span>
<span aria-hidden="true"></span>
</a>
);
@ -83,7 +91,7 @@ define(['react', 'classnames'], function(React, classNames) {
<a href="javascript:;"
onClick={ this.setFirstPage }
className="first-page">
<span className="screen-reader-text">First page</span>
<span className="screen-reader-text">{MailPoet.I18n.t('firstPage')}</span>
<span aria-hidden="true">«</span>
</a>
);
@ -94,7 +102,7 @@ define(['react', 'classnames'], function(React, classNames) {
<a href="javascript:;"
onClick={ this.setNextPage }
className="next-page">
<span className="screen-reader-text">Next page</span>
<span className="screen-reader-text">{MailPoet.I18n.t('nextPage')}</span>
<span aria-hidden="true"></span>
</a>
);
@ -105,7 +113,7 @@ define(['react', 'classnames'], function(React, classNames) {
<a href="javascript:;"
onClick={ this.setLastPage }
className="last-page">
<span className="screen-reader-text">Last page</span>
<span className="screen-reader-text">{MailPoet.I18n.t('lastPage')}</span>
<span aria-hidden="true">»</span>
</a>
);
@ -125,20 +133,20 @@ define(['react', 'classnames'], function(React, classNames) {
<span className="paging-input">
<label
className="screen-reader-text"
htmlFor="current-page-selector">Current Page</label>
htmlFor="current-page-selector">{MailPoet.I18n.t('currentPage')}</label>
<input
type="text"
onChange={ this.handleChangeManualPage }
onKeyUp={ this.handleSetManualPage }
onBlur={ this.handleBlurManualPage }
aria-describedby="table-paging"
size="1"
size="2"
ref="page"
value={ pageValue }
name="paged"
id="current-page-selector"
className="current-page" />
&nbsp;of&nbsp;
&nbsp;{MailPoet.I18n.t('pageOutOf')}&nbsp;
<span className="total-pages">
{Math.ceil(this.props.count / this.props.limit)}
</span>
@ -158,7 +166,9 @@ define(['react', 'classnames'], function(React, classNames) {
return (
<div className={ classes }>
<span className="displaying-num">{ this.props.count } items</span>
<span className="displaying-num">{
MailPoet.I18n.t('numberOfItems').replace('%$1d', this.props.count)
}</span>
{ pagination }
</div>
);
@ -167,4 +177,4 @@ define(['react', 'classnames'], function(React, classNames) {
});
return ListingPages;
});
});

View File

@ -1,4 +1,10 @@
define(['react'], function(React) {
define([
'mailpoet',
'react'
], function(
MailPoet,
React
) {
var ListingSearch = React.createClass({
handleSearch: function(e) {
@ -18,7 +24,7 @@ define(['react'], function(React) {
<form name="search" onSubmit={this.handleSearch}>
<p className="search-box">
<label htmlFor="search_input" className="screen-reader-text">
Search
{MailPoet.I18n.t('searchLabel')}
</label>
<input
type="search"
@ -28,7 +34,7 @@ define(['react'], function(React) {
defaultValue={this.props.search} />
<input
type="submit"
defaultValue={MailPoetI18n.searchLabel}
defaultValue={MailPoet.I18n.t('searchLabel')}
className="button" />
</p>
</form>

View File

@ -12,9 +12,19 @@ define([
'newsletter_editor/blocks/button',
'newsletter_editor/blocks/divider',
'newsletter_editor/components/communication',
'mailpoet',
'underscore',
'jquery'
], function(App, BaseBlock, ButtonBlock, DividerBlock, CommunicationComponent, _, jQuery) {
], function(
App,
BaseBlock,
ButtonBlock,
DividerBlock,
CommunicationComponent,
MailPoet,
_,
jQuery
) {
"use strict";
@ -73,7 +83,7 @@ define([
that.get('_container').get('blocks').reset(content, {parse: true});
that.trigger('postsChanged');
}).fail(function(error) {
console.log('ALC fetchPosts error', arguments);
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchRenderedPosts'));
});
},
/**

View File

@ -16,7 +16,7 @@ define([
defaults: function() {
return this._getDefaults({
type: 'footer',
text: '<a href="[unsubscribeUrl]">Unsubscribe</a> | <a href="[manageSubscriptionUrl]">Manage subscription</a><br /><b>Add your postal address here!</b>',
text: '<a href="[subscription:unsubscribe_url]">Unsubscribe</a> | <a href="[subscription:manage_url]">Manage subscription</a><br /><b>Add your postal address here!</b>',
styles: {
block: {
backgroundColor: 'transparent',
@ -79,7 +79,7 @@ define([
},
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
mailpoet_custom_fields_window_title: MailPoet.I18n.t('customFieldsWindowTitle'),
});
},
});

View File

@ -16,7 +16,7 @@ define([
defaults: function() {
return this._getDefaults({
type: 'header',
text: 'Display problems? <a href="[viewInBrowserUrl]">View it in your browser</a>',
text: 'Display problems? <a href="[newsletter:view_in_browser_url]">View it in your browser</a>',
styles: {
block: {
backgroundColor: 'transparent',
@ -79,7 +79,7 @@ define([
},
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
mailpoet_custom_fields_window_title: MailPoet.I18n.t('customFieldsWindowTitle'),
});
},
});

View File

@ -101,7 +101,7 @@ define([
that.get('_selectedPosts').reset(); // Empty out the collection
that.trigger('change:_availablePosts');
}).fail(function() {
console.log('Posts fetchPosts error', arguments);
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchAvailablePosts'));
});
},
_refreshTransformedPosts: function() {
@ -118,7 +118,7 @@ define([
CommunicationComponent.getTransformedPosts(data).done(function(posts) {
that.get('_transformedPosts').get('blocks').reset(posts, {parse: true});
}).fail(function() {
console.log('Posts _refreshTransformedPosts error', arguments);
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchRenderedPosts'));
});
},
_insertSelectedPosts: function() {
@ -134,7 +134,7 @@ define([
CommunicationComponent.getTransformedPosts(data).done(function(posts) {
collection.add(posts, { at: index });
}).fail(function() {
console.log('Posts fetchPosts error', arguments);
MailPoet.Notice.error(MailPoet.I18n.t('failedToFetchRenderedPosts'));
});
},
});

View File

@ -77,7 +77,7 @@ define([
},
mailpoet_custom_fields: App.getConfig().get('customFields').toJSON(),
mailpoet_custom_fields_window_title: App.getConfig().get('translations.customFieldsWindowTitle'),
mailpoet_custom_fields_window_title: MailPoet.I18n.t('customFieldsWindowTitle'),
});
}
},

View File

@ -10,7 +10,6 @@ define([
availableStyles: {},
socialIcons: {},
blockDefaults: {},
translations: {},
sidepanelWidth: '331px',
validation: {},
urls: {},

View File

@ -191,7 +191,7 @@ define([
if (templateName === '') {
MailPoet.Notice.error(
App.getConfig().get('translations.templateNameMissing'),
MailPoet.I18n.t('templateNameMissing'),
{
positionAfter: that.$el,
scroll: true,
@ -199,30 +199,27 @@ define([
);
} else if (templateDescription === '') {
MailPoet.Notice.error(
App.getConfig().get('translations.templateDescriptionMissing'),
MailPoet.I18n.t('templateDescriptionMissing'),
{
positionAfter: that.$el,
scroll: true,
}
);
} else {
console.log('Saving template with ', templateName, templateDescription);
Module.saveTemplate({
name: templateName,
description: templateDescription,
}).done(function() {
console.log('Template saved', arguments);
MailPoet.Notice.success(
App.getConfig().get('translations.templateSaved'),
MailPoet.I18n.t('templateSaved'),
{
positionAfter: that.$el,
scroll: true,
}
);
}).fail(function() {
console.log('Template save failed', arguments);
MailPoet.Notice.error(
App.getConfig().get('translations.templateSaveFailed'),
MailPoet.I18n.t('templateSaveFailed'),
{
positionAfter: that.$el,
scroll: true,
@ -247,7 +244,7 @@ define([
if (templateName === '') {
MailPoet.Notice.error(
App.getConfig().get('translations.templateNameMissing'),
MailPoet.I18n.t('templateNameMissing'),
{
positionAfter: that.$el,
scroll: true,
@ -255,14 +252,13 @@ define([
);
} else if (templateDescription === '') {
MailPoet.Notice.error(
App.getConfig().get('translations.templateDescriptionMissing'),
MailPoet.I18n.t('templateDescriptionMissing'),
{
positionAfter: that.$el,
scroll: true,
}
);
} else {
console.log('Exporting template with ', templateName, templateDescription);
Module.exportTemplate({
name: templateName,
description: templateDescription,
@ -278,7 +274,6 @@ define([
next: function() {
this.hideOptionContents();
if(!this.$('.mailpoet_save_next').hasClass('button-disabled')) {
console.log('Next');
window.location.href = App.getConfig().get('urls.send');
}
},
@ -289,8 +284,8 @@ define([
}
if (App.getConfig().get('validation.validateUnsubscribeLinkPresent') &&
JSON.stringify(jsonObject).indexOf("[unsubscribeUrl]") < 0) {
this.showValidationError(App.getConfig().get('translations.unsubscribeLinkMissing'));
JSON.stringify(jsonObject).indexOf("[subscription:unsubscribe_url]") < 0) {
this.showValidationError(MailPoet.I18n.t('unsubscribeLinkMissing'));
return;
}

View File

@ -1,13 +1,24 @@
define([
'newsletter_editor/App',
'newsletter_editor/components/communication',
'mailpoet',
'backbone',
'backbone.marionette',
'backbone.supermodel',
'underscore',
'jquery',
'sticky-kit'
], function(App, CommunicationComponent, Backbone, Marionette, SuperModel, _, jQuery, StickyKit) {
], function(
App,
CommunicationComponent,
MailPoet,
Backbone,
Marionette,
SuperModel,
_,
jQuery,
StickyKit
) {
"use strict";
@ -230,33 +241,45 @@ define([
json.body = JSON.stringify(json.body);
}
MailPoet.Modal.loading(true);
MailPoet.Ajax.post({
endpoint: 'newsletters',
action: 'render',
data: json,
}).done(function(response){
console.log('Should open a new window');
MailPoet.Modal.loading(false);
window.open('data:text/html;charset=utf-8,' + encodeURIComponent(response.rendered_body), '_blank');
}).fail(function(error) {
console.log('Preview error', json);
MailPoet.Modal.loading(false);
alert('Something went wrong, check console');
});
},
sendPreview: function() {
// testing sending method
console.log('trying to send a preview');
// get form data
var $emailField = this.$('#mailpoet_preview_to_email');
var data = {
subscriber: this.$('#mailpoet_preview_to_email').val(),
subscriber: $emailField.val(),
id: App.getNewsletter().get('id'),
};
if (data.subscriber.length <= 0) {
MailPoet.Notice.error(
MailPoet.I18n.t('newsletterPreviewEmailMissing'),
{
positionAfter: $emailField,
scroll: true,
}
);
return false;
}
// send test email
MailPoet.Modal.loading(true);
CommunicationComponent.previewNewsletter(data).done(function(response) {
if(response.result !== undefined && response.result === true) {
MailPoet.Notice.success(App.getConfig().get('translations.newsletterPreviewSent'), { scroll: true });
MailPoet.Notice.success(MailPoet.I18n.t('newsletterPreviewSent'), { scroll: true });
} else {
if (_.isArray(response.errors)) {
response.errors.map(function(error) {
@ -264,7 +287,7 @@ define([
});
} else {
MailPoet.Notice.error(
App.getConfig().get('translations.newsletterPreviewFailedToSend'),
MailPoet.I18n.t('newsletterPreviewFailedToSend'),
{
scroll: true,
static: true,

View File

@ -2,12 +2,14 @@ define(
[
'react',
'react-router',
'classnames'
'classnames',
'mailpoet'
],
function(
React,
Router,
classNames
classNames,
MailPoet
) {
var Link = Router.Link;
@ -21,20 +23,20 @@ define(
steps: [
{
name: 'type',
label: 'Select type',
label: MailPoet.I18n.t('selectType'),
link: '/new'
},
{
name: 'template',
label: 'Template'
label: MailPoet.I18n.t('template')
},
{
name: 'editor',
label: 'Designer'
label: MailPoet.I18n.t('designer')
},
{
name: 'send',
label: 'Send'
label: MailPoet.I18n.t('send')
}
]
};
@ -73,4 +75,4 @@ define(
return Breadcrumb;
}
);
);

View File

@ -4,39 +4,41 @@ define(
'react-router',
'listing/listing.jsx',
'classnames',
'jquery'
'jquery',
'mailpoet'
],
function(
React,
Router,
Listing,
classNames,
jQuery
jQuery,
MailPoet
) {
var Link = Router.Link;
var columns = [
{
name: 'subject',
label: 'Subject',
label: MailPoet.I18n.t('subject'),
sortable: true
},
{
name: 'status',
label: 'Status'
label: MailPoet.I18n.t('status')
},
{
name: 'segments',
label: 'Lists'
label: MailPoet.I18n.t('lists')
},
{
name: 'created_at',
label: 'Created on',
label: MailPoet.I18n.t('createdOn'),
sortable: true
},
{
name: 'updated_at',
label: 'Last modified on',
label: MailPoet.I18n.t('lastModifiedOn'),
sortable: true
}
];
@ -48,11 +50,11 @@ define(
if(count === 1) {
message = (
'1 newsletter was moved to the trash.'
MailPoet.I18n.t('oneNewsletterTrashed')
);
} else {
message = (
'%$1d newsletters were moved to the trash.'
MailPoet.I18n.t('multipleNewslettersTrashed')
).replace('%$1d', count);
}
MailPoet.Notice.success(message);
@ -63,11 +65,11 @@ define(
if(count === 1) {
message = (
'1 newsletter was permanently deleted.'
MailPoet.I18n.t('oneNewsletterDeleted')
);
} else {
message = (
'%$1d newsletters were permanently deleted.'
MailPoet.I18n.t('multipleNewslettersDeleted')
).replace('%$1d', count);
}
MailPoet.Notice.success(message);
@ -78,11 +80,11 @@ define(
if(count === 1) {
message = (
'1 newsletter has been restored from the trash.'
MailPoet.I18n.t('oneNewsletterRestored')
);
} else {
message = (
'%$1d newsletters have been restored from the trash.'
MailPoet.I18n.t('multipleNewslettersRestored')
).replace('%$1d', count);
}
MailPoet.Notice.success(message);
@ -92,7 +94,7 @@ define(
var bulk_actions = [
{
name: 'trash',
label: 'Trash',
label: MailPoet.I18n.t('trash'),
onSuccess: messages.onTrash
}
];
@ -103,7 +105,7 @@ define(
link: function(item) {
return (
<a href={ `?page=mailpoet-newsletter-editor&id=${ item.id }` }>
Edit
{MailPoet.I18n.t('edit')}
</a>
);
}
@ -135,9 +137,9 @@ define(
});
},
renderStatus: function(item) {
if(item.queue === null) {
if(!item.queue) {
return (
<span>Not sent yet.</span>
<span>{MailPoet.I18n.t('notSentYet')}</span>
);
} else {
var progressClasses = classNames(
@ -155,9 +157,11 @@ define(
if(item.queue.status === 'completed') {
label = (
<span>
Sent to {
item.queue.count_processed - item.queue.count_failed
} out of { item.queue.count_total }.
{
MailPoet.I18n.t('newsletterQueueCompleted')
.replace("%$1d", item.queue.count_processed - item.queue.count_failed)
.replace("%$2d", item.queue.count_total)
}
</span>
);
} else {
@ -171,14 +175,14 @@ define(
style={{ display: (item.queue.status === 'paused') ? 'inline-block': 'none' }}
href="javascript:;"
onClick={ this.resumeSending.bind(null, item) }
>Resume</a>
>{MailPoet.I18n.t('resume')}</a>
<a
id={ 'pause_'+item.id }
className="button mailpoet_pause"
style={{ display: (item.queue.status === null) ? 'inline-block': 'none' }}
href="javascript:;"
onClick={ this.pauseSending.bind(null, item) }
>Pause</a>
>{MailPoet.I18n.t('pause')}</a>
</span>
);
}
@ -208,10 +212,8 @@ define(
'has-row-actions'
);
var segments = mailpoet_segments.filter(function(segment) {
return (jQuery.inArray(segment.id, newsletter.segments) !== -1);
}).map(function(segment) {
return segment.name;
var segments = newsletter.segments.map(function(segment) {
return segment.name
}).join(', ');
return (
@ -229,10 +231,10 @@ define(
{ segments }
</td>
<td className="column-date" data-colname="Subscribed on">
<abbr>{ newsletter.created_at }</abbr>
<abbr>{ MailPoet.Date.full(newsletter.created_at) }</abbr>
</td>
<td className="column-date" data-colname="Last modified on">
<abbr>{ newsletter.updated_at }</abbr>
<abbr>{ MailPoet.Date.full(newsletter.updated_at) }</abbr>
</td>
</div>
);
@ -241,7 +243,7 @@ define(
return (
<div>
<h2 className="title">
Newsletters <Link className="add-new-h2" to="/new">New</Link>
{MailPoet.I18n.t('pageTitle')} <Link className="add-new-h2" to="/new">{MailPoet.I18n.t('new')}</Link>
</h2>
<Listing
@ -260,4 +262,4 @@ define(
return NewsletterList;
}
);
);

View File

@ -21,21 +21,20 @@ define(
var fields = [
{
name: 'subject',
label: 'Subject line',
tip: "Be creative! It's the first thing your subscribers see."+
"Tempt them to open your email.",
label: MailPoet.I18n.t('subjectLine'),
tip: MailPoet.I18n.t('subjectLineTip'),
type: 'text',
validation: {
'data-parsley-required': true,
'data-parsley-required-message': 'You need to specify a subject.'
'data-parsley-required-message': MailPoet.I18n.t('emptySubjectLineError')
}
},
{
name: 'segments',
label: 'Segments',
tip: "The subscriber segment that will be used for this campaign.",
label: MailPoet.I18n.t('segments'),
tip: MailPoet.I18n.t('segmentsTip'),
type: 'selection',
placeholder: "Select a segment",
placeholder: MailPoet.I18n.t('selectSegmentPlaceholder'),
id: "mailpoet_segments",
endpoint: "segments",
multiple: true,
@ -44,18 +43,18 @@ define(
},
validation: {
'data-parsley-required': true,
'data-parsley-required-message': 'You need to select a segment.'
'data-parsley-required-message': MailPoet.I18n.t('noSegmentsSelectedError')
}
},
{
name: 'sender',
label: 'Sender',
tip: "Name & email of yourself or your company.",
label: MailPoet.I18n.t('sender'),
tip: MailPoet.I18n.t('senderTip'),
fields: [
{
name: 'sender_name',
type: 'text',
placeholder: 'John Doe',
placeholder: MailPoet.I18n.t('senderNamePlaceholder'),
defaultValue: (settings.sender !== undefined) ? settings.sender.name : '',
validation: {
'data-parsley-required': true
@ -64,7 +63,7 @@ define(
{
name: 'sender_address',
type: 'text',
placeholder: 'john.doe@email.com',
placeholder: MailPoet.I18n.t('senderAddressPlaceholder'),
defaultValue: (settings.sender !== undefined) ? settings.sender.address : '',
validation: {
'data-parsley-required': true,
@ -75,21 +74,20 @@ define(
},
{
name: 'reply-to',
label: 'Reply-to',
tip: 'When the subscribers hit "reply" this is who will receive their '+
'email.',
label: MailPoet.I18n.t('replyTo'),
tip: MailPoet.I18n.t('replyToTip'),
inline: true,
fields: [
{
name: 'reply_to_name',
type: 'text',
placeholder: 'John Doe',
placeholder: MailPoet.I18n.t('replyToNamePlaceholder'),
defaultValue: (settings.reply_to !== undefined) ? settings.reply_to.name : '',
},
{
name: 'reply_to_address',
type: 'text',
placeholder: 'john.doe@email.com',
placeholder: MailPoet.I18n.t('replyToAddressPlaceholder'),
defaultValue: (settings.reply_to !== undefined) ? settings.reply_to.address : ''
},
]
@ -98,10 +96,10 @@ define(
var messages = {
onUpdate: function() {
MailPoet.Notice.success('Newsletter successfully updated!');
MailPoet.Notice.success(MailPoet.I18n.t('newsletterUpdated'));
},
onCreate: function() {
MailPoet.Notice.success('Newsletter successfully added!');
MailPoet.Notice.success(MailPoet.I18n.t('newsletterAdded'));
}
};
@ -138,15 +136,14 @@ define(
if(response.result === true) {
this.history.pushState(null, '/');
MailPoet.Notice.success(
'The newsletter is being sent...'
MailPoet.I18n.t('newsletterIsBeingSent')
);
} else {
if(response.errors) {
MailPoet.Notice.error(response.errors);
} else {
MailPoet.Notice.error(
'An error occurred while trying to send. '+
'<a href="?page=mailpoet-settings">Check your settings.</a>'
MailPoet.I18n.t('newsletterSendingError').replace("%$1s", '?page=mailpoet-settings')
);
}
}
@ -157,7 +154,7 @@ define(
render: function() {
return (
<div>
<h1>Final step: last details</h1>
<h1>{MailPoet.I18n.t('finalNewsletterStep')}</h1>
<Breadcrumb step="send" />
@ -174,18 +171,18 @@ define(
className="button button-primary"
type="button"
onClick={ this.handleSend }
value="Send" />
value={MailPoet.I18n.t('send')} />
&nbsp;
<input
className="button button-secondary"
type="submit"
value="Save as draft and close" />
&nbsp;or simply&nbsp;
value={MailPoet.I18n.t('saveDraftAndClose')} />
&nbsp;{MailPoet.I18n.t('orSimply')}&nbsp;
<a
href={
'?page=mailpoet-newsletter-editor&id='+this.props.params.id
}>
go back to design
{MailPoet.I18n.t('goBackToDesign')}
</a>.
</p>
</Form>
@ -196,4 +193,4 @@ define(
return NewsletterSend;
}
);
);

View File

@ -54,7 +54,7 @@ define(
try {
saveTemplate(JSON.parse(e.target.result));
} catch (err) {
MailPoet.Notice.error('This template file appears to be malformed. Please try another one.');
MailPoet.Notice.error(MailPoet.I18n.t('templateFileMalformedError'));
}
}.bind(this);
@ -63,15 +63,15 @@ define(
render: function() {
return (
<div>
<h2>Import a template</h2>
<h2>{MailPoet.I18n.t('importTemplateTitle')}</h2>
<form onSubmit={this.handleSubmit}>
<input type="file" placeholder="Select a .json file to upload" ref="templateFile" />
<input type="file" placeholder={MailPoet.I18n.t('selectJsonFileToUpload')} ref="templateFile" />
<p className="submit">
<input
className="button button-primary"
type="submit"
value="Upload" />
value={MailPoet.I18n.t('upload')} />
</p>
</form>
</div>
@ -108,9 +108,9 @@ define(
response = [
{
name:
"MailPoet's Guide",
MailPoet.I18n.t('mailpoetGuideTemplateTitle'),
description:
"This is the standard template that comes with MailPoet.",
MailPoet.I18n.t('mailpoetGuideTemplateDescription'),
readonly: "1"
}
]
@ -155,7 +155,9 @@ define(
this.setState({ loading: true });
if(
window.confirm(
'You are about to delete the template named "'+ template.name +'"'
(
MailPoet.I18n.t('confirmTemplateDeletion')
).replace("%$1s", template.name)
)
) {
MailPoet.Ajax.post({
@ -187,7 +189,7 @@ define(
href="javascript:;"
onClick={ this.handleDeleteTemplate.bind(null, template) }
>
Delete
{MailPoet.I18n.t('delete')}
</a>
</div>
), thumbnail = '';
@ -218,7 +220,7 @@ define(
className="button button-primary"
onClick={ this.handleSelectTemplate.bind(null, template) }
>
Select
{MailPoet.I18n.t('select')}
</a>
&nbsp;
<a
@ -226,7 +228,7 @@ define(
className="button button-secondary"
onClick={ this.handlePreviewTemplate.bind(null, template) }
>
Preview
{MailPoet.I18n.t('preview')}
</a>
</div>
{ (template.readonly === "1") ? false : deleteLink }
@ -242,7 +244,7 @@ define(
return (
<div>
<h1>Select a template</h1>
<h1>{MailPoet.I18n.t('selectTemplateTitle')}</h1>
<Breadcrumb step="template" />

View File

@ -26,7 +26,7 @@ define(
action: 'create',
data: {
type: type,
subject: 'Draft newsletter',
subject: MailPoet.I18n.t('draftNewsletterTitle'),
}
}).done(function(response) {
if(response.result && response.newsletter.id) {
@ -43,7 +43,7 @@ define(
render: function() {
return (
<div>
<h1>Pick a type of campaign</h1>
<h1>{MailPoet.I18n.t('pickCampaignType')}</h1>
<Breadcrumb step="type" />
@ -52,10 +52,9 @@ define(
<div className="mailpoet_thumbnail"></div>
<div className="mailpoet_description">
<h3>Newsletter</h3>
<h3>{MailPoet.I18n.t('regularNewsletterTypeTitle')}</h3>
<p>
Send a newsletter with images, buttons, dividers,
and social bookmarks. Or a simple email.
{MailPoet.I18n.t('regularNewsletterTypeDescription')}
</p>
</div>
@ -64,7 +63,7 @@ define(
className="button button-primary"
onClick={ this.createNewsletter.bind(null, 'standard') }
>
Create
{MailPoet.I18n.t('create')}
</a>
</div>
</li>
@ -73,9 +72,9 @@ define(
<div className="mailpoet_thumbnail"></div>
<div className="mailpoet_description">
<h3>Welcome email</h3>
<h3>{MailPoet.I18n.t('welcomeNewsletterTypeTitle')}</h3>
<p>
Send an email for new users.
{MailPoet.I18n.t('welcomeNewsletterTypeDescription')}
</p>
</div>
@ -84,7 +83,7 @@ define(
className="button button-primary"
onClick={ this.setupNewsletter.bind(null, 'welcome') }
>
Set up
{MailPoet.I18n.t('setUp')}
</a>
</div>
</li>
@ -93,9 +92,9 @@ define(
<div className="mailpoet_thumbnail"></div>
<div className="mailpoet_description">
<h3>Post notifications</h3>
<h3>{MailPoet.I18n.t('postNotificationNewsletterTypeTitle')}</h3>
<p>
Automatically send posts immediately, daily, weekly or monthly. Filter by categories, if you like.
{MailPoet.I18n.t('postNotificationsNewsletterTypeDescription')}
</p>
</div>
@ -104,7 +103,7 @@ define(
className="button button-primary"
onClick={ this.setupNewsletter.bind(null, 'notification') }
>
Set up
{MailPoet.I18n.t('setUp')}
</a>
</div>
</li>

View File

@ -25,11 +25,11 @@ define(
var intervalField = {
name: 'interval',
values: {
'daily': 'Once a day at...',
'weekly': 'Weekly on...',
'monthly': 'Monthly on the...',
'nthWeekDay': 'Monthly every...',
'immediately': 'Immediately.',
'daily': MailPoet.I18n.t('daily'),
'weekly': MailPoet.I18n.t('weekly'),
'monthly': MailPoet.I18n.t('monthly'),
'nthWeekDay': MailPoet.I18n.t('monthlyEvery'),
'immediately': MailPoet.I18n.t('immediately'),
},
};
@ -53,13 +53,13 @@ define(
var weekDayField = {
name: 'weekDay',
values: {
0: 'Monday',
1: 'Tuesday',
2: 'Wednesday',
3: 'Thursday',
4: 'Friday',
5: 'Saturday',
6: 'Sunday',
0: MailPoet.I18n.t('sunday'),
1: MailPoet.I18n.t('monday'),
2: MailPoet.I18n.t('tuesday'),
3: MailPoet.I18n.t('wednesday'),
4: MailPoet.I18n.t('thursday'),
5: MailPoet.I18n.t('friday'),
6: MailPoet.I18n.t('saturday')
},
};
@ -69,14 +69,19 @@ define(
values: _.object(_.map(
_.times(NUMBER_OF_DAYS_IN_MONTH, function(day) { return day; }),
function(day) {
var suffixes = {
0: 'st',
1: 'nd',
2: 'rd'
};
var suffix = suffixes[day] || 'th';
var labels = {
0: MailPoet.I18n.t('first'),
1: MailPoet.I18n.t('second'),
2: MailPoet.I18n.t('third')
},
label;
if (labels[day] !== undefined) {
label = labels[day];
} else {
label = MailPoet.I18n.t('nth').replace("%$1d", day + 1);
}
return [day, (day + 1).toString() + suffix];
return [day, label];
},
)),
};
@ -84,10 +89,10 @@ define(
var nthWeekDayField = {
name: 'nthWeekDay',
values: {
'0': '1st',
'1': '2nd',
'2': '3rd',
'3': 'last',
'1': MailPoet.I18n.t('first'),
'2': MailPoet.I18n.t('second'),
'3': MailPoet.I18n.t('third'),
'L': MailPoet.I18n.t('last'),
},
};
@ -99,9 +104,9 @@ define(
return {
intervalType: 'immediate', // 'immediate'|'daily'|'weekly'|'monthly'
timeOfDay: 0,
weekDay: 0,
weekDay: 1,
monthDay: 0,
nthWeekDay: 0,
nthWeekDay: 1,
};
},
handleIntervalChange: function(event) {
@ -197,7 +202,7 @@ define(
return (
<div>
<h1>Post notifications</h1>
<h1>{MailPoet.I18n.t('postNotificationNewsletterTypeTitle')}</h1>
<Breadcrumb step="type" />
<Select
@ -215,7 +220,7 @@ define(
className="button button-primary"
type="button"
onClick={ this.handleNext }
value="Next" />
value={MailPoet.I18n.t('next')} />
</p>
</div>
);

View File

@ -47,7 +47,7 @@ define(
render: function() {
return (
<div>
<h1>Newsletter</h1>
<h1>{MailPoet.I18n.t('regularNewsletterTypeTitle')}</h1>
<Breadcrumb step="type" />
</div>
);

View File

@ -28,8 +28,8 @@ define(
var events = {
name: 'event',
values: {
'segment': 'When someone subscribes to the list...',
'user': 'When a new Wordrpess user is added to your site...',
'segment': MailPoet.I18n.t('onSubscriptionToList'),
'user': MailPoet.I18n.t('onWordpressUserRegistration'),
}
};
@ -57,10 +57,10 @@ define(
var afterTimeTypeField = {
name: 'afterTimeType',
values: {
'immediate': 'immediately',
'hours': 'hour(s) after',
'days': 'day(s) after',
'weeks': 'week(s) after',
'immediate': MailPoet.I18n.t('delayImmediately'),
'hours': MailPoet.I18n.t('delayHoursAfter'),
'days': MailPoet.I18n.t('delayDaysAfter'),
'weeks': MailPoet.I18n.t('delayWeeksAfter'),
}
};
@ -152,9 +152,11 @@ define(
}
return (
<div>
<h1>Welcome email</h1>
<h1>{MailPoet.I18n.t('welcomeNewsletterTypeTitle')}</h1>
<Breadcrumb step="type" />
<h3>{MailPoet.I18n.t('selectEventToSendWelcomeEmail')}</h3>
<Select
field={events}
item={this.state}
@ -174,7 +176,7 @@ define(
className="button button-primary"
type="button"
onClick={ this.handleNext }
value="Next" />
value={MailPoet.I18n.t('next')} />
</p>
</div>
);

View File

@ -20,13 +20,18 @@ function(
$('form.mailpoet_form').each(function() {
var form = $(this);
form.parsley().on('form:submit', function(parsley) {
var data = form.serializeObject() || {};
form.parsley().on('form:validated', function(parsley) {
// clear messages
form.find('.mailpoet_message').html('');
// resize iframe
if(window.frameElement !== null) {
MailPoet.Iframe.autoSize(window.frameElement);
}
});
form.parsley().on('form:submit', function(parsley) {
var data = form.serializeObject() || {};
// check if we're on the same domain
if(isSameDomain(MailPoetForm.ajax_url) === false) {
// non ajax post request
@ -68,6 +73,11 @@ function(
// reset validation
parsley.reset();
}
// resize iframe
if(window.frameElement !== null) {
MailPoet.Iframe.autoSize(window.frameElement);
}
});
}
return false;

View File

@ -15,22 +15,22 @@ define(
let fields = [
{
name: 'name',
label: 'Name',
label: MailPoet.I18n.t('name'),
type: 'text'
},
{
name: 'description',
label: 'Description',
label: MailPoet.I18n.t('description'),
type: 'textarea'
}
];
const messages = {
onUpdate: function() {
MailPoet.Notice.success('Segment successfully updated!');
MailPoet.Notice.success(MailPoet.I18n.t('segmentUpdated'));
},
onCreate: function() {
MailPoet.Notice.success('Segment successfully added!');
MailPoet.Notice.success(MailPoet.I18n.t('segmentAdded'));
}
};
@ -42,7 +42,7 @@ define(
return (
<div>
<h2 className="title">
Segment
{MailPoet.I18n.t('segment')}
</h2>
<Form

View File

@ -10,32 +10,32 @@ import Listing from 'listing/listing.jsx'
var columns = [
{
name: 'name',
label: 'Name',
label: MailPoet.I18n.t('name'),
sortable: true
},
{
name: 'description',
label: 'Description',
label: MailPoet.I18n.t('description'),
sortable: false
},
{
name: 'subscribed',
label: 'Subscribed',
label: MailPoet.I18n.t('subscribed'),
sortable: false
},
{
name: 'unconfirmed',
label: 'Unconfirmed',
label: MailPoet.I18n.t('unconfirmed'),
sortable: false
},
{
name: 'unsubscribed',
label: 'Unsubscribed',
label: MailPoet.I18n.t('unsubscribed'),
sortable: false
},
{
name: 'created_at',
label: 'Created on',
label: MailPoet.I18n.t('createdOn'),
sortable: true
}
];
@ -47,11 +47,11 @@ const messages = {
if(count === 1) {
message = (
'1 segment was moved to the trash.'
MailPoet.I18n.t('oneSegmentTrashed')
);
} else {
message = (
'%$1d segments were moved to the trash.'
MailPoet.I18n.t('multipleSegmentsTrashed')
).replace('%$1d', count);
}
MailPoet.Notice.success(message);
@ -62,11 +62,11 @@ const messages = {
if(count === 1) {
message = (
'1 segment was permanently deleted.'
MailPoet.I18n.t('oneSegmentDeleted')
);
} else {
message = (
'%$1d segments were permanently deleted.'
MailPoet.I18n.t('multipleSegmentsDeleted')
).replace('%$1d', count);
}
MailPoet.Notice.success(message);
@ -77,11 +77,11 @@ const messages = {
if(count === 1) {
message = (
'1 segment has been restored from the trash.'
MailPoet.I18n.t('oneSegmentRestored')
);
} else {
message = (
'%$1d segments have been restored from the trash.'
MailPoet.I18n.t('multipleSegmentsRestored')
).replace('%$1d', count);
}
MailPoet.Notice.success(message);
@ -91,10 +91,10 @@ const messages = {
const item_actions = [
{
name: 'edit',
label: 'Edit',
label: MailPoet.I18n.t('edit'),
link: function(item) {
return (
<Link to={ `/edit/${item.id}` }>Edit</Link>
<Link to={ `/edit/${item.id}` }>{MailPoet.I18n.t('edit')}</Link>
);
},
display: function(segment) {
@ -111,7 +111,7 @@ const item_actions = [
data: item.id
}).done(function(response) {
MailPoet.Notice.success(
('List "%$1s" has been duplicated.').replace('%$1s', response.name)
(MailPoet.I18n.t('listDuplicated')).replace('%$1s', response.name)
);
refresh();
});
@ -122,7 +122,7 @@ const item_actions = [
},
{
name: 'synchronize_segment',
label: 'Update',
label: MailPoet.I18n.t('update'),
className: 'update',
onClick: function(item, refresh) {
MailPoet.Modal.loading(true);
@ -133,7 +133,7 @@ const item_actions = [
MailPoet.Modal.loading(false);
if(response === true) {
MailPoet.Notice.success(
('List "%$1s" has been synchronized.').replace('%$1s', item.name)
(MailPoet.I18n.t('listSynchronized')).replace('%$1s', item.name)
);
refresh();
}
@ -147,7 +147,7 @@ const item_actions = [
name: 'view_subscribers',
link: function(item) {
return (
<a href={ item.subscribers_url }>View subscribers</a>
<a href={ item.subscribers_url }>{MailPoet.I18n.t('viewSubscribers')}</a>
);
}
},
@ -190,7 +190,7 @@ const SegmentList = React.createClass({
<abbr>{ segment.subscribers_count.unsubscribed || 0 }</abbr>
</td>
<td className="column-date" data-colname="Created on">
<abbr>{ segment.created_at }</abbr>
<abbr>{ MailPoet.Date.full(segment.created_at) }</abbr>
</td>
</div>
);
@ -199,7 +199,7 @@ const SegmentList = React.createClass({
return (
<div>
<h2 className="title">
Segments <Link className="add-new-h2" to="/new">New</Link>
{MailPoet.I18n.t('pageTitle')} <Link className="add-new-h2" to="/new">{MailPoet.I18n.t('new')}</Link>
</h2>
<Listing
@ -219,4 +219,4 @@ const SegmentList = React.createClass({
}
});
module.exports = SegmentList;
module.exports = SegmentList;

View File

@ -3,47 +3,45 @@ define(
'react',
'react-router',
'mailpoet',
'form/form.jsx',
'moment'
'form/form.jsx'
],
function(
React,
Router,
MailPoet,
Form,
Moment
Form
) {
var fields = [
{
name: 'email',
label: 'E-mail',
label: MailPoet.I18n.t('email'),
type: 'text'
},
{
name: 'first_name',
label: 'Firstname',
label: MailPoet.I18n.t('firstname'),
type: 'text'
},
{
name: 'last_name',
label: 'Lastname',
label: MailPoet.I18n.t('lastname'),
type: 'text'
},
{
name: 'status',
label: 'Status',
label: MailPoet.I18n.t('status'),
type: 'select',
values: {
'unconfirmed': 'Unconfirmed',
'subscribed': 'Subscribed',
'unsubscribed': 'Unsubscribed'
'unconfirmed': MailPoet.I18n.t('unconfirmed'),
'subscribed': MailPoet.I18n.t('subscribed'),
'unsubscribed': MailPoet.I18n.t('unsubscribed')
}
},
{
name: 'segments',
label: 'Lists',
label: MailPoet.I18n.t('lists'),
type: 'selection',
placeholder: "Select a list",
placeholder: MailPoet.I18n.t('selectList'),
endpoint: "segments",
multiple: true,
selected: function(subscriber) {
@ -69,10 +67,15 @@ define(
label = segment.name;
if (subscription.status === 'unsubscribed') {
const unsubscribed_at = Moment(subscription.updated_at)
.utcOffset(parseInt(mailpoet_date_offset))
.format('ddd, D MMM YYYY HH:mm:ss');
label += ' (Unsubscribed on '+unsubscribed_at+')';
const unsubscribed_at = MailPoet.Date
.format(subscription.updated_at);
label += ' (%$1s)'.replace(
'%$1s',
MailPoet.I18n.t('unsubscribedOn').replace(
'%$1s',
unsubscribed_at
)
);
}
}
});
@ -102,10 +105,10 @@ define(
var messages = {
onUpdate: function() {
MailPoet.Notice.success('Subscriber successfully updated!');
MailPoet.Notice.success(MailPoet.I18n.t('subscriberUpdated'));
},
onCreate: function() {
MailPoet.Notice.success('Subscriber successfully added!');
MailPoet.Notice.success(MailPoet.I18n.t('subscriberAdded'));
}
};
@ -119,7 +122,7 @@ define(
return (
<div>
<h2 className="title">
Subscriber
{MailPoet.I18n.t('subscriber')}
</h2>
<Form

View File

@ -150,7 +150,7 @@ define(
if (response.result === false) {
MailPoet.Notice.error(response.errors);
} else {
resultMessage = MailPoetI18n.exportMessage
resultMessage = MailPoet.I18n.t('exportMessage')
.replace('%1$s', '<strong>' + response.data.totalExported + '</strong>')
.replace('[link]', '<a href="' + response.data.exportFileURL + '" target="_blank" >')
.replace('[/link]', '</a>');
@ -162,7 +162,7 @@ define(
.error(function (error) {
MailPoet.Modal.loading(false);
MailPoet.Notice.error(
MailPoetI18n.serverError + error.statusText.toLowerCase() + '.'
MailPoet.I18n.t('serverError') + error.statusText.toLowerCase() + '.'
);
});
});

View File

@ -7,7 +7,8 @@ define(
'handlebars',
'papaparse',
'select2',
'asyncqueue'
'asyncqueue',
'xss'
],
function (
Backbone,
@ -16,7 +17,8 @@ define(
MailPoet,
Handlebars,
Papa,
AsyncQueue
AsyncQueue,
xss
) {
if (!jQuery('#mailpoet_subscribers_import').length) {
return;
@ -126,7 +128,7 @@ define(
// get an approximate size of textarea paste in bytes
var pasteSize = encodeURI(pasteInputElement.val()).split(/%..|./).length - 1;
if (pasteSize > maxPostSizeBytes) {
MailPoet.Notice.error(MailPoetI18n.maxPostSizeNotice, {
MailPoet.Notice.error(MailPoet.I18n.t('maxPostSizeNotice'), {
timeout: noticeTimeout,
});
return;
@ -146,7 +148,7 @@ define(
var ext = this.value.match(/\.(.+)$/);
if (ext === null || ext[1].toLowerCase() !== 'csv') {
this.value = '';
MailPoet.Notice.error(MailPoetI18n.wrongFileFormat, {
MailPoet.Notice.error(MailPoet.I18n.t('wrongFileFormat'), {
timeout: noticeTimeout,
});
}
@ -210,7 +212,7 @@ define(
.removeClass()
.addClass('mailpoet_mailchimp-key-status mailpoet_mailchimp-ok');
if (!response.data) {
jQuery('.mailpoet_mailchimp-key-status').html(MailPoetI18n.noMailChimpLists);
jQuery('.mailpoet_mailchimp-key-status').html(MailPoet.I18n.t('noMailChimpLists'));
mailChimpListsContainerElement.hide();
toggleNextStepButton(mailChimpProcessButtonElement, 'off');
} else {
@ -221,7 +223,7 @@ define(
}).error(function (error) {
MailPoet.Modal.loading(false);
MailPoet.Notice.error(
MailPoetI18n.serverError + error.statusText.toLowerCase() + '.', {
MailPoet.I18n.t('serverError') + error.statusText.toLowerCase() + '.', {
timeout: noticeTimeout,
}
);
@ -256,7 +258,7 @@ define(
}).error(function () {
MailPoet.Modal.loading(false);
MailPoet.Notice.error(
MailPoetI18n.serverError + result.statusText.toLowerCase() + '.', {
MailPoet.I18n.t('serverError') + result.statusText.toLowerCase() + '.', {
timeout: noticeTimeout,
}
);
@ -348,14 +350,14 @@ define(
comments: advancedOptionComments,
error: function () {
MailPoet.Notice.hide();
MailPoet.Notice.error(MailPoetI18n.dataProcessingError, {
MailPoet.Notice.error(MailPoet.I18n.t('dataProcessingError'), {
timeout: noticeTimeout,
});
},
complete: function (CSV) {
for (var rowCount in CSV.data) {
var rowData = CSV.data[rowCount].map(function (el) {
return el.trim();
return filterXSS(el.trim());
}),
rowColumnCount = rowData.length;
// set the number of row elements based on the first non-empty row
@ -429,8 +431,8 @@ define(
}
else {
MailPoet.Modal.loading(false);
var errorNotice = MailPoetI18n.noValidRecords;
errorNotice = errorNotice.replace('[link]', MailPoetI18n.csvKBLink);
var errorNotice = MailPoet.I18n.t('noValidRecords');
errorNotice = errorNotice.replace('[link]', MailPoet.I18n.t('csvKBLink'));
errorNotice = errorNotice.replace('[/link]', '</a>');
MailPoet.Notice.error(errorNotice, {
timeout: noticeTimeout,
@ -499,17 +501,17 @@ define(
}
var import_results = {
notice: MailPoetI18n.importNoticeSkipped.replace(
notice: MailPoet.I18n.t('importNoticeSkipped').replace(
'%1$s',
'<strong>' + (subscribers.invalid.length + subscribers.duplicate.length) + '</strong>'
),
invalid: (subscribers.invalid.length)
? MailPoetI18n.importNoticeInvalid
? MailPoet.I18n.t('importNoticeInvalid')
.replace('%1$s', '<strong>' + subscribers.invalid.length + '</strong>')
.replace('%2$s', subscribers.invalid.join(', '))
: null,
duplicate: (subscribers.duplicate.length)
? MailPoetI18n.importNoticeDuplicate
? MailPoet.I18n.t('importNoticeDuplicate')
.replace('%1$s', '<strong>' + subscribers.duplicate.length + '</strong>')
.replace('%2$s', subscribers.duplicate.join(', '))
: null
@ -525,8 +527,8 @@ define(
jQuery(details).toggle();
this.text =
(jQuery(details).is(":visible"))
? MailPoetI18n.hideDetails
: MailPoetI18n.showDetails;
? MailPoet.I18n.t('hideDetails')
: MailPoet.I18n.t('showDetails');
});
// show available segments
@ -562,7 +564,7 @@ define(
var segmentSelectionNotice = jQuery('[data-id="notice_segmentSelection"]');
if (!this.value) {
if (!segmentSelectionNotice.length) {
MailPoet.Notice.error(MailPoetI18n.segmentSelectionRequired, {
MailPoet.Notice.error(MailPoet.I18n.t('segmentSelectionRequired'), {
static: true,
timeout: noticeTimeout,
scroll: true,
@ -582,7 +584,7 @@ define(
jQuery('.mailpoet_create_segment').click(function () {
MailPoet.Modal.popup({
title: MailPoetI18n.addNewList,
title: MailPoet.I18n.t('addNewList'),
template: jQuery('#new_segment_template').html()
})
jQuery('#new_segment_name').keypress(function (e) {
@ -642,7 +644,7 @@ define(
else {
MailPoet.Modal.close();
MailPoet.Notice.error(
MailPoetI18n.segmentCreateError + response.message + '.', {
MailPoet.I18n.t('segmentCreateError') + response.message + '.', {
timeout: noticeTimeout,
}
);
@ -651,7 +653,7 @@ define(
.error(function (error) {
MailPoet.Modal.close();
MailPoet.Notice.error(
MailPoetI18n.serverError + error.statusText.toLowerCase() + '.', {
MailPoet.I18n.t('serverError') + error.statusText.toLowerCase() + '.', {
timeout: noticeTimeout
}
);
@ -768,7 +770,7 @@ define(
selectEvent.preventDefault();
jQuery(selectElement).select2('close');
MailPoet.Modal.popup({
title: MailPoetI18n.addNewColumn,
title: MailPoet.I18n.t('addNewColumn'),
template: jQuery('#new_column_template').html()
});
jQuery('#new_column_name').keypress(function (e) {
@ -832,7 +834,7 @@ define(
// if this is the first custom column, create an "optgroup"
if (mailpoetColumnsSelect2.length === 2) {
mailpoetColumnsSelect2.push({
'name': MailPoetI18n.userColumns,
'name': MailPoet.I18n.t('userColumns'),
'children': []
});
}
@ -858,7 +860,7 @@ define(
filterSubscribers();
}
else {
MailPoet.Notice.error(MailPoetI18n.customFieldCreateError, {
MailPoet.Notice.error(MailPoet.I18n.t('customFieldCreateError'), {
timeout: noticeTimeout,
});
}
@ -867,7 +869,7 @@ define(
.error(function (error) {
MailPoet.Modal.loading(false);
MailPoet.Notice.error(
MailPoetI18n.serverError + error.statusText.toLowerCase() + '.', {
MailPoet.I18n.t('serverError') + error.statusText.toLowerCase() + '.', {
timeout: noticeTimeout,
}
);
@ -888,7 +890,7 @@ define(
// if another column has the same value and it's not an 'ignore', prompt user
if (elementId === selectedOptionId
&& elementId !== 'ignore') {
if (confirm(MailPoetI18n.selectedValueAlreadyMatched + ' ' + MailPoetI18n.confirmCorrespondingColumn)) {
if (confirm(MailPoet.I18n.t('selectedValueAlreadyMatched') + ' ' + MailPoet.I18n.t('confirmCorrespondingColumn'))) {
jQuery(element).data('column-id', 'ignore');
}
else {
@ -931,7 +933,7 @@ define(
if (!emailRegex.test(subscribersClone.subscribers[0][matchedColumn])) {
preventNextStep = true;
if (!jQuery('[data-id="notice_invalidEmail"]').length) {
MailPoet.Notice.error(MailPoetI18n.columnContainsInvalidElement, {
MailPoet.Notice.error(MailPoet.I18n.t('columnContainsInvalidElement'), {
static: true,
timeout: noticeTimeout,
scroll: true,
@ -951,18 +953,18 @@ define(
date = new Date(rowData.replace(/-/g, '/')), // IE doesn't like
// dashes as date separators
month_name = [
MailPoetI18n.january,
MailPoetI18n.february,
MailPoetI18n.march,
MailPoetI18n.april,
MailPoetI18n.may,
MailPoetI18n.june,
MailPoetI18n.july,
MailPoetI18n.august,
MailPoetI18n.september,
MailPoetI18n.october,
MailPoetI18n.november,
MailPoetI18n.december
MailPoet.I18n.t('january'),
MailPoet.I18n.t('february'),
MailPoet.I18n.t('march'),
MailPoet.I18n.t('april'),
MailPoet.I18n.t('may'),
MailPoet.I18n.t('june'),
MailPoet.I18n.t('july'),
MailPoet.I18n.t('august'),
MailPoet.I18n.t('september'),
MailPoet.I18n.t('october'),
MailPoet.I18n.t('november'),
MailPoet.I18n.t('december')
];
if (position !== fillterPosition) {
@ -975,8 +977,8 @@ define(
if (rowData.trim() === '') {
data[matchedColumn] =
'<span class="mailpoet_data_match mailpoet_import_error" title="'
+ MailPoetI18n.noDateFieldMatch + '">'
+ MailPoetI18n.emptyDate
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
+ MailPoet.I18n.t('emptyDate')
+ '</span>';
preventNextStep = true;
return;
@ -993,25 +995,25 @@ define(
+ ((date.getMinutes() < 10 ? '0' : '')
+ date.getMinutes()) + ' '
+ ((date.getHours() >= 12)
? MailPoetI18n.pm
: MailPoetI18n.am
? MailPoet.I18n.t('pm')
: MailPoet.I18n.t('am')
);
data[matchedColumn] +=
'<span class="mailpoet_data_match" title="'
+ MailPoetI18n.verifyDateMatch + '">'
+ MailPoet.I18n.t('verifyDateMatch') + '">'
+ date + '</span>';
}
else {
data[matchedColumn] +=
'<span class="mailpoet_data_match mailpoet_import_error" title="'
+ MailPoetI18n.noDateFieldMatch + '">'
+ MailPoetI18n.dateMatchError + '</span>';
+ MailPoet.I18n.t('noDateFieldMatch') + '">'
+ MailPoet.I18n.t('dateMatchError') + '</span>';
preventNextStep = true;
}
}
});
if (preventNextStep && !jQuery('.mailpoet_invalidDate').length) {
MailPoet.Notice.error(MailPoetI18n.columnContainsInvalidDate, {
MailPoet.Notice.error(MailPoet.I18n.t('columnContainsInvalidDate'), {
static: true,
timeout: noticeTimeout,
scroll: true,
@ -1056,7 +1058,7 @@ define(
var columns = {},
queue = new jQuery.AsyncQueue(),
batchNumber = 0,
batchSize = 500,
batchSize = 2000,
timestamp = Date.now() / 1000,
subscribers = [],
importResults = {
@ -1112,7 +1114,7 @@ define(
})
.error(function (error) {
importResults.errors.push(
MailPoetI18n.serverError + error.statusText.toLowerCase() + '.'
MailPoet.I18n.t('serverError') + error.statusText.toLowerCase() + '.'
);
queue.run();
});
@ -1169,12 +1171,12 @@ define(
exportMenuElement = jQuery('span.mailpoet_export'),
importResults = {
created: (importData.step2.created)
? MailPoetI18n.subscribersCreated
? MailPoet.I18n.t('subscribersCreated')
.replace('%1$s', '<strong>' + importData.step2.created + '</strong>')
.replace('%2$s', '"' + importData.step2.segments.join('", "') + '"')
: false,
updated: (importData.step2.updated)
? MailPoetI18n.subscribersUpdated
? MailPoet.I18n.t('subscribersUpdated')
.replace('%1$s', '<strong>' + importData.step2.updated + '</strong>')
.replace('%2$s', '"' + importData.step2.segments.join('", "') + '"')
: false,
@ -1210,4 +1212,4 @@ define(
Backbone.history.start();
}
});
});
});

View File

@ -11,28 +11,28 @@ import Selection from 'form/fields/selection.jsx'
const columns = [
{
name: 'email',
label: 'Subscriber',
label: MailPoet.I18n.t('subscriber'),
sortable: true
},
{
name: 'status',
label: 'Status',
label: MailPoet.I18n.t('status'),
sortable: true
},
{
name: 'segments',
label: 'Lists',
label: MailPoet.I18n.t('lists'),
sortable: false
},
{
name: 'created_at',
label: 'Subscribed on',
label: MailPoet.I18n.t('subscribedOn'),
sortable: true
},
{
name: 'updated_at',
label: 'Last modified on',
label: MailPoet.I18n.t('lastModifiedOn'),
sortable: true
},
];
@ -43,11 +43,11 @@ const messages = {
var message = null;
if(~~response === 1) {
message = (
'1 subscriber was moved to the trash.'
MailPoet.I18n.t('oneSubscriberTrashed')
);
} else if(~~response > 1) {
message = (
'%$1d subscribers were moved to the trash.'
MailPoet.I18n.t('multipleSubscribersTrashed')
).replace('%$1d', ~~response);
}
@ -61,11 +61,11 @@ const messages = {
var message = null;
if(~~response === 1) {
message = (
'1 subscriber was permanently deleted.'
MailPoet.I18n.t('oneSubscriberDeleted')
);
} else if(~~response > 1) {
message = (
'%$1d subscribers were permanently deleted.'
MailPoet.I18n.t('multipleSubscribersDeleted')
).replace('%$1d', ~~response);
}
@ -79,11 +79,11 @@ const messages = {
var message = null;
if(~~response === 1) {
message = (
'1 subscriber has been restored from the trash.'
MailPoet.I18n.t('oneSubscriberRestored')
);
} else if(~~response > 1) {
message = (
'%$1d subscribers have been restored from the trash.'
MailPoet.I18n.t('multipleSubscribersRestored')
).replace('%$1d', ~~response);
}
@ -97,7 +97,7 @@ const messages = {
const bulk_actions = [
{
name: 'moveToList',
label: 'Move to list...',
label: MailPoet.I18n.t('moveToList'),
onSelect: function() {
let field = {
id: 'move_to_segment',
@ -120,7 +120,7 @@ const bulk_actions = [
},
onSuccess: function(response) {
MailPoet.Notice.success(
'%$1d subscribers were moved to list <strong>%$2s</strong>.'
MailPoet.I18n.t('multipleSubscribersMovedToList')
.replace('%$1d', ~~response.subscribers)
.replace('%$2s', response.segment)
);
@ -128,7 +128,7 @@ const bulk_actions = [
},
{
name: 'addToList',
label: 'Add to list...',
label: MailPoet.I18n.t('addToList'),
onSelect: function() {
let field = {
id: 'add_to_segment',
@ -151,7 +151,7 @@ const bulk_actions = [
},
onSuccess: function(response) {
MailPoet.Notice.success(
'%$1d subscribers were added to list <strong>%$2s</strong>.'
MailPoet.I18n.t('multipleSubscribersAddedToList')
.replace('%$1d', ~~response.subscribers)
.replace('%$2s', response.segment)
);
@ -159,7 +159,7 @@ const bulk_actions = [
},
{
name: 'removeFromList',
label: 'Remove from list...',
label: MailPoet.I18n.t('removeFromList'),
onSelect: function() {
let field = {
id: 'remove_from_segment',
@ -182,7 +182,7 @@ const bulk_actions = [
},
onSuccess: function(response) {
MailPoet.Notice.success(
'%$1d subscribers were removed from list <strong>%$2s</strong>.'
MailPoet.I18n.t('multipleSubscribersRemovedFromList')
.replace('%$1d', ~~response.subscribers)
.replace('%$2s', response.segment)
);
@ -190,27 +190,37 @@ const bulk_actions = [
},
{
name: 'removeFromAllLists',
label: 'Remove from all lists',
label: MailPoet.I18n.t('removeFromAllLists'),
onSuccess: function(response) {
MailPoet.Notice.success(
'%$1d subscribers were removed from all lists.'
MailPoet.I18n.t('multipleSubscribersRemovedFromAllLists')
.replace('%$1d', ~~response)
);
}
},
{
name: 'confirmUnconfirmed',
label: 'Confirm unconfirmed',
label: MailPoet.I18n.t('confirmUnconfirmed'),
onSuccess: function(response) {
MailPoet.Notice.success(
'%$1d subscribers have been confirmed.'
MailPoet.I18n.t('multipleSubscribersConfirmed')
.replace('%$1d', ~~response)
);
}
},
{
name: 'sendConfirmationEmail',
label: MailPoet.I18n.t('resendConfirmationEmail'),
onSuccess: function(response) {
MailPoet.Notice.success(
MailPoet.I18n.t('multipleConfirmationEmailsSent')
.replace('%$1d', ~~response)
);
}
},
{
name: 'trash',
label: 'Trash',
label: MailPoet.I18n.t('trash'),
onSuccess: messages.onTrash
}
];
@ -218,10 +228,10 @@ const bulk_actions = [
const item_actions = [
{
name: 'edit',
label: 'Edit',
label: MailPoet.I18n.t('edit'),
link: function(item) {
return (
<Link to={ `/edit/${item.id}` }>Edit</Link>
<Link to={ `/edit/${item.id}` }>{MailPoet.I18n.t('edit')}</Link>
);
}
},
@ -252,15 +262,15 @@ const SubscriberList = React.createClass({
switch(subscriber.status) {
case 'subscribed':
status = 'Subscribed';
status = MailPoet.I18n.t('subscribed');
break;
case 'unconfirmed':
status = 'Unconfirmed';
status = MailPoet.I18n.t('unconfirmed');
break;
case 'unsubscribed':
status = 'Unsubscribed';
status = MailPoet.I18n.t('unsubscribed');
break;
}
@ -272,13 +282,13 @@ const SubscriberList = React.createClass({
subscriber.subscriptions.map((subscription) => {
const segment = this.getSegmentFromId(subscription.segment_id);
if(segment === false) return;
if (subscription.status === 'subscribed') {
subscribed_segments.push(segment.name);
} else {
} else if (subscription.status === 'unsubscribed') {
unsubscribed_segments.push(segment.name);
}
});
segments = (
<span>
<span className="mailpoet_segments_subscribed">
@ -292,7 +302,7 @@ const SubscriberList = React.createClass({
</span>
<span
className="mailpoet_segments_unsubscribed"
title="Lists to which the subscriber was subscribed."
title={MailPoet.I18n.t('listsToWhichSubscriberWasSubscribed')}
>
{ unsubscribed_segments.join(', ') }
</span>
@ -324,17 +334,17 @@ const SubscriberList = React.createClass({
</p>
{ actions }
</td>
<td className="column" data-colname="Status">
<td className="column" data-colname={MailPoet.I18n.t('status')}>
{ status }
</td>
<td className="column" data-colname="Lists">
<td className="column" data-colname={MailPoet.I18n.t('lists')}>
{ segments }
</td>
<td className="column-date" data-colname="Subscribed on">
<abbr>{ subscriber.created_at }</abbr>
<td className="column-date" data-colname={MailPoet.I18n.t('subscribedOn')}>
<abbr>{ MailPoet.Date.full(subscriber.created_at) }</abbr>
</td>
<td className="column-date" data-colname="Last modified on">
<abbr>{ subscriber.updated_at }</abbr>
<td className="column-date" data-colname={MailPoet.I18n.t('lastModifiedOn')}>
<abbr>{ MailPoet.Date.full(subscriber.updated_at) }</abbr>
</td>
</div>
);
@ -346,9 +356,9 @@ const SubscriberList = React.createClass({
return (
<div>
<h2 className="title">
Subscribers <Link className="add-new-h2" to="/new">New</Link>
<a className="add-new-h2" href="?page=mailpoet-import#step1">Import</a>
<a id="mailpoet_export_button" className="add-new-h2" href="?page=mailpoet-export">Export</a>
{MailPoet.I18n.t('pageTitle')} <Link className="add-new-h2" to="/new">{MailPoet.I18n.t('new')}</Link>
<a className="add-new-h2" href="?page=mailpoet-import#step1">{MailPoet.I18n.t('import')}</a>
<a id="mailpoet_export_button" className="add-new-h2" href="?page=mailpoet-export">{MailPoet.I18n.t('export')}</a>
</h2>
<Listing
@ -368,4 +378,4 @@ const SubscriberList = React.createClass({
}
});
module.exports = SubscriberList;
module.exports = SubscriberList;

View File

@ -9,6 +9,7 @@ settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
log: true
extensions:
enabled:
- Codeception\Extension\RunFailed

View File

@ -9,7 +9,7 @@
"j4mie/paris": "1.5.4",
"swiftmailer/swiftmailer": "^5.4",
"phpseclib/phpseclib": "*",
"mtdowling/cron-expression": "^1.0",
"mtdowling/cron-expression": "^1.1",
"nesbot/carbon": "^1.21",
"soundasleep/html2text": "^0.3.0"
},

331
composer.lock generated
View File

@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"hash": "db2edea5fb720fcb8013ac470e924c19",
"content-hash": "85119d1ccd5193b6b08fda305a2427e7",
"hash": "2bed8395d84740d7c0ae644a6c6216fd",
"content-hash": "7b66e221814f3d5839ed4faabd2f50ad",
"packages": [
{
"name": "cerdic/css-tidy",
@ -401,16 +401,16 @@
},
{
"name": "soundasleep/html2text",
"version": "0.3.0",
"version": "0.3.1",
"source": {
"type": "git",
"url": "https://github.com/soundasleep/html2text.git",
"reference": "55be17ddbb7234650722f66816ba2b10f66e565f"
"reference": "2a5fd94bf58b653a5a9d777ac6a5593f82d087db"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/soundasleep/html2text/zipball/55be17ddbb7234650722f66816ba2b10f66e565f",
"reference": "55be17ddbb7234650722f66816ba2b10f66e565f",
"url": "https://api.github.com/repos/soundasleep/html2text/zipball/2a5fd94bf58b653a5a9d777ac6a5593f82d087db",
"reference": "2a5fd94bf58b653a5a9d777ac6a5593f82d087db",
"shasum": ""
},
"require": {
@ -447,7 +447,7 @@
"php",
"text"
],
"time": "2015-12-18 02:30:26"
"time": "2016-02-25 00:00:36"
},
{
"name": "sunra/php-simple-html-dom-parser",
@ -547,7 +547,7 @@
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.1.0",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
@ -606,16 +606,16 @@
},
{
"name": "symfony/translation",
"version": "v2.8.2",
"version": "v2.8.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "bc0b666903944858f4ffec01c4e50c63e5c276c0"
"reference": "b7b4ebadd2b5e614ff7d2d6fc63e0ed0578909c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/bc0b666903944858f4ffec01c4e50c63e5c276c0",
"reference": "bc0b666903944858f4ffec01c4e50c63e5c276c0",
"url": "https://api.github.com/repos/symfony/translation/zipball/b7b4ebadd2b5e614ff7d2d6fc63e0ed0578909c7",
"reference": "b7b4ebadd2b5e614ff7d2d6fc63e0ed0578909c7",
"shasum": ""
},
"require": {
@ -666,7 +666,7 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2016-01-03 15:33:41"
"time": "2016-02-02 09:49:18"
},
{
"name": "tburry/pquery",
@ -785,41 +785,42 @@
"packages-dev": [
{
"name": "codeception/codeception",
"version": "2.1.6",
"version": "2.1.7",
"source": {
"type": "git",
"url": "https://github.com/Codeception/Codeception.git",
"reference": "b199941f5e59d1e7fd32d78296c8ab98db873d89"
"reference": "65971b0dee4972710365b6102154cd412a9bf7b1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/b199941f5e59d1e7fd32d78296c8ab98db873d89",
"reference": "b199941f5e59d1e7fd32d78296c8ab98db873d89",
"url": "https://api.github.com/repos/Codeception/Codeception/zipball/65971b0dee4972710365b6102154cd412a9bf7b1",
"reference": "65971b0dee4972710365b6102154cd412a9bf7b1",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"facebook/webdriver": ">=1.0.1",
"facebook/webdriver": ">=1.0.1 <2.0",
"guzzlehttp/guzzle": ">=4.1.4 <7.0",
"guzzlehttp/psr7": "~1.0",
"php": ">=5.4.0",
"phpunit/phpunit": "~4.8.0",
"symfony/browser-kit": ">=2.4|<3.1",
"symfony/console": ">=2.4|<3.1",
"symfony/css-selector": ">=2.4|<3.1",
"symfony/dom-crawler": ">=2.4|<3.1",
"symfony/event-dispatcher": ">=2.4|<3.1",
"symfony/finder": ">=2.4|<3.1",
"symfony/yaml": ">=2.4|<3.1"
"php": ">=5.4.0 <8.0",
"phpunit/php-code-coverage": ">=2.1.3",
"phpunit/phpunit": ">4.8.20 <6.0",
"symfony/browser-kit": ">=2.5 <3.1",
"symfony/console": ">=2.5 <3.1",
"symfony/css-selector": ">=2.5 <3.1",
"symfony/dom-crawler": ">=2.5 <3.1",
"symfony/event-dispatcher": ">=2.5 <3.1",
"symfony/finder": ">=2.5 <3.1",
"symfony/yaml": ">=2.5 <3.1"
},
"require-dev": {
"codeception/specify": "~0.3",
"facebook/php-sdk-v4": "~4.0",
"facebook/php-sdk-v4": "~5.0",
"flow/jsonpath": "~0.2",
"monolog/monolog": "~1.8",
"pda/pheanstalk": "~2.0",
"videlalvaro/php-amqplib": "~2.4"
"php-amqplib/php-amqplib": "~2.4"
},
"suggest": {
"codeception/phpbuiltinserver": "Extension to start and stop PHP built-in web server for your tests",
@ -861,7 +862,7 @@
"functional testing",
"unit testing"
],
"time": "2016-02-09 22:27:48"
"time": "2016-03-12 01:15:25"
},
{
"name": "codeception/verify",
@ -898,33 +899,36 @@
},
{
"name": "codegyre/robo",
"version": "0.6.0",
"version": "0.7.1",
"source": {
"type": "git",
"url": "https://github.com/Codegyre/Robo.git",
"reference": "d18185f0494c854d36aa5ee0ad931ee23bbef552"
"reference": "1f4e0621fdc37521e2eaca67f33d1c4e240dc7d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Codegyre/Robo/zipball/d18185f0494c854d36aa5ee0ad931ee23bbef552",
"reference": "d18185f0494c854d36aa5ee0ad931ee23bbef552",
"url": "https://api.github.com/repos/Codegyre/Robo/zipball/1f4e0621fdc37521e2eaca67f33d1c4e240dc7d8",
"reference": "1f4e0621fdc37521e2eaca67f33d1c4e240dc7d8",
"shasum": ""
},
"require": {
"henrikbjorn/lurker": "1.0.*@dev",
"henrikbjorn/lurker": "~1.0",
"php": ">=5.4.0",
"symfony/console": "~2.5",
"symfony/filesystem": "~2.5",
"symfony/finder": "~2.5",
"symfony/process": "~2.5"
"symfony/console": "~2.5|~3.0",
"symfony/filesystem": "~2.5|~3.0",
"symfony/finder": "~2.5|~3.0",
"symfony/process": "~2.5|~3.0"
},
"require-dev": {
"codeception/aspect-mock": "0.5.*",
"codeception/base": "~2.1",
"codeception/codeception": "2.1",
"codeception/aspect-mock": "0.5.4",
"codeception/base": "~2.1.5",
"codeception/verify": "0.2.*",
"natxet/cssmin": "~3.0",
"patchwork/jsqueeze": "~1.0"
"patchwork/jsqueeze": "~1.0",
"pear/archive_tar": "~1.0"
},
"suggest": {
"pear/archive_tar": "Allows tar archives to be created and extracted in taskPack and taskExtract, respectively."
},
"bin": [
"robo"
@ -946,7 +950,7 @@
}
],
"description": "Modern task runner",
"time": "2015-10-30 11:29:52"
"time": "2016-02-25 19:28:51"
},
{
"name": "doctrine/instantiator",
@ -1109,16 +1113,16 @@
},
{
"name": "guzzlehttp/promises",
"version": "1.0.3",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea"
"reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea",
"reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea",
"url": "https://api.github.com/repos/guzzle/promises/zipball/bb9024c526b22f3fe6ae55a561fd70653d470aa8",
"reference": "bb9024c526b22f3fe6ae55a561fd70653d470aa8",
"shasum": ""
},
"require": {
@ -1156,20 +1160,20 @@
"keywords": [
"promise"
],
"time": "2015-10-15 22:28:00"
"time": "2016-03-08 01:15:46"
},
{
"name": "guzzlehttp/psr7",
"version": "1.2.2",
"version": "1.2.3",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "f5d04bdd2881ac89abde1fb78cc234bce24327bb"
"reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/f5d04bdd2881ac89abde1fb78cc234bce24327bb",
"reference": "f5d04bdd2881ac89abde1fb78cc234bce24327bb",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/2e89629ff057ebb49492ba08e6995d3a6a80021b",
"reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b",
"shasum": ""
},
"require": {
@ -1214,20 +1218,20 @@
"stream",
"uri"
],
"time": "2016-01-23 01:23:02"
"time": "2016-02-18 21:54:00"
},
{
"name": "henrikbjorn/lurker",
"version": "1.0.0",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/flint/Lurker.git",
"reference": "a020d45b3bc37810aeafe27343c51af8a74c9419"
"reference": "ab45f9cefe600065cc3137a238217598d3a1d062"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/flint/Lurker/zipball/a020d45b3bc37810aeafe27343c51af8a74c9419",
"reference": "a020d45b3bc37810aeafe27343c51af8a74c9419",
"url": "https://api.github.com/repos/flint/Lurker/zipball/ab45f9cefe600065cc3137a238217598d3a1d062",
"reference": "ab45f9cefe600065cc3137a238217598d3a1d062",
"shasum": ""
},
"require": {
@ -1255,18 +1259,16 @@
],
"authors": [
{
"name": "Henrik Bjornskov",
"email": "henrik@bjrnskov.dk",
"homepage": "http://henrik.bjrnskov.dk"
"name": "Yaroslav Kiliba",
"email": "om.dattaya@gmail.com"
},
{
"name": "Konstantin Kudryashov",
"email": "ever.zet@gmail.com",
"homepage": "http://everzet.com"
"email": "ever.zet@gmail.com"
},
{
"name": "Yaroslav Kiliba",
"email": "om.dattaya@gmail.com"
"name": "Henrik Bjrnskov",
"email": "henrik@bjrnskov.dk"
}
],
"description": "Resource Watcher.",
@ -1275,7 +1277,7 @@
"resource",
"watching"
],
"time": "2013-05-24 06:47:29"
"time": "2015-10-27 09:19:19"
},
{
"name": "phpdocumentor/reflection-docblock",
@ -1630,16 +1632,16 @@
},
{
"name": "phpunit/phpunit",
"version": "4.8.23",
"version": "4.8.24",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "6e351261f9cd33daf205a131a1ba61c6d33bd483"
"reference": "a1066c562c52900a142a0e2bbf0582994671385e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/6e351261f9cd33daf205a131a1ba61c6d33bd483",
"reference": "6e351261f9cd33daf205a131a1ba61c6d33bd483",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1066c562c52900a142a0e2bbf0582994671385e",
"reference": "a1066c562c52900a142a0e2bbf0582994671385e",
"shasum": ""
},
"require": {
@ -1698,7 +1700,7 @@
"testing",
"xunit"
],
"time": "2016-02-11 14:56:33"
"time": "2016-03-14 06:16:08"
},
{
"name": "phpunit/phpunit-mock-objects",
@ -1974,16 +1976,16 @@
},
{
"name": "sebastian/environment",
"version": "1.3.3",
"version": "1.3.5",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "6e7133793a8e5a5714a551a8324337374be209df"
"reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e7133793a8e5a5714a551a8324337374be209df",
"reference": "6e7133793a8e5a5714a551a8324337374be209df",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf",
"reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf",
"shasum": ""
},
"require": {
@ -2020,7 +2022,7 @@
"environment",
"hhvm"
],
"time": "2015-12-02 08:37:27"
"time": "2016-02-26 18:40:46"
},
{
"name": "sebastian/exporter",
@ -2229,7 +2231,7 @@
},
{
"name": "symfony/browser-kit",
"version": "v3.0.2",
"version": "v3.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
@ -2286,22 +2288,25 @@
},
{
"name": "symfony/config",
"version": "v2.8.2",
"version": "v2.8.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
"reference": "41ee6c70758f40fa1dbf90d019ae0a66c4a09e74"
"reference": "0f8f94e6a32b5c480024eed5fa5cbd2790d0ad19"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/config/zipball/41ee6c70758f40fa1dbf90d019ae0a66c4a09e74",
"reference": "41ee6c70758f40fa1dbf90d019ae0a66c4a09e74",
"url": "https://api.github.com/repos/symfony/config/zipball/0f8f94e6a32b5c480024eed5fa5cbd2790d0ad19",
"reference": "0f8f94e6a32b5c480024eed5fa5cbd2790d0ad19",
"shasum": ""
},
"require": {
"php": ">=5.3.9",
"symfony/filesystem": "~2.3|~3.0.0"
},
"suggest": {
"symfony/yaml": "To use the yaml reference dumper"
},
"type": "library",
"extra": {
"branch-alias": {
@ -2332,30 +2337,30 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
"time": "2016-01-03 15:33:41"
"time": "2016-02-22 16:12:45"
},
{
"name": "symfony/console",
"version": "v2.8.2",
"version": "v3.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "d0239fb42f98dd02e7d342f793c5d2cdee0c478d"
"reference": "2ed5e2706ce92313d120b8fe50d1063bcfd12e04"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/d0239fb42f98dd02e7d342f793c5d2cdee0c478d",
"reference": "d0239fb42f98dd02e7d342f793c5d2cdee0c478d",
"url": "https://api.github.com/repos/symfony/console/zipball/2ed5e2706ce92313d120b8fe50d1063bcfd12e04",
"reference": "2ed5e2706ce92313d120b8fe50d1063bcfd12e04",
"shasum": ""
},
"require": {
"php": ">=5.3.9",
"php": ">=5.5.9",
"symfony/polyfill-mbstring": "~1.0"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/event-dispatcher": "~2.1|~3.0.0",
"symfony/process": "~2.1|~3.0.0"
"symfony/event-dispatcher": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0"
},
"suggest": {
"psr/log": "For using the console logger",
@ -2365,7 +2370,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
"dev-master": "3.0-dev"
}
},
"autoload": {
@ -2392,11 +2397,11 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2016-01-14 08:33:16"
"time": "2016-02-28 16:24:34"
},
{
"name": "symfony/css-selector",
"version": "v3.0.2",
"version": "v3.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
@ -2449,16 +2454,16 @@
},
{
"name": "symfony/dom-crawler",
"version": "v3.0.2",
"version": "v3.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
"reference": "b693a9650aa004576b593ff2e91ae749dc90123d"
"reference": "981c8edb4538f88ba976ed44bdcaa683fce3d6c6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/b693a9650aa004576b593ff2e91ae749dc90123d",
"reference": "b693a9650aa004576b593ff2e91ae749dc90123d",
"url": "https://api.github.com/repos/symfony/dom-crawler/zipball/981c8edb4538f88ba976ed44bdcaa683fce3d6c6",
"reference": "981c8edb4538f88ba976ed44bdcaa683fce3d6c6",
"shasum": ""
},
"require": {
@ -2501,20 +2506,20 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
"time": "2016-01-25 09:56:57"
"time": "2016-02-28 16:24:34"
},
{
"name": "symfony/event-dispatcher",
"version": "v2.8.2",
"version": "v2.8.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "ee278f7c851533e58ca307f66305ccb9188aceda"
"reference": "78c468665c9568c3faaa9c416a7134308f2d85c3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/ee278f7c851533e58ca307f66305ccb9188aceda",
"reference": "ee278f7c851533e58ca307f66305ccb9188aceda",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/78c468665c9568c3faaa9c416a7134308f2d85c3",
"reference": "78c468665c9568c3faaa9c416a7134308f2d85c3",
"shasum": ""
},
"require": {
@ -2561,20 +2566,20 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2016-01-13 10:28:07"
"time": "2016-01-27 05:14:19"
},
{
"name": "symfony/filesystem",
"version": "v2.8.2",
"version": "v2.8.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "637b64d0ee10f44ae98dbad651b1ecdf35a11e8c"
"reference": "65cb36b6539b1d446527d60457248f30d045464d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/637b64d0ee10f44ae98dbad651b1ecdf35a11e8c",
"reference": "637b64d0ee10f44ae98dbad651b1ecdf35a11e8c",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/65cb36b6539b1d446527d60457248f30d045464d",
"reference": "65cb36b6539b1d446527d60457248f30d045464d",
"shasum": ""
},
"require": {
@ -2610,29 +2615,29 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2016-01-13 10:28:07"
"time": "2016-02-22 15:02:30"
},
{
"name": "symfony/finder",
"version": "v2.8.2",
"version": "v3.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "c90fabdd97e431ee19b6383999cf35334dff27da"
"reference": "623bda0abd9aa29e529c8e9c08b3b84171914723"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/c90fabdd97e431ee19b6383999cf35334dff27da",
"reference": "c90fabdd97e431ee19b6383999cf35334dff27da",
"url": "https://api.github.com/repos/symfony/finder/zipball/623bda0abd9aa29e529c8e9c08b3b84171914723",
"reference": "623bda0abd9aa29e529c8e9c08b3b84171914723",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
"dev-master": "3.0-dev"
}
},
"autoload": {
@ -2659,20 +2664,20 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2016-01-14 08:26:52"
"time": "2016-01-27 05:14:46"
},
{
"name": "symfony/form",
"version": "v2.8.2",
"version": "v2.8.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/form.git",
"reference": "7fd5e4034cb8e215887136f5e176430bbf5ef085"
"reference": "25b71aec36879b4a84c2ea06603dbe7498b31f06"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/form/zipball/7fd5e4034cb8e215887136f5e176430bbf5ef085",
"reference": "7fd5e4034cb8e215887136f5e176430bbf5ef085",
"url": "https://api.github.com/repos/symfony/form/zipball/25b71aec36879b4a84c2ea06603dbe7498b31f06",
"reference": "25b71aec36879b4a84c2ea06603dbe7498b31f06",
"shasum": ""
},
"require": {
@ -2733,20 +2738,20 @@
],
"description": "Symfony Form Component",
"homepage": "https://symfony.com",
"time": "2016-01-12 17:46:01"
"time": "2016-02-28 15:05:09"
},
{
"name": "symfony/intl",
"version": "v3.0.2",
"version": "v3.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/intl.git",
"reference": "7fa23b8f2ddd96260f0154946b69eb0f2c2ce7bc"
"reference": "cafee6f65148dab9058cdb6de5631222aca820d0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/intl/zipball/7fa23b8f2ddd96260f0154946b69eb0f2c2ce7bc",
"reference": "7fa23b8f2ddd96260f0154946b69eb0f2c2ce7bc",
"url": "https://api.github.com/repos/symfony/intl/zipball/cafee6f65148dab9058cdb6de5631222aca820d0",
"reference": "cafee6f65148dab9058cdb6de5631222aca820d0",
"shasum": ""
},
"require": {
@ -2808,20 +2813,20 @@
"l10n",
"localization"
],
"time": "2016-01-27 05:14:46"
"time": "2016-02-23 15:16:06"
},
{
"name": "symfony/options-resolver",
"version": "v2.8.2",
"version": "v2.8.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "b98ca04f85240531b9ea8a0f00a21f2ecfbdfa51"
"reference": "d1e6e9182d9e5af6367bf85175e708f8b4a828c0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/b98ca04f85240531b9ea8a0f00a21f2ecfbdfa51",
"reference": "b98ca04f85240531b9ea8a0f00a21f2ecfbdfa51",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/d1e6e9182d9e5af6367bf85175e708f8b4a828c0",
"reference": "d1e6e9182d9e5af6367bf85175e708f8b4a828c0",
"shasum": ""
},
"require": {
@ -2862,26 +2867,29 @@
"configuration",
"options"
],
"time": "2016-01-03 15:33:41"
"time": "2016-01-21 09:05:51"
},
{
"name": "symfony/polyfill-intl-icu",
"version": "v1.1.0",
"version": "v1.1.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-icu.git",
"reference": "66b0bb4abda229bc073eff6bbc8f2685bdaac165"
"reference": "8328069d9f5322f0e7b3c3518485acfdc94c3942"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/66b0bb4abda229bc073eff6bbc8f2685bdaac165",
"reference": "66b0bb4abda229bc073eff6bbc8f2685bdaac165",
"url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/8328069d9f5322f0e7b3c3518485acfdc94c3942",
"reference": "8328069d9f5322f0e7b3c3518485acfdc94c3942",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"symfony/intl": "~2.3|~3.0"
},
"suggest": {
"ext-intl": "For best performance"
},
"type": "library",
"extra": {
"branch-alias": {
@ -2917,29 +2925,29 @@
"portable",
"shim"
],
"time": "2016-01-20 09:13:37"
"time": "2016-02-26 16:18:12"
},
{
"name": "symfony/process",
"version": "v2.8.2",
"version": "v3.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "6f1979c3b0f4c22c77a8a8971afaa7dd07f082ac"
"reference": "dfecef47506179db2501430e732adbf3793099c8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/6f1979c3b0f4c22c77a8a8971afaa7dd07f082ac",
"reference": "6f1979c3b0f4c22c77a8a8971afaa7dd07f082ac",
"url": "https://api.github.com/repos/symfony/process/zipball/dfecef47506179db2501430e732adbf3793099c8",
"reference": "dfecef47506179db2501430e732adbf3793099c8",
"shasum": ""
},
"require": {
"php": ">=5.3.9"
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
"dev-master": "3.0-dev"
}
},
"autoload": {
@ -2966,20 +2974,20 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2016-01-06 09:59:23"
"time": "2016-02-02 13:44:19"
},
{
"name": "symfony/property-access",
"version": "v3.0.2",
"version": "v3.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/property-access.git",
"reference": "95363dbabd606e404b6c75095669993bf7ddae4b"
"reference": "f138bcc0cdaf6a6aba99ecab20d235b394f46eba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/property-access/zipball/95363dbabd606e404b6c75095669993bf7ddae4b",
"reference": "95363dbabd606e404b6c75095669993bf7ddae4b",
"url": "https://api.github.com/repos/symfony/property-access/zipball/f138bcc0cdaf6a6aba99ecab20d235b394f46eba",
"reference": "f138bcc0cdaf6a6aba99ecab20d235b394f46eba",
"shasum": ""
},
"require": {
@ -3026,20 +3034,20 @@
"property path",
"reflection"
],
"time": "2016-01-03 15:35:16"
"time": "2016-02-13 09:23:44"
},
{
"name": "symfony/routing",
"version": "v2.8.2",
"version": "v2.8.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
"reference": "5451a8a1874fd4e6a4dd347ea611d86cd8441735"
"reference": "ae38e64bae52753c0f4a1a6583f5ba9bb2b742ab"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/5451a8a1874fd4e6a4dd347ea611d86cd8441735",
"reference": "5451a8a1874fd4e6a4dd347ea611d86cd8441735",
"url": "https://api.github.com/repos/symfony/routing/zipball/ae38e64bae52753c0f4a1a6583f5ba9bb2b742ab",
"reference": "ae38e64bae52753c0f4a1a6583f5ba9bb2b742ab",
"shasum": ""
},
"require": {
@ -3062,6 +3070,7 @@
"symfony/config": "For using the all-in-one router or any loader",
"symfony/dependency-injection": "For loading routes from a service",
"symfony/expression-language": "For using expression matching",
"symfony/http-foundation": "For using a Symfony Request object",
"symfony/yaml": "For using the YAML loader"
},
"type": "library",
@ -3100,20 +3109,20 @@
"uri",
"url"
],
"time": "2016-01-11 16:43:36"
"time": "2016-02-04 13:53:00"
},
{
"name": "symfony/twig-bridge",
"version": "v2.8.2",
"version": "v2.8.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/twig-bridge.git",
"reference": "e33b512de4b769a1c728cd6775e22668ae89fca9"
"reference": "ba898e4714734948dc00c4d776e1d6be165ff8c4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/twig-bridge/zipball/e33b512de4b769a1c728cd6775e22668ae89fca9",
"reference": "e33b512de4b769a1c728cd6775e22668ae89fca9",
"url": "https://api.github.com/repos/symfony/twig-bridge/zipball/ba898e4714734948dc00c4d776e1d6be165ff8c4",
"reference": "ba898e4714734948dc00c4d776e1d6be165ff8c4",
"shasum": ""
},
"require": {
@ -3181,20 +3190,20 @@
],
"description": "Symfony Twig Bridge",
"homepage": "https://symfony.com",
"time": "2016-01-12 17:46:01"
"time": "2016-02-22 15:02:30"
},
{
"name": "symfony/yaml",
"version": "v3.0.2",
"version": "v3.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "3cf0709d7fe936e97bee9e954382e449003f1d9a"
"reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/3cf0709d7fe936e97bee9e954382e449003f1d9a",
"reference": "3cf0709d7fe936e97bee9e954382e449003f1d9a",
"url": "https://api.github.com/repos/symfony/yaml/zipball/b5ba64cd67ecd6887f63868fa781ca094bd1377c",
"reference": "b5ba64cd67ecd6887f63868fa781ca094bd1377c",
"shasum": ""
},
"require": {
@ -3230,7 +3239,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2016-02-02 13:44:19"
"time": "2016-02-23 15:16:06"
},
{
"name": "twig/extensions",

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,12 @@
<?php
namespace MailPoet\Config;
use \MailPoet\Models\Setting;
use \MailPoet\Util\Url;
class Changelog {
function __construct() {
}
function init() {
$doing_ajax = (bool)(defined('DOING_AJAX') && DOING_AJAX);
@ -42,20 +46,7 @@ class Changelog {
// save version number
Setting::setValue('version', Env::$version);
global $wp;
$current_url = home_url(add_query_arg($wp->query_string, $wp->request));
if($redirect_url !== $current_url) {
wp_safe_redirect(
add_query_arg(
array(
'mailpoet_redirect' => urlencode($current_url)
),
$redirect_url
)
);
exit;
}
Url::redirectWithReferer($redirect_url);
}
}
}

View File

@ -13,7 +13,7 @@ class Env {
static $assets_path;
static $assets_url;
static $temp_path;
static $temp_URL;
static $temp_url;
static $languages_path;
static $lib_path;
static $plugin_prefix;
@ -26,6 +26,7 @@ class Env {
static $db_username;
static $db_password;
static $db_charset;
static $db_timezone_offset;
static function init($file, $version) {
global $wpdb;
@ -38,7 +39,7 @@ class Env {
self::$assets_url = plugins_url('/assets', $file);
$wp_upload_dir = wp_upload_dir();
self::$temp_path = $wp_upload_dir['path'];
self::$temp_URL = $wp_upload_dir['url'];
self::$temp_url = $wp_upload_dir['url'];
self::$languages_path = self::$path . '/lang';
self::$lib_path = self::$path . '/lib';
self::$plugin_prefix = 'mailpoet_';
@ -58,6 +59,7 @@ class Env {
self::$db_password = DB_PASSWORD;
self::$db_charset = $wpdb->get_charset_collate();
self::$db_source_name = self::dbSourceName(self::$db_host, self::$db_socket, self::$db_port);
self::$db_timezone_offset = self::getDbTimezoneOffset();
}
private static function dbSourceName($host, $socket, $port) {
@ -73,4 +75,13 @@ class Env {
);
return implode('', $source_name);
}
private static function getDbTimezoneOffset() {
$mins = get_option('gmt_offset') * 60;
$sgn = ($mins < 0 ? -1 : 1);
$mins = abs($mins);
$hrs = floor($mins / 60);
$mins -= $hrs * 60;
return sprintf('%+d:%02d', $hrs * $sgn, $mins);
}
}

View File

@ -1,5 +1,7 @@
<?php
namespace MailPoet\Config;
use MailPoet\Cron\Workers\Scheduler;
use MailPoet\Cron\Workers\SendingQueue;
use \MailPoet\Models\Setting;
class Hooks {
@ -95,7 +97,7 @@ class Hooks {
add_action(
'profile_update',
'\MailPoet\Segments\WP::synchronizeUser',
1
1,2
);
add_action(
'delete_user',

View File

@ -4,8 +4,6 @@ namespace MailPoet\Config;
use MailPoet\Models;
use MailPoet\Cron\Supervisor;
use MailPoet\Router;
use MailPoet\Models\Setting;
use MailPoet\Settings\Pages;
if(!defined('ABSPATH')) exit;
@ -26,6 +24,7 @@ class Initializer {
register_activation_hook(Env::$file, array($this, 'runPopulator'));
add_action('plugins_loaded', array($this, 'setup'));
add_action('init', array($this, 'onInit'));
add_action('widgets_init', array($this, 'setupWidget'));
}
@ -34,16 +33,14 @@ class Initializer {
$this->setupRenderer();
$this->setupLocalizer();
$this->setupMenu();
$this->setupRouter();
$this->setupPermissions();
$this->setupPublicAPI();
$this->setupAnalytics();
$this->setupChangelog();
$this->runQueueSupervisor();
$this->setupShortcodes();
$this->setupHooks();
$this->setupPages();
$this->setupImages();
$this->setupPublicAPI();
$this->runQueueSupervisor();
} catch(\Exception $e) {
// if anything goes wrong during init
// automatically deactivate the plugin
@ -51,15 +48,25 @@ class Initializer {
}
}
function onInit() {
$this->setupRouter();
$this->setupPages();
$this->runQueueSupervisor();
}
function setupDB() {
\ORM::configure(Env::$db_source_name);
\ORM::configure('username', Env::$db_username);
\ORM::configure('password', Env::$db_password);
\ORM::configure('logging', WP_DEBUG);
\ORM::configure('logger', function($query, $time) {
// error_log("\n".$query."\n");
});
\ORM::configure('driver_options', array(
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8',
\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET TIME_ZONE = "+00:00"'
\PDO::MYSQL_ATTR_INIT_COMMAND =>
'SET TIME_ZONE = "' . Env::$db_timezone_offset. '"'
));
$subscribers = Env::$db_prefix . 'subscribers';
@ -124,7 +131,7 @@ class Initializer {
}
function setupWidget() {
$widget = new Widget();
$widget = new Widget($this->renderer);
$widget->init();
}
@ -144,8 +151,11 @@ class Initializer {
}
function setupPages() {
$pages = new Pages();
$pages = new \MailPoet\Settings\Pages();
$pages->init();
$subscription_pages = new \MailPoet\Subscription\Pages();
$subscription_pages->init();
}
function setupShortcodes() {

View File

@ -367,6 +367,8 @@ class Menu {
$data['segments'] = Segment::findArray();
$data['settings'] = Setting::getAll();
$data['roles'] = $wp_roles->get_names();
$data['roles']['mailpoet_all'] = __('In any WordPress role');
echo $this->renderer->render('newsletters.html', $data);
}
@ -380,11 +382,12 @@ class Menu {
$data = array(
'customFields' => $custom_fields,
'settings' => Setting::getAll(),
);
wp_enqueue_media();
wp_enqueue_script('tinymce-wplink', includes_url('js/tinymce/plugins/wplink/plugin.js'));
wp_enqueue_style('editor', includes_url('css/editor.css'));
echo $this->renderer->render('newsletter/form.html', $data);
echo $this->renderer->render('newsletter/editor.html', $data);
}
function import() {

View File

@ -214,6 +214,9 @@ class Migrator {
$attributes = array(
'id mediumint(9) NOT NULL AUTO_INCREMENT,',
'newsletter_id mediumint(9) NOT NULL,',
'newsletter_rendered_body longtext,',
'newsletter_rendered_body_hash varchar(250) NULL DEFAULT NULL,',
'newsletter_rendered_subject varchar(250) NULL DEFAULT NULL,',
'subscribers longtext,',
'status varchar(12) NULL DEFAULT NULL,',
'priority mediumint(9) NOT NULL DEFAULT 0,',
@ -221,6 +224,7 @@ class Migrator {
'count_processed mediumint(9) NOT NULL DEFAULT 0,',
'count_to_process mediumint(9) NOT NULL DEFAULT 0,',
'count_failed mediumint(9) NOT NULL DEFAULT 0,',
'scheduled_at TIMESTAMP NOT NULL DEFAULT 0,',
'processed_at TIMESTAMP NOT NULL DEFAULT 0,',
'created_at TIMESTAMP NOT NULL DEFAULT 0,',
'updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,',
@ -267,4 +271,4 @@ class Migrator {
return implode("\n", $sql);
}
}
}

View File

@ -70,35 +70,36 @@ class Populator {
if($page === null) {
$mailpoet_page_id = Pages::createMailPoetPage();
Setting::setValue('subscription.page', $mailpoet_page_id);
} else {
$mailpoet_page_id = (int)$page->ID;
}
Setting::setValue('subscription.unsubscribe_page', $mailpoet_page_id);
Setting::setValue('subscription.manage_page', $mailpoet_page_id);
Setting::setValue('subscription.confirmation_page', $mailpoet_page_id);
}
private function createDefaultSettings() {
$current_user = wp_get_current_user();
// user name
$user_name = '';
if($current_user->user_firstname) {
$user_name = $current_user->user_firstname;
}
if($current_user->user_lastname) {
if($user_name) {
$user_name .= ' '.$current_user->user_lastname;
}
}
if(!$user_name) {
$user_name = $current_user->display_name;
}
// default sender info based on current user
$sender = array(
'name' => $current_user->display_name,
'address' => $current_user->user_email
);
// default from name & address
Setting::setValue('sender', array(
'name' => $user_name,
'address' => $current_user->user_email
));
Setting::setValue('sender', $sender);
// enable signup confirmation by default
Setting::setValue('signup_confirmation.enabled', true);
Setting::setValue('signup_confirmation', array(
'enabled' => true,
'from' => array(
'name' => get_option('blogname'),
'address' => get_option('admin_email')
),
'reply_to' => $sender
));
}
private function createDefaultSegments() {
@ -175,6 +176,14 @@ class Populator {
'name' => 'nthWeekDay',
'newsletter_type' => 'notification',
),
array(
'name' => 'schedule',
'newsletter_type' => 'notification',
),
array(
'name' => 'segments',
'newsletter_type' => 'notification',
)
);
}

View File

@ -142,7 +142,7 @@ class BlankTemplate {
"blocks" => array(
array(
"type" => "footer",
"text" => "<a href=\"[unsubscribeUrl]\">Unsubscribe</a> | <a href=\"[manageSubscriptionUrl]\">Manage subscription</a><br /><b>Add your postal address here!</b>",
"text" => "<a href=\"[subscription:unsubscribe_url]\">Unsubscribe</a> | <a href=\"[subscription:manage_url]\">Manage subscription</a><br /><b>Add your postal address here!</b>",
"styles" => array(
"block" => array(
"backgroundColor" => "transparent"

View File

@ -46,7 +46,7 @@ class FranksRoastHouseTemplate {
"blocks" => array(
array(
"type" => "header",
"text" => __("Display problems?&nbsp;<a href=\"[viewInBrowserUrl]\">View it in your browser</a>"),
"text" => __("Display problems?&nbsp;<a href=\"[newsletter:view_in_browser_url]\">View it in your browser</a>"),
"styles" => array(
"block" => array(
"backgroundColor" => "#ccc6c6"
@ -280,7 +280,7 @@ class FranksRoastHouseTemplate {
"blocks" => array(
array(
"type" => "footer",
"text" => __("<p><a href=\"[unsubscribeUrl]\">Unsubscribe</a> | <a href=\"[manageSubscriptionUrl]\">Manage subscription</a><br />12345 MailPoet Drive, EmailVille, 76543</p>"),
"text" => __("<p><a href=\"[subscription:unsubscribe_url]\">Unsubscribe</a> | <a href=\"[subscription:manage_url]\">Manage subscription</a><br />12345 MailPoet Drive, EmailVille, 76543</p>"),
"styles" => array(
"block" => array(
"backgroundColor" => "#a9a7a7"

View File

@ -242,7 +242,7 @@ class PostNotificationsBlankTemplate {
"blocks" => array(
array(
"type" => "footer",
"text" => __("<a href=\"[unsubscribeUrl]\">Unsubscribe</a> | <a href=\"[manageSubscriptionUrl]\">Manage subscription</a><br /><b>Add your postal address here!</b>"),
"text" => __("<a href=\"[subscription:unsubscribe_url]\">Unsubscribe</a> | <a href=\"[subscription:manage_url]\">Manage subscription</a><br /><b>Add your postal address here!</b>"),
"styles" => array(
"block" => array(
"backgroundColor" => "transparent"

View File

@ -46,7 +46,7 @@ class WelcomeTemplate {
"blocks" => array(
array(
"type" => "header",
"text" => __("Display problems?&nbsp;<a href=\"[viewInBrowserUrl]\">View it in your browser</a>"),
"text" => __("Display problems?&nbsp;<a href=\"[newsletter:view_in_browser_url]\">View it in your browser</a>"),
"styles" => array(
"block" => array(
"backgroundColor" => "transparent"
@ -224,7 +224,7 @@ class WelcomeTemplate {
"blocks" => array(
array(
"type" => "footer",
"text" => __("<a href=\"[unsubscribeUrl]\">Unsubscribe</a> | <a href=\"[manageSubscriptionUrl]\">Manage subscription</a><br /><b>Add your postal address here!</b>"),
"text" => __("<a href=\"[subscription:unsubscribe_url]\">Unsubscribe</a> | <a href=\"[subscription:manage_url]\">Manage subscription</a><br /><b>Add your postal address here!</b>"),
"styles" => array(
"block" => array(
"backgroundColor" => "transparent"

View File

@ -59,7 +59,7 @@ class Renderer {
}
function detectCache() {
$cache_path = Env::$views_path . '/cache';
$cache_path = Env::$temp_path . '/cache';
if(WP_DEBUG === false) {
return $cache_path;
}

View File

@ -1,11 +1,17 @@
<?php
namespace MailPoet\Config;
use \MailPoet\Util\Security;
use \MailPoet\Models\Form;
if(!defined('ABSPATH')) exit;
class Widget {
function __construct() {
private $renderer = null;
function __construct($renderer = null) {
if($renderer !== null) {
$this->renderer = $renderer;
}
}
function init() {
@ -13,11 +19,67 @@ class Widget {
if(!is_admin()) {
$this->setupDependencies();
$this->setupIframe();
} else {
$this->setupAdminDependencies();
}
}
function setupIframe() {
$form_id = (isset($_GET['mailpoet_form_iframe']) ? (int)$_GET['mailpoet_form_iframe'] : 0);
if($form_id > 0) {
$form = Form::findOne($form_id);
if($form !== false) {
$form_widget = new \MailPoet\Form\Widget();
$form_html = $form_widget->widget(array(
'form' => $form_id,
'form_type' => 'iframe'
));
// capture javascripts
ob_start();
wp_print_scripts('jquery');
wp_print_scripts('mailpoet_vendor');
wp_print_scripts('mailpoet_public');
$scripts = ob_get_contents();
ob_end_clean();
// language attributes
$language_attributes = array();
$is_rtl = (bool)(function_exists('is_rtl') && is_rtl());
if($is_rtl) {
$language_attributes[] = 'dir="rtl"';
}
if($lang = get_bloginfo('language')) {
if(get_option('html_type') === 'text/html') {
$language_attributes[] = "lang=\"$lang\"";
}
}
$language_attributes = apply_filters(
'language_attributes', implode(' ', $language_attributes)
);
$data = array(
'language_attributes' => $language_attributes,
'scripts' => $scripts,
'form' => $form_html,
'mailpoet_form' => array(
'ajax_url' => admin_url('admin-ajax.php', 'absolute'),
'is_rtl' => $is_rtl,
'token' => Security::generateToken()
)
);
echo $this->renderer->render('form/iframe.html', $data);
}
exit();
}
}
function registerWidget() {
register_widget('\MailPoet\Form\Widget');
}

View File

@ -68,4 +68,11 @@ class CronHelper {
// throw an error if all connection attempts failed
throw new \Exception(__('Site URL is unreachable.'));
}
static function checkExecutionTimer($timer) {
$elapsed_time = microtime(true) - $timer;
if($elapsed_time >= self::daemon_execution_limit) {
throw new \Exception(__('Maximum execution time reached.'));
}
}
}

View File

@ -1,6 +1,7 @@
<?php
namespace MailPoet\Cron;
use MailPoet\Cron\Workers\Scheduler;
use MailPoet\Cron\Workers\SendingQueue;
require_once(ABSPATH . 'wp-includes/pluggable.php');
@ -35,8 +36,10 @@ class Daemon {
}
$this->abortIfStopped($daemon);
try {
$sending_queue = new SendingQueue($this->timer);
$sending_queue->process();
$scheduler = new Scheduler();
$scheduler->process($this->timer);
$queue = new SendingQueue();
$queue->process($this->timer);
} catch(\Exception $e) {
}
$elapsed_time = microtime(true) - $this->timer;

View File

@ -0,0 +1,152 @@
<?php
namespace MailPoet\Cron\Workers;
use Carbon\Carbon;
use Cron\CronExpression as Cron;
use MailPoet\Cron\CronHelper;
use MailPoet\Models\Newsletter;
use MailPoet\Models\SendingQueue;
use MailPoet\Models\Subscriber;
use MailPoet\Models\SubscriberSegment;
use MailPoet\Newsletter\Renderer\Renderer;
use MailPoet\Util\Helpers;
require_once(ABSPATH . 'wp-includes/pluggable.php');
if(!defined('ABSPATH')) exit;
class Scheduler {
public $timer;
function __construct($timer = false) {
$this->timer = ($timer) ? $timer : microtime(true);
CronHelper::checkExecutionTimer($this->timer);
}
function process() {
$scheduled_queues = SendingQueue::where('status', 'scheduled')
->whereLte('scheduled_at', Carbon::createFromTimestamp(current_time('timestamp')))
->findMany();
if(!count($scheduled_queues)) return;
foreach($scheduled_queues as $queue) {
$newsletter = Newsletter::filter('filterWithOptions')
->findOne($queue->newsletter_id);
if(!$newsletter || $newsletter->deleted_at !== null) {
$queue->delete();
}
else if($newsletter->type === 'welcome') {
$this->processWelcomeNewsletter($newsletter, $queue);
}
else if($newsletter->type === 'notification') {
$this->processPostNotificationNewsletter($newsletter, $queue);
}
CronHelper::checkExecutionTimer($this->timer);
}
}
function processWelcomeNewsletter($newsletter, $queue) {
$subscriber = unserialize($queue->subscribers);
$subscriber_id = $subscriber['to_process'][0];
if($newsletter->event === 'segment') {
if ($this->verifyMailPoetSubscriber($subscriber_id, $newsletter, $queue) === false) {
return;
}
}
else if($newsletter->event === 'user') {
if ($this->verifyWPSubscriber($subscriber_id, $newsletter) === false) {
$queue->delete();
return;
}
}
$queue->status = null;
$queue->save();
}
function processPostNotificationNewsletter($newsletter, $queue) {
$next_run_date = $this->getQueueNextRunDate($newsletter->schedule);
$segments = unserialize($newsletter->segments);
$subscribers = SubscriberSegment::whereIn('segment_id', $segments)
->findArray();
$subscribers = Helpers::arrayColumn($subscribers, 'subscriber_id');
$subscribers = array_unique($subscribers);
if(!count($subscribers)) {
$queue->delete();
return;
}
if(!$this->checkIfNewsletterChanged($newsletter)) {
$queue->scheduled_at = $next_run_date;
$queue->save();
return;
}
// update current queue
$queue->subscribers = serialize(
array(
'to_process' => $subscribers
)
);
$queue->count_total = $queue->count_to_process = count($subscribers);
$queue->status = null;
$queue->save();
// schedule newsletter for next delivery
$new_queue = SendingQueue::create();
$new_queue->newsletter_id = $newsletter->id;
$new_queue->scheduled_at = $next_run_date;
$new_queue->status = 'scheduled';
$new_queue->save();
}
private function verifyMailPoetSubscriber($subscriber_id, $newsletter, $queue) {
// check if subscriber is in proper segment
$subscriber_in_segment =
SubscriberSegment::where('subscriber_id', $subscriber_id)
->where('segment_id', $newsletter->segment)
->where('status', 'subscribed')
->findOne();
if (!$subscriber_in_segment) {
$queue->delete();
return false;
}
// check if subscriber is confirmed (subscribed)
$subscriber = $subscriber_in_segment->subscriber()->findOne();
if ($subscriber->status !== 'subscribed') {
// reschedule delivery in 5 minutes
$scheduled_at = Carbon::createFromTimestamp(current_time('timestamp'));
$queue->scheduled_at = $scheduled_at->addMinutes(5);
$queue->save();
return false;
}
return true;
}
private function verifyWPSubscriber($subscriber_id, $newsletter) {
// check if user has the proper role
$subscriber = Subscriber::findOne($subscriber_id);
if(!$subscriber || $subscriber->wp_user_id === null) {
return false;
}
$wp_user = (array) get_userdata($subscriber->wp_user_id);
if(!in_array($newsletter->role, $wp_user['roles'])) {
return false;
}
return true;
}
private function checkIfNewsletterChanged($newsletter) {
$last_run_queue = SendingQueue::where('status', 'completed')
->where('newsletter_id', $newsletter->id)
->orderByDesc('id')
->findOne();
if(!$last_run_queue) return true;
$renderer = new Renderer($newsletter->asArray());
$rendered_newsletter = $renderer->render();
$new_hash = md5($rendered_newsletter['html']);
$old_hash = $last_run_queue->newsletter_rendered_body_hash;
return $new_hash !== $old_hash;
}
private function getQueueNextRunDate($schedule) {
$schedule = Cron::factory($schedule);
return $schedule->getNextRunDate(current_time('mysql'))
->format('Y-m-d H:i:s');
}
}

View File

@ -27,14 +27,18 @@ class SendingQueue {
'processBulkSubscribers' :
'processIndividualSubscriber';
$this->timer = ($timer) ? $timer : microtime(true);
CronHelper::checkExecutionTimer($this->timer);
}
function process() {
foreach($this->getQueues() as $queue) {
$newsletter = Newsletter::findOne($queue->newsletter_id);
if(!$newsletter) {
$queue->delete();
continue;
}
$newsletter = $newsletter->asArray();
$newsletter['body'] = $this->getNewsletterBodyAndSubject($queue, $newsletter);
$queue->subscribers = (object) unserialize($queue->subscribers);
if(!isset($queue->subscribers->processed)) {
$queue->subscribers->processed = array();
@ -42,8 +46,6 @@ class SendingQueue {
if(!isset($queue->subscribers->failed)) {
$queue->subscribers->failed = array();
}
$newsletter = $newsletter->asArray();
$newsletter['body'] = $this->renderNewsletter($newsletter);
$mailer = $this->configureMailer($newsletter);
foreach(array_chunk($queue->subscribers->to_process, self::batch_size) as
$subscribers_ids) {
@ -65,6 +67,20 @@ class SendingQueue {
}
}
function getNewsletterBodyAndSubject($queue, $newsletter) {
// check if newsletter has been rendered, in which case return its contents
// or render & and for future use
if($queue->newsletter_rendered_body === null) {
$newsletter['body'] = $this->renderNewsletter($newsletter);
$queue->newsletter_rendered_body = json_encode($newsletter['body']);
$queue->newsletter_rendered_body_hash = md5($newsletter['body']['text']);
$queue->save();
} else {
$newsletter['body'] = json_decode($queue->newsletter_rendered_body);
}
return (array) $newsletter['body'];
}
function processBulkSubscribers($mailer, $newsletter, $subscribers, $queue) {
foreach($subscribers as $subscriber) {
$processed_newsletters[] =
@ -85,7 +101,7 @@ class SendingQueue {
);
} else {
$newsletter_statistics =
array_map(function ($data) use ($newsletter, $subscribers_ids, $queue) {
array_map(function($data) use ($newsletter, $subscribers_ids, $queue) {
return array(
$newsletter['id'],
$subscribers_ids[$data],
@ -102,7 +118,7 @@ class SendingQueue {
}
$this->updateQueue($queue);
$this->checkSendingLimit();
$this->checkExecutionTimer();
CronHelper::checkExecutionTimer($this->timer);
return $queue->subscribers;
}
@ -110,6 +126,9 @@ class SendingQueue {
foreach($subscribers as $subscriber) {
$this->checkSendingLimit();
$processed_newsletter = $this->processNewsletter($newsletter, $subscriber);
if (!$queue->newsletter_rendered_subject) {
$queue->newsletter_rendered_subject = $processed_newsletter['subject'];
}
$transformed_subscriber = $mailer->transformSubscriber($subscriber);
$result = $this->sendNewsletter(
$mailer,
@ -117,7 +136,7 @@ class SendingQueue {
$transformed_subscriber
);
if(!$result) {
$queue->subscribers->failed[] = $subscriber['id'];;
$queue->subscribers->failed[] = $subscriber['id'];
} else {
$queue->subscribers->processed[] = $subscriber['id'];
$newsletter_statistics = array(
@ -129,7 +148,7 @@ class SendingQueue {
$this->updateNewsletterStatistics($newsletter_statistics);
}
$this->updateQueue($queue);
$this->checkExecutionTimer();
CronHelper::checkExecutionTimer($this->timer);
}
return $queue->subscribers;
}
@ -145,13 +164,17 @@ class SendingQueue {
function processNewsletter($newsletter, $subscriber = false) {
$divider = '***MailPoet***';
$data_for_shortcodes =
array_merge(array($newsletter['subject']), $newsletter['body']);
$body = implode($divider, $data_for_shortcodes);
$shortcodes = new Shortcodes(
implode($divider, $newsletter['body']),
$newsletter,
$subscriber
);
list($newsletter['body']['html'], $newsletter['body']['text']) =
explode($divider, $shortcodes->replace());
list($newsletter['subject'],
$newsletter['body']['html'],
$newsletter['body']['text']
) = explode($divider, $shortcodes->replace($body));
return $newsletter;
}
@ -201,7 +224,9 @@ class SendingQueue {
$queue->subscribers->failed
)
);
$queue->subscribers->to_process = array_values($queue->subscribers->to_process);
$queue->subscribers->to_process = array_values(
$queue->subscribers->to_process
);
$queue->count_processed =
count($queue->subscribers->processed) + count($queue->subscribers->failed);
$queue->count_to_process = count($queue->subscribers->to_process);
@ -259,11 +284,4 @@ class SendingQueue {
}
return;
}
function checkExecutionTimer() {
$elapsed_time = microtime(true) - $this->timer;
if($elapsed_time >= CronHelper::daemon_execution_limit) {
throw new \Exception(__('Maximum execution time reached.'));
}
}
}

View File

@ -112,4 +112,17 @@ abstract class Base {
&& strlen(trim($block['params']['value'])) > 0)
? esc_attr(trim($block['params']['value'])) : '';
}
protected static function getInputModifiers($block = array()) {
$modifiers = array();
if(isset($block['params']['readonly'])) {
$modifiers[] = 'readonly';
}
if(isset($block['params']['disabled'])) {
$modifiers[] = 'disabled';
}
return join(' ', $modifiers);
}
}

View File

@ -20,18 +20,22 @@ class Checkbox extends Base {
foreach($options as $option) {
$html .= '<label class="mailpoet_checkbox_label">';
$html .= '<input type="hidden" name="'.$field_name.'" value="" />';
$html .= '<input type="checkbox" class="mailpoet_checkbox" ';
$html .= 'name="'.$field_name.'" ';
$html .= 'value="1" ';
$html .= (isset($option['is_checked']) && $option['is_checked'])
? 'checked="checked"' : '';
$html .= (
(isset($option['is_checked']) && $option['is_checked'])
||
(self::getFieldValue($block))
) ? 'checked="checked"' : '';
$html .= $field_validation;
$html .= ' />'.$option['value'];
$html .= ' /> '.esc_attr($option['value']);
$html .= '</label>';
}

View File

@ -33,18 +33,37 @@ class Date extends Base {
// generate an array of selectors based on date format
$date_selectors = explode('/', $date_format);
// format value if present
$value = self::getFieldValue($block);
$day = null;
$month = null;
$year = null;
if($value) {
$day = (int)strftime('%d', $value);
$month = (int)strftime('%m', $value);
$year = (int)strftime('%Y', $value);
} else if(!empty($block['params']['is_default_today'])) {
$day = (int)strftime('%d');
$month = (int)strftime('%m');
$year = (int)strftime('%Y');
}
foreach($date_selectors as $date_selector) {
if($date_selector === 'dd') {
$block['selected'] = $day;
$html .= '<select class="mailpoet_date_day" ';
$html .= 'name="'.$field_name.'[day]" placeholder="'.__('Day').'">';
$html .= static::getDays($block);
$html .= '</select>';
} else if($date_selector === 'mm') {
$block['selected'] = $month;
$html .= '<select class="mailpoet_date_month" ';
$html .= 'name="'.$field_name.'[month]" placeholder="'.__('Month').'">';
$html .= static::getMonths($block);
$html .= '</select>';
} else if($date_selector === 'yyyy') {
$block['selected'] = $year;
$html .= '<select class="mailpoet_date_year" ';
$html .= 'name="'.$field_name.'[year]" placeholder="'.__('Year').'">';
$html .= static::getYears($block);
@ -84,11 +103,6 @@ class Date extends Base {
'selected' => null
);
// is default today
if(!empty($block['params']['is_default_today'])) {
$defaults['selected'] = (int)strftime('%m');
}
// merge block with defaults
$block = array_merge($defaults, $block);

View File

@ -25,14 +25,24 @@ class Radio extends Base {
$html .= 'name="'.$field_name.'" ';
$html .= 'value="'.esc_attr($option['value']).'" ';
if(is_array($option['value'])) {
$value = key($option['value']);
$label = reset($option['value']);
} else {
$value = $option['value'];
$label = $option['value'];
}
$html .= 'value="'.esc_attr($value).'" ';
$html .= (
(isset($option['is_checked']) && $option['is_checked'])
||
(self::getFieldValue($block) === $value)
) ? 'checked="checked"' : '';
$html .= (isset($option['is_checked']) && $option['is_checked'])
? 'checked="checked"' : '';
$html .= $field_validation;
$html .= ' />&nbsp;'.esc_attr($option['value']);
$html .= ' /> '.esc_attr($label);
$html .= '</label>';
}

View File

@ -28,7 +28,7 @@ class Segment extends Base {
$html .= 'name="'.$field_name.'[]" ';
$html .= 'value="'.$option['id'].'" '.$is_checked.' ';
$html .= $field_validation;
$html .= ' />'.$option['name'];
$html .= ' /> '.esc_attr($option['name']);
$html .= '</label>';
}

View File

@ -10,9 +10,7 @@ class Select extends Base {
$field_validation = static::getInputValidation($block);
$html .= '<p class="mailpoet_paragraph">';
$html .= static::renderLabel($block);
$html .= '<select class="mailpoet_select" name="'.$field_name.'">';
if(isset($block['params']['label_within'])
@ -20,11 +18,28 @@ class Select extends Base {
$html .= '<option value="">'.static::getFieldLabel($block).'</option>';
}
foreach($block['params']['values'] as $option) {
$is_selected = (isset($option['is_checked']) && $option['is_checked'])
? 'selected="selected"' : '';
$html .= '<option value="'.$option['value'].'" '.$is_selected.'>';
$html .= $option['value'];
$options = (!empty($block['params']['values'])
? $block['params']['values']
: array()
);
foreach($options as $option) {
$is_selected = (
(isset($option['is_checked']) && $option['is_checked'])
||
(self::getFieldValue($block) === $option['value'])
) ? 'selected="selected"' : '';
if(is_array($option['value'])) {
$value = key($option['value']);
$label = reset($option['value']);
} else {
$value = $option['value'];
$label = $option['value'];
}
$html .= '<option value="'.$value.'" '.$is_selected.'>';
$html .= esc_attr($label);
$html .= '</option>';
}
$html .= '</select>';

View File

@ -6,7 +6,7 @@ class Text extends Base {
static function render($block) {
$type = 'text';
if($block['id'] === 'email') {
$type = 'email';
$type = 'email';
}
$html = '';
@ -27,6 +27,8 @@ class Text extends Base {
$html .= static::getInputValidation($block);
$html .= static::getInputModifiers($block);
$html .= '/>';
$html .= '</p>';

View File

@ -19,6 +19,8 @@ class Textarea extends Base {
$html .= static::getInputValidation($block);
$html .= static::getInputModifiers($block);
$html .= '></textarea>';
$html .= '</p>';

View File

@ -39,8 +39,7 @@ class Renderer {
}
}
// private: rendering methods
private static function renderBlocks($blocks = array()) {
static function renderBlocks($blocks = array()) {
$html = '';
foreach ($blocks as $key => $block) {
$html .= static::renderBlock($block)."\n";
@ -49,7 +48,7 @@ class Renderer {
return $html;
}
private static function renderBlock($block = array()) {
static function renderBlock($block = array()) {
$html = '';
switch($block['type']) {
case 'html':

View File

@ -17,8 +17,7 @@ class Export {
case 'iframe':
// generate url to load iframe's content
$iframe_url = add_query_arg(array(
'mailpoet_page' => 'mailpoet_form_iframe',
'mailpoet_form' => $form['id']
'mailpoet_form_iframe' => $form['id']
), site_url());
// generate iframe
@ -31,7 +30,7 @@ class Export {
'class="mailpoet_form_iframe"',
'vspace="0"',
'tabindex="0"',
'onload="javascript:(this.style.height = this.contentWindow.document.body.scrollHeight + \'px\');"',
'onload="MailPoet.Iframe.autoSize(this);"',
'marginwidth="0"',
'marginheight="0"',
'hspace="0"',

View File

@ -17,7 +17,7 @@ class Styles {
}
/* labels */
.mailpoet_input_label,
.mailpoet_text_label,
.mailpoet_textarea_label,
.mailpoet_select_label,
.mailpoet_radio_label,
@ -28,7 +28,7 @@ class Styles {
}
/* inputs */
.mailpoet_input,
.mailpoet_text,
.mailpoet_textarea,
.mailpoet_select,
.mailpoet_date {
@ -36,9 +36,7 @@ class Styles {
}
.mailpoet_checkbox {
display:inline;
margin-right: 5px;
vertical-align:middle;
}
.mailpoet_validate_success {

View File

@ -154,7 +154,7 @@ class Widget extends \WP_Widget {
$output = '';
if(!empty($body)) {
$form_id = $this->id_base.'_'.$this->number;
$form_id = $this->id_base.'_'.$form['id'];
$data = array(
'form_id' => $form_id,

View File

@ -93,7 +93,7 @@ class Handler {
return array(
'count' => $count,
'filters' => $this->model->filter('filters'),
'filters' => $this->model->filter('filters', $this->data['group']),
'groups' => $this->model->filter('groups'),
'items' => $items
);

View File

@ -110,7 +110,7 @@ class Model extends \Sudzy\ValidModel {
$total = $orm->count();
if($total > 0) {
$models = $orm->select('id')
$models = $orm->select(static::$_table.'.id')
->offset(null)
->limit(null)
->findArray();

View File

@ -73,16 +73,20 @@ class Newsletter extends Model {
}
function withSendingQueue() {
$this->queue = $this->getQueue();
$queue = $this->getQueue();
if($queue === false) {
$this->queue = false;
} else {
$this->queue = $queue->asArray();
}
return $this;
}
static function search($orm, $search = '') {
return $orm->where_like('subject', '%' . $search . '%');
}
static function filters() {
static function filters($orm, $group = 'all') {
$segments = Segment::orderByAsc('name')->findMany();
$segment_list = array();
$segment_list[] = array(
@ -91,7 +95,9 @@ class Newsletter extends Model {
);
foreach($segments as $segment) {
$newsletters_count = $segment->newsletters()->count();
$newsletters_count = $segment->newsletters()
->filter('groupBy', $group)
->count();
if($newsletters_count > 0) {
$segment_list[] = array(
'label' => sprintf('%s (%d)', $segment->name, $newsletters_count),

View File

@ -35,7 +35,7 @@ class Segment extends Model {
__NAMESPACE__.'\SubscriberSegment',
'segment_id',
'subscriber_id'
);
)->where(MP_SUBSCRIBER_SEGMENT_TABLE.'.status', 'subscribed');
}
function duplicate($data = array()) {
@ -186,6 +186,6 @@ class Segment extends Model {
}
static function getPublic() {
return self::getPublished()->where('type', 'default');
return self::getPublished()->where('type', 'default')->orderByAsc('name');
}
}

View File

@ -6,6 +6,13 @@ if (!defined('ABSPATH')) exit;
class Setting extends Model {
public static $_table = MP_SETTINGS_TABLE;
public static $defaults = null;
const DEFAULT_SENDING_METHOD_GROUP = 'website';
const DEFAULT_SENDING_METHOD = 'PHPMail';
const DEFAULT_SENDING_FREQUENCY_EMAILS = 25;
const DEFAULT_SENDING_FREQUENCY_INTERVAL = 15; // in minutes
function __construct() {
parent::__construct();
@ -14,8 +21,34 @@ class Setting extends Model {
));
}
public static function getDefaults() {
if(self::$defaults === null) {
self::loadDefaults();
}
return self::$defaults;
}
public static function loadDefaults() {
self::$defaults = array(
'mta_group' => self::DEFAULT_SENDING_METHOD_GROUP,
'mta' => array(
'method' => self::DEFAULT_SENDING_METHOD,
'frequency' => array(
'emails' => self::DEFAULT_SENDING_FREQUENCY_EMAILS,
'interval' => self::DEFAULT_SENDING_FREQUENCY_INTERVAL
)
),
'signup_confirmation' => array(
'enabled' => true,
'subject' => sprintf(__('Confirm your subscription to %1$s'), get_option('blogname')),
'body' => __("Hello!\n\nHurray! You've subscribed to our site.\n\nWe need you to activate your subscription to the list(s): [lists_to_confirm] by clicking the link below: \n\n[activation_link]Click here to confirm your subscription.[/activation_link]\n\nThank you,\n\nThe team!")
)
);
}
public static function getValue($key, $default = null) {
$keys = explode('.', $key);
$defaults = self::getDefaults();
if(count($keys) === 1) {
$setting = Setting::where('name', $key)->findOne();
@ -23,9 +56,14 @@ class Setting extends Model {
return $default;
} else {
if(is_serialized($setting->value)) {
return unserialize($setting->value);
$value = unserialize($setting->value);
} else {
return $setting->value;
$value = $setting->value;
}
if(is_array($value) && array_key_exists($key, $defaults)) {
return array_replace_recursive($defaults[$key], $value);
} else {
return $value;
}
}
} else {
@ -93,7 +131,7 @@ class Setting extends Model {
$settings[$setting->name] = $value;
}
}
return $settings;
return array_replace_recursive(self::getDefaults(), $settings);
}
public static function createOrUpdate($data = array()) {

View File

@ -1,12 +1,19 @@
<?php
namespace MailPoet\Models;
use MailPoet\Mailer\Mailer;
use MailPoet\Newsletter\Scheduler\Scheduler;
use MailPoet\Util\Helpers;
use MailPoet\Subscription;
if(!defined('ABSPATH')) exit;
class Subscriber extends Model {
public static $_table = MP_SUBSCRIBERS_TABLE;
const STATUS_SUBSCRIBED = 'subscribed';
const STATUS_UNSUBSCRIBED = 'unsubscribed';
const STATUS_UNCONFIRMED = 'unconfirmed';
function __construct() {
parent::__construct();
@ -16,13 +23,22 @@ class Subscriber extends Model {
));
}
static function findOne($id = null) {
if(is_int($id) || (string)(int)$id === $id) {
return parent::findOne($id);
} else {
return parent::where('email', $id)->findOne();
}
}
function segments() {
return $this->has_many_through(
__NAMESPACE__.'\Segment',
__NAMESPACE__.'\SubscriberSegment',
'subscriber_id',
'segment_id'
);
)
->where(MP_SUBSCRIBER_SEGMENT_TABLE.'.status', self::STATUS_SUBSCRIBED);
}
function delete() {
@ -57,9 +73,79 @@ class Subscriber extends Model {
}
function sendConfirmationEmail() {
$this->set('status', 'unconfirmed');
if($this->status === self::STATUS_UNCONFIRMED) {
$signup_confirmation = Setting::getValue('signup_confirmation');
// TODO
$segments = $this->segments()->findMany();
$segment_names = array_map(function($segment) {
return $segment->name;
}, $segments);
$body = nl2br($signup_confirmation['body']);
// replace list of segments shortcode
$body = str_replace(
'[lists_to_confirm]',
'<strong>'.join(', ', $segment_names).'</strong>',
$body
);
// replace activation link
$body = str_replace(
array(
'[activation_link]',
'[/activation_link]'
),
array(
'<a href="'.esc_attr(Subscription\Url::getConfirmationUrl($this)).'">',
'</a>'
),
$body
);
// build email data
$email = array(
'subject' => $signup_confirmation['subject'],
'body' => array(
'html' => $body,
'text' => $body
)
);
// convert subscriber to array
$subscriber = $this->asArray();
// set from
$from = (
!empty($signup_confirmation['from'])
&& !empty($signup_confirmation['from']['address'])
) ? $signup_confirmation['from']
: false;
// set reply to
$reply_to = (
!empty($signup_confirmation['reply_to'])
&& !empty($signup_confirmation['reply_to']['address'])
) ? $signup_confirmation['reply_to']
: false;
// send email
try {
$mailer = new Mailer(false, $from, $reply_to);
return $mailer->send($email, $subscriber);
} catch(\Exception $e) {
$this->setError($e->getMessage());
return false;
}
}
return false;
}
static function generateToken($email = null) {
if($email !== null) {
return md5(AUTH_KEY.$email);
}
return false;
}
static function subscribe($subscriber_data = array(), $segment_ids = array()) {
@ -67,24 +153,37 @@ class Subscriber extends Model {
return false;
}
$subscriber = self::createOrUpdate($subscriber_data);
$signup_confirmation_enabled = (bool)Setting::getValue(
'signup_confirmation.enabled'
);
$subscriber = self::createOrUpdate($subscriber_data);
$errors = $subscriber->getErrors();
if($errors === false && $subscriber->id > 0) {
$subscriber = self::findOne($subscriber->id);
if($subscriber !== false && $subscriber->id() > 0) {
// restore deleted subscriber
if($subscriber->deleted_at !== NULL) {
$subscriber->setExpr('deleted_at', 'NULL');
}
if((bool)Setting::getValue('signup_confirmation.enabled')) {
if($subscriber->status !== 'subscribed') {
$subscriber->sendConfirmationEmail();
}
} else {
$subscriber->set('status', 'subscribed');
// auto subscribe when signup confirmation is disabled
if($signup_confirmation_enabled === false) {
$subscriber->set('status', self::STATUS_SUBSCRIBED);
}
if($subscriber->save()) {
// link subscriber to segments
$subscriber->addToSegments($segment_ids);
// signup confirmation
if($subscriber->status !== self::STATUS_SUBSCRIBED) {
$subscriber->sendConfirmationEmail();
}
// welcome email
Scheduler::welcomeForSegmentSubscription($subscriber->id, $segment_ids);
}
}
@ -102,7 +201,7 @@ class Subscriber extends Model {
);
}
static function filters() {
static function filters($orm, $group = 'all') {
$segments = Segment::orderByAsc('name')->findMany();
$segment_list = array();
$segment_list[] = array(
@ -119,8 +218,9 @@ class Subscriber extends Model {
foreach($segments as $segment) {
$subscribers_count = $segment->subscribers()
->whereNull('deleted_at')
->filter('groupBy', $group)
->count();
$segment_list[] = array(
'label' => sprintf('%s (%d)', $segment->name, $subscribers_count),
'value' => $segment->id()
@ -161,19 +261,19 @@ class Subscriber extends Model {
'count' => self::getPublished()->count()
),
array(
'name' => 'subscribed',
'name' => self::STATUS_SUBSCRIBED,
'label' => __('Subscribed'),
'count' => self::filter('subscribed')->count()
'count' => self::filter(self::STATUS_SUBSCRIBED)->count()
),
array(
'name' => 'unconfirmed',
'name' => self::STATUS_UNCONFIRMED,
'label' => __('Unconfirmed'),
'count' => self::filter('unconfirmed')->count()
'count' => self::filter(self::STATUS_UNCONFIRMED)->count()
),
array(
'name' => 'unsubscribed',
'name' => self::STATUS_UNSUBSCRIBED,
'label' => __('Unsubscribed'),
'count' => self::filter('unsubscribed')->count()
'count' => self::filter(self::STATUS_UNSUBSCRIBED)->count()
),
array(
'name' => 'trash',
@ -247,6 +347,9 @@ class Subscriber extends Model {
static function createOrUpdate($data = array()) {
$subscriber = false;
if(is_array($data) && !empty($data)) {
$data = stripslashes_deep($data);
}
if(isset($data['id']) && (int)$data['id'] > 0) {
$subscriber = self::findOne((int)$data['id']);
@ -272,16 +375,25 @@ class Subscriber extends Model {
foreach($data as $key => $value) {
if(strpos($key, 'cf_') === 0) {
if(is_array($value)) {
$value = array_filter($value);
$value = reset($value);
}
$custom_fields[(int)substr($key, 3)] = $value;
unset($data[$key]);
}
}
$old_status = false;
$new_status = false;
if($subscriber === false) {
$subscriber = self::create();
$subscriber->hydrate($data);
} else {
$old_status = $subscriber->status;
$subscriber->set($data);
$new_status = $subscriber->status;
}
if($subscriber->save()) {
@ -290,8 +402,19 @@ class Subscriber extends Model {
$subscriber->setCustomField($custom_field_id, $value);
}
}
if($segment_ids !== false) {
SubscriberSegment::setSubscriptions($subscriber, $segment_ids);
// check for status change
if(
($old_status === self::STATUS_SUBSCRIBED)
&&
($new_status === self::STATUS_UNSUBSCRIBED)
) {
// make sure we unsubscribe the user from all lists
SubscriberSegment::setSubscriptions($subscriber, array());
} else {
if($segment_ids !== false) {
SubscriberSegment::setSubscriptions($subscriber, $segment_ids);
}
}
}
return $subscriber;
@ -412,21 +535,23 @@ class Subscriber extends Model {
static function bulkConfirmUnconfirmed($orm) {
$subscribers = $orm->findResultSet();
$subscribers->set('status', 'subscribed')->save();
$subscribers->set('status', self::STATUS_SUBSCRIBED)->save();
return $subscribers->count();
}
static function bulkResendConfirmationEmail($orm) {
static function bulkSendConfirmationEmail($orm) {
$subscribers = $orm
->where('status', 'unconfirmed')
->findResultSet();
->where('status', self::STATUS_UNCONFIRMED)
->findMany();
$emails_sent = 0;
if(!empty($subscribers)) {
foreach($subscribers as $subscriber) {
$subscriber->sendConfirmationEmail();
if($subscriber->sendConfirmationEmail()) {
$emails_sent++;
}
}
return $subscribers->count();
return $emails_sent;
}
return false;
}
@ -467,19 +592,19 @@ class Subscriber extends Model {
static function subscribed($orm) {
return $orm
->whereNull('deleted_at')
->where('status', 'subscribed');
->where('status', self::STATUS_SUBSCRIBED);
}
static function unsubscribed($orm) {
return $orm
->whereNull('deleted_at')
->where('status', 'unsubscribed');
->where('status', self::STATUS_UNSUBSCRIBED);
}
static function unconfirmed($orm) {
return $orm
->whereNull('deleted_at')
->where('status', 'unconfirmed');
->where('status', self::STATUS_UNCONFIRMED);
}
static function withoutSegments($orm) {

View File

@ -12,51 +12,35 @@ class SubscriberSegment extends Model {
parent::__construct();
}
function subscriber() {
return $this->has_one(__NAMESPACE__.'\Subscriber', 'id');
}
static function setSubscriptions($subscriber, $segment_ids = array()) {
if($subscriber->id > 0) {
// unsubscribe from current subscriptions
SubscriberSegment::where('subscriber_id', $subscriber->id)
->whereNotIn('segment_id', $segment_ids)
->findResultSet()
->set('status', 'unsubscribed')
->set('status', Subscriber::STATUS_UNSUBSCRIBED)
->save();
// subscribe to segments
foreach($segment_ids as $segment_id) {
self::createOrUpdate(array(
'subscriber_id' => $subscriber->id,
'segment_id' => $segment_id,
'status' => 'subscribed'
));
if((int)$segment_id > 0) {
self::createOrUpdate(array(
'subscriber_id' => $subscriber->id,
'segment_id' => $segment_id,
'status' => Subscriber::STATUS_SUBSCRIBED
));
}
}
}
return $subscriber;
}
static function filterWithCustomFields($orm) {
$orm = $orm->select(MP_SUBSCRIBERS_TABLE.'.*');
$customFields = CustomField::findArray();
foreach ($customFields as $customField) {
$orm = $orm->select_expr(
'CASE WHEN ' .
MP_CUSTOM_FIELDS_TABLE . '.id=' . $customField['id'] . ' THEN ' .
MP_SUBSCRIBER_CUSTOM_FIELD_TABLE . '.value END as "' . $customField['name'].'"');
}
$orm = $orm
->left_outer_join(
MP_SUBSCRIBER_CUSTOM_FIELD_TABLE,
array(MP_SUBSCRIBERS_TABLE.'.id', '=',
MP_SUBSCRIBER_CUSTOM_FIELD_TABLE.'.subscriber_id'))
->left_outer_join(
MP_CUSTOM_FIELDS_TABLE,
array(MP_CUSTOM_FIELDS_TABLE.'.id','=',
MP_SUBSCRIBER_CUSTOM_FIELD_TABLE.'.custom_field_id'));
return $orm;
}
static function subscribed($orm) {
return $orm->where('status', 'subscribed');
return $orm->where('status', Subscriber::STATUS_SUBSCRIBED);
}
static function createOrUpdate($data = array()) {

View File

@ -169,6 +169,6 @@ class PostTransformer {
$alignment = (in_array($this->args['titleAlignment'], array('left', 'right', 'center'))) ? $this->args['titleAlignment'] : 'left';
return '<' . $tag . ' style="text-align: ' . $alignment . '">' . $title . '</' . $tag . '>';
return '<' . $tag . ' data-post-id="' . $post->ID . '" style="text-align: ' . $alignment . '">' . $title . '</' . $tag . '>';
}
}

View File

@ -9,11 +9,11 @@ class Button {
$element['styles']['block']['width'] = self::calculateWidth($element, $column_count);
$template = '
<tr>
<td class="mailpoet_padded" valign="top">
<td class="mailpoet_padded_bottom mailpoet_padded_side" valign="top">
<div>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="border-spacing:0;mso-table-lspace:0;mso-table-rspace:0;">
<tr>
<td class="mailpoet_button-container" style="padding:8px 0;text-align:' . $element['styles']['block']['textAlign'] . ';"><!--[if mso]>
<td class="mailpoet_button-container" style="padding:8px 20px;text-align:' . $element['styles']['block']['textAlign'] . ';"><!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word"
href="' . $element['url'] . '"
style="height:' . $element['styles']['block']['lineHeight'] . ';
@ -43,9 +43,12 @@ class Button {
static function calculateWidth($element, $column_count) {
$column_width = ColumnsHelper::columnWidth($column_count);
$column_width = $column_width - (StylesHelper::$padding_width * 2);
$column_width = ((int) $element['styles']['block']['width'] > $column_width) ?
$column_width . 'px' :
$element['styles']['block']['width'];
return $column_width;
$border_width = (int) $element['styles']['block']['borderWidth'];
$button_width = (int) $element['styles']['block']['width'];
$button_width = ($button_width > $column_width) ?
$column_width :
$button_width;
$button_width = $button_width - (2 * $border_width) . 'px';
return $button_width;
}
}

View File

@ -17,10 +17,15 @@ class Footer {
}
}
}
$background_color = $element['styles']['block']['backgroundColor'];
$background_color = ($background_color !== 'transparent') ?
'bgcolor="' . $background_color . '"' :
false;
if(!$background_color) unset($element['styles']['block']['backgroundColor']);
$template = '
<tr>
<td class="mailpoet_padded_header_footer mailpoet_footer" bgcolor="' . $element['styles']['block']['backgroundColor'] . '"
style="' . StylesHelper::getBlockStyles($element) . StylesHelper::getStyles($element['styles'], 'text') . '">
<td class="mailpoet_header_footer_padded mailpoet_footer" ' . $background_color . '
style="line-height: ' . StylesHelper::$line_height . ';' . StylesHelper::getBlockStyles($element) . StylesHelper::getStyles($element['styles'], 'text') . '">
' . $DOM->html() . '
</td>
</tr>';

View File

@ -17,9 +17,14 @@ class Header {
}
}
}
$background_color = $element['styles']['block']['backgroundColor'];
$background_color = ($background_color !== 'transparent') ?
'bgcolor="' . $background_color . '"' :
false;
if(!$background_color) unset($element['styles']['block']['backgroundColor']);
$template = '
<tr>
<td class="mailpoet_padded_header_footer mailpoet_header" bgcolor="' . $element['styles']['block']['backgroundColor'] . '"
<td class="mailpoet_header_footer_padded mailpoet_header" ' . $background_color . '
style="' . StylesHelper::getBlockStyles($element) . StylesHelper::getStyles($element['styles'], 'text') . '">
' . $DOM->html() . '
</td>

View File

@ -18,7 +18,7 @@ class Image {
}
$template = '
<tr>
<td class="mailpoet_image ' . (($element['fullWidth'] === false) ? 'mailpoet_padded' : '') . '" align="center" valign="top">
<td class="mailpoet_image ' . (($element['fullWidth'] === false) ? 'mailpoet_padded_bottom mailpoet_padded_side' : 'mailpoet_padded_bottom') . '" align="center" valign="top">
' . $image_template . '
</td>
</tr>';

View File

@ -1,10 +1,12 @@
<?php
namespace MailPoet\Newsletter\Renderer\Blocks;
use MailPoet\Newsletter\Renderer\StylesHelper;
class Renderer {
function render($data, $column_count) {
$block_content = '';
array_map(function ($block) use (&$block_content, &$columns, $column_count) {
array_map(function($block) use (&$block_content, &$columns, $column_count) {
$block_content .= $this->createElementFromBlockType($block, $column_count);
if(isset($block['blocks'])) {
$block_content = $this->render($block, $column_count);
@ -18,6 +20,7 @@ class Renderer {
}
function createElementFromBlockType($block, $column_count) {
$block = StylesHelper::setTextAlign($block);
$block_class = __NAMESPACE__ . '\\' . ucfirst($block['type']);
return (class_exists($block_class)) ? $block_class::render($block, $column_count) : '';
}

View File

@ -13,7 +13,7 @@ class Social {
}
$template = '
<tr>
<td class="mailpoet_padded" valign="top" align="center">
<td class="mailpoet_padded_side maipoet_padded_bottom" valign="top" align="center">
' . $icons_block . '
</td>
</tr>';

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Newsletter\Renderer\Blocks;
use MailPoet\Newsletter\Renderer\StylesHelper;
class Text {
static function render($element) {
$html = $element['text'];
@ -11,7 +13,7 @@ class Text {
$html = self::addLineBreakAfterTags($html);
$template = '
<tr>
<td class="mailpoet_text mailpoet_padded" valign="top" style="word-break:break-word;word-wrap:break-word;">
<td class="mailpoet_text mailpoet_padded_bottom mailpoet_padded_side" valign="top" style="word-break:break-word;word-wrap:break-word;">
' . $html . '
</td>
</tr>';
@ -77,9 +79,9 @@ class Text {
$paragraph->cellpadding = 0;
$paragraph->html('
<tr>
<td class="mailpoet_paragraph" style="word-break:break-word;word-wrap:break-word;' . $style . '">
<td class="mailpoet_paragraph" style="line-height:' . StylesHelper::$line_height . ';word-break:break-word;word-wrap:break-word;' . $style . '">
' . $contents . '
<br /><br />
<br />
</td>
</tr>'
);
@ -97,7 +99,7 @@ class Text {
$list->class = 'mailpoet_paragraph';
} else {
$list->class = 'mailpoet_paragraph';
$list->style .= 'padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;';
$list->style .= 'line-height:' . StylesHelper::$line_height . ';padding-top:0;padding-bottom:0;margin-top:0;margin-bottom:0;';
}
}
return $DOM->__toString();
@ -109,7 +111,7 @@ class Text {
$headings = $DOM->query('h1, h2, h3, h4');
if(!$headings->count()) return $html;
foreach($headings as $heading) {
$heading->style .= 'margin:0;font-style:normal;font-weight:normal;';
$heading->style .= 'line-height:' . StylesHelper::$line_height . ';margin:0;font-style:normal;font-weight:normal;';
}
return $DOM->__toString();
}

View File

@ -10,7 +10,8 @@ class Renderer {
$template = ($columns_count === 1) ?
$this->getOneColumnTemplate($styles, $class) :
$this->getMultipleColumnsTemplate($styles, $width, $alignment, $class);
$result = array_map(function ($content) use ($template) {
$result = array_map(function($content) use ($template) {
$content = self::removePaddingFromLastElement($content);
return $template['content_start'] . $content . $template['content_end'];
}, $columns_data);
$result = implode('', $result);
@ -21,6 +22,7 @@ class Renderer {
}
function getOneColumnTemplate($styles, $class) {
$background_color = $this->getBackgroundColor($styles);
$template['content_start'] = '
<tr>
<td class="mailpoet_content" align="center" style="border-collapse:collapse">
@ -28,7 +30,7 @@ class Renderer {
<tbody>
<tr>
<td style="padding-left:0;padding-right:0">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="mailpoet_' . $class . '" style="border-spacing:0;mso-table-lspace:0;mso-table-rspace:0;table-layout:fixed;margin-left:auto;margin-right:auto;padding-left:0;padding-right:0;background-color:' . $styles['backgroundColor'] . '!important;" bgcolor="' . $styles['backgroundColor'] . '">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="mailpoet_' . $class . '" style="border-spacing:0;mso-table-lspace:0;mso-table-rspace:0;table-layout:fixed;margin-left:auto;margin-right:auto;padding-left:0;padding-right:0;' . $background_color . '">
<tbody>';
$template['content_end'] = '
</tbody>
@ -43,9 +45,10 @@ class Renderer {
}
function getMultipleColumnsTemplate($styles, $width, $alignment, $class) {
$background_color = $this->getBackgroundColor($styles);
$template['container_start'] = '
<tr>
<td class="mailpoet_content-' . $class . '" align="left" style="border-collapse:collapse;background-color:' . $styles['backgroundColor'] . '!important;" bgcolor="' . $styles['backgroundColor'] . '">
<td class="mailpoet_content-' . $class . '" align="left" style="border-collapse:collapse;' . $background_color . '">
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-spacing:0;mso-table-lspace:0;mso-table-rspace:0">
<tbody>
<tr>
@ -75,4 +78,16 @@ class Renderer {
</tr>';
return $template;
}
function removePaddingFromLastElement($element) {
return preg_replace('/mailpoet_padded_bottom(?!.*mailpoet_padded_bottom)/ism', '', $element);
}
function getBackgroundColor($styles) {
if(!isset($styles['backgroundColor'])) return false;
$background_color = $styles['backgroundColor'];
return ($background_color !== 'transparent') ?
sprintf('background-color:%s!important;" bgcolor="%s', $background_color, $background_color) :
false;
}
}

View File

@ -43,9 +43,12 @@ class Renderer {
}
function renderBody($content) {
$content = array_map(function ($content_block) {
$content = array_map(function($content_block) {
$column_count = count($content_block['blocks']);
$column_data = $this->blocks_renderer->render($content_block, $column_count);
$column_data = $this->blocks_renderer->render(
$content_block,
$column_count
);
return $this->columns_renderer->render(
$content_block['styles'],
$column_count,
@ -59,17 +62,8 @@ class Renderer {
$css = '';
foreach($styles as $selector => $style) {
switch($selector) {
case 'h1':
$selector = 'h1';
break;
case 'h2':
$selector = 'h2';
break;
case 'h3':
$selector = 'h3';
break;
case 'text':
$selector = '.mailpoet_paragraph, td.mailpoet_blockquote';
$selector = 'td.mailpoet_paragraph, td.mailpoet_blockquote';
break;
case 'body':
$selector = 'body, .mailpoet-wrapper';
@ -81,13 +75,6 @@ class Renderer {
$selector = '.mailpoet_content-wrapper';
break;
}
if(isset($style['fontSize'])) {
$css .= StylesHelper::setFontAndLineHeight(
(int) $style['fontSize'],
$selector
);
unset($style['fontSize']);
}
if(isset($style['fontFamily'])) {
$css .= StylesHelper::setFontFamily(
$style['fontFamily'],

View File

@ -1,8 +1,6 @@
<?php
namespace MailPoet\Newsletter\Renderer;
use MailPoet\Newsletter\Renderer\Columns\ColumnsHelper;
class StylesHelper {
static $css_attributes = array(
'backgroundColor' => 'background-color',
@ -29,174 +27,7 @@ class StylesHelper {
'Trebuchet MS' => "'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif",
'Verdana' => 'Verdana, Geneva, sans-serif'
);
static $font_size = array(
// font_size => array(columnCount => lineHeight);
8 => array(
1 => "20",
2 => "15",
3 => "13"
),
9 => array(
1 => "20",
2 => "16",
3 => "14"
),
10 => array(
1 => "20",
2 => "17",
3 => "15"
),
11 => array(
1 => "21",
2 => "18",
3 => "16"
),
12 => array(
1 => "22",
2 => "19",
3 => "17"
),
13 => array(
1 => "23",
2 => "20",
3 => "19"
),
14 => array(
1 => "24",
2 => "21",
3 => "20"
),
15 => array(
1 => "25",
2 => "22",
3 => "21"
),
16 => array(
1 => "26",
2 => "23",
3 => "22"
),
17 => array(
1 => "27",
2 => "24",
3 => "24"
),
18 => array(
1 => "28",
2 => "25",
3 => "25"
),
19 => array(
1 => "29",
2 => "27",
3 => "26"
),
20 => array(
1 => "30",
2 => "28",
3 => "27"
),
21 => array(
1 => "31",
2 => "29",
3 => "29"
),
22 => array(
1 => "32",
2 => "30",
3 => "30"
),
23 => array(
1 => "33",
2 => "32",
3 => "31"
),
24 => array(
1 => "34",
2 => "33",
3 => "32"
),
25 => array(
1 => "36",
2 => "34",
3 => "34"
),
26 => array(
1 => "37",
2 => "35",
3 => "35"
),
27 => array(
1 => "38",
2 => "37",
3 => "36"
),
28 => array(
1 => "39",
2 => "38",
3 => "37"
),
29 => array(
1 => "40",
2 => "39",
3 => "39"
),
30 => array(
1 => "42",
2 => "40",
3 => "40"
),
31 => array(
1 => "43",
2 => "42",
3 => "41"
),
32 => array(
1 => "44",
2 => "43",
3 => "43"
),
33 => array(
1 => "45",
2 => "44",
3 => "44"
),
34 => array(
1 => "47",
2 => "46",
3 => "45"
),
35 => array(
1 => "48",
2 => "47",
3 => "46"
),
36 => array(
1 => "49",
2 => "48",
3 => "48"
),
37 => array(
1 => "50",
2 => "49",
3 => "49"
),
38 => array(
1 => "52",
2 => "51",
3 => "50"
),
39 => array(
1 => "53",
2 => "52",
3 => "52"
),
40 => array(
1 => "54",
2 => "53",
3 => "53"
)
);
static $line_height = 1.61803398875;
static $padding_width = 20;
static function getBlockStyles($element, $ignore_specific_styles = false) {
@ -207,7 +38,7 @@ class StylesHelper {
}
static function getStyles($data, $type, $ignore_specific_styles = false) {
$styles = array_map(function ($attribute, $style) use ($ignore_specific_styles) {
$styles = array_map(function($attribute, $style) use ($ignore_specific_styles) {
if(!$ignore_specific_styles || !in_array($attribute, $ignore_specific_styles)) {
return self::translateCSSAttribute($attribute) . ': ' . $style . ' !important;';
}
@ -231,17 +62,6 @@ class StylesHelper {
return $css;
}
static function setFontAndLineHeight($font_size, $selector) {
$css = '';
foreach(ColumnsHelper::columnClasses() as $column_count => $column_class) {
$css .= '.mailpoet_content-' . $column_class . ' ' . $selector . '{' . PHP_EOL;
$css .= 'font-size:' . $font_size . 'px;' . PHP_EOL;
$css .= 'line-height:' . StylesHelper::$font_size[$font_size][$column_count] . 'px;' . PHP_EOL;
$css .= '}' . PHP_EOL;
}
return $css;
}
static function setStyle($style, $selector) {
$css = $selector . '{' . PHP_EOL;
foreach($style as $attribute => $individual_style) {
@ -250,4 +70,20 @@ class StylesHelper {
$css .= '}' . PHP_EOL;
return $css;
}
static function setTextAlign($block) {
$alignments = array(
'center',
'right',
'justify'
);
$text_alignment = isset($block['styles']['block']['textAlign']) ?
strtolower($block['styles']['block']['textAlign']) :
false;
if(!$text_alignment || !in_array($text_alignment, $alignments)) {
return $block;
}
$block['styles']['block']['textAlign'] = 'left';
return $block;
}
}

View File

@ -35,14 +35,19 @@
outline: none;
text-align: center;
}
.mailpoet_padded {
padding-left: 20px;
padding-right: 20px;
.mailpoet_padded_bottom {
padding-bottom: 20px;
}
.mailpoet_padded_header_footer {
.mailpoet_padded_side {
padding-left: 20px;
padding-right: 20px;
}
.mailpoet_header_footer_padded {
padding: 10px 20px;
}
@media screen and (max-width: 480px) and (-webkit-min-device-pixel-ratio: 1) {
.mailpoet_button {width:100% !important;}
}
@media screen and (max-width: 599px) and (-webkit-min-device-pixel-ratio: 1) {
.mailpoet_header {
padding: 10px 20px;

View File

@ -0,0 +1,130 @@
<?php
namespace MailPoet\Newsletter\Scheduler;
use Carbon\Carbon;
use MailPoet\Models\Newsletter;
use MailPoet\Models\NewsletterOption;
use MailPoet\Models\NewsletterOptionField;
use MailPoet\Models\SendingQueue;
class Scheduler {
const seconds_in_hour = 3600;
const last_weekday_format = 'L';
static function postNotification($newsletter_id) {
$newsletter = Newsletter::filter('filterWithOptions')
->findOne($newsletter_id)
->asArray();
$interval_type = $newsletter['intervalType'];
$hour = (int) $newsletter['timeOfDay'] / self::seconds_in_hour;
$week_day = $newsletter['weekDay'];
$month_day = $newsletter['monthDay'];
$nth_week_day = ($newsletter['nthWeekDay'] === self::last_weekday_format) ?
$newsletter['nthWeekDay'] :
'#' . $newsletter['nthWeekDay'];
switch($interval_type) {
case 'immediately':
$schedule = '* * * * *';
break;
case 'immediate':
case 'daily':
$schedule = sprintf('0 %s * * *', $hour);
break;
case 'weekly':
$schedule = sprintf('0 %s * * %s', $hour, $week_day);
break;
case 'monthly':
$schedule = sprintf('0 %s %s * *', $hour, $month_day);
break;
case 'nthWeekDay':
$schedule = sprintf('0 %s ? * %s%s', $hour, $week_day, $nth_week_day);
break;
}
$option_field = NewsletterOptionField::where('name', 'schedule')
->findOne()
->asArray();
$relation = NewsletterOption::where('option_field_id', $option_field['id'])
->findOne();
if(!$relation) {
$relation = NewsletterOption::create();
$relation->newsletter_id = $newsletter['id'];
$relation->option_field_id = $option_field['id'];
}
$relation->value = $schedule;
$relation->save();
}
static function welcomeForSegmentSubscription($subscriber_id, array $segments) {
$newsletters = self::getWelcomeNewsletters();
if(!count($newsletters)) return;
foreach($newsletters as $newsletter) {
if($newsletter['event'] === 'segment' &&
in_array($newsletter['segment'], $segments)
) {
self::createSendingQueueEntry($newsletter, $subscriber_id);
}
}
}
static function welcomeForNewWPUser($subscriber_id, array $wp_user, $old_user_data) {
$newsletters = self::getWelcomeNewsletters();
if(!count($newsletters)) return;
foreach($newsletters as $newsletter) {
if($newsletter['event'] === 'user') {
if($old_user_data) {
// do not schedule welcome newsletter if roles have not changed
$old_role = (array) $old_user_data->roles;
$new_role = (array) $wp_user->roles;
if($newsletter['role'] === 'mailpoet_all' ||
!array_diff($old_role, $new_role)
) {
continue;
}
}
if($newsletter['role'] === 'mailpoet_all' ||
in_array($newsletter['role'], $wp_user['roles'])
) {
self::createSendingQueueEntry($newsletter, $subscriber_id);
}
}
}
}
private static function getWelcomeNewsletters() {
return Newsletter::where('type', 'welcome')
->whereNull('deleted_at')
->filter('filterWithOptions')
->findArray();
}
private static function createSendingQueueEntry($newsletter, $subscriber_id) {
$queue = SendingQueue::create();
$queue->newsletter_id = $newsletter['id'];
$queue->subscribers = serialize(
array(
'to_process' => array($subscriber_id)
)
);
$queue->count_total = $queue->count_to_process = 1;
$after_time_type = $newsletter['afterTimeType'];
$after_time_number = $newsletter['afterTimeNumber'];
$scheduled_at = null;
$current_time = Carbon::createFromTimestamp(current_time('timestamp'));
switch($after_time_type) {
case 'hours':
$scheduled_at = $current_time->addHours($after_time_number);
break;
case 'days':
$scheduled_at = $current_time->addDays($after_time_number);
break;
case 'weeks':
$scheduled_at = $current_time->addWeeks($after_time_number);
break;
default:
$scheduled_at = $current_time;
}
$queue->status = 'scheduled';
$queue->scheduled_at = $scheduled_at;
$queue->save();
}
}

View File

@ -1,30 +0,0 @@
<?php
namespace MailPoet\Newsletter\Shortcodes\Categories;
require_once(ABSPATH . 'wp-includes/pluggable.php');
class Link {
/*
{
text: '<%= __('Unsubscribe link') %>',
shortcode: 'global:unsubscribe',
},
{
text: '<%= __('Edit subscription page link') %>',
shortcode: 'global:manage',
},
{
text: '<%= __('View in browser link') %>',
shortcode: 'global:browser',
}
*/
static function process($action) {
// TODO: implement
$actions = array(
'unsubscribe' => '',
'manage' => '',
'browser' => ''
);
return (isset($actions[$action])) ? $actions[$action] : false;
}
}

View File

@ -1,6 +1,8 @@
<?php
namespace MailPoet\Newsletter\Shortcodes\Categories;
use MailPoet\Models\SendingQueue;
class Newsletter {
/*
{
@ -18,26 +20,54 @@ class Newsletter {
{
text: '<%= __('Issue number') %>',
shortcode: 'newsletter:number',
},
{
text: '<%= __('Issue number') %>',
shortcode: 'newsletter:number',
},
{
text: '<%= __('View in browser link') %>',
shortcode: 'newsletter:view_in_browser',
}
*/
static function process($action, $default_value = false, $newsletter) {
static function process($action,
$default_value = false,
$newsletter, $subscriber = false, $text) {
if(is_object($newsletter)) {
$newsletter = $newsletter->asArray();
}
switch($action) {
case 'subject':
return ($newsletter) ? $newsletter['subject'] : false;
break;
case 'total':
$posts = wp_count_posts();
return $posts->publish;
return substr_count($text, 'data-post-id');
break;
case 'post_title':
$post = wp_get_recent_posts(array('numberposts' => 1));
return (isset($post[0])) ? $post[0]['post_title'] : false;
break;
case 'number':
// TODO: implement
return;
if ($newsletter['type'] !== 'notification') return false;
$sent_newsletters = (int)
SendingQueue::where('newsletter_id', $newsletter['id'])->count();
return ++$sent_newsletters;
break;
case 'view_in_browser':
return '<a href="#TODO">'.__('View in your browser').'</a>';
break;
case 'view_in_browser_url':
return '#TODO';
break;
default:
return false;
break;
}
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace MailPoet\Newsletter\Shortcodes\Categories;
use MailPoet\Subscription\Url as SubscriptionUrl;
class Subscription {
/*
{
text: '<%= __('Unsubscribe') %>',-
shortcode: 'subscription:unsubscribe',
},
{
text: '<%= __('Manage subscriptions') %>',
shortcode: 'subscription:manage',
},
*/
static function process(
$action,
$default_value = false,
$newsletter = false,
$subscriber = false
) {
switch($action) {
case 'unsubscribe':
return '<a target="_blank" href="'.
esc_attr(SubscriptionUrl::getUnsubscribeUrl($subscriber))
.'">'.__('Unsubscribe').'</a>';
break;
case 'unsubscribe_url':
return SubscriptionUrl::getUnsubscribeUrl($subscriber);
break;
case 'manage':
return '<a target="_blank" href="'.
esc_attr(SubscriptionUrl::getManageUrl($subscriber))
.'">'.__('Manage subscription').'</a>';
break;
case 'manage_url':
return SubscriptionUrl::getManageUrl($subscriber);
break;
default:
return false;
break;
}
}
}

View File

@ -35,20 +35,31 @@ class User {
switch($action) {
case 'firstname':
return ($subscriber) ? $subscriber['first_name'] : $default_value;
break;
case 'lastname':
return ($subscriber) ? $subscriber['last_name'] : $default_value;
break;
case 'email':
return ($subscriber) ? $subscriber['email'] : false;
break;
case 'displayname':
if($subscriber && $subscriber['wp_user_id']) {
$wp_user = get_userdata($subscriber['wp_user_id']);
return $wp_user->user_login;
};
}
return $default_value;
break;
case 'count':
return Subscriber::count();
return Subscriber::filter('subscribed')->count();
break;
default:
return false;
break;
}
}
}

View File

@ -2,29 +2,25 @@
namespace MailPoet\Newsletter\Shortcodes;
class Shortcodes {
public $rendered_newsletter;
public $newsletter;
public $subscriber;
function __construct(
$rendered_newsletter,
$newsletter = false,
$subscriber = false) {
$this->rendered_newsletter = $rendered_newsletter;
$subscriber = false
) {
$this->newsletter = $newsletter;
$this->subscriber = $subscriber;
}
function extract() {
preg_match_all('/\[(?:\w+):.*?\]/', $this->rendered_newsletter, $shortcodes);
function extract($text) {
preg_match_all('/\[(?:\w+):.*?\]/', $text, $shortcodes);
return array_unique($shortcodes[0]);
}
function process($shortcodes) {
function process($shortcodes, $text) {
$processed_shortcodes = array_map(
function ($shortcode) {
// TODO: discuss renaming "global". It is a reserved name in PHP.
if($shortcode === 'global') $shortcode = 'link';
function($shortcode) use($text) {
preg_match(
'/\[(?P<type>\w+):(?P<action>\w+)(?:.*?default:(?P<default>.*?))?\]/',
$shortcode,
@ -32,22 +28,25 @@ class Shortcodes {
);
$shortcode_class =
__NAMESPACE__ . '\\Categories\\' . ucfirst($shortcode_details['type']);
$shortcode_action = $shortcode_details['action'];
$shortcode_default_value = isset($shortcode_details['default'])
? $shortcode_details['default'] : false;
if(!class_exists($shortcode_class)) return false;
return $shortcode_class::process(
$shortcode_details['action'],
isset($shortcode_details['default'])
? $shortcode_details['default'] : false,
$shortcode_action,
$shortcode_default_value,
$this->newsletter,
$this->subscriber
$this->subscriber,
$text
);
}, $shortcodes);
return array_filter($processed_shortcodes);
return $processed_shortcodes;
}
function replace() {
$shortcodes = $this->extract($this->rendered_newsletter);
$processed_shortcodes = $this->process($shortcodes);
function replace($text) {
$shortcodes = $this->extract($text);
$processed_shortcodes = $this->process($shortcodes, $text);
$shortcodes = array_intersect_key($shortcodes, $processed_shortcodes);
return str_replace($shortcodes, $processed_shortcodes, $this->rendered_newsletter);
return str_replace($shortcodes, $processed_shortcodes, $text);
}
}

View File

@ -1,7 +1,6 @@
<?php
namespace MailPoet\Router;
use Carbon\Carbon;
use MailPoet\Cron\CronHelper;
use MailPoet\Cron\Supervisor;
use MailPoet\Models\Setting;
@ -30,26 +29,8 @@ class Cron {
function getStatus() {
$daemon = Setting::where('name', 'cron_daemon')
->findOne();
return (
($daemon) ?
array_merge(
array(
'timeSinceStart' =>
Carbon::createFromFormat(
'Y-m-d H:i:s',
$daemon->created_at,
'UTC'
)->diffForHumans(),
'timeSinceUpdate' =>
Carbon::createFromFormat(
'Y-m-d H:i:s',
$daemon->updated_at,
'UTC'
)->diffForHumans()
),
unserialize($daemon->value)
) :
"false"
);
return ($daemon) ?
unserialize($daemon->value) :
false;
}
}

Some files were not shown because too many files have changed in this diff Show More