/**
  * Handler for unknown types.
  *
  * @return array As defined in initializeResultArray() of AbstractNode
  */
 public function render()
 {
     $resultArray = $this->initializeResultArray();
     $languageService = $this->getLanguageService();
     $row = $this->data['databaseRow'];
     $parameterArray = $this->data['parameterArray'];
     // If ratios are set do not add default options
     if (isset($parameterArray['fieldConf']['config']['ratios'])) {
         unset($this->defaultConfig['ratios']);
     }
     $config = ArrayUtility::arrayMergeRecursiveOverrule($this->defaultConfig, $parameterArray['fieldConf']['config']);
     // By default we allow all image extensions that can be handled by the GFX functionality
     if ($config['allowedExtensions'] === null) {
         $config['allowedExtensions'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
     }
     if ($config['readOnly']) {
         $options = array();
         $options['parameterArray'] = array('fieldConf' => array('config' => $config), 'itemFormElValue' => $parameterArray['itemFormElValue']);
         $options['renderType'] = 'none';
         return $this->nodeFactory->create($options)->render();
     }
     $file = $this->getFile($row, $config['file_field']);
     if (!$file) {
         return $resultArray;
     }
     $content = '';
     $preview = '';
     if (GeneralUtility::inList(mb_strtolower($config['allowedExtensions']), mb_strtolower($file->getExtension()))) {
         // Get preview
         $preview = $this->getPreview($file, $parameterArray['itemFormElValue']);
         // Check if ratio labels hold translation strings
         foreach ((array) $config['ratios'] as $ratio => $label) {
             $config['ratios'][$ratio] = $languageService->sL($label, true);
         }
         $formFieldId = StringUtility::getUniqueId('formengine-image-manipulation-');
         $wizardData = array('zoom' => $config['enableZoom'] ? '1' : '0', 'ratios' => json_encode($config['ratios']), 'file' => $file->getUid());
         $wizardData['token'] = GeneralUtility::hmac(implode('|', $wizardData), 'ImageManipulationWizard');
         $buttonAttributes = array('data-url' => BackendUtility::getAjaxUrl('wizard_image_manipulation', $wizardData), 'data-severity' => 'notice', 'data-image-name' => $file->getNameWithoutExtension(), 'data-image-uid' => $file->getUid(), 'data-file-field' => $config['file_field'], 'data-field' => $formFieldId);
         $button = '<button class="btn btn-default t3js-image-manipulation-trigger"';
         foreach ($buttonAttributes as $key => $value) {
             $button .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
         }
         $button .= '><span class="t3-icon fa fa-crop"></span>';
         $button .= $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.open-editor', true);
         $button .= '</button>';
         $inputField = '<input type="hidden" ' . 'id="' . $formFieldId . '" ' . 'name="' . $parameterArray['itemFormElName'] . '" ' . 'value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
         $content .= $inputField . $button;
         $content .= $this->getImageManipulationInfoTable($parameterArray['itemFormElValue']);
         $resultArray['requireJsModules'][] = array('TYPO3/CMS/Backend/ImageManipulation' => 'function(ImageManipulation){ImageManipulation.initializeTrigger()}');
     }
     $content .= '<p class="text-muted"><em>' . $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.supported-types-message', true) . '<br />';
     $content .= mb_strtoupper(implode(', ', GeneralUtility::trimExplode(',', $config['allowedExtensions'])));
     $content .= '</em></p>';
     $item = '<div class="media">';
     $item .= $preview;
     $item .= '<div class="media-body">' . $content . '</div>';
     $item .= '</div>';
     $resultArray['html'] = $item;
     return $resultArray;
 }
 /**
  * action show
  *
  * @return void
  */
 public function showAction()
 {
     // define some variables
     $recursive = (int) $this->settings['recursive'] < 10 ? (int) $this->settings['recursive'] : 10;
     // try to get all root-page-uids
     if ($this->settings['pages']) {
         $rootpageUids = \TYPO3\CMS\Extbase\Utility\ArrayUtility::integerExplode(",", $this->settings['pages']);
     } else {
         $rootpageUids = array($GLOBALS['TSFE']->id);
     }
     switch ($this->settings['layout']) {
         case "overview_from_directory":
         case "overview_from_directory_small":
             $queryGenerator = $this->objectManager->get('TYPO3\\CMS\\Core\\Database\\QueryGenerator');
             $pagesArr = array();
             $i = 0;
             foreach ($rootpageUids as $rootpageUid) {
                 $pageUidStr = $queryGenerator->getTreeList($rootpageUid, $recursive, 0, " doktype IN (1,2,3,4)");
                 if ($pageUidStr) {
                     $pagesArr = array_merge($pagesArr, \TYPO3\CMS\Extbase\Utility\ArrayUtility::integerExplode(",", $pageUidStr));
                 }
                 // remove rootpageUid
                 foreach (array_keys($pagesArr, $rootpageUid, false) as $key) {
                     unset($pagesArr[$key]);
                 }
             }
             // find the pages
             $pages = $this->pageRepository->findByUidArray(array_unique($pagesArr), "sorting");
             $this->view->assign("pages", $pages);
             $this->view->assign("current", $GLOBALS['TSFE']->id);
             return $this->view->render();
             break;
     }
     return "";
 }
 /**
  * Creates a new configuration object.
  *
  * @return MW_Config_Interface Configuration object
  */
 protected function getConfig()
 {
     $settings = (array) $this->settings;
     if (isset($this->settings['typo3']['tsconfig'])) {
         $tsconfig = Base::parseTS($this->settings['typo3']['tsconfig']);
         $settings = \TYPO3\CMS\Extbase\Utility\ArrayUtility::arrayMergeRecursiveOverrule($settings, $tsconfig);
     }
     return Base::getConfig($settings);
 }
Beispiel #4
0
 /**
  * Merges setup and flexform settings.
  * @param  array  $settings [description]
  * @return void
  */
 public function mergeSettings(array $settings)
 {
     if (isset($settings['setup']) && is_array($settings['setup'])) {
         $this->array = \TYPO3\CMS\Extbase\Utility\ArrayUtility::arrayMergeRecursiveOverrule($this->array, $settings['setup'], FALSE, FALSE);
     }
     if (isset($settings['flexform']) && is_array($settings['flexform'])) {
         $this->array = \TYPO3\CMS\Extbase\Utility\ArrayUtility::arrayMergeRecursiveOverrule($this->array, $settings['flexform'], FALSE, FALSE);
     }
 }
 /**
  * Constructs a new Repository
  *
  * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
  */
 public function __construct(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager)
 {
     $this->cicbaseConfiguration = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['cicbase']);
     $overrides = Arr::safePath($GLOBALS, 'TYPO3_CONF_VARS.EXTCONF.cicbase.document.awsConfs');
     if ($overrides) {
         $this->cicbaseConfiguration = ArrayUtility::arrayMergeRecursiveOverrule($this->cicbaseConfiguration, $overrides, FALSE, FALSE);
     }
     parent::__construct($objectManager);
 }
 /**
  * action list
  *
  * @return void
  */
 public function listAction()
 {
     $galleriesArray = explode(',', $this->settings['galleries']);
     $allUsedTags = [];
     $galleries = $this->galleryRepository->findByArrayUid($galleriesArray);
     foreach ($galleries as $gallery) {
         $allUsedTags = ArrayUtility::arrayMergeRecursiveOverrule($allUsedTags, TagService::getTagsFromGallery($gallery));
     }
     $this->view->assign('galleries', $galleries);
     $this->view->assign('allUsedTags', $allUsedTags);
 }
