Example #1
0
 function getFiles($relative, $filter = '')
 {
     $path = WFUtility::makePath($this->getBaseDir(), $relative);
     $path = WFUtility::fixPath($path);
     if (!JFolder::exists($path)) {
         $relative = '/';
         $path = $this->getBaseDir();
     }
     $list = JFolder::files($path, $filter);
     $files = array();
     $x = 1;
     if (!empty($list)) {
         // Sort alphabetically
         natcasesort($list);
         foreach ($list as $item) {
             $item = WFUtility::isUTF8($item) ? $item : utf8_encode($item);
             // create relative file
             $id = WFUtility::makePath($relative, $item, '/');
             // create url
             $url = WFUtility::makePath($this->getRootDir(), $id, '/');
             // remove leading slash
             $url = ltrim($url, '/');
             $data = array('id' => $id, 'url' => $url, 'name' => $item, 'writable' => is_writable(WFUtility::makePath($path, $item)) || $this->isFtp(), 'type' => 'files');
             $properties = self::getFileDetails($data['id'], $x);
             $files[] = array_merge($data, array('properties' => $properties));
             $x++;
         }
     }
     return $files;
 }