Save the update date in LinkDB and pass it to linklist templates
It can be used as a timestamp by templates under the key 'updated_timestamp'.
This commit is contained in:
parent
c7a42ab1d9
commit
9646b7da22
3 changed files with 23 additions and 3 deletions
|
@ -12,8 +12,9 @@
|
||||||
*
|
*
|
||||||
* Available keys:
|
* Available keys:
|
||||||
* - description: description of the entry
|
* - description: description of the entry
|
||||||
* - linkdate: date of the creation of this entry, in the form YYYYMMDD_HHMMSS
|
* - linkdate: creation date of this entry, format: YYYYMMDD_HHMMSS
|
||||||
* (e.g.'20110914_192317')
|
* (e.g.'20110914_192317')
|
||||||
|
* - updated: last modification date of this entry, format: YYYYMMDD_HHMMSS
|
||||||
* - private: Is this link private? 0=no, other value=yes
|
* - private: Is this link private? 0=no, other value=yes
|
||||||
* - tags: tags attached to this entry (separated by spaces)
|
* - tags: tags attached to this entry (separated by spaces)
|
||||||
* - title Title of the link
|
* - title Title of the link
|
||||||
|
|
12
index.php
12
index.php
|
@ -1227,6 +1227,9 @@ function renderPage($conf, $pluginManager)
|
||||||
// -------- User clicked the "Save" button when editing a link: Save link to database.
|
// -------- User clicked the "Save" button when editing a link: Save link to database.
|
||||||
if (isset($_POST['save_edit']))
|
if (isset($_POST['save_edit']))
|
||||||
{
|
{
|
||||||
|
$linkdate = $_POST['lf_linkdate'];
|
||||||
|
$updated = isset($LINKSDB[$linkdate]) ? strval(date('Ymd_His')) : false;
|
||||||
|
|
||||||
// Go away!
|
// Go away!
|
||||||
if (! tokenOk($_POST['token'])) {
|
if (! tokenOk($_POST['token'])) {
|
||||||
die('Wrong token.');
|
die('Wrong token.');
|
||||||
|
@ -1237,7 +1240,7 @@ function renderPage($conf, $pluginManager)
|
||||||
$tags = preg_replace('/(^| )\-/', '$1', $tags);
|
$tags = preg_replace('/(^| )\-/', '$1', $tags);
|
||||||
// Remove duplicates.
|
// Remove duplicates.
|
||||||
$tags = implode(' ', array_unique(explode(' ', $tags)));
|
$tags = implode(' ', array_unique(explode(' ', $tags)));
|
||||||
$linkdate = $_POST['lf_linkdate'];
|
|
||||||
$url = trim($_POST['lf_url']);
|
$url = trim($_POST['lf_url']);
|
||||||
if (! startsWith($url, 'http:') && ! startsWith($url, 'https:')
|
if (! startsWith($url, 'http:') && ! startsWith($url, 'https:')
|
||||||
&& ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:')
|
&& ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:')
|
||||||
|
@ -1252,6 +1255,7 @@ function renderPage($conf, $pluginManager)
|
||||||
'description' => $_POST['lf_description'],
|
'description' => $_POST['lf_description'],
|
||||||
'private' => (isset($_POST['lf_private']) ? 1 : 0),
|
'private' => (isset($_POST['lf_private']) ? 1 : 0),
|
||||||
'linkdate' => $linkdate,
|
'linkdate' => $linkdate,
|
||||||
|
'updated' => $updated,
|
||||||
'tags' => str_replace(',', ' ', $tags)
|
'tags' => str_replace(',', ' ', $tags)
|
||||||
);
|
);
|
||||||
// If title is empty, use the URL as title.
|
// If title is empty, use the URL as title.
|
||||||
|
@ -1696,6 +1700,12 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
|
||||||
$link['class'] = $link['private'] == 0 ? $classLi : 'private';
|
$link['class'] = $link['private'] == 0 ? $classLi : 'private';
|
||||||
$date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
|
$date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
|
||||||
$link['timestamp'] = $date->getTimestamp();
|
$link['timestamp'] = $date->getTimestamp();
|
||||||
|
if (! empty($link['updated'])) {
|
||||||
|
$date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['updated']);
|
||||||
|
$link['updated_timestamp'] = $date->getTimestamp();
|
||||||
|
} else {
|
||||||
|
$link['updated_timestamp'] = '';
|
||||||
|
}
|
||||||
$taglist = explode(' ', $link['tags']);
|
$taglist = explode(' ', $link['tags']);
|
||||||
uasort($taglist, 'strcasecmp');
|
uasort($taglist, 'strcasecmp');
|
||||||
$link['taglist'] = $taglist;
|
$link['taglist'] = $taglist;
|
||||||
|
|
|
@ -89,7 +89,16 @@
|
||||||
<br>
|
<br>
|
||||||
{if="$value.description"}<div class="linkdescription">{$value.description}</div>{/if}
|
{if="$value.description"}<div class="linkdescription">{$value.description}</div>{/if}
|
||||||
{if="!$hide_timestamps || isLoggedIn()"}
|
{if="!$hide_timestamps || isLoggedIn()"}
|
||||||
<span class="linkdate" title="Permalink"><a href="?{$value.linkdate|smallHash}">{function="strftime('%c', $value.timestamp)"} - permalink</a> - </span>
|
{$updated=$value.updated_timestamp ? 'Edited: '. strftime('%c', $value.updated_timestamp) : 'Permalink'}
|
||||||
|
<span class="linkdate" title="Permalink">
|
||||||
|
<a href="?{$value.linkdate|smallHash}">
|
||||||
|
<span title="{$updated}">
|
||||||
|
{function="strftime('%c', $value.timestamp)"}
|
||||||
|
{if="$value.updated_timestamp"}*{/if}
|
||||||
|
</span>
|
||||||
|
- permalink
|
||||||
|
</a> -
|
||||||
|
</span>
|
||||||
{else}
|
{else}
|
||||||
<span class="linkdate" title="Short link here"><a href="?{$value.shorturl}">permalink</a> - </span>
|
<span class="linkdate" title="Short link here"><a href="?{$value.shorturl}">permalink</a> - </span>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Reference in a new issue