Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/model/story/template/filter/default.php
<?php

/**
 * Story Template filter for data like $target, $subject
 *
 */
class AnModelStoryTemplateFilterDefault extends AnModelStoryTemplateFilterAbstract
{
	public function parse(&$text, $tokens, $story)
	{
		$kit     = KFactory::get('lib.anahita.uikit.actor.name');
						
		$data    = $story->data;

		foreach($tokens as $token) {
			
			$value = '';
			
			if ( $token == 'subject' || $token == 'target') {
				if ( $story->type == 'notification' && $token == 'target' )
					$value = JText::_('AN-SE-YOU');
				else {
					$actor   = $story->$token;
					$value   = KFactory::tmp('lib.anahita.model.story.data.text', array('text'=>$actor->name, 'href'=>$actor->profileURL));
				}
			} else if ( strpos($token, 'Pronoun') ) {
				$matches = array();
				preg_match('/(subject|target)\.(\w+)Pronoun/', $token, $matches);
				$actor   = $story->$matches[1];				
				$noun	 = $matches[2];
				$value   = JText::_($kit->setActor($actor)->noune($noun));
			} else if ( isset($data[$token]) ) {
				$value = $data[$token];
			}
						
			if ( is_array($value) ) {
				if ( $token == 'images' )
					$value  = implode(' ', $value);
				else	
					$value  = implode(', ', $value);
			}
			
			$this->_replace($text, $token, $value);
		}		
	}
}
Return current item: Anahita Social Engine