*&---------------------------------------------------------------------*
*&  Include           ZSOFTCOPY_O2                                     *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*& This file is part of ZSOFTCOPY.                                     *
*&                                                                     *
*& ZSOFTCOPY is free software: you can redistribute it and/or modify   *
*& it under the terms of the GNU General Public License as published   *
*& by the Free Software Foundation, either version 3 of the License,   *
*& or any later version.                                               *
*&                                                                     *
*& ZSOFTCOPY is distributed in the hope that it will be useful,        *
*& but WITHOUT ANY WARRANTY; without even the implied warranty of      *
*& MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the       *
*& GNU General Public License for more details.                        *
*&                                                                     *
*& You should have received a copy of the GNU General Public License   *
*& along with ZDOWNLOAD. If not, see <http://www.gnu.org/licenses/>.   *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&  Author:     Ruediger von Creytz     ruediger.creytz@globalbit.net  *
*&  Copyright:  globalBIT, LLC          http://www.globalbit.net       *
*&                                                                     *
*&---------------------------------------------------------------------*


*-----------------------------------------------------------------------
* o2
*-----------------------------------------------------------------------
FORM o2.
*BSP Application
  PERFORM o2_r3tr_wapa.
*BSP Applications
  PERFORM o2_r3tr_wapa_appl.
*Mimes
  PERFORM o2_r3tr_wapa_mime.
*BSP Extension
  PERFORM o2_r3tr_wtag.
*BSP Extensions
  PERFORM o2_r3tr_wtag_ext.
*XSLT
  PERFORM o2_r3tr_xslt.

ENDFORM.                    "o2


*-----------------------------------------------------------------------
* o2_get_mime_content
*-----------------------------------------------------------------------
FORM o2_get_mime_content
  USING
    value(i_objtype)
    value(i_class)
    value(i_objid)
  CHANGING
    ct_content_ascii TYPE it_o2content_ascii
    ct_content_binary TYPE it_o2content_binary
    c_filesize TYPE i.

  DATA:
  lo_io TYPE REF TO data,
  lo_phio TYPE REF TO data,
  lo_error TYPE REF TO data,
  lt_class_filter TYPE it_o2class_filter,
  lt_relation TYPE it_o2relation,
  lt_file_info TYPE it_o2file_info.

  FIELD-SYMBOLS:
  <ls_io> TYPE ANY,
  <ls_phio> TYPE ANY,
  <ls_error> TYPE ANY,
  <l_fs> TYPE ANY,
  <ls_relation> TYPE st_o2relation,
  <ls_file_info> TYPE st_o2file_info.

  CREATE DATA lo_io TYPE ('SKWF_IO').
  ASSIGN lo_io->* TO <ls_io>.
  CREATE DATA lo_phio TYPE ('SKWF_IO').
  ASSIGN lo_phio->* TO <ls_phio>.
  CREATE DATA lo_error TYPE ('SKWF_ERROR').
  ASSIGN lo_error->* TO <ls_error>.

  ASSIGN COMPONENT 'OBJTYPE' OF STRUCTURE <ls_io> TO <l_fs>.
  <l_fs> = i_objtype.
  ASSIGN COMPONENT 'CLASS' OF STRUCTURE <ls_io> TO <l_fs>.
  <l_fs> = i_class.
  ASSIGN COMPONENT 'OBJID' OF STRUCTURE <ls_io> TO <l_fs>.
  <l_fs> = i_objid.

  CALL FUNCTION 'SKWF_IO_FROM_RELATIONS_GET'
    EXPORTING
      io           = <ls_io>
    IMPORTING
      error        = <ls_error>
    TABLES
      class_filter = lt_class_filter
      relations    = lt_relation.
  CHECK <ls_error> IS INITIAL.

  LOOP AT lt_relation ASSIGNING <ls_relation>.
    CLEAR <ls_error>.
    ASSIGN COMPONENT 'OBJTYPE' OF STRUCTURE <ls_phio> TO <l_fs>.
    <l_fs> = <ls_relation>-objtype.
    ASSIGN COMPONENT 'CLASS' OF STRUCTURE <ls_phio> TO <l_fs>.
    <l_fs> = <ls_relation>-prtn_class.
    ASSIGN COMPONENT 'OBJID' OF STRUCTURE <ls_phio> TO <l_fs>.
    <l_fs> = <ls_relation>-prtn_id.
    CALL FUNCTION 'SKWF_PHIO_LOAD_CONTENT'
      EXPORTING
        phio                = <ls_phio>
      IMPORTING
        error               = <ls_error>
      TABLES
        file_access_info    = lt_file_info
        file_content_ascii  = ct_content_ascii
        file_content_binary = ct_content_binary.
    LOOP AT lt_file_info ASSIGNING <ls_file_info>.
      c_filesize = <ls_file_info>-file_size.
    ENDLOOP.
  ENDLOOP.
ENDFORM.                    "get_mime_content


*-----------------------------------------------------------------------
* o2_get_mimes
*-----------------------------------------------------------------------
FORM o2_get_mimes
  USING value(i_folder_name)
  CHANGING ct_mime TYPE it_mime.

  DATA:
  l_folder_name1(4096) TYPE c,
  l_folder_name2(4096) TYPE c,
  ls_folder TYPE st_skwf_io,
  ls_error TYPE st_skwf_error,
  ls_parent TYPE st_skwf_io,
  lt_io TYPE it_skwf_io,
  ls_io TYPE st_skwf_io,
  l_prefix(4096) TYPE c,
  l_len TYPE i,
  ls_mime TYPE st_mime,
  l_url(4096) TYPE c,
  l_rel_url(64) TYPE c,
  l_filename(255) TYPE c,
  l_url_prefix TYPE seovalue.

  REFRESH ct_mime.

  PERFORM get_class_attribute_value
    USING
      'CL_WB_MIME_REPOSITORY'
      'MR_URL_PREFIX'
    CHANGING
      l_url_prefix.
  IF l_url_prefix IS INITIAL.
    l_url_prefix = '/'.
  ENDIF.

  CONCATENATE l_url_prefix 'SAP' INTO l_url.
  CALL FUNCTION 'SKWF_NMSPC_IO_FIND_BY_ADDRESS'
    EXPORTING
      url   = l_url
      appl  = 'MIME'
    IMPORTING
      io    = ls_parent
      error = ls_error.
  IF NOT ls_parent IS INITIAL.
    l_folder_name1 = i_folder_name.
    DO.
      IF l_folder_name1 CS '/'.
        SPLIT l_folder_name1 AT '/' INTO l_folder_name2 l_folder_name1.
      ELSE.
        l_folder_name2 = l_folder_name1.
      ENDIF.
      CALL FUNCTION 'SKWF_NMSPC_IO_FIND_BY_ADDRESS'
        EXPORTING
          url    = l_folder_name2
          folder = ls_parent
        IMPORTING
          io     = ls_folder
          error  = ls_error.
      IF ls_folder IS INITIAL
      OR l_folder_name2 = l_folder_name1.
        EXIT.
      ENDIF.
      ls_parent = ls_folder.
    ENDDO.
    IF NOT ls_folder IS INITIAL.
      CALL FUNCTION 'SKWF_FOLDER_SUB_IOS_GET'
        EXPORTING
          folder  = ls_folder
          io_type = 'L'
        IMPORTING
          error   = ls_error
        TABLES
          ios     = lt_io.
      IF ls_error IS INITIAL.
        CONCATENATE l_url_prefix 'SAP/' i_folder_name '/'
            INTO l_prefix.
        l_len = strlen( l_prefix ).
        LOOP AT lt_io INTO ls_io.
          CLEAR ls_mime.
          CALL FUNCTION 'SKWF_NMSPC_IO_ADDRESS_GET'
            EXPORTING
              io           = ls_io
            IMPORTING
              url          = l_url
              relative_url = l_rel_url
              error        = ls_error.
          IF ls_error IS INITIAL.
*           Shave off prefix of URL
            SHIFT l_url BY l_len PLACES.
            ls_mime-key = l_url.
            TRANSLATE ls_mime-key TO UPPER CASE.
            ls_mime-name = l_url.
            ls_mime-objtype = ls_io-objtype.
            ls_mime-class = ls_io-class.
            ls_mime-objid = ls_io-objid.
            l_filename = l_rel_url.
