]> Kevux Git Server - koopa/commitdiff
Update: provide breadcrumbs at current path and plan on having login-specific path...
authorKevin Day <thekevinday@gmail.com>
Thu, 15 Jun 2017 05:08:11 +0000 (00:08 -0500)
committerKevin Day <thekevinday@gmail.com>
Thu, 15 Jun 2017 05:08:11 +0000 (00:08 -0500)
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
common/standard/paths/u/login.php
common/standard/paths/u/logout.php
common/standard/paths/u/user_create.php
common/standard/paths/u/user_delete.php
common/standard/paths/u/user_lock.php
common/standard/paths/u/user_settings.php
common/standard/paths/u/user_unlock.php
common/standard/paths/u/user_view.php

index 0f7e34c6e9dc31dddf704e8454a2557ebd88bb41..03170998d79d35ac143700690c36d232274fde24 100644 (file)
@@ -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);
index b12a0886b58d9f325380317febc0ffa3872c92a6..05e8fdef3b7fce26b6a6ed20a35396aaec4003b3 100644 (file)
@@ -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
index 759cf01cff4e02d0e4a15c1906a3459a1fc59c38..d907c035d525395bc9794bfd28a235b439e1e4a6 100644 (file)
@@ -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
index 28e53d1748ff10f4398861f061eca14eb27a7906..0142c19dd6704bbcfe24d437d25df5bbd6ecb1c0 100644 (file)
@@ -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() {
index ffea35a3766fd23adb30fb74ba77069250d8a410..a3c89f22ca9f1072cdd58d164bbd0f0b5a3de80b 100644 (file)
@@ -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() {
index 50b92076835f37d644c9a0b4b74dc1aee3d9ea84..b4186971d23698beaa34c52628f94a928a61882b 100644 (file)
@@ -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() {
index 079765376bebfd298c1b1527d48a9897acb4010e..4612e2a7d836af00f2bfe7a9c2d4a40474abaa5c 100644 (file)
@@ -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() {
index be3cc000197cf031cd86517604315f00639f05d2..1a93e04432c5b56f204a0a0eb808df1683edca7c 100644 (file)
@@ -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() {
index 44cc0b15f9ced01b38812a2052ecef7db231ded2..fcf7f76e51ca29c757484f22949a1b1e164e01d9 100644 (file)
@@ -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() {