/**
  * 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
 /**
  * Initialize this view helper.
  * This method is called before the render() method.
  *
  * @return void
  * @author Romain Ruetschi <*****@*****.**>
  */
 public function initialize()
 {
     // First call the parent class's "initialize" method.
     parent::initialize();
     $defaultSettings = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_' . $this->extensionName . '.'];
     // Override them with some predefined ones.
     $this->settings = t3lib_div::array_merge_recursive_overrule($defaultSettings, array('serviceList' => 'delicious, digg, facebook, twitter', 'useDefaultTemplate' => TRUE, 'useStats' => TRUE, 'useTinyURL' => FALSE, 'useTSTitle' => TRUE, 'pageTitle.' => array('field' => 'title')));
     // Get a new content object.
     $this->cObj = t3lib_div::makeInstance('tslib_cObj');
     $this->cObj->start(array(), '');
 }
 /**
  * Renders a single facet option link according to the rendering
  * instructions that may have been configured.
  *
  * @param	string	$option The facet option's raw string value.
  * @return	string	The facet option rendered according to rendering instructions if available
  */
 protected function renderOption($option)
 {
     $renderedFacetOption = $option;
     if (isset($this->facetConfiguration['renderingInstruction'])) {
         // TODO provide a data field with information about whether a facet option is selected, and pssibly all information from the renderOptions method so that one can use that with TS
         $this->contentObject->start(array('optionValue' => $option));
         $renderedFacetOption = $this->contentObject->cObjGetSingle($this->facetConfiguration['renderingInstruction'], $this->facetConfiguration['renderingInstruction.']);
     }
     return $renderedFacetOption;
 }
 /**
  * The constructor.
  *
  * @param int $registrationUid UID of the registration record, must be > 0
  */
 public function __construct($registrationUid = 0)
 {
     if ($registrationUid > 0) {
         $dbResult = tx_oelib_db::select('*', $this->tableName, 'uid = ' . $registrationUid);
     } else {
         $dbResult = FALSE;
     }
     $contentObject = new tslib_cObj();
     $contentObject->start(array());
     parent::__construct($contentObject, $dbResult);
 }
    public function setUp()
    {
        $this->backupGlobalVariables = array('_GET' => $_GET, '_POST' => $_POST, '_SERVER' => $_SERVER, 'TYPO3_CONF_VARS' => $GLOBALS['TYPO3_CONF_VARS']);
        $this->template = $this->getMock('t3lib_TStemplate', array('getFileName', 'linkData'));
        $this->tsfe = $this->getMock('tslib_fe', array(), array(), '', false);
        $this->tsfe->tmpl = $this->template;
        $this->tsfe->config = array();
        $GLOBALS['TSFE'] = $this->tsfe;
        $GLOBALS['TSFE']->csConvObj = new t3lib_cs();
        $GLOBALS['TYPO3_CONF_VARS']['SYS']['t3lib_cs_utils'] = 'mbstring';
        $className = 'tslib_cObj_' . uniqid('test');
        eval('
			class ' . $className . ' extends tslib_cObj {
				public $stdWrapHookObjects = array();
				public $getImgResourceHookObjects;
			}
		');
        $this->cObj = new $className();
        $this->cObj->start(array(), 'tt_content');
        $this->typoScriptImage = array('file' => 'typo3/clear.gif');
    }
Exemplo n.º 6
0
 /**
  * Initialize this view helper.
  * This method is called before the render() method.
  *
  * @return void
  * @author Romain Ruetschi <*****@*****.**>
  */
 public function initialize()
 {
     // First call the parent class's "initialize" method.
     parent::initialize();
     $defaultSettings = $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_pagebrowse_pi1.'];
     //  Build the extra query string.
     $extraQueryString = http_build_query(array('controller' => $this->controllerContext->getRequest()->getControllerName(), 'action' => $this->controllerContext->getRequest()->getControllerActionName()), $this->getPrefixIdentifier(), '&');
     // Override them with some predefined ones.
     $this->settings = t3lib_div::array_merge_recursive_overrule($defaultSettings, array('pageParameterName' => $this->getPageParameterName(), 'extraQueryString' => $extraQueryString));
     // Get a new content object.
     $this->cObj = t3lib_div::makeInstance('tslib_cObj');
     $this->cObj->start(array(), '');
 }
Exemplo n.º 7
0
 /**
  * Fills in the markerArray with data for a news item
  * @param array $row result row for a news item
  * @param array $lConf conf vars for the current template
  * @param string $textRenderObj
  * @return array|mixed filled marker array
  */
 function getItemMarkerArray($row, $lConf, $textRenderObj = 'displaySingle')
 {
     if ($this->debugTimes) {
         $this->hObj->getParsetime(__METHOD__);
     }
     $this->local_cObj->start($row, 'tt_news');
     $markerArray = array_flip($this->renderMarkers);
     while (list($mName) = each($markerArray)) {
         $markerArray[$mName] = '';
     }
     // get image markers
     if ($this->isRenderMarker('###NEWS_IMAGE###') || $textRenderObj == 'displaySingle') {
         $markerArray = $this->getImageMarkers($markerArray, $row, $lConf, $textRenderObj);
     }
     if ($textRenderObj == 'displaySingle' && ($this->isRenderMarker('###NEXT_ARTICLE###') || $this->isRenderMarker('###PREV_ARTICLE###'))) {
         $markerArray = $this->getPrevNextLinkMarkers($row, $lConf, $markerArray);
     }
     // get category markers
     if ($this->categories[$row['uid']] && ($this->isRenderMarker('###NEWS_CATEGORY_ROOTLINE###') || $this->isRenderMarker('###NEWS_CATEGORY_IMAGE###') || $this->isRenderMarker('###NEWS_CATEGORY###') || $this->isRenderMarker('###TEXT_CAT###') || $this->isRenderMarker('###TEXT_CAT_LATEST###'))) {
         if ($this->conf['catRootline.']['showCatRootline'] && $this->isRenderMarker('###NEWS_CATEGORY_ROOTLINE###')) {
             $markerArray['###NEWS_CATEGORY_ROOTLINE###'] = $this->getCategoryPath($this->categories[$row['uid']]);
         }
         // get markers and links for categories
         $markerArray = $this->getCatMarkerArray($markerArray, $row, $lConf);
     }
     $markerArray['###NEWS_UID###'] = $row['uid'];
     // show language label and/or flag
     if ($this->isRenderMarker('###NEWS_LANGUAGE###')) {
         if ($this->conf['showLangLabels']) {
             $markerArray['###NEWS_LANGUAGE###'] = $this->langArr[$row['sys_language_uid']]['title'];
         }
         if ($this->langArr[$row['sys_language_uid']]['flag'] && $this->conf['showFlags']) {
             $fImgFile = ($this->conf['flagPath'] ? $this->conf['flagPath'] : 'media/flags/flag_') . $this->langArr[$row['sys_language_uid']]['flag'];
             $fImgConf = $this->conf['flagImage.'];
             $fImgConf['file'] = $fImgFile;
             $flagImg = $this->local_cObj->IMAGE($fImgConf);
             $markerArray['###NEWS_LANGUAGE###'] .= $flagImg;
         }
     }
     if ($row['title'] && $this->isRenderMarker('###NEWS_TITLE###')) {
         $markerArray['###NEWS_TITLE###'] = $this->local_cObj->stdWrap($row['title'], $lConf['title_stdWrap.']);
     }
     if ($row['author'] && $this->isRenderMarker('###NEWS_AUTHOR###')) {
         $newsAuthor = $this->local_cObj->stdWrap($row['author'] ? $this->local_cObj->stdWrap($this->pi_getLL('preAuthor'), $lConf['preAuthor_stdWrap.']) . $row['author'] : '', $lConf['author_stdWrap.']);
         $markerArray['###NEWS_AUTHOR###'] = $this->formatStr($newsAuthor);
     }
     if ($row['author_email'] && $this->isRenderMarker('###NEWS_EMAIL###')) {
         $markerArray['###NEWS_EMAIL###'] = $this->local_cObj->stdWrap($row['author_email'], $lConf['email_stdWrap.']);
     }
     if ($row['datetime']) {
         if ($this->isRenderMarker('###NEWS_DATE###')) {
             $markerArray['###NEWS_DATE###'] = $this->local_cObj->stdWrap($row['datetime'], $lConf['date_stdWrap.']);
         }
         if ($this->isRenderMarker('###NEWS_TIME###')) {
             $markerArray['###NEWS_TIME###'] = $this->local_cObj->stdWrap($row['datetime'], $lConf['time_stdWrap.']);
         }
         if ($this->isRenderMarker('###NEWS_AGE###')) {
             $markerArray['###NEWS_AGE###'] = $this->local_cObj->stdWrap($row['datetime'], $lConf['age_stdWrap.']);
         }
         if ($this->isRenderMarker('###TEXT_NEWS_AGE###')) {
             $markerArray['###TEXT_NEWS_AGE###'] = $this->local_cObj->stdWrap($this->pi_getLL('textNewsAge'), $lConf['textNewsAge_stdWrap.']);
         }
     }
     if ($this->isRenderMarker('###NEWS_SUBHEADER###')) {
         if (!$this->piVars[$this->config['singleViewPointerName']] || $this->conf['subheaderOnAllSViewPages']) {
             $markerArray['###NEWS_SUBHEADER###'] = $this->formatStr($this->local_cObj->stdWrap($row['short'], $lConf['subheader_stdWrap.']));
         }
     }
     if ($row['keywords'] && $this->isRenderMarker('###NEWS_KEYWORDS###')) {
         $markerArray['###NEWS_KEYWORDS###'] = $this->local_cObj->stdWrap($row['keywords'], $lConf['keywords_stdWrap.']);
     }
     if (!$this->piVars[$this->config['singleViewPointerName']]) {
         if ($textRenderObj == 'displaySingle') {
             // load the keywords in the register 'newsKeywords' to access it from TS
             $this->local_cObj->LOAD_REGISTER(array('newsKeywords' => $row['keywords'], 'newsSubheader' => $row['short']), '');
         }
     }
     $sViewPagebrowser = FALSE;
     $newscontent = FALSE;
     if ($this->isRenderMarker('###NEWS_CONTENT###')) {
         if ($textRenderObj == 'displaySingle' && !$row['no_auto_pb'] && $this->config['maxWordsInSingleView'] > 1 && $this->config['useMultiPageSingleView']) {
             $row['bodytext'] = $this->hObj->insertPagebreaks($row['bodytext'], count(t3lib_div::trimExplode(' ', $row['short'], 1)));
         }
         if (strpos($row['bodytext'], $this->config['pageBreakToken'])) {
             if ($this->config['useMultiPageSingleView'] && $textRenderObj == 'displaySingle') {
                 $tmp = $this->hObj->makeMultiPageSView($row['bodytext'], $lConf);
                 $newscontent = $tmp[0];
                 $sViewPagebrowser = $tmp[1];
             } else {
                 $newscontent = $this->formatStr($this->local_cObj->stdWrap(preg_replace('/' . $this->config['pageBreakToken'] . '/', '', $row['bodytext']), $lConf['content_stdWrap.']));
             }
         } else {
             $newscontent = $this->formatStr($this->local_cObj->stdWrap($row['bodytext'], $lConf['content_stdWrap.']));
         }
         if ($this->conf['appendSViewPBtoContent']) {
             $newscontent = $newscontent . $sViewPagebrowser;
             $sViewPagebrowser = '';
         }
     }
     $markerArray['###NEWS_CONTENT###'] = $newscontent;
     $markerArray['###NEWS_SINGLE_PAGEBROWSER###'] = $sViewPagebrowser;
     if ($this->isRenderMarker('###MORE###')) {
         $markerArray['###MORE###'] = $this->pi_getLL('more');
     }
     // get title (or its language overlay) of the page where the backLink points to (this is done only in single view)
     if ($this->config['backPid'] && $textRenderObj == 'displaySingle' && $this->isRenderMarker('###BACK_TO_LIST###')) {
         $backPtitle = $this->getPageArrayEntry($this->config['backPid'], 'title');
         // generate the string for the backLink. By setting the conf-parameter 'hscBackLink',
         // you can switch whether the string is parsed through htmlspecialchars() or not.
         $markerArray['###BACK_TO_LIST###'] = sprintf($this->pi_getLL('backToList', '', $this->conf['hscBackLink']), $backPtitle);
     }
     // get related news
     $relatedNews = FALSE;
     if ($this->isRenderMarker('###TEXT_RELATED###') || $this->isRenderMarker('###NEWS_RELATED###')) {
         if ($this->conf['renderRelatedNewsAsList']) {
             $relatedNews = $this->getRelatedNewsAsList($row['uid']);
         } else {
             $relatedNews = $this->getRelated($row['uid']);
         }
         if ($relatedNews) {
             $rel_stdWrap = t3lib_div::trimExplode('|', $this->conf['related_stdWrap.']['wrap']);
             $markerArray['###TEXT_RELATED###'] = $rel_stdWrap[0] . $this->local_cObj->stdWrap($this->pi_getLL('textRelated'), $this->conf['relatedHeader_stdWrap.']);
             $markerArray['###NEWS_RELATED###'] = $relatedNews . $rel_stdWrap[1];
         }
     }
     // Links
     $newsLinks = FALSE;
     $links = trim($row['links']);
     if ($links && ($this->isRenderMarker('###TEXT_LINKS###') || $this->isRenderMarker('###NEWS_LINKS###'))) {
         $links_stdWrap = t3lib_div::trimExplode('|', $lConf['links_stdWrap.']['wrap']);
         $newsLinks = $this->local_cObj->stdWrap($this->formatStr($row['links']), $lConf['linksItem_stdWrap.']);
         $markerArray['###TEXT_LINKS###'] = $links_stdWrap[0] . $this->local_cObj->stdWrap($this->pi_getLL('textLinks'), $lConf['linksHeader_stdWrap.']);
         $markerArray['###NEWS_LINKS###'] = $newsLinks . $links_stdWrap[1];
     }
     // filelinks
     if ($row['news_files'] && ($this->isRenderMarker('###TEXT_FILES###') || $this->isRenderMarker('###FILE_LINK###') || $this->theCode == 'XML')) {
         $this->getFileLinks($markerArray, $row, $lConf);
     }
     // show news with the same categories in SINGLE view
     if ($textRenderObj == 'displaySingle' && $this->conf['showRelatedNewsByCategory'] && count($this->categories[$row['uid']]) && ($this->isRenderMarker('###NEWS_RELATEDBYCATEGORY###') || $this->isRenderMarker('###TEXT_RELATEDBYCATEGORY###'))) {
         $this->getRelatedNewsByCategory($markerArray, $row, $lConf);
     }
     // the markers: ###ADDINFO_WRAP_B### and ###ADDINFO_WRAP_E### are only inserted, if there are any files, related news or links
     if ($relatedNews || $newsLinks || $markerArray['###FILE_LINK###'] || $markerArray['###NEWS_RELATEDBYCATEGORY###']) {
         $addInfo_stdWrap = t3lib_div::trimExplode('|', $lConf['addInfo_stdWrap.']['wrap']);
         $markerArray['###ADDINFO_WRAP_B###'] = $addInfo_stdWrap[0];
         $markerArray['###ADDINFO_WRAP_E###'] = $addInfo_stdWrap[1];
     }
     // Page fields:
     if ($this->isRenderMarker('###PAGE_UID###')) {
         $markerArray['###PAGE_UID###'] = $row['pid'];
     }
     if ($this->isRenderMarker('###PAGE_TITLE###')) {
         $markerArray['###PAGE_TITLE###'] = $this->getPageArrayEntry($row['pid'], 'title');
     }
     if ($this->isRenderMarker('###PAGE_AUTHOR###')) {
         $markerArray['###PAGE_AUTHOR###'] = $this->local_cObj->stdWrap($this->getPageArrayEntry($row['pid'], 'author'), $lConf['author_stdWrap.']);
     }
     if ($this->isRenderMarker('###PAGE_AUTHOR_EMAIL###')) {
         $markerArray['###PAGE_AUTHOR_EMAIL###'] = $this->local_cObj->stdWrap($this->getPageArrayEntry($row['pid'], 'author_email'), $lConf['email_stdWrap.']);
     }
     // XML
     if ($this->theCode == 'XML') {
         $this->getXmlMarkers($markerArray, $row, $lConf);
     }
     $this->getGenericMarkers($markerArray, $row);
     //		debug($markerArray, ' ('.__CLASS__.'::'.__FUNCTION__.')', __LINE__, __FILE__, 3);
     // Adds hook for processing of extra item markers
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['extraItemMarkerHook'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tt_news']['extraItemMarkerHook'] as $_classRef) {
             $_procObj =& t3lib_div::getUserObj($_classRef);
             $markerArray = $_procObj->extraItemMarkerProcessor($markerArray, $row, $lConf, $this);
         }
     }
     // Pass to userdefined function
     if ($this->conf['itemMarkerArrayFunc']) {
         $markerArray = $this->userProcess('itemMarkerArrayFunc', $markerArray);
     }
     if ($this->debugTimes) {
         $this->hObj->getParsetime(__METHOD__ . ' OUT');
     }
     return $markerArray;
 }
 /**
  * Constructor for the edit panel. Creates a new cObject instance to be used in wrapping, etc.
  *
  * @return	void
  */
 public function __construct()
 {
     $this->cObj = t3lib_div::makeInstance('tslib_cObj');
     $this->cObj->start(array());
 }
 /**
  * Creates an instance of tslib_cObj in $this->cObj
  * This instance is used to start the rendering of the TypoScript template structure
  *
  * @return	void
  * @see pagegen.php
  */
 function newCObj()
 {
     $this->cObj = t3lib_div::makeInstance('tslib_cObj');
     $this->cObj->start($this->page, 'pages');
 }