Exemple #1
0
 public function chk()
 {
     //-------------------------------------------
     //init var
     //-------------------------------------------
     $bool = true;
     $delete = false;
     $file = $this->file_absolute;
     //-------------------------------------------
     foreach (Import::$filesLoaded as &$value) {
         if ($file == $value) {
             $bool = false;
         }
     }
     if ($bool) {
         $bool = Import::fileExist($file, $this->notExistException);
         //---------------------------------------
         if (!$bool) {
             return $bool;
         }
         //---------------------------------------
         array_push(Import::$filesLoaded, $file);
         //---------------------------------------
         if ($this->ext == "js") {
             echo Html::getExJs($file) . PHP_EOL;
             return $bool;
         } else {
             if ($this->ext == "css") {
                 echo Html::getExCss($file) . PHP_EOL;
                 return $bool;
             } else {
                 if ($this->ext == "scss") {
                     $file = GenFun::get_full_url(self::compileSass($file));
                     echo Html::getExCss($file) . PHP_EOL;
                     return $bool;
                 } else {
                     if ($this->importFunction == "include") {
                         require_once "Compiler.php";
                         $modified = "HHH" . filectime($file) . "HHH";
                         $newPath = $this->newPath_CFG($file) . "_" . $modified . ".php";
                         // krumo(Import::$latestFiles);
                         /*if (isset(Import::$latestFiles[$file]) && FileFolder::file_exists($newPath) && Import::$latestFiles[$file] == filectime($newPath)){
                              //print_r("kdhsf");
                              unset(Import::$latestFiles[$file]);
                           }*/
                         //-----------------------------------
                         //krumo(Import::$latestFiles);
                         if (!FileFolder::file_exists($newPath)) {
                             $content = file_get_contents($file);
                             //-----------------------------------
                             $prop = array("output" => $content, "onRemoveMatch" => array("Import", "onRemoveMatch"), "src_path" => $file, "matchProp" => array("ignoreIfExistInMatch" => array("<link")));
                             //---------------------------------------------
                             $css = new Compile_CSS($prop);
                             $content = $css->output_updated;
                             //$newPath = self::newPath_CFG($file);
                             //---------------------------------------------
                             //krumo($file);
                             /*$newScss = $newPath.".scss";
                             		$content = self::replaceEnv(Import::$uber_src_path."GlobalSass.scss");
                             		FileFolder::file_put_contents($newScss, $content.$css->mergedCode_noTag);
                             		$newCss = $newPath.".css";
                             		//$output = shell_exec("/usr/local/bin/sass --scss -t uncompressed --sourcemap=none ".$newScss." ".$newCss);
                             		exec("/usr/local/bin/sass --scss --sourcemap=none ".$newScss." ".$newCss." 2>&1", $output);*/
                             /*if (strpos(join($output), "Errno::") !== false) {
                             			krumo($output);
                             			die();
                             		};*/
                             FileFolder::file_put_contents($newPath, $content);
                             $this->file_absolute_tmp = $file = $newPath;
                             $this->compile_css = $css;
                             $file = Compiler::brand_CFG($file);
                         } else {
                             $file = $newPath;
                             $file = Compiler::brand_CFG($file);
                         }
                         //---------------------------------------------
                         /*if (sizeof($code->tmpl->matches) > 0) {
                         			echo '<!--{'.$file.'}-->'.$code->tmpl->mergedCode;
                         		}*/
                         //---------------------------------------------
                         /*$txt = Compiler::brand("script", $orig_txt, $file);
                         		$txt = Compiler::brand("style", $txt, $file);
                         		//-----------------------------------
                         		if ($txt != $orig_txt) {
                         			$delete = true;
                         			//-------------------------------
                         			$file = FileFolder::getPathFromFile($file).FileFolder::getFileName($file).".".FileFolder::getFileExt($file);
                         			$file = str_replace(array(Import::$uber_src_path, Import::getImportPath()), Compiler::$unminifiedPath_raw, $file);
                         			FileFolder::file_put_contents($file, $txt);
                         		}*/
                         //-----------------------------------
                         //if($delete) FileFolder::delete($file);
                     }
                 }
             }
         }
         if ($bool && !is_null($this->importFunction) && !$this->externalLink) {
             eval($this->importFunction . " '" . $file . "';");
         }
     }
     //-------------------------------------------
     return $bool;
 }