@@ -32,54 +32,54 @@ discard block |
||
32 | 32 | */ |
33 | 33 | public function indexAction() |
34 | 34 | { |
35 | - if( config( 'shop.authorize', true ) ) { |
|
36 | - $this->authorize( 'admin' ); |
|
35 | + if (config('shop.authorize', true)) { |
|
36 | + $this->authorize('admin'); |
|
37 | 37 | } |
38 | 38 | |
39 | - $site = \Input::get( 'site', 'default' ); |
|
40 | - $lang = \Input::get( 'lang', config( 'app.locale', 'en' ) ); |
|
39 | + $site = \Input::get('site', 'default'); |
|
40 | + $lang = \Input::get('lang', config('app.locale', 'en')); |
|
41 | 41 | |
42 | - $aimeos = app( '\Aimeos\Shop\Base\Aimeos' )->get(); |
|
43 | - $cntlPaths = $aimeos->getCustomPaths( 'controller/extjs' ); |
|
42 | + $aimeos = app('\Aimeos\Shop\Base\Aimeos')->get(); |
|
43 | + $cntlPaths = $aimeos->getCustomPaths('controller/extjs'); |
|
44 | 44 | |
45 | - $context = app( '\Aimeos\Shop\Base\Context' )->get( false ); |
|
46 | - $context = $this->setLocale( $context, $site, $lang ); |
|
45 | + $context = app('\Aimeos\Shop\Base\Context')->get(false); |
|
46 | + $context = $this->setLocale($context, $site, $lang); |
|
47 | 47 | |
48 | - $controller = new \Aimeos\Controller\ExtJS\JsonRpc( $context, $cntlPaths ); |
|
48 | + $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths); |
|
49 | 49 | $cssFiles = array(); |
50 | 50 | |
51 | - foreach( $aimeos->getCustomPaths( 'client/extjs' ) as $base => $paths ) |
|
51 | + foreach ($aimeos->getCustomPaths('client/extjs') as $base => $paths) |
|
52 | 52 | { |
53 | - foreach( $paths as $path ) |
|
53 | + foreach ($paths as $path) |
|
54 | 54 | { |
55 | 55 | $jsbAbsPath = $base . '/' . $path; |
56 | 56 | |
57 | - if( !is_file( $jsbAbsPath ) ) { |
|
58 | - throw new \Exception( sprintf( 'JSB2 file "%1$s" not found', $jsbAbsPath ) ); |
|
57 | + if (!is_file($jsbAbsPath)) { |
|
58 | + throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath)); |
|
59 | 59 | } |
60 | 60 | |
61 | - $jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $path ) ); |
|
62 | - $cssFiles = array_merge( $cssFiles, $jsb2->getUrls( 'css' ) ); |
|
61 | + $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path)); |
|
62 | + $cssFiles = array_merge($cssFiles, $jsb2->getUrls('css')); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
66 | - $params = array( 'site' => '{site}', 'lang' => '{lang}', 'tab' => '{tab}' ); |
|
67 | - $adminUrl = route( 'aimeos_shop_admin', $params ); |
|
68 | - $jsonUrl = route( 'aimeos_shop_admin_json', array( '_token' => csrf_token() ) ); |
|
66 | + $params = array('site' => '{site}', 'lang' => '{lang}', 'tab' => '{tab}'); |
|
67 | + $adminUrl = route('aimeos_shop_admin', $params); |
|
68 | + $jsonUrl = route('aimeos_shop_admin_json', array('_token' => csrf_token())); |
|
69 | 69 | |
70 | 70 | $vars = array( |
71 | 71 | 'lang' => $lang, |
72 | 72 | 'cssFiles' => $cssFiles, |
73 | - 'languages' => $this->getJsonLanguages( $context), |
|
74 | - 'config' => $this->getJsonClientConfig( $context ), |
|
75 | - 'site' => $this->getJsonSiteItem( $context, \Input::get( 'site', 'default' ) ), |
|
76 | - 'i18nContent' => $this->getJsonClientI18n( $aimeos->getI18nPaths(), $lang ), |
|
73 | + 'languages' => $this->getJsonLanguages($context), |
|
74 | + 'config' => $this->getJsonClientConfig($context), |
|
75 | + 'site' => $this->getJsonSiteItem($context, \Input::get('site', 'default')), |
|
76 | + 'i18nContent' => $this->getJsonClientI18n($aimeos->getI18nPaths(), $lang), |
|
77 | 77 | 'searchSchemas' => $controller->getJsonSearchSchemas(), |
78 | 78 | 'itemSchemas' => $controller->getJsonItemSchemas(), |
79 | - 'smd' => $controller->getJsonSmd( $jsonUrl ), |
|
80 | - 'urlTemplate' => urldecode( $adminUrl ), |
|
81 | - 'uploaddir' => \Config::get( 'shop::uploaddir' ), |
|
82 | - 'activeTab' => \Input::get( 'tab', 0 ), |
|
79 | + 'smd' => $controller->getJsonSmd($jsonUrl), |
|
80 | + 'urlTemplate' => urldecode($adminUrl), |
|
81 | + 'uploaddir' => \Config::get('shop::uploaddir'), |
|
82 | + 'activeTab' => \Input::get('tab', 0), |
|
83 | 83 | 'version' => $this->getVersion(), |
84 | 84 | ); |
85 | 85 | |
@@ -94,20 +94,20 @@ discard block |
||
94 | 94 | */ |
95 | 95 | public function doAction() |
96 | 96 | { |
97 | - if( config( 'shop.authorize', true ) ) { |
|
98 | - $this->authorize( 'admin' ); |
|
97 | + if (config('shop.authorize', true)) { |
|
98 | + $this->authorize('admin'); |
|
99 | 99 | } |
100 | 100 | |
101 | - $aimeos = app( '\Aimeos\Shop\Base\Aimeos' )->get(); |
|
102 | - $cntlPaths = $aimeos->getCustomPaths( 'controller/extjs' ); |
|
101 | + $aimeos = app('\Aimeos\Shop\Base\Aimeos')->get(); |
|
102 | + $cntlPaths = $aimeos->getCustomPaths('controller/extjs'); |
|
103 | 103 | |
104 | - $context = app( '\Aimeos\Shop\Base\Context' )->get( false ); |
|
105 | - $context = $this->setLocale( $context ); |
|
104 | + $context = app('\Aimeos\Shop\Base\Context')->get(false); |
|
105 | + $context = $this->setLocale($context); |
|
106 | 106 | |
107 | - $controller = new \Aimeos\Controller\ExtJS\JsonRpc( $context, $cntlPaths ); |
|
107 | + $controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths); |
|
108 | 108 | |
109 | - $response = $controller->process( \Input::instance()->request->all(), 'php://input' ); |
|
110 | - return \View::make('shop::admin.do', array( 'output' => $response )); |
|
109 | + $response = $controller->process(\Input::instance()->request->all(), 'php://input'); |
|
110 | + return \View::make('shop::admin.do', array('output' => $response)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | |
@@ -118,32 +118,32 @@ discard block |
||
118 | 118 | */ |
119 | 119 | public function fileAction() |
120 | 120 | { |
121 | - if( config( 'shop.authorize', true ) ) { |
|
122 | - $this->authorize( 'admin' ); |
|
121 | + if (config('shop.authorize', true)) { |
|
122 | + $this->authorize('admin'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | $contents = ''; |
126 | 126 | $jsFiles = array(); |
127 | - $aimeos = app( '\Aimeos\Shop\Base\Aimeos' )->get(); |
|
127 | + $aimeos = app('\Aimeos\Shop\Base\Aimeos')->get(); |
|
128 | 128 | |
129 | - foreach( $aimeos->getCustomPaths( 'client/extjs' ) as $base => $paths ) |
|
129 | + foreach ($aimeos->getCustomPaths('client/extjs') as $base => $paths) |
|
130 | 130 | { |
131 | - foreach( $paths as $path ) |
|
131 | + foreach ($paths as $path) |
|
132 | 132 | { |
133 | 133 | $jsbAbsPath = $base . '/' . $path; |
134 | - $jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $jsbAbsPath ) ); |
|
135 | - $jsFiles = array_merge( $jsFiles, $jsb2->getUrls( 'js', '' ) ); |
|
134 | + $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath)); |
|
135 | + $jsFiles = array_merge($jsFiles, $jsb2->getUrls('js', '')); |
|
136 | 136 | } |
137 | 137 | } |
138 | 138 | |
139 | - foreach( $jsFiles as $file ) |
|
139 | + foreach ($jsFiles as $file) |
|
140 | 140 | { |
141 | - if( ( $content = file_get_contents( $file ) ) !== false ) { |
|
141 | + if (($content = file_get_contents($file)) !== false) { |
|
142 | 142 | $contents .= $content; |
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
146 | - return response( $contents )->header( 'Content-Type', 'application/javascript' ); |
|
146 | + return response($contents)->header('Content-Type', 'application/javascript'); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | |
@@ -153,30 +153,30 @@ discard block |
||
153 | 153 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
154 | 154 | * @return array List of language IDs with labels |
155 | 155 | */ |
156 | - protected function getJsonLanguages( \Aimeos\MShop\Context\Item\Iface $context ) |
|
156 | + protected function getJsonLanguages(\Aimeos\MShop\Context\Item\Iface $context) |
|
157 | 157 | { |
158 | - $paths = app( '\Aimeos\Shop\Base\Aimeos' )->get()->getI18nPaths(); |
|
158 | + $paths = app('\Aimeos\Shop\Base\Aimeos')->get()->getI18nPaths(); |
|
159 | 159 | $langs = array(); |
160 | 160 | |
161 | - if( !isset( $paths['client/extjs'] ) ) { |
|
162 | - return json_encode( array() ); |
|
161 | + if (!isset($paths['client/extjs'])) { |
|
162 | + return json_encode(array()); |
|
163 | 163 | } |
164 | 164 | |
165 | - foreach( $paths['client/extjs'] as $path ) |
|
165 | + foreach ($paths['client/extjs'] as $path) |
|
166 | 166 | { |
167 | - $iter = new \DirectoryIterator( $path ); |
|
167 | + $iter = new \DirectoryIterator($path); |
|
168 | 168 | |
169 | - foreach( $iter as $file ) |
|
169 | + foreach ($iter as $file) |
|
170 | 170 | { |
171 | 171 | $name = $file->getFilename(); |
172 | 172 | |
173 | - if( preg_match('/^[a-z]{2,3}(_[A-Z]{2})?$/', $name ) ) { |
|
173 | + if (preg_match('/^[a-z]{2,3}(_[A-Z]{2})?$/', $name)) { |
|
174 | 174 | $langs[$name] = null; |
175 | 175 | } |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - return json_encode( $this->getLanguages( $context, array_keys( $langs ) ) ); |
|
179 | + return json_encode($this->getLanguages($context, array_keys($langs))); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | |
@@ -186,10 +186,10 @@ discard block |
||
186 | 186 | * @param \Aimeos\MShop\Context\Item\Iface $context Context item object |
187 | 187 | * @return string JSON encoded configuration object |
188 | 188 | */ |
189 | - protected function getJsonClientConfig( \Aimeos\MShop\Context\Item\Iface $context ) |
|
189 | + protected function getJsonClientConfig(\Aimeos\MShop\Context\Item\Iface $context) |
|
190 | 190 | { |
191 | - $config = $context->getConfig()->get( 'client/extjs', array() ); |
|
192 | - return json_encode( array( 'client' => array( 'extjs' => $config ) ), JSON_FORCE_OBJECT ); |
|
191 | + $config = $context->getConfig()->get('client/extjs', array()); |
|
192 | + return json_encode(array('client' => array('extjs' => $config)), JSON_FORCE_OBJECT); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -200,16 +200,16 @@ discard block |
||
200 | 200 | * @param string $lang ISO language code like "en" or "en_GB" |
201 | 201 | * @return string JSON encoded translation object |
202 | 202 | */ |
203 | - protected function getJsonClientI18n( array $i18nPaths, $lang ) |
|
203 | + protected function getJsonClientI18n(array $i18nPaths, $lang) |
|
204 | 204 | { |
205 | - $i18n = new \Aimeos\MW\Translation\Zend2( $i18nPaths, 'gettext', $lang, array( 'disableNotices' => true ) ); |
|
205 | + $i18n = new \Aimeos\MW\Translation\Zend2($i18nPaths, 'gettext', $lang, array('disableNotices' => true)); |
|
206 | 206 | |
207 | 207 | $content = array( |
208 | - 'client/extjs' => $i18n->getAll( 'client/extjs' ), |
|
209 | - 'client/extjs/ext' => $i18n->getAll( 'client/extjs/ext' ), |
|
208 | + 'client/extjs' => $i18n->getAll('client/extjs'), |
|
209 | + 'client/extjs/ext' => $i18n->getAll('client/extjs/ext'), |
|
210 | 210 | ); |
211 | 211 | |
212 | - return json_encode( $content, JSON_FORCE_OBJECT ); |
|
212 | + return json_encode($content, JSON_FORCE_OBJECT); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -221,19 +221,19 @@ discard block |
||
221 | 221 | * @return string JSON encoded site item object |
222 | 222 | * @throws Exception If no site item was found for the code |
223 | 223 | */ |
224 | - protected function getJsonSiteItem( \Aimeos\MShop\Context\Item\Iface $context, $site ) |
|
224 | + protected function getJsonSiteItem(\Aimeos\MShop\Context\Item\Iface $context, $site) |
|
225 | 225 | { |
226 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'locale/site' ); |
|
226 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'locale/site'); |
|
227 | 227 | |
228 | 228 | $criteria = $manager->createSearch(); |
229 | - $criteria->setConditions( $criteria->compare( '==', 'locale.site.code', $site ) ); |
|
230 | - $items = $manager->searchItems( $criteria ); |
|
229 | + $criteria->setConditions($criteria->compare('==', 'locale.site.code', $site)); |
|
230 | + $items = $manager->searchItems($criteria); |
|
231 | 231 | |
232 | - if( ( $item = reset( $items ) ) === false ) { |
|
233 | - throw new \Exception( sprintf( 'No site found for code "%1$s"', $site ) ); |
|
232 | + if (($item = reset($items)) === false) { |
|
233 | + throw new \Exception(sprintf('No site found for code "%1$s"', $site)); |
|
234 | 234 | } |
235 | 235 | |
236 | - return json_encode( $item->toArray() ); |
|
236 | + return json_encode($item->toArray()); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -244,18 +244,18 @@ discard block |
||
244 | 244 | * @param array $langIds List of language IDs |
245 | 245 | * @return array List of associative lists with "id" and "label" as keys |
246 | 246 | */ |
247 | - protected function getLanguages( \Aimeos\MShop\Context\Item\Iface $context, array $langIds ) |
|
247 | + protected function getLanguages(\Aimeos\MShop\Context\Item\Iface $context, array $langIds) |
|
248 | 248 | { |
249 | - $languageManager = \Aimeos\MShop\Factory::createManager( $context, 'locale/language' ); |
|
249 | + $languageManager = \Aimeos\MShop\Factory::createManager($context, 'locale/language'); |
|
250 | 250 | $result = array(); |
251 | 251 | |
252 | 252 | $search = $languageManager->createSearch(); |
253 | - $search->setConditions( $search->compare('==', 'locale.language.id', $langIds ) ); |
|
254 | - $search->setSortations( array( $search->sort( '-', 'locale.language.status' ), $search->sort( '+', 'locale.language.label' ) ) ); |
|
255 | - $langItems = $languageManager->searchItems( $search ); |
|
253 | + $search->setConditions($search->compare('==', 'locale.language.id', $langIds)); |
|
254 | + $search->setSortations(array($search->sort('-', 'locale.language.status'), $search->sort('+', 'locale.language.label'))); |
|
255 | + $langItems = $languageManager->searchItems($search); |
|
256 | 256 | |
257 | - foreach( $langItems as $id => $item ) { |
|
258 | - $result[] = array( 'id' => $id, 'label' => $item->getLabel() ); |
|
257 | + foreach ($langItems as $id => $item) { |
|
258 | + $result[] = array('id' => $id, 'label' => $item->getLabel()); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return $result; |
@@ -269,12 +269,12 @@ discard block |
||
269 | 269 | */ |
270 | 270 | protected function getVersion() |
271 | 271 | { |
272 | - if( ( $content = @file_get_contents( base_path( 'composer.lock' ) ) ) !== false |
|
273 | - && ( $content = json_decode( $content, true ) ) !== null && isset( $content['packages'] ) |
|
272 | + if (($content = @file_get_contents(base_path('composer.lock'))) !== false |
|
273 | + && ($content = json_decode($content, true)) !== null && isset($content['packages']) |
|
274 | 274 | ) { |
275 | - foreach( (array) $content['packages'] as $item ) |
|
275 | + foreach ((array) $content['packages'] as $item) |
|
276 | 276 | { |
277 | - if( $item['name'] === 'aimeos/aimeos-laravel' ) { |
|
277 | + if ($item['name'] === 'aimeos/aimeos-laravel') { |
|
278 | 278 | return $item['version']; |
279 | 279 | } |
280 | 280 | } |
@@ -292,17 +292,17 @@ discard block |
||
292 | 292 | * @param string $locale ISO language code, e.g. "en" or "en_GB" |
293 | 293 | * @return \Aimeos\MShop\Context\Item\Iface Modified context object |
294 | 294 | */ |
295 | - protected function setLocale( \Aimeos\MShop\Context\Item\Iface $context, $sitecode = 'default', $locale = null ) |
|
295 | + protected function setLocale(\Aimeos\MShop\Context\Item\Iface $context, $sitecode = 'default', $locale = null) |
|
296 | 296 | { |
297 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
297 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
298 | 298 | |
299 | 299 | try { |
300 | - $localeItem = $localeManager->bootstrap( $sitecode, $locale, '', false ); |
|
301 | - } catch( \Aimeos\MShop\Locale\Exception $e ) { |
|
300 | + $localeItem = $localeManager->bootstrap($sitecode, $locale, '', false); |
|
301 | + } catch (\Aimeos\MShop\Locale\Exception $e) { |
|
302 | 302 | $localeItem = $localeManager->createItem(); |
303 | 303 | } |
304 | 304 | |
305 | - $context->setLocale( $localeItem ); |
|
305 | + $context->setLocale($localeItem); |
|
306 | 306 | |
307 | 307 | return $context; |
308 | 308 | } |