http://www.mediawiki.org/wiki/Special:Code/MediaWiki/98627

Revision: 98627
Author:   fptc
Date:     2011-10-01 21:18:51 +0000 (Sat, 01 Oct 2011)
Log Message:
-----------
Fixing topics of rev. 96192

Modified Paths:
--------------
    trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.body.php
    trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.i18n.php
    trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php
    trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloudMaintenance.php
    trunk/extensions/FreqPatternTagCloud/includes/FrequentPattern.php
    trunk/extensions/FreqPatternTagCloud/includes/Proposal.php
    trunk/extensions/FreqPatternTagCloud/includes/Search.php
    trunk/extensions/FreqPatternTagCloud/includes/Tag.php
    trunk/extensions/FreqPatternTagCloud/includes/TagCloud.php
    
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentItemset.php
    
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternAlgorithm.php
    
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternApriori.php
    
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternRule.php
    
trunk/extensions/FreqPatternTagCloud/includes/computation/exceptions/InvalidItemCollectionException.php
    
trunk/extensions/FreqPatternTagCloud/includes/exceptions/InvalidAttributeException.php
    trunk/extensions/FreqPatternTagCloud/includes/exceptions/SQLException.php
    trunk/extensions/FreqPatternTagCloud/javascripts/main.js

Modified: trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.body.php
===================================================================
--- trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.body.php   
2011-10-01 20:20:46 UTC (rev 98626)
+++ trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.body.php   
2011-10-01 21:18:51 UTC (rev 98627)
@@ -16,6 +16,8 @@
        
        const ATTRIBUTE_VALUE_INDEX_SPECIALPAGE = "SearchByProperty";
        
