Exemple #1
0
    protected function _getList(KModelAbstract $model)
    {
    	// Save state data for later
        $state_data = $model->getState()->getData();

        $nodes = KFactory::get('com://admin/files.model.nodes')->set($state_data)->getList();

        $needed  = array();
        foreach ($nodes as $row)
        {
        	if ($row->isImage()) {
        		$needed[] = $row->name;	
        	}
        }

		$model->reset();
		$model->set('files', $needed);
		$list  = array_values($model->getList()->toArray());

    	$found = array();
        foreach ($list as $row) {
        	$found[] = $row['filename'];
        }

        if ($found !== $needed) 
        {
        	$new = array();
        	foreach ($nodes as $row) 
        	{
        		if ($row->isImage() && !in_array($row->name, $found)) 
        		{
	        		$result = $row->saveThumbnail(null);
	        		if ($result) {
	        			$new[] = $row->name;
	        		}
        		}
        	}
        	if (count($new))
        	{
				$model->reset();
				$model->set('files', $new);
				$list  = array_merge($list, array_values($model->getList()->toArray()));
        	}
        }
       
        $results = array();
        foreach ($list as $item) {
        	$key = $item['filename'];
        	$results[$key] = $item;
        }
        ksort($results);

        $output = new stdclass;
        $output->total  = count($list);
        $output->limit  = $state_data['limit'];
        $output->offset = $state_data['offset'];
        $output->items  = $results;

        return $output;
    }
Exemple #2
0
 public function getImages()
 {
     //Removed by DC Oct 2010 to allow for multiple image pickers on one page
     //if(!isset($this->_images))
     parent::getList();
     return $this->_images;
 }
 /**
  * Get packages
  *
  * @return  object
  */
 public function getList()
 {
     if (!isset($this->_list)) {
         $this->_list = JFolder::files($this->_state->directory, '^[A-Za-z0-9]', false, false);
         $this->_total = count($this->_list);
     }
     return parent::getList();
 }
Exemple #4
0
    protected function _getList(KModelAbstract $model)
    {
        $list  = array_values($model->getList()->toArray());
        $state = $model->getState();
        $total = $model->getTotal();

        $output = new stdclass;
        $output->total  = $total;
        $output->limit  = $state->limit;
        $output->offset = $state->offset;
        $output->items  = $list;

        return $output;
    }
Exemple #5
0
 /**
  * Get a list of items which represnts a  table rowset
  *
  * @return  object KDatabaseRowset
  */
 public function getList()
 {
     // Get the data if it doesn't already exist
     if (!isset($this->_list)) {
         $this->_list = $this->getTable()->fetchAll($this->_buildQuery(), $this->getState('offset'), $this->getState('limit'));
     }
     return parent::getList();
 }
 public function getList()
 {
     if (!isset($this->_list)) {
         $state = $this->_state;
         $languages = array();
         foreach ((array) KConfig::unbox($state->application) as $application) {
             $client = JApplicationHelper::getClientInfo($application, true);
             if (!empty($client)) {
                 $default = JComponentHelper::getParams('com_extensions')->get('language_' . $client->name, 'en-GB');
                 //Find the languages
                 $path = $client->path . '/language';
                 foreach (new DirectoryIterator($path) as $folder) {
                     if ($folder->isDir()) {
                         if (file_exists($folder->getRealPath() . '/' . $folder->getFilename() . '.xml')) {
                             $languages[] = array('path' => $folder->getRealPath(), 'application' => $client->name);
                         }
                     }
                 }
             }
         }
         //Set the total
         $this->_total = count($languages);
         //Apply limit and offset
         if ($state->limit) {
             $languages = array_slice($languages, $state->offset, $state->limit ? $state->limit : $this->_total);
         }
         //Apply direction
         if (strtolower($state->direction) == 'desc') {
             $languages = array_reverse($languages);
         }
         $rowset = $this->getService('com://admin/extensions.database.rowset.languages');
         foreach ($languages as $language) {
             $row = $rowset->getRow()->setData($language);
             $row->default = $row->name == $default;
             $rowset->insert($row);
         }
         $this->_list = $rowset;
     }
     return parent::getList();
 }
 /**
  * Get a list of items which represnts a  table rowset
  *
  * @return KDatabaseRowset
  */
 public function getList()
 {
     // Get the data if it doesn't already exist
     if (!isset($this->_list)) {
         $this->_list = $this->_filterItems();
         //$table = $this->getTable();
         //$query = $this->_buildQuery();
         //$this->_list = $table->fetchRowset($query);
     }
     return parent::getList();
 }