PKPTemplateManager::smartyLoadScript PHP Method

smartyLoadScript() public method

Custom Smarty function for printing scripts attached to a context.
public smartyLoadScript ( $params, $smarty ) : string
$params array associative array
$smarty Smarty
return string of HTML/Javascript
    function smartyLoadScript($params, $smarty)
    {
        if (empty($params['scripts'])) {
            return;
        }
        if (empty($params['context'])) {
            $params['context'] = 'frontend';
        }
        $scripts = $this->getResourcesByContext($params['scripts'], $params['context']);
        $output = '';
        foreach ($scripts as $priorityList) {
            foreach ($priorityList as $name => $data) {
                if ($data['inline']) {
                    $output .= '<script type="text/javascript">' . $data['script'] . '</script>';
                } else {
                    $output .= '<script src="' . $data['script'] . '" type="text/javascript"></script>';
                }
            }
        }
        return $output;
    }