Ejemplo n.º 1
0
 /**
  * 
  * @return array
  */
 public function listFiles()
 {
     $folders = array();
     try {
         $dir = $this->getStatisticsDir();
         $iterator = new DirectoryIterator($dir);
         foreach ($iterator as $folder) {
             if ($folder->isDot() || substr($folder->getFilename(), 0, 1) == '.') {
                 continue;
             }
             $fileIterator = new FilesystemIterator($folder->getPathname());
             $files = array();
             foreach ($fileIterator as $file) {
                 $type = App_Util_Mime::getMimeFile(strtolower($file->getExtension()));
                 $files[] = array('path' => $this->publicFileUrl($file->getPathname()), 'size' => App_Util_Readable::readBytes(App_Util_ByteSize::convert($file->getSize(), 'B', 'M'), 'M', true), 'type' => array_shift($type), 'name' => $file->getBasename(), 'date' => date('d/m/Y H:i', $file->getMTime()));
             }
             if (!empty($files)) {
                 $folders[$folder->getBasename()] = $files;
             }
         }
         return $folders;
     } catch (Exception $e) {
         return $folders;
     }
 }
Ejemplo n.º 2
0
 /**
  *
  * @return array 
  */
 public function listFiles()
 {
     $files = array();
     try {
         $dir = $this->getFefopDir();
         $iterator = new FilesystemIterator($dir);
         foreach ($iterator as $file) {
             $files[] = array('path' => $this->publicFileUrl($file->getPathname()), 'size' => App_Util_Readable::readBytes(App_Util_ByteSize::convert($file->getSize(), 'B', 'M'), 'M', true), 'type' => array_shift(App_Util_Mime::getMimeFile(strtolower($file->getExtension()))), 'name' => $file->getBasename(), 'date' => date('d/m/Y H:i', $file->getMTime()));
         }
         return $files;
     } catch (Exception $e) {
         return $files;
     }
 }