Add CSS to the page

@param string  $strCSS    The css, scss or less content
@param string  $strType   The type of the content
@param boolean $bolStatic Set false to add the content in an extra file (only when type is css)
436945
public function addCSS ($strCSS, $strType='scss', $bolStatic=true)
	{
		if ($strCSS == '')
		{
			return;
		}
		
		$strType = strtoupper($strType);
		
		if (!in_array($strType, array('CSS', 'SCSS' , 'LESS')))
		{
			return;
		}
		
		if (!$bolStatic && $strType == 'css')
		{
			$strKey = substr(md5($strType . $strCSS), 0, 12);
			$strPath = 'assets/css/' . $strKey . '.' . $strType;
			
			// Write to a temporary file in the assets folder
			if (!file_exists($strPath))
			{
				$objFile = new File($strPath, true);
				$objFile->write($strCSS);
				$objFile->close();
			}
			
			// Add the file path to TL_USER_CSS
			$GLOBALS[TL_USER_CSS][] = $strPath;
		
			return;
		}
		// Add to the combined CSS string
		$GLOBALS['TL_CTB_' . $strType] .= $strCSS;
	}
900713
public function addJavaScript( $uri, $type = NULL, $charset = NULL )
	{
		$typeDefault	= 'text/javascript';
		if( isset( $this->metaTags["http-equiv:content-script-type"] ) )
			$typeDefault	= $this->metaTags["http-equiv:content-script-type"]['content'];
		$scriptData	= array(
			'type'		=> $type ? $type : $typeDefault,
			'charset'	=> $charset ? $charset : NULL,
			'src'		=> $uri,
		);
		$this->scripts[]	= $scriptData;
	}
579055
public function output($sType = 'ALL', $bOutput = true)
    {
        $aOut  = [];
        $sType = strtoupper($sType);

        //  Linked Stylesheets
        if (!empty($this->aCss) && ($sType == 'CSS' || $sType == 'ALL')) {

            foreach ($this->aCss as $sAsset) {
                $sAsset = $this->addCacheBuster($sAsset);
                $aOut[] = link_tag($sAsset);
            }
        }

        // --------------------------------------------------------------------------

        //  Linked JS
        if (!empty($this->aJs) && ($sType == 'JS' || $sType == 'ALL')) {

            foreach ($this->aJs as $sAsset) {
                $sAsset = $this->addCacheBuster($sAsset);
                $aOut[] = '<script src="' . $sAsset . '"></script>';
            }
        }

        // --------------------------------------------------------------------------

        //  Inline CSS
        if (!empty($this->aCssInline) && ($sType == 'CSS-INLINE' || $sType == 'ALL')) {

            $aOut[] = '<style type="text/css">';
            foreach ($this->aCssInline as $sAsset) {
                $aOut[] = preg_replace('/<\/?style.*?>/si', '', $sAsset);
            }
            $aOut[] = '</style>';
        }

        // --------------------------------------------------------------------------

        //  Inline JS (Header)
        if (!empty($this->aJsInlineHeader) && ($sType == 'JS-INLINE-HEADER' || $sType == 'ALL')) {
            $aOut[] = '<script>';
            foreach ($this->aJsInlineHeader as $sAsset) {
                $aOut[] = preg_replace('/<\/?script.*?>/si', '', $sAsset);
            }
            $aOut[] = '</script>';
        }

        // --------------------------------------------------------------------------

        //  Inline JS (Footer)
        if (!empty($this->aJsInlineFooter) && ($sType == 'JS-INLINE-FOOTER' || $sType == 'ALL')) {
            $aOut[] = '<script>';
            foreach ($this->aJsInlineFooter as $sAsset) {
                $aOut[] = preg_replace('/<\/?script.*?>/si', '', $sAsset);
            }
            $aOut[] = '</script>';
        }

        // --------------------------------------------------------------------------

        //  Force SSL for assets if page is secure
        if (Functions::isPageSecure()) {
            foreach ($aOut as &$sLine) {
                $sLine = str_replace($this->sBaseUrl, $this->sBaseUrlSecure, $sLine);
            }
        }

        // --------------------------------------------------------------------------

        if ($bOutput) {
            echo implode("\n", $aOut);
        }

        return $aOut;
    }
352888
public function setContentType($type, $statusCode=null)
    {
        if (isset(static::$_types[$type])) {
            $type = static::$_types[$type];
        }
        $this->setHeader('Content-Type', $type);
        if ($statusCode) {
            $this->_statusCode = $statusCode;
        }
    }
