| 
									
										
										
										
											2013-08-06 18:07:05 +03:00
										 |  |  | <?php | 
					
						
							| 
									
										
										
										
											2013-08-08 00:22:21 +03:00
										 |  |  | /** | 
					
						
							| 
									
										
										
										
											2013-08-28 12:02:27 +02:00
										 |  |  |  * ownCloud - Documents App | 
					
						
							| 
									
										
										
										
											2013-08-08 00:22:21 +03:00
										 |  |  |  * | 
					
						
							|  |  |  |  * @author Victor Dubiniuk | 
					
						
							|  |  |  |  * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This file is licensed under the Affero General Public License version 3 or | 
					
						
							|  |  |  |  * later. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2013-08-06 18:07:05 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-28 12:02:27 +02:00
										 |  |  | namespace OCA\Documents; | 
					
						
							| 
									
										
										
										
											2013-08-06 18:07:05 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | class Request { | 
					
						
							|  |  |  | 	protected $data = array(); | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2013-08-06 19:43:26 +03:00
										 |  |  | 	protected $rawRequest = ''; | 
					
						
							|  |  |  | 	 | 
					
						
							| 
									
										
										
										
											2013-08-06 18:07:05 +03:00
										 |  |  | 	public function __construct(){ | 
					
						
							| 
									
										
										
										
											2013-08-06 19:43:26 +03:00
										 |  |  | 		$this->rawRequest = file_get_contents('php://input'); | 
					
						
							|  |  |  | 		$this->data = json_decode($this->rawRequest, true); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	public function getRawRequest(){ | 
					
						
							|  |  |  | 		return $this->rawRequest; | 
					
						
							| 
									
										
										
										
											2013-08-06 18:07:05 +03:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2013-08-06 19:43:26 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-06 18:07:05 +03:00
										 |  |  | 	public function getParam($name){ | 
					
						
							| 
									
										
										
										
											2013-08-06 19:43:26 +03:00
										 |  |  | 		if (empty($name)){ | 
					
						
							|  |  |  | 			return $this->data; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2013-08-06 18:07:05 +03:00
										 |  |  | 		$path = explode('/', $name); | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		reset($path); | 
					
						
							|  |  |  | 		$index = current($path); | 
					
						
							|  |  |  | 		$param = $this->data; | 
					
						
							|  |  |  | 		do { | 
					
						
							|  |  |  | 			if (!array_key_exists($index, $param)){ | 
					
						
							|  |  |  | 				return null; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			$param = $param[$index]; | 
					
						
							|  |  |  | 		} while (($index = next($path)) !== false); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		return $param; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 	 |