TYPO3 CMS  TYPO3_6-2
DownloadController.php
Go to the documentation of this file.
1 <?php
3 
19 
26 
32 
38 
43  protected $managementService;
44 
49  protected $installUtility;
50 
55  protected $downloadUtility;
56 
63  public function checkDependenciesAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) {
64  $message = '';
65  $title = '';
66  $hasDependencies = FALSE;
67  $hasErrors = FALSE;
68  try {
69  $dependencyTypes = $this->managementService->getAndResolveDependencies($extension);
70  if (count($dependencyTypes) > 0) {
71  $hasDependencies = TRUE;
72  $message = $this->translate('downloadExtension.dependencies.headline');
73  foreach ($dependencyTypes as $dependencyType => $dependencies) {
74  $extensions = '';
75  foreach ($dependencies as $extensionKey => $dependency) {
76  $extensions .= $this->translate('downloadExtension.dependencies.extensionWithVersion', array(
77  $extensionKey, $dependency->getVersion()
78  )) . '<br />';
79  }
80  $message .= $this->translate('downloadExtension.dependencies.typeHeadline',
81  array(
82  $this->translate('downloadExtension.dependencyType.' . $dependencyType),
83  $extensions
84  )
85  );
86  }
87  $title = $this->translate('downloadExtension.dependencies.resolveAutomatically');
88  }
89  $this->view->assign('dependencies', $dependencyTypes);
90  } catch (\Exception $e) {
91  $hasErrors = TRUE;
92  $title = $this->translate('downloadExtension.dependencies.errorTitle');
93  $message = $e->getMessage();
94  }
95  $this->view->assign('extension', $extension)
96  ->assign('hasDependencies', $hasDependencies)
97  ->assign('hasErrors', $hasErrors)
98  ->assign('message', $message)
99  ->assign('title', $title);
100  }
101 
108  public function installFromTerAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension, $downloadPath) {
109  list($result, $errorMessages) = $this->installFromTer($extension, $downloadPath);
110  $this->view
111  ->assign('result', $result)
112  ->assign('extension', $extension)
113  ->assign('unresolvedDependencies', $errorMessages);
114  }
115 
122  public function installExtensionWithoutSystemDependencyCheckAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) {
123  $this->managementService->setSkipSystemDependencyCheck(TRUE);
124  $this->forward('installFromTer', NULL, NULL, array('extension' => $extension, 'downloadPath' => 'Local'));
125  }
126 
134  public function installDistributionAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) {
135  if (!\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('impexp')) {
136  $this->forward('distributions', 'List');
137  }
138  list($result, $errorMessages) = $this->installFromTer($extension);
139  if ($errorMessages) {
140  foreach ($errorMessages as $extensionKey => $messages) {
141  foreach ($messages as $message) {
142  $this->addFlashMessage(
143  $message['message'],
144  \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate(
145  'distribution.error.headline',
146  'extensionmanager',
147  array($extensionKey)
148  ),
149  \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR
150  );
151  }
152  }
153 
154  // Redirect back to distributions list action
155  $this->redirect(
156  'distributions',
157  'List'
158  );
159  } else {
160  // FlashMessage that extension is installed
161  $this->addFlashMessage(
162  \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('distribution.welcome.message', 'extensionmanager')
163  . ' <strong>' . $extension->getExtensionKey() . '</strong>',
164  \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('distribution.welcome.headline', 'extensionmanager')
165  );
166 
167  // Redirect to show action
168  $this->redirect(
169  'show',
170  'Distribution',
171  NULL,
172  array('extension' => $extension)
173  );
174  }
175  }
176 
185  protected function updateExtensionAction() {
186  $extensionKey = $this->request->getArgument('extension');
187  $version = $this->request->getArgument('version');
188  $extension = $this->extensionRepository->findOneByExtensionKeyAndVersion($extensionKey, $version);
189  if (!$extension instanceof Extension) {
190  $extension = $this->extensionRepository->findHighestAvailableVersion($extensionKey);
191  }
193  try {
194  if (in_array($extensionKey, $installedExtensions, TRUE)) {
195  // To resolve new dependencies the extension is installed again
196  $this->managementService->installExtension($extension);
197  } else {
198  $this->managementService->downloadMainExtension($extension);
199  }
200  $this->addFlashMessage(
201  htmlspecialchars($this->translate('extensionList.updateFlashMessage.body', array($extensionKey))),
202  $this->translate('extensionList.updateFlashMessage.title')
203  );
204  } catch (\Exception $e) {
205  $this->addFlashMessage(htmlspecialchars($e->getMessage()), '', FlashMessage::ERROR);
206  }
207 
208  return '';
209  }
210 
218  protected function updateCommentForUpdatableVersionsAction() {
219  $extensionKey = $this->request->getArgument('extension');
220  $versionStart = $this->request->getArgument('integerVersionStart');
221  $versionStop = $this->request->getArgument('integerVersionStop');
222  $updateComments = array();
224  $updatableVersions = $this->extensionRepository->findByVersionRangeAndExtensionKeyOrderedByVersion(
225  $extensionKey,
226  $versionStart,
227  $versionStop,
228  FALSE
229  );
230  $highestPossibleVersion = FALSE;
231 
232  foreach ($updatableVersions as $updatableVersion) {
233  if ($highestPossibleVersion === FALSE) {
234  $highestPossibleVersion = $updatableVersion->getVersion();
235  }
236  $updateComments[$updatableVersion->getVersion()] = $updatableVersion->getUpdateComment();
237  }
238  $this->view->assign('updateComments', $updateComments)
239  ->assign('extensionKey', $extensionKey)
240  ->assign('version', $highestPossibleVersion);
241  }
242 
251  protected function installFromTer(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension, $downloadPath = 'Local') {
252  $result = FALSE;
253  $errorMessages = array();
254  try {
255  $this->downloadUtility->setDownloadPath($downloadPath);
256  if (($result = $this->managementService->installExtension($extension)) === FALSE) {
257  $errorMessages = $this->managementService->getDependencyErrors();
258  }
259  } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
260  $errorMessages = array(
261  $extension->getExtensionKey() => array(
262  array(
263  'code' => $e->getCode(),
264  'message' => $e->getMessage(),
265  )
266  ),
267  );
268  }
269 
270  return array($result, $errorMessages);
271  }
272 }
installExtensionWithoutSystemDependencyCheckAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension)
installDistributionAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension)
forward($actionName, $controllerName=NULL, $extensionName=NULL, array $arguments=NULL)
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)
addFlashMessage($messageBody, $messageTitle='', $severity=\TYPO3\CMS\Core\Messaging\AbstractMessage::OK, $storeInSession=TRUE)
static translate($key, $extensionName, $arguments=NULL)
installFromTer(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension, $downloadPath='Local')
installFromTerAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension, $downloadPath)
checkDependenciesAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension)