-my $htdocs = C4::Context->config('intrahtdocs');
-my ( $theme, $lang ) = themelanguage( $htdocs, $from, "intranet", $query );
-unless ( -e "$htdocs/$theme/$lang/$from" ) {
- $from = "modules/help/nohelp.tt";
- ( $theme, $lang ) = themelanguage( $htdocs, $from, "intranet", $query );
-}
-my $template = C4::Templates->new('intranet', "$htdocs/$theme/$lang/$from");
+# We need to call get_template_and_user to let it does the job correctly
+# for the language
+my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user(
+ {
+ template_name => "intranet-main.tt", # Just a valid template path
+ query => $query,
+ type => "intranet",
+ authnotrequired => 1,
+ }
+);
+
+# find the script that called the online help using the CGI referer()
+our $refer = $query->param('url');
+$refer = $query->referer() if !$refer || $refer eq 'undefined';