##------------------------------------------------------------------------------
## check/my_link.ext
## DE: Erweiterte Prüfung für My Link (Abhängigkeiten, etc.)
## EN: Additional checks for My Link (dependencies e.g.)
##------------------------------------------------------------------------------
##      Creation:  31.12.2005  V0.6.1 Manfred Schliesing <ms1958@web.de>
##      modified:  23.09.2008  V0.6.4 Florian Schlögl    <Florian_Schloegl.Wolfsteam@web.de>
## Last modified:  04.12.2011  V0.6.6 Manfred Schliesing <ms1958@web.de> 
##                             (Anpassung an FLI4L 3.7.x)
##------------------------------------------------------------------------------
if (OPT_MY_LINK)
then
	#--------------------
	# DE: Paket-Identifer für andere Pakete bereitstellen
	# EN: paket identifier for other pakets
	#--------------------
	provides my_link version 0.6.6
	
	#--------------------
	# DE; Abhängigkeit zu einem bestimmten Paket definieren
	# EN: dependencies on onther pakets
	#--------------------
	depends on fli4l version 3.0
	depends on httpd version 3.0
	
	#--------------------
	# DE: passende Sprachdatei mitkopieren
	# EN: copy language file
	#--------------------
	# DE: Sprache ermitteln
	# EN: get language
	if defined (HTTPD_GUI_LANG)
	then
		if (HTTPD_GUI_LANG == "auto")
		then
			set gui_lang=LOCALE
		else
			set gui_lang=HTTPD_GUI_LANG
		fi
	else
		set gui_lang=LOCALE
	fi
	
	# DE Sprachdatei heraussuchen und mitkopieren
	# EN: search and copy language file
	split (gui_lang, lang_tmp_%, ' ', NUMERIC)
	foreach lang in lang_tmp_%
	do
		stat("opt/files/srv/www/lang/my_link.$lang", langfile)
		if (langfile_res == "OK")
		then
			# DE: gefundene Sprachdatei mitkopieren
			# EN: copy language file
			add_to_opt "files/srv/www/lang/my_link.$lang" "mode=444 flags=sh"
		else
			# DE: keine passende Sprachdatei gefunden -> Englisch verwenden
			# EN: language file not found -> use default english
			warning "MY LINK: could not find 'files/srv/www/lang/my_link.$lang', perhaps this file isn't translated yet. Falling back to English."
			stat("files/srv/www/lang/my_link.en", langfile)
			if (langfile_res == "OK")
			then
				add_to_opt "files/srv/www/lang/my_link.en" "mode=444 flags=sh"
			else
				# DE: keine passende Sprachdatei gefunden -> Deutsch verwenden
				# EN: language file not found -> use default german
				warning "MY LINK: could not find 'files/srv/www/lang/my_link.en', perhaps this file isn't translated yet. Falling back to German."
				stat("files/srv/www/lang/my_link.de", langfile)
				if (langfile_res == "OK")
				then
					add_to_opt "files/srv/www/lang/my_link.de" "mode=444 flags=sh"
				else
					# DE: Deutsch-Sprachdatei existiert auch nicht!
					# EN: german language file also does not exist
					error "MY LINK: No default translation found! Check that the paket was correctly installed."
				fi
			fi
		fi
	done
	
	#--------------------
	# DE: Kontrollieren das HTTPD benutzt wird
	# EN: Check that HTTPD is in use
	#--------------------
	if (!OPT_HTTPD)
	then
		error "MY LINK requires OPT_HTTPD='yes'"
	fi
fi