Exemple #1
0
 /**
  * Default implementation for use in compiled templates
  *
  * @param array $arguments
  * @param \Closure $renderChildrenClosure
  * @param RenderingContextInterface $renderingContext
  * @return mixed
  */
 public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
 {
     if (self::$configurationService === NULL || self::$configurationManager === NULL || self::$recordService === NULL) {
         $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
         if (self::$configurationService === NULL) {
             self::$configurationService = $objectManager->get('FluidTYPO3\\Flux\\Service\\FluxService');
         }
         if (self::$configurationManager === NULL) {
             self::$configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManagerInterface');
         }
         if (self::$recordService === NULL) {
             self::$recordService = $objectManager->get('FluidTYPO3\\Flux\\Service\\WorkspacesAwareRecordService');
         }
     }
     $templateVariableContainer = $renderingContext->getTemplateVariableContainer();
     $loadRegister = FALSE;
     if (empty($arguments['loadRegister']) === FALSE) {
         self::$configurationManager->getContentObject()->cObjGetSingle('LOAD_REGISTER', $arguments['loadRegister']);
         $loadRegister = TRUE;
     }
     $record = $templateVariableContainer->get('record');
     $id = $record['uid'];
     $order = $arguments['order'];
     $area = $arguments['area'];
     $limit = $arguments['limit'] ? $arguments['limit'] : 99999;
     $offset = intval($arguments['offset']);
     $sortDirection = $arguments['sortDirection'];
     $order .= ' ' . $sortDirection;
     // Always use the $record['uid'] when fetching child rows, and fetch everything with same parent and column.
     // The RECORDS function called in getRenderedRecords will handle overlay, access restrictions, time etc.
     // Depending on the TYPO3 setting config.sys_language_overlay, the $record could be either one of the localized version or default version.
     $conditions = "(tx_flux_parent = '" . $id . "' AND tx_flux_column = '" . $area . "' AND pid = '" . $record['pid'] . "')" . $GLOBALS['TSFE']->cObj->enableFields('tt_content');
     $rows = self::$recordService->get('tt_content', '*', $conditions, '', $order, $offset . ',' . $limit);
     $elements = FALSE === (bool) $arguments['render'] ? $rows : self::getRenderedRecords($rows);
     if (TRUE === empty($arguments['as'])) {
         $content = $elements;
     } else {
         $as = $arguments['as'];
         if (TRUE === $templateVariableContainer->exists($as)) {
             $backup = $templateVariableContainer->get($as);
             $templateVariableContainer->remove($as);
         }
         $templateVariableContainer->add($as, $elements);
         $content = $renderChildrenClosure();
         $templateVariableContainer->remove($as);
         if (TRUE === isset($backup)) {
             $templateVariableContainer->add($as, $backup);
         }
     }
     if ($loadRegister) {
         self::$configurationManager->getContentObject()->cObjGetSingle('RESTORE_REGISTER', '');
     }
     return $content;
 }
