/**
  * Build browsable list of files
  *
  * @return  array
  */
 public function getFolders()
 {
     if (!empty($this->folders)) {
         return $this->folders;
     }
     $currentFolder = $this->getCurrentFolder();
     if (!file_exists($currentFolder)) {
         return $this->folders;
     }
     $folderList = JFolder::folders($currentFolder);
     $mediaHelper = new JHelperMedia();
     // Iterate over the folders if they exist
     if ($folderList !== false) {
         foreach ($folderList as $folder) {
             $tmp = new JObject();
             $tmp->name = basename($folder);
             $tmp->path = str_replace(DIRECTORY_SEPARATOR, '/', JPath::clean($currentFolder . '/' . $folder));
             $tmp->path_relative = str_replace($currentFolder, '', $tmp->path);
             $tmp->count = $mediaHelper->countFiles($tmp->path);
             $tmp->files = $tmp->count[0];
             $tmp->folders = $tmp->count[1];
             $this->folders[] = $tmp;
         }
     }
     return $this->folders;
 }
Esempio n. 2
0
 /**
  * Counts the files and directories in a directory that are not php or html files.
  *
  * @param   string  $dir  Directory name
  *
  * @return  array  The number of files and directories in the given directory
  *
  * @since   1.5
  * @deprecated  4.0  Use JHelperMedia::countFiles instead
  */
 public static function countFiles($dir)
 {
     JLog::add('MediaHelper::countFiles() is deprecated. Use JHelperMedia::countFiles() instead.', JLog::WARNING, 'deprecated');
     $mediaHelper = new JHelperMedia();
     return $mediaHelper->countFiles($dir);
 }
Esempio n. 3
0
 /**
  * Tests the countFiles method
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testCountFiles()
 {
     // If changes are made to the tests/unit/schema directory this test requires updates
     $countFiles = $this->object->countFiles(JPATH_TESTS . '/schema');
     $this->assertSame(array(4, 0), $countFiles);
 }
 /**
  * Tests the countFiles method
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testCountFiles()
 {
     $countFiles = $this->object->countFiles(JPATH_LIBRARIES . '/phputf8');
     $this->assertSame(array(2, 3), $countFiles);
 }