Extension talk:SelectCategoryTagCloud

Categories don't be saved when uploading (and categorizing) a file
Hi there, the extension works very well on articles. But when I select categories in the event of uploading a new file the categories selected won't be saved. I have to edit the file and select them again to save the categories.

--Trop 23:00, 26 April 2009 (UTC)

'''We resolved like below. Code will give reference ''' if ( $m_isUpload ) { //$m_pageObj->mUploadDescription .= $m_text; //Fixed Ticket#162 category availabe when upload
 * 1) If it is an upload we have to call a different method:

//FIXME: xiping.wang@gmail.com 20100429 // mComment becomes protected variable in MW 1.16.0. This feature is disabled before // we have other soultion // mComment variable must be public in SpecialUpload.php file of includes folder. $m_pageObj->mComment .= $m_text; } else{ $m_pageObj->textbox1 .= $m_text; }

Errors
I've got an errors caused by SelectCategoryTagCloudSuggest.php: 1 result set(s) not freed An other thing is the structure of this php-program, where at first query is executed and later checked if searchString perhaps is NULL. I've fixed the Error with mysql_free_result and changed the structure a little bit. My opinion is that this script may should more look like that: if(isset($_GET['q'])) { $searchString = mysql_real_escape_string($_GET['q']); if($searchString != NULL) { $sql = mysql_query("SELECT DISTINCT cl_to as cats FROM categorylinks WHERE cl_to LIKE '".$searchString."%'"); $suggestStrings=array; while($row = mysql_fetch_assoc($sql)) { array_push($suggestStrings,$row['cats']); }       echo implode(";",$suggestStrings); //echo $suggestStrings; if(mysql_num_rows($sql) == 0) { //echo "No results found"; }       mysql_free_result($sql); } }

The last problem is to have redundant DB-Access-Parameters on the top of the script, but the same data is provided by LocalSettings.php. Is there no way to require LocalSettings.php to use this params? Thanks -Stefan- ---79.211.199.108 14:46, 14 September 2007 (UTC)

Thanks for the suggestion, I included it in version 1.1 and updated the source file. Regarding the database credentials, the page is basically a standalone program and not part of the MediaWiki code. I have yet to find a work-around to get to the details in LocalSettings.php. Any suggestions are welcome. Thanks, --Lindele 16:10, 14 September 2007 (UTC)

It's me again I've found a Solution but its a bad one for a rich extended mediaWiki:

1.  & Manuel Schneider , Daniel Friesen http://wiki-tools.com * @licence GNU General Public Licence 2.0 or later * @description Adds a category selection tag cloud to the edit and upload pages and enables a Google Suggest like completion of categories entered by the user. *

define( 'MEDIAWIKI', true); require_once('../../includes/Defines.php'); # Grabb Defines to avoid Errors in LocalSettings require_once('../../LocalSettings.php'); # Load LocalSetting with all Settings but all Extensions (very dirty) global $wgDBserver,$wgDBname,$wgDBuser,$wgDBpassword;
 * 1) Set MEDIAWIKI to avoid the "Part Of mediaWiki-Errors"
 * 1) now we can load from mediaWiki globals

mysql_connect($wgDBserver,$wgDBuser,$wgDBpassword);

mysql_select_db($wgDBname);

