<?php

/**
 * 
 * Trida zajistuje prevod dat mezi poli pro paginator z array[index radek][index sloupce] na array[index radek][jmeno sloupce]
 * @author aaa
 *
 */
class Zend_View_Helper_PagerToPaginator extends Zend_View_Helper_Abstract
{
	/**
	 * 
	 * prevod dat mezi poli pro paginator z array[index radek][index sloupce] na array[index radek][jmeno sloupce]
	 * @param $pager
	 * @param $nameColumn
	 */
	public function PagerToPaginator($pager, $select)
	{
		$paginator=array();
			if  (empty($pager)){
				$zprava = "Zend_View_Helper_PagerToPaginator: Not exists paginator: "."\n";
        		throw new Exception($zprava);
			}
			
			if (($pager->getCurrentItemCount() === 0)){
				$zprava = "Zend_View_Helper_PagerToPaginator: Not exists items for current page: "."\n";
        		throw new Exception($zprava);
			}else {
			
				$nameColumn = $select->getPart('columns');
				foreach ($pager as $key => $value) {
        			foreach ($value as $key2 => $value2) {
        				$paginator[$key][$nameColumn[$key2][1]]=$value2;
        				//echo "<p>paginator value ".$value2." key ".$key." key2 ".$key2."</p>";
        			}
				}
        		return $paginator;
			}
			return NULL;
	}
}