User:Jack Phoenix/patches/RecentChangesCombined

Index: SpecialRecentchanges_combined.i18n.php

=
====================================================== --- SpecialRecentchanges_combined.i18n.php	(revision 115) +++ SpecialRecentchanges_combined.i18n.php	(working copy) @@ -3,24 +3,25 @@ /** * I18n for the special page to show recent changes from one or more wiki * - * @package MediaWiki - * @subpackage SpecialPage + * @ingroup Extensions * @author Przemek Piotrowski  for Wikia, Inc. - * @copyright (C) 2007, Wikia Inc. + * @copyright © 2007, Wikia Inc. * @licence GNU General Public Licence 2.0 or later * @version: $Id$ */ -global $wgMessageCache; -foreach (array -( -	'en' => array -	( -		'recentchanges_combined' => 'Recent changes (combined)', -	), -) as $lang => $messages) -{ -	$wgMessageCache->addMessages($messages, $lang); -} +$messages = array; -?> +/** English + * @author Przemek Piotrowski + */ +$messages['en'] = array ( +	'recentchanges_combined' => 'Recent changes (combined)', +); + +/** Finnish + * @author Jack Phoenix + */ +$messages['fi'] = array ( +	'recentchanges_combined' => 'Tuoreet muutokset (yhdistetyt)', +); \ No newline at end of file Index: SpecialRecentchanges_combined.php

