Ejemplo n.º 1
0
 /**
  * Exports min files to CDN
  *
  * @return array
  */
 function get_files_minify()
 {
     $files = array();
     if ($this->_config->get_boolean('minify.rewrite') && Util_Rule::can_check_rules() && (!$this->_config->get_boolean('minify.auto') || Cdn_Util::is_engine_mirror($this->_config->get_string('cdn.engine')))) {
         $minify = Dispatcher::component('Minify_Plugin');
         $document_root = Util_Environment::document_root();
         $minify_root = Util_Environment::cache_blog_dir('minify');
         $minify_path = ltrim(str_replace($document_root, '', $minify_root), '/');
         $urls = $minify->get_urls();
         // in WPMU + network admin (this code used for minify manual only)
         // common minify files are stored under context of main blog (i.e. 1)
         // but have urls of 0 blog, so download has to be used
         if ($this->_config->get_string('minify.engine') == 'file' && !(Util_Environment::is_wpmu() && is_network_admin())) {
             foreach ($urls as $url) {
                 Util_Http::get($url);
             }
             $files = Cdn_Util::search_files($minify_root, $minify_path, '*.css;*.js');
         } else {
             foreach ($urls as $url) {
                 $file = Util_Environment::normalize_file_minify($url);
                 $file = Util_Environment::translate_file($file);
                 if (!Util_Environment::is_url($file)) {
                     $file = $document_root . '/' . $file;
                     $file = ltrim(str_replace($minify_root, '', $file), '/');
                     $dir = dirname($file);
                     if ($dir) {
                         Util_File::mkdir($dir, 0777, $minify_root);
                     }
                     if (Util_Http::download($url, $minify_root . '/' . $file) !== false) {
                         $files[] = $minify_path . '/' . $file;
                     }
                 }
             }
         }
     }
     return $files;
 }