<?php
    class ThemeMystica extends MTheme
    {
        function __construct()
        {
            parent::__construct('mystica');
        }

        function init()
        {
            $ui = $this->manager->GetUI();
/*
            $logo_siga = $ui->getImageTheme($this->id, $this->manager->getConf('theme.logo'));
            $logo_ufjf = $ui->getImageTheme($this->id, 'logo_ufjf.gif');
            // top
            $aTop = array(
                new MTextHeader('', '1', $this->manager->getConf('theme.company')),
                new MTextHeader('', '2', $this->manager->getConf('theme.system'))
            );
            $img = new MImageLink('', 'Home', $this->manager->getConf('home.url'), $logo_siga);
            $img->image->addAttribute('width', '62px');
            $img->image->addAttribute('height', '40px');
            $img1 = new MImageLink('', 'Home', "http://www.ufjf.br", $logo_ufjf);
            $img1->image->addAttribute('width', '62px');
            $img1->image->addAttribute('height', '40px');
            $top = array(
                new MDiv('', $img, 'logo'),
                new MDiv('', $img1, 'text' )
            );
*/
            $logo = $ui->getImageTheme($this->id, $this->manager->getConf('theme.logo'));
            $top = new MBoxTitle('','&nbsp;'.$this->manager->getConf('theme.system'));
            $top->setIcon($logo);
            $this->setElement('top', $top, 'm-container-top');
            // navigation
            $this->setElement('navigation', new MNavigationBar(), 'm-container-topmenu');
        }

        function generate()
        {
            $method = "generate" . $this->layout;
            return $this->$method();
        }

        function generateDefault()
        {
            // bottom
            $this->setElement('bottom', new MStatusBar(), 'm-container-bottom');
            // module
            $this->setElementId('module', 'm-container-module');
            // menus
            $optionMenu = $this->manager->getConf('options.mainmenu');
            $idMenu = ($optionMenu == 2) ? 'm-container-dhtmlmenu' : 'm-container-menu';
            $this->setElementId('menus', $idMenu);
            // content
            $idContent = ($optionMenu == 2) ? 'm-container-content-full' : 'm-container-content';
            $this->SetElementId('content', $idContent);

            // generating html code

            $html = $this->GenerateElement('top');

            if ($this->hasMenuOptions())
            {
                $html .= $this->generateElement('menus');
            }

            if ($this->getElement('module') != NULL)
            {
                $html .= $this->generateElement('module');
            }

            if ($this->GetElement('navigation')->hasOptions())
            {
                $html .= $this->generateElement('navigation');
            }

            $html .= $this->generateElement('content');
            $html .= $this->generateElement('bottom');

            return $this->painter->div(new MDiv('m-container', $html));
        }

        function generateLookup()
        {
            // only 'content' element
            $html = $this->generateElement('content');
            $div = new MDiv('m-container', $html);
            $div->addStyle('width', '100%');
            return $this->painter->generateToString($div);
        }

        function generateHtmlArea()
        {
            // module
            $this->setElementId('module', 'm-container-module');
            // content
            $this->setElementId('content', 'm-htmlarea');
            // bottom
            $this->setElement('bottom', new MStatusBar(), 'm-container-bottom');

            $html = $this->generateElement('top');

            if ($this->getElement('module') != NULL)
            {
                $html .= $this->generateElement('module');
            }

            if ($this->getElement('navigation')->hasOptions())
            {
                $html .= $this->generateElement('navigation');
            }

            $html .= $this->generateElement('content');
            $html .= $this->generateElement('bottom');
            return $this->painter->div(new MDiv('m-container', $html));
        }

        function generatePopup()
        {
            $page = $this->manager->getPage();
//            $page->addScript('dif/dragiframe.js');
//            $page->onLoad("addHandle(document.getElementsByTagName('body').item(0), window);"); 
            // only 'content' element
            $this->SetElementId('content', 'm-container-content-popup');
            $html = $this->generateElement('content');
            $divContainer = new MDiv('', $html,  'm-container');
            $divContainer->addStyle('width', '100%');
            return $this->painter->generateToString($divContainer);
        }

        function generatePrint()
        {
            $this->generateDefault();
        }

        function generateDOMPdf()
        {
            // only 'content' element
            $html = $this->generateElement('content');
            $div = new MDiv('m-container', $html);
            $div->addStyle('width', '100%');
            return $this->painter->generateToString($div);
        }

    }
?>
