예제 #1
0
 /**
  * Load the complete extlist part from typoscript
  */
 protected function loadYagTyposcriptArray()
 {
     if (is_null($this->yagTypoScript)) {
         $extListTS = Tx_PtExtbase_Div::typoscriptRegistry('plugin.tx_yag.', $this->currentPid);
         $this->yagTypoScript = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertTypoScriptArrayToPlainArray($extListTS);
     }
 }
예제 #2
0
 /**
  * building this with a data provider actually makes the test harder to read and to understand
  *
  * @test
  */
 public function returnExtConfArrayTest()
 {
     $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'] = ['validArray' => ['data' => 'value'], 'validSerialized' => 'a:1:{s:5:"data2";s:13:"value as well";}', 'somethingInvalid' => 'a:2:{s:8:"data";s:1:"value";}'];
     $this->assertEquals(['data' => 'value'], $this->proxy->returnExtConfArray('validArray'));
     $this->assertEquals(['data2' => 'value as well'], $this->proxy->returnExtConfArray('validSerialized'));
     try {
         $this->proxy->returnExtConfArray('somethingInvalid');
     } catch (\Exception $e) {
         $this->assertEquals(1473087238, $e->getCode());
     }
     try {
         $this->proxy->returnExtConfArray('invalidExtensionKey');
     } catch (\Exception $e) {
         $this->assertEquals(1473087212, $e->getCode());
     }
 }
예제 #3
0
파일: Bootstrap.php 프로젝트: rabe69/yag
 /**
  * @return void
  */
 protected function initConfigurationBuilder()
 {
     $yagSettings = Tx_PtExtbase_Div::typoscriptRegistry('plugin.tx_yag.settings.');
     $yagEBSettings = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertTypoScriptArrayToPlainArray($yagSettings);
     Tx_Yag_Domain_Configuration_ConfigurationBuilderFactory::injectSettings($yagEBSettings);
     Tx_Yag_Domain_Configuration_ConfigurationBuilderFactory::getInstance($this->contextIdentifier, $this->theme);
     Tx_Yag_Domain_Context_YagContextFactory::createInstance($this->contextIdentifier);
 }
예제 #4
0
 public function __construct()
 {
     $this->extensionConfiguration = \Tx_PtExtbase_Div::returnExtConfArray('pt_extbase');
     $this->evaluateLogFilePath();
     $this->evaluateExceptionDirectory();
     $this->setLogLevelThresholdByExtensionConfigurationProperty('logLevelThreshold');
     $this->setLogLevelThresholdByExtensionConfigurationProperty('emailLogLevelThreshold');
     $this->evaluateEmailReceivers();
 }
 /**
  * Renders a cObject form an extbase formatted config
  *
  * @param mixed $config
  * @param array $data
  * @return string
  */
 public function render($config, $data = array())
 {
     if (!is_array($config)) {
         return $config;
     }
     if ($data) {
         Tx_PtExtbase_Div::getCobj()->start($data);
     }
     return Tx_PtExtbase_Div::getCobj()->cObjGetSingle($config['_typoScriptNodeValue'], Tx_Extbase_Service_TypoScriptService::convertPlainArrayToTypoScriptArray($config));
 }
예제 #6
0
파일: BaseTestCase.php 프로젝트: rabe69/yag
 /**
  * @param null $settings
  */
 protected function initConfigurationBuilderMock($settings = NULL)
 {
     if (!$settings) {
         $tsFilePath = ExtensionManagementUtility::extPath($this->extensionName) . 'Configuration/TypoScript/setup.txt';
         $typoscript = Tx_PtExtbase_Div::loadTypoScriptFromFile($tsFilePath);
         $settings = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertTypoScriptArrayToPlainArray($typoscript);
         $settings = $settings['plugin']['tx_yag']['settings'];
     }
     Tx_Yag_Domain_Configuration_ConfigurationBuilderFactory::injectSettings($settings);
     $this->configurationBuilder = Tx_Yag_Domain_Configuration_ConfigurationBuilderFactory::getInstance('test', 'default');
 }
예제 #7
0
 /**
  * This is a patch for TYPO3 6.2 - can be removed for
  * TYPO3 7.0 - see parents class method
  *
  * @param int $identifier
  * @param bool $ignoreEnableFields
  * @return Tx_Yag_Domain_Model_Album
  */
 public function findByUid($identifier, $ignoreEnableFields = false)
 {
     if (Tx_PtExtbase_Div::isMinTypo3Version(7)) {
         return parent::findByUid($identifier);
     }
     if ($this->session->hasIdentifier($identifier, $this->objectType)) {
         $object = $this->session->getObjectByIdentifier($identifier, $this->objectType);
     } else {
         $query = $this->createQuery();
         $query->getQuerySettings()->setRespectStoragePage(false);
         $query->getQuerySettings()->setRespectSysLanguage(false);
         $query->getQuerySettings()->setIgnoreEnableFields($ignoreEnableFields);
         $object = $query->matching($query->equals('uid', $identifier))->execute()->getFirst();
     }
     return $object;
 }
