/**
  * @test
  */
 public function testGetVendorNameAndExtensionNameWithVendorNameUnderscore()
 {
     list($vendorName, $extensionName) = ExtensionNamingUtility::getVendorNameAndExtensionName('FT3.foo_ext');
     $this->assertSame('FT3', $vendorName);
     $this->assertSame('FooExt', $extensionName);
 }
 /**
  * @return void
  */
 protected function initializeVariants()
 {
     $variants = (array) $this->getAllRegisteredVariants();
     foreach ($variants as $contentType => $registeredVariantExtensions) {
         if (TRUE === empty($registeredVariantExtensions)) {
             continue;
         }
         $this->variants[$contentType] = array();
         foreach ($registeredVariantExtensions as $extensionKeyOrArray) {
             $icon = NULL;
             $versions = array();
             if (TRUE === is_array($extensionKeyOrArray) && 3 === count($extensionKeyOrArray)) {
                 list($extensionKey, $labelReference, $icon) = $extensionKeyOrArray;
             } elseif (TRUE === is_array($extensionKeyOrArray) && 2 === count($extensionKeyOrArray)) {
                 list($extensionKey, $labelReference) = $extensionKeyOrArray;
             } else {
                 $extensionKey = ExtensionNamingUtility::getExtensionKey($extensionKeyOrArray);
                 $labelReference = 'fluidcontent_core.variantLabel';
             }
             $controllerName = 'CoreContent/' . ucfirst($contentType);
             $paths = $this->getViewConfigurationForExtensionName($extensionKey);
             $templatePaths = new TemplatePaths($paths);
             $files = $templatePaths->resolveAvailableTemplateFiles($controllerName);
             foreach ($files as $file) {
                 $versions[] = basename($file, '.' . TemplatePaths::DEFAULT_FORMAT);
             }
             $versions = array_unique($versions);
             $this->versions[$contentType] = array($extensionKey => $versions);
             $this->variants[$contentType][] = array($extensionKey, $labelReference, $icon);
         }
     }
 }
 /**
  * @param array $row
  * @return NULL|string
  */
 public function getExtensionKey(array $row)
 {
     if (TRUE === isset($row['name'])) {
         list($extensionName, , ) = explode('-', $row['name']);
     } else {
         list($extensionName, ) = $this->getExtensionKeyAndActionFromUrl();
     }
     return ExtensionNamingUtility::getExtensionKey($extensionName);
 }
示例#4
0
 /**
  * @param string $sectionName
  * @param string $formName
  * @return Form|NULL
  */
 public function getForm($sectionName = 'Configuration', $formName = 'form')
 {
     /** @var Form $form */
     $form = $this->getStoredVariable(AbstractFormViewHelper::SCOPE, $formName, $sectionName);
     if (NULL !== $form && TRUE === isset($this->templatePathAndFilename)) {
         $form->setOption(Form::OPTION_TEMPLATEFILE, $this->templatePathAndFilename);
         $signature = ExtensionNamingUtility::getExtensionSignature($this->controllerContext->getRequest()->getControllerExtensionName());
         $overrides = (array) $this->configurationService->getTypoScriptByPath('plugin.tx_' . $signature . '.forms.' . $form->getName());
         $form->modify($overrides);
     }
     return $form;
 }
 /**
  * @param string $table
  * @param Form $form
  */
 protected function processFormForTable($table, Form $form)
 {
     $extensionName = $form->getExtensionName();
     $extensionKey = ExtensionNamingUtility::getExtensionKey($extensionName);
     $tableConfiguration = self::$tableTemplate;
     $fields = array();
     $labelFields = $form->getOption(Form::OPTION_TCA_LABELS);
     $enableColumns = array();
     foreach ($form->getFields() as $field) {
         $name = $field->getName();
         // note: extracts the TCEforms sub-array from the configuration, as required in TCA.
         $fields[$name] = array_pop($field->build());
     }
     if (TRUE === $form->getOption(Form::OPTION_TCA_HIDE)) {
         $enableColumns['disabled'] = 'hidden';
     }
     if (TRUE === $form->getOption(Form::OPTION_TCA_START)) {
         $enableColumns['start'] = 'starttime';
     }
     if (TRUE === $form->getOption(Form::OPTION_TCA_END)) {
         $enableColumns['end'] = 'endtime';
     }
     if (TRUE === $form->getOption(Form::OPTION_TCA_FEGROUP)) {
         $enableColumns['fe_group'] = 'fe_group';
     }
     $tableConfiguration['iconfile'] = ExtensionManagementUtility::extRelPath($extensionKey) . $form->getOption(Form::OPTION_ICON);
     $tableConfiguration['enablecolumns'] = $enableColumns;
     $tableConfiguration['title'] = $form->getLabel();
     $tableConfiguration['languageField'] = 'sys_language_uid';
     $showRecordsFieldList = $this->buildShowItemList($form);
     $GLOBALS['TCA'][$table] = array('ctrl' => $tableConfiguration, 'interface' => array('showRecordFieldList' => implode(',', array_keys($fields))), 'columns' => $fields, 'types' => array(0 => array('showitem' => $showRecordsFieldList)));
     if (TRUE === $form->getOption(Form::OPTION_TCA_DELETE)) {
         $GLOBALS['TCA'][$table]['ctrl']['delete'] = 'deleted';
     }
     if (NULL === $labelFields) {
         reset($fields);
         $GLOBALS['TCA'][$table]['ctrl']['label'] = key($fields);
     } else {
         $GLOBALS['TCA'][$table]['ctrl']['label'] = array_shift($labelFields);
         $GLOBALS['TCA'][$table]['ctrl']['label_alt'] = implode(',', $labelFields);
     }
 }
