/** * Initialize this instance for a plugin * @param string $qualifier */ public function init($qualifier) { $this->setQualifier($qualifier); // get parametersArray for defined qualifier $parametersArray = $this->getParametersPlain($qualifier); tx_rnbase_util_Arrays::overwriteArray($this, $parametersArray); }
/** * Load flexformdata into the object * * Takes a xml string or an already rendered array. * Typically it would come from the field tt_content.pi_flexform * * This configuration assumes unique key names for the fields. * The names of the sheets are of no relevance. * If you need a more sophisticated solution simply write a your * own loader function in an inherited class. * * @param mixed xml or rendered flexform array * @return void */ function _setFlexForm($xmlOrArray) { $languagePointer = 'lDEF'; // we don't support languages here for now $valuePointer = 'vDEF'; // also hardcoded here if (!$xmlOrArray) { return FALSE; } // Converting flexform data into array if neccessary if (is_array($xmlOrArray)) { $array = $xmlOrArray; } else { $array = tx_rnbase_util_Arrays::xml2array($xmlOrArray); } $data = $array['data']; // Looking for the special sheet s_tssetup $flexTs = FALSE; if (isset($data['s_tssetup'])) { $flexTs = $data['s_tssetup']['lDEF']['flexformTS']['vDEF']; unset($data['s_tssetup']); } foreach ((array) $data as $sheet => $languages) { foreach ((array) $languages[$languagePointer] as $key => $def) { // Wir nehmen Flexformwerte nur, wenn sie sinnvolle Daten enthalten // Sonst werden evt. vorhandenen Daten überschrieben if (!(strlen($def[$valuePointer]) == 0)) { // || $def[$valuePointer] == '0') $pathArray = explode('.', trim($key)); if (count($pathArray) > 1) { // Die Angabe im Flexform ist in Punktnotation // Wir holen das Array im höchsten Knoten $dataArr = $this->_dataStore->offsetGet($pathArray[0] . '.'); $newValue = $def[$valuePointer]; $newArr = $this->insertIntoDataArray($dataArr, array_slice($pathArray, 1), $newValue); $this->_dataStore->offsetSet($pathArray[0] . '.', $newArr); } else { $this->_dataStore->offsetSet($key, $def[$valuePointer]); } } } } if ($flexTs) { // This handles ts setup from flexform $tsParser = tx_rnbase::makeInstance(tx_rnbase_util_Typo3Classes::getTypoScriptParserClass()); $tsParser->setup = $this->_dataStore->getArrayCopy(); $tsParser->parse($flexTs); $flexTsData = $tsParser->setup; $this->_dataStore->exchangeArray($flexTsData); } }
/** * 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; }
/** * Search database * * @param array $fields * @param array $options * @return array[tx_rnbase_model_base] */ public function search(array $fields, array $options) { if (empty($options['searchdef']) || !is_array($options['searchdef'])) { $options['searchdef'] = array(); } $options['searchdef'] = tx_rnbase_util_Arrays::mergeRecursiveWithOverrule($this->getSearchdef(), $options['searchdef']); return parent::search($fields, $options); }
/** * Creates the wizard config for the tca * * usage: * ... 'wizards' => Tx_Rnbase_Utility_TcaTool::getWizards( * 'mytable', * array( * ### overwriting the default label * ### or anything else * 'add' => array('title' => 'my new title'), * 'edit' => TRUE, * 'suggest' => TRUE * ) * ), * * @param string $table * @param array $options * @return array */ public static function getWizards($table, array $options = array()) { $globalPid = isset($options['globalPid']) ? $options['globalPid'] : false; $wizards = array('_PADDING' => 2, '_VERTICAL' => 1); if (isset($options['edit'])) { $wizards['edit'] = array('type' => 'popup', 'title' => 'Edit entry', 'icon' => tx_rnbase_util_TYPO3::isTYPO60OrHigher() ? 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_edit.gif' : 'edit2.gif', 'popup_onlyOpenIfSelected' => 1, 'JSopenParams' => 'height=576,width=720,status=0,menubar=0,scrollbars=1'); $wizards['edit'] = self::addWizardScriptForTypo3Version('edit', $wizards['edit']); if (is_array($options['edit'])) { $wizards['edit'] = tx_rnbase_util_Arrays::mergeRecursiveWithOverrule($wizards['edit'], $options['edit']); } } if (isset($options['add'])) { $wizards['add'] = array('type' => 'script', 'title' => 'Create new entry', 'icon' => tx_rnbase_util_TYPO3::isTYPO60OrHigher() ? 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_add.gif' : 'add.gif', 'params' => array('table' => $table, 'pid' => $globalPid ? '###STORAGE_PID###' : '###CURRENT_PID###', 'setValue' => 'prepend')); $wizards['add'] = self::addWizardScriptForTypo3Version('add', $wizards['add']); if (is_array($options['add'])) { $wizards['add'] = tx_rnbase_util_Arrays::mergeRecursiveWithOverrule($wizards['add'], $options['add']); } } if (isset($options['list'])) { $wizards['list'] = array('type' => 'popup', 'title' => 'List entries', 'icon' => tx_rnbase_util_TYPO3::isTYPO60OrHigher() ? 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_list.gif' : 'list.gif', 'params' => array('table' => $table, 'pid' => $globalPid ? '###STORAGE_PID###' : '###CURRENT_PID###'), 'JSopenParams' => 'height=576,width=720,status=0,menubar=0,scrollbars=1'); $wizards['list'] = self::addWizardScriptForTypo3Version('list', $wizards['list']); if (is_array($options['list'])) { $wizards['list'] = tx_rnbase_util_Arrays::mergeRecursiveWithOverrule($wizards['list'], $options['list']); } } if (isset($options['suggest'])) { $wizards['suggest'] = array('type' => 'suggest', 'default' => array('maxItemsInResultList' => 8, 'searchWholePhrase' => true)); if (is_array($options['suggest'])) { $wizards['suggest'] = tx_rnbase_util_Arrays::mergeRecursiveWithOverrule($wizards['suggest'], $options['suggest']); } } if (isset($options['RTE'])) { $wizards['RTE'] = array('notNewRecords' => 1, 'RTEonly' => 1, 'type' => 'script', 'title' => 'Full screen Rich Text Editing', 'icon' => tx_rnbase_util_TYPO3::isTYPO60OrHigher() ? 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_rte.gif' : 'wizard_rte2.gif'); $wizards['RTE'] = self::addWizardScriptForTypo3Version('rte', $wizards['RTE']); } if (isset($options['link'])) { $wizards['link'] = array('type' => 'popup', 'title' => 'LLL:EXT:cms/locallang_ttc.xml:header_link_formlabel', 'icon' => tx_rnbase_util_TYPO3::isTYPO60OrHigher() ? 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_link.gif' : 'link_popup.gif', 'script' => 'browse_links.php?mode=wizard', 'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1', 'params' => array('blindLinkOptions' => '')); if (is_array($options['link'])) { $wizards['link'] = tx_rnbase_util_Arrays::mergeRecursiveWithOverrule($wizards['link'], $options['link']); } $wizards['link'] = self::addWizardScriptForTypo3Version('link', $wizards['link']); } return $wizards; }
/** * Add a new local lang array from Typoscript _LOCAL_LANG. Merged with existing local lang * * @param array $langArr * * @return void */ protected function addLang($langArr) { if (!is_array($langArr)) { return; } //new values from the given array are added to the existing local lang. //existing values in the local lang are overruled with those of the given array. tx_rnbase::load('tx_rnbase_util_Arrays'); $this->LOCAL_LANG = tx_rnbase_util_Arrays::mergeRecursiveWithOverrule(is_array($this->LOCAL_LANG) ? $this->LOCAL_LANG : array(), $langArr); }
/** * 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; }
/** * Eleminate non-TCA-defined columns from given data * * Doesn't do anything if no TCA columns are found. * * @param array $data Data to be filtered * @return array Data now containing only TCA-defined columns */ public static function eleminateNonTcaColumns(Tx_Rnbase_Domain_Model_RecordInterface $model, array $data) { tx_rnbase::load('tx_rnbase_util_Arrays'); return tx_rnbase_util_Arrays::removeNotIn($data, $model->getColumnNames()); }
/** * Make the full configuration for the typolink function * * @param string $type: tag oder url * @return array the configuration * @access private */ function _makeConfig($type) { $conf = array(); $this->parameters = is_array($this->parameters) ? $this->parameters : array(); $this->overruledParameters = is_array($this->overruledParameters) ? $this->overruledParameters : array(); unset($this->overruledParameters['DATA']); tx_rnbase::load('tx_rnbase_util_Arrays'); $parameters = tx_rnbase_util_Arrays::mergeRecursiveWithOverrule($this->overruledParameters, $this->parameters); foreach ((array) $parameters as $key => $value) { // Ggf. hier auf die Parameter der eigenen Extension prüfen if ($this->getUniqueParameterId() !== NULL) { $value = array($key => $value); $key = $this->getUniqueParameterId(); } $conf['additionalParams'] .= $this->makeUrlParam($key, $value); } if ($this->noHashBoolean) { $conf['useCacheHash'] = 0; } else { $conf['useCacheHash'] = 1; } if ($this->noCacheBoolean) { $conf['no_cache'] = 1; $conf['useCacheHash'] = 0; } else { $conf['no_cache'] = 0; } if ($this->destination !== '') { $conf['parameter'] = $this->destination; } if ($type == 'url') { $conf['returnLast'] = 'url'; } if ($this->anchorString) { $conf['section'] = $this->anchorString; } if ($this->targetString) { $conf['target'] = $this->targetString; } $conf['extTarget'] = $this->externalTargetString != '-1' ? $this->externalTargetString : '_blank'; if ($this->classString) { $conf['ATagParams'] .= 'class="' . $this->classString . '" '; } if ($this->idString) { $conf['ATagParams'] .= 'id="' . $this->idString . '" '; } if ($this->titleString) { $title = $this->titleHasAlreadyHtmlSpecialChars ? $this->titleString : htmlspecialchars($this->titleString); $conf['ATagParams'] .= 'title="' . $title . '" '; } if (is_array($this->tagAttributes) && count($this->tagAttributes) > 0) { foreach ($this->tagAttributes as $key => $value) { $conf['ATagParams'] .= ' ' . $key . '="' . htmlspecialchars($value) . '" '; } } // Weiter generische Attribute setzen if (count($this->typolinkParams)) { $conf = array_merge($conf, $this->typolinkParams); } return $conf; }
/** * Prepares the simple generic searcher * * @param array $options * * @return void */ protected function prepareGenericSearcher(array &$options) { if (empty($options['searchdef']) || !is_array($options['searchdef'])) { $options['searchdef'] = array(); } $model = $this->getEmptyModel(); \tx_rnbase::load('tx_rnbase_util_Arrays'); $options['searchdef'] = \tx_rnbase_util_Arrays::mergeRecursiveWithOverrule(array('usealias' => 1, 'basetable' => $model->getTableName(), 'basetablealias' => 'DEVLOGENTRY', 'wrapperclass' => get_class($model), 'alias' => array('DEVLOGENTRY' => array('table' => $model->getTableName()))), $options['searchdef']); }
/** * @return array */ protected function getCacheKeyParts() { $keys = array(); // TSFE hash, contains page id, domain, etc. $keys[] = tx_rnbase_util_TYPO3::getTSFE()->getHash(); // the plugin ID (tt_content:uid or random md3, whenn rendered as USER in TS) $keys[] = $this->getConfigurations()->getPluginId(); // the conf id of the current action (without trailing dot) $keys[] = trim($this->getConfId(), '.'); // aditionaly a optional key set by ts $keys[] = $this->getSalt(); // include params to the cache key usage = qualifier|uid,tt_news|tt_news $params = $this->getIcludeParams(); if (!empty($params)) { // all get and post vars tx_rnbase::load('tx_rnbase_util_Arrays'); $gp = tx_rnbase_util_Arrays::mergeRecursiveWithOverrule(tx_rnbase_parameters::getGetParameters(), tx_rnbase_parameters::getPostParameters()); // the cobj to get the parameter value $cObj = $this->getConfigurations()->getCObj(); foreach ($params as $param) { $keys[] = 'P-' . $param . '-' . $cObj->getGlobal($param, $gp); } } return $keys; }