1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap |
4
|
|
|
{ |
5
|
|
|
public static $translator = null; |
6
|
|
|
|
7
|
16 |
|
protected function _initAutoload() |
8
|
|
|
{ |
9
|
|
|
// Add our own action helpers |
10
|
16 |
|
Zend_Controller_Action_HelperBroker::addPath(APPLICATION_PATH . '/mQueue/Controller/ActionHelper', 'mQueue\\Controller\\ActionHelper\\'); |
11
|
|
|
|
12
|
16 |
|
return Zend_Loader_AutoloaderFactory::factory([ |
|
|
|
|
13
|
16 |
|
'Zend_Loader_StandardAutoloader' => [ |
14
|
|
|
'autoregister_zf' => true, |
15
|
|
|
'namespaces' => [ |
16
|
|
|
'mQueue' => APPLICATION_PATH . '/mQueue', |
17
|
|
|
], |
18
|
|
|
], |
19
|
|
|
]); |
20
|
|
|
} |
21
|
|
|
|
22
|
16 |
|
protected function _initDoctype(): void |
23
|
|
|
{ |
24
|
16 |
|
$this->bootstrap('view'); |
25
|
16 |
|
$view = $this->getResource('view'); |
26
|
16 |
|
$view->doctype(Zend_View_Helper_Doctype::XHTML1_STRICT); |
27
|
|
|
|
28
|
|
|
// Enable our own View Helpers |
29
|
16 |
|
$view->addHelperPath(APPLICATION_PATH . '/mQueue/View/Helper', 'mQueue\\View\\Helper'); |
30
|
16 |
|
} |
31
|
|
|
|
32
|
16 |
|
protected function _initNavigation(): void |
33
|
|
|
{ |
34
|
16 |
|
$this->bootstrap('view'); |
35
|
16 |
|
$view = $this->getResource('view'); |
36
|
|
|
|
37
|
16 |
|
$navigation = new Zend_Navigation([ |
38
|
|
|
[ |
39
|
16 |
|
'label' => $view->translate('Movies'), |
40
|
16 |
|
'controller' => 'movie', |
41
|
16 |
|
'route' => 'default', |
42
|
|
|
'pages' => [ |
43
|
|
|
[ |
44
|
16 |
|
'label' => $view->translate('Add movie'), |
45
|
16 |
|
'controller' => 'movie', |
46
|
16 |
|
'action' => 'add', |
47
|
16 |
|
'route' => 'default', |
48
|
|
|
], |
49
|
|
|
[ |
50
|
16 |
|
'label' => $view->translate('Import votes from IMDb'), |
51
|
16 |
|
'controller' => 'movie', |
52
|
16 |
|
'action' => 'import', |
53
|
16 |
|
'route' => 'default', |
54
|
|
|
], |
55
|
|
|
], |
56
|
|
|
], |
57
|
|
|
[ |
58
|
16 |
|
'label' => $view->translate('Activity'), |
59
|
16 |
|
'controller' => 'activity', |
60
|
16 |
|
'route' => 'default', |
61
|
|
|
], |
62
|
|
|
[ |
63
|
16 |
|
'label' => $view->translate('Users'), |
64
|
16 |
|
'controller' => 'user', |
65
|
16 |
|
'route' => 'default', |
66
|
|
|
], |
67
|
|
|
[ |
68
|
16 |
|
'label' => $view->translate('FAQ'), |
69
|
16 |
|
'controller' => 'faq', |
70
|
16 |
|
'route' => 'default', |
71
|
|
|
], |
72
|
|
|
]); |
73
|
|
|
|
74
|
16 |
|
$view->navigation($navigation); |
75
|
16 |
|
} |
76
|
|
|
|
77
|
16 |
|
protected function _initSession(): void |
78
|
|
|
{ |
79
|
16 |
|
Zend_Session::setOptions(['name' => 'mqueue']); |
80
|
16 |
|
Zend_Session::rememberMe(1 * 60 * 60 * 24 * 31 * 12); // Cookie for 1 year |
81
|
16 |
|
} |
82
|
|
|
|
83
|
16 |
|
protected function _initLanguage(): void |
84
|
|
|
{ |
85
|
16 |
|
$session = new Zend_Session_Namespace(); |
86
|
|
|
|
87
|
|
|
// handle language switch |
88
|
16 |
|
if (isset($_GET['lang'])) { |
89
|
|
|
$session->locale = $_GET['lang']; |
90
|
|
|
} |
91
|
|
|
|
92
|
16 |
|
if (isset($session->locale)) { |
93
|
|
|
$locale = new Zend_Locale($session->locale); |
94
|
|
|
} else { |
95
|
16 |
|
$locale = new Zend_Locale(); // autodetect browser |
96
|
|
|
} |
97
|
16 |
|
Zend_Registry::set('Zend_Locale', $locale); |
98
|
|
|
|
99
|
16 |
|
$adapter = new Zend_Translate('gettext', APPLICATION_PATH . '/localization', $locale, ['scan' => Zend_Translate::LOCALE_FILENAME, 'disableNotices' => true]); |
100
|
16 |
|
Zend_Registry::set('Zend_Translate', $adapter); |
101
|
16 |
|
Zend_Form::setDefaultTranslator($adapter); |
102
|
16 |
|
self::$translator = $adapter; |
103
|
16 |
|
} |
104
|
|
|
|
105
|
16 |
|
protected function _initPagination(): void |
106
|
|
|
{ |
107
|
16 |
|
Zend_Paginator::setDefaultScrollingStyle('Elastic'); |
108
|
16 |
|
Zend_View_Helper_PaginationControl::setDefaultViewPartial('pagination.phtml'); |
109
|
16 |
|
} |
110
|
|
|
|
111
|
16 |
|
protected function _initRoutes(): void |
112
|
|
|
{ |
113
|
16 |
|
$front = Zend_Controller_Front::getInstance(); |
114
|
16 |
|
$router = $front->getRouter(); |
115
|
|
|
|
116
|
|
|
// Required for unit tests |
117
|
16 |
|
$router->addDefaultRoutes(); |
|
|
|
|
118
|
|
|
|
119
|
|
|
// A route for single id (typically view a single movie/user) |
120
|
16 |
|
$router->addRoute('singleid', new Zend_Controller_Router_Route(':controller/:action/:id', ['action' => 'view'])); |
|
|
|
|
121
|
|
|
|
122
|
|
|
// A route for activities |
123
|
16 |
|
$router->addRoute('activity', new Zend_Controller_Router_Route('activity/*', ['controller' => 'activity', 'action' => 'index'])); |
124
|
16 |
|
$router->addRoute('activityMovie', new Zend_Controller_Router_Route('activity/movie/:movie/*', ['controller' => 'activity', 'action' => 'index'])); |
125
|
16 |
|
$router->addRoute('activityUser', new Zend_Controller_Router_Route('activity/user/:user/*', ['controller' => 'activity', 'action' => 'index'])); |
126
|
|
|
|
127
|
|
|
// For backward compatibility with RSS readers we keep the old route |
128
|
16 |
|
$router->addRoute('activityOld', new Zend_Controller_Router_Route('activity/index/*', ['controller' => 'activity', 'action' => 'index'])); |
129
|
16 |
|
$router->addRoute('activityMovieOld', new Zend_Controller_Router_Route('activity/index/movie/:movie/*', ['controller' => 'activity', 'action' => 'index'])); |
130
|
16 |
|
$router->addRoute('activityUserOld', new Zend_Controller_Router_Route('activity/index/user/:user/*', ['controller' => 'activity', 'action' => 'index'])); |
131
|
|
|
|
132
|
|
|
// Routes to define and view statuses |
133
|
16 |
|
$router->addRoute('status', new Zend_Controller_Router_Route_Regex('status/(\d+)/(\d)', ['controller' => 'status', 'action' => 'index'], [1 => 'movie', 2 => 'rating'], 'status/%s/%s')); |
134
|
16 |
|
$router->addRoute('statusView', new Zend_Controller_Router_Route_Regex('status/(\d+)', ['controller' => 'status', 'action' => 'index'], [1 => 'movie'], 'status/%s')); |
135
|
16 |
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* Add the Zend_Db_Adapter to the registry if we need to call it outside of the modules. |
139
|
|
|
* |
140
|
|
|
* @return Zend_Db_Adapter |
141
|
|
|
*/ |
142
|
16 |
|
protected function _initMyDb() |
143
|
|
|
{ |
144
|
16 |
|
$db = $this->getPluginResource('db')->getDbAdapter(); |
|
|
|
|
145
|
16 |
|
Zend_Registry::set('db', $db); |
146
|
|
|
|
147
|
16 |
|
return $db; |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Global shortcut method that returns localized strings |
153
|
|
|
* |
154
|
|
|
* @param string $msgId the original string to translate |
155
|
|
|
* |
156
|
|
|
* @return string the translated string |
157
|
|
|
*/ |
158
|
|
|
function _tr($msgId) |
159
|
|
|
{ |
160
|
12 |
|
return Bootstrap::$translator->translate($msgId); |
161
|
|
|
} |
162
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.