mirror of
				https://github.com/getgrav/grav-plugin-admin.git
				synced 2025-11-03 20:05:53 +01:00 
			
		
		
		
	Added a task to get childTypes
This commit is contained in:
		@@ -1333,6 +1333,40 @@ class AdminController extends AdminBaseController
 | 
				
			|||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    protected function taskGetChildTypes()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (!$this->authorizeTask('get childtypes', ['admin.pages', 'admin.super'])) {
 | 
				
			||||||
 | 
					            return;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $data = $this->post;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $rawroute = !empty($data['rawroute']) ? $data['rawroute'] : null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if ($rawroute) {
 | 
				
			||||||
 | 
					            $page = $this->grav['pages']->dispatch($rawroute);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if ($page) {
 | 
				
			||||||
 | 
					                $child_type = $page->childType();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (isset($child_type)) {
 | 
				
			||||||
 | 
					                    $this->admin->json_response = [
 | 
				
			||||||
 | 
					                        'status' => 'success',
 | 
				
			||||||
 | 
					                        'child_type' => $child_type
 | 
				
			||||||
 | 
					                    ];
 | 
				
			||||||
 | 
					                    return true;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $this->admin->json_response = [
 | 
				
			||||||
 | 
					            'status'  => 'error',
 | 
				
			||||||
 | 
					            'message' => $this->admin->translate('PLUGIN_ADMIN.NO_CHILD_TYPE')
 | 
				
			||||||
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Handles filtering the page by modular/visible/routable in the pages list.
 | 
					     * Handles filtering the page by modular/visible/routable in the pages list.
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -655,3 +655,4 @@ PLUGIN_ADMIN:
 | 
				
			|||||||
  ZIP_PACKAGE_NOT_FOUND: "ZIP package could not be found"
 | 
					  ZIP_PACKAGE_NOT_FOUND: "ZIP package could not be found"
 | 
				
			||||||
  GPM_OFFICIAL_ONLY: "Official GPM Only"
 | 
					  GPM_OFFICIAL_ONLY: "Official GPM Only"
 | 
				
			||||||
  GPM_OFFICIAL_ONLY_HELP: "Only allow direct installs from the official GPM repository only."
 | 
					  GPM_OFFICIAL_ONLY_HELP: "Only allow direct installs from the official GPM repository only."
 | 
				
			||||||
 | 
					  NO_CHILD_TYPE: "No child type for this rawroute"
 | 
				
			||||||
		Reference in New Issue
	
	Block a user