Extension talk:SelectCategoryTagCloud

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)