r56331 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56330‎ | r56331 | r56332 >
Date:19:57, 14 September 2009
Author:ialex
Status:deferred
Tags:
Comment:
svn:eol-style native
Modified paths:
  • /trunk/extensions/ConditionalShowSection/README (modified) (history)
  • /trunk/extensions/HeaderTabs/LICENSE (modified) (history)
  • /trunk/extensions/HeaderTabs/skins/blank.html (modified) (history)
  • /trunk/extensions/Maps/Geocoders/Maps_BaseGeocoder.php (modified) (history)
  • /trunk/extensions/Maps/Geocoders/Maps_Geocoder.php (modified) (history)
  • /trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsParserFunctions.php (modified) (history)
  • /trunk/extensions/Maps/OpenLayers/Maps_OpenLayersParserFunctions.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/Maps_BaseMap.php (modified) (history)
  • /trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php (modified) (history)
  • /trunk/extensions/Maps/YahooMaps/Maps_YahooMapsParserFunctions.php (modified) (history)
  • /trunk/extensions/SemanticForms/libs/SF_ajax_form_preview.js (modified) (history)
  • /trunk/extensions/SemanticMaps/FormInputs/SM_FormInput.php (modified) (history)
  • /trunk/extensions/SemanticMaps/FormInputs/SM_FormInputFactory.php (modified) (history)
  • /trunk/extensions/SemanticMaps/FormInputs/SM_FormInputs.php (modified) (history)
  • /trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsQP.php (modified) (history)
  • /trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersQP.php (modified) (history)
  • /trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php (modified) (history)
  • /trunk/extensions/SemanticMaps/QueryPrinters/SM_Mapper.php (modified) (history)
  • /trunk/extensions/SemanticMaps/QueryPrinters/SM_QueryPrinters.php (modified) (history)
  • /trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsQP.php (modified) (history)
  • /trunk/extensions/StringFunctionsEscaped/README (modified) (history)
  • /trunk/phase3/js2/mwEmbed/example_usage/Add_Media_Wizard.html (modified) (history)
  • /trunk/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html (modified) (history)
  • /trunk/phase3/js2/mwEmbed/example_usage/Player_RelatedVideos.html (modified) (history)
  • /trunk/phase3/js2/mwEmbed/example_usage/Player_Simple_Themable.html (modified) (history)
  • /trunk/phase3/js2/mwEmbed/example_usage/Sequence_Editor.html (modified) (history)
  • /trunk/phase3/js2/mwEmbed/example_usage/media/sample_smil.xml (modified) (history)

Diff [purge]

Property changes on: trunk/phase3/js2/mwEmbed/example_usage/Firefogg_Make_Advanced.html
___________________________________________________________________
Added: svn:eol-style
11 + native
Property changes on: trunk/phase3/js2/mwEmbed/example_usage/media/sample_smil.xml
___________________________________________________________________
Added: svn:eol-style
22 + native
Property changes on: trunk/phase3/js2/mwEmbed/example_usage/Sequence_Editor.html
___________________________________________________________________
Added: svn:eol-style
33 + native
Property changes on: trunk/phase3/js2/mwEmbed/example_usage/Player_RelatedVideos.html
___________________________________________________________________
Added: svn:eol-style
44 + native
Property changes on: trunk/phase3/js2/mwEmbed/example_usage/Player_Simple_Themable.html
___________________________________________________________________
Added: svn:eol-style
55 + native
Property changes on: trunk/phase3/js2/mwEmbed/example_usage/Add_Media_Wizard.html
___________________________________________________________________
Added: svn:eol-style
66 + native
Index: trunk/extensions/SemanticMaps/FormInputs/SM_FormInputs.php
@@ -1,110 +1,110 @@
2 -<?php
3 -
4 -/**
5 - * Initialization file for form input functionality in the Maps extension
6 - *
7 - * @file SM_FormInputs.php
8 - * @ingroup SemanticMaps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -final class SMFormInputs {
18 -
19 - public static function initialize() {
20 - global $smgIP, $wgAutoloadClasses, $egMapsServices, $sfgFormPrinter;
21 -
22 - $wgAutoloadClasses['SMFormInput'] = $smgIP . '/FormInputs/SM_FormInput.php';
23 -
24 - // This feature can only be enbled when Semantic Forms is loaded.
25 - if (isset($sfgFormPrinter)) {
26 - $hasFormInputs = false;
27 -
28 - foreach($egMapsServices as $serviceName => $serviceData) {
29 - // Check if the service has a form input
30 - $hasFI = array_key_exists('fi', $serviceData);
31 -
32 - // If the service has no FI, skipt it and continue with the next one.
33 - if (!$hasFI) continue;
34 -
35 - // At least one form input will be enabled when this point is reached.
36 - $hasFormInputs = true;
37 -
38 - // Add the result form input type for the service name.
39 - self::initFormHook($serviceName, $serviceData['fi']);
40 -
41 - // Loop through the service alliases, and add them as form input types.
42 - foreach ($serviceData['aliases'] as $alias) self::initFormHook($alias, $serviceData['fi'], $serviceName);
43 - }
44 -
45 - // Add the 'map' form input type if there are mapping services that have FI's loaded.
46 - if ($hasFormInputs) self::initFormHook('map');
47 -
48 - }
49 -
50 - }
51 -
52 - /**
53 - * Adds a mapping service's form hook
54 - *
55 - * @param string $service
56 - * @param array $fi
57 - * @param strig $mainName
58 - */
59 - private static function initFormHook($service, array $fi = null, $mainName = '') {
60 - global $wgAutoloadClasses, $sfgFormPrinter, $smgIP;
61 -
62 - if (isset($fi)) {
63 - if (! array_key_exists($fi['class'], $wgAutoloadClasses)) {
64 - $file = $fi['local'] ? $smgIP . '/' . $fi['file'] : $fi['file'];
65 - $wgAutoloadClasses[$fi['class']] = $file;
66 - }
67 - }
68 -
69 - // Add the form input hook for the service
70 - $field_args = array();
71 - if (strlen($mainName) > 0) $field_args['service_name'] = $mainName;
72 - $sfgFormPrinter->setInputTypeHook($service, 'smfSelectFormInputHTML', $field_args);
73 - }
74 -
75 -}
76 -
77 -/**
78 - * Class for the form input type 'map'. The relevant form input class is called depending on the provided service.
79 - *
80 - * @param unknown_type $coordinates
81 - * @param unknown_type $input_name
82 - * @param unknown_type $is_mandatory
83 - * @param unknown_type $is_disabled
84 - * @param array $field_args
85 - * @return unknown
86 - */
87 -function smfSelectFormInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, array $field_args) {
88 - global $egMapsServices;
89 -
90 - // If service_name is set, use this value, and ignore any given
91 - // service parameters
92 - // This will prevent ..input type=googlemaps|service=yahoo.. from
93 - // showing up as a Yahoo! Maps map
94 - if (array_key_exists('service_name', $field_args)) {
95 - $service_name = $field_args['service_name'];
96 - }
97 - elseif (array_key_exists('service', $field_args)) {
98 - $service_name = $field_args['service'];
99 - }
100 - else{
101 - $service_name = null;
102 - }
103 -
104 - $service_name = MapsMapper::getValidService($service_name, 'fi');
105 -
106 - $formInput = new $egMapsServices[$service_name]['fi']['class']();
107 -
108 - // Get and return the form input HTML from the hook corresponding with the provided service
109 - return $formInput->formInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args);
110 -
 2+<?php
 3+
 4+/**
 5+ * Initialization file for form input functionality in the Maps extension
 6+ *
 7+ * @file SM_FormInputs.php
 8+ * @ingroup SemanticMaps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+final class SMFormInputs {
 18+
 19+ public static function initialize() {
 20+ global $smgIP, $wgAutoloadClasses, $egMapsServices, $sfgFormPrinter;
 21+
 22+ $wgAutoloadClasses['SMFormInput'] = $smgIP . '/FormInputs/SM_FormInput.php';
 23+
 24+ // This feature can only be enbled when Semantic Forms is loaded.
 25+ if (isset($sfgFormPrinter)) {
 26+ $hasFormInputs = false;
 27+
 28+ foreach($egMapsServices as $serviceName => $serviceData) {
 29+ // Check if the service has a form input
 30+ $hasFI = array_key_exists('fi', $serviceData);
 31+
 32+ // If the service has no FI, skipt it and continue with the next one.
 33+ if (!$hasFI) continue;
 34+
 35+ // At least one form input will be enabled when this point is reached.
 36+ $hasFormInputs = true;
 37+
 38+ // Add the result form input type for the service name.
 39+ self::initFormHook($serviceName, $serviceData['fi']);
 40+
 41+ // Loop through the service alliases, and add them as form input types.
 42+ foreach ($serviceData['aliases'] as $alias) self::initFormHook($alias, $serviceData['fi'], $serviceName);
 43+ }
 44+
 45+ // Add the 'map' form input type if there are mapping services that have FI's loaded.
 46+ if ($hasFormInputs) self::initFormHook('map');
 47+
 48+ }
 49+
 50+ }
 51+
 52+ /**
 53+ * Adds a mapping service's form hook
 54+ *
 55+ * @param string $service
 56+ * @param array $fi
 57+ * @param strig $mainName
 58+ */
 59+ private static function initFormHook($service, array $fi = null, $mainName = '') {
 60+ global $wgAutoloadClasses, $sfgFormPrinter, $smgIP;
 61+
 62+ if (isset($fi)) {
 63+ if (! array_key_exists($fi['class'], $wgAutoloadClasses)) {
 64+ $file = $fi['local'] ? $smgIP . '/' . $fi['file'] : $fi['file'];
 65+ $wgAutoloadClasses[$fi['class']] = $file;
 66+ }
 67+ }
 68+
 69+ // Add the form input hook for the service
 70+ $field_args = array();
 71+ if (strlen($mainName) > 0) $field_args['service_name'] = $mainName;
 72+ $sfgFormPrinter->setInputTypeHook($service, 'smfSelectFormInputHTML', $field_args);
 73+ }
 74+
 75+}
 76+
 77+/**
 78+ * Class for the form input type 'map'. The relevant form input class is called depending on the provided service.
 79+ *
 80+ * @param unknown_type $coordinates
 81+ * @param unknown_type $input_name
 82+ * @param unknown_type $is_mandatory
 83+ * @param unknown_type $is_disabled
 84+ * @param array $field_args
 85+ * @return unknown
 86+ */
 87+function smfSelectFormInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, array $field_args) {
 88+ global $egMapsServices;
 89+
 90+ // If service_name is set, use this value, and ignore any given
 91+ // service parameters
 92+ // This will prevent ..input type=googlemaps|service=yahoo.. from
 93+ // showing up as a Yahoo! Maps map
 94+ if (array_key_exists('service_name', $field_args)) {
 95+ $service_name = $field_args['service_name'];
 96+ }
 97+ elseif (array_key_exists('service', $field_args)) {
 98+ $service_name = $field_args['service'];
 99+ }
 100+ else{
 101+ $service_name = null;
 102+ }
 103+
 104+ $service_name = MapsMapper::getValidService($service_name, 'fi');
 105+
 106+ $formInput = new $egMapsServices[$service_name]['fi']['class']();
 107+
 108+ // Get and return the form input HTML from the hook corresponding with the provided service
 109+ return $formInput->formInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args);
 110+
111111 }
\ No newline at end of file
Property changes on: trunk/extensions/SemanticMaps/FormInputs/SM_FormInputs.php
___________________________________________________________________
Added: svn:eol-style
112112 + native
Index: trunk/extensions/SemanticMaps/FormInputs/SM_FormInputFactory.php
@@ -1,61 +1,61 @@
2 -<?php
3 -
4 -/**
5 - * Factory method for form input handling classes
6 - *
7 - * @file SM_FormInputFactory.php
8 - * @ingroup SemanticMaps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -class SMFormInputFactory {
18 -
19 - public static function getFormInputHtml() {
20 - global $egMapsServices;
21 -
22 - // If service_name is set, use this value, and ignore any given
23 - // service parameters
24 - // This will prevent ..input type=googlemaps|service=yahoo.. from
25 - // showing up as a Yahoo! Maps map
26 - if (array_key_exists('service_name', $field_args)) {
27 - $service_name = $field_args['service_name'];
28 - }
29 - elseif (array_key_exists('service', $field_args)) {
30 - $service_name = $field_args['service'];
31 - }
32 - else{
33 - $service_name = null;
34 - }
35 -
36 - $service_name = MapsMapper::getValidService($service_name, 'fi');
37 -
38 - $formInput = self::getFormInputInstance();
39 -
40 - // Get and return the form input HTML from the hook corresponding with the provided service
41 - return $formInput->formInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args);
42 - }
43 -
44 - private static function getFormInputInstance($serviceName) {
45 - return new $egMapsServices[$service_name]['fi']['class']();
46 - }
47 -
48 -}
49 -
50 -/**
51 - * Class for the form input type 'map'. The relevant form input class is called depending on the provided service.
52 - *
53 - * @param unknown_type $coordinates
54 - * @param unknown_type $input_name
55 - * @param unknown_type $is_mandatory
56 - * @param unknown_type $is_disabled
57 - * @param array $field_args
58 - * @return unknown
59 - */
60 -function smfSelectFormInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, array $field_args) {
61 -
 2+<?php
 3+
 4+/**
 5+ * Factory method for form input handling classes
 6+ *
 7+ * @file SM_FormInputFactory.php
 8+ * @ingroup SemanticMaps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+class SMFormInputFactory {
 18+
 19+ public static function getFormInputHtml() {
 20+ global $egMapsServices;
 21+
 22+ // If service_name is set, use this value, and ignore any given
 23+ // service parameters
 24+ // This will prevent ..input type=googlemaps|service=yahoo.. from
 25+ // showing up as a Yahoo! Maps map
 26+ if (array_key_exists('service_name', $field_args)) {
 27+ $service_name = $field_args['service_name'];
 28+ }
 29+ elseif (array_key_exists('service', $field_args)) {
 30+ $service_name = $field_args['service'];
 31+ }
 32+ else{
 33+ $service_name = null;
 34+ }
 35+
 36+ $service_name = MapsMapper::getValidService($service_name, 'fi');
 37+
 38+ $formInput = self::getFormInputInstance();
 39+
 40+ // Get and return the form input HTML from the hook corresponding with the provided service
 41+ return $formInput->formInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args);
 42+ }
 43+
 44+ private static function getFormInputInstance($serviceName) {
 45+ return new $egMapsServices[$service_name]['fi']['class']();
 46+ }
 47+
 48+}
 49+
 50+/**
 51+ * Class for the form input type 'map'. The relevant form input class is called depending on the provided service.
 52+ *
 53+ * @param unknown_type $coordinates
 54+ * @param unknown_type $input_name
 55+ * @param unknown_type $is_mandatory
 56+ * @param unknown_type $is_disabled
 57+ * @param array $field_args
 58+ * @return unknown
 59+ */
 60+function smfSelectFormInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, array $field_args) {
 61+
6262 }
\ No newline at end of file
Property changes on: trunk/extensions/SemanticMaps/FormInputs/SM_FormInputFactory.php
___________________________________________________________________
Added: svn:eol-style
6363 + native
Index: trunk/extensions/SemanticMaps/FormInputs/SM_FormInput.php
@@ -1,150 +1,150 @@
2 -<?php
3 -
4 -/**
5 - * Abstract class that provides the common functionallity for all map form inputs
6 - *
7 - * @file SM_FormInput.php
8 - * @ingroup SemanticMaps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -abstract class SMFormInput extends MapsMapFeature {
18 -
19 - /**
20 - * Determine if geocoding will be enabled and load the required dependencies.
21 - */
22 - protected abstract function manageGeocoding();
23 -
24 - /**
25 - * Ensures all dependencies for the used map are loaded, and increases that map service's count
26 - */
27 - protected abstract function addFormDependencies();
28 -
29 - protected $marker_lat;
30 - protected $marker_lon;
31 -
32 - protected $earthZoom;
33 -
34 - protected $showAddresFunction;
35 -
36 - protected $enableGeocoding = false;
37 -
38 - private $startingCoords ='';
39 -
40 - private $coordinates;
41 -
42 - /**
43 - * This function is a hook for Semantic Forms, and returns the HTML needed in
44 - * the form to handle coordinate data.
45 - */
46 - public final function formInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args) {
47 - // TODO: Use function args for sf stuffz
48 - global $sfgTabIndex;
49 -
50 - $this->coordinates = $coordinates;
51 -
52 - $this->manageGeocoding();
53 -
54 - $this->setMapSettings();
55 -
56 - $this->doMapServiceLoad();
57 -
58 - $this->manageMapProperties($field_args, __CLASS__);
59 -
60 - $this->setCoordinates();
61 - $this->setCentre();
62 - $this->setZoom();
63 -
64 - // Create html element names
65 - $this->setMapName();
66 - $this->mapName .= '_'.$sfgTabIndex;
67 - $this->geocodeFieldName = $this->elementNamePrefix.'_geocode_'.$this->elementNr.'_'.$sfgTabIndex;
68 - $this->coordsFieldName = $this->elementNamePrefix.'_coords_'.$this->elementNr.'_'.$sfgTabIndex;
69 - $this->infoFieldName = $this->elementNamePrefix.'_info_'.$this->elementNr.'_'.$sfgTabIndex;
70 -
71 - // Create the non specific form HTML
72 - $this->output .= "
73 - <input id='".$this->coordsFieldName."' name='$input_name' type='text' value='$this->startingCoords' size='40' tabindex='$sfgTabIndex'>
74 - <span id='".$this->infoFieldName."' class='error_message'></span>";
75 -
76 - if ($this->enableGeocoding) {
77 - $sfgTabIndex++;
78 -
79 - // Retrieve language values
80 - // wfLoadExtensionMessages( 'SemanticMaps' ); // TODO: remove?
81 - $enter_address_here_text = wfMsg('semanticmaps_enteraddresshere');
82 - $lookup_coordinates_text = wfMsg('semanticmaps_lookupcoordinates');
83 - $not_found_text = wfMsg('semanticmaps_notfound');
84 -
85 - $adress_field = smfGetDynamicInput($this->geocodeFieldName, $enter_address_here_text, 'size="30" name="geocode" style="color: #707070" tabindex="'.$sfgTabIndex.'"');
86 - $this->output .= "
87 - <p>
88 - $adress_field
89 - <input type='submit' onClick=\"$this->showAddresFunction(document.forms['createbox'].$this->geocodeFieldName.value, '$this->mapName', '$this->coordsFieldName', '$not_found_text'); return false\" value='$lookup_coordinates_text' />
90 - </p>";
91 - }
92 -
93 - $this->addSpecificMapHTML();
94 -
95 - return array($this->output, '');
96 - }
97 -
98 - /**
99 - * Sets the zoom so the whole map is visible in case there is no maker yet,
100 - * and sets it to the default when there is a marker but no zoom parameter.
101 - */
102 - private function setZoom() {
103 - if (empty($this->coordinates)) {
104 - $this->zoom = $this->earthZoom;
105 - } else if (strlen($this->zoom) < 1) {
106 - $this->zoom = $this->defaultZoom;
107 - }
108 - }
109 -
110 - /**
111 - * Sets the $marler_lon and $marler_lat fields and when set, the starting coordinates
112 - *
113 - */
114 - private function setCoordinates() {
115 - if (empty($this->coordinates)) {
116 - // If no coordinates exist yet, no marker should be displayed
117 - $this->marker_lat = 'null';
118 - $this->marker_lon = 'null';
119 - }
120 - else {
121 - $marker = MapsUtils::getLatLon($this->coordinates);
122 - $this->marker_lat = $marker['lat'];
123 - $this->marker_lon = $marker['lon'];
124 - $this->startingCoords = MapsUtils::latDecimal2Degree($this->marker_lat) . ', ' . MapsUtils::lonDecimal2Degree($this->marker_lon);
125 - }
126 - }
127 -
128 - /**
129 - * Sets the $centre_lat and $centre_lon fields.
130 - * Note: this needs to be done AFTRE the maker coordinates are set.
131 - *
132 - */
133 - private function setCentre() {
134 - if (empty($this->centre)) {
135 - if (isset($this->coordinates)) {
136 - $this->centre_lat = $this->marker_lat;
137 - $this->centre_lon = $this->marker_lon;
138 - }
139 - else {
140 - $this->centre_lat = '0';
141 - $this->centre_lon = '0';
142 - }
143 - }
144 - else {
145 - $centre = MapsUtils::getLatLon($this->centre);
146 - $this->centre_lat = $centre['lat'];
147 - $this->centre_lon = $centre['lon'];
148 - }
149 - }
150 -}
151 -
 2+<?php
 3+
 4+/**
 5+ * Abstract class that provides the common functionallity for all map form inputs
 6+ *
 7+ * @file SM_FormInput.php
 8+ * @ingroup SemanticMaps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+abstract class SMFormInput extends MapsMapFeature {
 18+
 19+ /**
 20+ * Determine if geocoding will be enabled and load the required dependencies.
 21+ */
 22+ protected abstract function manageGeocoding();
 23+
 24+ /**
 25+ * Ensures all dependencies for the used map are loaded, and increases that map service's count
 26+ */
 27+ protected abstract function addFormDependencies();
 28+
 29+ protected $marker_lat;
 30+ protected $marker_lon;
 31+
 32+ protected $earthZoom;
 33+
 34+ protected $showAddresFunction;
 35+
 36+ protected $enableGeocoding = false;
 37+
 38+ private $startingCoords ='';
 39+
 40+ private $coordinates;
 41+
 42+ /**
 43+ * This function is a hook for Semantic Forms, and returns the HTML needed in
 44+ * the form to handle coordinate data.
 45+ */
 46+ public final function formInputHTML($coordinates, $input_name, $is_mandatory, $is_disabled, $field_args) {
 47+ // TODO: Use function args for sf stuffz
 48+ global $sfgTabIndex;
 49+
 50+ $this->coordinates = $coordinates;
 51+
 52+ $this->manageGeocoding();
 53+
 54+ $this->setMapSettings();
 55+
 56+ $this->doMapServiceLoad();
 57+
 58+ $this->manageMapProperties($field_args, __CLASS__);
 59+
 60+ $this->setCoordinates();
 61+ $this->setCentre();
 62+ $this->setZoom();
 63+
 64+ // Create html element names
 65+ $this->setMapName();
 66+ $this->mapName .= '_'.$sfgTabIndex;
 67+ $this->geocodeFieldName = $this->elementNamePrefix.'_geocode_'.$this->elementNr.'_'.$sfgTabIndex;
 68+ $this->coordsFieldName = $this->elementNamePrefix.'_coords_'.$this->elementNr.'_'.$sfgTabIndex;
 69+ $this->infoFieldName = $this->elementNamePrefix.'_info_'.$this->elementNr.'_'.$sfgTabIndex;
 70+
 71+ // Create the non specific form HTML
 72+ $this->output .= "
 73+ <input id='".$this->coordsFieldName."' name='$input_name' type='text' value='$this->startingCoords' size='40' tabindex='$sfgTabIndex'>
 74+ <span id='".$this->infoFieldName."' class='error_message'></span>";
 75+
 76+ if ($this->enableGeocoding) {
 77+ $sfgTabIndex++;
 78+
 79+ // Retrieve language values
 80+ // wfLoadExtensionMessages( 'SemanticMaps' ); // TODO: remove?
 81+ $enter_address_here_text = wfMsg('semanticmaps_enteraddresshere');
 82+ $lookup_coordinates_text = wfMsg('semanticmaps_lookupcoordinates');
 83+ $not_found_text = wfMsg('semanticmaps_notfound');
 84+
 85+ $adress_field = smfGetDynamicInput($this->geocodeFieldName, $enter_address_here_text, 'size="30" name="geocode" style="color: #707070" tabindex="'.$sfgTabIndex.'"');
 86+ $this->output .= "
 87+ <p>
 88+ $adress_field
 89+ <input type='submit' onClick=\"$this->showAddresFunction(document.forms['createbox'].$this->geocodeFieldName.value, '$this->mapName', '$this->coordsFieldName', '$not_found_text'); return false\" value='$lookup_coordinates_text' />
 90+ </p>";
 91+ }
 92+
 93+ $this->addSpecificMapHTML();
 94+
 95+ return array($this->output, '');
 96+ }
 97+
 98+ /**
 99+ * Sets the zoom so the whole map is visible in case there is no maker yet,
 100+ * and sets it to the default when there is a marker but no zoom parameter.
 101+ */
 102+ private function setZoom() {
 103+ if (empty($this->coordinates)) {
 104+ $this->zoom = $this->earthZoom;
 105+ } else if (strlen($this->zoom) < 1) {
 106+ $this->zoom = $this->defaultZoom;
 107+ }
 108+ }
 109+
 110+ /**
 111+ * Sets the $marler_lon and $marler_lat fields and when set, the starting coordinates
 112+ *
 113+ */
 114+ private function setCoordinates() {
 115+ if (empty($this->coordinates)) {
 116+ // If no coordinates exist yet, no marker should be displayed
 117+ $this->marker_lat = 'null';
 118+ $this->marker_lon = 'null';
 119+ }
 120+ else {
 121+ $marker = MapsUtils::getLatLon($this->coordinates);
 122+ $this->marker_lat = $marker['lat'];
 123+ $this->marker_lon = $marker['lon'];
 124+ $this->startingCoords = MapsUtils::latDecimal2Degree($this->marker_lat) . ', ' . MapsUtils::lonDecimal2Degree($this->marker_lon);
 125+ }
 126+ }
 127+
 128+ /**
 129+ * Sets the $centre_lat and $centre_lon fields.
 130+ * Note: this needs to be done AFTRE the maker coordinates are set.
 131+ *
 132+ */
 133+ private function setCentre() {
 134+ if (empty($this->centre)) {
 135+ if (isset($this->coordinates)) {
 136+ $this->centre_lat = $this->marker_lat;
 137+ $this->centre_lon = $this->marker_lon;
 138+ }
 139+ else {
 140+ $this->centre_lat = '0';
 141+ $this->centre_lon = '0';
 142+ }
 143+ }
 144+ else {
 145+ $centre = MapsUtils::getLatLon($this->centre);
 146+ $this->centre_lat = $centre['lat'];
 147+ $this->centre_lon = $centre['lon'];
 148+ }
 149+ }
 150+}
 151+
