Define date format in templates instead of index.php.

This commit is contained in:
ArthurHoaro 2015-03-12 21:57:19 +01:00 committed by nodiscc
parent 129ff3c2e5
commit bec1870180
4 changed files with 7 additions and 17 deletions

View file

@ -567,16 +567,6 @@ function linkdate2iso8601($linkdate)
return date('c',linkdate2timestamp($linkdate)); // 'c' is for ISO 8601 date format. 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. // Parse HTTP response headers and return an associative array.
function http_parse_headers_shaarli( $headers ) function http_parse_headers_shaarli( $headers )
{ {
@ -1142,7 +1132,7 @@ function showDailyRSS()
$l = $LINKSDB[$linkdate]; $l = $LINKSDB[$linkdate];
$l['formatedDescription']=nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($l['description'])))); $l['formatedDescription']=nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($l['description']))));
$l['thumbnail'] = thumbnail($l['url']); $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 if (startsWith($l['url'],'?')) $l['url']=indexUrl().$l['url']; // make permalink URL absolute
$links[$linkdate]=$l; $links[$linkdate]=$l;
} }
@ -1190,7 +1180,7 @@ function showDaily()
$linksToDisplay[$key]['taglist']=$taglist; $linksToDisplay[$key]['taglist']=$taglist;
$linksToDisplay[$key]['formatedDescription']=nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description'])))); $linksToDisplay[$key]['formatedDescription']=nl2br(keepMultipleSpaces(text2clickable(htmlspecialchars($link['description']))));
$linksToDisplay[$key]['thumbnail'] = thumbnail($link['url']); $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. /* We need to spread the articles on 3 columns.
@ -1944,7 +1934,7 @@ function buildLinkList($PAGE,$LINKSDB)
$title=$link['title']; $title=$link['title'];
$classLi = $i%2!=0 ? '' : 'publicLinkHightLight'; $classLi = $i%2!=0 ? '' : 'publicLinkHightLight';
$link['class'] = ($link['private']==0 ? $classLi : 'private'); $link['class'] = ($link['private']==0 ? $classLi : 'private');
$link['localdate']=linkdate2locale($link['linkdate']); $link['timestamp']=linkdate2timestamp($link['linkdate']);
$taglist = explode(' ',$link['tags']); $taglist = explode(' ',$link['tags']);
uasort($taglist, 'strcasecmp'); uasort($taglist, 'strcasecmp');
$link['taglist']=$taglist; $link['taglist']=$taglist;

View file

@ -30,7 +30,7 @@
</div> </div>
{if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"} {if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"}
<div class="dailyEntryLinkdate"> <div class="dailyEntryLinkdate">
<a href="?{$link.linkdate|smallHash}">{$link.localdate}</a> <a href="?{$link.linkdate|smallHash}">{function="strftime('%c', $link.timestamp)"}</a>
</div> </div>
{/if} {/if}
{if="$link.tags"} {if="$link.tags"}

View file

@ -1,6 +1,6 @@
{loop="links"} {loop="links"}
<h3><a href="{$value.url}">{$value.title|htmlspecialchars}</a></h3> <h3><a href="{$value.url}">{$value.title|htmlspecialchars}</a></h3>
<small>{if="!$GLOBALS['config']['HIDE_TIMESTAMPS']"}{$value.localdate|htmlspecialchars} - {/if}{if="$value.tags"}{$value.tags|htmlspecialchars}{/if}<br> <small>{if="!$GLOBALS['config']['HIDE_TIMESTAMPS']"}{function="strftime('%c', $value.timestamp|htmlspecialchars)"} - {/if}{if="$value.tags"}{$value.tags|htmlspecialchars}{/if}<br>
{$value.url|htmlspecialchars}</small><br> {$value.url|htmlspecialchars}</small><br>
{if="$value.thumbnail"}{$value.thumbnail}{/if}<br> {if="$value.thumbnail"}{$value.thumbnail}{/if}<br>
{if="$value.description"}{$value.formatedDescription}{/if} {if="$value.description"}{$value.formatedDescription}{/if}

View file

@ -44,7 +44,7 @@
<br> <br>
{if="$value.description"}<div class="linkdescription">{$value.description}</div>{/if} {if="$value.description"}<div class="linkdescription">{$value.description}</div>{/if}
{if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"} {if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"}
<span class="linkdate" title="Permalink"><a href="?{$value.linkdate|smallHash}">{$value.localdate|htmlspecialchars} - permalink</a> - </span> <span class="linkdate" title="Permalink"><a href="?{$value.linkdate|smallHash}">{function="strftime('%c', $value.timestamp)"} - permalink</a> - </span>
{else} {else}
<span class="linkdate" title="Short link here"><a href="?{$value.linkdate|smallHash}">permalink</a> - </span> <span class="linkdate" title="Short link here"><a href="?{$value.linkdate|smallHash}">permalink</a> - </span>
{/if} {/if}
@ -53,7 +53,7 @@
{/if} {/if}
<div class="linkqrcode"><a href="http://qrfree.kaywa.com/?l=1&amp;s=8&amp;d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}" <div class="linkqrcode"><a href="http://qrfree.kaywa.com/?l=1&amp;s=8&amp;d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}"
onclick="return showQrCode(this);" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}"> onclick="return showQrCode(this);" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}">
<img src="images/qrcode.png#" alt="QR-Code" title="{$value.localdate|htmlspecialchars}"></a></div> - <img src="images/qrcode.png#" alt="QR-Code" title="{function="strftime('%c', $value.timestamp)"}"></a></div> -
<a href="{$value.url|htmlspecialchars}"><span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span></a><br> <a href="{$value.url|htmlspecialchars}"><span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span></a><br>
{if="$value.tags"} {if="$value.tags"}
<div class="linktaglist"> <div class="linktaglist">