Index: typo3/sysext/cms/layout/class.tx_cms_layout.php
===================================================================
--- typo3/sysext/cms/layout/class.tx_cms_layout.php (revision 3970)
+++ typo3/sysext/cms/layout/class.tx_cms_layout.php (working copy)
@@ -1677,140 +1677,160 @@
''.$this->linkEditContent($this->renderText($row['header']),$row).'
';
}
- // Make content:
- $infoArr=Array();
- switch($row['CType']) {
- case 'header':
- if ($row['subheader']) {
- $this->getProcessedValue('tt_content','layout',$row,$infoArr);
- $out.= $this->infoGif($infoArr).
- $this->linkEditContent($this->renderText($row['subheader']),$row).'
';
+ // Make content:
+ $infoArr = array();
+ $drawItem = true;
+
+ // Hook: Render an own preview of a record
+ $drawItemHooks =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem'];
+
+ if (is_array($drawItemHooks)) {
+ foreach($drawItemHooks as $hookClass) {
+ $hookObject = &t3lib_div::getUserObj($hookClass);
+
+ if(!($hookObject instanceof tx_cms_layout_tt_content_drawItemHook)) {
+ throw new UnexpectedValueException('$hookObject must implement interface tx_cms_layout_tt_content_drawItemHook', 1218547409);
}
- break;
- case 'text':
- case 'textpic':
- case 'image':
- if ($row['CType']=='text' || $row['CType']=='textpic') {
+
+ $hookObject->preProcess($this, $drawItem, $outHeader, $out, $row);
+ }
+ }
+
+ // Draw preview of the item depending on its CType (if not disabled by previous hook):
+ if ($drawItem) {
+ switch($row['CType']) {
+ case 'header':
+ if ($row['subheader']) {
+ $this->getProcessedValue('tt_content','layout',$row,$infoArr);
+ $out.= $this->infoGif($infoArr).
+ $this->linkEditContent($this->renderText($row['subheader']),$row).'
';
+ }
+ break;
+ case 'text':
+ case 'textpic':
+ case 'image':
+ if ($row['CType']=='text' || $row['CType']=='textpic') {
+ if ($row['bodytext']) {
+ $this->getProcessedValue('tt_content','text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
+ $out.= $this->infoGif($infoArr).
+ $this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
+ }
+ }
+ if ($row['CType']=='textpic' || $row['CType']=='image') {
+ if ($row['image']) {
+ $infoArr=Array();
+ $this->getProcessedValue('tt_content','imageorient,imagecols,image_noRows,imageborder,imageheight,image_link,image_zoom,image_compression,image_effects,image_frames',$row,$infoArr);
+ $out.= $this->infoGif($infoArr).
+ $this->thumbCode($row,'tt_content','image').'
';
+
+ if ($row['imagecaption']) {
+ $infoArr=Array();
+ $this->getProcessedValue('tt_content','imagecaption_position',$row,$infoArr);
+ $out.= $this->infoGif($infoArr).
+ $this->linkEditContent($this->renderText($row['imagecaption']),$row).'
';
+ }
+ }
+ }
+ break;
+ case 'bullets':
if ($row['bodytext']) {
- $this->getProcessedValue('tt_content','text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
- $out.= $this->infoGif($infoArr).
+ $this->getProcessedValue('tt_content','layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
+ $out.= $this->infoGif($infoArr).
$this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
}
- }
- if ($row['CType']=='textpic' || $row['CType']=='image') {
+ break;
+ case 'table':
+ if ($row['bodytext']) {
+ $this->getProcessedValue('tt_content','table_bgColor,table_border,table_cellspacing,cols,layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
+ $out.= $this->infoGif($infoArr).
+ $this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
+ }
+ break;
+ case 'uploads':
+ if ($row['media']) {
+ $this->getProcessedValue('tt_content','media,select_key,layout,filelink_size,table_bgColor,table_border,table_cellspacing',$row,$infoArr);
+ $out.= $this->infoGif($infoArr).
+ $this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
+ }
+ break;
+ case 'multimedia':
+ if ($row['multimedia']) {
+ $out.= $this->renderText($row['multimedia']).'
';
+ $out.= $this->renderText($row['parameters']).'
';
+ }
+ break;
+ case 'mailform':
+ if ($row['bodytext']) {
+ $this->getProcessedValue('tt_content','pages,subheader',$row,$infoArr);
+ $out.= $this->infoGif($infoArr).
+ $this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
+ }
+ break;
+ case 'splash':
+ if ($row['bodytext']) {
+ $out.= $this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
+ }
if ($row['image']) {
$infoArr=Array();
- $this->getProcessedValue('tt_content','imageorient,imagecols,image_noRows,imageborder,imageheight,image_link,image_zoom,image_compression,image_effects,image_frames',$row,$infoArr);
+ $this->getProcessedValue('tt_content','imagewidth',$row,$infoArr);
$out.= $this->infoGif($infoArr).
$this->thumbCode($row,'tt_content','image').'
';
-
- if ($row['imagecaption']) {
- $infoArr=Array();
- $this->getProcessedValue('tt_content','imagecaption_position',$row,$infoArr);
- $out.= $this->infoGif($infoArr).
- $this->linkEditContent($this->renderText($row['imagecaption']),$row).'
';
+ }
+ break;
+ case 'menu':
+ if ($row['pages']) {
+ $this->getProcessedValue('tt_content','menu_type',$row,$infoArr);
+ $out.= $this->infoGif($infoArr).
+ $this->linkEditContent($row['pages'],$row).'
';
+ }
+ break;
+ case 'shortcut':
+ if ($row['records']) {
+ $this->getProcessedValue('tt_content','layout',$row,$infoArr);
+ $out.= $this->infoGif($infoArr).
+ $this->linkEditContent($row['shortcut'],$row).'
';
+ }
+ break;
+ case 'list':
+ $this->getProcessedValue('tt_content','layout',$row,$infoArr);
+ $out.= $this->infoGif($infoArr).
+ $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','list_type'),1).' '.
+ $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','list_type',$row['list_type']),1).'
';
+ $hookArr = array();
+ $hookOut = '';
+ if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
+ $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
+ } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
+ $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
+ }
+ if (count($hookArr) > 0) {
+ $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
+ foreach ($hookArr as $_funcRef) {
+ $hookOut .= t3lib_div::callUserFunction($_funcRef, $_params, $this);
}
}
- }
- break;
- case 'bullets':
- if ($row['bodytext']) {
- $this->getProcessedValue('tt_content','layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
- $out.= $this->infoGif($infoArr).
- $this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
- }
- break;
- case 'table':
- if ($row['bodytext']) {
- $this->getProcessedValue('tt_content','table_bgColor,table_border,table_cellspacing,cols,layout,text_align,text_face,text_size,text_color,text_properties',$row,$infoArr);
- $out.= $this->infoGif($infoArr).
- $this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
- }
- break;
- case 'uploads':
- if ($row['media']) {
- $this->getProcessedValue('tt_content','media,select_key,layout,filelink_size,table_bgColor,table_border,table_cellspacing',$row,$infoArr);
- $out.= $this->infoGif($infoArr).
- $this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
- }
- break;
- case 'multimedia':
- if ($row['multimedia']) {
- $out.= $this->renderText($row['multimedia']).'
';
- $out.= $this->renderText($row['parameters']).'
';
- }
- break;
- case 'mailform':
- if ($row['bodytext']) {
- $this->getProcessedValue('tt_content','pages,subheader',$row,$infoArr);
- $out.= $this->infoGif($infoArr).
- $this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
- }
- break;
- case 'splash':
- if ($row['bodytext']) {
- $out.= $this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
- }
- if ($row['image']) {
+ if (strcmp($hookOut, '')) {
+ $out .= $hookOut;
+ } else {
+ $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'
';
+ }
+
$infoArr=Array();
- $this->getProcessedValue('tt_content','imagewidth',$row,$infoArr);
+ $this->getProcessedValue('tt_content','recursive',$row,$infoArr);
$out.= $this->infoGif($infoArr).
- $this->thumbCode($row,'tt_content','image').'
';
- }
- break;
- case 'menu':
- if ($row['pages']) {
- $this->getProcessedValue('tt_content','menu_type',$row,$infoArr);
- $out.= $this->infoGif($infoArr).
- $this->linkEditContent($row['pages'],$row).'
';
- }
- break;
- case 'shortcut':
- if ($row['records']) {
- $this->getProcessedValue('tt_content','layout',$row,$infoArr);
- $out.= $this->infoGif($infoArr).
- $this->linkEditContent($row['shortcut'],$row).'
';
- }
- break;
- case 'list':
- $this->getProcessedValue('tt_content','layout',$row,$infoArr);
- $out.= $this->infoGif($infoArr).
- $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','list_type'),1).' '.
- $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','list_type',$row['list_type']),1).'
';
- $hookArr = array();
- $hookOut = '';
- if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']])) {
- $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info'][$row['list_type']];
- } elseif (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'])) {
- $hookArr = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['list_type_Info']['_DEFAULT'];
- }
- if (count($hookArr) > 0) {
- $_params = array('pObj' => &$this, 'row' => $row, 'infoArr' => $infoArr);
- foreach ($hookArr as $_funcRef) {
- $hookOut .= t3lib_div::callUserFunction($_funcRef, $_params, $this);
+ $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','pages',$row['pages']),1).'
';
+ break;
+ case 'script':
+ $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'
';
+ $out.= '
'.$this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
+ $out.= '
'.$this->linkEditContent($this->renderText($row['imagecaption']),$row).'
';
+ break;
+ default:
+ if ($row['bodytext']) {
+ $out.=$this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
}
- }
- if (strcmp($hookOut, '')) {
- $out .= $hookOut;
- } else {
- $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'
';
- }
-
- $infoArr=Array();
- $this->getProcessedValue('tt_content','recursive',$row,$infoArr);
- $out.= $this->infoGif($infoArr).
- $GLOBALS['LANG']->sL(t3lib_BEfunc::getLabelFromItemlist('tt_content','pages',$row['pages']),1).'
';
- break;
- case 'script':
- $out.= $GLOBALS['LANG']->sL(t3lib_BEfunc::getItemLabel('tt_content','select_key'),1).' '.$row['select_key'].'
';
- $out.= '
'.$this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
- $out.= '
'.$this->linkEditContent($this->renderText($row['imagecaption']),$row).'
';
- break;
- default:
- if ($row['bodytext']) {
- $out.=$this->linkEditContent($this->renderText($row['bodytext']),$row).'
';
- }
- break;
+ break;
+ }
}
// Wrap span-tags:
Index: typo3/sysext/cms/layout/interfaces/interface.tx_cms_layout_tt_content_drawitemhook.php
===================================================================
--- typo3/sysext/cms/layout/interfaces/interface.tx_cms_layout_tt_content_drawitemhook.php (revision 0)
+++ typo3/sysext/cms/layout/interfaces/interface.tx_cms_layout_tt_content_drawitemhook.php (revision 0)
@@ -0,0 +1,49 @@
+
+* All rights reserved
+*
+* This script is part of the TYPO3 project. The TYPO3 project is
+* free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* The GNU General Public License can be found at
+* http://www.gnu.org/copyleft/gpl.html.
+* A copy is found in the textfile GPL.txt and important notices to the license
+* from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+* This script is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+
+
+/**
+ * Interface for classes which hook into tx_cms_layout and do additional tt_content_drawItem processing.
+ *
+ * @author Oliver Hader
+ * @package TYPO3
+ * @subpackage cms
+ */
+interface tx_cms_layout_tt_content_drawItemHook {
+ /**
+ * Preprocesses the preview rendering of a content element.
+ *
+ * @param tx_cms_layout $parentObject: Calling parent object
+ * @param boolean $drawItem: Whether to draw the item using the default functionalities
+ * @param string $headerContent: Header content
+ * @param string $itemContent: Item content
+ * @param array $row: Record row of tt_content
+ * @return void
+ */
+ public function preProcess(tx_cms_layout &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row);
+}
+?>
\ No newline at end of file