http://www.mediawiki.org/wiki/Special:Code/MediaWiki/96092
Revision: 96092
Author: reedy
Date: 2011-09-02 11:37:52 +0000 (Fri, 02 Sep 2011)
Log Message:
-----------
Whitespace, braces, unused variables and some documentation
Modified Paths:
--------------
trunk/extensions/CodeReview/backend/CodeRevision.php
trunk/extensions/GlobalUsage/ApiQueryGlobalUsage.php
trunk/extensions/GlobalUsage/GlobalUsage.php
trunk/extensions/GlobalUsage/GlobalUsageHooks.php
trunk/extensions/GlobalUsage/GlobalUsageQuery.php
trunk/extensions/GlobalUsage/SpecialGlobalUsage.php
Modified: trunk/extensions/CodeReview/backend/CodeRevision.php
===================================================================
--- trunk/extensions/CodeReview/backend/CodeRevision.php 2011-09-02
11:26:54 UTC (rev 96091)
+++ trunk/extensions/CodeReview/backend/CodeRevision.php 2011-09-02
11:37:52 UTC (rev 96092)
@@ -770,8 +770,11 @@
'cc_repo_id' => $this->repoId,
'cc_rev_id' => $this->id );
- if( $attached ) { $conditions['cc_patch_line!'] = null; }
- else { $conditions['cc_patch_line'] = null; }
+ if( $attached ) {
+ $conditions['cc_patch_line!'] = null;
+ } else {
+ $conditions['cc_patch_line'] = null;
+ }
$dbr = wfGetDB( DB_SLAVE );
$result = $dbr->select( 'code_comment',
Modified: trunk/extensions/GlobalUsage/ApiQueryGlobalUsage.php
===================================================================
--- trunk/extensions/GlobalUsage/ApiQueryGlobalUsage.php 2011-09-02
11:26:54 UTC (rev 96091)
+++ trunk/extensions/GlobalUsage/ApiQueryGlobalUsage.php 2011-09-02
11:37:52 UTC (rev 96092)
@@ -70,7 +70,7 @@
if ( isset( $prop['namespace']
) ) {
$result['ns'] =
$item['namespace_id'];
}
-
+
$fit = $apiResult->addValue(
array(
'query',
'pages', $pageId, 'globalusage'
), null, $result );
@@ -126,7 +126,7 @@
);
}
- public function getParamDescription () {
+ public function getParamDescription() {
return array(
'prop' => array(
'What properties to return',
@@ -143,7 +143,7 @@
public function getDescription() {
return 'Returns global image usage for a certain image';
}
-
+
public function getPossibleErrors() {
return array_merge( parent::getPossibleErrors(), array(
array ( 'code' => 'badcontinue', 'info' => 'Invalid
continue parameter' ),
Modified: trunk/extensions/GlobalUsage/GlobalUsage.php
===================================================================
--- trunk/extensions/GlobalUsage/GlobalUsage.php 2011-09-02 11:26:54 UTC
(rev 96091)
+++ trunk/extensions/GlobalUsage/GlobalUsage.php 2011-09-02 11:37:52 UTC
(rev 96092)
@@ -33,7 +33,6 @@
exit( 1 );
}
-
$dir = dirname( __FILE__ ) . '/';
$wgExtensionCredits['specialpage'][] = array(
Modified: trunk/extensions/GlobalUsage/GlobalUsageHooks.php
===================================================================
--- trunk/extensions/GlobalUsage/GlobalUsageHooks.php 2011-09-02 11:26:54 UTC
(rev 96091)
+++ trunk/extensions/GlobalUsage/GlobalUsageHooks.php 2011-09-02 11:37:52 UTC
(rev 96092)
@@ -43,6 +43,7 @@
return true;
}
+
/**
* Hook to TitleMoveComplete
* Sets the page title in usage table to the new name.
@@ -52,6 +53,7 @@
$gu->moveTo( $pageid, $nt );
return true;
}
+
/**
* Hook to ArticleDeleteComplete
* Deletes entries from usage table.
@@ -62,6 +64,7 @@
return true;
}
+
/**
* Hook to FileDeleteComplete
* Copies the local link table to the global.
@@ -83,6 +86,7 @@
$gu->deleteLinksToFile( $title );
return true;
}
+
/**
* Hook to UploadComplete
* Deletes the file from the global link table.
@@ -95,6 +99,8 @@
/**
* Initializes a GlobalUsage object for the current wiki.
+ *
+ * @return GlobalUsage
*/
private static function getGlobalUsage() {
global $wgGlobalUsageDatabase;
@@ -117,6 +123,8 @@
/**
* Hook to apply schema changes
+ *
+ * @param $updater DatabaseUpdater
*/
public static function onLoadExtensionSchemaUpdates( $updater = null ) {
$dir = dirname( __FILE__ );
Modified: trunk/extensions/GlobalUsage/GlobalUsageQuery.php
===================================================================
--- trunk/extensions/GlobalUsage/GlobalUsageQuery.php 2011-09-02 11:26:54 UTC
(rev 96091)
+++ trunk/extensions/GlobalUsage/GlobalUsageQuery.php 2011-09-02 11:37:52 UTC
(rev 96092)
@@ -1,7 +1,7 @@
<?php
/**
* A helper class to query the globalimagelinks table
- *
+ *
*/
class GlobalUsageQuery {
private $limit = 50;
@@ -27,7 +27,6 @@
$this->target = Title::makeTitleSafe( NS_FILE, $target
);
}
$this->offset = array();
-
}
/**
@@ -37,11 +36,13 @@
* @param $reversed bool True if this is the upper offset
*/
public function setOffset( $offset, $reversed = null ) {
- if ( !is_null( $reversed ) )
+ if ( !is_null( $reversed ) ) {
$this->reversed = $reversed;
-
- if ( !is_array( $offset ) )
+ }
+
+ if ( !is_array( $offset ) ) {
$offset = explode( '|', $offset );
+ }
if ( count( $offset ) == 3 ) {
$this->offset = $offset;
@@ -50,6 +51,7 @@
return false;
}
}
+
/**
* Return the offset set by the user
*
@@ -58,19 +60,21 @@
public function getOffsetString() {
return implode( '|', $this->offset );
}
+
/**
* Is the result reversed
- *
+ *
* @return bool
*/
public function isReversed() {
return $this->reversed;
}
+
/**
* Returns the string used for continuation
- *
+ *
* @return string
- *
+ *
*/
public function getContinueString() {
if ( $this->hasMore() )
@@ -101,14 +105,13 @@
$this->filterLocal = $value;
}
-
/**
* Executes the query
*/
public function execute() {
/* Construct the SQL query */
$tables = array( 'globalimagelinks' );
-
+
// Add target image(s)
if ( is_array( $this->target ) ) {
$namespace = NS_FILE;
@@ -122,21 +125,21 @@
case NS_CATEGORY:
$tables[] = 'categorylinks';
$tables[] = 'page';
- $where = array(
+ $where = array(
'cl_to' => $this->target->getDbKey(),
- 'cl_from = page_id',
- 'page_namespace = ' . NS_FILE,
+ 'cl_from = page_id',
+ 'page_namespace = ' . NS_FILE,
'gil_to = page_title',
);
break;
default:
return array();
}
-
-
- if ( $this->filterLocal )
+
+ if ( $this->filterLocal ) {
// Don't show local file usage
$where[] = 'gil_wiki != ' . $this->db->addQuotes(
wfWikiId() );
+ }
// Set the continuation condition
$order = 'ASC';
@@ -144,7 +147,7 @@
$qTo = $this->db->addQuotes( $this->offset[0] );
$qWiki = $this->db->addQuotes( $this->offset[1] );
$qPage = intval( $this->offset[2] );
-
+
// Check which limit we got in order to determine which
way to traverse rows
if ( $this->reversed ) {
// Reversed traversal; do not include offset row
@@ -157,7 +160,7 @@
$op2 = '>=';
$order = 'ASC';
}
-
+
$where[] = "(gil_to $op1 $qTo) OR " .
"(gil_to = $qTo AND gil_wiki $op1 $qWiki) OR " .
"(gil_to = $qTo AND gil_wiki = $qWiki AND
gil_page $op2 $qPage)";
@@ -186,11 +189,13 @@
// Always return the result in the same order; regardless
whether reversed was specified
// reversed is really only used to determine from which
direction the offset is
$rows = array();
- foreach ( $res as $row )
+ foreach ( $res as $row ) {
$rows[] = $row;
- if ( $this->reversed )
+ }
+ if ( $this->reversed ) {
$rows = array_reverse( $rows );
-
+ }
+
// Build the result array
$count = 0;
$this->hasMore = false;
@@ -204,10 +209,12 @@
break;
}
- if ( !isset( $this->result[$row->gil_to] ) )
+ if ( !isset( $this->result[$row->gil_to] ) ) {
$this->result[$row->gil_to] = array();
- if ( !isset(
$this->result[$row->gil_to][$row->gil_wiki] ) )
+ }
+ if ( !isset(
$this->result[$row->gil_to][$row->gil_wiki] ) ) {
$this->result[$row->gil_to][$row->gil_wiki] =
array();
+ }
$this->result[$row->gil_to][$row->gil_wiki][] = array(
'image' => $row->gil_to,
@@ -219,26 +226,28 @@
);
}
}
+
/**
* Returns the result set. The result is a 4 dimensional array
* (file, wiki, page), whose items are arrays with keys:
- * - image: File name
+ * - image: File name
* - id: Page id
* - namespace: Page namespace text
* - title: Unprefixed page title
* - wiki: Wiki id
- *
+ *
* @return array Result set
*/
public function getResult() {
return $this->result;
}
+
/**
* Returns a 3 dimensional array with the result of the first file.
Useful
* if only one image was queried.
- *
+ *
* For further information see documentation of getResult()
- *
+ *
* @return array Result set
*/
public function getSingleImageResult() {
@@ -259,7 +268,7 @@
/**
* Returns the result length
- *
+ *
* @return int
*/
public function count() {
Modified: trunk/extensions/GlobalUsage/SpecialGlobalUsage.php
===================================================================
--- trunk/extensions/GlobalUsage/SpecialGlobalUsage.php 2011-09-02 11:26:54 UTC
(rev 96091)
+++ trunk/extensions/GlobalUsage/SpecialGlobalUsage.php 2011-09-02 11:37:52 UTC
(rev 96092)
@@ -24,8 +24,7 @@
$this->showForm();
- if ( is_null( $this->target ) )
- {
+ if ( is_null( $this->target ) ) {
$wgOut->setPageTitle( wfMsg( 'globalusage' ) );
return;
}
@@ -34,7 +33,7 @@
$this->showResult();
}
-
+
/**
* Shows the search form
*/
@@ -58,12 +57,9 @@
// Filter local checkbox
. "\n\t<p>" . Xml::checkLabel( wfMsg(
'globalusage-filterlocal' ),
'filterlocal', 'mw-filterlocal',
$this->filterLocal ) . '</p>';
-
+
if ( !is_null( $this->target ) && wfFindFile( $this->target ) )
{
// Show the image if it exists
- global $wgUser;
- $skin = $wgUser->getSkin();
-
$html .= Linker::makeThumbLinkObj( $this->target,
wfFindFile( $this->target ),
/* $label */
$this->target->getPrefixedText(),
@@ -71,7 +67,7 @@
/* $handlerParams */ array(), /*
$framed */ false,
/* $manualThumb */ false );
}
-
+
// Wrap the entire form in a nice fieldset
$html .= Xml::fieldSet( wfMsg( 'globalusage-text' ),
$formContent ) . "\n</form>";
@@ -87,10 +83,11 @@
$query = new GlobalUsageQuery( $this->target );
// Extract params from $wgRequest
- if ( $wgRequest->getText( 'from' ) )
+ if ( $wgRequest->getText( 'from' ) ) {
$query->setOffset( $wgRequest->getText( 'from' ) );
- elseif ( $wgRequest->getText( 'to' ) )
+ } elseif ( $wgRequest->getText( 'to' ) ) {
$query->setOffset( $wgRequest->getText( 'to' ), true );
+ }
$query->setLimit( $wgRequest->getInt( 'limit', 50 ) );
$query->filterLocal( $this->filterLocal );
@@ -119,8 +116,9 @@
'globalusage-on-wiki',
'parseinline',
$targetName,
WikiMap::getWikiName( $wiki ) )
. "</h2><ul>\n" );
- foreach ( $result as $item )
+ foreach ( $result as $item ) {
$wgOut->addHtml( "\t<li>" . self::formatItem(
$item ) . "</li>\n" );
+ }
$wgOut->addHtml( "</ul>\n" );
}
$wgOut->addHtml( '</div>' );
@@ -128,14 +126,16 @@
// Bottom navbar
$wgOut->addHtml( $navbar );
}
+
/**
* Helper to format a specific item
*/
public static function formatItem( $item ) {
- if ( !$item['namespace'] )
+ if ( !$item['namespace'] ) {
$page = $item['title'];
- else
+ } else {
$page = "{$item['namespace']}:{$item['title']}";
+ }
$link = WikiMap::makeForeignLink( $item['wiki'], $page,
str_replace( '_', ' ', $page ) );
@@ -145,7 +145,7 @@
/**
* Helper function to create the navbar, stolen from wfViewPrevNext
- *
+ *
* @param $query GlobalUsageQuery An executed GlobalUsageQuery object
* @return string Navbar HTML
*/
@@ -157,7 +157,7 @@
$target = $this->target->getText();
$limit = $query->getLimit();
$fmtLimit = $wgLang->formatNum( $limit );
-
+
# Find out which strings are for the prev and which for the
next links
$offset = $query->getOffsetString();
$continue = $query->getContinueString();
@@ -205,7 +205,7 @@
$numLinks = array();
foreach ( array( 20, 50, 100, 250, 500 ) as $num ) {
$fmtLimit = $wgLang->formatNum( $num );
-
+
$q = array( 'offset' => $offset, 'limit' => $num,
'target' => $target );
if ( $this->filterLocal )
$q['filterlocal'] = '1';
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs