Added feature #13131: Add API to add stylesheet directories (Thanks to Steffen Gebert)
authorBenni Mack <benni.mack@typo3.org>
Fri, 19 Feb 2010 14:28:30 +0000 (14:28 +0000)
committerBenni Mack <benni.mack@typo3.org>
Fri, 19 Feb 2010 14:28:30 +0000 (14:28 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@6909 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
NEWS.txt
typo3/template.php

index 66195bb..8a5dce7 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-02-19  Benjamin Mack  <benni@typo3.org>
+
+       * Added feature #13131: Add API to add stylesheet directories (Thanks to Steffen Gebert)
+
 2010-02-14  Christian Kuhn  <lolli@schwarzbu.ch>
 
        * Follow-up to #13448: Do not unset $typo3CacheFactory singleton
index 03a4885..e8a9861 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -12,7 +12,7 @@ General
 Backend
 =======
 
-       * ...
+       * It is now possible to add whole directories of CSS files to the backend by setting $TBE_STYLES['stylesheetDirectories'][$_EXTKEY][] = 'EXT:myext/stylesheets/' 
 
 
 Frontend
index ceff805..54bd90e 100644 (file)
@@ -269,6 +269,27 @@ class template {
                if ($TBE_STYLES['styleSheetFile_post']) $this->styleSheetFile_post = $TBE_STYLES['styleSheetFile_post'];
                if ($TBE_STYLES['inDocStyles_TBEstyle'])        $this->inDocStyles_TBEstyle = $TBE_STYLES['inDocStyles_TBEstyle'];
 
+                       // Stylesheets from skins:
+                       // stylesheet directories have to be registered this way in ext_tables.php:
+                       // $TBE_STYLES['stylesheetDirectories'][$_EXTKEY][] = 'EXT:myext/stylesheets/visual/'
+               if (is_array($TBE_STYLES['stylesheetDirectories'])) {
+                               // loop over all extensions registering stylesheetDirectories
+                       foreach ($TBE_STYLES['stylesheetDirectories'] as $key => $directories) {
+                                       // loop over all stylesheetDirectories of this extension
+                               foreach ($directories as $directory) {
+                                               // we expect EXT:myext/.../ here
+                                       $extKey = substr($directory, 4, strpos($directory, '/') - 4);
+                                       $styleDirectory = substr($directory, strpos($directory, '/') + 1);
+                                               // ensure that we have a trailing /
+                                       $styleDirectory = rtrim($styleDirectory, '/') . '/';
+                                               // add stylesheets
+                                       if (is_readable(t3lib_extMgm::extPath($extKey) . $styleDirectory)) {
+                                               $this->addStyleSheetDirectory(t3lib_extMgm::extRelPath($extKey) . $styleDirectory);
+                                       }
+                               }
+                       }
+               }
+
                        // Background image
                if ($TBE_STYLES['background'])  $this->backGroundImage = $TBE_STYLES['background'];
        }
@@ -1029,6 +1050,25 @@ $str.=$this->docBodyTagBegin().
                $this->pageRenderer->addCssFile($file, $relation, $title);
        }
 
+       /**
+        * Add all *.css files of the directory $path to the stylesheets
+        *
+        * @param       string          directory to add
+        * @return      void
+        */
+       function addStyleSheetDirectory($path) {
+                       // calculation needed, when TYPO3 source is used via a symlink
+                       // absolute path to the stylesheets
+               $filePath = dirname(t3lib_div::getIndpEnv('SCRIPT_FILENAME')) . '/' . $GLOBALS['BACK_PATH'] . $path;
+                       // clean the path
+               $resolvedPath = t3lib_div::resolveBackPath($filePath);
+                       // read all files in directory and sort them alphabetically
+               $files = t3lib_div::getFilesInDir($resolvedPath, 'css', FALSE, 1);
+               foreach ($files as $file) {
+                       $this->pageRenderer->addCssFile($GLOBALS['BACK_PATH'] . $path . $file, 'stylesheet', 'all');
+               }
+       }
+
        /**
         * Insert post rendering document style into already rendered content
         * This is needed for extobjbase