r94658 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94657‎ | r94658 | r94659 >
Date:16:43, 16 August 2011
Author:siebrand
Status:ok
Tags:
Comment:
Stylize extension
Modified paths:
  • /trunk/extensions/Categorize/Categorize.api.php (modified) (history)
  • /trunk/extensions/Categorize/Categorize.body.php (modified) (history)
  • /trunk/extensions/Categorize/Categorize.css (modified) (history)
  • /trunk/extensions/Categorize/Categorize.hooks.php (modified) (history)
  • /trunk/extensions/Categorize/Categorize.js (modified) (history)
  • /trunk/extensions/Categorize/Categorize.php (modified) (history)
  • /trunk/extensions/Categorize/jquery.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Categorize/Categorize.php
@@ -6,10 +6,10 @@
77 * @licence GNU General Public Licence 3.0
88 * @description Adds input box to edit and upload page which allows users to assign categories to the article. When a user starts typing the name of a category, the extension queries the database to find categories that match the user input. Furthermore, a best categories labels cloud is displayed.
99 *
10 -*/
 10+ */
1111
1212 ## Abort if not used within Mediawiki
13 -if( !defined( 'MEDIAWIKI' ) ) {
 13+if ( !defined( 'MEDIAWIKI' ) ) {
1414 echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
1515 die();
1616 }
Index: trunk/extensions/Categorize/Categorize.css
@@ -31,7 +31,7 @@
3232 }
3333 span.xcategorize3 {
3434 background-color:#FBB6CA;
35 -
 35+
3636 }
3737 span.xcategorize4 {
3838 background-color:#FBDEB6;
@@ -73,7 +73,7 @@
7474
7575 /*Suggest search results DIV*/
7676 #searchResults {
77 - line-height: 1.6;
 77+ line-height: 1.6;
7878 overflow: auto;
7979 max-height: 170px;
8080 height: expression(
@@ -116,7 +116,7 @@
117117 color: #2d5381;
118118 }
119119
120 -
 120+
121121 /*Highlighted category in search results list*/
122122 span.highlight {
123123 /*background-color: rgb(231,71,71);*/
@@ -129,13 +129,13 @@
130130 margin: 0px;
131131 }
132132
133 -
 133+
134134 span.cs {
135135 /*color: rgb(231,71,71);*/
136136 color: #1C537A;
137137 background-color: white;
138138 cursor: pointer;
139 - line-Height: 1.6;
 139+ line-Height: 1.6;
140140 padding: 3px 4px;
141141 /* width: 278px; */
142142 margin: 0px;
@@ -146,7 +146,7 @@
147147 text-decoration: underline;
148148 font-weight: bold;
149149 }
150 -
 150+
151151 /*Highlighted category in search results list*/
152152 p.highlight {
153153 /*background-color: rgb(231,71,71);*/
@@ -159,7 +159,7 @@
160160 margin: 0px;
161161 }
162162
163 -
 163+
164164 p.cs {
165165 /*color: rgb(231,71,71);*/
166166 color: #1C537A;
Index: trunk/extensions/Categorize/Categorize.hooks.php
@@ -1,7 +1,7 @@
22 <?php
33 if ( !defined( 'MEDIAWIKI' ) )
44 die();
5 -
 5+
66 class CategorizeHooks {
77 /*************************************************************************************/
88 ## Entry point for the hook and main worker function for editing the page:
@@ -13,82 +13,82 @@
1414 # Get ALL categories from wiki:
1515 // $m_allCats = fnAjaxSuggestGetAllCategories();
1616 # Get the right member variables, depending on if we're on an upload form or not:
17 - if( !$m_isUpload ) {
 17+ if ( !$m_isUpload ) {
1818 # Check if page is subpage once to save method calls later:
1919 $m_isSubpage = $wgTitle->isSubpage();
2020
2121 # Check if page has been submitted already to Preview or Show Changes
22 - $strCatsFromPreview = trim($wgRequest->getVal('txtSelectedCategories2'));
23 - if(strlen($strCatsFromPreview)==0){
 22+ $strCatsFromPreview = trim( $wgRequest->getVal( 'txtSelectedCategories2' ) );
 23+ if ( strlen( $strCatsFromPreview ) == 0 ) {
2424 # Extract all categorylinks from PAGE:
2525 $m_pageCats = CategorizeBody::fnCategorizeGetPageCategories( $m_pageObj );
2626 } else {
2727 # Get cats from preview
28 - $m_pageCats = explode(";",$strCatsFromPreview);
 28+ $m_pageCats = explode( ";", $strCatsFromPreview );
2929 }
3030 # Never ever use editFormTextTop here as it resides outside the <form> so we will never get contents
3131 $m_place = 'editFormTextAfterWarn';
3232 # Print the localised title for the select box:
33 - $m_textBefore = '<b>'. wfMsg( 'categorize-title' ) . '</b>:';
 33+ $m_textBefore = '<b>' . wfMsg( 'categorize-title' ) . '</b>:';
3434 } else {
3535 # No need to get categories:
3636 $m_pageCats = array();
37 -
 37+
3838 # Place output at the right place:
3939 $m_place = 'uploadFormTextAfterSummary';
4040 }
41 -
42 - #ADD EXISTING CATEGORIES TO INPUT BOX
 41+
 42+ # ADD EXISTING CATEGORIES TO INPUT BOX
4343 $arrExistingCats = array();
44 - $arrExistingCats = array_unique($m_pageCats);
45 - #ADD JAVASCRIPT - use document.write so it is not presented if javascript is disabled.
 44+ $arrExistingCats = array_unique( $m_pageCats );
 45+ # ADD JAVASCRIPT - use document.write so it is not presented if javascript is disabled.
4646 $m_pageObj->$m_place .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"$wgScriptPath/extensions/Categorize/Categorize.css\" />
4747 \n"; # provisoire
4848 $m_pageObj->$m_place .= "<script type=\"text/javascript\" src=\"$wgScriptPath/extensions/Categorize/jquery.js\"></script>\n";
4949 $m_pageObj->$m_place .= "<script type=\"text/javascript\">var xSelectedLabels = new Array();</script>\n";
50 - foreach($arrExistingCats as $arrExistingCat)
 50+ foreach ( $arrExistingCats as $arrExistingCat )
5151 {
5252 $m_pageObj->$m_place .= "<script type=\"text/javascript\">xSelectedLabels['$arrExistingCat']=1;</script>\n";
5353 }
5454 $m_pageObj->$m_place .= "<script type=\"text/javascript\" src=\"" . $wgCategorizejs . "\"></script>\n";
55 - $m_pageObj->$m_place .= "<script type=\"text/javascript\">/*<![CDATA[*/\n";
56 - $m_pageObj->$m_place .= "document.write(\"<div id='categoryselectmaster2'><div style='border-bottom:1px solid #AAAAAA;'><b>" .wfMsg( 'categorize-title' ). "</b></div>\");\n";
57 - $m_pageObj->$m_place .= "document.write(\"<p>" . wfMsg( 'categorize-subtitle' ). "</p>\");\n";
 55+ $m_pageObj->$m_place .= "<script type=\"text/javascript\">/*<![CDATA[*/\n";
 56+ $m_pageObj->$m_place .= "document.write(\"<div id='categoryselectmaster2'><div style='border-bottom:1px solid #AAAAAA;'><b>" . wfMsg( 'categorize-title' ) . "</b></div>\");\n";
 57+ $m_pageObj->$m_place .= "document.write(\"<p>" . wfMsg( 'categorize-subtitle' ) . "</p>\");\n";
5858 $m_pageObj->$m_place .= "document.write(\"\");\n";
59 - $m_pageObj->$m_place .= "document.write(\"<input onkeyup='sendRequest(this,event);' autocomplete='off' type='text' name='txtSelectedCategories2' id='txtSelectedCategories2' maxlength='200' length='150' style='width:100%;' value='".str_replace("_"," ",implode(";", $arrExistingCats))."'/>\");\n";
 59+ $m_pageObj->$m_place .= "document.write(\"<input onkeyup='sendRequest(this,event);' autocomplete='off' type='text' name='txtSelectedCategories2' id='txtSelectedCategories2' maxlength='200' length='150' style='width:100%;' value='" . str_replace( "_", " ", implode( ";", $arrExistingCats ) ) . "'/>\");\n";
6060 $m_pageObj->$m_place .= "document.write(\"<br/><div id='searchResults'></div>\");\n";
61 - $m_pageObj->$m_place .= "document.write(\"<input type='hidden' value='" . $wgCategorySuggestCloud . "' id='txtCSDisplayType'/>\");\n";
62 - $m_pageObj->$m_place .= "document.write(\"<p>" . wfMsg( 'categorize-advice' ). "</p>\");\n";
 61+ $m_pageObj->$m_place .= "document.write(\"<input type='hidden' value='" . $wgCategorySuggestCloud . "' id='txtCSDisplayType'/>\");\n";
 62+ $m_pageObj->$m_place .= "document.write(\"<p>" . wfMsg( 'categorize-advice' ) . "</p>\");\n";
6363 $m_pageObj->$m_place .= "document.write(\"<p><table id='xtable'>\");\n";
6464 $l__categorize_index = 0;
65 - foreach($wgCategorizeLabels as $l__label_key=>$l__label_array)
 65+ foreach ( $wgCategorizeLabels as $l__label_key => $l__label_array )
6666 {
6767 $m_pageObj->$m_place .= "document.write(\"<tr>\");\n";
68 - if (substr($l__label_key,0,9)=='separator')
 68+ if ( substr( $l__label_key, 0, 9 ) == 'separator' )
6969 {
7070 $m_pageObj->$m_place .= "document.write(\"<td colspan=2> <hr/>\");\n";
7171 }
7272 else
7373 {
7474 $l__categorize_index += 1;
75 - $l__key_value_to_print = utf8_encode(str_replace("_","&nbsp;",$l__label_key));
76 - $l__xselected = (in_array($l__key_value_to_print,$arrExistingCats)) ? 'xselected' : '';
 75+ $l__key_value_to_print = utf8_encode( str_replace( "_", "&nbsp;", $l__label_key ) );
 76+ $l__xselected = ( in_array( $l__key_value_to_print, $arrExistingCats ) ) ? 'xselected' : '';
7777 $m_pageObj->$m_place .= "document.write(\"<th style='text-align:left;'><span class='xlabel xmaster xcategorize$l__categorize_index $l__xselected'>$l__key_value_to_print</span></th><td> \");\n";
78 - foreach($l__label_array as $l__label_value)
 78+ foreach ( $l__label_array as $l__label_value )
7979 {
80 - $l__label_value_to_print = utf8_encode(str_replace("_"," ",$l__label_value));
81 - $l__xselected = (in_array($l__label_value_to_print,$arrExistingCats)) ? 'xselected' : '';
 80+ $l__label_value_to_print = utf8_encode( str_replace( "_", " ", $l__label_value ) );
 81+ $l__xselected = ( in_array( $l__label_value_to_print, $arrExistingCats ) ) ? 'xselected' : '';
8282 $m_pageObj->$m_place .= "document.write(\"<span class='xlabel xcategorize$l__categorize_index $l__xselected'>$l__label_value_to_print</span>\");\n";
8383 }
8484 $m_pageObj->$m_place .= "document.write(\"</td></tr>\");\n";
8585 }
8686 }
8787 $m_pageObj->$m_place .= "document.write(\"</table></p>\");\n";
88 - $m_pageObj->$m_place .= "document.write(\"<p>" . wfMsg( 'categorize-footer' ). "</p>\");\n";
 88+ $m_pageObj->$m_place .= "document.write(\"<p>" . wfMsg( 'categorize-footer' ) . "</p>\");\n";
8989 $m_pageObj->$m_place .= "document.write(\"</div>\");\n";
9090 $m_pageObj->$m_place .= "/*]]>*/</script>\n";
91 -
92 -
 91+
 92+
9393 return true;
9494 }
9595
@@ -97,33 +97,33 @@
9898 public static function fnCategorizeSaveHook( $m_isUpload, $m_pageObj ) {
9999 global $wgContLang;
100100 global $wgOut;
101 -
 101+
102102 # Get localised namespace string:
103103 $m_catString = $wgContLang->getNsText( NS_CATEGORY );
104104 # Get some distance from the rest of the content:
105105 $m_text = "\n";
106 -
 106+
107107 # Assign all selected category entries:
108108 $strSelectedCats = $_POST['txtSelectedCategories2'];
109109
110 - #CHECK IF USER HAS SELECTED ANY CATEGORIES
111 - if(strlen($strSelectedCats)>1){
 110+ # CHECK IF USER HAS SELECTED ANY CATEGORIES
 111+ if ( strlen( $strSelectedCats ) > 1 ) {
112112 $arrSelectedCats = array();
113 - $arrSelectedCats = array_unique(explode(";",$_POST['txtSelectedCategories2']));
114 - foreach( $arrSelectedCats as $m_cat ) {
115 - if(strlen($m_cat)>0){
116 - $m_text .= "\n[[$m_catString:" . mysql_escape_string(trim($m_cat)) . "]]";
 113+ $arrSelectedCats = array_unique( explode( ";", $_POST['txtSelectedCategories2'] ) );
 114+ foreach ( $arrSelectedCats as $m_cat ) {
 115+ if ( strlen( $m_cat ) > 0 ) {
 116+ $m_text .= "\n[[$m_catString:" . mysql_escape_string( trim( $m_cat ) ) . "]]";
117117 }
118118 }
119119 # If it is an upload we have to call a different method:
120120 if ( $m_isUpload ) {
121121 $m_pageObj->mUploadDescription .= $m_text;
122 - } else{
 122+ } else {
123123 $m_pageObj->textbox1 .= $m_text;
124 - }
 124+ }
125125 }
126 - $wgOut->addHTML($m_text);
127 -
 126+ $wgOut->addHTML( $m_text );
 127+
128128 # Return to the let MediaWiki do the rest of the work:
129129 return true;
130130 }
Index: trunk/extensions/Categorize/Categorize.js
@@ -30,15 +30,15 @@
3131 var csQuery = '';
3232 addEvent(document, "mouseup",keyPressHandler);
3333
34 -function sendRequest(q,e) {
 34+function sendRequest(q,e) {
3535 if ([e.keyCode||e.which] == 27 ) {
3636 var resultDiv = document.getElementById('searchResults');
3737 resultDiv.style.visibility = 'hidden';
38 - e.preventDefault? e.preventDefault() : e.returnValue = false;
 38+ e.preventDefault? e.preventDefault() : e.returnValue = false;
3939 }
4040
4141 // remove characters that don't work in category names
42 - strQuery = new String(q.value);
 42+ strQuery = new String(q.value);
4343
4444 //CUT OFF EXISTING, COMPLETE CATEGORIES
4545 if(strQuery.lastIndexOf(';')!=-1){
@@ -51,8 +51,8 @@
5252 strQuery = strQueryR;
5353 q.value = strQueryR;
5454 }
55 -
5655
 56+
5757 if ( strQuery.toString() != csQuery.toString() ) {
5858 strQuery = strQuery.replace(/ /g,"_");
5959 csQuery = strQuery;
@@ -75,7 +75,7 @@
7676 }
7777 result.name = item.replace(/_/g," ");
7878 csWord = result.name;
79 -
 79+
8080 csHTML = '<span class="csSelect">' + csWord.substr(0, csQuery.length) + '</span>' + csWord.substr(csQuery.length) + " ";
8181 result.innerHTML = csHTML;
8282 result.onmouseover = highlight;
@@ -84,17 +84,17 @@
8585 result.title = 'Click here to add category to the category list!';
8686 result.className="cs";
8787 resultDiv.style.lineHeight='1';
88 - resultDiv.appendChild(result);
 88+ resultDiv.appendChild(result);
8989 });
9090 }
91 -
92 -
 91+
 92+
9393 });
94 -
95 -
 94+
 95+
9696 }
9797 }
98 -// WAIT FOR SERVER RESPONSE AND DISPLAY SUGGESTIONS
 98+// WAIT FOR SERVER RESPONSE AND DISPLAY SUGGESTIONS
9999 ajaxResponse = function handleResponse(response) {
100100 resultSet = response.responseText;
101101 var resultDiv = document.getElementById('searchResults');
@@ -117,7 +117,7 @@
118118 }
119119 result.name = resultSet[f].replace(/_/g," ");
120120 csWord = result.name;
121 -
 121+
122122 csHTML = '<span class="csSelect">' + csWord.substr(0, csQuery.length) + '</span>' + csWord.substr(csQuery.length) + " ";
123123 result.innerHTML = csHTML;
124124 result.onmouseover = highlight;
@@ -126,12 +126,12 @@
127127 result.title = 'Click here to add category to the category list!';
128128 result.className="cs";
129129 resultDiv.style.lineHeight='1';
130 - resultDiv.appendChild(result);
 130+ resultDiv.appendChild(result);
131131 }
132 - }
 132+ }
