<?php
//@*--


class Theme_Designer_Model_Theme extends Varien_Object
{
    public function getPublishUrl() {
        return $this->getUrl('publish');
    }

    public function getPreviewUrl() {
        $previewLink = Mage::helper('core/url')->addRequestParam(
            Mage::getModel("catalog/category")->load(15)->getUrl(),
            array('template' => $this->getName())
        );
        return $previewLink;
    }

    public function getRemoveUrl() {
        return $this->getUrl('remove');
    }

    public function getEditUrl() {
        return $this->getUrl();
    }

    public function getSettingsUrl() {
        return $this->getUrl('index', 'settings');
    }

    public function isActive() {
        $theme = Mage::getConfig()->getNode('default/design/theme/default');
        return $theme && Mage::getConfig()->getNode('default/design/theme/default')->asArray() == $this->getName();
    }

    public function getUrl($action = 'index', $controller = 'theme') {
        $params = array('theme' => $this->getName());
        $domain = Theme_Designer_Model_Export_Project::open($this->getName())->getDomain();
        if ($domain && $action === 'index' && $controller === 'theme') {
            $params['domain'] = $domain;
        }
        return Mage::helper('core/url')->addRequestParam(
            Mage::helper('adminhtml')->getUrl('designer/adminhtml_' . $controller . '/' . $action),
            $params
        );
    }
}

//--*@