/** * Returns information about this extension plugin * * @param array $params Parameters to the hook * * @return string Information about pi1 plugin * @hook TYPO3_CONF_VARS|SC_OPTIONS|cms/layout/class.tx_cms_layout.php|list_type_Info|calendarize_calendar */ public function getExtensionSummary(array $params) { if ($params['row']['list_type'] != 'calendarize_calendar') { return ''; } $this->flexFormService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\FlexFormService'); $this->flexFormService->load($params['row']['pi_flexform']); if (!$this->flexFormService->isValid()) { return ''; } $extensionIcon = IconUtility::getByExtensionKey('calendarize', true); $extensionRelPath = ExtensionManagementUtility::extRelPath('calendarize'); $this->layoutService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\ContentElementLayoutService'); $this->layoutService->setTitle('<img src="' . str_replace('EXT:calendarize/', $extensionRelPath, $extensionIcon) . '" width="32" height="32" /> Calendarize'); $actions = $this->flexFormService->get('switchableControllerActions', 'main'); $parts = GeneralUtility::trimExplode(';', $actions, true); $parts = array_map(function ($element) { $split = explode('->', $element); return ucfirst($split[1]); }, $parts); $actionKey = lcfirst(implode('', $parts)); $this->layoutService->addRow(TranslateUtility::get('mode'), TranslateUtility::get('mode.' . $actionKey)); $this->layoutService->addRow(TranslateUtility::get('configuration'), $this->flexFormService->get('settings.configuration', 'main')); if ((bool) $this->flexFormService->get('settings.hidePagination', 'main')) { $this->layoutService->addRow(TranslateUtility::get('hide.pagination.teaser'), '!!!'); } $this->addPageIdsToTable(); return $this->layoutService->render(); }
/** * 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; }
/** * Modifies CacheMenuItems array * * @param array $cacheActions * @param array $optionValues * * @return void */ public function manipulateCacheActions(&$cacheActions, &$optionValues) { if ($this->isProduction() || !$this->isAdmin()) { return; } $cacheActions[] = ['id' => 'autoloader', 'title' => 'EXT:autoloader caches', 'href' => BackendUtility::getAjaxUrl('autoloader::clearCache'), 'icon' => '<img src="' . IconUtility::getByExtensionKey('autoloader') . '">']; }
/** * 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); }
/** * Run the loading process for the ext_tables.php file * * @param Loader $loader * @param array $loaderInformation * * @return NULL */ public function loadExtensionTables(Loader $loader, array $loaderInformation) { if (!$loaderInformation) { return null; } $createWizardHeader = []; $predefinedWizards = ['common', 'special', 'forms', 'plugins']; // Add the divider $GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'][] = [TranslateUtility::getLllString('tt_content.' . $loader->getExtensionKey() . '.header', $loader->getExtensionKey()), '--div--']; foreach ($loaderInformation as $e => $config) { SmartObjectRegister::register($config['modelClass']); $typeKey = $loader->getExtensionKey() . '_' . $e; ExtensionManagementUtility::addPlugin([TranslateUtility::getLllOrHelpMessage('content.element.' . $e, $loader->getExtensionKey()), $typeKey, $config['iconExt']], 'CType'); if (!isset($GLOBALS['TCA']['tt_content']['types'][$typeKey]['showitem'])) { $baseTcaConfiguration = $this->wrapDefaultTcaConfiguration($config['fieldConfiguration'], (bool) $config['noHeader']); if (ExtensionManagementUtility::isLoaded('gridelements')) { $baseTcaConfiguration .= ',tx_gridelements_container,tx_gridelements_columns'; } $GLOBALS['TCA']['tt_content']['types'][$typeKey]['showitem'] = $baseTcaConfiguration; } // RTE if (isset($config['richTextFields']) && is_array($config['richTextFields']) && $config['richTextFields']) { foreach ($config['richTextFields'] as $field) { $GLOBALS['TCA']['tt_content']['types'][$typeKey]['columnsOverrides'][$field] = ['config' => ['type' => 'text'], 'defaultExtras' => 'richtext:rte_transform[flag=rte_enabled|mode=ts_css]']; } } IconUtility::addTcaTypeIcon('tt_content', $typeKey, $config['icon']); $tabName = $config['tabInformation'] ? $config['tabInformation'] : $loader->getExtensionKey(); if (!in_array($tabName, $predefinedWizards) && !in_array($tabName, $createWizardHeader)) { $createWizardHeader[] = $tabName; } ExtensionManagementUtility::addPageTSConfig(' mod.wizards.newContentElement.wizardItems.' . $tabName . '.elements.' . $typeKey . ' { icon = ' . $config['icon'] . ' title = ' . TranslateUtility::getLllOrHelpMessage('wizard.' . $e, $loader->getExtensionKey()) . ' description = ' . TranslateUtility::getLllOrHelpMessage('wizard.' . $e . '.description', $loader->getExtensionKey()) . ' tt_content_defValues { CType = ' . $typeKey . ' } } mod.wizards.newContentElement.wizardItems.' . $tabName . '.show := addToList(' . $typeKey . ')'); $cObjectConfiguration = ['extensionKey' => $loader->getExtensionKey(), 'backendTemplatePath' => 'EXT:' . $loader->getExtensionKey() . '/Resources/Private/Templates/Content/' . $config['model'] . 'Backend.html', 'modelClass' => $config['modelClass']]; $GLOBALS['TYPO3_CONF_VARS']['AUTOLOADER']['ContentObject'][$loader->getExtensionKey() . '_' . GeneralUtility::camelCaseToLowerCaseUnderscored($config['model'])] = $cObjectConfiguration; } if ($createWizardHeader) { foreach ($createWizardHeader as $element) { ExtensionManagementUtility::addPageTSConfig(' mod.wizards.newContentElement.wizardItems.' . $element . ' { show = * header = ' . TranslateUtility::getLllOrHelpMessage('wizard.' . $element . '.header', $loader->getExtensionKey()) . ' }'); } } return null; }
<?php /** * General ext_tables file and also an example for your own extension * * @category Extension * @package Calendarize * @author Tim Lochmüller */ if (!defined('TYPO3_MODE')) { die('Access denied.'); } \HDNET\Autoloader\Loader::extTables('HDNET', 'calendarize', \HDNET\Calendarize\Register::getDefaultAutoloader()); if (!(bool) \HDNET\Calendarize\Utility\ConfigurationUtility::get('disableDefaultEvent')) { \HDNET\Calendarize\Register::extTables(\HDNET\Calendarize\Register::getDefaultCalendarizeConfiguration()); \TYPO3\CMS\Core\Category\CategoryRegistry::getInstance()->add('calendarize', 'tx_calendarize_domain_model_event'); } \TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin('calendarize', 'Calendar', \HDNET\Calendarize\Utility\TranslateUtility::get('pluginName')); if (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('7.0.0')) { $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['calendarize_calendar'] .= ',categories'; } // module icon $extensionIcon = \HDNET\Autoloader\Utility\IconUtility::getByExtensionKey('calendarize', true); if (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('7.0')) { /** @var \TYPO3\CMS\Core\Imaging\IconRegistry $iconRegistry */ $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\IconRegistry'); $iconRegistry->registerIcon('apps-pagetree-folder-contains-calendarize', 'TYPO3\\CMS\\Core\\Imaging\\IconProvider\\BitmapIconProvider', ['source' => $extensionIcon]); } else { $extensionRelPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('calendarize'); \TYPO3\CMS\Backend\Sprite\SpriteManager::addTcaTypeIcon('pages', 'contains-calendar', str_replace('EXT:calendarize/', $extensionRelPath, $extensionIcon)); }
<?php use HDNET\Autoloader\Utility\IconUtility; $GLOBALS['TCA']['pages']['columns']['module']['config']['items'][] = array(0 => 'Calendarize', 1 => 'calendar', 2 => \TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('7.0') ? 'apps-pagetree-folder-contains-calendarize' : IconUtility::getByExtensionKey('calendarize', true));
/** * Register the indexer configuration * * @param array $params * @param object $pObj */ function registerIndexerConfiguration(&$params, $pObj) { $newArray = array('Calendarize Indexer', 'calendarize', IconUtility::getByExtensionKey('calendarize')); $params['items'][] = $newArray; $GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['sysfolder']['displayCond'] .= ',calendarize'; }