<?php

// base widget for all cms module
class CWidgetCMS extends CWidgetModule
{
    public $news_page;
    public $newsdetail_page;
    public $cart_page;
    public $checkout_page;
    public $cart;
    public $currencies;
    public $context;
    public $order;
    public $previewMode = false;
    public function init()
    {
        $this->news_page = strtolower(Yii::app()->cms->getBlogPage());
        $this->newsdetail_page = Yii::app()->cms->getBlogDetailPage();
        $this->context = Yii::app()->context;
        $this->previewMode = getIndex($this->data, 'previewMode', false, 'boolean');
        parent::init();
    }

    protected function createUrl($news)
    {
        return Yii::app()->createUrl($this->news_page, array('id' => $news));
    }
    protected function createCategoryUrl($id)
    {
        return Yii::app()->createAbsoluteUrl($this->news_page, array('category' => $id));
    }
    protected function createTagUrl($tag)
    {
        $rewrite = Yii::app()->cms->urlRewrite;

        return $rewrite->createPermanentUrl('tag', array('tag' => $tag));
    }
    protected function createMonthUrl($month, $year)
    {
        $rewrite = Yii::app()->cms->urlRewrite;

        return $rewrite->createPermanentUrl('month', array('month' => $month, 'year' => $year));
    }
}
