]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
Save the update date in LinkDB and pass it to linklist templates
[github/shaarli/Shaarli.git] / index.php
index b9576de8f989764ff7e9b57a5b1d0a32e972c77f..d425afda8014b5495b86a2db116e451e11463388 100644 (file)
--- a/index.php
+++ b/index.php
@@ -2,7 +2,7 @@
 /**
  * Shaarli v0.7.0 - Shaare your links...
  *
- * The personal, minimalist, super-fast, no-database Delicious clone.
+ * The personal, minimalist, super-fast, database free, bookmarking service.
  *
  * Friendly fork by the Shaarli community:
  *  - https://github.com/shaarli/Shaarli
@@ -1159,6 +1159,7 @@ function renderPage($conf, $pluginManager)
             $PAGE->assign('timezone_form', $timezone_form);
             $PAGE->assign('timezone_js',$timezone_js);
             $PAGE->assign('private_links_default', $conf->get('privacy.default_private_links', false));
+            $PAGE->assign('session_protection_disabled', $conf->get('security.session_protection_disabled', false));
             $PAGE->assign('enable_rss_permalinks', $conf->get('feed.rss_permalinks', false));
             $PAGE->assign('enable_update_check', $conf->get('updates.check_updates', true));
             $PAGE->assign('hide_public_links', $conf->get('privacy.hide_public_links', false));
@@ -1226,6 +1227,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.');
@@ -1236,7 +1240,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:')
@@ -1251,6 +1255,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.
@@ -1675,10 +1680,7 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
         $keys[] = $key;
     }
 
-    // If there is only a single link, we change on-the-fly the title of the page.
-    if (count($linksToDisplay) == 1) {
-        $conf->set('pagetitle', $linksToDisplay[$keys[0]]['title'] .' - '. $conf->get('general.title'));
-    }
+
 
     // Select articles according to paging.
     $pagecount = ceil(count($keys) / $_SESSION['LINKS_PER_PAGE']);
@@ -1698,6 +1700,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;
@@ -1740,9 +1748,10 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
         'links' => $linkDisp,
         'tags' => $LINKSDB->allTags(),
     );
-    // FIXME! temporary fix - see #399.
-    if ($conf->exists('pagetitle') && count($linkDisp) == 1) {
-        $data['pagetitle'] = $conf->get('pagetitle');
+
+    // If there is only a single link, we change on-the-fly the title of the page.
+    if (count($linksToDisplay) == 1) {
+        $data['pagetitle'] = $linksToDisplay[$keys[0]]['title'] .' - '. $conf->get('general.title');
     }
 
     $pluginManager->executeHooks('render_linklist', $data, array('loggedin' => isLoggedIn()));