示例#6
0
 /**
  * Returns the icon for a template
  * - checks and returns if manually set as option or
  * - checks and returns Icon if it exists by convention in
  *   EXT:$extensionKey/Resources/Public/Icons/$controllerName/$templateName.(png|gif)
  *
  * @param Form $form
  * @return string|NULL
  */
 public static function getIconForTemplate(Form $form)
 {
     if (TRUE === $form->hasOption(Form::OPTION_ICON)) {
         return $form->getOption(Form::OPTION_ICON);
     }
     if (TRUE === $form->hasOption(Form::OPTION_TEMPLATEFILE)) {
         $extensionKey = ExtensionNamingUtility::getExtensionKey($form->getExtensionName());
         $fullTemplatePathAndName = $form->getOption(Form::OPTION_TEMPLATEFILE);
         $templatePathParts = explode('/', $fullTemplatePathAndName);
         $templateName = pathinfo(array_pop($templatePathParts), PATHINFO_FILENAME);
         $controllerName = array_pop($templatePathParts);
         $allowedExtensions = implode(',', self::$allowedIconTypes);
         $iconFolder = ExtensionManagementUtility::extPath($extensionKey, 'Resources/Public/Icons/' . $controllerName . '/');
         $iconRelFolder = ExtensionManagementUtility::extRelPath($extensionKey) . 'Resources/Public/Icons/' . $controllerName . '/';
         $iconPathAndName = $iconFolder . $templateName;
         $iconMatchPattern = $iconPathAndName . '.{' . $allowedExtensions . '}';
         $filesInFolder = TRUE === is_dir($iconFolder) ? glob($iconMatchPattern, GLOB_BRACE) : array();
         $iconFile = TRUE === is_array($filesInFolder) && 0 < count($filesInFolder) ? reset($filesInFolder) : NULL;
         $iconRelPathAndFilename = FALSE === is_null($iconFile) ? $iconRelFolder . str_replace($iconFolder, '', $iconFile) : NULL;
         return $iconRelPathAndFilename;
     }
     return NULL;
 }
示例#7
0
 /**
  * @param string $label
  * @param string $path
  * @return NULL|string
  */
 protected function resolveLocalLanguageValueOfLabel($label, $path = NULL)
 {
     if ($this->getDisableLocalLanguageLabels()) {
         return $label;
     }
     $name = $this->getName();
     $extensionName = $this->extensionName;
     $extensionKey = ExtensionNamingUtility::getExtensionKey($extensionName);
     if (empty($label) && !ExtensionManagementUtility::isLoaded($extensionKey)) {
         return $name;
     } elseif (strpos($label, 'LLL:EXT:') === 0) {
         return $label;
     }
     $relativeFilePath = $this->getLocalLanguageFileRelativePath();
     $relativeFilePath = ltrim($relativeFilePath, '/');
     $filePrefix = 'LLL:EXT:' . $extensionKey . '/' . $relativeFilePath;
     if (strpos($label, 'LLL:') === 0) {
         // Shorthand LLL:name.of.index reference, expand
         list(, $labelIdentifier) = explode(':', $label, 2);
         return $filePrefix . ':' . $labelIdentifier;
     } elseif (!empty($label)) {
         return $label;
     }
     if ($this instanceof Form) {
         return $filePrefix . ':flux.' . $this->getName();
     }
     $root = $this->getRoot();
     $id = $root->getName();
     if (empty($path)) {
         $path = $this->getPath();
     }
     return $filePrefix . ':' . trim('flux.' . $id . '.' . $path, '.');
 }
