3. 4. 2011  |  1964 ogledov  |   povratna povezava  |  0 komentarjev

Small update of dam_ttnews

Extention dam_ttnews introduces support for DAM in the media tab of the tt_news item. This is very welcome, but, in some situations, we would like to keep the support for "direct" upload of images. Sometimes users have no need to store images in DAM. In such situations, uploading to DAM and selecting the image presents additional (unwanted) few steps.

imageMarkerFunc.php

PHP 
  1. // If there is no DAM image, use image from tt_news (keep the support for uploaded images that are not stored in DAM)
  2. if (count($damFiles) < 1 ) {
  3.          $imgs = t3lib_div::trimExplode(',', $row['image'], 1);
  4.          while (list(, $val) = each($imgs)) {
  5.                 if ($cc == $imageNum) break;
  6.                 if ($val) {
  7.                         $lConf['image.']['altText'] = ''; // reset altText
  8.                         $lConf['image.']['altText'] = $lConf['image.']['altText']; // set altText to value from TS
  9.                         $lConf['image.']['file'] = 'uploads/pics/'.$val;
  10.                         switch($lConf['imgAltTextField']) {
  11.                                 case 'image':
  12.                                         $lConf['image.']['altText'] .= $val;
  13.                                 break;
  14.                                 case 'imagecaption':
  15.                                         $lConf['image.']['altText'] .= $imgsCaptions[$cc];
  16.                                 break;
  17.                                 default:
  18.                                         $lConf['image.']['altText'] .= $row[$lConf['imgAltTextField']];
  19.                         }
  20.                 }
  21.                 $theImgCode .= $pObj->local_cObj->wrap($pObj->local_cObj->IMAGE($lConf['image.']).$pObj->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']),$lConf['imageWrapIfAny_'.$cc]);  
  22.                 $cc++;
  23.         }
  24. }
  25. else {  
  26.         // remove first img from the image array in single view if the TSvar firstImageIsPreview is set
  27.         if (((count($damFiles) > 1 && $pObj->config['firstImageIsPreview'])||(count($damFiles) >= 1 && $pObj->config['forceFirstImageIsPreview'])) && $pObj->theCode == 'SINGLE') {
  28.                 array_shift($damFiles);
  29.                 array_shift($imgsCaptions);
  30.                 array_shift($imgsAltTexts);
  31.                 array_shift($imgsTitleTexts);
  32.                 $shift=true;
  33.         }
  34.         // get img array parts for single view pages
  35.         if ($pObj->piVars[$pObj->pObj['singleViewPointerName']]) {
  36.                 $spage = $pObj->piVars[$pObj->config['singleViewPointerName']];
  37.                 $astart = $imageNum*$spage;
  38.                 $damFiles = array_slice($damFiles,$astart,$imageNum);
  39.                 $imgsCaptions = array_slice($imgsCaptions,$astart,$imageNum);
  40.                 $imgsAltTexts = array_slice($imgsAltTexts,$astart,$imageNum);
  41.                 $imgsTitleTexts = array_slice($imgsTitleTexts,$astart,$imageNum);
  42.         }
  43.         while (list(,$val) = each($damFiles)) {
  44.                 if ($cc == $imageNum) break;
  45.                 if ($val) {
  46.                         $lConf['image.']['altText'] = $imgsAltTexts[$cc];
  47.                         $lConf['image.']['titleText'] = $imgsTitleTexts[$cc];
  48.                         $lConf['image.']['file'] = $val;
  49.                 }
  50.                 $pObj->local_cObj->setCurrentVal($val);
  51.                 // enables correct use of extension perfectlightbox
  52.                 if ($shift) $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $cc+1;
  53.                 else $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $cc;
  54.  
  55.                 $theImgCode .= $pObj->local_cObj->wrap($pObj->local_cObj->IMAGE($lConf['image.']).$pObj->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']),$lConf['imageWrapIfAny_'.$cc]);  
  56.                 $cc++;
  57.         }
  58. }
  59.  
// If there is no DAM image, use image from tt_news (keep the support for uploaded images that are not stored in DAM)
if (count($damFiles) < 1 ) {
         $imgs = t3lib_div::trimExplode(',', $row['image'], 1);
         while (list(, $val) = each($imgs)) {
                if ($cc == $imageNum) break;
                if ($val) {
                        $lConf['image.']['altText'] = ''; // reset altText
                        $lConf['image.']['altText'] = $lConf['image.']['altText']; // set altText to value from TS
                        $lConf['image.']['file'] = 'uploads/pics/'.$val;
                        switch($lConf['imgAltTextField']) {
                                case 'image':
                                        $lConf['image.']['altText'] .= $val;
                                break;
                                case 'imagecaption':
                                        $lConf['image.']['altText'] .= $imgsCaptions[$cc];
                                break;
                                default:
                                        $lConf['image.']['altText'] .= $row[$lConf['imgAltTextField']];
                        }
                }
                $theImgCode .= $pObj->local_cObj->wrap($pObj->local_cObj->IMAGE($lConf['image.']).$pObj->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']),$lConf['imageWrapIfAny_'.$cc]);  
                $cc++;
        }
}
else {  
        // remove first img from the image array in single view if the TSvar firstImageIsPreview is set
        if (((count($damFiles) > 1 && $pObj->config['firstImageIsPreview'])||(count($damFiles) >= 1 && $pObj->config['forceFirstImageIsPreview'])) && $pObj->theCode == 'SINGLE') {
                array_shift($damFiles);
                array_shift($imgsCaptions);
                array_shift($imgsAltTexts);
                array_shift($imgsTitleTexts);
                $shift=true;
        }
        // get img array parts for single view pages
        if ($pObj->piVars[$pObj->pObj['singleViewPointerName']]) {
                $spage = $pObj->piVars[$pObj->config['singleViewPointerName']];
                $astart = $imageNum*$spage;
                $damFiles = array_slice($damFiles,$astart,$imageNum);
                $imgsCaptions = array_slice($imgsCaptions,$astart,$imageNum);
                $imgsAltTexts = array_slice($imgsAltTexts,$astart,$imageNum);
                $imgsTitleTexts = array_slice($imgsTitleTexts,$astart,$imageNum);
        }
        while (list(,$val) = each($damFiles)) {
                if ($cc == $imageNum) break;
                if ($val) {
                        $lConf['image.']['altText'] = $imgsAltTexts[$cc];
                        $lConf['image.']['titleText'] = $imgsTitleTexts[$cc];
                        $lConf['image.']['file'] = $val;
                }
                $pObj->local_cObj->setCurrentVal($val);
                // enables correct use of extension perfectlightbox
                if ($shift) $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $cc+1;
                else $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $cc;

                $theImgCode .= $pObj->local_cObj->wrap($pObj->local_cObj->IMAGE($lConf['image.']).$pObj->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']),$lConf['imageWrapIfAny_'.$cc]);  
                $cc++;
        }
}

Oznake: typo3, tt_news, dam

Na seznam prispevkov

« April 2011»
N P T S Č P S
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

Zadnje objave

Arhiv

  • 2012(1)
    • Marec(1)
  • 2011(14)
    • Oktober(2)
    • September(2)
    • Junij(2)
    • Maj(2)
    • April(1)
    • Marec(3)
    • Februar(2)
  • 2004(3)
    • April(3)
  • 2003(1)
    • April(1)
  • 2002(1)
    • Februar(1)
  • 2001(1)
    • April(1)