/** * Konstruktor * @param tx_rnbase_configurations $configurations */ function tx_rnbase_util_FormatUtil($configurations, $cObjClass = 'tslib_cObj') { $this->configurations = $configurations; // t3lib_div::debug($this->configurations->get('tt_content.') , 'util_formatUtil'); $this->cObj = $configurations->getCObj(); // $this->cObj = t3lib_div::makeInstance($cObjClass); // $this->cObj->data = $this->configurations->get('tt_content.'); }
/** * Lädt ein COnfigurations Objekt nach mit der TS aus der Extension * Dabei wird alles geholt was in "plugin.tx_$extKey", "lib.$extKey." und * "lib.links." liegt * * @param string $extKey Extension, deren TS Config geladen werden soll * @param string $extKeyTS Extension, deren Konfig innerhalb der * TS Config geladen werden soll. * Es kann also zb. das TS von mklib geladen werden aber darin die konfig für * das plugin von mkxyz * @param string $sStaticPath pfad zum TS * @param array $aConfig zusätzliche Konfig, die die default überschreibt * @param boolean $resolveReferences sollen referenzen die in lib. * und plugin.tx_$extKeyTS stehen aufgelöst werden? * @param boolean $forceTsfePreparation * @return tx_rnbase_configurations */ public static function loadConfig4BE($extKey, $extKeyTs = null, $sStaticPath = '', $aConfig = array(), $resolveReferences = false, $forceTsfePreparation = false) { $extKeyTs = is_null($extKeyTs) ? $extKey : $extKeyTs; if (!$sStaticPath) { $sStaticPath = '/static/ts/setup.txt'; } if (file_exists(t3lib_div::getFileAbsFileName('EXT:' . $extKey . $sStaticPath))) { t3lib_extMgm::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:' . $extKey . $sStaticPath . '">'); } tx_rnbase::load('tx_rnbase_configurations'); tx_rnbase::load('tx_rnbase_util_Misc'); $tsfePreparationOptions = array(); if ($forceTsfePreparation) { $tsfePreparationOptions['force'] = true; } // Ist bei Aufruf aus BE notwendig! (@TODO: sicher???) tx_rnbase_util_Misc::prepareTSFE($tsfePreparationOptions); $GLOBALS['TSFE']->config = array(); $cObj = t3lib_div::makeInstance('tslib_cObj'); $pageTsConfig = self::getPagesTSconfig(0); $tempConfig = $pageTsConfig['plugin.']['tx_' . $extKeyTs . '.']; $tempConfig['lib.'][$extKeyTs . '.'] = $pageTsConfig['lib.'][$extKeyTs . '.']; $tempConfig['lib.']['links.'] = $pageTsConfig['lib.']['links.']; if ($resolveReferences) { $GLOBALS['TSFE']->tmpl->setup['lib.'][$extKeyTs . '.'] = $tempConfig['lib.'][$extKeyTs . '.']; $GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_' . $extKeyTs . '.'] = $pageTsConfig['plugin.']['tx_' . $extKeyTs . '.']; } $pageTsConfig = $tempConfig; $qualifier = $pageTsConfig['qualifier'] ? $pageTsConfig['qualifier'] : $extKeyTs; // möglichkeit die default konfig zu überschreiben $pageTsConfig = t3lib_div::array_merge_recursive_overrule($pageTsConfig, $aConfig); $configurations = new tx_rnbase_configurations(); $configurations->init($pageTsConfig, $cObj, $extKeyTs, $qualifier); return $configurations; }
function test_logger() { if (tx_rnbase_util_Extensions::isLoaded('devlog')) { $minLog = tx_rnbase_configurations::getExtensionCfgValue('devlog', 'minLogLevel'); if ($minLog === FALSE) { $ret = tx_rnbase_util_Logger::isNoticeEnabled(); $this->assertTrue($ret, 'Notice funktioniert nicht.'); } if ($minLog == 1) { $ret = tx_rnbase_util_Logger::isNoticeEnabled(); $this->assertTrue($ret, 'Notice funktioniert nicht.'); $ret = tx_rnbase_util_Logger::isWarningEnabled(); $this->assertTrue($ret, 'Warning funktioniert nicht.'); $ret = tx_rnbase_util_Logger::isFatalEnabled(); $this->assertTrue($ret, 'Fatal funktioniert nicht.'); $ret = tx_rnbase_util_Logger::isInfoEnabled(); $this->assertFalse($ret, 'Info funktioniert nicht.'); $ret = tx_rnbase_util_Logger::isDebugEnabled(); $this->assertFalse($ret, 'Debug funktioniert nicht.'); } if ($minLog == 3) { $ret = tx_rnbase_util_Logger::isNoticeEnabled(); $this->assertFalse($ret, 'Notice funktioniert nicht.'); $ret = tx_rnbase_util_Logger::isWarningEnabled(); $this->assertFalse($ret, 'Warning funktioniert nicht.'); $ret = tx_rnbase_util_Logger::isFatalEnabled(); $this->assertTrue($ret, 'Fatal funktioniert nicht.'); $ret = tx_rnbase_util_Logger::isInfoEnabled(); $this->assertFalse($ret, 'Info funktioniert nicht.'); $ret = tx_rnbase_util_Logger::isDebugEnabled(); $this->assertFalse($ret, 'Debug funktioniert nicht.'); } } }
/** * * @param tx_rnbase_IParameters $parameters * @param tx_rnbase_configurations $configurations * @param ArrayObject $viewData * @return string error msg or null */ public function handleRequest(&$parameters, &$configurations, &$viewData) { // confIdExtended setzen $this->confIdExtended = $configurations->get($this->getConfId() . 'extendedConfId'); $this->confIdExtended = $this->confIdExtended ? $this->confIdExtended : 'default'; $confId = $this->getExtendedConfId(); // Filter erstellen. /* @var $filter tx_rnbase_filter_BaseFilter */ $filter = tx_rnbase_filter_BaseFilter::createFilter($parameters, $configurations, $viewData, $confId . 'filter.'); $fields = $options = array(); // Searcher instanzieren. Konfiguriert wird er über die options['searchdef'] /* @var $searcher tx_rnbase_util_SearchGeneric */ tx_rnbase::load('tx_rnbase_util_SearchBase'); $searcher = tx_rnbase_util_SearchBase::getInstance('tx_rnbase_util_SearchGeneric'); // Dem Filter den Searcher übergeben, fall er diese Möglichkeit bietet. if (method_exists($filter, 'setSearcher')) { $filter->setSearcher($searcher); } // Suche initialisieren und nur ausführen wenn der Filter es erlaubt. if ($doSearch = $filter->init($fields, $options)) { // Soll ein PageBrowser verwendet werden? if ($configurations->get($confId . 'pagebrowser')) { $pbOptions = array('searchcallback' => array($searcher, 'search')); $cbOptions['pbid'] = ($var = $configurations->get($confId . 'pagebrowser.cbid')) ? $var : 'pb' . $this->confIdExtended; $filter->handlePageBrowser($configurations, $confId . 'pagebrowser', $viewData, $fields, $options, $pbOptions); } // Soll ein CharBrowser verwendet werden? if ($configurations->get($confId . 'charbrowser')) { // optionen sammeln $cbOptions = array('searchcallback' => array($searcher, 'search')); $cbOptions['colname'] = ($var = $configurations->get($confId . 'charbrowser.colname')) ? $var : 'title'; $cbOptions['specials'] = ($var = $configurations->get($confId . 'charbrowser.specials')) ? $var : 'last'; $cbOptions['cbid'] = ($var = $configurations->get($confId . 'charbrowser.cbid')) ? $var : 'cb' . $this->confIdExtended; $filter->handleCharBrowser($configurations, $confId . 'charbrowser', $viewData, $fields, $options, $cbOptions); } // items besorgen. $items = $searcher->search($fields, $options); } else { $items = array(); } $viewData->offsetSet('items', $items); $viewData->offsetSet('searched', $doSearch); return null; }
/** * 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; }
/** * Liefert einen Wert aus der Extension-Konfiguration. * Gibt es für die angegebene Extension keine Konfiguration, * wird als Fallback der Wert von mklib zurückgegeben. * * @param string $sValueKey * @param string $sExtKey * @param boolean $bFallback * @return mixed */ public static function getExtensionValue($sValueKey, $sExtKey = 'mklib', $bFallback = false) { if (!$sExtKey) { $sExtKey = 'mklib'; } tx_rnbase::load('tx_rnbase_configurations'); $mValue = tx_rnbase_configurations::getExtensionCfgValue($sExtKey, $sValueKey); if ($bFallback && $mValue === false && $sExtKey != 'mklib') { $mValue = tx_rnbase_configurations::getExtensionCfgValue('mklib', $sValueKey); } return $mValue; }
public function init(tx_rnbase_configurations $conf, $confId) { $this->conf = $conf; $this->confId = $confId; $apiKey = $conf->get($confId . 'google.apikey'); $apiKey = $apiKey ? $apiKey : NULL; $width = $conf->get($confId . 'width'); $height = $conf->get($confId . 'height'); $this->map = tx_rnbase::makeInstance('tx_wecmap_map_google', $apiKey, $width, $height); // Der MapType $mapType = $conf->get($confId . 'maptype') ? constant($conf->get($confId . 'maptype')) : NULL; $types = array_flip(tx_rnbase_maps_TypeRegistry::getMapTypes()); if ($mapType && array_key_exists($mapType, $types)) { $this->setMapType(tx_rnbase_maps_TypeRegistry::getInstance()->getType($this, $mapType)); } // Controls $controls = $conf->get($confId . 'google.controls'); if ($controls) { $controls = tx_rnbase_util_Strings::trimExplode(',', $controls); foreach ($controls as $control) { $this->addControl(tx_rnbase::makeInstance('tx_rnbase_maps_google_Control', $control)); } } }
/** * Send an exeption mail for all exceptions during the store log process * * @param \Exception $e * * @TODO: add recursive call check for exceptions ( * throw exception, only block at secnd exception. * so the gelf logger can log the exception * and only a recursion of logging will prevented. * ) * * @return void */ protected function handleExceptionDuringLogging(\Exception $e) { // try to send mail $addr = \tx_rnbase_configurations::getExtensionCfgValue('rn_base', 'sendEmailOnException'); if ($addr) { \tx_rnbase_util_Misc::sendErrorMail($addr, 'Mklog\\DevlogLogger', $e); } }
/** * Function executed from the Scheduler. * * @return boolean Returns true on successful execution, false on error */ public function execute() { /* beispiel für das logging array. $devLog = array('message' => '', 'extKey' => 'mklib', 'dataVar' => FALSE); $devLog = array( tx_rnbase_util_Logger::LOGLEVEL_DEBUG => $devLog, tx_rnbase_util_Logger::LOGLEVEL_INFO => $devLog, tx_rnbase_util_Logger::LOGLEVEL_NOTICE => $devLog, tx_rnbase_util_Logger::LOGLEVEL_WARN => $devLog, tx_rnbase_util_Logger::LOGLEVEL_FATAL => $devLog ); */ $devLog = array(); $options = $this->getOptions(); $startTimeInMilliseconds = t3lib_div::milliseconds(); $memoryUsageAtStart = memory_get_usage(); tx_rnbase_util_Logger::info('[' . get_class($this) . ']: Scheduler starts', $this->getExtKey()); try { $message = $this->executeTask($options, $devLog); $this->setLastRunTime(); // devlog if (t3lib_extMgm::isLoaded('devlog')) { if (empty($devLog) || isset($devLog[tx_rnbase_util_Logger::LOGLEVEL_INFO]) && empty($devLog[tx_rnbase_util_Logger::LOGLEVEL_INFO]['message'])) { $devLog[tx_rnbase_util_Logger::LOGLEVEL_INFO]['message'] = $message; } foreach ($devLog as $logLevel => $logData) { if (empty($logData['message'])) { continue; } t3lib_div::devLog('[' . get_class($this) . ']: ' . $logData['message'], isset($logData['extKey']) ? $logData['extKey'] : $this->getExtKey(), $logLevel, isset($logData['dataVar']) ? $logData['dataVar'] : FALSE); } } } catch (Exception $exception) { $dataVar = array('errorcode' => $exception->getCode(), 'errormsg' => $exception->getMessage(), 'trace' => $exception->getTraceAsString(), 'options' => $options, 'devlog' => $devLog); if ($exception instanceof tx_rnbase_util_Exception) { $dataVar['exception_data'] = $exception->getAdditional(FALSE); } if (tx_rnbase_util_Logger::isFatalEnabled()) { tx_rnbase_util_Logger::fatal('Task [' . get_class($this) . '] failed.' . ' Error(' . $exception->getCode() . '):' . $exception->getMessage(), $this->getExtKey(), $dataVar); } // Exception Mail an die Entwicker senden $mail = tx_rnbase_configurations::getExtensionCfgValue('rn_base', 'sendEmailOnException'); if (!empty($mail)) { $this->sendErrorMail($mail, tx_rnbase::makeInstance('tx_rnbase_util_Exception', get_class($exception) . ': ' . $exception->getMessage(), $exception->getCode(), $dataVar, $exception)); } // Wir geben die Exception weiter, // damit der Scheduler eine entsprechende Meldung ausgeben kann. throw $exception; } $memoryUsageAtEnd = memory_get_usage(); tx_rnbase_util_Logger::info('[' . get_class($this) . ']: Scheduler ends successful ', $this->getExtKey(), array('Execution Time' => t3lib_div::milliseconds() - $startTimeInMilliseconds . ' ms', 'Memory Start' => $memoryUsageAtStart . ' Bytes', 'Memory End' => $memoryUsageAtEnd . ' Bytes', 'Memory Consumed' => $memoryUsageAtEnd - $memoryUsageAtStart . ' Bytes')); return true; }
/** * Konstruktor * @param tx_rnbase_configurations $configurations */ function tx_rnbase_util_FormatUtil($configurations) { $this->configurations = $configurations; $this->cObj = $configurations->getCObj(); }
/** * Is logging enabled? * * @param string $tablename * @return boolean */ private static function isLog($tablename) { if (self::$log == -1) { // erst die Extension Konfiguration fragen! tx_rnbase::load('tx_rnbase_configurations'); self::$log = intval(tx_rnbase_configurations::getExtensionCfgValue('mklib', 'logDbHandler')); if (self::$log) { tx_rnbase::load('tx_rnbase_util_Logger'); self::$log = tx_rnbase_util_Logger::isNoticeEnabled(); } } if (self::$log) { // ignore tables besorgen if (!is_array(self::$ignoreTables)) { self::$ignoreTables = t3lib_div::trimExplode(',', tx_rnbase_configurations::getExtensionCfgValue('mklib', 'logDbIgnoreTables'), true); } // tabelle loggen ? if (in_array($tablename, self::$ignoreTables)) { return false; } } return self::$log; }
<?php if (!defined('TYPO3_MODE')) { die('Access denied.'); } $rnbaseExtPath = t3lib_extMgm::extPath('rn_base'); require_once $rnbaseExtPath . 'class.tx_rnbase.php'; tx_rnbase::load('tx_rnbase_util_Debug'); tx_rnbase::load('tx_rnbase_configurations'); if (!is_array($TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['rnbase']) && tx_rnbase_configurations::getExtensionCfgValue('rn_base', 'activateCache')) { $TYPO3_CONF_VARS['SYS']['caching']['cacheConfigurations']['rnbase'] = array('backend' => 't3lib_cache_backend_FileBackend', 'options' => array()); } $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['rn_base']['loadHiddenObjects'] = intval(tx_rnbase_configurations::getExtensionCfgValue('rn_base', 'loadHiddenObjects')); // Include the mediaplayer service require_once $rnbaseExtPath . 'sv1/ext_localconf.php';
/** * Sendout an error mail * @param string $mailAddr commaseperated recipients * @param string $actionName * @param Exception $e * @param array $options */ public static function sendErrorMail($mailAddr, $actionName, Exception $e, array $options = array()) { $ignoreMailLock = array_key_exists('ignoremaillock', $options) && $options['ignoremaillock']; if (!$ignoreMailLock) { tx_rnbase::load('tx_rnbase_util_Lock'); // Only one mail within one minute! $lock = tx_rnbase_util_Lock::getInstance('errormail', 60); if ($lock->isLocked()) { return; } else { $lock->lockProcess(); } } $textPart = self::getErrorMailText($e, $actionName); $htmlPart = self::getErrorMailHtml($e, $actionName); /* @var $mail tx_rnbase_util_Mail */ $mail = tx_rnbase::makeInstance('tx_rnbase_util_Mail'); $mail->setSubject('Exception on site ' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']); $from = tx_rnbase_configurations::getExtensionCfgValue('rn_base', 'fromEmail'); $from = $from ? $from : 'error@' . tx_rnbase_util_Misc::getIndpEnv('TYPO3_HOST_ONLY'); $mail->setFrom($from); $mail->setTo($mailAddr); $mail->setTextPart($textPart); $mail->setHtmlPart($htmlPart); if ($lock && !$ignoreMailLock) { // refresh the lock $lock->lockProcess(); } return $mail->send(); }
/** * Find a configured cache handler. * * @param tx_rnbase_configurations $configurations * @param string $confId * @return tx_rnbase_action_ICacheHandler */ protected function getCacheHandler($configurations, $confId) { $clazz = $configurations->get($confId . 'class'); if (!$clazz) { return FALSE; } $handler = tx_rnbase::makeInstance($clazz, $configurations, $confId); return $handler; }
/** * Whether or not the caching in substituteMarkerArrayCached is enabled * @return boolean */ public static function isSubstCacheEnabled() { if (self::$substCacheEnabled === NULL) { self::$substCacheEnabled = (bool) tx_rnbase_configurations::getExtensionCfgValue('rn_base', 'activateSubstCache'); } return self::$substCacheEnabled; }
/** * Returns an ArrayObject containing all parameters * @param tx_rnbase_configurations $configurations */ protected function _makeParameterObject($configurations) { $parameters = tx_rnbase::makeInstance('tx_rnbase_parameters'); $parameters->setQualifier($configurations->getQualifier()); // get parametersArray for defined qualifier $parametersArray = tx_rnbase_parameters::getPostAndGetParametersMerged($configurations->getQualifier()); if ($configurations->isUniqueParameters() && array_key_exists($configurations->getPluginId(), $parametersArray)) { $parametersArray = $parametersArray[$configurations->getPluginId()]; } tx_rnbase_util_Arrays::overwriteArray($parameters, $parametersArray); // Initialize the cHash system if there are parameters available if (!$configurations->isPluginUserInt() && $GLOBALS['TSFE'] && $parameters->count()) { // Bei USER_INT wird der cHash nicht benötigt und führt zu 404 $GLOBALS['TSFE']->reqCHash(); } return $parameters; }
/** * Get a message string for empty list. This is an language string. The key is * taken from ts-config: [item].listinfo.llkeyEmpty * * @param array_object $viewData * @param tx_rnbase_configurations $configurations * @return string */ function getEmptyListMessage($confId, &$viewData, &$configurations) { return $configurations->getLL($configurations->get($confId . 'listinfo.llkeyEmpty')); }
/** * Bindet einen Buchstaben-Browser ein * * @param tx_rnbase_configurations $configurations * @param string $confid * @param ArrayObject $viewData * @param array $fields * @param array $options * @param array $cfg You have to set 'colname'. The database column used for character browsing. */ public static function handleCharBrowser(&$configurations, $confid, &$viewData, &$fields, &$options, $cfg = array()) { if ($configurations->get($confid)) { $colName = $cfg['colname']; if (!$colName) { throw new Exception('No column name for charbrowser defined'); } $pagerData = self::findPagerData($fields, $options, $cfg); $firstChar = $configurations->getParameters()->offsetGet($pagerData['pointername']); $firstChar = strlen(trim($firstChar)) > 0 ? substr($firstChar, 0, $firstChar[0] == '0' ? 3 : 1) : $pagerData['default']; // Existiert der Point in den aktuellen Daten $firstChar = array_key_exists($firstChar, $pagerData['list']) ? $firstChar : $pagerData['default']; $viewData->offsetSet('pagerData', $pagerData); $viewData->offsetSet('charpointer', $firstChar); } $filter = $viewData->offsetGet('filter'); // Der CharBrowser beachten wir nur, wenn keine Suche aktiv ist // TODO: Der Filter sollte eine Methode haben, die sagt, ob ein Formular aktiv ist if ($firstChar != '' && !$filter->isSpecialSearch()) { $specials = tx_rnbase_util_SearchBase::getSpecialChars(); $firsts = $specials[$firstChar]; if ($firsts) { $firsts = implode('\',\'', $firsts); } else { $firsts = $firstChar; } if ($fields[SEARCH_FIELD_CUSTOM]) { $fields[SEARCH_FIELD_CUSTOM] .= ' AND '; } $fields[SEARCH_FIELD_CUSTOM] .= 'LEFT(UCASE(' . $colName . "),1) IN ('{$firsts}') "; } }
/** * @return mixed */ protected function getExtensionCfgValue($key) { return tx_rnbase_configurations::getExtensionCfgValue($this->extKey, $key); }
/** * Initialisiert die interne Link-Instanz * TODO: Konfigurierbar machen!! * @param tx_rnbase_configurations $configuration */ protected function initLink(&$configuration, $pbConfId) { $this->link = $configuration->createLink(); $this->link->initByTS($configuration, $pbConfId . 'link.', array()); $this->token = md5(microtime()); $this->link->label($this->token); // $this->link->destination($GLOBALS['TSFE']->id); // Link auf aktuelle Seite $this->noLink = array('', ''); }
/** * Prüft, ob per Parameter oder Konfiguration der Debug für die Labels aktiv ist. * * @param tx_rnbase_configurations $configurations * @return boolean or string with debug type (plain, html) */ public static function isLabelDebugEnabled(tx_rnbase_configurations $configurations = NULL) { static $status = array(); // check global debug params if (!isset($status['global'])) { $status['global'] = !empty($_GET['labeldebug']) && self::isDebugEnabled() ? $_GET['labeldebug'] : self::isDebugEnabled(); } if ($status['global']) { return $status['global']; } // check plugin debug config if ($configurations instanceof tx_rnbase_configurations) { $pluginId = $configurations->getPluginId(); if (!isset($status[$pluginId])) { $status[$pluginId] = $configurations->get('labeldebug'); } return empty($status[$pluginId]) ? FALSE : $status[$pluginId]; } // no debug! return FALSE; }
/** * Initialisiert die interne Link-Instanz * TODO: Konfigurierbar machen!! * @param tx_rnbase_configurations $configuration */ protected function initLink(&$configuration, $pbConfId) { $this->link = $configuration->createLink(); $this->link->initByTS($configuration, $pbConfId . 'link.', array()); $this->token = md5(microtime()); $this->link->label($this->token); $this->noLink = array('', ''); }
/** * Führt vor dem parsen Änderungen am Model durch. * * @param Tx_Rnbase_Domain_Model_DataInterface $item * @param tx_rnbase_configurations &$configurations * @param string &$confId * @return void */ protected function prepareItem(Tx_Rnbase_Domain_Model_DataInterface $item, tx_rnbase_configurations $configurations, $confId) { if ($item->isEmpty()) { return; } $dotFieldFields = $configurations->getExploded($confId . 'dataMap.dotFieldFields'); $dotValueFields = $configurations->getExploded($confId . 'dataMap.dotValueFields'); $mapFields = array_merge($dotFieldFields, $dotValueFields); if (empty($mapFields)) { return; } // wir gehen über alle felder, und ersetzen ggf. enthaltene punkte // durch einen unterstrich. Dies ist für den Zugriff über Typoscript notwendig! // das gleiche machen wir für kleine werte, diese werden beispielsweise für // ein CASE im TS benötigt foreach ($mapFields as $field) { $newField = '_' . str_replace('.', '_', $field); $value = $item->getProperty($field); if (in_array($field, $dotFieldFields)) { $item->setProperty($newField, $value); } if (in_array($field, $dotValueFields)) { $item->setProperty($newField, str_replace('.', '_', $value)); } } }
/** * The global from mail address * * @return array */ public function getGlobalMailFrom() { return \tx_rnbase_configurations::getExtensionCfgValue('rn_base', 'fromEmail'); }
/** * @param boolean $defaultConfig * * @return tx_rnbase_configurations */ private function getConfigurations($defaultConfig = false) { tx_rnbase_util_Misc::prepareTSFE(); $configurations = new tx_rnbase_configurations(); $cObj = t3lib_div::makeInstance('tslib_cObj'); $config = array('myConfId.' => array('filter.' => array('sort.' => array('fields' => 'firstField,secondField', 'link.' => array('noHash' => 1))))); if ($defaultConfig) { $config['myConfId.']['filter.']['sort.']['default.'] = array('field' => 'firstField', 'sortOrder' => 'asc'); } $configurations->init($config, $cObj, 'mklib', 'mklib'); return $configurations; }
/** * Gets an ordered list of language label suffixes that should be tried to * get localizations in the preferred order of formality. * * Method copied from Tx_Oelib_SalutationSwitcher of Oliver Klee * * @param tx_rnbase_configurations $configurations * @return array ordered list of suffixes from "", "_formal" and "_informal", will not be empty */ private static function getSuffixesToTry($configurations) { $suffixesToTry = array(); $salutation = $configurations->get('salutation'); if ($salutation && $salutation == 'informal') { $suffixesToTry[] = '_informal'; } $suffixesToTry[] = '_formal'; $suffixesToTry[] = ''; return $suffixesToTry; }
/** * @param int $level * @return boolean */ private static function isLogLevel($level) { if (self::$minLog === FALSE) { if (tx_rnbase_util_Extensions::isLoaded('devlog')) { $minLog = tx_rnbase_configurations::getExtensionCfgValue('devlog', 'minLogLevel'); self::$minLog = $minLog !== FALSE ? $minLog : -1; } } $isEnabled = $level >= self::$minLog; return $isEnabled; }
/** * chechs, if the exception was allready thrown in the stack. * returns TRUE, if the exception was allready thrown. * * die recursion können wir an dieser stelle nicht über den backtrace prüfen. * bei ungecachten ausgaben wird bei typo3 mit int_script gearbeidet, * wodurch der stack auch bei mehrfacher rekursion immer gleich ist, * also die methode nur ein mal auftaucht. * * @param string $actionName * @param Exception $e * @param tx_rnbase_configurations $configurations * @return boolean */ private function checkExceptionRecursion($action, Exception $e, tx_rnbase_configurations $configurations, $type = 'error') { static $calls = 0, $trace = array(); // konfiguration für die maximale anzahl an durchläufen holen. $maxCalls = $configurations->getInt('recursionCheck.maxCalls'); $maxCalls = $maxCalls ? $maxCalls : 50; $maxThrows = $configurations->getInt('recursionCheck.maxThrows'); $maxThrows = $maxThrows ? $maxThrows : 1; // bei mehr als 50 exception calls, müssen wir davon ausgehen, // das ein kritischer fehler vorliegt if (++$calls > $maxCalls) { tx_rnbase_util_Logger::fatal('Too much recursion in "' . get_class($this) . '"' . ' That should not have happened.' . ' It looks as if there is a problem with a faulty configuration.', 'rn_base'); return TRUE; } // else // ansonsten setzen wir eine art stack aus action, errorcode und config zusammen. $code = $e->getCode(); // das typoscript wir bei jedem plugin aufruf neu generiert // und unterscheidet sich demnach. // wenn es zu einer rekursion kommt, ist das ts allerdings immer gleich! // (abgesehen von unaufgelösten referenzen) $configKey = md5(serialize($configurations->getConfigArray())); if (empty($trace[$type])) { $trace[$type] = array(); } if (empty($trace[$type][$action])) { $trace[$type][$action] = array(); } if (empty($trace[$type][$action][$code])) { $trace[$type][$action][$code] = array(); } if (empty($trace[$type][$action][$code][$configKey])) { $trace[$type][$action][$code][$configKey] = 0; } $trace[$type][$action][$code][$configKey]++; if (isset($trace[$type][$action][$code][$configKey]) && $trace[$type][$action][$code][$configKey] > $maxThrows) { return TRUE; } return FALSE; }
/** * Create a fully initialized link instance. Useful for controllers with formular handling. * * @param tx_rnbase_configurations $configurations * @param string $confId * @param array $params * @return \tx_rnbase_util_Link link instance */ protected function createLink($configurations, $confId, $params = array()) { $link = $configurations->createLink(); $link->initByTS($configurations, $confId, $params); if ($configurations->get($confId . 'noCache')) { $link->noCache(); } return $link; }
/** * This method is taken from TYPO3\CMS\Frontend\ContentObject\FileContentObject. * It is a good tradition in TYPO3 that code can not be re-used. TYPO3 6.x makes * no difference... * * @param tx_rnbase_configurations $conf * @param $cObj * @param string $confId * @return array */ public static function fetchFilesByTS($conf, $cObj, $confId = '') { /* @var $fileRepository \TYPO3\CMS\Core\Resource\FileRepository */ $fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository'); $fileObjects = array(); $pics = array(); tx_rnbase::load('tx_rnbase_util_Strings'); // Getting the files // Try DAM style if ($conf->get($confId . 'refTable')) { $referencesForeignTable = $conf->getCObj()->stdWrap($conf->get($confId . 'refTable'), $conf->get($confId . 'refTable.')); $referencesFieldName = $conf->getCObj()->stdWrap($conf->get($confId . 'refField'), $conf->get($confId . 'refField.')); $referencesForeignUid = $conf->getCObj()->stdWrap($conf->get($confId . 'refUid'), $conf->get($confId . 'refUid.')); if (!$referencesForeignUid) { $referencesForeignUid = isset($cObj->data['_LOCALIZED_UID']) ? $cObj->data['_LOCALIZED_UID'] : $cObj->data['uid']; } $pics = $fileRepository->findByRelation($referencesForeignTable, $referencesFieldName, $referencesForeignUid); } elseif (is_array($conf->get($confId . 'references.'))) { $refConfId = $confId . 'references.'; /* The TypoScript could look like this:# all items related to the page.media field: references { table = pages uid.data = page:uid fieldName = media }# or: sys_file_references with uid 27: references = 27 */ // It's important that this always stays "fieldName" and not be renamed to "field" as it would otherwise collide with the stdWrap key of that name $referencesFieldName = $conf->getCObj()->stdWrap($conf->get($refConfId . 'fieldName'), $conf->get($refConfId . 'fieldName.')); if ($referencesFieldName) { $table = $cObj->getCurrentTable(); if ($table === 'pages' && isset($cObj->data['_LOCALIZED_UID']) && intval($cObj->data['sys_language_uid']) > 0) { $table = 'pages_language_overlay'; } $referencesForeignTable = $conf->getCObj()->stdWrap($conf->get($refConfId . 'table'), $conf->get($refConfId . 'table.')); $referencesForeignTable = $referencesForeignTable ? $referencesForeignTable : $table; $referencesForeignUid = $conf->getCObj()->stdWrap($conf->get($refConfId . 'uid'), $conf->get($refConfId . 'uid.')); $referencesForeignUid = $referencesForeignUid ? $referencesForeignUid : (isset($cObj->data['_LOCALIZED_UID']) ? $cObj->data['_LOCALIZED_UID'] : $cObj->data['uid']); // Vermutlich kann hier auch nur ein Objekt geliefert werden... $pics = array(); $referencesForeignUid = tx_rnbase_util_Strings::intExplode(',', $referencesForeignUid); foreach ($referencesForeignUid as $refForUid) { if (!$conf->get($refConfId . 'treatIdAsReference')) { $pics[] = $fileRepository->findFileReferenceByUid($refForUid); } else { $pics[] = $fileRepository->findByRelation($referencesForeignTable, $referencesFieldName, $refForUid); } } } elseif ($refUids = $conf->getCObj()->stdWrap($conf->get($refConfId . 'uid'), $conf->get($refConfId . 'uid.'))) { if (!empty($refUids)) { $refUids = tx_rnbase_util_Strings::intExplode(',', $refUids); foreach ($refUids as $refUid) { $pics[] = $fileRepository->findFileReferenceByUid($refUid); } } } } // TODO: Hook tx_rnbase_util_Misc::callHook('rn_base', 'util_TSFal_fetchFilesByTS_appendMedia_hook', array('conf' => $conf, '$confId' => $confId, 'media' => &$pics), null); // gibt es ein Limit/offset $offset = intval($conf->get($confId . 'offset')); $limit = intval($conf->get($confId . 'limit')); if (!empty($pics) && $limit) { $pics = array_slice($pics, $offset, $limit); } elseif (!empty($pics) && $offset) { $pics = array_slice($pics, $offset); } // Die Bilder sollten jetzt noch in ein $fileObjects = self::convertRef2Media($pics); return $fileObjects; }