public static function go($obj, $arr) { if (!is_null($obj)) { try { if (!is_array($obj)) { throw new Exception("obj or arr is not an array"); } } catch (Exception $e) { krumo($obj, $arr); krumo($e); die; } } //------------------------------------------- $obj = ArrayUtil::array_replace_recursive($arr, $obj); //------------------------------------------- if (is_array($obj['file'])) { $files = array(); foreach ($obj['file'] as $value) { $newObj = ArrayUtil::array_replace_recursive(array(), $obj); $newObj['file'] = $value; //------------------------------------------- $ref = new Import($newObj); //------------------------------------------- array_push($files, $ref->init()); } } else { $ref = new Import($obj); return $ref->init(); } }
public function scrape_CFG() { /*preg_match_all('/<!--<seperate((?: {|{)(?:.*?)})(.*?)<!--<\/seperate>-->/s', $content, $matches); //--------------------------------------------------------- if (sizeof($matches[0]) > 0) { $this->css_CFG(NULL, $matches[2][0], json_decode($matches[1][0], true)); //----------------------------------------------------- $content = str_replace($matches[0][0], "", $content); //----------------------------------------------------- }*/ $this->tags = array(); //--------------------------------------------------------- $output_updated = $this->output_markup = Compiler::markUp_CHK($this->output, array("ignore" => true, "replace" => true)); //$output_updated = StringUtil::removeAllHtmlComments($output_updated); //--------------------------------------------------------- preg_match_all($this->regex, $output_updated, $matches, PREG_SET_ORDER); //--------------------------------------------------------- $this->matches = $matches; //--------------------------------------------------------- foreach ($matches as $key => $match) { $save_dir = $this->save_dir; //----------------------------------------------------- $prop = array("forceDownload" => $this->forceDownload, "compileType" => $this->compileType, "compilePath" => $this->compilePath, "compilerGlobal" => $this->compilerGlobal, "minify" => $this->minify, "save_dir" => $save_dir, "defaultSavePath" => $this->defaultSavePath, "output" => $this->output_updated, "match" => $match, "imagesProp" => $this->imagesProp, "index" => $key, "onRemoveMatch" => $this->onRemoveMatch, "src_path" => $this->src_path); //----------------------------------------------------- $newMatch = ClassUtil::classFromString($this->matchClass, array(ArrayUtil::array_replace_recursive($prop, $this->matchProp))); $newMatch->init(); //----------------------------------------------------- $this->output_updated = $newMatch->output_updated; //----------------------------------------------------- if (!is_null($newMatch->link)) { if ($this->saveasphp) { $this->mergedCode .= $newMatch->content_updated; } else { //$this->extLinks .= $newMatch->link; } } else { //if (is_null($this->compilerGlobal->mergedCode)) $this->compilerGlobal->mergedCode = ""; if (!is_null($newMatch->content_updated)) { if ($newMatch->tagType != "tmpl") { $this->mergedCode_noTag .= PHP_EOL . $newMatch->content_updated; $this->mergedCode .= "<" . $newMatch->tagType . ">" . PHP_EOL . $newMatch->content_updated . "</" . $newMatch->tagType . ">"; } else { $this->mergedCode .= PHP_EOL . $newMatch->content_updated; } } } //----------------------------------------------------- $this->tags[] = $newMatch; } //--------------------------------------------------------- //$this->output_updated = $output_updated; }
private function compile_CFG($url, $id, $savePath) { $_GET['compile'] = 1; $_GET['refresh'] = 1; $_GET['compile_id'] = $id; //--------------------------------------------------------- $prop = array("url" => $url, "compilePath" => $savePath); //--------------------------------------------------------- if (file_exists($path = GenFun::get_local_url($url) . "compileConfig.js")) { $this->compileObj = json_decode(file_get_contents($path), true); } else { if (class_exists("ProjectGlobal")) { $this->compileObj = ProjectGlobal::$compileObj; } } return $compiler = new Compiler(ArrayUtil::array_replace_recursive($this->compileObj, $prop)); //--------------------------------------------------------- }
function __construct($obj) { //----------------------------------------------------- SetPublicProp::go($this, $obj); //----------------------------------------------------- $this->compilePath = $this->compilerGlobal->compilePath . $this->save_path; $this->compilerGlobal->compileType = $this->compileType; //----------------------------------------------------- if ($this->insideCURL) { $this->complete(); } else { if (!$this->raw) { $prop = array("output" => $this->output, "minify" => $this->minify, "forceDownload" => $this->forceDownload, "compilerGlobal" => $this->compilerGlobal, "imagesProp" => $this->imagesProp, "compilePath" => $this->compilePath, "compileType" => $this->compileType); //--------------------------------------------- $this->css = new Compile_CSS(ArrayUtil::array_replace_recursive($prop, $this->cssProp)); $this->output_updated = $this->css->output_updated; //--------------------------------------------- $prop['output'] = $this->output_updated; $this->js = new Compile_JS(ArrayUtil::array_replace_recursive($prop, $this->jsProp)); $this->output_updated = $this->js->output_updated; //--------------------------------------------- $prop['output'] = $this->output_updated; $this->tmpl = new Compile_TMPL(ArrayUtil::array_replace_recursive($prop, $this->tmplProp)); $this->output_updated = $this->tmpl->output_updated; //----------------------------------------------------- $prop = array("src_content" => $this->output_updated, "forceDownload" => $this->forceDownload, "compilerGlobal" => $this->compilerGlobal, "compilePath" => $this->compilePath); $this->output_images = new Compile_Images($prop); $this->output_images->init($this->imagesProp); $this->output_updated = $this->output_images->src_content_updated; //--------------------------------------------- $this->css->output_updated = $this->output_updated; $this->css->compile(); $this->output_updated = $this->css->output_updated; //--------------------------------------------- $this->js->output_updated = $this->output_updated; $this->js->compile(); $this->output_updated = $this->js->output_updated; //--------------------------------------------- $this->tmpl->output_updated = $this->output_updated; $this->tmpl->compile(); $this->output_updated = $this->tmpl->output_updated; //--------------------------------------------- } $this->copy_CFG(); } //$this->compiler->getFiles($this->output, ""); //----------------------------------------------------- $this->output_updated = Compiler::markUp_CHK($this->output_updated); //----------------------------------------------------- //if ($this->compileType == "inject") $this->output_updated = str_replace("<head>","<head>".PHP_EOL.$this->mergedCode.PHP_EOL, $this->output_updated); //----------------------------------------------------- /*if ($this->compileType != "inject")*/ $this->output_updated = str_replace("<head>", "<head>" . PHP_EOL . $this->css->extLinks . PHP_EOL, $this->output_updated); //----------------------------------------------------- $this->output_updated = str_replace("<head>", "<head>" . PHP_EOL . $this->js->extLinks . PHP_EOL, $this->output_updated); //----------------------------------------------------- $this->clean_output(); //----------------------------------------------------- $this->output_updated = str_replace("<head>", '<head><meta charset="utf-8">', $this->output_updated); //----------------------------------------------------- if (is_array($this->outputContent)) { FileFolder::file_put_contents($this->compilePath . $this->outputContent['saveas'], $this->output_updated); } //----------------------------------------------------- $this->output_images->compile(); //----------------------------------------------------- Archive::zipDir($this->compilePath); }