r83294 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83293‎ | r83294 | r83295 >
Date:16:05, 5 March 2011
Author:reedy
Status:resolved
Tags:
Comment:
* (bug 19007) Allow (delimited) list of paths in Special:Code filter
Modified paths:
  • /trunk/extensions/CodeReview/ui/CodeRevisionListView.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/ui/CodeRevisionListView.php
@@ -15,14 +15,26 @@
1616 parent::__construct( $repo );
1717 global $wgRequest;
1818
19 - $this->mPath = htmlspecialchars( trim( $wgRequest->getVal( 'path' ) ) );
20 - if ( strlen( $this->mPath ) && $this->mPath[0] !== '/' ) {
21 - $this->mPath = "/{$this->mPath}"; // make sure this is a valid path
22 - }
 19+ $this->mPath = array_map( array( $this, 'preparePaths' ), explode( '|', $wgRequest->getVal( 'path' ) ) );
 20+
2321 $this->mAuthor = $wgRequest->getText( 'author' );
2422 $this->mAppliedFilter = null;
2523 }
2624
 25+ /**
 26+ * @param string $path
 27+ * @return string
 28+ */
 29+ function preparePaths( $path ) {
 30+ $path = trim( $path );
 31+ $path = rtrim( $path, '/' );
 32+ $path = htmlspecialchars( $path );
 33+ if ( strlen( $path ) && $path[0] !== '/' ) {
 34+ $path = "/{$path}"; // make sure this is a valid path
 35+ }
 36+ return $path;
 37+ }
 38+
2739 function execute() {
2840 global $wgOut, $wgUser, $wgRequest, $wgLang;
2941 if ( !$this->mRepo ) {
@@ -166,7 +178,7 @@
167179 $ret = Xml::openElement( 'form', array( 'action' => $wgScript, 'method' => 'get' ) ) .
168180 "<fieldset><legend>" . wfMsgHtml( 'code-pathsearch-legend' ) . "</legend>" .
169181 '<table width="100%"><tr><td>' .
170 - Xml::inputlabel( wfMsg( "code-pathsearch-path" ), 'path', 'path', 55, $this->mPath ) .
 182+ Xml::inputlabel( wfMsg( "code-pathsearch-path" ), 'path', 'path', 55, implode( '|', $this->mPath ) ) .
171183 '&#160;' . Xml::submitButton( wfMsg( 'allpagessubmit' ) ) .
172184 '</td>';
173185
@@ -228,7 +240,7 @@
229241 }
230242
231243 function getDefaultSort() {
232 - return strlen( $this->mView->mPath ) ? 'cp_rev_id' : 'cr_id';
 244+ return count( $this->mView->mPath ) ? 'cp_rev_id' : 'cr_id';
233245 }
234246
235247 function getQueryInfo() {
@@ -309,7 +321,7 @@
310322
311323 function formatRevValue( $name, $value, $row ) {
312324 global $wgLang;
313 - $pathQuery = ( strlen( $this->mView->mPath ) ) ? array( 'path' => $this->mView->mPath ) : array();
 325+ $pathQuery = count( $this->mView->mPath ) ? array( 'path' => $this->mView->mPath ) : array();
314326
315327 switch( $name ) {
316328 case 'selectforchange':

Follow-up revisions

RevisionCommit summaryAuthorDate
r83322Default mPath to be an array if the gotten path is ''...reedy19:57, 5 March 2011
r83324Followup r83294, fixup another usage of a pathreedy20:09, 5 March 2011

Status & tagging log