diff -Naur perfectlightbox.orig/class.tx_perfectlightbox.php perfectlightbox/class.tx_perfectlightbox.php --- perfectlightbox.orig/class.tx_perfectlightbox.php 2010-11-30 21:04:00.088454002 +0100 +++ perfectlightbox/class.tx_perfectlightbox.php 2010-12-10 08:49:56.523208002 +0100 @@ -87,6 +87,7 @@ return ''.$linkImg; } + /** * Example function that sets the register var "IMAGE_NUM_CURRENT" to the the current image number. * @@ -97,15 +98,17 @@ * @return array the processed markerArray */ - /* - function ttnewsImageMarkerFunc($paramArray,$conf) { + function ttnewsImageMarkerFunc($paramArray, $conf) { + + $marker = 'NEWS_IMAGE'; + $sViewSplitLConf = array(); + $tmpMarkers = array(); + $markerArray = $paramArray[0]; $lConf = $paramArray[1]; $pObj = &$conf['parentObj']; $row = $pObj->local_cObj->data; - - $imageNum = isset($lConf['imageCount']) ? $lConf['imageCount']:1; $imageNum = t3lib_div::intInRange($imageNum, 0, 100); $theImgCode = ''; @@ -114,30 +117,27 @@ $imgsAltTexts = explode(chr(10), $row['imagealttext']); $imgsTitleTexts = explode(chr(10), $row['imagetitletext']); - reset($imgs); - $cc = 0; - - // BEN: We need to mark these items prior to arrayshifting - if (count($imgs) == 1 && - $pObj->config['firstImageIsPreview'] && - $pObj->config['code'] == 'SINGLE' && - !$pObj->config['forceFirstImageIsPreview']) - { - $markedAsSpecial = 1; - } - // END. - - // remove first img from the image array in single view if the TSvar firstImageIsPreview is set - if (( (count($imgs) > 1 && $pObj->config['firstImageIsPreview']) - || - (count($imgs) >= 1 && $pObj->config['forceFirstImageIsPreview']) - ) && $pObj->config['code'] == 'SINGLE') { + $osCount = 0; + $iC = count($imgs); + // remove first img from image array in SINGLE or SINGLE2 view + // if the TSvar firstImageIsPreview is set + if ( ($pObj->config['code'] == 'SINGLE' || $pObj->config['code'] == 'SINGLE2') + && (($iC > 1 && $pObj->config['firstImageIsPreview']) + || ($iC >= 1 && $pObj->config['forceFirstImageIsPreview'])) ) { array_shift($imgs); array_shift($imgsCaptions); array_shift($imgsAltTexts); array_shift($imgsTitleTexts); - } + // BEN: We need to mark these items prior to arrayshifting + $markedAsSpecial = 1; + $iC--; + } + + if ($iC > $imageNum) { + $iC = $imageNum; + } + // get img array parts for single view pages if ($this->piVars[$pObj->config['singleViewPointerName']]) { $spage = $this->piVars[$pObj->config['singleViewPointerName']]; @@ -148,42 +148,71 @@ $imgsTitleTexts = array_slice($imgsTitleTexts,$astart,$imageNum); } - while (list(, $val) = each($imgs)) { - if ($cc == $imageNum) break; - if ($val) { + if ($pObj->conf['enableOptionSplit']) { + if ($lConf['imageMarkerOptionSplit'] && $pObj->config['code'] == 'SINGLE2') { + $ostmp = explode('|*|', $lConf['imageMarkerOptionSplit']); + $osCount = count($ostmp); + } + $sViewSplitLConf = $pObj->processOptionSplit($lConf, $iC); + } + $cc = 0; + foreach ($imgs as $val) { + if ($cc == $imageNum) + break; + if ($val) { + if (! empty($sViewSplitLConf[$cc])) { + $lConf = $sViewSplitLConf[$cc]; + } $lConf['image.']['altText'] = $imgsAltTexts[$cc]; $lConf['image.']['titleText'] = $imgsTitleTexts[$cc]; $lConf['image.']['file'] = 'uploads/pics/' . $val; - // BEN: We check count of images >(=) 0 here because the array got shifted before!!! (See above) - if (( (count($imgs) > 0 && $pObj->config['firstImageIsPreview']) - || - (count($imgs) >= 0 && $pObj->config['forceFirstImageIsPreview']) - ) && $pObj->config['code'] == 'SINGLE') { - // BEN: Additionally we need to check our special case - if (count($imgs) == 1 && $markedAsSpecial) { - $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $cc; - } else { - $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $cc+1; + + if ($markedAsSpecial == 1) + $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $cc+1; + else + $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $cc; + + $imgHtml = $pObj->local_cObj->IMAGE($lConf['image.']) . $pObj->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']); + + if ($osCount) { + if ($iC > 1) { + $mName = '###' . $marker . '_' . $lConf['imageMarkerOptionSplit'] . '###'; + } else { // fall back to the first image marker if only one image has been found + $mName = '###' . $marker . '_1###'; } + $tmpMarkers[$mName]['html'] .= $imgHtml; + $tmpMarkers[$mName]['wrap'] = $lConf['imageWrapIfAny']; } else { - $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $cc; + $theImgCode .= $imgHtml; } - // END. } - - $theImgCode .= $pObj->local_cObj->IMAGE($lConf['image.']) . $pObj->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']); $cc++; } - $markerArray['###NEWS_IMAGE###'] = ''; + // clear all image marker for SINGLE + $markerArray['###' . $marker . '###'] = ''; + // and for SINGLE2 + for ($m = 1; $m <= $imageNum; $m++) { + $markerArray['###' . $marker . '_' . $m . '###'] = ''; + } + if ($cc) { - $markerArray['###NEWS_IMAGE###'] = $pObj->local_cObj->wrap(trim($theImgCode), $lConf['imageWrapIfAny']); - } else { - $markerArray['###NEWS_IMAGE###'] = $pObj->local_cObj->stdWrap($markerArray['###NEWS_IMAGE###'],$lConf['image.']['noImage_stdWrap.']); + if ($osCount) { + foreach ($tmpMarkers as $mName => $res) { + $markerArray[$mName] = $pObj->local_cObj->wrap($res['html'], $res['wrap']); + } + } else { + $markerArray['###' . $marker . '###'] = $pObj->local_cObj->wrap($theImgCode, $lConf['imageWrapIfAny']); + } + } + else { + if ($lConf['imageMarkerOptionSplit']) { + $m = '_1'; + } + $markerArray['###' . $marker . $m . '###'] = $pObj->local_cObj->stdWrap($markerArray['###' . $marker . $m . '###'], $lConf['image.']['noImage_stdWrap.']); } return $markerArray; } - */ } // XCLASS inclusion code diff -Naur perfectlightbox.orig/static/setup.txt perfectlightbox/static/setup.txt --- perfectlightbox.orig/static/setup.txt 2010-11-30 21:04:00.128454002 +0100 +++ perfectlightbox/static/setup.txt 2010-12-03 20:37:50.239916998 +0100 @@ -154,11 +154,13 @@ [global] ### If dam_ttnews is also loaded do not include the imageMarkerFunc -#[globalString = TYPO3_LOADED_EXT|tt_news|type=*] AND [globalString = TYPO3_LOADED_EXT|dam_ttnews|type=*] -### Do nothing -#[else] -#plugin.tt_news.imageMarkerFunc = tx_perfectlightbox->user_imageMarkerFunc -#[global] +[globalString = TYPO3_LOADED_EXT|tt_news|type=L] AND [globalString = TYPO3_LOADED_EXT|dam_ttnews|type=L] +## Do nothing +[else] +plugin.tt_news.imageMarkerFunc = tx_perfectlightbox->ttnewsImageMarkerFunc +#plugin.tt_news.imageMarkerFunc > +#user_imageMarkerFunc +[global] ##### BEN: Due to the latest changes in tt_news the imageMarkerFunc isn't working anymore (Rupert added a new function to process ##### SINGLE differently (optionsplit). So everythings broken for now.