/** * Minify Javascript. * * @param string $js Javascript to be minified * @return string */ public static function minify($js) { $jsmin = new Paiva_Minify_JS($js); return $jsmin->min(); }
/** * Compile full list of files in $this->_cache array * * @return string */ protected function _getCompiledItem() { $fileProcessor = $this->getProcessor(); $path = $fileProcessor->getServerPath($this->getOption('dir') . $fileProcessor->fullFilename(md5(serialize($fileProcessor->getCache())))); if (!file_exists($path)) { // @todo: verificar a solução implementada no pacote minify $dir = dirname($path); if (!is_dir($dir) && !@mkdir($dir, 0777, true)) { throw new Zend_View_Exception('Impossible to create destination directory ' . $dir); } $jsContent = ''; foreach ($fileProcessor->getCache() as $js) { $jsContent .= (is_array($js) ? file_get_contents($js['filepath']) : $js) . ";\n\n"; } if ($this->getOption('compress')) { $jsContent = Paiva_Minify_JS::minify($jsContent); } file_put_contents($path, $jsContent); $fileProcessor->gzip($path, $jsContent); } return $this->createData('text/javascript', array('src' => $fileProcessor->getWebPath($path))); }