r98627 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98626‎ | r98627 | r98628 >
Date:21:18, 1 October 2011
Author:fptc
Status:deferred (Comments)
Tags:
Comment:
Fixing topics of rev. 96192
Modified paths:
  • /trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.body.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.i18n.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloudMaintenance.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/FrequentPattern.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/Proposal.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/Search.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/Tag.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/TagCloud.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentItemset.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternAlgorithm.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternApriori.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternRule.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/computation/exceptions/InvalidItemCollectionException.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/exceptions/InvalidAttributeException.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/exceptions/SQLException.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/javascripts/main.js (modified) (history)

Diff [purge]

Index: trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.body.php
@@ -16,6 +16,8 @@
1717
1818 const ATTRIBUTE_VALUE_INDEX_SPECIALPAGE = "SearchByProperty";
1919
 20+ const CATEGORY_PAGE = "Category";
 21+
2022 /**
2123 * Maximum font size of tags in px
2224 *
@@ -82,7 +84,6 @@
8385 $this->printSearchResult($par);
8486 }
8587 $this->printTagCloud($par);
86 -
8788 }
8889
8990 /**
@@ -94,23 +95,20 @@
9596 public static function getAttributeSuggestions($currentAttributeValue) {
9697 $dbr =& wfGetDB( DB_SLAVE );
9798
98 - if (!($res = mysql_query("SELECT smw_title
99 - FROM ".$dbr->tableName("smw_ids")."
100 - WHERE smw_namespace = 102
101 - AND LENGTH(smw_iw) = 0
102 - AND smw_title LIKE '%".mysql_real_escape_string($currentAttributeValue)."%'
103 - ORDER BY smw_title
104 - LIMIT 20"))) {
105 - return "[]";
106 - }
 99+ $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));
107100
108101 $attributes = array();
109 - while ($row = mysql_fetch_assoc($res)) {
 102+ while ($row = $res->fetchRow()) {
110103 $attributes[] = sprintf('"%s"', addcslashes($row['smw_title'], '"'));
111104 }
112105
113 - mysql_free_result($res);
 106+ // Category
 107+ if (strpos(wfMsg("categoryname"), $currentAttributeValue) !== false) {
 108+ $attributes[] = sprintf('"%s"', wfMsg("categoryname"));
 109+ }
114110
 111+ $res->free();
 112+
115113 return sprintf("[%s]", implode(", ", $attributes));
116114 }
117115
@@ -124,7 +122,7 @@
125123 $dbr =& wfGetDB( DB_SLAVE );
126124
127125 // Get possible attribute values
128 - if (!($res = mysql_query("SELECT DISTINCT vals.smw_title AS val, atts.smw_title AS att
 126+ $res = $dbr->query("(SELECT DISTINCT vals.smw_title AS val, atts.smw_title AS att
129127 FROM ".$dbr->tableName("smw_ids")." vals, ".$dbr->tableName("smw_ids")." atts, ".$dbr->tableName("smw_rels2")." rels
130128 WHERE vals.smw_id = rels.o_id
131129 AND atts.smw_id = rels.p_id
@@ -134,12 +132,17 @@
135133 AND LENGTH(atts.smw_iw) = 0
136134 AND vals.smw_title LIKE '%".mysql_real_escape_string($currentSearchValue)."%'
137135 ORDER BY vals.smw_title
138 - LIMIT 20"))) {
139 - return "[]";
140 - }
 136+ LIMIT 20) UNION (
 137+ SELECT smw_title AS val, '".wfMsg("categoryname")."' AS att
 138+ FROM ".$dbr->tableName("smw_ids")."
 139+ WHERE smw_title LIKE '%".mysql_real_escape_string($currentSearchValue)."%'
 140+ AND smw_namespace = 14
 141+ ORDER BY smw_title
 142+ LIMIT 10
 143+ )");
141144
142145 $suggestions = array();
143 - while ($row = mysql_fetch_assoc($res)) {
 146+ while ($row = $res->fetchRow()) {
144147 // Apply frequent pattern rules
145148 $conclusions = FrequentPattern::getConclusions($row['att'], $row['val']);
146149
@@ -147,12 +150,12 @@
148151 continue;
149152 } else {
150153 foreach ($conclusions as $conclusion) {
151 - $suggestions[] = sprintf('{ "label": "%s", "category": "'.addcslashes(wfMsg("SearchSuggestionValue"), '"').'" }', addcslashes($conclusion, '"'), addcslashes($row['val'], '"'));
 154+ $suggestions[] = sprintf('{ "label": "%s", "category": "'.addcslashes(wfMsg("searchSuggestionValue"), '"').'" }', addcslashes($conclusion, '"'), addcslashes($row['val'], '"'));
152155 }
153156 }
154157 }
155158
156 - mysql_free_result($res);
 159+ $res->free();
157160
158161 return sprintf("[%s]", implode(", ", $suggestions));
159162 }
@@ -193,11 +196,11 @@
194197 // Add input field
195198 if ($wgUser->isAllowed("protect")) {
196199 $refreshData = sprintf('<div id="fptc_refresh">%s</div>',
197 - $wgOut->parseInline(sprintf('[[:%s:%s|%s]]', self::SPECIALPAGE_PREFIX, self::MAINTENANCE_SPECIALPAGE, wfMsg("RefreshFrequentPatterns"))));
 200+ $wgOut->parseInline(sprintf('[[:%s:%s|%s]]', self::SPECIALPAGE_PREFIX, self::MAINTENANCE_SPECIALPAGE, wfMsg("refreshFrequentPatterns"))));
198201 } else {
199202 $refreshData = "";
200203 }
201 - $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();">
 204+ $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();">
202205 ');
203206
204207 $wgOut->addHTML("<br><br>");
@@ -218,10 +221,10 @@
219222 // Context menu
220223 $wgOut->addHTML('<ul id="fptc_contextMenu" class="contextMenu">
221224 <li class="browse">
222 - <a href="#browse">'.wfMsg("ContextMenu_Browse").'</a>
 225+ <a href="#browse">'.wfMsg("contextMenu_Browse").'</a>
223226 </li>
224227 <li class="suggestions separator">
225 - '.wfMsg("ContextMenu_SimilarTags").':
 228+ '.wfMsg("contextMenu_SimilarTags").':
226229 </li>
227230 </ul>');
228231
@@ -234,7 +237,7 @@
235238 } catch (InvalidAttributeException $e) {
236239 if ($attribute) {
237240 // Attribute not found -> show error
238 - $wgOut->addHTML('<span style="color:red; font-weight:bold;">'.wfMsg("InvalidAttribute").'</span>');
 241+ $wgOut->addHTML('<span style="color:red; font-weight:bold;">'.wfMsg("invalidAttribute").'</span>');
239242 }
240243 }
241244 }
@@ -251,7 +254,9 @@
252255
253256 $wgOut->addHTML(sprintf('<div class="fptc_tag" style="font-size:%dpx;">%s</div>',
254257 $this->fontSizeMin + ($this->fontSizeMax - $this->fontSizeMin) * $tag->getRate(),
255 - $wgOut->parseInline(sprintf("[[:%s:%s/%s/%s|%s]]", self::SPECIALPAGE_PREFIX, self::ATTRIBUTE_VALUE_INDEX_SPECIALPAGE, $attribute, $tag->getValue(), $tag->getValue()))));
 258+ $attribute == wfMsg("categoryname")
 259+ ? $wgOut->parseInline(sprintf("[[:%s:%s|%s]]", self::CATEGORY_PAGE, $tag->getValue(), $tag->getValue()))
 260+ : $wgOut->parseInline(sprintf("[[:%s:%s/%s/%s|%s]]", self::SPECIALPAGE_PREFIX, self::ATTRIBUTE_VALUE_INDEX_SPECIALPAGE, $attribute, $tag->getValue(), $tag->getValue()))));
256261 }
257262
258263 /** Prints the result of the search for attribute <code>attribute</code> to <code>$wgOut</code>
@@ -274,7 +279,7 @@
275280 try {
276281 // Only if suggestions found
277282 if ($proposal->getProposal()) {
278 - $wgOut->addHTML(wfMsg("Suggestion"));
 283+ $wgOut->addHTML(wfMsg("suggestion"));
279284 }
280285 $w=1;
281286 foreach ($proposal->getProposal() as $possibleAttribute) {
@@ -287,7 +292,7 @@
288293 }
289294
290295 } catch (InvalidAttributeException $e) {
291 - $wgOut->addHTML(wfMsg("NoSuggestion"));
 296+ $wgOut->addHTML(wfMsg("noSuggestion"));
292297 }
293298 if ($proposal->getProposal()) {
294299 $wgOut->addHTML("<br><br>");
@@ -296,6 +301,4 @@
297302 }
298303 }
299304 }
300 -}
301 -
302 -?>
\ No newline at end of file
 305+}
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.i18n.php
@@ -12,38 +12,39 @@
1313 $messages = array();
1414
1515 $messages['en'] = array(
16 - "ContextMenu_Browse" => "Browse Pages With This Value",
17 - "ContextMenu_SimilarTags" => "Similar Tags",
18 - "FormAttributeName" => "Property",
19 - "FormSubmitButton" => "Submit",
 16+ "categoryname" => "Category",
 17+ "contextMenu_Browse" => "Browse Pages With This Value",
 18+ "contextMenu_SimilarTags" => "Similar Tags",
 19+ "formAttributeName" => "Property",
 20+ "formSubmitButton" => "Submit",
2021 "freqpatterntagcloud" => "Frequent Pattern Tag Cloud",
2122 "freqpatterntagcloudmaintenance" => "Frequent Pattern Tag Cloud Maintenance",
22 - "InvalidAttribute" => "The entered property is invalid.",
23 - "InsufficientRightsForMaintenance" => "You have to log in as system administrator to view this page.",
24 - "RefreshFrequentPatterns" => "Refresh Data",
25 - "RefreshedFrequentPatterns" => "Frequent pattern rules refreshed.",
26 - "SearchAttributeName" => "Search property",
27 - "SearchButton" => "Search",
28 - "SearchSuggestionValue" => "Similar to \"%s\":",
29 - "Suggestion" => "Do you mean: ",
30 - "NoSuggestion" => "No suggestions found"
 23+ "invalidAttribute" => "The entered property is invalid.",
 24+ "insufficientRightsForMaintenance" => "You have to log in as system administrator to view this page.",
 25+ "refreshFrequentPatterns" => "Refresh Data",
 26+ "refreshedFrequentPatterns" => "Frequent pattern rules refreshed.",
 27+ "searchAttributeName" => "Search property",
 28+ "searchButton" => "Search",
 29+ "searchSuggestionValue" => "Similar to \"%s\":",
 30+ "suggestion" => "Do you mean: ",
 31+ "noSuggestion" => "No suggestions found"
3132 );
3233
3334 $messages['de'] = array(
34 - "ContextMenu_Browse" => "Durchsuche Seiten mit diesem Wert",
35 - "ContextMenu_SimilarTags" => "&Auml;hnliche Tags",
36 - "FormAttributeName" => "Attribut",
37 - "FormSubmitButton" => "Eingabe",
 35+ "categoryname" => "Kategorie",
 36+ "contextMenu_Browse" => "Durchsuche Seiten mit diesem Wert",
 37+ "contextMenu_SimilarTags" => "&Auml;hnliche Tags",
 38+ "formAttributeName" => "Attribut",
 39+ "formSubmitButton" => "Eingabe",
3840 "freqpatterntagcloud" => "Frequent Pattern Tag Cloud",
3941 "freqpatterntagcloudmaintenance" => "Frequent Pattern Tag Cloud Maintenance",
40 - "InvalidAttribute" => "Das eingegebene Attribut ist ung&uuml;ltig.",
41 - "InsufficientRightsForMaintenance" => "Um diese Seite sehen zu k&ouml;nnen m&uuml;ssen Sie als Systemadministrator angemeldet sein.",
42 - "RefreshFrequentPatterns" => "Aktualisierung der Daten",
43 - "RefreshedFrequentPatterns" => "Regeln f&uuml;r frequent pattern neu generiert.",
44 - "SearchAttributeName" => "Suche nach Attribut",
45 - "SearchButton" => "Suche",
46 - "SearchSuggestionValue" => "&Auml;hnlich zu \"%s\":",
47 - "Suggestion" => "Meinten Sie: ",
48 - "NoSuggestion" => "Keine Vorschl&auml;ge gefunden"
49 - );
50 -?>
\ No newline at end of file
 42+ "invalidAttribute" => "Das eingegebene Attribut ist ung&uuml;ltig.",
 43+ "insufficientRightsForMaintenance" => "Um diese Seite sehen zu k&ouml;nnen m&uuml;ssen Sie als Systemadministrator angemeldet sein.",
 44+ "refreshFrequentPatterns" => "Aktualisierung der Daten",
 45+ "refreshedFrequentPatterns" => "Regeln f&uuml;r frequent pattern neu generiert.",
 46+ "searchAttributeName" => "Suche nach Attribut",
 47+ "searchButton" => "Suche",
 48+ "searchSuggestionValue" => "&Auml;hnlich zu \"%s\":",
 49+ "suggestion" => "Meinten Sie: ",
 50+ "noSuggestion" => "Keine Vorschl&auml;ge gefunden"
 51+ );
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php
@@ -39,12 +39,6 @@
4040 'version' => '1.0'
4141 );
4242
43 -// Register hook to create new database to store frequent pattern information
44 -$wgHooks['LoadExtensionSchemaUpdates'][] = 'fptc_updateSchema';
45 -
46 -// Register hook to initialize frequent pattern database
47 -$wgHooks['LoadExtensionSchemaUpdates'][] = 'fptc_initializeRules';
48 -
4943 // Register hook to prepare header files
5044 $wgHooks['BeforePageDisplay'][] = 'fptc_initializeHeaders';
5145
@@ -66,19 +60,6 @@
6761
6862
6963 /**
70 - * Initializes frequent pattern rules
71 - *
72 - * @return bool Success
73 - */
74 -function fptc_initializeRules() {
75 - FrequentPattern::deleteAllRules();
76 - FrequentPattern::computeAllRules();
77 -
78 - return true;
79 -}
80 -
81 -
82 -/**
8364 * Initializes page headers
8465 *
8566 * @return bool Success
@@ -134,37 +115,4 @@
135116 $wgOut->addScript('<script type="text/javascript" src="'.$wgScriptPath.'/extensions/FreqPatternTagCloud/javascripts/main.js"></script>');
136117
137118 return true;
138 -}
139 -
140 -
141 -/**
142 - * Creates database schema
143 - *
144 - * @return bool Success
145 - */
146 -function fptc_updateSchema() {
147 - $dbr =& wfGetDB( DB_SLAVE );
148 -
149 - if (!(mysql_query("CREATE TABLE IF NOT EXISTS `".$dbr->tableName("fptc_associationrules")."` (
150 - `rule_id` int(11) NOT NULL auto_increment,
151 - `p_id` int(8) NOT NULL COMMENT 'Attribute',
152 - `rule_support` float(5,3) NOT NULL,
153 - `rule_confidence` float(5,3) NOT NULL,
154 - PRIMARY KEY (`rule_id`)
155 - );
156 - ALTER TABLE `fptc_associationrules` ADD INDEX ( `p_id` );"))) {
157 - throw new SQLException();
158 - }
159 - if (!(mysql_query("CREATE TABLE IF NOT EXISTS `".$dbr->tableName("fptc_items")."` (
160 - `o_id` INT( 8 ) NOT NULL ,
161 - `rule_id` INT NOT NULL ,
162 - `item_order` TINYINT( 1 ) NOT NULL ,
163 - PRIMARY KEY ( `o_id` , `rule_id` )
164 - );"))) {
165 - throw new SQLException();
166 - }
167 -
168 - return true;
169 -}
170 -
171 -?>
\ No newline at end of file
 119+}
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/includes/Tag.php
@@ -77,5 +77,3 @@
7878 return $this->_value;
7979 }
8080 }
81 -
82 -?>
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/includes/exceptions/InvalidAttributeException.php
@@ -21,5 +21,3 @@
2222 parent::__construct(sprintf("Attribute '%s' not found", $attribute ? $attribute : "<empty>"));
2323 }
2424 }
25 -
26 -?>
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/includes/exceptions/SQLException.php
@@ -14,5 +14,3 @@
1515 parent::__construct(mysql_error());
1616 }
1717 }
18 -
19 -?>
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/includes/computation/exceptions/InvalidItemCollectionException.php
@@ -20,5 +20,3 @@
2121 parent::__construct("Item collection must not be empty.");
2222 }
2323 }
24 -
25 -?>
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternApriori.php
@@ -121,5 +121,3 @@
122122 return $candidates;
123123 }
124124 }
125 -
126 -?>
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternAlgorithm.php
@@ -140,5 +140,3 @@
141141 return $rules;
142142 }
143143 }
144 -
145 -?>
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternRule.php
@@ -110,5 +110,3 @@
111111 $this->_confidence = $confidence;
112112 }
113113 }
114 -
115 -?>
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentItemset.php
@@ -66,5 +66,3 @@
6767 $this->_support = $support;
6868 }
6969 }
70 -
71 -?>
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/includes/Proposal.php
@@ -8,17 +8,17 @@
99 * @author Andreas Fay, University of Heidelberg
1010 * @version 1.0
1111 */
12 - include_once("exceptions/InvalidAttributeException.php");
13 -
14 - class Proposal {
15 -
16 - /**
 12+include_once("exceptions/InvalidAttributeException.php");
 13+
 14+class Proposal {
 15+
 16+ /**
1717 * Attribute name for search
18 - *
 18+ *
1919 * @var string
2020 */
2121 private $_attribute;
22 -
 22+
2323 /**
2424 * Constructor
2525 *
@@ -30,33 +30,35 @@
3131 $this->_attribute = $attribute;
3232 }
3333
34 - /**
35 - * Gets the available proposals computed with wildcard %
36 - *
37 - * @return array Array of attributes
38 - */
 34+ /**
 35+ * Gets the available proposals computed with wildcard %
 36+ *
 37+ * @return array Array of attributes
 38+ */
3939 public function getProposalWithWildcard() {
4040 $dbr =& wfGetDB( DB_SLAVE );
4141
4242 $attribute = $this->getAttribute();
4343
4444 // Search with wildcard '%'
45 - if (!($res = mysql_query("SELECT smw_id, smw_title
46 - FROM ".$dbr->tableName("smw_ids")."
47 - WHERE smw_namespace = 102
48 - AND LENGTH(smw_iw) = 0
49 - AND smw_title LIKE '%".mysql_real_escape_string($attribute)."%'"))) {
50 -
51 - throw new SQLException();
52 - }
 45+ $res = $dbr->query("SELECT smw_id, smw_title
 46+ FROM ".$dbr->tableName("smw_ids")."
 47+ WHERE smw_namespace = 102
 48+ AND LENGTH(smw_iw) = 0
 49+ AND smw_title LIKE '%".mysql_real_escape_string($attribute)."%'");
5350
5451 $attributes = array();
5552
56 - while ($row = mysql_fetch_assoc($res)) {
 53+ while ($row = $res->fetchRow()) {
5754 $attributes[] = $row['smw_title'];
5855 }
5956
60 - mysql_free_result($res);
 57+ // Category
 58+ if (strpos(wfMsg("categoryname"), $attribute) !== false) {
 59+ $attributes[] = sprintf("%s", wfMsg("categoryname"));
 60+ }
 61+
 62+ $res->free();
6163 return $attributes;
6264 }
6365
@@ -73,41 +75,45 @@
7476 $endAttribut = substr ($attribute,strlen($attribute)-2,strlen($attribute));
7577
7678 // Search with regexp for related attributes with the same beginning
77 - if (!($res = mysql_query("SELECT smw_id, smw_title
78 - FROM ".$dbr->tableName("smw_ids")."
79 - WHERE smw_namespace = 102
80 - AND LENGTH(smw_iw) = 0
81 - AND smw_title REGEXP '^".$beginAttribut."'"))) {
82 -
83 - throw new SQLException();
84 - }
 79+ $res = $dbr->query("SELECT smw_id, smw_title
 80+ FROM ".$dbr->tableName("smw_ids")."
 81+ WHERE smw_namespace = 102
 82+ AND LENGTH(smw_iw) = 0
 83+ AND smw_title REGEXP '^".$beginAttribut."'");
8584
8685 $attributes_1 = array();
8786
88 - while ($row = mysql_fetch_assoc($res)) {
 87+ while ($row = $res->fetchRow()) {
8988 $attributes_1[] = $row['smw_title'];
9089 }
9190
92 - // Search with regexp for related attributes with the same ending
93 - if (!($res = mysql_query("SELECT smw_id, smw_title
94 - FROM ".$dbr->tableName("smw_ids")."
95 - WHERE smw_namespace = 102
96 - AND LENGTH(smw_iw) = 0
97 - AND smw_title REGEXP '".$endAttribut."$'"))) {
98 -
99 - throw new SQLException();
 91+ // Category
 92+ if (strpos(wfMsg("categoryname"), $attribute) === 0) {
 93+ $attributes_1[] = sprintf("%s", wfMsg("categoryname"));
10094 }
10195
 96+ // Search with regexp for related attributes with the same ending
 97+ $res = $dbr->query("SELECT smw_id, smw_title
 98+ FROM ".$dbr->tableName("smw_ids")."
 99+ WHERE smw_namespace = 102
 100+ AND LENGTH(smw_iw) = 0
 101+ AND smw_title REGEXP '".$endAttribut."$'");
 102+
102103 $attributes_2 = array();
103104
104 - while ($row = mysql_fetch_assoc($res)) {
 105+ while ($row = $res->fetchRow()) {
105106 $attributes_2[] = $row['smw_title'];
106107 }
107108
 109+ // Category
 110+ if (strpos(wfMsg("categoryname"), $attribute) === strlen(wfMsg("categoryname")) - strlen($attribute)) {
 111+ $attributes_2[] = sprintf("%s", wfMsg("categoryname"));
 112+ }
 113+
108114 // Merge both arrays for one return
109115 $attributes = array_merge($attributes_1, $attributes_2);
110116
111 - mysql_free_result($res);
 117+ $res->free();
112118 return $attributes;
113119 }
114120
@@ -129,25 +135,27 @@
130136 $endAttribut = substr ($attribute,strlen($attribute)-2,strlen($attribute));
131137
132138 // Search for related attributes and attributes with the same beginning or ending
133 - if (!($res = mysql_query("SELECT DISTINCT smw_title
134 - FROM ".$dbr->tableName("smw_ids")."
135 - WHERE smw_namespace = 102
136 - AND LENGTH(smw_iw) = 0
137 - AND ((smw_title REGEXP '^".$beginAttribut."')
138 - OR (smw_title REGEXP '".$endAttribut."$')
139 - OR (smw_title LIKE '%".mysql_real_escape_string($attribute)."%'))
140 - ORDER BY smw_title asc"))) {
141 -
142 - throw new SQLException();
143 - }
 139+ $res = $dbr->query("SELECT DISTINCT smw_title
 140+ FROM ".$dbr->tableName("smw_ids")."
 141+ WHERE smw_namespace = 102
 142+ AND LENGTH(smw_iw) = 0
 143+ AND ((smw_title REGEXP '^".$beginAttribut."')
 144+ OR (smw_title REGEXP '".$endAttribut."$')
 145+ OR (smw_title LIKE '%".mysql_real_escape_string($attribute)."%'))
 146+ ORDER BY smw_title asc");
144147
145148 $attributes = array();
146149
147 - while ($row = mysql_fetch_assoc($res)) {
 150+ while ($row = $res->fetchRow()) {
148151 $attributes[] = $row['smw_title'];
149152 }
150153
151 - mysql_free_result($res);
 154+ // Category
 155+ if (strpos(wfMsg("categoryname"), $beginAttribut) === 0 || strpos(wfMsg("categoryname"), $endAttribut) === strlen(wfMsg("categoryname")) - strlen($endAttribut) || strpos(wfMsg("categoryname"), $attribute) !== false) {
 156+ $attributes[] = sprintf("%s", wfMsg("categoryname"));
 157+ }
 158+
 159+ $res->free();
152160 return $attributes;
153161 }
154162
@@ -161,4 +169,3 @@
162170 }
163171 }
164172
165 -?>
Index: trunk/extensions/FreqPatternTagCloud/includes/TagCloud.php
@@ -52,27 +52,30 @@
5353 * @return bool
5454 */
5555 private function checkAttribute($attribute) {
 56+ // Category
 57+ if (wfMsg("categoryname") == $attribute) {
 58+ return true;
 59+ }
 60+
5661 $dbr =& wfGetDB( DB_SLAVE );
5762
58 - if (!($res = mysql_query("SELECT smw_id
59 - FROM ".$dbr->tableName("smw_ids")."
60 - WHERE smw_namespace = 102
61 - AND LENGTH(smw_iw) = 0
62 - AND smw_title = '".mysql_real_escape_string($attribute)."'"))) {
63 - throw new SQLException();
64 - }
 63+ $res = $dbr->query("SELECT smw_id
 64+ FROM ".$dbr->tableName("smw_ids")."
 65+ WHERE smw_namespace = 102
 66+ AND LENGTH(smw_iw) = 0
 67+ AND smw_title = '".mysql_real_escape_string($attribute)."'");
6568
66 - if (mysql_num_rows($res) == 0) {
 69+ if ($res->numRows() == 0) {
6770 // Attribute not found
6871 return false;
6972 }
7073
71 - $row = mysql_fetch_row($res);
 74+ $row = $res->fetchRow();
7275
7376 // Assign id
7477 $this->_attributeId = $row[0];
7578
76 - mysql_free_result($res);
 79+ $res->free();
7780
7881 return true;
7982 }
@@ -87,15 +90,18 @@
8891 $dbr =& wfGetDB( DB_SLAVE );
8992
9093 // Get overall number of attribute values
91 - if (!($res = mysql_query("SELECT COUNT(1)
92 - FROM ".$dbr->tableName("smw_rels2")."
93 - WHERE p_id = ".mysql_real_escape_string($this->_attributeId)))) {
94 - throw new SQLException();
 94+ if (!$this->_attributeId) {
 95+ $res = $dbr->query("SELECT SUM(cat_pages)
 96+ FROM ".$dbr->tableName("category"));
 97+ } else {
 98+ $res = $dbr->query("SELECT COUNT(1)
 99+ FROM ".$dbr->tableName("smw_rels2")."
 100+ WHERE p_id = ".mysql_real_escape_string($this->_attributeId));
95101 }
96102
97 - $row = mysql_fetch_row($res);
 103+ $row = $res->fetchRow();
98104 $numValues = $row[0];
99 - mysql_free_result($res);
 105+ $res->free();
100106
101107 if ($numValues == 0) {
102108 // Abort because no tags available
@@ -103,26 +109,30 @@
104110 }
105111
106112 // Get tags
107 - 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
108 - FROM ".$dbr->tableName("smw_ids")."
109 - WHERE smw_namespace = 0
110 - AND LENGTH(smw_iw) = 0
111 - AND smw_id <> ".mysql_real_escape_string($this->_attributeId)."
112 - ORDER BY smw_title"))) {
113 - throw new SQLException();
 113+ if (!$this->_attributeId) {
 114+ $res = $dbr->query("SELECT smw_id, smw_title, (SELECT cat_pages FROM ".$dbr->tableName("category")." WHERE cat_title = smw_title)/$numValues AS rate
 115+ FROM ".$dbr->tableName("smw_ids")."
 116+ WHERE smw_namespace = 14
 117+ AND LENGTH(smw_iw) = 0
 118+ ORDER BY smw_title");
 119+ } else {
 120+ $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
 121+ FROM ".$dbr->tableName("smw_ids")."
 122+ WHERE smw_namespace = 0
 123+ AND LENGTH(smw_iw) = 0
 124+ AND smw_id <> ".mysql_real_escape_string($this->_attributeId)."
 125+ ORDER BY smw_title");
114126 }
115127
116128 $tags = array();
117 - while ($row = mysql_fetch_assoc($res)) {
 129+ while ($row = $res->fetchRow()) {
118130 if (floatval($row['rate']) > 0) {
119131 // Only consider relevant tags (because query also fetches tags that do not belong to desired attribute
120132 $tags[] = new Tag(intval($row['smw_id']), $row['smw_title'], floatval($row['rate']));
121133 }
122134 }
123 - mysql_free_result($res);
 135+ $res->free();
124136
125137 return $tags;
126138 }
127 -}
128 -
129 -?>
\ No newline at end of file
 139+}
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/includes/Search.php
@@ -17,7 +17,7 @@
1818 * @var string
1919 */
2020 private $_attribute;
21 -
 21+
2222 /**
2323 * Constructor
2424 *
@@ -31,7 +31,7 @@
3232 throw new InvalidAttributeException($attribute);
3333 }
3434 }
35 -
 35+
3636 /**
3737 * Checks whether attribute is correct, i.e. it exists in database; if yes it fetches the name of the attribute
3838 *
@@ -39,30 +39,33 @@
4040 * @return bool
4141 */
4242 private function attributeAvailable($attribute) {
 43+ // Category
 44+ if (wfMsg("categoryname") == $attribute) {
 45+ return true;
 46+ }
 47+
4348 $dbr = & wfGetDB(DB_SLAVE);
44 -
45 - if (!($res = mysql_query("SELECT smw_title
46 - FROM " . $dbr->tableName("smw_ids") . "
47 - WHERE smw_namespace = 102
48 - AND LENGTH(smw_iw) = 0
49 - AND smw_title = '" . mysql_real_escape_string($attribute) . "'"))) {
50 - throw new SQLException();
51 - }
52 -
53 - if (mysql_num_rows($res) == 0) {
 49+
 50+ $res = $dbr->query("SELECT smw_title
 51+ FROM " . $dbr->tableName("smw_ids") . "
 52+ WHERE smw_namespace = 102
 53+ AND LENGTH(smw_iw) = 0
 54+ AND smw_title = '" . mysql_real_escape_string($attribute) . "'");
 55+
 56+ if ($res->numRows() == 0) {
5457 // Attribute not found
5558 return false;
5659 }
57 -
58 - $row = mysql_fetch_row($res);
59 -
 60+
 61+ $row = $res->fetchRow();
 62+
6063 // Assign name
6164 $this->_attribute = $row[0];
62 -
63 - mysql_free_result($res);
 65+
 66+ $res->free();
6467 return true;
6568 }
66 -
 69+
6770 /**
6871 * Gets the available Attribute
6972 *
@@ -72,4 +75,3 @@
7376 return $this->_attribute;
7477 }
7578 }
76 -?>
Index: trunk/extensions/FreqPatternTagCloud/includes/FrequentPattern.php
@@ -18,14 +18,14 @@
1919 *
2020 * @var float
2121 */
22 - public static $min_confidence = 0.3;
 22+ public static $min_confidence = 0.1;
2323
2424 /**
2525 * Minimum support
2626 *
2727 * @var float
2828 */
29 - public static $min_support = 0.2;
 29+ public static $min_support = 0.05;
3030
3131
3232 /**
@@ -37,17 +37,15 @@
3838 public static function computeAllRules() {
3939 $dbr =& wfGetDB( DB_SLAVE );
4040
41 - if (!($res = mysql_query("SELECT smw_id
42 - FROM ".$dbr->tableName("smw_ids")."
43 - WHERE smw_namespace = 102
44 - AND LENGTH(smw_iw) = 0"))) {
45 - throw new SQLException();
46 - }
47 - while ($row = mysql_fetch_assoc($res)) {
 41+ $res = $dbr->query("(SELECT smw_id
 42+ FROM ".$dbr->tableName("smw_ids")."
 43+ WHERE smw_namespace = 102
 44+ AND LENGTH(smw_iw) = 0) UNION (SELECT 0)");
 45+ while ($row = $res->fetchRow()) {
4846 self::computeRules($row['smw_id']);
4947 }
5048
51 - mysql_free_result($res);
 49+ $res->free();
5250 }
5351
5452 /**
@@ -69,56 +67,65 @@
7068 }
7169
7270 $dbr =& wfGetDB( DB_SLAVE );
 71+ $dbw =& wfGetDB( DB_MASTER );
7372
7473 // Compile items = all possible o_ids
75 - if (!($res = mysql_query("SELECT GROUP_CONCAT(DISTINCT o_id)
76 - FROM ".$dbr->tableName("smw_rels2")."
77 - WHERE p_id = ".mysql_real_escape_string($attributeId)."
78 - GROUP BY p_id"))) {
79 - throw new SQLException();
 74+ if (!$attributeId) {
 75+ $res = $dbr->query("SELECT GROUP_CONCAT(smw_id)
 76+ FROM ".$dbr->tableName("smw_ids")."
 77+ WHERE smw_namespace = 14
 78+ AND LENGTH(smw_iw) = 0
 79+ GROUP BY smw_namespace");
 80+ } else {
 81+ $res = $dbr->query("SELECT GROUP_CONCAT(DISTINCT o_id)
 82+ FROM ".$dbr->tableName("smw_rels2")."
 83+ WHERE p_id = ".mysql_real_escape_string($attributeId)."
 84+ GROUP BY p_id");
8085 }
81 - $row = mysql_fetch_row($res);
 86+ $row = $res->fetchRow();
8287 $items = explode(",", $row[0]);
83 - mysql_free_result($res);
 88+ $res->free();
8489
8590 // Compile transactions = all corelated o_ids (by s_id)
86 - if (!($res = mysql_query("SELECT GROUP_CONCAT(o_id)
87 - FROM ".$dbr->tableName("smw_rels2")."
88 - WHERE p_id = ".mysql_real_escape_string($attributeId)."
89 - GROUP BY s_id"))) {
90 - throw new SQLException();
 91+ if (!$attributeId) {
 92+ $res = $dbr->query("SELECT GROUP_CONCAT(smw_id)
 93+ FROM ".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("categorylinks")." catlinks
 94+ WHERE ids.smw_title = catlinks.cl_to
 95+ AND ids.smw_namespace = 14
 96+ GROUP BY catlinks.cl_from");
 97+ } else {
 98+ $res = $dbr->query("SELECT GROUP_CONCAT(o_id)
 99+ FROM ".$dbr->tableName("smw_rels2")."
 100+ WHERE p_id = ".mysql_real_escape_string($attributeId)."
 101+ GROUP BY s_id");
91102 }
92103 $transactions = array();
93 - while ($row = mysql_fetch_row($res)) {
 104+ while ($row = $res->fetchRow()) {
94105 $transactions[] = explode(",", $row[0]);
95106 }
96 - mysql_free_result($res);
 107+ $res->free();
97108
98109 // Run algorithm
99110 $algorithm = new FrequentPatternApriori();
100111 $rules = $algorithm->computeRules($items, $transactions, self::$min_support, self::$min_confidence);
101112 foreach ($rules as $rule) {
102113 // Push rules to db
103 - if (!mysql_query("INSERT INTO ".$dbr->tableName("fptc_associationrules")." (p_id, rule_support, rule_confidence)
104 - VALUES (".mysql_real_escape_string($attributeId).", ".mysql_real_escape_string($rule->getSupport()).", ".mysql_real_escape_string($rule->getConfidence()).")")) {
105 - throw new SQLException();
106 - }
107 - $ruleId = mysql_insert_id();
 114+ $dbw->query("INSERT INTO ".$dbw->tableName("fptc_associationrules")." (p_id, rule_support, rule_confidence)
 115+ VALUES (".mysql_real_escape_string($attributeId).", ".mysql_real_escape_string($rule->getSupport()).", ".mysql_real_escape_string($rule->getConfidence()).")");
 116+ $ruleId = $dbw->insertId();
108117
109118 foreach ($rule->getAssumption() as $item) {
110 - if (!mysql_query("INSERT INTO ".$dbr->tableName("fptc_items")." (o_id, rule_id, item_order)
111 - VALUES (".mysql_real_escape_string($item).", ".mysql_real_escape_string($ruleId).", 0)")) {
112 - throw new SQLException();
113 - }
 119+ $dbw->query("INSERT INTO ".$dbw->tableName("fptc_items")." (o_id, rule_id, item_order)
 120+ VALUES (".mysql_real_escape_string($item).", ".mysql_real_escape_string($ruleId).", 0)");
114121 }
115122
116123 foreach ($rule->getConclusion() as $item) {
117 - if (!mysql_query("INSERT INTO ".$dbr->tableName("fptc_items")." (o_id, rule_id, item_order)
118 - VALUES (".mysql_real_escape_string($item).", ".mysql_real_escape_string($ruleId).", 1)")) {
119 - throw new SQLException();
120 - }
 124+ $dbw->query("INSERT INTO ".$dbw->tableName("fptc_items")." (o_id, rule_id, item_order)
 125+ VALUES (".mysql_real_escape_string($item).", ".mysql_real_escape_string($ruleId).", 1)");
121126 }
122127 }
 128+
 129+ $dbw->commit();
123130 }
124131
125132 /**
@@ -128,11 +135,10 @@
129136 * @throws SQLException
130137 */
131138 public static function deleteAllRules() {
132 - $dbr =& wfGetDB( DB_SLAVE );
 139+ $dbw =& wfGetDB( DB_MASTER );
133140
134 - if (!mysql_query("DELETE FROM ".$dbr->tableName("fptc_associationrules"))) {
135 - throw new SQLException();
136 - }
 141+ $dbw->query("DELETE FROM ".$dbw->tableName("fptc_associationrules"));
 142+ $dbw->query("DELETE FROM ".$dbw->tableName("fptc_items"));
137143 }
138144
139145 /**
@@ -147,60 +153,64 @@
148154 $dbr =& wfGetDB( DB_SLAVE );
149155
150156 // Get id of attribute
151 - if (!($res = mysql_query("SELECT smw_id
152 - FROM ".$dbr->tableName("smw_ids")."
153 - WHERE smw_title = '".mysql_real_escape_string($attribute)."'
154 - AND smw_namespace = 102
155 - AND LENGTH(smw_iw) = 0"))) {
156 - throw new SQLException();
 157+ if (wfMsg("categoryname") == $attribute) {
 158+ $res = $dbr->query("SELECT 0");
 159+ } else {
 160+ $res = $dbr->query("SELECT smw_id
 161+ FROM ".$dbr->tableName("smw_ids")."
 162+ WHERE smw_title = '".mysql_real_escape_string($attribute)."'
 163+ AND smw_namespace = 102
 164+ AND LENGTH(smw_iw) = 0");
157165 }
158 - $row = mysql_fetch_row($res);
 166+ $row = $res->fetchRow();
159167 $attributeId = $row[0];
160 - mysql_free_result($res);
 168+ $res->free();
161169
162170 // Get id of assumption
163 - if (!($res = mysql_query("SELECT smw_id
164 - FROM ".$dbr->tableName("smw_ids")."
165 - WHERE smw_title = '".mysql_real_escape_string($assumption)."'
166 - AND smw_namespace = 0
167 - AND LENGTH(smw_iw) = 0"))) {
168 - throw new SQLException();
169 - }
170 - $row = mysql_fetch_row($res);
 171+ if (wfMsg("categoryname") == $attribute) {
 172+ $res = $dbr->query("SELECT smw_id
 173+ FROM ".$dbr->tableName("smw_ids")."
 174+ WHERE smw_title = '".mysql_real_escape_string($assumption)."'
 175+ AND smw_namespace = 14
 176+ AND LENGTH(smw_iw) = 0");
 177+ } else {
 178+ $res = $dbr->query("SELECT smw_id
 179+ FROM ".$dbr->tableName("smw_ids")."
 180+ WHERE smw_title = '".mysql_real_escape_string($assumption)."'
 181+ AND smw_namespace = 0
 182+ AND LENGTH(smw_iw) = 0");
 183+ }
 184+ $row = $res->fetchRow();
171185 $assumptionId = $row[0];
172 - mysql_free_result($res);
 186+ $res->free();
173187
174188 // Get rules (only those where assumption is single item)
175 - if (!($res = mysql_query("SELECT rules.rule_id, rule_support, rule_confidence
176 - FROM ".$dbr->tableName("fptc_associationrules")." rules, ".$dbr->tableName("fptc_items")." items
177 - WHERE rules.rule_id = items.rule_id
178 - AND item_order = 0
179 - AND o_id = ".mysql_real_escape_string($assumptionId)."
180 - 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 )
181 - ORDER BY rule_support DESC, rule_confidence DESC"))) {
182 - throw new SQLException();
183 - }
 189+ $res = $dbr->query("SELECT rules.rule_id, rule_support, rule_confidence
 190+ FROM ".$dbr->tableName("fptc_associationrules")." rules, ".$dbr->tableName("fptc_items")." items
 191+ WHERE rules.rule_id = items.rule_id
 192+ AND item_order = 0
 193+ AND o_id = ".mysql_real_escape_string($assumptionId)."
 194+ 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 )
 195+ ORDER BY rule_support DESC, rule_confidence DESC");
184196 $conclusions = array();
185 - while ($row = mysql_fetch_assoc($res)) {
 197+ while ($row = $res->fetchRow()) {
186198 // Get conclusions
187 - if (!($resItems = mysql_query("SELECT smw_title
188 - FROM ".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("fptc_items")." items
189 - WHERE ids.smw_id = items.o_id
190 - AND item_order = 1
191 - AND rule_id = ".mysql_real_escape_string($row['rule_id'])))) {
192 - throw new SQLException();
193 - }
 199+ $resItems = $dbr->query("SELECT smw_title
 200+ FROM ".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("fptc_items")." items
 201+ WHERE ids.smw_id = items.o_id
 202+ AND item_order = 1
 203+ AND rule_id = ".mysql_real_escape_string($row['rule_id']));
194204
195205 // Only consider rules with single conclusion
196 - if (mysql_num_rows($resItems) > 1) {
 206+ if ($resItems->numRows() > 1) {
197207 continue;
198208 }
199 - $rowItem = mysql_fetch_assoc($resItems);
 209+ $rowItem = $resItems->fetchRow();
200210 $conclusions[] = $rowItem['smw_title'];
201 -
202 - mysql_free_result($resItems);
 211+
 212+ $resItems->free();
203213 }
204 - mysql_free_result($res);
 214+ $res->free();
205215
206216 return $conclusions;
207217 }
@@ -217,22 +227,18 @@
218228 $dbr =& wfGetDB( DB_SLAVE );
219229
220230 // Get rules
221 - if (!($res = mysql_query("SELECT smw_title, rule_id, rule_support, rule_confidence
222 - FROM ".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("fptc_associationrules")." rules
223 - WHERE ids.smw_id = rules.p_id"))) {
224 - throw new SQLException();
225 - }
226 - while ($row = mysql_fetch_assoc($res)) {
 231+ $res = $dbr->query("SELECT smw_title, rule_id, rule_support, rule_confidence
 232+ FROM ".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("fptc_associationrules")." rules
 233+ WHERE ids.smw_id = rules.p_id");
 234+ while ($row = $res->fetchRow()) {
227235 // Get items
228 - if (!($resItems = mysql_query("SELECT smw_title, item_order
229 - FROM ".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("fptc_items")." items
230 - WHERE ids.smw_id = items.o_id
231 - AND rule_id = ".mysql_real_escape_string($row['rule_id'])))) {
232 - throw new SQLException();
233 - }
 236+ $resItems = $dbr->query("SELECT smw_title, item_order
 237+ FROM ".$dbr->tableName("smw_ids")." ids, ".$dbr->tableName("fptc_items")." items
 238+ WHERE ids.smw_id = items.o_id
 239+ AND rule_id = ".mysql_real_escape_string($row['rule_id']));
234240 $assumption = array();
235241 $conclusion = array();
236 - while ($rowItem = mysql_fetch_assoc($resItems)) {
 242+ while ($rowItem = $resItems->fetchRow()) {
237243 if ($rowItem['item_order'] == '0') {
238244 $assumption[] = $rowItem['smw_title'];
239245 } else {
@@ -243,8 +249,6 @@
244250 // Display rule
245251 $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']));
246252 }
247 - mysql_free_result($res);
 253+ $res->free();
248254 }
249 -}
250 -
251 -?>
\ No newline at end of file
 255+}
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloudMaintenance.php
@@ -29,13 +29,22 @@
3030 */
3131 public function execute($par) {
3232 global $wgOut, $wgUser;
 33+ $dbr =& wfGetDB( DB_SLAVE );
3334
3435 $this->setHeaders();
3536
3637 if (!$wgUser->isAllowed("protect")) {
3738 // No admin
38 - $wgOut->addWikiText(wfMsg("InsufficientRightsForMaintenance"));
 39+ $wgOut->addWikiText(wfMsg("insufficientRightsForMaintenance"));
3940 } else {
 41+ // Check if this call is the first
 42+ try {
 43+ $dbr->query("SELECT COUNT(1) FROM ".$dbr->tableName("fptc_associationrules"));
 44+ } catch (exception $e) {
 45+ // Yes: create database tables
 46+ $this->initSchema();
 47+ }
 48+
4049 // Refresh frequent pattern rules
4150 include_once("includes/FrequentPattern.php");
4251
@@ -43,9 +52,34 @@
4453 FrequentPattern::computeAllRules();
4554
4655 // Notify user
47 - $wgOut->addWikiText(wfMsg("RefreshedFrequentPatterns"));
 56+ $wgOut->addWikiText(wfMsg("refreshedFrequentPatterns"));
4857 }
4958 }
50 -}
51 -
52 -?>
\ No newline at end of file
 59+
 60+
 61+
 62+
 63+ /**
 64+ * Creates database schema
 65+ *
 66+ * @return void
 67+ */
 68+ private function initSchema() {
 69+ $dbw =& wfGetDB( DB_MASTER );
 70+
 71+ $dbw->query("CREATE TABLE IF NOT EXISTS ".$dbw->tableName("fptc_associationrules")." (
 72+ `rule_id` int(11) NOT NULL auto_increment,
 73+ `p_id` int(8) NOT NULL COMMENT 'Attribute',
 74+ `rule_support` float(5,3) NOT NULL,
 75+ `rule_confidence` float(5,3) NOT NULL,
 76+ PRIMARY KEY (`rule_id`)
 77+ )");
 78+ $dbw->query("ALTER TABLE ".$dbw->tableName("fptc_associationrules")." ADD INDEX ( `p_id` );");
 79+ $dbw->query("CREATE TABLE IF NOT EXISTS ".$dbw->tableName("fptc_items")." (
 80+ `o_id` INT( 8 ) NOT NULL ,
 81+ `rule_id` INT NOT NULL ,
 82+ `item_order` TINYINT( 1 ) NOT NULL ,
 83+ PRIMARY KEY ( `o_id` , `rule_id` )
 84+ );");
 85+ }
 86+}
\ No newline at end of file
Index: trunk/extensions/FreqPatternTagCloud/javascripts/main.js
@@ -47,7 +47,7 @@
4848 if (action == "browse") {
4949 window.location = el.attr("href");
5050 } else if (action == "browse_similar_tag") {
51 - window.location = el.attr("href").replace(new RegExp(el.text()), menu.attr("title"));
 51+ window.location = el.attr("href").replace(new RegExp(encodeURI(el.text())), menu.attr("title"));
5252 }
5353 });
5454

Follow-up revisions

RevisionCommit summaryAuthorDate
r98772Fixing i18n topics of r98627fptc15:26, 3 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r96192initfptc14:42, 3 September 2011

Comments

#Comment by Raymond (talk | contribs)   22:25, 1 October 2011

Please use in your commit summaries the syntax "... r96192 ..." with leading r. This way the revisions are connected automagically.

#Comment by Raymond (talk | contribs)   22:44, 1 October 2011

Short i18n/l10n review:

  1. Please prefix all message keys with the extension name "freqpatterntagcloud-" or at least a abbreaviation like "fptc-". This avoids key conflicts with MediaWiki core and/or other extensions.
  2. Please add message documentation for the newly added messages. Thanks.
  3. Code convention for message keys is all lowercase, using dashes, no underscores: i.e. "contextMenu_Browse" -> "fptc-context-menu-browse" (incl. prefix from 1)
  4. No uppercasing in message text: "Browse Pages With This Value" -> "Browse pages with this Value"
  5. Trailing spaces are ignored: "Do you mean: " -> "Do you mean:". If needed add a space to the code or use message 'word-separator'
  6. Use UTF-8 instead of HTML entities: "&Auml ;hnliche Tags" -> "Ähnliche Tags"
  7. Language 'de' is informell (Du): "Meinten Sie: " -> "Meintest du:". Translatewiki.net folks will fix this after your extension is added to Translatewiki.net
  8. I have not read your code, so maybe I am wrong here: Normally $1...$9 are used as variables: "Similar to \"%s\":" -> "Similar to \"$1\":"

After fixing 1.-6., maybe 8 too, I will add your extension to translatewiki.net.

#Comment by FrequentPatternTagCloud (talk | contribs)   15:47, 3 October 2011

I have fixed 1.-6. in r98772.

Point 8. only works with %s -> no changes were made.

Status & tagging log