Skip to content
This repository has been archived by the owner on Aug 22, 2024. It is now read-only.

Commit

Permalink
- Added a helper to handle navigation links and updated navigation pa…
Browse files Browse the repository at this point in the history
…rtials accordingly.
  • Loading branch information
Raphaël Rougeron committed Apr 22, 2008
1 parent 82bd75e commit 6d166a9
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 11 deletions.
51 changes: 51 additions & 0 deletions PHP/App/Base/Helper/NavAction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* Helper for navigation links.
*
* It sets a 'class' attribute with 'current' as a value if the $href provided
* corresponds to the request URI.
*
*/
class PHP_App_Base_Helper_NavAction extends Solar_View_Helper_Action
{
/**
* Internal request object.
*
* @var Solar_Request
*/
protected $_request = null;

/**
* Constructor
*
* @param array $config User-specified configuration.
*/
public function __construct($config = null)
{
parent::__construct($config);

$this->_request = Solar::factory('Solar_Request');
}

/**
* Returns an action link.
*
* The $text link text will be put in a span tag.
*
* @param string $href The action href.
*
* @param string $text A locale translation key.
*
* @return string
*/
public function navAction($text, $href)
{
if ($this->_request->server('REQUEST_URI') == $href) {
return "<a class=\"current\" href=\"$href\"><span>$text</span></a>";
}
return "<a href=\"$href\"><span>$text</span></a>";
}
}

?>
6 changes: 3 additions & 3 deletions PHP/App/Base/Layout/_contributors_nav.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<ul id="nav-links">
<li class="current"><a href="/contributors"><span>My Account</span></a></li>
<li><a href="/contributors/upload"><span>Upload test(s)</span></a></li>
<li><a href="/contributors/myfiles"><span>My Files</span></a></li>
<li><?php echo $this->navAction('My Account', '/contributors'); ?></li>
<li><?php echo $this->navAction('Upload test(s)', '/contributors/upload'); ?></li>
<li><?php echo $this->navAction('My Files', '/contributors/myfiles'); ?></li>
</ul>
8 changes: 4 additions & 4 deletions PHP/App/Base/Layout/_mentors_nav.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<ul id="nav-links">
<li class="current"><a href="/mentors/my"><span>My Account</span></a></li>
<li><a href="/mentors/review"><span>Test Review</span></a></li>
<li><a href="/mentors/livetest"><span>Live Testing Area</span></a></li>
<li><a href="/mentors/announce"><span>Announcements</span></a></li>
<li><?php echo $this->navAction('My Account', '/mentors/my'); ?></li>
<li><?php echo $this->navAction('Test Review', '/mentors/review'); ?></li>
<li><?php echo $this->navAction('Live Testing Area', '/mentors/livetest'); ?></li>
<li><?php echo $this->navAction('Announcements', '/mentors/announce'); ?></li>
</ul>
2 changes: 1 addition & 1 deletion PHP/App/Contributors.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PHP_App_Contributors extends PHP_App_Base
*/
public function actionIndex()
{

}

/**
Expand Down
1 change: 0 additions & 1 deletion PHP/App/Mentors/Layout/index.php

This file was deleted.

4 changes: 2 additions & 2 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ ul#nav-links a:hover span {
background-position: 100% -120px;
}

ul#nav-links li.current a {
ul#nav-links a.current {
background-position: 0 -60px;
color: #fff;
font-weight: bold;
}

ul#nav-links li.current span {
ul#nav-links a.current span {
background-position: 100% -60px;
}

0 comments on commit 6d166a9

Please sign in to comment.