*           Get MIME type from filename
            CALL FUNCTION 'SKWF_MIMETYPE_OF_FILE_GET'
              EXPORTING
                filename = l_filename
              IMPORTING
                mimetype = ls_mime-mimetype.
*           Get MIME type description
            IF NOT ls_mime-mimetype IS INITIAL.
              CALL FUNCTION 'SKWF_MIMETYPE_DESCRIPTION_GET'
                EXPORTING
                  mimetype = ls_mime-mimetype
                  language = sy-langu
                IMPORTING
                  descript = ls_mime-mimetype_descript.
            ENDIF.
            IF NOT ls_mime IS INITIAL.
              APPEND ls_mime TO ct_mime.
            ENDIF.
          ENDIF.
        ENDLOOP.
      ENDIF.
    ENDIF.
  ENDIF.
  SORT ct_mime BY key.
ENDFORM.                    "get_mimes


*-----------------------------------------------------------------------
* o2_get_url
*-----------------------------------------------------------------------
FORM o2_get_url
  USING
    value(i_https) TYPE flag
    value(i_applname)                                       "char30
    value(i_pagekey)                                        "char70
    value(i_pagename)                                       "char70
    value(i_pagetype) TYPE c
    value(i_is_error_page) TYPE flag
  CHANGING
    c_url TYPE string.

  DATA:
  lo_page TYPE REF TO data.

  FIELD-SYMBOLS:
  <ls_page> TYPE ANY,
  <l_fs> TYPE ANY.

  CREATE DATA lo_page TYPE ('O2PAGENAME').
  ASSIGN lo_page->* TO <ls_page>.

  ASSIGN COMPONENT 'APPLNAME' OF STRUCTURE <ls_page> TO <l_fs>.
  <l_fs> = i_applname.
  ASSIGN COMPONENT 'PAGEKEY' OF STRUCTURE <ls_page> TO <l_fs>.
  <l_fs> = i_pagekey.
  ASSIGN COMPONENT 'PAGENAME' OF STRUCTURE <ls_page> TO <l_fs>.
  <l_fs> = i_pagename.
  ASSIGN COMPONENT 'PAGETYPE' OF STRUCTURE <ls_page> TO <l_fs>.
  <l_fs> = i_pagetype.
  ASSIGN COMPONENT 'IS_ERROR_PAGE' OF STRUCTURE <ls_page> TO <l_fs>.
  <l_fs> = i_is_error_page.

  CALL METHOD ('CL_O2_HELPER')=>generate_url_for_page
    EXPORTING
      p_page        = <ls_page>
      p_secure_http = i_https
    IMPORTING
      p_url         = c_url
    EXCEPTIONS
      OTHERS        = 1.

ENDFORM.                    "get_url


*-----------------------------------------------------------------------
* o2_r3tr_wapa                                  BSP Application
*-----------------------------------------------------------------------
FORM o2_r3tr_wapa.

  DATA:
  lt_tabstrip TYPE it_tabstrip,
  lt_html TYPE it_string,
  ls_attributes TYPE st_attributes,
  lo_appl TYPE REF TO data,
  lo_applt TYPE REF TO data,
  l_applname(30) TYPE c,
  l_applext(30) TYPE c,
  l_bname TYPE xubname,
  l_name_text TYPE ad_namtext,
  ls_o2navigation TYPE st_o2navigation,
  lt_o2navigation TYPE it_o2navigation,
  lo_navgraph TYPE REF TO data,
  l_pagekey(70) TYPE c,
  l_flag TYPE flag.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_appl> TYPE ANY,
  <ls_applt> TYPE ANY,
  <l_fs> TYPE ANY,
  <ls_navgraph> TYPE ANY,
  <ls_tabstrip> TYPE st_tabstrip.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'WAPA'
      AND o2pagekey = space
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    IF NOT <ls_navgraph> IS ASSIGNED.
      PERFORM get_tabstrip
      USING 'O2_R3TR_WAPA' space
      CHANGING lt_tabstrip.

      CREATE DATA lo_navgraph TYPE ('O2NAVGRAPH').
      ASSIGN lo_navgraph->* TO <ls_navgraph>.

      CREATE DATA lo_appl TYPE ('O2APPL').
      ASSIGN lo_appl->* TO <ls_appl>.

      CREATE DATA lo_applt TYPE ('O2APPLT').
      ASSIGN lo_applt->* TO <ls_applt>.
    ENDIF.

    REFRESH:
    lt_html,
    lt_o2navigation.

    CLEAR:
    ls_attributes,
    l_applname,
    l_applext,
    <ls_appl>,
    <ls_applt>.

*Properties
    l_applname = <ls_ztadir>-obj_name.
    SELECT SINGLE * FROM ('O2APPL') INTO <ls_appl>
        WHERE applname = l_applname
        AND version = 'A'.
    IF sy-subrc = 0.
      ASSIGN COMPONENT 'APPLEXT' OF STRUCTURE <ls_appl> TO <l_fs>.
      l_applext = <l_fs>.

      ls_attributes-space_after_descript = abap_true.
      ls_attributes-is_bsp_appl = abap_true.

      ls_attributes-descript = <ls_ztadir>-descript.
      ASSIGN COMPONENT 'AUTHOR' OF STRUCTURE <ls_appl> TO <l_fs>.
      ls_attributes-author = <l_fs>.
      l_bname = <l_fs>.
      PERFORM get_user
        USING l_bname
        CHANGING l_name_text.
      ls_attributes-author_text = l_name_text.
      ASSIGN COMPONENT 'CREATEDON' OF STRUCTURE <ls_appl> TO <l_fs>.
      PERFORM get_date
        USING <l_fs>
        CHANGING ls_attributes-date_created.
      ASSIGN COMPONENT 'CHANGEDBY' OF STRUCTURE <ls_appl> TO <l_fs>.
      ls_attributes-bname = <l_fs>.
      l_bname = <l_fs>.
      PERFORM get_user
        USING l_bname
        CHANGING l_name_text.
      ls_attributes-name_text = l_name_text.
      ASSIGN COMPONENT 'CHANGEDON' OF STRUCTURE <ls_appl> TO <l_fs>.
      PERFORM get_date
        USING <l_fs>
        CHANGING ls_attributes-date_last_changed.
      ls_attributes-devclass = <ls_ztadir>-devclass.
      PERFORM get_devclass
        USING <ls_ztadir>-devclass
        CHANGING ls_attributes-devclass_descr.
      PERFORM get_spras
        USING
          <ls_ztadir>-masterlang
        CHANGING
          ls_attributes-laiso
          ls_attributes-sptxt.
      ASSIGN COMPONENT 'APPLNAME' OF STRUCTURE <ls_appl> TO <l_fs>.
      ls_attributes-internal_name = <l_fs>.
      ASSIGN COMPONENT 'STARTPAGE' OF STRUCTURE <ls_appl> TO <l_fs>.
      ls_attributes-initial_bsp = <l_fs>.
      ASSIGN COMPONENT 'APPLCLAS' OF STRUCTURE <ls_appl> TO <l_fs>.
      ls_attributes-application_class = <l_fs>.
      ASSIGN COMPONENT 'THEME' OF STRUCTURE <ls_appl> TO <l_fs>.
      ls_attributes-initial_bsp = <l_fs>.
      ASSIGN COMPONENT 'STATEFUL' OF STRUCTURE <ls_appl> TO <l_fs>.
      ls_attributes-stateful = <l_fs>.
      ASSIGN COMPONENT 'SESSIONMANAGEMNT' OF STRUCTURE <ls_appl>
          TO <l_fs>.
      ls_attributes-supports_portal_integration = <l_fs>.
    ENDIF.

*Navigation
    SELECT * FROM ('O2NAVGRAPH') INTO <ls_navgraph>
        WHERE applname = l_applname
        AND version = 'A'.
      CLEAR ls_o2navigation.
* * * Navigation Request
      ASSIGN COMPONENT 'NODEEXIT' OF STRUCTURE <ls_navgraph>
          TO <l_fs>.
      ls_o2navigation-navrequest = <l_fs>.
