From bec18701801cc140d760c261dd115fda1507a0dd Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Thu, 12 Mar 2015 21:57:19 +0100 Subject: [PATCH] Define date format in templates instead of index.php. --- index.php | 16 +++------------- tpl/daily.html | 2 +- tpl/dailyrss.html | 2 +- tpl/linklist.html | 4 ++-- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/index.php b/index.php index 0d3c330..9ab70f6 100644 --- a/index.php +++ b/index.php @@ -567,16 +567,6 @@ function linkdate2iso8601($linkdate) return date('c',linkdate2timestamp($linkdate)); // 'c' is for ISO 8601 date format. } -/* Converts a linkdate time (YYYYMMDD_HHMMSS) of an article to a localized date format. - (used to display link date on screen) - The date format is automatically chosen according to locale/languages sniffed from browser headers (see autoLocale()). */ -function linkdate2locale($linkdate) -{ - return utf8_encode(strftime('%c',linkdate2timestamp($linkdate))); // %c is for automatic date format according to locale. - // Note that if you use a locale which is not installed on your webserver, - // the date will not be displayed in the chosen locale, but probably in US notation. -} - // Parse HTTP response headers and return an associative array. function http_parse_headers_shaarli( $headers ) { @@ -1142,7 +1132,7 @@ function showDailyRSS() $l = $LINKSDB[$linkdate]; $l['formatedDescription']=nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($l['description'])))); $l['thumbnail'] = thumbnail($l['url']); - $l['localdate']=linkdate2locale($l['linkdate']); + $l['timestamp'] = linkdate2timestamp($l['linkdate']); if (startsWith($l['url'],'?')) $l['url']=indexUrl().$l['url']; // make permalink URL absolute $links[$linkdate]=$l; } @@ -1190,7 +1180,7 @@ function showDaily() $linksToDisplay[$key]['taglist']=$taglist; $linksToDisplay[$key]['formatedDescription']=nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description'])))); $linksToDisplay[$key]['thumbnail'] = thumbnail($link['url']); - $linksToDisplay[$key]['localdate'] = linkdate2locale($link['linkdate']); + $linksToDisplay[$key]['timestamp'] = linkdate2timestamp($link['linkdate']); } /* We need to spread the articles on 3 columns. @@ -1944,7 +1934,7 @@ function buildLinkList($PAGE,$LINKSDB) $title=$link['title']; $classLi = $i%2!=0 ? '' : 'publicLinkHightLight'; $link['class'] = ($link['private']==0 ? $classLi : 'private'); - $link['localdate']=linkdate2locale($link['linkdate']); + $link['timestamp']=linkdate2timestamp($link['linkdate']); $taglist = explode(' ',$link['tags']); uasort($taglist, 'strcasecmp'); $link['taglist']=$taglist; diff --git a/tpl/daily.html b/tpl/daily.html index c53e6f7..919795b 100644 --- a/tpl/daily.html +++ b/tpl/daily.html @@ -30,7 +30,7 @@ {if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"}
- {$link.localdate} + {function="strftime('%c', $link.timestamp)"}
{/if} {if="$link.tags"} diff --git a/tpl/dailyrss.html b/tpl/dailyrss.html index 436e1cd..926704f 100644 --- a/tpl/dailyrss.html +++ b/tpl/dailyrss.html @@ -1,6 +1,6 @@ {loop="links"}

{$value.title|htmlspecialchars}

- {if="!$GLOBALS['config']['HIDE_TIMESTAMPS']"}{$value.localdate|htmlspecialchars} - {/if}{if="$value.tags"}{$value.tags|htmlspecialchars}{/if}
+ {if="!$GLOBALS['config']['HIDE_TIMESTAMPS']"}{function="strftime('%c', $value.timestamp|htmlspecialchars)"} - {/if}{if="$value.tags"}{$value.tags|htmlspecialchars}{/if}
{$value.url|htmlspecialchars}

{if="$value.thumbnail"}{$value.thumbnail}{/if}
{if="$value.description"}{$value.formatedDescription}{/if} diff --git a/tpl/linklist.html b/tpl/linklist.html index 353eca5..766a80c 100644 --- a/tpl/linklist.html +++ b/tpl/linklist.html @@ -44,7 +44,7 @@
{if="$value.description"}
{$value.description}
{/if} {if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"} - {$value.localdate|htmlspecialchars} - permalink - + {function="strftime('%c', $value.timestamp)"} - permalink - {else} permalink - {/if} @@ -53,7 +53,7 @@ {/if} - + QR-Code - {$value.url|htmlspecialchars}
{if="$value.tags"}