Show
Ignore:
Timestamp:
01/04/12 10:18:17 (1 year ago)
Author:
mbrevda
Message:

upstream changes (ready framework to move css compression)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • freepbx/branches/2.10/amp_conf/bin/retrieve_conf

    r12993 r13159  
    387387$con_dirs->cp_check_errors(); 
    388388 
     389//once we have all the connected files in place, lets compress the css 
     390if ($amp_conf['DISABLE_CSS_AUTOGEN'] != true) { 
     391  //compress_framework_css(); 
     392} 
    389393 
    390394// create an object of the extensions class 
  • freepbx/branches/2.10/amp_conf/htdocs/admin/libraries/utility.functions.php

    r13124 r13159  
    9292    return version_compare($version1, $version2); 
    9393  } 
     94} 
     95 
     96function compress_framework_css() { 
     97  global $amp_conf; 
     98  $mainstyle_css      = $amp_conf['BRAND_CSS_ALT_MAINSTYLE']  
     99            ? $amp_conf['BRAND_CSS_ALT_MAINSTYLE']  
     100            : 'assets/css/mainstyle.css';  
     101  $wwwroot      = $amp_conf['AMPWEBROOT'] . "/admin"; 
     102  $mainstyle_css_gen  = $wwwroot . '/' . $amp_conf['mainstyle_css_generated']; 
     103  $mainstyle_css    = $wwwroot . '/' . $mainstyle_css; 
     104  $new_css      = file_get_contents($mainstyle_css)  
     105            . file_get_contents($wwwroot . '/' . $amp_conf['JQUERY_CSS']); 
     106  $new_css      = CssMin::minify($new_css); 
     107  $new_md5      = md5($new_css); 
     108  $gen_md5      = file_exists($mainstyle_css_gen) ? md5(file_get_contents($mainstyle_css_gen)) : ''; 
     109 
     110   
     111  //regenerate if hashes dont match 
     112  if ($new_md5 != $gen_md5) { 
     113    $ms_path = dirname($mainstyle_css); 
     114 
     115    // it's important for filename tp unique  
     116    //because that will force browsers to reload vs. caching it 
     117    $mainstyle_css_generated = $ms_path.'/mstyle_autogen_' . time() . '.css'; 
     118    $ret = file_put_contents($mainstyle_css_generated, $new_css); 
     119 
     120    // Now assuming we write something reasonable, we need to save the generated file name and mtimes so 
     121    // next time through this ordeal, we see everything is setup and skip all of this. 
     122    //  
     123    // we skip this all this if we get back false or 0 (nothing written) in which case we will use the original 
     124    // We need to set the value in addition to defining the setting  
     125    //since if already defined the value won't be reset. 
     126    if ($ret) { 
     127      $freepbx_conf =& freepbx_conf::create(); 
     128      $val_update['mainstyle_css_generated'] = str_replace($wwwroot . '/', '', $mainstyle_css_generated); 
     129       
     130      // Update the values (in case these are new) and commit 
     131      $freepbx_conf->set_conf_values($val_update, true, true); 
     132 
     133 
     134      // If it is a regular file (could have been first time and previous was blank then delete old 
     135      if (is_file($mainstyle_css_gen) && !unlink($mainstyle_css_gen)) { 
     136        freepbx_log(FPBX_LOG_WARNING, 
     137              sprintf(_('failed to delete %s from assets/css directory after ' 
     138                  . 'creating updated CSS file.'),  
     139                  $mainstyle_css_generated_full_path)); 
     140      } 
     141    } 
     142  } 
     143   
    94144} 
    95145 
  • freepbx/branches/2.10/amp_conf/htdocs/admin/views/footer.php

    r13158 r13159  
    5252    . 'var fpbx=' 
    5353    . json_encode($fpbx) 
    54         . ';$(document).click();' //TODO: this should be cleaned up eventually as right now it prevents the nav bar from not being fully displayed 
    55         . '</script>'; 
     54   . ';$(document).click();' //TODO: this should be cleaned up eventually as right now it prevents the nav bar from not being fully displayed 
     55     . '</script>'; 
    5656 
    5757if ($amp_conf['USE_GOOGLE_CDN_JS']) { 
  • freepbx/branches/2.10/libfreepbx.install.php

    r13131 r13159  
    22102210  $set['type'] = CONF_TYPE_SELECT; 
    22112211  $freepbx_conf->define_conf_setting('ASTCONFAPP', $set); 
     2212   
     2213  //mainstyle_css_generated 
     2214  $set['value'] = $amp_conf['mainstyle_css_generated'] ? $amp_conf['mainstyle_css_generated'] : ''; 
     2215  $set['description'] = 'internal use'; 
     2216  $set['type'] = CONF_TYPE_TEXT; 
     2217  $set['defaultval'] = ''; 
     2218  $set['name'] = 'Compressed Copy of Main CSS'; 
     2219  $set['readonly'] = 1; 
     2220  $set['hidden'] = 1; 
     2221  $set['emptyok'] = 1; 
     2222  $freepbx_conf->define_conf_setting('mainstyle_css_generated', $set); 
    22122223   
    22132224  //JQUERY_VER