/**
  * 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.º 2
0
 /**
  * get the content for a news item NOT displayed as single item (List & Latest)
  *
  * @param	array		$itemparts : parts of the html template
  * @param	array		$selectConf : quety parameters in an array
  * @param	string		$prefix_display : the part of the TS-setup
  * @return	string		$itemsOut: itemlist as htmlcode
  */
 function getListContent($itemparts, $selectConf, $prefix_display)
 {
     if ($this->debugTimes) {
         $this->hObj->getParsetime(__METHOD__);
     }
     $limit = $this->config['limit'];
     $lConf = $this->conf[$prefix_display . '.'];
     $res = $this->exec_getQuery('tt_news', $selectConf);
     //get query for list contents
     //				debug($selectConf, $this->theCode.' final $selectConf (' . __CLASS__ . '::' . __FUNCTION__ . ')', __LINE__, __FILE__, 3);
     // make some final config manipulations
     // overwrite image sizes from TS with the values from content-element if they exist.
     if ($this->config['FFimgH'] || $this->config['FFimgW']) {
         $lConf['image.']['file.']['maxW'] = $this->config['FFimgW'];
         $lConf['image.']['file.']['maxH'] = $this->config['FFimgH'];
     }
     if ($this->config['croppingLenght']) {
         $lConf['subheader_stdWrap.']['crop'] = $this->config['croppingLenght'];
     }
     $this->splitLConf = array();
     $cropSuffix = FALSE;
     if ($this->conf['enableOptionSplit']) {
         if ($this->config['croppingLenghtOptionSplit']) {
             $crop = $lConf['subheader_stdWrap.']['crop'];
             if ($this->config['croppingLenght']) {
                 $crop = $this->config['croppingLenght'];
             }
             $cparts = explode('|', $crop);
             if (is_array($cparts)) {
                 $cropSuffix = '|' . $cparts[1] . ($cparts[2] ? '|' . $cparts[2] : '');
             }
             $lConf['subheader_stdWrap.']['crop'] = $this->config['croppingLenghtOptionSplit'];
         }
         $resCount = $this->db->sql_num_rows($res);
         $this->splitLConf = $this->processOptionSplit($lConf, $limit, $resCount);
     }
     $itemsOut = '';
     $itempartsCount = count($itemparts);
     $pTmp = $this->tsfe->ATagParams;
     $cc = 0;
     $piVarsArray = array('backPid' => $this->conf['dontUseBackPid'] ? null : $this->config['backPid'], 'year' => $this->conf['dontUseBackPid'] ? null : ($this->piVars['year'] ? $this->piVars['year'] : null), 'month' => $this->conf['dontUseBackPid'] ? null : ($this->piVars['month'] ? $this->piVars['month'] : null));
     // needed for external renderer
     $this->listData = array();
     // Getting elements
     while ($row = $this->db->sql_fetch_assoc($res)) {
         // gets the option splitted config for this record
         if ($this->conf['enableOptionSplit'] && !empty($this->splitLConf[$cc])) {
             $lConf = $this->splitLConf[$cc];
             $lConf['subheader_stdWrap.']['crop'] .= $cropSuffix;
         }
         $wrappedSubpartArray = array();
         $titleField = $lConf['linkTitleField'] ? $lConf['linkTitleField'] : '';
         // First get workspace/version overlay:
         if ($this->versioningEnabled) {
             $this->tsfe->sys_page->versionOL('tt_news', $row);
         }
         // Then get localization of record:
         if ($this->tsfe->sys_language_content) {
             // prevent link targets from being changed in localized records
             $tmpPage = $row['page'];
             $tmpExtURL = $row['ext_url'];
             $row = $this->tsfe->sys_page->getRecordOverlay('tt_news', $row, $this->tsfe->sys_language_content, $this->tsfe->sys_language_contentOL, '');
             $row['page'] = $tmpPage;
             $row['ext_url'] = $tmpExtURL;
         }
         // Register displayed news item globally:
         $GLOBALS['T3_VAR']['displayedNews'][] = $row['uid'];
         $this->tsfe->ATagParams = $pTmp . ' title="' . $this->local_cObj->stdWrap(trim(htmlspecialchars($row[$titleField])), $lConf['linkTitleField.']) . '"';
         if ($this->conf[$prefix_display . '.']['catOrderBy']) {
             $this->config['catOrderBy'] = $this->conf[$prefix_display . '.']['catOrderBy'];
         }
         //			if ($this->isRenderMarker('###NEWS_CATEGORY_ROOTLINE###')) {
         $this->categories = array();
         $this->categories[$row['uid']] = $this->getCategories($row['uid']);
         //			}
         $catSPid = FALSE;
         if ($row['type'] == 1 || $row['type'] == 2) {
             // News type article or external url
             $this->local_cObj->setCurrentVal($row['type'] == 1 ? $row['page'] : $row['ext_url']);
             $wrappedSubpartArray['###LINK_ITEM###'] = $this->local_cObj->typolinkWrap($this->conf['pageTypoLink.']);
             // fill the link string in a register to access it from TS
             $this->local_cObj->LOAD_REGISTER(array('newsMoreLink' => $this->local_cObj->typolink($this->pi_getLL('more'), $this->conf['pageTypoLink.'])), '');
         } else {
             //  Overwrite the singlePid from config-array with a singlePid given from the first entry in $this->categories
             if ($this->conf['useSPidFromCategory'] && is_array($this->categories)) {
                 $tmpcats = $this->categories;
                 if (is_array($tmpcats[$row['uid']])) {
                     $catSPid = array_shift($tmpcats[$row['uid']]);
                 }
             }
             $singlePid = $catSPid['single_pid'] ? $catSPid['single_pid'] : $this->config['singlePid'];
             $wrappedSubpartArray['###LINK_ITEM###'] = $this->getSingleViewLink($singlePid, $row, $piVarsArray);
         }
         // reset ATagParams
         $this->tsfe->ATagParams = $pTmp;
         $markerArray = $this->getItemMarkerArray($row, $lConf, $prefix_display);
         // XML
         if ($this->theCode == 'XML') {
             if ($row['type'] == 2) {
                 // external URL
                 $exturl = trim(strpos($row['ext_url'], 'http://') !== FALSE ? $row['ext_url'] : 'http://' . $row['ext_url']);
                 $exturl = strpos($exturl, ' ') ? substr($exturl, 0, strpos($exturl, ' ')) : $exturl;
                 $rssUrl = $exturl;
             } elseif ($row['type'] == 1) {
                 // internal URL
                 $rssUrl = $this->pi_getPageLink($row['page'], '');
                 if (strpos($rssUrl, '://') === FALSE) {
                     $rssUrl = $this->config['siteUrl'] . $rssUrl;
                 }
             } else {
                 // News detail link
                 $link = $this->getSingleViewLink($singlePid, $row, $piVarsArray, true);
                 $rssUrl = trim(strpos($link, '://') === FALSE ? $this->config['siteUrl'] : '') . $link;
             }
             // replace square brackets [] in links with their URLcodes and replace the &-sign with its ASCII code
             $rssUrl = preg_replace(array('/\\[/', '/\\]/', '/&/'), array('%5B', '%5D', '&'), $rssUrl);
             $markerArray['###NEWS_LINK###'] = $rssUrl;
             if ($this->conf['displayXML.']['xmlFormat'] == 'rdf') {
                 $this->rdfToc .= "\t\t\t\t" . '<rdf:li resource="' . $rssUrl . '" />' . "\n";
             }
         }
         $layoutNum = $itempartsCount == 0 ? 0 : $cc % $itempartsCount;
         if (!$this->useUpstreamRenderer) {
             // Store the result of template parsing in the Var $itemsOut, use the alternating layouts
             $itemsOut .= $this->cObj->substituteMarkerArrayCached($itemparts[$layoutNum], $markerArray, array(), $wrappedSubpartArray);
         }
         $this->listData[] = array('row' => $row, 'markerArray' => $markerArray, 'categories' => $this->categories);
         $cc++;
         if ($cc == $limit) {
             break;
         }
     }
     $this->db->sql_free_result($res);
     if ($this->debugTimes) {
         $this->hObj->getParsetime(__METHOD__);
     }
     return $itemsOut;
 }