=
====================================================== --- SpecialRecentchanges_combined.php	(revision 115) +++ SpecialRecentchanges_combined.php	(working copy) @@ -3,20 +3,26 @@ /** * Special page to show recent changes from one or more wiki * - * @package MediaWiki - * @subpackage SpecialPage + * @ingroup Extensions * @author Przemek Piotrowski  for Wikia, Inc. - * @copyright (C) 2007, Wikia Inc. + * @copyright © 2007, Wikia Inc. * @licence GNU General Public Licence 2.0 or later * @version: $Id$ */ -if (!defined('MEDIAWIKI')) -{ -   echo "This is MediaWiki extension.\n"; +if (!defined('MEDIAWIKI')) { +   echo "This is a MediaWiki extension.\n"; exit(1); } -extAddSpecialPage(dirname(__FILE__) . '/SpecialRecentchanges_combined_body.php', 'Recentchanges_combined', 'SpecialRecentchanges_combined'); +$wgExtensionCredits['specialpage'][] = array( +	'name' => 'RecentChanges Combined', +	'version' => '1.0', +	'author' => 'Przemek Piotrowski', +	'description' => 'Special page to show recent changes from one or more wiki', +); -?> +$dir = dirname(__FILE__). '/'; +$wgExtensionMessagesFiles['Recentchanges_combined'] = $dir. 'SpecialRecentchanges_combined.i18n.php'; +$wgAutoloadClasses['SpecialRecentchanges_combined'] = $dir. 'SpecialRecentchanges_combined_body.php'; +$wgSpecialPages['Recentchanges_combined'] = 'SpecialRecentchanges_combined'; \ No newline at end of file Index: SpecialRecentchanges_combined_body.php

=
====================================================== --- SpecialRecentchanges_combined_body.php	(revision 115) +++ SpecialRecentchanges_combined_body.php	(working copy) @@ -3,25 +3,20 @@ /** * Body of the special page to show recent changes from one or more wiki * - * @package MediaWiki - * @subpackage SpecialPage + * @ingroup Extensions * @author Przemek Piotrowski  for Wikia, Inc. - * @copyright (C) 2007, Wikia Inc. + * @copyright © 2007, Wikia Inc. * @licence GNU General Public Licence 2.0 or later * @version: $Id$ */ -require_once dirname(__FILE__). '/SpecialRecentchanges_combined.i18n.php'; - -class SpecialRecentchanges_combined extends SpecialPage -{ -	public function __construct -	{ +class SpecialRecentchanges_combined extends SpecialPage { +	public function __construct { parent::__construct('Recentchanges_combined'); +		wfLoadExtensionMessages('Recentchanges_combined'); } -	public function execute($params) -	{ +	public function execute($params) { wfProfileIn(__METHOD__); $params = $this->getParams; @@ -32,8 +27,7 @@ 		return true; } -	protected function getParams -	{ +	protected function getParams { wfProfileIn(__METHOD__); global $wgRequest; @@ -41,20 +35,16 @@ 		$params = array; $param = $wgRequest->getText('limit'); -		if (!empty($param)) -		{ +		if (!empty($param)) { $params['limit'] = $param; -		} else -		{ +		} else { $params['limit'] = 10; } 		$param = $wgRequest->getText('wiki'); -		if (!empty($param)) -		{ +		if (!empty($param)) { $wiki2 = array; -			foreach (preg_split('/[\s,|]+/', $param) as $wiki) -			{ +			foreach (preg_split('/[\s,|]+/', $param) as $wiki) { $wiki = preg_replace('/^http:\/\//', '', $wiki); $wiki = preg_replace('/[^a-z0-9.-]+/', '', $wiki); @@ -63,62 +53,48 @@ 				$wiki = preg_replace('/^([a-z0-9-]{3,})$/',  '\1.wikia.com', $wiki);     // three+ alpha => wikia $wiki = preg_replace('/^([a-z0-9.-]+)\.w$/', '\1.wikia.com', $wiki);     // foo.w => wikia -				if (!empty($wiki)) -				{ +				if (!empty($wiki)) { $wiki2[] = $wiki; } 			} -			if (count($wiki2)) -			{ +			if (count($wiki2)) { $params['wiki'] = $wiki2; } 		} -		if (count($params['wiki'])) -		{ +		if (count($params['wiki'])) { $params['wiki'] = join('|', $params['wiki']); -		} else -		{ +		} else { $params['wiki'] = str_replace('http://', '', $GLOBALS['wgServer']); } 		$param = $wgRequest->getIntArray('namespace'); -		if (count($param)) -		{ +		if (count($param)) { $keys = array_keys($param, '-1'); -			if (count($keys)) -			{ -				foreach ($keys as $key) -				{ +			if (count($keys)) { +				foreach ($keys as $key) { unset($param[$key]); } 			} -			if (count($param)) -			{ +			if (count($param)) { $params['namespace'] = join('|', $param); } 		} 		$show = array; -		foreach (array('minor', 'bot', 'anon', 'loggedin') as $name) -		{ -			if ($wgRequest->getCheck($name)) -			{ +		foreach (array('minor', 'bot', 'anon', 'loggedin') as $name) { +			if ($wgRequest->getCheck($name)) { $show["!{$name}"] = true; } 		} -		if (count($show)) -		{ -			if (array_key_exists('!anon', $show) && array_key_exists('!loggedin', $show)) -			{ +		if (count($show)) { +			if (array_key_exists('!anon', $show) && array_key_exists('!loggedin', $show)) { unset($show['!anon']); unset($show['!loggedin']); $show['anon'] = true; -			} elseif (array_key_exists('!anon', $show)) -			{ +			} elseif (array_key_exists('!anon', $show)) { // $show['!anon'] = true; is already set -			} elseif (array_key_exists('!loggedin', $show)) -			{ +			} elseif (array_key_exists('!loggedin', $show)) { unset($show['!loggedin']); $show['anon'] = true; } @@ -127,8 +103,7 @@ 		} 		$param = $wgRequest->getInt('limit'); -		if (!empty($param)) -		{ +		if (!empty($param)) { $params['limit'] = $param; } 		//echo ' '; print_r($params); die; @@ -137,12 +112,10 @@ 		return $params; } -	protected function getData($params) -	{ +	protected function getData($params) { wfProfileIn(__METHOD__); -		$request = new FauxRequest(array -		( +		$request = new FauxRequest( array( 'action' => 'recentchangescombined', 'rcwiki' =>  $params['wiki'], 'rcnamespace' => $params['namespace'], @@ -161,8 +134,7 @@ 		return $data; } -	protected function setOutput($data, $params) -	{ +	protected function setOutput($data, $params) { wfProfileIn(__METHOD__); $this->setHeaders; @@ -172,14 +144,12 @@ 		$tmpl->set_vars(array('params' => $params, 'this_url' => $this->getTitle->getLocalUrl)); $output = $tmpl->execute('form'); -		$wgOut->addHtml($output); +		$wgOut->addHTML($output); $tmpl->set_vars(array('data' => $data)); $output = $tmpl->execute('list'); -		$wgOut->addHtml($output); +		$wgOut->addHTML($output); wfProfileOut(__METHOD__); } -} - -?> +} \ No newline at end of file