예제 #1
0
파일: RawData.php 프로젝트: na2axl/FlatOS
 public function render()
 {
     $mime = $this->_getMimetype();
     $contents = $this->FS->read($this->path);
     $this->httpResponse->setCacheable();
     $this->httpResponse->addHeader("content-type: {$mime};charset=utf-8");
     $this->httpResponse->setContent($contents);
     $this->httpResponse->send();
 }
예제 #2
0
 /**
  * Attach requirements inclusion to X-Include-JS and X-Include-CSS headers on the HTTP response
  */
 function include_in_response(HTTPResponse $response)
 {
     $this->process_combined_files();
     $jsRequirements = array();
     $cssRequirements = array();
     foreach (array_diff_key($this->javascript, $this->blocked) as $file => $dummy) {
         $path = $this->path_for_file($file);
         if ($path) {
             $jsRequirements[] = $path;
         }
     }
     $response->addHeader('X-Include-JS', implode(',', $jsRequirements));
     foreach (array_diff_key($this->css, $this->blocked) as $file => $params) {
         $path = $this->path_for_file($file);
         if ($path) {
             $cssRequirements[] = isset($params['media']) ? "{$path}:##:{$params['media']}" : $path;
         }
     }
     $response->addHeader('X-Include-CSS', implode(',', $cssRequirements));
 }
예제 #3
0
 function html(HTTPResponse $response)
 {
     $response->addHeader("Content-type", "text/html; charset=" . self::$encoding);
     $response->addHeader("Vary", "Accept");
     $content = $response->getBody();
     $content = ereg_replace("<\\?xml[^>]+\\?>\n?", '', $content);
     $content = str_replace(array('/>', 'xml:lang', 'application/xhtml+xml'), array('>', 'lang', 'text/html'), $content);
     $content = ereg_replace('<!DOCTYPE[^>]+>', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', $content);
     $content = ereg_replace('<html xmlns="[^"]+"', '<html ', $content);
     $response->setBody($content);
 }
예제 #4
0
 function html(HTTPResponse $response)
 {
     $response->addHeader("Content-Type", "text/html; charset=" . self::$encoding);
     $response->addHeader("Vary", "Accept");
     $content = $response->getBody();
     $hasXMLHeader = substr($content, 0, 5) == '<' . '?xml';
     $content = ereg_replace("<\\?xml[^>]+\\?>\n?", '', $content);
     $content = str_replace(array('/>', 'xml:lang', 'application/xhtml+xml'), array('>', 'lang', 'text/html'), $content);
     // Only replace the doctype in templates with the xml header
     if ($hasXMLHeader) {
         $content = ereg_replace('<!DOCTYPE[^>]+>', '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', $content);
     }
     $content = ereg_replace('<html xmlns="[^"]+"', '<html ', $content);
     $response->setBody($content);
 }
 function handleConfirmation($request)
 {
     // Find the action handler
     $actions = Object::get_static($this->class, 'batch_actions');
     $actionClass = $actions[$request->param('BatchAction')];
     $actionHandler = new $actionClass();
     // Sanitise ID list and query the database for apges
     $ids = split(' *, *', trim($request->requestVar('csvIDs')));
     foreach ($ids as $k => $id) {
         $ids[$k] = (int) $id;
     }
     $ids = array_filter($ids);
     if ($actionHandler->hasMethod('confirmationDialog')) {
         $response = new HTTPResponse(json_encode($actionHandler->confirmationDialog($ids)));
     } else {
         $response = new HTTPResponse(json_encode(array('alert' => false)));
     }
     $response->addHeader("Content-type", "application/json");
     return $response;
 }
예제 #6
0
 /**
  * Construct an HTTPResponse that will deliver a file to the client
  */
 static function send_file($fileData, $fileName, $mimeType = null)
 {
     if (!$mimeType) {
         $mimeType = HTTP::getMimeType($fileName);
     }
     $response = new HTTPResponse($fileData);
     $response->addHeader("Content-Type", "{$mimeType}; name=\"" . addslashes($fileName) . "\"");
     $response->addHeader("Content-disposition", "attachment; filename=" . addslashes($fileName));
     $response->addHeader("Content-Length", strlen($fileData));
     $response->addHeader("Pragma", "");
     // Necessary because IE has issues sending files over SSL
     return $response;
 }
예제 #7
0
	/**
	 * Construct an HTTPResponse that will deliver a file to the client
	 */
	static function send_file($fileData, $fileName, $mimeType = null) {
		if(!$mimeType) $mimeType = HTTP::getMimeType($fileName);

		$response = new HTTPResponse($fileData);
		$response->addHeader("Content-Type", "$mimeType; name=\"" . addslashes($fileName) . "\"");
		$response->addHeader("Content-disposition", "attachment; filename=" . addslashes($fileName));
		$response->addHeader("Content-Length", strlen($fileData));
		
		return $response;
	}