Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/uikit/controller/behavior.php
<?php

class AnUikitControllerBehavior extends KMixinAbstract
{
	/**
	 * 
	 * @var identifier
	 */
	protected $_model;
	
	/**
	 * Initialize
	 * @return 
	 * @param $options array
	 */
	public function __construct($options = array())
	{
		parent::__construct($options);
		
		$model = clone $this->_mixer->getIdentifier();
		
		$model->path = array('model');
		
		$default = array(
			'behaviors' => array() ,
			'model'	    => $model  
		);
		
		$options = array_merge($default, $options);
		
		$this->_model = $options['model'];
		
		foreach($options['behaviors'] as $behavior) {
			$this->registerFunctionBefore($behavior, 'setEntities');
			$this->registerFunctionAfter($behavior ,  array('save','redirect'));
		}
	}
	
	public function _actionOrder()
	{
		$orders = KRequest::get('post.order',	'int');		
		$ids    = KRequest::get('request.id',	'int');
		$array  = array();		
		foreach($ids as $i=>$id)
		{
			$array[$id] = @$orders[$i];
		}
		$orders = $array;
		foreach($this->entities as $i => $entity)
		{	
			$entity->order = @$orders[$entity->id];			
		}
	
	}
	
	/**
	 * 
	 * 
	 * @return 
	 */	
	public function setEntities()
	{	
		$ids   = KRequest::get('request.id',	'int');
		
		$query = KFactory::get('lib.anahita.domain.factory.query')->get( $this->_model )->where('id','IN',$ids);
		
		$this->_mixer->entities = $query->fetchAll();
	}
	
	/**
	 * 
	 * 
	 * @return 
	 */	
	public function save()
	{
		KFactory::get('lib.anahita.domain.context')->save();
	}
	
	/**
	 * Redirect back
	 * 
	 * @return 
	 */
	public function redirect()
	{
		$this->_mixer->setRedirect( KRequest::referrer() );
	}
}
Return current item: Anahita Social Engine