r54186 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r54185‎ | r54186 | r54187 >
Date:21:13, 1 August 2009
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Modified paths:
  • /tags/extensions/SemanticMaps/REL_0_2_2/SemanticMaps.php (deleted) (history)

Diff [purge]

Index: tags/extensions/SemanticMaps/REL_0_2_2/SemanticMaps.php
@@ -1,188 +0,0 @@
2 -<?php
3 -
4 -/**
5 - * Initialization file for the Semantic Maps extension.
6 - * Extension documentation: http://www.mediawiki.org/wiki/Extension:Semantic_Maps
7 - *
8 - * @file SemanticMaps.php
9 - * @ingroup SemanticMaps
10 - *
11 - * @author Jeroen De Dauw
12 - */
13 -
14 -if( !defined( 'MEDIAWIKI' ) ) {
15 - die( 'Not an entry point.' );
16 -}
17 -
18 -define('SM_VERSION', '0.2.2');
19 -
20 -$smgScriptPath = $wgScriptPath . '/extensions/SemanticMaps';
21 -$smgIP = $IP . '/extensions/SemanticMaps';
22 -
23 -$wgExtensionFunctions[] = 'smfSetup';
24 -
25 -$wgHooks['AdminLinks'][] = 'smfAddToAdminLinks';
26 -
27 -$wgExtensionMessagesFiles['SemanticMaps'] = $smgIP . '/SemanticMaps.i18n.php';
28 -
29 -// Autoload the general classes
30 -$wgAutoloadClasses['SMMapPrinter'] = $smgIP . '/SM_MapPrinter.php';
31 -$wgAutoloadClasses['SMMapper'] = $smgIP . '/SM_Mapper.php';
32 -$wgAutoloadClasses['SMFormInput'] = $smgIP . '/SM_FormInput.php';
33 -
34 -function smfSetup() {
35 - global $wgExtensionCredits, $egMapsMainServices, $wgExtensionCredits;
36 -
37 - $services_list = implode(', ', $egMapsMainServices);
38 -
39 - wfLoadExtensionMessages( 'SemanticMaps' );
40 -
41 - $wgExtensionCredits['other'][]= array(
42 - 'path' => __FILE__,
43 - 'name' => wfMsg('semanticmaps_name'),
44 - 'version' => SM_VERSION,
45 - 'author' => array("[http://bn2vs.com Jeroen De Dauw]", "Yaron Koren", "Robert Buzink"),
46 - 'url' => 'http://www.mediawiki.org/wiki/Extension:Semantic_Maps',
47 - 'description' => wfMsg( 'semanticmaps_desc', $services_list ),
48 - 'descriptionmsg' => array( 'semanticmaps_desc', $services_list ),
49 - );
50 -
51 - smfInitFormat('map');
52 - smfInitializeService('map');
53 -
54 - foreach($egMapsMainServices as $service) smfInitFormat($service);
55 -
56 - smfInitializeServiceAliases('googlemaps');
57 - smfInitializeServiceAliases('yahoomaps');
58 - smfInitializeServiceAliases('openlayers');
59 -}
60 -
61 -/**
62 - * Apply smfInitializeService() to a service and all it's aliases.
63 - *
64 - * @param unknown_type $mainServiceName
65 - * @param unknown_type $queryPrinter
66 - */
67 -function smfInitializeServiceAliases($mainServiceName) {
68 - global $egMapsServices;
69 -
70 - smfInitializeService($mainServiceName, $mainServiceName);
71 - foreach ($egMapsServices[$mainServiceName] as $alias) smfInitializeService($alias, $mainServiceName);
72 -}
73 -
74 -/**
75 - * Add the service name as result format for the provided query printer,
76 - * and set a hook for it's form input.
77 - *
78 - * @param unknown_type $service
79 - * @param unknown_type $queryPrinter
80 - * @param unknown_type $mainName
81 - */
82 -function smfInitializeService($service, $mainName = '') {
83 - global $sfgFormPrinter;
84 -
85 - // Add the form input hook for the service
86 - $field_args = array();
87 - if (strlen($mainName) > 0) $field_args['service_name'] = $mainName;
88 - $sfgFormPrinter->setInputTypeHook($service, 'smfSelectFormInputHTML', $field_args);
89 -}
90 -
91 -/**
92 - * Initialize the result format depending on the map service
93 - */
94 -function smfInitFormat( $format ) {
95 - global $smwgResultFormats, $wgAutoloadClasses, $smgIP;
96 -
97 - switch ($format) {
98 - case 'map':
99 - $class = 'SMMapper';
100 - $file = $smgIP . '/SM_Mapper';
101 - break;
102 - case 'googlemaps':
103 - $class = 'SMGoogleMaps';
104 - $file = $smgIP . '/GoogleMaps/SM_GoogleMaps';
105 - break;
106 - case 'openlayers':
107 - $class = 'SMOpenLayers';
108 - $file = $smgIP . '/OpenLayers/SM_OpenLayers';
109 - break;
110 - case 'yahoomaps':
111 - $class = 'SMYahooMaps';
112 - $file = $smgIP . '/YahooMaps/SM_YahooMaps';
113 - break;
114 - }
115 -
116 - if (isset($class) && isset($file)) {
117 - // Check if $smwgResultFormats, a global variable introduced in SMW 1.2.2,
118 - // is set and add the query printer to the result format.
119 - if (isset($smwgResultFormats)) {
120 - $smwgResultFormats[$format] = $class;
121 - }
122 - else {
123 - SMWQueryProcessor::$formats[$format] = $class;
124 - }
125 -
126 - $wgAutoloadClasses[$class] = $file . ".php";
127 - $wgAutoloadClasses[$class . "FormInput"] = $file . "FormInput.php";
128 - }
129 -
130 -
131 -
132 -}
133 -
134 -/**
135 - * Class for the form input type 'map'. The relevant form input class is called depending on the provided service.
136 - *
137 - * @param unknown_type $coordinates
138 - * @param unknown_type $input_name
139 - * @param unknown_type $is_mandatory
140 - * @param unknown_type $is_disabled
141 - * @param unknown_type $field_args
142 - * @return unknown
143 - */
144 -function smfSelectFormInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args) {
145 - global $egMapsAvailableServices, $egMapsDefaultService;
146 -
147 - // If service_name is set, use this value, and ignore any given service parameters
148 - // This will prevent ..input type=googlemaps|service=yahoo.. from shwoing up a Yahoo! Maps map
149 - if (array_key_exists('service_name', $field_args)) $field_args['service'] = $field_args['service_name'];
150 -
151 - $field_args['service'] = MapsMapper::getValidService($field_args['service']);
152 -
153 - // Create an instace of
154 - switch ($field_args['service']) {
155 - case 'googlemaps' :
156 - $formInput = new SMGoogleMapsFormInput();
157 - break;
158 - case 'openlayers' :
159 - $formInput = new SMOpenLayersFormInput();
160 - break;
161 - case 'yahoomaps' :
162 - $formInput = new SMYahooMapsFormInput();
163 - break;
164 - }
165 -
166 - // Get and return the form input HTML from the hook corresponding with the provided service
167 - return $formInput->formInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args);
168 -}
169 -
170 -function smfGetDynamicInput($id, $value, $args='') {
171 - // By De Dauw Jeroen - November 2008 - http://code.bn2vs.com/viewtopic.php?t=120
172 - return '<input id="'.$id.'" '.$args.' value="'.$value.'" onfocus="if (this.value==\''.$value.'\') {this.value=\'\';}" onblur="if (this.value==\'\') {this.value=\''.$value.'\';}" />';
173 -}
174 -
175 -/**
176 - * Adds a link to Admin Links page
177 - */
178 -function smfAddToAdminLinks(&$admin_links_tree) {
179 - $displaying_data_section = $admin_links_tree->getSection(wfMsg('smw_adminlinks_displayingdata'));
180 - // Escape if SMW hasn't added links
181 - if (is_null($displaying_data_section))
182 - return true;
183 - $smw_docu_row = $displaying_data_section->getRow('smw');
184 - wfLoadExtensionMessages('SemanticMaps');
185 - $sm_docu_label = wfMsg('adminlinks_documentation', wfMsg('semanticmaps_name'));
186 - $smw_docu_row->addItem(AlItem::newFromExternalLink("http://www.mediawiki.org/wiki/Extension:Semantic_Maps", $sm_docu_label));
187 - return true;
188 -}
189 -

Status & tagging log