After some issues with TinyMCE and the way it deals with URL's I decided to do some digging around.
What I want to do
I want to be able to add relative URL's within WYSIWYG-content. I am using TinyMCE as my text-editor-of-choice inside Moodle 2. I want to use relative URL's because:
1.) the site / domain where I edit content might not necessarily be the site / domain through which this content is made available to the public, so if I am editing a site on domain A it will probably not display properly on domain B with full URL's; this is not a highly unlikely scenario is it? I can imagine you host different courses on one installation made available via different domains?
2.) I might want to move the entire site at some point without having to worry about some absolute URL's still being stuck on the old domain, I assume there is no "intelligent logic" that will automatically alter the domain-part of URL's as they are stored inside the WYSIWYG-texts right? Because how would this logic be able to distinguish between a full URL which is supposed to be an internal link and a "proper" external URL?
What I am thinking of doing
The only thing I have gathered sofar to accomplish the use (and enforcing) of relative URL's -which leaves external URL's (URL's clearly pointing to a different domain) alone, TinyMCE is at least that intelligent- is setting the relative_urls parameter value in lib/editor/tinymce/lib.php to true.
However...
Relative URL's still go awry because there is no base href present in the theme layouts (in the head part the following method is called: $OUTPUT->standard_head_html(), this does not contain a base href). I would have expected the <base href="" /> tag would be present by default through the standard_head_html() method or through $CFG->additionalhtmlhead inside that method, with $CFG->wwwroot as its default value. If this would be available by default (would be a nice addition, and I cannot think of a reason why this would break functionality) relative URL's would work "out of the box".
So my question is
Once I set the relative_urls parameter to true, what should I do? I want to use / enforce relative URL's in my entire Moodle installation without having to alter all my layouts so I either:
1.) add <base href="" /> to the standard_head_html() method with $CFG->wwwroot as its default value; I know this is "hacking" the core, but I feel like this should be present by default in Moodle
2.) add <base href="" /> to $CFG->additionalhtmlhead though I don't feel as if this is the right place to put such a "standard" thing
EDIT: Actually, the base href should perhaps even be one of the first elements in the head-tag, so it can precede relative calls to CSS and JavaScript files and such?
Which solution should I take, are there any other solutions to this problem (making relative URL's work / enforcing these)?
Thanks in advance for shedding any light on this topic.