if(isset($_GET['q'])) { $searchString = mysql_real_escape_string($_GET['q']); if($searchString != NULL) { $sql = mysql_query("SELECT DISTINCT cl_to as cats FROM categorylinks WHERE cl_to LIKE '".$searchString."%'"); $suggestStrings=array; while($row = mysql_fetch_assoc($sql)) { array_push($suggestStrings,$row['cats']); }       echo implode(";",$suggestStrings); //echo $suggestStrings; if(mysql_num_rows($sql) == 0) { //echo "No results found"; }       mysql_free_result($sql); }

} ?>

This works, but slowes up the CategorySuggest, because every extension and every setting is allocated per one request of suggest.

2. I think mediaWiki it self, should perhaps better provide a distributed Setting, something like "DatabaseSettings.php" as separate Solution. So you can require this Config-File in LocalSettings.php and every other Application that need this Params without running directly under mediaWiki, within one of the few Hook-Callbacks, although it will give the possibility to load only needed Settings under MediaWiki. Did you have some connections to mediaWiki core developers?

3. An other way could be to use the separat AdminSetting.php file, but not everyone might set this config file.

4. Perhaps you can grab the Settings in SelectCategoryTagCloud.php where they are available and write it to a file which can be included to SelectCategoryTagCloudSuggest.php, that will never be a Problem, because SelectCategoryTagCloud.php is called earlier than SelectCategoryTagCloudSuggest.php will be called first time.

5. You could do not require LocalSettings.php but read it with fopen or e.g. and use a regular expression to get the Settings without parsing LocalSettings.php

But nothing seems to be very great. All Solutions are dirty Solutions, in exception of creating a separate DatabaseSettings.php which will be included in LocalSettings and SelectCategoryTagCloudSuggest but that will make the installation quite more difficult. In this case(not a special one) I belive mediaWiki it self should be improved or I'm very interessted too in a good Solution with current mediaWiki. Whats your idea about this?

I would think that the easiest and cleanest way to solve this to extend the MediaWiki API to allow a list of all categories. This would be optimised for speed, secure and part of the core and therefore available for other projects to reuse. --Lindele 10:46, 27 September 2007 (UTC)

The native reason because I browsed to this talkpage follows...

Setting wgSelectCategoryRoot has no Effect

 * I wanna make a Playground Namespace with Playground Categories.
 * There for I've created a special categorie "Playground" wich should be the root category for NS_PLAYGROUND
 * My setting of wgSelectCategoryRoot doesnt have any effect, so I've read the Code and found out, that there is no usage
 * of the parameter wgSelectCategoryRoot in SelectCategoryTagCloudFunctions.php
 * Than I've seen the Code:

$m_allCats = fnSelectCategoryGetAllCategories;
 * and thats the only thing where categories are grapped from database, for the cloud.
 * There is no fnSelectCategoryGetAllSubCategoriesUnderRoot($wgSelectCategoryRoot[$current_namespace]) or e.g.
 * Is the wgSelectCategoryRoot setting only for normal SelectCategory-Extension available and not for this one?

Sorry my english is perhaps a little bit roughly :)

Thanks again -Stefan- 79.211.199.89 10:40, 25 September 2007 (UTC)

To be honest, that's the part of the code that I took 'as-is' from the existing Extension:SelectCategory. Maybe you can find some ideas there? --Lindele 10:43, 27 September 2007 (UTC)
 * I've been looking for a while and I've made something that works fine. Use function fnSelectCategoryGetAllCategories that is defined in selectCategory ext. in some php-file. You have to redefine method of building CloudTag, so that only things returned by this function are used.
 * It has still no effect! And 'SelectCategoryTagCloudFunctions.php' has been replaced with the Mediawiki built-in AJAX framework. Does anyone know a solution that works with current release of MediaWiki? Pmaas 11:56, 5 December 2010 (UTC)

Errors When trying to Input Categories Manually
I just installed the SelectCategoryTagCloud extension and it works fine when a user is clicking to select from the list of "Popular Categories". However, if you try to manually enter anything into the Categories text box, the following 2 warnings are displayed: Warning: mysql fetch assoc: supplied argument is not a valid MySQL result resource in /var/www/wiki/extemsopms/SelectCategoryTagCloud/SelectCategoryTagCloudSuggest.php on linne 20

Warning: mysql free result: supplied argument is not a valid MySQL result resource in /var/www/wiki/extemsopms/SelectCategoryTagCloud/SelectCategoryTagCloudSuggest.php on linne 26 In addition, there is no "auto-suggest" based on the initial letters that are manually input in the text box.

