/** * Interne Verarbeitung der Exception * * @param string $actionName * @param Exception $e * @param tx_rnbase_configurations $configurations * * @return string error message */ public function handleException($actionName, Exception $e, tx_rnbase_configurations $configurations) { // wir prüfen erst mal, ob die exception gefangen werden soll $catch = $this->catchException($actionName, $e, $configurations); if ($catch !== NULL) { return $catch; } // wenn nicht senden wir ggf den header if ($this->send503HeaderOnException($configurations)) { header('HTTP/1.1 503 Service Unavailable'); } // wir loggen nun den fehler tx_rnbase::load('tx_rnbase_util_Logger'); if (tx_rnbase_util_Logger::isFatalEnabled()) { $extKey = $configurations->getExtensionKey(); $extKey = $extKey ? $extKey : 'rn_base'; tx_rnbase_util_Logger::fatal('Fatal error for action ' . $actionName, $extKey, array('Exception' => array('message' => $e->getMessage(), 'code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTraceAsString()), '_GET' => $_GET, '_POST' => $_POST)); } // wir senden eine fehlermail $addr = tx_rnbase_configurations::getExtensionCfgValue('rn_base', 'sendEmailOnException'); if ($addr) { tx_rnbase_util_Misc::sendErrorMail($addr, $actionName, $e); } // Now message for FE $ret = $this->getErrorMessage($actionName, $e, $configurations); return $ret; }
public function testGetExtensionCfgValue() { $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dummyExtension'] = serialize(array('testConfig' => 'testConfigValue')); $extensionConfiguration = tx_rnbase::makeInstance('tx_mklib_util_ExtensionConfigurationTest'); $testConfigValue = $extensionConfiguration->getTestConfig(); $this->assertEquals('testConfigValue', $testConfigValue); }
/** * Die dazu das aktuelle item für eine Detailseite zu holen bzw dieses zurückzusetzen. * Dazu muss den Linker einfach folgendes für den action namen liefern: "show" + den eigentlichen key. * * Dann brauch man in der Detailansicht noch einen Button nach folgendem Schema: * $markerArray['###NEWSEARCHBTN###'] = $formTool->createSubmit('showHowTo[clear]', '###LABEL_BUTTON_BACK###'); * * @param string $key * @param tx_rnbase_mod_IModule $module * * @return tx_rnbase_model_base */ public static function getCurrentItem($key, tx_rnbase_mod_IModule $module) { $itemid = 0; $data = t3lib_div::_GP('show' . $key); if ($data) { list($itemid, ) = each($data); } $dataKey = 'current' . $key; if ($itemid === 'clear') { $data = t3lib_BEfunc::getModuleData(array($dataKey => ''), array($dataKey => '0'), $module->getName()); return false; } // Daten mit Modul abgleichen $changed = $itemid ? array($dataKey => $itemid) : array(); $data = t3lib_BEfunc::getModuleData(array($dataKey => ''), $changed, $module->getName()); $itemid = $data[$dataKey]; if (!$itemid) { return false; } $modelData = explode('|', $itemid); $item = tx_rnbase::makeInstance($modelData[0], $modelData[1]); if (!$item->isValid()) { $item = null; //auf null setzen damit die Suche wieder angezeigt wird } return $item; }
/** * Returns an instanceof tslib_cObj or \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer. * Since this object has functions for database access and frontend your ControllerAction * should always provide cObj for model and view. This ensures only one instance per request. * * @return an instance of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer or tslib_cObj */ function getCObj() { if (!$this->cObject) { $this->cObject = tx_rnbase::makeInstance(tx_rnbase_util_Typo3Classes::getContentObjectRendererClass()); } return $this->cObject; }
/** * Prüft ob korrekter text zurück erzeugt wird * Das umfasst auch Sonderzeichen */ public function testGeneratorReturnsCorrectPlainTextWhenNoInfoTable() { $aParams = array('defaultFontFace' => 0, 'defaultFontSize' => 22, 'paperOrientation' => 1, 'rtfVersion' => 1); $oRTFGenerator = tx_rnbase::makeInstance('tx_mklib_util_RTFGenerator', $aParams); $sRTFText = $oRTFGenerator->getRTF('###SPECIALCHAR_(###<strong>Das ist ein schöner Testtext.</strong> Auch mit ###SPECIALCHAR_)### verschiedenen ßonderzeichen und Ähnlichem. Sogar einem ###SPECIALCHAR_*###'); $this->assertEquals('{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0\\fcharset0\\fnil Arial;}{\\f1\\fcharset0\\fnil Wingdings;}}{\\f0\\fs22\\dn0 }{\\f1\\fs25\\dn0 (}{\\f0\\fs22\\dn0}{\\b\\f0\\fs22\\dn0 Das ist ein sch\\\'f6ner Testtext. }{\\f0\\fs22\\dn0 Auch mit }{\\f1\\fs25\\dn0 )}{\\f0\\fs22\\dn0 verschiedenen \\\'dfonderzeichen und \\\'c4hnlichem. Sogar einem }{\\f1\\fs25\\dn0 *}{\\f0\\fs22\\dn0}}', $sRTFText, 'Der generierte Text ist falsch.'); }
/** * Befüllt den Record Pfaden * * @param string $sPath * @return tx_mklib_model_Dam */ public function fillPath($sPath = false) { // Pathname immer setzen! if (!$this->hasFilePath()) { if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $this->setFilePathName($this->getUrl()); } else { $this->setFilePathName($this->getFilePath() . $this->getFileName()); } } tx_rnbase::load('tx_mklib_util_File'); // webpath setzen if ((!$sPath || $sPath == 'webpath') && !$this->hasFileWebpath()) { $this->setFileWebpath(tx_mklib_util_File::getWebPath($this->getFilePathName())); } // serverpath setzen if ((!$sPath || $sPath == 'serverpath') && !$this->hasFileServerpath()) { $this->setFileServerpath(tx_mklib_util_File::getServerPath($this->getFilePathName())); } // relpath setzen if ((!$sPath || $sPath == 'relpath') && !$this->hasFileRelpath()) { $this->setFileRelpath(tx_mklib_util_File::getRelPath($this->getFilePathName())); } return $this; }
private static function getDamDB() { if (!self::$damDb) { self::$damDb = tx_rnbase::makeInstance('tx_dam_db'); } return self::$damDb; }
protected function send45() { /* @var $mail TYPO3\CMS\Core\Mail\MailMessage */ $mail = tx_rnbase::makeInstance(tx_rnbase_util_Typo3Classes::getMailMessageClass()); $mail->setFrom(array($this->from => $this->fromName)); $mail->setTo(tx_rnbase_util_Strings::trimExplode(',', $this->toAsString)); $mail->setSubject($this->subject); if ($this->replyTo) { $mail->addReplyTo($this->replyTo, $this->replyToName); } // Or set it after like this if ($this->htmlPart) { $mail->setBody($this->htmlPart, 'text/html'); } // Add alternative parts with addPart() if ($this->textPart) { $mail->addPart($this->textPart, 'text/plain'); } if (!empty($this->attachments)) { foreach ($this->attachments as $attachment) { if (!$mail->attach(Swift_Attachment::fromPath($attachment['src']))) { tx_rnbase_util_Logger::warn('Adding attachment failed!', 'rn_base', array('subject' => $mail->subject, 'to' => $this->toAsString, 'attachment' => $attachment)); } } } $mail->send(); }
private function getConfig($confArr) { $cObj = tx_rnbase::makeInstance(tx_rnbase_util_Typo3Classes::getContentObjectRendererClass()); $configurations = tx_rnbase::makeInstance('tx_rnbase_configurations'); $configurations->init($confArr, $cObj, 'tx_rnbase', 'rnbase'); return $configurations; }
/** * returns object of network * * @return array|tx_t3socials_models_Network */ protected function getNetwork() { return tx_rnbase::makeInstance('tx_t3socials_models_Network', array('name' => 'Twitter', 'network' => 'twitter', 'username' => '', 'password' => '', 'config' => 'twitter { access_token = access_token_secret = }')); }
/** * Function executed from the Scheduler. * Sends an email * * @return boolean */ public function execute() { $success = TRUE; $taskId = $this->taskUid; tx_rnbase::load('tx_rnbase_util_Misc'); try { $lastRun = $this->getLastRunTime($taskId); /* @var $srv tx_mklog_srv_WatchDog */ $srv = tx_rnbase_util_Misc::getService('mklog', 'WatchDog'); $filters = array(); $options = array(); $options['minimalSeverity'] = $this->getMinimalSeverity(); $options['forceSummaryMail'] = $this->getForceSummaryMail(); $options['includeDataVar'] = $this->getIncludeDataVar(); //damit jede Nachricht nur einmal kommt, auch wenn sie mehrmals vorhanden ist if ($this->getGroupEntries()) { $options['groupby'] = Tx_Mklog_Utility_Devlog::getMessageFieldName() . ',extkey'; // wir wollen aber wissen wie oft jede Nachricht vorhanden ist $options['count'] = TRUE; } $srv->triggerMails($this->getEmailReceiver(), $lastRun, $filters, $options); $this->updateLastRunTime($taskId); } catch (Exception $e) { tx_rnbase_util_Logger::fatal('WatchDog failed!', 'mklog', array('Exception' => $e->getMessage())); $success = FALSE; } return $success; }
/** * @return tx_mklib_model_Currency */ public function getCurrency() { tx_rnbase::load('tx_mklib_model_Currency'); //@TODO: aktuellen Code auslesen und übergeben, // return tx_mklib_model_Currency::getByCountry(); return tx_mklib_model_Currency::getByCurrencyCode(); }
/** * It is possible to overwrite this method and return an array of tab functions * * @return array */ protected function getSubMenuItems() { $menuItems = tx_t3socials_network_Config::getNewtorkCommunicators(); array_unshift($menuItems, tx_rnbase::makeInstance('tx_t3socials_mod_handler_Trigger')); tx_rnbase_util_Misc::callHook('t3socials', 'modCommunicator_tabItems', array('tabItems' => &$menuItems), $this); return $menuItems; }
/** * Init object * * @param tx_rnbase_mod_IModule $mod * @param array $options * @param string $sSelector */ protected function init(tx_rnbase_mod_IModule $mod, $options, $sSelector = 'tx_mklib_mod1_util_Selector') { $this->options = $options; $this->mod = $mod; $this->formTool = $mod->getFormTool(); $this->selector = tx_rnbase::makeInstance($sSelector); $this->selector->init($mod); }
/** */ public function __construct() { /** @var TcaDatabaseRecord $formDataGroup */ $formDataGroup = tx_rnbase::makeInstance('TYPO3\\CMS\\Backend\\Form\\FormDataGroup\\TcaDatabaseRecord'); $this->formDataCompiler = tx_rnbase::makeInstance('TYPO3\\CMS\\Backend\\Form\\FormDataCompiler', $formDataGroup); $this->nodeFactory = tx_rnbase::makeInstance('TYPO3\\CMS\\Backend\\Form\\NodeFactory'); $this->formResultCompiler = tx_rnbase::makeInstance('TYPO3\\CMS\\Backend\\Form\\FormResultCompiler'); }
/** * @return tx_rnbase_util_Lang */ private function includeLocalLang() { $llFile = $this->getLLFile(); /* @var $lang tx_rnbase_util_Lang */ $lang = tx_rnbase::makeInstance('tx_rnbase_util_Lang'); $lang->loadLLFile($llFile); return $lang; }
public function testMakeLink() { $oLinker = tx_rnbase::makeInstance('tx_mklib_tests_fixtures_classes_DummyLinker'); $oModel = tx_rnbase::makeInstance('tx_rnbase_model_base', 1); $oModel->uid = 1; $oFormTool = tx_rnbase::makeInstance('tx_rnbase_util_FormTool'); $this->assertEquals('<input type="submit" name="showTest[tx_rnbase_model_base|1]" value="" />', $oLinker->makeLink($oModel, $oFormTool), 'Fsclher Link.'); }
/** * erzeugt eine Liste von Dateien. * * @param string $template * @param tx_mkdownloads_model_Download $item * @param tx_rnbase_util_FormatUtil $formatter * @param string $confId * @param string $marker * @return string */ public static function buildList($aRecords, $template, &$formatter, $confId, $marker) { if (!self::containsMarker($template, $marker . 'S')) { return $template; } $listBuilder = tx_rnbase::makeInstance('tx_rnbase_util_ListBuilder'); $template = $listBuilder->render($aRecords, $formatter->getConfigurations()->getViewData(), $template, 'tx_mklib_marker_MediaRecord', $confId, $marker, $formatter); return $template; }
public function testUniqueModelArray() { $aArray = array(tx_rnbase::makeInstance('tx_rnbase_model_base', array('uid' => 5, 'name' => 'Model Nr. 5')), tx_rnbase::makeInstance('tx_rnbase_model_base', array('uid' => 6, 'name' => 'Model Nr. 6')), tx_rnbase::makeInstance('tx_rnbase_model_base', array('uid' => 5, 'name' => 'Model Nr. 5')), tx_rnbase::makeInstance('tx_rnbase_model_base', array('uid' => 2, 'name' => 'Model Nr. 2'))); $aUnique = tx_mklib_util_Model::uniqueModels($aArray); $this->assertTrue(is_array($aUnique), 'No array given.'); $this->assertEquals(count($aUnique), 3, 'Array has a wrong count of entries.'); $this->assertArrayHasKey(2, $aUnique, 'Model with uid 2 not found'); $this->assertArrayHasKey(5, $aUnique, 'Model with uid 5 not found'); $this->assertArrayHasKey(6, $aUnique, 'Model with uid 6 not found'); }
/** * Returns the cache instance * * @param string $name * @return tx_rnbase_cache_ICache */ private static function getCacheImpl($name) { if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { return tx_rnbase::makeInstance('tx_rnbase_cache_TYPO3Cache62', $name); } elseif (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { return tx_rnbase::makeInstance('tx_rnbase_cache_TYPO3Cache60', $name); } elseif (tx_rnbase_util_TYPO3::isTYPO46OrHigher()) { return tx_rnbase::makeInstance('tx_rnbase_cache_TYPO3Cache46', $name); } return tx_rnbase::makeInstance('tx_rnbase_cache_TYPO3Cache', $name); }
/** * Erstellen des Frontend-Outputs */ function createOutput($template, &$viewData, &$configurations, &$formatter) { $confId = $this->getController()->getConfId(); // Die ViewData bereitstellen $item = $viewData->offsetGet('item'); $itemPath = $this->getItemPath($configurations, $confId); $markerClass = $this->getMarkerClass($configurations, $confId); $marker = tx_rnbase::makeInstance($markerClass); $out = $marker->parseTemplate($template, $item, $formatter, $confId . $itemPath . '.', strtoupper($itemPath)); return $out; }
/** * Validiert einen PLZ-String für ein Land. * @param tx_mklib_interface_IZipCountry $land * @param string $zip * @return boolean */ public static function validate(tx_mklib_interface_IZipCountry $country, $zip) { $result = true; switch ($country->getZipRule()) { case 0: // no rule set $result = true; tx_rnbase::load('tx_rnbase_util_Logger'); if (tx_rnbase_util_Logger::isNoticeEnabled()) { tx_rnbase_util_Logger::notice('No zip rule for country defined.', 'mklib', array('zip' => $zip, 'getISO2' => $country->getISO2(), 'getZipLength' => $country->getZipLength(), 'getZipRule' => $country->getZipRule())); } break; case 1: // maximum length without gaps $result = self::validateMaxLengthWG($country, $zip); break; case 2: // maximum length numerical without gaps $result = self::validateMaxLengthNumWG($country, $zip); break; case 3: // exact length without gaps $result = self::validateLengthWG($country, $zip); break; case 4: // exact length numerical without gaps $result = self::validateLengthNumWG($country, $zip); break; case 5: // maximum length with gaps $result = self::validateMaxLength($country, $zip); break; case 6: // maximum length numerical with gaps $result = self::validateMaxLengthNum($country, $zip); break; case 7: // exact length with gaps $result = self::validateLength($country, $zip); break; case 8: // exact length numerical with gaps $result = self::validateLengthNum($country, $zip); break; case 9: // special rules $result = self::validateSpecial($country, $zip); break; default: $result = false; break; } return $result; }
/** * 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('items'); $confId = $this->getController()->getExtendedConfId(); $itemPath = $this->getItemPath($configurations, $confId); $markerClass = $this->getMarkerClass($configurations, $confId); //Liste generieren $listBuilder = tx_rnbase::makeInstance('tx_rnbase_util_ListBuilder'); $out = $listBuilder->render($items, $viewData, $template, $markerClass, $confId . $itemPath . '.', strtoupper($itemPath), $formatter); return $out; }
protected function getConfigurations($aConfig = array()) { $configurations = tx_rnbase::makeInstance('tx_rnbase_configurations'); $parameters = tx_rnbase::makeInstance('tx_rnbase_parameters'); //@TODO: warum wird die klasse tslib_cObj nicht gefunden!? (mw: eternit local) if (!class_exists('tslib_cObj')) { require_once t3lib_extMgm::extPath('cms', 'tslib/class.tslib_content.php'); } $configurations->init($aConfig, $configurations->getCObj(1), 'mklib', 'mklib'); $configurations->setParameters($parameters); return $configurations; }
public function testGetInt() { $params = array('empty' => '', 'zero' => '0', 'seven' => '7', 'hello' => 'hello', 'NK_world' => 'world'); /* @var $parameters tx_rnbase_parameters */ $parameters = tx_rnbase::makeInstance('tx_rnbase_parameters', $params); $this->assertEquals(0, $parameters->getInt('empty')); $this->assertEquals(0, $parameters->getInt('zero')); $this->assertEquals(7, $parameters->getInt('seven')); $this->assertEquals(0, $parameters->getInt('hello')); $this->assertEquals(0, $parameters->getInt('world')); $this->assertEquals(0, $parameters->getInt('null')); }
/** * 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; }
/** * * @param tx_rnbase_model_base $model * @param array|tx_rnbase_model_data $options * @return string */ protected function makeLink($model = NULL, $options = NULL) { if (!$model instanceof tx_rnbase_model_base) { $item = $this->getModel(array('uid' => 14))->setTableName('pages'); } if (!$options instanceof tx_rnbase_model_data) { $options = tx_rnbase_model_data::getInstance($options); } /* @var $linker tx_rnbase_mod_linker_ShowDetails */ $linker = tx_rnbase::makeInstance('tx_rnbase_mod_linker_ShowDetails'); self::assertInstanceOf('tx_rnbase_mod_linker_LinkerInterface', $linker); return $linker->makeLink($item, tx_rnbase::makeInstance('tx_rnbase_util_FormTool'), 0, $options); }
/** * @group unit */ public function testInitMediaForFalMediaSetsFalPropertiesToRecord() { if (!tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $this->markTestSkipped('Runs only in TYPO3 6.0 and higher'); } $falModel = $this->getMock('stdClass', array('getProperties', 'getUid', 'getPublicUrl')); $falModel->expects($this->once())->method('getProperties')->will($this->returnValue(array('title' => 'sample picture reference', 'description' => 'this is a sample picture', 'otherField' => '/some/path', 'otherField2' => '/some/other/path'))); $mediaModel = tx_rnbase::makeInstance('tx_rnbase_model_media', $falModel); $this->assertEquals('sample picture reference', $mediaModel->record['title'], 'not the title of the reference'); $this->assertEquals('/some/path', $mediaModel->record['otherField'], 'not the otherField of the original'); $this->assertEquals('/some/other/path', $mediaModel->record['otherField2'], 'not the otherField2 of the otherField2'); $this->assertEquals('this is a sample picture', $mediaModel->record['description'], 'not the description of the original'); }
/** * Returns the cache * * @param string $name * @return tx_rnbase_cache_ICache */ private static function createTYPO3Cache($name) { if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) { $className = 'tx_rnbase_cache_TYPO3Cache62'; } elseif (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $className = 'tx_rnbase_cache_TYPO3Cache60'; } elseif (tx_rnbase_util_TYPO3::isTYPO46OrHigher()) { $className = 'tx_rnbase_cache_TYPO3Cache46'; } else { $className = 'tx_rnbase_cache_TYPO3Cache'; } return tx_rnbase::makeInstance($className, $name); }
/** * Render the PHP template, translate and return the output as string * * The ".php" suffix is added in this function. * Call this function after the $pathToTemplates is set. * The return value is the rendered result of the template, followed by translation. * It is typically a (x)html string, but can be used for any other text based format. * * @param string name of template file without the ".php" suffix * @param tx_rnbase_configurations configuration instance * @return string typically an (x)html string */ function render($view, $configurations) { $link = $configurations->createLink(); // Die ViewData bereitstellen $viewData =& $configurations->getViewData(); $formatter = tx_rnbase::makeInstance('tx_rnbase_util_FormatUtil', $configurations); $path = $this->getTemplate($view); // Für den PHP Include benötigen wir den absoluten Pfad $path = tx_rnbase_util_Files::getFileAbsFileName($path); ob_start(); include $path; $out = ob_get_clean(); return $out; }