647648
public function display($template = 'page.tpl', $cache_id = null, $compile_id = null, $parent = null)
    {
        if ($this->isFramed()) {
            $this->addStylesheet(
                DataUtilities::URLfromPath(__DIR__ . '/../css/StMarksSmarty.css') . '?isFramed=true',
                self::KEY
            );
        }
        $this->assign('isFramed', $this->isFramed());

        parent::display($template, $cache_id, $compile_id, $parent);
    }
66348
public function get_css_content_debug($type, $subtype, $sheet) {

        if ($type === 'scss') {
            // The SCSS file of the theme is requested.
            $csscontent = $this->get_css_content_from_scss(true);
            if ($csscontent !== false) {
                return $this->post_process($csscontent);
            }
            return '';
        } else if ($type === 'less') {
            // The LESS file of the theme is requested.
            $csscontent = $this->get_css_content_from_less(true);
            if ($csscontent !== false) {
                return $this->post_process($csscontent);
            }
            return '';
        }

        $cssfiles = array();
        $css = $this->get_css_files(true);

        if ($type === 'ie') {
            // IE is a sloppy browser with weird limits, sorry.
            if ($subtype === 'plugins') {
                $cssfiles = $css['plugins'];

            } else if ($subtype === 'parents') {
                if (empty($sheet)) {
                    // Do not bother with the empty parent here.
                } else {
                    // Build up the CSS for that parent so we can serve it as one file.
                    foreach ($css[$subtype][$sheet] as $parent => $css) {
                        $cssfiles[] = $css;
                    }
                }
            } else if ($subtype === 'theme') {
                $cssfiles = $css['theme'];
                foreach ($cssfiles as $key => $value) {
                    if (in_array($key, [$this->lessfile, self::SCSS_KEY])) {
                        // Remove the LESS/SCSS file from the theme CSS files.
                        // The LESS/SCSS files use the type 'less' or 'scss', not 'ie'.
                        unset($cssfiles[$key]);
                    }
                }
            }

        } else if ($type === 'plugin') {
            if (isset($css['plugins'][$subtype])) {
                $cssfiles[] = $css['plugins'][$subtype];
            }

        } else if ($type === 'parent') {
            if (isset($css['parents'][$subtype][$sheet])) {
                $cssfiles[] = $css['parents'][$subtype][$sheet];
            }

        } else if ($type === 'theme') {
            if (isset($css['theme'][$sheet])) {
                $cssfiles[] = $css['theme'][$sheet];
            }
        }

        $csscontent = '';
        foreach ($cssfiles as $file) {
            $contents = file_get_contents($file);
            $contents = $this->post_process($contents);
            $comment = "/** Path: $type $subtype $sheet.' **/\n";
            $stats = '';
            $csscontent .= $comment.$stats.$contents."\n\n";
        }

        return $csscontent;
    }
1011879
function add_css()
    {
        if ($this->css_loaded) {
            return;
        }

        $skin_path = $this->enigma->local_skin_path();
        $this->enigma->include_stylesheet("$skin_path/enigma.css");
        $this->css_loaded = true;
    }
582920
public function addStylesheet($stylesheet, $inline = true)
    {
        $type = $inline ? 'inline' : 'external';
        $this->stylesheets[$type][] = $stylesheet;
    }
