<?
/* 2011-09-26 - dodanie typu strony LINK */

global $lang;
?>


<fieldset>
  <script>
    $(document).ready(function() {
      <?
      if ( $this -> _rw == 'add' )
      {
        ?>
          $("#id_page_type").val( '2' );
        <?
      }
      ?>
      $("#tabs").tabs();
      var type = $("#id_page_type").val();
      if ( type == 5 || type == 6 || type == 7 || type == 8 || type == 9 || type == 10 || type == 11 )
      {
        $("#tr_article_number").css('display','none');
        $("#tr_id_sort_type").css('display','none');
        if ( type == 8 ) {
          $("#tr_show_title").css('display','none');
          $("#tr_link").css('display','table-row');
        }
      }
    });

    function changePageType()
    {
      var type = $("#id_page_type").val();
      if ( type == 5 || type == 6 || type == 7 || type == 8 || type == 9 || type == 10 || type == 11 )
      {
        $("#tr_article_number").css('display','none');
        $("#tr_id_sort_type").css('display','none');
        if ( type == 8 ) {
          $("#tr_show_title").css('display','none');
          $("#tr_link").css('display','table-row');
        } else {
          $("#tr_link").css('display','none');
        }
      }
      else
      {
        $("#tr_article_number").css('display','table-row');
        $("#tr_id_sort_type").css('display','table-row');
        $("#tr_show_title").css('display','table-row');
        $("#tr_link").css('display','none');
      }
    }
  </script>

  <form method='POST' id='formularz' action='index.php'>
    <?
    if ( $this -> _rw == 'add' )
    {
      ?>
      <input type='hidden' name='rw' value='add_new'>
      <input type='hidden' name='<?=base64_encode("time");?>' value='<?=base64_encode(date("Y-m-d H:i:s"));?>'>
      <?
    }
    if ( $this -> _rw == 'edit' )
    {
      ?>
      <input type='hidden' name='rw' value='save'>
      <input type='hidden' name='id' value='<?=$this -> _id;?>'>
      <?
    }
    ?>
    <input type='hidden' name='o' value='<?=$this -> _order;?>'>
  <div id="tabs">
    <ul>
      <?
      if ( is_array( $this -> _language ) ) foreach ( $this -> _language as $lg )
      {
        ?>
        <li>
          <a href="#lang_<?=$lg['id'];?>">
            <span><?=$lg['name'];?></span>
          </a>
        </li>
        <?
      }
      ?>
    </ul>
    <?
    if ( is_array( $this -> _language ) ) foreach ( $this -> _language as $lg )
    {
      ?>
      <div id="lang_<?=$lg['id'];?>">
        
        <div class="edit_line">
          <label><?=ucfirst( $lang -> getTrans( 'T_TYTUL' ) );?>:</label>
          <div class="input">
            <input type='text' name='title_<?=$lg['id'];?>' value='<? if ( isset( $lg['title'] ) ) echo $this -> secureHTML( $lg['title'] );?>'>
          </div>
        </div>
        
        <div class="edit_line">
          <label><?=ucfirst( $lang -> getTrans( 'T_LINK_SEO' ) );?>:</label>
          <div class="input">
            <input type='text' name='seo_link_<?=$lg['id'];?>' value='<? if ( isset( $lg['seo_link'] ) ) echo $this -> secureHTML( $lg['seo_link'] );?>'>
          </div>
        </div>

        <div class="edit_line">
          <label><?=ucfirst( $lang -> getTrans( 'T_META_OPIS' ) );?>:</label>
          <div class="input">
            <textarea name='meta_description_<?=$lg['id'];?>' cols='60' rows='5'><? if ( isset( $lg['meta_description'] ) ) echo $this -> secureHTML( $lg['meta_description'] );?></textarea>
          </div>
        </div>

        <div class="edit_line">
          <label><?=ucfirst( $lang -> getTrans( 'T_META_SLOWA_KLUCZOWE' ) );?>:</label>
          <div class="input">
            <textarea name='meta_keywords_<?=$lg['id'];?>' cols='60' rows='5'><? if ( isset( $lg['meta_keywords'] ) ) echo $this -> secureHTML( $lg['meta_keywords'] );?></textarea>
          </div>
        </div>
      </div>
      <?
    }
    ?>
  </div>
  <div>
    <div class="edit_line">
      <label><?=ucfirst( $lang -> getTrans( 'T_MENU' ) );?>:</label>
      <div class="input">
        <select name='menu'>
          <?
            if ( is_array( $this -> _menu ) ) foreach ( $this -> _menu as $menu )
            {
              ?>
              <option value='<?=$menu['id'];?>' <? if ( $this -> _menu_id == $menu['id'] || ( $this -> _rw == 'add' && $this -> _menu_id == $menu['id'] ) ) echo "selected='selected'";?>>
                <?=$menu['name'];?>
              </option>
              <?
            }
          ?>
        </select>
      </div>
    </div>

    <div class="edit_line">
      <label><?=ucfirst( $lang -> getTrans( 'T_TYP_STRONY' ) );?>:</label>
      <div class="input">
        <select name='page_type_id' id='id_page_type' onChange='changePageType()'>
          <?
            if ( is_array ( $this -> _pages ) ) foreach ( $this -> _pages as $page )
            {
              ?>
              <option value='<?=$page['id'];?>' <? if ( isset( $this -> _page_type_id ) && $this -> _page_type_id == $page['id'] ) echo "selected='selected'"; ?>>
                <?=$page['name'];?>
              </option>
              <?
            }
          ?>
        </select>
      </div>
    </div>

    <div class="edit_line">
      <label><?=ucfirst( $lang -> getTrans( 'T_KOLEJNOSC_WYSWIETLANIA' ) );?>:</label>
      <div class="input">
        <select name='sort_type'>
          <?
            if ( is_array( $this -> _sort ) ) foreach ( $this -> _sort as $sort )
            {
              ?>
              <option value='<?=$sort['id'];?>' <? if ( isset( $this -> _sort_type ) && $this -> _sort_type == $sort['id'] ) echo "selected='selected'";?>>
                <?=$sort['name'];?>
              </option>
              <?
            }
          ?>
        </select>
      </div>
    </div>

    <div class="edit_line">
      <label><?=ucfirst( $lang -> getTrans( 'T_POKAZ_TYTUL' ) );?>:</label>
      <div class="input">
        <input type="radio" name='show_title' id="show_title_0" value="0" <? if ( !isset( $this -> _show_title ) || $this -> _show_title == 0 ) echo "checked='checked'";?>>
        <?=$lang -> getTrans( 'T_NIE' );?>
        <input type="radio" name="show_title" value="1" <? if ( isset( $this -> _show_title ) && $this -> _show_title == 1 ) echo "checked='checked'";?>>
        <?=$lang -> getTrans( 'T_TAK' );?>
      </div>
    </div>

    <div class="edit_line">
      <label><?=ucfirst( $lang -> getTrans( 'T_LICZBA_ARTYKULOW' ) );?>:</label>
      <div class="input">
        <input type='text' name='article_number' value='<? if ( isset( $this -> _article_number ) ) echo $this -> _article_number; else echo '1';?>'>
      </div>
    </div>

    <div class="edit_line">
      <label><?=ucfirst( $lang -> getTrans( 'T_AKTYWNA' ) );?>:</label>
      <div class="input">
        <input type="radio" name="enabled" id="enabled_0" value="0" <? if ( !isset( $this -> _enabled ) || $this -> _enabled == 0 ) echo "checked='checked'";?>>
        <?=$lang -> getTrans( 'T_NIE' );?>
        <input type="radio" name="enabled" id="enabled_1" value='1' <? if ( isset( $this -> _enabled ) && $this -> _enabled == 1 ) echo "checked='checked'";?>>
        <?=$lang -> getTrans( 'T_TAK' );?>
      </div>
    </div>

    <div class="edit_line" id="tr_link" style="display: none;">
      <label><?=ucfirst( $lang -> getTrans( 'T_LINK' ) );?>:</label>
      <div class="input">
        <input type="text" name="link" value="<? if ( isset( $this -> _link ) ) echo $this -> _link;?>">
      </div>
    </div>
    
  </div>
  </form>
</fieldset>