slight controller/view/architecture refactor (incomplete)

This commit is contained in:
tmont 2008-10-18 09:02:23 +00:00
parent 4631ff1374
commit 14cfcb9610
11 changed files with 74 additions and 34 deletions

View File

@ -30,7 +30,7 @@
break; break;
case 'PanaceaView': case 'PanaceaView':
case 'PanaceaPageView': case 'PanaceaHomeView':
case 'PanaceaTemplateView': case 'PanaceaTemplateView':
case 'PanaceaHeaderView': case 'PanaceaHeaderView':
case 'PanaceaLogoView': case 'PanaceaLogoView':

View File

View File

@ -13,7 +13,7 @@
$uriRegex = str_replace(str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT']), '', dirname(__FILE__)); $uriRegex = str_replace(str_replace('/', DIRECTORY_SEPARATOR, $_SERVER['DOCUMENT_ROOT']), '', dirname(__FILE__));
$uriRegex = str_replace('\\', '/', $uriRegex); $uriRegex = str_replace('\\', '/', $uriRegex);
$uriRegex = '^' . $uriRegex . '/(.*)'; $uriRegex = '^' . $uriRegex . '/([^/]*)(?:/(.+))?';
Dispatcher::getInstance()->setUriRegex($uriRegex) Dispatcher::getInstance()->setUriRegex($uriRegex)
->setThrowExceptions(true) ->setThrowExceptions(true)

View File

@ -47,6 +47,9 @@
* Parses the URI fragments and determines which * Parses the URI fragments and determines which
* {@link Controller} to instantiate * {@link Controller} to instantiate
* *
* {@internal $section will be wiki, repo, tracker, etc.
* $page will be empty or the name of the page}}
*
* @author Tommy Montgomery * @author Tommy Montgomery
* @since 2008-10-05 * @since 2008-10-05
* *
@ -55,8 +58,16 @@
* @return PanaceaPageController * @return PanaceaPageController
*/ */
public function getController(array $uriFragments) { public function getController(array $uriFragments) {
if (count($uriFragments) !== 1) { if (count($uriFragments) < 2) {
throw new InvalidTypeException(1, 'array of size 1', $uriFragments); throw new InvalidTypeException(1, 'array with at least two elements', $uriFragments);
}
$section = '';
$page = $uriFragments[0];
if (isset($uriFragments[1])) {
$section = $uriFragments[0];
$page = $uriFragments[1];
} }
return new PanaceaPageController($uriFragments[0]); return new PanaceaPageController($uriFragments[0]);

View File

@ -20,8 +20,21 @@
*/ */
class PanaceaViewFactory extends ViewFactory { class PanaceaViewFactory extends ViewFactory {
/**
* The singleton instance
*
* @var PanaceaViewFactory
*/
protected static $instance = null; protected static $instance = null;
/**
* Gets the singleton instance
*
* @author Tommy Montgomery
* @since 2008-10-17
*
* @return PanaceaViewFactory
*/
public static function getInstance() { public static function getInstance() {
if (static::$instance === null) { if (static::$instance === null) {
static::$instance = new static(); static::$instance = new static();
@ -48,8 +61,11 @@
throw new InvalidTypeException(1, 'string', $page); throw new InvalidTypeException(1, 'string', $page);
} }
//parse out special pages here if (empty($page)) {
$viewName = 'PanaceaPageView'; $page = 'home';
}
$viewName = 'Panacea' . ucfirst($page) . 'View';
try { try {
$refclass = new ReflectionClass($viewName); $refclass = new ReflectionClass($viewName);

View File

@ -32,13 +32,13 @@
<div id="menu"> <div id="menu">
<ul> <ul>
<li><a href="<?php echo $this->root; ?>/">Home</a></li> <li><a href="<?php echo $this->root; ?>/"><b>Home</b></a></li>
<li><a href="<?php echo $this->root; ?>/repo">SVN Repo</a></li> <li><a href="<?php echo $this->root; ?>/repo/"><b>SVN Repo</b></a></li>
<li><a href="<?php echo $this->root; ?>/ci">Continuous Integration</a></li> <li><a href="<?php echo $this->root; ?>/ci/"><b>CI</b></a></li>
<li><a href="<?php echo $this->root; ?>/wiki">Wiki</a></li> <li><a href="<?php echo $this->root; ?>/wiki/"><b>Wiki</b></a></li>
<li><a href="<?php echo $this->root; ?>/tracker">Tracker</a></li> <li><a href="<?php echo $this->root; ?>/tracker/"><b>Tracker</b></a></li>
<li><a href="<?php echo $this->root; ?>/reviewer">Code Review</a></li> <li><a href="<?php echo $this->root; ?>/reviewer/"><b>Reviews</b></a></li>
<li><a href="<?php echo $this->root; ?>/manager">Project Management</a></li> <li><a href="<?php echo $this->root; ?>/manager/"><b>Projects</b></a></li>
</ul> </ul>
<div style="clear:left"></div> <div style="clear:left"></div>
</div> </div>

View File

@ -29,6 +29,7 @@ body {
#menu { #menu {
border-top: 2px solid #000000; border-top: 2px solid #000000;
border-bottom: 2px solid #000000; border-bottom: 2px solid #000000;
background-color: #DDDD77;
} }
#menu ul { #menu ul {
list-style-type: none; list-style-type: none;
@ -36,28 +37,40 @@ body {
padding: 0; padding: 0;
} }
#menu ul li { #menu ul li {
float: left; float:left;
position: relative; display:block;
margin-right:5px;
width:100px;
height:25px;
} }
#menu ul li a { #menu ul li a {
display: block;
color: #000000;
height: 1.5em;
line-height: 1.5em;
padding: .5em;
font-size: 1em;
font-weight: bold;
margin-right: 1px;
text-decoration: none;
background-color: #CCCCCC;
border: 1px solid transparent;
}
#menu ul li a:hover {
display: inline; display: inline;
background-color: #009999; float: left;
color: #FFFFFF; width: 100px;
border: 1px solid #000000; height: 25px;
border-top-width: 2px; position: absolute;
padding-bottom: 14px; text-align: center;
line-height: 1.9em; text-decoration: none;
}
#menu ul li a b {
display: block;
width: 100px;
height: 25px;
line-height: 24px;
color: #000000;
position: absolute;
top: 0;
left: 0;
}
#menu ul li a:hover b {
width: 110px;
height: 37px;
top: -6px;
left: -5px;
z-index: 2;
background-color: #999966;
font-size: 1.3em;
color: #FFFFFF;
line-height: 35px;
border: 1px solid #FFFFFF;
} }

View File

View File

View File

View File