Esempio n. 1
0
 public function getCode()
 {
     $this->content = $this->compiler->content;
     foreach ($this->code as $key => $value) {
         $txt = "";
         $minify = $this->isPropSet($value, "minify", true);
         if ($key == "css") {
             if (is_null($txt = Compiler::$css_code)) {
                 if (sizeof($this->compiler->linkTags) == 0) {
                     $result = $this->compiler->css_CFG(NULL, $this->content);
                     $this->content = $result['content'];
                     $this->compiler->linkTags = $result['linkTags'];
                 }
                 $txt = Compiler::$css_code = $this->getAllContent($this->compiler->linkTags, $key, $minify);
                 $txt = $this->isPropSet($value, "type", "inject") ? PHP_EOL . $txt . PHP_EOL : $txt;
             }
         } else {
             if ($key == "js") {
                 if (is_null($txt = Compiler::$js_code)) {
                     if (sizeof($this->compiler->scriptTags) == 0) {
                         $result = $this->compiler->script_CFG($this->content);
                         $this->content = $result['content'];
                         $this->compiler->scriptTags = $result['scriptTags'];
                     }
                     $scriptTags = $this->compiler->scriptTags;
                     $txt = Compiler::$js_code = $this->getAllContent($this->compiler->scriptTags, $key, $minify);
                     $txt = $this->isPropSet($value, "type", "inject") ? PHP_EOL . $txt . PHP_EOL : $txt;
                 }
             } else {
                 if ($key == "tmpl") {
                     if (is_null($txt = Compiler::$tmpl_code)) {
                         if (sizeof($this->compiler->scriptTags) == 0) {
                             $result = $this->compiler->script_CFG($this->content);
                             $this->content = $result['content'];
                             $this->compiler->scriptTags = $result['scriptTags'];
                         }
                         $txt = Compiler::$tmpl_code = $this->getAllContent($this->compiler->tmpl, $key, $minify);
                         if ($txt != "") {
                             $txt = $txt . PHP_EOL;
                         }
                     }
                 }
             }
         }
         //-----------------------------------------------------
         if ($this->isPropSet($value, "type", "inject")) {
             $this->injectTxt .= $txt . PHP_EOL;
         }
         //-----------------------------------------------------
         if ($this->isPropSet($value, "type", "single") && $txt != "") {
             $path = is_null($value['path']) ? "global/{$type}/" : $value['path'];
             if ($this->isPropSet($value, "type", "single")) {
                 FileFolder::file_put_contents($file = $this->path . $path . $this->compiler->compile_id . ($key == "tmpl" ? "_tmpl.html" : ".{$key}"), $txt);
             }
             $extLink = $this->getExtLink($path . $this->compiler->compile_id . ($key == "tmpl" ? "_tmpl.html" : ".{$key}"));
             $this->content = str_replace("</head>", $extLink . PHP_EOL . '</head>', $this->content);
         }
     }
     //krumo($this->compiler->getFiles($this->content, ""));
     //---------------------------------------------------------
     /*if ($this->type == "seperate"){
     			if (!$this->isPropSet($value, "type", "inject")) FileFolder::file_put_contents($this->path.$this->compiler->compile_id."_import.php", $this->import);
     		}*/
     //---------------------------------------------------------
     //FileFolder::file_put_contents(Compiler::$tmpPath.$this->id.".txt", $this->import);
     //---------------------------------------------------------
     return $txt;
 }