From fc0665b418206a5b6985fec6cd8e8f56e661d431 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Thu, 15 Jun 2017 00:08:11 -0500 Subject: [PATCH] Update: provide breadcrumbs at current path and plan on having login-specific path handling This provides breadcrumbs 'at feet' instead of 'behind feet'. The idea is that the breadcrumbs will show the current path as well as the path history (based on site structure, not browser/navigation history). Plan on having the login handler provide (and possibly conditionally so) the path of the current page instead of the login page. The login handler will show up on different pages than just 'u/login'. Those pages should display their breadcrumb path instead of the login path (unless otherwise hidden). One possible method is to pass the parent handler's path to the child path. --- common/standard/menus/menu_breadcrumbs.php | 1 + common/standard/paths/u/login.php | 26 ++++++++++++++++++++++++++ common/standard/paths/u/logout.php | 22 ++++++++++++++++++++++ common/standard/paths/u/user_create.php | 22 ++++++++++++++++++++++ common/standard/paths/u/user_delete.php | 22 ++++++++++++++++++++++ common/standard/paths/u/user_lock.php | 22 ++++++++++++++++++++++ common/standard/paths/u/user_settings.php | 22 ++++++++++++++++++++++ common/standard/paths/u/user_unlock.php | 22 ++++++++++++++++++++++ common/standard/paths/u/user_view.php | 22 ++++++++++++++++++++++ 9 files changed, 181 insertions(+) diff --git a/common/standard/menus/menu_breadcrumbs.php b/common/standard/menus/menu_breadcrumbs.php index 0f7e34c..0317099 100644 --- a/common/standard/menus/menu_breadcrumbs.php +++ b/common/standard/menus/menu_breadcrumbs.php @@ -41,6 +41,7 @@ class c_standard_menu_breadcrumbs extends c_standard_menu { $item_text = $item->get_text()->get_value_exact(); $item_uri = $item->get_uri()->get_value(); + if (is_string($item_uri) || is_array($item_uri)) { // @fixme: handle if $item_uri is an array. $tag = $this->pr_create_html_add_menu_item_link($item_text, $settings['base_path'] . $item_uri); diff --git a/common/standard/paths/u/login.php b/common/standard/paths/u/login.php index b12a088..05e8fde 100644 --- a/common/standard/paths/u/login.php +++ b/common/standard/paths/u/login.php @@ -25,6 +25,7 @@ require_once('common/theme/classes/theme_html.php'); * This listens on: /u/login */ class c_standard_path_user_login extends c_standard_path { + protected const PATH_SELF = 'u/login'; protected const USER_PUBLIC = 'u_standard_public'; /** @@ -296,6 +297,31 @@ class c_standard_path_user_login extends c_standard_path { } /** + * Implementation of pr_build_breadcrumbs(). + */ + protected function pr_build_breadcrumbs() { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } + unset($result); + + // @todo: using $this->path_tree->get_item_end(), get the current path and render the breadcrumb based on that path instead of this path. + // consider adding this with additional customization, because it may be desired for some paths to remain hidden until logged in. + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->breadcrumbs = new c_base_menu_item(); + } + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(12), self::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** * Validate and Perform the login. * * @param c_base_http &$http diff --git a/common/standard/paths/u/logout.php b/common/standard/paths/u/logout.php index 759cf01..d907c03 100644 --- a/common/standard/paths/u/logout.php +++ b/common/standard/paths/u/logout.php @@ -53,6 +53,28 @@ class c_standard_path_user_logout extends c_standard_path { } /** + * Implementation of pr_build_breadcrumbs(). + */ + protected function pr_build_breadcrumbs() { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } + unset($result); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->breadcrumbs = new c_base_menu_item(); + } + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** * Logout of the session. * * @param c_base_http &$http diff --git a/common/standard/paths/u/user_create.php b/common/standard/paths/u/user_create.php index 28e53d1..0142c19 100644 --- a/common/standard/paths/u/user_create.php +++ b/common/standard/paths/u/user_create.php @@ -41,6 +41,28 @@ class c_standard_path_user_create extends c_standard_path { } /** + * Implementation of pr_build_breadcrumbs(). + */ + protected function pr_build_breadcrumbs() { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } + unset($result); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->breadcrumbs = new c_base_menu_item(); + } + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** * Implementation of pr_create_html_add_header_link_canonical(). */ protected function pr_create_html_add_header_link_canonical() { diff --git a/common/standard/paths/u/user_delete.php b/common/standard/paths/u/user_delete.php index ffea35a..a3c89f2 100644 --- a/common/standard/paths/u/user_delete.php +++ b/common/standard/paths/u/user_delete.php @@ -41,6 +41,28 @@ class c_standard_path_user_delete extends c_standard_path { } /** + * Implementation of pr_build_breadcrumbs(). + */ + protected function pr_build_breadcrumbs() { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } + unset($result); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->breadcrumbs = new c_base_menu_item(); + } + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** * Implementation of pr_create_html_add_header_link_canonical(). */ protected function pr_create_html_add_header_link_canonical() { diff --git a/common/standard/paths/u/user_lock.php b/common/standard/paths/u/user_lock.php index 50b9207..b418697 100644 --- a/common/standard/paths/u/user_lock.php +++ b/common/standard/paths/u/user_lock.php @@ -41,6 +41,28 @@ class c_standard_path_user_lock extends c_standard_path { } /** + * Implementation of pr_build_breadcrumbs(). + */ + protected function pr_build_breadcrumbs() { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } + unset($result); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->breadcrumbs = new c_base_menu_item(); + } + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** * Implementation of pr_create_html_add_header_link_canonical(). */ protected function pr_create_html_add_header_link_canonical() { diff --git a/common/standard/paths/u/user_settings.php b/common/standard/paths/u/user_settings.php index 0797653..4612e2a 100644 --- a/common/standard/paths/u/user_settings.php +++ b/common/standard/paths/u/user_settings.php @@ -41,6 +41,28 @@ class c_standard_path_user_settings extends c_standard_path { } /** + * Implementation of pr_build_breadcrumbs(). + */ + protected function pr_build_breadcrumbs() { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } + unset($result); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->breadcrumbs = new c_base_menu_item(); + } + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** * Implementation of pr_create_html_add_header_link_canonical(). */ protected function pr_create_html_add_header_link_canonical() { diff --git a/common/standard/paths/u/user_unlock.php b/common/standard/paths/u/user_unlock.php index be3cc00..1a93e04 100644 --- a/common/standard/paths/u/user_unlock.php +++ b/common/standard/paths/u/user_unlock.php @@ -41,6 +41,28 @@ class c_standard_path_user_unlock extends c_standard_path { } /** + * Implementation of pr_build_breadcrumbs(). + */ + protected function pr_build_breadcrumbs() { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } + unset($result); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->breadcrumbs = new c_base_menu_item(); + } + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** * Implementation of pr_create_html_add_header_link_canonical(). */ protected function pr_create_html_add_header_link_canonical() { diff --git a/common/standard/paths/u/user_view.php b/common/standard/paths/u/user_view.php index 44cc0b1..fcf7f76 100644 --- a/common/standard/paths/u/user_view.php +++ b/common/standard/paths/u/user_view.php @@ -145,6 +145,28 @@ class c_standard_path_user_view extends c_standard_path { } /** + * Implementation of pr_build_breadcrumbs(). + */ + protected function pr_build_breadcrumbs() { + $result = parent::pr_build_breadcrumbs(); + if ($result instanceof c_base_return_false) { + unset($result); + return new c_base_return_false(); + } + unset($result); + + if (!($this->breadcrumbs instanceof c_base_menu_item)) { + $this->breadcrumbs = new c_base_menu_item(); + } + + $item = $this->pr_create_breadcrumbs_item($this->pr_get_text(0), self::PATH_SELF); + $this->breadcrumbs->set_item($item); + unset($item); + + return new c_base_return_true(); + } + + /** * Implementation of pr_create_html_add_header_link_canonical(). */ protected function pr_create_html_add_header_link_canonical() { -- 1.8.3.1