* * * Start
      ASSIGN COMPONENT 'CURRNODE' OF STRUCTURE <ls_navgraph>
          TO <l_fs>.
      SELECT SINGLE pagekey FROM ('O2NAVMAP') INTO l_pagekey
          WHERE applname = l_applname
          AND version = 'A'
          AND node = <l_fs>.
      IF sy-subrc = 0.
        SELECT SINGLE pagename FROM ('O2PAGDIR')
            INTO ls_o2navigation-start
            WHERE applname = l_applname
            AND pagekey = l_pagekey.
      ENDIF.
* * * Target
      ASSIGN COMPONENT 'FUPNODE' OF STRUCTURE <ls_navgraph>
          TO <l_fs>.
      SELECT SINGLE pagekey FROM ('O2NAVMAP') INTO l_pagekey
          WHERE applname = l_applname
          AND version = 'A'
          AND node = <l_fs>.
      IF sy-subrc = 0.
        SELECT SINGLE pagename FROM ('O2PAGDIR')
            INTO ls_o2navigation-target
            WHERE applname = l_applname
            AND pagekey = l_pagekey.
      ENDIF.
* * *
      APPEND ls_o2navigation TO lt_o2navigation.
    ENDSELECT.
*** TabStrip
    LOOP AT lt_tabstrip ASSIGNING <ls_tabstrip>.
      <ls_tabstrip>-empty = abap_false.
      CASE <ls_tabstrip>-id.
        WHEN 'NAVIGATION'.
          IF lt_o2navigation IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ENDIF.
      ENDCASE.
    ENDLOOP.
*HTML
    PERFORM html_main_header
      USING
        tpt_o2_wapa
        txt_bsp_application
        l_applext
        txt_active___1
        space
        space
        space
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
    l_flag = abap_false.
    IF lt_o2navigation IS INITIAL.
      l_flag = abap_true.
    ENDIF.
    PERFORM html_add_attributes_2
      USING
        ls_attributes
        'PROPERTIES'
        l_flag
      CHANGING
        lt_html.
    IF NOT lt_o2navigation IS INITIAL
    OR g_empty_tab = gc_empty_tab_display.
      PERFORM html_add_table
        USING
          'WAPA_NAVI'
          lt_o2navigation
          lt_o2navigation
          'NAVIGATION'
          abap_true
        CHANGING
          lt_html.
    ENDIF.
    PERFORM html_main_footer
      USING
        lt_html.

    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
  ENDLOOP.

ENDFORM.                                                    "r3tr_wapa


*-----------------------------------------------------------------------
* o2_r3tr_wapa_appl                             BSP Applications
*-----------------------------------------------------------------------
FORM o2_r3tr_wapa_appl.

  DATA:
  mt_string TYPE it_string.

  TYPES:
  BEGIN OF st_o2pagevhs,
    applname(30) TYPE c,
    pagekey(70) TYPE c,
    evhandler(30) TYPE c,
    version TYPE c,
    evhname(30) TYPE c,
    source LIKE mt_string,
  END OF st_o2pagevhs,
  it_o2pagevhs TYPE SORTED TABLE OF st_o2pagevhs
    WITH UNIQUE KEY evhandler.

  DATA:
  lt_html TYPE it_string,
  l_objname(110) TYPE c,
  l_applname(30) TYPE c,
  l_pagekey(70) TYPE c,
  l_pagename(70) TYPE c,
  l_pagetype(1) TYPE c,
  l_is_error_page TYPE flag,
  l_https TYPE flag,
  lo_pagdir TYPE REF TO data,
  ls_ti TYPE st_textinput,
  ls_rb TYPE st_access,
  lt_prop_header TYPE it_textinput,
  lt_prop_page_type_rb TYPE it_access,
  lt_prop_page_type_ti TYPE it_textinput,
  lt_prop_error_handling TYPE it_textinput,
  lt_prop_status_rb TYPE it_access,
  lt_prop_status_ti TYPE it_textinput,
  lt_prop_caching_li TYPE it_textinput,
  lt_prop_caching_re TYPE it_textinput,
  lt_prop_transfer_options_li TYPE it_textinput,
  lt_prop_transfer_options_re TYPE it_textinput,
  lt_prop_footer TYPE it_textinput,
  lt_dom_value TYPE it_dom_value,
  l_bname TYPE xubname,
  l_name TYPE ad_namtext,
  lt_line TYPE it_line,
  lt_layout_src TYPE it_string,
  l_str TYPE string,
  lt_o2pagevhs TYPE it_o2pagevhs,
  lt_o2pagpars TYPE it_o2pagpars,
  lt_typesrc TYPE it_string,
  lt_used_guid TYPE it_guid,
  lt_tabstrip TYPE it_tabstrip,
  l_o2type TYPE c,
  l_type(4) TYPE c,
  l_filename TYPE string,
  l_filename2 TYPE string,
  lt_pageattr TYPE it_o2pageattr,
  ls_pageattr TYPE st_o2pageattr,
  l_flag TYPE flag,
  ls_tabstrip TYPE st_tabstrip,
  l_type_title TYPE string,
  l_title TYPE string,
  l_id TYPE string,
  l_javascript TYPE string.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_pagdir> TYPE ANY,
  <ls_line> TYPE st_line,
  <l_fs> TYPE ANY,
  <ls_dom_value> TYPE st_dom_value,
  <ls_o2pagevhs> TYPE st_o2pagevhs,
  <ls_o2pagpars> TYPE st_o2pagpars,
  <ls_tabstrip> TYPE st_tabstrip.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'WAPA'
      AND o2pagekey <> space
      AND (
        o2type = gc_o2type_bsp
        OR o2type = gc_o2type_ctrl
        OR o2type = gc_o2type_incl
        OR o2type = gc_o2type_view
      )
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    IF NOT <ls_pagdir> IS ASSIGNED.
      CREATE DATA lo_pagdir TYPE ('O2PAGATTR').
      ASSIGN lo_pagdir->* TO <ls_pagdir>.
    ENDIF.

    REFRESH:
    lt_html,
    lt_prop_header,
    lt_prop_page_type_rb,
    lt_prop_page_type_ti,
    lt_prop_error_handling,
    lt_prop_status_rb,
    lt_prop_status_ti,
    lt_prop_caching_li,
    lt_prop_caching_re,
    lt_prop_transfer_options_li,
    lt_prop_transfer_options_re,
    lt_prop_footer,
    lt_layout_src,
    lt_o2pagevhs,
    lt_o2pagpars,
    lt_typesrc,
    lt_used_guid,
    lt_tabstrip,
    lt_pageattr.

    CLEAR:
    l_objname,
    l_o2type,
    <ls_pagdir>,
    l_type,
    l_filename,
    l_filename2,
    l_flag,
    l_type_title,
    l_title,
    l_id,
    l_javascript.

    l_applname = <ls_ztadir>-obj_name.
    l_pagekey = <ls_ztadir>-o2pagekey.
    l_objname+0(30) = <ls_ztadir>-obj_name.
    l_objname+30(70) = <ls_ztadir>-o2pagekey.

    CALL FUNCTION 'O2_GET_WAPA_SOURCEN'
      EXPORTING
        p_objname       = l_objname
        p_versno        = 0
        p_devclass      = <ls_ztadir>-devclass
        p_langu         = sy-langu
        p_master_l      = sy-langu
      IMPORTING
        pt_page_content = lt_line
        pt_ev_handler   = lt_o2pagevhs
        pt_parameters   = lt_o2pagpars
        ps_page_attr    = <ls_pagdir>
        pt_typesource   = lt_typesrc
        pt_used_guids   = lt_used_guid
      EXCEPTIONS
        OTHERS          = 1.

    ASSIGN COMPONENT 'PAGENAME' OF STRUCTURE <ls_pagdir> TO <l_fs>.
    l_pagename = <l_fs>.

* Properties - Header
*   Description
    CLEAR ls_ti.
    ls_ti-name = txt_description.
    ls_ti-value = <ls_ztadir>-descript.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_prop_header.
*
    IF <ls_ztadir>-o2type = gc_o2type_ctrl.
