Esempio n. 1
0
 /**
  * Get the absolute table icon for the given model name
  *
  * @param string  $modelClassName
  * @param boolean $extSyntax Get the EXT: Syntax instead of a rel Path
  *
  * @return string
  */
 public static function getByModelName($modelClassName, $extSyntax = false)
 {
     $modelInformation = ClassNamingUtility::explodeObjectModelName($modelClassName);
     $extensionKey = GeneralUtility::camelCaseToLowerCaseUnderscored($modelInformation['extensionName']);
     $modelName = str_replace('\\', '/', $modelInformation['modelName']);
     $tableIconPath = ExtensionManagementUtility::extPath($extensionKey) . 'Resources/Public/Icons/' . $modelName . '.';
     $fileExtension = self::getIconFileExtension($tableIconPath);
     if ($fileExtension) {
         return self::returnRelativeIconPath($extensionKey, 'Resources/Public/Icons/' . $modelName . '.' . $fileExtension, $extSyntax);
     }
     return self::getByExtensionKey($extensionKey, $extSyntax);
 }
Esempio n. 2
0
 /**
  * Find table and model information for the given extension key
  *
  * @param string $extensionKey
  *
  * @return array
  */
 protected function findTableAndModelInformationForExtension($extensionKey)
 {
     $information = [];
     $register = SmartObjectRegister::getRegister();
     foreach ($register as $class) {
         $parts = ClassNamingUtility::explodeObjectModelName($class);
         if (GeneralUtility::camelCaseToLowerCaseUnderscored($parts['extensionName']) === $extensionKey) {
             if (ModelUtility::getTableNameByModelReflectionAnnotation($class) === '') {
                 $information[] = ['table' => ModelUtility::getTableNameByModelName($class), 'class' => $class];
             }
         }
     }
     return $information;
 }
Esempio n. 3
0
 /**
  * Find table and model information for the given extension key
  *
  * @param string $extensionKey
  *
  * @return array
  */
 protected function findTableAndModelInformationForExtension($extensionKey)
 {
     $information = [];
     $register = SmartObjectRegister::getRegister();
     foreach ($register as $class) {
         $parts = ClassNamingUtility::explodeObjectModelName($class);
         if (GeneralUtility::camelCaseToLowerCaseUnderscored($parts['extensionName']) === $extensionKey) {
             if (ModelUtility::getTableNameByModelReflectionAnnotation($class) === '') {
                 $modelInformation = SmartObjectInformationService::getInstance()->getCustomModelFieldTca($class);
                 $information[] = ['table' => ModelUtility::getTableNameByModelName($class), 'properties' => array_keys($modelInformation)];
             }
         }
     }
     return $information;
 }
 /**
  * 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);
 }