/** @test */
 public function storingDataInEmptyArrayByNamespaceSetsData()
 {
     $testArray = array();
     $testArray = Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree('key1.key2.key3', $testArray, 'test2');
     $refArray['key1']['key2']['key3'] = 'test2';
     $this->assertEquals($testArray, $refArray);
 }
Пример #2
0
 /**
  * Renders link for an album
  *
  * @param Tx_Yag_Domain_Model_Album $album Album object to render link for
  * @param Tx_Yag_Domain_Model_Gallery $gallery Gallery object to render link for
  * @param integer $pageUid
  * @param integer $pageType type of the target page. See typolink.parameter
  * @param integer $pageType type of the target page. See typolink.parameter
  * @param boolean $noCache set this to disable caching for the target page. You should not need this.
  * @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this.
  * @param string $section the anchor to be added to the URI
  * @param string $format The requested format, e.g. ".html"
  * @return string Rendered link for album
  * @throws Exception
  */
 public function render(Tx_Yag_Domain_Model_Album $album = null, Tx_Yag_Domain_Model_Gallery $gallery = null, $pageUid = null, $pageType = 0, $noCache = false, $noCacheHash = false, $section = '', $format = '')
 {
     // TODO implement gallery download
     if ($album instanceof Tx_Yag_Domain_Model_Album) {
         $namespace = Tx_Yag_Domain_Context_YagContextFactory::getInstance()->getObjectNamespace() . '.albumUid';
         $arguments = Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($namespace, array(), $album->getUid());
     }
     Tx_PtExtbase_State_Session_SessionPersistenceManagerFactory::getInstance()->addSessionRelatedArguments($arguments);
     return parent::render('downloadAsZip', $arguments, 'ItemList', null, null, $pageUid, $pageType, $noCache, $noCacheHash, $section, $format);
 }
Пример #3
0
 /**
  * Renders link for an album
  *
  * @param int $galleryUid UID of album to render link for
  * @param \Tx_Yag_Domain_Model_Gallery $gallery Album object to render link for
  * @param int $pageUid (Optional) ID of page to render link for. If null, current page is used
  * @param int $pageType
  * @param bool $noCache
  * @param bool $noCacheHash
  * @param string $section
  * @param string $format
  * @throws Exception
  * @return string Rendered link for gallery
  *
  */
 public function render($galleryUid = null, \Tx_Yag_Domain_Model_Gallery $gallery = null, $pageUid = null, $pageType = 0, $noCache = false, $noCacheHash = false, $section = '', $format = '')
 {
     if ($galleryUid === null && $gallery === null) {
         throw new Exception('You have to set "galleryUid" or "gallery" as parameter. Both parameters can not be empty when using galleryLinkViewHelper', 1295575455);
     }
     if ($galleryUid === null) {
         $galleryUid = $gallery->getUid();
     }
     $namespace = \Tx_Yag_Domain_Context_YagContextFactory::getInstance()->getObjectNamespace() . '.galleryUid';
     $arguments = \Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($namespace, array(), $galleryUid);
     return parent::render('index', $arguments, 'Gallery', null, null, $pageUid, $pageType, $noCache, $noCacheHash, $section, $format);
 }
Пример #4
0
 /**
  * Renders the link to an image
  *
  * @param array $arguments Arguments
  * @param integer $pageUid target page. See TypoLink destination
  * @param integer $pageType type of the target page. See typolink.parameter
  * @param boolean $noCache set this to disable caching for the target page. You should not need this.
  * @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this.
  * @param string $section the anchor to be added to the URI
  * @param string $format The requested format, e.g. ".html"
  * @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
  * @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments)
  * @param boolean $absolute If set, the URI of the rendered link is absolute
  * @param boolean $addQueryString If set, the current query parameters will be kept in the URI
  * @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
  * @return string Rendered link
  */
 public function render($pageUid = null, $pageType = 0, array $arguments = array(), $noCache = false, $noCacheHash = false, $section = '', $format = '', $linkAccessRestrictedPages = false, array $additionalParams = array(), $absolute = false, $addQueryString = false, array $argumentsToBeExcludedFromQueryString = array())
 {
     $objectNameSpace = $namespace = Tx_Yag_Domain_Context_YagContextFactory::getInstance()->getObjectNamespace();
     $arguments = array();
     if (isset($this->arguments['album'])) {
         $albumUid = $this->arguments['album']->getUid();
         $arguments = Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($objectNameSpace . '.albumUid', $arguments, $albumUid);
     }
     if (isset($this->arguments['gallery'])) {
         $galleryUid = $this->arguments['gallery']->getUid();
         $arguments = Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($objectNameSpace . '.galleryUid', $arguments, $galleryUid);
     }
     Tx_PtExtbase_State_Session_SessionPersistenceManagerFactory::getInstance()->addSessionRelatedArguments($arguments);
     return parent::render('show', $arguments, 'Item', null, null, $pageUid, $pageType, $noCache, $noCacheHash, $section, $format, $linkAccessRestrictedPages, $additionalParams, $absolute, $addQueryString, $argumentsToBeExcludedFromQueryString);
 }
