<?php
/**
* @package ccNewsletter
* @version 1.0.6
* @author  Chill Creations <info@chillcreations.com>
* @link    http://www.chillcreations.com
* @copyright Copyright (C) 2008 - 2010 Chill Creations-All rights reserved
* @license GNU/GPL, see LICENSE.php for full license.
* See COPYRIGHT.php for more copyright notices and details.

This file is part of ccNewsletter.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
**/

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
jimport( 'joomla.application.component.view' );
/**
 * Hellos View
 *
 * @package    Joomla.Tutorials
 * @subpackage Components
 */
class ccNewsletterViewnewsletterarchive extends JView
{
	/**
	 * ccNewsletters display function
	 * @return void
	 **/
	function display($tpl = null)
	{

 		global $mainframe, $option;
 		$db =& JFactory::getDBO();
 		$uri 		=& JFactory::getURI();
		$context			= 'com_ccNewsletter.newsletter.list.';
		$nid = JRequest::getVar( 'nid', '', 'get', 'string');


		if($nid)
		{
			/*$query   = "SELECT * FROM #__ccnewsletter_newsletters WHERE id='".$nid."'";
			$db->setQuery( $query );
			$row     = $db->loadObject();
			$newsletterModel = $this->getModel();
			$message = $row->body;
			$message=$newsletterModel->convertImgTags($message);
			$message=$newsletterModel->convertBackgroundTags($message);
			$message=$newsletterModel->convertInternalLink($message);
			$this->assignRef('message',		$message);
			parent::display('detail');*/
		}
		else
		{

		$filter					= JRequest::getVar('newsletter_filter');
		$sortColumn		= JRequest::getVar('filter_order','ordering');
		$sortOrder		= JRequest::getVar('filter_order_Dir','asc');
		$rows		= $this->get('data');
		$pagination		= $this->get('pagination');

		$user =& JFactory::getUser();
		$this->assignRef('email',$user->email);
		$this->assignRef('name',$user->name);

			$javascript		= 'onchange="document.adminForm.submit();"';
			$this->assign('action', 	str_replace('&', '&amp;', $uri->toString()));
			$lists['order_Dir']	= $sortOrder;
			$lists['order']		= $sortColumn;
			$lists['search']= $filter;
			$this->assignRef('items',		$rows);
			$this->assignRef('pageNav',		$pagination);
			$this->assignRef('lists',		$lists);
			parent::display($tpl);
		}
	}
}
