lots of changes, added footer and main view, implemented an initial wiki page
This commit is contained in:
parent
4b987ca7de
commit
6d01fe82c7
@ -24,17 +24,26 @@
|
||||
$file = '';
|
||||
switch ($className) {
|
||||
case 'PanaceaControllerFactory':
|
||||
case 'PanaceaWikiController':
|
||||
case 'WikiViewFactory':
|
||||
case 'PanaceaDefaultController':
|
||||
case 'PanaceaViewFactory':
|
||||
$file = "$path/lib/$className.php";
|
||||
break;
|
||||
|
||||
case 'WikiPageView':
|
||||
$file = "$path/lib/views/wiki/$className.php";
|
||||
break;
|
||||
|
||||
case 'PanaceaView':
|
||||
case 'PanaceaHomeView':
|
||||
case 'PanaceaMainView':
|
||||
case 'PanaceaTemplateView':
|
||||
case 'PanaceaHeaderView':
|
||||
case 'PanaceaLogoView':
|
||||
case 'PanaceaMenuView':
|
||||
case 'PanaceaFooterView':
|
||||
case 'PanaceaWelcomeView':
|
||||
$file = "$path/lib/views/$className.php";
|
||||
break;
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
$uriRegex = str_replace(str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT']), '', dirname(__FILE__));
|
||||
$uriRegex = str_replace('\\', '/', $uriRegex);
|
||||
$uriRegex = '^' . $uriRegex . '/([^/]*)(?:/(.+))?';
|
||||
$uriRegex = '^' . $uriRegex . '/([^/]*)(?:/(.*))?';
|
||||
|
||||
Dispatcher::getInstance()->setUriRegex($uriRegex)
|
||||
->setThrowExceptions(true)
|
||||
|
@ -67,17 +67,24 @@
|
||||
|
||||
if (isset($uriFragments[1])) {
|
||||
$section = ucfirst($uriFragments[0]);
|
||||
$page = $uriFragments[1];
|
||||
$page = ucfirst($uriFragments[1]);
|
||||
}
|
||||
if (empty($section)) {
|
||||
$section = 'Default';
|
||||
}
|
||||
if (empty($page)) {
|
||||
$page = 'home';
|
||||
}
|
||||
|
||||
$controllerName = 'Panacea' . $section . 'Controller';
|
||||
|
||||
if (empty($page)) {
|
||||
try {
|
||||
$refclass = new ReflectionClass($controllerName);
|
||||
$page = $refclass->getMethod('getDefaultPageName')->invoke(null);
|
||||
}
|
||||
catch (ReflectionException $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
return new $controllerName($page);
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,18 @@
|
||||
$this->viewFactory = PanaceaViewFactory::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the default page if none is specified in the URI
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDefaultPageName() {
|
||||
return 'Home';
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the specified request, and generates a
|
||||
* suitable response
|
||||
@ -54,8 +66,9 @@
|
||||
}
|
||||
|
||||
try {
|
||||
$templateView = new PanaceaTemplateView($this->page);
|
||||
$templateView->addView($this->viewFactory->getView($this->page, $templateView->getNextPriority()));
|
||||
$title = (empty($this->page) || $this->page === 'Home') ? 'It doesn\'t suck' : $this->page;
|
||||
$templateView = new PanaceaTemplateView($title);
|
||||
$templateView->mainView->addView($this->viewFactory->getView($this->page));
|
||||
return $templateView;
|
||||
}
|
||||
catch (ClassNotFoundException $e) {
|
||||
|
@ -44,38 +44,16 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of a {@link View} given a
|
||||
* page name
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-05
|
||||
* @since 2008-10-18
|
||||
*
|
||||
* @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
|
||||
* @return string
|
||||
*/
|
||||
public function getView($page, $priority = 0) {
|
||||
if (!is_string($page)) {
|
||||
throw new InvalidTypeException(1, 'string', $page);
|
||||
}
|
||||
|
||||
$viewName = 'Panacea' . ucfirst($page) . 'View';
|
||||
|
||||
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);
|
||||
}
|
||||
protected function getViewName($page) {
|
||||
return 'Panacea' . ucfirst($page) . 'View';
|
||||
}
|
||||
|
||||
}
|
||||
|
71
src/lib/PanaceaWikiController.php
Normal file
71
src/lib/PanaceaWikiController.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PanaceaWikiController
|
||||
*
|
||||
* @package Panacea
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*/
|
||||
|
||||
/** Bootstraps the NowhereConcave framework */
|
||||
require_once 'NowhereConcave/bootstrap.php';
|
||||
|
||||
/**
|
||||
* Wiki controller
|
||||
*
|
||||
* @package Panacea
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*/
|
||||
class PanaceaWikiController extends PanaceaDefaultController {
|
||||
|
||||
public function __construct($page) {
|
||||
parent::__construct($page, View::VIEWTYPE_HTML);
|
||||
$this->viewFactory = WikiViewFactory::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDefaultPageName() {
|
||||
return 'MainPage';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
* @uses Request::create()
|
||||
* @uses HttpUtil::getRequestMethod()
|
||||
*
|
||||
* @throws {@link InvalidRequestException} if a {@link View} cannot be created
|
||||
* @return PanaceaTemplateView
|
||||
*/
|
||||
public function handleRequest(Request $request = null) {
|
||||
if (!($request instanceof Request)) {
|
||||
$request = Request::create(HttpUtil::getRequestMethod());
|
||||
}
|
||||
|
||||
try {
|
||||
$templateView = new PanaceaTemplateView('Wiki :: ' . $this->page);
|
||||
$mysql = MySql::getInstance('wiki', 'localhost', 'root', 'layne', 'wiki');
|
||||
$wikiObject = new WikiPageObject(WikiPage::loadByPageName($mysql, $this->page));
|
||||
$wikiObject->setRevision(WikiHistory::REV_LATEST, $mysql);
|
||||
$templateView->mainView->addView($this->viewFactory->getView($this->page, $wikiObject));
|
||||
return $templateView;
|
||||
}
|
||||
catch (ClassNotFoundException $e) {
|
||||
throw new InvalidRequestException($request);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
61
src/lib/WikiViewFactory.php
Normal file
61
src/lib/WikiViewFactory.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PanaceaViewFactory
|
||||
*
|
||||
* @package Panacea
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-05
|
||||
*/
|
||||
|
||||
/** Bootstraps the NowhereConcave framework */
|
||||
require_once 'NowhereConcave/bootstrap.php';
|
||||
|
||||
/**
|
||||
* Factory for generating {@link View}s
|
||||
*
|
||||
* @package Panacea
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-05
|
||||
*/
|
||||
class WikiViewFactory extends ViewFactory {
|
||||
|
||||
/**
|
||||
* The singleton instance
|
||||
*
|
||||
* @var WikiViewFactory
|
||||
*/
|
||||
protected static $instance = null;
|
||||
|
||||
/**
|
||||
* Gets the singleton instance
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-17
|
||||
*
|
||||
* @return WikiViewFactory
|
||||
*/
|
||||
public static function getInstance() {
|
||||
if (static::$instance === null) {
|
||||
static::$instance = new static();
|
||||
}
|
||||
|
||||
return static::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*
|
||||
* @param string $page The name of the page
|
||||
* @return string
|
||||
*/
|
||||
protected function getViewName($page) {
|
||||
return 'WikiPageView';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
50
src/lib/views/PanaceaFooterView.php
Normal file
50
src/lib/views/PanaceaFooterView.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PanaceaFooterView
|
||||
*
|
||||
* @package Panacea
|
||||
* @subpackage Views
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*/
|
||||
|
||||
/** Bootstraps the NowhereConcave framework */
|
||||
require_once 'NowhereConcave/bootstrap.php';
|
||||
|
||||
/**
|
||||
* View for standard Panacea pages
|
||||
*
|
||||
* @package Panacea
|
||||
* @subpackage Views
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*/
|
||||
class PanaceaFooterView extends PanaceaView {
|
||||
|
||||
/**
|
||||
* Renders the view
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*/
|
||||
public function send() { ?>
|
||||
|
||||
<div class="hrule"></div>
|
||||
|
||||
<div id="foot">
|
||||
<ul>
|
||||
<li><a href="<?php echo $this->root; ?>/about">About</a></li>
|
||||
<li><a href="<?php echo $this->root; ?>/credits">Credits</a></li>
|
||||
<li><a href="<?php echo $this->root; ?>/copyright">Copyright</a></li>
|
||||
<li><a href="<?php echo $this->root; ?>/contact">Contact</a></li>
|
||||
</ul>
|
||||
<div style="clear:right"></div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -22,21 +22,30 @@
|
||||
*/
|
||||
class PanaceaHomeView extends PanaceaView {
|
||||
|
||||
/**
|
||||
* Renders the view
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
* @uses addView()
|
||||
* @uses PanaceaWelcomeView
|
||||
*
|
||||
* @param int $priority The priority of this view
|
||||
*/
|
||||
public function __construct($priority = 0) {
|
||||
parent::__construct($priority);
|
||||
|
||||
$this->addView(new PanaceaWelcomeView(1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the view
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-05
|
||||
*/
|
||||
public function send() { ?>
|
||||
|
||||
<h1>Panacea</h1>
|
||||
|
||||
<p>
|
||||
Hello!
|
||||
</p>
|
||||
<?php
|
||||
|
||||
public function send() {
|
||||
parent::send();
|
||||
}
|
||||
|
||||
}
|
||||
|
43
src/lib/views/PanaceaMainView.php
Normal file
43
src/lib/views/PanaceaMainView.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PanaceaMainView
|
||||
*
|
||||
* @package Panacea
|
||||
* @subpackage Views
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-05
|
||||
*/
|
||||
|
||||
/** Bootstraps the NowhereConcave framework */
|
||||
require_once 'NowhereConcave/bootstrap.php';
|
||||
|
||||
/**
|
||||
* View for standard Panacea pages
|
||||
*
|
||||
* @package Panacea
|
||||
* @subpackage Views
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-05
|
||||
*/
|
||||
class PanaceaMainView extends PanaceaView {
|
||||
|
||||
/**
|
||||
* Renders the view
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-05
|
||||
*/
|
||||
public function send() { ?>
|
||||
|
||||
<div id="main">
|
||||
<?php parent::send(); ?>
|
||||
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -59,6 +59,8 @@
|
||||
$this->separator = ' - ';
|
||||
|
||||
$this->addView(new PanaceaHeaderView(1));
|
||||
$this->addView(new PanaceaMainView(2));
|
||||
$this->addView(new PanaceaFooterView(3));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,6 +103,8 @@
|
||||
case 'defaultTitle':
|
||||
case 'separator':
|
||||
return $this->$var;
|
||||
case 'mainView':
|
||||
return $this->views[1];
|
||||
default:
|
||||
return parent::__get($var);
|
||||
}
|
||||
|
100
src/lib/views/PanaceaWelcomeView.php
Normal file
100
src/lib/views/PanaceaWelcomeView.php
Normal file
@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PanaceaWelcomeView
|
||||
*
|
||||
* @package Panacea
|
||||
* @subpackage Views
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*/
|
||||
|
||||
/** Bootstraps the NowhereConcave framework */
|
||||
require_once 'NowhereConcave/bootstrap.php';
|
||||
|
||||
/**
|
||||
* View for the welcome message
|
||||
*
|
||||
* @package Panacea
|
||||
* @subpackage Views
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*/
|
||||
class PanaceaWelcomeView extends PanaceaView {
|
||||
|
||||
/**
|
||||
* Renders the view
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*/
|
||||
public function send() { ?>
|
||||
|
||||
<h2>Welcome</h2>
|
||||
<div class="inset">
|
||||
<p>
|
||||
Welcome to <i>Panacea</i>, a web-based application that
|
||||
doesn't suck. It's aimed at software developers,
|
||||
software development managers, <acronym>QA</acronym> professionals,
|
||||
and people who like using <a href="http://en.wikipedia.org/wiki/Wiki">wikis</a>
|
||||
(which should be everybody, unless you're a robot).
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<h2>What is <i>Panacea</i>?</h2>
|
||||
<div class="inset">
|
||||
<p>
|
||||
<i>Panacea</i> is modeled after <a href="http://trac.edgewall.org/">Trac</a>,
|
||||
which is a fantastic application very similar to this one. <i>Panacea</i>
|
||||
aims to ease integration, configuration and installation. That is not to say
|
||||
that <i>Panacea</i> is simple; it is in fact just the opposite. <i>Panacea</i> is
|
||||
infintely complex and extensible; it is well documented and well-written; it
|
||||
is a panacea to all your software development troubles; it's also a lot of
|
||||
fun, in the sense that there's a lot of crap to mess around with.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
More information about the technology and reason for <i>Panacea</i> can be
|
||||
viewed at the <a href="<?php echo $this->root; ?>/wiki/About">about</a> page.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<h2>Stuff to do here</h2>
|
||||
<div class="inset">
|
||||
<p>
|
||||
This whole site is an example of <i>Panacea</i>, except for this page.
|
||||
This page is just a bunch of static <acronym>HTML</acronym>, and is not
|
||||
under the control of a wiki.
|
||||
</p>
|
||||
|
||||
<h3>Demo</h3>
|
||||
<div class="inset">
|
||||
<p>
|
||||
Words are boring. Here is a demo: <a href="<?php echo $this->root; ?>/demo/">do
|
||||
it.</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<h3>Download</h3>
|
||||
<div class="inset">
|
||||
<p>
|
||||
<a href="<?php echo $this->root; ?>/wiki/Download">Click here</a> to go
|
||||
to our download page.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<h3>Install</h3>
|
||||
<div class="inset">
|
||||
<p>
|
||||
<a href="<?php echo $this->root; ?>/wiki/Install">Click here</a> to go
|
||||
to view installation instructions.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
44
src/lib/views/wiki/WikiPageView.php
Normal file
44
src/lib/views/wiki/WikiPageView.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* WikiPageView
|
||||
*
|
||||
* @package Panacea
|
||||
* @subpackage Views
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*/
|
||||
|
||||
/** Bootstraps the NowhereConcave framework */
|
||||
require_once 'NowhereConcave/bootstrap.php';
|
||||
|
||||
/**
|
||||
* View for wiki pages
|
||||
*
|
||||
* @package Panacea
|
||||
* @subpackage Views
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*/
|
||||
class WikiPageView extends PanaceaView {
|
||||
|
||||
protected $page;
|
||||
|
||||
public function __construct(WikiPageObject $page, $priority = 0) {
|
||||
parent::__construct($priority);
|
||||
$this->page = $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the view
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-18
|
||||
*/
|
||||
public function send() {
|
||||
echo $this->page;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -7,6 +7,9 @@ body {
|
||||
font-size: 8pt;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#wrapper {
|
||||
width: 95%;
|
||||
@ -38,7 +41,6 @@ body {
|
||||
}
|
||||
#menu ul li {
|
||||
float: left;
|
||||
display:block;
|
||||
margin-right: 5px;
|
||||
width: 100px;
|
||||
height: 25px;
|
||||
@ -74,3 +76,57 @@ body {
|
||||
line-height: 35px;
|
||||
border: 1px solid #FFFFFF;
|
||||
}
|
||||
|
||||
#main {
|
||||
position: relative;
|
||||
padding: 5px;
|
||||
}
|
||||
#main p {
|
||||
line-height: 1.5em;
|
||||
}
|
||||
#main a {
|
||||
border-bottom: 1px dotted #000000;
|
||||
color: #669966 ;
|
||||
font-weight: bold;
|
||||
}
|
||||
#main a:hover {
|
||||
color: #000000;
|
||||
border-bottom: 2px solid #669966;
|
||||
}
|
||||
|
||||
#foot {
|
||||
position: relative;
|
||||
padding: 5px;
|
||||
margin: 2px;
|
||||
}
|
||||
#foot ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
#foot ul li {
|
||||
float: right;
|
||||
}
|
||||
#foot ul li:first-child:after, #foot ul li:before {
|
||||
content: "|";
|
||||
color: #999999;
|
||||
}
|
||||
#foot ul li a {
|
||||
text-decoration: none;
|
||||
color: #999999;
|
||||
}
|
||||
#foot ul li a:hover {
|
||||
color: #000000;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
.inset {
|
||||
margin-left: 20px;
|
||||
}
|
||||
.hrule {
|
||||
height: .1em;
|
||||
border-top: 1px solid #000000;
|
||||
border-bottom: 1px solid #000000;
|
||||
background-color: #DDDD77;
|
||||
}
|
Loading…
Reference in New Issue
Block a user