Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Display name

  • Loading branch information...
commit fbe0d5a1899c0793850f353fab00fc5a11ac6f22 1 parent 6e8a083
@SocalNick SocalNick authored
View
1  config/module.config.php
@@ -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',
View
20 src/IgnGravatar/View/Helper/DisplayName.php
@@ -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 views/people/index.phtml
@@ -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; ?>
View
2  views/people/person.phtml
@@ -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>
Please sign in to comment.
Something went wrong with that request. Please try again.