Return the javascript header code and file includes

@return string
161349
public function getJs()
    {
        if(!$this->includeAssets())
        {
            return '';
        }
        $libraries = $this->getLibrariesInUse();
        $code = '';
        foreach($libraries as $library)
        {
            $code .= "\n" . $library->getJs() . "\n";
        }
        return $code;
    }
1061731
protected function getHeaders()
    {
        if (function_exists('headers_list') && $headers = headers_list()) {
            foreach ((array) $headers as $header) {
                if (strpos($header, ':')) {
                    $header = explode(':', strtolower($header), 2);
                    $this->headers[trim($header[0])] = trim($header[1]);
                }
            }
        }
    }
932848
public function GetHtmlHeadIncludes()
    {
        $aIncludes = parent::GetHtmlHeadIncludes();

        if (isset($this->oActiveShippingGroup)) {
            $oPaymentMethodList = TShopBasket::GetInstance()->GetAvailablePaymentMethods();
            if ($oPaymentMethodList) {
                while ($oPaymentMethod = $oPaymentMethodList->Next()) {
                    $oPaymentHandler = $oPaymentMethod->GetFieldShopPaymentHandler();

                    if (method_exists($oPaymentHandler, 'GetHtmlHeadIncludes')) {
                        $aAdditionalIncludes = $oPaymentHandler->GetHtmlHeadIncludes();
                        if (count($aAdditionalIncludes) > 0) {
                            $aIncludes = array_merge($aIncludes, $aAdditionalIncludes);
                        }
                    }
                }
            }
        }

        return $aIncludes;
    }
402976
private function checkIncludeJavascript() {
        $request = $this->requestStack->getCurrentRequest();
        $rtn = !$request->attributes->has($this::JS_INCLUDE_KEY);
        if (!$rtn) {
            $request->attributes->set($this::JS_INCLUDE_KEY, true);
        }
        return $rtn;
    }
278898
protected function getHeadersAsText()
    {
        $headers = '';

        foreach ($this->headers as $header) {
            foreach ($header[1] as $headerValue) {
                $headers .= $header[0] . ': ' . $headerValue . "\r\n";
            }
        }

        return $headers;
    }
310564
public function getSentHeaders()
    {
        $compiledHeaders = [];

        foreach ($this->headers as $header)
        {
            $compiledHeaders[] = (string) $header;
        }

        return implode("\n", $compiledHeaders);
    }
293261
protected function getFileName()
    {
        if (!$this->fileName) {
            $this->fileName = preg_replace('/\W/', '.', get_class($this)) . '.json';
        }
        return codecept_data_dir() . $this->fileName;
    }
1033287
public function export_headers()
    {
        $header_string = '';
        foreach ($this->headers as $header => $value) {
            $header_string .= "$header: $value\n";
        }
        $poified = self::poify($header_string);
        if ($this->comments_before_headers) {
            $before_headers = self::prepend_each_line(
                rtrim($this->comments_before_headers) . "\n",
                '# '
            );
        } else {
            $before_headers = '';
        }

        return rtrim("{$before_headers}msgid \"\"\nmsgstr $poified");
    }
