/**
  * @test
  */
 public function getImgResourceHookGetsCalled()
 {
     $this->template->expects($this->atLeastOnce())->method('getFileName')->with('typo3/clear.gif')->will($this->returnValue('typo3/clear.gif'));
     $className = uniqid('tx_coretest');
     $getImgResourceHookMock = $this->getMock('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectGetImageResourceHookInterface', array('getImgResourcePostProcess'), array(), $className);
     $getImgResourceHookMock->expects($this->once())->method('getImgResourcePostProcess')->will($this->returnCallback(array($this, 'isGetImgResourceHookCalledCallback')));
     $getImgResourceHookObjects = array($getImgResourceHookMock);
     $this->cObj->_setRef('getImgResourceHookObjects', $getImgResourceHookObjects);
     $this->cObj->IMAGE($this->typoScriptImage);
 }
 /**
  * Render link of type file
  *
  * @param array $lConf
  * @return array
  */
 private function renderLinktypeFile($lConf)
 {
     $viewAssign = array();
     // Get file
     $fileRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
     $fileObjects = $fileRepository->findByRelation('tt_content', 'mfp_image', $this->data['uid']);
     /** @var \TYPO3\CMS\Core\Resource\File $file */
     $file = $fileObjects[0];
     if (!empty($file)) {
         // Configure the image
         $this->cObj->setCurrentFile($file);
         $imageConf = $GLOBALS['TSFE']->tmpl->setup['lib.']['tx_jhmagnificpopup_pi1.']['image.'];
         $imageConf['file.']['treatIdAsReference'] = 1;
         $imageConf['file'] = $file;
         if (!empty($this->settings['mfpOption']['file_width'])) {
             $imageConf["file."]["maxW"] = $this->settings['mfpOption']['file_width'];
         }
         if (!empty($this->settings['mfpOption']['file_height'])) {
             $imageConf["file."]["maxH"] = $this->settings['mfpOption']['file_height'];
         }
         // Render image
         $theImgCode = $this->cObj->IMAGE($imageConf);
         // Get image orientation
         switch ($this->settings['mfpOption']['file_orient']) {
             case 1:
                 $viewAssign['imageorient'] = 'right';
                 break;
             case 2:
                 $viewAssign['imageorient'] = 'left';
                 break;
             case 0:
             default:
                 $viewAssign['imageorient'] = 'center';
         }
         // Get image description/caption
         $viewAssign['imagecaption'] = $file->getProperty('description');
         // Render typolink
         $viewAssign['tsLink'] = $this->cObj->typolink($theImgCode, $lConf);
     } else {
         $this->addFlashMessage('Please select an image', 'No image', AbstractMessage::WARNING);
     }
     return $viewAssign;
 }
Exemplo n.º 3
0
 /**
  * Render the flag image for autorenderer
  *
  * @param array $language
  * @return string
  */
 protected function getFlagImage(array $language)
 {
     $conf = array('file' => $language['flagSrc'], 'altText' => $language['label'], 'titleText' => $language['label']);
     return $this->cObj->IMAGE($conf);
 }
Exemplo n.º 4
0
 /**
  * Renders values from fieldlist to markers
  *
  * @param ContentObjectRenderer $cobj Content object
  * @param array $conf Configuration for this viewmode
  * @param string $prefix Optional prefix for marker
  *
  * @return array
  * @deprecated since commerce 1.0.0, this function will be removed in commerce 1.4.0, please use tx_commerce_pibase->renderElement in combination with $this->returnAssocArray instead
  */
 public function getMarkerArray(ContentObjectRenderer &$cobj, array $conf, $prefix = '')
 {
     \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
     $markContentArray = $this->returnAssocArray('');
     $markerArray = array();
     foreach ($markContentArray as $k => $v) {
         $vr = '';
         switch (strtoupper($conf[$k])) {
             case 'IMGTEXT':
                 // fall through
             // fall through
             case 'IMAGE':
                 $i = 1;
                 $imgArray = explode(';', $v);
                 foreach ($imgArray as $img) {
                     $conf[$k . '.'][$i . '.'] = $conf[$k . '.']['defaultImgConf.'];
                     $conf[$k . '.'][$i . '.']['file'] = $conf['imageFolder'] . $img;
                     $vr = $cobj->IMAGE($conf[$k . '.'][$i . '.']);
                 }
                 break;
             case 'STDWRAP':
                 $vr = $cobj->stdWrap($v, $conf[$k . '.']);
                 break;
             default:
                 $vr = $v;
         }
         $markerArray['###' . strtoupper($prefix . $k) . '###'] = $vr;
     }
     return $markerArray;
 }
