Exemplo n.º 1
0
 /**
  * Find FileReference objects by relation to other records
  *
  * @param int $uid The UID of the related record (needs to be the localized uid, as translated IRRE elements relate to them)
  * @param string $as The alias to use for the found files
  * @param string $tableName Table name of the related record
  * @param string $fieldName Field name of the related record
  *
  * @return string The render template
  */
 public function render($uid, $as = 'objects', $tableName = 'tt_content', $fieldName = 'image')
 {
     $filesFromRepository = $this->fileRepository->findByRelation($tableName, $fieldName, $uid);
     $this->templateVariableContainer->add($as, $filesFromRepository);
     $content = $this->renderChildren();
     $this->templateVariableContainer->remove($as);
     return $content;
 }
Exemplo n.º 2
0
 /**
  * @return void
  */
 public function initializeAction()
 {
     $this->fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
     $this->contentObj = $this->configurationManager->getContentObject();
     $this->data = $this->contentObj->data;
     $this->data['image'] = $this->fileRepository->findByRelation('tt_content', 'image', $this->data['uid']);
     $this->data['imagesvg'] = $this->fileRepository->findByRelation('tt_content', 'imagesvg', $this->data['uid']);
 }
 /**
  * @param array $data
  * @param string $as
  * @param string $table
  * @param string $field
  *
  * @return string
  */
 public function render($data, $as = "items", $table = "tt_content", $field = "image")
 {
     if (is_array($data) && $data['uid'] && $data[$field]) {
         $this->fileRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
         $items = $this->fileRepository->findByRelation($table, $field, $data['uid']);
     } else {
         $items = null;
     }
     $this->templateVariableContainer->add($as, $items);
     $content = $this->renderChildren();
     $this->templateVariableContainer->remove($as);
     return $content;
 }
 /**
  * @param int $uid
  * @param int $cField
  * @param string $as
  * @param string $table
  * @param string $field
  *
  * @return string
  */
 public function render($uid, $cField, $as = 'items', $table = 'tt_content', $field = 'image')
 {
     #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(array("FalViewHelper"=>array( "uid"=>$uid,  "cField"=>$cField)));
     if ($uid && $cField) {
         $this->fileRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\FileRepository');
         $items = $this->fileRepository->findByRelation($table, $field, $uid);
         #\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump(array("FalViewHelper"=>array( "uid"=>$uid,  "cField"=>$cField, "items"=>$items)));
     } else {
         $items = NULL;
     }
     $this->templateVariableContainer->add($as, $items);
     $content = $this->renderChildren();
     $this->templateVariableContainer->remove($as);
     return $content;
 }
 /**
  * Base view
  */
 public function indexAction()
 {
     if (!$this->settings['file']) {
         throw new \Exception('You have to select a valid FAL reference file', 12372183723.0);
     }
     $images = $this->fileRepository->findByRelation('tt_content', 'pdf', $this->configurationManager->getContentObject()->data['uid']);
     if (!sizeof($images)) {
         throw new \Exception('You have to select a valid FAL reference file', 12372183723.0);
     }
     /** @var FileReference $image */
     $image = current($images);
     $width = MathUtility::canBeInterpretedAsInteger($this->settings['width']) ? $this->settings['width'] . 'px' : $this->settings['width'];
     $height = MathUtility::canBeInterpretedAsInteger($this->settings['height']) ? $this->settings['height'] . 'px' : $this->settings['height'];
     $fileUrl = GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST') . '/' . $image->getPublicUrl();
     $this->view->assignMultiple(array('fileUrl' => urlencode($fileUrl), 'language' => $GLOBALS['TSFE']->config['config']['language'], 'width' => $width, 'height' => $height));
 }
Exemplo n.º 6
0
 /**
  * Fetch a fileReference from the file repository
  *
  * @param string $table name of the table to get the file reference for
  * @param string $field name of the field referencing a file
  * @param integer $uid uid of the related record
  * @return array
  */
 protected function getFileReferences($table, $field, $uid)
 {
     $fileObjects = $this->fileRepository->findByRelation($table, $field, $uid);
     return $fileObjects;
 }
Exemplo n.º 7
0
 /**
  * Test action
  *
  * @plugin Test
  */
 public function testAction()
 {
     $contentElement = $this->configurationManager->getContentObject()->data;
     $fileReferences = $this->fileRepository->findByRelation('tt_content', 'image', $contentElement['uid']);
     $this->view->assignMultiple(array('fileReferences' => $fileReferences, 'customRatio' => $contentElement['image_ratio']));
 }
Exemplo n.º 8
0
 /**
  * @param \TYPO3\CMS\Core\Resource\FileRepository $fileRepository
  * @param int $pageId
  * @return array
  * @deprecated will be removed if no occurences from nkwsubmenu are found
  */
 protected function getFilesFromNkwMenu($fileRepository, $pageId)
 {
     \TYPO3\CMS\Core\Utility\GeneralUtility::logDeprecatedFunction();
     return $fileRepository->findByRelation('pages', 'tx_nkwsubmenu_picture', $pageId);
 }