/**
  * Typoscript USER function for rendering DAM images.
  * This is a minimal Setup:
  * <pre>
  * yourObject.imagecol = USER
  * yourObject.imagecol {
  *   userFunc=tx_rnbase_util_TSFAL->printImages
  *   includeLibs = EXT:rn_base/util/class.tx_rnbase_util_TSFAL.php
  *   refField=imagecol
  *   refTable=tx_yourextkey_tablename
  *   template = EXT:rn_base/res/simplegallery.html
  *   # media is the fal reference record
  *   media {
  *     # field file contains the complete image path
  *     file = IMAGE
  *     file.file.import.field = file
  *   }
  *   # Optional setting for limit
  *   # limit = 1
  * }
  * </pre>
  * There are three additional fields in media record: file, file1 and thumbnail containing the complete
  * image path.
  * The output is rendered via HTML template with ListBuilder. Have a look at EXT:rn_base/res/simplegallery.html
  * Possible Typoscript options:
  * refField: DAM reference field of the media records (defined in TCA and used to locate the record in MM-Table)
  * refTable: should be the tablename where the DAM record is referenced to
  * template: Full path to HTML template file.
  * media: Formatting options of the DAM record. Have a look at tx_dam to find all column names
  * limit: Limits the number of medias
  * offset: Start media output with an offset
  * forcedIdField: force another reference column (other than UID or _LOCALIZED_UID)
  *
  *
  * @param string $content
  * @param array $tsConf
  * @return string
  */
 public function printImages($content, $tsConf)
 {
     tx_rnbase::load('tx_rnbase_util_Templates');
     $conf = $this->createConf($tsConf);
     $file = $conf->get('template');
     $file = $file ? $file : 'EXT:rn_base/res/simplegallery.html';
     $subpartName = $conf->get('subpartName');
     $subpartName = $subpartName ? $subpartName : '###DAM_IMAGES###';
     $templateCode = tx_rnbase_util_Templates::getSubpartFromFile($file, $subpartName);
     if (!$templateCode) {
         return '<!-- NO TEMPLATE OR SUBPART ' . $subpartName . ' FOUND -->';
     }
     // Is there a customized language field configured
     $langField = DEFAULT_LOCAL_FIELD;
     $locUid = $conf->getCObj()->data[$langField];
     // Save original uid
     if ($conf->get('forcedIdField')) {
         $langField = $conf->get('forcedIdField');
         // Copy localized UID
         $conf->getCObj()->data[DEFAULT_LOCAL_FIELD] = $conf->getCObj()->data[$langField];
     }
     // Check if there is a valid uid given.
     $parentUid = intval($conf->getCObj()->data[DEFAULT_LOCAL_FIELD] ? $conf->getCObj()->data[DEFAULT_LOCAL_FIELD] : $conf->getCObj()->data['uid']);
     if (!$parentUid) {
         return '<!-- Invalid data record given -->';
     }
     $medias = self::fetchFilesByTS($conf, $conf->getCObj());
     $listBuilder = tx_rnbase::makeInstance('tx_rnbase_util_ListBuilder');
     $out = $listBuilder->render($medias, FALSE, $templateCode, 'tx_rnbase_util_MediaMarker', 'media.', 'MEDIA', $conf->getFormatter());
     // Now set the identifier
     $markerArray = array('###MEDIA_PARENTUID###' => $parentUid);
     $out = tx_rnbase_util_BaseMarker::substituteMarkerArrayCached($out, $markerArray);
     return $out;
 }