If I ignore the warnings, type something in the box anyway, and then save the page, it will properly add the new or existing tag to the page.

In short, everything seems to be working fine except for the auto-suggest and the error messages (presumably related). Thoughts?

--jaysailor 9 October 2007

--- I had this same error today, after installing this extension. In SelectCategoryTagCloudSuggest.php I forgot to update the name of the database to "wikidb". If "wikidb" is the default database name for MediaWiki, then I think that the next release should use that instead of "DBNAME" (unless "Move SelectCategoryTagCloudSuggest.php configuration for database access into Mediawiki framework to simplify configuration" is checked off the to do list).

The line I modified in SelectCategoryTagCloudSuggest.php is: mysql_select_db("DBNAME");

-d 4 January 2008 --- I am seeing a similar issue. When I manually type in category names using Firefox on Mac I do not get any autocompletion. I get these errors in the error console: Error: [Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.status]" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)"  location: "JS frame ::  http://-snip-]/extensions/SelectCategoryTagCloud/SelectCategoryTagCloud.js :: handleResponse :: line 118"  data: no] Source File: http://-snip-/wiki/extensions/SelectCategoryTagCloud/SelectCategoryTagCloud.js Line: 118 Error: uncaught exception: [Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]"  nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)"  location: "JS frame ::  http://-snip-/wiki/extensions/SelectCategoryTagCloud/SelectCategoryTagCloud.js :: sendRequest :: line 112"  data: no] In Opera on Mac OS I do get autocompletion, but I am seeing two copies of every possible complemetion.

In Safari, autocompletion works as expected.

Any thoughts?

Tnabtaf, 24 January 2008 -- I fixed the problems in Opera and Firefox by removing the onkeydown from SelectCategoryTagCloudFunctions.php: 70c70 <              $m_pageObj->$m_place .= "\n"; --- >              $m_pageObj->$m_place .= "\n";

With many thanks to Kevin S at ZFIN.

Tnabtaf, 25 January 2008

Removing the onkeydown does work but when I remove my courser from that field I get the same error. So I took the onkeyup off and it fixed the problem...but it doesn't have auto suggest now. Any suggestions how I can fix this problem? (Ed March 27, 2008)

How to exclude Templates from Showing
This is a great extension. However, at the moment, it is showing all my templates as well as the more meaningful categories. Is there any way that I can change it so that it doesn't include any categories with the word template in them? A kind of automatic "*template*" exclude? Any help/advice much appreciated. Thanks

That would be valuable, I agree! There is no out of the box functionality for this right now. Any suggestions how to build it into the extension gracefully would be appreciated. A short term fix could be to modify the SQL statement in the SelectCategoryTagCloudSuggest.php file along the lines of [...] WHERE cl_to LIKE '".$searchString."%' AND LOWER(cl_to) NOT LIKE LOWER('%TEMPLATE%')

The LOWER function is included to ignore case differences in how you spell template.

I haven't tested this, let me know if it works...

- Lindele 21:10, 23 October 2007 (UTC)

SelectCategoryTagCloud is stripping Leading spaces from text lines
Hey all, first off I just wanted to say I love this extension. I tend to forget the spelling of my categories and always get them messed up this is a huge help. That being said I discovered a problem with the extension. It strips out the leading text from your wiki page. This is only a problem if you are trying to use the leading spaces to create sections on the page. I tracked the problem back to "SelectCategoryTagCloudFunctions.php" file. In here you are using the "trim" function which strips the blanks from BOTH the front and end of the lines. I changed all 4 "trim" commands to "rtrim" and the extension is now working fantastically. Anyway I wanted to pass this info on so it can be included into the new versions.

- John P 18 Nov 2007

Same Issue
Hi, I'm getting the same issue today. I can't find the SelectCategoryTagCloudFunctions.php file to verify that trim is now rtrim. I'm using version 1.3.

Strmtrupr2 18:49, 28 May 2008 (UTC)

