diff --git a/bootstrap.php b/bootstrap.php index 1bc1c0a..6bde842 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -24,6 +24,7 @@ require('core/router/Router.php'); include_once('core/util/helpers.php'); +include_once('core/util/breadcrumbs.php'); // Initialize Database $db = Database::loadFromConfig(); @@ -32,4 +33,7 @@ // Initialize View loading / routing $viewLoader = new ViewLoader(BASEPATH.'/views/'); $view = new View($viewLoader); -$router = new Router(); \ No newline at end of file +$router = new Router(); + +//load the breadcrumbs +$breadcrumbs = new BreadCrumbs(); \ No newline at end of file diff --git a/core/util/breadcrumbs.php b/core/util/breadcrumbs.php new file mode 100644 index 0000000..1bdd9b9 --- /dev/null +++ b/core/util/breadcrumbs.php @@ -0,0 +1,114 @@ +route =$route; + } + //adds a page to the history array + public function addPage(){ + $arr = null; + //checks to see if the history array has something in it + if($this::checkLength()){ + //add route to the history array + $this::addRouteToBreadcrumb(); + }else{ + if($this::checkEntries()){ + $arr = [$this->route['title'] => $this->route['url']]; + $_SESSION['history'][] = $arr; + } + } + } + //grabs the last key of history array + public function getLastKey(){ + if($this::checkLength()){ + return key($_SESSION['history'][ (sizeof($_SESSION['history']) -1)]); + }else{ + + } + } + //loops through history array to generate links/labels for each breadcrumb + public function displayBreadcrumbs(){ + $this::removeLink(); + foreach($_SESSION['history'] as $keys =>$values){ + if($keys == 0){ + foreach($values as $names => $urls){ + echo "
"; + } + }else{ + foreach($values as $names => $urls){ + echo ""; + +} + } + } + } + //if the link is valid, add it to the history array + public function addRouteToBreadcrumb(){ + if($this::checkEntries()){ + $arr = [$this->route['title'] => $this->route['url']]; + $_SESSION['history'][] = $arr; + } + } + //checks the current length of the history array + public function checkLength(){ + if(empty($_SESSION['history'])){ + return false; + }else{ + return true; + } + } + //validates the links before they are added to the history array + public function checkEntries(){ + if($this->route['title'] != "Page not found!" && $this->route['title'] != $this::getLastKey() ){ + return true; + }else{ + return false; + } + } + //clears history array + public function clearHistory(){ + $_SESSION['history'] = array(); + } + //when a user clicks a specific link, all entries after the link will be removed + public function removeLink(){ + if(isset($_POST['remove'])){ + if($this->route['title'] == "Agency Requests"){ + unset($_POST); + } + $arrPos= $_POST['remove']; + $newHistory = array_slice($_SESSION['history'], 0, $arrPos+1); + $_SESSION['history'] = $newHistory; + }else{ + if($this->route['title'] == 'Login'){ + $this::clearHistory(); + } + if($this->route['title'] == 'Home'){ + $newHistory = array_slice($_SESSION['history'], 0, 1); + $_SESSION['history'] = $newHistory; + } + + } + } + + + +} diff --git a/public/css/custom.css b/public/css/custom.css index 27461be..f978853 100644 --- a/public/css/custom.css +++ b/public/css/custom.css @@ -34,6 +34,24 @@ html, body { margin-top: -3px; transform: skew(45deg); } +.cpca-link{ + text-decoration:none; + color:#5C629C; + padding-left:5px; + padding-right:5px; + border:none; + background-color:transparent; +} +.cpca-link-dark{ + color:#808080!important; +} +.cpca-link:hover{ + font-weight:bold; + color:#5C629C; + padding-left:5px; + padding-right:5px; + cursor:pointer; +} .navbar-left, .navbar-center, diff --git a/public/header.php b/public/header.php index b48282c..e980923 100644 --- a/public/header.php +++ b/public/header.php @@ -1,5 +1,5 @@ @@ -24,6 +24,7 @@ + @@ -54,5 +55,16 @@