Beispiel #7
0
 protected function getMergedConfiguration($pid, $node, $cType)
 {
     // Get configuration ctype specific configuration
     $cTypeConfig = $GLOBALS["BE_USER"]->getTSConfig('themes.content.' . $node . '.' . $cType, \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($pid));
     $this->ctypeProperties = $cTypeConfig['properties'];
     // Get default configuration
     $defaultConfig = $GLOBALS["BE_USER"]->getTSConfig('themes.content.' . $node . '.default', \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($pid));
     $this->defaultProperties = $defaultConfig['properties'];
     // Merge configurations
     $config = ArrayUtility::arrayMergeRecursiveOverrule($cTypeConfig, $defaultConfig);
     return $config;
 }
 /**
  * Does not render anything, just tweaks configuration.
  *
  * @return string
  * @api
  */
 public function render()
 {
     $name = $this->arguments['property'];
     //$this->getName();
     $allowedPropertyNames = \TYPO3\CMS\Extbase\Utility\ArrayUtility::trimExplode(',', $this->arguments['allowProperties']);
     foreach ($allowedPropertyNames as $allowedPropertyName) {
         for ($i = 0; $i <= $this->arguments['count']; $i++) {
             $this->registerFieldNameForFormTokenGeneration($name . '[' . $allowedPropertyName . ']');
         }
     }
     return '';
 }
 /**
  * Get the settings 
  * 
  * @param Tx_PtExtlist_Domain_Configuration_ConfigurationBuilder $configurationBuilder
  * @return array
  */
 protected static function getExportSettingsForCurrentView(Tx_PtExtlist_Domain_Configuration_ConfigurationBuilder $configurationBuilder)
 {
     $allExportSettings = $configurationBuilder->getSettingsForConfigObject('export');
     $controllerSettings = $configurationBuilder->getSettings('controller');
     $selectedViewSettingsKey = $controllerSettings['Export']['download']['view'];
     $exportSettingsPath = explode('.', $selectedViewSettingsKey);
     $exportSettings = \TYPO3\CMS\Extbase\Utility\ArrayUtility::getValueByPath($configurationBuilder->getSettings(), $exportSettingsPath);
     /* In this case we have to merge the prototype settings again because the prototype settings are filled from flexform....
      * This smells ... 
      * TODO: find a better way .... 
      */
     return $configurationBuilder->getMergedSettingsWithPrototype($exportSettings, 'export');
 }
 /**
  * Extends the getData()-Method of \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer to process more/other commands
  *
  * @param  string                                                  $getDataString Full content of getData-request e.g. "TSFE:id // field:title // field:uid
  * @param  array                                                   $fields        Current field-array
  * @param  string                                                  $sectionValue  Currently examined section value of the getData request e.g. "field:title
  * @param  string                                                  $returnValue   Current returnValue that was processed so far by getData
  * @param  \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $parentObject  Parent content object
  * @return string                                                  Get data result
  */
 public function getDataExtension($getDataString, array $fields, $sectionValue, $returnValue, \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer &$parentObject)
 {
     $parts = explode(':', $sectionValue, 2);
     $type = strtolower(trim($parts[0]));
     $key = trim($parts[1]);
     switch ($type) {
         case 'qbtools_flexform_field':
             $flexform_service = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Service\\FlexFormService');
             $flexform_fields = $flexform_service->convertFlexFormContentToArray($fields['pi_flexform']);
             $returnValue = ArrayUtility::getValueByPath($flexform_fields, $key);
             break;
     }
     return $returnValue;
 }
 /**
  * @return void
  */
 public function initializeAction()
 {
     $this->objects = $this->widgetConfiguration['objects'];
     if (version_compare(TYPO3_branch, '6.2', '<')) {
         \TYPO3\CMS\Extbase\Utility\ArrayUtility::arrayMergeRecursiveOverrule($this->configuration, $this->widgetConfiguration['configuration'], FALSE);
     } else {
         \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->configuration, $this->widgetConfiguration['configuration'], FALSE);
     }
     if ($this->configuration['sliceSub']) {
         $this->numberOfPages = ceil(array_sum(array_map("count", $this->objects)) / (int) $this->configuration['itemsPerPage']);
     } else {
         $this->numberOfPages = ceil(count($this->objects) / (int) $this->configuration['itemsPerPage']);
     }
     $this->maximumNumberOfLinks = (int) $this->configuration['maximumNumberOfLinks'];
 }
 /**
  * @param string $content
  * @param array $conf
  * @return string
  */
 public function getTemplateFromName($content, $conf)
 {
     $basename = $content;
     if ($conf['paths'][0] === '<') {
         $key = trim(substr($conf['paths'], 1));
         $typoScriptParser = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\TypoScript\\Parser\\TypoScriptParser');
         list($name, $conf['paths.']) = $typoScriptParser->getVal($key, $GLOBALS['TSFE']->tmpl->setup);
     }
     $paths = ArrayUtility::sortArrayWithIntegerKeys($conf['paths.']);
     $paths = array_reverse($paths, TRUE);
     foreach ($paths as $path) {
         // why does it have to be relative?
         $test_file = PathUtility::getRelativePathTo(GeneralUtility::getFileAbsFileName($path)) . $basename;
         if (is_file($test_file)) {
             return $test_file;
         }
         if (is_file($test_file . '.html')) {
             return $test_file . '.html';
         }
     }
     return $content;
 }
 /**
  * Add support for variable argument lists using a wildcard property name '*'.
  * This is required for a file multiupload, as you can't guess how many files
  * will be uploaded when rendering the form (and generating the
  * trustedPropertiesToken) on the server.
  *
  * You can use it like this:
  * If you write a formfield viewhelper, you have to register all the properties
  * that should be mapped when processing the input on the server. To allow
  * the mapping of some properties of all submitted elements, insert a wildcard
  * in the path at the position where new keys will appear. This class will
  * enable the mapping of all arguments that are assigned to this path.
  *
  * So, if you have this line in your viewhelper:
  *		$this->registerFieldNameForFormTokenGeneration('my_plugin[my_object][object_storage_property][*][foo]');
  * and request arguments like this:
  *		array( 'my_object' => array( 'object_storage_property' => array(
  *			0 => array( 'foo' => 13 ),
  *			1 => array( 'foo' => 42 ),
  *			2 => array( 'foo' => false )
  *		)))
  * the PropertyMapper won't complain about missing permissions to "map
  * attribute my_object.object_storage_property.0".
  *
  * This is different from simply using $propertyMappingConfiguration->allowAllProperties()
  * because:
  * - You don't have to post that line into each of your controllers
  * - You can control which sub-properties to map
  * - You don't override assigned settings for specific keys: if there is a
  *   configuration for my_object.object_storage_property.42, it won't be
  *   changed to the wildcard value.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\Request $request
  * @param \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $controllerArguments
  * @return void
  */
 public function initializePropertyMappingConfigurationFromRequest(\TYPO3\CMS\Extbase\Mvc\Request $request, \TYPO3\CMS\Extbase\Mvc\Controller\Arguments $controllerArguments)
 {
     $trustedPropertiesToken = $request->getInternalArgument('__trustedProperties');
     if (!is_string($trustedPropertiesToken)) {
         return;
     }
     $serializedTrustedProperties = $this->hashService->validateAndStripHmac($trustedPropertiesToken);
     $trustedProperties = unserialize($serializedTrustedProperties);
     foreach ($trustedProperties as $propertyName => $propertyConfiguration) {
         if (!$controllerArguments->hasArgument($propertyName)) {
             continue;
         }
         $propertyMappingConfiguration = $controllerArguments->getArgument($propertyName)->getPropertyMappingConfiguration();
         //
         // Extended from parent class - begin
         //
         if (is_array($propertyConfiguration)) {
             foreach (HelhumArrayUtility::getPathsToKey($propertyConfiguration, '*') as $path) {
                 $configurationTemplate = ExtbaseArrayUtility::getValueByPath($propertyConfiguration, $path . '.*');
                 $propertyConfiguration = ExtbaseArrayUtility::unsetValueByPath($propertyConfiguration, $path . '.*');
                 if ($request->hasArgument($propertyName) && is_array($request->getArgument($propertyName))) {
                     $rawArgument = ExtbaseArrayUtility::getValueByPath($request->getArgument($propertyName), $path);
                     $subPropertyConfiguration = ExtbaseArrayUtility::getValueByPath($propertyConfiguration, $path);
                     foreach ($rawArgument as $index => $_) {
                         if (!is_int($index) || array_key_exists($index, $subPropertyConfiguration)) {
                             continue;
                         }
                         $propertyConfiguration = ExtbaseArrayUtility::setValueByPath($propertyConfiguration, $path . '.' . $index, $configurationTemplate);
                     }
                 }
             }
         }
         //
         // Extended from parent class - end
         //
         $this->modifyPropertyMappingConfiguration($propertyConfiguration, $propertyMappingConfiguration);
     }
 }
 /**
  * action list
  *
  * @return void
  */
 public function listAction()
 {
     // find the locations
     $uidList = \TYPO3\CMS\Extbase\Utility\ArrayUtility::integerExplode(",", $this->settings['GoogleMap']['locationUidList']);
     $locations = array();
     if (count($uidList)) {
         foreach ($uidList as $uid) {
             $location = $this->locationRepository->findByUid($uid);
             if ($location) {
                 $locations[] = $location;
             }
         }
     }
     // calculate the center of the map
     $averageLatitude = 0;
     $averageLongitude = 0;
     if (count($locations)) {
         $validLocations = array();
         foreach ($locations as $location) {
             if (is_numeric($location->getLatitude()) && is_numeric($location->getLongitude())) {
                 $averageLatitude += $location->getLatitude();
                 $averageLongitude += $location->getLongitude();
                 $validLocations[] = $location;
             }
         }
         if (count($validLocations)) {
             $averageLatitude = $averageLatitude / count($validLocations);
             $averageLongitude = $averageLongitude / count($validLocations);
         }
         $locations = $validLocations;
         unset($validLocations);
     }
     // add JavaScript and Stylesheets
     $this->addStylesheetFiles($this->settings['GoogleMap']['Stylesheets']);
     $this->addJavaScriptFiles($this->settings['GoogleMap']['JavaScript']);
     $this->view->assignMultiple(array('locations' => $locations, 'latitude' => $averageLatitude, 'longitude' => $averageLongitude, 'data' => $this->configurationManager->getContentObject()->data));
 }
