<?php
/**
 * @version $Id$
 * @package    Contact_Enhanced
 * @subpackage Views
 * @author     Douglas Machado {@link http://ideal.fok.com.br}
 * @author     Created on 28-Jul-09
 * @license		GNU/GPL, see license.txt
 * Contact Enhanced  is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 */

//--No direct access
defined('_JEXEC') or die('Direct Access NOT Allowed. Please try to access the main page');

jimport('joomla.application.component.view');

class Contact_EnhancedsViewtemplates extends JView
{

	function display($tpl = null)
	{
		global $controller,$option,$mainframe;
		JHTML::stylesheet( 'contact_enhanced.css', 'administrator/components/com_contact_enhanced/assets/css/' );
		JToolBarHelper::title(   '&nbsp;&nbsp;'.JText::_( 'Contact Enhanced' ). '&nbsp;&nbsp;<small><small>[' .JText::_( 'Templates' ).']</small></small>', 'thememanager');
		JToolBarHelper::editListX();
		
		$templateType	= JRequest::getVar('templateType','email');
		
		// Initialize the pagination variables
		$limit		= $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
		$limitstart = $mainframe->getUserStateFromRequest($option.'templates.limitstart', 'limitstart', 0, 'int');

		$tBaseDir = JPATH_ROOT.DS.'components'.DS.COMPONENT_FOLDER.DS.'templates'.DS.$templateType;
		require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_templates'.DS.'helpers'.DS.'template.php');
		//get template xml file info
		$rows = array();
		$rows = TemplatesHelper::parseXMLTemplateFiles($tBaseDir);

		
		jimport('joomla.html.pagination');
		$page = new JPagination(count($rows), $limitstart, $limit);

		$rows = array_slice($rows, $page->limitstart, $page->limit);
		
		$this->assignRef('rows', $rows);
		$this->assignRef('page', $page);

		parent::display($tpl);
	}// function

}// class
