Created
February 25, 2011 02:44
-
-
Save sams/843300 to your computer and use it in GitHub Desktop.
to reduce the complexity of bakingplates layouts; keep'em clean
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class PlateHelper extends AppHelper { | |
var $helpers = array('Html', 'Form'); | |
/* | |
* function js_lib | |
* @param host = google, lib = jquery, version = null, compressed = true | |
*/ | |
function jsLib($host = 'google', $lib = 'jquery', $version = null, $compressed = true) { | |
$min = $compressed ? '.min' : ''; | |
$fallback = is_null($version) ? '' : $this->Html->scriptBlock("!window.jQuery && document.write(unescape('%3Cscript src=\"libs/{$lib}-{$version}{$min}\"%3E%3C/script%3E'))"); | |
// ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.js | |
$cdn = ($host == 'google') ? '//ajax.googleapis.com/ajax/libs/'.$lib.'/'.$version.'/'.$lib.$min.'.js' : sprintf($host, $lib, $version, $min); | |
$cdn = $this->Html->script($cdn); | |
return $cdn.$fallback; | |
} | |
/* | |
* function dd_png | |
* @param void | |
*/ | |
function pngFix($fixClasses) { | |
$classes = implode(',', $fixClasses); | |
return | |
$this->Html->script(array('libs/dd_belatedpng')) . | |
$this->Html->scriptBlock("DD_belatedPNG.fix('$classes'); "); | |
} | |
/* | |
* function profiling | |
* outputs yahoo profiling code - only if admin is logged in and debug is set | |
* @param void | |
*/ | |
function profiling() { | |
if(Configure::read('site.YahooProfiling')) { | |
return $this->Html->script(array('profiling/yahoo-profiling.min', 'profiling/config')); | |
} | |
} | |
/* | |
* function analytics | |
* outputs google analytics code - only if on live domain and the GA id is set | |
* @param void | |
*/ | |
function conditionalComment($content, $ie = '7') { | |
} | |
function chromeFrame() { | |
return "<!--[if IE]><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"><![endif]-->"; | |
} | |
/* | |
* function analytics | |
* outputs google analytics code - only if on live domain and the GA id is set | |
* @param void | |
*/ | |
function analytics() { | |
$GoogleAnalytics = Configure::read('site.GoogleAnalytics'); | |
if(!Configure::read('debug') && $GoogleAnalytics) { | |
return $this->View->element('extras/google_analytics', array('google_analytics' => $GoogleAnalytics)); | |
} | |
} | |
/* | |
* function modernizr | |
* @param $default = true | |
*/ | |
function modernizr($default = true) { | |
$default = ($default === true) ? 'modernizr' : $default; | |
return $this->Html->script('libs/' . $default); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JsLib in new version you can indeed to all of that - I have array for cdns include microsoft, jquery and google (adding your our is not something I have tested as yet); all seems well I just need to give it a final review and refresh it in my mind and browser :)