*     Controller Class
      CLEAR ls_ti.
      ls_ti-name = txt_controller_class.
      ASSIGN COMPONENT 'IMPLCLASS' OF STRUCTURE <ls_pagdir> TO <l_fs>.
      ls_ti-value = <l_fs>.
      ls_ti-input = abap_true.
      APPEND ls_ti TO lt_prop_header.
    ENDIF.
*
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_view.
*     Mime Type
      CLEAR ls_ti.
      ls_ti-name = txt_mime_type.
      ASSIGN COMPONENT 'MIMETYPE' OF STRUCTURE <ls_pagdir> TO <l_fs>.
      ls_ti-value = <l_fs>.
      IF ls_ti-value IS INITIAL.
        ls_ti-value = 'application/octet-stream'.
      ENDIF.
      ls_ti-input = abap_true.
      APPEND ls_ti TO lt_prop_header.
*     Compression
      CLEAR ls_ti.
      ls_ti-name = txt_compression.
      ASSIGN COMPONENT 'STRIPMODE' OF STRUCTURE <ls_pagdir>
          TO <l_fs>.
      PERFORM get_dom_value_text
        USING 'O2STRIPMODE' <l_fs>
        CHANGING ls_ti-value.
      ls_ti-input = abap_true.
      APPEND ls_ti TO lt_prop_header.
*     W/O Script Code
      CLEAR ls_ti.
      ls_ti-name = txt_wo_script_code.
      ASSIGN COMPONENT 'NO_SCRIPT' OF STRUCTURE <ls_pagdir> TO <l_fs>.
      ls_ti-value = <l_fs>.
      ls_ti-flag = abap_true.
      APPEND ls_ti TO lt_prop_header.
    ENDIF.
*
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_incl
    OR <ls_ztadir>-o2type = gc_o2type_view.
* Properties - Page Type
      ASSIGN COMPONENT 'PAGETYPE' OF STRUCTURE <ls_pagdir> TO <l_fs>.
      l_pagetype = <l_fs>.
*     View
      CLEAR ls_rb.
      ls_rb-ddtext = txt_view.
      IF l_pagetype = gc_o2type_view.
        ls_rb-checked = abap_true.
      ENDIF.
      APPEND ls_rb TO lt_prop_page_type_rb.
*     Page with Flow Logic
      CLEAR ls_rb.
      ls_rb-ddtext = txt_page_with_flow_logic.
      IF l_pagetype = gc_o2type_bsp.
        ls_rb-checked = abap_true.
      ENDIF.
      APPEND ls_rb TO lt_prop_page_type_rb.
*     Page Fragment
      CLEAR ls_rb.
      ls_rb-ddtext = txt_page_fragment.
      IF l_pagetype = gc_o2type_incl.
        ls_rb-checked = abap_true.
      ENDIF.
      APPEND ls_rb TO lt_prop_page_type_rb.
*     Controller class
      CLEAR ls_ti.
      ls_ti-name = txt_controller_class.
      ASSIGN COMPONENT 'CONTROLLERURL' OF STRUCTURE <ls_pagdir>
          TO <l_fs>.
      ls_ti-value = <l_fs>.
      ls_ti-input = abap_true.
      APPEND ls_ti TO lt_prop_page_type_ti.
    ENDIF.
*
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_ctrl
    OR <ls_ztadir>-o2type = gc_o2type_view.
* Properties - Error Handling
*     Is Error Page
      CLEAR ls_ti.
      ls_ti-name = txt_is_error_page.
      ASSIGN COMPONENT 'IS_ERROR_PAGE' OF STRUCTURE <ls_pagdir>
          TO <l_fs>.
      l_is_error_page = <l_fs>.
      ls_ti-value = l_is_error_page.
      ls_ti-flag = abap_true.
      APPEND ls_ti TO lt_prop_error_handling.
*     Assigned Error Page
      CLEAR ls_ti.
      ls_ti-name = txt_assigned_error_page.
      ASSIGN COMPONENT 'ERROR_PAGE' OF STRUCTURE <ls_pagdir>
          TO <l_fs>.
      ls_ti-value = <l_fs>.
      ls_ti-input = abap_true.
      APPEND ls_ti TO lt_prop_error_handling.
    ENDIF.
*
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_ctrl.
* Properties - Status
      PERFORM get_dom_value_texts
        USING 'O2PAGSTATE'
        CHANGING lt_dom_value.
      SORT lt_dom_value BY value.
      ASSIGN COMPONENT 'STATE' OF STRUCTURE <ls_pagdir> TO <l_fs>.
      LOOP AT lt_dom_value ASSIGNING <ls_dom_value>.
        CLEAR ls_rb.
        ls_rb-ddtext = <ls_dom_value>-text.
        IF <ls_dom_value>-value = <l_fs>.
          ls_rb-checked = abap_true.
        ENDIF.
        APPEND ls_rb TO lt_prop_status_rb.
      ENDLOOP.
*     Lifetime
      CLEAR ls_ti.
      ls_ti-name = txt_lifetime.
      ASSIGN COMPONENT 'LIFETIME' OF STRUCTURE <ls_pagdir> TO <l_fs>.
      PERFORM get_dom_value_text
        USING 'O2LIFETIME' <l_fs>
        CHANGING ls_ti-value.
      ls_ti-input = abap_true.
      APPEND ls_ti TO lt_prop_status_ti.
* Properties - Caching
*     Browser Cache
      CLEAR ls_ti.
      ls_ti-name = txt_browser_cache.
      ASSIGN COMPONENT 'BROWSER_CACHE' OF STRUCTURE <ls_pagdir>
          TO <l_fs>.
      ls_ti-value = <l_fs>.
      ls_ti-input = abap_true.
      ls_ti-description = txt_sec.
      APPEND ls_ti TO lt_prop_caching_li.
*     Server Cache
      CLEAR ls_ti.
      ls_ti-name = txt_server_cache.
      ASSIGN COMPONENT 'SERVER_CACHE' OF STRUCTURE <ls_pagdir>
          TO <l_fs>.
      ls_ti-value = <l_fs>.
      ls_ti-input = abap_true.
      ls_ti-description = txt_sec.
      APPEND ls_ti TO lt_prop_caching_li.
*
      CLEAR ls_ti.
      ls_ti-space = abap_true.
      APPEND ls_ti TO lt_prop_caching_re.
*     Browser-Specific
      CLEAR ls_ti.
      ls_ti-name = txt_browser_specific.
      ASSIGN COMPONENT 'BROWSER_DEP' OF STRUCTURE <ls_pagdir>
          TO <l_fs>.
      ls_ti-value = <l_fs>.
      ls_ti-flag = abap_true.
      APPEND ls_ti TO lt_prop_caching_re.
* Properties - Transfer Options
*     Compression
      CLEAR ls_ti.
      ls_ti-name = txt_compression.
      ASSIGN COMPONENT 'COMPRESSION' OF STRUCTURE <ls_pagdir>
          TO <l_fs>.
      ls_ti-value = <l_fs>.
      ls_ti-flag = abap_true.
      APPEND ls_ti TO lt_prop_transfer_options_li.
    ENDIF.
*
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_ctrl
    OR <ls_ztadir>-o2type = gc_o2type_view.
*     Delta Handling
      CLEAR ls_ti.
      ls_ti-name = txt_delta_handling.
      ASSIGN COMPONENT 'DELTA_HANDLING' OF STRUCTURE <ls_pagdir>
          TO <l_fs>.
      ls_ti-value = <l_fs>.
      ls_ti-flag = abap_true.
      APPEND ls_ti TO lt_prop_transfer_options_li.
    ENDIF.
*
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_ctrl.
*     HTTPS
      CLEAR ls_ti.
      ls_ti-name = txt_https.
      ASSIGN COMPONENT 'SECUREHTTP' OF STRUCTURE <ls_pagdir>
          TO <l_fs>.
      l_https = <l_fs>.
      ls_ti-value = l_https.
      ls_ti-flag = abap_true.
      APPEND ls_ti TO lt_prop_transfer_options_re.
    ENDIF.
