moved wiki into panacea
This commit is contained in:
		
							parent
							
								
									73ede72b0e
								
							
						
					
					
						commit
						64379360f0
					
				
							
								
								
									
										67
									
								
								src/inc/WikiControllerFactory.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								src/inc/WikiControllerFactory.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,67 @@ | ||||
| <?php | ||||
| 
 | ||||
| 	/** | ||||
| 	 * WikiControllerFactory | ||||
| 	 * | ||||
| 	 * @package    Wiki | ||||
| 	 * @author     Tommy Montgomery | ||||
| 	 * @since      2008-10-05 | ||||
| 	 */ | ||||
| 
 | ||||
| 	/** Bootstraps the NowhereConcave framework */ | ||||
| 	require_once 'NowhereConcave/bootstrap.php'; | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Creates a {@link Controller} | ||||
| 	 * | ||||
| 	 * @package    Wiki | ||||
| 	 * @author     Tommy Montgomery | ||||
| 	 * @since      2008-10-05 | ||||
| 	 */ | ||||
| 	class WikiControllerFactory extends ControllerFactory { | ||||
| 		 | ||||
| 		/** | ||||
| 		 * The <kbd>WikiControllerFactory</kbd> instance | ||||
| 		 * | ||||
| 		 * @var Dispatcher | ||||
| 		 */ | ||||
| 		protected static $instance = null; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Gets the {@link ControllerFactory} instance | ||||
| 		 * | ||||
| 		 * @author Tommy Montgomery | ||||
| 		 * @since  2008-10-05 | ||||
| 		 * | ||||
| 		 * @return ControllerFactory | ||||
| 		 */ | ||||
| 		public static function getInstance() { | ||||
| 			if (self::$instance === null) { | ||||
| 				self::$instance = new self(); | ||||
| 			} | ||||
| 			 | ||||
| 			return self::$instance; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Parses the URI fragments and determines which  | ||||
| 		 * {@link Controller} to instantiate | ||||
| 		 * | ||||
| 		 * @author Tommy Montgomery | ||||
| 		 * @since  2008-10-05 | ||||
| 		 * | ||||
| 		 * @param  array $uriFragments The URI fragments | ||||
| 		 * @throws {@link ClassNotFoundException} | ||||
| 		 * @return WikiPageController | ||||
| 		 */ | ||||
| 		public function getController(array $uriFragments) { | ||||
| 			if (count($uriFragments) !== 1) { | ||||
| 				throw new InvalidTypeException(1, 'array of size 1', $uriFragments); | ||||
| 			} | ||||
| 			 | ||||
| 			return new WikiPageController($uriFragments[0]); | ||||
| 		} | ||||
| 		 | ||||
| 	} | ||||
| 
 | ||||
| ?>
 | ||||
							
								
								
									
										66
									
								
								src/inc/WikiPageController.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								src/inc/WikiPageController.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,66 @@ | ||||
| <?php | ||||
| 
 | ||||
| 	/** | ||||
| 	 * WikiPageController | ||||
| 	 * | ||||
| 	 * @package    Wiki | ||||
| 	 * @author     Tommy Montgomery | ||||
| 	 * @since      2008-10-05 | ||||
| 	 */ | ||||
| 	 | ||||
| 	/** Bootstraps the NowhereConcave framework */ | ||||
| 	require_once 'NowhereConcave/bootstrap.php'; | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Wiki page controller | ||||
| 	 * | ||||
| 	 * @package    Wiki | ||||
| 	 * @author     Tommy Montgomery | ||||
| 	 * @since      2008-10-05 | ||||
| 	 */ | ||||
| 	class WikiPageController extends Controller { | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Creates a new {@link Controller} | ||||
| 		 * | ||||
| 		 * @author Tommy Montgomery | ||||
| 		 * @since  2008-10-05 | ||||
| 		 * @uses   DefaultViewFactory::getInstance() | ||||
| 		 * | ||||
| 		 * @param  string $page     Name of the page (view) | ||||
| 		 * @param  int    $viewType One of the {@link View}<kbd>::VIEWTYPE_*</kbd> constants | ||||
| 		 * @throws {@link InvalidTypeException} | ||||
| 		 */ | ||||
| 		public function __construct($page = '', $viewType = View::VIEWTYPE_HTML) { | ||||
| 			parent::__construct($page, $viewType); | ||||
| 			$this->viewFactory = WikiViewFactory::getInstance(); | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Handles the specified request, and generates a | ||||
| 		 * suitable response | ||||
| 		 * | ||||
| 		 * @author Tommy Montgomery | ||||
| 		 * @since  2008-10-05 | ||||
| 		 * @uses   Request::create() | ||||
| 		 * @uses   HttpUtil::getRequestMethod() | ||||
| 		 * | ||||
| 		 * @throws {@link InvalidRequestException} if a {@link View} cannot be created | ||||
| 		 * @return View | ||||
| 		 */ | ||||
| 		public function handleRequest(Request $request = null) { | ||||
| 			if (!($request instanceof Request)) { | ||||
| 				$request = Request::create(HttpUtil::getRequestMethod()); | ||||
| 			} | ||||
| 			 | ||||
| 			try { | ||||
| 				return $this->viewFactory->getView($this->page, $request->__toString()); | ||||
| 			} | ||||
| 			catch (ClassNotFoundException $e) { | ||||
| 				throw new InvalidRequestException($request); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 	} | ||||
| 
 | ||||
| ?>
 | ||||
							
								
								
									
										71
									
								
								src/inc/WikiViewFactory.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								src/inc/WikiViewFactory.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,71 @@ | ||||
| <?php | ||||
| 
 | ||||
| 	/** | ||||
| 	 * WikiViewFactory | ||||
| 	 * | ||||
| 	 * @package    Wiki | ||||
| 	 * @author     Tommy Montgomery | ||||
| 	 * @since      2008-10-05 | ||||
| 	 */ | ||||
| 	 | ||||
| 	/** Bootstraps the NowhereConcave framework */ | ||||
| 	require_once 'NowhereConcave/bootstrap.php'; | ||||
| 	 | ||||
| 	/** | ||||
| 	 * Factory for generating {@link View}s | ||||
| 	 * | ||||
| 	 * @package    Wiki | ||||
| 	 * @author     Tommy Montgomery | ||||
| 	 * @since      2008-10-05 | ||||
| 	 */ | ||||
| 	class WikiViewFactory extends ViewFactory { | ||||
| 		 | ||||
| 		protected static $instance = null; | ||||
| 		 | ||||
| 		public static function getInstance() { | ||||
| 			if (static::$instance === null) { | ||||
| 				static::$instance = new static(); | ||||
| 			} | ||||
| 			 | ||||
| 			return static::$instance; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Creates an instance of a {@link View} given a | ||||
| 		 * page name | ||||
| 		 * | ||||
| 		 * @author Tommy Montgomery | ||||
| 		 * @since  2008-10-05 | ||||
| 		 * | ||||
| 		 * @param  string $page The name of the page | ||||
| 		 * @param  mixed  $args Other arguments for creating the view | ||||
| 		 * @throws {@link InvalidTypeException} | ||||
| 		 * @throws {@link ClassNotFoundException} | ||||
| 		 * @return View | ||||
| 		 */ | ||||
| 		public function getView($page) { | ||||
| 			if (!is_string($page)) { | ||||
| 				throw new InvalidTypeException(1, 'string', $page); | ||||
| 			} | ||||
| 			 | ||||
| 			//parse out special pages here
 | ||||
| 			$viewName = 'WikiPageView'; | ||||
| 			 | ||||
| 			try { | ||||
| 				$refclass = new ReflectionClass($viewName); | ||||
| 				$args = array_slice(func_get_args(), 1, 1); | ||||
| 				if (!empty($args)) { | ||||
| 					return $refclass->newInstanceArgs($args); | ||||
| 				} | ||||
| 				else { | ||||
| 					return $refclass->newInstance(); | ||||
| 				} | ||||
| 			} | ||||
| 			catch (ReflectionException $e) { | ||||
| 				throw new ClassNotFoundException($viewName); | ||||
| 			} | ||||
| 		} | ||||
| 		 | ||||
| 	} | ||||
| 
 | ||||
| ?>
 | ||||
							
								
								
									
										73
									
								
								src/inc/views/WikiPageView.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										73
									
								
								src/inc/views/WikiPageView.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,73 @@ | ||||
| <?php | ||||
| 
 | ||||
| 	/** | ||||
| 	 * WikiPageView | ||||
| 	 * | ||||
| 	 * @package    Wiki | ||||
| 	 * @subpackage Views | ||||
| 	 * @author     Tommy Montgomery | ||||
| 	 * @since      2008-07-03 | ||||
| 	 */ | ||||
| 
 | ||||
| 	/** Bootstraps the NowhereConcave framework */ | ||||
| 	require_once 'NowhereConcave/bootstrap.php'; | ||||
| 
 | ||||
| 	/** | ||||
| 	 * View for standard wiki pages | ||||
| 	 * | ||||
| 	 * @package    Wiki | ||||
| 	 * @subpackage Views | ||||
| 	 * @author     Tommy Montgomery | ||||
| 	 * @since      2008-10-05 | ||||
| 	 */ | ||||
| 	class WikiPageView extends View { | ||||
| 		 | ||||
| 		protected $wikiText; | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Creates a new {@link WikiPageView} with the specified | ||||
| 		 * priority | ||||
| 		 * | ||||
| 		 * @author Tommy Montgomery | ||||
| 		 * @since  2008-10-05 | ||||
| 		 * | ||||
| 		 * @param  int $priority The priority of this view | ||||
| 		 */ | ||||
| 		public function __construct($wikiText, $priority = 0) { | ||||
| 			if (!is_string($wikiText)) { | ||||
| 				throw new InvalidTypeException(1, 'string', $wikiText); | ||||
| 			} | ||||
| 			 | ||||
| 			parent::__construct($priority); | ||||
| 			 | ||||
| 			$this->wikiText = $wikiText; | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Gets all meta data associated with this view | ||||
| 		 * | ||||
| 		 * @author Tommy Montgomery | ||||
| 		 * @since  2008-10-05 | ||||
| 		 * | ||||
| 		 * @return ViewMetaData | ||||
| 		 */ | ||||
| 		public function getMetaData() { | ||||
| 			return new ViewMetaData(); | ||||
| 		} | ||||
| 		 | ||||
| 		/** | ||||
| 		 * Renders the view | ||||
| 		 * | ||||
| 		 * @author Tommy Montgomery | ||||
| 		 * @since  2008-10-05 | ||||
| 		 * | ||||
| 		 * @param bool $sendHeaders Whether to send the response headers or not | ||||
| 		 */ | ||||
| 		public function send() { | ||||
| 			WikiParser::parseText($this->wikiText); | ||||
| 			echo $this->wikiText; | ||||
| 		} | ||||
| 		 | ||||
| 	} | ||||
| 
 | ||||
| ?>
 | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user