r40890 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40889‎ | r40890 | r40891 >
Date:00:07, 16 September 2008
Author:brion
Status:old
Tags:
Comment:
Split view classes out from SpecialCode.php, which is growing larger
Modified paths:
  • /trunk/extensions/CodeReview/CodeRepoListView.php (added) (history)
  • /trunk/extensions/CodeReview/CodeReview.php (modified) (history)
  • /trunk/extensions/CodeReview/CodeRevisionListView.php (added) (history)
  • /trunk/extensions/CodeReview/CodeRevisionView.php (added) (history)
  • /trunk/extensions/CodeReview/SpecialCode.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/CodeReview.php
@@ -39,7 +39,10 @@
4040 $dir = dirname(__FILE__) . '/';
4141
4242 $wgAutoloadClasses['CodeRepository'] = $dir . 'CodeRepository.php';
 43+$wgAutoloadClasses['CodeRepoListView'] = $dir . 'CodeRepoListView.php';
4344 $wgAutoloadClasses['CodeRevision'] = $dir . 'CodeRevision.php';
 45+$wgAutoloadClasses['CodeRevisionListView'] = $dir . 'CodeRevisionListView.php';
 46+$wgAutoloadClasses['CodeRevisionView'] = $dir . 'CodeRevisionView.php';
