CI =& get_instance(); $this->CI->load->helper('url'); $this->controller = $controller; $this->init(); $this->compileTags(); }//constructor function init(){ $this->minifyCachePath = '/home/me/minify/cache'; $this->jsFilesNeed = array(); $this->cssFilesNeed = array(); $this->jsFilesHave = array(); $this->jsFilesHave['jquery.bgiframe'] = '//scripts/jquery.bgiframe.js'; $this->jsFilesHave['jquery.date'] = '//scripts/jquery.date.js'; $this->jsFilesHave['jquery.datePicker'] = '//scripts/jquery.datePicker.js'; $this->jsFilesHave['jquery.dimensions'] = '//scripts/jquery.dimensions.js'; $this->jsFilesHave['jquery.easing.1.3'] = '//scripts/jquery.easing.1.3.js'; $this->jsFilesHave['jquery.jcarousel'] = '//scripts/jquery.jcarousel.js'; $this->jsFilesHave['jquery'] = '//scripts/jquery.js'; $this->jsFilesHave['jquery.superfish'] = '//scripts/jquery.superfish.js'; $this->jsFilesHave['jquery.thickbox'] = '//scripts/jquery.thickbox.js'; $this->jsFilesHave['jquery.tooltip'] = '//scripts/jquery.tooltip.js'; $this->jsFilesHave['my.form-validation'] = '//scripts/my.form-validation.js'; $this->jsFilesHave['my.global'] = '//scripts/my.global.js'; $this->jsFilesHave['my.roster'] = '//scripts/my.roster.js'; $this->jsFilesHave['my.splash'] = '//scripts/my.splash.js'; $this->jsFilesHave['my.tooltips'] = '//scripts/my.tooltips.js'; $this->jsFilesHave['my.utils'] = '//scripts/my.utils.js'; $this->cssFilesHave = array(); $this->cssFilesHave['jquery.datePicker'] = '//style/jquery.datePicker.css'; $this->cssFilesHave['jquery.thickbox'] = '//style/jquery.thickbox.css'; $this->cssFilesHave['jquery.tooltip'] = '//style/jquery.tooltip.css'; $this->cssFilesHave['my.main'] = '//style/my.main.css'; //from minify examples: //Add the location of Minify's "lib" directory to the include_path. ini_set('include_path', '/home/me/minify/lib/.:' . ini_get('include_path') ); require 'Minify/Build.php'; require 'Minify.php'; }//method init function compileTags(){ //assume all need the main.css $this->cssFilesNeed[] = 'my.main'; $this->cssFilesNeed[] = 'jquery.thickbox'; //assume all need the global one and the nav ones $this->jsFilesNeed[] = 'jquery'; $this->jsFilesNeed[] = 'jquery.superfish'; $this->jsFilesNeed[] = 'jquery.thickbox'; $this->jsFilesNeed[] = 'my.global'; if( $this->controller == 'member/register' ){ $this->addMemberRegister(); } else if( $this->controller == 'member/invite' ){ $this->addValidation(); }//if-else ifs }//method compileTags function getJSFiles(){ $jsFiles = array(); foreach( $this->jsFilesNeed as $idx=>$name ){ $jsFiles[] = $this->jsFilesHave[ $name ]; }//foreach return $jsFiles; }//method getJSFiles function jsTag($str = ""){ //make sure convert this to CI-type URL (no "?") $jsBuild = new Minify_Build( $this->getJSFiles() ); $fileName = str_replace('/', '-', $this->controller); $url = site_url('includetag/js/' . $this->convertController() ); return str_replace('?', '/', $jsBuild->uri($url)); }//method jsTag function getCSSFiles(){ $cssFiles = array(); foreach( $this->cssFilesNeed as $idx=>$name ){ $cssFiles[] = $this->cssFilesHave[ $name ]; }//foreach return $cssFiles; }//method getCSSFiles function cssTag($str = ""){ //make sure convert this to CI-type URL (no "?") $cssBuild = new Minify_Build( $this->getCSSFiles() ); $url = site_url('includetag/css/' . $this->convertController() ); return str_replace('?', '/', $cssBuild->uri($url)); }//method cssTag function convertController(){ return str_replace('/', '-', $this->controller); }//method convertController function serveJS($fileName){ $groupSources = array($fileName => $this->getJSFiles() ); Minify::setCache($this->minifyCachePath); Minify::serve('Groups', array('groups' => $groupSources ,'maxAge' => 31536000 // 1 yr )); }//method serve function serveCSS($fileName){ $groupSources = array($fileName => $this->getCSSFiles() ); Minify::setCache($this->minifyCachePath); Minify::serve('Groups', array('groups' => $groupSources ,'maxAge' => 31536000 // 1 yr )); }//method serveCSS function addValidation(){ $this->jsFilesNeed[] = 'my.utils'; $this->jsFilesNeed[] = 'my.form-validation'; }//method addValidation function addMemberRegister(){ $this->jsFilesNeed[] = 'jquery.easing.1.3'; $this->jsFilesNeed[] = 'my.splash'; $this->jsFilesNeed[] = 'jquery.jcarousel'; $this->addValidation(); }//method addMemberRegister }//class MY_Includes ?>