Development

Changeset 19843

You must first sign up to be able to contribute.

Changeset 19843

Show
Ignore:
Timestamp:
07/03/09 14:45:44 (7 months ago)
Author:
jerome.etienne
Message:

- creating cache directory automatically if needed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/jeMinifyJsCssPlugin/config/app.yml

    r19787 r19843  
    11#dev: 
    2 sf_combine_filter_plugin: 
     2je_minify_js_css_plugin: 
    33#    enabled: false 
    44 
    55 
    66all: # these are the defaults, you should override them in your application/config/app.yml file 
    7   sf_combine_filter_plugin: 
     7  je_minify_js_css_plugin: 
    88    #css_filtered_paths:          [%SF_ROOT_DIR%, plugins/, web/]  # you want to end your paths (comma seperated) with a / 
    99    css_filtered_paths:          [%SF_ROOT_DIR%/config/themes, %SF_ROOT_DIR%/web, ["=%SF_ROOT_DIR%/plugins/(\w+)/web/(.*)=", "$1/$2" ]]  # you want to end your paths (comma seperated) with a / 
     
    1212 
    1313    #defaults 
    14     javascripts:    tru
     14    javascripts:    fals
    1515    stylesheets:    true 
    1616    minimize_js:    true 
    17     minimize_css:   tru
     17    minimize_css:   fals
    1818    enabled:        true 
    1919    #root_js_only:   false 
  • plugins/jeMinifyJsCssPlugin/lib/jeMinifyJsCssFilter.class.php

    r19787 r19843  
    3232    $filterChain->execute(); 
    3333 
    34     if(sfConfig::get('app_sf_combine_filter_plugin_enabled')) { 
    35 ezDbg::err('ALALA'); 
     34    if(sfConfig::get('app_je_minify_js_css_plugin_enabled')) { 
    3635      sfContext::getInstance()->getConfiguration()->loadHelpers('Asset'); 
    37       $this->response = $this->getContext()->getResponse(); 
    38       $this->request = $this->getContext()->getRequest(); 
     36      $this->response  = $this->getContext()->getResponse(); 
     37      $this->request = $this->getContext()->getRequest(); 
    3938      $this->sf_relative_url_root = $this->request->getRelativeUrlRoot(). $this->request->getScriptName(); 
    4039 
     
    4241      { 
    4342 
    44         if (sfConfig::get('app_sf_combine_filter_plugin_javascripts',true)) 
     43        if (sfConfig::get('app_je_minify_js_css_plugin_javascripts',true)) 
    4544        { 
    4645          $this->type = 'javascript'; 
     
    5049        } 
    5150 
    52         if (sfConfig::get('app_sf_combine_filter_plugin_stylesheets',true)) 
     51        if (sfConfig::get('app_je_minify_js_css_plugin_stylesheets',true)) 
    5352        { 
    5453          $this->type = 'css'; 
     
    6362  protected function getCombinedJavascripts() 
    6463  { 
    65     $root_js_only = sfConfig::get('app_sf_combine_filter_plugin_root_js_only', false); 
     64    $root_js_only = sfConfig::get('app_je_minify_js_css_plugin_root_js_only', false); 
    6665 
    6766    $already_seen = array(); 
     
    9190 
    9291          // do not include, when in exclude array 
    93           foreach (sfConfig::get('app_sf_combine_filter_plugin_js_exclude_files', array()) as $exclude) 
     92          foreach (sfConfig::get('app_je_minify_js_css_plugin_js_exclude_files', array()) as $exclude) 
    9493          { 
    9594            if (strpos($path, $exclude)!==false) continue 2; 
     
    123122  protected function cacheFile($cacheFileName, $file_extension) 
    124123  { 
    125 ezDbg::err('super cachefile='.$cacheFileName); 
    126  
    127 $cache_fname  = sfConfig::get('sf_cache_dir'). "/" . self::PACK_CACHE_FOLDER . "/" . $cacheFileName . "." . $file_extension; 
    128  
    129 if(false){ 
    130     //get an instance of the file cache object. We grab the web root then get the name of the cache folder 
    131     //we don't want to use sf_cache_dir because that is application and environment specific 
    132     //we don't want to a path relative to sf_web_dir because the sf_root_dir can be changed, better to start from there 
    133     $cache = new sfFileCache(array('cache_dir' => sfConfig::get('sf_cache_dir'). "/" . self::PACK_CACHE_FOLDER)); 
    134  
    135     //cached files are in the 'packed_files' name space 
    136  
    137     //Next we see if we can pull the file from the cache. 
    138     if($cache->has($cacheFileName)) 
    139     { 
    140       //Ok! We have a cached copy of the file! 
    141       return true; 
    142     } 
    143 }else{ 
     124  $cache_dname  = sfConfig::get('sf_cache_dir')."/".self::PACK_CACHE_FOLDER; 
     125  // create $cache_dname if needed 
     126  if( !is_dir($cache_dname) ) mkdir($cache_dname, 0777); 
     127 
     128  // determine the filename of the cache file 
     129  $cache_fname  = $cache_dname."/".$cacheFileName.".".$file_extension; 
     130 
     131  // if the file already exists, return now 
    144132  if(file_exists($cache_fname)) return true; 
    145 } 
    146133 
    147134    { 
     
    154141          $con = "\n\n".'/* include css file: '.$path." */\n\n"; 
    155142          $cssPath = $path; 
    156   $filtered_paths = sfConfig::get('app_sf_combine_filter_plugin_css_filtered_paths'); 
     143  $filtered_paths = sfConfig::get('app_je_minify_js_css_plugin_css_filtered_paths'); 
    157144  foreach($filtered_paths as $filtered_path){ 
    158145    if( is_string($filtered_path) ){ 
     
    162149    } 
    163150  } 
    164     ezDbg::err('css REPLACE:', $path, $cssPath); 
     151    ezDbg::err('cssE REPLACE:', $path, $cssPath); 
    165152          $con .= $this->fixCssPaths(file_get_contents($path), $cssPath); 
     153    ezDbg::err($this->fixCssPaths(file_get_contents($path), $cssPath)); 
    166154        } 
    167155        else 
     
    175163      } 
    176164 
    177       if ($this->type=='javascript'&& sfConfig::get('app_sf_combine_filter_plugin_minimize_js', false)) 
     165      if ($this->type=='javascript'&& sfConfig::get('app_je_minify_js_css_plugin_minimize_js', false)) 
    178166      { 
    179167  if(false){ 
     
    202190  } 
    203191      } 
    204       elseif($this->type=='css'&& sfConfig::get('app_sf_combine_filter_plugin_minimize_css', true)) 
     192      elseif($this->type=='css'&& sfConfig::get('app_je_minify_js_css_plugin_minimize_css', true)) 
    205193      { 
    206194  if(true){ 
     
    218206      } 
    219207 
    220       //Write the file data to the cache 
    221 if(false){ 
    222       $cache->set($cacheFileName, $contents); 
    223 }else{ 
     208  //Write the file data to the cache 
    224209  $written_len  = file_put_contents($cache_fname, $contents); 
    225210  if( $written_len != strlen($contents) ) return false; 
    226 
     211 
    227212      return true; 
    228213    } 
     
    314299  protected function getCombinedStylesheets() 
    315300  { 
    316     $root_css_only = sfConfig::get('app_sf_combine_filter_plugin_root_css_only', false); 
     301    $root_css_only = sfConfig::get('app_je_minify_js_css_plugin_root_css_only', false); 
    317302    $already_seen = array(); 
    318303    $combined_sources = array(); 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting.
Sensio Labs also supports several large Open-Source projects.