Minor changes

This commit is contained in:
dignajar 2015-09-14 20:07:15 -03:00
parent 7e9be455a4
commit bc3a108578
6 changed files with 28 additions and 7 deletions

View File

@ -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();

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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));
}