src/Common/Service/Asset.php
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;
    }
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;
    }
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 ; }
Output the assets for HTML

@param  string  $sType   The type of asset to output
@param  boolean $bOutput Whether to output to the browser or to return as a string

@return string
Output the assets for HTML