]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
Merge pull request #622 from ArthurHoaro/update-date
[github/shaarli/Shaarli.git] / index.php
index 9f50d15323d2ea40207e14d08d030cfcdbb20025..5bc13d49fd812f88d662c1d21bc53e3ae02c2a10 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1245,6 +1245,9 @@ function renderPage($conf, $pluginManager)
     // -------- User clicked the "Save" button when editing a link: Save link to database.
     if (isset($_POST['save_edit']))
     {
+        $linkdate = $_POST['lf_linkdate'];
+        $updated = isset($LINKSDB[$linkdate]) ? strval(date('Ymd_His')) : false;
+
         // Go away!
         if (! tokenOk($_POST['token'])) {
             die('Wrong token.');
@@ -1255,7 +1258,7 @@ function renderPage($conf, $pluginManager)
         $tags = preg_replace('/(^| )\-/', '$1', $tags);
         // Remove duplicates.
         $tags = implode(' ', array_unique(explode(' ', $tags)));
-        $linkdate = $_POST['lf_linkdate'];
+
         $url = trim($_POST['lf_url']);
         if (! startsWith($url, 'http:') && ! startsWith($url, 'https:')
             && ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:')
@@ -1270,6 +1273,7 @@ function renderPage($conf, $pluginManager)
             'description' => $_POST['lf_description'],
             'private' => (isset($_POST['lf_private']) ? 1 : 0),
             'linkdate' => $linkdate,
+            'updated' => $updated,
             'tags' => str_replace(',', ' ', $tags)
         );
         // If title is empty, use the URL as title.
@@ -1633,6 +1637,12 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
         $link['class'] = $link['private'] == 0 ? $classLi : 'private';
         $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']);
         $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']);
         uasort($taglist, 'strcasecmp');
         $link['taglist'] = $taglist;