예제 #8
0
 /**
  * Render the given dataValues with cObj
  *
  * @param array $tsConfigValue Array with two values in first level 'renderObj' => 'TEXT|COA|IMAGE|...', 'renderObj.' => array(...)
  * @return string renderedData
  */
 public static function renderCObjectWithPlainArray($tsConfigValue)
 {
     if (!is_array($tsConfigValue) && array_key_exists('cObject', $tsConfigValue)) {
         return $tsConfigValue;
     }
     $tsArray = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertPlainArrayToTypoScriptArray($tsConfigValue);
     return Tx_PtExtbase_Div::getCobj()->cObjGetSingle($tsArray['cObject'], $tsArray['cObject.']);
 }
예제 #9
0
파일: Gallery.php 프로젝트: kabarakh/yag
 /**
  * Returns an album designated as thumbnail for this gallery
  * If the album thumb was marked as hidden, return the first not hidden album
  *
  * @return Tx_Yag_Domain_Model_Album Thumbnail album for gallery
  */
 public function getThumbAlbum()
 {
     $album = Tx_PtExtbase_Div::getLazyLoadedObject($this->thumbAlbum);
     if (!$album instanceof Tx_Yag_Domain_Model_Album) {
         if ($this->albums->count() > 0) {
             $album = $this->albums->current();
         }
     }
     return $album;
 }
예제 #10
0
파일: Album.php 프로젝트: kabarakh/yag
 /**
  * Getter for thumb
  *
  * @return Tx_Yag_Domain_Model_Item Holds thumbnail for this album
  */
 public function getThumb()
 {
     return Tx_PtExtbase_Div::getLazyLoadedObject($this->thumb);
 }
예제 #11
0
 /**
  * Test if value is an associative array
  * 
  * @param   mixed   $val    Value to be tested
  * @param   array   $info   Array of information
  * @throws  Tx_PtExtbase_Exception_Assertion   if assertion fails
  */
 public static function isAssociativeArray($val, array $info = array())
 {
     return self::test(Tx_PtExtbase_Div::isAssociativeArray($val), true, $info);
 }
예제 #12
0
 /**
  * Get the typoscript loaded on the current page
  *
  * @param $pid integer
  * @return array
  */
 protected function getTyposcriptSettings($pid)
 {
     $typoScript = Tx_PtExtbase_Div::returnTyposcriptSetup($pid, 'module.tx_yag.settings.');
     if (!is_array($typoScript) || empty($typoScript)) {
         $configuration = array('extensionName' => self::EXTENSION_NAME, 'pluginName' => self::PLUGIN_NAME, 'controller' => 'Backend', 'action' => 'settingsNotAvailable', 'switchableControllerActions' => array('Backend' => array('settingsNotAvailable')));
         echo $this->bootstrap->run('', $configuration);
         die;
     }
     return GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertTypoScriptArrayToPlainArray($typoScript);
 }
예제 #13
0
 /**
  * Build and return whereClause part with TYPO3 enablefields criterias
  * for all tables which are defined in backendConfig.tables and in TCA
  * 
  * @return string whereClause part with TYPO3 enablefields criterias
  */
 protected function getTypo3SpecialFieldsWhereClause()
 {
     $typo3Tables = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->backendConfiguration->getDataBackendSettings('tables'), true);
     $specialFieldsWhereClause = '';
     foreach ($typo3Tables as $typo3Table) {
         list($table, $alias) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(' ', $typo3Table, true);
         $alias = trim($alias);
         if (is_array($GLOBALS['TCA'][$table])) {
             $specialFieldsWhereClauseSnippet = Tx_PtExtbase_Div::getCobj()->enableFields($table);
             if ($alias) {
                 // Make sure not to replace parts of table names with wrong aliases! So check for ' ' to come before and '.' to come after
                 $specialFieldsWhereClauseSnippet = str_replace(' ' . $table . '.', ' ' . $alias . '.', $specialFieldsWhereClauseSnippet);
                 // Make sure not to replace parts of table names with wrong aliases! So check for '(' to come before and '.' to come after
                 $specialFieldsWhereClauseSnippet = str_replace('(' . $table . '.', '(' . $alias . '.', $specialFieldsWhereClauseSnippet);
                 // Make sure not to replace parts of table names with wrong aliases! So check for ',' to come before and '.' to come after
                 $specialFieldsWhereClauseSnippet = str_replace(',' . $table . '.', ',' . $alias . '.', $specialFieldsWhereClauseSnippet);
             }
             $specialFieldsWhereClause .= $specialFieldsWhereClauseSnippet;
         }
     }
     return $specialFieldsWhereClause;
 }
