Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/uikit/actor/name.php
<?php
/**
 * @version		$Id: html.php 1286 2009-10-20 18:11:30Z rmdstudio $
 * @category	Anahita Social Engine™
 * @copyright	Copyright (C) 2007 - 2010 rmdStudio Inc. and Peerglobe Technology Inc. All rights reserved.
 * @license		GNU GPLv2 <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
 * @link     	http://www.anahitapolis.com
 */

class AnUikitActorName 
{
		
	protected $_actor   = null;
	
	protected $_linked  = true;
	
	public function setActor($actor)
	{
		$this->_actor = $actor;
		return $this;
	}
		
	public function setLinked($bool=true)
	{
		$this->_linked = $bool;
		return $this;
	}
	
	public function noune($type, $options = array())
	{
		$options = array_merge(array('useyou'=>false), $options);
		
		$gender  = strtolower($this->_actor->gender);
				
		if ( !isset($this->_actor) || is_null($this->_actor)) {
			return "";
		}
		
		switch(strtolower($type)) {	
			case 'pronoune'   :
					if($options['useyou'])
						$value = 'AN-SE-YOU';
					else
					{									
						$value  = $gender == 'male' 
								 ? 'AN-SE-HE' : ($gender == 'female'
								 ? 'AN-SE-SHE' 
								 : 'AN-SE-THEY');
					}
					break;
					
			case 'possessive' : 
			
					if($options['useyou']) {
						$value = 'AN-SE-YOUR';
						break;
					}				
									
					$value  = $gender == 'male' 
							 ? 'AN-SE-HIS' : ($gender == 'female'
							 ? 'AN-SE-HER' 
							 : 'AN-SE-THEIR');
					break;
					
			case 'objective' : 
					if($options['useyou']) {
						$value = 'AN-SE-YOU';
						break;
					}	
					
					$value  = $gender == 'male' 
							 ? 'AN-SE-HIM' : ($gender == 'female'
							 ? 'AN-SE-HER' 
							 : 'AN-SE-THEM');
					break;
		}	
		
		return $value;	
		
	}
	
	public function __toString()
	{
		if ( !isset($this->_actor) || is_null($this->_actor)) {
			return "";
		}
		
		$name		 = "<span actorid=\"{$this->_actor->id}\">{$this->_actor->name}</span>";
		
		if ( !$this->_linked ) return (string) $name;
		
		$application = KFactory::get('lib.joomla.application');
		
		if ( $application->getClientId() != 0 )
		{								
			static $base;
			
			if ( !$base ) 
			{
				$base = KFactory::get('lib.joomla.uri')->base();
				$base = preg_replace('/\w+\/$/', '', $base);
			} 
			$url    = $base.$this->_actor->profileURL;								
		} else $url = JRoute::_($this->_actor->profileURL);
		
		return "<a actorid=\"{$this->_actor->id}\" href=\"{$url}\">{$name}</a>";
	}
}
Return current item: Anahita Social Engine