#
# FUNKTION: Erstellung einer HTML-Datei für den Start der Bilder-Galerie
#
INC_NAME_INDEX_START_GALLERY='inc_index_html_file_start_gallery.txt'

# Variablen überprüfen
GALLERY_MAIN_DIRECTORY=${GALLERY_MAIN_DIRECTORY:='gallery'}
GALLERY_FILE_NAME_START_INDEX=${GALLERY_FILE_NAME_START_INDEX:='index.html'}
GALLERY_FILE_NAME_INDEX=${GALLERY_FILE_NAME_INDEX:='index.htm'}
PICTURE_GALLERY_NAME_TITLE_TAG=${PICTURE_GALLERY_NAME_TITLE_TAG:='Kobold'}
GALLERY_CHARSET=${GALLERY_CHARSET:='utf-8'}
# LANGUAGE_NAME_PART_B -> inc_language_selection.txt
LANGUAGE_NAME_PART_B=${LANGUAGE_NAME_PART_B:='EMPTY'}
if [ "${LANGUAGE_NAME_PART_B}" = 'EMPTY' ]
then
echo -e "\nERROR-CODE: CREATE-GALLERY AND TOOLS CREATE-HTML-FILE-START-INDEX 1-1 \nVARIABLE: NOT FOUND \nSCRIPT-NAME: ${INC_NAME_INDEX_START_GALLERY}\n"
exit 1
fi
LANGUAGE_NAME_PART_B=$(echo ${LANGUAGE_NAME_PART_B} | tr [:upper:] [:lower:])
  if [ $? -ge 1 ]
  then
  echo -e "\nERROR-CODE: CREATE-GALLERY AND TOOLS CREATE-HTML-FILE-START-INDEX 1-2 \nSCRIPT-NAME: ${INC_NAME_INDEX_START_GALLERY}\n"
  exit 1
  fi
LANGUAGE_SHORT_CODE=$(echo ${LANGUAGE_NAME_PART_B} | tr [:lower:] [:upper:])
  if [ $? -ge 1 ]
  then
  echo -e "\nERROR-CODE: CREATE-GALLERY AND TOOLS CREATE-HTML-FILE-START-INDEX 1-3 \nSCRIPT-NAME: ${INC_NAME_INDEX_START_GALLERY}\n"
  exit 1
  fi
GALLERY_CHARSET=$(echo ${GALLERY_CHARSET} | tr [:upper:] [:lower:])
 if [ $? -ge 1 ]
 then
 echo -e "\nERROR-CODE: CREATE-GALLERY AND TOOLS CREATE-HTML-FILE-START-INDEX 1-4 \nSCRIPT-NAME: ${INC_NAME_INDEX_START_GALLERY}\n"
 exit 1
 fi
 
# Verzeichnis überprüfen
GALLERY_MAIN_DIRECTORY_PATH="../../${GALLERY_MAIN_DIRECTORY}"
if [ ! -d ${GALLERY_MAIN_DIRECTORY_PATH} ]
then
echo -e "\nERROR-CODE: CREATE-GALLERY AND TOOLS CREATE-HTML-FILE-START-INDEX 2 \nDIRECTORY: »${GALLERY_MAIN_DIRECTORY_PATH}« NOT FOUND \nSCRIPT-NAME: ${INC_NAME_INDEX_START_GALLERY}\n"
exit 1
fi

### BEGINN: Erstellung der HTML-Start-1-Datei
GALLERY_FILE_NAME_START_INDEX_1_PATH="../../${GALLERY_FILE_NAME_START_INDEX}"
GALLERY_HTML_START_INDEX_2_PATH="./${GALLERY_MAIN_DIRECTORY}/${GALLERY_FILE_NAME_INDEX}"
echo -e "<!DOCTYPE html>
<html>
<head>
<title>${PICTURE_GALLERY_NAME_TITLE_TAG} - ${LANGUAGE_SHORT_CODE} - ${GALLERY_FILE_NAME_START_INDEX}</title>
<meta charset=\"${GALLERY_CHARSET}\">
<meta http-equiv=\"refresh\" content=\"0;URL=${GALLERY_HTML_START_INDEX_2_PATH}\">
</head>
<body>

</body>
</html>
" > ${GALLERY_FILE_NAME_START_INDEX_1_PATH}
  if [ $? -ge 1 ]
  then
  echo -e "\nERROR-CODE: CREATE-GALLERY AND TOOLS CREATE-HTML-FILE-START-INDEX 3 \nFILE: CAN NOT WRITE FILE »${GALLERY_FILE_NAME_START_INDEX_1_PATH}« \nSCRIPT-NAME: ${INC_NAME_INDEX_START_GALLERY}\n"
  exit 1
  fi

# Textkodierung prüfen und evtl. ändern
change_text_coding ${GALLERY_FILE_NAME_START_INDEX_1_PATH} ${GALLERY_CHARSET}
### ENDE: Erstellung der HTML-Start-1-Datei