Exemple #2
0
 /**
  * Render
  *
  * @return mixed
  */
 public function render()
 {
     $loadRegister = FALSE;
     if (empty($this->arguments['loadRegister']) === FALSE) {
         $this->configurationManager->getContentObject()->cObjGetSingle('LOAD_REGISTER', $this->arguments['loadRegister']);
         $loadRegister = TRUE;
     }
     $record = $this->templateVariableContainer->get('record');
     $id = $record['uid'];
     $order = $this->arguments['order'];
     $area = $this->arguments['area'];
     $limit = $this->arguments['limit'] ? $this->arguments['limit'] : 99999;
     $offset = intval($this->arguments['offset']);
     $sortDirection = $this->arguments['sortDirection'];
     $order .= ' ' . $sortDirection;
     // Always use the $record['uid'] when fetching child rows, and fetch everything with same parent and column.
     // The RECORDS function called in getRenderedRecords will handle overlay, access restrictions, time etc.
     // Depending on the TYPO3 setting config.sys_language_overlay, the $record could be either one of the localized version or default version.
     $conditions = "(tx_flux_parent = '" . $id . "' AND tx_flux_column = '" . $area . "' AND pid = '" . $record['pid'] . "')" . $GLOBALS['TSFE']->cObj->enableFields('tt_content');
     $rows = $this->recordService->get('tt_content', '*', $conditions, '', $order, $offset . ',' . $limit);
     $elements = FALSE === (bool) $this->arguments['render'] ? $rows : $this->getRenderedRecords($rows);
     if (TRUE === empty($this->arguments['as'])) {
         $content = $elements;
     } else {
         $as = $this->arguments['as'];
         if (TRUE === $this->templateVariableContainer->exists($as)) {
             $backup = $this->templateVariableContainer->get($as);
             $this->templateVariableContainer->remove($as);
         }
         $this->templateVariableContainer->add($as, $elements);
         $content = $this->renderChildren();
         $this->templateVariableContainer->remove($as);
         if (TRUE === isset($backup)) {
             $this->templateVariableContainer->add($as, $backup);
         }
     }
     if ($loadRegister) {
         $this->configurationManager->getContentObject()->cObjGetSingle('RESTORE_REGISTER', '');
     }
     return $content;
 }
Exemple #3
0
 /**
  * Returns the page record with localisation applied, if any
  * exists in database.
  *
  * @return array
  */
 protected function getPageValues()
 {
     $record = $GLOBALS['TSFE']->page;
     if ($GLOBALS['TSFE']->sys_language_uid != 0) {
         $localisation = $this->recordService->get('pages_language_overlay', '*', 'pid = "' . $record['uid'] . '" AND sys_language_uid = "' . $GLOBALS['TSFE']->sys_language_uid . '"');
     }
     if (FALSE === empty($localisation)) {
         $record = RecursiveArrayUtility::merge($record, reset($localisation));
     }
     return $record;
 }
 /**
  * @param integer $parentUid
  * @return array|NULL
  */
 protected function loadRecordsFromDatabase($parentUid)
 {
     $parentUid = (int) $parentUid;
     return $this->workspacesAwareRecordService->get('tt_content', '*', "tx_flux_parent = '" . $parentUid . "'");
 }
Exemple #5
0
 /**
  * Returns the page record with localisation applied, if any
  * exists in database. Maintains uid and pid of the original
  * page if localisation is applied.
  *
  * @return array
  */
 protected function getPageValues()
 {
     $record = $GLOBALS['TSFE']->page;
     if ($GLOBALS['TSFE']->sys_language_uid != 0) {
         $localisation = $this->recordService->get('pages_language_overlay', '*', 'pid = "' . $record['uid'] . '" AND sys_language_uid = "' . $GLOBALS['TSFE']->sys_language_uid . '"' . ' AND hidden = false' . ' AND deleted = false' . ' AND (starttime = 0 OR starttime <= UNIX_TIMESTAMP())' . ' AND (endtime = 0 OR endtime > UNIX_TIMESTAMP())');
     }
     if (FALSE === empty($localisation)) {
         $mergedRecord = RecursiveArrayUtility::merge($record, reset($localisation));
         if (isset($record['uid']) && isset($record['pid'])) {
             $mergedRecord['uid'] = $record['uid'];
             $mergedRecord['pid'] = $record['pid'];
         }
         return $mergedRecord;
     }
     return $record;
 }
Exemple #6
0
 /**
  * Returns the page record with localisation applied, if any
  * exists in database.
  *
  * @return array
  */
 protected function getPageValues()
 {
     $record = $GLOBALS['TSFE']->page;
     $localisation = $this->recordService->get('pages_language_overlay', '*', "pid = '" . $record['uid'] . "'");
     if (FALSE === empty($localisation)) {
         $record = RecursiveArrayUtility::merge($record, reset($localisation));
     }
     return $record;
 }