<?php

class CWidgetEcommerce extends CWidgetModule
{
	public $product_page;
	public $productdetail_page;
	public $cart_page;
	public $checkout_page;
	public $cart;
	public $currencies;
	public $context;
	public $order;
	public $previewMode = false;
	public function init()
	{
		parent::init();
		try
		{
			Yii::app()->ecommerce->init();
		}
		catch(Exception $e)
		{
			$this->addError($e->getMessage());
		}
		
		$this->product_page = Yii::app()->ecommerce->getProductPage();
		$this->productdetail_page = Yii::app()->ecommerce->getProductDetailPage();
		$this->cart_page = Yii::app()->ecommerce->getCartPage();
		$this->checkout_page = Yii::app()->ecommerce->getCheckoutPage();
		$this->context = Yii::app()->context;
		$this->cart = Yii::app()->ecommerce->cart;
		$this->currencies = Yii::app()->ecommerce->currency;
		$this->previewMode = getIndex($this->data, 'previewMode', false, 'boolean');
		
	}
	
	protected function createUrl($product)
	{
		return Yii::app()->createUrl($this->product_page, array('id' => $product));
		$rewrite = new Ecommerce_Rewrite;
		return Yii::app()->ecommerce->urlRewrite->createUrl($news);

	}
	protected function createCategoryUrl($id)
	{
		$rewrite = new Ecommerce_Rewrite;
		$c = new News_Category($id);
		return $rewrite->createPermanentUrl('category', array('category'=>$c->getUniqueName() ));

	}
	protected function createTagUrl($tag)
	{
		$rewrite = new Ecommerce_Rewrite;
		return $rewrite->createPermanentUrl('tag', array('tag'=>$tag ));

	}
	protected function createMonthUrl($month, $year)
	{
		$rewrite = new Ecommerce_Rewrite;
		return $rewrite->createPermanentUrl('month', array('month'=>$month, 'year'=>$year ));
	}
	
	
}