1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license MIT, http://opensource.org/licenses/MIT |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015 |
6
|
|
|
* @package laravel-package |
7
|
|
|
* @subpackage Controller |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Shop\Controller; |
12
|
|
|
|
13
|
|
|
use Illuminate\Support\Facades\View; |
14
|
|
|
use Illuminate\Support\Facades\Input; |
15
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Aimeos controller for the JQuery admin interface |
20
|
|
|
* |
21
|
|
|
* @package laravel-package |
22
|
|
|
* @subpackage Controller |
23
|
|
|
*/ |
24
|
|
|
class JqadmController extends AdminController |
25
|
|
|
{ |
26
|
|
|
use AuthorizesRequests; |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Returns the HTML code for a copy of a resource object |
31
|
|
|
* |
32
|
|
|
* @param string Resource location, e.g. "product" |
33
|
|
|
* @param string $sitecode Unique site code |
|
|
|
|
34
|
|
|
* @param integer $id Unique resource ID |
35
|
|
|
* @return string Generated output |
36
|
|
|
*/ |
37
|
|
View Code Duplication |
public function copyAction( $site = 'default', $resource, $id ) |
|
|
|
|
38
|
|
|
{ |
39
|
|
|
if( config( 'shop.authorize', true ) ) { |
40
|
|
|
$this->authorize( 'admin' ); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
$cntl = $this->createClient( $site, $resource ); |
44
|
|
|
$content = $cntl->copy( $id ); |
|
|
|
|
45
|
|
|
|
46
|
|
|
return View::make('shop::admin.jqadm', array( 'content' => $content, 'site' => $site ) ); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Returns the HTML code for a new resource object |
52
|
|
|
* |
53
|
|
|
* @param string Resource location, e.g. "product" |
54
|
|
|
* @param string $sitecode Unique site code |
|
|
|
|
55
|
|
|
* @return string Generated output |
56
|
|
|
*/ |
57
|
|
View Code Duplication |
public function createAction( $site = 'default', $resource ) |
|
|
|
|
58
|
|
|
{ |
59
|
|
|
if( config( 'shop.authorize', true ) ) { |
60
|
|
|
$this->authorize( 'admin' ); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
$cntl = $this->createClient( $site, $resource ); |
64
|
|
|
$content = $cntl->create(); |
65
|
|
|
|
66
|
|
|
return View::make('shop::admin.jqadm', array( 'content' => $content, 'site' => $site ) ); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Deletes the resource object or a list of resource objects |
72
|
|
|
* |
73
|
|
|
* @param string Resource location, e.g. "product" |
74
|
|
|
* @param string $sitecode Unique site code |
|
|
|
|
75
|
|
|
* @param integer $id Unique resource ID |
76
|
|
|
* @return string Generated output |
77
|
|
|
*/ |
78
|
|
View Code Duplication |
public function deleteAction( $site = 'default', $resource, $id ) |
|
|
|
|
79
|
|
|
{ |
80
|
|
|
if( config( 'shop.authorize', true ) ) { |
81
|
|
|
$this->authorize( 'admin' ); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
$cntl = $this->createClient( $site, $resource ); |
85
|
|
|
$content = $cntl->delete( $id ) . $cntl->search(); |
|
|
|
|
86
|
|
|
|
87
|
|
|
return View::make('shop::admin.jqadm', array( 'content' => $content, 'site' => $site ) ); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* Returns the HTML code for the requested resource object |
93
|
|
|
* |
94
|
|
|
* @param string Resource location, e.g. "product" |
95
|
|
|
* @param string $sitecode Unique site code |
|
|
|
|
96
|
|
|
* @param integer $id Unique resource ID |
97
|
|
|
* @return string Generated output |
98
|
|
|
*/ |
99
|
|
View Code Duplication |
public function getAction( $site = 'default', $resource, $id ) |
|
|
|
|
100
|
|
|
{ |
101
|
|
|
if( config( 'shop.authorize', true ) ) { |
102
|
|
|
$this->authorize( 'admin' ); |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
$cntl = $this->createClient( $site, $resource ); |
106
|
|
|
$content = $cntl->get( $id ); |
|
|
|
|
107
|
|
|
|
108
|
|
|
return View::make('shop::admin.jqadm', array( 'content' => $content, 'site' => $site ) ); |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Saves a new resource object |
114
|
|
|
* |
115
|
|
|
* @param string Resource location, e.g. "product" |
116
|
|
|
* @param string $sitecode Unique site code |
|
|
|
|
117
|
|
|
* @return string Generated output |
118
|
|
|
*/ |
119
|
|
View Code Duplication |
public function saveAction( $site = 'default', $resource ) |
|
|
|
|
120
|
|
|
{ |
121
|
|
|
if( config( 'shop.authorize', true ) ) { |
122
|
|
|
$this->authorize( 'admin' ); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
$cntl = $this->createClient( $site, $resource ); |
126
|
|
|
$content = ( $cntl->save() ? : $cntl->search() ); |
127
|
|
|
|
128
|
|
|
return View::make('shop::admin.jqadm', array( 'content' => $content, 'site' => $site ) ); |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* Returns the HTML code for a list of resource objects |
134
|
|
|
* |
135
|
|
|
* @param string Resource location, e.g. "product" |
136
|
|
|
* @param string $sitecode Unique site code |
|
|
|
|
137
|
|
|
* @return string Generated output |
138
|
|
|
*/ |
139
|
|
View Code Duplication |
public function searchAction( $site = 'default', $resource ) |
|
|
|
|
140
|
|
|
{ |
141
|
|
|
if( config( 'shop.authorize', true ) ) { |
142
|
|
|
$this->authorize( 'admin' ); |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
$cntl = $this->createClient( $site, $resource ); |
146
|
|
|
$content = $cntl->search(); |
147
|
|
|
|
148
|
|
|
return View::make('shop::admin.jqadm', array( 'content' => $content, 'site' => $site ) ); |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Returns the resource controller |
154
|
|
|
* |
155
|
|
|
* @param string $sitecode Unique site code |
156
|
|
|
* @return \Aimeos\MShop\Context\Item\Iface Context item |
157
|
|
|
*/ |
158
|
|
View Code Duplication |
protected function createClient( $sitecode, $resource ) |
|
|
|
|
159
|
|
|
{ |
160
|
|
|
$lang = Input::get( 'lang', config( 'app.locale', 'en' ) ); |
161
|
|
|
|
162
|
|
|
$aimeos = app( '\Aimeos\Shop\Base\Aimeos' )->get(); |
163
|
|
|
$templatePaths = $aimeos->getCustomPaths( 'admin/jqadm/templates' ); |
164
|
|
|
|
165
|
|
|
$context = app( '\Aimeos\Shop\Base\Context' )->get( false ); |
166
|
|
|
$context = $this->setLocale( $context, $sitecode, $lang ); |
167
|
|
|
|
168
|
|
|
$view = app( '\Aimeos\Shop\Base\View' )->create( $context->getConfig(), $templatePaths, $lang ); |
169
|
|
|
$context->setView( $view ); |
170
|
|
|
|
171
|
|
|
return \Aimeos\Admin\JQAdm\Factory::createClient( $context, $templatePaths, $resource ); |
172
|
|
|
} |
173
|
|
|
} |
174
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.