*&---------------------------------------------------------------------*
*&  Include           ZSOFTCOPY_HTML_LINKS                             *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*& 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       *
*&                                                                     *
*&---------------------------------------------------------------------*


*-----------------------------------------------------------------------
* html_links_leaf
*-----------------------------------------------------------------------
FORM html_links_leaf
  USING
    value(i_id)
    value(i_sub_id)
    value(i_name)
    value(i_descript)
  CHANGING
    ct_html TYPE it_string.

  PERFORM html_links_leaf_filename
    USING
      i_id
      i_sub_id
      i_name
      i_name
      i_descript
    CHANGING
      ct_html.
ENDFORM.                    "html_links_leaf


*-----------------------------------------------------------------------
* html_links_leaf_filename
*-----------------------------------------------------------------------
FORM html_links_leaf_filename
  USING
    value(i_id)
    value(i_sub_id)
    value(i_name)
    value(i_filename)
    value(i_descript)
  CHANGING
    ct_html TYPE it_string.

  DATA:
  ls_html TYPE string,
  l_text TYPE string,
  l_title TYPE string,
  l_fname TYPE string.

  l_text = i_name.
  l_title = i_descript.
  PERFORM encode_html CHANGING l_text.
  PERFORM encode_html CHANGING l_title.

  l_fname = i_filename.
  SHIFT l_fname LEFT DELETING LEADING '/'.
  PERFORM replace_all
    USING '<' '-'
    CHANGING l_fname.
  PERFORM replace_all
    USING '>' '-'
    CHANGING l_fname.
  PERFORM encode_uri
    CHANGING l_fname.

  ADD 1 TO g_cnt_link_leaves.

  CONCATENATE
      '<li class="leaf">'
        '<a class="leafLink"'
        ' href="' i_id '/' l_fname '.' gc_extension_htm '"'
        ' id="' i_id '_' i_sub_id '_' g_cnt_link_leaves '"'
        ' onclick="showObject(''' i_id ''',''' l_fname ''');'
            'return false" title="' l_title '">'
          l_text
        '</a>'
      '</li>'
      INTO ls_html.
  APPEND ls_html TO ct_html.
ENDFORM.                    "html_links_leaf_filename


*-----------------------------------------------------------------------
* html_links_leaf_mime
*-----------------------------------------------------------------------
FORM html_links_leaf_mime
  USING
    value(i_id)
    value(i_name)
    value(i_filename)
    value(i_descript)
  CHANGING
    ct_html TYPE it_string.

  DATA:
  ls_html TYPE string,
  l_text TYPE string,
  l_title TYPE string,
  l_fname TYPE string.

  l_text = i_name.
  l_title = i_descript.
  PERFORM encode_html CHANGING l_text.
  PERFORM encode_html CHANGING l_title.

  l_fname = i_filename.
  SHIFT l_fname LEFT DELETING LEADING '/'.
  PERFORM replace_all
    USING '<' '-'
    CHANGING l_fname.
  PERFORM replace_all
    USING '>' '-'
    CHANGING l_fname.
  PERFORM encode_uri
    CHANGING l_fname.

  CONCATENATE
      '<li class="leaf">'
        '<a class="leafLink" href="' i_id '/' l_fname '"'
        ' onclick="window.open(''' i_id '/' l_fname ''');'
            'return false" title="' l_title '">'
          l_text
        '</a>'
      '</li>'
      INTO ls_html.
  APPEND ls_html TO ct_html.
ENDFORM.                    "html_links_leaf_mime


*-----------------------------------------------------------------------
* html_links_leaf_popup
*-----------------------------------------------------------------------
FORM html_links_leaf_popup
  USING
    value(i_id)
    value(i_name)
    value(i_filename)
    value(i_descript)
    value(i_caption)
  CHANGING
    ct_html TYPE it_string.

  DATA:
  ls_html TYPE string,
  l_text TYPE string,
  l_title TYPE string,
  l_fname TYPE string.

  l_text = i_name.
  l_title = i_descript.
  PERFORM encode_html CHANGING l_text.
  PERFORM encode_html CHANGING l_title.

  l_fname = i_filename.
  SHIFT l_fname LEFT DELETING LEADING '/'.
  PERFORM replace_all
    USING '<' '-'
    CHANGING l_fname.
  PERFORM replace_all
    USING '>' '-'
    CHANGING l_fname.
  PERFORM encode_uri
    CHANGING l_fname.

  CONCATENATE
      '<li class="leaf">'
        '<a class="leafLink" href="' i_id '/' l_fname '"'
        ' onclick="parent.parent.showObject(''' i_id '/' l_fname
            ''', ''' i_caption ''');'
            'return false" title="' l_title '">'
          l_text
        '</a>'
      '</li>'
      INTO ls_html.
  APPEND ls_html TO ct_html.
ENDFORM.                    "html_links_leaf_popup


*-----------------------------------------------------------------------
* html_links_node_end
*-----------------------------------------------------------------------
FORM html_links_node_end
  CHANGING
    ct_html TYPE it_string.

  APPEND '</ul></li>' TO ct_html.
ENDFORM.                    "html_links_node_end


*-----------------------------------------------------------------------
* html_links_node_start
*-----------------------------------------------------------------------
FORM html_links_node_start
  USING
    value(i_id)
    value(i_text)
    value(i_filename)
    value(i_descript)
  CHANGING
    ct_html TYPE it_string.

  DATA:
  ls_html TYPE string,
  l_dir TYPE string,
  l_suffix TYPE string,
  l_title TYPE string,
  l_fname TYPE string,
  l_dblclick TYPE string,
  l_info TYPE string.

  l_title = i_descript.
  PERFORM encode_html CHANGING l_title.

  SPLIT i_id AT '__' INTO l_dir l_suffix.

  IF NOT i_filename IS INITIAL.
    l_fname = i_filename.
    SHIFT l_fname LEFT DELETING LEADING '/'.
    PERFORM replace_all
      USING '<' '-'
      CHANGING l_fname.
    PERFORM replace_all
      USING '>' '-'
      CHANGING l_fname.
    PERFORM encode_uri
      CHANGING l_fname.

    CONCATENATE
        ' ondblclick="showObject(''' l_dir ''',''' l_fname ''','
        '''POPUP'',''' txt_info ''');return false"'
        INTO l_dblclick.
    CONCATENATE
        '&#160;<a class="info"'
        ' href="' l_dir '/' l_fname '.' gc_extension_htm '"'
        ' onclick="showObject(''' l_dir ''',''' l_fname ''','
        '''POPUP'',''' txt_info ''');return false">*</a>'
        INTO l_info.
  ENDIF.

  CONCATENATE
      '<li class="node">'
        '<a class="nodeLink" href="#"'
        ' onclick="toggleVisibility(''' i_id ''');return false"'
        l_dblclick
        ' title="' l_title '">'
          i_text
        '</a>'
        l_info
        '<ul id="' i_id '">'
      INTO ls_html.
  APPEND ls_html TO ct_html.
ENDFORM.                    "html_links_node_start
