Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/uikit/page/next.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
 */

class AnUikitPageNext extends AnUikitViewUikit
{
	protected $_layout = 'next';
	
	public function setLayout($layout) {}
	
	public function setCollection($collection, $options=array())
	{		
		$options = array_merge(array('calculate_total' => null, 'url'=>null, 'label'=>JText::_('AN-SE-ACTION-GET-MORE-RECORDS')), $options);
		
		$url 	 = $options['url'];
		
		$this->assign('collection',  $collection);
		
		if ( $options['calculate_total'] )
			$this->assign('total',		 $collection->getTotal());
		
		$this->assign('offset',		 $collection->getOffset());
		$this->assign('limit' ,		 $collection->getLimit());
		$this->assign('label',		 $options['label']);
		$this->assign('next_offset', $this->offset + $this->limit);
		
		if ( $options['calculate_total'] && $this->next_offset >= $this->total ) {
			$this->assign('next_page_url', null);
			return $this;
		}
		
		if  ( is_null($url)	) 
		{
			$page_url   = clone KRequest::url();
		} 
		else if(is_string($url))
		{
			$page_url  = KFactory::tmp('lib.koowa.http.uri',array('uri'=>$url));
				
		} else if (is_array($url)) {
			
			$page_url   = clone KRequest::url();
			$page_url->setQuery(array_merge($page_url->getQuery(true), $url));
		}

		
		$query = array_merge($page_url->getQuery(true), array('limit'=>$this->limit, 'start'=>$this->next_offset));
		$page_url->setQuery($query);
		
		$this->assign('next_page_url', $page_url);
		
		return $this;
	}
	
}
Return current item: Anahita Social Engine