예제 #1
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;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 public static function substituteMarkerArrayCached($content, $markContentArray = array(), $subpartContentArray = array(), $wrappedSubpartContentArray = array())
 {
     return tx_rnbase_util_Templates::substituteMarkerArrayCached($content, $markContentArray, $subpartContentArray, $wrappedSubpartContentArray);
 }
 /**
  *
  * 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;
 }
    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);
    }
 /**
  * @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;
 }
 /**
  * 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;
 }