now you can edit/create wiki pages
This commit is contained in:
parent
f90dd02210
commit
bb2acc1ce1
@ -39,6 +39,7 @@
|
|||||||
//handlers
|
//handlers
|
||||||
case 'PanaceaPostHandlerFactory':
|
case 'PanaceaPostHandlerFactory':
|
||||||
case 'WikiEditPagePostHandler':
|
case 'WikiEditPagePostHandler':
|
||||||
|
case 'WikiNewPagePostHandler':
|
||||||
$file = "$path/lib/controllers/handlers/$className.php";
|
$file = "$path/lib/controllers/handlers/$className.php";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -67,11 +67,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$templateView = new PanaceaTemplateView('Wiki :: ' . $this->page);
|
try {
|
||||||
$wikiObject = new PanaceaWikiPageObject(WikiPage::loadByPageName($mysql, $this->page));
|
$wikiObject = new PanaceaWikiPageObject(WikiPage::loadByPageName($mysql, $this->page));
|
||||||
|
$wikiObject->setRevision(WikiHistory::REV_LATEST, $mysql);
|
||||||
|
}
|
||||||
|
catch (DomainException $e) {
|
||||||
|
//the page doesn't exist, so we don't need to pass the wiki object or action along
|
||||||
|
$wikiObject = null;
|
||||||
|
$this->action = 'new';
|
||||||
|
}
|
||||||
|
|
||||||
$wikiObject->setRevision(WikiHistory::REV_LATEST, $mysql);
|
$templateView = new PanaceaTemplateView('Wiki :: ' . $this->page);
|
||||||
$templateView->mainView->addView($this->viewFactory->getView($this->page, $wikiObject, $this->action));
|
$templateView->mainView->addView($this->viewFactory->getView($this->page, $wikiObject, $this->action, $this->page));
|
||||||
|
|
||||||
return $templateView;
|
return $templateView;
|
||||||
}
|
}
|
||||||
|
@ -48,15 +48,18 @@
|
|||||||
|
|
||||||
public static function getPostHandler(array $postData) {
|
public static function getPostHandler(array $postData) {
|
||||||
if (!isset($postData['handler'])) {
|
if (!isset($postData['handler'])) {
|
||||||
throw new InvalidPostDataException('handler', $postData);
|
throw new InvalidPostDataException($postData, array('handler'));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($postData['handler']) {
|
switch ($postData['handler']) {
|
||||||
case 'wikisource':
|
case 'wikiedit':
|
||||||
unset($postData['handler']);
|
unset($postData['handler']);
|
||||||
return new WikiPagePostHandler($postData);
|
return new WikiEditPagePostHandler($postData);
|
||||||
|
case 'wikinew':
|
||||||
|
unset($postData['handler']);
|
||||||
|
return new WikiNewPagePostHandler($postData);
|
||||||
default:
|
default:
|
||||||
throw new InvalidPostDataException('wikisource', $postData);
|
throw new Exception();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WikiPagePostHandler
|
* WikiEditPagePostHandler
|
||||||
*
|
*
|
||||||
* @package Panacea
|
* @package Panacea
|
||||||
* @subpackage Wiki
|
* @subpackage Wiki
|
||||||
@ -20,7 +20,7 @@
|
|||||||
* @author Tommy Montgomery
|
* @author Tommy Montgomery
|
||||||
* @since 2008-10-18
|
* @since 2008-10-18
|
||||||
*/
|
*/
|
||||||
class WikiPagePostHandler extends PostHandler {
|
class WikiEditPagePostHandler extends PostHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
|
74
src/lib/controllers/handlers/WikiNewPagePostHandler.php
Normal file
74
src/lib/controllers/handlers/WikiNewPagePostHandler.php
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WikiNewPagePostHandler
|
||||||
|
*
|
||||||
|
* @package Panacea
|
||||||
|
* @subpackage Wiki
|
||||||
|
* @author Tommy Montgomery
|
||||||
|
* @since 2008-10-21
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Bootstraps the NowhereConcave framework */
|
||||||
|
require_once 'NowhereConcave/bootstrap.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Object for handling POST requests for creating a new page
|
||||||
|
*
|
||||||
|
* @package Panacea
|
||||||
|
* @subpackage Wiki
|
||||||
|
* @author Tommy Montgomery
|
||||||
|
* @since 2008-10-21
|
||||||
|
*/
|
||||||
|
class WikiNewPagePostHandler extends PostHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*
|
||||||
|
* Creates a new wiki page and a its first revision.
|
||||||
|
*
|
||||||
|
* @author Tommy Montgomery
|
||||||
|
* @since 2008-10-21
|
||||||
|
*
|
||||||
|
* @param DatabaseVendor $vendor Database connection
|
||||||
|
* @throws {@link InvalidTypeException}
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function execute(DatabaseVendor $vendor = null) {
|
||||||
|
if (!($vendor instanceof DatabaseVendor)) {
|
||||||
|
throw new InvalidTypeException(1, 'DatabaseVendor', $vendor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($this->data['wikitext'])) {
|
||||||
|
throw new InvalidPostDataException('wikitext', $this->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
//create row in wiki.pages
|
||||||
|
$page = new WikiPage();
|
||||||
|
$fields = WikiPage::getFields($vendor);
|
||||||
|
foreach ($this->data as $key => $value) {
|
||||||
|
if (!isset($fields[$key])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
settype($value, $fields[$key]['type']);
|
||||||
|
$page->$key = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
$page->created_user_id = 1;
|
||||||
|
$page->category_id = 1;
|
||||||
|
$pageId = $page->insert($vendor);
|
||||||
|
|
||||||
|
//create first revision in wiki.history
|
||||||
|
$history = new WikiHistory();
|
||||||
|
WikiHistory::getFields($vendor);
|
||||||
|
$history->page_id = $pageId;
|
||||||
|
$history->revision = 1;
|
||||||
|
$history->wikitext = $this->data['wikitext'];
|
||||||
|
$history->created_user_id = 1;
|
||||||
|
return $history->insert($vendor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -29,6 +29,11 @@
|
|||||||
*/
|
*/
|
||||||
protected $page;
|
protected $page;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The action to take on the page (e.g. edit)
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
protected $action;
|
protected $action;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -38,9 +43,10 @@
|
|||||||
* @since 2008-10-18
|
* @since 2008-10-18
|
||||||
*
|
*
|
||||||
* @param WikiPageObject $page The wiki page to display
|
* @param WikiPageObject $page The wiki page to display
|
||||||
|
* @param string $action The action to perform on the page (e.g. edit)
|
||||||
* @param int $priority The priority of the view
|
* @param int $priority The priority of the view
|
||||||
*/
|
*/
|
||||||
public function __construct(WikiPageObject $page, $action = null, $priority = 0) {
|
public function __construct(WikiPageObject $page = null, $action = null, $priority = 0) {
|
||||||
parent::__construct($priority);
|
parent::__construct($priority);
|
||||||
|
|
||||||
$this->page = $page;
|
$this->page = $page;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<div class="wikicontent">
|
<div class="wikicontent">
|
||||||
<form action="<?php echo $this->wikiPath . '/' . $this->page->page->page_name; ?>" method="post">
|
<form action="<?php echo $this->wikiPath . '/' . $this->page->page->page_name; ?>" method="post">
|
||||||
<input type="hidden" name="handler" value="wikisource"/>
|
<input type="hidden" name="handler" value="wikiedit"/>
|
||||||
<input type="hidden" name="page_id" value="<?php echo $this->page->page->page_id ?>"/>
|
<input type="hidden" name="page_id" value="<?php echo $this->page->page->page_id ?>"/>
|
||||||
<textarea name="wikitext" rows="12" cols="80"><?php echo $this->page->getRevision()->wikitext; ?></textarea>
|
<textarea name="wikitext" rows="12" cols="80"><?php echo $this->page->getRevision()->wikitext; ?></textarea>
|
||||||
|
|
||||||
|
79
src/lib/views/wiki/WikiPageNewView.php
Normal file
79
src/lib/views/wiki/WikiPageNewView.php
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WikiPageNewView
|
||||||
|
*
|
||||||
|
* @package Panacea
|
||||||
|
* @subpackage Views
|
||||||
|
* @author Tommy Montgomery
|
||||||
|
* @since 2008-10-20
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Bootstraps the NowhereConcave framework */
|
||||||
|
require_once 'NowhereConcave/bootstrap.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View for creating a new wiki page
|
||||||
|
*
|
||||||
|
* @package Panacea
|
||||||
|
* @subpackage Views
|
||||||
|
* @author Tommy Montgomery
|
||||||
|
* @since 2008-10-20
|
||||||
|
*/
|
||||||
|
class WikiPageNewView extends PanaceaWikiView {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the new page
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $pageName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new {@link WikiPageNewView} for the specified page name
|
||||||
|
*
|
||||||
|
* @author Tommy Montgomery
|
||||||
|
* @since 2008-10-20
|
||||||
|
*
|
||||||
|
* @param string $pageName The name of the new page
|
||||||
|
*/
|
||||||
|
public function __construct($pageName, $priority = 0) {
|
||||||
|
if (!is_string($pageName)) {
|
||||||
|
throw new InvalidTypeException(1, 'string', $pageName);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::__construct(null, null, $priority);
|
||||||
|
|
||||||
|
$this->pageName = $pageName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the view
|
||||||
|
*
|
||||||
|
* @author Tommy Montgomery
|
||||||
|
* @since 2008-10-20
|
||||||
|
*/
|
||||||
|
public function send() { ?>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The page <b><tt><?php echo $this->pageName; ?></tt></b> has not
|
||||||
|
yet been created. Type some stuff into the textarea below, and then
|
||||||
|
press <i>Create New Page</i> to create the page.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="wikicontent">
|
||||||
|
<form action="<?php echo $this->wikiPath . '/' . $this->pageName; ?>" method="post">
|
||||||
|
<input type="hidden" name="handler" value="wikinew"/>
|
||||||
|
<input type="hidden" name="page_name" value="<?php echo $this->pageName; ?>"/>
|
||||||
|
<textarea name="wikitext" rows="12" cols="80"></textarea>
|
||||||
|
<input type="submit" name="submit" value="Create New Page"/>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -27,31 +27,37 @@
|
|||||||
*
|
*
|
||||||
* @author Tommy Montgomery
|
* @author Tommy Montgomery
|
||||||
* @since 2008-10-18
|
* @since 2008-10-18
|
||||||
|
* @uses addView()
|
||||||
*
|
*
|
||||||
* @param WikiPageObject $page The wiki page to display
|
* @param WikiPageObject $page The wiki page to display
|
||||||
|
* @param string $action The action to take
|
||||||
* @param int $priority The priority of the view
|
* @param int $priority The priority of the view
|
||||||
|
* @param string $pageName The name of the page
|
||||||
*/
|
*/
|
||||||
public function __construct(WikiPageObject $page, $action = null, $priority = 0) {
|
public function __construct(WikiPageObject $page = null, $action = null, $pageName = '', $priority = 0) {
|
||||||
parent::__construct($page, $action, $priority);
|
parent::__construct($page, $action, $priority);
|
||||||
|
|
||||||
$this->addView(new WikiPageMenuView($page, $action, 1));
|
$this->addView(new WikiPageMenuView($page, $action, 1));
|
||||||
|
|
||||||
switch ($action) {
|
switch ($this->action) {
|
||||||
|
case 'new':
|
||||||
|
$this->addView(new WikiPageNewView($pageName, 2));
|
||||||
|
break;
|
||||||
case 'edit':
|
case 'edit':
|
||||||
$this->addView(new WikiPageEditView($page, $action, 2));
|
$this->addView(new WikiPageEditView($this->page, $this->action, 2));
|
||||||
break;
|
break;
|
||||||
case 'history':
|
case 'history':
|
||||||
$this->addView(new WikiPageHistoryView($page, $action, 2));
|
$this->addView(new WikiPageHistoryView($this->page, $this->action, 2));
|
||||||
break;
|
break;
|
||||||
case 'stats':
|
case 'stats':
|
||||||
$this->addView(new WikiPageStatsView($page, $action, 2));
|
$this->addView(new WikiPageStatsView($this->page, $this->action, 2));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->addView(new WikiPageContentView($page, $action, 2));
|
$this->addView(new WikiPageContentView($this->page, $this->action, 2));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->addView(new WikiPageMenuView($page, $action, 3));
|
$this->addView(new WikiPageMenuView($this->page, $this->action, 3));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -94,12 +94,20 @@ ul.menu {
|
|||||||
}
|
}
|
||||||
#main a {
|
#main a {
|
||||||
border-bottom: 1px dotted #000000;
|
border-bottom: 1px dotted #000000;
|
||||||
color: #669966 ;
|
color: #000099;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
#main a.broken {
|
||||||
|
color: #CC6666;
|
||||||
|
}
|
||||||
|
#main a.broken:hover {
|
||||||
|
background-color: #CC6666;
|
||||||
|
color: #FFFFFF;
|
||||||
|
}
|
||||||
#main a:hover {
|
#main a:hover {
|
||||||
color: #000000;
|
background-color: #000099;
|
||||||
border-bottom: 2px solid #669966;
|
color: #FFFFFF;
|
||||||
|
border-bottom: 1px solid transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
#foot {
|
#foot {
|
||||||
|
Loading…
Reference in New Issue
Block a user