/** * Display the view */ public function display($tpl = null) { $app = JFactory::getApplication(); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->filter = $this->get('Filter'); // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } foreach ($this->items as &$item) { $item->thumbObject = $thumb = new WebgalleryThumb($item->a_id); $path = JPATH_ROOT . '/' . $thumb->getPath(); $files = array(); if (JFolder::exists($path)) { $files = JFolder::files($path); } $item->thumbs = $files; } parent::displayWithPanel($tpl); }
/** * function fetchShots */ public function fetchImages() { $input = JFactory::getApplication()->input; $params = JComponentHelper::getParams('com_webgallery'); $token = $input->getVar($params->get('cron_token', 'grazingcat')); // Check Cron Token if ($token === null) { jexit('Invalid Token'); } $db = JFactory::getDbo(); // Get Lastest Queue $this->addModelPath(WEBGALLERY_ADMIN . '/models'); $model = $this->getModel('Queues'); $model->setState('list.limit', 1); $model->setState('list.ordering', 'a.id'); $model->setState('list.direction', 'asc'); $model->setState('filter', array('status' => '0')); $queues = $model->getItems(); // Check is lastest queue exists $queue = JArrayHelper::getValue($queues, 0, false); if (!$queue) { jexit(); } // Update status to 1 $q = $db->getQuery(true); $q->update('#__webgallery_queues')->set("status = 1")->where("id = {$queue->a_id}"); $db->setQuery($q); $db->execute(); // Fetch Images $thumb = new WebgalleryThumb($queue->a_item_id); $thumb->fetchImages(); // Update status to 2 $q = $db->getQuery(true); $q->update('#__webgallery_queues')->set("status = 2")->where("id = {$queue->a_id}"); $db->setQuery($q); $db->execute(); jexit(); }