/** * Return if there are no files * * @return string */ public function generate() { // Use the home directory of the current user as file source if ($this->useHomeDir && FE_USER_LOGGED_IN) { $this->import('FrontendUser', 'User'); if ($this->User->assignDir && $this->User->homeDir) { $this->multiSRC = array($this->User->homeDir); } } else { $this->multiSRC = \StringUtil::deserialize($this->multiSRC); } // Return if there are no files if (!is_array($this->multiSRC) || empty($this->multiSRC)) { return ''; } // Get the file entries from the database $this->objFiles = \FilesModel::findMultipleByUuids($this->multiSRC); if ($this->objFiles === null) { return ''; } $file = \Input::get('file', true); // Send the file to the browser and do not send a 404 header (see #4632) if ($file != '' && !preg_match('/^meta(_[a-z]{2})?\\.txt$/', basename($file))) { while ($this->objFiles->next()) { if ($file == $this->objFiles->path || dirname($file) == $this->objFiles->path) { \Controller::sendFileToBrowser($file); } } $this->objFiles->reset(); } return parent::generate(); }
/** * Parse one or more items and return them as array * * @param Model\Collection $objArticles * @param boolean $blnAddArchive * * @return array */ protected function parseArticles($objArticles, $blnAddArchive = false) { $limit = $objArticles->count(); if ($limit < 1) { return array(); } $count = 0; $arrArticles = array(); while ($objArticles->next()) { /** @var NewsModel $objArticle */ $objArticle = $objArticles->current(); $arrArticles[] = $this->parseArticle($objArticle, $blnAddArchive, (++$count == 1 ? ' first' : '') . ($count == $limit ? ' last' : '') . ($count % 2 == 0 ? ' odd' : ' even'), $count); } return $arrArticles; }