Beispiel #15
0
 /**
  * Creates a new configuration object.
  *
  * @param array $paths Paths to the configuration directories
  * @param array $local Multi-dimensional associative list with local configuration
  * @return \Aimeos\MW\Config\Iface Configuration object
  */
 public static function get(array $paths, array $local = array())
 {
     if (self::$config === null) {
         // Using extension config directories
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['confDirs'])) {
             ksort($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['confDirs']);
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['confDirs'] as $dir) {
                 if (($absPath = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($dir)) !== '') {
                     $paths[] = $absPath;
                 }
             }
         }
         $conf = new \Aimeos\MW\Config\PHPArray(array(), $paths);
         if (function_exists('apc_store') === true && (bool) \Aimeos\Aimeos\Base::getExtConfig('useAPC', false) === true) {
             $conf = new \Aimeos\MW\Config\Decorator\APC($conf, \Aimeos\Aimeos\Base::getExtConfig('apcPrefix', 't3:'));
         }
         self::$config = $conf;
     }
     if (isset($local['typo3']['tsconfig'])) {
         $tsconfig = \Aimeos\Aimeos\Base::parseTS($local['typo3']['tsconfig']);
         $local = \TYPO3\CMS\Extbase\Utility\ArrayUtility::arrayMergeRecursiveOverrule($local, $tsconfig);
     }
     return new \Aimeos\MW\Config\Decorator\Memory(self::$config, $local);
 }
