<?php
//@*--


class Theme_Designer_Adminhtml_SettingsController extends Theme_Designer_Controller_AdminAction
{
    public function _construct() {
        parent::_construct();
    }

    public function indexAction() {
        $this->loadLayout();
        if (!Theme_Designer_Model_Export_Project::exists($this->currentTheme)) {
            $this->_addContent($this->getLayout()
                 ->createBlock('designer/adminhtml_designer')
                 ->setTemplate('designer/noroute.phtml'));
        } else {
            Mage::register('designer_settings_theme', $this->currentTheme);
            $this->_addContent($this->getLayout()->createBlock('designer/adminhtml_settings_edit'))
                 ->_addLeft($this->getLayout()->createBlock('designer/adminhtml_settings_edit_tabs'));
        }
        $this->renderLayout();
    }

    public function saveAction() {
        if (($data = $this->getRequest()->getPost()) && Theme_Designer_Model_Export_Project::exists($this->currentTheme)) {
            $menu = Mage::getSingleton('Theme_Designer_Model_Settings_Menu');
            $menu->saveOptions($this->currentTheme, $data);

            $logo = Mage::getSingleton('Theme_Designer_Model_Settings_Logo');
            $logo->saveOptions($this->currentTheme, $data);
        }
        $this->adminRedirect('designer/adminhtml_settings/index', array('theme' => $this->currentTheme));
    }
}

//--*@