Exemplo n.º 5
0
 /**
  * Fills the image markers for the SINGLE view with data. Supports Optionssplit for some parameters
  *
  * @param $lConf
  * @param $imgs
  * @param $imgsCaptions
  * @param $imgsAltTexts
  * @param $imgsTitleTexts
  * @param $imageNum
  * @param $markerArray
  * @return mixed
  */
 function getSingleViewImages($lConf, $imgs, $imgsCaptions, $imgsAltTexts, $imgsTitleTexts, $imageNum, $markerArray)
 {
     $marker = 'NEWS_IMAGE';
     $sViewSplitLConf = array();
     $tmpMarkers = array();
     $iC = count($imgs);
     // remove first img from image array in single view if the TSvar firstImageIsPreview is set
     if ($iC > 1 && $this->config['firstImageIsPreview'] || $iC >= 1 && $this->config['forceFirstImageIsPreview']) {
         array_shift($imgs);
         array_shift($imgsCaptions);
         array_shift($imgsAltTexts);
         array_shift($imgsTitleTexts);
         $iC--;
     }
     if ($iC > $imageNum) {
         $iC = $imageNum;
     }
     // get img array parts for single view pages
     if ($this->piVars[$this->config['singleViewPointerName']]) {
         /**
          * TODO
          * does this work with optionsplit ?
          */
         $spage = $this->piVars[$this->config['singleViewPointerName']];
         $astart = $imageNum * $spage;
         $imgs = array_slice($imgs, $astart, $imageNum);
         $imgsCaptions = array_slice($imgsCaptions, $astart, $imageNum);
         $imgsAltTexts = array_slice($imgsAltTexts, $astart, $imageNum);
         $imgsTitleTexts = array_slice($imgsTitleTexts, $astart, $imageNum);
     }
     $osCount = 0;
     if ($this->conf['enableOptionSplit']) {
         if ($lConf['imageMarkerOptionSplit']) {
             $ostmp = explode('|*|', $lConf['imageMarkerOptionSplit']);
             $osCount = count($ostmp);
         }
         $sViewSplitLConf = $this->processOptionSplit($lConf, $iC);
     }
     // reset markers for optionSplitted images
     for ($m = 1; $m <= $imageNum; $m++) {
         $markerArray['###' . $marker . '_' . $m . '###'] = '';
     }
     $cc = 0;
     $theImgCode = '';
     foreach ($imgs as $val) {
         if ($cc == $imageNum) {
             break;
         }
         if ($val) {
             if (!empty($sViewSplitLConf[$cc])) {
                 $lConf = $sViewSplitLConf[$cc];
             }
             //				if (1) {
             //					$lConf['image.']['imgList.'] = '';
             //					$lConf['image.']['imgList'] = $val;
             //					$lConf['image.']['imgPath'] = 'uploads/pics/';
             //	debug($lConf['image.'], ' ('.__CLASS__.'::'.__FUNCTION__.')', __LINE__, __FILE__, 3);
             //
             //					$imgHtml = $this->local_cObj->IMGTEXT($lConf['image.']);
             //
             //				} else {
             $lConf['image.']['altText'] = $imgsAltTexts[$cc];
             $lConf['image.']['titleText'] = $imgsTitleTexts[$cc];
             $lConf['image.']['file'] = 'uploads/pics/' . $val;
             $imgHtml = $this->local_cObj->IMAGE($lConf['image.']) . $this->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']);
             //				}
             //debug($imgHtml, '$imgHtml ('.__CLASS__.'::'.__FUNCTION__.')', __LINE__, __FILE__, 3);
             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 {
                 $theImgCode .= $imgHtml;
             }
         }
         $cc++;
     }
     if ($cc) {
         if ($osCount) {
             foreach ($tmpMarkers as $mName => $res) {
                 $markerArray[$mName] = $this->local_cObj->wrap($res['html'], $res['wrap']);
             }
         } else {
             $markerArray['###' . $marker . '###'] = $this->local_cObj->wrap($theImgCode, $lConf['imageWrapIfAny']);
         }
     } else {
         if ($lConf['imageMarkerOptionSplit']) {
             $m = '_1';
         } else {
             $m = '';
         }
         $markerArray['###' . $marker . $m . '###'] = $this->local_cObj->stdWrap($markerArray['###' . $marker . $m . '###'], $lConf['image.']['noImage_stdWrap.']);
     }
     //		debug($sViewSplitLConf, '$sViewSplitLConf ('.__CLASS__.'::'.__FUNCTION__.')', __LINE__, __FILE__, 2);
     return $markerArray;
 }