mirror of
				https://github.com/getgrav/grav-plugin-admin.git
				synced 2025-10-31 10:25:50 +01:00 
			
		
		
		
	function reorg
This commit is contained in:
		| @@ -1387,39 +1387,86 @@ class AdminController extends AdminBaseController | |||||||
|         return true; |         return true; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     protected function taskGetInitialFolderListing() | ||||||
|  |     { | ||||||
|  | //        if (!$this->authorizeTask('save', $this->dataPermissions())) { | ||||||
|  | //            return false; | ||||||
|  | //        } | ||||||
|  |  | ||||||
|  |         // Get data from post | ||||||
|  |         $data = $this->post; | ||||||
|  |  | ||||||
|  |         $data['route'] = $this->grav['uri']->param('route'); // For testing | ||||||
|  |         $data['initial'] = true; | ||||||
|  |  | ||||||
|  |         $route = $data['route'] ? base64_decode($data['route']) : $this->grav['locator']->findResource('page://', true); | ||||||
|  |  | ||||||
|  |         // Do parent route stuff | ||||||
|  |  | ||||||
|  |         list($status, $message, $response) = $this->getFolderListing($data); | ||||||
|  |  | ||||||
|  |         $this->admin->json_response = [ | ||||||
|  |             'status'  => $status, | ||||||
|  |             'message' => $this->admin::translate($message ?? 'PLUGIN_ADMIN.NO_ROUTE_PROVIDED'), | ||||||
|  |             'data' => $response | ||||||
|  |         ]; | ||||||
|  |  | ||||||
|  |         return true; | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * $data['route'] = $this->grav['uri']->param('route'); | ||||||
|  |      * $data['sortby'] = $this->grav['uri']->param('sortby', null); | ||||||
|  |      * $data['filters'] = $this->grav['uri']->param('filters', null); | ||||||
|  |      * $data['page'] $this->grav['uri']->param('page', true); | ||||||
|  |      * | ||||||
|  |      * @return bool | ||||||
|  |      */ | ||||||
|     protected function taskGetFolderListing() |     protected function taskGetFolderListing() | ||||||
|     { |     { | ||||||
| //        if (!$this->authorizeTask('save', $this->dataPermissions())) { | //        if (!$this->authorizeTask('save', $this->dataPermissions())) { | ||||||
| //            return false; | //            return false; | ||||||
| //        } | //        } | ||||||
|  |  | ||||||
|         // Valid types are dir|file|link |  | ||||||
|         $default_filters =  ['type'=> ['dir','file'], 'name' => null, 'extension' => null]; |  | ||||||
|  |  | ||||||
|         // Get data from post |         // Get data from post | ||||||
|         $data = $this->post; |         $data = $this->post; | ||||||
|  |  | ||||||
|         $data['route'] = $this->grav['uri']->param('route');            // Temp for testing |         $data['route'] = $this->grav['uri']->param('route'); // For testing | ||||||
|         $data['sortby'] = $this->grav['uri']->param('sortby', null);    // Temp for testing |  | ||||||
|         $data['filters'] = $this->grav['uri']->param('filters', null);  // Temp for testing |  | ||||||
|  |  | ||||||
|         $route = $data['route'] ? base64_decode($data['route']) : $this->grav['locator']->findResource('page://', true); |         list($status, $message, $response) = $this->getFolderListing($data); | ||||||
|  |  | ||||||
|  |         $this->admin->json_response = [ | ||||||
|  |             'status'  => $status, | ||||||
|  |             'message' => $this->admin::translate($message ?? 'PLUGIN_ADMIN.NO_ROUTE_PROVIDED'), | ||||||
|  |             'data' => $response | ||||||
|  |         ]; | ||||||
|  |  | ||||||
|  |         return true; | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     protected function getFolderListing($data) | ||||||
|  |     { | ||||||
|  |         // Valid types are dir|file|link | ||||||
|  |         $default_filters =  ['type'=> ['dir','file'], 'name' => null, 'extension' => null]; | ||||||
|  |  | ||||||
|  |         $is_page = $data['page'] ?? true; | ||||||
|  |         $route = isset($data['route']) ? base64_decode($data['route']) : $this->grav['locator']->findResource('page://', true); | ||||||
|  |         $filters = isset($data['filters']) ? $default_filters + json_decode($data['filters']) : $default_filters; | ||||||
|         $sortby = $data['sortby'] ?? 'filename'; |         $sortby = $data['sortby'] ?? 'filename'; | ||||||
|         $order = $data['order'] ?? SORT_ASC; |         $order = $data['order'] ?? SORT_ASC; | ||||||
|         $filters = $data['filters'] ? $default_filters + json_decode($data['filters']) : $default_filters; |  | ||||||
|         $filter_type = (array) $filters['type']; |         $filter_type = (array) $filters['type']; | ||||||
|  |  | ||||||
|         $status = 'error'; |         $status = 'error'; | ||||||
|         $msg = null; |         $msg = null; | ||||||
|         $response = []; |         $response = []; | ||||||
|  |  | ||||||
|  |         if ($is_page) { | ||||||
|             /** @var PageInterface $page */ |             /** @var PageInterface $page */ | ||||||
|             $page = $this->grav['pages']->dispatch($route); |             $page = $this->grav['pages']->dispatch($route); | ||||||
|         $path = null; |             $path = $page ? $page->path() : null; | ||||||
|  |  | ||||||
|         // If a page is found by route... |  | ||||||
|         if ($page) { |  | ||||||
|             $path = $page->path(); |  | ||||||
|         } else { |         } else { | ||||||
|             // Try a physical path |             // Try a physical path | ||||||
|             if (!Utils::startsWith($route, GRAV_ROOT)) { |             if (!Utils::startsWith($route, GRAV_ROOT)) { | ||||||
| @@ -1431,6 +1478,7 @@ class AdminController extends AdminBaseController | |||||||
|             $path = file_exists($try_path) ? $try_path : null; |             $path = file_exists($try_path) ? $try_path : null; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|         if ($path) { |         if ($path) { | ||||||
|             /** @var \SplFileInfo $fileInfo */ |             /** @var \SplFileInfo $fileInfo */ | ||||||
|             $status = 'success'; |             $status = 'success'; | ||||||
| @@ -1479,14 +1527,7 @@ class AdminController extends AdminBaseController | |||||||
|  |  | ||||||
|         $response = Utils::arrayFlatten(Utils::sortArrayByArray($temp_array, $filter_type)); |         $response = Utils::arrayFlatten(Utils::sortArrayByArray($temp_array, $filter_type)); | ||||||
|  |  | ||||||
|         $this->admin->json_response = [ |         return [$status, $this->admin::translate($msg ?? 'PLUGIN_ADMIN.NO_ROUTE_PROVIDED'), $response]; | ||||||
|             'status'  => $status, |  | ||||||
|             'message' => $this->admin::translate($msg ?? 'PLUGIN_ADMIN.NO_ROUTE_PROVIDED'), |  | ||||||
|             'data' => $response |  | ||||||
|         ]; |  | ||||||
|  |  | ||||||
|         return true; |  | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     protected function taskGetChildTypes() |     protected function taskGetChildTypes() | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								themes/grav/css-compiled/preset.css
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								themes/grav/css-compiled/preset.css
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Reference in New Issue
	
	Block a user