/** * 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 = 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) { if (!\Validator::isUuid($this->multiSRC[0])) { return '<p class="error">' . $GLOBALS['TL_LANG']['ERR']['version2format'] . '</p>'; } 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(); }
/** * Generate the module */ protected function compile() { $this->Template->size = ''; // Set the size if ($this->playerSize != '') { $size = deserialize($this->playerSize); if (is_array($size)) { $this->Template->size = ' width="' . $size[0] . 'px" height="' . $size[1] . 'px"'; } } $this->Template->poster = false; // Optional poster if ($this->posterSRC != '') { if (($objFile = \FilesModel::findByPk($this->posterSRC)) !== null) { $this->Template->poster = $objFile->path; } } // Pre-sort the array by preference if (in_array($this->objFiles->extension, array('mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv'))) { $this->Template->isVideo = true; $arrFiles = array('mp4' => null, 'm4v' => null, 'mov' => null, 'wmv' => null, 'webm' => null, 'ogv' => null); } else { $this->Template->isVideo = false; $arrFiles = array('m4a' => null, 'mp3' => null, 'wma' => null, 'mpeg' => null, 'wav' => null); } $this->objFiles->reset(); // Pass File objects to the template while ($this->objFiles->next()) { $objFile = new \File($this->objFiles->path); $arrFiles[$objFile->extension] = $objFile; } $this->Template->files = array_values(array_filter($arrFiles)); $this->Template->autoplay = $this->autoplay; }
/** * Generate the module */ protected function compile() { global $objPage; $this->Template->size = ''; // Set the size if ($this->playerSize != '') { $size = deserialize($this->playerSize); if (is_array($size)) { $this->Template->size = ' width="' . $size[0] . '" height="' . $size[1] . '"'; } } $this->Template->poster = false; // Optional poster if ($this->posterSRC != '') { if (($objFile = \FilesModel::findByUuid($this->posterSRC)) !== null) { $this->Template->poster = $objFile->path; } } // Pre-sort the array by preference if (in_array($this->objFiles->extension, array('mp4', 'm4v', 'mov', 'wmv', 'webm', 'ogv'))) { $this->Template->isVideo = true; $arrFiles = array('mp4' => null, 'm4v' => null, 'mov' => null, 'wmv' => null, 'webm' => null, 'ogv' => null); } else { $this->Template->isVideo = false; $arrFiles = array('m4a' => null, 'mp3' => null, 'wma' => null, 'mpeg' => null, 'wav' => null, 'ogg' => null); } $this->objFiles->reset(); // Convert the language to a locale (see #5678) $strLanguage = str_replace('-', '_', $objPage->language); // Pass File objects to the template while ($this->objFiles->next()) { $arrMeta = deserialize($this->objFiles->meta); if (is_array($arrMeta) && isset($arrMeta[$strLanguage])) { $strTitle = $arrMeta[$strLanguage]['title']; } else { $strTitle = $this->objFiles->name; } $objFile = new \File($this->objFiles->path, true); $objFile->title = specialchars($strTitle); $arrFiles[$objFile->extension] = $objFile; } $this->Template->files = array_values(array_filter($arrFiles)); $this->Template->autoplay = $this->autoplay; }
protected function getPlayerSRCList($arrFiles) { global $objPage; $arrFiles = array(); $this->objFiles->reset(); // Convert the language to a locale (see #5678) $strLanguage = str_replace('-', '_', $objPage->language); // Pass File objects to the template while ($this->objFiles->next()) { $arrMeta = deserialize($this->objFiles->meta); if (is_array($arrMeta) && isset($arrMeta[$strLanguage])) { $strTitle = $arrMeta[$strLanguage]['title']; } else { $strTitle = $this->objFiles->name; } $objFile = new \File($this->objFiles->path, true); $objFile->title = specialchars($strTitle); $arrFiles[$objFile->extension] = $objFile; } return $arrFiles; }