Issue here
Found the same issue and performed the change to five 'trim' functions in "SelectCategoryTagCloud.body.php". Now leading spaces are no longer removed.

Fix to Issue
As far as I can tell, the only place trim was causing a problem was on the line $m_cleanText .= trim( preg_replace( "/{$m_pattern}/i", "", $m_textLine ) ). "\n"; Inside the fnSelectCategoryStripCats($texttostrip, &$catsintext) function. I changed it to $m_cleanText .= preg_replace( "/{$m_pattern}/i", "", $m_textLine ). "\n"; And everything appears to be working properly. --64.140.241.82 16:58, 21 October 2008 (UTC) (Kevin Hamer)

Also fixed with rtrim: $m_cleanText .= rtrim( preg_replace( "/{$m_pattern}/i", "", $m_textLine ) ). "\n"; 89.223.122.29 15:49, 11 May 2010 (UTC)

Applying to a new namespace
Hi, and thanks for this piece of code.

Here's my problem : I've created a "Doc" namespace, and the cloud doesn't appear in it.

My LocalSettings has this: $wgExtraNamespaces[100] = "Doc"; $wgExtraNamespaces[101] = "Doc_talk"; I can create pages in Doc namespace and it appears well in the Special Search page - so I guess it works.

Then I added a line to wiki/extensions/SelectCategoryTagCloud/SelectCategoryTagCloud.php: (the Cloud works well on "standard" pages) (Last line with Doc)

I don't know if I made a mistake, or if the code is limited on this topic?

(I wasn't lucky either with : $wgSelectCategoryNamespaces[NS_DOC] = true;

BTW, thanks for the 1.2 version, I can use "spaces in 1st line" again ! --FredT34 12:05, 27 November 2007 (UTC)

I checked and I hadn't realised that it doesn't work for me either. But the solution is simple, you need to use the following syntax: 100            => true

and not NS_DOC                 => true

Cheers, Lindele 18:35, 27 November 2007 (UTC)

YES, 100 => true does the trick. Thanks ! --FredT34 22:11, 28 November 2007 (UTC)

Adding Categories with ampersands in their title
In some cases it is possible to have Short URL's (mod rewrite) and ampersands in titles. To Add Categories with ampersands (&), you need to modify the js-code to something like this:

/extensions/SelectCategoryTagCloud/SelectCategoryTagCloud.js

This ensures that escaped innerHTML content is put correctyl in the input-field.

--Kaspera 15:55, 5 December 2007 (UTC)


 * This is great! But it doesn't work completely:

--Robinson Weijman 11:55, 5 November 2010 (UTC)
 * 1) when I click on a category in the cloud it still displays &amp at first.
 * 2) if I have added a category called A&B to a page and then, after saving the page, click on the category I get a link to Category:A instead of Category:A&B

nowiki exclusion
I am a little confused by the extension SelectCategory, what are the main differences?

I would like to know if the request to escape categories between nowiki has been noticed, solved or could be solved with a quick fix. The main reason is template inclusion, wich are categorised and show up on articles.

--Kaspera 15:55, 5 December 2007 (UTC)


 * Did it myself. Fixed multiple categories on one line bug, and noinclude bug.


 * Changes:


 * Added file SelectCategoryTagCloudHack.php:


 * Fixed the last newline bug. --Kaspera 13:12, 14 December 2007 (UTC)

Disclaimer: I havent'had time to document this script. Due to the lack of documentation, I recommend to make no changes to the regular expression unless you really know what you are doing. The matches variable will be populated depending on how many subpatterns the regexp contains.

What it does:

 * First of all, the script devides the text into two arrays, one part is everything but the nowiki part (it even spans multiple lines) and the other continaing everything within the nowiki tags.
 * Only text in the first part will be 'parsed'. At the end, both parts are joined and returned.
 * I slightly modified the regular expressions to be less greedy, and solved the 'multiple categories on one line ignored' bug by recoding that part.


 * Feel free to modify the code (keep me posted)! --Kaspera 14:18, 10 December 2007 (UTC)


 * I've noticed that the latest version of the extension adds extra spaces around a nowiki tag everytime you edit it. Does this hack fix that behavior?  Or was this hack folded in to the extension and causes it?  98.215.227.116 09:55, 5 October 2008 (UTC)

