implemented the history portion of the wiki page; added the "Page" link to the wiki menu

This commit is contained in:
tmont 2008-10-22 08:17:09 +00:00
parent 378e4a31ad
commit 395f83d5dc
4 changed files with 124 additions and 4 deletions

View File

@ -13,7 +13,7 @@
require_once 'NowhereConcave/bootstrap.php';
/**
* View for wiki source
* View for a wiki page's history
*
* @package Panacea
* @subpackage Views
@ -22,12 +22,38 @@
*/
class WikiPageHistoryView extends PanaceaWikiView {
/**
* Creates a new {@link WikiPageHistoryView}
*
* @author Tommy Montgomery
* @since 2008-10-21
* @uses addView()
* @uses WikiRevisionHistoryView
*
* @param WikiPageObject $page The wiki page to display
* @param array $revisions The revisions to display
* @param string $action The action to take
* @param int $priority The priority of the view
*/
public function __construct(WikiPageObject $page, array $revisions, $action = null, $priority = 0) {
parent::__construct($page, $action, $priority);
$this->addView(new WikiRevisionHistoryView($revisions, 1));
}
/**
* Renders the view
*
* @author Tommy Montgomery
* @since 2008-10-21
*/
public function send() { ?>
<h1>Revision History for <i><?php echo $this->page->page->page_name; ?></i></h1>
<?php
parent::send();
}
}

View File

@ -35,6 +35,7 @@
<li><a href="<?php echo $this->wikiPath; ?>/<?php echo $this->page->page->page_name; ?>?stats">Statistics</a></li>
<li><a href="<?php echo $this->wikiPath; ?>/<?php echo $this->page->page->page_name; ?>?history">History</a></li>
<li><a href="<?php echo $this->wikiPath; ?>/<?php echo $this->page->page->page_name; ?>?edit">Edit</a></li>
<li><a href="<?php echo $this->wikiPath; ?>/<?php echo $this->page->page->page_name; ?>">Page</a></li>
</ul>
<div style="clear:right"></div>
</div>

View File

@ -47,7 +47,10 @@
$this->addView(new WikiPageEditView($this->page, $this->action, 2));
break;
case 'history':
$this->addView(new WikiPageHistoryView($this->page, $this->action, 2));
//get all revisions for the page
$vendor = MySql::getInstance('wiki', 'localhost', 'root', 'layne', 'wiki');
$revisions = WikiHistory::getRevisionsForPage($vendor, $this->page->page);
$this->addView(new WikiPageHistoryView($this->page, $revisions, $this->action, 2));
break;
case 'stats':
$this->addView(new WikiPageStatsView($this->page, $this->action, 2));

View File

@ -0,0 +1,90 @@
<?php
/**
* WikiRevisionHistoryView
*
* @package Panacea
* @subpackage Views
* @author Tommy Montgomery
* @since 2008-10-21
*/
/** Bootstraps the NowhereConcave framework */
require_once 'NowhereConcave/bootstrap.php';
/**
* View for a wiki page's revision history
*
* @package Panacea
* @subpackage Views
* @author Tommy Montgomery
* @since 2008-10-21
*/
class WikiRevisionHistoryView extends PanaceaView {
/**
* Array of {@link WikiHistory}s
*
* @var array
*/
protected $revisions;
/**
* Creates a new {@link WikiRevisionHistoryView}
*
* @author Tommy Montgomery
* @since 2008-10-21
*
* @param array $revisions The revisions to display
* @param int $priority The priority of the view
*/
public function __construct(array $revisions, $priority = 0) {
parent::__construct($priority);
$this->revisions = $revisions;
}
/**
* Renders the view
*
* @author Tommy Montgomery
* @since 2008-10-21
*/
public function send() { ?>
<table>
<tr>
<th>#</th>
<th>Date</th>
<th>Message</th>
<th>Author</th>
<th>Affected Lines</th>
</tr>
<?php
foreach ($this->revisions as $revision => $history) { ?>
<tr>
<td><?php echo $revision; ?></td>
<td><?php echo $history->created; ?></td>
<td>Not implemented yet</td>
<td><?php echo $history->created_user_id; ?></td>
<td>Not implemented yet</td>
</tr>
<?php
}
?>
</table>
<?php
}
}
?>