aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-08-03 09:44:04 +0200
committerArthurHoaro <arthur@hoa.ro>2016-08-03 09:44:04 +0200
commit9646b7da22c4c6f3419bfe51431720dd622374d8 (patch)
tree0f5c685ecb63409a8d478aaa0c4ecb4fba475560 /index.php
parentc7a42ab1d9b21bf53cd30bc57b57789716c8711b (diff)
downloadShaarli-9646b7da22c4c6f3419bfe51431720dd622374d8.tar.gz
Shaarli-9646b7da22c4c6f3419bfe51431720dd622374d8.tar.zst
Shaarli-9646b7da22c4c6f3419bfe51431720dd622374d8.zip
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'.
Diffstat (limited to 'index.php')
-rw-r--r--index.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/index.php b/index.php
index 55b12adc..d425afda 100644
--- a/index.php
+++ b/index.php
@@ -1227,6 +1227,9 @@ function renderPage($conf, $pluginManager)
1227 // -------- User clicked the "Save" button when editing a link: Save link to database. 1227 // -------- User clicked the "Save" button when editing a link: Save link to database.
1228 if (isset($_POST['save_edit'])) 1228 if (isset($_POST['save_edit']))
1229 { 1229 {
1230 $linkdate = $_POST['lf_linkdate'];
1231 $updated = isset($LINKSDB[$linkdate]) ? strval(date('Ymd_His')) : false;
1232
1230 // Go away! 1233 // Go away!
1231 if (! tokenOk($_POST['token'])) { 1234 if (! tokenOk($_POST['token'])) {
1232 die('Wrong token.'); 1235 die('Wrong token.');
@@ -1237,7 +1240,7 @@ function renderPage($conf, $pluginManager)
1237 $tags = preg_replace('/(^| )\-/', '$1', $tags); 1240 $tags = preg_replace('/(^| )\-/', '$1', $tags);
1238 // Remove duplicates. 1241 // Remove duplicates.
1239 $tags = implode(' ', array_unique(explode(' ', $tags))); 1242 $tags = implode(' ', array_unique(explode(' ', $tags)));
1240 $linkdate = $_POST['lf_linkdate']; 1243
1241 $url = trim($_POST['lf_url']); 1244 $url = trim($_POST['lf_url']);
1242 if (! startsWith($url, 'http:') && ! startsWith($url, 'https:') 1245 if (! startsWith($url, 'http:') && ! startsWith($url, 'https:')
1243 && ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:') 1246 && ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:')
@@ -1252,6 +1255,7 @@ function renderPage($conf, $pluginManager)
1252 'description' => $_POST['lf_description'], 1255 'description' => $_POST['lf_description'],
1253 'private' => (isset($_POST['lf_private']) ? 1 : 0), 1256 'private' => (isset($_POST['lf_private']) ? 1 : 0),
1254 'linkdate' => $linkdate, 1257 'linkdate' => $linkdate,
1258 'updated' => $updated,
1255 'tags' => str_replace(',', ' ', $tags) 1259 'tags' => str_replace(',', ' ', $tags)
1256 ); 1260 );
1257 // If title is empty, use the URL as title. 1261 // If title is empty, use the URL as title.
@@ -1696,6 +1700,12 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1696 $link['class'] = $link['private'] == 0 ? $classLi : 'private'; 1700 $link['class'] = $link['private'] == 0 ? $classLi : 'private';
1697 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); 1701 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
1698 $link['timestamp'] = $date->getTimestamp(); 1702 $link['timestamp'] = $date->getTimestamp();
1703 if (! empty($link['updated'])) {
1704 $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['updated']);
1705 $link['updated_timestamp'] = $date->getTimestamp();
1706 } else {
1707 $link['updated_timestamp'] = '';
1708 }
1699 $taglist = explode(' ', $link['tags']); 1709 $taglist = explode(' ', $link['tags']);
1700 uasort($taglist, 'strcasecmp'); 1710 uasort($taglist, 'strcasecmp');
1701 $link['taglist'] = $taglist; 1711 $link['taglist'] = $taglist;