<?php

/**
 * OntoWiki layout template
 *
 * @author  Norman Heino <norman.heino@gmail.com>
 * @author  Michael Haschke
 * @version $Id: layout.phtml 4308 2009-10-14 15:13:51Z jonas.brekle@gmail.com $
 */

?>
<?php echo $this->doctype('XHTML1_STRICT') ?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head xmlns:update="http://ns.aksw.org/update/">
    <?php echo $this->headTitle() ?>
    <?php echo $this->headMeta() ?>
    <?php echo $this->headLink() ?>

    <?php echo $this->partial('partials/meta.phtml') ?>

    <link rel="shortcut icon" type="image/x-icon" href="<?php echo $this->staticUrlBase;?>favicon.png" />

    <?php if ($this->has('jsonVars')): ?>
        <script type="text/javascript">
            <?php echo $this->jsonVars ?>
        </script>
    <?php endif; ?>

    <?php if ($this->has('metaDescription')){ ?>
        <meta name="Description" content="<?php echo $this->metaDescription ?>" />
    <?php }  ?>
    <?php if ($this->has('metaKeywords')){ ?>
        <meta name="Keywords" content="<?php echo $this->metaKeywords ?>" />
    <?php }  ?>

    <!-- ontowiki stylesheets -->
    <link rel="stylesheet" href="<?php echo $this->themeUrlBase ?>styles/default.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="<?php echo $this->themeUrlBase ?>styles/clickmenu.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="<?php echo $this->themeUrlBase ?>styles/jquery-ui.css" type="text/css" media="screen" />

    <!-- additional ontowiki stylesheets -->
    <?php foreach($this->themeExtraStyles as $stylesheet_extra): ?>
        <link rel="stylesheet" href="<?php echo $this->themeUrlBase ?>../<?php echo trim($stylesheet_extra); ?>/styles/default.css" type="text/css" media="screen" />
    <?php endforeach; ?>

    <?php if (defined('_OWDEBUG')): ?>
    <!-- developer styles, e.g. for deprecated and legacy gui elements -->
    <link rel="stylesheet" href="<?php echo $this->themeUrlBase ?>styles/default.dev.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="<?php echo $this->themeUrlBase ?>styles/deprecated.dev.css" type="text/css" media="screen" />
    <?php endif; ?>

    <!-- dynamic styles -->
    <?php echo $this->headStyle() ?>

    <!-- jQuery -->
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/libraries/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/libraries/jquery-migrate-1.3.0.js"></script>
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/libraries/jquery-ui-1.8.22.js"></script>

    <!-- included js libraries -->
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/libraries/jquery.json.js"></script>
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/libraries/jquery.livequery.js"></script>
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/libraries/jquery.clickmenu.js"></script>
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/libraries/jquery.simplemodal.js"></script>
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/libraries/jquery.tablesorter.js"></script>
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/libraries/jquery.rdfquery.rdfa-1.0.js"></script>

    <!-- ontowiki js -->
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/main.js"></script>
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/support.js"></script>
    <script type="text/javascript" src="<?php echo $this->themeUrlBase ?>scripts/jquery.ontowiki.js"></script>

    <!-- dynamic js -->
    <?php echo $this->headScript() ?>

</head>

