Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit c8b928c
Showing
19 changed files
with
591 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2010 Thibault Duplessis | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is furnished | ||
to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
dmGoogleMapPlugin allows to display configurable google maps. | ||
It packages a Diem front widget, and adds a _map() helper. | ||
The plugin is fully extensible. Only works with [Diem 5.0](http://diem-project.org/) installed. | ||
|
||
Documentation | ||
------------- | ||
|
||
See the online documentation : [Diem Google Map plugin documentation](http://diem-project.org/plugins/dmgooglemapplugin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
js: | ||
|
||
dmGoogleMapPlugin: | ||
|
||
api: http://maps.google.com/maps/api/js?sensor=false | ||
|
||
widgetShowForm: widget/showForm | ||
|
||
launcher: launcher | ||
dmGoogleMap: dmGoogleMap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
parameters: | ||
|
||
google_map_tag.class: dmGoogleMapTag | ||
google_map_tag.options: [] | ||
|
||
google_map_helper.class: dmGoogleMapHelper | ||
|
||
services: | ||
|
||
google_map_tag: | ||
class: %google_map_tag.class% | ||
shared: false | ||
arguments: [ %google_map_tag.options% ] | ||
|
||
google_map_helper: | ||
class: %google_map_helper.class% | ||
shared: true | ||
arguments: [ @context ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dmWidgetGoogleMap: | ||
|
||
show: | ||
cache: false | ||
public_name: Google Map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
<?php | ||
|
||
class dmWidgetGoogleMapShowForm extends dmWidgetPluginForm | ||
{ | ||
|
||
public function configure() | ||
{ | ||
$this->widgetSchema['address'] = new sfWidgetFormInputText(); | ||
$this->validatorSchema['address'] = new sfValidatorString(); | ||
$this->widgetSchema['address']->setLabel('Search a place'); | ||
|
||
$this->widgetSchema['mapTypeId'] = new sfWidgetFormSelect(array( | ||
'choices' => dmArray::valueToKey($this->getMapTypeIds()) | ||
)); | ||
$this->validatorSchema['mapTypeId'] = new sfValidatorChoice(array( | ||
'choices' => $this->getMapTypeIds() | ||
)); | ||
$this->widgetSchema['mapTypeId']->setLabel('Map type'); | ||
|
||
$this->widgetSchema['zoom'] = new sfWidgetFormSelect(array( | ||
'choices' => dmArray::valueToKey($this->getZooms()) | ||
)); | ||
$this->validatorSchema['zoom'] = new sfValidatorChoice(array( | ||
'choices' => $this->getZooms() | ||
)); | ||
|
||
$this->widgetSchema['navigationControl'] = new sfWidgetFormInputCheckbox(); | ||
$this->validatorSchema['navigationControl'] = new sfValidatorBoolean(); | ||
$this->widgetSchema['navigationControl']->setLabel('Navigation'); | ||
|
||
$this->widgetSchema['mapTypeControl'] = new sfWidgetFormInputCheckbox(); | ||
$this->validatorSchema['mapTypeControl'] = new sfValidatorBoolean(); | ||
$this->widgetSchema['mapTypeControl']->setLabel('Map type'); | ||
|
||
$this->widgetSchema['scaleControl'] = new sfWidgetFormInputCheckbox(); | ||
$this->validatorSchema['scaleControl'] = new sfValidatorBoolean(); | ||
$this->widgetSchema['scaleControl']->setLabel('Scale'); | ||
|
||
$this->widgetSchema['width'] = new sfWidgetFormInputText(array(), array('size' => 5)); | ||
$this->validatorSchema['width'] = new dmValidatorCssSize(array( | ||
'required' => false | ||
)); | ||
|
||
$this->widgetSchema['height'] = new sfWidgetFormInputText(array(), array('size' => 5)); | ||
$this->validatorSchema['height'] = new dmValidatorCssSize(array( | ||
'required' => false | ||
)); | ||
|
||
$this->widgetSchema['splash'] = new sfWidgetFormInputText(); | ||
$this->validatorSchema['splash'] = new sfValidatorString(array( | ||
'required' => false | ||
)); | ||
$this->widgetSchema->setHelp('splash', 'Display a message while the map is loading'); | ||
|
||
if(!$this->getDefault('width')) | ||
{ | ||
$this->setDefault('width', '100%'); | ||
} | ||
if(!$this->getDefault('height')) | ||
{ | ||
$this->setDefault('height', '300px'); | ||
} | ||
if(!$this->getDefault('mapTypeId')) | ||
{ | ||
$this->setDefault('mapTypeId', 'hybrid'); | ||
} | ||
if(!$this->getDefault('zoom')) | ||
{ | ||
$this->setDefault('zoom', '14'); | ||
} | ||
|
||
parent::configure(); | ||
} | ||
|
||
protected function getMapTypeIds() | ||
{ | ||
return array('roadmap', 'satellite', 'hybrid', 'terrain'); | ||
} | ||
|
||
protected function getZooms() | ||
{ | ||
return range(2, 20); | ||
} | ||
|
||
public function getStylesheets() | ||
{ | ||
return array( | ||
'lib.ui-tabs' | ||
); | ||
} | ||
|
||
public function getJavascripts() | ||
{ | ||
return array( | ||
'lib.ui-tabs', | ||
'core.tabForm', | ||
'dmGoogleMapPlugin.widgetShowForm' | ||
); | ||
} | ||
|
||
protected function renderContent($attributes) | ||
{ | ||
return $this->getHelper()->renderPartial('dmWidgetGoogleMap', 'showForm', array( | ||
'form' => $this, | ||
'baseTabId' => 'dm_widget_google_map_'.$this->dmWidget->get('id') | ||
)); | ||
} | ||
|
||
public function getWidgetValues() | ||
{ | ||
$values = parent::getWidgetValues(); | ||
|
||
return $values; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
class dmWidgetGoogleMapShowView extends dmWidgetPluginView | ||
{ | ||
|
||
public function configure() | ||
{ | ||
parent::configure(); | ||
|
||
$this->addRequiredVar(array( | ||
'address', | ||
'mapTypeId', | ||
'zoom', | ||
'navigationControl', | ||
'mapTypeControl', | ||
'scaleControl', | ||
'width', | ||
'height')); | ||
} | ||
|
||
protected function doRender() | ||
{ | ||
$vars = $this->getViewVars(); | ||
|
||
$map = $this->getService('google_map_helper')->map() | ||
->address($vars['address']) | ||
->mapTypeId($vars['mapTypeId']) | ||
->zoom($vars['zoom']) | ||
->style(sprintf( | ||
'width: %s; height: %s;', | ||
dmArray::get($vars, 'width', '100%'), | ||
dmArray::get($vars, 'height', '300px') | ||
)) | ||
->navigationControl($vars['navigationControl']) | ||
->mapTypeControl($vars['mapTypeControl']) | ||
->scaleControl($vars['scaleControl']) | ||
->splash($vars['splash']); | ||
|
||
$this | ||
->addJavascript($map->getJavascripts()) | ||
->addStylesheet($map->getStylesheets()); | ||
|
||
return $map; | ||
} | ||
|
||
protected function doRenderForIndex() | ||
{ | ||
$vars = $this->getViewVars(); | ||
|
||
return $vars['address']; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
/* | ||
* Get a dmGoogleMapTag instance | ||
*/ | ||
function _map() | ||
{ | ||
return sfContext::getInstance()->get('google_map_helper')->map(); | ||
} | ||
|
||
/* | ||
* Alternative to £map | ||
*/ | ||
function £map() | ||
{ | ||
return _map(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
class dmGoogleMapHelper extends dmConfigurable | ||
{ | ||
protected | ||
$context; | ||
|
||
public function __construct(dmContext $context, array $options = array()) | ||
{ | ||
$this->context = $context; | ||
|
||
$this->initialize($options); | ||
} | ||
|
||
public function initialize(array $options) | ||
{ | ||
$this->configure($options); | ||
} | ||
|
||
/* | ||
* Get a dmGoogleMapTag instance | ||
*/ | ||
public function map() | ||
{ | ||
$map = $this->context->get('google_map_tag'); | ||
|
||
$response = $this->context->getResponse(); | ||
|
||
foreach($map->getStylesheets() as $stylesheet) | ||
{ | ||
$response->addStylesheet($stylesheet); | ||
} | ||
|
||
foreach($map->getJavascripts() as $javascript) | ||
{ | ||
$response->addJavascript($javascript); | ||
} | ||
|
||
/* | ||
* Async loading won't work | ||
* as the api itself uses async loading | ||
*/ | ||
if(!$this->context->getRequest()->isXmlHttpRequest()) | ||
{ | ||
$response->addJavascript('dmGoogleMapPlugin.api'); | ||
} | ||
|
||
return $map; | ||
} | ||
|
||
public function £map() | ||
{ | ||
return $this->map(); | ||
} | ||
} |
Oops, something went wrong.