Index: trunk/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php |
— | — | @@ -1,63 +1,60 @@ |
2 | 2 | <?php |
3 | | - |
4 | 3 | /** |
5 | 4 | * Frequent Pattern Tag Cloud Plug-in |
6 | 5 | * Setup file |
7 | | - * |
| 6 | + * |
| 7 | + * @file |
| 8 | + * @ingroup Extensions |
| 9 | + * @version 1.0 |
8 | 10 | * @author Tobias Beck, University of Heidelberg |
9 | 11 | * @author Andreas Fay, University of Heidelberg |
10 | | - * @version 1.0 |
11 | 12 | */ |
12 | 13 | |
13 | 14 | // 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' ) ) { |
15 | 16 | echo <<<EOT |
16 | 17 | To install this extension, put the following line in LocalSettings.php: |
17 | | -\$wgUseAjax = true; |
18 | 18 | require_once( "\$IP/extensions/FreqPatternTagCloud/FreqPatternTagCloud.php" ); |
19 | 19 | EOT; |
20 | 20 | exit( 1 ); |
21 | 21 | } |
22 | 22 | |
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/' ); |
26 | 26 | |
27 | | -// Register plug-in with Special:Version |
| 27 | +// Register extension with Special:Version |
28 | 28 | $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 | +); |
42 | 35 | |
43 | 36 | // Register hook to prepare header files |
44 | 37 | $wgHooks['BeforePageDisplay'][] = 'fptc_initializeHeaders'; |
45 | 38 | |
46 | 39 | // 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'; |
49 | 42 | $wgSpecialPages['FreqPatternTagCloud'] = 'FreqPatternTagCloud'; |
50 | 43 | |
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'; |
53 | 45 | $wgSpecialPages['FreqPatternTagCloudMaintenance'] = 'FreqPatternTagCloudMaintenance'; |
54 | 46 | |
55 | | -// Register ajax functions |
| 47 | +// Register AJAX functions |
56 | 48 | $wgAjaxExportList[] = 'FreqPatternTagCloud::getAttributeSuggestions'; |
57 | 49 | $wgAjaxExportList[] = 'FreqPatternTagCloud::getSearchSuggestions'; |
58 | 50 | $wgAjaxExportList[] = 'FreqPatternTagCloud::getSuggestions'; |
59 | 51 | |
60 | | -include_once(FPTC_PATH_INCLUDES."FrequentPattern.php"); |
| 52 | +include_once( FPTC_PATH_INCLUDES . 'FrequentPattern.php' ); |
61 | 53 | |
| 54 | +# Configuration settings |
| 55 | +// Add search modification for suggestions using frequent pattern mining |
| 56 | +// Configuration |
| 57 | +// Activate on default |
| 58 | +$wgFreqPatternTagCloudSearchBarModification = true; |
62 | 59 | |
63 | 60 | /** |
64 | 61 | * Initializes page headers |
— | — | @@ -66,53 +63,24 @@ |
67 | 64 | */ |
68 | 65 | function fptc_initializeHeaders() { |
69 | 66 | 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' ); |
87 | 78 | } |
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 | + |
100 | 80 | // 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 | + |
118 | 86 | return true; |
119 | 87 | } |
\ No newline at end of file |