registry = $this->getCreatorRegistry(); } /** * Return the registry used by this controller * * @return CreatorRegistry */ abstract protected function getCreatorRegistry(); /** * Get a file of a custom interaction */ public function getFile() { if ($this->hasRequestParameter('file')) { $file = urldecode($this->getRequestParameter('file')); $filePathTokens = explode('/', $file); $typeIdentifier = array_shift($filePathTokens); $relPath = implode(DIRECTORY_SEPARATOR, $filePathTokens); $this->renderFile($typeIdentifier, $relPath); } } /** * Get the directory where the implementation sits * * @param string $typeIdentifier * @return string */ protected function getImplementationDirectory($typeIdentifier) { return $this->registry->getDevImplementationDirectory($typeIdentifier); } /** * Render the file to the browser * * @param string $typeIdentifier * @param string $relPath * @throws common_exception_Error */ private function renderFile($typeIdentifier, $relPath) { if (tao_helpers_File::securityCheck($relPath, true)) { $folder = $this->getImplementationDirectory($typeIdentifier); $filename = $folder . $relPath; //@todo : find better way to to this //load amd module if (! file_exists($filename) && file_exists($filename . '.js')) { $filename = $filename . '.js'; } tao_helpers_Http::returnFile($filename); } else { throw new common_exception_Error('invalid item preview file path'); } } }