added in ability to view diffs from the history page
This commit is contained in:
parent
cb39cca4fb
commit
649def05df
@ -58,6 +58,7 @@
|
|||||||
case 'WikiPageContentView':
|
case 'WikiPageContentView':
|
||||||
case 'PanaceaWikiView':
|
case 'PanaceaWikiView':
|
||||||
case 'WikiRevisionHistoryView':
|
case 'WikiRevisionHistoryView':
|
||||||
|
case 'WikiRevisionDiffView':
|
||||||
$file = "$path/lib/views/wiki/$className.php";
|
$file = "$path/lib/views/wiki/$className.php";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
public function __construct(WikiPageObject $page, Collection $revisions, $action = null, $priority = 0) {
|
public function __construct(WikiPageObject $page, Collection $revisions, $action = null, $priority = 0) {
|
||||||
parent::__construct($page, $action, $priority);
|
parent::__construct($page, $action, $priority);
|
||||||
|
|
||||||
$this->addView(new WikiRevisionHistoryView($revisions, 1));
|
$this->addView(new WikiRevisionHistoryView($revisions, $this->page->page->page_name, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
$this->addView(new WikiPageMenuView($page, $action, 1));
|
$this->addView(new WikiPageMenuView($page, $action, 1));
|
||||||
|
|
||||||
|
$vendor = MySql::getInstance('wiki', 'localhost', 'root', 'layne', 'wiki');
|
||||||
|
|
||||||
switch ($this->action) {
|
switch ($this->action) {
|
||||||
case 'new':
|
case 'new':
|
||||||
$this->addView(new WikiPageNewView($pageName, 2));
|
$this->addView(new WikiPageNewView($pageName, 2));
|
||||||
@ -48,7 +50,6 @@
|
|||||||
break;
|
break;
|
||||||
case 'history':
|
case 'history':
|
||||||
//get all revisions for the page
|
//get all revisions for the page
|
||||||
$vendor = MySql::getInstance('wiki', 'localhost', 'root', 'layne', 'wiki');
|
|
||||||
$revisions = WikiHistory::getRevisionsForPage($vendor, $this->page->page);
|
$revisions = WikiHistory::getRevisionsForPage($vendor, $this->page->page);
|
||||||
$this->addView(new WikiPageHistoryView($this->page, $revisions, $this->action, 2));
|
$this->addView(new WikiPageHistoryView($this->page, $revisions, $this->action, 2));
|
||||||
break;
|
break;
|
||||||
@ -56,7 +57,20 @@
|
|||||||
$this->addView(new WikiPageStatsView($this->page, $this->action, 2));
|
$this->addView(new WikiPageStatsView($this->page, $this->action, 2));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$this->addView(new WikiPageContentView($this->page, $this->action, 2));
|
//check for diffs: WikiPage?diff[oldRev,newRev]
|
||||||
|
if (preg_match('/^diff\[(\d+),(\d+)\]$/', $this->action, $matches)) {
|
||||||
|
$oldRevision = (int)$matches[1];
|
||||||
|
$newRevision = (int)$matches[2];
|
||||||
|
|
||||||
|
$diff = $this->page->compareRevisions($oldRevision, $newRevision, $vendor);
|
||||||
|
//echo '<pre>'; var_dump($diff); echo '</pre>'; exit;
|
||||||
|
|
||||||
|
$this->addView(new WikiRevisionDiffView($this->page, $diff, $this->action, 2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//bogus/non-existent action, so just display the normal content
|
||||||
|
$this->addView(new WikiPageContentView($this->page, $this->action, 2));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
67
src/lib/views/wiki/WikiRevisionDiffView.php
Normal file
67
src/lib/views/wiki/WikiRevisionDiffView.php
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WikiPageHistoryView
|
||||||
|
*
|
||||||
|
* @package Panacea
|
||||||
|
* @subpackage Views
|
||||||
|
* @author Tommy Montgomery
|
||||||
|
* @since 2008-10-18
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Bootstraps the NowhereConcave framework */
|
||||||
|
require_once 'NowhereConcave/bootstrap.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* View for a wiki page's history
|
||||||
|
*
|
||||||
|
* @package Panacea
|
||||||
|
* @subpackage Views
|
||||||
|
* @author Tommy Montgomery
|
||||||
|
* @since 2008-10-18
|
||||||
|
*/
|
||||||
|
class WikiRevisionDiffView extends PanaceaWikiView {
|
||||||
|
|
||||||
|
protected $diff;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 WikiDiff $diff The diff between the two revisions
|
||||||
|
* @param string $action The action to take
|
||||||
|
* @param int $priority The priority of the view
|
||||||
|
*/
|
||||||
|
public function __construct(WikiPageObject $page, WikiDiff $diff, $action = null, $priority = 0) {
|
||||||
|
parent::__construct($page, $action, $priority);
|
||||||
|
|
||||||
|
$this->diff = $diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Renders the view
|
||||||
|
*
|
||||||
|
* @author Tommy Montgomery
|
||||||
|
* @since 2008-10-21
|
||||||
|
*/
|
||||||
|
public function send() { ?>
|
||||||
|
|
||||||
|
<h1>Diff r<?php echo $this->diff->oldRevision->revision; ?>/r<?php echo $this->diff->newRevision->revision;?></h1>
|
||||||
|
|
||||||
|
<div class="wikidiff">
|
||||||
|
<pre><?php echo $this->diff->getDiff(); ?></pre>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
parent::send();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -27,6 +27,13 @@
|
|||||||
*/
|
*/
|
||||||
protected $revisions;
|
protected $revisions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the page
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $pageName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link WikiRevisionHistoryView}
|
* Creates a new {@link WikiRevisionHistoryView}
|
||||||
*
|
*
|
||||||
@ -34,9 +41,10 @@
|
|||||||
* @since 2008-10-21
|
* @since 2008-10-21
|
||||||
*
|
*
|
||||||
* @param Collection $revisions The revisions to display
|
* @param Collection $revisions The revisions to display
|
||||||
|
* @param string $pageName The name of the page
|
||||||
* @param int $priority The priority of the view
|
* @param int $priority The priority of the view
|
||||||
*/
|
*/
|
||||||
public function __construct(Collection $revisions, $priority = 0) {
|
public function __construct(Collection $revisions, $pageName, $priority = 0) {
|
||||||
parent::__construct($priority);
|
parent::__construct($priority);
|
||||||
|
|
||||||
if ($revisions->type !== 'WikiHistory') {
|
if ($revisions->type !== 'WikiHistory') {
|
||||||
@ -44,6 +52,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->revisions = $revisions;
|
$this->revisions = $revisions;
|
||||||
|
$this->pageName = $pageName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,21 +69,32 @@
|
|||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
<th>Message</th>
|
<th>Message</th>
|
||||||
<th>Author</th>
|
<th>Author</th>
|
||||||
<th>Affected Lines</th>
|
<th>Diff</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
foreach ($this->revisions as $revision => $history) { ?>
|
$previous = null;
|
||||||
|
foreach ($this->revisions as $revision => $history) {
|
||||||
<tr>
|
$affectedBytes = 'n/a';
|
||||||
<td><?php echo $history->revision; ?></td>
|
if ($previous !== null) {
|
||||||
<td><?php echo $history->created; ?></td>
|
$link = $this->wikiPath . '/' . $this->pageName;
|
||||||
<td>Not implemented yet</td>
|
$link .= '?diff[' . $previous->revision . ',' . $revision .']';
|
||||||
<td><?php echo $history->created_user_id; ?></td>
|
$affectedBytes = strlen($history->wikitext) - strlen($previous->wikitext);
|
||||||
<td>Not implemented yet</td>
|
$affectedBytes = '<a href="' . $link .'">' . $affectedBytes . ' bytes</a>';
|
||||||
</tr>
|
}
|
||||||
|
|
||||||
|
$previous = $history;
|
||||||
|
?>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td><?php echo $history->revision; ?></td>
|
||||||
|
<td><?php echo $history->created; ?></td>
|
||||||
|
<td><?php echo $history->message; ?></td>
|
||||||
|
<td><?php echo $history->created_user_id; ?></td>
|
||||||
|
<td><?php echo $affectedBytes; ?></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user