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/Database/Repository/DocumentRepository.php +24 -2 1.5.21.9.2 View file →
@@ -197,18 +197,31 @@
197 197 /**
198 198 * Save changes directly to current document
199 199 *
200 200 * @param array $fields
201 + * @param array $args
201 202 *
202 203 * @return array
203 204 * @throws Exception
204 205 */
205 - public function getList( array $fields = [] )
206 + public function getList( array $fields = [], $args = [] )
206 207 {
207 208 $columnsName = !empty( $fields ) ? $fields : ['id', 'name', 'slug', 'author', 'sections_count', 'created_at', 'modified_at', 'thumbnail', 'status'];
208 - $documents = $this->select( $fields )->findAll()->get();
209 + $numberOfPages = '';
210 + if ( !empty( $args['page'] ) && !empty( $args['perPage'] ) ) {
211 + $pager = $this->select( $fields )->paginate( $args['perPage'], $args['page'] );
212 + if ( $pager ) {
213 + $numberOfPages = $pager->getNumberOfPages();
214 + $documents = $pager->getResults();
215 + } else {
216 + $documents = [];
217 + }
209 218
219 + } else {
220 + $documents = $this->select( $fields )->findAll()->get();
221 + }
210 222
223 +
211 224 $documents = $documents ? $documents->toArray() : [];
212 225
213 226 if ( $documents && empty( $fields ) ) {
214 227 $uploadDir = wp_upload_dir();
@@ -220,8 +233,17 @@
220 233 } else {
221 234 $documents[ $key ]['previewImage'] = '';
222 235 }
223 236 }
237 + }
238 +
239 + if ( !empty( $numberOfPages ) ) {
240 + return [
241 + 'page' => $args['page'],
242 + 'perPage' => $args['perPage'],
243 + 'numberOfPages' => $numberOfPages,
244 + 'documents' => $documents
245 + ];
224 246 }
225 247
226 248 return $documents;
227 249 }