/**
  * Handle list directory requests (/filemanager/api/ls).
  */
 public function get_ls()
 {
     $file = urldecode(join('/', func_get_args()));
     if (!self::verify_folder($file, $this->root)) {
         return $this->error(i18n_get('Invalid folder name'));
     }
     $d = dir($this->root . $file);
     $out = array('dirs' => array(), 'files' => array());
     while (false != ($entry = $d->read())) {
         if (preg_match('/^\\./', $entry)) {
             continue;
         } elseif (@is_dir($this->root . $file . '/' . $entry)) {
             $out['dirs'][] = array('name' => $entry, 'path' => ltrim($file . '/' . $entry, '/'), 'mtime' => I18n::date_time(filemtime($this->root . $file . '/' . $entry)));
         } else {
             $out['files'][] = array('name' => $entry, 'path' => ltrim($file . '/' . $entry, '/'), 'mtime' => I18n::date_time(filemtime($this->root . $file . '/' . $entry)), 'fsize' => format_filesize(filesize($this->root . $file . '/' . $entry)));
         }
     }
     $d->close();
     usort($out['dirs'], array('FileManager', 'fsort'));
     usort($out['files'], array('FileManager', 'fsort'));
     return $out;
 }
Exemple #2
0
 function test_date_time()
 {
     $date = '2012-05-01 18:30:00';
     $time = strtotime($date);
     $expected = '<time class="datetime" datetime="2012-05-01T18:30:00+00:00">May 1, 2012 - 6:30pm</time>';
     $this->assertEquals($expected, I18n::date_time($date));
     $this->assertEquals($expected, I18n::date_time($time));
 }