|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright Andreas Heigl <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy |
|
6
|
|
|
* of this software and associated documentation files (the "Software"), to deal |
|
7
|
|
|
* in the Software without restriction, including without limitation the rights |
|
8
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
9
|
|
|
* copies of the Software, and to permit persons to whom the Software is |
|
10
|
|
|
* furnished to do so, subject to the following conditions: |
|
11
|
|
|
* |
|
12
|
|
|
* The above copyright notice and this permission notice shall be included in |
|
13
|
|
|
* all copies or substantial portions of the Software. |
|
14
|
|
|
* |
|
15
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
16
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
17
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
18
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
19
|
|
|
* LIBILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
20
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
21
|
|
|
* THE SOFTWARE. |
|
22
|
|
|
* |
|
23
|
|
|
* @author Andreas Heigl<[email protected]> |
|
24
|
|
|
* @copyright Andreas Heigl |
|
25
|
|
|
* @license http://www.opesource.org/licenses/mit-license.php MIT-License |
|
26
|
|
|
* @version 0.0 |
|
27
|
|
|
* @since 29.07.13 |
|
28
|
|
|
* @link https://github.com/heiglandreas/OrgHeiglGeolocation |
|
29
|
|
|
*/ |
|
30
|
|
|
|
|
31
|
|
|
namespace Org_Heigl\Geolocation\Renderer\Geolocation; |
|
32
|
|
|
|
|
33
|
|
|
use Zend\Mvc\Router\RouteInterface; |
|
34
|
|
|
use Zend\Stdlib\AbstractOptions; |
|
35
|
|
|
use Zend\EventManager\StaticEventManager; |
|
36
|
|
|
use Zend\View\ViewEvent; |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
class GeolocationRenderer |
|
40
|
|
|
{ |
|
41
|
|
|
/** |
|
42
|
|
|
* @var \Zend\Mvc\Router\RouteInterface $httpRouter |
|
43
|
|
|
*/ |
|
44
|
|
|
protected $httpRouter = null; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @var \Zend\StdLib\AbstractOptions $options |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $options = null; |
|
50
|
|
|
|
|
51
|
|
|
public function __construct() |
|
52
|
|
|
{ |
|
53
|
|
|
$events = StaticEventManager::getInstance (); |
|
54
|
|
|
|
|
55
|
|
|
// Add event of authentication before dispatch |
|
56
|
|
|
$events->attach('Zend\View\View', ViewEvent::EVENT_RENDERER_POST, array( |
|
57
|
|
|
$this, |
|
58
|
|
|
'preRenderForm' |
|
59
|
|
|
), 110 ); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Executed before the ZF2 view helper renders the element |
|
64
|
|
|
* |
|
65
|
|
|
* @param \Zend\View\ViewEvent $view |
|
66
|
|
|
*/ |
|
67
|
|
|
public function preRenderForm(ViewEvent $view) : self |
|
68
|
|
|
{ |
|
69
|
|
|
$view = $view->getRenderer(); |
|
70
|
|
|
$inlineScript = $view->plugin('inlineScript'); |
|
71
|
|
|
|
|
72
|
|
|
$assetBaseUri = $this->getHttpRouter()->assemble(array(), array('name' => 'home')); |
|
73
|
|
|
|
|
74
|
|
|
$inlineScript->appendFile($assetBaseUri . '/js/geolocation.js'); |
|
75
|
|
|
|
|
76
|
|
|
return $this; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function getHttpRouter() : RouteInterface |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->httpRouter; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function setHttpRouter(RouteInterface $httpRouter) : self |
|
85
|
|
|
{ |
|
86
|
|
|
$this->httpRouter = $httpRouter; |
|
87
|
|
|
|
|
88
|
|
|
return $this; |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
public function getOptions() : AbstractOptions |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->options; |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function setOptions(AbstractOptions $options = null) : self |
|
97
|
|
|
{ |
|
98
|
|
|
$this->options = $options; |
|
99
|
|
|
|
|
100
|
|
|
return $this; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|