* Properties - Footer
*   Created on
    CLEAR ls_ti.
    ls_ti-name = txt_created_on.
    ASSIGN COMPONENT 'AUTHOR' OF STRUCTURE <ls_pagdir> TO <l_fs>.
    l_bname = <l_fs>.
    PERFORM get_user
      USING l_bname
      CHANGING l_name.
    ls_ti-value = l_bname.
    ls_ti-value_text = l_name.
    ASSIGN COMPONENT 'CREATEDON' OF STRUCTURE <ls_pagdir> TO <l_fs>.
    PERFORM get_date
      USING <l_fs>
      CHANGING ls_ti-value_ext.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_prop_footer.
*   Last Changed on
    CLEAR ls_ti.
    ls_ti-name = txt_last_changed_on.
    ASSIGN COMPONENT 'CHANGEDBY' OF STRUCTURE <ls_pagdir> TO <l_fs>.
    l_bname = <l_fs>.
    PERFORM get_user
      USING l_bname
      CHANGING l_name.
    ls_ti-value = l_bname.
    ls_ti-value_text = l_name.
    ASSIGN COMPONENT 'CHANGEDON' OF STRUCTURE <ls_pagdir> TO <l_fs>.
    PERFORM get_date
      USING <l_fs>
      CHANGING ls_ti-value_ext.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_prop_footer.
*   Package
    CLEAR ls_ti.
    ls_ti-name = txt_package.
    ls_ti-value = <ls_ztadir>-devclass.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_prop_footer.
*
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_ctrl.
*     URL
      CLEAR ls_ti.
      ls_ti-name = txt_url.
      PERFORM o2_get_url
        USING
          l_https
          l_applname
          l_pagekey
          l_pagename
          l_pagetype
          l_is_error_page
        CHANGING
          ls_ti-value.
      ls_ti-input = abap_true.
      APPEND ls_ti TO lt_prop_footer.
    ENDIF.

* Layout
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_incl
    OR <ls_ztadir>-o2type = gc_o2type_view.
      LOOP AT lt_line ASSIGNING <ls_line>.
        l_str = <ls_line>-line.
        APPEND l_str TO lt_layout_src.
      ENDLOOP.
    ENDIF.

