aboutsummaryrefslogtreecommitdiffhomepage
path: root/application
diff options
context:
space:
mode:
authorVirtualTam <virtualtam+github@flibidi.net>2016-10-20 20:41:24 +0200
committerGitHub <noreply@github.com>2016-10-20 20:41:24 +0200
commitfb6c8f770a07e38d5250ca4d6717445002e7bfb3 (patch)
tree499d26ccee0d0df3aeac5fe9d27faf2800721698 /application
parentceeb8fbeb89f69e41791ae192d073d6afea00f4b (diff)
parent7af9a41881ed0b9d44d18a0ce03a123a8441adf5 (diff)
downloadShaarli-fb6c8f770a07e38d5250ca4d6717445002e7bfb3.tar.gz
Shaarli-fb6c8f770a07e38d5250ca4d6717445002e7bfb3.tar.zst
Shaarli-fb6c8f770a07e38d5250ca4d6717445002e7bfb3.zip
Merge pull request #671 from ArthurHoaro/cleanup-code
Minor code cleanup: PHPDoc, spelling, unused variables, etc.
Diffstat (limited to 'application')
-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
10 files changed, 24 insertions, 29 deletions
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 {