- Updates Migrator with new column for Segments

- Updates Segmnets tests
- Updates MailPoet's Notice.js with additional options
- Updates Import's router, WP menu bootstrap logic, client- and
  server-side logic
This commit is contained in:
MrCasual
2015-11-01 20:00:23 -05:00
parent ff5353c894
commit ad0adb48e1
12 changed files with 1464 additions and 258 deletions

View File

@@ -0,0 +1,106 @@
<?php namespace MailPoet\Import;
use MailPoet\Models\CustomField;
use MailPoet\Models\Segment;
use MailPoet\Util\Helpers;
class BootstrapMenu {
function __construct() {
$this->subscriberFields = $this->getSubscriberFields();
$this->subscriberCustomFields = $this->getSubscriberCustomFields();
$this->segments = $this->getSegments();
}
function getSubscriberFields() {
return array(
'subscriber_email' => __("Email"),
'subscriber_firstname' => __("First name"),
'subscriber_lastname' => __("Last name"),
/* 'subscriber_confirmed_ip' => __("IP address"),
'subscriber_confirmed_at' => __("Subscription date"),*/
'subscriber_state' => __("Status")
);
}
function getSegments() {
return Segment::findArray();
}
function getSubscriberCustomFields() {
return CustomField::findArray();
}
function formatSubscriberFields() {
return array_map(function ($fieldId, $fieldName) {
return array(
'id' => $fieldId,
'name' => $fieldName,
'type' => ($fieldId === 'subscriber_confirmed_at') ? 'date' : null,
'custom' => false
);
}, array_keys($this->subscriberFields), $this->subscriberFields);
}
function formatSubscriberCustomFields() {
return array_map(function ($field) {
return array(
'id' => $field['id'],
'name' => $field['name'],
'label' => $field['name'],
'type' => $field['type'],
'custom' => true
);
}, $this->subscriberCustomFields);
}
function formatSubscriberFieldsSelect2() {
$select2Fields = array(
array(
'name' => __("Actions"),
'children' => array(
array(
'id' => 'ignore',
'name' => __("Ignore column..."),
),
array(
'id' => 'create',
'name' => __("Create new column...")
),
)
),
array(
'name' => __("System columns"),
'children' => $this->formatSubscriberFields()
)
);
if($this->subscriberCustomFields) {
array_push($select2Fields, array(
'name' => __("User columns"),
'children' => $this->formatSubscriberCustomFields()
));
}
return $select2Fields;
}
function bootstrap() {
$data['segments'] = array_map(function ($segment) {
return array(
'id' => $segment['id'],
'name' => $segment['name'],
);
}, $this->getSegments());
$data['subscriberFields'] = array_merge(
$this->formatSubscriberFields(),
$this->formatSubscriberCustomFields()
);
$data['subscriberFieldsSelect2'] = $this->formatSubscriberFieldsSelect2();
$data = array_map('json_encode', $data);
$data['maxPostSizeBytes'] = Helpers::getMaxPostSize('bytes');
$data['maxPostSize'] = Helpers::getMaxPostSize();
return $data;
}
}