Changeset 5d8d5f


Ignore:
Timestamp:
05/20/15 13:13:32 (2 years ago)
Author:
pierre-alain <pierre-alain@…>
Branches:
master
Children:
f08393
Parents:
a82c98
git-author:
pierre-alain <pierre-alain@…> (05/20/15 13:13:32)
git-committer:
pierre-alain <pierre-alain@…> (05/20/15 13:13:32)
Message:

adding minify and getList function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • OWR/Theme.php

    r5419f2 r5d8d5f  
    136136        $this->_className = 'OWR\Includes\Themes\\' . $this->_name . '\Theme'; 
    137137 
    138         $this->_path = __DIR__ . DIRECTORY_SEPARATOR . 'Includes' . DIRECTORY_SEPARATOR . 'Themes' . DIRECTORY_SEPARATOR . $this->_name . DIRECTORY_SEPARATOR; 
     138        $this->_path = OWR_THEMES_PATH . $this->_name . DIRECTORY_SEPARATOR; 
    139139        $this->_pagesPath = $this->_path . 'tpl' . DIRECTORY_SEPARATOR; 
    140140        $this->_blocksPath = $this->_path . 'tpl' . DIRECTORY_SEPARATOR . 'blocks' . DIRECTORY_SEPARATOR; 
     
    263263        return $this->_parent; 
    264264    } 
     265 
     266    /** 
     267     * Returns the list of all available themes 
     268     * 
     269     * @author Pierre-Alain Mignot <contact@openwebreader.org> 
     270     * @access public 
     271     * @return array list of available themes 
     272     */ 
     273    static public function getList() 
     274    { 
     275        $themes = array(); 
     276 
     277        $userTheme = User::iGet()->getConfig('theme'); 
     278         
     279        foreach(new \DirectoryIterator(OWR_THEMES_PATH) as $theme) 
     280        { 
     281            if($theme->isDot() || !$theme->isDir()) continue; 
     282             
     283            $name = $theme->getBaseName(); 
     284            $themes[$name] = $userTheme === $name; 
     285        } 
     286 
     287        return $themes; 
     288    } 
     289 
     290    /** 
     291     * Removes all indentation from file 
     292     * 
     293     * @access public 
     294     * @var string $file the file to minify 
     295     * @return string the mimnified file 
     296     */ 
     297    public function minify($file) 
     298    { 
     299        $content = @file_get_contents($file); 
     300        if(empty($content)) return ''; 
     301 
     302//        $content = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $content); 
     303        $content = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $content); 
     304 
     305        return $content; 
     306    } 
    265307} 
Note: See TracChangeset for help on using the changeset viewer.