/** * Get all the complex data for the loader. * This return value will be cached and stored in the database * There is no file monitoring for this cache * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $grids = []; if (!ExtensionManagementUtility::isLoaded('gridelements')) { return $grids; } $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Resources/Private/Grids/'; $files = FileUtility::getBaseFilesWithExtensionInDir($commandPath, 'ts,txt'); foreach ($files as $file) { $pathInfo = PathUtility::pathinfo($file); $iconPath = 'EXT:' . $loader->getExtensionKey() . '/Resources/Public/Icons/Grids/' . $pathInfo['filename'] . '.'; $extension = IconUtility::getIconFileExtension(GeneralUtility::getFileAbsFileName($iconPath)); $translationKey = 'grid.' . $pathInfo['filename']; if ($type === LoaderInterface::EXT_TABLES) { TranslateUtility::assureLabel($translationKey, $loader->getExtensionKey(), $pathInfo['filename']); } $path = 'EXT:' . $loader->getExtensionKey() . '/Resources/Private/Grids/' . $file; $icon = $extension ? $iconPath . $extension : false; $label = TranslateUtility::getLllString($translationKey, $loader->getExtensionKey()); $content = GeneralUtility::getUrl(GeneralUtility::getFileAbsFileName($path)); $flexForm = 'EXT:' . $loader->getExtensionKey() . '/Configuration/FlexForms/Grids/' . $pathInfo['filename'] . '.xml'; $flexFormFile = GeneralUtility::getFileAbsFileName($flexForm); $flexFormContent = is_file($flexFormFile) ? GeneralUtility::getUrl($flexFormFile) : false; $grids[] = $this->getPageTsConfig($pathInfo['filename'], $label, $content, $icon, $flexFormContent); } return $grids; }
/** * @param Question $question * @param int $mode * * @return string */ public function voteAction(Question $question, $mode) { /** @var \HDNET\Faq\Domain\Model\Request\Vote $vote */ $vote = $this->objectManager->get('HDNET\\Faq\\Domain\\Model\\Request\\Vote'); $vote->setMode($mode); $vote->setQuestion($question); $result = ['state' => 'ERROR', 'description' => 'Unknown', 'currentCounter' => 0]; $sessionIdentifier = 'topflop'; try { $ids = $this->sessionService->setAndGet($sessionIdentifier, []); $vote->checkAgainst($ids); array_push($ids, $vote->getQuestion()->getUid()); $this->sessionService->set($sessionIdentifier, $ids); $vote->updateQuestion(); $this->questionRepository->update($vote->getQuestion()); $result['state'] = 'OK'; $result['description'] = TranslateUtility::assureLabel('eid.ok', 'hdnet_faq', 'Vielen Dank für Ihre Wertung.'); $result['currentCounter'] = $vote->getQuestionVotes(); } catch (AlreadyVotedException $e) { $result['description'] = TranslateUtility::assureLabel('eid.error.multivote', 'hdnet_faq', 'Sie haben für diese Frage bereits abgestimmt!'); } catch (VoteException $e) { $result['description'] = $e->getMessage(); } return json_encode($result); }
/** * Prepare the content object loader * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $loaderInformation = []; $modelPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Classes/Domain/Model/Content/'; $models = FileUtility::getBaseFilesInDir($modelPath, 'php'); if ($models) { TranslateUtility::assureLabel('tt_content.' . $loader->getExtensionKey() . '.header', $loader->getExtensionKey(), $loader->getExtensionKey() . ' (Header)'); } foreach ($models as $model) { $key = GeneralUtility::camelCaseToLowerCaseUnderscored($model); $className = ClassNamingUtility::getFqnByPath($loader->getVendorName(), $loader->getExtensionKey(), 'Domain/Model/Content/' . $model); if (!$loader->isInstantiableClass($className)) { continue; } $fieldConfiguration = []; $richTextFields = []; $noHeader = $this->isTaggedWithNoHeader($className); // create labels in the ext_tables run, to have a valid DatabaseConnection if ($type === LoaderInterface::EXT_TABLES) { TranslateUtility::assureLabel('wizard.' . $key, $loader->getExtensionKey(), $key . ' (Title)'); TranslateUtility::assureLabel('wizard.' . $key . '.description', $loader->getExtensionKey(), $key . ' (Description)'); $fieldConfiguration = $this->getClassPropertiesInLowerCaseUnderscored($className); $defaultFields = $this->getDefaultTcaFields(null, $noHeader); $fieldConfiguration = array_diff($fieldConfiguration, $defaultFields); // RTE manipulation $classReflection = ReflectionUtility::createReflectionClass($className); foreach ($classReflection->getProperties() as $property) { /** @var $property PropertyReflection */ if ($property->isTaggedWith('enableRichText')) { $search = array_search(GeneralUtility::camelCaseToLowerCaseUnderscored($property->getName()), $fieldConfiguration); if ($search !== false) { if (GeneralUtility::compat_version('7.0')) { $richTextFields[] = $fieldConfiguration[$search]; } else { $fieldConfiguration[$search] .= ';;;richtext:rte_transform[flag=rte_enabled|mode=ts_css]'; } } } } } $entry = ['fieldConfiguration' => implode(',', $fieldConfiguration), 'richTextFields' => $richTextFields, 'modelClass' => $className, 'model' => $model, 'icon' => IconUtility::getByModelName($className), 'iconExt' => IconUtility::getByModelName($className, true), 'noHeader' => $noHeader, 'tabInformation' => ReflectionUtility::getFirstTagValue($className, 'wizardTab')]; SmartObjectRegister::register($entry['modelClass']); $loaderInformation[$key] = $entry; } $this->checkAndCreateDummyTemplates($loaderInformation, $loader); return $loaderInformation; }
/** * Get all the complex data and information for the loader. * This return value will be cached and stored in the core_cache of TYPO3. * There is no file monitoring for this cache. * * @param Loader $loader * @param int $type * * @return array */ public function prepareLoader(Loader $loader, $type) { $backendLayouts = array(); $commandPath = ExtensionManagementUtility::extPath($loader->getExtensionKey()) . 'Resources/Private/BackendLayouts/'; $backendLayoutFiles = FileUtility::getBaseFilesWithExtensionInDir($commandPath, 'ts,txt'); foreach ($backendLayoutFiles as $file) { $pathInfo = PathUtility::pathinfo($file); $iconPath = 'EXT:' . $loader->getExtensionKey() . '/Resources/Public/Icons/BackendLayouts/' . $pathInfo['filename'] . '.'; $extension = IconUtility::getIconFileExtension(GeneralUtility::getFileAbsFileName($iconPath)); $translationKey = 'backendLayout.' . $pathInfo['basename']; if ($type === LoaderInterface::EXT_TABLES) { TranslateUtility::assureLabel($translationKey, $loader->getExtensionKey(), $pathInfo['filename']); } $backendLayouts[] = array('path' => 'EXT:' . $loader->getExtensionKey() . '/Resources/Private/BackendLayouts/' . $file, 'filename' => $pathInfo['filename'], 'icon' => $extension ? $iconPath . $extension : FALSE, 'label' => TranslateUtility::getLllString($translationKey, $loader->getExtensionKey()), 'extension' => $loader->getExtensionKey()); } return $backendLayouts; }
/** * Pre build TCA information for the given model * * @param string $modelClassName * * @return array */ public function getTcaInformation($modelClassName) { $modelInformation = ClassNamingUtility::explodeObjectModelName($modelClassName); $extensionName = GeneralUtility::camelCaseToLowerCaseUnderscored($modelInformation['extensionName']); $reflectionTableName = ModelUtility::getTableNameByModelReflectionAnnotation($modelClassName); $tableName = ModelUtility::getTableNameByModelName($modelClassName); $searchFields = []; $customFields = $this->getCustomModelFieldTca($modelClassName, $searchFields); if ($reflectionTableName !== '') { $customConfiguration = ['columns' => $customFields]; $base = is_array($GLOBALS['TCA'][$reflectionTableName]) ? $GLOBALS['TCA'][$reflectionTableName] : []; return ArrayUtility::mergeRecursiveDistinct($base, $customConfiguration); } $excludes = ModelUtility::getSmartExcludesByModelName($modelClassName); $dataSet = $this->getDataSet(); $dataImplementations = $dataSet->getAllAndExcludeList($excludes); $baseTca = $dataSet->getTcaInformation($dataImplementations, $tableName); // title $fields = array_keys($customFields); $labelField = 'title'; if (!in_array($labelField, $fields)) { $labelField = $fields[0]; } try { TranslateUtility::assureLabel($tableName, $extensionName); } catch (\Exception $ex) { // @todo handle } if (!is_array($baseTca['columns'])) { $baseTca['columns'] = []; } $baseTca['columns'] = ArrayUtility::mergeRecursiveDistinct($baseTca['columns'], $customFields); // items $showitem = $fields; if (!in_array('language', $excludes)) { $showitem[] = '--palette--;LLL:EXT:lang/locallang_general.xlf:LGL.language;language'; } if (!in_array('workspaces', $excludes)) { $baseTca['ctrl']['shadowColumnsForNewPlaceholders'] .= ',' . $labelField; } if (GeneralUtility::compat_version('7.0')) { $languagePrefix = 'LLL:EXT:frontend/Resources/Private/Language/'; } else { $languagePrefix = 'LLL:EXT:cms/'; } if (!in_array('enableFields', $excludes)) { $showitem[] = '--div--;' . $languagePrefix . 'locallang_ttc.xlf:tabs.access'; $showitem[] = '--palette--;' . $languagePrefix . 'locallang_tca.xlf:pages.palettes.access;access'; } $showitem[] = '--div--;' . $languagePrefix . 'locallang_ttc.xlf:tabs.extended'; $overrideTca = ['ctrl' => ['title' => TranslateUtility::getLllOrHelpMessage($tableName, $extensionName), 'label' => $labelField, 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', 'dividers2tabs' => true, 'sortby' => 'sorting', 'delete' => 'deleted', 'searchFields' => implode(',', $searchFields), 'iconfile' => IconUtility::getByModelName($modelClassName, GeneralUtility::compat_version('7.0'))], 'interface' => ['showRecordFieldList' => implode(',', array_keys($baseTca['columns']))], 'types' => ['1' => ['showitem' => implode(',', $showitem)]], 'palettes' => ['access' => ['showitem' => 'starttime, endtime, --linebreak--, hidden, editlock, --linebreak--, fe_group']]]; return ArrayUtility::mergeRecursiveDistinct($baseTca, $overrideTca); }