/** * The view action loads the file from the given documentation and * acts as a proxy between the documentation browser and the private * documentation, that is not directly accessible. * * @param string $packageKey The package key * @param string $documentationName The documentation name * @param string $language The language * @param string $file The file to display * @return string The file contents * @author Christopher Hlubek <*****@*****.**> */ public function viewAction($packageKey, $documentationName, $language, $file) { $packageKey = $this->packageManager->getCaseSensitivePackageKey($packageKey); $package = $this->packageManager->getPackage($packageKey); $documentations = $package->getPackageDocumentations(); foreach ($documentations as $iteratedDocumentationName => $iteratedDocumentation) { if (strtolower($iteratedDocumentationName) == strtolower($documentationName)) { $documentation = $iteratedDocumentation; break; } } if (!isset($documentation)) { return 'Documentation for ' . $packageKey . ' / ' . $documentationName . ' not found'; } $formats = $documentation->getDocumentationFormats(); if (!isset($formats['HTML'])) { return 'HTML documentation for ' . $packageKey . ' not found'; } $format = $formats['HTML']; $contentType = $this->guessContentTypeByFilename($file); header('Content-Type: ' . $contentType); $path = $format->getFormatPath() . $language . '/' . $file; $path = dirname($path) . '/' . basename($path); if (strpos($path, $documentation->getDocumentationPath()) !== 0) { return 'Invalid file for documentation'; } return file_get_contents($path); }
/** * Sets the package key of the controller. * * @param string $packageKey The package key. * @return void * @throws \F3\FLOW3\MVC\Exception\InvalidPackageKeyException if the package key is not valid * @author Robert Lemke <*****@*****.**> */ public function setControllerPackageKey($packageKey) { $upperCamelCasedPackageKey = $this->packageManager->getCaseSensitivePackageKey($packageKey); if ($upperCamelCasedPackageKey !== FALSE) { $this->controllerPackageKey = $upperCamelCasedPackageKey; } else { $this->controllerPackageKey = $packageKey; } }