From a689efafc8260f53ed67fbe5d67e013ea41c3923 Mon Sep 17 00:00:00 2001 From: Seb Sauvage Date: Mon, 6 Feb 2012 17:35:44 +0100 Subject: [PATCH] =?utf8?q?Version=200.0.38=20beta:=20-=20Corrected:=20Corr?= =?utf8?q?ected=20the=20tag=20encoding=20(there=20was=20a=20bug=20when=20s?= =?utf8?q?electing=20a=20second=20tag=20which=20contains=20accented=20char?= =?utf8?q?acters).=20-=20Changed:=20The=20=E2=80=9CDaily=E2=80=9D=20page?= =?utf8?q?=20now=20automatically=20skips=20empty=20days.=20-=20Added:=20Au?= =?utf8?q?tomatic=20creation=20of=20the=20tmp=20directory=20with=20proper?= =?utf8?q?=20rights=20(for=20RainTPL).=20-=20Added:=20When=20you=20click?= =?utf8?q?=20the=20key=20to=20see=20only=20private=20links,=20it=20turns?= =?utf8?q?=20yellow.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- images/private_16x16_active.png | Bin 0 -> 475 bytes index.php | 36 ++++++++++++++++++++++++++------ tpl/daily.html | 8 ++++--- tpl/linklist.paging.html | 8 ++++++- 4 files changed, 42 insertions(+), 10 deletions(-) create mode 100644 images/private_16x16_active.png diff --git a/images/private_16x16_active.png b/images/private_16x16_active.png new file mode 100644 index 0000000000000000000000000000000000000000..dd43baf2f888becd1452f8744c8825eb8f1405ac GIT binary patch literal 475 zcmV<10VMv3P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FZT01FZU(%pXi00007bV*G`2iyV% z4-ycVoL#~I00CP`L_t(I%Z1XhYg9oL#o=#XUPOW#n}|eF6cYr&&SHrKiJd5xVqtA* zWocn!Ws|~Mu&@%VjY1F!t_kEHkdSm@&_WCdTDaM)&3W)x-XjCU3}@zd=FYvhv$JRcDR^ITH z4Lpk0!Tmz}IEAAzT*I&EZ!w6;Oq0PV&<=K^J-{N);29=!XS;0q!Z7RKyfllC_=75G zKk;%rf{DPVv5L7ERc96a1NZQ?Y=F;V1y`eQU>OUT#uvQCw|XB`@HxE0mB8z`gT1zD zl_;@~i+G==8R8ReCl6(kTXpC`rXuh>K4cw4KZcWmhPAn0!Ii<~{P_a@r9>lKLmxA> zmmB}_G(8VT0$1VwuI(E~iB}2zb6$U#r1o()2`uVij~lF{=7VTcssEuc{0HSiTAl3= R{hDoX literal 0 HcmV?d00001 diff --git a/index.php b/index.php index 936d6129..2611e04e 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ '); // Suffix to encapsulate data in php code. checkphpversion(); @@ -58,8 +59,8 @@ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); -define('shaarli_version','0.0.37 beta'); if (!is_dir($GLOBALS['config']['DATADIR'])) { mkdir($GLOBALS['config']['DATADIR'],0705); chmod($GLOBALS['config']['DATADIR'],0705); } +if (!is_dir('tmp')) { mkdir('tmp',0705); chmod('tmp',0705); } // For RainTPL temporary files. if (!is_file($GLOBALS['config']['DATADIR'].'/.htaccess')) { file_put_contents($GLOBALS['config']['DATADIR'].'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files. if ($GLOBALS['config']['ENABLE_LOCALCACHE']) { @@ -531,6 +532,7 @@ class pageBuilder $this->tpl->assign('version',shaarli_version); $this->tpl->assign('scripturl',indexUrl()); $this->tpl->assign('pagetitle','Shaarli'); + $this->tpl->assign('privateonly',!empty($_SESSION['privateonly'])); // Show only private links ? if (!empty($GLOBALS['title'])) $this->tpl->assign('pagetitle',$GLOBALS['title']); if (!empty($GLOBALS['pagetitle'])) $this->tpl->assign('pagetitle',$GLOBALS['pagetitle']); $this->tpl->assign('shaarlititle',empty($GLOBALS['title']) ? 'Shaarli': $GLOBALS['title'] ); @@ -746,6 +748,20 @@ class linkdb implements Iterator, Countable, ArrayAccess arsort($tags); // Sort tags by usage (most used tag first) return $tags; } + + // Returns the list of days containing articles (oldest first) + // Output: An array containing days (in format YYYYMMDD). + public function days() + { + $linkdays=array(); + foreach(array_keys($this->links) as $day) + { + $linkdays[substr($day,0,8)]=0; + } + $linkdays=array_keys($linkdays); + sort($linkdays); + return $linkdays; + } } // ------------------------------------------------------------------------------------------ @@ -998,7 +1014,7 @@ function renderPage() // Get previous URL (http_referer) and add the tag to the searchtags parameters in query. if (empty($_SERVER['HTTP_REFERER'])) { header('Location: ?searchtags='.urlencode($_GET['addtag'])); exit; } // In case browser does not send HTTP_REFERER parse_str(parse_url($_SERVER['HTTP_REFERER'],PHP_URL_QUERY), $params); - $params['searchtags'] = (empty($params['searchtags']) ? trim($_GET['addtag']) : trim($params['searchtags']).' '.urlencode(trim($_GET['addtag']))); + $params['searchtags'] = (empty($params['searchtags']) ? trim($_GET['addtag']) : trim($params['searchtags']).' '.trim($_GET['addtag'])); unset($params['page']); // We also remove page (keeping the same page has no sense, since the results are different) header('Location: ?'.http_build_query($params)); exit; @@ -1049,10 +1065,18 @@ function renderPage() { $day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD. if (isset($_GET['day'])) $day=$_GET['day']; - - $previousday = Date('Ymd',strtotime('-1 day',strtotime($day))); - $nextday = Date('Ymd',strtotime('+1 day',strtotime($day))); + $days = $LINKSDB->days(); + $i = array_search($day,$days); + if ($i==false) { $i=count($days)-1; $day=$days[$i]; } + $previousday=''; + $nextday=''; + if ($i!==false) + { + if ($i>1) $previousday=$days[$i-1]; + if ($ifilterDay($day); // We pre-format some fields for proper output. foreach($linksToDisplay as $key=>$link) diff --git a/tpl/daily.html b/tpl/daily.html index bdaf2032..4bc8568b 100644 --- a/tpl/daily.html +++ b/tpl/daily.html @@ -6,11 +6,13 @@
All links of one day
in a single page.
- <Previous day - - Next day>

+ {if="$previousday"} <Previous day{else}<Previous day{/if} + - + {if="$nextday"}Next day>{else}Next day>{/if} +

Daily RSS Feed
-
The Shaarli Daily
+
The Daily Shaarli
——————————— {$day} ———————————
diff --git a/tpl/linklist.paging.html b/tpl/linklist.paging.html index b1f9871f..b0c119d9 100644 --- a/tpl/linklist.paging.html +++ b/tpl/linklist.paging.html @@ -1,7 +1,13 @@
{if="isLoggedIn()"} {/if}
-- 2.41.0