예제 #1
0
 /**
  * Minifies a Javascript file
  * @param string $src The src element of the script tag
  * @return string $src The src element of the minified file
  */
 private function minifyJS()
 {
     // pass the file elements by reference
     foreach ($this->scriptfiles as &$file) {
         $src = $file['src'];
         if (strpos($src, ".min.js") === false) {
             // it's already minified
             $jsfile = $file['src'];
             // get the last element (the concrete filename)
             $content = file_get_contents(PUBLIC_FOLDER . $jsfile);
             $jsmin = ServiceManager::getInstance()->get('jsmin', $content);
             $minifiedcontent = $jsmin->min();
             // get the minified content
             $minifiedfile = PUBLIC_FOLDER . rtrim($jsfile, "js") . "min.js";
             file_put_contents($minifiedfile, $minifiedcontent);
             // put the contents into a file
             $file['src'] = str_replace(PUBLIC_FOLDER, BASEPATH . "/", $minifiedfile);
         }
     }
 }
예제 #2
0
 /**
  * Minifies CSS files
  */
 private function minify()
 {
     // pass the file elements by reference
     foreach ($this->links as &$file) {
         $href = $file['href'];
         if (strpos($href, ".scss") == true) {
             $href = $this->compileCSS($href);
         }
         if (strpos($href, ".min.css") === false) {
             // it's already minified
             $segments = explode('/', $href);
             $cssfile = array_pop($segments);
             // get the last element (the concrete filename)
             $content = file_get_contents($this->getCssDir() . $cssfile);
             ServiceManager::getInstance()->get('cssmin', $content);
             $minifiedcontent = \CssMin::minify($content);
             // get the minified content
             $minifiedfile = $this->getCssDir() . rtrim($cssfile, "css") . "min.css";
             file_put_contents($minifiedfile, $minifiedcontent);
             // put the contents into a file
             $file['href'] = str_replace($this->getCssDir(), $this->getCssUrl(), $minifiedfile);
         }
     }
 }
예제 #3
0
 protected function __construct()
 {
     $this->dbadapter = ServiceManager::getInstance()->get('db');
 }
 public function __construct()
 {
     $this->sm = ServiceManager::getInstance();
     $this->layout = new Layout();
     $this->session = Session::getInstance();
 }