Esempio n. 1
0
 public function getList()
 {
     if (!isset($this->_list)) {
         $state = $this->_state;
         $folders = $state->container->getAdapter('iterator')->getFolders(array('path' => $this->_getPath(), 'recurse' => !!$state->tree, 'filter' => array($this, 'iteratorFilter'), 'map' => array($this, 'iteratorMap')));
         if ($folders === false) {
             throw new KModelException('Invalid folder');
         }
         $this->_total = count($folders);
         $folders = array_slice($folders, $state->offset, $state->limit ? $state->limit : $this->_total);
         if (strtolower($this->_state->direction) == 'desc') {
             $folders = array_reverse($folders);
         }
         $results = array();
         foreach ($folders as $folder) {
             $hierarchy = array();
             if ($state->tree) {
                 $hierarchy = explode('/', dirname($folder));
                 if (count($hierarchy) === 1 && $hierarchy[0] === '.') {
                     $hierarchy = array();
                 }
             }
             $results[] = array('container' => $state->container, 'folder' => $hierarchy ? implode('/', $hierarchy) : $state->folder, 'name' => basename($folder), 'hierarchy' => $hierarchy);
         }
         $this->_list = $this->getRowset()->addData($results);
     }
     return parent::getList();
 }
Esempio n. 2
0
 public function getList()
 {
     if (!isset($this->_list)) {
         $state = $this->_state;
         $files = $state->container->getAdapter('iterator')->getFiles(array('path' => $this->_getPath(), 'exclude' => array('.svn', '.htaccess', '.git', 'CVS', 'index.html', '.DS_Store', 'Thumbs.db', 'Desktop.ini'), 'filter' => array($this, 'iteratorFilter'), 'map' => array($this, 'iteratorMap')));
         if ($files === false) {
             throw new KModelException('Invalid folder');
         }
         $this->_total = count($files);
         $files = array_slice($files, $state->offset, $state->limit ? $state->limit : $this->_total);
         if (strtolower($this->_state->direction) == 'desc') {
             $files = array_reverse($files);
         }
         $data = array();
         foreach ($files as $file) {
             $data[] = array('container' => $state->container, 'folder' => $state->folder, 'name' => $file);
         }
         $this->_list = $this->getRowset(array('data' => $data));
     }
     return parent::getList();
 }