diff --git a/src/bootstrap.php b/src/bootstrap.php index 001ce41..b133619 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -58,6 +58,7 @@ case 'WikiPageContentView': case 'PanaceaWikiView': case 'WikiRevisionHistoryView': + case 'WikiRevisionDiffView': $file = "$path/lib/views/wiki/$className.php"; break; diff --git a/src/lib/views/wiki/WikiPageHistoryView.php b/src/lib/views/wiki/WikiPageHistoryView.php index 93f5341..da764c0 100644 --- a/src/lib/views/wiki/WikiPageHistoryView.php +++ b/src/lib/views/wiki/WikiPageHistoryView.php @@ -38,7 +38,7 @@ public function __construct(WikiPageObject $page, Collection $revisions, $action = null, $priority = 0) { parent::__construct($page, $action, $priority); - $this->addView(new WikiRevisionHistoryView($revisions, 1)); + $this->addView(new WikiRevisionHistoryView($revisions, $this->page->page->page_name, 1)); } /** diff --git a/src/lib/views/wiki/WikiPageView.php b/src/lib/views/wiki/WikiPageView.php index f6ec5cc..0fd3208 100644 --- a/src/lib/views/wiki/WikiPageView.php +++ b/src/lib/views/wiki/WikiPageView.php @@ -39,6 +39,8 @@ $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)); @@ -48,7 +50,6 @@ break; case 'history': //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; @@ -56,7 +57,20 @@ $this->addView(new WikiPageStatsView($this->page, $this->action, 2)); break; 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 '
'; var_dump($diff); echo ''; 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; } diff --git a/src/lib/views/wiki/WikiRevisionDiffView.php b/src/lib/views/wiki/WikiRevisionDiffView.php new file mode 100644 index 0000000..87775e4 --- /dev/null +++ b/src/lib/views/wiki/WikiRevisionDiffView.php @@ -0,0 +1,67 @@ +diff = $diff; + } + + /** + * Renders the view + * + * @author Tommy Montgomery + * @since 2008-10-21 + */ + public function send() { ?> + +
diff->getDiff(); ?>+