Beispiel #16
0
 /**
  * @param \GeorgRinger\News\Domain\Model\News $news
  * @param array $importItem
  * @param array $importItemOverwrite
  * @return \GeorgRinger\News\Domain\Model\News
  */
 protected function hydrateNewsRecord(\GeorgRinger\News\Domain\Model\News $news, array $importItem, array $importItemOverwrite)
 {
     if (!empty($importItemOverwrite)) {
         $importItem = array_merge($importItem, $importItemOverwrite);
     }
     $news->setPid($importItem['pid']);
     $news->setHidden($importItem['hidden']);
     $news->setStarttime($importItem['starttime']);
     $news->setEndtime($importItem['endtime']);
     $news->setFeGroup($importItem['fe_group']);
     $news->setTstamp($importItem['tstamp']);
     $news->setCrdate($importItem['crdate']);
     $news->setSysLanguageUid($importItem['sys_language_uid']);
     $news->setSorting((int) $importItem['sorting']);
     $news->setTitle($importItem['title']);
     $news->setTeaser($importItem['teaser']);
     $news->setBodytext($importItem['bodytext']);
     $news->setType($importItem['type']);
     $news->setKeywords($importItem['keywords']);
     $news->setDatetime(new \DateTime(date('Y-m-d H:i:sP', $importItem['datetime'])));
     $news->setArchive(new \DateTime(date('Y-m-d H:i:sP', $importItem['archive'])));
     $contentElementUidArray = \TYPO3\CMS\Extbase\Utility\ArrayUtility::trimExplode(',', $importItem['content_elements'], TRUE);
     foreach ($contentElementUidArray as $contentElementUid) {
         if (is_object($contentElement = $this->ttContentRepository->findByUid($contentElementUid))) {
             $news->addContentElement($contentElement);
         }
     }
     $news->setInternalurl($importItem['internalurl']);
     $news->setExternalurl($importItem['externalurl']);
     $news->setType($importItem['type']);
     $news->setKeywords($importItem['keywords']);
     $news->setAuthor($importItem['author']);
     $news->setAuthorEmail($importItem['author_email']);
     $news->setImportid($importItem['import_id']);
     $news->setImportSource($importItem['import_source']);
     if (is_array($importItem['categories'])) {
         foreach ($importItem['categories'] as $categoryUid) {
             if ($this->settings['findCategoriesByImportSource']) {
                 $category = $this->categoryRepository->findOneByImportSourceAndImportId($this->settings['findCategoriesByImportSource'], $categoryUid);
             } else {
                 $category = $this->categoryRepository->findByUid($categoryUid);
             }
             if ($category) {
                 $news->addCategory($category);
             } else {
                 $this->logger->warning(sprintf('Category with ID "%s" was not found', $categoryUid));
             }
         }
     }
     /** @var $basicFileFunctions \TYPO3\CMS\Core\Utility\File\BasicFileUtility */
     $basicFileFunctions = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Utility\\File\\BasicFileUtility');
     // media relation
     if (is_array($importItem['media'])) {
         foreach ($importItem['media'] as $mediaItem) {
             // multi media
             if ((int) $mediaItem['type'] === Media::MEDIA_TYPE_MULTIMEDIA) {
                 if (($media = $this->getMultiMediaIfAlreadyExists($news, $mediaItem['multimedia'])) === FALSE) {
                     /** @var Media $media */
                     $media = $this->objectManager->get('GeorgRinger\\News\\Domain\\Model\\Media');
                     $media->setMultimedia($mediaItem['multimedia']);
                     $news->addMedia($media);
                 }
                 if (isset($mediaItem['caption'])) {
                     $media->setDescription($mediaItem['caption']);
                 }
                 if (isset($mediaItem['copyright'])) {
                     $media->setCopyright($mediaItem['copyright']);
                 }
                 if (isset($mediaItem['showinpreview'])) {
                     $media->setShowinpreview($mediaItem['showinpreview']);
                 }
                 $media->setType($mediaItem['type']);
                 $media->setPid($importItem['pid']);
                 // Images FAL enabled
             } elseif ($this->emSettings->getUseFal() > 0) {
                 // get fileobject by given identifier (file UID, combined identifier or path/filename)
                 try {
                     $file = $this->getResourceFactory()->retrieveFileOrFolderObject($mediaItem['image']);
                 } catch (\TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException $exception) {
                     $file = FALSE;
                 }
                 // no file found skip processing of this item
                 if ($file === FALSE) {
                     continue;
                 }
                 // file not inside a storage then search for same file based on hash (to prevent duplicates)
                 if ($file->getStorage()->getUid() === 0) {
                     $existingFile = $this->findFileByHash($file->getSha1());
                     if ($existingFile !== NULL) {
                         $file = $existingFile;
                     }
                 }
                 /** @var $media FileReference */
                 if (!($media = $this->getIfFalRelationIfAlreadyExists($news->getFalMedia(), $file))) {
                     // file not inside a storage copy the one form storage 0 to the import folder
                     if ($file->getStorage()->getUid() === 0) {
                         $file = $this->getResourceStorage()->copyFile($file, $this->getImportFolder());
                     }
                     $media = $this->objectManager->get('GeorgRinger\\News\\Domain\\Model\\FileReference');
                     $media->setFileUid($file->getUid());
                     $news->addFalMedia($media);
                 }
                 if ($media) {
                     $media->setTitle($mediaItem['title']);
                     $media->setAlternative($mediaItem['alt']);
                     $media->setDescription($mediaItem['caption']);
                     $media->setShowinpreview($mediaItem['showinpreview']);
                     $media->setPid($importItem['pid']);
                 }
             } else {
                 if (!($media = $this->getMediaIfAlreadyExists($news, $mediaItem['image']))) {
                     $uniqueName = $basicFileFunctions->getUniqueName($mediaItem['image'], PATH_site . self::UPLOAD_PATH);
                     copy(PATH_site . $mediaItem['image'], $uniqueName);
                     $media = $this->objectManager->get('GeorgRinger\\News\\Domain\\Model\\Media');
                     $news->addMedia($media);
                     $media->setImage(basename($uniqueName));
                 }
                 $media->setTitle($mediaItem['title']);
                 $media->setAlt($mediaItem['alt']);
                 $media->setCaption($mediaItem['caption']);
                 $media->setType($mediaItem['type']);
                 $media->setShowinpreview($mediaItem['showinpreview']);
                 $media->setPid($importItem['pid']);
             }
         }
     }
     // related files
     if (is_array($importItem['related_files'])) {
         // FAL enabled
         if ($this->emSettings->getUseFal() > 0) {
             foreach ($importItem['related_files'] as $fileItem) {
                 // get fileObject by given identifier (file UID, combined identifier or path/filename)
                 try {
                     $file = $this->getResourceFactory()->retrieveFileOrFolderObject($fileItem['file']);
                 } catch (\TYPO3\CMS\Core\Resource\Exception\ResourceDoesNotExistException $exception) {
                     $file = FALSE;
                 }
                 // no file found skip processing of this item
                 if ($file === FALSE) {
                     continue;
                 }
                 // file not inside a storage then search for same file based on hash (to prevent duplicates)
                 if ($file->getStorage()->getUid() === 0) {
                     $existingFile = $this->findFileByHash($file->getSha1());
                     if ($existingFile !== NULL) {
                         $file = $existingFile;
                     }
                 }
                 /** @var $relatedFile FileReference */
                 if (!($relatedFile = $this->getIfFalRelationIfAlreadyExists($news->getFalRelatedFiles(), $file))) {
                     // file not inside a storage copy the one form storage 0 to the import folder
                     if ($file->getStorage()->getUid() === 0) {
                         $file = $this->getResourceStorage()->copyFile($file, $this->getImportFolder());
                     }
                     $relatedFile = $this->objectManager->get('GeorgRinger\\News\\Domain\\Model\\FileReference');
                     $relatedFile->setFileUid($file->getUid());
                     $news->addFalRelatedFile($relatedFile);
                 }
                 if ($relatedFile) {
                     $relatedFile->setTitle($fileItem['title']);
                     $relatedFile->setDescription($fileItem['description']);
                     $relatedFile->setPid($importItem['pid']);
                 }
             }
         } else {
             foreach ($importItem['related_files'] as $file) {
                 if (!($relatedFile = $this->getRelatedFileIfAlreadyExists($news, $file['file']))) {
                     $uniqueName = $basicFileFunctions->getUniqueName($file['file'], PATH_site . self::UPLOAD_PATH);
                     copy(PATH_site . $file['file'], $uniqueName);
                     $relatedFile = $this->objectManager->get('GeorgRinger\\News\\Domain\\Model\\File');
                     $news->addRelatedFile($relatedFile);
                     $relatedFile->setFile(basename($uniqueName));
                 }
                 $relatedFile->setTitle($file['title']);
                 $relatedFile->setDescription($file['description']);
                 $relatedFile->setPid($importItem['pid']);
             }
         }
     }
     if (is_array($importItem['related_links'])) {
         foreach ($importItem['related_links'] as $link) {
             /** @var $relatedLink Link */
             if (($relatedLink = $this->getRelatedLinkIfAlreadyExists($news, $link['uri'])) === FALSE) {
                 $relatedLink = $this->objectManager->get('GeorgRinger\\News\\Domain\\Model\\Link');
                 $relatedLink->setUri($link['uri']);
                 $news->addRelatedLink($relatedLink);
             }
             $relatedLink->setTitle($link['title']);
             $relatedLink->setDescription($link['description']);
             $relatedLink->setPid($importItem['pid']);
         }
     }
     $arguments = array('importItem' => $importItem, 'news' => $news);
     $this->emitSignal('postHydrate', $arguments);
     return $news;
 }
 /**
  * Resolve the viewClassname defined via typoscript
  *
  * View class can be configured in TS via
  * plugin.<plugin_key>.settings.controller.<Controller_Name_without_Controller>.<action_Name_without_Action>.view = ViewClassName
  *
  * @throws Exception if view class does not exist
  * @return string
  */
 protected function resolveTsDefinedViewClassName()
 {
     $viewClassName = $this->getTsViewClassName();
     if ($viewClassName != '') {
         if (!class_exists($viewClassName)) {
             // Use the viewClassName as redirect path to a typoscript value holding the viewClassName
             $redirectedViewClassName = $viewClassName . '.viewClassName';
             $tsRedirectPath = explode('.', $redirectedViewClassName);
             $redirectedViewClassName = \TYPO3\CMS\Extbase\Utility\ArrayUtility::getValueByPath($this->settings, $tsRedirectPath);
             if ($redirectedViewClassName) {
                 $viewClassName = $redirectedViewClassName;
             }
         }
     }
     if ($viewClassName && !class_exists($viewClassName)) {
         throw new Exception('View class does not exist: ' . $viewClassName . ' 1281369758');
     }
     // TODO make sure that given class implements a view
     return $viewClassName;
 }
 /**
  * Set the request array from JSON
  *
  * @param string $request
  */
 protected function setRequestArgumentsFromJSON($request)
 {
     $requestArray = json_decode($request, true);
     if (is_array($requestArray)) {
         \TYPO3\CMS\Extbase\Utility\ArrayUtility::mergeRecursiveWithOverrule($this->requestArguments, $requestArray);
     }
 }
