1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2016 |
6
|
|
|
* @package laravel |
7
|
|
|
* @subpackage Controller |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Shop\Controller; |
12
|
|
|
|
13
|
|
|
use Aimeos\Shop\Facades\Shop; |
14
|
|
|
use Illuminate\Routing\Controller; |
15
|
|
|
use Illuminate\Support\Facades\Response; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Aimeos controller for catalog related functionality. |
20
|
|
|
* |
21
|
|
|
* @package laravel |
22
|
|
|
* @subpackage Controller |
23
|
|
|
*/ |
24
|
|
|
class CatalogController extends Controller |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Returns the view for the XHR response with the counts for the facetted search. |
28
|
|
|
* |
29
|
|
|
* @return \Illuminate\Http\Response Response object with output and headers |
30
|
|
|
*/ |
31
|
|
|
public function countAction() |
32
|
|
|
{ |
33
|
|
|
$params = ['page' => 'page-catalog-count']; |
34
|
|
|
|
35
|
|
|
foreach( app( 'config' )->get( 'shop.page.catalog-count' ) as $name ) |
36
|
|
|
{ |
37
|
|
|
$params['aiheader'][$name] = Shop::get( $name )->header(); |
|
|
|
|
38
|
|
|
$params['aibody'][$name] = Shop::get( $name )->body(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
return Response::view( Shop::template( 'catalog.count' ), $params ) |
|
|
|
|
42
|
|
|
->header( 'Content-Type', 'application/javascript' ) |
43
|
|
|
->header( 'Cache-Control', 'public, max-age=300' ); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Returns the html for the catalog detail page. |
49
|
|
|
* |
50
|
|
|
* @return \Illuminate\Http\Response Response object with output and headers |
51
|
|
|
*/ |
52
|
|
|
public function detailAction() |
53
|
|
|
{ |
54
|
|
|
$params = ['page' => 'page-catalog-detail']; |
55
|
|
|
|
56
|
|
|
foreach( app( 'config' )->get( 'shop.page.catalog-detail' ) as $name ) |
57
|
|
|
{ |
58
|
|
|
try { |
59
|
|
|
$params['aiheader'][$name] = Shop::get( $name )->header(); |
|
|
|
|
60
|
|
|
$params['aibody'][$name] = Shop::get( $name )->body(); |
61
|
|
|
} catch( \Exception $e ) { |
62
|
|
|
if( $e->getCode() === 404 ) { abort( 404 ); } |
63
|
|
|
throw $e; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
return Response::view( Shop::template( 'catalog.detail' ), $params ) |
68
|
|
|
->header( 'Cache-Control', 'private, max-age=10' ); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Returns the html for the catalog home page. |
74
|
|
|
* |
75
|
|
|
* @return \Illuminate\Http\Response Response object with output and headers |
76
|
|
|
*/ |
77
|
|
|
public function homeAction() |
78
|
|
|
{ |
79
|
|
|
$params = ['page' => 'page-catalog-home']; |
80
|
|
|
|
81
|
|
|
foreach( app( 'config' )->get( 'shop.page.catalog-home' ) as $name ) |
82
|
|
|
{ |
83
|
|
|
$params['aiheader'][$name] = Shop::get( $name )->header(); |
|
|
|
|
84
|
|
|
$params['aibody'][$name] = Shop::get( $name )->body(); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
return Response::view( Shop::template( 'catalog.home' ), $params ) |
88
|
|
|
->header( 'Cache-Control', 'private, max-age=10' ); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Returns the html for the catalog list page. |
94
|
|
|
* |
95
|
|
|
* @return \Illuminate\Http\Response Response object with output and headers |
96
|
|
|
*/ |
97
|
|
|
public function listAction() |
98
|
|
|
{ |
99
|
|
|
$params = ['page' => 'page-catalog-list']; |
100
|
|
|
|
101
|
|
|
foreach( app( 'config' )->get( 'shop.page.catalog-list' ) as $name ) |
102
|
|
|
{ |
103
|
|
|
$params['aiheader'][$name] = Shop::get( $name )->header(); |
|
|
|
|
104
|
|
|
$params['aibody'][$name] = Shop::get( $name )->body(); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
return Response::view( Shop::template( 'catalog.list' ), $params ) |
108
|
|
|
->header( 'Cache-Control', 'private, max-age=10' ); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Returns the html for the catalog session page. |
114
|
|
|
* |
115
|
|
|
* @return \Illuminate\Http\Response Response object with output and headers |
116
|
|
|
*/ |
117
|
|
|
public function sessionAction() |
118
|
|
|
{ |
119
|
|
|
$params = ['page' => 'page-catalog-session']; |
120
|
|
|
|
121
|
|
|
foreach( app( 'config' )->get( 'shop.page.catalog-session' ) as $name ) |
122
|
|
|
{ |
123
|
|
|
$params['aiheader'][$name] = Shop::get( $name )->header(); |
|
|
|
|
124
|
|
|
$params['aibody'][$name] = Shop::get( $name )->body(); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
return Response::view( Shop::template( 'catalog.session' ), $params ) |
128
|
|
|
->header( 'Cache-Control', 'no-cache' ); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Returns the html body part for the catalog stock page. |
134
|
|
|
* |
135
|
|
|
* @return \Illuminate\Http\Response Response object with output and headers |
136
|
|
|
*/ |
137
|
|
|
public function stockAction() |
138
|
|
|
{ |
139
|
|
|
$params = ['page' => 'page-catalog-stock']; |
140
|
|
|
|
141
|
|
|
foreach( app( 'config' )->get( 'shop.page.catalog-stock' ) as $name ) |
142
|
|
|
{ |
143
|
|
|
$params['aiheader'][$name] = Shop::get( $name )->header(); |
|
|
|
|
144
|
|
|
$params['aibody'][$name] = Shop::get( $name )->body(); |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
return Response::view( Shop::template( 'catalog.stock' ), $params ) |
148
|
|
|
->header( 'Content-Type', 'application/javascript' ) |
149
|
|
|
->header( 'Cache-Control', 'public, max-age=30' ); |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Returns the view for the XHR response with the product information for the search suggestion. |
155
|
|
|
* |
156
|
|
|
* @return \Illuminate\Http\Response Response object with output and headers |
157
|
|
|
*/ |
158
|
|
|
public function suggestAction() |
159
|
|
|
{ |
160
|
|
|
$params = ['page' => 'page-catalog-suggest']; |
161
|
|
|
|
162
|
|
|
foreach( app( 'config' )->get( 'shop.page.catalog-suggest' ) as $name ) |
163
|
|
|
{ |
164
|
|
|
$params['aiheader'][$name] = Shop::get( $name )->header(); |
|
|
|
|
165
|
|
|
$params['aibody'][$name] = Shop::get( $name )->body(); |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
return Response::view( Shop::template( 'catalog.suggest' ), $params ) |
169
|
|
|
->header( 'Cache-Control', 'private, max-age=300' ) |
170
|
|
|
->header( 'Content-Type', 'application/json' ); |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Returns the html for the catalog tree page. |
176
|
|
|
* |
177
|
|
|
* @return \Illuminate\Http\Response Response object with output and headers |
178
|
|
|
*/ |
179
|
|
|
public function treeAction() |
180
|
|
|
{ |
181
|
|
|
$params = ['page' => 'page-catalog-tree']; |
182
|
|
|
|
183
|
|
|
foreach( app( 'config' )->get( 'shop.page.catalog-tree' ) as $name ) |
184
|
|
|
{ |
185
|
|
|
$params['aiheader'][$name] = Shop::get( $name )->header(); |
|
|
|
|
186
|
|
|
$params['aibody'][$name] = Shop::get( $name )->body(); |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
return Response::view( Shop::template( 'catalog.tree' ), $params ) |
190
|
|
|
->header( 'Cache-Control', 'private, max-age=10' ); |
191
|
|
|
} |
192
|
|
|
} |
193
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.