Removing view logic and adding translation

This commit is contained in:
Christopher Pitt 2015-04-01 13:25:54 +13:00
parent 947f65241f
commit 9e6e5b0d25
2 changed files with 10 additions and 7 deletions

View File

@ -371,7 +371,8 @@ class BlogPost extends Page {
foreach($authors as $author) { foreach($authors as $author) {
$item = new ArrayData(array( $item = new ArrayData(array(
'Name' => $author->Name, 'Name' => $author->Name,
'Join' => '', 'IsAndJoin' => false,
'IsCommaJoin' => false,
'URL' => '', 'URL' => '',
)); ));
@ -398,7 +399,8 @@ class BlogPost extends Page {
foreach($authors as $author) { foreach($authors as $author) {
$item = new ArrayData(array( $item = new ArrayData(array(
'Name' => $author, 'Name' => $author,
'Join' => '', 'IsAndJoin' => false,
'IsCommaJoin' => false,
'URL' => '' 'URL' => ''
)); ));
@ -419,17 +421,18 @@ class BlogPost extends Page {
$count = count($items); $count = count($items);
for($i = 0; $i < $count; $i++) { for($i = 0; $i < $count; $i++) {
if($count === 2 && $i > 0) { if($count === 2 && $i === 1) {
$items[$i]->Join = ' and '; $items[$i]->IsAndJoin = true;
} }
if($count > 2) { if($count > 2) {
if($i > 0) { if($i > 0) {
$items[$i]->Join = ', '; $items[$i]->IsCommaJoin = true;
} }
if($i + 1 === $count) { if($i + 1 === $count) {
$items[$i]->Join = ' and '; $items[$i]->IsCommaJoin = false;
$items[$i]->IsAndJoin = true;
} }
} }
} }

View File

@ -25,6 +25,6 @@
<% if $Credits %> <% if $Credits %>
<%t Blog.By "by" %> <%t Blog.By "by" %>
<% loop $Credits %><% if $URL %>$Join<a href="$URL">$Name.XML</a><% else %>$Join$Name.XML<% end_if %><% end_loop %> <% loop $Credits %><% if $URL %><% if $IsAndJoin %><%t Blog.Join.And " and " %><% end_if %><% if $IsCommaJoin %><%t Blog.Join.Comma ", " %><% end_if %><a href="$URL">$Name.XML</a><% else %><% if $IsAndJoin %><%t Blog.Join.And " and " %><% end_if %><% if $IsCommaJoin %><%t Blog.Join.Comma ", " %><% end_if %>$Name.XML<% end_if %><% end_loop %>
<% end_if %> <% end_if %>
</p> </p>