Preview edits loses categories
When previewing changes, all categories are lost. The suggested bugfix only applies to the SelectCategory extension.

The given solution works with an array, submitted by $_POST, the SelectCategoryTagCloud extension however submits a string.

To solve this error with this extension, use this:

--Kaspera 15:04, 20 December 2007 (UTC)

tagcloud suggestion
Hello,

I got a bug on the tagcloud suggestion tool.When a user want to modify an article, the tag suggestion doesn't work. I tried to debug the script and the function Handleresponse is never called.Maybe because the readyStatus doesn't change. The suggestion tool works well only when the user want to upload a picture or a sound.

I am a "beginner" so I don't really know where can I find the solution.

Can someone help me please?

Thanks

Finally I fixed my problem.

The problem came from a conflict between the Tag cloud extension and the rating extension. When the http.readyState changes,HandleResponse is called.In my case there were two functions HandleResponse,so only the HandleRespone in the Rating extension was called.

To fix it maybe rename the function like: HandleResponseRating and HandleResponseSuggest.

The fnSelectCategoryGetPageCategories removes empty lines in code listings
The fnSelectCategoryGetPageCategories uses the rtrim function which transforms lines with a single whitespace (necessary in longer code listings that have empty lines) into empty lines, thus breaking the code listings in two parts in the wiki markup.

Here is the diff to SelectCategoryTagCloudFunctions.php from version 1.2 (2007-09-27):

@@ -177,7 +177,7 @@ 	# Check linewise for category links: foreach( explode( "\n", $m_pageText ) as $m_textLine ) { # Filter line through pattern and store the result: -               $m_cleanText .= rtrim( preg_replace( "/{$m_pattern}/i", "", $m_textLine ) ). "\n"; +               $m_cleanText .= ((substr($m_textLine,0,1) == " ") ? $m_textLine : rtrim( preg_replace( "/{$m_pattern}/i", "", $m_textLine ) ) ). "\n"; # Check if we have found a category, else proceed with next line: if( !preg_match( "/{$m_pattern}/i", $m_textLine) ) continue; # Get the category link from the original text and store it in our list: Ivan Pepelnjak 20:41, 27 March 2008 (UTC)


 * I introduced rtrim in order to fix a previous bug. I don't understand your problem statement. Do you have an example?
 * --Lindele 17:00, 1 April 2008 (UTC)

actually i think that we should not change any chars of the original content, even the white spaces of each line are always useles. so i agree with him, leave the white space where they are is safe. 121.8.153.6 09:38, 13 August 2010 (UTC)

