<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
<?
\S::set_session( 'admin', true );
global $db;
ob_start();
?>
<div id="settings-tabs">
  <ul class="resp-tabs-list settings-tabs">
    <li><i class="fa fa-wrench"></i>Ustawienia</li>
    <li><i class="fa fa-file"></i>Zawartość</li>
  </ul>
  <div class="resp-tabs-container settings-tabs">
    <div>
      <?= \Html::input( [
        'label' => 'Autor',
        'name'  => 'author',
        'id'    => 'author',
        'value' => $this -> author['author'],
        'class' => 'require'
       ] );?>
      <?= \Html::input_icon( [
        'label' => 'Zdjęcie',
        'name' => 'image',
        'id' => 'image',
        'value' => $this -> author['image'],
        'icon_content' => 'przeglądaj',
        'icon_js' => "window.open ( '/libraries/filemanager-9.14.1/dialog.php?type=1&popup=1&field_id=image&akey=c3cb2537d25c0efc9e573d059d79c3b8', 'mywindow', 'location=1,status=1,scrollbars=1, width=1100,height=700');"
      ] );?>
    </div>
    <div>
      <div id="languages-main">
        <ul class="resp-tabs-list languages-main">
          <? 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::textarea( [
                  'label' => 'Opis',
                  'name' => 'description',
                  'id' => 'description_' . $lg['id'],
                  'value' => $this -> author['languages'][$lg['id']]['description']
                ] );?>
                <script type="text/javascript">
                  $(function () {
                    $('#description_<?= $lg['id'];?>').ckeditor({
                      toolbar: 'MyTool',
                      height: '300'
                    });
                  });
                </script>
              </div>
            <? endif;?>
          <? endforeach; endif;?>
        </div>
        <div class="clear"></div>
      </div>
    </div>
  </div>
</div>
<?
$out = ob_get_clean();

$grid = new \gridEdit;
$grid -> id = 'author-edit';
$grid -> gdb_opt = $gdb;
$grid -> include_plugins = true;
$grid -> title = 'Edycja autora';
$grid -> fields = [
  [
    'db' => 'id',
    'type' => 'hidden',
    'value' => $this -> author['id']
  ]
];
$grid -> external_code = $out;
$grid -> actions = [
  'save'   => [ 'url' => '/admin/authors/save/', 'back_url' => '/admin/authors/view_list/' ],
  'cancel' => [ 'url' => '/admin/authors/view_list/' ]
];
$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>