Пример #5
0
 /**
  * Renders link for an album
  *
  * @param integer $albumUid UID of album to render link for
  * @param Tx_Yag_Domain_Model_Album $album Album object to render link for
  * @param Tx_Yag_Domain_Model_Gallery $gallery Gallery object to render link for
  * @param integer pageUid (Optional) ID of page to render link for. If null, current page is used
  * @param integer $pageType type of the target page. See typolink.parameter
  * @param integer $pageType type of the target page. See typolink.parameter
  * @param boolean $noCache set this to disable caching for the target page. You should not need this.
  * @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this.
  * @param string $section the anchor to be added to the URI
  * @param string $format The requested format, e.g. ".html"
  * @return string Rendered link for album
  * @throws Exception
  */
 public function render($albumUid = 0, Tx_Yag_Domain_Model_Album $album = NULL, Tx_Yag_Domain_Model_Gallery $gallery = NULL, $pageUid = NULL, $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $format = '')
 {
     if ($albumUid == 0 && $album === NULL) {
         throw new Exception('You have to set "albumUid" or "album" as parameter. Both parameters can not be empty when using albumLinkViewHelper', 1295575454);
     }
     if ($albumUid == 0) {
         $albumUid = $album->getUid();
     }
     $baseNamespace = Tx_Yag_Domain_Context_YagContextFactory::getInstance()->getObjectNamespace();
     $arguments = Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($baseNamespace . '.albumUid', array(), $albumUid);
     if ($gallery !== NULL) {
         $arguments = Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($baseNamespace . '.galleryUid', $arguments, $gallery->getUid());
     }
     return parent::render('submitFilter', $arguments, 'ItemList', NULL, NULL, $pageUid, $pageType, $noCache, $noCacheHash, $section, $format);
 }
Пример #6
0
 /**
  * Get an argument array out of a string
  * 
  * @param string $argumentString
  * @return array
  */
 public function getArgumentArray($argumentString)
 {
     $argumentArray = array();
     $argumentChunks = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $argumentString);
     foreach ($argumentChunks as $argument) {
         if (strstr($argument, ':')) {
             list($key, $value) = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(':', $argument);
             $argumentArray = Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($key, $argumentArray, $value);
         } else {
             $key = $argument;
             $argumentArray[$key] = false;
         }
     }
     return $argumentArray;
 }
 /**
  * Persists a given object to session
  *
  * @param Tx_PtExtbase_State_Session_SessionPersistableInterface $object
  * @throws Exception if session hash has been already calculated and session data has changed
  */
 public function persistToSession(Tx_PtExtbase_State_Session_SessionPersistableInterface $object)
 {
     $sessionNamespace = $object->getObjectNamespace();
     if ($this->sessionAdapaterClass == self::STORAGE_ADAPTER_DB && $this->sessionHash != null && $this->sessionHash != md5(serialize($this->sessionData))) {
         throw new Exception('Session Hash already calculated and current sessiondata changed!! 1293004344' . $sessionNamespace . ': Calc:' . $this->sessionHash . ' NEW: ' . md5(serialize($this->sessionData)));
     }
     Tx_PtExtbase_Assertions_Assert::isNotEmptyString($sessionNamespace, array('message' => 'Object namespace must not be empty! 1278436822'));
     $objectData = $object->_persistToSession();
     if ($this->sessionData == null) {
         $this->sessionData = array();
     }
     if ($objectData) {
         $this->sessionData = Tx_PtExtbase_Utility_NameSpace::saveDataInNamespaceTree($sessionNamespace, $this->sessionData, $objectData);
     }
     // Remove session values, if object data is null or empty array
     if ($objectData === null || count($objectData) == 0) {
         $this->sessionData = Tx_PtExtbase_Utility_NameSpace::removeDataFromNamespaceTree($sessionNamespace, $this->sessionData);
     }
 }