Beispiel #19
0
 /**
  * Returns all pages in $page
  *
  * @param string $uidList
  * @param string $order
  * @return \TYPO3\CMS\Extbase\Persistence\QueryResult<\LBR\LbrSitemap\Domain\Model\Page>
  * @deprecated Use $this->findByUidArray() instead
  */
 public function findByUidList($uidList, $order = "title")
 {
     return $this->findByUidArray(\TYPO3\CMS\Extbase\Utility\ArrayUtility::integerExplode(",", $uidList), $order);
 }
 /**
  * First checks if all the validation are correctly filled.
  *
  * @return    array    The validation of the field.
  */
 public function getValidation()
 {
     $this->checkValidationArrayConfiguration($this->localValidation);
     $this->checkValidationArrayConfiguration($this->validation);
     return ArrayUtility::arrayMergeRecursiveOverrule($this->localValidation, $this->validation);
 }
 /**
  * @param string $value
  * @return array
  */
 protected function determineValue($value)
 {
     $retArr = [];
     $parts = \TYPO3\CMS\Extbase\Utility\ArrayUtility::trimExplode("|", $value);
     foreach ($parts as $num => $part) {
         if (preg_match('/^([0-9]|[0-1][0-9]|2[0-3]):([0-5][0-9])$/', $part)) {
             $retArr[$num] = array('type' => "singletime", 'value' => $part);
         } else {
             if (preg_match("/^([0-9]|[0-1][0-9]|2[0-3]):([0-5][0-9])-([0-9]|[0-1][0-9]|2[0-3]):([0-5][0-9])\$/", $part)) {
                 $timeParts = explode("-", $part);
                 $retArr[$num] = array('type' => "doubletime", 'value1' => $timeParts[0], 'value2' => $timeParts[1]);
             } else {
                 if ($part) {
                     $retArr[$num] = array('type' => "string", 'value' => $part);
                 }
             }
         }
     }
     return $retArr;
 }
 /**
  * Handles the path resolving for *rootPath(s)
  * singular one is deprecated and will be removed two versions after 6.2
  * if deprecated setting is found, use it as the very last fallback target
  *
  * numerical arrays get ordered by key ascending
  *
  * @param array $extbaseFrameworkConfiguration
  * @param string $setting parameter name from TypoScript
  * @param string $deprecatedSetting parameter name from TypoScript
  *
  * @return array
  */
 protected function getViewProperty($extbaseFrameworkConfiguration, $setting, $deprecatedSetting = '')
 {
     $values = array();
     if (!empty($extbaseFrameworkConfiguration['view'][$setting]) && is_array($extbaseFrameworkConfiguration['view'][$setting])) {
         $values = \TYPO3\CMS\Extbase\Utility\ArrayUtility::sortArrayWithIntegerKeys($extbaseFrameworkConfiguration['view'][$setting]);
         $values = array_reverse($values, TRUE);
     }
     // @todo remove handling of deprecatedSetting two versions after 6.2
     if (isset($extbaseFrameworkConfiguration['view'][$deprecatedSetting]) && strlen($extbaseFrameworkConfiguration['view'][$deprecatedSetting]) > 0) {
         $values[] = $extbaseFrameworkConfiguration['view'][$deprecatedSetting];
     }
     return $values;
 }
 /**
  * return a typoscript array by given typoscript path
  *
  * @param string $typoScriptPath
  *
  * @return array
  */
 protected function getTSArrayByPath($typoScriptPath)
 {
     $pathArray = explode('.', $typoScriptPath);
     $outTSArray = \TYPO3\CMS\Extbase\Utility\ArrayUtility::getValueByPath($this->extListTypoScript, $pathArray);
     if (!is_array($outTSArray)) {
         $outTSArray = array();
     }
     return $outTSArray;
 }