1215837
function postcssToHTML(root, builder) {
	function toString(node) {
		if ('atrule' === node.type) {
			return atruleToString(node);
		} if ('rule' === node.type) {
			return ruleToString(node);
		} else if ('decl' === node.type) {
			return declToString(node);
		} else if ('comment' === node.type) {
			return commentToString(node);
		} else {
			return node.nodes ? node.nodes.map(childNodes => toString(childNodes)).join('') : '';
		}
	}

	function replaceVars(string) {
		return string
			.replace(/:?--[\w-]+/g, '<span class=css-var>$&</span>')
	}

	function replaceVarsAndFns(string) {
		return replaceVars(string)
			.replace(/(:?[\w-]+)\(/g, '<span class=css-function>$1</span>(')
			.replace(/"[^"]+"/g, '<span class=css-string>$&</span>')
	}

	function atruleToString(atrule) {
		return `${atrule.raws.before||''}<span class=css-atrule><span class=css-atrule-name>@${atrule.name}</span>${atrule.raws.afterName||''}<span class=css-atrule-params>${replaceVarsAndFns(atrule.params)}</span>${atrule.raws.between||''}${atrule.nodes?`<span class=css-block>{${atrule.nodes.map(node => toString(node)).join('')}${atrule.raws.after||''}}</span>`:';'}</span>`;
	}

	function ruleToString(rule) {
		return `${rule.raws.before||''}<span class=css-rule><span class=css-selector>${replaceVars(rule.selector)}</span>${rule.raws.between||''}<span class=css-block>{${rule.nodes.map(node => toString(node)).join('')}${rule.raws.after||''}}</span></span>`;
	}

	function declToString(decl) {
		return `${decl.raws.before || ''}<span class=css-declaration><span class=css-property>${decl.prop}</span>${decl.raws.between || ':'}<span class=css-value>${replaceVarsAndFns(decl.value)}</span>;</span>`;
	}

	function commentToString(comment) {
		return `${comment.raws.before}<span class=css-comment>/*${comment.raws.left}${comment.text}${comment.raws.right}*/</span>`;
	}

	builder(
		toString(root)
	);
}
1156007
public function css($header = true) {
        $out = '';
        if (count($this->errors) > 0) {
            if ($header)
                $out .= '<style type="text/css" media="screen">';
            $out .= "#" . implode(", #", array_keys($this->errors)) . " { {$this->style} }";
            if ($header)
                $out .= '</style>';
        }
        echo $out;
    }
946547
public void writeResources(String strClassName)
    {
    	boolean bResourceListBundle = ResourceTypeField.LIST_RESOURCE_BUNDLE.equals(this.getRecord(ProgramControl.PROGRAM_CONTROL_FILE).getField(ProgramControl.CLASS_RESOURCE_TYPE).toString());
	   	if (bResourceListBundle)
	   	{
	        m_StreamOut.writeit("protected Object[][] contents = {\n");
	        m_StreamOut.setTabs(+1);
	   	}
        ClassResource recClassResource = new ClassResource(this);
        recClassResource.setKeyArea(ClassResource.CLASS_NAME_KEY);
        recClassResource.addListener(new StringSubFileFilter(strClassName, ClassResource.CLASS_NAME, null, null, null, null));
        try   {
            recClassResource.close();
            while (recClassResource.hasNext())
            {
                recClassResource.next();
               	if (bResourceListBundle)
               		m_StreamOut.writeit("{\"" + recClassResource.getField(ClassResource.KEY_NAME).toString()
                            + "\"," + ResourcesUtilities.fixPropertyValue(recClassResource.getField(ClassResource.VALUE_NAME).toString(), bResourceListBundle) + "},\n");
               	else
                    m_StreamOut.writeit(recClassResource.getField(ClassResource.KEY_NAME).toString()
                        + "=" + ResourcesUtilities.fixPropertyValue(recClassResource.getField(ClassResource.VALUE_NAME).toString(), bResourceListBundle) + "\n");
            }
        } catch (DBException ex)    {
            ex.printStackTrace();
        }
        recClassResource.free();
       	if (bResourceListBundle)
       	{
       		m_StreamOut.setTabs(-1);
       		m_StreamOut.writeit("};\n");
       	}
    }
783822
public static function convertToInlineCss($strText, $strCssText = null)
    {
        // apply the css inliner
        $objCssInliner = new \TijsVerkoyen\CssToInlineStyles\CssToInlineStyles();

        return $objCssInliner->convert($strText, $strCssText);
    }
218600
public function addCss($link) {
        if ( ! empty($link)) {
            if ( ! is_array($link)) {
                $link = [$link];
            }
            $this->css = array_merge($this->css, $link);
        }
    }
1155272
public function addString($str_name, $bol_index = TRUE)
    {
        return $this->addProperty($str_name, self::PROPERTY_STRING, $bol_index);
    }
1087229
public void setContent(final String contentString, final String type) {
        final Content newContent = new Content();
        newContent.setType(type == null ? Content.HTML : type);
        newContent.setValue(contentString);
        final ArrayList<Content> contents = new ArrayList<Content>();
        contents.add(newContent);
        setContents(contents);
    }
503488
public function writeHtml($strHtml, $strCss = '')
    {
        $strHtml = ($strCss ? '<style>' . $strCss . '</style>' : '') . $strHtml;

        $this->objPdf->WriteHTML(html_entity_decode($this->replaceInsertTags($strHtml)));
    }
681138
public static function AppendCSS($sFilenameCSS){
            $oThis = self::CreateInstanceIfNotExists();

            if(file_exists($sFilenameCSS))
                $oThis->aCSS[] = file_get_contents($sFilenameCSS);
        }