Beispiel #1
0
 public static function writeToFile($to_file, $data, $type, $overrideGZ = false)
 {
     if (!$to_file) {
         return false;
     }
     $to_file = JBETOLO_CACHE_DIR . '/' . str_replace(JBETOLO_CACHE_DIR . '/', '', $to_file);
     if (JFile::exists($to_file)) {
         return true;
     }
     if ($type == 'css' || $type == 'js') {
         $minify = JBETOLO_IS_MINIFY && plgSystemJBetolo::param($type . '_minify');
         $exclMinify = plgSystemJBetolo::param('minify_exclude');
         if (is_array($data)) {
             if ($minify && $exclMinify && count($exclMinify) > 0) {
                 $exclMinify = explode(',', $exclMinify);
                 foreach ($data as $d => $content) {
                     if (jbetoloFileHelper::isFileExcluded($content['file'], $exclMinify)) {
                         $data[$d] = $content['content'];
                     } else {
                         $data[$d] = jbetoloFileHelper::minify($type, $content['content']);
                     }
                 }
                 $data = implode("\n", $data);
             } else {
                 $data = jbetoloHelper::getArrayValues($data, 'content');
                 $data = implode("\n", $data);
                 if ($minify) {
                     $data = jbetoloFileHelper::minify($type, $data);
                 }
             }
         } else {
             if ($minify) {
                 $data = jbetoloFileHelper::minify($type, $data);
             } else {
                 $data = jbetoloHelper::eatWhiteSpace($data);
             }
         }
     }
     if (JBETOLO_IS_GZ && (plgSystemJBetolo::param($type . '_gzip') || $overrideGZ)) {
         $data = gzencode($data);
         JFile::write($to_file, $data);
     } else {
         JFile::write($to_file, $data);
     }
     return true;
 }