r100338 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100337‎ | r100338 | r100339 >
Date:12:08, 20 October 2011
Author:fptc
Status:deferred
Tags:
Comment:
FreqPatternTagCloud: Bugfix jQuery and compatibility issues with UsabilityInitiative extension
Modified paths:
  • /trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.body.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternApriori.php (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/javascripts/jquery-ui-1.8.custom.min.js (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/javascripts/jquery.contextMenu.js (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/javascripts/main.js (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/javascripts/search.js (modified) (history)
  • /trunk/extensions/FreqPatternTagCloud/stylesheets/main.css (modified) (history)

Diff [purge]

Index: trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.body.php
@@ -130,7 +130,6 @@
131131 $dbr = wfGetDB( DB_SLAVE );
132132
133133 // Get possible attribute values
134 - // @todo FIXME: ugly + SQL INJECTION POINT!
135134 $res = $dbr->query(
136135 "(SELECT DISTINCT vals.smw_title AS val, atts.smw_title AS att
137136 FROM ".$dbr->tableName("smw_ids")." vals, ".$dbr->tableName("smw_ids")." atts, ".$dbr->tableName("smw_rels2")." rels
@@ -140,10 +139,10 @@
141140 AND atts.smw_namespace = 102
142141 AND LENGTH(vals.smw_iw) = 0
143142 AND LENGTH(atts.smw_iw) = 0
144 - AND vals.smw_title LIKE '%".mysql_real_escape_string($currentSearchValue)."%'
145 - ORDER BY vals.smw_title
146 - LIMIT 20) UNION (
147 - SELECT smw_title AS val, '".wfMsg("fptc-categoryname")."' AS att
 143+ AND vals.smw_title LIKE '%".mysql_real_escape_string($currentSearchValue)."%'
 144+ ORDER BY vals.smw_title
 145+ LIMIT 20) UNION (
 146+ SELECT smw_title AS val, '".mysql_real_escape_string(wfMsg("fptc-categoryname"))."' AS att
148147 FROM ".$dbr->tableName("smw_ids")."
149148 WHERE smw_title LIKE '%".mysql_real_escape_string($currentSearchValue)."%'
150149 AND smw_namespace = 14
@@ -252,7 +251,7 @@
253252 <li class="browse">
254253 <a href="#browse">' . wfMsg( 'fptc-context-menu-browse' ) . '</a>
255254 </li>
256 - <li class="suggestions separator">
 255+ <li class="fptc_suggestions separator">
257256 ' . wfMsg( 'fptc-context-menu-similar-tags' ) . '
258257 </li>
259258 </ul>'
Index: trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php
@@ -70,7 +70,8 @@
7171 // @todo FIXME: this should use ResourceLoader and the appropriate core
7272 // functions instead of using its own jQuery etc.
7373 $wgOut->addExtensionStyle( $wgScriptPath.'/extensions/FreqPatternTagCloud/stylesheets/jquery/ui-lightness/jquery-ui-1.8.custom.css' );
74 - $wgOut->addScriptFile( $wgScriptPath . '/extensions/FreqPatternTagCloud/javascripts/jquery-1.4.2.min.js' );
 74+ #$wgOut->addScriptFile( $wgScriptPath . '/extensions/FreqPatternTagCloud/javascripts/jquery-1.4.2.min.js' );
 75+ $wgOut->addScriptFile( $wgScriptPath . '/extensions/FreqPatternTagCloud/javascripts/jquery.parseJSON.js' );
7576 $wgOut->addScriptFile( $wgScriptPath . '/extensions/FreqPatternTagCloud/javascripts/jquery-ui-1.8.custom.min.js' );
7677
7778 if ( $wgFreqPatternTagCloudSearchBarModification ) {
Index: trunk/extensions/FreqPatternTagCloud/includes/computation/FrequentPatternApriori.php
@@ -17,6 +17,10 @@
1818 $numTransactions = count($transactions);
1919 $allFrequentItemsets = array();
2020
 21+ if ($numTransactions == 0) {
 22+ return array();
 23+ }
 24+ else {
2125 // Get all 1-frequent itemsets
2226 foreach ($items as $item) {
2327 $freq = 0;
@@ -65,6 +69,7 @@
6670 }
6771
6872 return $allFrequentItemsets;
 73+ }
6974 }
7075
7176
Index: trunk/extensions/FreqPatternTagCloud/javascripts/main.js
@@ -16,31 +16,32 @@
1717
1818 // Relocate
1919 var pageName = RegExp.$1;
20 - window.location = window.location.href.replace(new RegExp(pageName + ".*"), pageName + "/" + $("#fptc_attributeName").val());
 20+ window.location = window.location.href.replace(new RegExp(pageName + ".*"), pageName + "/" + $j("#fptc_attributeName").val());
2121 };
2222
23 -$().ready(function() {
 23+
 24+$j().ready(function() {
2425 // Process form when key "return" is pressed
25 - $("#fptc_attributeName").keypress(function(e) {
 26+ $j("#fptc_attributeName").keypress(function(e) {
2627 if(e.which == 13){
2728 fptc_relocate();
2829 }
2930 });
3031
31 - var attribute = $("#fptc_attributeName").val();
 32+ var attribute = $j("#fptc_attributeName").val();
3233
3334 // Context menu for tag cloud
34 - $(".fptc_tag a").contextMenu({
 35+ $j(".fptc_tag a").contextMenu({
3536 menu: "fptc_contextMenu",
3637 onOpen: function(el) {
3738 // Indicate loading
38 - $("#fptc_contextMenu li").slice(2).remove();
39 - $("#fptc_contextMenu").append('<li class="loading"></li>');
 39+ $j("#fptc_contextMenu li").slice(2).remove();
 40+ $j("#fptc_contextMenu").append('<li class="loading"></li>');
4041
4142 // Replace contents when done with loading
4243 sajax_do_call("FreqPatternTagCloud::getSuggestions", [attribute, el.text()], function(data) {
4344 // Process return data
44 - $("#fptc_contextMenu .loading").replaceWith(data.responseText);
 45+ $j("#fptc_contextMenu .loading").replaceWith(data.responseText);
4546 });
4647 }
4748 }, function(action, el, pos, menu) {
@@ -52,7 +53,7 @@
5354 });
5455
5556 // Autosuggestion for input field
56 - $("#fptc_attributeName").autocomplete({
 57+ $j("#fptc_attributeName").autocomplete({
5758 delay: 0,
5859 source: function(currentValue, callbackForResults) {
5960 sajax_do_call("FreqPatternTagCloud::getAttributeSuggestions", [currentValue.term], function(data) {
Index: trunk/extensions/FreqPatternTagCloud/javascripts/search.js
@@ -7,12 +7,12 @@
88 * @version 1.0
99 */
1010
11 - $().ready(function() {
 11+ $j().ready(function() {
1212 // Autosuggestion for search input field using frequent pattern techniques
13 - $.widget( "custom.autocomplete_search", $.ui.autocomplete, {
 13+ $j.widget( "custom.autocomplete_search", $j.ui.autocomplete, {
1414 _renderMenu: function( ul, items ) {
1515 var self = this, currentCategory = "";
16 - $.each( items, function( index, item ) {
 16+ $j.each( items, function( index, item ) {
1717 if ( item.category != currentCategory ) {
1818 // Value changed
1919 ul.append('<li class="fptc_search_category">' + item.category + "</li>" );
@@ -22,7 +22,7 @@
2323 });
2424 }
2525 });
26 - $("#searchInput, #searchText").autocomplete_search({
 26+ $j("#searchInput, #searchText").autocomplete_search({
2727 delay: 0,
2828 source: function(currentValue, callbackForResults) {
2929 sajax_do_call("FreqPatternTagCloud::getSearchSuggestions", [currentValue.term], function(data) {
Index: trunk/extensions/FreqPatternTagCloud/javascripts/jquery.contextMenu.js
@@ -1,3 +1,5 @@
 2+jQuery( document ).ready( function( $ ) {
 3+
24 // jQuery Context Menu Plugin
35 //
46 // Version 1.01
@@ -212,4 +214,6 @@
213215 }
214216
215217 });
216 -})(jQuery);
\ No newline at end of file
 218+})(jQuery);
 219+
 220+});
Index: trunk/extensions/FreqPatternTagCloud/javascripts/jquery-ui-1.8.custom.min.js
@@ -1,4 +1,4 @@
2 -/*!
 2+ /*!
33 * jQuery UI 1.8
44 *
55 * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about)
@@ -401,4 +401,4 @@
402402 * Depends:
403403 * jquery.effects.core.js
404404 */
405 -(function(a){a.effects.transfer=function(b){return this.queue(function(){var f=a(this),h=a(b.options.to),e=h.offset(),g={top:e.top,left:e.left,height:h.innerHeight(),width:h.innerWidth()},d=f.offset(),c=a('<div class="ui-effects-transfer"></div>').appendTo(document.body).addClass(b.options.className).css({top:d.top,left:d.left,height:f.innerHeight(),width:f.innerWidth(),position:"absolute"}).animate(g,b.duration,b.options.easing,function(){c.remove();(b.callback&&b.callback.apply(f[0],arguments));f.dequeue()})})}})(jQuery);;
\ No newline at end of file
 405+(function(a){a.effects.transfer=function(b){return this.queue(function(){var f=a(this),h=a(b.options.to),e=h.offset(),g={top:e.top,left:e.left,height:h.innerHeight(),width:h.innerWidth()},d=f.offset(),c=a('<div class="ui-effects-transfer"></div>').appendTo(document.body).addClass(b.options.className).css({top:d.top,left:d.left,height:f.innerHeight(),width:f.innerWidth(),position:"absolute"}).animate(g,b.duration,b.options.easing,function(){c.remove();(b.callback&&b.callback.apply(f[0],arguments));f.dequeue()})})}})(jQuery);;
Index: trunk/extensions/FreqPatternTagCloud/stylesheets/main.css
@@ -22,7 +22,7 @@
2323
2424 #fptc_contextMenu .loading,
2525 #fptc_contextMenu .no_entries,
26 -#fptc_contextMenu .suggestions
 26+#fptc_contextMenu .fptc_suggestions
2727 {
2828 text-decoration: none;
2929 display: block;
@@ -40,7 +40,7 @@
4141 background-image: url("../images/loading.gif");
4242 }
4343
44 -#fptc_contextMenu .suggestions
 44+#fptc_contextMenu .fptc_suggestions
4545 {
4646 font-weight: bold;
4747 }
\ No newline at end of file

Status & tagging log