updated controllers and views to use new configuration-driven database objects
This commit is contained in:
parent
10e076a269
commit
4eb51ee6ae
@ -15,6 +15,13 @@
|
||||
$uriRegex = str_replace('\\', '/', $uriRegex);
|
||||
$uriRegex = '^' . $uriRegex . '/([^/]*)(?:/([^\?]*)(?:\?(.*))?)?';
|
||||
|
||||
$configFile = dirname(__FILE__) . DIRECTORY_SEPARATOR .
|
||||
'lib' . DIRECTORY_SEPARATOR .
|
||||
'config' . DIRECTORY_SEPARATOR .
|
||||
'panacea.ini';
|
||||
|
||||
$config = new Configuration($configFile);
|
||||
|
||||
/*
|
||||
* $uriRegex: ^/webroot/([^/]*)(?:/(.*)(?:\?(.*))?)?
|
||||
*
|
||||
@ -27,6 +34,6 @@
|
||||
Dispatcher::getInstance()->setUriRegex($uriRegex)
|
||||
->setThrowExceptions(true)
|
||||
->setControllerFactory(PanaceaControllerFactory::getInstance())
|
||||
->dispatch($_SERVER['REQUEST_URI']);
|
||||
->dispatch($_SERVER['REQUEST_URI'], $config);
|
||||
|
||||
?>
|
@ -32,8 +32,8 @@
|
||||
*
|
||||
* @param WikiPage $page A wiki page
|
||||
*/
|
||||
public function __construct(WikiPage $page) {
|
||||
parent::__construct($page, PanaceaWikiParser::getInstance());
|
||||
public function __construct(WikiPage $page, Configuration $config) {
|
||||
parent::__construct($page, new PanaceaWikiParser($config));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,13 +22,6 @@
|
||||
*/
|
||||
class PanaceaWikiParser extends WikiParser {
|
||||
|
||||
/**
|
||||
* The singleton instance
|
||||
*
|
||||
* @var WikiParser
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Creates a new {@link PanaceaWikiParser}
|
||||
*
|
||||
@ -36,28 +29,12 @@
|
||||
* @since 2008-10-19
|
||||
* @todo Use configuration object for linkRoot
|
||||
*/
|
||||
protected function __construct() {
|
||||
parent::__construct();
|
||||
public function __construct(Configuration $config) {
|
||||
parent::__construct($config);
|
||||
|
||||
$this->linkRoot = '/panacea/src/wiki';
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the singleton instance
|
||||
*
|
||||
* @author Tommy Montgomery
|
||||
* @since 2008-10-19
|
||||
*
|
||||
* @return PanaceaWikiParser
|
||||
*/
|
||||
public static function getInstance() {
|
||||
if (self::$instance === null) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -63,7 +63,7 @@
|
||||
* @throws {@link InvalidRequestException} if a {@link View} cannot be created
|
||||
* @return PanaceaTemplateView
|
||||
*/
|
||||
public function handleRequest(Request $request = null) {
|
||||
public function handleRequest(Request $request = null, Configuration $config = null) {
|
||||
if (!($request instanceof Request)) {
|
||||
$request = Request::create(HttpUtil::getRequestMethod());
|
||||
}
|
||||
|
@ -50,7 +50,7 @@
|
||||
* @throws {@link InvalidRequestException} if a {@link View} cannot be created
|
||||
* @return PanaceaTemplateView
|
||||
*/
|
||||
public function handleRequest(Request $request = null) {
|
||||
public function handleRequest(Request $request = null, Configuration $config = null) {
|
||||
if (!($request instanceof Request)) {
|
||||
$request = Request::create(HttpUtil::getRequestMethod());
|
||||
}
|
||||
|
@ -53,12 +53,12 @@
|
||||
* @throws {@link InvalidRequestException} if a {@link View} cannot be created
|
||||
* @return PanaceaTemplateView
|
||||
*/
|
||||
public function handleRequest(Request $request = null) {
|
||||
public function handleRequest(Request $request = null, Configuration $config = null) {
|
||||
if (!($request instanceof Request)) {
|
||||
$request = Request::create(HttpUtil::getRequestMethod());
|
||||
}
|
||||
|
||||
$mysql = MySql::getInstance('wiki', 'localhost', 'root', 'layne', 'wiki');
|
||||
$mysql = new MySql($config);
|
||||
|
||||
//handle request metadata
|
||||
if ($request->method === HttpUtil::HTTP_METHOD_POST) {
|
||||
@ -68,7 +68,7 @@
|
||||
|
||||
try {
|
||||
try {
|
||||
$wikiObject = new PanaceaWikiPageObject(WikiPage::loadByPageName($mysql, $this->page));
|
||||
$wikiObject = new PanaceaWikiPageObject(WikiPage::loadByPageName($mysql, $this->page), $config);
|
||||
$wikiObject->setRevision(WikiHistory::REV_LATEST, $mysql);
|
||||
}
|
||||
catch (DomainException $e) {
|
||||
@ -77,8 +77,10 @@
|
||||
$this->action = 'new';
|
||||
}
|
||||
|
||||
$vendor = new MySql($config);
|
||||
|
||||
$templateView = new PanaceaTemplateView('Wiki :: ' . $this->page);
|
||||
$templateView->mainView->addView($this->viewFactory->getView($this->page, $wikiObject, $this->action, $this->page));
|
||||
$templateView->mainView->addView($this->viewFactory->getView($this->page, $wikiObject, $vendor, $this->action, $this->page));
|
||||
|
||||
return $templateView;
|
||||
}
|
||||
|
@ -30,17 +30,16 @@
|
||||
* @uses addView()
|
||||
*
|
||||
* @param WikiPageObject $page The wiki page to display
|
||||
* @param DatabaseVendor $vendor A database connection object
|
||||
* @param string $action The action to take
|
||||
* @param int $priority The priority of the view
|
||||
* @param string $pageName The name of the page
|
||||
*/
|
||||
public function __construct(WikiPageObject $page = null, $action = null, $pageName = '', $priority = 0) {
|
||||
public function __construct(WikiPageObject $page = null, DatabaseVendor $vendor = null, $action = null, $pageName = '', $priority = 0) {
|
||||
parent::__construct($page, $action, $priority);
|
||||
|
||||
$this->addView(new WikiPageMenuView($page, $action, 1));
|
||||
|
||||
$vendor = MySql::getInstance('wiki', 'localhost', 'root', 'layne', 'wiki');
|
||||
|
||||
switch ($this->action) {
|
||||
case 'new':
|
||||
$this->addView(new WikiPageNewView($pageName, 2));
|
||||
|
Loading…
Reference in New Issue
Block a user