Beispiel #24
0
 /**
  * Get a freshly built request object pointing to the Referrer.
  *
  * @return Request the referring request, or NULL if no referrer found
  */
 public function getReferringRequest()
 {
     if (isset($this->internalArguments['__referrer']) && is_array($this->internalArguments['__referrer'])) {
         $referrerArray = $this->internalArguments['__referrer'];
         $referringRequest = new \TYPO3\CMS\Extbase\Mvc\Web\Request();
         $arguments = array();
         if (isset($referrerArray['arguments'])) {
             $serializedArgumentsWithHmac = $referrerArray['arguments'];
             $serializedArguments = $this->hashService->validateAndStripHmac($serializedArgumentsWithHmac);
             $arguments = unserialize(base64_decode($serializedArguments));
             unset($referrerArray['arguments']);
         }
         $referringRequest->setArguments(\TYPO3\CMS\Extbase\Utility\ArrayUtility::arrayMergeRecursiveOverrule($arguments, $referrerArray));
         return $referringRequest;
     }
     return NULL;
 }
Beispiel #25
0
 /**
  * Builds a list of possible candidates for a given template name
  *
  * @param string $templateName Name of the template to search for
  * @param array $paths Paths to search in
  * @param string $format The file format to use. e.g 'html' or 'txt'
  * @return array Array of paths to search for the template file
  */
 protected function buildListOfTemplateCandidates($templateName, array $paths, $format)
 {
     $upperCasedTemplateName = $this->ucFileNameInPath($templateName);
     $possibleTemplatePaths = array();
     $paths = ArrayUtility::sortArrayWithIntegerKeys($paths);
     $paths = array_reverse($paths, TRUE);
     foreach ($paths as $layoutRootPath) {
         $possibleTemplatePaths[] = $this->resolveFileNamePath($layoutRootPath . '/' . $upperCasedTemplateName . '.' . $format);
         $possibleTemplatePaths[] = $this->resolveFileNamePath($layoutRootPath . '/' . $upperCasedTemplateName);
         if ($upperCasedTemplateName !== $templateName) {
             $possibleTemplatePaths[] = $this->resolveFileNamePath($layoutRootPath . '/' . $templateName . '.' . $format);
             $possibleTemplatePaths[] = $this->resolveFileNamePath($layoutRootPath . '/' . $templateName);
         }
     }
     return $possibleTemplatePaths;
 }
