diff options
author | Thedro Neely <thedroneely@gmail.com> | 2019-01-10 01:33:23 -0500 |
---|---|---|
committer | Thedro Neely <thedroneely@gmail.com> | 2019-01-10 01:33:23 -0500 |
commit | eaaf2121cc92f187ea336919d1a3aca4c8dab663 (patch) | |
tree | f0fed5b4d8e7bc7c61089e00d9264d4838246e76 /app/model | |
parent | 96efff3c26852e214e0e5e5d251ca5bf64102f5e (diff) | |
download | thedroneely.com-eaaf2121cc92f187ea336919d1a3aca4c8dab663.tar.gz thedroneely.com-eaaf2121cc92f187ea336919d1a3aca4c8dab663.tar.bz2 thedroneely.com-eaaf2121cc92f187ea336919d1a3aca4c8dab663.zip |
app/model/Navigation: Rework Navigator
Streamline mobile view
Dry some redundant elements
Diffstat (limited to 'app/model')
-rw-r--r-- | app/model/Navigation.php | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/app/model/Navigation.php b/app/model/Navigation.php index 1b5ba88..0e4542a 100644 --- a/app/model/Navigation.php +++ b/app/model/Navigation.php @@ -2,38 +2,33 @@ class Navigation { - public function generateHomeButton() + public function requestContains($route) { - if ($_SERVER['REQUEST_URI'] === '/') { - echo '<a class="navbar__active navbar-item navbar__item" href="/">Home</a>'; - return; + if (strpos($_SERVER['REQUEST_URI'], $route) !== false) { + return true; } - echo '<a class="navbar-item navbar__item" href="/">Home</a>'; + return false; } - public function generateNavBar() + public function isActiveHome() { - $navbar = [ - 'Posts' => ['uri' => '/post/'], - 'Projects' => ['uri' => '/project/'], - 'Profile' => ['uri' => '/about/'], - 'Contact' => ['uri' => '/contact/'], - ]; + if ($_SERVER['REQUEST_URI'] === '/') { + return 'navbar__active '; + } + return; + } - foreach ($navbar as $title => $route) { - $append =''; - if ($route['uri'] === $_SERVER['REQUEST_URI'] - || strpos($_SERVER['REQUEST_URI'], $route['uri']) !== false - ) { - $append = 'navbar__active'; - } - echo str_repeat("\t", 4) . - "<a class=\"navbar-item navbar__item $append\"" . - ' href="' . $route['uri'] . '">' . $title . '</a>' . "\n"; + public function isActive($route) + { + if ($_SERVER['REQUEST_URI'] === $route + || $this->requestContains($route) + ) { + return 'navbar__active '; } + return; } - public function generateTitle() + public function title() { switch ($_SERVER['REQUEST_URI']) { case '/contact/': |