* Page Attributes
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_view.
      LOOP AT lt_o2pagpars ASSIGNING <ls_o2pagpars>.
        CLEAR ls_pageattr.
        MOVE-CORRESPONDING <ls_o2pagpars> TO ls_pageattr.
        PERFORM get_dom_value_text
          USING
            'O2TYPTYPE'
            ls_pageattr-typtype
          CHANGING
            ls_pageattr-typtype_txt.
        IF ls_pageattr-pardecltyp = '0'.
          ls_pageattr-pardecltyp_flag = abap_true.
        ENDIF.
        APPEND ls_pageattr TO lt_pageattr.
      ENDLOOP.
    ENDIF.

    l_o2type = <ls_ztadir>-o2type.
    IF l_o2type IS INITIAL.
      l_o2type = 'B'.
    ENDIF.
    PERFORM get_tabstrip
      USING 'O2_R3TR_WAPA_APPL' l_o2type
      CHANGING lt_tabstrip.
    LOOP AT lt_tabstrip ASSIGNING <ls_tabstrip>.
      <ls_tabstrip>-empty = abap_false.
      CASE <ls_tabstrip>-id.
        WHEN 'LAYOUT'.
          IF lt_layout_src IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ELSE.
            CONCATENATE l_javascript 'makeDivSize(''LAYOUT'');'
                INTO l_javascript.
          ENDIF.
        WHEN 'EVENT_HANDLER'.
          IF lt_o2pagevhs IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ENDIF.
        WHEN 'PAGE_ATTRIBUTES'.
          IF lt_pageattr IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ENDIF.
        WHEN 'TYPE_DEFINITIONS'.
          IF lt_typesrc IS INITIAL.
            <ls_tabstrip>-empty = abap_true.
          ELSE.
            CONCATENATE l_javascript
                'makeDivSize(''TYPE_DEFINITIONS'');'
                INTO l_javascript.
          ENDIF.
      ENDCASE.
    ENDLOOP.
    LOOP AT lt_o2pagevhs ASSIGNING <ls_o2pagevhs>.
      CLEAR ls_tabstrip.
      ls_tabstrip-form = 'O2_R3TR_WAPA_APPL'.
      ls_tabstrip-id = <ls_o2pagevhs>-evhandler.
      ls_tabstrip-parent_id = 'EVENT_HANDLER'.
      ls_tabstrip-text = <ls_o2pagevhs>-evhname.
      IF sy-tabix = 1.
        ls_tabstrip-active = abap_true.
      ENDIF.
      ls_tabstrip-tab_nr = sy-tabix + 20.
      APPEND ls_tabstrip TO lt_tabstrip.
      CONCATENATE l_javascript
          'makeDivSize(''' <ls_o2pagevhs>-evhandler ''');'
          INTO l_javascript.
    ENDLOOP.

*Filename
    CASE <ls_ztadir>-o2type.
      WHEN gc_o2type_ctrl.
        l_type = 'ctrl'.
        l_title = tpt_o2_wapa_ctrl.
        l_type_title = txt_controller.
      WHEN gc_o2type_view.
        l_type = 'view'.
        l_title = tpt_o2_wapa_page.
        l_type_title = txt_page.
      WHEN gc_o2type_bsp.
        l_type = 'bsp'.
        l_title = tpt_o2_wapa_page.
        l_type_title = txt_page.
      WHEN gc_o2type_incl.
        l_type = 'incl'.
        l_title = tpt_o2_wapa_page.
        l_type_title = txt_page.
    ENDCASE.
    PERFORM replace_single
      USING '#NAME_VALUE#' <ls_ztadir>-obj_name
      CHANGING l_title.
    CONCATENATE <ls_ztadir>-obj_name '-' l_type
        '/' <ls_ztadir>-o2pagename
        INTO l_filename.

*HTML
    PERFORM html_main_header
      USING
        l_title
        l_type_title
        <ls_ztadir>-o2pagename
        txt_active___1
        space
        space
        l_javascript
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
*Properties
    l_flag = abap_true.
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_incl
    OR <ls_ztadir>-o2type = gc_o2type_view.
      IF NOT lt_layout_src IS INITIAL
      OR g_empty_tab = gc_empty_tab_display.
        l_flag = abap_false.
      ENDIF.
    ENDIF.
    PERFORM html_add_properties_o2
      USING
        lt_prop_header
        txt_page_type
        lt_prop_page_type_rb
        lt_prop_page_type_ti
        txt_error_handling
        lt_prop_error_handling
        txt_status
        lt_prop_status_rb
        lt_prop_status_ti
        txt_caching
        lt_prop_caching_li
        lt_prop_caching_re
        txt_transfer_options
        lt_prop_transfer_options_li
        lt_prop_transfer_options_re
        lt_prop_footer
        'PROPERTIES'
        l_flag
      CHANGING
        lt_html.
*Layout
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_incl
    OR <ls_ztadir>-o2type = gc_o2type_view.
      IF NOT lt_layout_src IS INITIAL
      OR g_empty_tab = gc_empty_tab_display.
        PERFORM html_add_sourcecode
          USING
            lt_layout_src
            l_filename
            space
            space
            gc_extension_txt
            'LAYOUT'
            abap_true
          CHANGING
            lt_html.
        PERFORM download
          USING
            lt_layout_src
            <ls_ztadir>-pgmid
            <ls_ztadir>-object
            l_filename
            gc_extension_txt
            abap_false.
      ENDIF.
    ENDIF.
*Event Handler
    IF <ls_ztadir>-o2type = gc_o2type_bsp.
      IF NOT lt_o2pagevhs IS INITIAL
      OR g_empty_tab = gc_empty_tab_display.
        PERFORM html_add_container_begin
          USING
            lt_tabstrip
            'EVENT_HANDLER'
            abap_false
          CHANGING
            lt_html.
*
        LOOP AT lt_o2pagevhs ASSIGNING <ls_o2pagevhs>.
          l_flag = abap_false.
          IF sy-tabix = 1.
            l_flag = abap_true.
          ENDIF.
          CONCATENATE l_filename '.' <ls_o2pagevhs>-evhandler
              INTO l_filename2.
          PERFORM html_add_sourcecode
            USING
              <ls_o2pagevhs>-source
              l_filename2
              space
              space
              gc_extension_txt
              <ls_o2pagevhs>-evhandler
              l_flag
            CHANGING
              lt_html.
          PERFORM download
            USING
              <ls_o2pagevhs>-source
              <ls_ztadir>-pgmid
              <ls_ztadir>-object
              l_filename2
              gc_extension_txt
              abap_false.
        ENDLOOP.
*
        PERFORM html_add_container_end
          CHANGING
            lt_html.
      ENDIF.
    ENDIF.
*Page Attributes
    IF <ls_ztadir>-o2type = gc_o2type_bsp
    OR <ls_ztadir>-o2type = gc_o2type_view.
      IF NOT lt_pageattr IS INITIAL
      OR g_empty_tab = gc_empty_tab_display.
        PERFORM get_id
          USING 'WAPA_ATTR|' l_o2type
          CHANGING l_id.
        PERFORM html_add_table
          USING
            l_id
            lt_pageattr
            lt_pageattr
            'PAGE_ATTRIBUTES'
            abap_false
          CHANGING
            lt_html.
      ENDIF.
    ENDIF.
*Type Definitions
    IF <ls_ztadir>-o2type = gc_o2type_bsp.
      IF NOT lt_typesrc IS INITIAL
      OR g_empty_tab = gc_empty_tab_display.
        CONCATENATE l_filename '.types' INTO l_filename2.
        PERFORM html_add_sourcecode
          USING
            lt_typesrc
            l_filename2
            space
            space
            gc_extension_txt
            'TYPE_DEFINITIONS'
            abap_false
          CHANGING
            lt_html.
        PERFORM download
          USING
            lt_typesrc
            <ls_ztadir>-pgmid
            <ls_ztadir>-object
            l_filename2
            gc_extension_txt
            abap_false.
      ENDIF.
    ENDIF.
*
    PERFORM html_main_footer
      USING
        lt_html.

    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        l_filename
        gc_extension_htm
        abap_true.
  ENDLOOP.

ENDFORM.                    "r3tr_wapa_appl


*-----------------------------------------------------------------------
* o2_r3tr_wapa_mime                             Mimes
*-----------------------------------------------------------------------
FORM o2_r3tr_wapa_mime.

  DATA:
  lt_content_ascii TYPE it_o2content_ascii,
  lt_content_binary TYPE it_o2content_binary,
  lt_ascii TYPE it_string,
  ls_ascii TYPE string,
  l_filename TYPE string,
  l_filesize TYPE i.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_content_ascii> TYPE st_o2content_ascii.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'WAPA'
      AND o2pagekey <> space
      AND o2type = gc_o2type_mime
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    CLEAR:
    l_filesize.

    REFRESH:
    lt_content_ascii,
    lt_content_binary,
    lt_ascii.

    PERFORM o2_get_mime_content
      USING
        <ls_ztadir>-mime_objtype
        <ls_ztadir>-mime_class
        <ls_ztadir>-mime_objid
      CHANGING
        lt_content_ascii
        lt_content_binary
        l_filesize.

    CONCATENATE <ls_ztadir>-obj_name '-mime/'
        <ls_ztadir>-o2pagename
        INTO l_filename.

    IF NOT lt_content_ascii IS INITIAL.
      LOOP AT lt_content_ascii ASSIGNING <ls_content_ascii>.
        ls_ascii = <ls_content_ascii>-line.
        APPEND ls_ascii TO lt_ascii.
      ENDLOOP.

      PERFORM download
        USING
          lt_ascii
          <ls_ztadir>-pgmid
          <ls_ztadir>-object
          l_filename
          space
          abap_true.
    ENDIF.

    IF NOT lt_content_binary IS INITIAL.
      PERFORM download_binary
        USING
          lt_content_binary
          l_filesize
          <ls_ztadir>-pgmid
          <ls_ztadir>-object
          l_filename
          space
          abap_true.
    ENDIF.

  ENDLOOP.

ENDFORM.                    "r3tr_wapa_mime


*-----------------------------------------------------------------------
* o2_r3tr_wtag                                  BSP Extension
*-----------------------------------------------------------------------
FORM o2_r3tr_wtag.

  DATA:
  lt_tabstrip TYPE it_tabstrip,
  lt_html TYPE it_string,
  ls_ti TYPE st_textinput,
  lt_props TYPE it_textinput,
  lt_general TYPE it_textinput,
  lo_taglib TYPE REF TO data,
  l_tlibid(30) TYPE c,
  l_tlibname(30) TYPE c,
  l_masterlang TYPE masterlang,
  l_bname TYPE xubname,
  l_name_text TYPE ad_namtext,
  l_laiso TYPE laiso,
  l_sptxt TYPE sptxt,
  l_title TYPE string.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_taglib> TYPE ANY,
  <l_fs> TYPE ANY.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'WTAG'
      AND o2pagekey = space
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    IF NOT <ls_taglib> IS ASSIGNED.
      PERFORM get_tabstrip
        USING 'O2_R3TR_WTAG' space
        CHANGING lt_tabstrip.

      CREATE DATA lo_taglib TYPE ('O2TAGLIB').
      ASSIGN lo_taglib->* TO <ls_taglib>.
    ENDIF.

    REFRESH:
    lt_html,
    lt_props,
    lt_general.

    CLEAR <ls_taglib>.

    l_tlibid = <ls_ztadir>-obj_name.

    SELECT SINGLE masterlang FROM tadir INTO l_masterlang
        WHERE pgmid = 'R3TR'
        AND object = 'WTAG'
        AND obj_name = <ls_ztadir>-obj_name.

    SELECT SINGLE * FROM ('O2TAGLIB') INTO <ls_taglib>
        WHERE tlibid = l_tlibid
        AND state = 'A'.

    ASSIGN COMPONENT 'TLIBNAME' OF STRUCTURE <ls_taglib> TO <l_fs>.
    l_tlibname = <l_fs>.

*Properties
*   Short Description
    CLEAR ls_ti.
    ls_ti-name = txt_short_description___2.
    ls_ti-value = <ls_ztadir>-descript.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_props.
*   Default Prefix
    CLEAR ls_ti.
    ls_ti-name = txt_default_prefix.
    ASSIGN COMPONENT 'PREFIX' OF STRUCTURE <ls_taglib> TO <l_fs>.
    ls_ti-value = <l_fs>.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_props.
*   BSP Extension Class
    CLEAR ls_ti.
    ls_ti-name = txt_bsp_extension_class.
    ASSIGN COMPONENT 'TAGLIBCLASS' OF STRUCTURE <ls_taglib> TO <l_fs>.
    ls_ti-value = <l_fs>.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_props.
*   BSP Element Basis Class
    CLEAR ls_ti.
    ls_ti-name = txt_bsp_element_basis_class.
    ASSIGN COMPONENT 'TAGBASECLASS' OF STRUCTURE <ls_taglib>
        TO <l_fs>.
    ls_ti-value = <l_fs>.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_props.
*General Data
*   Created by
    CLEAR ls_ti.
    ls_ti-name = txt_created_by___1.
    ASSIGN COMPONENT 'AUTHOR' OF STRUCTURE <ls_taglib> TO <l_fs>.
    ls_ti-value = <l_fs>.
    l_bname = <l_fs>.
    PERFORM get_user
      USING l_bname
      CHANGING l_name_text.
    ls_ti-value_text = l_name_text.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_general.
*   Creation Date
    CLEAR ls_ti.
    ls_ti-name = txt_creation_date.
    ASSIGN COMPONENT 'CREATEDON' OF STRUCTURE <ls_taglib> TO <l_fs>.
    PERFORM get_date
      USING
        <l_fs>
      CHANGING
        ls_ti-value.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_general.
*   Last Changed
    CLEAR ls_ti.
    ls_ti-name = txt_last_changed.
    ASSIGN COMPONENT 'CHANGEDBY' OF STRUCTURE <ls_taglib> TO <l_fs>.
    ls_ti-value = <l_fs>.
    l_bname = <l_fs>.
    PERFORM get_user
      USING l_bname
      CHANGING l_name_text.
    ls_ti-value_text = l_name_text.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_general.
*   Changed On
    CLEAR ls_ti.
    ls_ti-name = txt_changed_on.
    ASSIGN COMPONENT 'CHANGEDON' OF STRUCTURE <ls_taglib> TO <l_fs>.
    PERFORM get_date
      USING
        <l_fs>
      CHANGING
        ls_ti-value.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_general.
*   Time changed
    CLEAR ls_ti.
    ls_ti-name = txt_time_changed.
    ASSIGN COMPONENT 'STAMP' OF STRUCTURE <ls_taglib> TO <l_fs>.
    PERFORM get_time
      USING
        <l_fs>
      CHANGING
        ls_ti-value.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_general.
*   Package
    CLEAR ls_ti.
    ls_ti-name = txt_package.
    ls_ti-value = <ls_ztadir>-devclass.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_general.
*   Original Language
    CLEAR ls_ti.
    ls_ti-name = txt_original_language.
    PERFORM get_spras
      USING l_masterlang
      CHANGING l_laiso l_sptxt.
    ls_ti-value = l_laiso.
    ls_ti-value_text = l_sptxt.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_general.
*Title
    l_title = tpt_o2_wtag.
    PERFORM replace_single
      USING
        var_name_value
        <ls_ztadir>-obj_name
      CHANGING
        l_title.
*HTML
    PERFORM html_main_header
      USING
        l_title
        txt_bsp_extension
        l_tlibname
        txt_active___1
        space
        space
        space
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
*Properties
    PERFORM html_add_textinput_subbox
      USING
        lt_props
        txt_general_data
        lt_general
        'PROPERTIES'
        abap_true
      CHANGING
        lt_html.
*
    PERFORM html_main_footer
      USING
        lt_html.

    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
  ENDLOOP.

ENDFORM.                                                    "r3tr_wtag


*-----------------------------------------------------------------------
* o2_r3tr_wtag_ext                              BSP Extensions
*-----------------------------------------------------------------------
FORM o2_r3tr_wtag_ext.

  DATA:
  lt_tabstrip TYPE it_tabstrip,
  lt_html TYPE it_string,
  ls_ti TYPE st_textinput,
  lt_props TYPE it_textinput,
  lt_general TYPE it_textinput,
  lt_options TYPE it_textinput,
  ls_rb TYPE st_access,
  lt_content TYPE it_access,
  lo_tag TYPE REF TO data,
  lo_att TYPE REF TO data,
  ls_att TYPE st_o2tagatt,
  lt_att TYPE it_o2tagatt,
  l_tlibid(30) TYPE c,
  l_tagid(30) TYPE c,
  l_masterlang TYPE masterlang,
  l_bname TYPE xubname,
  l_name_text TYPE ad_namtext,
  l_laiso TYPE laiso,
  l_sptxt TYPE sptxt,
  l_title TYPE string,
  l_filename TYPE string.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_tag> TYPE ANY,
  <ls_att> TYPE ANY,
  <l_fs> TYPE ANY.

  CONSTANTS:
  lc_content_empty      TYPE c VALUE 'E',
  lc_content_inner_tags TYPE c VALUE 'I',
  lc_content_bsp        TYPE c VALUE 'B',
  lc_content_tagdep     TYPE c VALUE 'T'.

  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'WTAG'
      AND o2pagekey <> space
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    IF NOT <ls_tag> IS ASSIGNED.
      PERFORM get_tabstrip
        USING 'O2_R3TR_WTAG_EXT' space
        CHANGING lt_tabstrip.

      CREATE DATA lo_tag TYPE ('O2TAG').
      ASSIGN lo_tag->* TO <ls_tag>.

      CREATE DATA lo_att TYPE ('O2TAGATT').
      ASSIGN lo_att->* TO <ls_att>.
    ENDIF.

    REFRESH:
    lt_html,
    lt_props,
    lt_general,
    lt_content,
    lt_options,
    lt_att.

    CLEAR:
    <ls_tag>,
    <ls_att>,
    ls_rb,
    ls_att,
    l_filename.

    l_tlibid = <ls_ztadir>-obj_name.
    l_tagid = <ls_ztadir>-o2name.

    SELECT SINGLE * FROM ('O2TAG') INTO <ls_tag>
        WHERE tlibid = l_tlibid
        AND tagid = l_tagid
        AND state = 'A'.

*Properties
*   Short Description
    CLEAR ls_ti.
    ls_ti-name = txt_short_description___2.
    ls_ti-value = <ls_ztadir>-descript.
    ls_ti-input = abap_true.
    APPEND ls_ti TO lt_props.
*   Element Handler Class
    CLEAR ls_ti.
    ls_ti-name = txt_element_handler_class.
    ASSIGN COMPONENT 'TAGCLASS' OF STRUCTURE <ls_tag> TO <l_fs>.
    ls_ti-value = <l_fs>.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_props.
*   BSP Extension Class
    CLEAR ls_ti.
    ls_ti-name = txt_bsp_extension_class.
    ASSIGN COMPONENT 'GENCLASS' OF STRUCTURE <ls_tag> TO <l_fs>.
    ls_ti-value = <l_fs>.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_props.
*Element: content
    ASSIGN COMPONENT 'BCONTENT' OF STRUCTURE <ls_tag> TO <l_fs>.
*   Blank
    CLEAR ls_rb.
    ls_rb-ddtext = txt_blank.
    IF <l_fs> = lc_content_empty.
      ls_rb-checked = abap_true.
    ENDIF.
    APPEND ls_rb TO lt_content.
*   BSP Elements Only
    CLEAR ls_rb.
    ls_rb-ddtext = txt_bsp_elements_only.
    IF <l_fs> = lc_content_inner_tags.
      ls_rb-checked = abap_true.
    ENDIF.
    APPEND ls_rb TO lt_content.
*   BSP Elements and Static HTML
    CLEAR ls_rb.
    ls_rb-ddtext = txt_bsp_elements_and_static_ht.
    IF <l_fs> = lc_content_bsp.
      ls_rb-checked = abap_true.
    ENDIF.
    APPEND ls_rb TO lt_content.
*   Element Interprets Content Itself
    CLEAR ls_rb.
    ls_rb-ddtext = txt_element_interprets_content.
    IF <l_fs> = lc_content_tagdep.
      ls_rb-checked = abap_true.
    ENDIF.
    APPEND ls_rb TO lt_content.
*Further options
*   User-Defined Validation
    CLEAR ls_ti.
    ls_ti-name = txt_user_defined_validation.
    ASSIGN COMPONENT 'VALIDATION' OF STRUCTURE <ls_tag> TO <l_fs>.
    ls_ti-value = <l_fs>.
    ls_ti-flag = abap_true.
    APPEND ls_ti TO lt_options.
*   Iteration over Element Content
    CLEAR ls_ti.
    ls_ti-name = txt_iteration_over_element_con.
    ASSIGN COMPONENT 'ITERATION' OF STRUCTURE <ls_tag> TO <l_fs>.
    ls_ti-value = <l_fs>.
    ls_ti-flag = abap_true.
    APPEND ls_ti TO lt_options.
*   Manipulation of Element Content
    CLEAR ls_ti.
    ls_ti-name = txt_manipulation_of_element_co.
    ASSIGN COMPONENT 'BODYWRITER' OF STRUCTURE <ls_tag> TO <l_fs>.
    ls_ti-value = <l_fs>.
    ls_ti-flag = abap_true.
    APPEND ls_ti TO lt_options.
*   "PAGE DONE" is not returned at end of BSP element
    CLEAR ls_ti.
    ls_ti-name = txt_page_done_is_not_returned_.
    ASSIGN COMPONENT 'NOPAGEDONE' OF STRUCTURE <ls_tag> TO <l_fs>.
    ls_ti-value = <l_fs>.
    ls_ti-flag = abap_true.
    APPEND ls_ti TO lt_options.
*General Data
*   Created by
    CLEAR ls_ti.
    ls_ti-name = txt_created_by___1.
    ASSIGN COMPONENT 'AUTHOR' OF STRUCTURE <ls_tag> TO <l_fs>.
    ls_ti-value = <l_fs>.
    l_bname = <l_fs>.
    PERFORM get_user
      USING l_bname
      CHANGING l_name_text.
    ls_ti-value_text = l_name_text.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_general.
*   Creation Date
    CLEAR ls_ti.
    ls_ti-name = txt_creation_date.
    ASSIGN COMPONENT 'CREATEDON' OF STRUCTURE <ls_tag> TO <l_fs>.
    PERFORM get_date
      USING
        <l_fs>
      CHANGING
        ls_ti-value.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_general.
*   Last Changed
    CLEAR ls_ti.
    ls_ti-name = txt_last_changed.
    ASSIGN COMPONENT 'CHANGEDBY' OF STRUCTURE <ls_tag> TO <l_fs>.
    ls_ti-value = <l_fs>.
    l_bname = <l_fs>.
    PERFORM get_user
      USING l_bname
      CHANGING l_name_text.
    ls_ti-value_text = l_name_text.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_general.
*   Changed On
    CLEAR ls_ti.
    ls_ti-name = txt_changed_on.
    ASSIGN COMPONENT 'CHANGEDON' OF STRUCTURE <ls_tag> TO <l_fs>.
    PERFORM get_date
      USING
        <l_fs>
      CHANGING
        ls_ti-value.
    ls_ti-value_ext_space = abap_true.
    ls_ti-input = abap_true.
    ls_ti-has_value_ext = abap_true.
    APPEND ls_ti TO lt_general.
*Attribute
    SELECT * FROM ('O2TAGATT') INTO <ls_att>
        WHERE tlibid = l_tlibid
        AND state = 'A'
        AND tagid = l_tagid.
      ASSIGN COMPONENT 'ATTID' OF STRUCTURE <ls_att> TO <l_fs>.
      ls_att-attid = <l_fs>.
      ASSIGN COMPONENT 'REQUIRED' OF STRUCTURE <ls_att> TO <l_fs>.
      ls_att-required = <l_fs>.
      ASSIGN COMPONENT 'RTEXPR' OF STRUCTURE <ls_att> TO <l_fs>.
      ls_att-rtexpr = <l_fs>.
      ASSIGN COMPONENT 'BYREF' OF STRUCTURE <ls_att> TO <l_fs>.
      ls_att-byref = <l_fs>.
      ASSIGN COMPONENT 'TYPE' OF STRUCTURE <ls_att> TO <l_fs>.
      ls_att-type = <l_fs>.
      ASSIGN COMPONENT 'DEFVAL' OF STRUCTURE <ls_att> TO <l_fs>.
      ls_att-defval = <l_fs>.
      ASSIGN COMPONENT 'BINDABLE' OF STRUCTURE <ls_att> TO <l_fs>.
      ls_att-bindable = <l_fs>.
      ASSIGN COMPONENT 'TYPTYPE' OF STRUCTURE <ls_att> TO <l_fs>.
      PERFORM get_dom_value_text
        USING
          'O2TYPTYPE'
          <l_fs>
        CHANGING
          ls_att-typtype_txt.
      SELECT SINGLE descript FROM ('TAGATTT') INTO ls_att-descript
          WHERE tlibid = l_tlibid
          AND state = 'A'
          AND langu = sy-langu
          AND tagid = l_tagid
          AND attid = ls_att-attid.
      APPEND ls_att TO lt_att.
    ENDSELECT.
*Title
    l_title = tpt_o2_wtag.
    PERFORM replace_single
      USING
        var_name_value
        <ls_ztadir>-obj_name
      CHANGING
        l_title.
*HTML
    PERFORM html_main_header
      USING
        l_title
        txt_bsp_element
        l_tagid
        txt_active___1
        space
        space
        space
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
*   Properties
    PERFORM html_add_textinput_subboxes
      USING
        lt_props
        txt_element_content
        'ec'
        lt_content
        txt_further_options
        lt_options
        txt_general_data
        lt_general
        'PROPERTIES'
        abap_true
      CHANGING
        lt_html.
*   Attribute
    PERFORM html_add_table
      USING
        'WTAG_ATTR'
        lt_att
        lt_att
        'ATTRIBUTE'
        abap_false
      CHANGING
        lt_html.
*
    PERFORM html_main_footer
      USING
        lt_html.

    CONCATENATE <ls_ztadir>-obj_name '-' l_tagid INTO l_filename.
    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        l_filename
        gc_extension_htm
        abap_true.
  ENDLOOP.

ENDFORM.                    "r3tr_wtag_ext


*-----------------------------------------------------------------------
* o2_r3tr_xslt                                  Transformations
*-----------------------------------------------------------------------
FORM o2_r3tr_xslt.

  DATA:
  lt_html TYPE it_string,
  lt_tabstrip TYPE it_tabstrip,
  l_name(40) TYPE c,
  ls_attributes TYPE st_attributes,
  l_author TYPE xubname,
  l_createdon TYPE dats,
  l_changedon TYPE dats,
  l_bname TYPE xubname,
  l_xslt_id(43) TYPE c,
  l_xslt_name TYPE progname.

  FIELD-SYMBOLS:
  <ls_ztadir> TYPE st_ztadir,
  <ls_xslt_source> TYPE st_o2pageline.



  LOOP AT gt_ztadir ASSIGNING <ls_ztadir>
      WHERE pgmid = 'R3TR'
      AND object = 'XSLT'
      AND downloaded = abap_false.
    <ls_ztadir>-downloaded = abap_true.

    IF lt_tabstrip IS INITIAL.
      PERFORM get_tabstrip
        USING 'O2_R3TR_XSLT' space
        CHANGING lt_tabstrip.
    ENDIF.

    CLEAR:
    ls_attributes,
    l_xslt_name.

    REFRESH:
    lt_html.

    l_name = <ls_ztadir>-obj_name.
*Attributes
    SELECT SINGLE author createdon changedon changedby
      FROM ('O2XSLTDESC')
      INTO (ls_attributes-author, l_createdon,
        l_changedon, ls_attributes-bname)
      WHERE xsltdesc = l_name
      AND state = 'A'
      AND srtf2 = 0.

    l_author = ls_attributes-author.
    PERFORM get_user
      USING l_author
      CHANGING ls_attributes-author_text.
    PERFORM get_date
      USING l_createdon
      CHANGING ls_attributes-date_created.
    PERFORM get_date
      USING l_changedon
      CHANGING ls_attributes-date_last_changed.
    l_bname = ls_attributes-bname.
    PERFORM get_user
        USING l_bname
        CHANGING ls_attributes-name_text.

    ls_attributes-descript = <ls_ztadir>-descript.
    ls_attributes-devclass = <ls_ztadir>-devclass.
    PERFORM get_devclass
      USING ls_attributes-devclass
      CHANGING ls_attributes-devclass_descr.

    PERFORM get_spras
      USING <ls_ztadir>-masterlang
      CHANGING ls_attributes-laiso ls_attributes-sptxt.
*Source
    PERFORM get_trdir_name
      USING l_name 'XT'
      CHANGING l_xslt_name.
*HTML
    PERFORM html_main_header
      USING
        tpt_o2_xslt
        txt_transformation
        <ls_ztadir>-obj_name
        txt_active___1
        space
        space
        'makeDivSize(''SOURCECODE'')'
        lt_tabstrip
        gt_link
      CHANGING
        lt_html.
    PERFORM html_add_attributes_2
      USING
        ls_attributes
        'ATTRIBUTES'
        abap_false
      CHANGING
        lt_html.
    PERFORM add_report_sourcecode
      USING
        l_xslt_name
        l_name
        gc_extension_xsl
        abap_false
        <ls_ztadir>
        'SOURCECODE'
        abap_true
      CHANGING
        lt_html.
*
    PERFORM html_main_footer
      USING
        lt_html.

    PERFORM download
      USING
        lt_html
        <ls_ztadir>-pgmid
        <ls_ztadir>-object
        <ls_ztadir>-obj_name
        gc_extension_htm
        abap_true.
  ENDLOOP.

ENDFORM.                                                    "r3tr_xslt
