Skip to content

Commit

Permalink
Merge branch 'wip-MDL-34748-MOODLE_23_STABLE' of git://github.com/mar…
Browse files Browse the repository at this point in the history
…inaglancy/moodle into MOODLE_23_STABLE
  • Loading branch information
Aparup Banerjee committed Aug 14, 2012
2 parents 69e0f50 + ff21775 commit 38ace22
Showing 1 changed file with 35 additions and 23 deletions.
58 changes: 35 additions & 23 deletions repository/filesystem/lib.php
Expand Up @@ -91,37 +91,49 @@ public function get_listing($path = '', $page = '') {
$list['dynload'] = true; $list['dynload'] = true;
$list['nologin'] = true; $list['nologin'] = true;
$list['nosearch'] = true; $list['nosearch'] = true;
// retrieve list of files and directories and sort them
$fileslist = array();
$dirslist = array();
if ($dh = opendir($this->root_path)) { if ($dh = opendir($this->root_path)) {
while (($file = readdir($dh)) != false) { while (($file = readdir($dh)) != false) {
if ( $file != '.' and $file !='..') { if ( $file != '.' and $file !='..') {
if (filetype($this->root_path.$file) == 'file') { if (is_file($this->root_path.$file)) {
$list['list'][] = array( $fileslist[] = $file;
'title' => $file,
'source' => $path.'/'.$file,
'size' => filesize($this->root_path.$file),
'datecreated' => filectime($this->root_path.$file),
'datemodified' => filemtime($this->root_path.$file),
'thumbnail' => $OUTPUT->pix_url(file_extension_icon($file, 90))->out(false),
'icon' => $OUTPUT->pix_url(file_extension_icon($file, 24))->out(false)
);
} else { } else {
if (!empty($path)) { $dirslist[] = $file;
$current_path = $path . '/'. $file;
} else {
$current_path = $file;
}
$list['list'][] = array(
'title' => $file,
'children' => array(),
'datecreated' => filectime($this->root_path.$file),
'datemodified' => filemtime($this->root_path.$file),
'thumbnail' => $OUTPUT->pix_url(file_folder_icon(90))->out(false),
'path' => $current_path
);
} }
} }
} }
} }
collatorlib::asort($fileslist, collatorlib::SORT_STRING);
collatorlib::asort($dirslist, collatorlib::SORT_STRING);
// fill the $list['list']
foreach ($dirslist as $file) {
if (!empty($path)) {
$current_path = $path . '/'. $file;
} else {
$current_path = $file;
}
$list['list'][] = array(
'title' => $file,
'children' => array(),
'datecreated' => filectime($this->root_path.$file),
'datemodified' => filemtime($this->root_path.$file),
'thumbnail' => $OUTPUT->pix_url(file_folder_icon(90))->out(false),
'path' => $current_path
);
}
foreach ($fileslist as $file) {
$list['list'][] = array(
'title' => $file,
'source' => $path.'/'.$file,
'size' => filesize($this->root_path.$file),
'datecreated' => filectime($this->root_path.$file),
'datemodified' => filemtime($this->root_path.$file),
'thumbnail' => $OUTPUT->pix_url(file_extension_icon($file, 90))->out(false),
'icon' => $OUTPUT->pix_url(file_extension_icon($file, 24))->out(false)
);
}
$list['list'] = array_filter($list['list'], array($this, 'filter')); $list['list'] = array_filter($list['list'], array($this, 'filter'));
return $list; return $list;
} }
Expand Down

0 comments on commit 38ace22

Please sign in to comment.