Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/model/story/abstract.php
<?php
/**
 * @version		1.0.0
 * @category	Anahita Social Engine™
 * @copyright	Copyright (C) 2008 - 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
 */

abstract class AnModelStoryAbstract extends AnModelNode 
{
		
	static public function describe($model)
	{	
		$model->setTable('socialengine_nodes AS story');
		
		$model->property('id', 	     		  array('field'=>'story.socialengine_node_id', 'unique'=>true));
		
		$model->property('type',			  array('required'=>true, 'field'=>'story.story_type'));

		$model->property('data', 	     	  array('class'=>'lib.anahita.model.story.data', 'initialize_with' => array('data'=>'story.story_tmpl_data')));

		$model->property('template', 	      array('required'=>true, 'class'=>'lib.anahita.model.story.template',   'initialize_with' => array( 'type'=>'story.story_type', 'component'=> 'story.story_component', 'name' =>'story.story_name')));			 

		$model->property('date',	  		  array('required'=>true, 'class'=>'lib.anahita.type.date', 'initialize_with' => array('date'=>'story.story_created_on')));
			
		$model->belongsTo('application',	  array('model'=>'lib.anahita.model.application', 	 'child_key'=>'story.story_component', 'parent_key'=>'component' ));
		
		$model->belongsTo('subject', 	      array('required'=>true,'model'=>'lib.anahita.model.actor', 'child_key'=>'story.story_subject_id'));

		$model->belongsTo('target', 	      array('model'=>'lib.anahita.model.actor', 'child_key'=>'story.story_target_id' ));
		
		$model->belongsTo('owner',	    	array(
			'base_model'	   => 'lib.anahita.model.actor' , 
			'polymorphic'      => true,
			'type_field' 	   => 'story.story_owner_type'  ,
			'child_key'		   => 'story.story_owner_id' ));
		
		$model->belongsTo('object',	array(
			'base_model'	   => 'lib.anahita.model.medium' , 
			'polymorphic'      => true,
			'type_field' 	   => 'story.story_object_type'  ,
			'child_key'		   => 'story.story_object_id' ));
						
		$model->belongsTo('author', array('required'=>true,'model'=>'lib.anahita.model.actor', 'child_key'=>'story.story_created_by'));		
	}
	
	/**
	 * 
	 * @return 
	 */				
	public function getIconUrl()
	{	
		if ( $this->template )
			return  $this->template->getIcon();
	}
		
	/**
	 * Parse the title of the template of the story using the story data
	 * @return 
	 */
	public function getTitle()
	{
		return $this->template->parseTitle($this);
	}
	
	/**
	 * Parse the body of the template of the story using the story data
	 * @return 
	 */
	public function getBody()
	{
		return $this->template->parseBody($this);
	}
	
	/**
	 * Parse the subtitle of the template of the story using the story data
	 * @return 
	 */
	public function getSubTitle()
	{
		return $this->template->parseSubTitle($this);
	}
		
	/**
	 * 
	 * @return 
	 */	
	public function hasBody()
	{
		return strlen($this->template->getBody()) > 2;
	}
	
//end class	
}
Return current item: Anahita Social Engine