<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
<?
global $db;

ob_start();
?>
  <div id="settings-tabs">
    <ul class="resp-tabs-list settings-tabs">
      <li><i class="fa fa-file"></i>Treść</li>
      <li><i class="fa fa-wrench"></i>Ustawienia</li>
    </ul>
    <div class="resp-tabs-container settings-tabs">
      <div>
        <div id="languages-main">
          <ul class="resp-tabs-list languages-main htabs">
            <? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
              <? if ( $lg['status'] ):?>
                <li><?= $lg['name'];?></a></li>
              <? endif;?>
            <? endforeach; endif;?>
          </ul>
          <div class="resp-tabs-container languages-main">
            <? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
              <? if ( $lg['status'] ):?>
                <div>
                  <?= \Html::input(
                              array(
                                'label'   => 'Tytuł',
                                'name'    => 'title[' . $lg['id'] . ']',
                                'id'      => 'title_' . $lg['id'],
                                'value'   => $this -> container['languages'][ $lg['id'] ]['title'],
                                'inline'  => true
                              )
                          );?>
                  <?= \Html::textarea(
                              array(
                                'label'   => 'Treść',
                                'name'    => 'text[' . $lg['id'] . ']',
                                'id'      => 'text_' . $lg['id'],
                                'value'   => $this -> container['languages'][ $lg['id'] ]['text'],
                                'inline'  => true
                              )
                          );?>
                  <script type="text/javascript">
                    $( function() {
                      $( '#text_<?= $lg['id'];?>' ).ckeditor( {
                        toolbar : 'MyToolbar',
                        height:'300'
                      });
                    });
                  </script>
                </div>
              <? endif;?>
            <? endforeach; endif;?>
          </div>
          <div class="clear"></div>
        </div>
      </div>
      <div>
        <?= \Html::input_switch(
                    array(
                      'label'   => 'Aktywny',
                      'name'    => 'status',
                      'checked' => $this -> container['status'] == 1 or !$this -> container['id'] ? true : false
                    )
                );?>
        <?= \Html::input_switch(
                    array(
                      'label'   => 'Pokaż tytuł',
                      'name'    => 'show_title',
                      'checked' => $this -> container['show_title'] == 1 ? true : false
                    )
                );?>
      </div>
    </div>
  </div>
<?
$out = ob_get_clean();

$grid = new \gridEdit;
$grid -> id               = 'container-edit';
$grid -> gdb_opt          = $gdb;
$grid -> include_plugins  = true;
$grid -> title            = 'Edycja kontenera statycznego';
$grid -> fields           = [
                              [
                                'db' => 'id',
                                'type' => 'hidden',
                                'value' => $this -> container['id']
                              ]
                            ];
$grid -> actions          = [
                              'save' => [ 'url' => '/admin/scontainers/container_save/', 'back_url' => '/admin/scontainers/view_list/' ],
                              'cancel' => [ 'url' => '/admin/scontainers/view_list/' ]
                            ];
$grid -> external_code    = $out;
$grid -> persist_edit     = true;
$grid -> id_param         = 'id';

echo $grid -> draw();
?>
<script type="text/javascript">
  $( function()
  {
    disable_menu();

    $( '#settings-tabs' ).easyResponsiveTabs({
      width: 'auto',
      fit: true,
      tabidentify: 'settings-tabs',
      type: 'vertical'
    });

    $( '#languages-main' ).easyResponsiveTabs({
      width: 'auto',
      fit: true,
      tabidentify: 'languages-main'
    });

  });
</script>
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>