aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--application/config/ConfigManager.php2
-rw-r--r--doc/md/Shaarli-configuration.md5
-rw-r--r--index.php56
-rw-r--r--tpl/default/loginform.html3
-rw-r--r--tpl/vintage/loginform.html4
5 files changed, 44 insertions, 26 deletions
diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php
index 0fc5a5c7..fdd5b3d7 100644
--- a/application/config/ConfigManager.php
+++ b/application/config/ConfigManager.php
@@ -328,6 +328,8 @@ class ConfigManager
328 $this->setEmpty('privacy.default_private_links', false); 328 $this->setEmpty('privacy.default_private_links', false);
329 $this->setEmpty('privacy.hide_public_links', false); 329 $this->setEmpty('privacy.hide_public_links', false);
330 $this->setEmpty('privacy.hide_timestamps', false); 330 $this->setEmpty('privacy.hide_timestamps', false);
331 // default state of the 'remember me' checkbox of the login form
332 $this->setEmpty('privacy.remember_user_default', true);
331 333
332 $this->setEmpty('thumbnail.enable_thumbnails', true); 334 $this->setEmpty('thumbnail.enable_thumbnails', true);
333 $this->setEmpty('thumbnail.enable_localcache', true); 335 $this->setEmpty('thumbnail.enable_localcache', true);
diff --git a/doc/md/Shaarli-configuration.md b/doc/md/Shaarli-configuration.md
index 188a3c09..d90e95eb 100644
--- a/doc/md/Shaarli-configuration.md
+++ b/doc/md/Shaarli-configuration.md
@@ -91,6 +91,8 @@ _These settings should not be edited_
91- **default_private_links**: Check the private checkbox by default for every new link. 91- **default_private_links**: Check the private checkbox by default for every new link.
92- **hide_public_links**: All links are hidden while logged out. 92- **hide_public_links**: All links are hidden while logged out.
93- **hide_timestamps**: Timestamps are hidden. 93- **hide_timestamps**: Timestamps are hidden.
94- **remember_user_default**: Default state of the login page's *remember me* checkbox
95 - `true`: checked by default, `false`: unchecked by default
94 96
95### Feed 97### Feed
96 98
@@ -192,7 +194,8 @@ _These settings should not be edited_
192 "privacy": { 194 "privacy": {
193 "default_private_links": true, 195 "default_private_links": true,
194 "hide_public_links": false, 196 "hide_public_links": false,
195 "hide_timestamps": false 197 "hide_timestamps": false,
198 "remember_user_default": true
196 }, 199 },
197 "thumbnail": { 200 "thumbnail": {
198 "enable_thumbnails": true, 201 "enable_thumbnails": true,
diff --git a/index.php b/index.php
index b2f4ded5..07470a08 100644
--- a/index.php
+++ b/index.php
@@ -583,20 +583,29 @@ function showDailyRSS($conf) {
583 */ 583 */
584function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager) 584function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager)
585{ 585{
586 $day=date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD. 586 $day = date('Ymd', strtotime('-1 day')); // Yesterday, in format YYYYMMDD.
587 if (isset($_GET['day'])) $day=$_GET['day']; 587 if (isset($_GET['day'])) {
588 $day = $_GET['day'];
589 }
588 590
589 $days = $LINKSDB->days(); 591 $days = $LINKSDB->days();
590 $i = array_search($day,$days); 592 $i = array_search($day, $days);
591 if ($i===false) { $i=count($days)-1; $day=$days[$i]; } 593 if ($i === false && count($days)) {
592 $previousday=''; 594 // no links for day, but at least one day with links
593 $nextday=''; 595 $i = count($days) - 1;
594 if ($i!==false) 596 $day = $days[$i];
595 {
596 if ($i>=1) $previousday=$days[$i-1];
597 if ($i<count($days)-1) $nextday=$days[$i+1];
598 } 597 }
598 $previousday = '';
599 $nextday = '';
599 600
601 if ($i !== false) {
602 if ($i >= 1) {
603 $previousday=$days[$i - 1];
604 }
605 if ($i < count($days) - 1) {
606 $nextday = $days[$i + 1];
607 }
608 }
600 try { 609 try {
601 $linksToDisplay = $LINKSDB->filterDay($day); 610 $linksToDisplay = $LINKSDB->filterDay($day);
602 } catch (Exception $exc) { 611 } catch (Exception $exc) {
@@ -605,9 +614,7 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager)
605 } 614 }
606 615
607 // We pre-format some fields for proper output. 616 // We pre-format some fields for proper output.
608 foreach($linksToDisplay as $key=>$link) 617 foreach($linksToDisplay as $key => $link) {
609 {
610
611 $taglist = explode(' ',$link['tags']); 618 $taglist = explode(' ',$link['tags']);
612 uasort($taglist, 'strcasecmp'); 619 uasort($taglist, 'strcasecmp');
613 $linksToDisplay[$key]['taglist']=$taglist; 620 $linksToDisplay[$key]['taglist']=$taglist;
@@ -621,21 +628,22 @@ function showDaily($pageBuilder, $LINKSDB, $conf, $pluginManager)
621 so I manually spread entries with a simple method: I roughly evaluate the 628 so I manually spread entries with a simple method: I roughly evaluate the
622 height of a div according to title and description length. 629 height of a div according to title and description length.
623 */ 630 */
624 $columns=array(array(),array(),array()); // Entries to display, for each column. 631 $columns = array(array(), array(), array()); // Entries to display, for each column.
625 $fill=array(0,0,0); // Rough estimate of columns fill. 632 $fill = array(0, 0, 0); // Rough estimate of columns fill.
626 foreach($linksToDisplay as $key=>$link) 633 foreach($linksToDisplay as $key => $link) {
627 {
628 // Roughly estimate length of entry (by counting characters) 634 // Roughly estimate length of entry (by counting characters)
629 // Title: 30 chars = 1 line. 1 line is 30 pixels height. 635 // Title: 30 chars = 1 line. 1 line is 30 pixels height.
630 // Description: 836 characters gives roughly 342 pixel height. 636 // Description: 836 characters gives roughly 342 pixel height.
631 // This is not perfect, but it's usually OK. 637 // This is not perfect, but it's usually OK.
632 $length=strlen($link['title'])+(342*strlen($link['description']))/836; 638 $length = strlen($link['title']) + (342 * strlen($link['description'])) / 836;
633 if ($link['thumbnail']) $length +=100; // 1 thumbnails roughly takes 100 pixels height. 639 if ($link['thumbnail']) {
640 $length += 100; // 1 thumbnails roughly takes 100 pixels height.
641 }
634 // Then put in column which is the less filled: 642 // Then put in column which is the less filled:
635 $smallest=min($fill); // find smallest value in array. 643 $smallest = min($fill); // find smallest value in array.
636 $index=array_search($smallest,$fill); // find index of this smallest value. 644 $index = array_search($smallest, $fill); // find index of this smallest value.
637 array_push($columns[$index],$link); // Put entry in this column. 645 array_push($columns[$index], $link); // Put entry in this column.
638 $fill[$index]+=$length; 646 $fill[$index] += $length;
639 } 647 }
640 648
641 $dayDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $day.'_000000'); 649 $dayDate = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $day.'_000000');
@@ -737,6 +745,8 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history)
737 $PAGE->assign('username', escape($_GET['username'])); 745 $PAGE->assign('username', escape($_GET['username']));
738 } 746 }
739 $PAGE->assign('returnurl',(isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']):'')); 747 $PAGE->assign('returnurl',(isset($_SERVER['HTTP_REFERER']) ? escape($_SERVER['HTTP_REFERER']):''));
748 // add default state of the 'remember me' checkbox
749 $PAGE->assign('remember_user_default', $conf->get('privacy.remember_user_default'));
740 $PAGE->renderPage('loginform'); 750 $PAGE->renderPage('loginform');
741 exit; 751 exit;
742 } 752 }
diff --git a/tpl/default/loginform.html b/tpl/default/loginform.html
index eb6d8378..5777a218 100644
--- a/tpl/default/loginform.html
+++ b/tpl/default/loginform.html
@@ -30,7 +30,8 @@
30 </div> 30 </div>
31 <div class="remember-me"> 31 <div class="remember-me">
32 <input type="checkbox" name="longlastingsession" id="longlastingsessionform" 32 <input type="checkbox" name="longlastingsession" id="longlastingsessionform"
33 checked="checked" tabindex="22"> 33 {if="$remember_user_default"}checked="checked"{/if}
34 tabindex="22">
34 <label for="longlastingsessionform">{'Remember me'|t}</label> 35 <label for="longlastingsessionform">{'Remember me'|t}</label>
35 </div> 36 </div>
36 <div> 37 <div>
diff --git a/tpl/vintage/loginform.html b/tpl/vintage/loginform.html
index 84176385..1becd44f 100644
--- a/tpl/vintage/loginform.html
+++ b/tpl/vintage/loginform.html
@@ -24,7 +24,9 @@
24 </label> 24 </label>
25 <input type="submit" value="Login" class="bigbutton" tabindex="4"> 25 <input type="submit" value="Login" class="bigbutton" tabindex="4">
26 <label for="longlastingsession"> 26 <label for="longlastingsession">
27 <input type="checkbox" name="longlastingsession" id="longlastingsession" tabindex="3"> 27 <input type="checkbox" name="longlastingsession"
28 id="longlastingsession" tabindex="3"
29 {if="$remember_user_default"}checked="checked"{/if}>
28 Stay signed in (Do not check on public computers)</label> 30 Stay signed in (Do not check on public computers)</label>
29 <input type="hidden" name="token" value="{$token}"> 31 <input type="hidden" name="token" value="{$token}">
30 {if="$returnurl"}<input type="hidden" name="returnurl" value="{$returnurl}">{/if} 32 {if="$returnurl"}<input type="hidden" name="returnurl" value="{$returnurl}">{/if}