public function setUp() { $this->oSelector = tx_rnbase::makeInstance('tx_mklib_mod1_util_Selector'); $this->oMod = tx_rnbase::makeInstance('tx_mklib_tests_fixtures_classes_DummyMod'); $this->oSelector->init($this->oMod); $this->sModuleKey = 'testSearch'; //Modul daten zurücksetzen $GLOBALS['BE_USER']->uc['moduleData'][$this->oMod->getName()] = null; $_GET['SET'] = null; //für cli $GLOBALS['TBE_TEMPLATE'] = t3lib_div::makeInstance('template'); $GLOBALS['CLIENT']['FORMSTYLE'] = 'something'; //sprache auf default setzen damit wir die richtigen labels haben $GLOBALS['LANG']->lang = 'default'; //damit labels geladen sind global $LOCAL_LANG; //ab typo 4.6 ist das mit den lang labels anders $mHideEntry = 'Hide hidden entries'; $mShowEntry = 'Show hidden entries'; if (tx_rnbase_util_TYPO3::isTYPO46OrHigher()) { $LOCAL_LANG['default']['label_select_hide_hidden'][0]['target'] = $mHideEntry; $LOCAL_LANG['default']['label_select_show_hidden'][0]['target'] = $mShowEntry; } else { $LOCAL_LANG['default']['label_select_hide_hidden'] = $mHideEntry; $LOCAL_LANG['default']['label_select_show_hidden'] = $mShowEntry; } // sonst fehler die icon klassen if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { \TYPO3\CMS\Backend\Sprite\SpriteManager::initialize(); } }
/** * 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; }
/** * @return \TYPO3\CMS\Core\Utility\ExtensionManagementUtility or t3lib_extMgm */ protected static function getExtensionManagementUtilityClass() { if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $class = '\\TYPO3\\CMS\\Core\\Utility\\ExtensionManagementUtility'; } else { $class = 't3lib_extMgm'; } return $class; }
/** * @return \TYPO3\CMS\Backend\Utility\IconUtility or t3lib_iconWorks */ protected static function getIconUtilityClass() { if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $class = '\\TYPO3\\CMS\\Backend\\Utility\\IconUtility'; } else { $class = 't3lib_iconWorks'; } return $class; }
/** * @return \TYPO3\CMS\Backend\Utility\BackendUtility or t3lib_BEfunc */ protected static function getBackendUtilityClass() { if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $backendUtilityClass = '\\TYPO3\\CMS\\Backend\\Utility\\BackendUtility'; } else { $backendUtilityClass = 't3lib_BEfunc'; } return $backendUtilityClass; }
/** * 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); }
/** * 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); }
/** * @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'); }
protected function prepareItem(Tx_Rnbase_Domain_Model_RecordInterface $item, tx_rnbase_configurations $configurations, $confId) { if (!tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { // Localize data (DAM 1.1.0) if (method_exists(self::getDamDB(), 'getRecordOverlay')) { $loc = self::getDamDB()->getRecordOverlay('tx_dam', $item->getRecord(), array('sys_language_uid' => $GLOBALS['TSFE']->sys_language_uid)); if ($loc) { $item->setProperty($loc); } } } // TODO: record overlay for FAL?? parent::prepareItem($item, $configurations, $confId); }
/** * @group unit */ public function testGetWizardsReturnsWizardsWithCorrectIcons() { $wizards = Tx_Rnbase_Utility_TcaTool::getWizards('', array('add' => 1, 'edit' => 1, 'list' => 1, 'RTE' => 1)); if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { self::assertEquals('EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_add.gif', $wizards['add']['icon']); self::assertEquals('EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_edit.gif', $wizards['edit']['icon']); self::assertEquals('EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_list.gif', $wizards['list']['icon']); self::assertEquals('EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_rte.gif', $wizards['RTE']['icon']); } else { self::assertEquals('edit2.gif', $wizards['add']['icon']); self::assertEquals('add.gif', $wizards['edit']['icon']); self::assertEquals('list.gif', $wizards['list']['icon']); self::assertEquals('wizard_rte2.gif', $wizards['RTE']['icon']); } }
private function initMedia($media) { // Ab TYPO3 6.x wird nur noch FAL unterstützt. if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { // Bei FAL steckt in Media eine Referenz if ($media instanceof TYPO3\CMS\Core\Resource\FileReference) { $this->initFalReference($media); } else { $this->initFalFile($media); } } else { // DAM $this->uid = $media->meta['uid']; $this->record = $media->meta; } }
public function setUp() { //wir nutzen hier die pages tabelle und überschreiben die TCA //für ein paar felder. wir müssen das mit bestehenden feldern //in einer echten tabelle testen da es sonst zu warnungen kommt. global $TCA; $this->tcaBackup = $TCA[$this->testTable]; $TCA[$this->testTable] = array('ctrl' => array('title' => $this->testTable, 'readOnly' => 1, 'is_static' => 1), 'columns' => array($this->fieldMappings['inputNotRequiredField'] => array('exclude' => 1, 'config' => array('type' => 'input')), $this->fieldMappings['selectNotRequired1Field'] => array('exclude' => 1, 'config' => array('type' => 'select')), $this->fieldMappings['selectNotRequired2Field'] => array('exclude' => 1, 'config' => array('type' => 'select', 'eval' => 'required')), $this->fieldMappings['selectNotRequired3Field'] => array('exclude' => 1, 'config' => array('type' => 'select', 'maxitems' => 1)), $this->fieldMappings['selectRequired1Field'] => array('exclude' => 1, 'config' => array('type' => 'select', 'eval' => 'required', 'maxitems' => 1, 'minitems' => 1)), $this->fieldMappings['selectRequired2Field'] => array('exclude' => 1, 'config' => array('type' => 'select', 'eval' => 'int,required', 'maxitems' => 1, 'minitems' => 1)), $this->fieldMappings['selectRequired3Field'] => array('exclude' => 1, 'config' => array('type' => 'select', 'eval' => 'required,int', 'maxitems' => 1, 'minitems' => 1)), $this->fieldMappings['selectRequired4Field'] => array('exclude' => 1, 'config' => array('type' => 'select', 'eval' => 'int,required,trim', 'maxitems' => 1, 'minitems' => 1)), $this->fieldMappings['selectRequired6Field'] => array('exclude' => 1, 'config' => array('type' => 'select', 'minitems' => 1)), $this->fieldMappings['selectNotRequired4Field'] => array('exclude' => 1, 'config' => array('type' => 'select', 'eval' => 'required', 'maxitems' => 1)))); //damit alles auf der CLI funktioniert $GLOBALS['BE_USER']->user['admin'] = 1; //tceforms initialisieren $this->oTceForms = t3lib_div::makeInstance('t3lib_tceforms'); // sonst Warning in typo3/sysext/backend/Classes/Utility/IconUtility.php line 594 if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable'] = (array) $GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable']; } }
/** * Wrapped Method t3lib_div::getRandomHexString() * * @param int $count * @return string */ public static function getRandomHexString($count) { tx_rnbase::load('tx_rnbase_util_TYPO3'); if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { return \TYPO3\CMS\Core\Utility\GeneralUtility::getRandomHexString($count); } else { return t3lib_div::getRandomHexString($count); } }
/** * @param string $wizardType * @param array $wizardConfig * @return array */ private static function addWizardScriptForTypo3Version($wizardType, array $wizardConfig) { $completeWizardName = 'wizard_' . $wizardType; if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $wizardConfig['module']['name'] = $completeWizardName; if (isset($wizardConfig['script'])) { unset($wizardConfig['script']); } } else { if (!isset($wizardConfig['script'])) { $wizardConfig['script'] = $completeWizardName . '.php'; } } return $wizardConfig; }
/** * @return boolean TRUE if fName starts with file: */ public static function isFALReference($fName) { return tx_rnbase_util_TYPO3::isTYPO60OrHigher() ? tx_rnbase_util_Strings::isFirstPartOfStr($fName, 'file:') : FALSE; }
/** * @group unit */ public function testGetWizardsReturnsWizardsWithCorrectScriptOrModuleKey() { $wizards = tx_mklib_util_TCA::getWizards('', array('add' => 1, 'edit' => 1, 'list' => 1, 'RTE' => 1)); if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $this->assertArrayNotHasKey('script', $wizards['add']); $this->assertArrayNotHasKey('script', $wizards['edit']); $this->assertArrayNotHasKey('script', $wizards['list']); $this->assertArrayNotHasKey('script', $wizards['RTE']); $this->assertEquals('wizard_add', $wizards['add']['module']['name']); $this->assertEquals('wizard_edit', $wizards['edit']['module']['name']); $this->assertEquals('wizard_list', $wizards['list']['module']['name']); $this->assertEquals('wizard_rte', $wizards['RTE']['module']['name']); } else { $this->assertArrayNotHasKey('module', $wizards['add']); $this->assertArrayNotHasKey('module', $wizards['edit']); $this->assertArrayNotHasKey('module', $wizards['list']); $this->assertArrayNotHasKey('module', $wizards['RTE']); $this->assertEquals('wizard_add.php', $wizards['add']['script']); $this->assertEquals('wizard_edit.php', $wizards['edit']['script']); $this->assertEquals('wizard_list.php', $wizards['list']['script']); $this->assertEquals('wizard_rte.php', $wizards['RTE']['script']); } }
/** * Setzt das fe_user objekt, falls es noch nicht gesetzt wurde * * @param tslib_feuserauth $oFeUser Erzeugt das tslib_feuserauth Objekt wenn nix übergeben wurde * @param boolean $bForce Setzt das fe_user Objekt auch, wenn es bereits gesetzt ist. * @return void */ public static function setFeUserObject($oFeUser = null, $bForce = false) { if (!$GLOBALS['TSFE']->fe_user instanceof tslib_feuserauth || $bForce) { if (!is_object($oFeUser)) { if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $oFeUser = new \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication(); } else { $oFeUser = new tslib_feuserauth(); } } if (!is_object($GLOBALS['TSFE'])) { $GLOBALS['TSFE'] = new stdClass(); } $GLOBALS['TSFE']->fe_user = $oFeUser; } }
/** * liefert die typo3 flexform utils * * @return array */ private function xml2array($xmlData) { $className = '\\TYPO3\\CMS\\Core\\Utility\\GeneralUtility'; if (!tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $className = 't3lib_div'; } return $className::xml2array($xmlData); }
* modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA ***************************************************************/ define('DEFAULT_LOCAL_FIELD', '_LOCALIZED_UID'); tx_rnbase::load('tx_rnbase_util_TYPO3'); if (!tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { return; } tx_rnbase::load('Tx_Rnbase_Backend_Utility'); tx_rnbase::load('tx_rnbase_util_Strings'); /** * Contains utility functions for FAL */ class tx_rnbase_util_TSFAL { /** * Typoscript USER function for rendering DAM images. * This is a minimal Setup: * <pre> * yourObject.imagecol = USER * yourObject.imagecol {
/** * @unit * @expectedException RuntimeException */ public function testMkdirDeepThrowsExceptionIfDirectoryCreationFails() { if (!tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $this->markTestSkipped('Runtime Exception is not thrown before TYPO3 6.x'); } tx_rnbase_util_Files::mkdir_deep('http://localhost'); }
/** * @return \TYPO3\CMS\Frontend\Page\PageRepository or t3lib_pageSelect */ public static function getSysPage() { if (!is_object(self::$sysPage)) { if (is_object($GLOBALS['TSFE']->sys_page)) { self::$sysPage = $GLOBALS['TSFE']->sys_page; } else { self::$sysPage = tx_rnbase::makeInstance(tx_rnbase_util_TYPO3::isTYPO60OrHigher() ? 'TYPO3\\CMS\\Frontend\\Page\\PageRepository' : 't3lib_pageSelect'); self::$sysPage->init(0); // $this->showHiddenPage } } return self::$sysPage; }
/** * @param array $possibleClasses * @return string */ protected static function getClassByCurrentTypo3Version(array $possibleClasses) { return tx_rnbase_util_TYPO3::isTYPO60OrHigher() ? $possibleClasses[self::HIGHER6] : $possibleClasses[self::LOWER6]; }
/** * Creates a proxy class of the specified class which allows * for calling even protected methods and access of protected properties. * This method is taken from TYPO3 BaseTestCase * * @param string $className Name of class to make available, must not be empty * @return string Fully qualified name of the built class, will not be empty * @see Tx_Extbase_Tests_Unit_BaseTestCase::buildAccessibleProxy */ protected function buildAccessibleProxy($className) { $accessibleClassName = uniqid('Tx_Phpunit_AccessibleProxy'); $class = new \ReflectionClass($className); $abstractModifier = $class->isAbstract() ? 'abstract ' : ''; $interfaces = ''; if (tx_rnbase_util_TYPO3::isTYPO60OrHigher()) { $interfaces = 'Tx_Phpunit_Interface_AccessibleObject'; } $interfaces = empty($interfaces) ? '' : ' implements ' . $interfaces; eval($abstractModifier . 'class ' . $accessibleClassName . ' extends ' . $className . $interfaces . ' {' . 'public function _call($methodName) {' . 'if ($methodName === \'\') {' . 'throw new \\InvalidArgumentException(\'$methodName must not be empty.\', 1334663993);' . '}' . '$args = func_get_args();' . 'return call_user_func_array(array($this, $methodName), array_slice($args, 1));' . '}' . 'public function _callRef(' . '$methodName, &$arg1 = NULL, &$arg2 = NULL, &$arg3 = NULL, &$arg4 = NULL, &$arg5= NULL, &$arg6 = NULL, ' . '&$arg7 = NULL, &$arg8 = NULL, &$arg9 = NULL' . ') {' . 'if ($methodName === \'\') {' . 'throw new \\InvalidArgumentException(\'$methodName must not be empty.\', 1334664210);' . '}' . 'switch (func_num_args()) {' . 'case 0:' . 'throw new RuntimeException(\'The case of 0 arguments is not supposed to happen.\', 1334703124);' . 'break;' . 'case 1:' . '$returnValue = $this->$methodName();' . 'break;' . 'case 2:' . '$returnValue = $this->$methodName($arg1);' . 'break;' . 'case 3:' . '$returnValue = $this->$methodName($arg1, $arg2);' . 'break;' . 'case 4:' . '$returnValue = $this->$methodName($arg1, $arg2, $arg3);' . 'break;' . 'case 5:' . '$returnValue = $this->$methodName($arg1, $arg2, $arg3, $arg4);' . 'break;' . 'case 6:' . '$returnValue = $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5);' . 'break;' . 'case 7:' . '$returnValue = $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);' . 'break;' . 'case 8:' . '$returnValue = $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7);' . 'break;' . 'case 9:' . '$returnValue = $this->$methodName($arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8);' . 'break;' . 'case 10:' . '$returnValue = $this->$methodName(' . '$arg1, $arg2, $arg3, $arg4, $arg5, $arg6, $arg7, $arg8, $arg9' . ');' . 'break;' . 'default:' . 'throw new \\InvalidArgumentException(' . '\'_callRef currently only allows calls to methods with no more than 9 parameters.\'' . ');' . '}' . 'return $returnValue;' . '}' . 'public function _set($propertyName, $value) {' . 'if ($propertyName === \'\') {' . 'throw new \\InvalidArgumentException(\'$propertyName must not be empty.\', 1334664355);' . '}' . '$this->$propertyName = $value;' . '}' . 'public function _setRef($propertyName, &$value) {' . 'if ($propertyName === \'\') {' . 'throw new \\InvalidArgumentException(\'$propertyName must not be empty.\', 1334664545);' . '}' . '$this->$propertyName = $value;' . '}' . 'public function _setStatic($propertyName, $value) {' . 'if ($propertyName === \'\') {' . 'throw new \\InvalidArgumentException(\'$propertyName must not be empty.\', 1344242602);' . '}' . 'self::$$propertyName = $value;' . '}' . 'public function _get($propertyName) {' . 'if ($propertyName === \'\') {' . 'throw new \\InvalidArgumentException(\'$propertyName must not be empty.\', 1334664967);' . '}' . 'return $this->$propertyName;' . '}' . 'public function _getStatic($propertyName) {' . 'if ($propertyName === \'\') {' . 'throw new \\InvalidArgumentException(\'$propertyName must not be empty.\', 1344242603);' . '}' . 'return self::$$propertyName;' . '}' . '}'); return $accessibleClassName; }