- Updates all datetime references to use WordPress format

- Removes depreciated datetime conversion method from Helpers
- Fixes translation & error display issue in import
Closes #432
This commit is contained in:
Vlad
2016-05-11 10:53:52 -04:00
parent a1d8dec047
commit bc92d9a61e
10 changed files with 33 additions and 85 deletions

View File

@@ -141,7 +141,7 @@ const FormList = React.createClass({
{ segments }
</td>
<td className="column-date" data-colname={MailPoet.I18n.t('createdOn')}>
<abbr>{ MailPoet.Date.full(form.created_at) }</abbr>
<abbr>{ MailPoet.Date.format(form.created_at) }</abbr>
</td>
</div>
);

View File

@@ -148,7 +148,7 @@ define(
} else {
if (item.queue.status === 'scheduled') {
return (
<span>{MailPoet.I18n.t('scheduledFor')} { item.queue.scheduled_at } </span>
<span>{MailPoet.I18n.t('scheduledFor')} { MailPoet.Date.format(item.queue.scheduled_at) } </span>
)
}
var progressClasses = classNames(
@@ -273,10 +273,10 @@ define(
</td>
{ statistics_column }
<td className="column-date" data-colname="Subscribed on">
<abbr>{ MailPoet.Date.full(newsletter.created_at) }</abbr>
<abbr>{ MailPoet.Date.format(newsletter.created_at) }</abbr>
</td>
<td className="column-date" data-colname="Last modified on">
<abbr>{ MailPoet.Date.full(newsletter.updated_at) }</abbr>
<abbr>{ MailPoet.Date.format(newsletter.updated_at) }</abbr>
</td>
</div>
);

View File

@@ -191,7 +191,7 @@ const SegmentList = React.createClass({
<abbr>{ parseInt(unsubscribed).toLocaleString() }</abbr>
</td>
<td className="column-date" data-colname="Created on">
<abbr>{ MailPoet.Date.full(segment.created_at) }</abbr>
<abbr>{ MailPoet.Date.format(segment.created_at) }</abbr>
</td>
</div>
);

View File

@@ -976,7 +976,7 @@ define(
data[matchedColumn] +=
'<span class="mailpoet_data_match" title="'
+ MailPoet.I18n.t('verifyDateMatch') + '">'
+ date + '</span>';
+ MailPoet.Date.format(date) + '</span>';
}
else {
data[matchedColumn] +=

View File

@@ -341,10 +341,10 @@ const SubscriberList = React.createClass({
{ segments }
</td>
<td className="column-date" data-colname={MailPoet.I18n.t('subscribedOn')}>
<abbr>{ MailPoet.Date.full(subscriber.created_at) }</abbr>
<abbr>{ MailPoet.Date.format(subscriber.created_at) }</abbr>
</td>
<td className="column-date" data-colname={MailPoet.I18n.t('lastModifiedOn')}>
<abbr>{ MailPoet.Date.full(subscriber.updated_at) }</abbr>
<abbr>{ MailPoet.Date.format(subscriber.updated_at) }</abbr>
</td>
</div>
);

View File

@@ -42,10 +42,20 @@ class Functions extends \Twig_Extension {
'get_option',
array('is_safe' => array('all'))
),
new \Twig_SimpleFunction(
'get_option',
'get_option',
array('is_safe' => array('all'))
),
new \Twig_SimpleFunction(
'sending_frequency',
array($this, 'getSendingFrequency'),
array('is_safe' => array('all'))
),
new \Twig_SimpleFunction(
'wp_datetime_format',
array($this, 'getWPDateTimeFormat'),
array('is_safe' => array('all'))
)
);
}
@@ -86,6 +96,16 @@ class Functions extends \Twig_Extension {
}
}
function getWPDateTimeFormat() {
$date_format = (get_option('date_format')) ?
get_option('date_format') :
'F j, Y';
$time_format = (get_option('time_format')) ?
get_option('time_format') :
'g:i a';
return sprintf('%s %s', $date_format, $time_format);
}
function params($key = null) {
$args = stripslashes_deep($_GET);
if(array_key_exists($key, $args)) {

View File

@@ -2,77 +2,6 @@
namespace MailPoet\Util;
class Helpers {
/*
* Matches each symbol of PHP date format standard
* with jQuery equivalent codeword
* @author Tristan Jahier
*/
static function dateformat_PHP_to_jQueryUI($php_format) {
$SYMBOLS_MATCHING = array(
// Day
'd' => 'dd',
'D' => 'D',
'j' => 'd',
'l' => 'DD',
'N' => '',
'S' => '',
'w' => '',
'z' => 'o',
// Week
'W' => '',
// Month
'F' => 'MM',
'm' => 'mm',
'M' => 'M',
'n' => 'm',
't' => '',
// Year
'L' => '',
'o' => '',
'Y' => 'yy',
'y' => 'y',
// Time
'a' => '',
'A' => '',
'B' => '',
'g' => '',
'G' => '',
'h' => '',
'H' => '',
'i' => '',
's' => '',
'u' => ''
);
$jqueryui_format = "";
$escaping = false;
for ($i = 0; $i < strlen($php_format); $i++) {
$char = $php_format[$i];
if($char === '\\') // PHP date format escaping character
{
$i++;
if($escaping) {
$jqueryui_format .= $php_format[$i];
} else {
$jqueryui_format .= '\'' . $php_format[$i];
}
$escaping = true;
} else {
if($escaping) {
$jqueryui_format .= "'";
$escaping = false;
}
if(isset($SYMBOLS_MATCHING[$char])) {
$jqueryui_format .= $SYMBOLS_MATCHING[$char];
} else {
$jqueryui_format .= $char;
}
}
}
return $jqueryui_format;
}
static function getMaxPostSize($bytes = false) {
$maxPostSize = ini_get('post_max_size');
if(!$bytes) return $maxPostSize;

View File

@@ -40,7 +40,7 @@
)%>
<script type="text/javascript">
var mailpoet_date_format = "<%= get_option('date_format') %>";
var mailpoet_date_format = "<%= wp_datetime_format() %>";
</script>
<script>

View File

@@ -1,8 +1,7 @@
<% extends 'layout.html' %>
<% block content %>
<% set csvDescription = __('This needs to be in CSV style. See [link]examples in our support site[/link].') %>
<% set csvKBLink = '<a target="_blank" href="http://support.mailpoet.com/knowledgebase/importing-subscribers-with-a-csv-file?utm_source=wpadmin&utm_campaign=import">' %>
<% extends 'layout.html' %>
<% block content %>
<div id="mailpoet_subscribers_import" class="wrap">
<h1 class="title">
<%= __('Import') %>

View File

@@ -126,7 +126,7 @@
</td>
{{#.}}
<td>
{{this}}
{{{this}}}
</td>
{{/.}}
</tr>