Example #1
0
 /**
  * Initializes PID detector
  */
 protected function initPidDetector()
 {
     if ($this->respectPidDetector) {
         $PIDs = $this->pidDetector->getPids();
         if (!$PIDs) {
             // throw new Exception('It was not possible to determine any page IDs to get records from. Please configure your plugin correctly.', 1331382978);
         }
         if ($this->defaultQuerySettings === NULL) {
             $this->defaultQuerySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
         }
         $this->defaultQuerySettings->setRespectStoragePage(TRUE);
         $this->defaultQuerySettings->setStoragePageIds($PIDs);
     }
 }
Example #2
0
 /**
  * @return mixed
  */
 protected function getPages()
 {
     $pathInfo = new PathInfo();
     if (!array_key_exists('/', $this->yagDirectoryCache)) {
         $this->yagDirectoryCache['/'] = array();
         $pageRecordList = $this->pidDetector->getPageRecords();
         foreach ($pageRecordList as $pageRecord) {
             $pathInfo->setDisplayName($pageRecord['title'])->setPid($pageRecord['uid'])->setPathType(PathInfo::INFO_PID);
             $this->yagDirectoryCache['/'][$pageRecord['uid']] = array('ctime' => $pageRecord['crdate'], 'mtime' => $pageRecord['tstamp'], 'name' => $pageRecord['title'] . ' |' . $pageRecord['uid'], 'identifier' => $pageRecord['title'] . ' |' . $pageRecord['uid'], 'storage' => $this->storage->getUid());
             $this->yagDirectoryPathCache['/' . $pageRecord['uid']] = true;
         }
     }
     return $this->yagDirectoryCache['/'];
 }
Example #3
0
 /**
  * Determine the storage page ID for a given NEW record
  *
  * This does the following:
  * - If there is a TypoScript configuration "classes.CLASSNAME.newRecordStoragePid", that is used to store new records.
  * - If there is no such TypoScript configuration, it uses the first value of The "storagePid" taken for reading records.
  *
  * @param \TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object
  * @return int the storage Page ID where the object should be stored
  */
 protected function determineStoragePageIdForNewRecord(\TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface $object = null)
 {
     $pids = null;
     /**
      * What happens here?
      *
      * We globally overwrite implementation of backend class (this class).
      * This means that all other Extbase plugins that are probably inserted on the
      * same page would also use this backend class.
      *
      * So we give the yag domain models an interface which we check here and use
      * pid detection only, if we get a new objecte that implements this interface.
      * All other objects will be handled the default way.
      */
     if (is_a($object, 'Tx_Yag_Domain_Model_DomainModelInterface')) {
         $pids = $this->pidDetector->getPids();
     }
     if (!empty($pids) && count($pids) > 0) {
         return $pids[0] == -1 ? 0 : $pids[0];
     } else {
         return parent::determineStoragePageIdForNewRecord($object);
     }
 }
Example #4
0
 /**
  * Render a source selector to select gallery / album / item at once
  *
  * @param array $PA
  * @param t3lib_TCEforms $fobj
  *
  * @return string
  */
 public function renderSourceSelector(&$PA, &$fobj)
 {
     $this->determineCurrentPID($PA['row']['pid']);
     $this->init();
     $PA['elementID'] = 'field_' . md5($PA['itemFormElID']);
     $template = GeneralUtility::getFileAbsFileName('EXT:yag/Resources/Private/Templates/Backend/FlexForm/FlexFormSource.html');
     $renderer = $this->getFluidRenderer();
     $renderer->setTemplatePathAndFilename($template);
     /* @var $galleryRepository Tx_Yag_Domain_Repository_GalleryRepository */
     $galleryRepository = $this->objectManager->get('Tx_Yag_Domain_Repository_GalleryRepository');
     $galleries = $galleryRepository->findAll();
     $pages = $this->pidDetector->getPageRecords();
     $renderer->assign('galleries', $galleries);
     $renderer->assign('PA', $PA);
     $renderer->assign('pages', $pages);
     $content = $renderer->render();
     $this->extbaseShutdown();
     return $content;
 }
Example #5
0
 /** @test */
 public function getCurrentPageIsYagPageThrowsExceptionIfNotInBeMode()
 {
     $pidDetector = new Tx_Yag_Utility_PidDetector(Tx_Yag_Utility_PidDetector::FE_MODE);
     try {
         $pidDetector->getCurrentPageIsYagPage();
     } catch (Exception $e) {
         return;
     }
     $this->fail("No exception has been thrown when trying to call Tx_Yag_Utility_PidDetector::getCurrentPageIsYagPage in non-backend mode.");
 }
 /**
  * Initializes the view before invoking an action method.
  *
  * Override this method to solve assign variables common for all actions
  * or prepare the view in another way before the action is called.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view to be initialized
  * @return void
  * @api
  */
 protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     if (method_exists($view, 'injectConfigurationBuilder')) {
         $view->setConfigurationBuilder($this->configurationBuilder);
     }
     $this->setCustomPathsInView($view);
     if ($this->yagContext !== null) {
         $this->yagContext->injectControllerContext($this->controllerContext);
     }
     $this->view->assign('config', $this->configurationBuilder);
     $this->view->assign('yagContext', $this->yagContext);
     $this->view->assign('currentPid', current($this->pidDetector->getPids()));
 }