r98778 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98777‎ | r98778 | r98779 >
Date:17:27, 3 October 2011
Author:ashley
Status:deferred
Tags:
Comment:
FreqPatternTagCloud: cleanup the setup file:
*remove duplicate $wgExtensionCredits definition
*use addExtensionStyle() to add CSS and addScriptFile() to add JS
**should eventually use ResourceLoader instead
*fix register_globals issue
*remove unnecessary $wgExtensionMessagesFiles declaration
*coding style tweaks
Modified paths:
  • /trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php
@@ -1,63 +1,60 @@
22 <?php
3 -
43 /**
54 * Frequent Pattern Tag Cloud Plug-in
65 * Setup file
7 - *
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ * @version 1.0
810 * @author Tobias Beck, University of Heidelberg
911 * @author Andreas Fay, University of Heidelberg
10 - * @version 1.0
1112 */
1213
1314 // Alert the user that this is not a valid entry point to MediaWiki if they try to access the special pages file directly.
14 -if (!defined('MEDIAWIKI') || !$wgUseAjax) {
 15+if ( !defined( 'MEDIAWIKI' ) ) {
1516 echo <<<EOT
1617 To install this extension, put the following line in LocalSettings.php:
17 -\$wgUseAjax = true;
1818 require_once( "\$IP/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php" );
1919 EOT;
2020 exit( 1 );
2121 }
2222
23 -define("FPTC_PATH_HOME", dirname(__FILE__)."/");
24 -define("FPTC_PATH_INCLUDES", dirname(__FILE__)."/includes/");
25 -define("FPTC_PATH_RESOURCES", dirname(__FILE__)."/res/");
 23+define( 'FPTC_PATH_HOME', dirname( __FILE__ ) . '/' );
 24+define( 'FPTC_PATH_INCLUDES', dirname( __FILE__ ) . '/includes/' );
 25+define( 'FPTC_PATH_RESOURCES', dirname( __FILE__ ) . '/res/' );
2626
27 -// Register plug-in with Special:Version
 27+// Register extension with Special:Version
2828 $wgExtensionCredits['specialpage'][] = array(
29 - 'author' =>'Tobias Beck, Andreas Fay',
30 - 'name' => 'FreqPatternTagCloud',
31 - 'description' => 'Extension is represented by a special page that allows to build a tag cloud based on properties and to search for similar property values.',
32 - 'url' => 'http://www.mediawiki.org/wiki/Extension:FrequentPatternTagCloud',
33 - 'version' => '1.0'
34 - );
35 -$wgExtensionCredits['specialpage'][] = array(
36 - 'author' =>'Tobias Beck, Andreas Fay',
37 - 'name' => 'FreqPatternTagCloudMaintenance',
38 - 'description' => 'Extension is represented by a special page that allows to build a tag cloud based on properties and to search for similar property values.',
39 - 'url' => 'http://www.mediawiki.org/wiki/Extension:FrequentPatternTagCloud',
40 - 'version' => '1.0'
41 - );
 29+ 'author' => array( 'Tobias Beck', 'Andreas Fay' ),
 30+ 'version' => '1.0',
 31+ 'name' => 'FreqPatternTagCloud',
 32+ 'description' => 'Extension is represented by a special page that allows to build a tag cloud based on properties and to search for similar property values.',
 33+ 'url' => 'http://www.mediawiki.org/wiki/Extension:FrequentPatternTagCloud',
 34+);
4235
4336 // Register hook to prepare header files
4437 $wgHooks['BeforePageDisplay'][] = 'fptc_initializeHeaders';
4538
4639 // Register files
47 -$wgAutoloadClasses['FreqPatternTagCloud'] = FPTC_PATH_HOME.'FreqPatternTagCloud.body.php';
48 -$wgExtensionMessagesFiles['FreqPatternTagCloud'] = FPTC_PATH_HOME.'FreqPatternTagCloud.i18n.php';
 40+$wgAutoloadClasses['FreqPatternTagCloud'] = FPTC_PATH_HOME . 'FreqPatternTagCloud.body.php';
 41+$wgExtensionMessagesFiles['FreqPatternTagCloud'] = FPTC_PATH_HOME . 'FreqPatternTagCloud.i18n.php';
4942 $wgSpecialPages['FreqPatternTagCloud'] = 'FreqPatternTagCloud';
5043
51 -$wgAutoloadClasses['FreqPatternTagCloudMaintenance'] = FPTC_PATH_HOME.'FreqPatternTagCloudMaintenance.php';
52 -$wgExtensionMessagesFiles['FreqPatternTagCloudMaintenance'] = FPTC_PATH_HOME.'FreqPatternTagCloud.i18n.php';
 44+$wgAutoloadClasses['FreqPatternTagCloudMaintenance'] = FPTC_PATH_HOME . 'FreqPatternTagCloudMaintenance.php';
5345 $wgSpecialPages['FreqPatternTagCloudMaintenance'] = 'FreqPatternTagCloudMaintenance';
5446
55 -// Register ajax functions
 47+// Register AJAX functions
