예제 #1
0
파일: Core.php 프로젝트: busynoggin/flux
 /**
  * @param string $table
  * @param Form $form
  * @return void
  */
 public static function registerFormForTable($table, Form $form)
 {
     if (NULL === $form->getName()) {
         $form->setName($table);
     }
     if (NULL === $form->getExtensionName() && TRUE === isset($GLOBALS['_EXTKEY'])) {
         $form->setExtensionName(GeneralUtility::underscoredToUpperCamelCase($GLOBALS['_EXTKEY']));
     }
     self::$forms['tables'][$table] = $form;
 }
 /**
  * @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);
 }