<!DOCTYPE html>
<html lang="en">
<head>
  <base href="<?=BASE_URL."cms/"?>" />
  <meta charset="utf-8">
  <?php echo $this->headTitle() ?>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="">
  <meta name="author" content="">
  <script type="text/javascript">
    var BASE_URL = '<?=BASE_URL?>';
  </script>

  <!-- Le styles -->
  <?php echo $this->headLink() ?>

  <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
  <!--[if lt IE 9]>
  <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  <![endif]-->

  <?php echo $this->headMeta() ?>
  <script type="text/javascript" src="js/jquery.js"></script>
  <script src="chosen/chosen.jquery.js" type="text/javascript"></script>

  <link rel="stylesheet" href="chosen/chosen.css">
</head>

<body>

  <?php 

  if (empty($this->framed) || !$this->framed==1) {
    ?>
    <script type="text/javascript">
      function toggleMenu(){
        $('.navbar.navbar-inverse.navbar-fixed-top').toggleClass('closed');
        $('.togglemenu').toggleClass('closed');
      }
    </script>
    <div class="navbar navbar-inverse navbar-fixed-top">
      <div class="navbar-inner">
        <div class="container-fluid myBar">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="brand" href="<?=$this->linkTo("index");?>">CMS</a>
          <a class="togglemenu" href="javascript:toggleMenu();">
            Menu
          </a>
          <!-- le menu -->
          <div class="nav-collapse">
            <?php $_controller = Zend_Controller_Front::getInstance()->getRequest()->getControllerName();?>
            <ul class="nav">
              <?php
              $model = new Model_Cms_Systems();
              $menuArray = array();
              foreach($model->fetchAllOrder() as $item)
              {
                $aqui = false;
                if($item->id != 2 && $item->getTotalItems($this->loggedUser()->usergroup_id) > 0 && $item->online == '1')
                {
                  foreach($item->getItems($this->loggedUser()->usergroup_id) as $sub)
                  {
                //if( (($this->loggedUser()->usergroup_id == 3 && $sub->status_id == 3) || ($this->loggedUser()->usergroup_id < 3)) && $sub->hidden == 0  && $sub->online == '1')
                    if($_controller == $sub->folder)
                    {
                      $aqui = true;
                    }
                  }
                  ?>
                  <li class="dropdown <?= ($aqui? 'active': ''); ?>">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                      <?= $item->page_cat; ?>
                      <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu">
                      <?php
                      foreach($item->getItems($this->loggedUser()->usergroup_id) as $sub)
                      {
                        if( (($this->loggedUser()->usergroup_id == 3 && $sub->status_id == 3) || ($this->loggedUser()->usergroup_id < 3)) && $sub->hidden == 0  && $sub->online == '1')
                        {
                          echo '<li class="'. (($_controller == $sub->folder)? 'active': '') .'"><a href="'. $this->urlTo("cms/".$sub->folder).'"><span>'.$sub->title.'</span></a></li>';
                        }
                      }
                      ?>
                    </ul>
                  </li>
                  <?php
                }
            // barra do menu
                if($item->id == 2 && $item->getTotalItems($this->loggedUser()->usergroup_id) > 0)
                {
                  foreach($item->getItems($this->loggedUser()->usergroup_id) as $sub)
                  {
                    if( (($this->loggedUser()->usergroup_id == 3 && $sub->status_id == 3) || ($this->loggedUser()->usergroup_id < 3)) && $sub->hidden == 0  && $sub->online == '1')
                    {
                      echo '<li class="'. (($_controller == $sub->folder)? 'active': '') .'"><a href="'. $this->urlTo("cms/".$sub->folder).'"><span>'.$sub->title.'</span></a></li>';
                    }
                  }
                }
              }
              ?>
            </ul>

            <ul class="nav pull-right">
              <?php if($this->loggedUser()->usergroup_id <= 2): ?>
                <li class="dropdown">
                  <a href="#" class="dropdown-toggle settings" data-toggle="dropdown">
                    Reports <b class="caret"></b>
                  </a>
                  <ul class="dropdown-menu">
                    <!--              <li>-->
                    <!--                <a class="open" href="--><?//=$this->linkTo("cms_stats", "list");?><!--">Statistics</a>-->
                    <!--              </li>-->
                    <li>
                      <a class="open" href="<?=$this->linkTo("cms_log", "list");?>">Logs</a>
                    </li>
                  </ul>
                </li>

                <li class="dropdown">
                  <a href="#" class="dropdown-toggle settings" data-toggle="dropdown">
                    Settings <b class="caret"></b>
                  </a>
                  <ul class="dropdown-menu">
                    <li>
                      <a class="open" href="<?=$this->linkTo("cms_setting", "edit");?>">Site Settings</a>
                    </li>
                    <li>
                      <a class="open" href="<?=$this->linkTo("cms_user", "list");?>">User Management</a>
                    </li>
                  </ul>
                </li>
              <?php endif; ?>
              <?php if($this->loggedUser()->usergroup_id == 1): ?>
                <li>
                  <a class="open" href="<?=$this->linkTo("cms_system", "list");?>">System</a>
                </li>
              <?php endif; ?>
              <li class="dropdown">
                <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                  <strong><?=$this->loggedUser()->name;?></strong> <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                  <li>
                    <a class="open" href="<?=$this->linkTo("cms_user", "profile");?>">Profile</a>
                  </li>
                  <li class="divider"></li>
                  <li>
                    <a class="open" href="<?=$this->linkTo("cms_login", "logout");?>">Sign Out</a>
                  </li>
                </ul>
              </li>

              <li>
                <a class="open visitsite" href="<?=$this->urlTo("");?>">Visit site »</a>
              </li>
            </ul>

          </div><!--/.nav-collapse -->
        </div>
      </div>
    </div>
    <?php 
  }
  ?>

  <div class="modal hide fade" id="tagModal" tabindex="-1" role="dialog" aria-labelledby="tagModalLabel" aria-hidden="true">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h3>Nova tag</h3>
    </div>
    <div class="modal-body">
      <label>Nome</label>
      <input type="text" name="page[nome]" class="modalinput"  id="nometag" placeholder="Digite o nome da tag">
    </div>
    <div class="modal-footer">
      <a href="#"  data-dismiss="modal" class="btn">Cancelar</a>
      <a href="javascript:addTag();" class="btn btn-primary">Adicionar </a>
    </div>
  </div>
  <div class="modal hide fade" id="autorModal" tabindex="-1" role="dialog" aria-labelledby="autorModalLabel" aria-hidden="true">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
      <h3>Novo autor</h3>
    </div>
    <div class="modal-body">
      <label>Nome</label>
      <input type="text" name="page[nome]" class="modalinput"  id="nomeAutor" placeholder="Digite o nome do autor">
    </div>
    <div class="modal-footer">
      <a href="#"  data-dismiss="modal" class="btn">Cancelar</a>
      <a href="javascript:addAutor();" class="btn btn-primary">Adicionar </a>
    </div>
  </div>

  <div class="container-fluid" id="layout">
    <?php $this->messenger(); ?>
    <?php echo $this->layout()->content ?>

    <hr class="clearfix" style="display: none;">
    <footer style="display: none;">
      <p>&copy; l.on Digital <?=date("Y");?> - <a href="mailto:chao@londigital.com.br">Contate-nos</a>
        <?php
        if($this->loggedUser()->usergroup_id == 3):
          ?>
        <span class="pull-right">v3.2.1beta</span>
      </p>
      <?php
      endif;
      ?>
    </footer>

  </div><!--/.fluid-container-->

<!-- Le javascript
  ================================================== -->
  <!-- Placed at the end of the document so the pages load faster -->
  <script type="text/javascript">
    $(document).ready(function(){
      $('#tagModal').on('shown.bs.modal', function () {
        $('#nometag').focus();
      })
    });
  </script>

  <?php echo $this->headStyle() ?>
  <?php echo $this->headScript() ?>

</body>
</html>