예제 #14
0
파일: Div.php 프로젝트: beyond-agentur/yag
 /**
  * @return mixed
  */
 protected function getVersionIndependableFileMounts()
 {
     if (Tx_PtExtbase_Div::isMinTypo3Version('6.0')) {
         $fileMounts = array();
         if ($GLOBALS['BE_USER']->user['admin'] == 1) {
             $fileMounts[]['path'] = $this->getT3BasePath() . 'fileadmin/';
         }
         $fileStorages = $GLOBALS['BE_USER']->getFileStorages();
         foreach ($fileStorages as $fileStorage) {
             /** @var TYPO3\CMS\Core\Resource\ResourceStorage $fileStorage */
             $configuration = $fileStorage->getConfiguration();
             $basePath = $configuration['basePath'];
             foreach ($fileStorage->getFileMounts() as $fileMount) {
                 $relativeFolder = substr($fileMount['path'], 0, 1) === '/' ? substr($fileMount['path'], 1) : $fileMount['path'];
                 $fileMounts[]['path'] = $this->getT3BasePath() . $basePath . $relativeFolder;
             }
         }
         return $fileMounts;
     } else {
         return $GLOBALS['FILEMOUNTS'];
     }
 }
예제 #15
0
파일: Div.php 프로젝트: punktde/pt_extbase
 /**
  * Filters the elements of a given ArrayAccess object for HTML output on web pages to prevent XSS attacks and similar hacks.
  * Should be used instead of htmlspecialchars() for any ArrayAccess object intended for output in FE plugins.
  *
  * IMPORTANT: since the object will be cloned internally, this method does not work for non-clonable objects (e.g. Singletons).
  * In this case you could implement the tx_pttools_iTemplateable interface to your object and sent the return of the getMarkerArray() method through Tx_PtExtbase_Div::htmlOutputArray.
  *
  * IMPORTANT: since the object will be cloned internally, this method does not work if the reference to this object is important to you
  * or any persistance manager or other fancy stuff you might use.
  *
  * IMPORTANT: ArrayAccess objects usually aren't Arrays for a reason. Applying this method on them (which btw will be applied automatically
  * when passing it to a pt_mvc view if not explicitely preventing this by setting the addItem's third parameter to false) will propably
  * mess your object up. So if you don't want to spend hours debugging strange side effects think twice _before_ you let your object pass this
  * method. Of course having all values htmlspecialchars'ed is always a good thing, but in case of objects it's not always a good idea to do this with
  * a hammer-style method like this one. Think of validating/sanitizing your values before passing it to the view (which is a good idea in any case -
  * and btw: ext:tcaobjects offers a nice and elegant solution to do this) or use Smarty's escape modifier to do this for the object's values when
  * really outputting them {$myObject.evilPropertyAccessedByArrayAccess|escape:"html"}
  *
  * Bye, and have a nice day, Fabrizio
  * (Why do I have the nagging feeling, that noone will ever read this comment?!)
  *
  * @param   ArrayAccess     object implementing the ArrayAccess interface containing property values to be filtered for output
  * @param   boolean         (optional) flag whether keys of eventually contained nested arrays should be filtered, too. See comment of $filterKeys in htmlOutputArray.
  * @return  ArrayAccess     cloned object (implementing the ArrayAccess interface) containing filtered property values
  * @see     Tx_PtExtbase_Div::htmlOutput()
  * @see     Tx_PtExtbase_Div::htmlOutputArray()
  * @author  Rainer Kuhn 
  */
 public static function htmlOutputArrayAccess(ArrayAccess $arrayObject, $filterNestedArrayKeys = 1)
 {
     // prevent endless recursion loop for nested objects
     static $loopCounter = 0;
     $loopCounter += 1;
     if ($loopCounter > 99) {
         throw new \PunktDe\PtExtbase\Exception\InternalException('Recursion break', 'Max. recursion depth of 99 exceeded in ' . __METHOD__);
     }
     $filteredObject = clone $arrayObject;
     foreach ($filteredObject as $key => $value) {
         // scalars: use default htmlOutput()
         if (is_scalar($value)) {
             $tmp = Tx_PtExtbase_Div::htmlOutput($value);
             // Write only back to property if something has changed. Writing properties in the ArrayAccess interface can be much much than setting a value...
             if (strcmp($tmp, $value) != 0) {
                 // unset the property first, because overwriting it can have side-effects on ArrayAccess objects (e.g. when checking if an item already exists in the collection)
                 unset($filteredObject[$key]);
                 $filteredObject[$key] = $tmp;
             }
             // arrays: use htmlOutputArray()
         } elseif (is_array($value)) {
             // unset the property first, because overwriting it can have side-effects on ArrayAccess objects (e.g. when checking if an item already exists in the collection)
             unset($filteredObject[$key]);
             $filteredObject[$key] = Tx_PtExtbase_Div::htmlOutputArray($value, $filterNestedArrayKeys);
             // objects implementing the ArrayAccess interface: recursive function call
         } elseif ($value instanceof ArrayAccess) {
             // unset the property first, because overwriting it can have side-effects on ArrayAccess objects (e.g. when checking if an item already exists in the collection)
             unset($filteredObject[$key]);
             $filteredObject[$key] = Tx_PtExtbase_Div::htmlOutputArrayAccess($value, $filterNestedArrayKeys);
             // NULL: keep NULL as filtered value
         } elseif (is_null($value)) {
             // unset the property first, because overwriting it can have side-effects on ArrayAccess objects (e.g. when checking if an item already exists in the collection)
             unset($filteredObject[$key]);
             $filteredObject[$key] = null;
             // all other values (including non-ArrayAccess objects): set filtered value to empty string
         } else {
             // unset the property first, because overwriting it can have side-effects on ArrayAccess objects (e.g. when checking if an item already exists in the collection)
             unset($filteredObject[$key]);
             $filteredObject[$key] = '';
             if (TYPO3_DLOG) {
                 GeneralUtility::devLog(__METHOD__ . '(): unfilterable ArrayAccess object property "' . $key . '" has been converted to empty string', 'pt_tools', 2, array('original value' => $value));
             }
         }
     }
     return $filteredObject;
 }
