/**
  * Renders the TypoScript object in the given TypoScript setup path.
  *
  * @param string $typoscriptObjectPath the TypoScript setup path of the TypoScript object to render
  * @param mixed $data the data to be used for rendering the cObject. Can be an object, array or string. If this argument is not set, child nodes will be used
  * @param string $currentValueKey
  * @return string the content of the rendered TypoScript object
  * @author Bastian Waidelich <*****@*****.**>
  * @author Niels Pardon <*****@*****.**>
  */
 public function render($typoscriptObjectPath, $data = NULL, $currentValueKey = NULL)
 {
     if ($data === NULL) {
         $data = $this->renderChildren();
     }
     $currentValue = NULL;
     if (is_object($data)) {
         $data = Tx_Extbase_Reflection_ObjectAccess::getAccessibleProperties($data);
     } elseif (is_string($data)) {
         $currentValue = $data;
         $data = array($data);
     }
     $this->contentObject->start($data);
     if ($currentValue !== NULL) {
         $this->contentObject->setCurrentVal($currentValue);
     } elseif ($currentValueKey !== NULL && isset($data[$currentValueKey])) {
         $this->contentObject->setCurrentVal($data[$currentValueKey]);
     }
     $pathSegments = t3lib_div::trimExplode('.', $typoscriptObjectPath);
     $lastSegment = array_pop($pathSegments);
     $setup = $this->typoScriptSetup;
     foreach ($pathSegments as $segment) {
         if (!array_key_exists($segment . '.', $setup)) {
             throw new Tx_Fluid_Core_ViewHelper_Exception('TypoScript object path "' . htmlspecialchars($typoscriptObjectPath) . '" does not exist', 1253191023);
         }
         $setup = $setup[$segment . '.'];
     }
     return $this->contentObject->cObjGetSingle($setup[$lastSegment], $setup[$lastSegment . '.']);
 }
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));
     // 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', '&#38;'), $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;
         // Store the result of template parsing in the Var $itemsOut, use the alternating layouts
         $itemsOut .= $this->cObj->substituteMarkerArrayCached($itemparts[$layoutNum], $markerArray, array(), $wrappedSubpartArray);
         $cc++;
         if ($cc == $limit) {
             break;
         }
     }
     $this->db->sql_free_result($res);
     if ($this->debugTimes) {
         $this->hObj->getParsetime(__METHOD__);
     }
     return $itemsOut;
 }