@@ -28,7 +28,7 @@ class Html
2828
2929 private $ name = '' ;
3030 private $ cached = false ;
31- private $ mode = 'pro ' ; //pro|dev
31+ private $ mode = 'dev ' ; //pro|dev
3232
3333 private $ pathHtml = null ;
3434 private $ pathHtmlCache = null ;
@@ -72,8 +72,8 @@ function __construct(
7272 foreach ($ config as $ k => $ v ) {
7373 $ this ->{$ k } = $ v ;
7474 }
75- } elseif (method_exists ('Config\Html ' , 'getParams ' )) {
76- foreach ((new \Config \Html )->getParams () as $ k => $ v ) {
75+ } elseif (method_exists ('Config\Lib\ Html ' , 'getParams ' )) {
76+ foreach ((new \Config \Lib \ Html )->getParams () as $ k => $ v ) {
7777 $ this ->{$ k } = $ v ;
7878 }
7979 }
@@ -328,51 +328,39 @@ function forceCompress($b = true)
328328
329329 private function assetsComp ()
330330 {
331- ini_set ('max_execution_time ' , '200 ' );
332-
333- $ java = 'java -jar ' .__DIR__ .'/min/yc.jar ' ;
334- $ allcss = strtolower ($ this ->pathStyle .$ this ->name ).'_all.css ' ;
335- $ alljs = strtolower ($ this ->pathScript .$ this ->name ).'_all.js ' ;
336-
337331 //CSS STYLES
338- if (file_exists ($ allcss ) && !$ this ->forceCompress ) {
339- $ content = file_get_contents ($ allcss );
332+ if (file_exists ($ this -> pathStyle . $ this -> name . ' _all.css ' ) && !$ this ->forceCompress ) {
333+ $ content = file_get_contents ($ this -> pathStyle . $ this -> name . ' _all.css ' );
340334 } else {
341335 $ content = '' ;
342336 foreach ($ this ->styles as $ file ) {
343- $ temp = exec ($ java .'" ' .$ this ->pathStyle .$ file .'.css" ' );
344- //echo "\n\n<br><br>".$file.' == '.substr($temp, 0, 10);
345- $ content .= $ temp ;
337+ $ content .= exec ('java -jar ' .__DIR__ .'/min/yc.jar " ' .$ this ->pathStyle .$ file .'.css" ' );
346338 }
347- file_put_contents ($ allcss , $ content );
348- // $content = exec($ java.$allcss.' "');
349- // file_put_contents($allcss , $content);
339+ file_put_contents ($ this -> pathStyle . $ this -> name . ' _all.css ' , $ content );
340+ $ content = exec (' java -jar ' . __DIR__ . ' /min/yc.jar " ' . $ this -> pathStyle . $ this -> name . ' _all.css " ' );
341+ file_put_contents ($ this -> pathStyle . $ this -> name . ' _all.css ' , $ content );
350342 }
351- $ this ->val ('style ' , '<link id="stylesheet_base" rel="stylesheet" href=" ' . strtolower ( $ this -> url . ' css/ ' . $ this -> name ). ' _all.css"> ' ); // >'.$content.'</style>');
343+ $ this ->val ('style ' , '<style id="stylesheet_base"> ' .$ content .'</style> ' );
352344
353345 //JAVASCRIPTS
354- if (file_exists ($ alljs ) && !$ this ->forceCompress ) {
355- $ content = file_get_contents ($ alljs );
346+ if (file_exists ($ this -> pathScript . $ this -> name . ' _all.js ' ) && !$ this ->forceCompress ) {
347+ $ content = file_get_contents ($ this -> pathScript . $ this -> name . ' _all.js ' );
356348 } else {
357349 $ content = '; ' ;
358350 foreach ($ this ->scripts as $ file ) {
359- $ temp = exec ($ java .'" ' .$ this ->pathScript .$ file .'.js" ' );
360- //echo "\n\n<br><br>".$file.' == '.substr($temp, 0, 10);
361- $ content .= $ temp ;
351+ $ content .= exec ('java -jar ' .__DIR__ .'/min/yc.jar " ' .$ this ->pathScript .$ file .'.js" ' );
362352 }
363- file_put_contents ($ alljs , $ content );
364- // $content = exec($ java.' "'.$alljs.' "');
365- // file_put_contents($alljs , $content);
353+ file_put_contents ($ this -> pathScript . $ this -> name . ' _all.js ' , $ content );
354+ $ content = exec (' java -jar ' . __DIR__ . ' /min/yc.jar " ' .$ this -> pathScript . $ this -> name . ' _all.js " ' );
355+ file_put_contents ($ this -> pathScript . $ this -> name . ' _all.js ' , $ content );
366356 }
367357
368358 $ s = '<script id="javascript_base">var _URL= \'' .$ this ->url .'\'' ;
369359 foreach ($ this ->jsvalues as $ n => $ v ) {
370360 $ s .= ', ' .$ n .'= ' .(is_string ($ v ) ? '\'' .str_replace ("' " , '" ' , $ v ).'\'' : $ v );
371361 }
372362 $ s .= '; ' ;
373- $ this ->val ('script ' , $ s .'</script><script src=" ' .strtolower ($ this ->url .'js/ ' .$ this ->name ).'_all.js"></script> ' );
374-
375- //exit('ok');
363+ $ this ->val ('script ' , $ s .$ content .'</script> ' );
376364 }
377365
378366
@@ -416,15 +404,13 @@ function send()
416404 header ('Expires: ' . gmdate ('D, d M Y H:i:s ' , time () + 31536000 ) . ' GMT ' );
417405 header ('Cache-Control: must_revalidate, public, max-age=31536000 ' );
418406 header ('X-Server: Qzumba/0.1.8.beta ' );//for safety ...
419- header ('X-Powered-By: DevBrasil/0.1.1 ' );//for safety ...
407+ header ('X-Powered-By: NEOS PHP FRAMEWORK/1.3.0 ' );//for safety ...
420408
421409 if ($ this ->cached &&
422410 file_exists ($ this ->pathHtmlCache .$ this ->name .'_cache.html ' )) {
423411 return $ this ->sendWithCach ();
424412 } else {
425- //$this->content = $this->minify_html($this->content);
426- //\Lib\App::e($this);
427- exit (eval ('?> ' .$ this ->minify_html ($ this ->content )));
413+ exit (eval ('?> ' .$ this ->content ));
428414 }
429415 }
430416
@@ -691,7 +677,7 @@ private function _var($ret)
691677 return '' ;
692678 }
693679 //$ret['-content-'] .= $v;
694- $ ret ['-content- ' ] .= '<?php echo Lib\Html::minify_html(Lib\Html:: get(" ' .trim ($ ret ['var ' ]).'") )?> ' ;
680+ $ ret ['-content- ' ] .= '<?php echo Lib\Html::get(" ' .trim ($ ret ['var ' ]).'")?> ' ;
695681
696682 //List type
697683 if (is_array ($ v )) {
@@ -770,15 +756,14 @@ private function _block($ret)
770756 */
771757 private function _select ($ ret )
772758 {
773- //App::e($ret);
774759 $ var = $ this ->getVar ($ ret ['data ' ]);
775760 if (!$ var ) {
776761 return false ;
777762 }
778763
779764 $ o = '' ;
780765 foreach ($ var ['data ' ] as $ k => $ v ) {
781- $ o .= '<option value=" ' .$ k .'" ' .(isset ( $ var [ ' default ' ]) && $ var ['default ' ] == $ k ? ' selected ' :'' ).'> ' .$ v .'</option> ' ;
766+ $ o .= '<option value=" ' .$ k .'" ' .($ var ['default ' ] == $ k ? ' selected ' :'' ).'> ' .$ v .'</option> ' ;
782767 }
783768 $ ret ['-content- ' ] = $ o ;
784769 $ ret ['tag ' ] = 'select ' ;
@@ -836,105 +821,4 @@ function clearData($ret)
836821 $ ret ['data ' ]);
837822 return $ ret ;
838823 }
839-
840-
841- /**
842- * Minify HTML
843- * @param string $input content for html
844- * @return string Minified html string
845- */
846- static function minify_html ($ input )
847- {
848- if (trim ($ input ) === "" ) {
849- return $ input ;
850- }
851- // Remove extra white-space(s) between HTML attribute(s)
852- $ input = preg_replace_callback ('#<([^\/\s<>!]+)(?:\s+([^<>]*?)\s*|\s*)(\/?)>#s ' , function ($ matches ) {
853- return '< ' . $ matches [1 ] . preg_replace ('#([^\s=]+)(\=([ \'"]?)(.*?)\3)?(\s+|$)#s ' , ' $1$2 ' , $ matches [2 ]) . $ matches [3 ] . '> ' ;
854- }, str_replace ("\r" , "" , $ input ));
855- // Minify inline CSS declaration(s)
856- if (strpos ($ input , ' style= ' ) !== false ) {
857- $ input = preg_replace_callback ('#<([^<]+?)\s+style=([ \'"])(.*?)\2(?=[\/\s>])#s ' , function ($ matches ) {
858- return '< ' . $ matches [1 ] . ' style= ' . $ matches [2 ] . static ::minify_css ($ matches [3 ]) . $ matches [2 ];
859- }, $ input );
860- }
861- return preg_replace (
862- array (
863- // t = text
864- // o = tag open
865- // c = tag close
866- // Keep important white-space(s) after self-closing HTML tag(s)
867- '#<(img|input)(>| .*?>)#s ' ,
868- // Remove a line break and two or more white-space(s) between tag(s)
869- '#(<!--.*?-->)|(>)(?:\n*|\s{2,})(<)|^\s*|\s*$#s ' ,
870- '#(<!--.*?-->)|(?<!\>)\s+(<\/.*?>)|(<[^\/]*?>)\s+(?!\<)#s ' , // t+c || o+t
871- '#(<!--.*?-->)|(<[^\/]*?>)\s+(<[^\/]*?>)|(<\/.*?>)\s+(<\/.*?>)#s ' , // o+o || c+c
872- '#(<!--.*?-->)|(<\/.*?>)\s+(\s)(?!\<)|(?<!\>)\s+(\s)(<[^\/]*?\/?>)|(<[^\/]*?\/?>)\s+(\s)(?!\<)#s ' , // c+t || t+o || o+t -- separated by long white-space(s)
873- '#(<!--.*?-->)|(<[^\/]*?>)\s+(<\/.*?>)#s ' , // empty tag
874- '#<(img|input)(>| .*?>)<\/\1>#s ' , // reset previous fix
875- '#( ) (?![<\s])# ' , // clean up ...
876- '#(?<=\>)( )(?=\<)# ' , // --ibid
877- // Remove HTML comment(s) except IE comment(s)
878- '#\s*<!--(?!\[if\s).*?-->\s*|(?<!\>)\n+(?=\<[^!])#s '
879- ),
880- array (
881- '<$1$2</$1> ' ,
882- '$1$2$3 ' ,
883- '$1$2$3 ' ,
884- '$1$2$3$4$5 ' ,
885- '$1$2$3$4$5$6$7 ' ,
886- '$1$2$3 ' ,
887- '<$1$2 ' ,
888- '$1 ' ,
889- '$1 ' ,
890- ""
891- ),
892- $ input );
893- }
894-
895-
896- static function minify_css ($ input )
897- {
898- if (trim ($ input ) === "" ) {
899- return $ input ;
900- }
901- return preg_replace (
902- array (
903- // Remove comment(s)
904- '#("(?:[^" \\\]++| \\\.)*+"| \'(?:[^ \'\\\\]++| \\\.)*+ \')|\/\*(?!\!)(?>.*?\*\/)|^\s*|\s*$#s ' ,
905- // Remove unused white-space(s)
906- '#("(?:[^" \\\]++| \\\.)*+"| \'(?:[^ \'\\\\]++| \\\.)*+ \'|\/\*(?>.*?\*\/))|\s*+;\s*+(})\s*+|\s*+([*$~^|]?+=|[{};,>~+]|\s*+-(?![0-9\.])|!important\b)\s*+|([[(:])\s++|\s++([])])|\s++(:)\s*+(?!(?>[^{}" \']++|"(?:[^" \\\]++| \\\.)*+"| \'(?:[^ \'\\\\]++| \\\.)*+ \')*+{)|^\s++|\s++\z|(\s)\s+#si ' ,
907- // Replace `0(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)` with `0`
908- '#(?<=[\s:])(0)(cm|em|ex|in|mm|pc|pt|px|vh|vw|%)#si ' ,
909- // Replace `:0 0 0 0` with `:0`
910- '#:(0\s+0|0\s+0\s+0\s+0)(?=[;\}]|\!important)#i ' ,
911- // Replace `background-position:0` with `background-position:0 0`
912- '#(background-position):0(?=[;\}])#si ' ,
913- // Replace `0.6` with `.6`, but only when preceded by `:`, `,`, `-` or a white-space
914- '#(?<=[\s:,\-])0+\.(\d+)#s ' ,
915- // Minify string value
916- '#(\/\*(?>.*?\*\/))|(?<!content\:)([ \'"])([a-z_][a-z0-9\-_]*?)\2(?=[\s\{\}\];,])#si ' ,
917- '#(\/\*(?>.*?\*\/))|(\burl\()([ \'"])([^\s]+?)\3(\))#si ' ,
918- // Minify HEX color code
919- '#(?<=[\s:,\-]\#)([a-f0-6]+)\1([a-f0-6]+)\2([a-f0-6]+)\3#i ' ,
920- // Replace `(border|outline):none` with `(border|outline):0`
921- '#(?<=[\{;])(border|outline):none(?=[;\}\!])# ' ,
922- // Remove empty selector(s)
923- '#(\/\*(?>.*?\*\/))|(^|[\{\}])(?:[^\s\{\}]+)\{\}#s '
924- ),
925- array (
926- '$1 ' ,
927- '$1$2$3$4$5$6$7 ' ,
928- '$1 ' ,
929- ':0 ' ,
930- '$1:0 0 ' ,
931- '.$1 ' ,
932- '$1$3 ' ,
933- '$1$2$4$5 ' ,
934- '$1$2$3 ' ,
935- '$1:0 ' ,
936- '$1$2 '
937- ),
938- $ input );
939- }
940824}
0 commit comments