예제 #16
0
 /**
  * @param string $extensionKey
  * @return array
  */
 protected function loadExtensionSettings($extensionKey)
 {
     $settings = \Tx_PtExtbase_Div::returnExtConfArray($extensionKey);
     return $settings;
 }
예제 #17
0
파일: Item.php 프로젝트: beyond-agentur/yag
 /**
  * Getter for itemMeta
  *
  * @return Tx_Yag_Domain_Model_ItemMeta Holds meta data for item
  */
 public function getItemMeta()
 {
     Tx_PtExtbase_Div::getLazyLoadedObject($this->itemMeta);
     if (!$this->itemMeta instanceof Tx_Yag_Domain_Model_ItemMeta) {
         $this->itemMeta = $this->objectManager->get('Tx_Yag_Domain_Model_ItemMeta');
     }
     return $this->itemMeta;
 }
예제 #18
0
 /**
  * Build and return whereclause part with TYPO3 enablefields criterias
  * for all tables which are defined in backendConfig.tables and in TCA
  *
  * @param array $typo3Tables
  * @return string whereclause part with TYPO3 enablefields criterias
  */
 protected function getTypo3SpecialFieldsWhereClause(array $typo3Tables)
 {
     $specialFieldsWhereClause = '';
     foreach ($typo3Tables as $typo3Table) {
         if (is_array($GLOBALS['TCA'][$typo3Table])) {
             $specialFieldsWhereClause .= Tx_PtExtbase_Div::getCobj()->enableFields($typo3Table);
         }
     }
     return $specialFieldsWhereClause;
 }
예제 #19
0
 /**
  * Get Typoscript for defined listIdentifier
  *
  * @param string $listIdentifier
  * @param array $customTSArray custom ts array
  * @throws Exception
  * @return array
  */
 protected static function getExtListTyposcriptSettings($listIdentifier, $customTSArray = null)
 {
     $extListTS = Tx_PtExtbase_Div::getTS('plugin.tx_ptextlist.settings.');
     $extListTSArray = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\TypoScriptService')->convertTypoScriptArrayToPlainArray($extListTS);
     if (!is_array($extListTSArray['listConfig'])) {
         $extListTSArray['listConfig'] = array();
     }
     if (is_array($customTSArray)) {
         \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($extListTSArray['listConfig'], array($listIdentifier => $customTSArray));
     }
     if (!array_key_exists($listIdentifier, $extListTSArray['listConfig'])) {
         throw new Exception('No listconfig with listIdentifier ' . $listIdentifier . ' defined on this page! 1284655053');
     }
     $extListTSArray['listIdentifier'] = $listIdentifier;
     return $extListTSArray;
 }