]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use TemplateLayout functions for finding js and css files in minimizer
authorBart Visscher <bartv@thisnet.nl>
Mon, 18 Jun 2012 13:40:43 +0000 (15:40 +0200)
committerBart Visscher <bartv@thisnet.nl>
Mon, 18 Jun 2012 13:40:48 +0000 (15:40 +0200)
core/minimizer.php
lib/minimizer.php
lib/minimizer/css.php
lib/minimizer/js.php

index 47e3d855e7b31857fa754adb4e826c81a8e8423c..0abbca7502723aa962a664785068978ae73ba2df 100644 (file)
@@ -5,11 +5,11 @@ OC_App::loadApps();
 
 if ($service == 'core.css'){
        $minimizer = new OC_Minimizer_CSS();
-       $files = $minimizer->findFiles(OC_Util::$core_styles);
+       $files = OC_TemplateLayout::findStylesheetFiles(OC_Util::$core_styles);
        $minimizer->output($files, $service);
 }
 else if ($service == 'core.js'){
        $minimizer = new OC_Minimizer_JS();
-       $files = $minimizer->findFiles(OC_Util::$core_scripts);
+       $files = OC_TemplateLayout::findJavascriptFiles(OC_Util::$core_scripts);
        $minimizer->output($files, $service);
 }
index 428fa477f77b4ee8b89d2baa3239a19e0c17662d..e17c114f0650fa69d257cf425216176c2a9b7887 100644 (file)
@@ -1,17 +1,6 @@
 <?php
 
-abstract class OC_Minimizer
-{
-       protected $files = array();
-
-       protected function appendIfExist($root, $webroot, $file) {
-                if (is_file($root.'/'.$file)) {
-                       $this->files[] = array($root, $webroot, $file);
-                        return true;
-                }
-                return false;
-       }
-
+abstract class OC_Minimizer {
        public function getLastModified($files) {
                $last_modified = 0;
                foreach($files as $file_info) {
index 09a0efdc3a73a4792d6718aa975cb972870d86d5..da502bfa9e8ce9a5fe81288f4f5f73b75bec98be 100644 (file)
@@ -6,50 +6,6 @@ class OC_Minimizer_CSS extends OC_Minimizer
 {
        protected $contentType = 'text/css';
 
-       public function findFiles($styles) {
-               // Read the selected theme from the config file
-               $theme=OC_Config::getValue( "theme" );
-
-               // Read the detected formfactor and use the right file name.
-               $fext = OC_Template::getFormFactorExtension();
-               foreach($styles as $style){
-                       // is it in 3rdparty?
-                       if($this->appendIfExist(OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $style.'.css')) {
-
-                       // or in apps?
-                       }elseif($this->appendIfExist(OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$style$fext.css" )) {
-                       }elseif($this->appendIfExist(OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$style.css" )) {
-
-                       // or in the owncloud root?
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "$style$fext.css" )) {
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "$style.css" )) {
-
-                       // or in core ?
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "core/$style$fext.css" )) {
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "core/$style.css" )) {
-
-                       }else{
-                               echo('css file not found: style:'.$style.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
-                               die();
-                       }
-               }
-               // Add the theme css files. you can override the default values here
-               if(!empty($theme)) {
-                       foreach($styles as $style){
-                                    if($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style$fext.css" )) {
-                               }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$style.css" )) {
-
-                               }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style$fext.css" )) {
-                               }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$style.css" )) {
-
-                               }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style$fext.css" )) {
-                               }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$style.css" )) {
-                               }
-                       }
-               }
-               return $this->files;
-       }
-
        public function minimizeFiles($files) {
                $css_out = '';
                $appswebroot = (string) OC::$APPSWEBROOT;
index b9a023e06862c15ebb557fea4b3392335a54a2c0..0f5cb7e5577f4bec2659bda44cf1de735cc87fb5 100644 (file)
@@ -6,49 +6,6 @@ class OC_Minimizer_JS extends OC_Minimizer
 {
        protected $contentType = 'application/javascript';
 
-       public function findFiles($scripts) {
-               // Read the selected theme from the config file
-               $theme=OC_Config::getValue( "theme" );
-
-               // Read the detected formfactor and use the right file name.
-               $fext = OC_Template::getFormFactorExtension();
-               // Add the core js files or the js files provided by the selected theme
-               foreach($scripts as $script){
-                       // Is it in 3rd party?
-                       if($this->appendIfExist(OC::$THIRDPARTYROOT, OC::$THIRDPARTYWEBROOT, $script.'.js')) {
-
-                       // Is it in apps and overwritten by the theme?
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script$fext.js" )) {
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/apps/$script.js" )) {
-
-                       // Is it part of an app?
-                       }elseif($this->appendIfExist(OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$script$fext.js" )) {
-                       }elseif($this->appendIfExist(OC::$APPSROOT, OC::$APPSWEBROOT, "apps/$script.js" )) {
-
-                       // Is it in the owncloud root but overwritten by the theme?
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script$fext.js" )) {
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/$script.js" )) {
-
-                       // Is it in the owncloud root ?
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "$script$fext.js" )) {
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "$script.js" )) {
-
-                       // Is in core but overwritten by a theme?
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$script$fext.js" )) {
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "themes/$theme/core/$script.js" )) {
-
-                       // Is it in core?
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "core/$script$fext.js" )) {
-                       }elseif($this->appendIfExist(OC::$SERVERROOT, OC::$WEBROOT, "core/$script.js" )) {
-
-                       }else{
-                               echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT);
-                               die();
-                       }
-               }
-               return $this->files;
-       }
-
        public function minimizeFiles($files) {
                $js_out = '';
                foreach($files as $file_info) {