Esempio n. 1
0
 public function getRowset()
 {
     if (!isset($this->_rowset)) {
         $state = $this->getState();
         $folders = $this->getContainer()->getAdapter('iterator')->getFolders(array('path' => $this->_getPath(), 'recurse' => !!$state->tree, 'filter' => array($this, 'iteratorFilter'), 'map' => array($this, 'iteratorMap'), 'sort' => $state->sort));
         if ($folders === false) {
             throw new \UnexpectedValueException('Invalid folder');
         }
         $this->_total = count($folders);
         if (strtolower($state->direction) == 'desc') {
             $folders = array_reverse($folders);
         }
         $folders = array_slice($folders, $state->offset, $state->limit ? $state->limit : $this->_total);
         $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->_rowset = $this->createRowset()->addRow($results);
     }
     return parent::getRowset();
 }
Esempio n. 2
0
 public function getRowset()
 {
     if (!isset($this->_rowset)) {
         $state = $this->getState();
         $files = $this->getContainer()->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'), 'sort' => $state->sort));
         if ($files === false) {
             throw new \UnexpectedValueException('Invalid folder');
         }
         $this->_total = count($files);
         if (strtolower($this->getState()->direction) == 'desc') {
             $files = array_reverse($files);
         }
         $files = array_slice($files, $state->offset, $state->limit ? $state->limit : $this->_total);
         $data = array();
         foreach ($files as $file) {
             $data[] = array('container' => $state->container, 'folder' => $state->folder, 'name' => $file);
         }
         $this->_rowset = $this->createRowset(array('data' => $data));
     }
     return parent::getRowset();
 }