diff --git a/src/bootstrap.php b/src/bootstrap.php index b133619..8474106 100644 --- a/src/bootstrap.php +++ b/src/bootstrap.php @@ -54,6 +54,7 @@ case 'WikiPageNewView': case 'WikiPageEditView': case 'WikiPageHistoryView': + case 'WikiPageStatsView': case 'WikiPageMenuView': case 'WikiPageContentView': case 'PanaceaWikiView': diff --git a/src/lib/views/wiki/PanaceaWikiView.php b/src/lib/views/wiki/PanaceaWikiView.php index c8581dd..a5f7f8a 100644 --- a/src/lib/views/wiki/PanaceaWikiView.php +++ b/src/lib/views/wiki/PanaceaWikiView.php @@ -1,7 +1,7 @@ action = $action; } + public function makeWikiUserLink($user) { + if (!is_string($user)) { + throw new InvalidTypeException(1, 'string', $user); + } + + return '' . $user . ''; + } + /** * Gets meta data for this view * diff --git a/src/lib/views/wiki/WikiPageEditView.php b/src/lib/views/wiki/WikiPageEditView.php index 5c8f63a..df7da8f 100644 --- a/src/lib/views/wiki/WikiPageEditView.php +++ b/src/lib/views/wiki/WikiPageEditView.php @@ -22,6 +22,13 @@ */ class WikiPageEditView extends PanaceaWikiView { + /** + * Renders the view + * + * @author Tommy Montgomery + * @since 2008-10-18 + * @uses WikiPageObject::getRevision() + */ public function send() { ?>
diff --git a/src/lib/views/wiki/WikiPageStatsView.php b/src/lib/views/wiki/WikiPageStatsView.php new file mode 100644 index 0000000..d2c4737 --- /dev/null +++ b/src/lib/views/wiki/WikiPageStatsView.php @@ -0,0 +1,110 @@ +stats = $stats; + } + + /** + * Renders the view + * + * @author Tommy Montgomery + * @since 2008-10-26 + */ + public function send() { + $age = time() - strtotime($this->stats->created); + $ageInDays = $age / 86400; + + $mostActiveAuthors = ''; + foreach ($this->stats->mostActiveAuthor as $author => $numRevisions) { + $mostActiveAuthors .= $this->makeWikiUserLink($author) . ' (' . $numRevisions . ' revisions)
'; + } + $mostActiveAuthors = substr($mostActiveAuthors, 0, -6); + + ?> + +

page->page->page_name; ?>: Statistics

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Createdstats->created; ?> by makeWikiUserLink($this->stats->creator); ?>
Last changestats->lastUpdated; ?> by makeWikiUserLink($this->stats->lastAuthor); ?>
Age days
Unparsed sizestats->size; ?> bytes
Revisionsstats->numRevisions; ?>
Revisions/daystats->numRevisions / $ageInDays; ?>
Unique authorsstats->numAuthors; ?>
Most active author(s)
+
+ + \ No newline at end of file diff --git a/src/lib/views/wiki/WikiPageView.php b/src/lib/views/wiki/WikiPageView.php index 0fd3208..b01f862 100644 --- a/src/lib/views/wiki/WikiPageView.php +++ b/src/lib/views/wiki/WikiPageView.php @@ -54,7 +54,8 @@ $this->addView(new WikiPageHistoryView($this->page, $revisions, $this->action, 2)); break; case 'stats': - $this->addView(new WikiPageStatsView($this->page, $this->action, 2)); + $stats = new WikiStats($this->page); + $this->addView(new WikiPageStatsView($this->page, $stats, $this->action, 2)); break; default: //check for diffs: WikiPage?diff[oldRev,newRev] @@ -63,8 +64,6 @@ $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 { diff --git a/src/lib/views/wiki/WikiRevisionDiffView.php b/src/lib/views/wiki/WikiRevisionDiffView.php index 566caba..2109300 100644 --- a/src/lib/views/wiki/WikiRevisionDiffView.php +++ b/src/lib/views/wiki/WikiRevisionDiffView.php @@ -1,45 +1,45 @@ diff = $diff; }