+       const CATEGORY_PAGE = "Category";
+       
        /**
         * Maximum font size of tags in px
         *
@@ -82,7 +84,6 @@
                        $this->printSearchResult($par);
                }
                $this->printTagCloud($par);
-               
        }
        
        /**
@@ -94,23 +95,20 @@
        public static function getAttributeSuggestions($currentAttributeValue) {
                $dbr =& wfGetDB( DB_SLAVE );
                
-               if (!($res = mysql_query("SELECT smw_title
-                                                       FROM 
".$dbr->tableName("smw_ids")."
-                                                       WHERE smw_namespace = 
102
-                                                       AND LENGTH(smw_iw) = 0
-                                                       AND smw_title LIKE 
'%".mysql_real_escape_string($currentAttributeValue)."%'
-                                                       ORDER BY smw_title
-                                                       LIMIT 20"))) {
-                       return "[]";
-               }
+               $res = $dbr->select("smw_ids", "smw_title", "smw_namespace = 
102 AND LENGTH(smw_iw) = 0 AND smw_title LIKE 
'%".mysql_real_escape_string($currentAttributeValue)."%'", __METHOD__, 
array("ORDER BY" => "smw_title", "LIMIT" => 20));
                
                $attributes = array();
-               while ($row = mysql_fetch_assoc($res)) {
+               while ($row = $res->fetchRow()) {
                        $attributes[] = sprintf('"%s"', 
addcslashes($row['smw_title'], '"'));
                }
                
-               mysql_free_result($res);
+               // Category
+               if (strpos(wfMsg("categoryname"), $currentAttributeValue) !== 
false) {
+                       $attributes[] = sprintf('"%s"', wfMsg("categoryname"));
+               }
                
+               $res->free();
+               
                return sprintf("[%s]", implode(", ", $attributes));
        }
        
@@ -124,7 +122,7 @@
                $dbr =& wfGetDB( DB_SLAVE );
                
                // Get possible attribute values
-               if (!($res = mysql_query("SELECT DISTINCT vals.smw_title AS 
val, atts.smw_title AS att
+               $res = $dbr->query("(SELECT DISTINCT vals.smw_title AS val, 
atts.smw_title AS att
                                                        FROM 
".$dbr->tableName("smw_ids")." vals, ".$dbr->tableName("smw_ids")." atts, 
".$dbr->tableName("smw_rels2")." rels
                                                        WHERE vals.smw_id = 
rels.o_id
                                                        AND atts.smw_id = 
rels.p_id
@@ -134,12 +132,17 @@
                                                        AND LENGTH(atts.smw_iw) 
= 0
                                                        AND vals.smw_title LIKE 
'%".mysql_real_escape_string($currentSearchValue)."%'
                                                        ORDER BY vals.smw_title
-                                                       LIMIT 20"))) {
-                       return "[]";
-               }
+                                                       LIMIT 20) UNION (
+                                                       SELECT smw_title AS 
val, '".wfMsg("categoryname")."' AS att
+                                                       FROM 
".$dbr->tableName("smw_ids")."
+                                                       WHERE smw_title LIKE 
'%".mysql_real_escape_string($currentSearchValue)."%'
+                                                       AND smw_namespace = 14
+                                                       ORDER BY smw_title
+                                                       LIMIT 10
+                                                       )");
                
                $suggestions = array();
-               while ($row = mysql_fetch_assoc($res)) {
+               while ($row = $res->fetchRow()) {
                        // Apply frequent pattern rules
                        $conclusions = 
FrequentPattern::getConclusions($row['att'], $row['val']);
                        
@@ -147,12 +150,12 @@
                                continue;
                        } else {
                                foreach ($conclusions as $conclusion) {
-                                       $suggestions[] = sprintf('{ "label": 
"%s", "category": "'.addcslashes(wfMsg("SearchSuggestionValue"), '"').'" }', 
addcslashes($conclusion, '"'), addcslashes($row['val'], '"'));
+                                       $suggestions[] = sprintf('{ "label": 
"%s", "category": "'.addcslashes(wfMsg("searchSuggestionValue"), '"').'" }', 
addcslashes($conclusion, '"'), addcslashes($row['val'], '"'));
                                }
                        }
                }
                
-               mysql_free_result($res);
+               $res->free();
                
                return sprintf("[%s]", implode(", ", $suggestions));
        }
@@ -193,11 +196,11 @@
                // Add input field
                if ($wgUser->isAllowed("protect")) {
                        $refreshData = sprintf('<div 
id="fptc_refresh">%s</div>', 
-                                       
$wgOut->parseInline(sprintf('[[:%s:%s|%s]]', self::SPECIALPAGE_PREFIX, 
self::MAINTENANCE_SPECIALPAGE, wfMsg("RefreshFrequentPatterns"))));
+                                       
$wgOut->parseInline(sprintf('[[:%s:%s|%s]]', self::SPECIALPAGE_PREFIX, 
self::MAINTENANCE_SPECIALPAGE, wfMsg("refreshFrequentPatterns"))));
                } else {
                        $refreshData = "";
                }
-               $wgOut->addHTML($refreshData.wfMsg("FormAttributeName").': 
<input type="text" name="fptc_attributeName" id="fptc_attributeName" 
value="'.$defaultAttribute.'"><input type="submit" 
value="'.wfMsg("FormSubmitButton").'" onClick="fptc_relocate();">
+               $wgOut->addHTML($refreshData.wfMsg("formAttributeName").': 
<input type="text" name="fptc_attributeName" id="fptc_attributeName" 
value="'.$defaultAttribute.'"><input type="submit" 
value="'.wfMsg("formSubmitButton").'" onClick="fptc_relocate();">
                                        ');
                
                $wgOut->addHTML("<br><br>");
@@ -218,10 +221,10 @@
                        // Context menu
                        $wgOut->addHTML('<ul id="fptc_contextMenu" 
class="contextMenu">
                                                <li class="browse">
-                                               <a 
href="#browse">'.wfMsg("ContextMenu_Browse").'</a>
+                                               <a 
href="#browse">'.wfMsg("contextMenu_Browse").'</a>
                                                </li>
                                                <li class="suggestions 
separator">
-                                               
'.wfMsg("ContextMenu_SimilarTags").':
+                                               
'.wfMsg("contextMenu_SimilarTags").':
                                                </li>
                                                </ul>');
                        
@@ -234,7 +237,7 @@
                } catch (InvalidAttributeException $e) {
                        if ($attribute) {       
                                // Attribute not found -> show error
-                               $wgOut->addHTML('<span style="color:red; 
font-weight:bold;">'.wfMsg("InvalidAttribute").'</span>');
+                               $wgOut->addHTML('<span style="color:red; 
font-weight:bold;">'.wfMsg("invalidAttribute").'</span>');
                        }
                }
        }
@@ -251,7 +254,9 @@
                
                $wgOut->addHTML(sprintf('<div class="fptc_tag" 
style="font-size:%dpx;">%s</div>', 
                                        $this->fontSizeMin + 
($this->fontSizeMax - $this->fontSizeMin) * $tag->getRate(),
-                                       
$wgOut->parseInline(sprintf("[[:%s:%s/%s/%s|%s]]", self::SPECIALPAGE_PREFIX, 
self::ATTRIBUTE_VALUE_INDEX_SPECIALPAGE, $attribute, $tag->getValue(), 
$tag->getValue()))));
+                                       $attribute == wfMsg("categoryname") 
+                                               ? 
$wgOut->parseInline(sprintf("[[:%s:%s|%s]]", self::CATEGORY_PAGE, 
$tag->getValue(), $tag->getValue())) 
+                                               : 
$wgOut->parseInline(sprintf("[[:%s:%s/%s/%s|%s]]", self::SPECIALPAGE_PREFIX, 
self::ATTRIBUTE_VALUE_INDEX_SPECIALPAGE, $attribute, $tag->getValue(), 
$tag->getValue()))));
        }
        
         /** Prints the result of the search for attribute 
<code>attribute</code> to <code>$wgOut</code>
@@ -274,7 +279,7 @@
                                        try {
                                                // Only if suggestions found
                                                if ($proposal->getProposal()) {
-                                                       
$wgOut->addHTML(wfMsg("Suggestion"));
+                                                       
$wgOut->addHTML(wfMsg("suggestion"));
                                                }
                                                $w=1;
                                                foreach 
($proposal->getProposal() as $possibleAttribute) {
@@ -287,7 +292,7 @@
                                                }
                                                
                                        } catch (InvalidAttributeException $e) {
-                                               
$wgOut->addHTML(wfMsg("NoSuggestion"));
+                                               
$wgOut->addHTML(wfMsg("noSuggestion"));
                                        }
                                        if ($proposal->getProposal()) {
                                                $wgOut->addHTML("<br><br>");
@@ -296,6 +301,4 @@
                        }
                }
        }
-}
-
-?>
\ No newline at end of file
+}
\ No newline at end of file

Modified: trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.i18n.php
===================================================================
--- trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.i18n.php   
2011-10-01 20:20:46 UTC (rev 98626)
+++ trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.i18n.php   
2011-10-01 21:18:51 UTC (rev 98627)
@@ -12,38 +12,39 @@
 $messages = array();
 
 $messages['en'] = array(
-               "ContextMenu_Browse" => "Browse Pages With This Value",
-               "ContextMenu_SimilarTags" => "Similar Tags",
-               "FormAttributeName" => "Property",
-               "FormSubmitButton" => "Submit",
+               "categoryname" => "Category",
+               "contextMenu_Browse" => "Browse Pages With This Value",
+               "contextMenu_SimilarTags" => "Similar Tags",
+               "formAttributeName" => "Property",
+               "formSubmitButton" => "Submit",
                "freqpatterntagcloud" => "Frequent Pattern Tag Cloud",
                "freqpatterntagcloudmaintenance" => "Frequent Pattern Tag Cloud 
Maintenance",
-               "InvalidAttribute" => "The entered property is invalid.",
-               "InsufficientRightsForMaintenance" => "You have to log in as 
system administrator to view this page.",
-               "RefreshFrequentPatterns" => "Refresh Data",
-               "RefreshedFrequentPatterns" => "Frequent pattern rules 
refreshed.",
-               "SearchAttributeName" => "Search property",
-               "SearchButton" => "Search",
-               "SearchSuggestionValue" => "Similar to \"%s\":",
-               "Suggestion" => "Do you mean: ",
-               "NoSuggestion" => "No suggestions found"
+               "invalidAttribute" => "The entered property is invalid.",
+               "insufficientRightsForMaintenance" => "You have to log in as 
system administrator to view this page.",
+               "refreshFrequentPatterns" => "Refresh Data",
+               "refreshedFrequentPatterns" => "Frequent pattern rules 
refreshed.",
+               "searchAttributeName" => "Search property",
+               "searchButton" => "Search",
+               "searchSuggestionValue" => "Similar to \"%s\":",
+               "suggestion" => "Do you mean: ",
+               "noSuggestion" => "No suggestions found"
                );
                
 $messages['de'] = array(
-               "ContextMenu_Browse" => "Durchsuche Seiten mit diesem Wert",
-               "ContextMenu_SimilarTags" => "&Auml;hnliche Tags",
-               "FormAttributeName" => "Attribut",
-               "FormSubmitButton" => "Eingabe",
+               "categoryname" => "Kategorie",
+               "contextMenu_Browse" => "Durchsuche Seiten mit diesem Wert",
+               "contextMenu_SimilarTags" => "&Auml;hnliche Tags",
+               "formAttributeName" => "Attribut",
+               "formSubmitButton" => "Eingabe",
                "freqpatterntagcloud" => "Frequent Pattern Tag Cloud",
                "freqpatterntagcloudmaintenance" => "Frequent Pattern Tag Cloud 
Maintenance",
-               "InvalidAttribute" => "Das eingegebene Attribut ist 
ung&uuml;ltig.",
-               "InsufficientRightsForMaintenance" => "Um diese Seite sehen zu 
k&ouml;nnen m&uuml;ssen Sie als Systemadministrator angemeldet sein.",
-               "RefreshFrequentPatterns" => "Aktualisierung der Daten",
-               "RefreshedFrequentPatterns" => "Regeln f&uuml;r frequent 
pattern neu generiert.",
-               "SearchAttributeName" => "Suche nach Attribut",
-               "SearchButton" => "Suche",
-               "SearchSuggestionValue" => "&Auml;hnlich zu \"%s\":",
-               "Suggestion" => "Meinten Sie: ",
-               "NoSuggestion" => "Keine Vorschl&auml;ge gefunden"
-               );
-?>
\ No newline at end of file
+               "invalidAttribute" => "Das eingegebene Attribut ist 
ung&uuml;ltig.",
+               "insufficientRightsForMaintenance" => "Um diese Seite sehen zu 
k&ouml;nnen m&uuml;ssen Sie als Systemadministrator angemeldet sein.",
+               "refreshFrequentPatterns" => "Aktualisierung der Daten",
+               "refreshedFrequentPatterns" => "Regeln f&uuml;r frequent 
pattern neu generiert.",
+               "searchAttributeName" => "Suche nach Attribut",
+               "searchButton" => "Suche",
+               "searchSuggestionValue" => "&Auml;hnlich zu \"%s\":",
+               "suggestion" => "Meinten Sie: ",
+               "noSuggestion" => "Keine Vorschl&auml;ge gefunden"
+               );
\ No newline at end of file

Modified: trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php
===================================================================
--- trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php        
2011-10-01 20:20:46 UTC (rev 98626)
+++ trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php        
2011-10-01 21:18:51 UTC (rev 98627)
@@ -39,12 +39,6 @@
                'version' => '1.0'
                );
 
-// Register hook to create new database to store frequent pattern information
-$wgHooks['LoadExtensionSchemaUpdates'][] = 'fptc_updateSchema';
-
-// Register hook to initialize frequent pattern database
-$wgHooks['LoadExtensionSchemaUpdates'][] = 'fptc_initializeRules';
-
 // Register hook to prepare header files
 $wgHooks['BeforePageDisplay'][] = 'fptc_initializeHeaders';
 
@@ -66,19 +60,6 @@
 
 
 /**
- * Initializes frequent pattern rules
- *
- * @return bool Success
- */
-function fptc_initializeRules() {
-       FrequentPattern::deleteAllRules();
-       FrequentPattern::computeAllRules();
-       
-       return true;
-}
-
-
-/**
  * Initializes page headers
  *
  * @return bool Success
@@ -134,37 +115,4 @@
        $wgOut->addScript('<script type="text/javascript" 
src="'.$wgScriptPath.'/extensions/FreqPatternTagCloud/javascripts/main.js"></script>');
        
        return true;
-}
-
-
-/**
- * Creates database schema
- *
- * @return bool Success
- */
-function fptc_updateSchema() {
-       $dbr =& wfGetDB( DB_SLAVE );
-       
-       if (!(mysql_query("CREATE TABLE IF NOT EXISTS 
`".$dbr->tableName("fptc_associationrules")."` (
-                                               `rule_id` int(11) NOT NULL 
auto_increment,
-                                               `p_id` int(8) NOT NULL COMMENT 
'Attribute',
-                                               `rule_support` float(5,3) NOT 
NULL,
-                                               `rule_confidence` float(5,3) 
NOT NULL,
-                                               PRIMARY KEY  (`rule_id`)
-                                               );
-                                               ALTER TABLE 
`fptc_associationrules` ADD INDEX ( `p_id` );"))) {
-               throw new SQLException();
-       }
-       if (!(mysql_query("CREATE TABLE IF NOT EXISTS 
`".$dbr->tableName("fptc_items")."` (
-                                               `o_id` INT( 8 ) NOT NULL ,
-                                               `rule_id` INT NOT NULL ,
-                                               `item_order` TINYINT( 1 ) NOT 
NULL ,
-                                               PRIMARY KEY ( `o_id` , 
`rule_id` )
-                                               );"))) {
-               throw new SQLException();
-       }
-       
-       return true;
-}
-
-?>
\ No newline at end of file
+}
\ No newline at end of file

Modified: 
trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloudMaintenance.php
===================================================================
--- trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloudMaintenance.php     
2011-10-01 20:20:46 UTC (rev 98626)
+++ trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloudMaintenance.php     
2011-10-01 21:18:51 UTC (rev 98627)
@@ -29,13 +29,22 @@
         */
        public function execute($par) {
                global $wgOut, $wgUser;
+               $dbr =& wfGetDB( DB_SLAVE );
                
                $this->setHeaders();
                
                if (!$wgUser->isAllowed("protect")) {
                        // No admin
-                       
$wgOut->addWikiText(wfMsg("InsufficientRightsForMaintenance"));
+                       
$wgOut->addWikiText(wfMsg("insufficientRightsForMaintenance"));
                } else {
+                       // Check if this call is the first
+                       try {
+                               $dbr->query("SELECT COUNT(1) FROM 
".$dbr->tableName("fptc_associationrules"));
+                       } catch (exception $e) {
+                               // Yes: create database tables
+                               $this->initSchema();
+                       }
+                       
                        // Refresh frequent pattern rules
                        include_once("includes/FrequentPattern.php");
                        
@@ -43,9 +52,34 @@
                        FrequentPattern::computeAllRules();
                        
                        // Notify user
-                       $wgOut->addWikiText(wfMsg("RefreshedFrequentPatterns"));
+                       $wgOut->addWikiText(wfMsg("refreshedFrequentPatterns"));
                }
        }
-}
-
-?>
\ No newline at end of file
+       
+       
+       
+       
+       /**
+        * Creates database schema
+        *
+        * @return void
+        */
+       private function initSchema() {
+               $dbw =& wfGetDB( DB_MASTER );
+               
+               $dbw->query("CREATE TABLE IF NOT EXISTS 
".$dbw->tableName("fptc_associationrules")." (
+                                       `rule_id` int(11) NOT NULL 
auto_increment,
+                                       `p_id` int(8) NOT NULL COMMENT 
'Attribute',
+                                       `rule_support` float(5,3) NOT NULL,
+                                       `rule_confidence` float(5,3) NOT NULL,
+                                       PRIMARY KEY  (`rule_id`)
+                                       )");
+               $dbw->query("ALTER TABLE 
".$dbw->tableName("fptc_associationrules")." ADD INDEX ( `p_id` );");
+               $dbw->query("CREATE TABLE IF NOT EXISTS 
".$dbw->tableName("fptc_items")." (
+                                       `o_id` INT( 8 ) NOT NULL ,
+                                       `rule_id` INT NOT NULL ,
+                                       `item_order` TINYINT( 1 ) NOT NULL ,
+                                       PRIMARY KEY ( `o_id` , `rule_id` )
+                                       );");
+       }
+}
\ No newline at end of file

Modified: trunk/extensions/FreqPatternTagCloud/includes/FrequentPattern.php
===================================================================
--- trunk/extensions/FreqPatternTagCloud/includes/FrequentPattern.php   
2011-10-01 20:20:46 UTC (rev 98626)
+++ trunk/extensions/FreqPatternTagCloud/includes/FrequentPattern.php   
2011-10-01 21:18:51 UTC (rev 98627)
@@ -18,14 +18,14 @@
         * 
         * @var float
         */
-       public static $min_confidence = 0.3;
+       public static $min_confidence = 0.1;
        
        /**
         * Minimum support
         * 
         * @var float
         */
-       public static $min_support = 0.2;
+       public static $min_support = 0.05;
        
        
        /**
@@ -37,17 +37,15 @@
        public static function computeAllRules() {
                $dbr =& wfGetDB( DB_SLAVE );
                
-               if (!($res = mysql_query("SELECT smw_id
-                                                       FROM 
".$dbr->tableName("smw_ids")."
-                                                       WHERE smw_namespace = 
102
-                                                       AND LENGTH(smw_iw) = 
0"))) {
-                       throw new SQLException();
-               }
-               while ($row = mysql_fetch_assoc($res)) {
+               $res = $dbr->query("(SELECT smw_id
+                                       FROM ".$dbr->tableName("smw_ids")."
+                                       WHERE smw_namespace = 102
+                                       AND LENGTH(smw_iw) = 0) UNION (SELECT 
0)");
+               while ($row = $res->fetchRow()) {
                        self::computeRules($row['smw_id']);
                }
                
-               mysql_free_result($res);
+               $res->free();
        }
        
        /**
@@ -69,56 +67,65 @@
                }
                
                $dbr =& wfGetDB( DB_SLAVE );
+               $dbw =& wfGetDB( DB_MASTER );
                
                // Compile items = all possible o_ids
-               if (!($res = mysql_query("SELECT GROUP_CONCAT(DISTINCT o_id)
-                                                       FROM 
".$dbr->tableName("smw_rels2")."
-                                                       WHERE p_id = 
".mysql_real_escape_string($attributeId)."
-                                                       GROUP BY p_id"))) {
-                       throw new SQLException();
+               if (!$attributeId) {
+                       $res = $dbr->query("SELECT GROUP_CONCAT(smw_id)
+                                               FROM 
".$dbr->tableName("smw_ids")."
+                                               WHERE smw_namespace = 14
+                                               AND LENGTH(smw_iw) = 0
+                                               GROUP BY smw_namespace");
+               } else {
+                       $res = $dbr->query("SELECT GROUP_CONCAT(DISTINCT o_id)
+                                               FROM 
".$dbr->tableName("smw_rels2")."
+                                               WHERE p_id = 
".mysql_real_escape_string($attributeId)."
+                                               GROUP BY p_id");
                }
-               $row = mysql_fetch_row($res);
+               $row = $res->fetchRow();
                $items = explode(",", $row[0]);
-               mysql_free_result($res);
+               $res->free();
                
                // Compile transactions = all corelated o_ids (by s_id)
-               if (!($res = mysql_query("SELECT GROUP_CONCAT(o_id)
-                                                       FROM 
".$dbr->tableName("smw_rels2")."
-                                                       WHERE p_id = 
".mysql_real_escape_string($attributeId)."
-                                                       GROUP BY s_id"))) {
-                       throw new SQLException();
+               if (!$attributeId) {
+                       $res = $dbr->query("SELECT GROUP_CONCAT(smw_id)
+                                               FROM 
".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("categorylinks")." 
catlinks
+                                               WHERE ids.smw_title = 
catlinks.cl_to
+                                               AND ids.smw_namespace = 14
+                                               GROUP BY catlinks.cl_from");
+               } else {
+                       $res = $dbr->query("SELECT GROUP_CONCAT(o_id)
+                                               FROM 
".$dbr->tableName("smw_rels2")."
+                                               WHERE p_id = 
".mysql_real_escape_string($attributeId)."
+                                               GROUP BY s_id");
                }
                $transactions = array();
-               while ($row = mysql_fetch_row($res)) {
+               while ($row = $res->fetchRow()) {
                        $transactions[] = explode(",", $row[0]);
                }
-               mysql_free_result($res);
+               $res->free();
                
                // Run algorithm
                $algorithm = new FrequentPatternApriori();
                $rules = $algorithm->computeRules($items, $transactions, 
self::$min_support, self::$min_confidence);
                foreach ($rules as $rule) {
                        // Push rules to db
-                       if (!mysql_query("INSERT INTO 
".$dbr->tableName("fptc_associationrules")." (p_id, rule_support, 
rule_confidence)
-                                                               VALUES 
(".mysql_real_escape_string($attributeId).", 
".mysql_real_escape_string($rule->getSupport()).", 
".mysql_real_escape_string($rule->getConfidence()).")")) {
-                               throw new SQLException();
-                       }
-                       $ruleId = mysql_insert_id();
+                       $dbw->query("INSERT INTO 
".$dbw->tableName("fptc_associationrules")." (p_id, rule_support, 
rule_confidence)
+                                               VALUES 
(".mysql_real_escape_string($attributeId).", 
".mysql_real_escape_string($rule->getSupport()).", 
".mysql_real_escape_string($rule->getConfidence()).")");
+                       $ruleId = $dbw->insertId();
                        
                        foreach ($rule->getAssumption() as $item) {
-                               if (!mysql_query("INSERT INTO 
".$dbr->tableName("fptc_items")." (o_id, rule_id, item_order)
-                                                               VALUES 
(".mysql_real_escape_string($item).", ".mysql_real_escape_string($ruleId).", 
0)")) {
-                                       throw new SQLException();
-                               }
+                               $dbw->query("INSERT INTO 
".$dbw->tableName("fptc_items")." (o_id, rule_id, item_order)
+                                                       VALUES 
(".mysql_real_escape_string($item).", ".mysql_real_escape_string($ruleId).", 
0)");
                        }
                        
                        foreach ($rule->getConclusion() as $item) {
-                               if (!mysql_query("INSERT INTO 
".$dbr->tableName("fptc_items")." (o_id, rule_id, item_order)
-                                                               VALUES 
(".mysql_real_escape_string($item).", ".mysql_real_escape_string($ruleId).", 
1)")) {
-                                       throw new SQLException();
-                               }
+                               $dbw->query("INSERT INTO 
".$dbw->tableName("fptc_items")." (o_id, rule_id, item_order)
+                                                       VALUES 
(".mysql_real_escape_string($item).", ".mysql_real_escape_string($ruleId).", 
1)");
                        }
                }
+               
+               $dbw->commit();
        }
        
        /**
@@ -128,11 +135,10 @@
         * @throws SQLException  
         */
        public static function deleteAllRules() {
-               $dbr =& wfGetDB( DB_SLAVE );
+               $dbw =& wfGetDB( DB_MASTER );
                
-               if (!mysql_query("DELETE FROM 
".$dbr->tableName("fptc_associationrules"))) {
-                       throw new SQLException();
-               }
+               $dbw->query("DELETE FROM 
".$dbw->tableName("fptc_associationrules"));
+               $dbw->query("DELETE FROM ".$dbw->tableName("fptc_items"));
        }
        
        /**
@@ -147,60 +153,64 @@
                $dbr =& wfGetDB( DB_SLAVE );
                
                // Get id of attribute
-               if (!($res = mysql_query("SELECT smw_id
-                                                       FROM 
".$dbr->tableName("smw_ids")."
-                                                       WHERE smw_title = 
'".mysql_real_escape_string($attribute)."'
-                                                       AND smw_namespace = 102
-                                                       AND LENGTH(smw_iw) = 
0"))) {
-                       throw new SQLException();
+               if (wfMsg("categoryname") == $attribute) {
+                       $res = $dbr->query("SELECT 0");
+               } else {
+                       $res = $dbr->query("SELECT smw_id
+                                               FROM 
".$dbr->tableName("smw_ids")."
+                                               WHERE smw_title = 
'".mysql_real_escape_string($attribute)."'
+                                               AND smw_namespace = 102
+                                               AND LENGTH(smw_iw) = 0");
                }
-               $row = mysql_fetch_row($res);
+               $row = $res->fetchRow();
                $attributeId = $row[0];
-               mysql_free_result($res);
+               $res->free();
                
                // Get id of assumption
-               if (!($res = mysql_query("SELECT smw_id
-                                                       FROM 
".$dbr->tableName("smw_ids")."
-                                                       WHERE smw_title = 
'".mysql_real_escape_string($assumption)."'
-                                                       AND smw_namespace = 0
-                                                       AND LENGTH(smw_iw) = 
0"))) {
-                       throw new SQLException();
-               }
-               $row = mysql_fetch_row($res);
+               if (wfMsg("categoryname") == $attribute) {
+                       $res = $dbr->query("SELECT smw_id
+                                               FROM 
".$dbr->tableName("smw_ids")."
+                                               WHERE smw_title = 
'".mysql_real_escape_string($assumption)."'
+                                               AND smw_namespace = 14
+                                               AND LENGTH(smw_iw) = 0");
+               } else {
+                       $res = $dbr->query("SELECT smw_id
+                                               FROM 
".$dbr->tableName("smw_ids")."
+                                               WHERE smw_title = 
'".mysql_real_escape_string($assumption)."'
+                                               AND smw_namespace = 0
+                                               AND LENGTH(smw_iw) = 0");
+               }       
+               $row = $res->fetchRow();
                $assumptionId = $row[0];
-               mysql_free_result($res);
+               $res->free();
                
                // Get rules (only those where assumption is single item)
-               if (!($res = mysql_query("SELECT rules.rule_id, rule_support, 
rule_confidence
-                                                       FROM 
".$dbr->tableName("fptc_associationrules")." rules, 
".$dbr->tableName("fptc_items")." items
-                                                       WHERE rules.rule_id = 
items.rule_id
-                                                       AND item_order = 0
-                                                       AND o_id = 
".mysql_real_escape_string($assumptionId)."
-                                                       AND NOT EXISTS( SELECT 
1 FROM ".$dbr->tableName("fptc_items")." WHERE rule_id = rules.rule_id AND 
item_order = 0 AND o_id != items.o_id )
-                                                       ORDER BY rule_support 
DESC, rule_confidence DESC"))) {
-                       throw new SQLException();
-               }
+               $res = $dbr->query("SELECT rules.rule_id, rule_support, 
rule_confidence
+                                       FROM 
".$dbr->tableName("fptc_associationrules")." rules, 
".$dbr->tableName("fptc_items")." items
+                                       WHERE rules.rule_id = items.rule_id
+                                       AND item_order = 0
+                                       AND o_id = 
".mysql_real_escape_string($assumptionId)."
+                                       AND NOT EXISTS( SELECT 1 FROM 
".$dbr->tableName("fptc_items")." WHERE rule_id = rules.rule_id AND item_order 
= 0 AND o_id != items.o_id )
+                                       ORDER BY rule_support DESC, 
rule_confidence DESC");
                $conclusions = array();
-               while ($row = mysql_fetch_assoc($res)) {
+               while ($row = $res->fetchRow()) {
                        // Get conclusions
-                       if (!($resItems = mysql_query("SELECT smw_title
-                                                               FROM 
".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("fptc_items")." items
-                                                               WHERE 
ids.smw_id = items.o_id
-                                                               AND item_order 
= 1
-                                                               AND rule_id = 
".mysql_real_escape_string($row['rule_id'])))) {
-                               throw new SQLException();
-                       }
+                       $resItems = $dbr->query("SELECT smw_title
+                                               FROM 
".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("fptc_items")." items
+                                               WHERE ids.smw_id = items.o_id
+                                               AND item_order = 1
+                                               AND rule_id = 
".mysql_real_escape_string($row['rule_id']));
                        
                        // Only consider rules with single conclusion
-                       if (mysql_num_rows($resItems) > 1) {
+                       if ($resItems->numRows() > 1) {
                                continue;
                        }
-                       $rowItem = mysql_fetch_assoc($resItems);
+                       $rowItem = $resItems->fetchRow();
                        $conclusions[] = $rowItem['smw_title'];
-
-                       mysql_free_result($resItems);
+                       
+                       $resItems->free();
                }
-               mysql_free_result($res);
+               $res->free();
                
                return $conclusions;
        }
@@ -217,22 +227,18 @@
                $dbr =& wfGetDB( DB_SLAVE );
                
                // Get rules
-               if (!($res = mysql_query("SELECT smw_title, rule_id, 
rule_support, rule_confidence
-                                                       FROM 
".$dbr->tableName("smw_ids")." ids, 
".$dbr->tableName("fptc_associationrules")." rules
-                                                       WHERE ids.smw_id = 
rules.p_id"))) {
-                       throw new SQLException();
-               }
-               while ($row = mysql_fetch_assoc($res)) {
+               $res = $dbr->query("SELECT smw_title, rule_id, rule_support, 
rule_confidence
+                                       FROM ".$dbr->tableName("smw_ids")." 
ids, ".$dbr->tableName("fptc_associationrules")." rules
+                                       WHERE ids.smw_id = rules.p_id");
+               while ($row = $res->fetchRow()) {
                        // Get items
-                       if (!($resItems = mysql_query("SELECT smw_title, 
item_order
-                                                               FROM 
".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("fptc_items")." items
-                                                               WHERE 
ids.smw_id = items.o_id
-                                                               AND rule_id = 
".mysql_real_escape_string($row['rule_id'])))) {
-                               throw new SQLException();
-                       }
+                       $resItems = $dbr->query("SELECT smw_title, item_order
+                                               FROM 
".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("fptc_items")." items
+                                               WHERE ids.smw_id = items.o_id
+                                               AND rule_id = 
".mysql_real_escape_string($row['rule_id']));
                        $assumption = array();
                        $conclusion = array();
-                       while ($rowItem = mysql_fetch_assoc($resItems)) {
+                       while ($rowItem = $resItems->fetchRow()) {
                                if ($rowItem['item_order'] == '0') {
                                        $assumption[] = $rowItem['smw_title'];
                                } else {
@@ -243,8 +249,6 @@
                        // Display rule
                        $wgOut->addWikiText(sprintf("%s: '%s' =&gt; '%s' (Sup: 
%0.2f, Conf: %0.2f)\n", $row['smw_title'], implode(",", $assumption), 
implode(",", $conclusion), $row['rule_support'], $row['rule_confidence']));
                }
-               mysql_free_result($res);
+               $res->free();
        }
-}
-
-?>
\ No newline at end of file
+}
\ No newline at end of file

Modified: trunk/extensions/FreqPatternTagCloud/includes/Proposal.php
===================================================================
--- trunk/extensions/FreqPatternTagCloud/includes/Proposal.php  2011-10-01 
20:20:46 UTC (rev 98626)
+++ trunk/extensions/FreqPatternTagCloud/includes/Proposal.php  2011-10-01 
21:18:51 UTC (rev 98627)
@@ -8,17 +8,17 @@
 * @author Andreas Fay, University of Heidelberg
 * @version 1.0
 */
- include_once("exceptions/InvalidAttributeException.php");
- 
- class Proposal {
-       
-       /**
+include_once("exceptions/InvalidAttributeException.php");
+
+class Proposal {
+       
+       /**
        * Attribute name for search
-       *
+               *
        * @var string 
        */
        private $_attribute;
-
+       
        /**
        * Constructor
        *
@@ -30,33 +30,35 @@
                $this->_attribute = $attribute;
        }
        
-       /**
-        * Gets the available proposals computed with wildcard %
-        *
-        * @return array Array of attributes
-        */
+       /**
+       * Gets the available proposals computed with wildcard %
+       *
+       * @return array Array of attributes
+       */
        public function getProposalWithWildcard() {
                $dbr =& wfGetDB( DB_SLAVE );
                
                $attribute = $this->getAttribute();
                
                // Search with wildcard '%'
-               if (!($res = mysql_query("SELECT smw_id, smw_title
-                                                       FROM 
".$dbr->tableName("smw_ids")."
-                                                       WHERE smw_namespace = 
102
-                                                       AND LENGTH(smw_iw) = 0
-                                                       AND smw_title LIKE 
'%".mysql_real_escape_string($attribute)."%'"))) {
-                       
-                       throw new SQLException();
-               }
+               $res = $dbr->query("SELECT smw_id, smw_title
+                                       FROM ".$dbr->tableName("smw_ids")."
+                                       WHERE smw_namespace = 102
+                                       AND LENGTH(smw_iw) = 0
+                                       AND smw_title LIKE 
'%".mysql_real_escape_string($attribute)."%'");
                
                $attributes = array();
                
-               while ($row = mysql_fetch_assoc($res)) {
+               while ($row = $res->fetchRow()) {
                        $attributes[] = $row['smw_title'];              
                }
                
-               mysql_free_result($res);
+               // Category
+               if (strpos(wfMsg("categoryname"), $attribute) !== false) {
+                       $attributes[] = sprintf("%s", wfMsg("categoryname"));
+               }
+               
+               $res->free();
                return $attributes;
        }
        
@@ -73,41 +75,45 @@
                $endAttribut = substr 
($attribute,strlen($attribute)-2,strlen($attribute));
                
                // Search with regexp for related attributes with the same 
beginning 
-               if (!($res = mysql_query("SELECT smw_id, smw_title
-                                                       FROM 
".$dbr->tableName("smw_ids")."
-                                                       WHERE smw_namespace = 
102
-                                                       AND LENGTH(smw_iw) = 0
-                                                       AND smw_title REGEXP 
'^".$beginAttribut."'"))) {
-                       
-                       throw new SQLException();
-               }
+               $res = $dbr->query("SELECT smw_id, smw_title
+                                       FROM ".$dbr->tableName("smw_ids")."
+                                       WHERE smw_namespace = 102
+                                       AND LENGTH(smw_iw) = 0
+                                       AND smw_title REGEXP 
'^".$beginAttribut."'");
                
                $attributes_1 = array();
                
-               while ($row = mysql_fetch_assoc($res)) {
+               while ($row = $res->fetchRow()) {
                        $attributes_1[] = $row['smw_title'];            
                }
                
-               // Search with regexp for related attributes with the same 
ending 
-               if (!($res = mysql_query("SELECT smw_id, smw_title
-                                                       FROM 
".$dbr->tableName("smw_ids")."
-                                                       WHERE smw_namespace = 
102
-                                                       AND LENGTH(smw_iw) = 0
-                                                       AND smw_title REGEXP 
'".$endAttribut."$'"))) {
-                       
-                       throw new SQLException();
+               // Category
+               if (strpos(wfMsg("categoryname"), $attribute) === 0) {
+                       $attributes_1[] = sprintf("%s", wfMsg("categoryname"));
                }
                
+               // Search with regexp for related attributes with the same 
ending 
+               $res = $dbr->query("SELECT smw_id, smw_title
+                                       FROM ".$dbr->tableName("smw_ids")."
+                                       WHERE smw_namespace = 102
+                                       AND LENGTH(smw_iw) = 0
+                                       AND smw_title REGEXP 
'".$endAttribut."$'");
+               
                $attributes_2 = array();
                
-               while ($row = mysql_fetch_assoc($res)) {
+               while ($row = $res->fetchRow()) {
                        $attributes_2[] = $row['smw_title'];            
                }
                
+               // Category
+               if (strpos(wfMsg("categoryname"), $attribute) === 
strlen(wfMsg("categoryname")) - strlen($attribute)) {
+                       $attributes_2[] = sprintf("%s", wfMsg("categoryname"));
+               }
+               
                // Merge both arrays for one return
                $attributes = array_merge($attributes_1, $attributes_2);
                
-               mysql_free_result($res);
+               $res->free();
                return $attributes;
        }
        
@@ -129,25 +135,27 @@
                $endAttribut = substr 
($attribute,strlen($attribute)-2,strlen($attribute));
                
                // Search for related attributes and attributes with the same 
beginning or ending 
-               if (!($res = mysql_query("SELECT DISTINCT smw_title
-                                                       FROM 
".$dbr->tableName("smw_ids")."
-                                                       WHERE smw_namespace = 
102
-                                                       AND LENGTH(smw_iw) = 0
-                                                       AND ((smw_title REGEXP 
'^".$beginAttribut."')
-                                                       OR (smw_title REGEXP 
'".$endAttribut."$')
-                                                       OR (smw_title LIKE 
'%".mysql_real_escape_string($attribute)."%'))
-                                                       ORDER BY smw_title 
asc"))) {
-                       
-                       throw new SQLException();
-               }
+               $res = $dbr->query("SELECT DISTINCT smw_title
+                                       FROM ".$dbr->tableName("smw_ids")."
+                                       WHERE smw_namespace = 102
+                                       AND LENGTH(smw_iw) = 0
+                                       AND ((smw_title REGEXP 
'^".$beginAttribut."')
+                                       OR (smw_title REGEXP 
'".$endAttribut."$')
+                                       OR (smw_title LIKE 
'%".mysql_real_escape_string($attribute)."%'))
+                                       ORDER BY smw_title asc");
                
                $attributes = array();
                
-               while ($row = mysql_fetch_assoc($res)) {
+               while ($row = $res->fetchRow()) {
                        $attributes[] = $row['smw_title'];              
                }
                
-               mysql_free_result($res);
+               // Category
+               if (strpos(wfMsg("categoryname"), $beginAttribut) === 0 || 
strpos(wfMsg("categoryname"), $endAttribut) === strlen(wfMsg("categoryname")) - 
strlen($endAttribut) || strpos(wfMsg("categoryname"), $attribute) !== false) {
+                       $attributes[] = sprintf("%s", wfMsg("categoryname"));
+               }
+               
+               $res->free();
                return $attributes;
        }
        
@@ -161,4 +169,3 @@
        }
 }
 
-?>

Modified: trunk/extensions/FreqPatternTagCloud/includes/Search.php
===================================================================
--- trunk/extensions/FreqPatternTagCloud/includes/Search.php    2011-10-01 
20:20:46 UTC (rev 98626)
+++ trunk/extensions/FreqPatternTagCloud/includes/Search.php    2011-10-01 
21:18:51 UTC (rev 98627)
@@ -17,7 +17,7 @@
        * @var string 
        */
        private $_attribute;
-
+       
        /**
        * Constructor
        *
@@ -31,7 +31,7 @@
                        throw new InvalidAttributeException($attribute);
                }
        }
-
+       
        /**
         * Checks whether attribute is correct, i.e. it exists in database; if 
yes it fetches the name of the attribute
         *
@@ -39,30 +39,33 @@
         * @return bool 
         */
        private function attributeAvailable($attribute) {
+               // Category
+               if (wfMsg("categoryname") == $attribute) {
+                       return true;
+               }
+               
                $dbr = & wfGetDB(DB_SLAVE);
-
-               if (!($res = mysql_query("SELECT smw_title
-                                                                       FROM " 
. $dbr->tableName("smw_ids") . "
-                                                                       WHERE 
smw_namespace = 102
-                                                                       AND 
LENGTH(smw_iw) = 0
-                                                                       AND 
smw_title = '" . mysql_real_escape_string($attribute) . "'"))) {
-                       throw new SQLException();
-               }
-
-               if (mysql_num_rows($res) == 0) {
+               
+               $res = $dbr->query("SELECT smw_title
+                                       FROM " . $dbr->tableName("smw_ids") . "
+                                       WHERE smw_namespace = 102
+                                       AND LENGTH(smw_iw) = 0
+                                       AND smw_title = '" . 
mysql_real_escape_string($attribute) . "'");
+               
+               if ($res->numRows() == 0) {
                        // Attribute not found
                        return false;
                }
-
-               $row = mysql_fetch_row($res);
-
+               
+               $row = $res->fetchRow();
+               
                // Assign name
                $this->_attribute = $row[0];
-
-               mysql_free_result($res);
+               
+               $res->free();
                return true;
        }
-
+       
        /**
         * Gets the available Attribute
         *
@@ -72,4 +75,3 @@
                return $this->_attribute;
        }
 }
-?>

Modified: trunk/extensions/FreqPatternTagCloud/includes/Tag.php
===================================================================
--- trunk/extensions/FreqPatternTagCloud/includes/Tag.php       2011-10-01 
20:20:46 UTC (rev 98626)
+++ trunk/extensions/FreqPatternTagCloud/includes/Tag.php       2011-10-01 
21:18:51 UTC (rev 98627)
@@ -77,5 +77,3 @@
                return $this->_value;
        }
 }
-
-?>
\ No newline at end of file

Modified: trunk/extensions/FreqPatternTagCloud/includes/TagCloud.php
===================================================================
--- trunk/extensions/FreqPatternTagCloud/includes/TagCloud.php  2011-10-01 
20:20:46 UTC (rev 98626)
+++ trunk/extensions/FreqPatternTagCloud/includes/TagCloud.php  2011-10-01 
21:18:51 UTC (rev 98627)
@@ -52,27 +52,30 @@
         * @return bool 
         */
        private function checkAttribute($attribute) {
+               // Category
+               if (wfMsg("categoryname") == $attribute) {
+                       return true;
+               }
+               
                $dbr =& wfGetDB( DB_SLAVE );
                
-               if (!($res = mysql_query("SELECT smw_id
-                                                       FROM 
".$dbr->tableName("smw_ids")."
-                                                       WHERE smw_namespace = 
102
-                                                       AND LENGTH(smw_iw) = 0
-                                                       AND smw_title = 
'".mysql_real_escape_string($attribute)."'"))) {
-                       throw new SQLException();
-               }
+               $res = $dbr->query("SELECT smw_id
+                                       FROM ".$dbr->tableName("smw_ids")."
+                                       WHERE smw_namespace = 102
+                                       AND LENGTH(smw_iw) = 0
+                                       AND smw_title = 
'".mysql_real_escape_string($attribute)."'");
                
-               if (mysql_num_rows($res) == 0) {
+               if ($res->numRows() == 0) {
                        // Attribute not found
                        return false;
                }
                
-               $row = mysql_fetch_row($res);
+               $row = $res->fetchRow();
                
                // Assign id
                $this->_attributeId = $row[0];
                
-               mysql_free_result($res);
+               $res->free();
                
                return true;
        }
@@ -87,15 +90,18 @@
                $dbr =& wfGetDB( DB_SLAVE );
                
                // Get overall number of attribute values
-               if (!($res = mysql_query("SELECT COUNT(1)
-                                                       FROM 
".$dbr->tableName("smw_rels2")."
-                                                       WHERE p_id = 
".mysql_real_escape_string($this->_attributeId)))) {
-                       throw new SQLException();
+               if (!$this->_attributeId) {
+                       $res = $dbr->query("SELECT SUM(cat_pages)
+                                               FROM 
".$dbr->tableName("category"));
+               } else {
+                       $res = $dbr->query("SELECT COUNT(1)
+                                               FROM 
".$dbr->tableName("smw_rels2")."
+                                               WHERE p_id = 
".mysql_real_escape_string($this->_attributeId));
                }
                
-               $row = mysql_fetch_row($res);
+               $row = $res->fetchRow();
                $numValues = $row[0];
-               mysql_free_result($res);
+               $res->free();
                
                if ($numValues == 0) {
                        // Abort because no tags available
@@ -103,26 +109,30 @@
                }
                
                // Get tags
-               if (!($res = mysql_query("SELECT smw_id, smw_title, (SELECT 
COUNT(1) FROM ".$dbr->tableName("smw_rels2")." WHERE o_id = smw_id AND p_id = 
".mysql_real_escape_string($this->_attributeId).")/$numValues AS rate
-                                                       FROM 
".$dbr->tableName("smw_ids")."
-                                                       WHERE smw_namespace = 0
-                                                       AND LENGTH(smw_iw) = 0
-                                                       AND smw_id <> 
".mysql_real_escape_string($this->_attributeId)."
-                                                       ORDER BY smw_title"))) {
-                       throw new SQLException();
+               if (!$this->_attributeId) {
+                       $res = $dbr->query("SELECT smw_id, smw_title, (SELECT 
cat_pages FROM ".$dbr->tableName("category")." WHERE cat_title = 
smw_title)/$numValues AS rate
+                                               FROM 
".$dbr->tableName("smw_ids")."
+                                               WHERE smw_namespace = 14
+                                               AND LENGTH(smw_iw) = 0
+                                               ORDER BY smw_title");
+               } else {
+                       $res = $dbr->query("SELECT smw_id, smw_title, (SELECT 
COUNT(1) FROM ".$dbr->tableName("smw_rels2")." WHERE o_id = smw_id AND p_id = 
".mysql_real_escape_string($this->_attributeId).")/$numValues AS rate
+                                               FROM 
".$dbr->tableName("smw_ids")."
+                                               WHERE smw_namespace = 0
+                                               AND LENGTH(smw_iw) = 0
+                                               AND smw_id <> 
".mysql_real_escape_string($this->_attributeId)."
+                                               ORDER BY smw_title");
                }
                
                $tags = array();
-               while ($row = mysql_fetch_assoc($res)) {
+               while ($row = $res->fetchRow()) {
                        if (floatval($row['rate']) > 0) {
                                // Only consider relevant tags (because query 
also fetches tags that do not belong to desired attribute
                                $tags[] = new Tag(intval($row['smw_id']), 
$row['smw_title'], floatval($row['rate']));
                        }
                }
-               mysql_free_result($res);
+               $res->free();
                
                return $tags;
        }
-}
-
-?>
\ No newline at end of file
+}
\ No newline at end of file

Modified: 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentItemset.php
===================================================================
--- 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentItemset.php   
    2011-10-01 20:20:46 UTC (rev 98626)
+++ 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentItemset.php   
    2011-10-01 21:18:51 UTC (rev 98627)
@@ -66,5 +66,3 @@
                $this->_support = $support;
        }
 }
-
-?>
\ No newline at end of file

Modified: 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternAlgorithm.php
===================================================================
--- 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternAlgorithm.php
      2011-10-01 20:20:46 UTC (rev 98626)
+++ 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternAlgorithm.php
      2011-10-01 21:18:51 UTC (rev 98627)
@@ -140,5 +140,3 @@
                return $rules;
        }
 }
-
-?>
\ No newline at end of file

Modified: 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternApriori.php
===================================================================
--- 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternApriori.php
        2011-10-01 20:20:46 UTC (rev 98626)
+++ 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternApriori.php
        2011-10-01 21:18:51 UTC (rev 98627)
@@ -121,5 +121,3 @@
                return $candidates;
        }
 }
-
-?>
\ No newline at end of file

Modified: 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternRule.php
===================================================================
--- 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternRule.php
   2011-10-01 20:20:46 UTC (rev 98626)
+++ 
trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternRule.php
   2011-10-01 21:18:51 UTC (rev 98627)
@@ -110,5 +110,3 @@
                $this->_confidence = $confidence;
        }
 }
-
-?>
\ No newline at end of file

Modified: 
trunk/extensions/FreqPatternTagCloud/includes/computation/exceptions/InvalidItemCollectionException.php
===================================================================
--- 
trunk/extensions/FreqPatternTagCloud/includes/computation/exceptions/InvalidItemCollectionException.php
     2011-10-01 20:20:46 UTC (rev 98626)
+++ 
trunk/extensions/FreqPatternTagCloud/includes/computation/exceptions/InvalidItemCollectionException.php
     2011-10-01 21:18:51 UTC (rev 98627)
@@ -20,5 +20,3 @@
                parent::__construct("Item collection must not be empty.");
        }
 }
-
-?>
\ No newline at end of file

Modified: 
trunk/extensions/FreqPatternTagCloud/includes/exceptions/InvalidAttributeException.php
===================================================================
--- 
trunk/extensions/FreqPatternTagCloud/includes/exceptions/InvalidAttributeException.php
      2011-10-01 20:20:46 UTC (rev 98626)
+++ 
trunk/extensions/FreqPatternTagCloud/includes/exceptions/InvalidAttributeException.php
      2011-10-01 21:18:51 UTC (rev 98627)
@@ -21,5 +21,3 @@
                parent::__construct(sprintf("Attribute '%s' not found", 
$attribute ? $attribute : "<empty>"));
        }
 }
-
-?>
\ No newline at end of file

Modified: 
trunk/extensions/FreqPatternTagCloud/includes/exceptions/SQLException.php
===================================================================
--- trunk/extensions/FreqPatternTagCloud/includes/exceptions/SQLException.php   
2011-10-01 20:20:46 UTC (rev 98626)
+++ trunk/extensions/FreqPatternTagCloud/includes/exceptions/SQLException.php   
2011-10-01 21:18:51 UTC (rev 98627)
@@ -14,5 +14,3 @@
                parent::__construct(mysql_error());
        }
 }
-
-?>
\ No newline at end of file

Modified: trunk/extensions/FreqPatternTagCloud/javascripts/main.js
===================================================================
--- trunk/extensions/FreqPatternTagCloud/javascripts/main.js    2011-10-01 
20:20:46 UTC (rev 98626)
+++ trunk/extensions/FreqPatternTagCloud/javascripts/main.js    2011-10-01 
21:18:51 UTC (rev 98627)
@@ -47,7 +47,7 @@
         if (action == "browse") {
             window.location = el.attr("href");
         } else if (action == "browse_similar_tag") {
-            window.location = el.attr("href").replace(new RegExp(el.text()), 
menu.attr("title"));
+            window.location = el.attr("href").replace(new 
RegExp(encodeURI(el.text())), menu.attr("title"));
         }
     });
     


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to