Esempio n. 1
0
    public function loadThemes($folder)
    {
        $f_origin = $folder;
        $folder = Filter::realPath($folder);
        if (!$folder) {
            throw new ErrorRuntime("Folder \"{$f_origin}\", not exists. It's important to save Themes.");
        }
        $parser = new Parser();
        $DS = DIRECTORY_SEPARATOR;
        if (!$parser->file()->exists(Filter::systemPath($folder . "/" . $this->getMainConfig()))) {
            echo <<<DOC
            No found {$folder}{$DS}{$this->getMainConfig()}
            Please, create one file of
            configuration to themes, something as config.yml:
            <pre>
            themes:
                "light": true
                "dark":
                "one-style":
            
DOC;
            exit;
        }
        if (!$parser->file()->exists(Filter::systemPath($this->getFolderTmpTheme()))) {
            echo <<<DOC
            <pre>
            Please, follow steps:
            
                1 - Create a folder in "public/theme"
                2 - Create a file in "public/theme/index.php", containing:
            
                    < ?php
                    require_once __DIR__.'/../../vendor/autoload.php';
                    use Glance\\Response;
                    Response::listenMessage();
            
                3 - Create a file in "public/theme/.htaccess", containing:
            
                    
                    RewriteEngine On
                    RewriteCond %{REQUEST_FILENAME} !-f
                    RewriteCond %{REQUEST_FILENAME} !-d
                    RewriteRule ^(.*)\$ index.php?get=\$1 [L]
                    
            </pre>
DOC;
            exit;
        }
        $themes = $parser->loadYAML(Filter::systemPath($folder . "/" . $this->getMainConfig()));
        $ftheme = NULL;
        foreach ($themes['themes'] as $theme => $value) {
            if (!$parser->file()->exists(Filter::systemPath($folder . "/" . $theme))) {
                throw new ErrorRuntime("Folder of the THEME: \"{$theme}\", not exists.");
            } else {
                if (!$ftheme) {
                    $ftheme = $theme;
                }
                if ($value and !$this->activated) {
                    $this->activated = $theme;
                }
            }
        }
        if ($ftheme and !$this->activated) {
            $this->activated = $ftheme;
        }
    }