예제 #2
0
 public function main()
 {
     $out = '';
     $conf = $this->getModule()->getConfigurations();
     $file = t3lib_div::getFileAbsFileName($conf->get($this->getConfId() . 'template'));
     $templateCode = t3lib_div::getURL($file);
     if (!$templateCode) {
         return $conf->getLL('msg_template_not_found') . '<br />File: \'' . $file . '\'<br />ConfId: \'' . $this->getConfId() . 'template\'';
     }
     $subpart = '###' . strtoupper($this->getFuncId()) . '###';
     $template = tx_rnbase_util_Templates::getSubpart($templateCode, $subpart);
     if (!$template) {
         return $conf->getLL('msg_subpart_not_found') . ': ' . $subpart;
     }
     $start = microtime(TRUE);
     $memStart = memory_get_usage();
     $out .= $this->getContent($template, $conf, $conf->getFormatter(), $this->getModule()->getFormTool());
     if (tx_rnbase_util_BaseMarker::containsMarker($out, 'MOD_')) {
         $markerArr = array();
         $memEnd = memory_get_usage();
         $markerArr['###MOD_PARSETIME###'] = microtime(TRUE) - $start;
         $markerArr['###MOD_MEMUSED###'] = $memEnd - $memStart;
         $markerArr['###MOD_MEMSTART###'] = $memStart;
         $markerArr['###MOD_MEMEND###'] = $memEnd;
         $out = tx_rnbase_util_Templates::substituteMarkerArrayCached($out, $markerArr);
     }
     return $out;
 }
 /**
  * Typoscript USER function for rendering DAM images.
  * This is a minimal Setup:
  * <pre>
  * yourObject.imagecol = USER
  * yourObject.imagecol {
  *   userFunc=tx_rnbase_util_TSDAM->printImages
  *   refField=imagecol
  *   refTable=tx_yourextkey_tablename
  *   template = EXT:rn_base/res/simplegallery.html
  *   # media is the dam record
  *   media {
  *     # field file contains the complete image path
  *     file = IMAGE
  *     file.file.import.field = file
  *   }
  *   # Optional setting for limit
  *   # limit = 1
  * }
  * </pre>
  * There are three additional fields in media record: file, file1 and thumbnail containing the complete
  * image path.
  * The output is rendered via HTML template with ListBuilder. Have a look at EXT:rn_base/res/simplegallery.html
  * Possible Typoscript options:
  * refField: DAM reference field of the media records (defined in TCA and used to locate the record in MM-Table)
  * refTable: should be the tablename where the DAM record is referenced to
  * template: Full path to HTML template file.
  * media: Formatting options of the DAM record. Have a look at tx_dam to find all column names
  * limit: Limits the number of medias
  * offset: Start media output with an offset
  * forcedIdField: force another refernce column (other than UID or _LOCALIZED_UID)
  *
  *
  * @param string $content
  * @param array $tsConf
  * @return string
  */
 function printImages($content, $tsConf)
 {
     if (!tx_rnbase_util_Extensions::isLoaded('dam')) {
         return '';
     }
     $conf = $this->createConf($tsConf);
     $file = $conf->get('template');
     $file = $file ? $file : 'EXT:rn_base/res/simplegallery.html';
     $subpartName = $conf->get('subpartName');
     $subpartName = $subpartName ? $subpartName : '###DAM_IMAGES###';
     $templateCode = tx_rnbase_util_Templates::getSubpartFromFile($file, $subpartName);
     if (!$templateCode) {
         return '<!-- NO TEMPLATE OR SUBPART ' . $subpartName . ' FOUND -->';
     }
     // Is there a customized language field configured
     $langField = DEFAULT_LOCAL_FIELD;
     $locUid = $conf->getCObj()->data[$langField];
     // Save original uid
     if ($conf->get('forcedIdField')) {
         $langField = $conf->get('forcedIdField');
         // Copy localized UID
         $conf->getCObj()->data[DEFAULT_LOCAL_FIELD] = $conf->getCObj()->data[$langField];
     }
     // Check if there is a valid uid given.
     $parentUid = intval($conf->getCObj()->data[DEFAULT_LOCAL_FIELD] ? $conf->getCObj()->data[DEFAULT_LOCAL_FIELD] : $conf->getCObj()->data['uid']);
     if (!$parentUid) {
         return '<!-- Invalid data record given -->';
     }
     $damPics = $this->fetchFileList($tsConf, $conf->getCObj());
     $conf->getCObj()->data[DEFAULT_LOCAL_FIELD] = $locUid;
     // Reset UID
     $offset = intval($conf->get('offset'));
     $limit = intval($conf->get('limit'));
     if (!$limit && $offset && count($damPics)) {
         $damPics = array_slice($damPics, $offset);
     } elseif ($limit && count($damPics)) {
         $damPics = array_slice($damPics, $offset, $limit);
     }
     $damDb = tx_rnbase::makeInstance('tx_dam_db');
     $medias = array();
     while (list($uid, $baseRecord) = each($damPics)) {
         $mediaObj = tx_rnbase::makeInstance('tx_rnbase_model_media', $baseRecord['uid']);
         // Localize data (DAM 1.1.0)
         if (method_exists($damDb, 'getRecordOverlay')) {
             $loc = $damDb->getRecordOverlay('tx_dam', $mediaObj->getRecord(), array('sys_language_uid' => $GLOBALS['TSFE']->sys_language_uid));
             if ($loc) {
                 $mediaObj->setProperty($loc);
             }
         }
         $mediaObj->setParentuid($parentUid);
         $medias[] = $mediaObj;
     }
     $listBuilder = tx_rnbase::makeInstance('tx_rnbase_util_ListBuilder');
     $out = $listBuilder->render($medias, FALSE, $templateCode, 'tx_rnbase_util_MediaMarker', 'media.', 'MEDIA', $conf->getFormatter());
     // Now set the identifier
     $markerArray['###MEDIA_PARENTUID###'] = $parentUid;
     $out = tx_rnbase_util_BaseMarker::substituteMarkerArrayCached($out, $markerArray);
     return $out;
 }
 protected function getWrapForSubpart($template, $marker, $required = true)
 {
     // wir teilen das Template, da der erste teil direkt ausgegeben werden muss!
     $token = md5(time()) . md5(get_class());
     $wrap = tx_rnbase_util_Templates::substituteSubpart($template, '###' . $marker . '###', $token, 0);
     $wrap = explode($token, $wrap);
     if ($required && count($wrap) != 2) {
         // es ist etwas schiefgelaufen, wir sollten immer 2 teile haben
         // einmal header und einmal footer
         throw new Exception('Marker ' . $marker . ' not fount in Template', 1361171589);
     }
     return $wrap;
 }
 /**
  * Returns the maps template from $confId.'template'
  *
  * @param tx_rnbase_configurations $configurations
  * @param string $confId
  * @return string empty string if template was not found
  */
 public static function getMapTemplate($configurations, $confId)
 {
     $file = $configurations->get($confId . 'template');
     if (!$file) {
         return '';
     }
     $subpartName = $configurations->get($confId . 'subpart');
     if (!$subpartName) {
         return '';
     }
     $ret = '';
     try {
         $subpart = tx_rnbase_util_Templates::getSubpartFromFile($file, $subpartName);
         $ret = str_replace(array("\r\n", "\n", "\r"), '', $subpart);
     } catch (Exception $e) {
         $ret = '';
     }
     return $ret;
 }
 /**
  * Enter description here...
  *
  * @param string $view default name of view
  * @param tx_rnbase_configurations $configurations
  * @return string
  */
 function render($view, &$configurations)
 {
     $this->_init($configurations);
     $templateCode = tx_rnbase_util_Files::getFileResource($this->getTemplate($view, '.html'));
     if (!strlen($templateCode)) {
         tx_rnbase::load('tx_rnbase_util_Misc');
         tx_rnbase_util_Misc::mayday('TEMPLATE NOT FOUND: ' . $this->getTemplate($view, '.html'));
     }
     // Die ViewData bereitstellen
     $viewData =& $configurations->getViewData();
     // Optional kann schon ein Subpart angegeben werden
     $subpart = $this->getMainSubpart($viewData);
     if (!empty($subpart)) {
         $templateCode = tx_rnbase_util_Templates::getSubpart($templateCode, $subpart);
         if (!strlen($templateCode)) {
             tx_rnbase::load('tx_rnbase_util_Misc');
             tx_rnbase_util_Misc::mayday('SUBPART NOT FOUND: ' . $subpart);
         }
     }
     $controller = $this->getController();
     if ($controller) {
         // disable substitution marker cache
         if ($configurations->getBool($controller->getConfId() . '_caching.disableSubstCache')) {
             tx_rnbase_util_Templates::disableSubstCache();
         }
     }
     $out = $templateCode;
     $out = $this->createOutput($templateCode, $viewData, $configurations, $configurations->getFormatter());
     $out = $this->renderPluginData($out, $configurations);
     if ($controller) {
         $params = array();
         $params['confid'] = $controller->getConfId();
         $params['item'] = $controller->getViewData()->offsetGet('item');
         $params['items'] = $controller->getViewData()->offsetGet('items');
         $markerArray = $subpartArray = $wrappedSubpartArray = array();
         tx_rnbase_util_BaseMarker::callModules($out, $markerArray, $subpartArray, $wrappedSubpartArray, $params, $configurations->getFormatter());
         $out = tx_rnbase_util_BaseMarker::substituteMarkerArrayCached($out, $markerArray, $subpartArray, $wrappedSubpartArray);
     }
     return $out;
 }
 /**
  * Do the output rendering.
  *
  * As this is a generic view which can be called by
  * many different actions we need the actionConfId in
  * $viewData in order to read its special configuration,
  * including redirection options etc.
  *
  * @param string $template
  * @param ArrayObject	$viewData
  * @param tx_rnbase_configurations	$configurations
  * @param tx_rnbase_util_FormatUtil	$formatter
  * @return mixed Ready rendered output or HTTP redirect
  */
 public function createOutput($template, &$viewData, &$configurations, &$formatter)
 {
     //View-Daten abholen
     $items = $viewData->offsetGet(self::VIEWDATA_ITEMS);
     $filter = $viewData->offsetGet(self::VIEWDATA_FILTER);
     $markerData = $viewData->offsetGet(self::VIEWDATA_MARKER);
     $confId = $this->getController()->getConfId();
     $markerArray = $formatter->getItemMarkerArrayWrapped($markerData, $confId . 'markers.');
     $subpartArray = array();
     $itemPath = $this->getItemPath($configurations, $confId);
     if ($filter && $filter->hideResult()) {
         $subpartArray['###' . strtoupper($itemPath) . 'S###'] = '';
         $items = array();
         $template = $filter->getMarker()->parseTemplate($template, $formatter, $confId . $itemPath . '.filter.', strtoupper($itemPath));
     } else {
         $markerClass = $this->getMarkerClass($configurations, $confId);
         //Liste generieren
         $listBuilder = tx_rnbase::makeInstance('tx_rnbase_util_ListBuilder');
         $template = $listBuilder->render($items, $viewData, $template, $markerClass, $confId . $itemPath . '.', strtoupper($itemPath), $formatter);
     }
     $template = tx_rnbase_util_Templates::substituteMarkerArrayCached($template, $markerArray, $subpartArray);
     //, $wrappedSubpartArray);
     return $template;
 }
 /**
  * @param string $template HTML template
  * @param tx_rnbase_util_FormatUtil $formatter
  * @param string $confId
  * @param string $marker
  * 
  * @return string
  */
 public function parseTemplate($template, &$formatter, $confId, $marker = 'FILTER')
 {
     $markerArray = $subpartArray = $wrappedSubpartArray = array();
     $this->initSorting();
     $this->insertMarkersForSorting($template, $markerArray, $subpartArray, $wrappedSubpartArray, $formatter, $confId);
     $template = tx_rnbase_util_Templates::substituteMarkerArrayCached($template, $markerArray, $subpartArray, $wrappedSubpartArray);
     return $template;
 }
 /**
  * Prints out the module HTML
  *
  * @return	void
  */
 function printContent()
 {
     $this->content .= $this->getDoc()->endPage();
     $params = $markerArray = $subpartArray = $wrappedSubpartArray = array();
     tx_rnbase::load('tx_rnbase_util_BaseMarker');
     tx_rnbase::load('tx_rnbase_util_Templates');
     tx_rnbase_util_BaseMarker::callModules($this->content, $markerArray, $subpartArray, $wrappedSubpartArray, $params, $this->getConfigurations()->getFormatter());
     $content = tx_rnbase_util_Templates::substituteMarkerArrayCached($this->content, $markerArray, $subpartArray, $wrappedSubpartArray);
     echo $content;
 }
 /**
  * Parst den DEBUG Subpart und gibt diesen direkt aus!
  *
  * @param string $template
  * @param int $timeStart
  * @param int $memStart
  * @param array $markerArr
  * @return boolean
  */
 protected function parseDebugs($template, $timeStart = 0, $memStart = 0, array $markerArr = array())
 {
     if (empty($template)) {
         return FALSE;
     }
     tx_rnbase::load('tx_mklib_util_Date');
     $memEnd = memory_get_usage();
     $markerArr['###DEBUG_PARSETIME###'] = microtime(true) - $timeStart;
     $markerArr['###DEBUG_MEMUSED###'] = $memEnd - $memStart;
     $markerArr['###DEBUG_MEMSTART###'] = $memStart;
     $markerArr['###DEBUG_MEMEND###'] = $memEnd;
     $markerArr['###DEBUG_DATE###'] = tx_mklib_util_Date::getExecDate(DATE_ATOM);
     $markerArr['###DEBUG_ITEMCOUNT###'] = 'N/A';
     // die anzahl der ausgegebenen Datensätze ermitteln.
     $provider = $this->getListProvider();
     if ($provider instanceof tx_rnbase_util_ListProvider) {
         $params = array($provider->fields, $provider->options);
         $params[1]['count'] = 1;
         $count = call_user_func_array($provider->searchCallback, $params);
         $markerArr['###DEBUG_ITEMCOUNT###'] = $count;
     }
     $out = tx_rnbase_util_Templates::substituteMarkerArrayCached($template, $markerArr);
     echo $out;
     return TRUE;
 }
 public static function substituteMarkerArrayCached($content, $markContentArray = array(), $subpartContentArray = array(), $wrappedSubpartContentArray = array())
 {
     return tx_rnbase_util_Templates::substituteMarkerArrayCached($content, $markContentArray, $subpartContentArray, $wrappedSubpartContentArray);
 }
 /**
  * (non-PHPdoc)
  * @see PHPUnit_Framework_TestCase::tearDown()
  */
 protected function tearDown()
 {
     tx_rnbase_util_Templates::enableSubstCache();
 }
 /**
  * Returns the reference to a 'resource' in TypoScript.
  * This could be from the filesystem if '/' is found in the value $fileFromSetup, else from the resource-list
  *
  * @param string $file TypoScript "resource" data type value.
  *
  * @return string Resulting filename, if any.
  */
 public static function getFileName($file)
 {
     tx_rnbase::load('tx_rnbase_util_Templates');
     return tx_rnbase_util_Templates::getTSTemplate()->getFileName($file);
 }
 /**
  *
  * Daten im Record:
  *  uid, pid, title, media_type, tstamp, crdate, cruser_id,
  *  deleted, sys_language_uid, l18n_parent, hidden, starttime, endtime, fe_group,
  *  file_name, file_dl_name, file_path, file_size, file_type, file_ctime, file_mtime,
  *  file_hash, file_mime_type, file_mime_subtype, file_status, index_type, parent_id
  *
  * @param 	tx_mklib_model_Dam 				$item
  * @param 	array 							$record
  * @param 	tx_rnbase_util_FormatUtil 		$formatter
  * @param 	string 							$confId
  * @param 	string 							$marker
  * @return 	string
  */
 public function parseTemplate($template, &$item, &$formatter, $confId, $marker = 'FILE')
 {
     if (!is_object($item)) {
         $item = self::getEmptyInstance('tx_mklib_model_Dam');
     }
     $item->record['file_path_name'] = isset($item->record['file_path_name']) ? $item->record['file_path_name'] : $item->record['file_path'] . $item->record['file_name'];
     if ($this->containsMarker($template, $marker . '_FILE_WEBPATH')) {
         $item->fillPath('webpath');
     }
     if ($this->containsMarker($template, $marker . '_FILE_SERVERPATH')) {
         $item->fillPath('serverpath');
     }
     if ($this->containsMarker($template, $marker . '_FILE_RELPATH')) {
         $item->fillPath('relpath');
     }
     $template = $this->addIcon($template, $item, $formatter, $confId, $marker);
     // Fill marker array with data
     $ignore = self::findUnusedCols($item->record, $template, $marker);
     $markerArray = $formatter->getItemMarkerArrayWrapped($item->record, $confId, $ignore, $marker . '_', $item->getColumnNames());
     $wrappedSubpartArray = array();
     $subpartArray = array();
     $this->prepareLinks($item, $marker, $markerArray, $subpartArray, $wrappedSubpartArray, $confId, $formatter, $template);
     $out = tx_rnbase_util_Templates::substituteMarkerArrayCached($template, $markerArray, $subpartArray, $wrappedSubpartArray);
     return $out;
 }
 private function createContent($template, $conf)
 {
     $formTool = $this->getModule()->getFormTool();
     $out = '';
     // TabMenu initialisieren
     $menuItems = array();
     $menu = $this->initSubMenu($menuItems, $this->getModule()->getFormTool());
     $this->getModule()->setSubMenu($menu['menu']);
     // SubSelectors
     $selectorStr = '';
     $subSels = $this->makeSubSelectors($selectorStr);
     $this->getModule()->setSelector($selectorStr);
     if (is_array($subSels) && count($subSels) == 0) {
         // Abbruch, da kein Wert gewählt
         return $this->handleNoSubSelectorValues();
     } elseif (is_string($subSels)) {
         // Ein String als Ergebnis bedeutet ebenfalls Abbruch.
         return $subSels;
     }
     $args = array();
     //$out .= $this->getContent($template, $conf, $conf->getFormatter(), $formTool);
     $handler = $menuItems[$menu['value']];
     if (is_object($handler)) {
         $subpart = '###' . strtoupper($handler->getSubID()) . '###';
         $templateSub = tx_rnbase_util_Templates::getSubpart($template, $subpart);
         $args[] = $templateSub;
         $args[] = $this->getModule();
         $args[] = array('subSels' => $subSels);
         // Der Handler sollte nicht das gesamte Template bekommen, sondern nur seinen Subpart...
         $subOut = call_user_func_array(array($handler, 'showScreen'), $args);
     }
     // Jetzt noch die COMMON-PARTS
     $content .= $formTool->getTCEForm()->printNeededJSFunctions_top();
     $content .= tx_rnbase_util_Templates::getSubpart($template, '###COMMON_START###');
     $content .= $subOut;
     $content .= tx_rnbase_util_Templates::getSubpart($template, '###COMMON_END###');
     // Den JS-Code für Validierung einbinden
     $content .= $formTool->getTCEForm()->printNeededJSFunctions();
     return $content;
 }
 /**
  * resets the cache configuration for substituteMarkerArrayCached
  */
 public static function resetSubstCache()
 {
     self::$substCacheEnabled = NULL;
 }
 /**
  * Render an array of data entries with an html template. The html template should look like this:
  * ###DATAS###
  * ###DATA###
  * ###DATA_UID###
  * ###DATA###
  * ###DATAEMPTYLIST###
  * Shown if list is empty
  * ###DATAEMPTYLIST###
  * ###DATAS###
  * We have some conventions here:
  * The given parameter $marker should be named 'DATA' for this example. The the list subpart
  * is experted to be named '###'.$marker.'S###'. Please notice the trailing S!
  * If you want to render a pagebrowser add it to the $viewData with key 'pagebrowser'.
  * A filter will be detected and rendered too. It should be available in $viewData with key 'filter'.
  *
  * @param array|Traversable $dataArr entries
  * @param string $template
  * @param string $markerClassname item-marker class
  * @param string $confId ts-Config for data entries like team.
  * @param string $marker name of marker like TEAM
  * @param tx_rnbase_util_FormatUtil $formatter
  * @param array $markerParams array of settings for itemmarker
  * @return string
  */
 function render(&$dataArr, $viewData, $template, $markerClassname, $confId, $marker, $formatter, $markerParams = NULL)
 {
     $viewData = is_object($viewData) ? $viewData : new ArrayObject();
     $debugKey = $formatter->getConfigurations()->get($confId . '_debuglb');
     $debug = $debugKey && ($debugKey === '1' || $_GET['debug'] && array_key_exists($debugKey, array_flip(tx_rnbase_util_Strings::trimExplode(',', $_GET['debug']))) || $_POST['debug'] && array_key_exists($debugKey, array_flip(tx_rnbase_util_Strings::trimExplode(',', $_POST['debug']))));
     if ($debug) {
         $time = microtime(TRUE);
         $mem = memory_get_usage();
         $wrapTime = tx_rnbase_util_FormatUtil::$time;
         $wrapMem = tx_rnbase_util_FormatUtil::$mem;
     }
     $outerMarker = $this->getOuterMarker($marker, $template);
     $htmlParser = tx_rnbase_util_Typo3Classes::getHtmlParserClass();
     while ($templateList = $htmlParser::getSubpart($template, '###' . $outerMarker . 'S###')) {
         if ((is_array($dataArr) || $dataArr instanceof Traversable) && count($dataArr)) {
             /* @var $listMarker tx_rnbase_util_ListMarker */
             $listMarker = tx_rnbase::makeInstance('tx_rnbase_util_ListMarker', $this->info->getListMarkerInfo());
             $templateEntry = $htmlParser::getSubpart($templateList, '###' . $marker . '###');
             $offset = 0;
             $pageBrowser = $viewData->offsetGet('pagebrowser');
             if ($pageBrowser) {
                 $state = $pageBrowser->getState();
                 $offset = $state['offset'];
             }
             $markerArray = $subpartArray = array();
             $listMarker->addVisitors($this->visitors);
             $out = $listMarker->render($dataArr, $templateEntry, $markerClassname, $confId, $marker, $formatter, $markerParams, $offset);
             $subpartArray['###' . $marker . '###'] = $out;
             $subpartArray['###' . $marker . 'EMPTYLIST###'] = '';
             // Das Menu für den PageBrowser einsetzen
             if ($pageBrowser) {
                 $subpartArray['###PAGEBROWSER###'] = tx_rnbase_util_BaseMarker::fillPageBrowser($htmlParser::getSubpart($template, '###PAGEBROWSER###'), $pageBrowser, $formatter, $confId . 'pagebrowser.');
                 $listSize = $pageBrowser->getListSize();
             } else {
                 $listSize = count($dataArr);
             }
             $markerArray['###' . $marker . 'COUNT###'] = $formatter->wrap($listSize, $confId . 'count.');
             // charbrowser
             $pagerData = $viewData->offsetGet('pagerData');
             $charPointer = $viewData->offsetGet('charpointer');
             $subpartArray['###CHARBROWSER###'] = tx_rnbase_util_BaseMarker::fillCharBrowser(tx_rnbase_util_Templates::getSubpart($template, '###CHARBROWSER###'), $markerArray, $pagerData, $charPointer, $formatter->getConfigurations(), $confId . 'charbrowser.');
             $out = tx_rnbase_util_BaseMarker::substituteMarkerArrayCached($templateList, $markerArray, $subpartArray);
         } else {
             // Support für EMPTYLIST-Block
             if (tx_rnbase_util_BaseMarker::containsMarker($template, $marker . 'EMPTYLIST')) {
                 $out = $htmlParser::getSubpart($template, '###' . $marker . 'EMPTYLIST###');
             } else {
                 $out = $this->info->getEmptyListMessage($confId, $viewData, $formatter->getConfigurations());
             }
         }
         $template = tx_rnbase_util_Templates::substituteSubpart($template, '###' . $outerMarker . 'S###', $out, 0);
     }
     $markerArray = array();
     $subpartArray = array();
     // Muss ein Formular mit angezeigt werden
     // Zuerst auf einen Filter prüfen
     $filter = $viewData->offsetGet('filter');
     if ($filter) {
         $template = $filter->getMarker()->parseTemplate($template, $formatter, $confId . 'filter.', $marker);
     }
     // Jetzt noch die alte Variante
     $markerArray['###SEARCHFORM###'] = '';
     $seachform = $viewData->offsetGet('searchform');
     if ($seachform) {
         $markerArray['###SEARCHFORM###'] = $seachform;
     }
     $out = tx_rnbase_util_BaseMarker::substituteMarkerArrayCached($template, $markerArray, $subpartArray);
     if ($debug) {
         tx_rnbase::load('class.tx_rnbase_util_Misc.php');
         $wrapTime = tx_rnbase_util_FormatUtil::$time - $wrapTime;
         $wrapMem = tx_rnbase_util_FormatUtil::$mem - $wrapMem;
         tx_rnbase_util_Debug::debug(array('Rows' => count($dataArr), 'Execustion time' => microtime(TRUE) - $time, 'WrapTime' => $wrapTime, 'WrapMem' => $wrapMem, 'Memory start' => $mem, 'Memory consumed' => memory_get_usage() - $mem), 'ListBuilder Statistics for: ' . $confId . ' Key: ' . $debugKey);
     }
     return $out;
 }
 /**
  * @param tx_rnbase_parameters $parameters
  * @param tx_rnbase_configurations $configurations
  *
  * @return string
  */
 function execute(&$parameters, &$configurations)
 {
     $this->setConfigurations($configurations);
     $debugKey = $configurations->get($this->getConfId() . '_debugview');
     $debug = $debugKey && ($debugKey === '1' || $_GET['debug'] && array_key_exists($debugKey, array_flip(tx_rnbase_util_Strings::trimExplode(',', $_GET['debug']))) || $_POST['debug'] && array_key_exists($debugKey, array_flip(tx_rnbase_util_Strings::trimExplode(',', $_POST['debug']))));
     if ($debug) {
         $time = microtime(TRUE);
         $memStart = memory_get_usage();
     }
     if ($configurations->getBool($this->getConfId() . 'toUserInt')) {
         if ($debug) {
             tx_rnbase_util_Debug::debug('Converting to USER_INT!', 'View statistics for: ' . $this->getConfId() . ' Key: ' . $debugKey);
         }
         $configurations->convertToUserInt();
     }
     // Add JS or CSS files
     $this->addResources($configurations, $this->getConfId());
     $cacheHandler = $this->getCacheHandler($configurations, $this->getConfId() . '_caching.');
     $out = $cacheHandler ? $cacheHandler->getOutput() : '';
     $cached = !empty($out);
     if (!$cached) {
         $viewData =& $configurations->getViewData();
         tx_rnbase_util_Misc::pushTT(get_class($this), 'handleRequest');
         $out = $this->handleRequest($parameters, $configurations, $viewData);
         tx_rnbase_util_Misc::pullTT();
         if (!$out) {
             // View
             // It is possible to set another view via typoscript
             $viewClassName = $configurations->get($this->getConfId() . 'viewClassName');
             $viewClassName = strlen($viewClassName) > 0 ? $viewClassName : $this->getViewClassName();
             // TODO: error handling...
             $view = tx_rnbase::makeInstance($viewClassName);
             $view->setTemplatePath($configurations->getTemplatePath());
             if (method_exists($view, 'setController')) {
                 $view->setController($this);
             }
             // Das Template wird komplett angegeben
             $tmplName = $this->getTemplateName();
             if (!$tmplName || !strlen($tmplName)) {
                 tx_rnbase_util_Misc::mayday('No template name defined!');
             }
             $view->setTemplateFile($configurations->get($tmplName . 'Template', TRUE));
             tx_rnbase_util_Misc::pushTT(get_class($this), 'render');
             $out = $view->render($tmplName, $configurations);
             tx_rnbase_util_Misc::pullTT();
         }
         if ($cacheHandler) {
             $cacheHandler->setOutput($out);
         }
     }
     if ($debug) {
         $memEnd = memory_get_usage();
         tx_rnbase_util_Debug::debug(array('Action' => get_class($this), 'Conf Id' => $this->getConfId(), 'Execution Time' => microtime(TRUE) - $time, 'Memory Start' => $memStart, 'Memory End' => $memEnd, 'Memory Consumed' => $memEnd - $memStart, 'Cached?' => $cached ? 'yes' : 'no', 'CacheHandler' => is_object($cacheHandler) ? get_class($cacheHandler) : '', 'SubstCacheEnabled?' => tx_rnbase_util_Templates::isSubstCacheEnabled() ? 'yes' : 'no'), 'View statistics for: ' . $this->getConfId() . ' Key: ' . $debugKey);
     }
     // reset the substCache after each view!
     tx_rnbase_util_Templates::resetSubstCache();
     return $out;
 }
    public function test_substMarkerArrayCached()
    {
        $this->setTTOff();
        $markerArr = array('###UID###' => 2, '###PID###' => 1, '###TITLE###' => 'My Titel 1');
        $cnt = tx_rnbase_util_Templates::substituteMarkerArrayCached(self::$template, $markerArr);
        $exp = '
<html>
<h1>Test</h1>
<ul>
<li>UID: 2</li>
<li>PID: 1</li>
<li>Title: My Titel 1</li>
</ul>
</html>
';
        $this->assertEquals($exp, $cnt);
    }