Skip to content
This repository has been archived by the owner on Nov 24, 2019. It is now read-only.

Commit

Permalink
use FuelPHP read_dir() to list folders sorted.
Browse files Browse the repository at this point in the history
  • Loading branch information
ve3 committed Aug 25, 2014
1 parent 8d2d68b commit a6b2358
Showing 1 changed file with 42 additions and 22 deletions.
64 changes: 42 additions & 22 deletions fuel/app/classes/library/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,21 @@ public function listAdminNavbar()

// loop module paths
foreach ($this->module_paths as $module_path) {
if ($handle = opendir($module_path)) {
while (false != ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && is_dir($module_path . $file)) {
$config['basedir'] = $module_path;
$file_area = \File::forge($config);
unset($config);

$files = \File::read_dir($module_path, 1,
array(
'!^\.',
),
$file_area
);
unset($file_area);

foreach ($files as $file => $subs) {
$file = mb_substr($file, 0, mb_strlen($file)-1);
if (is_dir($module_path . $file)) {
if (file_exists($module_path . $file . DS . 'classes' . DS . $file . 'admin.php') && is_file($module_path . $file . DS . 'classes' . DS . $file . 'admin.php')) {
$class_name_with_namespace = '\\' . ucfirst($file) . '\\' . ucfirst($file) . 'Admin' ;

Expand All @@ -138,15 +150,13 @@ public function listAdminNavbar()
$output .= "\t" . call_user_func_array(array($obj, 'admin_navbar'), array()) . "\n";
}
}
}
}
}

closedir($handle);
}
}
}// endif file exists.
}// endif is dir
}// endforaech;
unset($class_name_with_namespace, $file, $files, $obj, $subs);
}// endforaech;

unset($class_name_with_namespace, $file, $handle, $module_path, $obj);
unset($module_path);

if ($output != null) {
$output = "\n" . '<ul>' . "\n" . $output . '</ul>' . "\n";
Expand All @@ -172,9 +182,21 @@ public function listModulesWithPermission()

// loop module paths
foreach ($this->module_paths as $module_path) {
if ($handle = opendir($module_path)) {
while (false != ($file = readdir($handle))) {
if ($file != '.' && $file != '..' && is_dir($module_path . $file)) {
$config['basedir'] = $module_path;
$file_area = \File::forge($config);
unset($config);

$files = \File::read_dir($module_path, 1,
array(
'!^\.',
),
$file_area
);
unset($file_area);

foreach ($files as $file => $subs) {
$file = mb_substr($file, 0, mb_strlen($file)-1);
if (is_dir($module_path . $file)) {
if (file_exists($module_path . $file . DS . 'classes' . DS . $file . 'admin.php') && is_file($module_path . $file . DS . 'classes' . DS . $file . 'admin.php')) {
$class_name_with_namespace = '\\' . ucfirst($file) . '\\' . ucfirst($file) . 'Admin' ;

Expand All @@ -196,15 +218,13 @@ public function listModulesWithPermission()
$i++;
}
}
}
}
}

closedir($handle);
}
}
}// endif file exists.
}// endif is dir
}// endforaech;
unset($class_name_with_namespace, $file, $files, $subs);
}// endforaech;

unset($class_name_with_namespace, $file, $handle, $i, $info, $module_path);
unset($module_path);

return $output;
}
Expand Down

0 comments on commit a6b2358

Please sign in to comment.