Missing openpopup function in uploaded file

Missing openpopup function in uploaded file

von Joseph Rézeau -
Anzahl Antworten: 0
Nutzerbild von Core developers Nutzerbild von Particularly helpful Moodlers Nutzerbild von Plugin developers Nutzerbild von Testers Nutzerbild von Translators

Using Moodle version 1.3.2 with Glossary module v 1.25.4.1

The auto-linking procedure of Moodle parses the Resource files and adds the appropriate hyperlinks to the HTML code or plain text.

The resulting code looks something like this:

(1) <P>In the <A class=autolink title="Archaeology Glossary: mesolithic" Xonclick="return openpopup('/mod/glossary/showentry.php?courseid=2\&concept=mesolithic', 'entry', 'menubar=0,location=0,scrollbars,resizable,width=600,height=450', 0);" href="http://localhost/moodle/mod/glossary/showentry.php?courseid=2&concept=mesolithic" target=entry>mesolithic</A> age, ...</P>

However, there is a difference between the displaying of the internal resources (plain text or HTML) and the downloaded files. When an internal resource file is displayed, the source code contains a number of javascript functions among which is the openpopup() function, called by the onclick in the autolink hyperlink (see above).

(2) function openpopup(url,name,options,fullscreen) {
  fullurl = "http://localhost/moodle" + url;
  windowobj = window.open(fullurl,name,options);
  if (fullscreen) {
     windowobj.moveTo(0,0);
     windowobj.resizeTo(screen.availWidth,screen.availHeight);
  }
  windowobj.focus();
  return false;
}
In the downloaded files, the autolink parser only adds the hyperlink coding (1). If the user clicks on an auto-linked hyperlink and the Javascript debugger is activated, he gets an error message ("Object not found"). The linking still works, because of the second part of the coding (href= etc.) but in a full-size window, not a nice pop-up one...

Suggested solution:

The Moodle Glossary auto-linking procedure (I think it's in the moodle\mod\glossary\filter.php file) could be modified to dynamically write the openpopup() function into the head section of downloaded files when they are displayed. Then we could do without the (useless) href URL reference in (1) and replace it with a simple href=# (or something similar)...

Joseph