Completed
Push — master ( cc1295...fbd02f )
by Aimeos
02:49
created
src/Aimeos/Shop/Controller/ExtadmController.php 2 patches
Doc Comments   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	 * Creates a list of all available translations.
162 162
 	 *
163 163
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
164
-	 * @return array List of language IDs with labels
164
+	 * @return string List of language IDs with labels
165 165
 	 */
166 166
 	protected function getJsonLanguages( \Aimeos\MShop\Context\Item\Iface $context )
167 167
 	{
@@ -237,7 +237,6 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
239 239
 	 * @param string $sitecode Unique site code
240
-	 * @param string $locale ISO language code, e.g. "en" or "en_GB"
241 240
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
242 241
 	 */
243 242
 	protected function setLocale( \Aimeos\MShop\Context\Item\Iface $context, $sitecode = 'default' )
Please login to merge, or discard this patch.
Spacing   +77 added lines, -77 removed lines patch added patch discarded remove patch
@@ -34,64 +34,64 @@  discard block
 block discarded – undo
34 34
 	 * @param \Illuminate\Http\Request $request Laravel request object
35 35
 	 * @return \Illuminate\Contracts\View\View View for rendering the output
36 36
 	 */
37
-	public function indexAction( Request $request )
37
+	public function indexAction(Request $request)
38 38
 	{
39
-		if( config( 'shop.authorize', true ) ) {
40
-			$this->authorize( 'admin', [['admin']] );
39
+		if (config('shop.authorize', true)) {
40
+			$this->authorize('admin', [['admin']]);
41 41
 		}
42 42
 
43
-		$site = Route::input( 'site', Input::get( 'site', 'default' ) );
44
-		$lang = Route::input( 'lang', Input::get( 'lang', config( 'app.locale', 'en' ) ) );
45
-		$tab = Route::input( 'tab', Input::get( 'tab', 0 ) );
43
+		$site = Route::input('site', Input::get('site', 'default'));
44
+		$lang = Route::input('lang', Input::get('lang', config('app.locale', 'en')));
45
+		$tab = Route::input('tab', Input::get('tab', 0));
46 46
 
47
-		$aimeos = app( '\Aimeos\Shop\Base\Aimeos' );
47
+		$aimeos = app('\Aimeos\Shop\Base\Aimeos');
48 48
 
49 49
 		$bootstrap = $aimeos->get();
50
-		$cntlPaths = $bootstrap->getCustomPaths( 'controller/extjs' );
50
+		$cntlPaths = $bootstrap->getCustomPaths('controller/extjs');
51 51
 
52
-		$context = app( '\Aimeos\Shop\Base\Context' )->get( false );
53
-		$context = $this->setLocale( $context, $site );
52
+		$context = app('\Aimeos\Shop\Base\Context')->get(false);
53
+		$context = $this->setLocale($context, $site);
54 54
 
55
-		$controller = new \Aimeos\Controller\ExtJS\JsonRpc( $context, $cntlPaths );
55
+		$controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths);
56 56
 		$cssFiles = array();
57 57
 
58
-		foreach( $bootstrap->getCustomPaths( 'admin/extjs' ) as $base => $paths )
58
+		foreach ($bootstrap->getCustomPaths('admin/extjs') as $base => $paths)
59 59
 		{
60
-			foreach( $paths as $path )
60
+			foreach ($paths as $path)
61 61
 			{
62
-				$jsbAbsPath = $base . '/' . $path;
62
+				$jsbAbsPath = $base.'/'.$path;
63 63
 
64
-				if( !is_file( $jsbAbsPath ) ) {
65
-					throw new \Exception( sprintf( 'JSB2 file "%1$s" not found', $jsbAbsPath ) );
64
+				if (!is_file($jsbAbsPath)) {
65
+					throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath));
66 66
 				}
67 67
 
68
-				$jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $path ) );
69
-				$cssFiles = array_merge( $cssFiles, $jsb2->getUrls( 'css' ) );
68
+				$jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path));
69
+				$cssFiles = array_merge($cssFiles, $jsb2->getUrls('css'));
70 70
 			}
71 71
 		}
72 72
 
