PluginProbe
Depicter — Popup & Slider Builder / 1.9.2
Depicter — Popup & Slider Builder v1.9.2
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
← All changes | app/src/Controllers/Ajax/CuratedAPIAjaxController.php +15 -5 1.5.2 → 1.9.2 View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2 namespace Depicter\Controllers\Ajax;
3 3
4 4 use Averta\WordPress\Utility\JSON;
5 +use Depicter\Document\Mapper;
5 6 use Depicter\GuzzleHttp\Exception\GuzzleException;
6 7 use Depicter\Services\AssetsAPIService;
7 8 use Depicter\Utility\Http;
8 9 use Depicter\Utility\Sanitize;
@@ -65,8 +66,9 @@
65 66 $category = !empty( $request->query('category') ) ? Sanitize::textfield( $request->query('category') ) : '';
66 67 $search = !empty( $request->query('s') ) ? Sanitize::textfield( $request->query('s') ) : '';
67 68 $version = !empty( $request->query('v') ) ? Sanitize::textfield( $request->query('v') ) : '1';
68 69 $from = !empty( $request->query('from') ) ? Sanitize::textfield( $request->query('from') ) : 'website';
70 + $directory= !empty( $request->query('directory') ) ? Sanitize::textfield( $request->query('directory') ) : 2;
69 71
70 72 $options = [
71 73 'page' => $page,
72 74 'perpage' => $perpage,
@@ -72,9 +74,10 @@
72 74 'perpage' => $perpage,
73 75 'category' => $category,
74 76 's' => $search,
75 77 'v' => $version,
76 - 'from' => $from
78 + 'from' => $from,
79 + 'directory' => $directory
77 80 ];
78 81
79 82 try {
80 83 return \Depicter::json( AssetsAPIService::searchDocumentTemplates( $options ) );
@@ -90,11 +93,15 @@
90 93 }
91 94
92 95 public function getDocumentTemplateCategories( RequestInterface $request, $view )
93 96 {
94 - $category = !empty( $request->query('category') ) ? Sanitize::textfield( $request->query('category') ) : '';
97 + $category = !empty( $request->query('category') ) ? Sanitize::textfield( $request->query('category') ) : '';
98 + $directory = !empty( $request->query('directory') ) ? Sanitize::textfield( $request->query('directory') ) : 2;
95 99
96 - $options = [ 'category' => $category ];
100 + $options = [
101 + 'category' => $category,
102 + 'directory' => $directory
103 + ];
97 104
98 105 try {
99 106 return \Depicter::json( AssetsAPIService::getDocumentTemplateCategories( $options ) );
100 107 } catch ( \Exception $exception ) {
@@ -117,11 +124,12 @@
117 124 */
118 125 public function importDocumentTemplate( RequestInterface $request, $view ) {
119 126 $templateID = !empty( $request->query('ID') ) ? Sanitize::textfield( $request->query('ID') ) : '';
120 127 $endpointVersion = !empty( $request->query('v') ) ? Sanitize::int( $request->query('v') ) : 1;
128 + $directory = !empty( $request->query('directory') ) ? Sanitize::textfield( $request->query('directory') ) : 2;
121 129
122 130 try {
123 - $result = AssetsAPIService::getDocumentTemplateData( $templateID, [ 'v' => $endpointVersion ] );
131 + $result = AssetsAPIService::getDocumentTemplateData( $templateID, [ 'v' => $endpointVersion, 'directory' => $directory ] );
124 132
125 133 if ( !empty( $result->errors ) ) {
126 134 return Http::getErrorJson( $result->errors );
127 135
@@ -171,10 +179,12 @@
171 179 * @throws GuzzleException
172 180 */
173 181 public function previewDocumentTemplate( RequestInterface $request, $view ) {
174 182 $templateID = !empty( $request->query('ID') ) ? Sanitize::textfield( $request->query('ID') ) : '';
183 + $directory = !empty( $request->query('directory') ) ? Sanitize::textfield( $request->query('directory') ) : 2;
184 +
175 185 try {
176 - $result = AssetsAPIService::previewDocumentTemplate( $templateID );
186 + $result = AssetsAPIService::previewDocumentTemplate( $templateID, $directory );
177 187 return \Depicter::output( $result );
178 188 } catch ( \Exception $exception ) {
179 189 $error = Http::getErrorExceptionResponse( $exception );
180 190