Permalink
Browse files

Display name

  • Loading branch information...
1 parent 6e8a083 commit fbe0d5a1899c0793850f353fab00fc5a11ac6f22 @SocalNick SocalNick committed Jan 21, 2012
Showing with 23 additions and 8 deletions.
  1. +1 −0 config/module.config.php
  2. +20 −0 src/IgnGravatar/View/Helper/DisplayName.php
  3. +1 −7 views/people/index.phtml
  4. +1 −1 views/people/person.phtml
View
@@ -39,6 +39,7 @@
'parameters' => array(
'map' => array(
'accounts' => 'IgnGravatar\View\Helper\Accounts',
+ 'displayname' => 'IgnGravatar\View\Helper\DisplayName',
'phonenumbers' => 'IgnGravatar\View\Helper\PhoneNumbers',
'safeemail' => 'IgnGravatar\View\Helper\SafeEmail',
'safeims' => 'IgnGravatar\View\Helper\SafeIms',
@@ -0,0 +1,20 @@
+<?php
+
+namespace IgnGravatar\View\Helper;
+
+use Zend\View\Helper\AbstractHelper,
+ IgnGravatar\Model\Profile;
+
+class DisplayName extends AbstractHelper
+{
+
+ public function __invoke (Profile $profile)
+ {
+ $name = $profile->getName();
+ if (isset($name) && ($formattedName = $name->getFormatted())) {
+ return $this->view->escape($formattedName);
+ } else {
+ return $this->view->escape($profile->getDisplayName());
+ }
+ }
+}
View
@@ -8,13 +8,7 @@
foreach ($this->profiles as $email => $profile): ?>
<div class="span4">
<h2><?php
- $name = $profile->getName();
- if (isset($name) && ($formattedName = $name->getFormatted())) {
- $displayName = $this->escape($formattedName);
- } else {
- $displayName = $this->escape($profile->getDisplayName());
- }
- ?><a href="<?php echo $this->url('person', array('username' => $profile->getPreferredUsername())); ?>"><?php echo $displayName;?></a></h2>
+ ?><a href="<?php echo $this->url('person', array('username' => $profile->getPreferredUsername())); ?>"><?php echo $this->displayName($profile);?></a></h2>
<?php echo $this->gravatar($email, array('img_size' => 200)); ?>
</div>
<?php endforeach; ?>
@@ -44,7 +44,7 @@ $accounts = $this->profile->getAccounts();
<p class="clear"></p>
</div>
- <h2 class="fn">Nicholas Calugar</h2>
+ <h2 class="fn"><?php echo $this->displayName($this->profile); ?></h2>
<p class="location">San Francisco, CA</p>
<p id="bio" class="description">I hack at IGN Entertainment</p>
<h3>Personal Links</h3>

0 comments on commit fbe0d5a

Please sign in to comment.