38 $documents = $this->findSphinxDocuments();
39 $openOfficeDocuments = $this->findOpenOfficeDocuments();
42 foreach ($openOfficeDocuments as $documentKey => $document) {
43 if (!isset($documents[$documentKey])) {
44 $documents[$documentKey] = $document;
57 public function findByLanguage($language) {
58 $allDocuments = $this->
findAll();
61 $languageDependencies = array();
65 $shortLanguage = $language;
66 if (!in_array($shortLanguage,
$locales->getLocales()) && strpos($shortLanguage,
'_') !== FALSE) {
67 list($shortLanguage, $_) = explode(
'_', $shortLanguage);
69 if (in_array($shortLanguage,
$locales->getLocales())) {
70 $languageDependencies[] = $language;
71 if ($language !== $shortLanguage) {
72 $languageDependencies[] = $shortLanguage;
74 foreach (
$locales->getLocaleDependencies($shortLanguage) as $languageDependency) {
75 $languageDependencies[] = $languageDependency;
78 if ($language !==
'default') {
79 $languageDependencies[] =
'default';
82 foreach ($allDocuments as $document) {
84 $selectedTranslation = NULL;
85 $highestPriorityLanguageIndex = count($languageDependencies);
87 $translations = $document->getTranslations();
88 foreach ($translations as $translation) {
89 $languageIndex = array_search($translation->getLanguage(), $languageDependencies);
90 if ($languageIndex !== FALSE) {
91 if ($languageIndex < $highestPriorityLanguageIndex) {
92 $selectedTranslation = $translation;
93 $highestPriorityLanguageIndex = $languageIndex;
98 if (strpos($translation->getLanguage(),
'_') !== FALSE) {
99 list($translationLanguage, $_) = explode(
'_', $translation->getLanguage());
100 $languageIndex = array_search($translationLanguage, $languageDependencies);
101 if ($languageIndex !== FALSE && $languageIndex < $highestPriorityLanguageIndex) {
102 $selectedTranslation = $translation;
103 $highestPriorityLanguageIndex = $languageIndex;
109 $newTranslations = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
110 $document->setTranslations($newTranslations);
111 if ($selectedTranslation !== NULL) {
112 $document->addTranslation($selectedTranslation);
117 return $allDocuments;
125 protected function findSphinxDocuments() {
126 $basePath =
'typo3conf/Documentation/';
128 $documents = array();
131 if (!is_array($documentKeys)) {
135 foreach ($documentKeys as $documentKey) {
139 $document = $this->objectManager->get(
'TYPO3\\CMS\\Documentation\\Domain\\Model\\Document')
140 ->setPackageKey($documentKey)
143 $languagePath = $basePath . $documentKey .
'/';
145 foreach ($languages as $language) {
146 $metadata = $this->
getMetadata($documentKey, $language);
147 if (!empty($metadata[
'extensionKey'])) {
148 $document->setExtensionKey($metadata[
'extensionKey']);
152 $documentTranslation = $this->objectManager->get(
'TYPO3\\CMS\\Documentation\\Domain\\Model\\DocumentTranslation')
153 ->setLanguage($language)
154 ->setTitle($metadata[
'title'])
155 ->setDescription($metadata[
'description']);
157 $formatPath = $languagePath . $language .
'/';
159 foreach ($formats as $format) {
164 $indexFiles = array(
'Index.html',
'index.html',
'index.htm');
165 foreach ($indexFiles as $indexFile) {
166 if (file_exists(PATH_site . $formatPath . $format .
'/' . $indexFile)) {
167 $documentFile = $indexFile;
175 if (count($files) > 0) {
176 $documentFile = current($files);
180 if (!empty($documentFile)) {
182 $documentFormat = $this->objectManager->get(
'TYPO3\\CMS\\Documentation\\Domain\\Model\\DocumentFormat')
184 ->setPath($formatPath . $format .
'/' . $documentFile);
186 $documentTranslation->addFormat($documentFormat);
190 if (count($documentTranslation->getFormats()) > 0) {
191 $document->addTranslation($documentTranslation);
192 $documents[$documentKey] = $document;
205 protected function findOpenOfficeDocuments() {
206 $documents = array();
207 $language =
'default';
209 foreach (
$GLOBALS[
'TYPO3_LOADED_EXT'] as $extensionKey => $extensionData) {
210 $path = $extensionData[
'siteRelPath'] .
'doc/';
211 if (is_file(PATH_site . $path .
'manual.sxw')) {
212 $documentKey =
'typo3cms.extensions.' . $extensionKey;
216 $document = $this->objectManager->get(
'TYPO3\\CMS\\Documentation\\Domain\\Model\\Document')
217 ->setPackageKey($documentKey)
218 ->setExtensionKey($extensionKey)
221 $metadata = $this->
getMetadata($documentKey, $language);
223 $documentTranslation = $this->objectManager->get(
'TYPO3\\CMS\\Documentation\\Domain\\Model\\DocumentTranslation')
224 ->setLanguage($language)
225 ->setTitle($metadata[
'title'])
226 ->setDescription($metadata[
'description']);
229 $documentFormat = $this->objectManager->get(
'TYPO3\\CMS\\Documentation\\Domain\\Model\\DocumentFormat')
231 ->setPath($path .
'manual.sxw');
233 $documentTranslation->addFormat($documentFormat);
234 $document->addTranslation($documentTranslation);
235 $documents[$documentKey] = $document;
250 $documentPath = PATH_site .
'typo3conf/Documentation/' . $documentKey .
'/' . $language .
'/';
252 'title' => $documentKey,
256 $extensionKey = substr($documentKey, 20);
257 if (\
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded($extensionKey)) {
260 } elseif (is_file($documentPath .
'composer.json')) {
261 $info = json_decode(file_get_contents($documentPath .
'composer.json'), TRUE);
262 if (is_array($info)) {
263 $metadata[
'title'] = $info[
'name'];
264 $metadata[
'description'] = $info[
'description'];
getMetadata($documentKey, $language)
static isFirstPartOfStr($str, $partStr)
static getIcon($documentKey)
static makeInstance($className)
static getFilesInDir($path, $extensionList='', $prependPath=FALSE, $order='', $excludePattern='')
static getExtensionMetaData($extensionKey)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]