diff --git a/install.php b/install.php index 6582a97a..af59ef8e 100755 --- a/install.php +++ b/install.php @@ -241,7 +241,7 @@ function install($adminPassword, $email) 'description'=>'Welcome to Bludit', 'username'=>'admin', 'status'=>'published', - 'tags'=>'bludit, cms, flat-file', + 'tags'=>'bludit,cms,flat-file', 'allowComments'=>false, 'date'=>$currentDate ) diff --git a/kernel/dblanguage.class.php b/kernel/dblanguage.class.php index 7da6c0fa..58a999cc 100644 --- a/kernel/dblanguage.class.php +++ b/kernel/dblanguage.class.php @@ -87,7 +87,7 @@ class dbLanguage extends dbJSON // Returns an array with all dictionaries. public function getLanguageList() { - $files = glob(PATH_LANGUAGES.'*.json'); + $files = Filesystem::listFiles(PATH_LANGUAGES, '*', 'json'); $tmp = array(); diff --git a/kernel/dbpages.class.php b/kernel/dbpages.class.php index d0f112b4..9d0331ea 100644 --- a/kernel/dbpages.class.php +++ b/kernel/dbpages.class.php @@ -301,7 +301,8 @@ class dbPages extends dbJSON $fields['status'] = CLI_STATUS; $fields['date'] = Date::current(DB_DATE_FORMAT); - $tmpPaths = glob(PATH_PAGES.'*', GLOB_ONLYDIR); + //$tmpPaths = glob(PATH_PAGES.'*', GLOB_ONLYDIR); + $tmpPaths = Filesystem::listDirectories(PATH_PAGES); foreach($tmpPaths as $directory) { $key = basename($directory); @@ -312,7 +313,8 @@ class dbPages extends dbJSON } // Recovery pages from subdirectories - $subPaths = glob($directory.DS.'*', GLOB_ONLYDIR); + //$subPaths = glob($directory.DS.'*', GLOB_ONLYDIR); + $subPaths = Filesystem::listDirectories($directory.DS); foreach($subPaths as $subDirectory) { $subKey = basename($subDirectory); diff --git a/kernel/dbposts.class.php b/kernel/dbposts.class.php index d2f7bda4..93d5cce1 100644 --- a/kernel/dbposts.class.php +++ b/kernel/dbposts.class.php @@ -370,7 +370,8 @@ class dbPosts extends dbJSON $fields['date'] = Date::current(DB_DATE_FORMAT); // Recovery pages from the first level of directories - $tmpPaths = glob(PATH_POSTS.'*', GLOB_ONLYDIR); + //$tmpPaths = glob(PATH_POSTS.'*', GLOB_ONLYDIR); + $tmpPaths = Filesystem::listDirectories(PATH_POSTS); foreach($tmpPaths as $directory) { $key = basename($directory); diff --git a/kernel/helpers/filesystem.class.php b/kernel/helpers/filesystem.class.php index 33de445f..3832d660 100644 --- a/kernel/helpers/filesystem.class.php +++ b/kernel/helpers/filesystem.class.php @@ -5,7 +5,24 @@ class Filesystem { // NEW public static function listDirectories($path, $regex='*') { - return glob($path.$regex, GLOB_ONLYDIR); + $directories = glob($path.$regex, GLOB_ONLYDIR); + + if(empty($directories)) { + return array(); + } + + return $directories; + } + + public static function listFiles($path, $regex='*', $extension) + { + $files = glob($path.$regex.'.'.$extension); + + if(empty($files)) { + return array(); + } + + return $files; } public static function mkdir($pathname, $recursive=false) diff --git a/kernel/page.class.php b/kernel/page.class.php index e3dc6b85..9335b445 100644 --- a/kernel/page.class.php +++ b/kernel/page.class.php @@ -141,7 +141,8 @@ class Page extends fileContent public function children() { $tmp = array(); - $paths = glob(PATH_PAGES.$this->getField('key').DS.'*', GLOB_ONLYDIR); + //$paths = glob(PATH_PAGES.$this->getField('key').DS.'*', GLOB_ONLYDIR); + $paths = Filesystem::listDirectories(PATH_PAGES.$this->getField('key').DS); foreach($paths as $path) { array_push($tmp, basename($path)); }