<?php
$version = new Msd_Version();
$menu = $this->menu($version);
$t = Msd_Language::getInstance()->getTranslator();

?>

<div data-role="page" id="menu_1">
    <?php echo $this->partial('/partials/header.phtml', array(
        'title'    => 'L_HOME',
        'lastPage' => array(
            'title'      => 'L_HOME',
            'url'        => $this->absoluteUrl(array(
                    'controller' => 'index',
                    'action'     => 'index'
                )),
    ))); ?>
    <ul id="carousel_menu" style="display: none;">
    <li>
    <div id="menu_content" data-role="content">
       <div id="menu_icons">
           <table id="menu_table" summary="menu">
               <tr>
                   <td>
                       <div <?php if ($this->controller == 'index')
                        echo 'class="active"';?>>
                            <a href="<?php echo $this->absoluteUrl(array(
                                    'controller' => 'index',
                                    'action'     => 'index'
                                ));?>" data-ajax="false">
                            <?php echo$this->getIcon('Home', $t->_('L_HOME'), 48);?>
                            </a>
                       </div>
                   </td>
                   <td>
                       <div <?php if ($this->controller == 'config')
                        echo 'class="active"';?>>
                            <a href="<?php echo $this->absoluteUrl(array(
                                    'controller' => 'config',
                                    'action'     => 'index'
                                ));?>" data-ajax="false">
                            <?php echo $this->getIcon('Configure', $t->_('L_CONFIG'), 48);?>
                            </a>
                        </div>
                   </td>
                   <td>
                       <div <?php if ($this->controller == 'files' && $this->action == 'restore')
                       echo 'class="active"';?>>
                           <a href="<?php echo $this->absoluteUrl(array(
                                    'controller' => 'files',
                                    'action'     => 'restore'
                               ));?>" data-ajax="false">
                           <?php echo$this->getIcon('RestoreDatabase', $t->_('L_RESTORE'), 48);?>
                           </a>
                       </div>
                   </td>
               </tr>
               <tr>
                   <td>
                       <div <?php if ($this->controller == 'files' && $this->action != 'restore')
                       echo 'class="active"';?>>
                           <a href="<?php echo $this->absoluteUrl(array(
                                    'controller' => 'files',
                                    'action'     => 'index'
                               ));?> data-ajax="false"">
                           <?php echo$this->getIcon('FileManagement', $t->_('L_FILE_MANAGE'), 48);?>
                           </a>
                       </div>
                   </td>
                   <td>
                       <div <?php if ($this->controller == 'sql')
                       echo 'class="active"';?>>
                           <a  href="<?php echo $this->absoluteUrl(
                               array(
                                   'controller' => 'sql',
                                   'action' => 'show.tables'
                               ));?>" data-ajax="false">
                           <?php echo$this->getIcon('SqlBrowser', $t->_('L_SQL_BROWSER'), 48);?>
                           </a>
                       </div>
                   </td>
                   <td>
                       <div <?php if ($this->controller == 'sql.server')
                       echo 'class="active"';?>>
                           <a href="<?php echo $this->absoluteUrl(
                               array(
                                   'controller' => 'sql.server',
                                   'action'     => 'index'
                               ));?>" data-ajax="false">
                           <?php echo$this->getIcon('Server', $t->_('L_SQL_SERVER'), 48);?>
                           </a>
                       </div>
                   </td>
               </tr>
               <tr>
                   <td>
                       <div <?php if ($this->controller == 'log')
                        echo 'class="active"';?>>
                            <a href="<?php echo $this->absoluteUrl(
                                array(
                                    'controller' => 'log',
                                    'action'     => 'index'
                                ));?>" data-ajax="false">
                            <?php echo$this->getIcon('log', $t->_('L_LOG'), 48);?>
                            </a>
                        </div>
                   </td>
                   <td>
                       <?php if (count($this->databases) > 0): ?>
                       <div <?php if ($this->controller == 'dump')
                        echo 'class="active"';?>>
                            <a href="<?php echo $this->absoluteUrl(
                                array(
                                    'controller' => 'dump',
                                    'action'     => 'index'
                                )); ?>" data-ajax="false">
                            <?php echo$this->getIcon('BackupDatabase', $t->_('L_DUMP'), 48);?></a>
                        </div>
                        <?php endif; ?>
                   </td>
                   <td>
                        <div class="active">
                            <a href="http://www.mysqldumper.net/credits/" class="new-window">
                            <?php echo$this->getIcon('Help', $t->_('L_CREDITS'), 48);?>
                            </a>
                         </div>
                   </td>
               </tr>
           </table>
       </div>
    </div>
    </li>
    </li>
    <div id="selectConfig">
        <form action="<?php echo $this->absoluteUrl(array(
                'controller' => 'index',
                'action'     => 'selectdb'
            ));?>"
            method="post" id="formSelectDb">
        <fieldset id="dbSelect"><legend><?php echo$t->_('L_CHOOSE_DB');?>:</legend>
        <div data-role="fieldcontain">
            <input type ="hidden" name="lastController" value="<?php echo $this->controller;?>" />
            <input type ="hidden" name="lastAction" value="<?php echo $this->action;?>" />
            <?php if (count($this->databases) > 0 ) { ?>
                <select name="selectedDb" id="selectedDb" data-native-menu="false" onchange="this.form.submit()">
                <?php
                    foreach ($this->databases as $db) {
                        echo '<option value="'.base64_encode($db).'"';
                        if ($db == $this->config->get('dynamic.dbActual')) {
                            echo ' selected="selected"';
                        }
                        echo '>'.$db.'</option>';
                    }
                ?>
                </select>
            <?php } else {
                echo $t->_('L_NO_DB_FOUND');
            } ?>
        </div>
        </fieldset>
        </form>
        <form action="<?php echo $this->absoluteUrl(
            array(
                    'controller' => 'index',
                    'action'     => 'switchconfig'
            ));?>" method="post">
            <fieldset id="configSelect"><legend><?php echo$t->_('L_CONFIG');?>:</legend>
                <div data-role="fieldcontain">
                <input type ="hidden" name="lastController" value="<?php echo $this->controller;?>" />
                <input type ="hidden" name="lastAction" value="<?php echo $this->action;?>" />
                <select name="selectedConfig" id="selectedConfig" style="width: 157px;" onchange="this.form.submit()">
                <?php
                    $this->configFiles = Msd_File::getConfigNames();
                    foreach ($this->configFiles as $file) {
                        echo "\n" . '<option value="' . base64_encode($file) . '"';
                        if ($this->config->get('dynamic.configFile') == $file) {
                            echo ' selected="selected"';
                        }
                        echo '>'.$this->getConfigTitle($file).'</option>';
                    }
                ?>
                </select>
            </div>
            </fieldset>
        </form>
    </div>
    </li>
    </ul>
    <div data-role="footer" class="ui-bar">
            <a href="<?php echo $this->absoluteUrl(
                array(
                    'controller' => 'index',
                    'action'     => 'logout'
            ));?>"
               data-role="button" data-icon="delete" data-ajax="false" >
                <?php echo $t->_('L_LOGOUT'); ?>
            </a>
    </div>
</div>
    <script type="text/javascript">
        $("#carousel_menu").carousel();
    </script>
