No subject


Mon Nov 23 20:10:05 CET 2009


"It should be useful to have a stdwrap properties in page.includeJS
includeCSS includeFooterJS ... to be able to use "if" conditions in
every file included.
For example it's very common to load a JS/CSS lib if you insert a FCE,
you could use page.headerData but it isnt as clean as includeJS"

Solution:
Add stdWrap possibilities to CSS and JS inclusion methods, in TS to the
properties:
- includeCSS
- includeJSlibs
- includeJSFooterlibs
- includeJS
- includeJSFooter

Can be used from extensions (PHP), too.

How to test:
Use some TS like the following and look at your source code (adjust the
filenames to existing ones):

page {
  includeCSS {
    file1 = fileadmin/template/test.css
    file1.stdWrap.wrap = <!-- test | -->
  }
  includeJS {
    file1 = fileadmin/template/test.js
    file1.stdWrap.wrap = <!-- test | -->
  }
  includeJSFooter {
    file1 = fileadmin/template/test2.js
    file1.stdWrap.wrap = <!-- test2 | -->
  }
  includeJSFooterlibs {
    file1 = fileadmin/template/test3.js
    file1.stdWrap.wrap = <!-- test3 | -->
  }
}

Test from extension:
Use f.e. the pagerenderers addCSSfile with a stdWrap config array as
last parameter:

$pageRenderer->addCssFile($file, 'stylesheet', 'screen', '', TRUE,
FALSE, '', $stdWrap)


Documentation:
Add stdWrap to the properties of
- includeCSS
- includeJSlibs
- includeJSFooterlibs
- includeJS
- includeJSFooter
in chapter 1.6 at "PAGE":
.stdWrap - stdWrap properties, processed after allWrap

Best regards,

Susanne

--------------040700080108020002090507
Content-Type: text/plain;
 name="13074_feature_stdWrapPageRenderer.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="13074_feature_stdWrapPageRenderer.diff"

Index: typo3/sysext/cms/tslib/class.tslib_pagegen.php
===================================================================
--- typo3/sysext/cms/tslib/class.tslib_pagegen.php	(revision 6745)
+++ typo3/sysext/cms/tslib/class.tslib_pagegen.php	(working copy)
@@ -549,8 +549,9 @@
 								$GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] ? $GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['title'] : '',
 								$GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['compress'] ? TRUE : FALSE,
 								$GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
-								$GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['allWrap']);
-
+								$GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['allWrap'], 
+								$GLOBALS['TSFE']->pSetup['includeCSS.'][$key . '.']['stdWrap.']
+							);
 						}
 					}
 				}
@@ -684,7 +685,8 @@
 							htmlspecialchars($type),
 							$GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['compress'] ? TRUE : FALSE,
 							$GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
-							$GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['allWrap']
+							$GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['allWrap'],
+							$GLOBALS['TSFE']->pSetup['includeJSlibs.'][$key . '.']['stdWrap.']
 						);
 					}
 				}
@@ -706,7 +708,8 @@
 							htmlspecialchars($type),
 							$GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['compress'] ? TRUE : FALSE,
 							$GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
-							$GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['allWrap']
+							$GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['allWrap'],
+							$GLOBALS['TSFE']->pSetup['includeJSFooterlibs.'][$key . '.']['stdWrap.']
 						);
 					}
 				}
@@ -728,7 +731,8 @@
 							htmlspecialchars($type),
 							$GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['compress'] ? TRUE : FALSE,
 							$GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
-							$GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['allWrap']
+							$GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['allWrap'],
+							$GLOBALS['TSFE']->pSetup['includeJS.'][$key . '.']['stdWrap.']
 						);
 					}
 				}
@@ -749,7 +753,8 @@
 							htmlspecialchars($type),
 							$GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['compress'] ? TRUE : FALSE,
 							$GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['forceOnTop'] ? TRUE : FALSE,
-							$GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['allWrap']
+							$GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['allWrap'],
+							$GLOBALS['TSFE']->pSetup['includeJSFooter.'][$key . '.']['stdWrap.']
 						);
 					}
 				}
