/** * @param $location * @throws UglifyJs2Exception */ public function setLocation($location) { if (file_exists($location)) { self::$location = $location; } else { throw new UglifyJs2Exception("Cannot find executable in given location"); } }
function referenceResources($reg, &$txtCnt, $urlBase, $sType) { preg_match_all($reg, $txtCnt, $aSrcs); $aCnts = []; for ($cntSrcs = 0; $cntSrcs < count($aSrcs[0]); $cntSrcs++) { $sResource = $aSrcs[0][$cntSrcs]; $urlRel = $aSrcs[1][$cntSrcs]; $urlAbs = calAbsUrl($urlRel, $urlBase); $txtSrc = getContent($urlAbs); $txtCnt = str_replace($sResource, '', $txtCnt); if ($txtSrc === false) { echo "File doesn't exist!!! {$urlRel} in {$urlBase}"; } else { $aCnts[] = $txtSrc; } } $txtSrc = implode('', $aCnts); switch ($sType) { case 'css': $txtCnt = '<style>' . $txtSrc . '</style>' . $txtCnt; break; case 'js': if (!DEVELOPING) { $fileTmp = WEBROOT_AT_DISK . TEMPORARY_JS; writeFile(TEMPORARY_JS, $txtSrc); $ug = new JSUglify2(); $ug->uglify([$fileTmp], $fileTmp); $txtSrc = getContent(TEMPORARY_JS); unlink($fileTmp); } $txtCnt .= '<script>' . $txtSrc . '</script>'; break; default: # code... break; } return; }