Property changes on: trunk/extensions/SemanticMaps/FormInputs/SM_FormInput.php
___________________________________________________________________
Added: svn:eol-style
152152 + native
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php
@@ -1,254 +1,254 @@
2 -<?php
3 -
4 -/**
5 - * Abstract class that provides the common functionallity for all map query printers
6 - *
7 - * @file SM_MapPrinter.php
8 - * @ingroup SemanticMaps
9 - *
10 - * @author Jeroen De Dauw
11 - * @author Robert Buzink
12 - * @author Yaron Koren
13 - */
14 -
15 -if( !defined( 'MEDIAWIKI' ) ) {
16 - die( 'Not an entry point.' );
17 -}
18 -
19 -abstract class SMMapPrinter extends SMWResultPrinter {
20 -
21 - /**
22 - * Sets the map service specific element name
23 - */
24 - protected abstract function setQueryPrinterSettings();
25 -
26 - /**
27 - * Map service spesific map count and loading of dependencies
28 - */
29 - protected abstract function doMapServiceLoad();
30 -
31 - /**
32 - * Gets the query result
33 - */
34 - protected abstract function addSpecificMapHTML();
35 -
36 - public $serviceName;
37 -
38 - protected $defaultParams = array();
39 -
40 - protected $m_locations = array();
41 -
42 - protected $defaultZoom;
43 - protected $elementNr;
44 - protected $elementNamePrefix;
45 -
46 - protected $mapName;
47 -
48 - protected $centre_lat;
49 - protected $centre_lon;
50 -
51 - protected $output = '';
52 -
53 - protected $mapFeature;
54 -
55 - /**
56 - * Builds up and returns the HTML for the map, with the queried coordinate data on it.
57 - *
58 - * @param unknown_type $res
59 - * @param unknown_type $outputmode
60 - * @return array
61 - */
62 - public final function getResultText($res, $outputmode) {
63 - $this->formatResultData($res, $outputmode);
64 -
65 - $this->setQueryPrinterSettings();
66 -
67 - $this->manageMapProperties($this->m_params);
68 -
69 - // Only create a map when there is at least one result.
70 - if (count($this->m_locations) > 0) {
71 - $this->doMapServiceLoad();
72 -
73 - $this->setMapName();
74 -
75 - $this->setZoom();
76 -
77 - $this->setCentre();
78 -
79 - $this->addSpecificMapHTML();
80 - }
81 -
82 - return array($this->output, 'noparse' => 'true', 'isHTML' => 'true');
83 - }
84 -
85 - public final function getResult($results, $params, $outputmode) {
86 - // Skip checks, results with 0 entries are normal
87 - $this->readParameters($params, $outputmode);
88 - return $this->getResultText($results, SMW_OUTPUT_HTML);
89 - }
90 -
91 - private function formatResultData($res, $outputmode) {
92 - while ( ($row = $res->getNext()) !== false ) {
93 - $this->addResultRow($outputmode, $row);
94 - }
95 - }
96 -
97 - /**
98 - * This function will loop through all properties (fields) of one record (row),
99 - * and add the location data, title, label and icon to the m_locations array.
100 - *
101 - * @param unknown_type $outputmode
102 - * @param unknown_type $row The record you want to add data from
103 - */
104 - private function addResultRow($outputmode, $row) {
105 - global $wgUser;
106 - $skin = $wgUser->getSkin();
107 -
108 - $title = '';
109 - $text = '';
110 - $lat = '';
111 - $lon = '';
112 -
113 - $coords = array();
114 -
115 - // Loop throught all fields of the record
116 - foreach ($row as $i => $field) {
117 - $pr = $field->getPrintRequest();
118 -
119 - // Loop throught all the parts of the field value
120 - while ( ($object = $field->getNextObject()) !== false ) {
121 - if ($object->getTypeID() == '_wpg' && $i == 0) {
122 - $title = $object->getLongText($outputmode, $skin);
123 - }
124 -
125 - if ($object->getTypeID() != '_geo' && $i != 0) {
126 - $text .= $pr->getHTMLText($skin) . ': ' . $object->getLongText($outputmode, $skin) . '<br />';
127 - }
128 -
129 - if ($pr->getMode() == SMWPrintRequest::PRINT_PROP && $pr->getTypeID() == '_geo') {
130 - $coords[] = explode(',', $object->getXSDValue());
131 - }
132 - }
133 - }
134 -
135 - foreach ($coords as $coord) {
136 - if (count($coord) == 2) {
137 - list($lat, $lon) = $coord;
138 -
139 - if (strlen($lat) > 0 && strlen($lon) > 0) {
140 - $icon = $this->getLocationIcon($row);
141 - $this->m_locations[] = array($lat, $lon, $title, $text, $icon);
142 - }
143 -
144 - }
145 - }
146 -
147 - }
148 -
149 - /**
150 - * Get the icon for a row
151 - *
152 - * @param unknown_type $row
153 - * @return unknown
154 - */
155 - private function getLocationIcon($row) {
156 - $icon = '';
157 - $legend_labels = array();
158 -
159 - // Look for display_options field, which can be set by Semantic Compound Queries
160 - if (property_exists($row[0], 'display_options')) {
161 - if (array_key_exists('icon', $row[0]->display_options)) {
162 - $icon = $row[0]->display_options['icon'];
163 -
164 - // This is somewhat of a hack - if a legend label has been set, we're getting it for every point, instead of just once per icon
165 - if (array_key_exists('legend label', $row[0]->display_options)) {
166 -
167 - $legend_label = $row[0]->display_options['legend label'];
168 -
169 - if (! array_key_exists($icon, $legend_labels)) {
170 - $legend_labels[$icon] = $legend_label;
171 - }
172 - }
173 - }
174 - // Icon can be set even for regular, non-compound queries If it is, though, we have to translate the name into a URL here
175 - } elseif (array_key_exists('icon', $this->m_params)) {
176 -
177 - $icon_title = Title::newFromText($this->m_params['icon']);
178 - $icon_image_page = new ImagePage($icon_title);
179 - $icon = $icon_image_page->getDisplayedFile()->getURL();
180 - }
181 -
182 - return $icon;
183 - }
184 -
185 - private function manageMapProperties($mapProperties) {
186 - global $egMapsServices;
187 -
188 - $mapProperties = MapsMapper::getValidParams($mapProperties, $egMapsServices[$this->serviceName]['parameters']);
189 - $mapProperties = MapsMapper::setDefaultParValues($mapProperties, $this->defaultParams);
190 -
191 - if (isset($this->serviceName)) $mapProperties['service'] = $this->serviceName;
192 -
193 - // Go through the array with map parameters and create new variables
194 - // with the name of the key and value of the item if they don't exist on class level yet.
195 - foreach($mapProperties as $paramName => $paramValue) {
196 - if (!property_exists(__CLASS__, $paramName)) {
197 - $this->{$paramName} = $paramValue;
198 - }
199 - }
200 -
201 - MapsMapper::enforceArrayValues($this->controls);
202 - }
203 -
204 - /**
205 - * Sets the zoom level to the provided value, or when not set, to the default.
206 - *
207 - */
208 - private function setZoom() {
209 - if (strlen($this->zoom) < 1) {
210 - if (count($this->m_locations) > 1) {
211 - $this->zoom = 'null';
212 - }
213 - else {
214 - $this->zoom = $this->defaultZoom;
215 - }
216 - }
217 - }
218 -
219 - /**
220 - * Sets the $centre_lat and $centre_lon fields.
221 - * Note: this needs to be done AFTRE the maker coordinates are set.
222 - *
223 - */
224 - private function setCentre() {
225 - if (strlen($this->centre) > 0) {
226 - // If a centre value is set, use it.
227 - $centre = MapsUtils::getLatLon($this->centre);
228 - $this->centre_lat = $centre['lat'];
229 - $this->centre_lon = $centre['lon'];
230 - }
231 - elseif (count($this->m_locations) > 1) {
232 - // If centre is not set, and there are multiple points, set the values to null, to be auto determined by the JS of the mapping API.
233 - $this->centre_lat = 'null';
234 - $this->centre_lon = 'null';
235 - }
236 - else {
237 - // If centre is not set and there is exactelly one marker, use it's coordinates.
238 - $this->centre_lat = $this->m_locations[0][0];
239 - $this->centre_lon = $this->m_locations[0][1];
240 - }
241 - }
242 -
243 - /**
244 - * Sets the $mapName field, using the $elementNamePrefix and $elementNr.
245 - *
246 - */
247 - protected function setMapName() {
248 - $this->mapName = $this->elementNamePrefix.'_'.$this->elementNr;
249 - }
250 -
251 - public final function getName() {
252 - return wfMsg('maps_' . $this->serviceName);
253 - }
254 -
255 -}
 2+<?php
 3+
 4+/**
 5+ * Abstract class that provides the common functionallity for all map query printers
 6+ *
 7+ * @file SM_MapPrinter.php
 8+ * @ingroup SemanticMaps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ * @author Robert Buzink
 12+ * @author Yaron Koren
 13+ */
 14+
 15+if( !defined( 'MEDIAWIKI' ) ) {
 16+ die( 'Not an entry point.' );
 17+}
 18+
 19+abstract class SMMapPrinter extends SMWResultPrinter {
 20+
 21+ /**
 22+ * Sets the map service specific element name
 23+ */
 24+ protected abstract function setQueryPrinterSettings();
 25+
 26+ /**
 27+ * Map service spesific map count and loading of dependencies
 28+ */
 29+ protected abstract function doMapServiceLoad();
 30+
 31+ /**
 32+ * Gets the query result
 33+ */
 34+ protected abstract function addSpecificMapHTML();
 35+
 36+ public $serviceName;
 37+
 38+ protected $defaultParams = array();
 39+
 40+ protected $m_locations = array();
 41+
 42+ protected $defaultZoom;
 43+ protected $elementNr;
 44+ protected $elementNamePrefix;
 45+
 46+ protected $mapName;
 47+
 48+ protected $centre_lat;
 49+ protected $centre_lon;
 50+
 51+ protected $output = '';
 52+
 53+ protected $mapFeature;
 54+
 55+ /**
 56+ * Builds up and returns the HTML for the map, with the queried coordinate data on it.
 57+ *
 58+ * @param unknown_type $res
 59+ * @param unknown_type $outputmode
 60+ * @return array
 61+ */
 62+ public final function getResultText($res, $outputmode) {
 63+ $this->formatResultData($res, $outputmode);
 64+
 65+ $this->setQueryPrinterSettings();
 66+
 67+ $this->manageMapProperties($this->m_params);
 68+
 69+ // Only create a map when there is at least one result.
 70+ if (count($this->m_locations) > 0) {
 71+ $this->doMapServiceLoad();
 72+
 73+ $this->setMapName();
 74+
 75+ $this->setZoom();
 76+
 77+ $this->setCentre();
 78+
 79+ $this->addSpecificMapHTML();
 80+ }
 81+
 82+ return array($this->output, 'noparse' => 'true', 'isHTML' => 'true');
 83+ }
 84+
 85+ public final function getResult($results, $params, $outputmode) {
 86+ // Skip checks, results with 0 entries are normal
 87+ $this->readParameters($params, $outputmode);
 88+ return $this->getResultText($results, SMW_OUTPUT_HTML);
 89+ }
 90+
 91+ private function formatResultData($res, $outputmode) {
 92+ while ( ($row = $res->getNext()) !== false ) {
 93+ $this->addResultRow($outputmode, $row);
 94+ }
 95+ }
 96+
 97+ /**
 98+ * This function will loop through all properties (fields) of one record (row),
 99+ * and add the location data, title, label and icon to the m_locations array.
 100+ *
 101+ * @param unknown_type $outputmode
 102+ * @param unknown_type $row The record you want to add data from
 103+ */
 104+ private function addResultRow($outputmode, $row) {
 105+ global $wgUser;
 106+ $skin = $wgUser->getSkin();
 107+
 108+ $title = '';
 109+ $text = '';
 110+ $lat = '';
 111+ $lon = '';
 112+
 113+ $coords = array();
 114+
 115+ // Loop throught all fields of the record
 116+ foreach ($row as $i => $field) {
 117+ $pr = $field->getPrintRequest();
 118+
 119+ // Loop throught all the parts of the field value
 120+ while ( ($object = $field->getNextObject()) !== false ) {
 121+ if ($object->getTypeID() == '_wpg' && $i == 0) {
 122+ $title = $object->getLongText($outputmode, $skin);
 123+ }
 124+
 125+ if ($object->getTypeID() != '_geo' && $i != 0) {
 126+ $text .= $pr->getHTMLText($skin) . ': ' . $object->getLongText($outputmode, $skin) . '<br />';
 127+ }
 128+
 129+ if ($pr->getMode() == SMWPrintRequest::PRINT_PROP && $pr->getTypeID() == '_geo') {
 130+ $coords[] = explode(',', $object->getXSDValue());
 131+ }
 132+ }
 133+ }
 134+
 135+ foreach ($coords as $coord) {
 136+ if (count($coord) == 2) {
 137+ list($lat, $lon) = $coord;
 138+
 139+ if (strlen($lat) > 0 && strlen($lon) > 0) {
 140+ $icon = $this->getLocationIcon($row);
 141+ $this->m_locations[] = array($lat, $lon, $title, $text, $icon);
 142+ }
 143+
 144+ }
 145+ }
 146+
 147+ }
 148+
 149+ /**
 150+ * Get the icon for a row
 151+ *
 152+ * @param unknown_type $row
 153+ * @return unknown
 154+ */
 155+ private function getLocationIcon($row) {
 156+ $icon = '';
 157+ $legend_labels = array();
 158+
 159+ // Look for display_options field, which can be set by Semantic Compound Queries
 160+ if (property_exists($row[0], 'display_options')) {
 161+ if (array_key_exists('icon', $row[0]->display_options)) {
 162+ $icon = $row[0]->display_options['icon'];
 163+
 164+ // This is somewhat of a hack - if a legend label has been set, we're getting it for every point, instead of just once per icon
 165+ if (array_key_exists('legend label', $row[0]->display_options)) {
 166+
 167+ $legend_label = $row[0]->display_options['legend label'];
 168+
 169+ if (! array_key_exists($icon, $legend_labels)) {
 170+ $legend_labels[$icon] = $legend_label;
 171+ }
 172+ }
 173+ }
 174+ // Icon can be set even for regular, non-compound queries If it is, though, we have to translate the name into a URL here
 175+ } elseif (array_key_exists('icon', $this->m_params)) {
 176+
 177+ $icon_title = Title::newFromText($this->m_params['icon']);
 178+ $icon_image_page = new ImagePage($icon_title);
 179+ $icon = $icon_image_page->getDisplayedFile()->getURL();
 180+ }
 181+
 182+ return $icon;
 183+ }
 184+
 185+ private function manageMapProperties($mapProperties) {
 186+ global $egMapsServices;
 187+
 188+ $mapProperties = MapsMapper::getValidParams($mapProperties, $egMapsServices[$this->serviceName]['parameters']);
 189+ $mapProperties = MapsMapper::setDefaultParValues($mapProperties, $this->defaultParams);
 190+
 191+ if (isset($this->serviceName)) $mapProperties['service'] = $this->serviceName;
 192+
 193+ // Go through the array with map parameters and create new variables
 194+ // with the name of the key and value of the item if they don't exist on class level yet.
 195+ foreach($mapProperties as $paramName => $paramValue) {
 196+ if (!property_exists(__CLASS__, $paramName)) {
 197+ $this->{$paramName} = $paramValue;
 198+ }
 199+ }
 200+
 201+ MapsMapper::enforceArrayValues($this->controls);
 202+ }
 203+
 204+ /**
 205+ * Sets the zoom level to the provided value, or when not set, to the default.
 206+ *
 207+ */
 208+ private function setZoom() {
 209+ if (strlen($this->zoom) < 1) {
 210+ if (count($this->m_locations) > 1) {
 211+ $this->zoom = 'null';
 212+ }
 213+ else {
 214+ $this->zoom = $this->defaultZoom;
 215+ }
 216+ }
 217+ }
 218+
 219+ /**
 220+ * Sets the $centre_lat and $centre_lon fields.
 221+ * Note: this needs to be done AFTRE the maker coordinates are set.
 222+ *
 223+ */
 224+ private function setCentre() {
 225+ if (strlen($this->centre) > 0) {
 226+ // If a centre value is set, use it.
 227+ $centre = MapsUtils::getLatLon($this->centre);
 228+ $this->centre_lat = $centre['lat'];
 229+ $this->centre_lon = $centre['lon'];
 230+ }
 231+ elseif (count($this->m_locations) > 1) {
 232+ // If centre is not set, and there are multiple points, set the values to null, to be auto determined by the JS of the mapping API.
 233+ $this->centre_lat = 'null';
 234+ $this->centre_lon = 'null';
 235+ }
 236+ else {
 237+ // If centre is not set and there is exactelly one marker, use it's coordinates.
 238+ $this->centre_lat = $this->m_locations[0][0];
 239+ $this->centre_lon = $this->m_locations[0][1];
 240+ }
 241+ }
 242+
 243+ /**
 244+ * Sets the $mapName field, using the $elementNamePrefix and $elementNr.
 245+ *
 246+ */
 247+ protected function setMapName() {
 248+ $this->mapName = $this->elementNamePrefix.'_'.$this->elementNr;
 249+ }
 250+
 251+ public final function getName() {
 252+ return wfMsg('maps_' . $this->serviceName);
 253+ }
 254+
 255+}