<body class="javascript-off" xmlns:update="http://ns.aksw.org/update/">

    <script type="text/javascript">
        // get body element
        var body = document.body;
        var bodyClass = body.className;
        // set javascript = on
        bodyClass = bodyClass.replace(/javascript-off/g, "javascript-on");
        // set application in processing state
        bodyClass = bodyClass + " is-processing";
        // process changes
        body.setAttribute("class", bodyClass, 0);
    </script>

    <?php echo $this->inlineScript() ?>

    <div class="section-mainwindows <?php echo $this->placeholder('main.window.additionalclasses') ?>">
        <div class="window<?php echo (OntoWiki::getInstance()->getNavigation()->isDisabled() ? '' : ' tabbed') ?>">
            <?php
                /**
                 * @trigger onDisplayMainWindowTitle
                 */
                $event = new Erfurt_Event('onDisplayMainWindowTitle');
                $event->setDefault($this->placeholder('main.window.title'));
                $title = $event->trigger();
            ?>
            <h1 class="title"><?php echo $title ?></h1>
            <div class="slidehelper">
                <?php if (isset($this->preTabsContent)): ?>
                    <div id="pre_tabs_content">
                        <?php echo $this->preTabsContent; ?>
                    </div>
                <?php endif; ?>
                <?php echo $this->partial('partials/navigation.phtml', array('navigation' => OntoWiki::getInstance ()->getNavigation()->toArray())) ?>

                <?php if ($this->has('main.window.innerwindows')): ?>
                    <div class="content has-innerwindows">
                        <?php if ($this->has('formActionUrl') and $this->has('formMethod')): ?>
                            <form action="<?php echo $this->formActionUrl ?>"
                                  method="<?php echo $this->formMethod ?>"
                                  <?php if ($this->has('formName')) echo 'name="' . $this->formName . '"' ?>
                                  <?php if ($this->has('formId')) echo 'id="' . $this->formId . '"' ?>
                                  <?php if ($this->has('formEncoding')) echo 'enctype="' . $this->formEncoding . '"' ?>
                                  <?php if ($this->has('formClass')) echo 'class="' . $this->formClass . '"' ?>>
                                  <?php if ($this->has('redirectUrl')): ?>
                                      <input type="hidden" name="redirect" value="<?php echo $this->redirectUrl ?>"/>
                                  <?php endif; ?>
                        <?php endif;?>

                        <?php if ($this->has('main.window.toolbar')): ?>
                            <div class="messagebox"><?php echo $this->placeholder('main.window.toolbar') ?></div>
                        <?php endif; ?>

                        <div class="innercontent">
                            <?php foreach (OntoWiki::getInstance()->drawMessages() as $message): ?>
                                <?php echo $this->partial('partials/message.phtml', array('message' => $message)) ?>
                            <?php endforeach; ?>

                            <?php echo $this->layout()->content ?>
                        </div><!-- .innercontent -->

                        <?php if ($this->has('formActionUrl')): ?>
                            </form>
                        <?php endif;?>

                        <div class="innerwindows">
                            <?php echo $this->placeholder('main.window.innerwindows') ?>
                        </div><!-- .innerwindows -->

                    </div><!-- .content .has-innerwindows -->
                <?php else: ?>
                    <div class="content">
                        <?php if ($this->has('formActionUrl') and $this->has('formMethod')): ?>
                            <form action="<?php echo $this->formActionUrl ?>"
                                  method="<?php echo $this->formMethod ?>"
                                  <?php if ($this->has('formName')) echo 'name="' . $this->formName . '"' ?>
                                  <?php if ($this->has('formEncoding')) echo 'enctype="' . $this->formEncoding . '"' ?>
                                  <?php if ($this->has('formClass')) echo 'class="' . $this->formClass . '"' ?>>
                        <?php endif;?>

                        <?php if ($this->has('main.window.toolbar')): ?>
                            <div class="messagebox"><?php echo $this->placeholder('main.window.toolbar') ?></div>
                        <?php endif; ?>

                        <?php foreach (OntoWiki::getInstance()->drawMessages() as $message): ?>
                            <?php echo $this->partial('partials/message.phtml', array('message' => $message)) ?>
                        <?php endforeach; ?>

                        <?php echo $this->layout()->content ?>
                        <?php if ($this->has('formActionUrl')): ?>
                            </form>
                        <?php endif;?>
                    </div><!-- .content -->
                <?php endif; ?>

                <?php if ($this->has('main.window.menu')): ?>
                    <ul class="menu">
                        <?php echo $this->partial('partials/menu.phtml', array('menu' => $this->placeholder('main.window.menu')->getValue())) ?>
                    </ul>
                <?php endif; ?>

                <?php echo $this->partial('partials/statusbar.phtml', array('statusbar' => $this->placeholder('main.window.statusbar'))) ?>
            </div><!-- .slidehelper -->
        </div><!-- .window -->
    </div><!-- .section-mainwindows -->

    <div class="section-sidewindows">
        <?php echo $this->placeholder('main.sidewindows') ?>
    </div><!-- .section-sidewindows -->
    <?php if (defined('REQUEST_START')) {
        $queryCount = OntoWiki::getInstance()->erfurt->getStore()->getQueryCount();
        $time       = (microtime(true) - REQUEST_START) * 1000;
    ?><!-- <?php echo sprintf($this->_('Rendered in %1$d ms using %2$d SPARQL queries.'), $time, $queryCount) ?> --><?php } ?>
</body>
</html>
