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; }
/** * Test flexform value with pointed keys. * */ function test_flexformSetup() { $GLOBALS['TSFE'] = new tx_rnbase_tsfeDummy(); $GLOBALS['TSFE']->tmpl->setup['lib.']['feuser.']['link'] = array('pid' => '10'); $flexXml = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <T3FlexForms> <data> <sheet index="sDEF"> <language index="lDEF"> <field index="action"> <value index="vDEF">tx_rnuserregister_actions_Login</value> </field> <field index="feuserPages"> <value index="vDEF"></value> </field> <field index="feuserPagesRecursive"> <value index="vDEF"></value> </field> </language> </sheet> <sheet index="s_loginbox"> <language index="lDEF"> <field index="view.loginbox.header"> <value index="vDEF">Welcome</value> </field> <field index="view.loginbox.message"> <value index="vDEF"></value> </field> <field index="listview.fegroup.link.pid"> <value index="vDEF">25</value> </field> <field index="detailview.feuser.link.pid"> <value index="vDEF">35</value> </field> </language> </sheet> </data> </T3FlexForms>'; $configurationArray['template'] = 'test.html'; $configurationArray['view.']['dummy'] = '1'; $configurationArray['view.']['dummy.']['test'] = '1'; $configurationArray['view.']['loginbox.']['header.']['enable'] = '1'; $configurationArray['view.']['loginbox.']['header'] = 'Wrong Header'; $configurationArray['view.']['loginbox.']['message'] = 'Hello'; $configurationArray['listview.']['feuser'] = '******'; $cObj = tx_rnbase::makeInstance(tx_rnbase_util_Typo3Classes::getContentObjectRendererClass()); $cObj->data['pi_flexform'] = $flexXml; $configurations = tx_rnbase::makeInstance('tx_rnbase_configurations'); $configurations->init($configurationArray, $cObj, 'extkey_text', 'rntest'); $this->assertEquals('Welcome', $configurations->get('view.loginbox.header'), 'Header should be Welcome'); $this->assertEquals('Hello', $configurations->get('view.loginbox.message'), 'Message should be Hello'); $this->assertEquals('test.html', $configurations->get('template'), 'Template should be test.html'); $this->assertEquals('1', $configurations->get('view.dummy'), 'Dummy should be 1'); $pid = $configurations->get('listview.fegroup.link.pid'); $this->assertEquals('25', $pid, 'PID from flexform should be 25 but was: ' . $pid); $pid = $configurations->get('detailview.feuser.link.pid'); $this->assertEquals('35', $pid, 'PID from flexform should be 35 but was: ' . $pid); }
/** * 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; }
/** * Sample: * self::createConfigurations( * array(), 'rn_base', 'rn_base', * tx_rnbase::makeInstance('tx_rnbase_parameters'), * tx_rnbase::makeInstance(tx_rnbase_util_Typo3Classes::getContentObjectRendererClass()) * ); * * @param array $configurationArray * @param string $extensionKey * @param string $qualifier * @return tx_rnbase_configurations */ protected static function createConfigurations(array $configurationArray, $extensionKey, $qualifier = '') { $qualifier = empty($qualifier) ? $extensionKey : $qualifier; $parameters = NULL; $cObj = NULL; $args = func_get_args(); $args = count($args) > 3 ? array_slice($args, 3) : array(); foreach ($args as $arg) { if ($arg instanceof tx_rnbase_parameters) { $parameters = $arg; } $contentObjectRendererClass = tx_rnbase_util_Typo3Classes::getContentObjectRendererClass(); if ($arg instanceof $contentObjectRendererClass) { $cObj = $arg; } } /* @var $configurations tx_rnbase_configurations */ $configurations = tx_rnbase::makeInstance('tx_rnbase_configurations'); $configurations->init($configurationArray, $cObj, $extensionKey, $qualifier); if ($arg instanceof tx_rnbase_parameters) { $configurations->setParameters($parameters); } return $configurations; }
/** * Create your individuell instance of cObj. For each id only one instance is created. * If id == 0 the will get the plugins original cOBj. * @param $id any * @param $cObjClass String Optional cObj-classname * @return \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer or tslib_cObj */ public function &getCObj($id = 0, $cObjClass = NULL) { $cObjClass = $cObjClass === NULL ? tx_rnbase_util_Typo3Classes::getContentObjectRendererClass() : $cObjClass; if (strcmp($id, '0') == 0) { if (!is_object($this->cObj)) { $this->cObj = tx_rnbase::makeInstance($cObjClass); $this->cObjs[0] = $this->cObj; } return $this->cObj; } $cObj = $this->_cObjs[$id]; if (!is_object($cObj)) { $this->cObjs[$id] = tx_rnbase::makeInstance($cObjClass); } return $this->cObjs[$id]; }
/** * Same method as tslib_pibase::pi_getPidList() * @return string commaseparated list of pids */ public static function getPidList($pid_list, $recursive = 0) { tx_rnbase::load('tx_rnbase_util_Math'); tx_rnbase::load('tx_rnbase_util_Typo3Classes'); if (!strcmp($pid_list, '')) { $pid_list = tx_rnbase_util_TYPO3::getTSFE()->id; } $recursive = tx_rnbase_util_Math::intInRange($recursive, 0); $pid_list_arr = array_unique(tx_rnbase_util_Strings::trimExplode(',', $pid_list, 1)); $pid_list = array(); foreach ($pid_list_arr as $val) { $val = tx_rnbase_util_Math::intInRange($val, 0); if ($val) { /* @var $cObj \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer */ $cObj = tx_rnbase::makeInstance(tx_rnbase_util_Typo3Classes::getContentObjectRendererClass()); $_list = $cObj->getTreeList(-1 * $val, $recursive); if ($_list) { $pid_list[] = $_list; } } } return implode(',', $pid_list); }
/** * Liefert eine Instanz von tx_rnbase_configurations. Da wir uns im BE bewegen, wird diese mit einem * Config-Array aus der TSConfig gefüttert. Dabei wird die Konfiguration unterhalb von mod.extkey. genommen. * Für "extkey" wird der Wert der Methode getExtensionKey() verwendet. * Zusätzlich wird auch die Konfiguration von "lib." bereitgestellt. * Wenn Daten für BE-Nutzer oder Gruppen überschrieben werden sollen, dann darauf achten, daß die * Konfiguration mit "page." beginnen muss. Also bspw. "page.lib.test = 42". * * Ein eigenes TS-Template für das BE wird in der ext_localconf.php mit dieser Anweisung eingebunden: * tx_rnbase_util_Extensions::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:myext/mod1/pageTSconfig.txt">'); * @return tx_rnbase_configurations */ public function getConfigurations() { if (!$this->configurations) { tx_rnbase::load('tx_rnbase_configurations'); tx_rnbase::load('tx_rnbase_util_Misc'); tx_rnbase::load('tx_rnbase_util_Typo3Classes'); tx_rnbase_util_Misc::prepareTSFE(); // Ist bei Aufruf aus BE notwendig! $cObj = tx_rnbase::makeInstance(tx_rnbase_util_Typo3Classes::getContentObjectRendererClass()); $pageTSconfigFull = Tx_Rnbase_Backend_Utility::getPagesTSconfig($this->getPid()); $pageTSconfig = $pageTSconfigFull['mod.'][$this->getExtensionKey() . '.']; $pageTSconfig['lib.'] = $pageTSconfigFull['lib.']; $userTSconfig = $GLOBALS['BE_USER']->getTSConfig('mod.' . $this->getExtensionKey() . '.'); if (!empty($userTSconfig['properties'])) { tx_rnbase::load('tx_rnbase_util_Arrays'); $pageTSconfig = tx_rnbase_util_Arrays::mergeRecursiveWithOverrule($pageTSconfig, $userTSconfig['properties']); } $qualifier = $pageTSconfig['qualifier'] ? $pageTSconfig['qualifier'] : $this->getExtensionKey(); $this->configurations = new tx_rnbase_configurations(); $this->configurations->init($pageTSconfig, $cObj, $this->getExtensionKey(), $qualifier); } return $this->configurations; }
/** * * @param array $config * @return PHPUnit_Framework_MockObject_MockObject|tx_rnbase_action_CacheHandlerDefault */ protected function getHandlerMock(array $config = array(), array $methods = array()) { $handler = $this->getMock('tx_rnbase_action_CacheHandlerDefault', array_merge(array('getConfigurations', 'getConfId'), $methods)); // create cobject with the plugin id. $cObj = tx_rnbase::makeInstance(tx_rnbase_util_Typo3Classes::getContentObjectRendererClass()); $cObj->data['uid'] = '75'; $confId = 'myaction.'; $configurations = $this->createConfigurations(array($confId => array('_caching.' => $config)), 'rn_base', 'rn_base', $cObj); $handler->expects($this->atLeastOnce())->method('getConfigurations')->will($this->returnValue($configurations)); $handler->expects($this->any())->method('getConfId')->will($this->returnValue($confId . '_caching.')); return $handler; }
/** * 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; }
/** * Construct a link object * * By default this object wraps \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::typolink(); * The $cObjectClass parameter can be used to provide a mock object * for unit tests. * * @param object mock object for testing purpuses * @return void */ function __construct($cObject = NULL) { if (is_object($cObject)) { $this->cObject = $cObject; } else { $this->cObject = tx_rnbase::makeInstance($cObject === NULL ? tx_rnbase_util_Typo3Classes::getContentObjectRendererClass() : $cObject); } }