Add space between if and ‘(‘

[MAILPOET-1791]
This commit is contained in:
Ján Mikláš
2019-02-13 13:08:49 +01:00
committed by M. Shull
parent a935b091d3
commit 3ee58aea10
333 changed files with 4001 additions and 4001 deletions

View File

@@ -46,7 +46,7 @@ class DefaultSubscribersGetter extends SubscribersGetter {
)
->groupBy(Segment::$_table . '.id');
if($this->get_subscribers_without_segment !== false) {
if ($this->get_subscribers_without_segment !== false) {
// if there are subscribers who do not belong to any segment, use
// a CASE function to group them under "Not In Segment"
$subscribers = $subscribers
@@ -76,4 +76,4 @@ class DefaultSubscribersGetter extends SubscribersGetter {
return $subscribers;
}
}
}

View File

@@ -17,7 +17,7 @@ class DynamicSubscribersGetter extends SubscribersGetter {
function __construct($segments_ids, $batch_size, WPFunctions $wp = null) {
parent::__construct($segments_ids, $batch_size);
if($wp == null) {
if ($wp == null) {
$wp = new WPFunctions;
}
$this->wp = $wp;
@@ -36,7 +36,7 @@ class DynamicSubscribersGetter extends SubscribersGetter {
$segment_id
);
if(!is_array($filters) || empty($filters)) {
if (!is_array($filters) || empty($filters)) {
return array();
}
@@ -57,13 +57,13 @@ class DynamicSubscribersGetter extends SubscribersGetter {
}
public function get() {
if($this->segment_index >= count($this->segments_ids)) {
if ($this->segment_index >= count($this->segments_ids)) {
$this->finished = true;
}
$subscribers = parent::get();
if($subscribers !== false && count($subscribers) < $this->batch_size) {
if ($subscribers !== false && count($subscribers) < $this->batch_size) {
$this->segment_index ++;
$this->offset = 0;
$this->finished = false;

View File

@@ -23,7 +23,7 @@ class Export {
public $dynamic_subscribers_getter;
public function __construct($data) {
if(strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
if (strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
set_time_limit(0);
}
@@ -52,10 +52,10 @@ class Export {
function process() {
$this->default_subscribers_getter->reset();
try {
if(is_writable($this->export_path) === false) {
if (is_writable($this->export_path) === false) {
throw new \Exception(__('The export file could not be saved on the server.', 'mailpoet'));
}
if(!extension_loaded('zip')) {
if (!extension_loaded('zip')) {
throw new \Exception(__('Export requires a ZIP extension to be installed on the host.', 'mailpoet'));
}
$processed_subscribers = call_user_func(
@@ -129,7 +129,7 @@ class Export {
// sorted by segment name (due to slow queries when using ORDER BY and LIMIT),
// we need to keep track of processed segments so that we do not create header
// multiple times when switching from one segment to another and back.
if((!count($processed_segments) || $last_segment !== $current_segment) &&
if ((!count($processed_segments) || $last_segment !== $current_segment) &&
(!in_array($last_segment, $processed_segments) || !in_array($current_segment, $processed_segments))
) {
$this->writeXLSX(
@@ -142,7 +142,7 @@ class Export {
$last_segment = ucwords($subscriber['segment_name']);
// detect RTL language and set Excel to properly display the sheet
$RTL_regex = '/\p{Arabic}|\p{Hebrew}/u';
if(!$XLSX_writer->rtl && (
if (!$XLSX_writer->rtl && (
preg_grep($RTL_regex, $subscriber) ||
preg_grep($RTL_regex, $this->formatted_subscriber_fields))
) {
@@ -166,7 +166,7 @@ class Export {
function getSubscribers() {
$subscribers = $this->default_subscribers_getter->get();
if($subscribers === false) {
if ($subscribers === false) {
$subscribers = $this->dynamic_subscribers_getter->get();
}
return $subscribers;

View File

@@ -27,7 +27,7 @@ abstract class SubscribersGetter {
/**
* Initialize the query by selecting fields and ignoring trashed subscribers.
*
*
* @return \ORM
*/
protected function select() {
@@ -47,7 +47,7 @@ abstract class SubscribersGetter {
/**
* Filters the subscribers query based on the segments, offset and batch size.
*
*
* @param \ORM $subscribers
* @return array
*/
@@ -57,7 +57,7 @@ abstract class SubscribersGetter {
* Gets the next batch of subscribers or `false` if no more!
*/
public function get() {
if($this->finished) {
if ($this->finished) {
return false;
}
@@ -66,10 +66,10 @@ abstract class SubscribersGetter {
$this->offset += $this->batch_size;
if(count($subscribers) < $this->batch_size) {
if (count($subscribers) < $this->batch_size) {
$this->finished = true;
}
return $subscribers;
}
}
}

View File

@@ -65,7 +65,7 @@ class Import {
);
// 1. data should contain all required fields
// 2. column names should only contain alphanumeric & underscore characters
if(count(array_intersect_key(array_flip($required_data_fields), $data)) !== count($required_data_fields) ||
if (count(array_intersect_key(array_flip($required_data_fields), $data)) !== count($required_data_fields) ||
preg_grep('/[^a-zA-Z0-9_]/', array_keys($data['columns']))
) {
throw new \Exception(__('Missing or invalid import data.', 'mailpoet'));
@@ -88,7 +88,7 @@ class Import {
$this->subscribers_data,
$this->subscribers_fields_validation_rules
);
if(!$subscribers_data) {
if (!$subscribers_data) {
throw new \Exception(__('No valid subscribers were found.', 'mailpoet'));
}
// permanently trash deleted subscribers
@@ -106,7 +106,7 @@ class Import {
// create or update subscribers
$created_subscribers = $updated_subscribers = array();
try {
if($new_subscribers['data']) {
if ($new_subscribers['data']) {
// add, if required, missing required fields to new subscribers
$new_subscribers = $this->addMissingRequiredFields($new_subscribers);
$new_subscribers = $this->setSubscriptionStatusToSubscribed($new_subscribers);
@@ -118,14 +118,14 @@ class Import {
$this->subscribers_custom_fields
);
}
if($existing_subscribers['data'] && $this->update_subscribers) {
if ($existing_subscribers['data'] && $this->update_subscribers) {
$updated_subscribers =
$this->createOrUpdateSubscribers(
'update',
$existing_subscribers,
$this->subscribers_custom_fields
);
if($wp_users) {
if ($wp_users) {
$this->synchronizeWPUsers($wp_users);
}
}
@@ -155,10 +155,10 @@ class Import {
$validator = new ModelValidator();
foreach ($subscribers_data as $column => &$data) {
$validation_rule = $validation_rules[$column];
if($validation_rule === 'email') {
if ($validation_rule === 'email') {
$data = array_map(
function($index, $email) use(&$invalid_records, $validator) {
if(!$validator->validateEmail($email)) {
if (!$validator->validateEmail($email)) {
$invalid_records[] = $index;
}
return strtolower($email);
@@ -166,15 +166,15 @@ class Import {
);
}
// if this is a custom column
if(in_array($column, $this->subscribers_custom_fields)) {
if (in_array($column, $this->subscribers_custom_fields)) {
$custom_field = CustomField::findOne($column);
// validate date type
if($custom_field->type === 'date') {
if ($custom_field->type === 'date') {
$data = array_map(
function($index, $date) use($validation_rule, &$invalid_records) {
if (empty($date)) return $date;
$date = Date::convertDateToDatetime($date, $validation_rule);
if(!$date) {
if (!$date) {
$invalid_records[] = $index;
}
return $date;
@@ -183,13 +183,13 @@ class Import {
}
}
}
if($invalid_records) {
if ($invalid_records) {
foreach ($subscribers_data as $column => &$data) {
$data = array_diff_key($data, array_flip($invalid_records));
$data = array_values($data);
}
}
if(empty($subscribers_data['email'])) return false;
if (empty($subscribers_data['email'])) return false;
return $subscribers_data;
}
@@ -217,7 +217,7 @@ class Import {
->findArray()
);
}
if(!$temp_existing_subscribers) {
if (!$temp_existing_subscribers) {
return array(
false, // existing subscribers
$subscribers_data, // new subscribers
@@ -258,7 +258,7 @@ class Import {
->findArray();
}, array_chunk($subscribers_data['email'], self::DB_QUERY_CHUNK_SIZE))
);
if(!$existing_trashed_records) return;
if (!$existing_trashed_records) return;
$existing_trashed_records = Helpers::flattenArray($existing_trashed_records);
foreach (array_chunk($existing_trashed_records, self::DB_QUERY_CHUNK_SIZE) as
$subscriber_ids) {
@@ -272,7 +272,7 @@ class Import {
function addMissingRequiredFields($subscribers) {
$subscribers_count = count($subscribers['data'][key($subscribers['data'])]);
foreach (array_keys($this->required_subscribers_fields) as $required_field) {
if(in_array($required_field, $subscribers['fields'])) continue;
if (in_array($required_field, $subscribers['fields'])) continue;
$subscribers['data'][$required_field] = array_fill(
0,
$subscribers_count,
@@ -284,7 +284,7 @@ class Import {
}
function setSubscriptionStatusToSubscribed($subscribers_data) {
if(!in_array('status', $subscribers_data['fields'])) return $subscribers_data;
if (!in_array('status', $subscribers_data['fields'])) return $subscribers_data;
$subscribers_data['data']['status'] = array_map(function() {
return Subscriber::STATUS_SUBSCRIBED;
}, $subscribers_data['data']['status']);
@@ -306,7 +306,7 @@ class Import {
return array_values(
array_filter(
array_map(function($field) {
if(!is_int($field)) return $field;
if (!is_int($field)) return $field;
}, $subscribers_fields)
)
);
@@ -316,7 +316,7 @@ class Import {
return array_values(
array_filter(
array_map(function($field) {
if(is_int($field)) return $field;
if (is_int($field)) return $field;
}, $subscribers_fields)
)
);
@@ -334,13 +334,13 @@ class Import {
}, $subscribers_data['fields']);
}, range(0, $subscribers_count - 1));
foreach (array_chunk($subscribers, self::DB_QUERY_CHUNK_SIZE) as $data) {
if($action == 'create') {
if ($action == 'create') {
Subscriber::createMultiple(
$subscribers_data['fields'],
$data
);
}
if($action == 'update') {
if ($action == 'update') {
Subscriber::updateMultiple(
$subscribers_data['fields'],
$data,
@@ -355,9 +355,9 @@ class Import {
Subscriber::selectMany(array('id', 'email'))->whereIn('email', $data)->findArray()
);
}
if(empty($created_or_updated_subscribers)) return null;
if (empty($created_or_updated_subscribers)) return null;
$created_or_updated_subscribers_ids = array_column($created_or_updated_subscribers, 'id');
if($subscribers_custom_fields) {
if ($subscribers_custom_fields) {
$this->createOrUpdateCustomFields(
$action,
$created_or_updated_subscribers,
@@ -384,7 +384,7 @@ class Import {
->select('id')
->findArray()
);
if(!$subscribers_custom_fields_ids) return;
if (!$subscribers_custom_fields_ids) return;
// assemble a two-dimensional array: [[custom_field_id, subscriber_id, value], [custom_field_id, subscriber_id, value], ...]
$subscribers_custom_fields_data = array();
$subscribers_emails = array_flip($subscribers_data['data']['email']);
@@ -392,7 +392,7 @@ class Import {
$subscriber_index = $subscribers_emails[$created_or_updated_subscriber['email']];
foreach ($subscribers_data['data'] as $field => $values) {
// exclude non-custom fields
if(!is_int($field)) continue;
if (!is_int($field)) continue;
$subscribers_custom_fields_data[] = array(
(int)$field,
$created_or_updated_subscriber['id'],
@@ -404,7 +404,7 @@ class Import {
SubscriberCustomField::createMultiple(
$subscribers_custom_fields_data_chunk
);
if($action === 'update') {
if ($action === 'update') {
SubscriberCustomField::updateMultiple(
$subscribers_custom_fields_data_chunk
);

View File

@@ -20,19 +20,19 @@ class MailChimp {
}
function getLists() {
if(!$this->api_key || !$this->data_center) {
if (!$this->api_key || !$this->data_center) {
return $this->throwException('API');
}
$connection = @fopen(sprintf($this->lists_url, $this->data_center, $this->api_key), 'r');
if(!$connection) {
if (!$connection) {
return $this->throwException('connection');
} else {
$response = '';
while (!feof($connection)) {
$buffer = fgets($connection, 4096);
if(trim($buffer) !== '') {
if (trim($buffer) !== '') {
$response .= $buffer;
}
}
@@ -41,7 +41,7 @@ class MailChimp {
$response = json_decode($response);
if(!$response) {
if (!$response) {
return $this->throwException('API');
}
@@ -57,11 +57,11 @@ class MailChimp {
}
function getSubscribers($lists = array()) {
if(!$this->api_key || !$this->data_center) {
if (!$this->api_key || !$this->data_center) {
return $this->throwException('API');
}
if(!$lists) {
if (!$lists) {
return $this->throwException('lists');
}
@@ -71,20 +71,20 @@ class MailChimp {
foreach ($lists as $list) {
$url = sprintf($this->export_url, $this->data_center, $this->api_key, $list);
$connection = @fopen($url, 'r');
if(!$connection) {
if (!$connection) {
return $this->throwException('connection');
}
$i = 0;
while (!feof($connection)) {
$buffer = fgets($connection, 4096);
if(trim($buffer) !== '') {
if (trim($buffer) !== '') {
$obj = json_decode($buffer);
if($i === 0) {
if ($i === 0) {
$header = $obj;
if(is_object($header) && isset($header->error)) {
if (is_object($header) && isset($header->error)) {
return $this->throwException('lists');
}
if(!isset($header_hash)) {
if (!isset($header_hash)) {
$header_hash = md5(implode(',', $header));
} elseif (md5(implode(',', $header) !== $header_hash)) {
return $this->throwException('headers');
@@ -95,14 +95,14 @@ class MailChimp {
$i++;
}
$bytes_fetched += strlen($buffer);
if($bytes_fetched > $this->max_post_size) {
if ($bytes_fetched > $this->max_post_size) {
return $this->throwException('size');
}
}
fclose($connection);
}
if(!count($subscribers)) {
if (!count($subscribers)) {
return $this->throwException('subscribers');
}
@@ -116,7 +116,7 @@ class MailChimp {
}
function getDataCenter($api_key) {
if(!$api_key) return false;
if (!$api_key) return false;
$api_key_parts = explode('-', $api_key);
return end($api_key_parts);
}

View File

@@ -8,7 +8,7 @@ use MailPoet\Util\Helpers;
use MailPoet\WP\Functions as WPFunctions;
class ImportExportFactory {
const IMPORT_ACTION = 'import';
const IMPORT_ACTION = 'import';
const EXPORT_ACTION = 'export';
public $action;
@@ -21,7 +21,7 @@ class ImportExportFactory {
}
function getSegments() {
if($this->action === self::IMPORT_ACTION) {
if ($this->action === self::IMPORT_ACTION) {
$segments = Segment::getSegmentsForImport();
} else {
$segments = Segment::getSegmentsForExport();
@@ -32,8 +32,8 @@ class ImportExportFactory {
}
return array_map(function($segment) {
if(!$segment['name']) $segment['name'] = __('Not In List', 'mailpoet');
if(!$segment['id']) $segment['id'] = 0;
if (!$segment['name']) $segment['name'] = __('Not In List', 'mailpoet');
if (!$segment['id']) $segment['id'] = 0;
return array(
'id' => $segment['id'],
'name' => $segment['name'],
@@ -48,7 +48,7 @@ class ImportExportFactory {
'first_name' => __('First name', 'mailpoet'),
'last_name' => __('Last name', 'mailpoet')
);
if($this->action === 'export') {
if ($this->action === 'export') {
$fields = array_merge(
$fields,
array(
@@ -122,7 +122,7 @@ class ImportExportFactory {
'children' => $this->formatSubscriberFields($subscriber_fields)
)
);
if($subscriber_custom_fields) {
if ($subscriber_custom_fields) {
array_push($select2Fields, array(
'name' => __('User fields', 'mailpoet'),
'children' => $this->formatSubscriberCustomFields(
@@ -143,7 +143,7 @@ class ImportExportFactory {
$subscriber_custom_fields
)
);
if($this->action === 'import') {
if ($this->action === 'import') {
$data['subscriberFields'] = json_encode(
array_merge(
$this->formatSubscriberFields($subscriber_fields),

View File

@@ -18,7 +18,7 @@ class NewsletterClicksExporter {
}
private function exportSubscriber($subscriber, $page) {
if(!$subscriber) return array();
if (!$subscriber) return array();
$result = array();

View File

@@ -20,7 +20,7 @@ class NewslettersExporter {
}
private function exportSubscriber($subscriber, $page) {
if(!$subscriber) return array();
if (!$subscriber) return array();
$result = array();
@@ -48,7 +48,7 @@ class NewslettersExporter {
'name' => __('Sent at', 'mailpoet'),
'value' => $statistics_row['sent_at'],
);
if(isset($statistics_row['opened_at'])) {
if (isset($statistics_row['opened_at'])) {
$newsletter_data[] = array(
'name' => __('Opened', 'mailpoet'),
'value' => 'Yes',
@@ -63,7 +63,7 @@ class NewslettersExporter {
'value' => __('No', 'mailpoet'),
);
}
if(isset($newsletters[$statistics_row['newsletter_id']])) {
if (isset($newsletters[$statistics_row['newsletter_id']])) {
$newsletter_data[] = array(
'name' => __('Email preview', 'mailpoet'),
'value' => Url::getViewInBrowserUrl(
@@ -88,7 +88,7 @@ class NewslettersExporter {
return $statistics_row['newsletter_id'];
}, $statistics);
if(empty($newsletter_ids)) return array();
if (empty($newsletter_ids)) return array();
$newsletters = Newsletter::whereIn('id', $newsletter_ids)->findMany();

View File

@@ -14,7 +14,7 @@ class SegmentsExporter {
}
private function exportSubscriber($subscriber) {
if(!$subscriber) return array();
if (!$subscriber) return array();
$result = array();
$segments = $subscriber->getAllSegmentNamesWithStatus();

View File

@@ -16,7 +16,7 @@ class SubscriberExporter {
}
private function exportSubscriber($subscriber) {
if(!$subscriber) return array();
if (!$subscriber) return array();
return array(array(
'group_id' => 'mailpoet-subscriber',
'group_label' => __('MailPoet Subscriber Data', 'mailpoet'),
@@ -45,13 +45,13 @@ class SubscriberExporter {
'value' => $subscriber->status,
),
);
if($subscriber->subscribed_ip) {
if ($subscriber->subscribed_ip) {
$result[] = array(
'name' => __('Subscribed IP', 'mailpoet'),
'value' => $subscriber->subscribed_ip,
);
}
if($subscriber->confirmed_ip) {
if ($subscriber->confirmed_ip) {
$result[] = array(
'name' => __('Confirmed IP', 'mailpoet'),
'value' => $subscriber->confirmed_ip,
@@ -64,7 +64,7 @@ class SubscriberExporter {
foreach ($custom_fields as $custom_field_id => $custom_field_name) {
$custom_field_value = $subscriber->{$custom_field_id};
if($custom_field_value) {
if ($custom_field_value) {
$result[] = array(
'name' => $custom_field_name,
'value' => $custom_field_value,