Property changes on: trunk/extensions/SemanticMaps/QueryPrinters/SM_MapPrinter.php
___________________________________________________________________
Added: svn:eol-style
256256 + native
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_Mapper.php
@@ -1,47 +1,47 @@
2 -<?php
3 -
4 -/**
5 - * General map query printer class
6 - *
7 - * @file SM_Mapper.php
8 - * @ingroup SemanticMaps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -final class SMMapper {
18 -
19 - private $queryPrinter;
20 -
21 - public function __construct($format, $inline) {
22 - global $egMapsDefaultServices, $egMapsServices;
23 -
24 - // TODO: allow service parameter to override the default
25 - if ($format == 'map') $format = $egMapsDefaultServices['qp'];
26 -
27 - $service = MapsMapper::getValidService($format, 'qp');
28 -
29 - $this->queryPrinter = new $egMapsServices[$service]['qp']['class']($format, $inline);
30 - }
31 -
32 - public function getName() {
33 - return $this->queryPrinter->getName();
34 - }
35 -
36 - public function getQueryMode($context) {
37 - return $this->queryPrinter->getQueryMode($context);
38 - }
39 -
40 - public function getResult($results, $params, $outputmode) {
41 - return $this->queryPrinter->getResult($results, $params, $outputmode);
42 - }
43 -
44 - protected function getResultText($res, $outputmode) {
45 - return $this->queryPrinter->getResultText($res, $outputmode);
46 - }
47 -
48 -}
 2+<?php
 3+
 4+/**
 5+ * General map query printer class
 6+ *
 7+ * @file SM_Mapper.php
 8+ * @ingroup SemanticMaps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+final class SMMapper {
 18+
 19+ private $queryPrinter;
 20+
 21+ public function __construct($format, $inline) {
 22+ global $egMapsDefaultServices, $egMapsServices;
 23+
 24+ // TODO: allow service parameter to override the default
 25+ if ($format == 'map') $format = $egMapsDefaultServices['qp'];
 26+
 27+ $service = MapsMapper::getValidService($format, 'qp');
 28+
 29+ $this->queryPrinter = new $egMapsServices[$service]['qp']['class']($format, $inline);
 30+ }
 31+
 32+ public function getName() {
 33+ return $this->queryPrinter->getName();
 34+ }
 35+
 36+ public function getQueryMode($context) {
 37+ return $this->queryPrinter->getQueryMode($context);
 38+ }
 39+
 40+ public function getResult($results, $params, $outputmode) {
 41+ return $this->queryPrinter->getResult($results, $params, $outputmode);
 42+ }
 43+
 44+ protected function getResultText($res, $outputmode) {
 45+ return $this->queryPrinter->getResultText($res, $outputmode);
 46+ }
 47+
 48+}
Property changes on: trunk/extensions/SemanticMaps/QueryPrinters/SM_Mapper.php
___________________________________________________________________
Added: svn:eol-style
4949 + native
Index: trunk/extensions/SemanticMaps/QueryPrinters/SM_QueryPrinters.php
@@ -1,70 +1,70 @@
2 -<?php
3 -
4 -/**
5 - * Initialization file for query printer functionality in the Maps extension
6 - *
7 - * @file SM_FormInputs.php
8 - * @ingroup SemanticMaps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -final class SMQueryPrinters {
18 -
19 - public static function initialize() {
20 - global $smgIP, $wgAutoloadClasses, $egMapsServices;
21 -
22 - $wgAutoloadClasses['SMMapPrinter'] = $smgIP . '/QueryPrinters/SM_MapPrinter.php';
23 -
24 - global $egMapsServices;
25 -
26 - $hasQueryPrinters = false;
27 -
28 - foreach($egMapsServices as $serviceName => $serviceData) {
29 - // Check if the service has a query printer
30 - $hasQP = array_key_exists('qp', $serviceData);
31 -
32 - // If the service has no QP, skipt it and continue with the next one.
33 - if (!$hasQP) continue;
34 -
35 - // At least one query printer will be enabled when this point is reached.
36 - $hasQueryPrinters = true;
37 -
38 - // Add the result format for the service name.
39 - self::initFormat($serviceName, $serviceData['qp']);
40 -
41 - // Loop through the service alliases, and add them as result formats to the query printer.
42 - foreach ($serviceData['aliases'] as $alias) self::initFormat($alias, $serviceData['qp']);
43 - }
44 -
45 - // Add the 'map' result format if there are mapping services that have QP's loaded.
46 - if ($hasQueryPrinters) self::initFormat('map', array('class' => 'SMMapper', 'file' => 'QueryPrinters/SM_Mapper.php', 'local' => true));
47 - }
48 -
49 - /**
50 - * Add the result format for a mapping service or alias
51 - *
52 - * @param string $format
53 - * @param array $qp
54 - */
55 - private static function initFormat($format, array $qp) {
56 - global $wgAutoloadClasses, $smwgResultFormats, $smgIP;
57 -
58 - if (! array_key_exists($qp['class'], $wgAutoloadClasses)) {
59 - $file = $qp['local'] ? $smgIP . '/' . $qp['file'] : $qp['file'];
60 - $wgAutoloadClasses[$qp['class']] = $file;
61 - }
62 -
63 - if (isset($smwgResultFormats)) {
64 - $smwgResultFormats[$format] = $qp['class'];
65 - }
66 - else {
67 - SMWQueryProcessor::$formats[$format] = $qp['class'];
68 - }
69 - }
70 -
 2+<?php
 3+
 4+/**
 5+ * Initialization file for query printer functionality in the Maps extension
 6+ *
 7+ * @file SM_FormInputs.php
 8+ * @ingroup SemanticMaps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+final class SMQueryPrinters {
 18+
 19+ public static function initialize() {
 20+ global $smgIP, $wgAutoloadClasses, $egMapsServices;
 21+
 22+ $wgAutoloadClasses['SMMapPrinter'] = $smgIP . '/QueryPrinters/SM_MapPrinter.php';
 23+
 24+ global $egMapsServices;
 25+
 26+ $hasQueryPrinters = false;
 27+
 28+ foreach($egMapsServices as $serviceName => $serviceData) {
 29+ // Check if the service has a query printer
 30+ $hasQP = array_key_exists('qp', $serviceData);
 31+
 32+ // If the service has no QP, skipt it and continue with the next one.
 33+ if (!$hasQP) continue;
 34+
 35+ // At least one query printer will be enabled when this point is reached.
 36+ $hasQueryPrinters = true;
 37+
 38+ // Add the result format for the service name.
 39+ self::initFormat($serviceName, $serviceData['qp']);
 40+
 41+ // Loop through the service alliases, and add them as result formats to the query printer.
 42+ foreach ($serviceData['aliases'] as $alias) self::initFormat($alias, $serviceData['qp']);
 43+ }
 44+
 45+ // Add the 'map' result format if there are mapping services that have QP's loaded.
 46+ if ($hasQueryPrinters) self::initFormat('map', array('class' => 'SMMapper', 'file' => 'QueryPrinters/SM_Mapper.php', 'local' => true));
 47+ }
 48+
 49+ /**
 50+ * Add the result format for a mapping service or alias
 51+ *
 52+ * @param string $format
 53+ * @param array $qp
 54+ */
 55+ private static function initFormat($format, array $qp) {
 56+ global $wgAutoloadClasses, $smwgResultFormats, $smgIP;
 57+
 58+ if (! array_key_exists($qp['class'], $wgAutoloadClasses)) {
 59+ $file = $qp['local'] ? $smgIP . '/' . $qp['file'] : $qp['file'];
 60+ $wgAutoloadClasses[$qp['class']] = $file;
 61+ }
 62+
 63+ if (isset($smwgResultFormats)) {
 64+ $smwgResultFormats[$format] = $qp['class'];
 65+ }
 66+ else {
 67+ SMWQueryProcessor::$formats[$format] = $qp['class'];
 68+ }
 69+ }
 70+
7171 }
\ No newline at end of file
Property changes on: trunk/extensions/SemanticMaps/QueryPrinters/SM_QueryPrinters.php
___________________________________________________________________
Added: svn:eol-style
7272 + native
Index: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsQP.php
@@ -1,100 +1,100 @@
2 -<?php
3 -/**
4 - * A query printer for maps using the Google Maps API
5 - *
6 - * @file SM_GoogleMaps.php
7 - * @ingroup SemanticMaps
8 - *
9 - * @author Robert Buzink
10 - * @author Yaron Koren
11 - * @author Jeroen De Dauw
12 - */
13 -
14 -if( !defined( 'MEDIAWIKI' ) ) {
15 - die( 'Not an entry point.' );
16 -}
17 -
18 -final class SMGoogleMapsQP extends SMMapPrinter {
19 -
20 - public $serviceName = MapsGoogleMapsUtils::SERVICE_NAME;
21 -
22 - /**
23 - * @see SMMapPrinter::setQueryPrinterSettings()
24 - *
25 - */
26 - protected function setQueryPrinterSettings() {
27 - global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix;
28 -
29 - $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
30 -
31 - $this->defaultZoom = $egMapsGoogleMapsZoom;
32 -
33 - $this->defaultParams = MapsGoogleMapsUtils::getDefaultParams();
34 - }
35 -
36 - /**
37 - * @see SMMapPrinter::doMapServiceLoad()
38 - *
39 - */
40 - protected function doMapServiceLoad() {
41 - global $egGoogleMapsOnThisPage;
42 -
43 - if (empty($egGoogleMapsOnThisPage)) {
44 - $egGoogleMapsOnThisPage = 0;
45 - MapsGoogleMapsUtils::addGMapDependencies($this->output);
46 - }
47 -
48 - $egGoogleMapsOnThisPage++;
49 -
50 - $this->elementNr = $egGoogleMapsOnThisPage;
51 - }
52 -
53 - /**
54 - * @see SMMapPrinter::getQueryResult()
55 - *
56 - */
57 - protected function addSpecificMapHTML() {
58 - global $wgJsMimeType;
59 -
60 - $enableEarth = MapsGoogleMapsUtils::getEarthValue($this->earth);
61 -
62 - // Get the Google Maps names for the control and map types
63 - $this->type = MapsGoogleMapsUtils::getGMapType($this->type, true);
64 -
65 - $this->controls = MapsGoogleMapsUtils::createControlsString($this->controls);
66 -
67 - $this->autozoom = MapsGoogleMapsUtils::getAutozoomJSValue($this->autozoom);
68 -
69 - $markerItems = array();
70 -
71 - foreach ($this->m_locations as $location) {
72 - list($lat, $lon, $title, $label, $icon) = $location;
73 -
74 - $title = str_replace("'", "\'", $title);
75 - $label = str_replace("'", "\'", $label);
76 -
77 - $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label', '$icon')";
78 - }
79 -
80 - // Create a string containing the marker JS
81 - $markersString = implode(',', $markerItems);
82 -
83 - $this->types = explode(",", $this->types);
84 -
85 - $typesString = MapsGoogleMapsUtils::createTypesString($this->types, $enableEarth);
86 -
87 - $this->output .= <<<END
88 -<div id="$this->mapName" class="$this->class" style="$this->style" ></div>
89 -<script type="$wgJsMimeType"> /*<![CDATA[*/
90 -addLoadEvent(
91 - initializeGoogleMap('$this->mapName', $this->width, $this->height, $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
92 -);
93 -/*]]>*/ </script>
94 -
95 -END;
96 -
97 - }
98 -
99 -
100 -}
101 -
 2+<?php
 3+/**
 4+ * A query printer for maps using the Google Maps API
 5+ *
 6+ * @file SM_GoogleMaps.php
 7+ * @ingroup SemanticMaps
 8+ *
 9+ * @author Robert Buzink
 10+ * @author Yaron Koren
 11+ * @author Jeroen De Dauw
 12+ */
 13+
 14+if( !defined( 'MEDIAWIKI' ) ) {
 15+ die( 'Not an entry point.' );
 16+}
 17+
 18+final class SMGoogleMapsQP extends SMMapPrinter {
 19+
 20+ public $serviceName = MapsGoogleMapsUtils::SERVICE_NAME;
 21+
 22+ /**
 23+ * @see SMMapPrinter::setQueryPrinterSettings()
 24+ *
 25+ */
 26+ protected function setQueryPrinterSettings() {
 27+ global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix;
 28+
 29+ $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
 30+
 31+ $this->defaultZoom = $egMapsGoogleMapsZoom;
 32+
 33+ $this->defaultParams = MapsGoogleMapsUtils::getDefaultParams();
 34+ }
 35+
 36+ /**
 37+ * @see SMMapPrinter::doMapServiceLoad()
 38+ *
 39+ */
 40+ protected function doMapServiceLoad() {
 41+ global $egGoogleMapsOnThisPage;
 42+
 43+ if (empty($egGoogleMapsOnThisPage)) {
 44+ $egGoogleMapsOnThisPage = 0;
 45+ MapsGoogleMapsUtils::addGMapDependencies($this->output);
 46+ }
 47+
 48+ $egGoogleMapsOnThisPage++;
 49+
 50+ $this->elementNr = $egGoogleMapsOnThisPage;
 51+ }
 52+
 53+ /**
 54+ * @see SMMapPrinter::getQueryResult()
 55+ *
 56+ */
 57+ protected function addSpecificMapHTML() {
 58+ global $wgJsMimeType;
 59+
 60+ $enableEarth = MapsGoogleMapsUtils::getEarthValue($this->earth);
 61+
 62+ // Get the Google Maps names for the control and map types
 63+ $this->type = MapsGoogleMapsUtils::getGMapType($this->type, true);
 64+
 65+ $this->controls = MapsGoogleMapsUtils::createControlsString($this->controls);
 66+
 67+ $this->autozoom = MapsGoogleMapsUtils::getAutozoomJSValue($this->autozoom);
 68+
 69+ $markerItems = array();
 70+
 71+ foreach ($this->m_locations as $location) {
 72+ list($lat, $lon, $title, $label, $icon) = $location;
 73+
 74+ $title = str_replace("'", "\'", $title);
 75+ $label = str_replace("'", "\'", $label);
 76+
 77+ $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label', '$icon')";
 78+ }
 79+
 80+ // Create a string containing the marker JS
 81+ $markersString = implode(',', $markerItems);
 82+
 83+ $this->types = explode(",", $this->types);
 84+
 85+ $typesString = MapsGoogleMapsUtils::createTypesString($this->types, $enableEarth);
 86+
 87+ $this->output .= <<<END
 88+<div id="$this->mapName" class="$this->class" style="$this->style" ></div>
 89+<script type="$wgJsMimeType"> /*<![CDATA[*/
 90+addLoadEvent(
 91+ initializeGoogleMap('$this->mapName', $this->width, $this->height, $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
 92+);
 93+/*]]>*/ </script>
 94+
 95+END;
 96+
 97+ }
 98+
 99+
 100+}
 101+
Property changes on: trunk/extensions/SemanticMaps/GoogleMaps/SM_GoogleMapsQP.php
___________________________________________________________________
Added: svn:eol-style
102102 + native
Index: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsQP.php
@@ -1,90 +1,90 @@
2 -<?php
3 -/**
4 - * A query printer for maps using the Yahoo Maps API
5 - *
6 - * @file SM_YahooMaps.php
7 - * @ingroup SemanticMaps
8 - *
9 - * @author Jeroen De Dauw
10 - */
11 -
12 -if( !defined( 'MEDIAWIKI' ) ) {
13 - die( 'Not an entry point.' );
14 -}
15 -
16 -final class SMYahooMapsQP extends SMMapPrinter {
17 -
18 - public $serviceName = MapsYahooMapsUtils::SERVICE_NAME;
19 -
20 - /**
21 - * @see SMMapPrinter::setQueryPrinterSettings()
22 - *
23 - */
24 - protected function setQueryPrinterSettings() {
25 - global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix;
26 -
27 - $this->elementNamePrefix = $egMapsYahooMapsPrefix;
28 -
29 - $this->defaultZoom = $egMapsYahooMapsZoom;
30 -
31 - $this->defaultParams = MapsYahooMapsUtils::getDefaultParams();
32 - }
33 -
34 - /**
35 - * @see SMMapPrinter::doMapServiceLoad()
36 - *
37 - */
38 - protected function doMapServiceLoad() {
39 - global $egYahooMapsOnThisPage;
40 -
41 - MapsYahooMapsUtils::addYMapDependencies($this->output);
42 - $egYahooMapsOnThisPage++;
43 -
44 - $this->elementNr = $egYahooMapsOnThisPage;
45 - }
46 -
47 - /**
48 - * @see SMMapPrinter::addSpecificMapHTML()
49 - *
50 - */
51 - protected function addSpecificMapHTML() {
52 - global $wgJsMimeType;
53 -
54 - $this->type = MapsYahooMapsUtils::getYMapType($this->type, true);
55 - $this->controls = MapsYahooMapsUtils::createControlsString($this->controls);
56 -
57 - MapsUtils::makePxValue($this->width);
58 - MapsUtils::makePxValue($this->height);
59 -
60 - $this->autozoom = MapsYahooMapsUtils::getAutozoomJSValue($this->autozoom);
61 -
62 - $markerItems = array();
63 -
64 - foreach ($this->m_locations as $location) {
65 - // Create a string containing the marker JS
66 - list($lat, $lon, $title, $label, $icon) = $location;
67 -
68 - $title = str_replace("'", "\'", $title);
69 - $label = str_replace("'", "\'", $label);
70 -
71 - $markerItems[] = "getYMarkerData($lat, $lon, '$title', '$label', '$icon')";
72 - }
73 -
74 - $markersString = implode(',', $markerItems);
75 -
76 - $this->types = explode(",", $this->types);
77 -
78 - $typesString = MapsYahooMapsUtils::createTypesString($this->types);
79 -
80 - $this->output .= "
81 - <div id='$this->mapName' style='width: $this->width; height: $this->height;'></div>
82 -
83 - <script type='$wgJsMimeType'>/*<![CDATA[*/
84 - addLoadEvent(
85 - initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
86 - );
87 - /*]]>*/</script>";
88 -
89 - }
90 -
 2+<?php
 3+/**
 4+ * A query printer for maps using the Yahoo Maps API
 5+ *
 6+ * @file SM_YahooMaps.php
 7+ * @ingroup SemanticMaps
 8+ *
 9+ * @author Jeroen De Dauw
 10+ */
 11+
 12+if( !defined( 'MEDIAWIKI' ) ) {
 13+ die( 'Not an entry point.' );
 14+}
 15+
 16+final class SMYahooMapsQP extends SMMapPrinter {
 17+
 18+ public $serviceName = MapsYahooMapsUtils::SERVICE_NAME;
 19+
 20+ /**
 21+ * @see SMMapPrinter::setQueryPrinterSettings()
 22+ *
 23+ */
 24+ protected function setQueryPrinterSettings() {
 25+ global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix;
 26+
 27+ $this->elementNamePrefix = $egMapsYahooMapsPrefix;
 28+
 29+ $this->defaultZoom = $egMapsYahooMapsZoom;
 30+
 31+ $this->defaultParams = MapsYahooMapsUtils::getDefaultParams();
 32+ }
 33+
 34+ /**
 35+ * @see SMMapPrinter::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egYahooMapsOnThisPage;
 40+
 41+ MapsYahooMapsUtils::addYMapDependencies($this->output);
 42+ $egYahooMapsOnThisPage++;
 43+
 44+ $this->elementNr = $egYahooMapsOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see SMMapPrinter::addSpecificMapHTML()
 49+ *
 50+ */
 51+ protected function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $this->type = MapsYahooMapsUtils::getYMapType($this->type, true);
 55+ $this->controls = MapsYahooMapsUtils::createControlsString($this->controls);
 56+
 57+ MapsUtils::makePxValue($this->width);
 58+ MapsUtils::makePxValue($this->height);
 59+
 60+ $this->autozoom = MapsYahooMapsUtils::getAutozoomJSValue($this->autozoom);
 61+
 62+ $markerItems = array();
 63+
 64+ foreach ($this->m_locations as $location) {
 65+ // Create a string containing the marker JS
 66+ list($lat, $lon, $title, $label, $icon) = $location;
 67+
 68+ $title = str_replace("'", "\'", $title);
 69+ $label = str_replace("'", "\'", $label);
 70+
 71+ $markerItems[] = "getYMarkerData($lat, $lon, '$title', '$label', '$icon')";
 72+ }
 73+
 74+ $markersString = implode(',', $markerItems);
 75+
 76+ $this->types = explode(",", $this->types);
 77+
 78+ $typesString = MapsYahooMapsUtils::createTypesString($this->types);
 79+
 80+ $this->output .= "
 81+ <div id='$this->mapName' style='width: $this->width; height: $this->height;'></div>
 82+
 83+ <script type='$wgJsMimeType'>/*<![CDATA[*/
 84+ addLoadEvent(
 85+ initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
 86+ );
 87+ /*]]>*/</script>";
 88+
 89+ }
 90+
9191 }
\ No newline at end of file
Property changes on: trunk/extensions/SemanticMaps/YahooMaps/SM_YahooMapsQP.php
___________________________________________________________________
Added: svn:eol-style
9292 + native
Index: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersQP.php
@@ -1,83 +1,83 @@
2 -<?php
3 -
4 -/**
5 - * A query printer for maps using the Open Layers API
6 - *
7 - * @file SM_OpenLayers.php
8 - * @ingroup SemanticMaps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -final class SMOpenLayersQP extends SMMapPrinter {
18 -
19 - public $serviceName = MapsOpenLayersUtils::SERVICE_NAME;
20 -
21 - /**
22 - * @see SMMapPrinter::setQueryPrinterSettings()
23 - *
24 - */
25 - protected function setQueryPrinterSettings() {
26 - global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
27 -
28 - $this->elementNamePrefix = $egMapsOpenLayersPrefix;
29 - $this->defaultZoom = $egMapsOpenLayersZoom;
30 -
31 - $this->defaultParams = MapsOpenLayersUtils::getDefaultParams();
32 - }
33 -
34 - /**
35 - * @see SMMapPrinter::doMapServiceLoad()
36 - *
37 - */
38 - protected function doMapServiceLoad() {
39 - global $egOpenLayersOnThisPage;
40 -
41 - MapsOpenLayersUtils::addOLDependencies($this->output);
42 - $egOpenLayersOnThisPage++;
43 -
44 - $this->elementNr = $egOpenLayersOnThisPage;
45 - }
46 -
47 - /**
48 - * @see SMMapPrinter::addSpecificMapHTML()
49 - *
50 - */
51 - protected function addSpecificMapHTML() {
52 - global $wgJsMimeType;
53 -
54 - $controlItems = MapsOpenLayersUtils::createControlsString($this->controls);
55 -
56 - MapsMapper::enforceArrayValues($this->layers);
57 - $layerItems = MapsOpenLayersUtils::createLayersStringAndLoadDependencies($this->output, $this->layers);
58 -
59 - MapsUtils::makePxValue($this->width);
60 - MapsUtils::makePxValue($this->height);
61 -
62 - $markerItems = array();
63 -
64 - foreach ($this->m_locations as $location) {
65 - // Create a string containing the marker JS
66 - list($lat, $lon, $title, $label, $icon) = $location;
67 -
68 - $title = str_replace("'", "\'", $title);
69 - $label = str_replace("'", "\'", $label);
70 -
71 - $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')";
72 - }
73 -
74 - $markersString = implode(',', $markerItems);
75 -
76 - $this->output .= "<div id='$this->mapName' style='width: $this->width; height: $this->height; background-color: #cccccc;'></div>
77 - <script type='$wgJsMimeType'> /*<![CDATA[*/
78 - addLoadEvent(
79 - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems], [$markersString])
80 - );
81 - /*]]>*/ </script>";
82 - }
83 -
84 -}
 2+<?php
 3+
 4+/**
 5+ * A query printer for maps using the Open Layers API
 6+ *
 7+ * @file SM_OpenLayers.php
 8+ * @ingroup SemanticMaps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+final class SMOpenLayersQP extends SMMapPrinter {
 18+
 19+ public $serviceName = MapsOpenLayersUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see SMMapPrinter::setQueryPrinterSettings()
 23+ *
 24+ */
 25+ protected function setQueryPrinterSettings() {
 26+ global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
 27+
 28+ $this->elementNamePrefix = $egMapsOpenLayersPrefix;
 29+ $this->defaultZoom = $egMapsOpenLayersZoom;
 30+
 31+ $this->defaultParams = MapsOpenLayersUtils::getDefaultParams();
 32+ }
 33+
 34+ /**
 35+ * @see SMMapPrinter::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egOpenLayersOnThisPage;
 40+
 41+ MapsOpenLayersUtils::addOLDependencies($this->output);
 42+ $egOpenLayersOnThisPage++;
 43+
 44+ $this->elementNr = $egOpenLayersOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see SMMapPrinter::addSpecificMapHTML()
 49+ *
 50+ */
 51+ protected function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $controlItems = MapsOpenLayersUtils::createControlsString($this->controls);
 55+
 56+ MapsMapper::enforceArrayValues($this->layers);
 57+ $layerItems = MapsOpenLayersUtils::createLayersStringAndLoadDependencies($this->output, $this->layers);
 58+
 59+ MapsUtils::makePxValue($this->width);
 60+ MapsUtils::makePxValue($this->height);
 61+
 62+ $markerItems = array();
 63+
 64+ foreach ($this->m_locations as $location) {
 65+ // Create a string containing the marker JS
 66+ list($lat, $lon, $title, $label, $icon) = $location;
 67+
 68+ $title = str_replace("'", "\'", $title);
 69+ $label = str_replace("'", "\'", $label);
 70+
 71+ $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')";
 72+ }
 73+
 74+ $markersString = implode(',', $markerItems);
 75+
 76+ $this->output .= "<div id='$this->mapName' style='width: $this->width; height: $this->height; background-color: #cccccc;'></div>
 77+ <script type='$wgJsMimeType'> /*<![CDATA[*/
 78+ addLoadEvent(
 79+ initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems], [$markersString])
 80+ );
 81+ /*]]>*/ </script>";
 82+ }
 83+
 84+}
