aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md1
-rw-r--r--application/ApplicationUtils.php8
-rw-r--r--application/CachedPage.php2
-rw-r--r--application/LinkUtils.php3
-rw-r--r--application/NetscapeBookmarkUtils.php2
-rw-r--r--application/TimeZone.php10
-rw-r--r--application/Updater.php2
-rw-r--r--application/Url.php14
-rw-r--r--application/Utils.php8
-rw-r--r--application/config/ConfigJson.php2
-rw-r--r--application/config/ConfigManager.php2
-rw-r--r--index.php8
-rw-r--r--tests/config/ConfigJsonTest.php2
13 files changed, 28 insertions, 36 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 60af7223..e32ef459 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
19- Release archives now have the same structure as GitHub-generated archives: 19- Release archives now have the same structure as GitHub-generated archives:
20 - archives contain a `Shaarli` directory, itself containing sources + dependencies 20 - archives contain a `Shaarli` directory, itself containing sources + dependencies
21 - the tarball is now gzipped 21 - the tarball is now gzipped
22- Minor code cleanup: PHPDoc, spelling, unused variables, etc.
22 23
23### Fixed 24### Fixed
24- Fix the server `<self>` value in Atom/RSS feeds 25- Fix the server `<self>` value in Atom/RSS feeds
diff --git a/application/ApplicationUtils.php b/application/ApplicationUtils.php
index e67b2902..7f963e97 100644
--- a/application/ApplicationUtils.php
+++ b/application/ApplicationUtils.php
@@ -15,6 +15,9 @@ class ApplicationUtils
15 * 15 *
16 * The code is read from the raw content of the version file on the Git server. 16 * The code is read from the raw content of the version file on the Git server.
17 * 17 *
18 * @param string $url URL to reach to get the latest version.
19 * @param int $timeout Timeout to check the URL (in seconds).
20 *
18 * @return mixed the version code from the repository if available, else 'false' 21 * @return mixed the version code from the repository if available, else 'false'
19 */ 22 */
20 public static function getLatestGitVersionCode($url, $timeout=2) 23 public static function getLatestGitVersionCode($url, $timeout=2)
@@ -49,6 +52,7 @@ class ApplicationUtils
49 * @param int $checkInterval the minimum interval between update checks (in seconds 52 * @param int $checkInterval the minimum interval between update checks (in seconds
50 * @param bool $enableCheck whether to check for new versions 53 * @param bool $enableCheck whether to check for new versions
51 * @param bool $isLoggedIn whether the user is logged in 54 * @param bool $isLoggedIn whether the user is logged in
55 * @param string $branch check update for the given branch
52 * 56 *
53 * @throws Exception an invalid branch has been set for update checks 57 * @throws Exception an invalid branch has been set for update checks
54 * 58 *
@@ -152,7 +156,7 @@ class ApplicationUtils
152 } 156 }
153 } 157 }
154 158
155 // Check cache and data directories are readable and writeable 159 // Check cache and data directories are readable and writable
156 foreach (array( 160 foreach (array(
157 $conf->get('resource.thumbnails_cache'), 161 $conf->get('resource.thumbnails_cache'),
158 $conf->get('resource.data_dir'), 162 $conf->get('resource.data_dir'),
@@ -167,7 +171,7 @@ class ApplicationUtils
167 } 171 }
168 } 172 }
169 173
170 // Check configuration files are readable and writeable 174 // Check configuration files are readable and writable
171 foreach (array( 175 foreach (array(
172 $conf->getConfigFileExt(), 176 $conf->getConfigFileExt(),
173 $conf->get('resource.datastore'), 177 $conf->get('resource.datastore'),
diff --git a/application/CachedPage.php b/application/CachedPage.php
index 50cfa9ac..5087d0c4 100644
--- a/application/CachedPage.php
+++ b/application/CachedPage.php
@@ -35,7 +35,7 @@ class CachedPage
35 /** 35 /**
36 * Returns the cached version of a page, if it exists and should be cached 36 * Returns the cached version of a page, if it exists and should be cached
37 * 37 *
38 * @return a cached version of the page if it exists, null otherwise 38 * @return string a cached version of the page if it exists, null otherwise
39 */ 39 */
40 public function cachedVersion() 40 public function cachedVersion()
41 { 41 {
diff --git a/application/LinkUtils.php b/application/LinkUtils.php
index eeca631f..9d9ae3cb 100644
--- a/application/LinkUtils.php
+++ b/application/LinkUtils.php
@@ -81,7 +81,7 @@ function html_extract_charset($html)
81/** 81/**
82 * Count private links in given linklist. 82 * Count private links in given linklist.
83 * 83 *
84 * @param array $links Linklist. 84 * @param array|Countable $links Linklist.
85 * 85 *
86 * @return int Number of private links. 86 * @return int Number of private links.
87 */ 87 */
@@ -162,6 +162,7 @@ function space2nbsp($text)
162 * 162 *
163 * @param string $description shaare's description. 163 * @param string $description shaare's description.
164 * @param string $redirector if a redirector is set, use it to gerenate links. 164 * @param string $redirector if a redirector is set, use it to gerenate links.
165 * @param string $indexUrl URL to Shaarli's index.
165 * 166 *
166 * @return string formatted description. 167 * @return string formatted description.
167 */ 168 */
diff --git a/application/NetscapeBookmarkUtils.php b/application/NetscapeBookmarkUtils.php
index c3181254..d6840d37 100644
--- a/application/NetscapeBookmarkUtils.php
+++ b/application/NetscapeBookmarkUtils.php
@@ -86,7 +86,7 @@ class NetscapeBookmarkUtils
86 * Imports Web bookmarks from an uploaded Netscape bookmark dump 86 * Imports Web bookmarks from an uploaded Netscape bookmark dump
87 * 87 *
88 * @param array $post Server $_POST parameters 88 * @param array $post Server $_POST parameters
89 * @param array $file Server $_FILES parameters 89 * @param array $files Server $_FILES parameters
90 * @param LinkDB $linkDb Loaded LinkDB instance 90 * @param LinkDB $linkDb Loaded LinkDB instance
91 * @param string $pagecache Page cache 91 * @param string $pagecache Page cache
92 * 92 *
diff --git a/application/TimeZone.php b/application/TimeZone.php
index 26f2232d..36a8fb12 100644
--- a/application/TimeZone.php
+++ b/application/TimeZone.php
@@ -7,9 +7,9 @@
7 * Example: preselect Europe/Paris 7 * Example: preselect Europe/Paris
8 * list($htmlform, $js) = generateTimeZoneForm('Europe/Paris'); 8 * list($htmlform, $js) = generateTimeZoneForm('Europe/Paris');
9 * 9 *
10 * @param string $preselected_timezone preselected timezone (optional) 10 * @param string $preselectedTimezone preselected timezone (optional)
11 * 11 *
12 * @return an array containing the generated HTML form and Javascript code 12 * @return array containing the generated HTML form and Javascript code
13 **/ 13 **/
14function generateTimeZoneForm($preselectedTimezone='') 14function generateTimeZoneForm($preselectedTimezone='')
15{ 15{
@@ -27,10 +27,6 @@ function generateTimeZoneForm($preselectedTimezone='')
27 $pcity = substr($preselectedTimezone, $spos+1); 27 $pcity = substr($preselectedTimezone, $spos+1);
28 } 28 }
29 29
30 // Display config form:
31 $timezoneForm = '';
32 $timezoneJs = '';
33
34 // The list is in the form 'Europe/Paris', 'America/Argentina/Buenos_Aires' 30 // The list is in the form 'Europe/Paris', 'America/Argentina/Buenos_Aires'
35 // We split the list in continents/cities. 31 // We split the list in continents/cities.
36 $continents = array(); 32 $continents = array();
@@ -97,7 +93,7 @@ function generateTimeZoneForm($preselectedTimezone='')
97 * @param string $continent the timezone continent 93 * @param string $continent the timezone continent
98 * @param string $city the timezone city 94 * @param string $city the timezone city
99 * 95 *
100 * @return whether continent/city is a valid timezone 96 * @return bool whether continent/city is a valid timezone
101 */ 97 */
102function isTimeZoneValid($continent, $city) 98function isTimeZoneValid($continent, $city)
103{ 99{
diff --git a/application/Updater.php b/application/Updater.php
index b6cbc56c..90913235 100644
--- a/application/Updater.php
+++ b/application/Updater.php
@@ -37,7 +37,7 @@ class Updater
37 * 37 *
38 * @param array $doneUpdates Updates which are already done. 38 * @param array $doneUpdates Updates which are already done.
39 * @param LinkDB $linkDB LinkDB instance. 39 * @param LinkDB $linkDB LinkDB instance.
40 * @oaram ConfigManager $conf Configuration Manager instance. 40 * @param ConfigManager $conf Configuration Manager instance.
41 * @param boolean $isLoggedIn True if the user is logged in. 41 * @param boolean $isLoggedIn True if the user is logged in.
42 */ 42 */
43 public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn) 43 public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn)
diff --git a/application/Url.php b/application/Url.php
index c166ff6e..c5c7dd18 100644
--- a/application/Url.php
+++ b/application/Url.php
@@ -62,21 +62,7 @@ function add_trailing_slash($url)
62{ 62{
63 return $url . (!endsWith($url, '/') ? '/' : ''); 63 return $url . (!endsWith($url, '/') ? '/' : '');
64} 64}
65/**
66 * Converts an URL with an IDN host to a ASCII one.
67 *
68 * @param string $url Input URL.
69 *
70 * @return string converted URL.
71 */
72function url_with_idn_to_ascii($url)
73{
74 $parts = parse_url($url);
75 $parts['host'] = idn_to_ascii($parts['host']);
76 65
77 $httpUrl = new \http\Url($parts);
78 return $httpUrl->toString();
79}
80/** 66/**
81 * URL representation and cleanup utilities 67 * URL representation and cleanup utilities
82 * 68 *
diff --git a/application/Utils.php b/application/Utils.php
index 7d7eaffd..0166ee2a 100644
--- a/application/Utils.php
+++ b/application/Utils.php
@@ -32,6 +32,10 @@ function logm($logFile, $clientIp, $message)
32 * 32 *
33 * In Shaarli, they are used as a tinyurl-like link to individual entries, 33 * In Shaarli, they are used as a tinyurl-like link to individual entries,
34 * e.g. smallHash('20111006_131924') --> yZH23w 34 * e.g. smallHash('20111006_131924') --> yZH23w
35 *
36 * @param string $text Create a hash from this text.
37 *
38 * @return string generated small hash.
35 */ 39 */
36function smallHash($text) 40function smallHash($text)
37{ 41{
@@ -106,7 +110,9 @@ function unescape($str)
106} 110}
107 111
108/** 112/**
109 * Link sanitization before templating 113 * Sanitize link before rendering.
114 *
115 * @param array $link Link to escape.
110 */ 116 */
111function sanitizeLink(&$link) 117function sanitizeLink(&$link)
112{ 118{
diff --git a/application/config/ConfigJson.php b/application/config/ConfigJson.php
index d07fefee..30007eb4 100644
--- a/application/config/ConfigJson.php
+++ b/application/config/ConfigJson.php
@@ -21,7 +21,7 @@ class ConfigJson implements ConfigIO
21 $data = json_decode($data, true); 21 $data = json_decode($data, true);
22 if ($data === null) { 22 if ($data === null) {
23 $error = json_last_error(); 23 $error = json_last_error();
24 throw new Exception('An error occured while parsing JSON file: error code #'. $error); 24 throw new Exception('An error occurred while parsing JSON file: error code #'. $error);
25 } 25 }
26 return $data; 26 return $data;
27 } 27 }
diff --git a/application/config/ConfigManager.php b/application/config/ConfigManager.php
index ff41772a..f5f753f8 100644
--- a/application/config/ConfigManager.php
+++ b/application/config/ConfigManager.php
@@ -37,6 +37,8 @@ class ConfigManager
37 37
38 /** 38 /**
39 * Constructor. 39 * Constructor.
40 *
41 * @param string $configFile Configuration file path without extension.
40 */ 42 */
41 public function __construct($configFile = 'data/config') 43 public function __construct($configFile = 'data/config')
42 { 44 {
diff --git a/index.php b/index.php
index f7e73bde..6d712aee 100644
--- a/index.php
+++ b/index.php
@@ -606,8 +606,6 @@ function showDailyRSS($conf) {
606 $absurl = escape(index_url($_SERVER).'?do=daily&day='.$day); // Absolute URL of the corresponding "Daily" page. 606 $absurl = escape(index_url($_SERVER).'?do=daily&day='.$day); // Absolute URL of the corresponding "Daily" page.
607 607
608 // Build the HTML body of this RSS entry. 608 // Build the HTML body of this RSS entry.
609 $html = '';
610 $href = '';
611 $links = array(); 609 $links = array();
612 610
613 // We pre-format some fields for proper output. 611 // We pre-format some fields for proper output.
@@ -833,7 +831,7 @@ function renderPage($conf, $pluginManager)
833 // Get only links which have a thumbnail. 831 // Get only links which have a thumbnail.
834 foreach($links as $link) 832 foreach($links as $link)
835 { 833 {
836 $permalink='?'.escape(smallhash($link['linkdate'])); 834 $permalink='?'.escape(smallHash($link['linkdate']));
837 $thumb=lazyThumbnail($conf, $link['url'],$permalink); 835 $thumb=lazyThumbnail($conf, $link['url'],$permalink);
838 if ($thumb!='') // Only output links which have a thumbnail. 836 if ($thumb!='') // Only output links which have a thumbnail.
839 { 837 {
@@ -867,7 +865,7 @@ function renderPage($conf, $pluginManager)
867 $maxcount = max($maxcount, $value); 865 $maxcount = max($maxcount, $value);
868 } 866 }
869 867
870 // Sort tags alphabetically: case insensitive, support locale if avalaible. 868 // Sort tags alphabetically: case insensitive, support locale if available.
871 uksort($tags, function($a, $b) { 869 uksort($tags, function($a, $b) {
872 // Collator is part of PHP intl. 870 // Collator is part of PHP intl.
873 if (class_exists('Collator')) { 871 if (class_exists('Collator')) {
@@ -1670,8 +1668,6 @@ function buildLinkList($PAGE,$LINKSDB, $conf, $pluginManager)
1670 $next_page_url = '?page=' . ($page-1) . $searchtermUrl . $searchtagsUrl; 1668 $next_page_url = '?page=' . ($page-1) . $searchtermUrl . $searchtagsUrl;
1671 } 1669 }
1672 1670
1673 $token = isLoggedIn() ? getToken($conf) : '';
1674
1675 // Fill all template fields. 1671 // Fill all template fields.
1676 $data = array( 1672 $data = array(
1677 'previous_page_url' => $previous_page_url, 1673 'previous_page_url' => $previous_page_url,
diff --git a/tests/config/ConfigJsonTest.php b/tests/config/ConfigJsonTest.php
index 99c88820..07f6ab49 100644
--- a/tests/config/ConfigJsonTest.php
+++ b/tests/config/ConfigJsonTest.php
@@ -41,7 +41,7 @@ class ConfigJsonTest extends PHPUnit_Framework_TestCase
41 * Read a non existent config file -> empty array. 41 * Read a non existent config file -> empty array.
42 * 42 *
43 * @expectedException Exception 43 * @expectedException Exception
44 * @expectedExceptionMessage An error occured while parsing JSON file: error code #4 44 * @expectedExceptionMessage An error occurred while parsing JSON file: error code #4
45 */ 45 */
46 public function testReadInvalidJson() 46 public function testReadInvalidJson()
47 { 47 {