public function createLook($imgByteArr, $imgName, $styleId, $name, $thumbWidth, $thumbHeight) { //---------------------------------------------------------- //init var //---------------------------------------------------------- $chk = array("bool" => 1); //---------------------------------------------------------- FileFolder::createFolderStructure($this->rootPath . $this->largeImg_dir); FileFolder::createFolderStructure($this->rootPath . $this->thumbImg_dir); //---------------------------------------------------------- $chk = $this->saveAsJPEG($imgByteArr, $this->rootPath . $this->largeImg_dir . $imgName); //---------------------------------------------------------- $chk = $this->saveThumb($this->rootPath . $this->largeImg_dir . $imgName, $this->rootPath . $this->thumbImg_dir . $imgName, $thumbWidth, $thumbHeight); //---------------------------------------------------------- return (bool) $chk["bool"] ? $this->setData($styleId, $name, $this->largeImg_dir . $imgName, $this->thumbImg_dir . $imgName) : $chk; }
public static function moveToFolder($file, $folder = "") { //---------------------------------------------------------- $path = FileFolder::getPathFromFile($file) . $folder; //---------------------------------------------------------- $name = FileFolder::getFileName($file, false); //---------------------------------------------------------- FileFolder::createFolderStructure($path); //---------------------------------------------------------- $arr = explode("/", $file); //---------------------------------------------------------- $newFile = $path . $name; //---------------------------------------------------------- rename($file, $newFile); //---------------------------------------------------------- return $newFile; }
public function start() { if (is_null($this->folderName)) { if (isset($_GET['pageID'])) { $this->folderName = $_GET['pageID']; } } //--------------------------------------------------------- $folderName = Compile::$minifiedPath; //--------------------------------------------------------- $GET = array_merge($_GET, array()); //--------------------------------------------------------- unset($GET["pageID"]); //--------------------------------------------------------- //$GET["compile"]=0; //$GET['print_cookie'] = 1; unset($GET['refresh']); $_COOKIE['compile_curl'] = 1; //--------------------------------------------------------- $this->url .= "?" . http_build_query($GET); //--------------------------------------------------------- if (is_null($folderName) && FileFolder::getFileName($this->url) != "") { $folderName = explode("/", $this->url); end($folderName); $folderName = prev($folderName); } //--------------------------------------------------------- $this->fileCss = Compile::$minifiedPath . "global/css/" . $this->folderName . "/min.css"; $this->fileJs = Compile::$minifiedPath . "global/js/" . $this->folderName . "/min.js"; $this->fileTmpl = Compile::$minifiedPath . $this->folderName . "/min.php"; //--------------------------------------------------------- $this->fileCssAb = GenFun::get_full_url($this->fileCss); $this->fileJsAb = GenFun::get_full_url($this->fileJs); //--------------------------------------------------------- FileFolder::createFolderStructure($this->fileCss); //--------------------------------------------------------- FileFolder::folderCopy(Import::getImportPath(), Compile::$minifiedPath); FileFolder::folderCopy(Import::getImportPath(), Compile::$unminifiedPath); //--------------------------------------------------------- $this->content = CurlUtil::go(array("url" => $this->url)); //--------------------------------------------------------- preg_match_all('/Fatal error(.*?)<br \\/>/s', $this->content, $errors); //--------------------------------------------------------- if (sizeof($errors[0]) > 0) { krumo($errors[0]); die; } //--------------------------------------------------------- $this->content = $this->css_CFG(); $this->script_CFG(); $this->content = str_replace("<head>", '<head><script type="text/javascript" src="' . $this->fileJsAb . '"></script>' . PHP_EOL, $this->content); $this->content = str_replace("<head>", '<head><link rel="stylesheet" type="text/css" href="' . $this->fileCssAb . '"/>' . PHP_EOL, $this->content); $this->content = str_replace("<head>", '<head>' . PHP_EOL . file_get_contents($this->fileTmpl), $this->content); //--------------------------------------------------------- $this->project = str_replace("<head>", '<head>' . PHP_EOL . file_get_contents($this->fileTmpl), $this->project); //--------------------------------------------------------- FileFolder::delete($this->fileTmpl); //--------------------------------------------------------- $this->project = StringUtil::removeWhiteLines($this->project); //--------------------------------------------------------- file_put_contents(Import::getImportPath() . "project/index.php", $this->project); //--------------------------------------------------------- $this->content = StringUtil::removeWhiteLines($this->content); FileFolder::file_put_contents(Compile::$minifiedPath . "index.php", $this->content); //--------------------------------------------------------- return $this->content; }
private static function compileSass($file, $css = NULL, $appendToName = "") { $content = ""; //------------------------------------------- if (is_null($css)) { $css = FileFolder::file_get_contents($file); } //------------------------------------------- $newPath = self::newPath_CFG($file); $newScss = $newPath . $appendToName . ".scss"; //------------------------------------------- $arr = FileFolder::fileExistInFolder($file, ["init.werm.scss"], true); //------------------------------------------- //krumo($file); //krumo($arr); //krumo($file); //krumo($arr); foreach ($arr as $value) { $content .= self::replaceEnv($value); //krumo($content); } //------------------------------------------- //$content .= self::replaceEnv($newScss); //krumo(self::replaceEnv($newScss)); //------------------------------------------- FileFolder::file_put_contents($newScss, $content . $css); //------------------------------------------- $content = self::replaceEnv($newScss); //------------------------------------------- //krumo($content); $newCss = $newPath . $appendToName . ".css"; //------------------------------------------- FileFolder::createFolderStructure(dirname($newCss) . "/"); //------------------------------------------- exec("/usr/local/bin/sass --scss --no-cache --sourcemap=none " . $newScss . " " . $newCss . " 2>&1", $output); //------------------------------------------- if (strpos(join($output), "Errno::") || strpos(join($output), "Error:") !== false) { krumo($output); die; } //------------------------------------------- return $newCss; }
public static function extract($file, $extractToPath = NULL) { if (is_null($extractToPath)) { $extractToPath = FileFolder::getPathFromFile($file); } FileFolder::createFolderStructure($extractToPath); $zip = new ZipArchive(); if ($zip->open($file) === TRUE) { $zip->extractTo($extractToPath); $zip->close(); } }