protected static function fadeIn()
 {
     if (self::$config['LazyLoadFadeIn']) {
         $file = self::$config['BasePath'] . self::$config['LazyLoadBasePath'] . self::$config['cacheId'] . DIRECTORY_SEPARATOR . self::$config['LazyLoadCssFilePath'] . 'LazyLoad.css';
         if (!file_exists($file)) {
             @mkdir(dirname($file), 0777, true);
             copy(self::$base . self::$config['LazyLoadCssFilePath'] . 'LazyLoad.css', $file);
         }
         self::$htmlHeaders->addCss(array('href' => self::$path . self::$config['LazyLoadCssFilePath'] . 'LazyLoad.css', 'rel' => 'stylesheet', 'type' => 'text/css', 'media' => 'screen'));
     }
 }
 protected function integrateAllCss()
 {
     $this->setCssFileName();
     foreach ($this->csss as $key => $csss) {
         $set_css[$key][] = array('href' => Url::normalizeUrl($this->config['URIBasePath'] . $this->config['PublicCacheDir'] . $this->config['cacheId'] . $this->config['CssMinifiedFilePath'] . $this->filename[$key]), 'type' => 'text/css', 'rel' => 'stylesheet', 'media' => $key);
         $this->filename[$key] = $this->config['BasePath'] . $this->config['PublicCacheDir'] . '/' . $this->config['cacheId'] . $this->config['CssMinifiedFilePath'] . $this->filename[$key];
         $this->makeFilePath($this->filename[$key], $key);
         if (!file_exists($this->completeFilePath[$key])) {
             foreach ($csss as $item) {
                 if ($item['data-type'] == 'inline') {
                     $referer = filter_input(INPUT_SERVER, 'REQUEST_URI');
                 } else {
                     $referer = $item['href'];
                 }
                 $this->content[$key] .= $this->fixUrl($this->get_data($item['href']), Url::normalizeUrl($referer)) . PHP_EOL;
             }
             $this->writeCssFile($key);
         }
     }
     $this->htmlHeaders->setCss($set_css);
 }
 public function __construct($config)
 {
     $this->config = $config;
     $this->htmlHeaders = HtmlHeaders::getInstance();
     $this->jss = $this->htmlHeaders->getJs();
 }
 /**
  * @param HtmlHeaders $htmlHeaders
  */
 private function organizeJS($htmlHeaders)
 {
     $htmlContent = $this->DOMHtml->getContent();
     $regex = '/<script((?:.)*?)>(.*?)<\\/script>/smix';
     $config = $this->config;
     $self = $this;
     $content = preg_replace_callback($regex, function ($script) use($htmlHeaders, $config, $self) {
         $regex_tribb = '/(\\S+)=["\']((?:.(?!["\']\\s+(?:\\S+)=|[>"\']))+.)["\']/';
         preg_match_all($regex_tribb, $script[1], $matches);
         if (isset($matches[1]) && isset($matches[2])) {
             foreach ($matches[1] as $k => $key) {
                 if (trim($key) == 'src') {
                     $v = File::url_decode(trim($matches[2][$k]));
                 } else {
                     $v = trim($matches[2][$k]);
                 }
                 $attributes[trim($key)] = $v;
             }
         }
         if ($attributes['type'] == 'text/javascript' || !$attributes['type']) {
             if ($attributes['src']) {
                 $htmlHeaders->addJs($attributes);
                 return;
             } elseif ($config['JavascriptIntegrateInline'] && $config['JavascriptIntegrate']) {
                 $attributes['value'] = isset($script[2]) ? $script[2] : '';
                 if (!$self->jsAwaysInline($attributes['value'])) {
                     $self->addJsInline($htmlHeaders, $attributes);
                     return;
                 } else {
                     return $script[0];
                     /**
                      * @todo Adjust to work fine with document.write
                      */
                     /*
                      $id = md5($script[0]);
                      $attributes['value'] = str_replace('document.write(', 'replace_text("' . $id . '",', $attributes['value']);
                      $self->addJsInline($htmlHeaders, $attributes);
                      $replace = '<script type="text/javascript" id="' . $id . '">';
                      $replace .= 'var elem = document.getElementById("' . $id . '");';
                      $replace .= 'elem.addEventListener("' . $id . '", function (event) {';
                      $replace .= 'document.write(event.detail);';
                      $replace .= '});';
                      $replace .= '</script>';
                      return $replace;
                     */
                 }
             } else {
                 return $script[0];
             }
         } else {
             return $script[0];
         }
     }, $htmlContent);
     $this->DOMHtml->setContent($content ?: $htmlContent);
 }