示例#8
0
 /**
  * @param string $controllerName
  * @param string $actionName
  * @return string|NULL
  */
 protected function getLabelForControllerAction($controllerName, $actionName)
 {
     $localLanguageFileRelativePath = $this->getLocalLanguageFileRelativePath();
     $extensionName = $this->getControllerExtensionName();
     $extensionKey = ExtensionNamingUtility::getExtensionKey($extensionName);
     $pluginName = $this->getPluginName();
     $separator = $this->getSeparator();
     $controllerClassName = $this->buildExpectedAndExistingControllerClassName($controllerName);
     $disableLocalLanguageLabels = $this->getDisableLocalLanguageLabels();
     $labelPath = strtolower($pluginName . '.' . $controllerName . '.' . $actionName);
     $hasLocalLanguageFile = file_exists(ExtensionManagementUtility::extPath($extensionKey, $localLanguageFileRelativePath));
     $label = $actionName . $separator . $controllerName;
     if (FALSE === $disableLocalLanguageLabels && TRUE === $hasLocalLanguageFile) {
         $label = 'LLL:EXT:' . $extensionKey . $localLanguageFileRelativePath . ':' . $labelPath;
     } elseif (TRUE === method_exists($controllerClassName, $actionName . 'Action') && TRUE === $disableLocalLanguageLabels) {
         $methodReflection = $this->reflectAction($controllerName, $actionName);
         $line = array_shift(explode("\n", trim($methodReflection->getDocComment(), "/*\n")));
         $line = trim(trim($line), '* ');
         if (substr($line, 0, 1) !== '@') {
             $label = $line;
         }
     }
     return $label;
 }
 /**
  * @param string $extensionName
  * @return array|NULL
  */
 public function getViewConfigurationForExtensionName($extensionName)
 {
     $extensionKey = ExtensionNamingUtility::getExtensionKey($extensionName);
     $configuration = $this->getTypoScriptSubConfiguration(NULL, 'view', $extensionName);
     if (FALSE === is_array($configuration) || 0 === count($configuration) || TRUE === empty($configuration['templateRootPath'])) {
         $configuration = array('templateRootPath' => 'EXT:' . $extensionKey . '/Resources/Private/Templates', 'partialRootPath' => 'EXT:' . $extensionKey . '/Resources/Private/Partials', 'layoutRootPath' => 'EXT:' . $extensionKey . '/Resources/Private/Layouts');
     }
     return $configuration;
 }
