<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/
class Fields_View_Helper_FieldTwitter extends Fields_View_Helper_FieldAbstract
{
  public function fieldTwitter($subject, $field, $value)
  {
    $regex = '/^((http(s|):\/\/|)(www\.|)|)twitter\.com\/(#!|)/i';
    $username = preg_replace($regex, '', trim($value->value));
    $twitterUrl = 'https://www.twitter.com/#!/' .  $username;
    
    return $this->view->htmlLink($twitterUrl, $value->value, array(
      'target' => '_blank',
      'ref' => 'nofollow',
    ));
  }
}