133133 }
134134
135 -
 135+
136136 // SELECT CATEGORY FROM SUGGEST DIV AND ADD IT TO THE INPUT BOX
137137 function selectEntry () {
138138 var strExistingValues = document.getElementById('txtSelectedCategories2').value;
@@ -140,7 +140,7 @@
141141 strExistingValues = strExistingValues.substr(0, intIndex+1);
142142 document.getElementById('txtSelectedCategories2').value = strExistingValues + this.name;
143143 } else {
144 - document.getElementById('txtSelectedCategories2').value = this.name;
 144+ document.getElementById('txtSelectedCategories2').value = this.name;
145145 }
146146 document.getElementById('searchResults').style.visibility='hidden';
147147 document.getElementById('searchResults').innerHTML='';
@@ -150,7 +150,7 @@
151151 function highlight (){
152152 this.className='highlight';
153153 }
154 -
 154+
155155 function unHighlight (){
156156 this.className='cs';
157157 }
@@ -186,10 +186,10 @@
187187 function keyPressHandler(e) {
188188 var resultDiv = document.getElementById('searchResults');
189189 resultDiv.style.visibility = 'hidden';
190 - e.preventDefault? e.preventDefault() : e.returnValue = false;
 190+ e.preventDefault? e.preventDefault() : e.returnValue = false;
191191 //}
192192 }
193 -
 193+
