aboutsummaryrefslogtreecommitdiffhomepage
path: root/application/helper/ApplicationUtils.php
diff options
context:
space:
mode:
Diffstat (limited to 'application/helper/ApplicationUtils.php')
-rw-r--r--application/helper/ApplicationUtils.php47
1 files changed, 26 insertions, 21 deletions
diff --git a/application/helper/ApplicationUtils.php b/application/helper/ApplicationUtils.php
index 4b34e114..212dd8e2 100644
--- a/application/helper/ApplicationUtils.php
+++ b/application/helper/ApplicationUtils.php
@@ -1,4 +1,5 @@
1<?php 1<?php
2
2namespace Shaarli\Helper; 3namespace Shaarli\Helper;
3 4
4use Exception; 5use Exception;
@@ -16,7 +17,7 @@ class ApplicationUtils
16 17
17 public static $GITHUB_URL = 'https://github.com/shaarli/Shaarli'; 18 public static $GITHUB_URL = 'https://github.com/shaarli/Shaarli';
18 public static $GIT_RAW_URL = 'https://raw.githubusercontent.com/shaarli/Shaarli'; 19 public static $GIT_RAW_URL = 'https://raw.githubusercontent.com/shaarli/Shaarli';
19 public static $GIT_BRANCHES = array('latest', 'stable'); 20 public static $GIT_BRANCHES = ['latest', 'stable'];
20 private static $VERSION_START_TAG = '<?php /* '; 21 private static $VERSION_START_TAG = '<?php /* ';
21 private static $VERSION_END_TAG = ' */ ?>'; 22 private static $VERSION_END_TAG = ' */ ?>';
22 23
@@ -64,8 +65,8 @@ class ApplicationUtils
64 } 65 }
65 66
66 return str_replace( 67 return str_replace(
67 array(self::$VERSION_START_TAG, self::$VERSION_END_TAG, PHP_EOL), 68 [self::$VERSION_START_TAG, self::$VERSION_END_TAG, PHP_EOL],
68 array('', '', ''), 69 ['', '', ''],
69 $data 70 $data
70 ); 71 );
71 } 72 }
@@ -184,13 +185,15 @@ class ApplicationUtils
184 $rainTplDir = rtrim($conf->get('resource.raintpl_tpl'), '/'); 185 $rainTplDir = rtrim($conf->get('resource.raintpl_tpl'), '/');
185 186
186 // Check script and template directories are readable 187 // Check script and template directories are readable
187 foreach ([ 188 foreach (
188 'application', 189 [
189 'inc', 190 'application',
190 'plugins', 191 'inc',
191 $rainTplDir, 192 'plugins',
192 $rainTplDir . '/' . $conf->get('resource.theme'), 193 $rainTplDir,
193 ] as $path) { 194 $rainTplDir . '/' . $conf->get('resource.theme'),
195 ] as $path
196 ) {
194 if (!is_readable(realpath($path))) { 197 if (!is_readable(realpath($path))) {
195 $errors[] = '"' . $path . '" ' . t('directory is not readable'); 198 $errors[] = '"' . $path . '" ' . t('directory is not readable');
196 } 199 }
@@ -203,10 +206,10 @@ class ApplicationUtils
203 ]; 206 ];
204 } else { 207 } else {
205 $folders = [ 208 $folders = [
206 $conf->get('resource.thumbnails_cache'), 209 $conf->get('resource.thumbnails_cache'),
207 $conf->get('resource.data_dir'), 210 $conf->get('resource.data_dir'),
208 $conf->get('resource.page_cache'), 211 $conf->get('resource.page_cache'),
209 $conf->get('resource.raintpl_tmp'), 212 $conf->get('resource.raintpl_tmp'),
210 ]; 213 ];
211 } 214 }
212 215
@@ -224,13 +227,15 @@ class ApplicationUtils
224 } 227 }
225 228
226 // Check configuration files are readable and writable 229 // Check configuration files are readable and writable
227 foreach (array( 230 foreach (
228 $conf->getConfigFileExt(), 231 [
229 $conf->get('resource.datastore'), 232 $conf->getConfigFileExt(),
230 $conf->get('resource.ban_file'), 233 $conf->get('resource.datastore'),
231 $conf->get('resource.log'), 234 $conf->get('resource.ban_file'),
232 $conf->get('resource.update_check'), 235 $conf->get('resource.log'),
233 ) as $path) { 236 $conf->get('resource.update_check'),
237 ] as $path
238 ) {
234 if (!is_file(realpath($path))) { 239 if (!is_file(realpath($path))) {
235 # the file may not exist yet 240 # the file may not exist yet
236 continue; 241 continue;