73
-		$jqadmUrl = route( 'aimeos_shop_jqadm_search', array( 'site' => $site, 'resource' => 'product' ) );
74
-		$jsonUrl = route( 'aimeos_shop_extadm_json', array( 'site' => $site, '_token' => csrf_token() ) );
75
-		$adminUrl = route( 'aimeos_shop_extadm', array( 'site' => '<site>', 'lang' => '<lang>', 'tab' => '<tab>' ) );
73
+		$jqadmUrl = route('aimeos_shop_jqadm_search', array('site' => $site, 'resource' => 'product'));
74
+		$jsonUrl = route('aimeos_shop_extadm_json', array('site' => $site, '_token' => csrf_token()));
75
+		$adminUrl = route('aimeos_shop_extadm', array('site' => '<site>', 'lang' => '<lang>', 'tab' => '<tab>'));
76 76
 
77 77
 		$vars = array(
78 78
 			'lang' => $lang,
79 79
 			'cssFiles' => $cssFiles,
80
-			'languages' => $this->getJsonLanguages( $context),
81
-			'config' => $this->getJsonClientConfig( $context ),
82
-			'site' => $this->getJsonSiteItem( $context, $site ),
83
-			'i18nContent' => $this->getJsonClientI18n( $bootstrap->getI18nPaths(), $lang ),
80
+			'languages' => $this->getJsonLanguages($context),
81
+			'config' => $this->getJsonClientConfig($context),
82
+			'site' => $this->getJsonSiteItem($context, $site),
83
+			'i18nContent' => $this->getJsonClientI18n($bootstrap->getI18nPaths(), $lang),
84 84
 			'searchSchemas' => $controller->getJsonSearchSchemas(),
85 85
 			'itemSchemas' => $controller->getJsonItemSchemas(),
86
-			'smd' => $controller->getJsonSmd( $jsonUrl ),
87
-			'urlTemplate' => str_replace( ['<', '>'], ['{', '}'], urldecode( $adminUrl ) ),
88
-			'uploaddir' => config( 'shop::uploaddir' ),
86
+			'smd' => $controller->getJsonSmd($jsonUrl),
87
+			'urlTemplate' => str_replace(['<', '>'], ['{', '}'], urldecode($adminUrl)),
88
+			'uploaddir' => config('shop::uploaddir'),
89 89
 			'version' => $aimeos->getVersion(),
90 90
 			'jqadmurl' => $jqadmUrl,
91 91
 			'activeTab' => $tab,
92 92
 		);
93 93
 
94
-		return View::make( 'shop::extadm.index', $vars );
94
+		return View::make('shop::extadm.index', $vars);
95 95
 	}
96 96
 
97 97
 
@@ -101,23 +101,23 @@  discard block
 block discarded – undo
101 101
 	 * @param \Illuminate\Http\Request $request Laravel request object
102 102
 	 * @return \Illuminate\Contracts\View\View View for rendering the output
103 103
 	 */
104
-	public function doAction( Request $request )
104
+	public function doAction(Request $request)
105 105
 	{
106
-		if( config( 'shop.authorize', true ) ) {
107
-			$this->authorize( 'admin', [['admin']] );
106
+		if (config('shop.authorize', true)) {
107
+			$this->authorize('admin', [['admin']]);
108 108
 		}
109 109
 
110
-		$aimeos = app( '\Aimeos\Shop\Base\Aimeos' )->get();
111
-		$cntlPaths = $aimeos->getCustomPaths( 'controller/extjs' );
110
+		$aimeos = app('\Aimeos\Shop\Base\Aimeos')->get();
111
+		$cntlPaths = $aimeos->getCustomPaths('controller/extjs');
112 112
 
113
-		$context = app( '\Aimeos\Shop\Base\Context' )->get( false );
114
-		$context->setView( app( '\Aimeos\Shop\Base\View' )->create( $context->getConfig(), array() ) );
115
-		$context = $this->setLocale( $context );
113
+		$context = app('\Aimeos\Shop\Base\Context')->get(false);
114
+		$context->setView(app('\Aimeos\Shop\Base\View')->create($context->getConfig(), array()));
115
+		$context = $this->setLocale($context);
116 116
 
117
-		$controller = new \Aimeos\Controller\ExtJS\JsonRpc( $context, $cntlPaths );
117
+		$controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths);
118 118
 
119
-		$response = $controller->process( Input::instance()->request->all(), $request->getContent() );
120
-		return View::make( 'shop::extadm.do', array( 'output' => $response ) );
119
+		$response = $controller->process(Input::instance()->request->all(), $request->getContent());
120
+		return View::make('shop::extadm.do', array('output' => $response));
121 121
 	}