示例#10
0
 /**
  * @return string
  * @route off
  */
 public function renderAction()
 {
     $row = $this->getRecord();
     $extensionKey = $this->provider->getExtensionKey($row);
     $extensionSignature = ExtensionNamingUtility::getExtensionSignature($extensionKey);
     $pluginSignature = 'tx_' . $extensionSignature . '_' . $this->request->getPluginName();
     $controllerExtensionKey = $this->provider->getControllerExtensionKeyFromRecord($row);
     $requestActionName = $this->resolveOverriddenFluxControllerActionNameFromRequestParameters($pluginSignature);
     $controllerActionName = $this->provider->getControllerActionFromRecord($row);
     $actualActionName = NULL !== $requestActionName ? $requestActionName : $controllerActionName;
     $controllerName = $this->request->getControllerName();
     return $this->performSubRendering($controllerExtensionKey, $controllerName, $actualActionName, $pluginSignature);
 }
 /**
  * @param array $row
  * @return string
  */
 public function getExtensionKey(array $row)
 {
     $action = $row['tx_fed_fcefile'];
     if (FALSE !== strpos($action, ':')) {
         $extensionName = array_shift(explode(':', $action));
     }
     if (FALSE === empty($extensionName)) {
         $extensionKey = ExtensionNamingUtility::getExtensionKey($extensionName);
         return $extensionKey;
     }
     return parent::getExtensionKey($row);
 }
 /**
  * Renders a Fluid Page Layout file selector
  *
  * @param array $parameters
  * @param mixed $pObj
  * @return string
  */
 public function renderField(&$parameters, &$pObj)
 {
     $name = $parameters['itemFormElName'];
     $value = $parameters['itemFormElValue'];
     $availableTemplates = $this->pageService->getAvailablePageTemplateFiles();
     if (FALSE === strpos($name, 'tx_fed_controller_action_sub')) {
         $onChange = 'onclick="if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };"';
     }
     $selector = '<div>';
     $typoScript = $this->configurationManager->getTypoScriptSetup();
     $hideInheritFieldSiteRoot = (bool) (TRUE === isset($typoScript['plugin.']['tx_fluidpages.']['siteRootInheritance']) ? 1 > $typoScript['plugin.']['tx_fluidpages.']['siteRootInheritance'] : FALSE);
     $pageIsSiteRoot = (bool) $parameters['row']['is_siteroot'];
     $forceDisplayInheritSiteRoot = (bool) ('tx_fed_page_controller_action_sub' === $parameters['field']);
     $forceHideInherit = (bool) (0 === intval($parameters['row']['pid']));
     if (FALSE === $pageIsSiteRoot || TRUE === $forceDisplayInheritSiteRoot || FALSE === $hideInheritFieldSiteRoot) {
         if (FALSE === $forceHideInherit) {
             $emptyLabel = LocalizationUtility::translate('pages.tx_fed_page_controller_action.default', 'Fluidpages');
             $selected = TRUE === empty($value) ? ' checked="checked" ' : NULL;
             $selector .= '<label>';
             $selector .= '<input type="radio" name="' . $name . '" ' . $onChange . '" value="" ' . $selected . '/> ' . $emptyLabel . LF;
             $selector .= '</label>' . LF;
         }
     }
     foreach ($availableTemplates as $extension => $group) {
         $extensionKey = ExtensionNamingUtility::getExtensionKey($extension);
         if (FALSE === ExtensionManagementUtility::isLoaded($extensionKey)) {
             $groupTitle = ucfirst($extension);
         } else {
             $emConfigFile = ExtensionManagementUtility::extPath($extensionKey, 'ext_emconf.php');
             require $emConfigFile;
             $groupTitle = $EM_CONF['']['title'];
         }
         $packageLabel = LocalizationUtility::translate('pages.tx_fed_page_package', 'Fluidpages');
         $selector .= '<h4 style="clear: both; margin-top: 1em;">' . $packageLabel . ': ' . $groupTitle . '</h4>' . LF;
         foreach ($group as $template) {
             try {
                 $paths = $this->configurationService->getPageConfiguration($extension);
                 $extensionName = ExtensionNamingUtility::getExtensionName($extension);
                 $templatePathAndFilename = $this->pageService->expandPathsAndTemplateFileToTemplatePathAndFilename($paths, $template);
                 if (FALSE === file_exists($templatePathAndFilename)) {
                     $this->configurationService->message('Missing template file: ' . $templatePathAndFilename, GeneralUtility::SYSLOG_SEVERITY_WARNING);
                     continue;
                 }
                 $form = $this->configurationService->getFormFromTemplateFile($templatePathAndFilename, 'Configuration', 'form', $paths, $extensionName);
                 if (FALSE === $form instanceof Form) {
                     $this->configurationService->message('Template file ' . $templatePathAndFilename . ' contains an unparsable Form definition', GeneralUtility::SYSLOG_SEVERITY_FATAL);
                     continue;
                 }
                 if (FALSE === $form->getEnabled()) {
                     continue;
                 }
                 $thumbnail = $form->getIcon();
                 $label = $form->getLabel();
                 $translatedLabel = LocalizationUtility::translate($label, $extensionName);
                 if (NULL !== $translatedLabel) {
                     $label = $translatedLabel;
                 }
                 $optionValue = $extension . '->' . $template;
                 $selected = $optionValue == $value ? ' checked="checked"' : '';
                 $option = '<label style="padding: 0.5em; border: 1px solid #CCC; display: inline-block; vertical-align: bottom; margin: 0 1em 1em 0; cursor: pointer; ' . ($selected ? 'background-color: #DDD;' : '') . '">';
                 $option .= '<img src="' . $thumbnail . '" alt="' . $label . '" style="margin: 0.5em 0 0.5em 0; max-width: 196px; max-height: 128px;"/><br />';
                 $option .= '<input type="radio" value="' . $optionValue . '"' . $selected . ' name="' . $name . '" ' . $onChange . ' /> ' . $label;
                 $option .= '</label>';
                 $selector .= $option . LF;
             } catch (\Exception $error) {
                 $this->configurationService->debug($error);
             }
         }
     }
     $selector .= '</div>' . LF;
     unset($pObj);
     return $selector;
 }
 /**
  * @param string $qualifiedExtensionName
  * @param Form $form
  * @return void
  * @throws \RuntimeException
  */
 public function registerModuleBasedOnFluxForm($qualifiedExtensionName, Form $form)
 {
     $extensionKey = ExtensionNamingUtility::getExtensionKey($qualifiedExtensionName);
     $signature = ExtensionNamingUtility::getExtensionSignature($qualifiedExtensionName);
     $options = $form->getOption('Fluidbackend');
     $formId = $form->getName();
     $module = 'web';
     if (TRUE === isset($options[Constants::FORM_OPTION_MODULE_GROUP])) {
         $module = $options[Constants::FORM_OPTION_MODULE_GROUP];
     }
     $position = 'before:help';
     if (TRUE === isset($options[Constants::FORM_OPTION_MODULE_POSITION])) {
         $position = $options[Constants::FORM_OPTION_MODULE_POSITION];
     }
     $navigationComponent = '';
     if (TRUE === isset($options[Constants::FORM_OPTION_MODULE_PAGE_TREE]) && TRUE === (bool) $options[Constants::FORM_OPTION_MODULE_PAGE_TREE]) {
         $navigationComponent = 'typo3-pagetree';
     }
     $icon = MiscellaneousUtility::getIconForTemplate($form);
     if (TRUE === empty($icon)) {
         $icon = 'EXT:' . $extensionKey . '/ext_icon.gif';
     }
     if (NULL === $this->getResolver()->resolveFluxControllerClassNameByExtensionKeyAndAction($qualifiedExtensionName, 'render', 'Backend')) {
         throw new \RuntimeException('Attempt to register a Backend controller without an associated BackendController. Extension key: ' . $extensionKey, 1368826271);
     }
     $moduleConfiguration = array('access' => 'user,group', 'icon' => $icon, 'labels' => 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_module_' . $formId . '.xlf');
     if (FALSE === empty($navigationComponent)) {
         $moduleConfiguration['navigationComponentId'] = $navigationComponent;
     }
     $moduleSignature = 'tx_' . $signature . '_' . ucfirst($formId);
     if (FALSE === isset($GLOBALS['TBE_MODULES'][$module])) {
         if (FALSE === strpos($position, ':')) {
             if ('top' === $position) {
                 $temp_TBE_MODULES = array($module => '');
                 $temp_TBE_MODULES = RecursiveArrayUtility::mergeRecursiveOverrule($temp_TBE_MODULES, $GLOBALS['TBE_MODULES']);
             } else {
                 $temp_TBE_MODULES = (array) $GLOBALS['TBE_MODULES'];
                 $temp_TBE_MODULES[$module] = '';
             }
         } else {
             list($command, $relativeKey) = explode(':', $position);
             foreach ($GLOBALS['TBE_MODULES'] as $key => $val) {
                 if ($key === $relativeKey) {
                     if ('before' === $command) {
                         $temp_TBE_MODULES[$module] = '';
                         $temp_TBE_MODULES[$key] = $val;
                     } else {
                         $temp_TBE_MODULES[$key] = $val;
                         $temp_TBE_MODULES[$module] = '';
                     }
                 } else {
                     $temp_TBE_MODULES[$key] = $val;
                 }
             }
         }
         $GLOBALS['TBE_MODULES'] = (array) $temp_TBE_MODULES;
         // register pseudo-module acting as group header
         $moduleConfiguration['labels'] = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_modulegroup.xlf';
         ExtensionUtility::registerModule($qualifiedExtensionName, $module, '', $position, array('Backend' => 'render,save'), $moduleConfiguration);
     }
     // register individual module in group
     $moduleConfiguration['labels'] = 'LLL:EXT:' . $extensionKey . '/Resources/Private/Language/locallang_module_' . $formId . '.xlf';
     ExtensionUtility::registerModule($qualifiedExtensionName, $module, $moduleSignature, $position, array('Backend' => 'render,save'), $moduleConfiguration);
 }
示例#14
0
 /**
  * @param string $label
  * @param string $path
  * @return NULL|string
  */
 protected function resolveLocalLanguageValueOfLabel($label, $path = NULL)
 {
     if (TRUE === $this->getDisableLocalLanguageLabels()) {
         return $label;
     }
     $name = $this->getName();
     $root = $this->getRoot();
     $extensionName = $this->extensionName;
     if (FALSE === $root instanceof Form) {
         $id = 'form';
     } else {
         $id = $root->getName();
     }
     $extensionKey = ExtensionNamingUtility::getExtensionKey($extensionName);
     if (FALSE === empty($label)) {
         return $this->translateLabelReference($label, $extensionKey);
     }
     if (TRUE === empty($extensionKey) || FALSE === ExtensionManagementUtility::isLoaded($extensionKey)) {
         return $name;
     }
     if (TRUE === empty($path)) {
         if (FALSE === $this instanceof Form) {
             $path = $this->getPath();
         } else {
             $path = '';
         }
     }
     $relativeFilePath = $this->getLocalLanguageFileRelativePath();
     $relativeFilePath = ltrim($relativeFilePath, '/');
     $filePrefix = 'LLL:EXT:' . $extensionKey . '/' . $relativeFilePath;
     $labelIdentifier = $filePrefix . ':' . trim('flux.' . $id . '.' . $path, '.');
     $translated = LocalizationUtility::translate($labelIdentifier, $extensionKey);
     return NULL !== $translated ? $translated : $labelIdentifier;
 }
 /**
  * @param array $row
  * @return array
  */
 public function getTemplatePaths(array $row)
 {
     $paths = parent::getTemplatePaths($row);
     $variant = $this->getVariant($row);
     if (FALSE === empty($variant)) {
         $extensionKey = ExtensionNamingUtility::getExtensionKey($variant);
         if (FALSE === empty($extensionKey)) {
             $overlayPaths = $this->configurationService->getViewConfigurationForExtensionName($extensionKey);
             $paths = array_merge_recursive($paths, $overlayPaths);
         }
     }
     return $paths;
 }
示例#16
0
 /**
  * Fills path arrays with default expected paths
  * based on package name (converted to extension
  * key automatically).
  *
  * Will replace any currently configured paths.
  *
  * @param string $packageName
  * @return void
  * @api
  */
 public function fillDefaultsByPackageName($packageName)
 {
     $extensionKey = ExtensionNamingUtility::getExtensionKey($packageName);
     $extensionPath = ExtensionManagementUtility::extPath($extensionKey);
     $this->setTemplateRootPaths(array($extensionPath . self::DEFAULT_TEMPLATES_DIRECTORY));
     $this->setLayoutRootPaths(array($extensionPath . self::DEFAULT_LAYOUTS_DIRECTORY));
     $this->setPartialRootPaths(array($extensionPath . self::DEFAULT_PARTIALS_DIRECTORY));
 }
示例#17
0
 /**
  * @param array $row
  * @return string
  */
 public function getExtensionKey(array $row)
 {
     $controllerExtensionKey = $this->getControllerExtensionKeyFromRecord($row);
     if (FALSE === empty($controllerExtensionKey)) {
         return ExtensionNamingUtility::getExtensionKey($controllerExtensionKey);
     }
     return parent::getExtensionKey($row);
 }
示例#18
0
 /**
  * @param array $row
  * @param Column $column
  * @param integer $colPosFluxContent
  * @param PageLayoutView $dblist
  * @param integer $target
  * @param string $id
  * @param string $content
  * @return string
  */
 protected function parseGridColumnTemplate(array $row, Column $column, $colPosFluxContent, $dblist, $target, $id, $content)
 {
     $label = $column->getLabel();
     if (strpos($label, 'LLL:') === 0) {
         $label = LocalizationUtility::translate($label, ExtensionNamingUtility::getExtensionName($column->getExtensionName()));
         if (empty($label)) {
             $label = $column->getLabel();
         }
     }
     // this variable defines if this drop-area gets activated on drag action
     // of a ce with the same data-language_uid
     $templateClassJsSortableLanguageId = $row['sys_language_uid'];
     // this variable defines which drop-areas will be activated
     // with a drag action of this element
     $templateDataLanguageUid = $row['sys_language_uid'];
     // but for language mode all (uid -1):
     if ((int) $row['sys_language_uid'] === -1) {
         /** @var \TYPO3\CMS\Backend\Controller\PageLayoutController $pageLayoutController */
         $pageLayoutController = $GLOBALS['SOBE'];
         $isColumnView = (int) $pageLayoutController->MOD_SETTINGS['function'] === 1;
         $isLanguagesView = (int) $pageLayoutController->MOD_SETTINGS['function'] === 2;
         if ($isColumnView) {
             $templateClassJsSortableLanguageId = $pageLayoutController->current_sys_language;
             $templateDataLanguageUid = $pageLayoutController->current_sys_language;
         } elseif ($isLanguagesView) {
             // If this is a language-all (uid -1) grid-element in languages-view
             // we use language-uid 0 for this elements drop-areas.
             // This can be done because a ce with language-uid -1 in languages view
             // is in TYPO3 7.6.4 only displayed in the default-language-column (maybe a bug atm.?).
             // Additionally there is no access to the information which
             // language column is currently rendered from here!
             // ($lP in typo3/cms/typo3/sysext/backend/Classes/View/PageLayoutView.php L485)
             $templateClassJsSortableLanguageId = 0;
             $templateDataLanguageUid = 0;
         }
     }
     return sprintf($this->templates['gridColumn'], $column->getColspan(), $column->getRowspan(), $column->getStyle(), $colPosFluxContent, $templateClassJsSortableLanguageId, $templateDataLanguageUid, $label, $target, $id, $this->drawNewIcon($row, $column) . $this->drawPasteIcon($row, $column) . $this->drawPasteIcon($row, $column, TRUE), $content);
 }
 /**
  * @param array $row
  * @return array
  */
 public function getTemplatePaths(array $row)
 {
     $paths = $this->templatePaths;
     $extensionKey = $this->getExtensionKey($row);
     $extensionKey = ExtensionNamingUtility::getExtensionKey($extensionKey);
     if (FALSE === is_array($paths)) {
         $extensionKey = $this->getExtensionKey($row);
         if (FALSE === empty($extensionKey) && TRUE === ExtensionManagementUtility::isLoaded($extensionKey)) {
             $paths = $this->configurationService->getViewConfigurationForExtensionName($extensionKey);
         }
     }
     if (NULL !== $paths && FALSE === is_array($paths)) {
         $this->configurationService->message('Template paths resolved for "' . $extensionKey . '" was not an array.', GeneralUtility::SYSLOG_SEVERITY_WARNING);
         $paths = NULL;
     }
     if (NULL === $paths) {
         $extensionKey = $this->getExtensionKey($row);
         if (FALSE === empty($extensionKey) && TRUE === ExtensionManagementUtility::isLoaded($extensionKey)) {
             $paths = array(ExtensionManagementUtility::extPath($extensionKey, 'Resources/Private/Templates/'), ExtensionManagementUtility::extPath($extensionKey, 'Resources/Private/Partials/'), ExtensionManagementUtility::extPath($extensionKey, 'Resources/Private/Layouts/'));
         } else {
             $paths = array();
         }
     }
     if (TRUE === is_array($paths)) {
         $paths = PathUtility::translatePath($paths);
     }
     return $paths;
 }
示例#20
0
文件: Form.php 项目: fluidtypo3/flux
 /**
  * @return string
  */
 public function getDescription()
 {
     $description = $this->description;
     $translated = NULL;
     $extensionKey = ExtensionNamingUtility::getExtensionKey($this->extensionName);
     if (TRUE === empty($description)) {
         $relativeFilePath = $this->getLocalLanguageFileRelativePath();
         $relativeFilePath = ltrim($relativeFilePath, '/');
         $filePrefix = 'LLL:EXT:' . $extensionKey . '/' . $relativeFilePath;
         $description = $filePrefix . ':' . trim('flux.' . $this->id . '.description');
     }
     return $description;
 }
示例#21
0
 /**
  * @param array $row
  * @return array
  */
 public function getTemplatePaths(array $row)
 {
     $paths = $this->templatePaths;
     $extensionKey = $this->getExtensionKey($row);
     $extensionKey = ExtensionNamingUtility::getExtensionKey($extensionKey);
     if (FALSE === is_array($paths)) {
         if (FALSE === empty($extensionKey)) {
             $paths = $this->configurationService->getViewConfigurationForExtensionName($extensionKey);
         }
     }
     if (TRUE === is_array($paths)) {
         $paths = PathUtility::translatePath($paths);
     }
     return $paths;
 }
 /**
  * @param string $extensionName
  * @param string $controllerName
  * @param string $actionName
  * @param string $pluginSignature
  * @return string
  */
 protected function performSubRendering($extensionName, $controllerName, $actionName, $pluginSignature)
 {
     $shouldRelay = $this->hasSubControllerActionOnForeignController($extensionName, $controllerName, $actionName);
     if (TRUE === $shouldRelay) {
         $foreignControllerClass = ResolveUtility::resolveFluxControllerClassNameByExtensionKeyAndAction($extensionName, $actionName, $controllerName);
         $extensionName = ExtensionNamingUtility::getExtensionName($extensionName);
         return $this->callSubControllerAction($extensionName, $foreignControllerClass, $actionName, $pluginSignature);
     }
     return $this->view->render();
 }
 /**
  * @return Form[][]
  */
 public function getContentElementFormInstances()
 {
     $elements = array();
     $allTemplatePaths = $this->getContentConfiguration();
     $controllerName = 'Content';
     foreach ($allTemplatePaths as $registeredExtensionKey => $templatePathSet) {
         $files = array();
         $extensionKey = TRUE === isset($templatePathSet['extensionKey']) ? $templatePathSet['extensionKey'] : $registeredExtensionKey;
         $extensionKey = ExtensionNamingUtility::getExtensionKey($extensionKey);
         $templatePaths = new TemplatePaths($templatePathSet);
         $viewContext = new ViewContext(NULL, $extensionKey);
         $viewContext->setTemplatePaths($templatePaths);
         $viewContext->setSectionName('Configuration');
         foreach ($templatePaths->getTemplateRootPaths() as $templateRootPath) {
             $files = GeneralUtility::getAllFilesAndFoldersInPath($files, $templateRootPath . '/' . $controllerName . '/', 'html');
             if (0 < count($files)) {
                 foreach ($files as $templateFilename) {
                     $actionName = pathinfo($templateFilename, PATHINFO_FILENAME);
                     $fileRelPath = $actionName . '.html';
                     $viewContext->setTemplatePathAndFilename($templateFilename);
                     $form = $this->getFormFromTemplateFile($viewContext);
                     if (TRUE === empty($form)) {
                         $this->sendDisabledContentWarning($templateFilename);
                         continue;
                     }
                     if (FALSE === $form->getEnabled()) {
                         $this->sendDisabledContentWarning($templateFilename);
                         continue;
                     }
                     $id = preg_replace('/[\\.\\/]/', '_', $registeredExtensionKey . '/' . $actionName . '.html');
                     $form->setOption('contentElementId', $registeredExtensionKey . ':' . $fileRelPath);
                     $elements[$registeredExtensionKey][$id] = $form;
                 }
             }
         }
     }
     return $elements;
 }
示例#24
0
 /**
  * @param array $data
  * @return mixed
  */
 public function conduct($data)
 {
     $extensionName = $this->getExtensionName();
     /** @var $request Request */
     $request = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Request');
     $request->setControllerName($this->getController());
     $request->setControllerActionName($this->getAction());
     list($vendorName, $extensionName) = ExtensionNamingUtility::getVendorNameAndExtensionName($extensionName);
     $request->setControllerExtensionName($extensionName);
     if (NULL !== $vendorName) {
         $request->setControllerVendorName($vendorName);
     }
     $request->setArguments($data);
     /** @var $response Response */
     $response = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
     /** @var $dispatcher Dispatcher */
     $dispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Dispatcher');
     $dispatcher->dispatch($request, $response);
     return $response->getContent();
 }
示例#25
0
 /**
  * @param string $extensionName
  * @param string $controllerName
  * @param string $actionName
  * @return boolean
  */
 protected function hasSubControllerActionOnForeignController($extensionName, $controllerName, $actionName)
 {
     $potentialControllerClassName = $this->configurationService->getResolver()->resolveFluxControllerClassNameByExtensionKeyAndAction($extensionName, $actionName, $controllerName);
     $isForeign = ExtensionNamingUtility::getExtensionName($extensionName) !== ExtensionNamingUtility::getExtensionName($this->extensionName);
     $isValidController = class_exists($potentialControllerClassName);
     return TRUE === $isForeign && TRUE === $isValidController;
 }
 /**
  * @param string $extensionKey
  * @param string $controllerName
  * @return boolean|string
  */
 private static function buildControllerClassNameFromExtensionKeyAndControllerType($extensionKey, $controllerName)
 {
     if (TRUE === ExtensionNamingUtility::hasVendorName($extensionKey)) {
         list($vendorName, $extensionName) = ExtensionNamingUtility::getVendorNameAndExtensionName($extensionKey);
         $potentialClassName = $vendorName . '\\' . $extensionName . '\\Controller\\' . $controllerName . 'Controller';
     } else {
         $extensionName = ExtensionNamingUtility::getExtensionName($extensionKey);
         $potentialClassName = $extensionName . '\\Controller\\' . $controllerName . 'Controller';
         if (FALSE === class_exists($potentialClassName)) {
             $potentialClassName = 'Tx_' . $extensionName . '_Controller_' . $controllerName . 'Controller';
         }
     }
     return $potentialClassName;
 }
示例#27
0
 /**
  * Stub: Get the package name of the controller associated with $row
  *
  * @param array $row
  * @return string
  */
 public function getControllerPackageNameFromRecord(array $row)
 {
     $extensionKey = $this->getControllerExtensionKeyFromRecord($row);
     $extensionName = ExtensionNamingUtility::getExtensionName($extensionKey);
     $vendor = ExtensionNamingUtility::getVendorName($extensionKey);
     return NULL !== $vendor ? $vendor . '.' . $extensionName : $extensionName;
 }
示例#28
0
 /**
  * Returns the plugin.tx_extsignature.settings array.
  * Accepts any input extension name type.
  *
  * @param string $extensionName
  * @return array
  */
 public function getSettingsForExtensionName($extensionName)
 {
     $signature = ExtensionNamingUtility::getExtensionSignature($extensionName);
     return (array) $this->getTypoScriptByPath('plugin.tx_' . $signature . '.settings');
 }
示例#29
0
 /**
  * @param string $extension
  * @param string $template
  * @param array $parameters
  * @return string
  */
 protected function renderOption($extension, $template, array $parameters)
 {
     $name = $parameters['itemFormElName'];
     $value = $parameters['itemFormElValue'];
     $onChange = 'onclick="if (confirm(TBE_EDITOR.labels.onChangeAlert) && TBE_EDITOR.checkSubmit(-1)){ TBE_EDITOR.submitForm() };"';
     $selector = '';
     try {
         $extensionName = ExtensionNamingUtility::getExtensionKey($extension);
         $paths = $this->configurationService->getPageConfiguration($extensionName);
         $templatePaths = new TemplatePaths($paths);
         $templatePathAndFilename = $templatePaths->resolveTemplateFileForControllerAndActionAndFormat('Page', $template);
         if (FALSE === file_exists($templatePathAndFilename)) {
             $this->configurationService->message('Missing template file: ' . $templatePathAndFilename, GeneralUtility::SYSLOG_SEVERITY_WARNING);
             return '';
         }
         $viewContext = new ViewContext($templatePathAndFilename, $extensionName);
         $viewContext->setTemplatePaths($templatePaths);
         $viewContext->setSectionName('Configuration');
         $form = $this->configurationService->getFormFromTemplateFile($viewContext);
         if (FALSE === $form instanceof Form) {
             $this->configurationService->message('Template file ' . $templatePathAndFilename . ' contains an unparsable Form definition', GeneralUtility::SYSLOG_SEVERITY_FATAL);
             return '';
         }
         if (FALSE === $form->getEnabled()) {
             $this->configurationService->message('Template file ' . $templatePathAndFilename . ' is disabled by configuration', GeneralUtility::SYSLOG_SEVERITY_NOTICE);
             return '';
         }
         $thumbnail = MiscellaneousUtility::getIconForTemplate($form);
         $label = $form->getLabel();
         $optionValue = $extension . '->' . $template;
         $selected = $optionValue == $value ? ' checked="checked"' : '';
         $option = '<label style="padding: 0.5em; border: 1px solid #CCC; display: inline-block; vertical-align: bottom; margin: 0 1em 1em 0; cursor: pointer; ' . ($selected ? 'background-color: #DDD;' : '') . '">';
         $option .= '<img src="' . $thumbnail . '" alt="' . $label . '" style="margin: 0.5em 0 0.5em 0; max-width: 196px; max-height: 128px;"/><br />';
         $option .= '<input type="radio" value="' . $optionValue . '"' . $selected . ' name="' . $name . '" ' . $onChange . ' /> ' . $label;
         $option .= '</label>';
         $selector .= $option . LF;
     } catch (\RuntimeException $error) {
         $this->configurationService->debug($error);
     }
     return $selector;
 }
示例#30
0
 /**
  * @param string $extension
  * @param string $contentType
  * @param string $version
  * @return string
  */
 public function getIconFromVersion($extension, $contentType, $version = NULL)
 {
     $extensionKey = ExtensionNamingUtility::getExtensionKey($extension);
     $templatePathAndFilename = $this->resolveTemplateFileForVariant($extensionKey, $contentType, $extension, $version);
     $paths = $this->getViewConfigurationForExtensionName($extensionKey);
     $templatePaths = new TemplatePaths($paths);
     $viewContext = new ViewContext($templatePathAndFilename, $extensionKey);
     $viewContext->setTemplatePaths($templatePaths);
     $viewContext->setSectionName('Configuration');
     $form = FluxService::getFormFromTemplateFile($viewContext);
     if (FALSE === $form instanceof Form) {
         return '';
     } else {
         return MiscellaneousUtility::getIconForTemplate($form);
     }
 }