Index: t3lib/class.t3lib_pagerenderer.php
===================================================================
--- t3lib/class.t3lib_pagerenderer.php	(revision 6745)
+++ t3lib/class.t3lib_pagerenderer.php	(working copy)
@@ -36,6 +36,8 @@
  */
 class t3lib_PageRenderer implements t3lib_Singleton {
 
+	protected $cObj;
+	
 	protected $compressJavascript = FALSE;
 	protected $compressCss = FALSE;
 	protected $removeLineBreaksFromTemplate = FALSE;
@@ -129,6 +131,7 @@
 
 		$this->reset();
 		$this->csConvObj = t3lib_div::makeInstance('t3lib_cs');
+		$this->cObj = t3lib_div::makeInstance('tslib_cObj');
 
 		if (strlen($templateFile)) {
 			$this->templateFile = $templateFile;
@@ -558,9 +561,10 @@
 	 * @param boolean $compress		flag if library should be compressed
 	 * @param boolean $forceOnTop	flag if added library should be inserted at begin of this block
 	 * @param string $allWrap
+	 * @param array $stdWrap stdWrap options
 	 * @return void
 	 */
-	public function addJsLibrary($name, $file, $type = 'text/javascript', $compress = FALSE, $forceOnTop = FALSE, $allWrap = '') {
+	public function addJsLibrary($name, $file, $type = 'text/javascript', $compress = FALSE, $forceOnTop = FALSE, $allWrap = '', $stdWrap=array()) {
 		if (!in_array(strtolower($name), $this->jsLibs)) {
 			$this->jsLibs[strtolower($name)] = array (
 				'file'        => $file,
@@ -568,7 +572,8 @@
 				'section'     => self::PART_HEADER,
 				'compress'    => $compress,
 				'forceOnTop'  => $forceOnTop,
-				'allWrap'     => $allWrap
+				'allWrap'     => $allWrap,
+				'stdWrap'	  => $stdWrap
 			);
 		}
 
@@ -583,9 +588,10 @@
 	 * @param boolean $compress	flag if library should be compressed
 	 * @param boolean $forceOnTop	flag if added library should be inserted at begin of this block
 	 * @param string $allWrap
+	 * @param array $stdWrap stdWrap options
 	 * @return void
 	 */
-	public function addJsFooterLibrary($name, $file, $type = 'text/javascript', $compress = FALSE, $forceOnTop = FALSE, $allWrap = '') {
+	public function addJsFooterLibrary($name, $file, $type = 'text/javascript', $compress = FALSE, $forceOnTop = FALSE, $allWrap = '', $stdWrap = array()) {
 		if (!in_array(strtolower($name), $this->jsLibs)) {
 			$this->jsLibs[strtolower($name)] = array (
 				'file'        => $file,
@@ -593,7 +599,8 @@
 				'section'     => self::PART_FOOTER,
 				'compress'    => $compress,
 				'forceOnTop'  => $forceOnTop,
-				'allWrap'     => $allWrap
+				'allWrap'     => $allWrap,
+				'stdWrap'	  => $stdWrap
 			);
 		}
 
@@ -607,16 +614,18 @@
 	 * @param boolean $compress
 	 * @param boolean $forceOnTop
 	 * @param string $allWrap
+	 * @param array $stdWrap stdWrap options
 	 * @return void
 	 */
-	public function addJsFile($file, $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
+	public function addJsFile($file, $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '', $stdWrap = array()) {
 		if (!isset($this->jsFiles[$file])) {
 			$this->jsFiles[$file] = array (
 				'type'        => $type,
 				'section'     => self::PART_HEADER,
 				'compress'    => $compress,
 				'forceOnTop'  => $forceOnTop,
-				'allWrap'     => $allWrap
+				'allWrap'     => $allWrap,
+				'stdWrap'	  => $stdWrap
 			);
 		}
 	}
@@ -628,16 +637,18 @@
 	 * @param string $type
 	 * @param boolean $compress
 	 * @param boolean $forceOnTop
+	 * @param array $stdWrap stdWrap options
 	 * @return void
 	 */
-	public function addJsFooterFile($file, $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
+	public function addJsFooterFile($file, $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '', $stdWrap = array()) {
 		if (!isset($this->jsFiles[$file])) {
 			$this->jsFiles[$file] = array (
 				'type'        => $type,
 				'section'     => self::PART_FOOTER,
 				'compress'    => $compress,
 				'forceOnTop'  => $forceOnTop,
-				'allWrap'     => $allWrap
+				'allWrap'     => $allWrap, 
+				'stdWrap'	  => $stdWrap
 			);
 		}
 	}
@@ -707,9 +718,11 @@
 	 * @param string $title
 	 * @param boolean $compress
 	 * @param boolean $forceOnTop
+	 * @param string $allWrap
+	 * @param array $stdWrap stdWrap options
 	 * @return void
 	 */
-	public function addCssFile($file, $rel = 'stylesheet', $media = 'screen', $title = '', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '') {
+	public function addCssFile($file, $rel = 'stylesheet', $media = 'screen', $title = '', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '', $stdWrap = array()) {
 		if (!isset($this->cssFiles[$file])) {
 			$this->cssFiles[$file] = array (
 				'rel'        => $rel,
@@ -717,7 +730,8 @@
 				'title'      => $title,
 				'compress'   => $compress,
 				'forceOnTop' => $forceOnTop,
-				'allWrap'    => $allWrap
+				'allWrap'    => $allWrap,
+				'stdWrap'	 => $stdWrap
 			);
 		}
 	}
@@ -999,6 +1013,9 @@
 				if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
 					$tag = str_replace('|', $tag, $properties['allWrap']);
 				}
+				if ($properties['stdWrap']) {
+					$tag = $this->cObj->stdWrap($tag, $properties['stdWrap']);
+				}
 				if ($properties['forceOnTop']) {
 					$cssFiles = $tag . chr(10) . $cssFiles;
 				} else {
@@ -1027,6 +1044,9 @@
 				if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
 					$tag = str_replace('|', $tag, $properties['allWrap']);
 				}
+				if ($properties['stdWrap']) {
+					$tag = $this->cObj->stdWrap($tag, $properties['stdWrap']);
+				}
 				if ($properties['forceOnTop']) {
 					if ($properties['section'] === self::PART_HEADER) {
 						$jsLibs = $tag . chr(10) . $jsLibs;
@@ -1051,6 +1071,9 @@
 					if ($properties['allWrap'] && strpos($properties['allWrap'], '|') !== FALSE) {
 						$tag = str_replace('|', $tag, $properties['allWrap']);
 					}
+					if ($properties['stdWrap']) {
+						$tag = $this->cObj->stdWrap($tag, $properties['stdWrap']);
+					}
 					if ($properties['forceOnTop']) {
 						if ($properties['section'] === self::PART_HEADER) {
 							$jsFiles = $tag . chr(10) . $jsFiles;


--------------040700080108020002090507--


More information about the TYPO3-team-core mailing list