src/View.php
public function setStyle($style)
    {
        $dir = ForumEnv::get('WEB_ROOT').'themes/'.$style.'/';
        if (!is_dir($dir)) {
            throw new RunBBException('The style '.$style.' doesn\'t exist');
        }

        if (is_file($dir . 'bootstrap.php')) {
            $vars = include_once $dir . 'bootstrap.php';
            // file exist but return nothing
            if (!is_array($vars)) {
                $vars = [];
            }
            foreach ($vars as $key => $assets) {
                if ($key === 'jsraw' || !in_array($key, ['js', 'jshead', 'css'])) {
                    continue;
                }
                foreach ($assets as $asset) {
                    $params = ($key === 'css') ? ['type' => 'text/css', 'rel' => 'stylesheet'] : (
                    ($key === 'js' || $key === 'jshead') ? ['type' => 'text/javascript'] : []
                    );
                    $this->addAsset($key, $asset, $params);
                }
            }
            $this->set('jsraw', isset($vars['jsraw']) ? $vars['jsraw'] : '');
        }

        if (isset($vars['themeTemplates']) && $vars['themeTemplates'] == true) {
            $templatesDir = ForumEnv::get('WEB_ROOT').'themes/'.$style.'/view';
        } else {
            $templatesDir = ForumEnv::get('FORUM_ROOT') . 'View/';
        }

        $this->set('style', (string) $style);

        $this->addTemplatesDirectory($templatesDir);
    }
public function setStyle($style)
    {
        $dir = ForumEnv::get('WEB_ROOT').'themes/'.$style.'/';
        if (!is_dir($dir)) {
            throw new RunBBException('The style '.$style.' doesn\'t exist');
        }

        if (is_file($dir . 'bootstrap.php')) {
            $vars = include_once $dir . 'bootstrap.php';
            // file exist but return nothing
            if (!is_array($vars)) {
                $vars = [];
            }
            foreach ($vars as $key => $assets) {
                if ($key === 'jsraw' || !in_array($key, ['js', 'jshead', 'css'])) {
                    continue;
                }
                foreach ($assets as $asset) {
                    $params = ($key === 'css') ? ['type' => 'text/css', 'rel' => 'stylesheet'] : (
                    ($key === 'js' || $key === 'jshead') ? ['type' => 'text/javascript'] : []
                    );
                    $this->addAsset($key, $asset, $params);
                }
            }
            $this->set('jsraw', isset($vars['jsraw']) ? $vars['jsraw'] : '');
        }

        if (isset($vars['themeTemplates']) && $vars['themeTemplates'] == true) {
            $templatesDir = ForumEnv::get('WEB_ROOT').'themes/'.$style.'/view';
        } else {
            $templatesDir = ForumEnv::get('FORUM_ROOT') . 'View/';
        }

        $this->set('style', (string) $style);

        $this->addTemplatesDirectory($templatesDir);
    }
public function setStyle ( $ style ) { $ dir = ForumEnv :: get ( 'WEB_ROOT' ) . 'themes/' . $ style . '/' ; if ( ! is_dir ( $ dir ) ) { throw new RunBBException ( 'The style ' . $ style . ' doesn\'t exist' ) ; } if ( is_file ( $ dir . 'bootstrap.php' ) ) { $ vars = include_once $ dir . 'bootstrap.php' ; // file exist but return nothing if ( ! is_array ( $ vars ) ) { $ vars = [ ] ; } foreach ( $ vars as $ key => $ assets ) { if ( $ key === 'jsraw' || ! in_array ( $ key , [ 'js' , 'jshead' , 'css' ] ) ) { continue ; } foreach ( $ assets as $ asset ) { $ params = ( $ key === 'css' ) ? [ 'type' => 'text/css' , 'rel' => 'stylesheet' ] : ( ( $ key === 'js' || $ key === 'jshead' ) ? [ 'type' => 'text/javascript' ] : [ ] ) ; $ this -> addAsset ( $ key , $ asset , $ params ) ; } } $ this -> set ( 'jsraw' , isset ( $ vars [ 'jsraw' ] ) ? $ vars [ 'jsraw' ] : '' ) ; } if ( isset ( $ vars [ 'themeTemplates' ] ) && $ vars [ 'themeTemplates' ] == true ) { $ templatesDir = ForumEnv :: get ( 'WEB_ROOT' ) . 'themes/' . $ style . '/view' ; } else { $ templatesDir = ForumEnv :: get ( 'FORUM_ROOT' ) . 'View/' ; } $ this -> set ( 'style' , ( string ) $ style ) ; $ this -> addTemplatesDirectory ( $ templatesDir ) ; }
Initialise style, load assets for given style
@param $style
@throws RunBBException
Initialise style load assets for given style