5648 $wgAjaxExportList[] = 'FreqPatternTagCloud::getAttributeSuggestions';
5749 $wgAjaxExportList[] = 'FreqPatternTagCloud::getSearchSuggestions';
5850 $wgAjaxExportList[] = 'FreqPatternTagCloud::getSuggestions';
5951
60 -include_once(FPTC_PATH_INCLUDES."FrequentPattern.php");
 52+include_once( FPTC_PATH_INCLUDES . 'FrequentPattern.php' );
6153
 54+# Configuration settings
 55+// Add search modification for suggestions using frequent pattern mining
 56+// Configuration
 57+// Activate on default
 58+$wgFreqPatternTagCloudSearchBarModification = true;
6259
6360 /**
6461 * Initializes page headers
@@ -66,53 +63,24 @@
6764 */
6865 function fptc_initializeHeaders() {
6966 global $wgOut, $wgScriptPath, $wgFreqPatternTagCloudSearchBarModification;
70 -
71 - // Add jquery & jquery ui
72 - $wgOut->addLink(
73 - array(
74 - 'rel' => 'stylesheet',
75 - 'type' => 'text/css',
76 - 'href' => $wgScriptPath.'/extensions/FreqPatternTagCloud/stylesheets/jquery/ui-lightness/jquery-ui-1.8.custom.css'
77 - )
78 - );
79 - $wgOut->addScript('<script type="text/javascript" src="'.$wgScriptPath.'/extensions/FreqPatternTagCloud/javascripts/jquery-1.4.2.min.js"></script>');
80 - $wgOut->addScript('<script type="text/javascript" src="'.$wgScriptPath.'/extensions/FreqPatternTagCloud/javascripts/jquery-ui-1.8.custom.min.js"></script>');
81 -
82 - // Add search modification for suggestions using frequent pattern mining
83 - // Configuration
84 - if (!isset($wgFreqPatternTagCloudSearchBarModification)) {
85 - // Activate on default
86 - $wgFreqPatternTagCloudSearchBarModification = true;
 67+
 68+ // Add jQuery & jQuery UI
 69+ // @todo FIXME: this should use ResourceLoader and the appropriate core
 70+ // functions instead of using its own jQuery etc.
 71+ $wgOut->addExtensionStyle( $wgScriptPath.'/extensions/FreqPatternTagCloud/stylesheets/jquery/ui-lightness/jquery-ui-1.8.custom.css' );
 72+ $wgOut->addScriptFile( $wgScriptPath . '/extensions/FreqPatternTagCloud/javascripts/jquery-1.4.2.min.js' );
 73+ $wgOut->addScriptFile( $wgScriptPath . '/extensions/FreqPatternTagCloud/javascripts/jquery-ui-1.8.custom.min.js' );
 74+
 75+ if ( $wgFreqPatternTagCloudSearchBarModification ) {
 76+ $wgOut->addExtensionStyle( $wgScriptPath.'/extensions/FreqPatternTagCloud/stylesheets/search.css' );
 77+ $wgOut->addScriptFile( $wgScriptPath . '/extensions/FreqPatternTagCloud/javascripts/search.js' );
8778 }
88 -
89 - if ($wgFreqPatternTagCloudSearchBarModification) {
90 - $wgOut->addLink(
91 - array(
92 - 'rel' => 'stylesheet',
93 - 'type' => 'text/css',
94 - 'href' => $wgScriptPath.'/extensions/FreqPatternTagCloud/stylesheets/search.css'
95 - )
96 - );
97 - $wgOut->addScript('<script type="text/javascript" src="'.$wgScriptPath.'/extensions/FreqPatternTagCloud/javascripts/search.js"></script>');
98 - }
99 -
 79+
10080 // Add freq pattern tag cloud
101 - $wgOut->addLink(
102 - array(
103 - 'rel' => 'stylesheet',
104 - 'type' => 'text/css',
105 - 'href' => $wgScriptPath.'/extensions/FreqPatternTagCloud/stylesheets/jquery.contextMenu.css'
106 - )
107 - );
108 - $wgOut->addLink(
109 - array(
110 - 'rel' => 'stylesheet',
111 - 'type' => 'text/css',
112 - 'href' => $wgScriptPath.'/extensions/FreqPatternTagCloud/stylesheets/main.css'
113 - )
114 - );
115 - $wgOut->addScript('<script type="text/javascript" src="'.$wgScriptPath.'/extensions/FreqPatternTagCloud/javascripts/jquery.contextMenu.js"></script>');
116 - $wgOut->addScript('<script type="text/javascript" src="'.$wgScriptPath.'/extensions/FreqPatternTagCloud/javascripts/main.js"></script>');
117 -
 81+ $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/FreqPatternTagCloud/stylesheets/jquery.contextMenu.css' );
 82+ $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/FreqPatternTagCloud/stylesheets/main.css' );
 83+ $wgOut->addScriptFile( $wgScriptPath . '/extensions/FreqPatternTagCloud/javascripts/jquery.contextMenu.js' );
 84+ $wgOut->addScriptFile( $wgScriptPath . '/extensions/FreqPatternTagCloud/javascripts/main.js' );
 85+
11886 return true;
11987 }
\ No newline at end of file

Status & tagging log