Пример #1
0
 protected function _fetchData(KViewContext $context)
 {
     $state = $this->getModel()->getState();
     $container = $this->getModel()->getContainer();
     $config = new KObjectConfig($state->config);
     $config->append(array('router' => array('defaults' => array('option' => 'com_' . substr($container->slug, 0, strpos($container->slug, '-')), 'routed' => '1')), 'initial_response' => true))->append($this->getConfig()->config);
     if ($config->initial_response === true) {
         $count = 0;
         $query = $state->getValues();
         unset($query['config']);
         $query['thumbnails'] = $this->getModel()->getContainer()->getParameters()->thumbnails;
         if (strpos($this->getLayout(), 'compact') !== false) {
             $query['limit'] = 0;
             $count = ComFilesIteratorDirectory::countNodes(array('path' => $this->getModel()->getPath()));
         }
         if ($count < 100) {
             $controller = $this->getObject('com:files.controller.node');
             $controller->getRequest()->setQuery($query);
             $config->initial_response = $controller->format('json')->render();
         } else {
             unset($config->initial_response);
         }
     }
     $state->config = $config->toArray();
     $context->data->sitebase = trim(JURI::root(), '/');
     $context->data->token = $this->getObject('user')->getSession()->getToken();
     $context->data->container = $container;
     $context->data->debug = KClassLoader::getInstance()->isDebug();
     parent::_fetchData($context);
     $context->parameters = $state->getValues();
     $context->parameters->config = $config;
 }
Пример #2
0
 public function getNodes(array $config = array())
 {
     $config['path'] = $this->getObject('com:files.adapter.folder', array('path' => $config['path']))->getRealPath();
     try {
         $results = ComFilesIteratorDirectory::getNodes($config);
     } catch (Exception $e) {
         return false;
     }
     return $results;
 }
Пример #3
0
 public function getNodes(array $config = array())
 {
     $config['path'] = $this->getService('com://admin/files.adapter.local.folder', array('path' => $config['path']))->getRealPath();
     try {
         $results = ComFilesIteratorDirectory::getNodes($config);
     } catch (Exception $e) {
         return false;
     }
     foreach ($results as &$result) {
         $result = rawurldecode($result);
     }
     return $results;
 }
Пример #4
0
 public function getList()
 {
     if (!isset($this->_list)) {
         $state = $this->_state;
         $state->basepath = rtrim(str_replace('\\', '/', $state->basepath), '\\');
         $path = $state->basepath;
         if (!empty($state->folder) && $state->folder != '/') {
             $path .= '/' . ltrim($state->folder, '/');
         }
         if (!$state->basepath || !is_dir($path)) {
             throw new KModelException('Basepath is not a valid folder');
         }
         if (!empty($state->path)) {
             $folders = array();
             foreach ((array) $state->path as $path) {
                 $folders[] = $path;
             }
         } else {
             $folders = ComFilesIteratorDirectory::getFolders(array('path' => $path, 'recurse' => !!$state->tree, 'filter' => array($this, 'iteratorFilter'), 'map' => array($this, 'iteratorMap')));
         }
         $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) {
             $hier = array();
             if ($state->tree) {
                 $hier = explode('/', dirname($folder));
                 if (count($hier) === 1 && $hier[0] === '.') {
                     $hier = array();
                 }
             }
             $results[] = array('basepath' => $state->basepath, 'path' => $folder, 'hierarchy' => $hier);
         }
         $rowset = $this->getService('com://admin/files.database.rowset.folders');
         $rowset->addData($results);
         $this->_list = $rowset;
     }
     return parent::getList();
 }
Пример #5
0
 public function getList()
 {
     if (!isset($this->_list)) {
         $state = $this->_state;
         if (!$state->basepath) {
             throw new KModelException('Basepath is not a valid folder');
         }
         $basepath = $state->basepath;
         $path = $basepath;
         if (!empty($state->folder) && $state->folder != '/') {
             $path .= '/' . ltrim($state->folder, '/');
         }
         if (!is_dir($path)) {
             throw new KModelException('Basepath is not a valid folder');
         }
         $name = $state->path ? $state->path : null;
         if (is_string($name)) {
             $files[] = $name;
         } else {
             if (is_array($name)) {
                 $files = array();
                 foreach ($name as $n) {
                     $files[] = $n;
                 }
             } else {
                 $files = ComFilesIteratorDirectory::getFiles(array('path' => $path, 'exclude' => array('.svn', '.htaccess', '.git', 'CVS', 'index.html', '.DS_Store', 'Thumbs.db', 'Desktop.ini'), 'filter' => array($this, 'iteratorFilter'), 'map' => array($this, 'iteratorMap')));
             }
         }
         $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, 'basepath' => $basepath, 'path' => $file);
         }
         $this->_list = $this->getService('com://admin/files.database.rowset.files', array('data' => $data));
     }
     return parent::getList();
 }
Пример #6
0
	public function getIcons()
	{
		static $path = 'media/com_files/images', $default, $icons16, $icons32;

		if (!isset($default)) {
			$default = $path.'/con_info.png';
		}
		if (!isset($icons16)) {
			$icons16 = ComFilesIteratorDirectory::getFiles(array(
            	'path' => JPATH_ROOT.'/'.$path.'/mime-icon-16',
				'filter' => array('png')
            ));
		}
		if (!isset($icons32)) {
			$icons32 = ComFilesIteratorDirectory::getFiles(array(
            	'path' => JPATH_ROOT.'/'.$path.'/mime-icon-32',
				'filter' => array('png')
            ));
		}

		$icons = array();

		$icons['16'] = in_array($this->extension.'.png', $icons16) ? $path.'/mime-icon-16/'.$this->extension.'.png' : $default;
		$icons['32'] = in_array($this->extension.'.png', $icons32) ? $path.'/mime-icon-32/'.$this->extension.'.png' : $default;

		return $icons;
	}