Skip to content

Commit

Permalink
Don't preg_match just use a nav variable on including the common head…
Browse files Browse the repository at this point in the history
…er template
  • Loading branch information
jacques committed Jan 19, 2016
1 parent 9dfb27b commit 1562148
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion accounts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* Copyright 2014-2015 Jacques Marneweck. All rights strictly reserved.
*}
{include file="header.tpl" title="Accounts Page"}
{include file="header.tpl" title="Accounts Page" nav="accounts"}

<div>
<h2 class="page-header">Diamond Cash Card Dashboard</h2>
Expand Down
4 changes: 2 additions & 2 deletions beneficiaries.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2014-2015 Jacques Marneweck. All rights strictly reserved.
* Copyright 2014-2016 Jacques Marneweck. All rights strictly reserved.
*}
{include file="header.tpl" title="Beneficiaries Page"}
{include file="header.tpl" title="Beneficiaries Page" nav="beneficiaries"}

<div>
<h2 class="page-header">Beneficiaries</h2>
Expand Down
28 changes: 18 additions & 10 deletions header.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
{*
* Common header for the Diamond Cash theme
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2014-2016 Jacques Marneweck. All rights strictly reserved.
*}
<!DOCTYPE html>
<html lang="en">
<head>
Expand All @@ -21,11 +30,11 @@
<div class="container">
<div class="header hidden-print">
<ul class="nav nav-pills pull-right">
<li{if preg_match("!\/accounts?.+!", $smarty.server.REQUEST_URI)} class="active"{/if}><a href="/accounts">Accounts</a></li>
<li{if preg_match("!\/transfer?.+!", $smarty.server.REQUEST_URI)} class="active"{/if}><a href="/transfer">Transfer</a></li>
<li{if preg_match("!\/beneficiaries?.+!", $smarty.server.REQUEST_URI)} class="active"{/if}><a href="/beneficiaries">Pay Beneficiary</a></li>
<li{if $nav == "accounts"} class="active"{/if}><a href="/accounts">Accounts</a></li>
<li{if $nav == "transfer"} class="active"{/if}><a href="/transfer">Transfer</a></li>
<li{if $nav == "beneficiaries"} class="active"{/if}><a href="/beneficiaries">Pay Beneficiary</a></li>
{if $globals.features.prepaid}
<li class="dropdown{if preg_match("!\/prepaid?.+!", $smarty.server.REQUEST_URI)} active{/if}">
<li class="dropdown{if $nav == "prepaid"} active{/if}">
<a class="dropdown-toggle"
data-toggle="dropdown"
href="#">
Expand All @@ -39,10 +48,10 @@
</li>
{/if}
{if $globals.features.sms}
<li{if preg_match("!\/sms?.+!", $smarty.server.REQUEST_URI)} class="active"{/if}><a href="/sms">SMS</a></li>
<li{if $nav == "sms"} class="active"{/if}><a href="/sms">SMS</a></li>
{/if}
{if $smarty.session.show_biztools}
<li class="dropdown{if preg_match("!\/(agency?|debitorders?|payrolls?).+!", $smarty.server.REQUEST_URI)} active{/if}">
<li class="dropdown">
<a class="dropdown-toggle"
data-toggle="dropdown"
href="#">
Expand Down Expand Up @@ -78,15 +87,14 @@
</li>
{if $smarty.session.is_agent}
<li><a href="/agent"><i class="fa fa-wrench"></i> Agent</a></li>
{/if}
{if $smarty.session.is_admin}
<li><a href="/admin"><i class="fa fa-cogs"></i> Basecamp</a></li>
{/if}
</li>
<li><a href="/logout"><i class="fa fa-sign-out"></i> Logout</a></li>
</ul>
{if !(array_key_exists('brand', $smarty.session))}
<h3 class="text-muted"><img src="/images/brands/diamondcash.jpg" alt="Diamond Cash Card" height="100"></h3>
{else}
<h3 class="text-muted">&nbsp;</h3>
{/if}
</div>

<hr />
Expand Down
2 changes: 1 addition & 1 deletion transfer.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{include file="header.tpl" title="Transfer Between Accounts Page"}
{include file="header.tpl" title="Transfer Between Accounts Page" nav="transfer"}

<div>
<h2 class="page-header">Transfer Between Accounts</h2>
Expand Down

0 comments on commit 1562148

Please sign in to comment.