Beispiel #26
0
 /**
  * Resolve the partial path and filename based on $this->getPartialRootPaths() and request format
  *
  * @param string $partialName The name of the partial
  * @return string The full path which should be used. The path definitely exists.
  * @throws InvalidTemplateResourceException
  */
 protected function getPartialPathAndFilename($partialName)
 {
     $upperCasedPartialName = ucfirst($partialName);
     $paths = ArrayUtility::sortArrayWithIntegerKeys($this->getPartialRootPaths());
     $paths = array_reverse($paths, TRUE);
     $possiblePartialPaths = array();
     foreach ($paths as $partialRootPath) {
         $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $upperCasedPartialName . '.' . $this->getRequest()->getFormat());
         $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $upperCasedPartialName);
         if ($upperCasedPartialName !== $partialName) {
             $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $partialName . '.' . $this->getRequest()->getFormat());
             $possiblePartialPaths[] = GeneralUtility::fixWindowsFilePath($partialRootPath . '/' . $partialName);
         }
     }
     foreach ($possiblePartialPaths as $partialPathAndFilename) {
         if ($this->testFileExistence($partialPathAndFilename)) {
             return $partialPathAndFilename;
         }
     }
     throw new InvalidTemplateResourceException('Could not load partial file. Tried following paths: "' . implode('", "', $possiblePartialPaths) . '".', 1288092556);
 }
 /**
  * @param string $path
  * @return NULL|bool|int|string|array
  */
 public function getValue($path)
 {
     try {
         return ArrayUtility::getValueByPath($this->data, $path);
     } catch (\InvalidArgumentException $exception) {
         return NULL;
     }
 }