122 122
 
123 123
 
@@ -128,32 +128,32 @@  discard block
 block discarded – undo
128 128
 	 */
129 129
 	public function fileAction()
130 130
 	{
131
-		if( config( 'shop.authorize', true ) ) {
132
-			$this->authorize( 'admin', [['admin']] );
131
+		if (config('shop.authorize', true)) {
132
+			$this->authorize('admin', [['admin']]);
133 133
 		}
134 134
 
135 135
 		$contents = '';
136 136
 		$jsFiles = array();
137
-		$aimeos = app( '\Aimeos\Shop\Base\Aimeos' )->get();
137
+		$aimeos = app('\Aimeos\Shop\Base\Aimeos')->get();
138 138
 
139
-		foreach( $aimeos->getCustomPaths( 'admin/extjs' ) as $base => $paths )
139
+		foreach ($aimeos->getCustomPaths('admin/extjs') as $base => $paths)
140 140
 		{
141
-			foreach( $paths as $path )
141
+			foreach ($paths as $path)
142 142
 			{
143
-				$jsbAbsPath = $base . '/' . $path;
144
-				$jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $jsbAbsPath ) );
145
-				$jsFiles = array_merge( $jsFiles, $jsb2->getFiles( 'js' ) );
143
+				$jsbAbsPath = $base.'/'.$path;
144
+				$jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath));
145
+				$jsFiles = array_merge($jsFiles, $jsb2->getFiles('js'));
146 146
 			}
147 147
 		}
148 148
 
149
-		foreach( $jsFiles as $file )
149
+		foreach ($jsFiles as $file)
150 150
 		{
151
-			if( ( $content = file_get_contents( $file ) ) !== false ) {
151
+			if (($content = file_get_contents($file)) !== false) {
152 152
 				$contents .= $content;
153 153
 			}
154 154
 		}
155 155
 
156
-		return response( $contents )->header( 'Content-Type', 'application/javascript' );
156
+		return response($contents)->header('Content-Type', 'application/javascript');
157 157
 	}
158 158
 
159 159
 
@@ -163,15 +163,15 @@  discard block
 block discarded – undo
163 163
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
164 164
 	 * @return array List of language IDs with labels
165 165
 	 */
