Classes/Services/LayerContentService.php
public function getFolderData($objLayer, $key=false, $folder=false, $count=0)
    {
        if (!$folder) {
            $folder = $this->getFolder($objLayer);
        }
        if (!$key) {
            $key =$objLayer->id;
        }
        $folderPath = realpath(TL_ROOT.'/'.$folder);
        $countFiles = 2050;
        
        if (is_dir($folderPath)) {
            $dict = scandir($folderPath);
            unset($dict[array_search('.', $dict)]);
            unset($dict[array_search('..', $dict)]);
            foreach ($dict as $value) {
//                $value = utf8_encode($value);
                $path = realpath(TL_ROOT."/".$folder."/".$value);
                if (is_dir($path)) {
                    $fileFolder = pathinfo($path);
                    $arrSubFolder = $this->getFolderContent($objLayer, $fileFolder, $key, $count);
                    $count += 1;
                    $data = $this->getFolderData($objLayer,  $arrSubFolder['id'], $folder."/".$value, $count);
                    if ($data) {
                        $arrSubFolder['childsCount'] = count($data);
                        $arrSubFolder['childs'] = $data;
                        $arrData[] = $arrSubFolder;
                    }
                } elseif (is_file($path)) {
                    $fileData = pathinfo($path);
                    $arrFile = $this->getFileContent($objLayer, $folder, $fileData, $key, $countFiles);
                    $countFiles += 2;
                    if($arrFile) {
                        $arrData[] = $arrFile;
                    }
                }
            }
            return $arrData;
        } else {
            return false;
        }
    }
public function getFolderData($objLayer, $key=false, $folder=false, $count=0)
    {
        if (!$folder) {
            $folder = $this->getFolder($objLayer);
        }
        if (!$key) {
            $key =$objLayer->id;
        }
        $folderPath = realpath(TL_ROOT.'/'.$folder);
        $countFiles = 2050;
        
        if (is_dir($folderPath)) {
            $dict = scandir($folderPath);
            unset($dict[array_search('.', $dict)]);
            unset($dict[array_search('..', $dict)]);
            foreach ($dict as $value) {
//                $value = utf8_encode($value);
                $path = realpath(TL_ROOT."/".$folder."/".$value);
                if (is_dir($path)) {
                    $fileFolder = pathinfo($path);
                    $arrSubFolder = $this->getFolderContent($objLayer, $fileFolder, $key, $count);
                    $count += 1;
                    $data = $this->getFolderData($objLayer,  $arrSubFolder['id'], $folder."/".$value, $count);
                    if ($data) {
                        $arrSubFolder['childsCount'] = count($data);
                        $arrSubFolder['childs'] = $data;
                        $arrData[] = $arrSubFolder;
                    }
                } elseif (is_file($path)) {
                    $fileData = pathinfo($path);
                    $arrFile = $this->getFileContent($objLayer, $folder, $fileData, $key, $countFiles);
                    $countFiles += 2;
                    if($arrFile) {
                        $arrData[] = $arrFile;
                    }
                }
            }
            return $arrData;
        } else {
            return false;
        }
    }
public function getFolderData ( $ objLayer , $ key = false , $ folder = false , $ count = 0 ) { if ( ! $ folder ) { $ folder = $ this -> getFolder ( $ objLayer ) ; } if ( ! $ key ) { $ key = $ objLayer -> id ; } $ folderPath = realpath ( TL_ROOT . '/' . $ folder ) ; $ countFiles = 2050 ; if ( is_dir ( $ folderPath ) ) { $ dict = scandir ( $ folderPath ) ; unset ( $ dict [ array_search ( '.' , $ dict ) ] ) ; unset ( $ dict [ array_search ( '..' , $ dict ) ] ) ; foreach ( $ dict as $ value ) { //                $value = utf8_encode($value); $ path = realpath ( TL_ROOT . "/" . $ folder . "/" . $ value ) ; if ( is_dir ( $ path ) ) { $ fileFolder = pathinfo ( $ path ) ; $ arrSubFolder = $ this -> getFolderContent ( $ objLayer , $ fileFolder , $ key , $ count ) ; $ count += 1 ; $ data = $ this -> getFolderData ( $ objLayer , $ arrSubFolder [ 'id' ] , $ folder . "/" . $ value , $ count ) ; if ( $ data ) { $ arrSubFolder [ 'childsCount' ] = count ( $ data ) ; $ arrSubFolder [ 'childs' ] = $ data ; $ arrData [ ] = $ arrSubFolder ; } } elseif ( is_file ( $ path ) ) { $ fileData = pathinfo ( $ path ) ; $ arrFile = $ this -> getFileContent ( $ objLayer , $ folder , $ fileData , $ key , $ countFiles ) ; $ countFiles += 2 ; if ( $ arrFile ) { $ arrData [ ] = $ arrFile ; } } } return $ arrData ; } else { return false ; } }
Creates the layer data for a given layer of the location_type folder.
@param $objLayer
@param bool $key
@param bool $folder
@param int $count
@return array|bool
Creates the layer data for a given layer of the location_type folder .