core-bundle/src/Resources/contao/elements/ContentDownloads.php
public function generate()
	{
		// Use the home directory of the current user as file source
		if ($this->useHomeDir && FE_USER_LOGGED_IN)
		{
			$this->import(FrontendUser::class, '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 (empty($this->multiSRC) && !\is_array($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 (see #4632 and #8375)
		if ($file != '' && (!isset($_GET['cid']) || Input::get('cid') == $this->id))
		{
			while ($this->objFiles->next())
			{
				if ($file == $this->objFiles->path || \dirname($file) == $this->objFiles->path)
				{
					Controller::sendFileToBrowser($file, (bool) $this->inline);
				}
			}

			if (isset($_GET['cid']))
			{
				throw new PageNotFoundException('Invalid file name');
			}

			$this->objFiles->reset();
		}

		return parent::generate();
	}
public function generate()
	{
		// Use the home directory of the current user as file source
		if ($this->useHomeDir && FE_USER_LOGGED_IN)
		{
			$this->import(FrontendUser::class, '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 (empty($this->multiSRC) && !\is_array($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 (see #4632 and #8375)
		if ($file != '' && (!isset($_GET['cid']) || Input::get('cid') == $this->id))
		{
			while ($this->objFiles->next())
			{
				if ($file == $this->objFiles->path || \dirname($file) == $this->objFiles->path)
				{
					Controller::sendFileToBrowser($file, (bool) $this->inline);
				}
			}

			if (isset($_GET['cid']))
			{
				throw new PageNotFoundException('Invalid file name');
			}

			$this->objFiles->reset();
		}

		return parent::generate();
	}
public function generate ( ) { // Use the home directory of the current user as file source if ( $ this -> useHomeDir && FE_USER_LOGGED_IN ) { $ this -> import ( FrontendUser :: class , '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 ( empty ( $ this -> multiSRC ) && ! \ is_array ( $ 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 (see #4632 and #8375) if ( $ file != '' && ( ! isset ( $ _GET [ 'cid' ] ) || Input :: get ( 'cid' ) == $ this -> id ) ) { while ( $ this -> objFiles -> next ( ) ) { if ( $ file == $ this -> objFiles -> path || \ dirname ( $ file ) == $ this -> objFiles -> path ) { Controller :: sendFileToBrowser ( $ file , ( bool ) $ this -> inline ) ; } } if ( isset ( $ _GET [ 'cid' ] ) ) { throw new PageNotFoundException ( 'Invalid file name' ) ; } $ this -> objFiles -> reset ( ) ; } return parent :: generate ( ) ; }
Return if there are no files

@return string
Return if there are no files