@@ -1,19 +1,19 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | 8 | |
9 | -$build = function( \Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems ) |
|
9 | +$build = function(\Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems, array $listItems) |
|
10 | 10 | { |
11 | 11 | $id = $item->getId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | 14 | |
15 | - if( isset( $fields[$type] ) ) { |
|
16 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
15 | + if (isset($fields[$type])) { |
|
16 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | $result = array( |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | 'relationships' => array() |
24 | 24 | ); |
25 | 25 | |
26 | - foreach( $childItems as $childItem ) |
|
26 | + foreach ($childItems as $childItem) |
|
27 | 27 | { |
28 | - if( $childItem->getParentId() == $id ) |
|
28 | + if ($childItem->getParentId() == $id) |
|
29 | 29 | { |
30 | 30 | $type = $childItem->getResourceType(); |
31 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
31 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
35 | - foreach( $listItems as $listItem ) |
|
35 | + foreach ($listItems as $listItem) |
|
36 | 36 | { |
37 | - if( $listItem->getParentId() == $id ) |
|
37 | + if ($listItem->getParentId() == $id) |
|
38 | 38 | { |
39 | 39 | $type = $listItem->getDomain(); |
40 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $listItem->getRefId(), 'type' => $type, 'attributes' => $listItem->toArray() ) ); |
|
40 | + $result['relationships'][$type][] = array('data' => array('id' => $listItem->getRefId(), 'type' => $type, 'attributes' => $listItem->toArray())); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
@@ -45,28 +45,28 @@ discard block |
||
45 | 45 | }; |
46 | 46 | |
47 | 47 | |
48 | -$fields = $this->param( 'fields', array() ); |
|
48 | +$fields = $this->param('fields', array()); |
|
49 | 49 | |
50 | -foreach( (array) $fields as $resource => $list ) { |
|
51 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
50 | +foreach ((array) $fields as $resource => $list) { |
|
51 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | -$data = $this->get( 'data', array() ); |
|
56 | -$childItems = $this->get( 'childItems', array() ); |
|
57 | -$listItems = $this->get( 'listItems', array() ); |
|
55 | +$data = $this->get('data', array()); |
|
56 | +$childItems = $this->get('childItems', array()); |
|
57 | +$listItems = $this->get('listItems', array()); |
|
58 | 58 | |
59 | -if( is_array( $data ) ) |
|
59 | +if (is_array($data)) |
|
60 | 60 | { |
61 | 61 | $response = array(); |
62 | 62 | |
63 | - foreach( $data as $item ) { |
|
64 | - $response[] = $build( $item, $fields, $childItems, $listItems ); |
|
63 | + foreach ($data as $item) { |
|
64 | + $response[] = $build($item, $fields, $childItems, $listItems); |
|
65 | 65 | } |
66 | 66 | } |
67 | -elseif( $data !== null ) |
|
67 | +elseif ($data !== null) |
|
68 | 68 | { |
69 | - $response = $build( $data, $fields, $childItems, $listItems ); |
|
69 | + $response = $build($data, $fields, $childItems, $listItems); |
|
70 | 70 | } |
71 | 71 | else |
72 | 72 | { |
@@ -74,4 +74,4 @@ discard block |
||
74 | 74 | } |
75 | 75 | |
76 | 76 | |
77 | -echo json_encode( $response, $options ); |
|
78 | 77 | \ No newline at end of file |
78 | +echo json_encode($response, $options); |
|
79 | 79 | \ No newline at end of file |
@@ -63,12 +63,10 @@ |
||
63 | 63 | foreach( $data as $item ) { |
64 | 64 | $response[] = $build( $item, $fields, $childItems, $listItems ); |
65 | 65 | } |
66 | -} |
|
67 | -elseif( $data !== null ) |
|
66 | +} elseif( $data !== null ) |
|
68 | 67 | { |
69 | 68 | $response = $build( $data, $fields, $childItems, $listItems ); |
70 | -} |
|
71 | -else |
|
69 | +} else |
|
72 | 70 | { |
73 | 71 | $response = null; |
74 | 72 | } |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | 8 | |
9 | -echo json_encode( $this->get( 'errors', array() ), $options ); |
|
10 | 9 | \ No newline at end of file |
10 | +echo json_encode($this->get('errors', array()), $options); |
|
11 | 11 | \ No newline at end of file |
@@ -1,28 +1,28 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | 8 | |
9 | -$build = function( \Aimeos\MW\View\Iface $view, array $items, array $fields ) |
|
9 | +$build = function(\Aimeos\MW\View\Iface $view, array $items, array $fields) |
|
10 | 10 | { |
11 | 11 | $list = array(); |
12 | 12 | |
13 | - $target = $view->config( 'admin/jsonadm/url/target' ); |
|
14 | - $cntl = $view->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
15 | - $action = $view->config( 'admin/jsonadm/url/action', 'get' ); |
|
16 | - $config = $view->config( 'admin/jsonadm/url/config', array() ); |
|
13 | + $target = $view->config('admin/jsonadm/url/target'); |
|
14 | + $cntl = $view->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
15 | + $action = $view->config('admin/jsonadm/url/action', 'get'); |
|
16 | + $config = $view->config('admin/jsonadm/url/config', array()); |
|
17 | 17 | |
18 | - foreach( (array) $items as $item ) |
|
18 | + foreach ((array) $items as $item) |
|
19 | 19 | { |
20 | 20 | $id = $item->getId(); |
21 | 21 | $attributes = $item->toArray(); |
22 | 22 | $type = $item->getResourceType(); |
23 | 23 | |
24 | - if( isset( $fields[$type] ) ) { |
|
25 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
24 | + if (isset($fields[$type])) { |
|
25 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | $list[] = array( |
@@ -30,9 +30,9 @@ discard block |
||
30 | 30 | 'type' => $type, |
31 | 31 | 'attributes' => $attributes, |
32 | 32 | 'links' => array( |
33 | - 'self' => $view->url( $target, $cntl, $action, array( 'resource' => $type, 'id' => $id ), array(), $config ), |
|
33 | + 'self' => $view->url($target, $cntl, $action, array('resource' => $type, 'id' => $id), array(), $config), |
|
34 | 34 | 'related' => array( |
35 | - 'href' => $view->url( $target, $cntl, $action, array( 'resource' => $type, 'id' => null ), array(), $config ) |
|
35 | + 'href' => $view->url($target, $cntl, $action, array('resource' => $type, 'id' => null), array(), $config) |
|
36 | 36 | ) |
37 | 37 | ) |
38 | 38 | ); |
@@ -43,14 +43,14 @@ discard block |
||
43 | 43 | |
44 | 44 | |
45 | 45 | $response = array(); |
46 | -$fields = $this->param( 'fields', array() ); |
|
46 | +$fields = $this->param('fields', array()); |
|
47 | 47 | |
48 | -foreach( (array) $fields as $resource => $list ) { |
|
49 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
48 | +foreach ((array) $fields as $resource => $list) { |
|
49 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
50 | 50 | } |
51 | 51 | |
52 | -$response = $build( $this, $this->get( 'childItems', array() ), $fields ); |
|
53 | -$response = array_merge( $response, $build( $this, $this->get( 'refItems', array() ), $fields ) ); |
|
52 | +$response = $build($this, $this->get('childItems', array()), $fields); |
|
53 | +$response = array_merge($response, $build($this, $this->get('refItems', array()), $fields)); |
|
54 | 54 | |
55 | 55 | |
56 | -echo json_encode( $response, $options ); |
|
57 | 56 | \ No newline at end of file |
57 | +echo json_encode($response, $options); |
|
58 | 58 | \ No newline at end of file |
@@ -1,19 +1,19 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | -$build = function( \Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems ) |
|
8 | +$build = function(\Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems) |
|
9 | 9 | { |
10 | 10 | $id = $item->getId(); |
11 | 11 | $baseId = $item->getBaseId(); |
12 | 12 | $attributes = $item->toArray(); |
13 | 13 | $type = $item->getResourceType(); |
14 | 14 | |
15 | - if( isset( $fields[$type] ) ) { |
|
16 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
15 | + if (isset($fields[$type])) { |
|
16 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | $result = array( |
@@ -23,13 +23,13 @@ discard block |
||
23 | 23 | 'relationships' => array() |
24 | 24 | ); |
25 | 25 | |
26 | - foreach( $childItems as $childItem ) |
|
26 | + foreach ($childItems as $childItem) |
|
27 | 27 | { |
28 | - if( $childItem instanceof \Aimeos\MShop\Order\Item\Status\Iface && $childItem->getParentId() == $id |
|
28 | + if ($childItem instanceof \Aimeos\MShop\Order\Item\Status\Iface && $childItem->getParentId() == $id |
|
29 | 29 | || $childItem instanceof \Aimeos\MShop\Order\Item\Base\Iface && $childItem->getId() == $baseId |
30 | 30 | ) { |
31 | 31 | $type = $childItem->getResourceType(); |
32 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
32 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
@@ -37,27 +37,27 @@ discard block |
||
37 | 37 | }; |
38 | 38 | |
39 | 39 | |
40 | -$fields = $this->param( 'fields', array() ); |
|
40 | +$fields = $this->param('fields', array()); |
|
41 | 41 | |
42 | -foreach( (array) $fields as $resource => $list ) { |
|
43 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
42 | +foreach ((array) $fields as $resource => $list) { |
|
43 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | |
47 | -$data = $this->get( 'data', array() ); |
|
48 | -$childItems = $this->get( 'childItems', array() ); |
|
47 | +$data = $this->get('data', array()); |
|
48 | +$childItems = $this->get('childItems', array()); |
|
49 | 49 | |
50 | -if( is_array( $data ) ) |
|
50 | +if (is_array($data)) |
|
51 | 51 | { |
52 | 52 | $response = array(); |
53 | 53 | |
54 | - foreach( $data as $item ) { |
|
55 | - $response[] = $build( $item, $fields, $childItems ); |
|
54 | + foreach ($data as $item) { |
|
55 | + $response[] = $build($item, $fields, $childItems); |
|
56 | 56 | } |
57 | 57 | } |
58 | -elseif( $data !== null ) |
|
58 | +elseif ($data !== null) |
|
59 | 59 | { |
60 | - $response = $build( $data, $fields, $childItems ); |
|
60 | + $response = $build($data, $fields, $childItems); |
|
61 | 61 | } |
62 | 62 | else |
63 | 63 | { |
@@ -65,4 +65,4 @@ discard block |
||
65 | 65 | } |
66 | 66 | |
67 | 67 | |
68 | -echo json_encode( $response, $options ); |
|
69 | 68 | \ No newline at end of file |
69 | +echo json_encode($response, $options); |
|
70 | 70 | \ No newline at end of file |
@@ -54,12 +54,10 @@ |
||
54 | 54 | foreach( $data as $item ) { |
55 | 55 | $response[] = $build( $item, $fields, $childItems ); |
56 | 56 | } |
57 | -} |
|
58 | -elseif( $data !== null ) |
|
57 | +} elseif( $data !== null ) |
|
59 | 58 | { |
60 | 59 | $response = $build( $data, $fields, $childItems ); |
61 | -} |
|
62 | -else |
|
60 | +} else |
|
63 | 61 | { |
64 | 62 | $response = null; |
65 | 63 | } |
@@ -1,18 +1,18 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | $options = 0; |
4 | -if( defined( 'JSON_PRETTY_PRINT' ) ) { |
|
4 | +if (defined('JSON_PRETTY_PRINT')) { |
|
5 | 5 | $options = JSON_PRETTY_PRINT; |
6 | 6 | } |
7 | 7 | |
8 | -$build = function( \Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems ) |
|
8 | +$build = function(\Aimeos\MShop\Common\Item\Iface $item, array $fields, array $childItems) |
|
9 | 9 | { |
10 | 10 | $id = $item->getId(); |
11 | 11 | $attributes = $item->toArray(); |
12 | 12 | $type = $item->getResourceType(); |
13 | 13 | |
14 | - if( isset( $fields[$type] ) ) { |
|
15 | - $attributes = array_intersect_key( $attributes, $fields[$type] ); |
|
14 | + if (isset($fields[$type])) { |
|
15 | + $attributes = array_intersect_key($attributes, $fields[$type]); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | $result = array( |
@@ -22,12 +22,12 @@ discard block |
||
22 | 22 | 'relationships' => array() |
23 | 23 | ); |
24 | 24 | |
25 | - foreach( $childItems as $childItem ) |
|
25 | + foreach ($childItems as $childItem) |
|
26 | 26 | { |
27 | - if( $childItem->getBaseId() == $id ) |
|
27 | + if ($childItem->getBaseId() == $id) |
|
28 | 28 | { |
29 | 29 | $type = $childItem->getResourceType(); |
30 | - $result['relationships'][$type][] = array( 'data' => array( 'id' => $childItem->getId(), 'type' => $type ) ); |
|
30 | + $result['relationships'][$type][] = array('data' => array('id' => $childItem->getId(), 'type' => $type)); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 | |
@@ -35,27 +35,27 @@ discard block |
||
35 | 35 | }; |
36 | 36 | |
37 | 37 | |
38 | -$fields = $this->param( 'fields', array() ); |
|
38 | +$fields = $this->param('fields', array()); |
|
39 | 39 | |
40 | -foreach( (array) $fields as $resource => $list ) { |
|
41 | - $fields[$resource] = array_flip( explode( ',', $list ) ); |
|
40 | +foreach ((array) $fields as $resource => $list) { |
|
41 | + $fields[$resource] = array_flip(explode(',', $list)); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | -$data = $this->get( 'data', array() ); |
|
46 | -$childItems = $this->get( 'childItems', array() ); |
|
45 | +$data = $this->get('data', array()); |
|
46 | +$childItems = $this->get('childItems', array()); |
|
47 | 47 | |
48 | -if( is_array( $data ) ) |
|
48 | +if (is_array($data)) |
|
49 | 49 | { |
50 | 50 | $response = array(); |
51 | 51 | |
52 | - foreach( $data as $item ) { |
|
53 | - $response[] = $build( $item, $fields, $childItems ); |
|
52 | + foreach ($data as $item) { |
|
53 | + $response[] = $build($item, $fields, $childItems); |
|
54 | 54 | } |
55 | 55 | } |
56 | -elseif( $data !== null ) |
|
56 | +elseif ($data !== null) |
|
57 | 57 | { |
58 | - $response = $build( $data, $fields, $childItems ); |
|
58 | + $response = $build($data, $fields, $childItems); |
|
59 | 59 | } |
60 | 60 | else |
61 | 61 | { |
@@ -63,4 +63,4 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | |
66 | -echo json_encode( $response, $options ); |
|
67 | 66 | \ No newline at end of file |
67 | +echo json_encode($response, $options); |
|
68 | 68 | \ No newline at end of file |
@@ -52,12 +52,10 @@ |
||
52 | 52 | foreach( $data as $item ) { |
53 | 53 | $response[] = $build( $item, $fields, $childItems ); |
54 | 54 | } |
55 | -} |
|
56 | -elseif( $data !== null ) |
|
55 | +} elseif( $data !== null ) |
|
57 | 56 | { |
58 | 57 | $response = $build( $data, $fields, $childItems ); |
59 | -} |
|
60 | -else |
|
58 | +} else |
|
61 | 59 | { |
62 | 60 | $response = null; |
63 | 61 | } |
@@ -1,12 +1,12 @@ |
||
1 | 1 | { |
2 | -<?php if( isset( $this->errors ) ) : ?> |
|
3 | - "errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?>, |
|
4 | -<?php elseif( isset( $this->data ) ) : ?> |
|
5 | - "data": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-data', 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ) ) ); ?>, |
|
2 | +<?php if (isset($this->errors)) : ?> |
|
3 | + "errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?>, |
|
4 | +<?php elseif (isset($this->data)) : ?> |
|
5 | + "data": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-data', 'partials/data-standard.php'), array('data' => $this->get('data'))); ?>, |
|
6 | 6 | <?php endif; ?> |
7 | 7 | |
8 | 8 | "meta": { |
9 | - "total": <?php echo $this->get( 'total', 0 ); ?> |
|
9 | + "total": <?php echo $this->get('total', 0); ?> |
|
10 | 10 | |
11 | 11 | } |
12 | 12 | } |
@@ -1,29 +1,29 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -$target = $this->config( 'admin/jsonadm/url/target' ); |
|
4 | -$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
5 | -$action = $this->config( 'admin/jsonadm/url/action', 'get' ); |
|
6 | -$config = $this->config( 'admin/jsonadm/url/config', array() ); |
|
3 | +$target = $this->config('admin/jsonadm/url/target'); |
|
4 | +$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
5 | +$action = $this->config('admin/jsonadm/url/action', 'get'); |
|
6 | +$config = $this->config('admin/jsonadm/url/config', array()); |
|
7 | 7 | |
8 | 8 | $resources = $attributes = array(); |
9 | -$site = $this->param( 'site', 'default' ); |
|
9 | +$site = $this->param('site', 'default'); |
|
10 | 10 | |
11 | -foreach( $this->get( 'resources', array() ) as $resource ) { |
|
12 | - $resources[$resource] = $this->url( $target, $cntl, $action, array( 'site' => $site, 'resource' => $resource, 'id' => '' ), array(), $config ); |
|
11 | +foreach ($this->get('resources', array()) as $resource) { |
|
12 | + $resources[$resource] = $this->url($target, $cntl, $action, array('site' => $site, 'resource' => $resource, 'id' => ''), array(), $config); |
|
13 | 13 | } |
14 | 14 | |
15 | -foreach( $this->get( 'attributes', array() ) as $attr ) { |
|
15 | +foreach ($this->get('attributes', array()) as $attr) { |
|
16 | 16 | $attributes[$attr->getCode()] = $attr->toArray(); |
17 | 17 | } |
18 | 18 | |
19 | 19 | ?> |
20 | 20 | { |
21 | 21 | "meta": { |
22 | - "resources": <?php echo json_encode( $resources ); ?>, |
|
23 | - "attributes": <?php echo json_encode( $attributes ); ?> |
|
22 | + "resources": <?php echo json_encode($resources); ?>, |
|
23 | + "attributes": <?php echo json_encode($attributes); ?> |
|
24 | 24 | } |
25 | -<?php if( isset( $this->errors ) ) : ?> |
|
26 | - ,"errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
25 | +<?php if (isset($this->errors)) : ?> |
|
26 | + ,"errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
27 | 27 | <?php endif; ?> |
28 | 28 | |
29 | 29 | } |
@@ -1,6 +1,6 @@ |
||
1 | 1 | { |
2 | -<?php if( isset( $this->errors ) ) : ?> |
|
3 | - "errors": <?php echo $this->partial( $this->config( 'admin/jsonadm/partials/template-errors', 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
2 | +<?php if (isset($this->errors)) : ?> |
|
3 | + "errors": <?php echo $this->partial($this->config('admin/jsonadm/partials/template-errors', 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
4 | 4 | <?php endif; ?> |
5 | 5 | |
6 | 6 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | * @see admin/jsonadm/url/action |
15 | 15 | * @see admin/jsonadm/url/config |
16 | 16 | */ |
17 | -$target = $this->config( 'admin/jsonadm/url/target' ); |
|
17 | +$target = $this->config('admin/jsonadm/url/target'); |
|
18 | 18 | |
19 | 19 | /** admin/jsonadm/url/controller |
20 | 20 | * Name of the client whose action should be called |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * @see admin/jsonadm/url/action |
31 | 31 | * @see admin/jsonadm/url/config |
32 | 32 | */ |
33 | -$cntl = $this->config( 'admin/jsonadm/url/controller', 'jsonadm' ); |
|
33 | +$cntl = $this->config('admin/jsonadm/url/controller', 'jsonadm'); |
|
34 | 34 | |
35 | 35 | /** admin/jsonadm/url/action |
36 | 36 | * Name of the action that should create the output |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @see admin/jsonadm/url/controller |
47 | 47 | * @see admin/jsonadm/url/config |
48 | 48 | */ |
49 | -$action = $this->config( 'admin/jsonadm/url/action', 'get' ); |
|
49 | +$action = $this->config('admin/jsonadm/url/action', 'get'); |
|
50 | 50 | |
51 | 51 | /** admin/jsonadm/url/config |
52 | 52 | * Associative list of configuration options used for generating the URL |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @see admin/jsonadm/url/controller |
69 | 69 | * @see admin/jsonadm/url/action |
70 | 70 | */ |
71 | -$config = $this->config( 'admin/jsonadm/url/config', array() ); |
|
71 | +$config = $this->config('admin/jsonadm/url/config', array()); |
|
72 | 72 | |
73 | 73 | |
74 | 74 | /** admin/jsonadm/partials/template-errors |
@@ -120,22 +120,22 @@ discard block |
||
120 | 120 | */ |
121 | 121 | |
122 | 122 | |
123 | -$ref = array( 'id', 'resource', 'filter', 'page', 'sort', 'include', 'fields' ); |
|
124 | -$params = array_intersect_key( $this->param(), array_flip( $ref ) ); |
|
123 | +$ref = array('id', 'resource', 'filter', 'page', 'sort', 'include', 'fields'); |
|
124 | +$params = array_intersect_key($this->param(), array_flip($ref)); |
|
125 | 125 | |
126 | -if( !isset( $params['id'] ) ) { |
|
126 | +if (!isset($params['id'])) { |
|
127 | 127 | $params['id'] = ''; |
128 | 128 | } |
129 | 129 | |
130 | 130 | |
131 | -$total = $this->get( 'total', 0 ); |
|
132 | -$offset = max( $this->param( 'page/offset', 0 ), 0 ); |
|
133 | -$limit = max( $this->param( 'page/limit', 25 ), 1 ); |
|
131 | +$total = $this->get('total', 0); |
|
132 | +$offset = max($this->param('page/offset', 0), 0); |
|
133 | +$limit = max($this->param('page/limit', 25), 1); |
|
134 | 134 | |
135 | -$first = ( $offset > 0 ? 0 : null ); |
|
136 | -$prev = ( $offset - $limit >= 0 ? $offset - $limit : null ); |
|
137 | -$next = ( $offset + $limit < $total ? $offset + $limit : null ); |
|
138 | -$last = ( ((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null ); |
|
135 | +$first = ($offset > 0 ? 0 : null); |
|
136 | +$prev = ($offset - $limit >= 0 ? $offset - $limit : null); |
|
137 | +$next = ($offset + $limit < $total ? $offset + $limit : null); |
|
138 | +$last = (((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null); |
|
139 | 139 | |
140 | 140 | ?> |
141 | 141 | { |
@@ -144,27 +144,27 @@ discard block |
||
144 | 144 | |
145 | 145 | }, |
146 | 146 | "links": { |
147 | -<?php if( is_array( $this->get( 'data' ) ) ) : ?> |
|
148 | -<?php if( $first !== null ) : ?> |
|
149 | - "first": "<?php $params['page']['offset'] = $first; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
147 | +<?php if (is_array($this->get('data'))) : ?> |
|
148 | +<?php if ($first !== null) : ?> |
|
149 | + "first": "<?php $params['page']['offset'] = $first; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
150 | 150 | <?php endif; ?> |
151 | -<?php if( $prev !== null ) : ?> |
|
152 | - "prev": "<?php $params['page']['offset'] = $prev; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
151 | +<?php if ($prev !== null) : ?> |
|
152 | + "prev": "<?php $params['page']['offset'] = $prev; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
153 | 153 | <?php endif; ?> |
154 | -<?php if( $next !== null ) : ?> |
|
155 | - "next": "<?php $params['page']['offset'] = $next; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
154 | +<?php if ($next !== null) : ?> |
|
155 | + "next": "<?php $params['page']['offset'] = $next; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
156 | 156 | <?php endif; ?> |
157 | -<?php if( $last !== null ) : ?> |
|
158 | - "last": "<?php $params['page']['offset'] = $last; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>", |
|
157 | +<?php if ($last !== null) : ?> |
|
158 | + "last": "<?php $params['page']['offset'] = $last; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>", |
|
159 | 159 | <?php endif; ?> |
160 | 160 | <?php endif; ?> |
161 | - "self": "<?php $params['page']['offset'] = $offset; echo $this->url( $target, $cntl, $action, $params, array(), $config ); ?>" |
|
161 | + "self": "<?php $params['page']['offset'] = $offset; echo $this->url($target, $cntl, $action, $params, array(), $config); ?>" |
|
162 | 162 | }, |
163 | -<?php if( isset( $this->errors ) ) : ?> |
|
164 | - "errors": <?php echo $this->partial( $this->config( $this->get( 'partial-errors', 'admin/jsonadm/partials/template-errors' ), 'partials/errors-standard.php' ), array( 'errors' => $this->errors ) ); ?> |
|
165 | -<?php elseif( isset( $this->data ) ) : ?> |
|
166 | - "data": <?php echo $this->partial( $this->config( $this->get( 'partial-data', 'admin/jsonadm/partials/template-data' ), 'partials/data-standard.php' ), array( 'data' => $this->get( 'data' ), 'childItems' => $this->get( 'childItems', array() ), 'listItems' => $this->get( 'listItems', array() ) ) ); ?>, |
|
167 | - "included": <?php echo $this->partial( $this->config( $this->get( 'partial-included', 'admin/jsonadm/partials/template-included' ), 'partials/included-standard.php' ), array( 'childItems' => $this->get( 'childItems', array() ), 'refItems' => $this->get( 'refItems', array() ) ) ); ?> |
|
163 | +<?php if (isset($this->errors)) : ?> |
|
164 | + "errors": <?php echo $this->partial($this->config($this->get('partial-errors', 'admin/jsonadm/partials/template-errors'), 'partials/errors-standard.php'), array('errors' => $this->errors)); ?> |
|
165 | +<?php elseif (isset($this->data)) : ?> |
|
166 | + "data": <?php echo $this->partial($this->config($this->get('partial-data', 'admin/jsonadm/partials/template-data'), 'partials/data-standard.php'), array('data' => $this->get('data'), 'childItems' => $this->get('childItems', array()), 'listItems' => $this->get('listItems', array()))); ?>, |
|
167 | + "included": <?php echo $this->partial($this->config($this->get('partial-included', 'admin/jsonadm/partials/template-included'), 'partials/included-standard.php'), array('childItems' => $this->get('childItems', array()), 'refItems' => $this->get('refItems', array()))); ?> |
|
168 | 168 | <?php endif; ?> |
169 | 169 | |
170 | 170 | } |