166
-	protected function getJsonLanguages( \Aimeos\MShop\Context\Item\Iface $context )
166
+	protected function getJsonLanguages(\Aimeos\MShop\Context\Item\Iface $context)
167 167
 	{
168 168
 		$result = array();
169 169
 
170
-		foreach( app( '\Aimeos\Shop\Base\Aimeos' )->get()->getI18nList( 'admin' ) as $id ) {
171
-			$result[] = array( 'id' => $id, 'label' => $id );
170
+		foreach (app('\Aimeos\Shop\Base\Aimeos')->get()->getI18nList('admin') as $id) {
171
+			$result[] = array('id' => $id, 'label' => $id);
172 172
 		}
173 173
 
174
-		return json_encode( $result );
174
+		return json_encode($result);
175 175
 	}
176 176
 
177 177
 
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item object
182 182
 	 * @return string JSON encoded configuration object
183 183
 	 */
184
-	protected function getJsonClientConfig( \Aimeos\MShop\Context\Item\Iface $context )
184
+	protected function getJsonClientConfig(\Aimeos\MShop\Context\Item\Iface $context)
185 185
 	{
186
-		$config = $context->getConfig()->get( 'admin/extjs', array() );
187
-		return json_encode( array( 'admin' => array( 'extjs' => $config ) ), JSON_FORCE_OBJECT );
186
+		$config = $context->getConfig()->get('admin/extjs', array());
187
+		return json_encode(array('admin' => array('extjs' => $config)), JSON_FORCE_OBJECT);
188 188
 	}
189 189
 
190 190
 
@@ -195,16 +195,16 @@  discard block
 block discarded – undo
195 195
 	 * @param string $lang ISO language code like "en" or "en_GB"
196 196
 	 * @return string JSON encoded translation object
197 197
 	 */
198
-	protected function getJsonClientI18n( array $i18nPaths, $lang )
198
+	protected function getJsonClientI18n(array $i18nPaths, $lang)
199 199
 	{
200
-		$i18n = new \Aimeos\MW\Translation\Gettext( $i18nPaths, $lang );
200
+		$i18n = new \Aimeos\MW\Translation\Gettext($i18nPaths, $lang);
201 201
 
202 202
 		$content = array(
203
-			'admin' => $i18n->getAll( 'admin' ),
204
-			'admin/ext' => $i18n->getAll( 'admin/ext' ),
203
+			'admin' => $i18n->getAll('admin'),
204
+			'admin/ext' => $i18n->getAll('admin/ext'),
205 205
 		);
206 206
 
207
-		return json_encode( $content, JSON_FORCE_OBJECT );
207
+		return json_encode($content, JSON_FORCE_OBJECT);
208 208
 	}
209 209
 
210 210
 
@@ -216,19 +216,19 @@  discard block
 block discarded – undo
216 216
 	 * @return string JSON encoded site item object
217 217
 	 * @throws Exception If no site item was found for the code
218 218
 	 */
219
-	protected function getJsonSiteItem( \Aimeos\MShop\Context\Item\Iface $context, $site )
219
+	protected function getJsonSiteItem(\Aimeos\MShop\Context\Item\Iface $context, $site)
220 220
 	{
221
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'locale/site' );
221
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'locale/site');
222 222
 
223 223
 		$criteria = $manager->createSearch();
224
-		$criteria->setConditions( $criteria->compare( '==', 'locale.site.code', $site ) );
225
-		$items = $manager->searchItems( $criteria );
224
+		$criteria->setConditions($criteria->compare('==', 'locale.site.code', $site));
225
+		$items = $manager->searchItems($criteria);
226 226
 
227
-		if( ( $item = reset( $items ) ) === false ) {
228
-			throw new \Exception( sprintf( 'No site found for code "%1$s"', $site ) );
227
+		if (($item = reset($items)) === false) {
228
+			throw new \Exception(sprintf('No site found for code "%1$s"', $site));
229 229
 		}
230 230
 
231
-		return json_encode( $item->toArray() );
231
+		return json_encode($item->toArray());
232 232
 	}
233 233
 
234 234
 
@@ -240,22 +240,22 @@  discard block
 block discarded – undo
240 240
 	 * @param string $locale ISO language code, e.g. "en" or "en_GB"
241 241
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
242 242
 	 */
243
-	protected function setLocale( \Aimeos\MShop\Context\Item\Iface $context, $sitecode = 'default' )
243
+	protected function setLocale(\Aimeos\MShop\Context\Item\Iface $context, $sitecode = 'default')
244 244
 	{
245
-		$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
245
+		$localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale');
246 246
 
247 247
 		try
248 248
 		{
249
-			$localeItem = $localeManager->bootstrap( $sitecode, '', '', false );
250
-			$localeItem->setLanguageId( null );
251
-			$localeItem->setCurrencyId( null );
249
+			$localeItem = $localeManager->bootstrap($sitecode, '', '', false);
250
+			$localeItem->setLanguageId(null);
251
+			$localeItem->setCurrencyId(null);
252 252
 		}
253
-		catch( \Aimeos\MShop\Locale\Exception $e )
253
+		catch (\Aimeos\MShop\Locale\Exception $e)
254 254
 		{
255 255
 			$localeItem = $localeManager->createItem();
256 256
 		}
257 257
 
258
-		$context->setLocale( $localeItem );
258
+		$context->setLocale($localeItem);
259 259
 
260 260
 		return $context;
261 261
 	}
Please login to merge, or discard this patch.