Пример #1
0
 /**
  * Add the label to a XML file
  *
  * @param string $extensionKey
  * @param string $key
  * @param string $default
  *
  * @return NULL
  */
 public function addLabel($extensionKey, $key, $default)
 {
     // Excelude
     if (!strlen($default)) {
         return;
     }
     if (!strlen($key)) {
         return;
     }
     if (!strlen($extensionKey)) {
         return;
     }
     if (GeneralUtility::isFirstPartOfStr($key, 'LLL:')) {
         return;
     }
     $absolutePath = $this->getAbsoluteFilename($extensionKey);
     $content = GeneralUtility::getUrl($absolutePath);
     if (strpos($content, ' index="' . $key . '"') !== false || trim($content) === '') {
         return;
     }
     $replace = '<languageKey index="default" type="array">' . LF . TAB . TAB . TAB . '<label index="' . $key . '">' . $this->wrapCdata($default) . '</label>';
     $content = str_replace('<languageKey index="default" type="array">', $replace, $content);
     FileUtility::writeFileAndCreateFolder($absolutePath, $content);
     $this->clearCache();
 }
 /**
  * Create default file
  *
  * @param string $extensionKey
  *
  * @return bool
  */
 public function createFileIfNotExists($extensionKey)
 {
     $fileName = $this->getAbsoluteFilename($extensionKey);
     if (is_file($fileName)) {
         return true;
     }
     return FileUtility::writeFileAndCreateFolder($fileName, $this->getBaseFileContent($extensionKey));
 }
Пример #3
0
 /**
  * Add the label
  *
  * @param string $extensionKey
  * @param string $key
  * @param string $default
  *
  * @return bool
  */
 public function addLabel($extensionKey, $key, $default)
 {
     // Exclude
     if (!strlen($default)) {
         return;
     }
     if (!strlen($key)) {
         return;
     }
     if (!strlen($extensionKey)) {
         return;
     }
     $absolutePath = $this->getAbsoluteFilename($extensionKey);
     include $absolutePath;
     $LOCAL_LANG['default'][$key] = $default;
     FileUtility::writeFileAndCreateFolder($absolutePath, $this->getPhpContentByLabels($LOCAL_LANG));
     $this->clearCache();
 }
Пример #4
0
 /**
  * Add the Label to the local lang XLIFF
  *
  * @param string $extensionKey
  * @param string $key
  * @param string $default
  *
  * @return NULL
  */
 public function addLabel($extensionKey, $key, $default)
 {
     // Exclude
     if (!strlen($default)) {
         return;
     }
     if (!strlen($key)) {
         return;
     }
     if (!strlen($extensionKey)) {
         return;
     }
     $absolutePath = $this->getAbsoluteFilename($extensionKey);
     $content = GeneralUtility::getUrl($absolutePath);
     $replace = '<body>' . LF . TAB . TAB . TAB . '<trans-unit id="' . $key . '"><source><![CDATA[' . $default . ']]></source></trans-unit>';
     $content = str_replace('<body>', $replace, $content);
     FileUtility::writeFileAndCreateFolder($absolutePath, $content);
     $this->clearCache();
 }
Пример #5
0
 /**
  * Add the Label to the local lang XLIFF
  *
  * @param string $extensionKey
  * @param string $key
  * @param string $default
  *
  * @return NULL
  */
 public function addLabel($extensionKey, $key, $default)
 {
     // Exclude
     if (!strlen($default)) {
         return;
     }
     if (!strlen($key)) {
         return;
     }
     if (!strlen($extensionKey)) {
         return;
     }
     $absolutePath = $this->getAbsoluteFilename($extensionKey);
     $content = GeneralUtility::getUrl($absolutePath);
     if (strpos($content, ' id="' . $key . '"') !== false || trim($content) === '') {
         return;
     }
     $replace = '<body>' . LF . TAB . TAB . TAB . '<trans-unit id="' . $key . '"><source>' . $this->wrapCdata($default) . '</source></trans-unit>';
     $content = str_replace('<body>', $replace, $content);
     FileUtility::writeFileAndCreateFolder($absolutePath, $content);
     $this->clearCache();
 }
Пример #6
0
 /**
  * Write the given content object template to the target path
  *
  * @param string $name
  * @param string $absoluteTargetPath
  */
 protected function writeContentTemplateToTarget($name, $absoluteTargetPath)
 {
     $template = GeneralUtility::getUrl(ExtensionManagementUtility::extPath('autoloader', 'Resources/Private/Templates/ContentObjects/' . $name . '.html'));
     FileUtility::writeFileAndCreateFolder($absoluteTargetPath, $template);
 }
Пример #7
0
 /**
  * Check if the given file is already existing
  *
  * @param $path
  * @param $modelClass
  *
  * @return void
  */
 protected function checkCshFile($path, $modelClass)
 {
     if (is_file($path)) {
         return;
     }
     $dir = PathUtility::dirname($path);
     if (!is_dir($dir)) {
         GeneralUtility::mkdir_deep($dir);
     }
     $information = SmartObjectInformationService::getInstance()->getCustomModelFieldTca($modelClass);
     $properties = array_keys($information);
     $templatePath = 'Resources/Private/Templates/ContextSensitiveHelp/LanguageDescription.xml';
     $standaloneView = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
     $standaloneView->setTemplatePathAndFilename(ExtensionManagementUtility::extPath('autoloader', $templatePath));
     $standaloneView->assign('properties', $properties);
     $content = $standaloneView->render();
     FileUtility::writeFileAndCreateFolder($path, $content);
 }
Пример #8
0
 /**
  * Check and create the TCA information
  * disable this for better performance
  */
 public static function checkAndCreateTcaInformation()
 {
     $register = SmartObjectRegister::getRegister();
     $baseTemplatePath = ExtensionManagementUtility::extPath('autoloader', 'Resources/Private/Templates/TcaFiles/');
     $defaultTemplate = GeneralUtility::getUrl($baseTemplatePath . 'Default.tmpl');
     $overrideTemplate = GeneralUtility::getUrl($baseTemplatePath . 'Override.tmpl');
     $search = ['__modelName__', '__tableName__', '__extensionKey__'];
     foreach ($register as $model) {
         $extensionKey = ClassNamingUtility::getExtensionKeyByModel($model);
         $basePath = ExtensionManagementUtility::extPath($extensionKey) . 'Configuration/TCA/';
         $tableName = ModelUtility::getTableNameByModelReflectionAnnotation($model);
         if ($tableName !== '') {
             $tcaFileName = $basePath . 'Overrides/' . $tableName . '.php';
             $template = $overrideTemplate;
         } else {
             $tableName = ModelUtility::getTableNameByModelName($model);
             $tcaFileName = $basePath . $tableName . '.php';
             $template = $defaultTemplate;
         }
         if (!is_file($tcaFileName)) {
             $replace = [str_replace('\\', '\\\\', $model), $tableName, $extensionKey];
             $content = str_replace($search, $replace, $template);
             FileUtility::writeFileAndCreateFolder($tcaFileName, $content);
         }
     }
 }