Beispiel #28
0
 /**
  * Replace the variables in the given format string with fileName or properties of the
  * itemMeta object.
  *
  * @param Tx_Yag_Domain_Model_Item $item
  * @param string $format
  * @param array $additionalVars
  * @return Tx_Yag_Domain_Model_Item $item;
  */
 protected function processStringFromMetaData(Tx_Yag_Domain_Model_Item $item, $format, $additionalVars = array())
 {
     if ($item->getItemMeta() instanceof Tx_Yag_Domain_Model_ItemMeta) {
         $vars = $item->getItemMeta()->getAttributeArray();
     } else {
         $vars = array();
     }
     $vars['origFileName'] = $item->getOriginalFilename();
     $vars['fileName'] = $this->processTitleFromFileName($item->getOriginalFilename());
     $vars = \TYPO3\CMS\Extbase\Utility\ArrayUtility::arrayMergeRecursiveOverrule($vars, $additionalVars);
     $formattedString = Tx_PtExtlist_Utility_RenderValue::renderDataByConfigArray($vars, $format);
     return $formattedString;
 }
Beispiel #29
0
 /**
  * @param array $overwrites
  */
 public function setOverrides($overwrites)
 {
     foreach ($overwrites as $key => $overwrite) {
         if (empty($overwrite)) {
             unset($overwrites[$key]);
         }
     }
     $this->overrides = ArrayUtility::arrayMergeRecursiveOverrule($this->overrides, $overwrites);
 }
 /**
  * Resolve the viewClassname defined via typoscript
  *
  * @return string
  * @throws Exception
  */
 protected function resolveTsDefinedViewClassName()
 {
     $viewClassName = $this->settings['controller'][$this->request->getControllerName()][$this->request->getControllerActionName()]['view'];
     if ($viewClassName != '') {
         if (!class_exists($viewClassName)) {
             // Use the viewClassName as redirect path to a typoscript value holding the viewClassName
             $viewClassName .= '.viewClassName';
             $tsRedirectPath = explode('.', $viewClassName);
             $viewClassName = \TYPO3\CMS\Extbase\Utility\ArrayUtility::getValueByPath($this->settings, $tsRedirectPath);
         }
     }
     if ($viewClassName && !class_exists($viewClassName)) {
         throw new Exception('View class does not exist! ' . $viewClassName, 1281369758);
     }
     return $viewClassName;
 }