TYPO3 CMS  TYPO3_6-2
DocumentController.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
33 
39 
46  protected $languageUtility;
47 
55 
61  public function listAction() {
62  $documents = $this->getDocuments();
63 
64  // Filter documents to be shown for current user
65  $hideDocuments = $this->getBackendUser()->getTSConfigVal('mod.help_DocumentationDocumentation.documents.hide');
66  $hideDocuments = GeneralUtility::trimExplode(',', $hideDocuments, TRUE);
67  if (count($hideDocuments) > 0) {
68  $documents = array_diff_key($documents, array_flip($hideDocuments));
69  }
70  $showDocuments = $this->getBackendUser()->getTSConfigVal('mod.help_DocumentationDocumentation.documents.show');
71  $showDocuments = GeneralUtility::trimExplode(',', $showDocuments, TRUE);
72  if (count($showDocuments) > 0) {
73  $documents = array_intersect_key($documents, array_flip($showDocuments));
74  }
75 
76  $this->view->assign('documents', $documents);
77  }
78 
85  public function getDocuments() {
86  $language = $this->languageUtility->getDocumentationLanguage();
87  $documents = $this->documentRepository->findByLanguage($language);
88 
89  $documents = $this->emitAfterInitializeDocumentsSignal($language, $documents);
90 
91  return $documents;
92  }
93 
101  protected function emitAfterInitializeDocumentsSignal($language, array $documents) {
102  $this->signalSlotDispatcher->dispatch(
103  __CLASS__,
104  'afterInitializeDocuments',
105  array(
106  $language,
107  &$documents,
108  )
109  );
110  return $documents;
111  }
112 
118  public function downloadAction() {
119  // This action is reserved for admin users. Redirect to default view if not.
120  if (!$this->getBackendUser()->isAdmin()) {
121  $this->redirect('list');
122  }
123 
124  // Retrieve the list of official documents
125  $documents = $this->documentationService->getOfficialDocuments();
126 
127  // Merge with the list of local extensions
128  $extensions = $this->documentationService->getLocalExtensions();
129  $allDocuments = array_merge($documents, $extensions);
130 
131  $this->view->assign('documents', $allDocuments);
132  }
133 
142  public function fetchAction($url, $key, $version = NULL) {
143  // This action is reserved for admin users. Redirect to default view if not.
144  if (!$this->getBackendUser()->isAdmin()) {
145  $this->redirect('list');
146  }
147 
148  $language = $this->languageUtility->getDocumentationLanguage();
149  try {
150  $result = $this->documentationService->fetchNearestDocument($url, $key, $version ?: 'latest', $language);
151 
152  if ($result) {
153  $this->controllerContext->getFlashMessageQueue()->enqueue(
155  'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
156  \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
157  'downloadSucceeded',
158  'documentation'
159  ),
160  '',
161  \TYPO3\CMS\Core\Messaging\AbstractMessage::OK,
162  TRUE
163  )
164  );
165  } else {
166  $this->controllerContext->getFlashMessageQueue()->enqueue(
168  'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
169  \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
170  'downloadFailedNoArchive',
171  'documentation'
172  ),
173  \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
174  'downloadFailed',
175  'documentation'
176  ),
177  \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR,
178  TRUE
179  )
180  );
181  }
182  } catch (\Exception $e) {
183  $this->controllerContext->getFlashMessageQueue()->enqueue(
185  'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
186  \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
187  'downloadFailedDetails',
188  'documentation',
189  array(
190  $key,
191  $e->getMessage(),
192  $e->getCode()
193  )
194  ),
196  'downloadFailed',
197  'documentation'
198  ),
200  TRUE
201  )
202  );
203  }
204  $this->redirect('download');
205  }
206 
212  protected function getBackendUser() {
213  return $GLOBALS['BE_USER'];
214  }
215 
216 }
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
redirect($actionName, $controllerName=NULL, $extensionName=NULL, array $arguments=NULL, $pageUid=NULL, $delay=0, $statusCode=303)
static translate($key, $extensionName, $arguments=NULL)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]