src/Controller/Navigation.php
public function showNavigations(array $request = [])
    {
        $navigations_list = $this->core->api('Navigation/all/flatten', 'GET')->run(0, null, []);
        if (($navigations_list["headers"][0][2] - 200) * ($navigations_list["headers"][0][2] - 299) > 0) {
            if (headers_sent() === false) {
                foreach ($navigations_list["headers"] as $header) {
                    header($header[0], $header[1], $header[2]);
                }
            }
            return $this->templates->render("500", [
                "error" => $navigations_list['response'],
                "result" => ''
            ]);
        }
        $navigations_list = $navigations_list['response'];

        $pages = $this->core->api('Page/all', 'GET')->run();
        $pages_list = [];
        foreach ($pages['response'] as $key => $page) {
            if ($page->status === true && $page->navigation === null) {
                $pages_list[] = $page;
            }
        }

        $messages = [
            'error' => '',
            'info' => '',
            'success' => '',
            'warning' => ''
        ];
        if (empty($request['m']) === false) {
            if ($request['m'] == 1) {
                $messages['success'] = 'Navigation element added successfully.';
            } elseif ($request['m'] == 2) {
                $messages['success'] = 'Navigations list edited successfully.';
            } elseif ($request['m'] == 3) {
                if (headers_sent() === false) {
                    header('X-PHP-Response-Code: 202', true, 202);
                }
                $messages['success'] = 'Navigation element deleted successfully.';
            } elseif ($request['m'] == 4) {
                if (headers_sent() === false) {
                    header('X-PHP-Response-Code: 422', true, 422);
                }
                $messages['error'] = 'Error - Navigation element not found.';
            }
        }

        return $this->templates->render("Main::Navigation", [
            "messages" => $messages,
            "navigations" => $navigations_list,
            "pages" => $pages_list
        ]);
    }
public function showNavigations(array $request = [])
    {
        $navigations_list = $this->core->api('Navigation/all/flatten', 'GET')->run(0, null, []);
        if (($navigations_list["headers"][0][2] - 200) * ($navigations_list["headers"][0][2] - 299) > 0) {
            if (headers_sent() === false) {
                foreach ($navigations_list["headers"] as $header) {
                    header($header[0], $header[1], $header[2]);
                }
            }
            return $this->templates->render("500", [
                "error" => $navigations_list['response'],
                "result" => ''
            ]);
        }
        $navigations_list = $navigations_list['response'];

        $pages = $this->core->api('Page/all', 'GET')->run();
        $pages_list = [];
        foreach ($pages['response'] as $key => $page) {
            if ($page->status === true && $page->navigation === null) {
                $pages_list[] = $page;
            }
        }

        $messages = [
            'error' => '',
            'info' => '',
            'success' => '',
            'warning' => ''
        ];
        if (empty($request['m']) === false) {
            if ($request['m'] == 1) {
                $messages['success'] = 'Navigation element added successfully.';
            } elseif ($request['m'] == 2) {
                $messages['success'] = 'Navigations list edited successfully.';
            } elseif ($request['m'] == 3) {
                if (headers_sent() === false) {
                    header('X-PHP-Response-Code: 202', true, 202);
                }
                $messages['success'] = 'Navigation element deleted successfully.';
            } elseif ($request['m'] == 4) {
                if (headers_sent() === false) {
                    header('X-PHP-Response-Code: 422', true, 422);
                }
                $messages['error'] = 'Error - Navigation element not found.';
            }
        }

        return $this->templates->render("Main::Navigation", [
            "messages" => $messages,
            "navigations" => $navigations_list,
            "pages" => $pages_list
        ]);
    }
public function showNavigations ( array $ request = [ ] ) { $ navigations_list = $ this -> core -> api ( 'Navigation/all/flatten' , 'GET' ) -> run ( 0 , null , [ ] ) ; if ( ( $ navigations_list [ "headers" ] [ 0 ] [ 2 ] - 200 ) * ( $ navigations_list [ "headers" ] [ 0 ] [ 2 ] - 299 ) > 0 ) { if ( headers_sent ( ) === false ) { foreach ( $ navigations_list [ "headers" ] as $ header ) { header ( $ header [ 0 ] , $ header [ 1 ] , $ header [ 2 ] ) ; } } return $ this -> templates -> render ( "500" , [ "error" => $ navigations_list [ 'response' ] , "result" => '' ] ) ; } $ navigations_list = $ navigations_list [ 'response' ] ; $ pages = $ this -> core -> api ( 'Page/all' , 'GET' ) -> run ( ) ; $ pages_list = [ ] ; foreach ( $ pages [ 'response' ] as $ key => $ page ) { if ( $ page -> status === true && $ page -> navigation === null ) { $ pages_list [ ] = $ page ; } } $ messages = [ 'error' => '' , 'info' => '' , 'success' => '' , 'warning' => '' ] ; if ( empty ( $ request [ 'm' ] ) === false ) { if ( $ request [ 'm' ] == 1 ) { $ messages [ 'success' ] = 'Navigation element added successfully.' ; } elseif ( $ request [ 'm' ] == 2 ) { $ messages [ 'success' ] = 'Navigations list edited successfully.' ; } elseif ( $ request [ 'm' ] == 3 ) { if ( headers_sent ( ) === false ) { header ( 'X-PHP-Response-Code: 202' , true , 202 ) ; } $ messages [ 'success' ] = 'Navigation element deleted successfully.' ; } elseif ( $ request [ 'm' ] == 4 ) { if ( headers_sent ( ) === false ) { header ( 'X-PHP-Response-Code: 422' , true , 422 ) ; } $ messages [ 'error' ] = 'Error - Navigation element not found.' ; } } return $ this -> templates -> render ( "Main::Navigation" , [ "messages" => $ messages , "navigations" => $ navigations_list , "pages" => $ pages_list ] ) ; }
Show the navigations list page
Show the navigations list page