194194 $(document).ready(function() {
195195 $('.xlabel').click(function(){
196196 var xvalue = $(this).text();
Index: trunk/extensions/Categorize/Categorize.api.php
@@ -35,21 +35,21 @@
3636 $params = $this->extractRequestParams();
3737 $strquery = $params['strquery'];
3838 $result = $this->getResult();
39 -
40 - if(isset($strquery) && $strquery != NULL) {
 39+
 40+ if ( isset( $strquery ) && $strquery != NULL ) {
4141 $searchString = str_replace( '%' , '\%' , $strquery );
4242 $searchString = str_replace( '_' , '\_' , $searchString );
4343 $searchString = str_replace( '|' , '%' , $searchString );
44 - $dbr = $this->getDB();;
45 -
 44+ $dbr = $this->getDB(); ;
 45+
4646 $suggestStrings = array();
47 -
 47+
4848 $this->addTables( 'categorylinks' );
4949 $this->addFields( 'DISTINCT cl_to' );
50 - $this->addWhere ( " UPPER(CONVERT(cl_to using latin1)) LIKE UPPER(CONVERT('$searchString%' using latin1)) ");
 50+ $this->addWhere ( " UPPER(CONVERT(cl_to using latin1)) LIKE UPPER(CONVERT('$searchString%' using latin1)) " );
5151 $res = $this->select( __METHOD__ );
5252 while ( $row = $res->fetchObject() ) {
53 - array_push($suggestStrings,$row->cl_to);
 53+ array_push( $suggestStrings, $row->cl_to );
5454 $fit = $result->addValue( array( 'query', $this->getModuleName() ), null, $row->cl_to );
5555 if ( !$fit ) {
5656 $this->setContinueEnumParameter( 'start', wfTimestamp( TS_ISO_8601, $row->afl_timestamp ) );
@@ -78,7 +78,7 @@
7979 public function getDescription() {
8080 return 'Show categories beginning by "strquery" string.';
8181 }
82 -
 82+
8383 public function getPossibleErrors() {
8484 return array_merge( parent::getPossibleErrors(), array(
8585 // to fill
Index: trunk/extensions/Categorize/jquery.js
@@ -11,7 +11,7 @@
1212 */
1313 (function(){
1414
15 -var
 15+var
1616 // Will speed up references to window, and allows munging its name.
1717 window = this,
1818 // Will speed up references to undefined, and allows munging its name.
@@ -399,13 +399,13 @@
400400 },
401401
402402 val: function( value ) {
403 - if ( value === undefined ) {
 403+ if ( value === undefined ) {
404404 var elem = this[0];
405405
406406 if ( elem ) {
407407 if( jQuery.nodeName( elem, 'option' ) )
408408 return (elem.attributes.value || {}).specified ? elem.value : elem.text;
409 -
 409+
410410 // We need to handle select boxes special
411411 if ( jQuery.nodeName( elem, "select" ) ) {
412412 var index = elem.selectedIndex,
@@ -434,7 +434,7 @@
435435 }
436436 }
437437
438 - return values;
 438+ return values;
439439 }
440440
441441 // Everything else, we just grab the value
@@ -513,13 +513,13 @@
514514 if ( first )
515515 for ( var i = 0, l = this.length; i < l; i++ )
516516 callback.call( root(this[i], first), i > 0 ? extra.cloneNode(true) : fragment );
517 -
 517+
518518 if ( scripts )
519519 jQuery.each( scripts, evalScript );
520520 }
521521
522522 return this;
523 -
 523+
524524 function root( elem, cur ) {
525525 return table && jQuery.nodeName(elem, "table") && jQuery.nodeName(cur, "tr") ?
526526 (elem.getElementsByTagName("tbody")[0] ||
@@ -586,7 +586,7 @@
587587
588588 // Recurse if we're merging object values
589589 if ( deep && copy && typeof copy === "object" && !copy.nodeType )
590 - target[ name ] = jQuery.extend( deep,
 590+ target[ name ] = jQuery.extend( deep,
591591 // Never move original objects, clone them
592592 src || ( copy.length != null ? [ ] : { } )
593593 , copy );
@@ -923,7 +923,7 @@
924924 // IE completely kills leading whitespace when innerHTML is used
925925 if ( !jQuery.support.leadingWhitespace && /^\s/.test( elem ) )
926926 div.insertBefore( context.createTextNode( elem.match(/^\s*/)[0] ), div.firstChild );
927 -
 927+
928928 elem = jQuery.makeArray( div.childNodes );
929929 }
930930
@@ -944,7 +944,7 @@
945945 fragment.appendChild( ret[i] );
946946 }
947947 }
948 -
 948+
949949 return scripts;
950950 }
951951
@@ -1322,16 +1322,16 @@
13231323 },
13241324 queue: function( elem, type, data ) {
13251325 if ( elem ){
1326 -
 1326+
13271327 type = (type || "fx") + "queue";
1328 -
 1328+
13291329 var q = jQuery.data( elem, type );
1330 -
 1330+
13311331 if ( !q || jQuery.isArray(data) )
13321332 q = jQuery.data( elem, type, jQuery.makeArray(data) );
13331333 else if( data )
13341334 q.push( data );
1335 -
 1335+
13361336 }
13371337 return q;
13381338 },
@@ -1339,10 +1339,10 @@
13401340 dequeue: function( elem, type ){
13411341 var queue = jQuery.queue( elem, type ),
13421342 fn = queue.shift();
1343 -
 1343+
13441344 if( !type || type === "fx" )
13451345 fn = queue[0];
1346 -
 1346+
13471347 if( fn !== undefined )
13481348 fn.call(elem);
13491349 }
@@ -1384,7 +1384,7 @@
13851385
13861386 return this.each(function(){
13871387 var queue = jQuery.queue( this, type, data );
1388 -
 1388+
13891389 if( type == "fx" && queue.length == 1 )
13901390 queue[0].call(this);
13911391 });
@@ -1412,19 +1412,19 @@
14131413
14141414 if ( context.nodeType !== 1 && context.nodeType !== 9 )
14151415 return [];
1416 -
 1416+
14171417 if ( !selector || typeof selector !== "string" ) {
14181418 return results;
14191419 }
14201420
14211421 var parts = [], m, set, checkSet, check, mode, extra, prune = true;
1422 -
 1422+
14231423 // Reset the position of the chunker regexp (start from head)
14241424 chunker.lastIndex = 0;
1425 -
 1425+
14261426 while ( (m = chunker.exec(selector)) !== null ) {
14271427 parts.push( m[1] );
1428 -
 1428+
14291429 if ( m[2] ) {
14301430 extra = RegExp.rightContext;
14311431 break;
@@ -1525,7 +1525,7 @@
15261526
15271527 for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
15281528 var type = Expr.order[i], match;
1529 -
 1529+
15301530 if ( (match = Expr.match[ type ].exec( expr )) ) {
15311531 var left = RegExp.leftContext;
15321532
@@ -1770,7 +1770,7 @@
17711771 },
17721772 ATTR: function(match){
17731773 var name = match[1].replace(/\\/g, "");
1774 -
 1774+
17751775 if ( Expr.attrMap[name] ) {
17761776 match[1] = Expr.attrMap[name];
17771777 }
@@ -1796,7 +1796,7 @@
17971797 } else if ( Expr.match.POS.test( match[0] ) ) {
17981798 return true;
17991799 }
1800 -
 1800+
18011801 return match;
18021802 },
18031803 POS: function(match){
@@ -1894,7 +1894,7 @@
18951895 var type = match[1], parent = elem.parentNode;
18961896
18971897 var doneName = match[0];
1898 -
 1898+
18991899 if ( parent && (!parent[ doneName ] || !elem.nodeIndex) ) {
19001900 var count = 1;
19011901
@@ -2004,7 +2004,7 @@
20052005 results.push.apply( results, array );
20062006 return results;
20072007 }
2008 -
 2008+
20092009 return array;
20102010 };
20112011
@@ -2115,7 +2115,7 @@
21162116 if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
21172117 return;
21182118 }
2119 -
 2119+
21202120 Sizzle = function(query, context, extra, seed){
21212121 context = context || document;
21222122
@@ -2126,7 +2126,7 @@
21272127 return makeArray( context.querySelectorAll(query), extra );
21282128 } catch(e){}
21292129 }
2130 -
 2130+
21312131 return oldSizzle(query, context, extra, seed);
21322132 };
21332133
@@ -2368,7 +2368,7 @@
23692369
23702370 // Get the current list of functions bound to this event
23712371 var handlers = events[type];
2372 -
 2372+
23732373 if ( jQuery.event.specialAll[type] )
23742374 jQuery.event.specialAll[type].setup.call(elem, data, namespaces);
23752375
@@ -2441,7 +2441,7 @@
24422442 // Handle the removal of namespaced events
24432443 if ( namespace.test(events[type][handle].type) )
24442444 delete events[type][handle];
2445 -
 2445+
24462446 if ( jQuery.event.specialAll[type] )
24472447 jQuery.event.specialAll[type].teardown.call(elem, namespaces);
24482448
@@ -2508,11 +2508,11 @@
25092509 // don't do events on text and comment nodes
25102510 if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 )
25112511 return undefined;
2512 -
 2512+
25132513 // Clean up in case it is reused
25142514 event.result = undefined;
25152515 event.target = elem;
2516 -
 2516+
25172517 // Clone the incoming data, if any
25182518 data = jQuery.makeArray(data);
25192519 data.unshift( event );
@@ -2559,7 +2559,7 @@
25602560
25612561 // Cache this now, all = true means, any handler
25622562 all = !namespaces.length && !event.exclusive;
2563 -
 2563+
25642564 var namespace = RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
25652565
25662566 handlers = ( jQuery.data(this, "events") || {} )[event.type];
@@ -2657,7 +2657,7 @@
26582658 teardown: function() {}
26592659 }
26602660 },
2661 -
 2661+
26622662 specialAll: {
26632663 live: {
26642664 setup: function( selector, namespaces ){
@@ -2666,12 +2666,12 @@
26672667 teardown: function( namespaces ){
26682668 if ( namespaces.length ) {
26692669 var remove = 0, name = RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
2670 -
 2670+
26712671 jQuery.each( (jQuery.data(this, "events").live || {}), function(){
26722672 if ( name.test(this.type) )
26732673 remove++;
26742674 });
2675 -
 2675+
26762676 if ( remove < 1 )
26772677 jQuery.event.remove( this, namespaces[0], liveHandler );
26782678 }
@@ -2684,7 +2684,7 @@
26852685 // Allow instantiation without the 'new' keyword
26862686 if( !this.preventDefault )
26872687 return new jQuery.Event(src);
2688 -
 2688+
26892689 // Event object
26902690 if( src && src.type ){
26912691 this.originalEvent = src;
@@ -2696,7 +2696,7 @@
26972697 // timeStamp is buggy for some events on Firefox(#3843)
26982698 // So we won't rely on the native value
26992699 this.timeStamp = now();
2700 -
 2700+
27012701 // Mark it as fixed
27022702 this[expando] = true;
27032703 };
@@ -2752,7 +2752,7 @@
27532753 while ( parent && parent != this )
27542754 try { parent = parent.parentNode; }
27552755 catch(e) { parent = this; }
2756 -
 2756+
27572757 if( parent != this ){
27582758 // set the correct event type
27592759 event.type = event.data;
@@ -2760,9 +2760,9 @@
27612761 jQuery.event.handle.apply( this, arguments );
27622762 }
27632763 };
2764 -
2765 -jQuery.each({
2766 - mouseover: 'mouseenter',
 2764+
 2765+jQuery.each({
 2766+ mouseover: 'mouseenter',
27672767 mouseout: 'mouseleave'
27682768 }, function( orig, fix ){
27692769 jQuery.event.special[ fix ] = {
@@ -2772,7 +2772,7 @@
27732773 teardown: function(){
27742774 jQuery.event.remove( this, orig, withinElement );
27752775 }
2776 - };
 2776+ };
27772777 });
27782778
27792779 jQuery.fn.extend({
@@ -2811,7 +2811,7 @@
28122812 event.stopPropagation();
28132813 jQuery.event.trigger( event, data, this[0] );
28142814 return event.result;
2815 - }
 2815+ }
28162816 },
28172817
28182818 toggle: function( fn ) {
@@ -2854,7 +2854,7 @@
28552855
28562856 return this;
28572857 },
2858 -
 2858+
28592859 live: function( type, fn ){
28602860 var proxy = jQuery.event.proxy( fn );
28612861 proxy.guid += this.selector + type;
@@ -2863,7 +2863,7 @@
28642864
28652865 return this;
28662866 },
2867 -
 2867+
28682868 die: function( type, fn ){
28692869 jQuery(document).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null );
28702870 return this;
@@ -2983,12 +2983,12 @@
29842984 // Prevent memory leaks in IE
29852985 // And prevent errors on refresh with events like mouseover in other browsers
29862986 // Window isn't included so as not to unbind existing unload events
2987 -jQuery( window ).bind( 'unload', function(){
 2987+jQuery( window ).bind( 'unload', function(){
29882988 for ( var id in jQuery.cache )
29892989 // Skip the window
29902990 if ( id != 1 && jQuery.cache[ id ].handle )
29912991 jQuery.event.remove( jQuery.cache[ id ].handle.elem );
2992 -});
 2992+});
29932993 (function(){
29942994
29952995 jQuery.support = {};
@@ -3012,32 +3012,32 @@
30133013 jQuery.support = {
30143014 // IE strips leading whitespace when .innerHTML is used
30153015 leadingWhitespace: div.firstChild.nodeType == 3,
3016 -
 3016+
30173017 // Make sure that tbody elements aren't automatically inserted
30183018 // IE will insert them into empty tables
30193019 tbody: !div.getElementsByTagName("tbody").length,
3020 -
 3020+
30213021 // Make sure that you can get all elements in an <object> element
30223022 // IE 7 always returns no results
30233023 objectAll: !!div.getElementsByTagName("object")[0]
30243024 .getElementsByTagName("*").length,
3025 -
 3025+
30263026 // Make sure that link elements get serialized correctly by innerHTML
30273027 // This requires a wrapper element in IE
30283028 htmlSerialize: !!div.getElementsByTagName("link").length,
3029 -
 3029+
30303030 // Get the style information from getAttribute
30313031 // (IE uses .cssText insted)
30323032 style: /red/.test( a.getAttribute("style") ),
3033 -
 3033+
30343034 // Make sure that URLs aren't manipulated
30353035 // (IE normalizes it by default)
30363036 hrefNormalized: a.getAttribute("href") === "/a",
3037 -
 3037+
30383038 // Make sure that element opacity exists
30393039 // (IE uses filter instead)
30403040 opacity: a.style.opacity === "0.5",
3041 -
 3041+
30423042 // Verify style float existence
30433043 // (IE uses styleFloat instead of cssFloat)
30443044 cssFloat: !!a.style.cssFloat,
@@ -3047,14 +3047,14 @@
30483048 noCloneEvent: true,
30493049 boxModel: null
30503050 };
3051 -
 3051+
30523052 script.type = "text/javascript";
30533053 try {
30543054 script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
30553055 } catch(e){}
30563056
30573057 root.insertBefore( script, root.firstChild );
3058 -
 3058+
30593059 // Make sure that the execution of code works by injecting a script
30603060 // tag with appendChild/createTextNode
30613061 // (IE doesn't support this, fails, and uses .text instead)
@@ -3199,7 +3199,7 @@
32003200 var jsc = now();
32013201
32023202 jQuery.extend({
3203 -
 3203+
32043204 get: function( url, data, callback, type ) {
32053205 // shift arguments if data argument was ommited
32063206 if ( jQuery.isFunction( data ) ) {
@@ -3585,7 +3585,7 @@
35863586
35873587 if ( xml && data.documentElement.tagName == "parsererror" )
35883588 throw "parsererror";
3589 -
 3589+
35903590 // Allow a pre-filtering function to sanitize the response
35913591 // s != null is checked to keep backwards compatibility
35923592 if( s && s.dataFilter )
@@ -3602,7 +3602,7 @@
36033603 if ( type == "json" )
36043604 data = window["eval"]("(" + data + ")");
36053605 }
3606 -
 3606+
36073607 return data;
36083608 },
36093609
@@ -3666,30 +3666,30 @@
36673667 } else {
36683668 for ( var i = 0, l = this.length; i < l; i++ ){
36693669 var old = jQuery.data(this[i], "olddisplay");
3670 -
 3670+
36713671 this[i].style.display = old || "";
3672 -
 3672+
36733673 if ( jQuery.css(this[i], "display") === "none" ) {
36743674 var tagName = this[i].tagName, display;
3675 -
 3675+
36763676 if ( elemdisplay[ tagName ] ) {
36773677 display = elemdisplay[ tagName ];
36783678 } else {
36793679 var elem = jQuery("<" + tagName + " />").appendTo("body");
3680 -
 3680+
36813681 display = elem.css("display");
36823682 if ( display === "none" )
36833683 display = "block";
3684 -
 3684+
36853685 elem.remove();
3686 -
 3686+
36873687 elemdisplay[ tagName ] = display;
36883688 }
3689 -
 3689+
36903690 this[i].style.display = jQuery.data(this[i], "olddisplay", display);
36913691 }
36923692 }
3693 -
 3693+
36943694 return this;
36953695 }
36963696 },
@@ -3732,11 +3732,11 @@
37333733 var optall = jQuery.speed(speed, easing, callback);
37343734
37353735 return this[ optall.queue === false ? "each" : "queue" ](function(){
3736 -
 3736+
37373737 var opt = jQuery.extend({}, optall), p,
37383738 hidden = this.nodeType == 1 && jQuery(this).is(":hidden"),
37393739 self = this;
3740 -
 3740+
37413741 for ( p in prop ) {
37423742 if ( prop[p] == "hide" && hidden || prop[p] == "show" && !hidden )
37433743 return opt.complete.call(this);
@@ -3990,7 +3990,7 @@
39913991 if ( this.options.hide || this.options.show )
39923992 for ( var p in this.options.curAnim )
39933993 jQuery.attr(this.elem.style, p, this.options.orig[p]);
3994 -
 3994+
39953995 // Execute the complete function
39963996 this.options.complete.call( this.elem );
39973997 }
@@ -4044,7 +4044,7 @@
40454045 left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
40464046 return { top: top, left: left };
40474047 };
4048 -else
 4048+else
40494049 jQuery.fn.offset = function() {
40504050 if ( !this[0] ) return { top: 0, left: 0 };
40514051 if ( this[0] === this[0].ownerDocument.body ) return jQuery.offset.bodyOffset( this[0] );
@@ -4134,7 +4134,7 @@
41354135 parentOffset = /^body|html$/i.test(offsetParent[0].tagName) ? { top: 0, left: 0 } : offsetParent.offset();
41364136
41374137 // Subtract element margins
4138 - // note: when an element has margin: auto the offsetLeft and marginLeft
 4138+ // note: when an element has margin: auto the offsetLeft and marginLeft
41394139 // are the same in Safari causing offset.left to incorrectly be 0
41404140 offset.top -= num( this, 'marginTop' );
41414141 offset.left -= num( this, 'marginLeft' );
@@ -4165,7 +4165,7 @@
41664166 // Create scrollLeft and scrollTop methods
41674167 jQuery.each( ['Left', 'Top'], function(i, name) {
41684168 var method = 'scroll' + name;
4169 -
 4169+
41704170 jQuery.fn[ method ] = function(val) {
41714171 if (!this[0]) return null;
41724172
@@ -4210,7 +4210,7 @@
42114211 (margin ?
42124212 num(this, "margin" + tl) + num(this, "margin" + br) : 0);
42134213 };
4214 -
 4214+
42154215 var type = name.toLowerCase();
42164216
42174217 jQuery.fn[ type ] = function( size ) {
Index: trunk/extensions/Categorize/Categorize.body.php
@@ -2,13 +2,13 @@
33 /* Categorize Mediawiki Extension
44 *
55 * @author Andreas Rindler (mediawiki at jenandi dot com) for initial Extension:CategorySuggest and Thomas Fauré (faure dot thomas at gmail dot com) for Categorize improvments
6 - * @credits
 6+ * @credits
77 * @licence GNU General Public Licence 3.0
8 - * @description
 8+ * @description
99 *
1010 */
1111
12 -if( !defined( 'MEDIAWIKI' ) ) {
 12+if ( !defined( 'MEDIAWIKI' ) ) {
1313 echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
1414 die();
1515 }
@@ -24,9 +24,9 @@
2525 $m_pageText = $m_pageObj->textbox1;
2626
2727 $arrAllCats = Array();
28 - $regulartext ='';
 28+ $regulartext = '';
2929 $nowikitext = '';
30 - $cleanedtext ='';
 30+ $cleanedtext = '';
3131 $finaltext = '';
3232 # Check linewise for category links:
3333 # Get the first part of the text up until the first <nowiki> tag.
@@ -34,31 +34,31 @@
3535 $regulartext = $arrBlocks1[0];
3636
3737 # Get and strip categories from the first part
38 - $cleanedtext = CategorizeBody::fnCategorizeStripCats($regulartext,$arrAllCats);
 38+ $cleanedtext = CategorizeBody::fnCategorizeStripCats( $regulartext, $arrAllCats );
3939 $finaltext .= $cleanedtext;
40 -
 40+
4141 # Go through the rest of the blocks to find more categories
42 - for($i=1; $i<count($arrBlocks1); $i++){
 42+ for ( $i = 1; $i < count( $arrBlocks1 ); $i++ ) {
4343 $arrBlocks2 = explode( "</nowiki>", $arrBlocks1[$i] );
44 - //ignore cats here because it is part of the <nowiki> block
 44+ // ignore cats here because it is part of the <nowiki> block
4545 $nowikitext = $arrBlocks2[0];
46 - //add to final text
 46+ // add to final text
4747 $finaltext .= '<nowiki>' . $nowikitext . '</nowiki> ';
48 -
49 - //strip cats here because it's the text after the <nowiki> block
 48+
 49+ // strip cats here because it's the text after the <nowiki> block
5050 $regulartext = $arrBlocks2[1];
51 - $cleanedtext = CategorizeBody::fnCategorizeStripCats($regulartext,$arrAllCats);
52 - $finaltext .= ltrim($cleanedtext);
 51+ $cleanedtext = CategorizeBody::fnCategorizeStripCats( $regulartext, $arrAllCats );
 52+ $finaltext .= ltrim( $cleanedtext );
5353 }
5454
55 - //Place cleaned text back into the text box:
 55+ // Place cleaned text back into the text box:
5656 $m_pageObj->textbox1 = rtrim( $finaltext );
57 -
 57+
5858 return $arrAllCats;
59 -
 59+
6060 }
6161
62 - public static function fnCategorizeStripCats($texttostrip, &$catsintext){
 62+ public static function fnCategorizeStripCats( $texttostrip, &$catsintext ) {
6363 global $wgContLang, $wgOut;
6464
6565 # Get localised namespace string:
@@ -73,27 +73,27 @@
7474
7575
7676 # Check linewise for category links:
77 - foreach( explode( "\n", $texttostrip ) as $m_textLine ) {
 77+ foreach ( explode( "\n", $texttostrip ) as $m_textLine ) {
7878 # Filter line through pattern and store the result:
79 - $m_cleanText .= rtrim( preg_replace( "/{$m_pattern}/i", "", $m_textLine ) ) . "\n";
 79+ $m_cleanText .= rtrim( preg_replace( "/{$m_pattern}/i", "", $m_textLine ) ) . "\n";
8080
8181 # Check if we have found a category, else proceed with next line:
82 - if( preg_match_all( "/{$m_pattern}/i", $m_textLine,$catsintext2,PREG_SET_ORDER) ){
83 - foreach( $catsintext2 as $local_cat => $m_prefix ) {
84 - //Set first letter to upper case to match MediaWiki standard
85 - $strFirstLetter = substr($m_prefix[2], 0,1);
86 - strtoupper($strFirstLetter);
87 - $newString = strtoupper($strFirstLetter) . substr($m_prefix[2], 1);
88 - array_push($catsintext,$newString);
89 -
 82+ if ( preg_match_all( "/{$m_pattern}/i", $m_textLine, $catsintext2, PREG_SET_ORDER ) ) {
 83+ foreach ( $catsintext2 as $local_cat => $m_prefix ) {
 84+ // Set first letter to upper case to match MediaWiki standard
 85+ $strFirstLetter = substr( $m_prefix[2], 0, 1 );
 86+ strtoupper( $strFirstLetter );
 87+ $newString = strtoupper( $strFirstLetter ) . substr( $m_prefix[2], 1 );
 88+ array_push( $catsintext, $newString );
 89+
9090 }
9191 # Get the category link from the original text and store it in our list:
92 - preg_replace( "/.*{$m_pattern}/i", $m_replace, $m_textLine,-1,$intNumber );
 92+ preg_replace( "/.*{$m_pattern}/i", $m_replace, $m_textLine, -1, $intNumber );
9393 }
94 -
 94+
9595 }
9696 return $m_cleanText;
97 -
 97+
9898 }
9999 }
100100 ?>

Status & tagging log