Property changes on: trunk/extensions/SemanticMaps/OpenLayers/SM_OpenLayersQP.php
___________________________________________________________________
Added: svn:eol-style
8585 + native
Property changes on: trunk/extensions/HeaderTabs/skins/blank.html
___________________________________________________________________
Added: svn:eol-style
8686 + native
Property changes on: trunk/extensions/HeaderTabs/LICENSE
___________________________________________________________________
Added: svn:eol-style
8787 + native
Property changes on: trunk/extensions/SemanticForms/libs/SF_ajax_form_preview.js
___________________________________________________________________
Added: svn:eol-style
8888 + native
Index: trunk/extensions/StringFunctionsEscaped/README
@@ -1,185 +1,185 @@
2 -{{Extension|templatemode=
3 -|name = StringFunctionsEscaped
4 -|status = beta
5 -|type1 = parser function
6 -|type2 =
7 -|hook1 = LanguageGetMagic
8 -|hook2 =
9 -|username = [[user:jpond | Jack D. Pond ]]
10 -|author =
11 -|description = Defines a superset of string parser functions that allow character escaping in the 'search for' and 'replace with' arguments.
12 -|image =
13 -|imagesize =
14 -|version = 1.0.0
15 -|update = 2009-09-11
16 -|mediawiki = Tested with 1.14,1.15,1.16A, Should work with all
17 -|php =
18 -|license = GNU Version 2
19 -|download =
20 -|readme =
21 -|changelog =
22 -|parameters = $wgPFEnableStringFunctions
23 -|tags =
24 -|rights =
25 -|example =
26 -|compatibility =
27 -}}
28 -
29 -
30 -
31 -==What can this extension do?==
32 -
33 -Wikitext allows the imbedding of certain control characters (newline, tab, etc.). These parser functions allow them to be identified and used with standard c-type escape character sequence (/n,/t, etc.).
34 -
35 -These can be used (among other things) to make infoblox-type templates much more WYSIWIG (see Examples) for novice/non-technical users.
36 -
37 -==Usage==
38 -
39 -These functions are all invoked exactly as their string parser functions would be (except with the '_e' appended to distinguish).
40 -
41 -=== pos_e: (string position)===
42 -
43 -<nowiki>{{#pos_e:value|key|offset}}</nowiki>
44 -
45 -Returns the first position of key inside the given value, or an empty string.
46 -If offset is defined, this method will not search the first offset characters.
47 -
48 -See: http://php.net/manual/function.strpos.php
49 -
50 -=== rpos_e: (string position, reverse) ===
51 -<nowiki>{{#rpos_e:value|key}}</nowiki>
52 -Returns the last position of key inside the given value, or -1 if the key is not found. When using this to search for the last delimiter, add +1 to the result to retreive position after the last delimiter. This also works when the delimiter is not found, because "-1 + 1" is zero, which is the beginning of the given value.
53 -
54 -See: http://php.net/manual/function.strrpos.php
55 -
56 -=== pad_e: (pad string) ===
57 -<nowiki>{{#pad_e:value|length|with|direction}}</nowiki>
58 -
59 -Returns the value padded to the certain length with the given with string.
60 -If the with string is not given, spaces are used for padding. The direction may be specified as: 'left', 'center' or 'right'.
61 -
62 -See: http://php.net/manual/function.str-pad.php
63 -
64 -=== replace_e: (string replace) ===
65 -
66 -<nowiki>{{#replace_e:value|from|to}}</nowiki>
67 -
68 -Returns the given value with all occurences of 'from' replaced with 'to'.
69 -
70 -See: http://php.net/manual/function.str-replace.php
71 -
72 -=== explode_e: (explode string) ===
73 -<nowiki>{{#explode_e:value|delimiter|position}}</nowiki>
74 -
75 -Splits the given value into pieces by the given delimiter and returns the position-th piece. Empty string is returned if there are not enough pieces.
76 -
77 -Note: Pieces are counted from 0.<br>
78 -Note: A negative value can be used to count pieces from the end, instead of counting from the beginning. The last piece is at position -1.
79 -
80 -See: http://php.net/manual/function.explode.php
81 -
82 -==Download instructions==
83 -<!-- revise these instructions if code is available via a download site -->
84 -Please cut and paste the code found [[#Code|below]] and place it in <code>$IP/extensions/ExtensionName/ExtensionName.php</code>. ''Note: [[Manual:$IP|$IP]] stands for the root directory of your MediaWiki installation, the same directory that holds [[Manual:LocalSettings.php|LocalSettings.php]]''.
85 -
86 -==Installation==
87 -String functions were integrated into [[Extension:ParserFunctions]] extension as of [[Special:Code/MediaWiki/50997|r50997]]. This revision of [[Extension:ParserFunctions]] is designed for MediaWiki 1.16, but updating to the trunk version may work on previous versions. If you are using a prior version of [[Extension:ParserFunctions]], you will also have to include [[Extension:StringFunctions]].
88 -
89 -Install and test [[Extension:ParserFunctions]] and (if necessary) [[Extension:StringFunctions]] prior to installing this extension.
90 -
91 -This extension must be included AFTER the invocation of the string parser functions.
92 -To install this extension, add the following to [[Manual:LocalSettings.php|LocalSettings.php]]:
93 -
94 -=== For MediaWiki 1.15.1 and before ===
95 -<source lang="php">
96 -require_once("$IP/extensions/ParserFunctions/ParserFunctions.php");
97 -require_once("$IP/extensions/StringFunctions/StringFunctions.php");
98 -require_once("$IP/extensions/StringFunctionsEscaped/StringFunctionsEscaped.php");
99 -</source>
100 -
101 -=== For MediaWiki 1.16a and after ===
102 -<source lang="php">
103 -require_once("$IP/extensions/ParserFunctions/ParserFunctions.php");
104 -$wgPFEnableStringFunctions = true; // Note: this must be after ParserFunctions and before StringFunctionsEscaped
105 -require_once("$IP/extensions/StringFunctionsEscaped/StringFunctionsEscaped.php");
106 -</source>
107 -==Examples==
108 -
109 -=== pos_e ===
110 -
111 -<pre>
112 -{{#pos_e:Line 1
113 -Line 2
114 -Line 3|\n|7}}
115 -
116 -Returns:
117 -
118 -13
119 -</pre>
120 -
121 -=== rpos_e ===
122 -<pre>
123 -{{#rpos_e:Line 1
124 -Line 2
125 -Line 3|\n}}
126 -
127 -Returns:
128 -
129 -13
130 -</pre>
131 -
132 -=== pad_e ===
133 -<pre>
134 -~~{{#pad_e:xox|9|\n|center}}~~
135 -
136 -Returns:
137 -
138 -~~
139 -
140 -
141 -xox
142 -
143 -
144 -~~
145 -</pre>
146 -
147 -=== replace_e ===
148 -<pre>
149 -{{#replace_e:Line 1
150 -Line 2
151 -Line 3|\n|<br>\n}}
152 -
153 -Returns:
154 -
155 -Line 1<br>
156 -Line 2<br>
157 -Line 3
158 -
159 -Which would display as:
160 -
161 -Line 1
162 -Line 2
163 -Line 3
164 -
165 -Rather than the unescaped:
166 -
167 -Line 1 Line 2 Line 3
168 -
169 -</pre>
170 -
171 -=== explode_e ===
172 -<pre>
173 -{{#explode_e:Line 1
174 -Line 2
175 -Line 3|\n|1}}
176 -
177 -Returns:
178 -
179 -Line 2
180 -
181 -</pre>
182 -==See also==
183 -
184 -* [[Extension:ParserFunctions]]
185 -* [[Extension:StringFunctions]]
186 -* [[Extension:Lua]]
 2+{{Extension|templatemode=
 3+|name = StringFunctionsEscaped
 4+|status = beta
 5+|type1 = parser function
 6+|type2 =
 7+|hook1 = LanguageGetMagic
 8+|hook2 =
 9+|username = [[user:jpond | Jack D. Pond ]]
 10+|author =
 11+|description = Defines a superset of string parser functions that allow character escaping in the 'search for' and 'replace with' arguments.
 12+|image =
 13+|imagesize =
 14+|version = 1.0.0
 15+|update = 2009-09-11
 16+|mediawiki = Tested with 1.14,1.15,1.16A, Should work with all
 17+|php =
 18+|license = GNU Version 2
 19+|download =
 20+|readme =
 21+|changelog =
 22+|parameters = $wgPFEnableStringFunctions
 23+|tags =
 24+|rights =
 25+|example =
 26+|compatibility =
 27+}}
 28+
 29+
 30+
 31+==What can this extension do?==
 32+
 33+Wikitext allows the imbedding of certain control characters (newline, tab, etc.). These parser functions allow them to be identified and used with standard c-type escape character sequence (/n,/t, etc.).
 34+
 35+These can be used (among other things) to make infoblox-type templates much more WYSIWIG (see Examples) for novice/non-technical users.
 36+
 37+==Usage==
 38+
 39+These functions are all invoked exactly as their string parser functions would be (except with the '_e' appended to distinguish).
 40+
 41+=== pos_e: (string position)===
 42+
 43+<nowiki>{{#pos_e:value|key|offset}}</nowiki>
 44+
 45+Returns the first position of key inside the given value, or an empty string.
 46+If offset is defined, this method will not search the first offset characters.
 47+
 48+See: http://php.net/manual/function.strpos.php
 49+
 50+=== rpos_e: (string position, reverse) ===
 51+<nowiki>{{#rpos_e:value|key}}</nowiki>
 52+Returns the last position of key inside the given value, or -1 if the key is not found. When using this to search for the last delimiter, add +1 to the result to retreive position after the last delimiter. This also works when the delimiter is not found, because "-1 + 1" is zero, which is the beginning of the given value.
 53+
 54+See: http://php.net/manual/function.strrpos.php
 55+
 56+=== pad_e: (pad string) ===
 57+<nowiki>{{#pad_e:value|length|with|direction}}</nowiki>
 58+
 59+Returns the value padded to the certain length with the given with string.
 60+If the with string is not given, spaces are used for padding. The direction may be specified as: 'left', 'center' or 'right'.
 61+
 62+See: http://php.net/manual/function.str-pad.php
 63+
 64+=== replace_e: (string replace) ===
 65+
 66+<nowiki>{{#replace_e:value|from|to}}</nowiki>
 67+
 68+Returns the given value with all occurences of 'from' replaced with 'to'.
 69+
 70+See: http://php.net/manual/function.str-replace.php
 71+
 72+=== explode_e: (explode string) ===
 73+<nowiki>{{#explode_e:value|delimiter|position}}</nowiki>
 74+
 75+Splits the given value into pieces by the given delimiter and returns the position-th piece. Empty string is returned if there are not enough pieces.
 76+
 77+Note: Pieces are counted from 0.<br>
 78+Note: A negative value can be used to count pieces from the end, instead of counting from the beginning. The last piece is at position -1.
 79+
 80+See: http://php.net/manual/function.explode.php
 81+
 82+==Download instructions==
 83+<!-- revise these instructions if code is available via a download site -->
 84+Please cut and paste the code found [[#Code|below]] and place it in <code>$IP/extensions/ExtensionName/ExtensionName.php</code>. ''Note: [[Manual:$IP|$IP]] stands for the root directory of your MediaWiki installation, the same directory that holds [[Manual:LocalSettings.php|LocalSettings.php]]''.
 85+
 86+==Installation==
 87+String functions were integrated into [[Extension:ParserFunctions]] extension as of [[Special:Code/MediaWiki/50997|r50997]]. This revision of [[Extension:ParserFunctions]] is designed for MediaWiki 1.16, but updating to the trunk version may work on previous versions. If you are using a prior version of [[Extension:ParserFunctions]], you will also have to include [[Extension:StringFunctions]].
 88+
 89+Install and test [[Extension:ParserFunctions]] and (if necessary) [[Extension:StringFunctions]] prior to installing this extension.
 90+
 91+This extension must be included AFTER the invocation of the string parser functions.
 92+To install this extension, add the following to [[Manual:LocalSettings.php|LocalSettings.php]]:
 93+
 94+=== For MediaWiki 1.15.1 and before ===
 95+<source lang="php">
 96+require_once("$IP/extensions/ParserFunctions/ParserFunctions.php");
 97+require_once("$IP/extensions/StringFunctions/StringFunctions.php");
 98+require_once("$IP/extensions/StringFunctionsEscaped/StringFunctionsEscaped.php");
 99+</source>
 100+
 101+=== For MediaWiki 1.16a and after ===
 102+<source lang="php">
 103+require_once("$IP/extensions/ParserFunctions/ParserFunctions.php");
 104+$wgPFEnableStringFunctions = true; // Note: this must be after ParserFunctions and before StringFunctionsEscaped
 105+require_once("$IP/extensions/StringFunctionsEscaped/StringFunctionsEscaped.php");
 106+</source>
 107+==Examples==
 108+
 109+=== pos_e ===
 110+
 111+<pre>
 112+{{#pos_e:Line 1
 113+Line 2
 114+Line 3|\n|7}}
 115+
 116+Returns:
 117+
 118+13
 119+</pre>
 120+
 121+=== rpos_e ===
 122+<pre>
 123+{{#rpos_e:Line 1
 124+Line 2
 125+Line 3|\n}}
 126+
 127+Returns:
 128+
 129+13
 130+</pre>
 131+
 132+=== pad_e ===
 133+<pre>
 134+~~{{#pad_e:xox|9|\n|center}}~~
 135+
 136+Returns:
 137+
 138+~~
 139+
 140+
 141+xox
 142+
 143+
 144+~~
 145+</pre>
 146+
 147+=== replace_e ===
 148+<pre>
 149+{{#replace_e:Line 1
 150+Line 2
 151+Line 3|\n|<br>\n}}
 152+
 153+Returns:
 154+
 155+Line 1<br>
 156+Line 2<br>
 157+Line 3
 158+
 159+Which would display as:
 160+
 161+Line 1
 162+Line 2
 163+Line 3
 164+
 165+Rather than the unescaped:
 166+
 167+Line 1 Line 2 Line 3
 168+
 169+</pre>
 170+
 171+=== explode_e ===
 172+<pre>
 173+{{#explode_e:Line 1
 174+Line 2
 175+Line 3|\n|1}}
 176+
 177+Returns:
 178+
 179+Line 2
 180+
 181+</pre>
 182+==See also==
 183+
 184+* [[Extension:ParserFunctions]]
 185+* [[Extension:StringFunctions]]
 186+* [[Extension:Lua]]
Property changes on: trunk/extensions/StringFunctionsEscaped/README
___________________________________________________________________
Added: svn:eol-style
187187 + native
Index: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersParserFunctions.php
@@ -1,88 +1,88 @@
2 -<?php
3 -
4 -/**
5 - * Class for handling the Maps parser functions with OpenLayers
6 - *
7 - * @file Maps_OpenLayersParserFunctions.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -class MapsOpenLayersParserFunctions extends MapsBaseMap {
18 -
19 - public $serviceName = MapsOpenLayersUtils::SERVICE_NAME;
20 -
21 - /**
22 - * @see MapsBaseMap::setMapSettings()
23 - *
24 - */
25 - protected function setMapSettings() {
26 - global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
27 -
28 - $this->defaultParams = MapsOpenLayersUtils::getDefaultParams();
29 -
30 - $this->elementNamePrefix = $egMapsOpenLayersPrefix;
31 - $this->defaultZoom = $egMapsOpenLayersZoom;
32 - }
33 -
34 - /**
35 - * @see MapsBaseMap::doMapServiceLoad()
36 - *
37 - */
38 - protected function doMapServiceLoad() {
39 - global $egOpenLayersOnThisPage;
40 -
41 - MapsOpenLayersUtils::addOLDependencies($this->output);
42 - $egOpenLayersOnThisPage++;
43 -
44 - $this->elementNr = $egOpenLayersOnThisPage;
45 - }
46 -
47 - /**
48 - * @see MapsBaseMap::addSpecificMapHTML()
49 - *
50 - */
51 - public function addSpecificMapHTML() {
52 - global $wgJsMimeType;
53 -
54 - $controlItems = MapsOpenLayersUtils::createControlsString($this->controls);
55 -
56 - MapsMapper::enforceArrayValues($this->layers);
57 - $layerItems = MapsOpenLayersUtils::createLayersStringAndLoadDependencies($this->output, $this->layers);
58 -
59 - MapsUtils::makePxValue($this->width);
60 - MapsUtils::makePxValue($this->height);
61 -
62 - $markerItems = array();
63 -
64 - // TODO: Refactor up
65 - foreach ($this->markerData as $markerData) {
66 - $lat = $markerData['lat'];
67 - $lon = $markerData['lon'];
68 -
69 - $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
70 - $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
71 -
72 - $title = str_replace("'", "\'", $title);
73 - $label = str_replace("'", "\'", $label);
74 -
75 - $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
76 - $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')";
77 - }
78 -
79 - $markersString = implode(',', $markerItems);
80 -
81 - $this->output .= "<div id='$this->mapName' style='width: $this->width; height: $this->height; background-color: #cccccc;'></div>
82 - <script type='$wgJsMimeType'> /*<![CDATA[*/
83 - addLoadEvent(
84 - initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[$markersString])
85 - );
86 - /*]]>*/ </script>";
87 - }
88 -
 2+<?php
 3+
 4+/**
 5+ * Class for handling the Maps parser functions with OpenLayers
 6+ *
 7+ * @file Maps_OpenLayersParserFunctions.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+class MapsOpenLayersParserFunctions extends MapsBaseMap {
 18+
 19+ public $serviceName = MapsOpenLayersUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsBaseMap::setMapSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsOpenLayersZoom, $egMapsOpenLayersPrefix;
 27+
 28+ $this->defaultParams = MapsOpenLayersUtils::getDefaultParams();
 29+
 30+ $this->elementNamePrefix = $egMapsOpenLayersPrefix;
 31+ $this->defaultZoom = $egMapsOpenLayersZoom;
 32+ }
 33+
 34+ /**
 35+ * @see MapsBaseMap::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egOpenLayersOnThisPage;
 40+
 41+ MapsOpenLayersUtils::addOLDependencies($this->output);
 42+ $egOpenLayersOnThisPage++;
 43+
 44+ $this->elementNr = $egOpenLayersOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see MapsBaseMap::addSpecificMapHTML()
 49+ *
 50+ */
 51+ public function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $controlItems = MapsOpenLayersUtils::createControlsString($this->controls);
 55+
 56+ MapsMapper::enforceArrayValues($this->layers);
 57+ $layerItems = MapsOpenLayersUtils::createLayersStringAndLoadDependencies($this->output, $this->layers);
 58+
 59+ MapsUtils::makePxValue($this->width);
 60+ MapsUtils::makePxValue($this->height);
 61+
 62+ $markerItems = array();
 63+
 64+ // TODO: Refactor up
 65+ foreach ($this->markerData as $markerData) {
 66+ $lat = $markerData['lat'];
 67+ $lon = $markerData['lon'];
 68+
 69+ $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
 70+ $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
 71+
 72+ $title = str_replace("'", "\'", $title);
 73+ $label = str_replace("'", "\'", $label);
 74+
 75+ $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
 76+ $markerItems[] = "getOLMarkerData($lon, $lat, '$title', '$label', '$icon')";
 77+ }
 78+
 79+ $markersString = implode(',', $markerItems);
 80+
 81+ $this->output .= "<div id='$this->mapName' style='width: $this->width; height: $this->height; background-color: #cccccc;'></div>
 82+ <script type='$wgJsMimeType'> /*<![CDATA[*/
 83+ addLoadEvent(
 84+ initOpenLayer('$this->mapName', $this->centre_lon, $this->centre_lat, $this->zoom, [$layerItems], [$controlItems],[$markersString])
 85+ );
 86+ /*]]>*/ </script>";
 87+ }
 88+
8989 }
\ No newline at end of file
Property changes on: trunk/extensions/Maps/OpenLayers/Maps_OpenLayersParserFunctions.php
___________________________________________________________________
Added: svn:eol-style
9090 + native
Index: trunk/extensions/Maps/ParserFunctions/Maps_BaseMap.php
@@ -1,161 +1,161 @@
2 -<?php
3 -
4 -/**
5 - * MapsBaseMap is an abstract class inherited by the map services classes
6 - *
7 - * @file Maps_BaseMap.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -abstract class MapsBaseMap extends MapsMapFeature {
18 -
19 - // TODO: move this abstract function to a new MapsBaseMapUtils file?
20 - //protected abstract static function getDefaultParams();
21 -
22 - protected $markerData = array();
23 -
24 - /**
25 - * Handles the request from the parser hook by doing the work that's common for all
26 - * mapping services, calling the specific methods and finally returning the resulting output.
27 - *
28 - * @param unknown_type $parser
29 - * @param array $map
30 - * @return html
31 - */
32 - public final function displayMap(&$parser, array $params) {
33 - global $wgLang;
34 -
35 - $this->setMapSettings();
36 -
37 - $coords = $this->manageMapProperties($params);
38 -
39 - $this->doMapServiceLoad();
40 -
41 - $this->setMapName();
42 -
43 - $this->setCoordinates();
44 -
45 - $this->setZoom();
46 -
47 - $this->setCentre();
48 -
49 - $this->doParsing($parser);
50 -
51 - $this->doEscaping();
52 -
53 - $this->addSpecificMapHTML();
54 -
55 - return $this->output;
56 - }
57 -
58 - protected function manageMapProperties($params) {
59 - parent::manageMapProperties($params, __CLASS__);
60 - }
61 -
62 - /**
63 - * Sets the zoom level to the provided value. When no zoom is provided, set
64 - * it to the default when there is only one location, or the best fitting soom when
65 - * there are multiple locations.
66 - *
67 - */
68 - private function setZoom() {
69 - if (strlen($this->zoom) < 1) {
70 - if (count($this->markerData) > 1) {
71 - $this->zoom = 'null';
72 - }
73 - else {
74 - $this->zoom = $this->defaultZoom;
75 - }
76 - }
77 - }
78 -
79 - /**
80 - * Fills the $markerData array with the locations and their meta data.
81 - *
82 - */
83 - private function setCoordinates() {
84 - $this->coordinates = explode(';', $this->coordinates);
85 -
86 - foreach($this->coordinates as $coordinates) {
87 - $args = explode('~', $coordinates);
88 -
89 - $args[0] = str_replace('″', '"', $args[0]);
90 - $args[0] = str_replace('′', "'", $args[0]);
91 -
92 - $markerData = MapsUtils::getLatLon($args[0]);
93 -
94 - if (count($args) > 1) {
95 - $markerData['title'] = $args[1];
96 -
97 - if (count($args) > 2) {
98 - $markerData['label'] = $args[2];
99 -
100 - if (count($args) > 3) {
101 - $markerData['icon'] = $args[3];
102 - }
103 - }
104 - }
105 -
106 - $this->markerData[] = $markerData;
107 - }
108 - }
109 -
110 - /**
111 - * Sets the $centre_lat and $centre_lon fields.
112 - * Note: this needs to be done AFTRE the maker coordinates are set.
113 - *
114 - */
115 - private function setCentre() {
116 - if (empty($this->centre)) {
117 - if (count($this->markerData) == 1) {
118 - // If centre is not set and there is exactelly one marker, use it's coordinates.
119 - $this->centre_lat = $this->markerData[0]['lat'];
120 - $this->centre_lon = $this->markerData[0]['lon'];
121 - }
122 - elseif (count($this->markerData) > 1) {
123 - // If centre is not set and there are multiple markers, set the values to null,
124 - // to be auto determined by the JS of the mapping API.
125 - $this->centre_lat = 'null';
126 - $this->centre_lon = 'null';
127 - }
128 - else {
129 - // If centre is not set and there are no markers, use the default latitude and longitutde.
130 - global $egMapsMapLat, $egMapsMapLon;
131 - $this->centre_lat = $egMapsMapLat;
132 - $this->centre_lon = $egMapsMapLon;
133 - }
134 - }
135 - else {
136 - // If a centre value is set, use it.
137 - $centre = MapsUtils::getLatLon($this->centre);
138 - $this->centre_lat = $centre['lat'];
139 - $this->centre_lon = $centre['lon'];
140 - }
141 - }
142 -
143 - /**
144 - * Parse the wiki text in the title and label values.
145 - *
146 - * @param $parser
147 - */
148 - private function DoParsing(&$parser) {
149 - $this->title = $parser->recursiveTagParse( $this->title );
150 - $this->label = $parser->recursiveTagParse( $this->label );
151 - }
152 -
153 - /**
154 - * Escape the title and label text
155 - *
156 - */
157 - private function doEscaping() {
158 - $this->title = str_replace("'", "\'", $this->title);
159 - $this->label = str_replace("'", "\'", $this->label);
160 - }
161 -
162 -}
 2+<?php
 3+
 4+/**
 5+ * MapsBaseMap is an abstract class inherited by the map services classes
 6+ *
 7+ * @file Maps_BaseMap.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+abstract class MapsBaseMap extends MapsMapFeature {
 18+
 19+ // TODO: move this abstract function to a new MapsBaseMapUtils file?
 20+ //protected abstract static function getDefaultParams();
 21+
 22+ protected $markerData = array();
 23+
 24+ /**
 25+ * Handles the request from the parser hook by doing the work that's common for all
 26+ * mapping services, calling the specific methods and finally returning the resulting output.
 27+ *
 28+ * @param unknown_type $parser
 29+ * @param array $map
 30+ * @return html
 31+ */
 32+ public final function displayMap(&$parser, array $params) {
 33+ global $wgLang;
 34+
 35+ $this->setMapSettings();
 36+
 37+ $coords = $this->manageMapProperties($params);
 38+
 39+ $this->doMapServiceLoad();
 40+
 41+ $this->setMapName();
 42+
 43+ $this->setCoordinates();
 44+
 45+ $this->setZoom();
 46+
 47+ $this->setCentre();
 48+
 49+ $this->doParsing($parser);
 50+
 51+ $this->doEscaping();
 52+
 53+ $this->addSpecificMapHTML();
 54+
 55+ return $this->output;
 56+ }
 57+
 58+ protected function manageMapProperties($params) {
 59+ parent::manageMapProperties($params, __CLASS__);
 60+ }
 61+
 62+ /**
 63+ * Sets the zoom level to the provided value. When no zoom is provided, set
 64+ * it to the default when there is only one location, or the best fitting soom when
 65+ * there are multiple locations.
 66+ *
 67+ */
 68+ private function setZoom() {
 69+ if (strlen($this->zoom) < 1) {
 70+ if (count($this->markerData) > 1) {
 71+ $this->zoom = 'null';
 72+ }
 73+ else {
 74+ $this->zoom = $this->defaultZoom;
 75+ }
 76+ }
 77+ }
 78+
 79+ /**
 80+ * Fills the $markerData array with the locations and their meta data.
 81+ *
 82+ */
 83+ private function setCoordinates() {
 84+ $this->coordinates = explode(';', $this->coordinates);
 85+
 86+ foreach($this->coordinates as $coordinates) {
 87+ $args = explode('~', $coordinates);
 88+
 89+ $args[0] = str_replace('″', '"', $args[0]);
 90+ $args[0] = str_replace('′', "'", $args[0]);
 91+
 92+ $markerData = MapsUtils::getLatLon($args[0]);
 93+
 94+ if (count($args) > 1) {
 95+ $markerData['title'] = $args[1];
 96+
 97+ if (count($args) > 2) {
 98+ $markerData['label'] = $args[2];
 99+
 100+ if (count($args) > 3) {
 101+ $markerData['icon'] = $args[3];
 102+ }
 103+ }
 104+ }
 105+
 106+ $this->markerData[] = $markerData;
 107+ }
 108+ }
 109+
 110+ /**
 111+ * Sets the $centre_lat and $centre_lon fields.
 112+ * Note: this needs to be done AFTRE the maker coordinates are set.
 113+ *
 114+ */
 115+ private function setCentre() {
 116+ if (empty($this->centre)) {
 117+ if (count($this->markerData) == 1) {
 118+ // If centre is not set and there is exactelly one marker, use it's coordinates.
 119+ $this->centre_lat = $this->markerData[0]['lat'];
 120+ $this->centre_lon = $this->markerData[0]['lon'];
 121+ }
 122+ elseif (count($this->markerData) > 1) {
 123+ // If centre is not set and there are multiple markers, set the values to null,
 124+ // to be auto determined by the JS of the mapping API.
 125+ $this->centre_lat = 'null';
 126+ $this->centre_lon = 'null';
 127+ }
 128+ else {
 129+ // If centre is not set and there are no markers, use the default latitude and longitutde.
 130+ global $egMapsMapLat, $egMapsMapLon;
 131+ $this->centre_lat = $egMapsMapLat;
 132+ $this->centre_lon = $egMapsMapLon;
 133+ }
 134+ }
 135+ else {
 136+ // If a centre value is set, use it.
 137+ $centre = MapsUtils::getLatLon($this->centre);
 138+ $this->centre_lat = $centre['lat'];
 139+ $this->centre_lon = $centre['lon'];
 140+ }
 141+ }
 142+
 143+ /**
 144+ * Parse the wiki text in the title and label values.
 145+ *
 146+ * @param $parser
 147+ */
 148+ private function DoParsing(&$parser) {
 149+ $this->title = $parser->recursiveTagParse( $this->title );
 150+ $this->label = $parser->recursiveTagParse( $this->label );
 151+ }
 152+
 153+ /**
 154+ * Escape the title and label text
 155+ *
 156+ */
 157+ private function doEscaping() {
 158+ $this->title = str_replace("'", "\'", $this->title);
 159+ $this->label = str_replace("'", "\'", $this->label);
 160+ }
 161+
 162+}
Property changes on: trunk/extensions/Maps/ParserFunctions/Maps_BaseMap.php
___________________________________________________________________
Added: svn:eol-style
163163 + native
Index: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
@@ -1,244 +1,244 @@
2 -<?php
3 -
4 -/**
5 - * Initialization file for parser function functionality in the Maps extension
6 - *
7 - * @file Maps_ParserFunctions.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -$wgHooks['LanguageGetMagic'][] = 'efMapsFunctionMagic';
18 -
19 -/**
20 - * Adds the magic words for the parser functions
21 - */
22 -function efMapsFunctionMagic( &$magicWords, $langCode ) {
23 - $magicWords['display_point'] = array( 0, 'display_point' );
24 - $magicWords['display_points'] = array( 0, 'display_points' );
25 - $magicWords['display_address'] = array( 0, 'display_address' );
26 - $magicWords['display_addresses'] = array( 0, 'display_addresses' );
27 -
28 - $magicWords['geocode'] = array( 0, 'geocode' );
29 - $magicWords['geocodelat'] = array ( 0, 'geocodelat' );
30 - $magicWords['geocodelng'] = array ( 0, 'geocodelng' );
31 -
32 - return true; // Unless we return true, other parser functions won't get loaded
33 -}
34 -
35 -/**
36 - * A class that holds handlers for the mapping parser functions.
37 - * Spesific functions are located in @see MapsUtils
38 - *
39 - * @author Jeroen De Dauw
40 - *
41 - */
42 -final class MapsParserFunctions {
43 -
44 - /**
45 - * Initialize the parser functions feature
46 - *
47 - */
48 - public static function initialize() {
49 - global $egMapsIP, $wgAutoloadClasses;
50 - $wgAutoloadClasses['MapsBaseMap'] = $egMapsIP . '/ParserFunctions/Maps_BaseMap.php';
51 -
52 - self::addParserHooks();
53 - }
54 -
55 - /**
56 - * Adds the parser function hooks
57 - */
58 - private static function addParserHooks() {
59 - global $wgParser;
60 -
61 - // A hooks to enable the '#display_point' and '#display_points' parser functions
62 - $wgParser->setFunctionHook( 'display_point', array('MapsParserFunctions', 'displayPointRender') );
63 - $wgParser->setFunctionHook( 'display_points', array('MapsParserFunctions', 'displayPointsRender') );
64 -
65 - // A hooks to enable the '#display_adress' and '#display_adresses' parser functions
66 - $wgParser->setFunctionHook( 'display_address', array('MapsParserFunctions', 'displayAddressRender') );
67 - $wgParser->setFunctionHook( 'display_addresses', array('MapsParserFunctions', 'displayAddressesRender') );
68 -
69 - // A hook to enable the geocoder parser functions
70 - $wgParser->setFunctionHook( 'geocode', array('MapsGeocoder', 'renderGeocoder') );
71 - $wgParser->setFunctionHook( 'geocodelat' , array('MapsGeocoder', 'renderGeocoderLat') );
72 - $wgParser->setFunctionHook( 'geocodelng' , array('MapsGeocoder', 'renderGeocoderLng') );
73 - }
74 -
75 - public static function getMapHtml(&$parser, array $params, array $coordFails = array()) {
76 - global $wgLang;
77 -
78 - $map = array();
79 -
80 - // Go through all parameters, split their names and values, and put them in the $map array.
81 - foreach($params as $param) {
82 - $split = split('=', $param);
83 - if (count($split) > 1) {
84 - $paramName = strtolower(trim($split[0]));
85 - $paramValue = trim($split[1]);
86 - if (strlen($paramName) > 0 && strlen($paramValue) > 0) {
87 - $map[$paramName] = $paramValue;
88 - }
89 - }
90 - else if (count($split) == 1) { // Default parameter (without name)
91 - $split[0] = trim($split[0]);
92 - if (strlen($split[0]) > 0) $map['coordinates'] = $split[0];
93 - }
94 - }
95 -
96 - $coords = MapsMapper::getParamValue('coordinates', $map);
97 -
98 - if ($coords) {
99 - if (! MapsMapper::paramIsPresent('service', $map)) $map['service'] = '';
100 - $map['service'] = MapsMapper::getValidService($map['service'], 'pf');
101 -
102 - $mapClass = self::getParserClassInstance($map['service']);
103 -
104 - // Call the function according to the map service to get the HTML output
105 - $output = $mapClass->displayMap($parser, $map);
106 -
107 - if (count($coordFails) > 0) {
108 - $output .= '<i>' . wfMsgExt( 'maps_geocoding_failed_for', array( 'parsemag' ), $wgLang->listToText($coordFails ), count( $coordFails ) ) . '</i>';
109 - }
110 - }
111 - elseif (trim($coords) == "" && count($coordFails) > 0) {
112 - $output = '<i>' . wfMsgExt( 'maps_geocoding_failed', array( 'parsemag' ), $wgLang->listToText( $coordFails ), count( $coordFails ) ) . '</i>';
113 - }
114 - else {
115 - $output = '<i>'.wfMsg( 'maps_coordinates_missing' ).'</i>';
116 - }
117 -
118 - // Return the result
119 - return array( $output, 'noparse' => true, 'isHTML' => true );
120 - }
121 -
122 - private static function getParserClassInstance($service) {
123 - global $egMapsServices;
124 - return new $egMapsServices[$service]['pf']['class']();
125 - }
126 -
127 - /**
128 - * Sets the default map properties, gets the map HTML depending
129 - * on the provided service, and then returns it.
130 - *
131 - * @param unknown_type $parser
132 - * @return array
133 - */
134 - public static function displayPointRender(&$parser) {
135 - $params = func_get_args();
136 - array_shift( $params ); // We already know the $parser ...
137 -
138 - return self::getMapHtml($parser, $params);
139 - }
140 -
141 - /**
142 - * Sets the default map properties, gets the map HTML depending
143 - * on the provided service, and then returns it.
144 - *
145 - * @param unknown_type $parser
146 - */
147 - public static function displayPointsRender(&$parser) {
148 - $params = func_get_args();
149 - array_shift( $params ); // We already know the $parser ...
150 -
151 - return self::getMapHtml($parser, $params);
152 - }
153 -
154 - /**
155 - * Turns the address parameter into coordinates, then calls
156 - * getMapHtml() and returns it's result.
157 - *
158 - * @param unknown_type $parser
159 - * @return array
160 - */
161 - public static function displayAddressRender(&$parser) {
162 - $params = func_get_args();
163 - array_shift( $params ); // We already know the $parser ...
164 -
165 - $fails = self::changeAddressToCoords($params);
166 -
167 - return self::getMapHtml($parser, $params, $fails);
168 - }
169 -
170 - /**
171 - * Turns the address parameter into coordinates, then calls
172 - * getMapHtml() and returns it's result.
173 - *
174 - * @param unknown_type $parser
175 - */
176 - public static function displayAddressesRender(&$parser) {
177 - $params = func_get_args();
178 - array_shift( $params ); // We already know the $parser ...
179 -
180 - $fails = self::changeAddressToCoords($params);
181 -
182 - return self::getMapHtml($parser, $params, $fails);
183 - }
184 -
185 - /**
186 - * Changes the values of the address or addresses parameter into coordinates
187 - * in the provided array. Returns an array containing the addresses that
188 - * could not be geocoded.
189 - *
190 - * @param array $params
191 - */
192 - private static function changeAddressToCoords(&$params) {
193 - global $egMapsDefaultService;
194 -
195 - $fails = array();
196 -
197 - for ($i = 0; $i < count($params); $i++) {
198 - $split = split('=', $params[$i]);
199 - if (MapsMapper::inParamAliases(strtolower(trim($split[0])), 'service') && count($split) > 1) {
200 - $service = trim($split[1]);
201 - }
202 - else if (strtolower(trim($split[0])) == 'geoservice' && count($split) > 1) {
203 - $geoservice = trim($split[1]);
204 - }
205 - }
206 -
207 - $service = isset($service) ? MapsMapper::getValidService($service, 'pf') : $egMapsDefaultService;
208 -
209 - $geoservice = isset($geoservice) ? $geoservice : '';
210 -
211 - for ($i = 0; $i < count($params); $i++) {
212 - $split = split('=', $params[$i]);
213 - if (((strtolower(trim($split[0])) == 'address' || strtolower(trim($split[0])) == 'addresses') && count($split) > 0)) {
214 - $address_srting = count($split) == 1 ? $split[0] : $split[1];
215 - //var_dump($address_srting);
216 - $addresses = explode(';', $address_srting);
217 -
218 - $coordinates = array();
219 -
220 - foreach($addresses as $address) {
221 - $args = explode('~', $address);
222 - $args[0] = trim($args[0]);
223 -
224 - if (strlen($args[0]) > 0) {
225 - $coords = MapsGeocoder::geocodeToString($args[0], $geoservice, $service);
226 -
227 - if ($coords) {
228 - $args[0] = $coords;
229 - $coordinates[] = implode('~', $args);
230 - }
231 - else {
232 - $fails[] = $args[0];
233 - }
234 - }
235 - }
236 -
237 - $params[$i] = 'coordinates=' . implode(';', $coordinates);
238 -
239 - }
240 - } //exit;
241 -
242 - return $fails;
243 - }
244 -
 2+<?php
 3+
 4+/**
 5+ * Initialization file for parser function functionality in the Maps extension
 6+ *
 7+ * @file Maps_ParserFunctions.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+$wgHooks['LanguageGetMagic'][] = 'efMapsFunctionMagic';
 18+
 19+/**
 20+ * Adds the magic words for the parser functions
 21+ */
 22+function efMapsFunctionMagic( &$magicWords, $langCode ) {
 23+ $magicWords['display_point'] = array( 0, 'display_point' );
 24+ $magicWords['display_points'] = array( 0, 'display_points' );
 25+ $magicWords['display_address'] = array( 0, 'display_address' );
 26+ $magicWords['display_addresses'] = array( 0, 'display_addresses' );
 27+
 28+ $magicWords['geocode'] = array( 0, 'geocode' );
 29+ $magicWords['geocodelat'] = array ( 0, 'geocodelat' );
 30+ $magicWords['geocodelng'] = array ( 0, 'geocodelng' );
 31+
 32+ return true; // Unless we return true, other parser functions won't get loaded
 33+}
 34+
 35+/**
 36+ * A class that holds handlers for the mapping parser functions.
 37+ * Spesific functions are located in @see MapsUtils
 38+ *
 39+ * @author Jeroen De Dauw
 40+ *
 41+ */
 42+final class MapsParserFunctions {
 43+
 44+ /**
 45+ * Initialize the parser functions feature
 46+ *
 47+ */
 48+ public static function initialize() {
 49+ global $egMapsIP, $wgAutoloadClasses;
 50+ $wgAutoloadClasses['MapsBaseMap'] = $egMapsIP . '/ParserFunctions/Maps_BaseMap.php';
 51+
 52+ self::addParserHooks();
 53+ }
 54+
 55+ /**
 56+ * Adds the parser function hooks
 57+ */
 58+ private static function addParserHooks() {
 59+ global $wgParser;
 60+
 61+ // A hooks to enable the '#display_point' and '#display_points' parser functions
 62+ $wgParser->setFunctionHook( 'display_point', array('MapsParserFunctions', 'displayPointRender') );
 63+ $wgParser->setFunctionHook( 'display_points', array('MapsParserFunctions', 'displayPointsRender') );
 64+
 65+ // A hooks to enable the '#display_adress' and '#display_adresses' parser functions
 66+ $wgParser->setFunctionHook( 'display_address', array('MapsParserFunctions', 'displayAddressRender') );
 67+ $wgParser->setFunctionHook( 'display_addresses', array('MapsParserFunctions', 'displayAddressesRender') );
 68+
 69+ // A hook to enable the geocoder parser functions
 70+ $wgParser->setFunctionHook( 'geocode', array('MapsGeocoder', 'renderGeocoder') );
 71+ $wgParser->setFunctionHook( 'geocodelat' , array('MapsGeocoder', 'renderGeocoderLat') );
 72+ $wgParser->setFunctionHook( 'geocodelng' , array('MapsGeocoder', 'renderGeocoderLng') );
 73+ }
 74+
 75+ public static function getMapHtml(&$parser, array $params, array $coordFails = array()) {
 76+ global $wgLang;
 77+
 78+ $map = array();
 79+
 80+ // Go through all parameters, split their names and values, and put them in the $map array.
 81+ foreach($params as $param) {
 82+ $split = split('=', $param);
 83+ if (count($split) > 1) {
 84+ $paramName = strtolower(trim($split[0]));
 85+ $paramValue = trim($split[1]);
 86+ if (strlen($paramName) > 0 && strlen($paramValue) > 0) {
 87+ $map[$paramName] = $paramValue;
 88+ }
 89+ }
 90+ else if (count($split) == 1) { // Default parameter (without name)
 91+ $split[0] = trim($split[0]);
 92+ if (strlen($split[0]) > 0) $map['coordinates'] = $split[0];
 93+ }
 94+ }
 95+
 96+ $coords = MapsMapper::getParamValue('coordinates', $map);
 97+
 98+ if ($coords) {
 99+ if (! MapsMapper::paramIsPresent('service', $map)) $map['service'] = '';
 100+ $map['service'] = MapsMapper::getValidService($map['service'], 'pf');
 101+
 102+ $mapClass = self::getParserClassInstance($map['service']);
 103+
 104+ // Call the function according to the map service to get the HTML output
 105+ $output = $mapClass->displayMap($parser, $map);
 106+
 107+ if (count($coordFails) > 0) {
 108+ $output .= '<i>' . wfMsgExt( 'maps_geocoding_failed_for', array( 'parsemag' ), $wgLang->listToText($coordFails ), count( $coordFails ) ) . '</i>';
 109+ }
 110+ }
 111+ elseif (trim($coords) == "" && count($coordFails) > 0) {
 112+ $output = '<i>' . wfMsgExt( 'maps_geocoding_failed', array( 'parsemag' ), $wgLang->listToText( $coordFails ), count( $coordFails ) ) . '</i>';
 113+ }
 114+ else {
 115+ $output = '<i>'.wfMsg( 'maps_coordinates_missing' ).'</i>';
 116+ }
 117+
 118+ // Return the result
 119+ return array( $output, 'noparse' => true, 'isHTML' => true );
 120+ }
 121+
 122+ private static function getParserClassInstance($service) {
 123+ global $egMapsServices;
 124+ return new $egMapsServices[$service]['pf']['class']();
 125+ }
 126+
 127+ /**
 128+ * Sets the default map properties, gets the map HTML depending
 129+ * on the provided service, and then returns it.
 130+ *
 131+ * @param unknown_type $parser
 132+ * @return array
 133+ */
 134+ public static function displayPointRender(&$parser) {
 135+ $params = func_get_args();
 136+ array_shift( $params ); // We already know the $parser ...
 137+
 138+ return self::getMapHtml($parser, $params);
 139+ }
 140+
 141+ /**
 142+ * Sets the default map properties, gets the map HTML depending
 143+ * on the provided service, and then returns it.
 144+ *
 145+ * @param unknown_type $parser
 146+ */
 147+ public static function displayPointsRender(&$parser) {
 148+ $params = func_get_args();
 149+ array_shift( $params ); // We already know the $parser ...
 150+
 151+ return self::getMapHtml($parser, $params);
 152+ }
 153+
 154+ /**
 155+ * Turns the address parameter into coordinates, then calls
 156+ * getMapHtml() and returns it's result.
 157+ *
 158+ * @param unknown_type $parser
 159+ * @return array
 160+ */
 161+ public static function displayAddressRender(&$parser) {
 162+ $params = func_get_args();
 163+ array_shift( $params ); // We already know the $parser ...
 164+
 165+ $fails = self::changeAddressToCoords($params);
 166+
 167+ return self::getMapHtml($parser, $params, $fails);
 168+ }
 169+
 170+ /**
 171+ * Turns the address parameter into coordinates, then calls
 172+ * getMapHtml() and returns it's result.
 173+ *
 174+ * @param unknown_type $parser
 175+ */
 176+ public static function displayAddressesRender(&$parser) {
 177+ $params = func_get_args();
 178+ array_shift( $params ); // We already know the $parser ...
 179+
 180+ $fails = self::changeAddressToCoords($params);
 181+
 182+ return self::getMapHtml($parser, $params, $fails);
 183+ }
 184+
 185+ /**
 186+ * Changes the values of the address or addresses parameter into coordinates
 187+ * in the provided array. Returns an array containing the addresses that
 188+ * could not be geocoded.
 189+ *
 190+ * @param array $params
 191+ */
 192+ private static function changeAddressToCoords(&$params) {
 193+ global $egMapsDefaultService;
 194+
 195+ $fails = array();
 196+
 197+ for ($i = 0; $i < count($params); $i++) {
 198+ $split = split('=', $params[$i]);
 199+ if (MapsMapper::inParamAliases(strtolower(trim($split[0])), 'service') && count($split) > 1) {
 200+ $service = trim($split[1]);
 201+ }
 202+ else if (strtolower(trim($split[0])) == 'geoservice' && count($split) > 1) {
 203+ $geoservice = trim($split[1]);
 204+ }
 205+ }
 206+
 207+ $service = isset($service) ? MapsMapper::getValidService($service, 'pf') : $egMapsDefaultService;
 208+
 209+ $geoservice = isset($geoservice) ? $geoservice : '';
 210+
 211+ for ($i = 0; $i < count($params); $i++) {
 212+ $split = split('=', $params[$i]);
 213+ if (((strtolower(trim($split[0])) == 'address' || strtolower(trim($split[0])) == 'addresses') && count($split) > 0)) {
 214+ $address_srting = count($split) == 1 ? $split[0] : $split[1];
 215+ //var_dump($address_srting);
 216+ $addresses = explode(';', $address_srting);
 217+
 218+ $coordinates = array();
 219+
 220+ foreach($addresses as $address) {
 221+ $args = explode('~', $address);
 222+ $args[0] = trim($args[0]);
 223+
 224+ if (strlen($args[0]) > 0) {
 225+ $coords = MapsGeocoder::geocodeToString($args[0], $geoservice, $service);
 226+
 227+ if ($coords) {
 228+ $args[0] = $coords;
 229+ $coordinates[] = implode('~', $args);
 230+ }
 231+ else {
 232+ $fails[] = $args[0];
 233+ }
 234+ }
 235+ }
 236+
 237+ $params[$i] = 'coordinates=' . implode(';', $coordinates);
 238+
 239+ }
 240+ } //exit;
 241+
 242+ return $fails;
 243+ }
 244+
245245 }
\ No newline at end of file
Property changes on: trunk/extensions/Maps/ParserFunctions/Maps_ParserFunctions.php
___________________________________________________________________
Added: svn:eol-style
246246 + native
Index: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsParserFunctions.php
@@ -1,98 +1,98 @@
2 -<?php
3 -
4 -/**
5 - * Class for handling the Maps parser functions with Google Maps
6 - *
7 - * @file Maps_GoogleMapsParserFunctions.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -final class MapsGoogleMapsParserFunctions extends MapsBaseMap {
18 -
19 - public $serviceName = MapsGoogleMapsUtils::SERVICE_NAME;
20 -
21 - /**
22 - * @see MapsBaseMap::setMapSettings()
23 - *
24 - */
25 - protected function setMapSettings() {
26 - global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix;
27 -
28 - $this->defaultParams = MapsGoogleMapsUtils::getDefaultParams();
29 -
30 - $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
31 - $this->defaultZoom = $egMapsGoogleMapsZoom;
32 - }
33 -
34 - /**
35 - * @see MapsBaseMap::doMapServiceLoad()
36 - *
37 - */
38 - protected function doMapServiceLoad() {
39 - global $egGoogleMapsOnThisPage;
40 -
41 - MapsGoogleMapsUtils::addGMapDependencies($this->output);
42 - $egGoogleMapsOnThisPage++;
43 -
44 - $this->elementNr = $egGoogleMapsOnThisPage;
45 - }
46 -
47 - /**
48 - * @see MapsBaseMap::addSpecificMapHTML()
49 - *
50 - */
51 - public function addSpecificMapHTML() {
52 - global $wgJsMimeType;
53 -
54 - $enableEarth = MapsGoogleMapsUtils::getEarthValue($this->earth);
55 -
56 - $this->type = MapsGoogleMapsUtils::getGMapType($this->type, true);
57 -
58 - $this->controls = MapsGoogleMapsUtils::createControlsString($this->controls);
59 -
60 - $this->autozoom = MapsGoogleMapsUtils::getAutozoomJSValue($this->autozoom);
61 -
62 - $markerItems = array();
63 -
64 - // TODO: Refactor up
65 - foreach ($this->markerData as $markerData) {
66 - $lat = $markerData['lat'];
67 - $lon = $markerData['lon'];
68 -
69 - $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
70 - $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
71 -
72 - $title = str_replace("'", "\'", $title);
73 - $label = str_replace("'", "\'", $label);
74 -
75 - $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
76 - $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label', '$icon')";
77 - }
78 -
79 - $markersString = implode(',', $markerItems);
80 -
81 - $this->types = explode(",", $this->types);
82 -
83 - $typesString = MapsGoogleMapsUtils::createTypesString($this->types, $enableEarth);
84 -
85 - $this->output .=<<<END
86 -
87 -<div id="$this->mapName" class="$this->class" style="$this->style" ></div>
88 -<script type="$wgJsMimeType"> /*<![CDATA[*/
89 -addLoadEvent(
90 - initializeGoogleMap('$this->mapName', $this->width, $this->height, $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
91 -);
92 -/*]]>*/ </script>
93 -
94 -END;
95 -
96 - }
97 -
98 -}
99 -
 2+<?php
 3+
 4+/**
 5+ * Class for handling the Maps parser functions with Google Maps
 6+ *
 7+ * @file Maps_GoogleMapsParserFunctions.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+final class MapsGoogleMapsParserFunctions extends MapsBaseMap {
 18+
 19+ public $serviceName = MapsGoogleMapsUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsBaseMap::setMapSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsGoogleMapsZoom, $egMapsGoogleMapsPrefix;
 27+
 28+ $this->defaultParams = MapsGoogleMapsUtils::getDefaultParams();
 29+
 30+ $this->elementNamePrefix = $egMapsGoogleMapsPrefix;
 31+ $this->defaultZoom = $egMapsGoogleMapsZoom;
 32+ }
 33+
 34+ /**
 35+ * @see MapsBaseMap::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egGoogleMapsOnThisPage;
 40+
 41+ MapsGoogleMapsUtils::addGMapDependencies($this->output);
 42+ $egGoogleMapsOnThisPage++;
 43+
 44+ $this->elementNr = $egGoogleMapsOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see MapsBaseMap::addSpecificMapHTML()
 49+ *
 50+ */
 51+ public function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $enableEarth = MapsGoogleMapsUtils::getEarthValue($this->earth);
 55+
 56+ $this->type = MapsGoogleMapsUtils::getGMapType($this->type, true);
 57+
 58+ $this->controls = MapsGoogleMapsUtils::createControlsString($this->controls);
 59+
 60+ $this->autozoom = MapsGoogleMapsUtils::getAutozoomJSValue($this->autozoom);
 61+
 62+ $markerItems = array();
 63+
 64+ // TODO: Refactor up
 65+ foreach ($this->markerData as $markerData) {
 66+ $lat = $markerData['lat'];
 67+ $lon = $markerData['lon'];
 68+
 69+ $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
 70+ $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
 71+
 72+ $title = str_replace("'", "\'", $title);
 73+ $label = str_replace("'", "\'", $label);
 74+
 75+ $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
 76+ $markerItems[] = "getGMarkerData($lat, $lon, '$title', '$label', '$icon')";
 77+ }
 78+
 79+ $markersString = implode(',', $markerItems);
 80+
 81+ $this->types = explode(",", $this->types);
 82+
 83+ $typesString = MapsGoogleMapsUtils::createTypesString($this->types, $enableEarth);
 84+
 85+ $this->output .=<<<END
 86+
 87+<div id="$this->mapName" class="$this->class" style="$this->style" ></div>
 88+<script type="$wgJsMimeType"> /*<![CDATA[*/
 89+addLoadEvent(
 90+ initializeGoogleMap('$this->mapName', $this->width, $this->height, $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
 91+);
 92+/*]]>*/ </script>
 93+
 94+END;
 95+
 96+ }
 97+
 98+}
 99+
Property changes on: trunk/extensions/Maps/GoogleMaps/Maps_GoogleMapsParserFunctions.php
___________________________________________________________________
Added: svn:eol-style
100100 + native
Index: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsParserFunctions.php
@@ -1,96 +1,96 @@
2 -<?php
3 -
4 -/**
5 - * Class for handling the Maps parser functions with Yahoo! Maps
6 - *
7 - * @file Maps_YahooMapsParserFunctions.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -class MapsYahooMapsParserFunctions extends MapsBaseMap {
18 -
19 - public $serviceName = MapsYahooMapsUtils::SERVICE_NAME;
20 -
21 - /**
22 - * @see MapsBaseMap::setFormInputSettings()
23 - *
24 - */
25 - protected function setMapSettings() {
26 - global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix;
27 -
28 - $this->defaultParams = MapsYahooMapsUtils::getDefaultParams();
29 -
30 - $this->elementNamePrefix = $egMapsYahooMapsPrefix;
31 - $this->defaultZoom = $egMapsYahooMapsZoom;
32 - }
33 -
34 - /**
35 - * @see MapsBaseMap::doMapServiceLoad()
36 - *
37 - */
38 - protected function doMapServiceLoad() {
39 - global $egYahooMapsOnThisPage;
40 -
41 - MapsYahooMapsUtils::addYMapDependencies($this->output);
42 - $egYahooMapsOnThisPage++;
43 -
44 - $this->elementNr = $egYahooMapsOnThisPage;
45 - }
46 -
47 - /**
48 - * @see MapsBaseMap::addSpecificMapHTML()
49 - *
50 - */
51 - public function addSpecificMapHTML() {
52 - global $wgJsMimeType;
53 -
54 - $this->type = MapsYahooMapsUtils::getYMapType($this->type, true);
55 -
56 - $this->controls = MapsYahooMapsUtils::createControlsString($this->controls);
57 -
58 - MapsUtils::makePxValue($this->width);
59 - MapsUtils::makePxValue($this->height);
60 -
61 - $this->autozoom = MapsYahooMapsUtils::getAutozoomJSValue($this->autozoom);
62 -
63 - $markerItems = array();
64 -
65 - // TODO: Refactor up
66 - foreach ($this->markerData as $markerData) {
67 - $lat = $markerData['lat'];
68 - $lon = $markerData['lon'];
69 -
70 - $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
71 - $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
72 -
73 - $title = str_replace("'", "\'", $title);
74 - $label = str_replace("'", "\'", $label);
75 -
76 - $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
77 - $markerItems[] = "getYMarkerData($lat, $lon, '$title', '$label', '$icon')";
78 - }
79 -
80 - $markersString = implode(',', $markerItems);
81 -
82 - $this->types = explode(",", $this->types);
83 -
84 - $typesString = MapsYahooMapsUtils::createTypesString($this->types);
85 -
86 - $this->output .= <<<END
87 - <div id="$this->mapName" style="width: $this->width; height: $this->height;"></div>
88 -
89 - <script type="$wgJsMimeType">/*<![CDATA[*/
90 - addLoadEvent(
91 - initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
92 - );
93 - /*]]>*/</script>
94 -END;
95 - }
96 -
97 -}
 2+<?php
 3+
 4+/**
 5+ * Class for handling the Maps parser functions with Yahoo! Maps
 6+ *
 7+ * @file Maps_YahooMapsParserFunctions.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+class MapsYahooMapsParserFunctions extends MapsBaseMap {
 18+
 19+ public $serviceName = MapsYahooMapsUtils::SERVICE_NAME;
 20+
 21+ /**
 22+ * @see MapsBaseMap::setFormInputSettings()
 23+ *
 24+ */
 25+ protected function setMapSettings() {
 26+ global $egMapsYahooMapsZoom, $egMapsYahooMapsPrefix;
 27+
 28+ $this->defaultParams = MapsYahooMapsUtils::getDefaultParams();
 29+
 30+ $this->elementNamePrefix = $egMapsYahooMapsPrefix;
 31+ $this->defaultZoom = $egMapsYahooMapsZoom;
 32+ }
 33+
 34+ /**
 35+ * @see MapsBaseMap::doMapServiceLoad()
 36+ *
 37+ */
 38+ protected function doMapServiceLoad() {
 39+ global $egYahooMapsOnThisPage;
 40+
 41+ MapsYahooMapsUtils::addYMapDependencies($this->output);
 42+ $egYahooMapsOnThisPage++;
 43+
 44+ $this->elementNr = $egYahooMapsOnThisPage;
 45+ }
 46+
 47+ /**
 48+ * @see MapsBaseMap::addSpecificMapHTML()
 49+ *
 50+ */
 51+ public function addSpecificMapHTML() {
 52+ global $wgJsMimeType;
 53+
 54+ $this->type = MapsYahooMapsUtils::getYMapType($this->type, true);
 55+
 56+ $this->controls = MapsYahooMapsUtils::createControlsString($this->controls);
 57+
 58+ MapsUtils::makePxValue($this->width);
 59+ MapsUtils::makePxValue($this->height);
 60+
 61+ $this->autozoom = MapsYahooMapsUtils::getAutozoomJSValue($this->autozoom);
 62+
 63+ $markerItems = array();
 64+
 65+ // TODO: Refactor up
 66+ foreach ($this->markerData as $markerData) {
 67+ $lat = $markerData['lat'];
 68+ $lon = $markerData['lon'];
 69+
 70+ $title = array_key_exists('title', $markerData) ? $markerData['title'] : $this->title;
 71+ $label = array_key_exists('label', $markerData) ? $markerData['label'] : $this->label;
 72+
 73+ $title = str_replace("'", "\'", $title);
 74+ $label = str_replace("'", "\'", $label);
 75+
 76+ $icon = array_key_exists('icon', $markerData) ? $markerData['icon'] : '';
 77+ $markerItems[] = "getYMarkerData($lat, $lon, '$title', '$label', '$icon')";
 78+ }
 79+
 80+ $markersString = implode(',', $markerItems);
 81+
 82+ $this->types = explode(",", $this->types);
 83+
 84+ $typesString = MapsYahooMapsUtils::createTypesString($this->types);
 85+
 86+ $this->output .= <<<END
 87+ <div id="$this->mapName" style="width: $this->width; height: $this->height;"></div>
 88+
 89+ <script type="$wgJsMimeType">/*<![CDATA[*/
 90+ addLoadEvent(
 91+ initializeYahooMap('$this->mapName', $this->centre_lat, $this->centre_lon, $this->zoom, $this->type, [$typesString], [$this->controls], $this->autozoom, [$markersString])
 92+ );
 93+ /*]]>*/</script>
 94+END;
 95+ }
 96+
 97+}
Property changes on: trunk/extensions/Maps/YahooMaps/Maps_YahooMapsParserFunctions.php
___________________________________________________________________
Added: svn:eol-style
9898 + native
Index: trunk/extensions/Maps/Geocoders/Maps_Geocoder.php
@@ -1,190 +1,190 @@
2 -<?php
3 -
4 -/**
5 - * File containing the MapsGeocoder class which handles the non specific geocoding tasks
6 - *
7 - * {{#geocode:<Address>|<param1>=<value1>|<param2>=<value2>}}
8 - * {{#geocodelat:<Address>|<param1>=<value1>|<param2>=<value2>}}
9 - * {{#geocodelng:<Address>|<param1>=<value1>|<param2>=<value2>}}
10 - *
11 - * @file Maps_Geocoder.php
12 - * @ingroup Maps
13 - *
14 - * @author Jeroen De Dauw
15 - * @author Sergey Chernyshev
16 - */
17 -
18 -if( !defined( 'MEDIAWIKI' ) ) {
19 - die( 'Not an entry point.' );
20 -}
21 -
22 -final class MapsGeocoder {
23 -
24 - /**
25 - * Holds if geocoded data should be cached or not.
26 - *
27 - * @var boolean
28 - */
29 - private static $mEnableCache = true;
30 -
31 - /**
32 - * The geocoder cache, holding geocoded data when enabled.
33 - *
34 - * @var array
35 - */
36 - private static $mGeocoderCache = array();
37 -
38 - /**
39 - * Handler for the geocode parser function. Returns the latitude and longitude
40 - * for the provided address, or an empty string, when the geocoding fails.
41 - *
42 - * @param unknown_type $parser
43 - * @param string $address The address to geocode.
44 - * @param string $service Optional. The geocoding service to use.
45 - * @param string $mappingService Optional. The mapping service that will use the geocoded data.
46 - * @return string
47 - */
48 - public static function renderGeocoder($parser, $address, $service = '', $mappingService = '') {
49 - $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
50 - return $geovalues ? $geovalues['lat'].', '.$geovalues['lon'] : '';
51 - }
52 -
53 - /**
54 - * Handler for the geocode parser function. Returns the latitude
55 - * for the provided address, or an empty string, when the geocoding fails.
56 - *
57 - * @param unknown_type $parser
58 - * @param string $address The address to geocode.
59 - * @param string $service Optional. The geocoding service to use.
60 - * @param string $mappingService Optional. The mapping service that will use the geocoded data.
61 - * @return string
62 - */
63 - public static function renderGeocoderLat(&$parser, $address, $service = '', $mappingService = '') {
64 - $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
65 - return $geovalues ? $geovalues['lat'] : '';
66 - }
67 -
68 - /**
69 - * Handler for the geocode parser function. Returns the longitude
70 - * for the provided address, or an empty string, when the geocoding fails.
71 - *
72 - * @param unknown_type $parser
73 - * @param string $address The address to geocode.
74 - * @param string $service Optional. The geocoding service to use.
75 - * @param string $mappingService Optional. The mapping service that will use the geocoded data.
76 - * @return string
77 - */
78 - public static function renderGeocoderLng(&$parser, $address, $service = '', $mappingService = '') {
79 - $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
80 - return $geovalues ? $geovalues['lon'] : '';
81 - }
82 -
83 - /**
84 - * Geocodes an address with the provided geocoding service and returns the result
85 - * as a string with the optionally provided format, or false when the geocoding failed.
86 - *
87 - * @param string $address
88 - * @param string $service
89 - * @param string $mappingService
90 - * @param string $format
91 - * @return formatted coordinate string or false
92 - */
93 - public static function geocodeToString($address, $service = '', $mappingService = '', $format = '%1$s, %2$s') {
94 - $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
95 - return $geovalues ? sprintf($format, $geovalues['lat'], $geovalues['lon']) : false;
96 - }
97 -
98 - /**
99 - * Geocodes an address with the provided geocoding service and returns the result
100 - * as an array, or false when the geocoding failed.
101 - *
102 - * @param string $address
103 - * @param string $service
104 - * @param string $mappingService
105 - * @return array with coordinates or false
106 - */
107 - private static function geocode($address, $service, $mappingService) {
108 - global $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
109 -
110 - // If the adress is already in the cache and the cache is enabled, return the coordinates
111 - if (self::$mEnableCache && array_key_exists($address, MapsGeocoder::$mGeocoderCache)) {
112 - return self::$mGeocoderCache[$address];
113 - }
114 -
115 - $coordinates = false;
116 -
117 - $service = self::getValidGeoService($service, $mappingService);
118 -
119 - // If not, use the selected geocoding service to geocode the provided adress
120 - switch(strtolower($service)) {
121 - case 'google':
122 - self::addAutoloadClassIfNeeded('MapsGoogleGeocoder', 'Maps_GoogleGeocoder.php');
123 - $coordinates = MapsGoogleGeocoder::geocode($address);
124 - break;
125 - case 'yahoo':
126 - self::addAutoloadClassIfNeeded('MapsYahooGeocoder', 'Maps_YahooGeocoder.php');
127 - $coordinates = MapsYahooGeocoder::geocode($address);
128 - break;
129 - case 'geonames':
130 - self::addAutoloadClassIfNeeded('MapsGeonamesGeocoder', 'Maps_GeonamesGeocoder.php');
131 - $coordinates = MapsGeonamesGeocoder::geocode($address);
132 - break;
133 - }
134 -
135 - // Add the obtained coordinates to the cache when there is a result and the cache is enabled
136 - if (self::$mEnableCache && $coordinates) {
137 - MapsGeocoder::$mGeocoderCache[$address] = $coordinates;
138 - }
139 -
140 - return $coordinates;
141 - }
142 -
143 - /**
144 - * Add a geocoder class to the $wgAutoloadClasses array when it's not present yet.
145 - *
146 - * @param string $className
147 - * @param string $fileName
148 - */
149 - private static function addAutoloadClassIfNeeded($className, $fileName) {
150 - global $wgAutoloadClasses, $egMapsIP;
151 - if (!array_key_exists($className, $wgAutoloadClasses)) $wgAutoloadClasses[$className] = $egMapsIP . '/Geocoders/' . $fileName;
152 - }
153 -
154 - /**
155 - * Makes sure that the geo service is one of the available ones.
156 - * Also enforces licencing restrictions when no geocoding service is explicitly provided.
157 - *
158 - * @param string $service
159 - * @param string $mappingService
160 - * @return string
161 - */
162 - private static function getValidGeoService($service, $mappingService) {
163 - global $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
164 -
165 - if (strlen($service) < 1) {
166 -
167 - // Set the default geocoding services.
168 - // Note that googlemaps and yahoomaps are excetions to the general rule due to licencing.
169 - switch ($mappingService) {
170 - case 'googlemaps' :
171 - $service = 'google';
172 - break;
173 - case 'yahoomaps' :
174 - $service = 'yahoo';
175 - break;
176 - default :
177 - $service = $egMapsDefaultGeoService;
178 - break;
179 - }
180 -
181 - }
182 - else {
183 - if(!in_array($service, $egMapsAvailableGeoServices)) $service = $egMapsDefaultGeoService;
184 - }
185 -
186 - return $service;
187 - }
188 -}
189 -
190 -
191 -
 2+<?php
 3+
 4+/**
 5+ * File containing the MapsGeocoder class which handles the non specific geocoding tasks
 6+ *
 7+ * {{#geocode:<Address>|<param1>=<value1>|<param2>=<value2>}}
 8+ * {{#geocodelat:<Address>|<param1>=<value1>|<param2>=<value2>}}
 9+ * {{#geocodelng:<Address>|<param1>=<value1>|<param2>=<value2>}}
 10+ *
 11+ * @file Maps_Geocoder.php
 12+ * @ingroup Maps
 13+ *
 14+ * @author Jeroen De Dauw
 15+ * @author Sergey Chernyshev
 16+ */
 17+
 18+if( !defined( 'MEDIAWIKI' ) ) {
 19+ die( 'Not an entry point.' );
 20+}
 21+
 22+final class MapsGeocoder {
 23+
 24+ /**
 25+ * Holds if geocoded data should be cached or not.
 26+ *
 27+ * @var boolean
 28+ */
 29+ private static $mEnableCache = true;
 30+
 31+ /**
 32+ * The geocoder cache, holding geocoded data when enabled.
 33+ *
 34+ * @var array
 35+ */
 36+ private static $mGeocoderCache = array();
 37+
 38+ /**
 39+ * Handler for the geocode parser function. Returns the latitude and longitude
 40+ * for the provided address, or an empty string, when the geocoding fails.
 41+ *
 42+ * @param unknown_type $parser
 43+ * @param string $address The address to geocode.
 44+ * @param string $service Optional. The geocoding service to use.
 45+ * @param string $mappingService Optional. The mapping service that will use the geocoded data.
 46+ * @return string
 47+ */
 48+ public static function renderGeocoder($parser, $address, $service = '', $mappingService = '') {
 49+ $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
 50+ return $geovalues ? $geovalues['lat'].', '.$geovalues['lon'] : '';
 51+ }
 52+
 53+ /**
 54+ * Handler for the geocode parser function. Returns the latitude
 55+ * for the provided address, or an empty string, when the geocoding fails.
 56+ *
 57+ * @param unknown_type $parser
 58+ * @param string $address The address to geocode.
 59+ * @param string $service Optional. The geocoding service to use.
 60+ * @param string $mappingService Optional. The mapping service that will use the geocoded data.
 61+ * @return string
 62+ */
 63+ public static function renderGeocoderLat(&$parser, $address, $service = '', $mappingService = '') {
 64+ $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
 65+ return $geovalues ? $geovalues['lat'] : '';
 66+ }
 67+
 68+ /**
 69+ * Handler for the geocode parser function. Returns the longitude
 70+ * for the provided address, or an empty string, when the geocoding fails.
 71+ *
 72+ * @param unknown_type $parser
 73+ * @param string $address The address to geocode.
 74+ * @param string $service Optional. The geocoding service to use.
 75+ * @param string $mappingService Optional. The mapping service that will use the geocoded data.
 76+ * @return string
 77+ */
 78+ public static function renderGeocoderLng(&$parser, $address, $service = '', $mappingService = '') {
 79+ $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
 80+ return $geovalues ? $geovalues['lon'] : '';
 81+ }
 82+
 83+ /**
 84+ * Geocodes an address with the provided geocoding service and returns the result
 85+ * as a string with the optionally provided format, or false when the geocoding failed.
 86+ *
 87+ * @param string $address
 88+ * @param string $service
 89+ * @param string $mappingService
 90+ * @param string $format
 91+ * @return formatted coordinate string or false
 92+ */
 93+ public static function geocodeToString($address, $service = '', $mappingService = '', $format = '%1$s, %2$s') {
 94+ $geovalues = MapsGeocoder::geocode($address, $service, $mappingService);
 95+ return $geovalues ? sprintf($format, $geovalues['lat'], $geovalues['lon']) : false;
 96+ }
 97+
 98+ /**
 99+ * Geocodes an address with the provided geocoding service and returns the result
 100+ * as an array, or false when the geocoding failed.
 101+ *
 102+ * @param string $address
 103+ * @param string $service
 104+ * @param string $mappingService
 105+ * @return array with coordinates or false
 106+ */
 107+ private static function geocode($address, $service, $mappingService) {
 108+ global $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
 109+
 110+ // If the adress is already in the cache and the cache is enabled, return the coordinates
 111+ if (self::$mEnableCache && array_key_exists($address, MapsGeocoder::$mGeocoderCache)) {
 112+ return self::$mGeocoderCache[$address];
 113+ }
 114+
 115+ $coordinates = false;
 116+
 117+ $service = self::getValidGeoService($service, $mappingService);
 118+
 119+ // If not, use the selected geocoding service to geocode the provided adress
 120+ switch(strtolower($service)) {
 121+ case 'google':
 122+ self::addAutoloadClassIfNeeded('MapsGoogleGeocoder', 'Maps_GoogleGeocoder.php');
 123+ $coordinates = MapsGoogleGeocoder::geocode($address);
 124+ break;
 125+ case 'yahoo':
 126+ self::addAutoloadClassIfNeeded('MapsYahooGeocoder', 'Maps_YahooGeocoder.php');
 127+ $coordinates = MapsYahooGeocoder::geocode($address);
 128+ break;
 129+ case 'geonames':
 130+ self::addAutoloadClassIfNeeded('MapsGeonamesGeocoder', 'Maps_GeonamesGeocoder.php');
 131+ $coordinates = MapsGeonamesGeocoder::geocode($address);
 132+ break;
 133+ }
 134+
 135+ // Add the obtained coordinates to the cache when there is a result and the cache is enabled
 136+ if (self::$mEnableCache && $coordinates) {
 137+ MapsGeocoder::$mGeocoderCache[$address] = $coordinates;
 138+ }
 139+
 140+ return $coordinates;
 141+ }
 142+
 143+ /**
 144+ * Add a geocoder class to the $wgAutoloadClasses array when it's not present yet.
 145+ *
 146+ * @param string $className
 147+ * @param string $fileName
 148+ */
 149+ private static function addAutoloadClassIfNeeded($className, $fileName) {
 150+ global $wgAutoloadClasses, $egMapsIP;
 151+ if (!array_key_exists($className, $wgAutoloadClasses)) $wgAutoloadClasses[$className] = $egMapsIP . '/Geocoders/' . $fileName;
 152+ }
 153+
 154+ /**
 155+ * Makes sure that the geo service is one of the available ones.
 156+ * Also enforces licencing restrictions when no geocoding service is explicitly provided.
 157+ *
 158+ * @param string $service
 159+ * @param string $mappingService
 160+ * @return string
 161+ */
 162+ private static function getValidGeoService($service, $mappingService) {
 163+ global $egMapsAvailableGeoServices, $egMapsDefaultGeoService;
 164+
 165+ if (strlen($service) < 1) {
 166+
 167+ // Set the default geocoding services.
 168+ // Note that googlemaps and yahoomaps are excetions to the general rule due to licencing.
 169+ switch ($mappingService) {
 170+ case 'googlemaps' :
 171+ $service = 'google';
 172+ break;
 173+ case 'yahoomaps' :
 174+ $service = 'yahoo';
 175+ break;
 176+ default :
 177+ $service = $egMapsDefaultGeoService;
 178+ break;
 179+ }
 180+
 181+ }
 182+ else {
 183+ if(!in_array($service, $egMapsAvailableGeoServices)) $service = $egMapsDefaultGeoService;
 184+ }
 185+
 186+ return $service;
 187+ }
 188+}
 189+
 190+
 191+
Property changes on: trunk/extensions/Maps/Geocoders/Maps_Geocoder.php
___________________________________________________________________
Added: svn:eol-style
192192 + native
Index: trunk/extensions/Maps/Geocoders/Maps_BaseGeocoder.php
@@ -1,118 +1,118 @@
2 -<?php
3 -
4 -/**
5 - * MapsBaseGeocoder is an abstract class inherited by the geocoding classes
6 - *
7 - * @file Maps_BaseGeocoder.php
8 - * @ingroup Maps
9 - *
10 - * @author Jeroen De Dauw
11 - */
12 -
13 -if( !defined( 'MEDIAWIKI' ) ) {
14 - die( 'Not an entry point.' );
15 -}
16 -
17 -abstract class MapsBaseGeocoder {
18 -
19 - /**
20 - * Returns an array containing the geocoded latitude (lat) and
21 - * longitude (lon) of the provided address, or false in case the
22 - * geocoding fails.
23 - *
24 - * @param string $address
25 - */
26 - public abstract static function geocode($address);
27 -
28 - /**
29 - * Returns the content of the requested file, or false when the connection fails
30 - *
31 - * @param string $requestURL
32 - * @return string or false
33 - */
34 - protected static function GetResponse($requestURL) {
35 - // Attempt to get CURL response
36 - $response = self::GetCurlResponse($requestURL);
37 -
38 - // Attempt to get response using fopen when the CURL request failed
39 - if (!$response) $response = self::GetUrlResponse($requestURL);
40 -
41 - return $response;
42 - }
43 -
44 - /**
45 - * Attempts to get the contents of a file via cURL request and
46 - * returns it, or false when the attempt fails.
47 - *
48 - * @param string $requestURL
49 - * @return string or false
50 - */
51 - protected static function GetCurlResponse($requestURL) {
52 - if (function_exists("curl_init")) {
53 - try {
54 - //Set up a CURL request, telling it not to spit back headers, and to throw out a user agent.
55 - $ch = curl_init();
56 -
57 - curl_setopt($ch, CURLOPT_URL, $requestURL);
58 - curl_setopt($ch, CURLOPT_HEADER, 0); //Change this to a 1 to return headers
59 - curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
60 - curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
61 - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
62 -
63 - $result = curl_exec($ch);
64 - curl_close($ch);
65 -
66 - return $result;
67 - }
68 - catch(Exception $ex) {
69 - return false;
70 - }
71 - }
72 - else {
73 - return false;
74 - }
75 - }
76 -
77 - /**
78 - * Attempts to get the contents of a file via fopen and
79 - * returns it, or false when the attempt fails.
80 - *
81 - * @param string $requestURL
82 - * @return string or false
83 - */
84 - protected static function GetUrlResponse($requestURL) {
85 - if (function_exists('fopen')) {
86 - try {
87 - if ($handle = fopen($requestURL, 'r')) {
88 - $result = fread($handle, 10000);
89 - fclose($handle);
90 - }
91 - else { // When the request fails, return false
92 - $result = false;
93 - }
94 - }
95 - catch(Exception $ex) {
96 - $result = false;
97 - }
98 - }
99 - else {
100 - $result = false;
101 - }
102 - return $result;
103 - }
104 -
105 - /**
106 - * Gets the contents of the first XML tag with the provided name,
107 - * returns false when no matching element is found.
108 - *
109 - * @param string $xml
110 - * @param string $tagName
111 - * @return string or false
112 - */
113 - protected static function getXmlElementValue($xml, $tagName) {
114 - $match = array();
115 - preg_match("/<$tagName>(.*?)<\/$tagName>/", $xml, $match);
116 - return count($match) > 1 ? $match[1] : false;
117 - }
118 -
119 -}
 2+<?php
 3+
 4+/**
 5+ * MapsBaseGeocoder is an abstract class inherited by the geocoding classes
 6+ *
 7+ * @file Maps_BaseGeocoder.php
 8+ * @ingroup Maps
 9+ *
 10+ * @author Jeroen De Dauw
 11+ */
 12+
 13+if( !defined( 'MEDIAWIKI' ) ) {
 14+ die( 'Not an entry point.' );
 15+}
 16+
 17+abstract class MapsBaseGeocoder {
 18+
 19+ /**
 20+ * Returns an array containing the geocoded latitude (lat) and
 21+ * longitude (lon) of the provided address, or false in case the
 22+ * geocoding fails.
 23+ *
 24+ * @param string $address
 25+ */
 26+ public abstract static function geocode($address);
 27+
 28+ /**
 29+ * Returns the content of the requested file, or false when the connection fails
 30+ *
 31+ * @param string $requestURL
 32+ * @return string or false
 33+ */
 34+ protected static function GetResponse($requestURL) {
 35+ // Attempt to get CURL response
 36+ $response = self::GetCurlResponse($requestURL);
 37+
 38+ // Attempt to get response using fopen when the CURL request failed
 39+ if (!$response) $response = self::GetUrlResponse($requestURL);
 40+
 41+ return $response;
 42+ }
 43+
 44+ /**
 45+ * Attempts to get the contents of a file via cURL request and
 46+ * returns it, or false when the attempt fails.
 47+ *
 48+ * @param string $requestURL
 49+ * @return string or false
 50+ */
 51+ protected static function GetCurlResponse($requestURL) {
 52+ if (function_exists("curl_init")) {
 53+ try {
 54+ //Set up a CURL request, telling it not to spit back headers, and to throw out a user agent.
 55+ $ch = curl_init();
 56+
 57+ curl_setopt($ch, CURLOPT_URL, $requestURL);
 58+ curl_setopt($ch, CURLOPT_HEADER, 0); //Change this to a 1 to return headers
 59+ curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
 60+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 61+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 62+
 63+ $result = curl_exec($ch);
 64+ curl_close($ch);
 65+
 66+ return $result;
 67+ }
 68+ catch(Exception $ex) {
 69+ return false;
 70+ }
 71+ }
 72+ else {
 73+ return false;
 74+ }
 75+ }
 76+
 77+ /**
 78+ * Attempts to get the contents of a file via fopen and
 79+ * returns it, or false when the attempt fails.
 80+ *
 81+ * @param string $requestURL
 82+ * @return string or false
 83+ */
 84+ protected static function GetUrlResponse($requestURL) {
 85+ if (function_exists('fopen')) {
 86+ try {
 87+ if ($handle = fopen($requestURL, 'r')) {
 88+ $result = fread($handle, 10000);
 89+ fclose($handle);
 90+ }
 91+ else { // When the request fails, return false
 92+ $result = false;
 93+ }
 94+ }
 95+ catch(Exception $ex) {
 96+ $result = false;
 97+ }
 98+ }
 99+ else {
 100+ $result = false;
 101+ }
 102+ return $result;
 103+ }
 104+
 105+ /**
 106+ * Gets the contents of the first XML tag with the provided name,
 107+ * returns false when no matching element is found.
 108+ *
 109+ * @param string $xml
 110+ * @param string $tagName
 111+ * @return string or false
 112+ */
 113+ protected static function getXmlElementValue($xml, $tagName) {
 114+ $match = array();
 115+ preg_match("/<$tagName>(.*?)<\/$tagName>/", $xml, $match);
 116+ return count($match) > 1 ? $match[1] : false;
 117+ }
 118+
 119+}
Property changes on: trunk/extensions/Maps/Geocoders/Maps_BaseGeocoder.php
___________________________________________________________________
Added: svn:eol-style
120120 + native
Index: trunk/extensions/ConditionalShowSection/README
@@ -1,126 +1,126 @@
2 -/*
3 - * ConditionalShowSection MediaWiki extension
4 - *
5 - * @author Jean-Lou Dupont
6 - * @package MediaWiki
7 - * @subpackage Extensions
8 - * @licence GNU General Public Licence 2.0
9 - * This extension enables to conditionally show/hide a section
10 - * of wikitext that appears between the <cshow> </cshow> tags.
11 - *
12 - * Add to LocalSettings.php
13 - * with: require_once("extensions/ConditionalShowSection/ConditionalShowSection.php");
14 - *
15 - * HISTORY:
16 - * 1.1: corrected bug when "ingroup" option not present, wrong results.
17 - * 1.2: used "recursiveTagParse" to get cleaner parsing.
18 - * 1.3: corrected error with default initialisation of userReqLogged
19 - * 1.4: changed to using 'getEffectiveGroups' in order to have also access
20 - * to the implicit '*' group and the default group for logged users 'user'.
21 - * 1.5: Allow to check multiple groups - separated by ","
22 - */
23 -
24 -
25 -
26 -{{Extension|templatemode =
27 -|name = ConditionalShow
28 -|status = stable
29 -|type1 = tag
30 -|type2 = user rights
31 -|type3 = mywiki
32 -|hook1 = ParserFirstCallInit
33 -|hook2 =
34 -|username = [[user:jldupont]]
35 -|author =
36 -|description = Conditionally show a wikitext section based on user group rights
37 -|image =
38 -|imagesize =
39 -|version = 1.5
40 -|update = 2009-09-10
41 -|mediawiki = tested on 1.8.2, 1.9.3, 1.10, 1.14, 1.15, 1.16A
42 -|php =
43 -|license = GNU General Public Licence 2.0
44 -|download = [http://wiki.jldupont.com/Extension:ConditionalContent http version <1.5]
45 -|readme =
46 -|changelog =
47 -|parameters =
48 -|tags = <cshow>,</cshow>
49 -|rights =
50 -|example =
51 -|compatibility =
52 -}}
53 -
54 -==What can this extension do?==
55 -This extension implementes the <nowiki><cshow></nowiki> tag which conditionally shows wikitext within the tags based on user group rights and certain other parameters.
56 -
57 -Using the tags should be to make the user experience less confusing or more useful by only showing information relevant to the user and specific groups that user belongs to.
58 -<div style="width: 80%; margin-left: auto; margin-right: auto; padding: 4px; border: 2px solid #FF0000; background-color: #FFDDDD; text-align: center;">
59 -'''PLEASE NOTE!!!'''
60 -
61 -This tag does not protect information or instructions from being disclosed to the reader.
62 -
63 -The user can still see the information by editing the page or even by "view source". If you are looking to actually protect information, this is '''NOT''' the extension you want to use!
64 -
65 -This extension only helps you selectively show content or navigation based on groups the user belongs to.
66 -</div>
67 -==Note==
68 -
69 -This extension is not 'cache' friendly; if one requires this feature, then [[Extension:BizzWiki|BizzWiki platform]] provides a solution through [[Extension:ParserPhase2|Parser Phase 2 extension]].
70 -
71 -==Usage==
72 -
73 -Like other tags, this can be used two ways - by using the tag itself within wikitext, or by using the tag function within templates.
74 -
75 -If you are using it within normal wikitext, the <nowiki><cshow>. . .</cshow></nowiki> syntax suffices. If you are using it within a template, you will need to use the parser tag function as illustrated [[#Example within a Template | below]].
76 -
77 -===Example in Wikitext===
78 -By default, the section of wikitext within the tags is HIDDEN unless the conditions are met - in this case the user must be logged in and belong the group 'sysops'
79 -
80 -<pre>
81 -<cshow logged=1 ingroup='sysop'> This text will appear if a user with membership to 'sysop' group views this page</cshow>
82 -</pre>
83 -
84 -===Example within a Template===
85 -
86 -If you are using this within a template or as part of a template, you need to use the <nowiki>{{##tag: . . .}}</nowiki> syntax.
87 -
88 -<pre>
89 -{{#tag:cshow |
90 -This text will appear if a user with membership to 'sysop' group views this page
91 -| logged=1 ingroup='sysop'
92 -}}
93 -</pre>
94 -
95 -==Arguments==
96 -
97 -By default, the tagged section is HIDDEN unless the following conditions are met:
98 -* Argument: logged = '1' or '0'
99 -* Argument: ingroup = 'group XYZ' (Note, as of version 1.5, you can list multiple groups, e.g. 'sysop,approved'
100 -
101 -If no arguments are provided for:
102 -logged --> assume 'don't care'
103 -innGroup --> assume '' (no group)
104 -
105 -In other words, if no 'ingroup' parameter is given, then the condition 'ingroup' is never met.
106 -
107 -If no "logged" parameter is given, then this condition is always met.
108 -
109 -==Download instructions==
110 -
111 -The current version is available from SVN.
112 -
113 -Source Code and additional information can also be found at [http://bluecortex.com/index.php?title=Bluecortex:ConditionalShow].
114 -The code should be loaded to:
115 -
116 -<code>$IP/extensions/ConditionalShowSection/ConditionalShowSection.php</code>. ''Note: [[Manual:$IP|$IP]] stands for the root directory of your MediaWiki installation, the same directory that holds [[Manual:LocalSettings.php|LocalSettings.php]]''.
117 -
118 -==Installation==
119 -To install this extension, add the following to [[Manual:LocalSettings.php|LocalSettings.php]]:
120 -<source lang="php">
121 -require_once("$IP/extensions/ConditionalShowSection/ConditionalShowSection.php");
122 -</source>
123 -
124 -== Other Options ==
125 -* [[Extension:ConditionalContent]]
126 -
127 -[[Category:View page extensions]]
 2+/*
 3+ * ConditionalShowSection MediaWiki extension
 4+ *
 5+ * @author Jean-Lou Dupont
 6+ * @package MediaWiki
 7+ * @subpackage Extensions
 8+ * @licence GNU General Public Licence 2.0
 9+ * This extension enables to conditionally show/hide a section
 10+ * of wikitext that appears between the <cshow> </cshow> tags.
 11+ *
 12+ * Add to LocalSettings.php
 13+ * with: require_once("extensions/ConditionalShowSection/ConditionalShowSection.php");
 14+ *
 15+ * HISTORY:
 16+ * 1.1: corrected bug when "ingroup" option not present, wrong results.
 17+ * 1.2: used "recursiveTagParse" to get cleaner parsing.
 18+ * 1.3: corrected error with default initialisation of userReqLogged
 19+ * 1.4: changed to using 'getEffectiveGroups' in order to have also access
 20+ * to the implicit '*' group and the default group for logged users 'user'.
 21+ * 1.5: Allow to check multiple groups - separated by ","
 22+ */
 23+
 24+
 25+
 26+{{Extension|templatemode =
 27+|name = ConditionalShow
 28+|status = stable
 29+|type1 = tag
 30+|type2 = user rights
 31+|type3 = mywiki
 32+|hook1 = ParserFirstCallInit
 33+|hook2 =
 34+|username = [[user:jldupont]]
 35+|author =
 36+|description = Conditionally show a wikitext section based on user group rights
 37+|image =
 38+|imagesize =
 39+|version = 1.5
 40+|update = 2009-09-10
 41+|mediawiki = tested on 1.8.2, 1.9.3, 1.10, 1.14, 1.15, 1.16A
 42+|php =
 43+|license = GNU General Public Licence 2.0
 44+|download = [http://wiki.jldupont.com/Extension:ConditionalContent http version <1.5]
 45+|readme =
 46+|changelog =
 47+|parameters =
 48+|tags = <cshow>,</cshow>
 49+|rights =
 50+|example =
 51+|compatibility =
 52+}}
 53+
 54+==What can this extension do?==
 55+This extension implementes the <nowiki><cshow></nowiki> tag which conditionally shows wikitext within the tags based on user group rights and certain other parameters.
 56+
 57+Using the tags should be to make the user experience less confusing or more useful by only showing information relevant to the user and specific groups that user belongs to.
 58+<div style="width: 80%; margin-left: auto; margin-right: auto; padding: 4px; border: 2px solid #FF0000; background-color: #FFDDDD; text-align: center;">
 59+'''PLEASE NOTE!!!'''
 60+
 61+This tag does not protect information or instructions from being disclosed to the reader.
 62+
 63+The user can still see the information by editing the page or even by "view source". If you are looking to actually protect information, this is '''NOT''' the extension you want to use!
 64+
 65+This extension only helps you selectively show content or navigation based on groups the user belongs to.
 66+</div>
 67+==Note==
 68+
 69+This extension is not 'cache' friendly; if one requires this feature, then [[Extension:BizzWiki|BizzWiki platform]] provides a solution through [[Extension:ParserPhase2|Parser Phase 2 extension]].
 70+
 71+==Usage==
 72+
 73+Like other tags, this can be used two ways - by using the tag itself within wikitext, or by using the tag function within templates.
 74+
 75+If you are using it within normal wikitext, the <nowiki><cshow>. . .</cshow></nowiki> syntax suffices. If you are using it within a template, you will need to use the parser tag function as illustrated [[#Example within a Template | below]].
 76+
 77+===Example in Wikitext===
 78+By default, the section of wikitext within the tags is HIDDEN unless the conditions are met - in this case the user must be logged in and belong the group 'sysops'
 79+
 80+<pre>
 81+<cshow logged=1 ingroup='sysop'> This text will appear if a user with membership to 'sysop' group views this page</cshow>
 82+</pre>
 83+
 84+===Example within a Template===
 85+
 86+If you are using this within a template or as part of a template, you need to use the <nowiki>{{##tag: . . .}}</nowiki> syntax.
 87+
 88+<pre>
 89+{{#tag:cshow |
 90+This text will appear if a user with membership to 'sysop' group views this page
 91+| logged=1 ingroup='sysop'
 92+}}
 93+</pre>
 94+
 95+==Arguments==
 96+
 97+By default, the tagged section is HIDDEN unless the following conditions are met:
 98+* Argument: logged = '1' or '0'
 99+* Argument: ingroup = 'group XYZ' (Note, as of version 1.5, you can list multiple groups, e.g. 'sysop,approved'
 100+
 101+If no arguments are provided for:
 102+logged --> assume 'don't care'
 103+innGroup --> assume '' (no group)
 104+
 105+In other words, if no 'ingroup' parameter is given, then the condition 'ingroup' is never met.
 106+
 107+If no "logged" parameter is given, then this condition is always met.
 108+
 109+==Download instructions==
 110+
 111+The current version is available from SVN.
 112+
 113+Source Code and additional information can also be found at [http://bluecortex.com/index.php?title=Bluecortex:ConditionalShow].
 114+The code should be loaded to:
 115+
 116+<code>$IP/extensions/ConditionalShowSection/ConditionalShowSection.php</code>. ''Note: [[Manual:$IP|$IP]] stands for the root directory of your MediaWiki installation, the same directory that holds [[Manual:LocalSettings.php|LocalSettings.php]]''.
 117+
 118+==Installation==
 119+To install this extension, add the following to [[Manual:LocalSettings.php|LocalSettings.php]]:
 120+<source lang="php">
 121+require_once("$IP/extensions/ConditionalShowSection/ConditionalShowSection.php");
 122+</source>
 123+
 124+== Other Options ==
 125+* [[Extension:ConditionalContent]]
 126+
 127+[[Category:View page extensions]]
Property changes on: trunk/extensions/ConditionalShowSection/README
___________________________________________________________________
Added: svn:eol-style
128128 + native

Status & tagging log