示例#1
0
 /**
  * load css scripts
  * @param  String|Array  $files      paths to file/s
  * @param  boolean       $cache      if set to true a cache will be created and serverd
  * @param  boolean       $refresh    if true the cache will be updated
  * @param  string        $cachedMins minutes to hold the cache
  */
 public static function css($files, $cache = false, $refresh = false, $cachedMins = '1440')
 {
     $path = APPDIR . Url::relativeTemplatePath() . 'css/compressed.min.css';
     $type = 'css';
     if ($cache == false) {
         static::resource($files, $type);
     } else {
         if ($refresh == false && file_exists($path) && filemtime($path) > time() - 60 * $cachedMins) {
             $path = str_replace(APPDIR, null, $path);
             $path = Inflector::tableize($path);
             static::resource(DIR . $path, $type);
         } else {
             $source = static::collect($files, $type);
             $source = static::compress($source);
             file_put_contents($path, $source);
             $path = str_replace(APPDIR, null, $path);
             $path = Inflector::tableize($path);
             static::resource(DIR . $path, $type);
         }
     }
 }