示例#1
0
 public function run()
 {
     $fileManager = $this->managers->getManagerOf('file');
     $configManager = $this->managers->getManagerOf('config');
     if (!$this->httpRequest->getExists('type')) {
         $this->httpResponse()->addHeader('HTTP/1.0 400 Bad Request');
         throw new \RuntimeException('No manifest specified');
     }
     $manifestType = $this->httpRequest->getData('type');
     if (!isset($this->manifestsPaths[$manifestType])) {
         $this->httpResponse()->addHeader('HTTP/1.0 404 Not Found');
         throw new \RuntimeException('Invalid manifest type');
     }
     $manifestPath = $this->manifestsPaths[$manifestType];
     $manifestFile = $configManager->open($manifestPath);
     $manifest = $manifestFile->read();
     if ($manifestType == 'firefox') {
         if (isset($_SERVER['SERVER_NAME'])) {
             $manifest['name'] .= ' · ' . $_SERVER['SERVER_NAME'];
         }
         //$manifest['version'] = $fileManager->read(self::WEBOS_VERSION_FILE);
         if (isset($_SERVER['REQUEST_URI'])) {
             $manifest['launch_path'] = preg_replace('#\\/webos\\.webapp$#', '', $_SERVER['REQUEST_URI']);
         }
     }
     $manifestStr = json_encode($manifest);
     $this->httpResponse->setCacheable();
     $this->httpResponse->addHeader('Content-Type: ' . $fileManager->mimetype($manifestPath));
     $this->httpResponse->addHeader('Content-Length: ' . strlen($manifestStr));
     $resp = new RawResponse();
     $resp->setValue($manifestStr);
     $this->httpResponse->setContent($resp);
 }
 public function run()
 {
     //TODO: Language detection
     /*$conf = new Config($this);
     		if ($this->managers()->get('File')->exists('~/.config/locale.xml')) {
     			$conf->load('~/.config/locale.xml');
     		}
     		if ($conf->exist('language')) {
     			$this->managers()->get('Translation')->setLanguage($conf->get('language'));
     		} else {
     			$lang = $this->managers()->get('Translation')->detectLanguage();
     			if ($this->user->isConnected()) {
     				$conf->set('language', $lang);
     				$conf->save('~/.config/locale.xml');
     			}
     		}*/
     $jsIncludes = $this->_getIncludes();
     $t = new TranslationDictionary();
     ob_start();
     //Include layout (basic HTML structure)
     require 'boot/includes/layout.php';
     $out = ob_get_contents();
     ob_end_clean();
     $resp = new RawResponse();
     $resp->setValue($out);
     $this->httpResponse->addHeader('Content-Type: text/html');
     $this->httpResponse->setContent($resp);
 }