4447 $wgAutoloadClasses['CodeComment'] = $dir . 'CodeComment.php';
4548 $wgAutoloadClasses['SpecialCode'] = $dir . 'SpecialCode.php';
4649 $wgAutoloadClasses['SpecialRepoAdmin'] = $dir . 'SpecialRepoAdmin.php';
Index: trunk/extensions/CodeReview/SpecialCode.php
@@ -144,306 +144,3 @@
145145 return "[[" . $title->getPrefixedText() . "|$text]]";
146146 }
147147 }
148 -
149 -// Special:Code
150 -class CodeRepoListView {
151 -
152 - function execute() {
153 - global $wgOut;
154 - $repos = CodeRepository::getRepoList();
155 - if( !count( $repos ) ){
156 - $wgOut->addWikiMsg( 'code-no-repo' );
157 - return;
158 - }
159 - $text = '';
160 - foreach( $repos as $repo ){
161 - $name = $repo->getName();
162 - $text .= "* [[Special:Code/$name|$name]]\n";
163 - }
164 - $wgOut->addWikiText( $text );
165 - }
166 -}
167 -
168 -// Special:Code/MediaWiki
169 -class CodeRevisionListView extends CodeView {
170 - function __construct( $repoName ) {
171 - parent::__construct();
172 - $this->mRepo = CodeRepository::newFromName( $repoName );
173 - }
174 -
175 - function execute() {
176 - global $wgOut;
177 - if( !$this->mRepo ) {
178 - $view = new CodeRepoListView();
179 - $view->execute();
180 - return;
181 - }
182 - $pager = new SvnRevTablePager( $this );
183 - $wgOut->addHtml( $pager->getBody() . $pager->getNavigationBar() );
184 - }
185 -}
186 -
187 -// Pager for CodeRevisionListView
188 -class SvnRevTablePager extends TablePager {
189 -
190 - function __construct( CodeRevisionListView $view ){
191 - $this->mView = $view;
192 - $this->mRepo = $view->mRepo;
193 - $this->mDefaultDirection = true;
194 - parent::__construct();
195 - }
196 -
197 - function isFieldSortable( $field ){
198 - return $field == 'cr_id';
199 - }
200 -
201 - function getDefaultSort(){ return 'cr_id'; }
202 -
203 - function getQueryInfo(){
204 - return array(
205 - 'tables' => array( 'code_rev' ),
206 - 'fields' => array_keys( $this->getFieldNames() ),
207 - 'conds' => array( 'cr_repo_id' => $this->mRepo->getId() ),
208 - );
209 - }
210 -
211 - function getFieldNames(){
212 - return array(
213 - 'cr_id' => wfMsg( 'code-field-id' ),
214 - 'cr_message' => wfMsg( 'code-field-message' ),
215 - 'cr_author' => wfMsg( 'code-field-author' ),
216 - 'cr_timestamp' => wfMsg( 'code-field-timestamp' ),
217 - );
218 - }
219 -
220 - function formatValue( $name, $value ){
221 - global $wgUser, $wgLang;
222 - switch( $name ){
223 - case 'cr_id':
224 - global $wgUser;
225 - return $wgUser->getSkin()->link(
226 - SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $value ), htmlspecialchars( $value )
227 - );
228 - case 'cr_author':
229 - return $this->mView->authorLink( $value );
230 - case 'cr_message':
231 - return $this->mView->messageFragment( $value );
232 - case 'cr_timestamp':
233 - global $wgLang;
234 - return $wgLang->timeanddate( $value );
235 - }
236 - }
237 -
238 - function getTitle(){
239 - return SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() );
240 - }
241 -}
242 -
243 -// Special:Code/MediaWiki/40696
244 -class CodeRevisionView extends CodeView {
245 -
246 - function __construct( $repoName, $rev, $replyTarget=null ){
247 - parent::__construct();
248 - $this->mRepo = CodeRepository::newFromName( $repoName );
249 - $this->mRev = $this->mRepo ? $this->mRepo->getRevision( intval( $rev ) ) : null;
250 - $this->mReplyTarget = $replyTarget;
251 - }
252 -
253 - function execute(){
254 - global $wgOut, $wgUser;
255 - if( !$this->mRepo || !$this->mRev ) {
256 - $view = new CodeRepoListView();
257 - $view->execute();
258 - return;
259 - }
260 -
261 - $redirectOnPost = $this->checkPostings();
262 - if( $redirectOnPost ) {
263 - $wgOut->redirect( $redirectOnPost );
264 - return;
265 - }
266 -
267 - $repoLink = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ),
268 - htmlspecialchars( $this->mRepo->getName() ) );
269 - $rev = $this->mRev->getId();
270 - $revText = htmlspecialchars( $rev );
271 - $viewvc = $this->mRepo->getViewVcBase();
272 - if( $viewvc ){
273 - $url = htmlspecialchars( "$viewvc/?view=rev&revision=$rev" );
274 - $viewvcTxt = wfMsgHtml( 'code-rev-rev-viewvc' );
275 - $revText .= " (<a href=\"$url\" title=\"revision $rev\">$viewvcTxt</a>)";
276 - }
277 - $paths = '';
278 - $modifiedPaths = $this->mRev->getModifiedPaths();
279 - foreach( $modifiedPaths as $row ){
280 - $paths .= $this->formatPathLine( $row->cp_path, $row->cp_action );
281 - }
282 - if( $paths ){
283 - $paths = "<ul>\n$paths</ul>";
284 - }
285 - $html = '<table>
286 -<tr><td valign="top">' . wfMsgHtml( 'code-rev-repo' ) . '</td><td valign="top">' . $repoLink . '</td></tr>
287 -<tr><td valign="top">' . wfMsgHtml( 'code-rev-rev' ) . '</td><td valign="top">' . $revText . '</td></tr>
288 -<tr><td valign="top">' . wfMsgHtml( 'code-rev-author' ) . '</td><td valign="top">' . $this->authorLink( $this->mRev->getAuthor() ) . '</td></tr>
289 -<tr><td valign="top">' . wfMsgHtml( 'code-rev-message' ) . '</td><td valign="top">' . $this->formatMessage( $this->mRev->getMessage() ) . '</td></tr>
290 -<tr><td valign="top">' . wfMsgHtml( 'code-rev-paths' ) . '</td><td valign="top">' . $paths . '</td></tr>
291 -</table>';
292 - $html .=
293 - "<h2>" . wfMsgHtml( 'code-rev-diff' ) . "</h2>" .
294 - "<div class='mw-codereview-diff'>" .
295 - $this->formatDiff() .
296 - "</div>";
297 -
298 - $html .=
299 - "<h2>Comments</h2>" .
300 - $this->formatComments();
301 -
302 - if( $this->mReplyTarget ) {
303 - $id = intval( $this->mReplyTarget );
304 - $html .= "<script>addOnloadHook(function(){" .
305 - "document.getElementById('wpReplyTo$id').focus();" .
306 - "});</script>";
307 - }
308 -
309 - $wgOut->addHtml( $html );
310 - }
311 -
312 - function checkPostings() {
313 - global $wgRequest, $wgUser;
314 - if( $wgRequest->wasPosted()
315 - && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
316 - // Look for a posting...
317 - $text = $wgRequest->getText( 'wpReply' );
318 - $parent = $wgRequest->getIntOrNull( 'wpParent' );
319 - $review = $wgRequest->getInt( 'wpReview' );
320 - $isPreview = $wgRequest->getCheck( 'wpCommentPreview' );
321 - if( $isPreview ) {
322 - // NYI
323 - } else {
324 - $id = $this->mRev->saveComment( $text, $review, $parent );
325 -
326 - // Redirect to the just-saved comment; this avoids POST
327 - // horrors on forward/rewind. Hope we don't have slave issues?
328 - $permaLink = $this->commentLink( $id );
329 - return $permaLink->getFullUrl();
330 - }
331 - }
332 - return false;
333 - }
334 -
335 - function formatPathLine( $path, $action ) {
336 - $desc = wfMsgHtml( 'code-rev-modified-'.strtolower( $action ) );
337 - $encPath = htmlspecialchars( $path );
338 - $viewvc = $this->mRepo->getViewVcBase();
339 - if( $viewvc ) {
340 - $rev = $this->mRev->getId();
341 - $safePath = wfUrlEncode( $path );
342 - $link = $this->mSkin->makeExternalLink(
343 - "$viewvc$safePath?view=markup&pathrev=$rev",
344 - $encPath );
345 - } else {
346 - $link = $encPath;
347 - }
348 - return "<li>$link ($desc)</li>\n";
349 - }
350 -
351 - function formatDiff() {
352 - $diff = $this->mRepo->getDiff( $this->mRev->getId() );
353 - return "<pre>" . htmlspecialchars( $diff ) . "</pre>";
354 - }
355 -
356 - function formatComments() {
357 - return "<div class='mw-codereview-comments'>" .
358 - implode( "\n",
359 - array_map(
360 - array( $this, 'formatCommentInline' ),
361 - $this->mRev->getComments() ) ) .
362 - $this->postCommentForm() .
363 - "</div>";
364 - }
365 -
366 - function formatCommentInline( $comment ) {
367 - if( $comment->id == $this->mReplyTarget ) {
368 - return $this->formatComment( $comment,
369 - $this->postCommentForm( $comment->id ) );
370 - } else {
371 - return $this->formatComment( $comment );
372 - }
373 - }
374 -
375 - function commentLink( $commentId ) {
376 - $repo = $this->mRepo->getName();
377 - $rev = $this->mRev->getId();
378 - $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" );
379 - $title->setFragment( "#c{$commentId}" );
380 - return $title;
381 - }
382 -
383 - function formatComment( $comment, $replyForm='' ) {
384 - global $wgOut, $wgLang;
385 - $linker = new CodeCommentLinkerWiki( $this->mRepo );
386 -
387 - return Xml::openElement( 'div',
388 - array(
389 - 'class' => 'mw-codereview-comment',
390 - 'id' => 'c' . intval( $comment->id ),
391 - 'style' => $this->commentStyle( $comment ) ) ) .
392 - '<div class="mw-codereview-comment-meta">' .
393 - $this->mSkin->link( $this->commentLink( $comment->id ), "#" ) .
394 - wfMsgHtml( 'code-rev-comment-by',
395 - $this->mSkin->userLink( $comment->user, $comment->userText ) .
396 - $this->mSkin->userToolLinks( $comment->user, $comment->userText ) ) .
397 - ' &nbsp; ' .
398 - $wgLang->timeanddate( $comment->timestamp ) .
399 - ' ' .
400 - $this->commentReplyLink( $comment->id ) .
401 - '</div>' .
402 - '<div class="mw-codereview-comment-text">' .
403 - $wgOut->parse( $linker->link( $comment->text ) ) .
404 - '</div>' .
405 - $replyForm .
406 - '</div>';
407 - }
408 -
409 - function commentStyle( $comment ) {
410 - $depth = $comment->threadDepth();
411 - $margin = ($depth - 1) * 48;
412 - return "margin-left: ${margin}px";
413 - }
414 -
415 - function commentReplyLink( $id ) {
416 - $repo = $this->mRepo->getName();
417 - $rev = $this->mRev->getId();
418 - $self = SpecialPage::getTitleFor( 'Code', "$repo/$rev/reply/$id" );
419 - $self->setFragment( "#c$id" );
420 - return '[' .
421 - $this->mSkin->link( $self, wfMsg( 'codereview-reply-link' ) ) .
422 - ']';
423 - }
424 -
425 - function postCommentForm( $parent=null ) {
426 - global $wgUser;
427 - return '<div class="mw-codereview-post-comment">' .
428 - Xml::openElement( 'form',
429 - array(
430 - 'action' => '', // fixme
431 - 'method' => 'post' ) ) .
432 - Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
433 - ($parent ? Xml::hidden( 'wpParent', $parent ) : '') .
434 - '<div>' .
435 - Xml::openElement( 'textarea', array(
436 - 'name' => 'wpReply',
437 - 'id' => "wpReplyTo{$parent}",
438 - 'cols' => 40,
439 - 'rows' => 5 ) ) .
440 - '</textarea>' .
441 - '</div>' .
442 - '<div>' .
443 - Xml::submitButton( wfMsg( 'code-rev-comment-submit' ), array( 'name' => 'wpSave' ) ) .
444 - ' ' .
445 - Xml::submitButton( wfMsg( 'code-rev-comment-preview' ), array( 'name' => 'wpPreview' ) ) .
446 - '</div>' .
447 - '</div>' .
448 - '</form>';
449 - }
450 -}
Index: trunk/extensions/CodeReview/CodeRevisionListView.php
@@ -0,0 +1,76 @@
 2+<?php
 3+
 4+// Special:Code/MediaWiki
 5+class CodeRevisionListView extends CodeView {
 6+ function __construct( $repoName ) {
 7+ parent::__construct();
 8+ $this->mRepo = CodeRepository::newFromName( $repoName );
 9+ }
 10+
 11+ function execute() {
 12+ global $wgOut;
 13+ if( !$this->mRepo ) {
 14+ $view = new CodeRepoListView();
 15+ $view->execute();
 16+ return;
 17+ }
 18+ $pager = new SvnRevTablePager( $this );
 19+ $wgOut->addHtml( $pager->getBody() . $pager->getNavigationBar() );
 20+ }
 21+}
 22+
 23+// Pager for CodeRevisionListView
 24+class SvnRevTablePager extends TablePager {
 25+
 26+ function __construct( CodeRevisionListView $view ){
 27+ $this->mView = $view;
 28+ $this->mRepo = $view->mRepo;
 29+ $this->mDefaultDirection = true;
 30+ parent::__construct();
 31+ }
 32+
 33+ function isFieldSortable( $field ){
 34+ return $field == 'cr_id';
 35+ }
 36+
 37+ function getDefaultSort(){ return 'cr_id'; }
 38+
 39+ function getQueryInfo(){
 40+ return array(
 41+ 'tables' => array( 'code_rev' ),
 42+ 'fields' => array_keys( $this->getFieldNames() ),
 43+ 'conds' => array( 'cr_repo_id' => $this->mRepo->getId() ),
 44+ );
 45+ }
 46+
 47+ function getFieldNames(){
 48+ return array(
 49+ 'cr_id' => wfMsg( 'code-field-id' ),
 50+ 'cr_message' => wfMsg( 'code-field-message' ),
 51+ 'cr_author' => wfMsg( 'code-field-author' ),
 52+ 'cr_timestamp' => wfMsg( 'code-field-timestamp' ),
 53+ );
 54+ }
 55+
 56+ function formatValue( $name, $value ){
 57+ global $wgUser, $wgLang;
 58+ switch( $name ){
 59+ case 'cr_id':
 60+ global $wgUser;
 61+ return $wgUser->getSkin()->link(
 62+ SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() . '/' . $value ), htmlspecialchars( $value )
 63+ );
 64+ case 'cr_author':
 65+ return $this->mView->authorLink( $value );
 66+ case 'cr_message':
 67+ return $this->mView->messageFragment( $value );
 68+ case 'cr_timestamp':
 69+ global $wgLang;
 70+ return $wgLang->timeanddate( $value );
 71+ }
 72+ }
 73+
 74+ function getTitle(){
 75+ return SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() );
 76+ }
 77+}