973860
private function getCode()
    {
        $_paq = '';
        foreach ($this->options as $key => $values) {
            foreach ($values as &$value) {
                $value = "'".$value."'";
            }
            $_paq .= sprintf("_paq.push([%s]);\n", implode($values, ','));
        }

        return <<<PWK
<script>
var _paq = _paq || [];
{$_paq}
(function() {
    var u="{$this->piwikUrl}";
    _paq.push(['setSiteId', {$this->siteId}]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="{$this->piwikUrl}piwik.php?idsite={$this->siteId}" style="border:0;" alt="" /></p></noscript>
PWK;
    }
776823
public function getHeadersAsArray()
    {
        $headers = array();
        foreach ($this->getHeaders() as $headerNode) {
            $header = array(
                'type' => $headerNode->getType(),
                'name' => $headerNode->getName(),
                'value' => $headerNode->getValue(),
                'uri' => $headerNode->getUri(),
                'override' => $headerNode->getOverride(),
                'append' => $headerNode->getAppend()
            );
            $headers[$headerNode->getType()][] = $header;
        }
        return $headers;
    }
1327076
protected function getSourceHeaders()
    {
        $headers = [];

        if (!$this->user_agent_header || !$this->source_header) {
            $version = trim(file_get_contents(__DIR__ . '/../../VERSION'));

            if (!$this->user_agent_header) {
                $this->user_agent_header = sprintf('filestack-php-%s',
                    $version);
            }

            if (!$this->source_header) {
                $this->source_header = sprintf('PHP-%s',
                    $version);
            }
        }

        $headers['user-agent'] = $this->user_agent_header;
        $headers['filestack-source'] = $this->source_header;

        //user_agent_header
        return $headers;
    }
508681
public function getScripts(): string
    {
        $str = '';

        if(isset($this->scripts))
            foreach($this->scripts as $script)
                if(isset($script['content']))
                    $str .= '<script type="'.$script['type'].'">'.$script['content'].'</script>';
                elseif(isset($script['href']))
                    $str .= '<script type="'.$script['type'].'" src="'.$script['href'].'"'.(($script['defer']) ? ' defer async' : '').'></script>';
                elseif(isset($script['raw']))
                    $str .= $script['raw'];

        return $str;
    }
1021996
public function compileHeaders()
    {
        if (count($this->attachement) > 0) {
            $this->headers[] = "Content-type: multipart/mixed; boundary=\"{$this->boundary}\"" . self::END;

            foreach ($this->attachement as $file) {
                $filename = basename($file);
                $this->headers[] = "--" . $this->boundary;
                $this->headers[] = "Content-Type: application/octet-stream; name=\"{$filename}\"";
                $this->headers[] = "Content-Transfer-Encoding: base64";
                $this->headers[] = "Content-Disposition: attachment" . self::END;
                $this->headers[] = chunk_split(base64_encode(file_get_contents($file)));
            }

            $this->headers[] = "--" . $this->boundary;
        }

        return implode(self::END, $this->headers).self::END;
    }
1129336
public function getJavaScriptCode()
    {
        $fieldsJavaScriptCode = [];
        $formConfiguration = $this->getFormObject()->getConfiguration();

        foreach ($formConfiguration->getFields() as $field) {
            $fieldsJavaScriptCode[] = $this->processField($field);
        }

        $formName = GeneralUtility::quoteJSvalue($this->getFormObject()->getName());
        $fieldsJavaScriptCode = implode(CRLF, $fieldsJavaScriptCode);

        return <<<JS
(function() {
    Fz.Form.get(
        $formName,
        function(form) {
            var field = null;

$fieldsJavaScriptCode
        }
    );
})();
JS;
    }
547897
private function getDumpFileHeader()
    {
        $header = '';
        if (!$this->dumpSettings['skip-comments']) {
            // Some info about software, source and time
            $header = "-- mysqldump-php https://github.com/ifsnop/mysqldump-php".PHP_EOL.
                    "--".PHP_EOL.
                    "-- Host: {$this->host}\tDatabase: {$this->dbName}".PHP_EOL.
                    "-- ------------------------------------------------------".PHP_EOL;

            if (!empty($this->version)) {
                $header .= "-- Server version \t".$this->version.PHP_EOL;
            }

            if (!$this->dumpSettings['skip-dump-date']) {
                $header .= "-- Date: ".date('r').PHP_EOL.PHP_EOL;
            }
        }
        return $header;
    }
982270
public function javascript_files($type) {
        if ($type === 'footer') {
            $type = 'javascripts_footer';
        } else {
            $type = 'javascripts';
        }

        $js = array();
        // find out wanted parent javascripts
        $excludes = $this->resolve_excludes('parents_exclude_javascripts');
        if ($excludes !== true) {
            foreach (array_reverse($this->parent_configs) as $parent_config) { // base first, the immediate parent last
                $parent = $parent_config->name;
                if (empty($parent_config->$type)) {
                    continue;
                }
                if (!empty($excludes[$parent]) and $excludes[$parent] === true) {
                    continue;
                }
                foreach ($parent_config->$type as $javascript) {
                    if (!empty($excludes[$parent]) and is_array($excludes[$parent])
                        and in_array($javascript, $excludes[$parent])) {
                        continue;
                    }
                    $javascriptfile = "$parent_config->dir/javascript/$javascript.js";
                    if (is_readable($javascriptfile)) {
                        $js[] = $javascriptfile;
                    }
                }
            }
        }

        // current theme javascripts
        if (is_array($this->$type)) {
            foreach ($this->$type as $javascript) {
                $javascriptfile = "$this->dir/javascript/$javascript.js";
                if (is_readable($javascriptfile)) {
                    $js[] = $javascriptfile;
                }
            }
        }
        return $js;
    }
810730
protected function getSource()
	{
		$rootDir = __DIR__ . '/..';
		$src     = '';

		// If getLogger() is not exported we use a dummy Logger that can be optimized away
		$logger = (in_array('getLogger', $this->exports)) ? 'Logger.js' : 'NullLogger.js';

		// Prepare the list of files
		$files   = glob($rootDir . '/Parser/AttributeFilters/*.js');
		$files[] = $rootDir . '/Parser/utils.js';
		$files[] = $rootDir . '/Parser/FilterProcessing.js';
		$files[] = $rootDir . '/Parser/' . $logger;
		$files[] = $rootDir . '/Parser/Tag.js';
		$files[] = $rootDir . '/Parser.js';

		// Append render.js if we export the preview method
		if (in_array('preview', $this->exports, true))
		{
			$files[] = $rootDir . '/render.js';
			$src .= '/** @const */ var xsl=' . $this->getStylesheet() . ";\n";
		}

		$src .= implode("\n", array_map('file_get_contents', $files));

		return $src;
	}