Contao\ContentDownload::compile PHP Method

compile() protected method

Generate the content element
protected compile ( )
    protected function compile()
    {
        $objFile = new \File($this->singleSRC);
        if ($this->linkTitle == '') {
            $this->linkTitle = \StringUtil::specialchars($objFile->basename);
        }
        $strHref = \Environment::get('request');
        // Remove an existing file parameter (see #5683)
        if (preg_match('/(&(amp;)?|\\?)file=/', $strHref)) {
            $strHref = preg_replace('/(&(amp;)?|\\?)file=[^&]+/', '', $strHref);
        }
        $strHref .= (strpos($strHref, '?') !== false ? '&' : '?') . 'file=' . \System::urlEncode($objFile->value);
        $this->Template->link = $this->linkTitle;
        $this->Template->title = \StringUtil::specialchars($this->titleText ?: sprintf($GLOBALS['TL_LANG']['MSC']['download'], $objFile->basename));
        $this->Template->href = $strHref;
        $this->Template->filesize = $this->getReadableSize($objFile->filesize, 1);
        $this->Template->icon = \Image::getPath($objFile->icon);
        $this->Template->mime = $objFile->mime;
        $this->Template->extension = $objFile->extension;
        $this->Template->path = $objFile->dirname;
    }
ContentDownload