Property changes on: trunk/extensions/CodeReview/CodeRevisionListView.php
___________________________________________________________________
Added: svn:eol-style
178 + native
Index: trunk/extensions/CodeReview/CodeRevisionView.php
@@ -0,0 +1,210 @@
 2+<?php
 3+
 4+// Special:Code/MediaWiki/40696
 5+class CodeRevisionView extends CodeView {
 6+
 7+ function __construct( $repoName, $rev, $replyTarget=null ){
 8+ parent::__construct();
 9+ $this->mRepo = CodeRepository::newFromName( $repoName );
 10+ $this->mRev = $this->mRepo ? $this->mRepo->getRevision( intval( $rev ) ) : null;
 11+ $this->mReplyTarget = $replyTarget;
 12+ }
 13+
 14+ function execute(){
 15+ global $wgOut, $wgUser;
 16+ if( !$this->mRepo || !$this->mRev ) {
 17+ $view = new CodeRepoListView();
 18+ $view->execute();
 19+ return;
 20+ }
 21+
 22+ $redirectOnPost = $this->checkPostings();
 23+ if( $redirectOnPost ) {
 24+ $wgOut->redirect( $redirectOnPost );
 25+ return;
 26+ }
 27+
 28+ $repoLink = $wgUser->getSkin()->link( SpecialPage::getTitleFor( 'Code', $this->mRepo->getName() ),
 29+ htmlspecialchars( $this->mRepo->getName() ) );
 30+ $rev = $this->mRev->getId();
 31+ $revText = htmlspecialchars( $rev );
 32+ $viewvc = $this->mRepo->getViewVcBase();
 33+ if( $viewvc ){
 34+ $url = htmlspecialchars( "$viewvc/?view=rev&revision=$rev" );
 35+ $viewvcTxt = wfMsgHtml( 'code-rev-rev-viewvc' );
 36+ $revText .= " (<a href=\"$url\" title=\"revision $rev\">$viewvcTxt</a>)";
 37+ }
 38+ $paths = '';
 39+ $modifiedPaths = $this->mRev->getModifiedPaths();
 40+ foreach( $modifiedPaths as $row ){
 41+ $paths .= $this->formatPathLine( $row->cp_path, $row->cp_action );
 42+ }
 43+ if( $paths ){
 44+ $paths = "<ul>\n$paths</ul>";
 45+ }
 46+ $html = '<table>
 47+<tr><td valign="top">' . wfMsgHtml( 'code-rev-repo' ) . '</td><td valign="top">' . $repoLink . '</td></tr>
 48+<tr><td valign="top">' . wfMsgHtml( 'code-rev-rev' ) . '</td><td valign="top">' . $revText . '</td></tr>
 49+<tr><td valign="top">' . wfMsgHtml( 'code-rev-author' ) . '</td><td valign="top">' . $this->authorLink( $this->mRev->getAuthor() ) . '</td></tr>
 50+<tr><td valign="top">' . wfMsgHtml( 'code-rev-message' ) . '</td><td valign="top">' . $this->formatMessage( $this->mRev->getMessage() ) . '</td></tr>
 51+<tr><td valign="top">' . wfMsgHtml( 'code-rev-paths' ) . '</td><td valign="top">' . $paths . '</td></tr>
 52+</table>';
 53+ $html .=
 54+ "<h2>" . wfMsgHtml( 'code-rev-diff' ) . "</h2>" .
 55+ "<div class='mw-codereview-diff'>" .
 56+ $this->formatDiff() .
 57+ "</div>";
 58+
 59+ $html .=
 60+ "<h2>Comments</h2>" .
 61+ $this->formatComments();
 62+
 63+ if( $this->mReplyTarget ) {
 64+ $id = intval( $this->mReplyTarget );
 65+ $html .= "<script>addOnloadHook(function(){" .
 66+ "document.getElementById('wpReplyTo$id').focus();" .
 67+ "});</script>";
 68+ }
 69+
 70+ $wgOut->addHtml( $html );
 71+ }
 72+
 73+ function checkPostings() {
 74+ global $wgRequest, $wgUser;
 75+ if( $wgRequest->wasPosted()
 76+ && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ) ) {
 77+ // Look for a posting...
 78+ $text = $wgRequest->getText( 'wpReply' );
 79+ $parent = $wgRequest->getIntOrNull( 'wpParent' );
 80+ $review = $wgRequest->getInt( 'wpReview' );
 81+ $isPreview = $wgRequest->getCheck( 'wpCommentPreview' );
 82+ if( $isPreview ) {
 83+ // NYI
 84+ } else {
 85+ $id = $this->mRev->saveComment( $text, $review, $parent );
 86+
 87+ // Redirect to the just-saved comment; this avoids POST
 88+ // horrors on forward/rewind. Hope we don't have slave issues?
 89+ $permaLink = $this->commentLink( $id );
 90+ return $permaLink->getFullUrl();
 91+ }
 92+ }
 93+ return false;
 94+ }
 95+
 96+ function formatPathLine( $path, $action ) {
 97+ $desc = wfMsgHtml( 'code-rev-modified-'.strtolower( $action ) );
 98+ $encPath = htmlspecialchars( $path );
 99+ $viewvc = $this->mRepo->getViewVcBase();
 100+ if( $viewvc ) {
 101+ $rev = $this->mRev->getId();
 102+ $safePath = wfUrlEncode( $path );
 103+ $link = $this->mSkin->makeExternalLink(
 104+ "$viewvc$safePath?view=markup&pathrev=$rev",
 105+ $encPath );
 106+ } else {
 107+ $link = $encPath;
 108+ }
 109+ return "<li>$link ($desc)</li>\n";
 110+ }
 111+
 112+ function formatDiff() {
 113+ $diff = $this->mRepo->getDiff( $this->mRev->getId() );
 114+ return "<pre>" . htmlspecialchars( $diff ) . "</pre>";
 115+ }
 116+
 117+ function formatComments() {
 118+ return "<div class='mw-codereview-comments'>" .
 119+ implode( "\n",
 120+ array_map(
 121+ array( $this, 'formatCommentInline' ),
 122+ $this->mRev->getComments() ) ) .
 123+ $this->postCommentForm() .
 124+ "</div>";
 125+ }
 126+
 127+ function formatCommentInline( $comment ) {
 128+ if( $comment->id == $this->mReplyTarget ) {
 129+ return $this->formatComment( $comment,
 130+ $this->postCommentForm( $comment->id ) );
 131+ } else {
 132+ return $this->formatComment( $comment );
 133+ }
 134+ }
 135+
 136+ function commentLink( $commentId ) {
 137+ $repo = $this->mRepo->getName();
 138+ $rev = $this->mRev->getId();
 139+ $title = SpecialPage::getTitleFor( 'Code', "$repo/$rev" );
 140+ $title->setFragment( "#c{$commentId}" );
 141+ return $title;
 142+ }
 143+
 144+ function formatComment( $comment, $replyForm='' ) {
 145+ global $wgOut, $wgLang;
 146+ $linker = new CodeCommentLinkerWiki( $this->mRepo );
 147+
 148+ return Xml::openElement( 'div',
 149+ array(
 150+ 'class' => 'mw-codereview-comment',
 151+ 'id' => 'c' . intval( $comment->id ),
 152+ 'style' => $this->commentStyle( $comment ) ) ) .
 153+ '<div class="mw-codereview-comment-meta">' .
 154+ $this->mSkin->link( $this->commentLink( $comment->id ), "#" ) .
 155+ wfMsgHtml( 'code-rev-comment-by',
 156+ $this->mSkin->userLink( $comment->user, $comment->userText ) .
 157+ $this->mSkin->userToolLinks( $comment->user, $comment->userText ) ) .
 158+ ' &nbsp; ' .
 159+ $wgLang->timeanddate( $comment->timestamp ) .
 160+ ' ' .
 161+ $this->commentReplyLink( $comment->id ) .
 162+ '</div>' .
 163+ '<div class="mw-codereview-comment-text">' .
 164+ $wgOut->parse( $linker->link( $comment->text ) ) .
 165+ '</div>' .
 166+ $replyForm .
 167+ '</div>';
 168+ }
 169+
 170+ function commentStyle( $comment ) {
 171+ $depth = $comment->threadDepth();
 172+ $margin = ($depth - 1) * 48;
 173+ return "margin-left: ${margin}px";
 174+ }
 175+
 176+ function commentReplyLink( $id ) {
 177+ $repo = $this->mRepo->getName();
 178+ $rev = $this->mRev->getId();
 179+ $self = SpecialPage::getTitleFor( 'Code', "$repo/$rev/reply/$id" );
 180+ $self->setFragment( "#c$id" );
 181+ return '[' .
 182+ $this->mSkin->link( $self, wfMsg( 'codereview-reply-link' ) ) .
 183+ ']';
 184+ }
 185+
 186+ function postCommentForm( $parent=null ) {
 187+ global $wgUser;
 188+ return '<div class="mw-codereview-post-comment">' .
 189+ Xml::openElement( 'form',
 190+ array(
 191+ 'action' => '', // fixme
 192+ 'method' => 'post' ) ) .
 193+ Xml::hidden( 'wpEditToken', $wgUser->editToken() ) .
 194+ ($parent ? Xml::hidden( 'wpParent', $parent ) : '') .
 195+ '<div>' .
 196+ Xml::openElement( 'textarea', array(
 197+ 'name' => 'wpReply',
 198+ 'id' => "wpReplyTo{$parent}",
 199+ 'cols' => 40,
 200+ 'rows' => 5 ) ) .
 201+ '</textarea>' .
 202+ '</div>' .
 203+ '<div>' .
 204+ Xml::submitButton( wfMsg( 'code-rev-comment-submit' ), array( 'name' => 'wpSave' ) ) .
 205+ ' ' .
 206+ Xml::submitButton( wfMsg( 'code-rev-comment-preview' ), array( 'name' => 'wpPreview' ) ) .
 207+ '</div>' .
 208+ '</div>' .
 209+ '</form>';
 210+ }
 211+}
Property changes on: trunk/extensions/CodeReview/CodeRevisionView.php
___________________________________________________________________
Added: svn:eol-style
1212 + native
Index: trunk/extensions/CodeReview/CodeRepoListView.php
@@ -0,0 +1,21 @@
 2+<?php
 3+
 4+// Special:Code
 5+class CodeRepoListView {
 6+
 7+ function execute() {
 8+ global $wgOut;
 9+ $repos = CodeRepository::getRepoList();
 10+ if( !count( $repos ) ){
 11+ $wgOut->addWikiMsg( 'code-no-repo' );
 12+ return;
 13+ }
 14+ $text = '';
 15+ foreach( $repos as $repo ){
 16+ $name = $repo->getName();
 17+ $text .= "* [[Special:Code/$name|$name]]\n";
 18+ }
 19+ $wgOut->addWikiText( $text );
 20+ }
 21+}
 22+
Property changes on: trunk/extensions/CodeReview/CodeRepoListView.php
___________________________________________________________________
Added: svn:eol-style
123 + native

Status & tagging log