/** * @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; }
/** * (non-PHPdoc) * @see tx_mklib_srv_Base::handleCreation() */ public function handleCreation(array $data) { tx_rnbase::load('tx_rnbase_util_Debug'); tx_rnbase_util_Debug::debug(array('creating a static country via the service can\'t be done.'), __METHOD__ . ' Line: ' . __LINE__); // @TODO: remove me }
/** * 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; }
/** * Make a query to database. You will receive an array with result rows. All * database resources are closed after each call. * A Hidden and Delete-Clause for FE-Requests is added for requested table. * * @param $what requested columns * @param $from either the name of on table or an array with index 0 the from clause * and index 1 the requested tablename * @param $where * @param $groupby * @param $orderby * @param $wrapperClass Name einer WrapperKlasse für jeden Datensatz * @param $limit = '' Limits number of results * @param $debug = 0 Set to 1 to debug sql-String * @deprecated use tx_rnbase_util_DB::doSelect() */ function queryDB($what, $from, $where, $groupBy = '', $orderBy = '', $wrapperClass = 0, $limit = '', $debug = 0) { $tableName = $from; $fromClause = $from; if (is_array($from)) { $tableName = $from[1]; $fromClause = $from[0]; } $limit = intval($limit) > 0 ? intval($limit) : ''; // Zur Where-Clause noch die gültigen Felder hinzufügen $contentObjectRendererClass = tx_rnbase_util_Typo3Classes::getContentObjectRendererClass(); $where .= $contentObjectRendererClass::enableFields($tableName); if ($debug) { $sql = $GLOBALS['TYPO3_DB']->SELECTquery($what, $fromClause, $where, $groupBy, $orderBy); tx_rnbase_util_Debug::debug($sql, 'SQL'); tx_rnbase_util_Debug::debug(array($what, $from, $where)); } $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($what, $fromClause, $where, $groupBy, $orderBy, $limit); $wrapper = is_string($wrapperClass) ? tx_rnbase::makeInstanceClassName($wrapperClass) : 0; $rows = array(); while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $rows[] = $wrapper ? new $wrapper($row) : $row; } $GLOBALS['TYPO3_DB']->sql_free_result($res); if ($debug) { tx_rnbase_util_Debug::debug(count($rows), 'Rows retrieved'); } return $rows; }
/** * Gibt die gesammelten Debug meldungen aus * Funktioiniert nur, wenn die debugs nicht in eine datie geschrieben wird. */ public static function t3Debug() { tx_rnbase_util_Debug::debug(self::$aDebug, 'tx_mklib_util_Debug', 'mklib Debug'); // @TODO: remove me }