public function getDirectory($parentLink = '', $acceptableMime = array(), $depth = 1)
    {
        if (! tao_helpers_File::securityCheck($parentLink)) {
            throw new common_exception_Error(__('Your path contains error'));
        }

        $label = rtrim($parentLink,'/');
        if(strrpos($parentLink, '/') !== false && substr($parentLink, -1) !== '/'){
            $label = substr($parentLink,strrpos($parentLink, '/') + 1);
            $parentLink = $parentLink.'/';
        }

        if(in_array($parentLink,array('','/'))){
            $label = $this->getItem()->getLabel();
            $parentLink = '/';
        }

        $data = array(
            'path' => $parentLink,
            'label' => $label
        );

        if ($depth <= 0) {
            $data['parent'] = $parentLink;
            return $data;
        }

        $children = array();

        /** @var \oat\oatbox\filesystem\Directory $directory */
        $itemDirectory = $this->getItemDirectory();
        if ($parentLink != '/') {
            $directory = $itemDirectory->getDirectory($parentLink);
        } else {
            $directory = $itemDirectory;
        }

        $iterator = $directory->getFlyIterator();
        foreach ($iterator as $content) {
            if ($content instanceof Directory) {
                $children[] = $this->getDirectory($itemDirectory->getRelPath($content), $acceptableMime, $depth - 1);
            } else {
                $fileInfo = $this->getInfoFromFile($content);
                if (empty($acceptableMime) || in_array($fileInfo['mime'], $acceptableMime)) {
                    $children[] = $fileInfo;
                }
            }
        }

        $data['children'] = $children;
        return $data;
    }
public function getDirectory($parentLink = '', $acceptableMime = array(), $depth = 1)
    {
        if (! tao_helpers_File::securityCheck($parentLink)) {
            throw new common_exception_Error(__('Your path contains error'));
        }

        $label = rtrim($parentLink,'/');
        if(strrpos($parentLink, '/') !== false && substr($parentLink, -1) !== '/'){
            $label = substr($parentLink,strrpos($parentLink, '/') + 1);
            $parentLink = $parentLink.'/';
        }

        if(in_array($parentLink,array('','/'))){
            $label = $this->getItem()->getLabel();
            $parentLink = '/';
        }

        $data = array(
            'path' => $parentLink,
            'label' => $label
        );

        if ($depth <= 0) {
            $data['parent'] = $parentLink;
            return $data;
        }

        $children = array();

        /** @var \oat\oatbox\filesystem\Directory $directory */
        $itemDirectory = $this->getItemDirectory();
        if ($parentLink != '/') {
            $directory = $itemDirectory->getDirectory($parentLink);
        } else {
            $directory = $itemDirectory;
        }

        $iterator = $directory->getFlyIterator();
        foreach ($iterator as $content) {
            if ($content instanceof Directory) {
                $children[] = $this->getDirectory($itemDirectory->getRelPath($content), $acceptableMime, $depth - 1);
            } else {
                $fileInfo = $this->getInfoFromFile($content);
                if (empty($acceptableMime) || in_array($fileInfo['mime'], $acceptableMime)) {
                    $children[] = $fileInfo;
                }
            }
        }

        $data['children'] = $children;
        return $data;
    }
public function getDirectory ( $ parentLink = '' , $ acceptableMime = array ( ) , $ depth = 1 ) { if ( ! tao_helpers_File :: securityCheck ( $ parentLink ) ) { throw new common_exception_Error ( __ ( 'Your path contains error' ) ) ; } $ label = rtrim ( $ parentLink , '/' ) ; if ( strrpos ( $ parentLink , '/' ) !== false && substr ( $ parentLink , - 1 ) !== '/' ) { $ label = substr ( $ parentLink , strrpos ( $ parentLink , '/' ) + 1 ) ; $ parentLink = $ parentLink . '/' ; } if ( in_array ( $ parentLink , array ( '' , '/' ) ) ) { $ label = $ this -> getItem ( ) -> getLabel ( ) ; $ parentLink = '/' ; } $ data = array ( 'path' => $ parentLink , 'label' => $ label ) ; if ( $ depth <= 0 ) { $ data [ 'parent' ] = $ parentLink ; return $ data ; } $ children = array ( ) ; /** @var \oat\oatbox\filesystem\Directory $directory */ $ itemDirectory = $ this -> getItemDirectory ( ) ; if ( $ parentLink != '/' ) { $ directory = $ itemDirectory -> getDirectory ( $ parentLink ) ; } else { $ directory = $ itemDirectory ; } $ iterator = $ directory -> getFlyIterator ( ) ; foreach ( $ iterator as $ content ) { if ( $ content instanceof Directory ) { $ children [ ] = $ this -> getDirectory ( $ itemDirectory -> getRelPath ( $ content ) , $ acceptableMime , $ depth - 1 ) ; } else { $ fileInfo = $ this -> getInfoFromFile ( $ content ) ; if ( empty ( $ acceptableMime ) || in_array ( $ fileInfo [ 'mime' ] , $ acceptableMime ) ) { $ children [ ] = $ fileInfo ; } } } $ data [ 'children' ] = $ children ; return $ data ; }
Get a array representing the tree of directory

@see \oat\tao\model\media\MediaBrowser::getDirectory
@param string $parentLink
@param array $acceptableMime
@param int $depth
@return array
@throws \FileNotFoundException
@throws \tao_models_classes_FileNotFoundException
@throws common_exception_Error
Get a array representing the tree of directory