aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/feed/Cache.php (renamed from application/Cache.php)0
-rw-r--r--application/feed/CachedPage.php (renamed from application/CachedPage.php)4
-rw-r--r--application/feed/FeedBuilder.php (renamed from application/FeedBuilder.php)37
3 files changed, 23 insertions, 18 deletions
diff --git a/application/Cache.php b/application/feed/Cache.php
index e5d43e61..e5d43e61 100644
--- a/application/Cache.php
+++ b/application/feed/Cache.php
diff --git a/application/CachedPage.php b/application/feed/CachedPage.php
index e11cc52d..1c51ac73 100644
--- a/application/CachedPage.php
+++ b/application/feed/CachedPage.php
@@ -1,4 +1,6 @@
1<?php 1<?php
2
3namespace Shaarli\Feed;
2/** 4/**
3 * Simple cache system, mainly for the RSS/ATOM feeds 5 * Simple cache system, mainly for the RSS/ATOM feeds
4 */ 6 */
@@ -24,7 +26,7 @@ class CachedPage
24 { 26 {
25 // TODO: check write access to the cache directory 27 // TODO: check write access to the cache directory
26 $this->cacheDir = $cacheDir; 28 $this->cacheDir = $cacheDir;
27 $this->filename = $this->cacheDir.'/'.sha1($url).'.cache'; 29 $this->filename = $this->cacheDir . '/' . sha1($url) . '.cache';
28 $this->shouldBeCached = $shouldBeCached; 30 $this->shouldBeCached = $shouldBeCached;
29 } 31 }
30 32
diff --git a/application/FeedBuilder.php b/application/feed/FeedBuilder.php
index 73fafcbe..dcfd2c89 100644
--- a/application/FeedBuilder.php
+++ b/application/feed/FeedBuilder.php
@@ -1,4 +1,8 @@
1<?php 1<?php
2namespace Shaarli\Feed;
3
4use DateTime;
5use LinkDB;
2 6
3/** 7/**
4 * FeedBuilder class. 8 * FeedBuilder class.
@@ -38,12 +42,12 @@ class FeedBuilder
38 protected $feedType; 42 protected $feedType;
39 43
40 /** 44 /**
41 * @var array $_SERVER. 45 * @var array $_SERVER
42 */ 46 */
43 protected $serverInfo; 47 protected $serverInfo;
44 48
45 /** 49 /**
46 * @var array $_GET. 50 * @var array $_GET
47 */ 51 */
48 protected $userInput; 52 protected $userInput;
49 53
@@ -75,10 +79,10 @@ class FeedBuilder
75 /** 79 /**
76 * Feed constructor. 80 * Feed constructor.
77 * 81 *
78 * @param LinkDB $linkDB LinkDB instance. 82 * @param LinkDB $linkDB LinkDB instance.
79 * @param string $feedType Type of feed. 83 * @param string $feedType Type of feed.
80 * @param array $serverInfo $_SERVER. 84 * @param array $serverInfo $_SERVER.
81 * @param array $userInput $_GET. 85 * @param array $userInput $_GET.
82 * @param boolean $isLoggedIn True if the user is currently logged in, false otherwise. 86 * @param boolean $isLoggedIn True if the user is currently logged in, false otherwise.
83 */ 87 */
84 public function __construct($linkDB, $feedType, $serverInfo, $userInput, $isLoggedIn) 88 public function __construct($linkDB, $feedType, $serverInfo, $userInput, $isLoggedIn)
@@ -124,7 +128,7 @@ class FeedBuilder
124 $data['show_dates'] = !$this->hideDates || $this->isLoggedIn; 128 $data['show_dates'] = !$this->hideDates || $this->isLoggedIn;
125 // Remove leading slash from REQUEST_URI. 129 // Remove leading slash from REQUEST_URI.
126 $data['self_link'] = escape(server_url($this->serverInfo)) 130 $data['self_link'] = escape(server_url($this->serverInfo))
127 . escape($this->serverInfo['REQUEST_URI']); 131 . escape($this->serverInfo['REQUEST_URI']);
128 $data['index_url'] = $pageaddr; 132 $data['index_url'] = $pageaddr;
129 $data['usepermalinks'] = $this->usePermalinks === true; 133 $data['usepermalinks'] = $this->usePermalinks === true;
130 $data['links'] = $linkDisplayed; 134 $data['links'] = $linkDisplayed;
@@ -142,18 +146,18 @@ class FeedBuilder
142 */ 146 */
143 protected function buildItem($link, $pageaddr) 147 protected function buildItem($link, $pageaddr)
144 { 148 {
145 $link['guid'] = $pageaddr .'?'. $link['shorturl']; 149 $link['guid'] = $pageaddr . '?' . $link['shorturl'];
146 // Check for both signs of a note: starting with ? and 7 chars long. 150 // Check for both signs of a note: starting with ? and 7 chars long.
147 if ($link['url'][0] === '?' && strlen($link['url']) === 7) { 151 if ($link['url'][0] === '?' && strlen($link['url']) === 7) {
148 $link['url'] = $pageaddr . $link['url']; 152 $link['url'] = $pageaddr . $link['url'];
149 } 153 }
150 if ($this->usePermalinks === true) { 154 if ($this->usePermalinks === true) {
151 $permalink = '<a href="'. $link['url'] .'" title="'. t('Direct link') .'">'. t('Direct link') .'</a>'; 155 $permalink = '<a href="' . $link['url'] . '" title="' . t('Direct link') . '">' . t('Direct link') . '</a>';
152 } else { 156 } else {
153 $permalink = '<a href="'. $link['guid'] .'" title="'. t('Permalink') .'">'. t('Permalink') .'</a>'; 157 $permalink = '<a href="' . $link['guid'] . '" title="' . t('Permalink') . '">' . t('Permalink') . '</a>';
154 } 158 }
155 $link['description'] = format_description($link['description'], '', false, $pageaddr); 159 $link['description'] = format_description($link['description'], '', false, $pageaddr);
156 $link['description'] .= PHP_EOL .'<br>&#8212; '. $permalink; 160 $link['description'] .= PHP_EOL . '<br>&#8212; ' . $permalink;
157 161
158 $pubDate = $link['created']; 162 $pubDate = $link['created'];
159 $link['pub_iso_date'] = $this->getIsoDate($pubDate); 163 $link['pub_iso_date'] = $this->getIsoDate($pubDate);
@@ -164,7 +168,6 @@ class FeedBuilder
164 $link['up_iso_date'] = $this->getIsoDate($upDate, DateTime::ATOM); 168 $link['up_iso_date'] = $this->getIsoDate($upDate, DateTime::ATOM);
165 } else { 169 } else {
166 $link['up_iso_date'] = $this->getIsoDate($pubDate, DateTime::ATOM); 170 $link['up_iso_date'] = $this->getIsoDate($pubDate, DateTime::ATOM);
167 ;
168 } 171 }
169 172
170 // Save the more recent item. 173 // Save the more recent item.
@@ -223,11 +226,11 @@ class FeedBuilder
223 public function getTypeLanguage() 226 public function getTypeLanguage()
224 { 227 {
225 // Use the locale do define the language, if available. 228 // Use the locale do define the language, if available.
226 if (! empty($this->locale) && preg_match('/^\w{2}[_\-]\w{2}/', $this->locale)) { 229 if (!empty($this->locale) && preg_match('/^\w{2}[_\-]\w{2}/', $this->locale)) {
227 $length = ($this->feedType == self::$FEED_RSS) ? 5 : 2; 230 $length = ($this->feedType === self::$FEED_RSS) ? 5 : 2;
228 return str_replace('_', '-', substr($this->locale, 0, $length)); 231 return str_replace('_', '-', substr($this->locale, 0, $length));
229 } 232 }
230 return ($this->feedType == self::$FEED_RSS) ? 'en-en' : 'en'; 233 return ($this->feedType === self::$FEED_RSS) ? 'en-en' : 'en';
231 } 234 }
232 235
233 /** 236 /**
@@ -287,7 +290,7 @@ class FeedBuilder
287 } 290 }
288 291
289 $intNb = intval($this->userInput['nb']); 292 $intNb = intval($this->userInput['nb']);
290 if (! is_int($intNb) || $intNb == 0) { 293 if (!is_int($intNb) || $intNb == 0) {
291 return self::$DEFAULT_NB_LINKS; 294 return self::$DEFAULT_NB_LINKS;
292 } 295 }
293 296