Only works for editing Categories
I am trying this with the latest version of mediawiki (1.12?) and it only works when editing a category page (category:example). For any other page, it comes out lookng garbled. There is no nice box around the category suggestion section and the category cloud over laps on top of the Popular Categories and Category Hierarchy tabs. Also,I have been unable to get the auto suggestion to work when typing in the search box (no drop down ever appears- which may be related to this problem.
 * Yeah. I'm having the same problem with formating. It seems that mediawiki 1.13 strips the CSS from v1.2 of this extension. Does anybody know how to fix this? I'd update to v1.3 but it doesn't seem to work with my fix width skin. (Ed D May 7,2008)

problem with mediawiki + postgres
This extension don't run on mediawiki 1.12 + postgres 8.1:

Warning: pg_query [function.pg-query]: Query failed: ERROR: no existe la columna «count» in /var/www/wikipalme/includes/DatabasePostgres.php on line 553 Error interno

Set $wgShowExceptionDetails = true; at the bottom of LocalSettings.php to show detailed debugging information.

To fix this, you need to edit the line 350 of the SelectCategoryTagCloud.body.php:

Original: $sql = "SELECT cl_to as title, COUNT(*) as count FROM $categorylinks ". $exclude_condition. " GROUP BY cl_to HAVING count >= $min_count_input ORDER BY cl_to ASC";

Fixed: $sql = "SELECT cl_to as title, COUNT(*) as count FROM $categorylinks ". $exclude_condition. " GROUP BY cl_to HAVING count(*) >= $min_count_input ORDER BY cl_to ASC";

A little modification on fnSelectCategoryTagCloudAjax function
The use of mysql_real_escape_string function requires connection parameter. It is better to use strencode function from Database object. It does the same thing: function fnSelectCategoryTagCloudAjax( $query ) { if(isset($query) && $query != NULL) { -              $searchString = mysql_real_escape_string($query); -              # % and _ are not escaped so do it here +              $dbr =& wfGetDB( DB_SLAVE ); +              $searchString = $dbr->strencode( $query ); $searchString = str_replace( '%', '\%' , $searchString ); $searchString = str_replace( '_', '\_' , $searchString ); $searchString = str_replace( '|', '%' , $searchString ); -              $dbr =& wfGetDB( DB_SLAVE ); $categorylinks = $dbr->tableName('categorylinks'); $page         = $dbr->tableName('page'); $sql =
 * 1) Entry point for Ajax, registered in $wgAjaxExportList; returns all cats starting with $query

Fix for uploading files in MediaWiki 13alpha
In MediaWiki 13alpha (maybe, earlier -- I can't tell you for sure) there's no mUploadDescription method for uploading objects. It has been renamed to mComment. So, I've fixed this problem in SelectCategoryTagCloud.body.php by changing this method:

# If it is an upload we have to call a different method: if ( $m_isUpload ) { -			$m_pageObj->mUploadDescription .= $m_text; +			$m_pageObj->mComment .= $m_text;

Bugs when FCK-Editor is active
We've got a project running and found out this nice extension doesn't work well together with fck because fck uses html-syntax so the regex for finding the categories will not work. The result is, that used categories are not marked and cannot be removed via clicks.

After struggling around for some hours here's a working solution to overcome this problem

in function fnSelectCategoryGetPageCategories determine fck-usage

// use fck-editor? $edit_export = var_export($m_pageObj, true); if(strpos( $edit_export, "FCKeditorEditPage") === false) $fckusage = false; else $fckusage = true; add third param to fnSelectCategoryStripCats function fnSelectCategoryStripCats($texttostrip, &$catsintext, $fckusage = false) change this in fnSelectCategoryStripCats

# The regular expression to find the category links: $m_pattern = "\[\[({$m_catString}|category):(.*?)\]\]"; //pattern for FCK-Editor!! if($fckusage) $m_pattern = '(.*?)<\/a>'; change lines $cleanedtext = fnSelectCategoryStripCats($regulartext,$arrAllCats); to $cleanedtext = fnSelectCategoryStripCats($regulartext,$arrAllCats,$fckusage );

Now Tagcloud will work just fine together with FCK

Greetings

good job, but i still found that there remains a problem, only in the rich edit model this extension can show these categories in the textbox. If change to none rich edit model and edit, there's nothing. This regular expression has something i don't understand. why do you use @@@"('."{$m_catString}".'|@@@ but not @@@"({$m_catString}|@@@. I fixed this regular expresion to suit both the old type as @@@@ @@@@ and the new type as @@@@@@@@. So no matter in rich edit model or none rich edit model, both conditions are ok. I am using the decode of zh-hans, i am afraid this problem is only occure to me. So if others meet with the same problem can give me an email, extirpate0832@gmail.com

121.8.153.6 01:19, 24 August 2010 (UTC)

For those who want to include pages without the categories
Hi... I wanted to get the categories not includable when we set them... So I use to put $m_text .= "\n $m_catString:" . mysql_escape_string(trim($m_cat)) . " ";

on line 149 in the fnSelectCategorySaveHook function

and place

$finaltext = ereg_replace('\<\noinclude\>\<\/noinclude\>','',$finaltext);

on line 241, like this

$cleanedtext = fnSelectCategoryStripCats($regulartext,$arrAllCats); $finaltext .= $cleanedtext; }			$finaltext = ereg_replace('\<\noinclude\>\<\/noinclude\>','',$finaltext);

//Place cleaned text back into the text box: $m_pageObj->textbox1 = trim( $finaltext );

This code also remove unnecessary noinclude tags. Just to share it with you...

Kronoxt 22:00, 5 April 2009 (UTC)

Categories and Sections
There are two issues regarding category selection and section editing:
 * When editing a section, the page categories are not shown. For well-developed pages, most editing is probably done inside of a section, making it hard to use the full potential of this extension.
 * In some use cases, category references are intended to be linked with a particular section. This extension does not support that capability.

Any thoughts on these? I know these are more design issues than "bugs". -- Joeclarkia 16:45, 12 May 2009 (UTC)

Causes some problems Semantic MediaWiki inline queries
When I enter the Semantic MediaWikiinline query

on saving the page, SelectCategoryTagCloudSuggest strips the category out of the query and puts it at the end of the article. This functionality breaks some inline queries.

I tried getting around this by using the notationCategory:City, i.e.,

Now SelectCategoryTagCloudSuggest does not strip out the Category, however the inline query does not seem to work.


 * Apply the fix described in . that should solve the problem


 * --Jackeapen 11:17, 21 July 2009 (UTC)

problems with &lt;nowiki&gt; sections
This thing is sticking line breaks around nowiki sections; here's how I fixed it. SelectCatgoryTagCloud.body.php before: # Check linewise for category links: foreach( explode( "\n", $texttostrip ) as $m_textLine ) { # Filter line through pattern and store the result: $m_cleanText .= trim( preg_replace( "/{$m_pattern}/i", "", $m_textLine ) ). "\n"; after: $i = 1; # Check linewise for category links: $texttostrip = explode( "\n", $texttostrip ); foreach( $texttostrip as $m_textLine ) { # Filter line through pattern and store the result: $m_cleanText .= trim( preg_replace( "/{$m_pattern}/i", "", $m_textLine ) ); if ( $i !== count( $texttostrip ) ) $m_cleanText .= "\n"; All it does is check if it's on the last line of the text it's passed. If it is, then it doesn't add a carriage return.

good job! thx! finnally you solved this problem, i like you ! seems that you forget the $i=$i+1;

and i found that this solutions get another problem. every time editing a section, the "\n" after the headings is always eatten up by this action. i don't know why. So i just add these codes " if($i==1) $m_cleanText .= "\n";", assuming that the first \n is belonged to the headings all the time.

so the finnal codes to solve the  problem is:

.....       $i = 1; # Check linewise for category links: $texttostrip = explode( "\n", $texttostrip ); foreach( $texttostrip as $m_textLine ) { # Filter line through pattern and store the result: $m_cleanText .= trim( preg_replace( "/{$m_pattern}/i", "", $m_textLine ) ); if($i==1) $m_cleanText .= "\n"; if ( $i !== count( $texttostrip ) ) $m_cleanText .= "\n"; $i = $i+1; .....

121.8.153.6 02:32, 13 August 2010 (UTC)

Enable only for Category edits?
I'm trying to get it so that the category tag cloud only shows up when editing Categories. I have this defined for $wgSelectCategoryNamespaces:

if( !isset( $wgSelectCategoryNamespaces ) ) $wgSelectCategoryNamespaces = array(       NS_MEDIA                  => false,        NS_MAIN                   => false,        NS_TALK                   => false,        NS_USER                   => false,        NS_USER_TALK      => false,        NS_PROJECT                => false,        NS_PROJECT_TALK   => false,        NS_IMAGE                  => false,        NS_IMAGE_TALK     => false,        NS_MEDIAWIKI      => false,        NS_MEDIAWIKI_TALK => false,        NS_TEMPLATE               => false,        NS_TEMPLATE_TALK  => false,        NS_HELP                   => false,        NS_HELP_TALK      => false,        NS_CATEGORY               => true,        NS_CATEGORY_TALK  => false,        100               => false );

Yet when I click on "Upload file" I still see the Category Cloud beneath the Summary box. How can this be turned off? --Gkullberg 16:40, 2 November 2009 (UTC)

Category Hierarchy
On the Category Hierarchy tab it says "Coming soon..." What is meant by that (i.e. what exactly is coming and when)? More importantly, is there a way to switch this tab off? I don't want my users to get confused by this. --Robinson Weijman 13:00, 18 February 2010 (UTC)

find these codes document.write(" ");

change it into

document.write(" ");

can make the Category Hierarchy''' disappear 121.8.153.6 02:43, 13 August 2010 (UTC)


 * Sorry for the late reply - thanks! --Robinson Weijman 12:57, 24 September 2010 (UTC)

Every pages' layout has been changed since i installed this extensionsolved
everything works well as the extension has said, but i found that every page of my mediawiki has changed. For example, all the words's size get bigger and the lay out of the pages are weird.

i disabled the extension in the localsettings.php page, and everyting get back as normal.

i use my smart phone (neuxs one and iphone) to launch my mediawiki, the page layout is normal.

i tried to disable the 4 hooks, didn't work. i don't know what is wrong, and how i can change it. this is such a good extension, i really want to fix this problem and use it normally.

who can help me ?219.137.235.162 13:00, 15 August 2010 (UTC)

I solved this problem. At first I saved the "SelectCategoryTagCloud.body.php" as utf-8 file type, then these strange things happened. The original codes are ok. When i reinstalled the extension, everything turned good. But i still don't know what has actually happend when i save it as "utf-8". Such a weird thing. 219.137.235.162 13:00, 15 August 2010 (UTC)

oh, i found that the problem was caused by the bom of the utf-8, when i save the .php file as "utf-8 without bom", then everything remains normal.

many thx to www.baidu.com, i found the answer through it219.137.235.162 13:10, 15 August 2010 (UTC)

PHP > 5.3.0 bug
After upgrading an Ubuntu installation from 9.10 to 10.04, I started having a problem with this extension. It's the same problem documented here. I'm guessing it has to do with the PHP changes in 5.3.1 (I have php 5.3.2 now, but I have a feeling some of the "bugs" in 5.3.1 are still present, or were not really bugs). In any case, will this extension be updated to work with current versions of PHP? For completeness: my MediaWiki version is 1.15.4, in case this actually is a MediaWiki version-related bug. Joeclarkia 05:53, 30 August 2010 (UTC)

Fix Issue for PHP 5.3.x
Just change SelectCategoryTagCloud.body.php from version 1.4

Line 166

function fnSelectCategoryOutputHook( &$m_pageObj, &$m_parserOutput ) {

to

function fnSelectCategoryOutputHook( &$m_pageObj, $m_parserOutput ) {

Next Version
1 Please replace in SelectCategoryTagCloud.body.php (leading white spaces problem)
 * $m_cleanText .= trim( preg_replace( "/{$m_pattern}/i", "", $m_textLine ) ) . "\n";
 * with
 * $m_cleanText .= rtrim( preg_replace( "/{$m_pattern}/i", "", $m_textLine ) ) . "\n";

2 Please correct the version-number.

Turn off the Cloud and only use Category Suggest ?
because extension:categorysuggest doesn't work with mediawiki 1.16 and php5.3 -> is it possible to "switch off" the cloud in this extension and only use the "categorySuggest" Part? The cloud is much to big in our Wiki because there are a lot of categories and so we wont use it.