diff options
author | Arthur <arthur@hoa.ro> | 2016-10-12 14:51:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-12 14:51:37 +0200 |
commit | 03542572665bae57705a2f57b0737ed43f4f1415 (patch) | |
tree | ed4f096826babda6ad25eba4951a6a76cbad2a34 /index.php | |
parent | adcdac1dec45090e2fa1cd4a340e91a40c7a205f (diff) | |
parent | c6d876bb2afe7e9ec1a64c74e766360e2fa441e0 (diff) | |
download | Shaarli-03542572665bae57705a2f57b0737ed43f4f1415.tar.gz Shaarli-03542572665bae57705a2f57b0737ed43f4f1415.tar.zst Shaarli-03542572665bae57705a2f57b0737ed43f4f1415.zip |
Merge pull request #622 from ArthurHoaro/update-date
Save link update dates and render it in templates and feeds
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -1245,6 +1245,9 @@ function renderPage($conf, $pluginManager) | |||
1245 | // -------- User clicked the "Save" button when editing a link: Save link to database. | 1245 | // -------- User clicked the "Save" button when editing a link: Save link to database. |
1246 | if (isset($_POST['save_edit'])) | 1246 | if (isset($_POST['save_edit'])) |
1247 | { | 1247 | { |
1248 | $linkdate = $_POST['lf_linkdate']; | ||
1249 | $updated = isset($LINKSDB[$linkdate]) ? strval(date('Ymd_His')) : false; | ||
1250 | |||
1248 | // Go away! | 1251 | // Go away! |
1249 | if (! tokenOk($_POST['token'])) { | 1252 | if (! tokenOk($_POST['token'])) { |
1250 | die('Wrong token.'); | 1253 | die('Wrong token.'); |
@@ -1255,7 +1258,7 @@ function renderPage($conf, $pluginManager) | |||
1255 | $tags = preg_replace('/(^| )\-/', '$1', $tags); | 1258 | $tags = preg_replace('/(^| )\-/', '$1', $tags); |
1256 | // Remove duplicates. | 1259 | // Remove duplicates. |
1257 | $tags = implode(' ', array_unique(explode(' ', $tags))); | 1260 | $tags = implode(' ', array_unique(explode(' ', $tags))); |
1258 | $linkdate = $_POST['lf_linkdate']; | 1261 | |
1259 | $url = trim($_POST['lf_url']); | 1262 | $url = trim($_POST['lf_url']); |
1260 | if (! startsWith($url, 'http:') && ! startsWith($url, 'https:') | 1263 | if (! startsWith($url, 'http:') && ! startsWith($url, 'https:') |
1261 | && ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:') | 1264 | && ! startsWith($url, 'ftp:') && ! startsWith($url, 'magnet:') |
@@ -1270,6 +1273,7 @@ function renderPage($conf, $pluginManager) | |||
1270 | 'description' => $_POST['lf_description'], | 1273 | 'description' => $_POST['lf_description'], |
1271 | 'private' => (isset($_POST['lf_private']) ? 1 : 0), | 1274 | 'private' => (isset($_POST['lf_private']) ? 1 : 0), |
1272 | 'linkdate' => $linkdate, | 1275 | 'linkdate' => $linkdate, |
1276 | 'updated' => $updated, | ||
1273 | 'tags' => str_replace(',', ' ', $tags) | 1277 | 'tags' => str_replace(',', ' ', $tags) |
1274 | ); | 1278 | ); |
1275 | // If title is empty, use the URL as title. | 1279 | // If title is empty, use the URL as title. |
@@ -1633,6 +1637,12 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager) | |||
1633 | $link['class'] = $link['private'] == 0 ? $classLi : 'private'; | 1637 | $link['class'] = $link['private'] == 0 ? $classLi : 'private'; |
1634 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); | 1638 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); |
1635 | $link['timestamp'] = $date->getTimestamp(); | 1639 | $link['timestamp'] = $date->getTimestamp(); |
1640 | if (! empty($link['updated'])) { | ||
1641 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['updated']); | ||
1642 | $link['updated_timestamp'] = $date->getTimestamp(); | ||
1643 | } else { | ||
1644 | $link['updated_timestamp'] = ''; | ||
1645 | } | ||
1636 | $taglist = explode(' ', $link['tags']); | 1646 | $taglist = explode(' ', $link['tags']); |
1637 | uasort($taglist, 'strcasecmp'); | 1647 | uasort($taglist, 'strcasecmp'); |
1638 | $link['taglist'] = $taglist; | 1648 | $link['taglist'] = $taglist; |