joomla/joomla-cms — pull request #4310 by jo-sf (2014-09-19 18:59:48+00:00)
Title: Allow relative URLs for links A/B/C in articles

Suppose you have a Joomla website that is reachable via different domain names or via HTTP and HTTPS. If you want to use the links A/B/C in your articles (I assume that your template knows what to do with these, which is the case e.g. with the Protostar template) you currently have to decide which of your domain names you want to use resp. whether you want to use HTTP or HTTPS as protocol if you want to assign links to other pages within your website to the links A/B/C.

This PR proposes changes which allow to assign internal links to the links A/B/C.

About testing these changes:
- it is possible to assign to the links A/B/C both in the backend and in the frontend, but for the frontend it must be enabled first in the options menu of the article manager
- there are four cases to be considered in testing:
- Joomla is installed in the document root of your webserver
- SEO URL rewriting is not active (means: all server relative paths start with "index.php")
- SEO URL rewriting is active
- Joomla is installed in a subdirectory of the document root of your webserver
- SEO URL rewriting is not active (means: all server relative paths start with the subdirectory followed by "index.php")
- SEO URL rewriting is active

For testing I used the fruit shop welcome page from the example installation but any other pages should work as well. I added links to the "Apples", "Bananas" and "Tamarind" pages to the "Welcome" page of the fruit shop.

What should work with these changes (and what not) - examples based upon the fruit shop pages:
- document root installation, no URL rewriting
- index.php/fruit-encyclopedia/38-a => /index.php/fruit-encyclopedia/38-a
- /index.php/fruit-encyclopedia/38-a => will not be changed
- http://<ServerName>/index.php/fruit-encyclopedia/38-a => will not be changed
- document root installation, URL rewriting
- fruit-encyclopedia/38-a.html => /fruit-encyclopedia/38-a.html
- /fruit-encyclopedia/38-a.html => will not be changed
- http://<ServerName>/fruit-encyclopedia/38-a.html => will not be changed
- subdirectory installation (j3/), no URL rewriting
- index.php/fruit-encyclopedia/38-a => /j3/index.php/fruit-encyclopedia/38-a
- j3/index.php/fruit-encyclopedia/38-a => /j3/j3/index.php/fruit-encyclopedia/38-a (wrong!)
- /j3/index.php/fruit-encyclopedia/38-a => will not be changed
- http://<ServerName>/j3/index.php/fruit-encyclopedia/38-a => will not be changed
- subdirectory installation (j3/), URL rewriting
- fruit-encyclopedia/38-a.html => /j3/fruit-encyclopedia/38-a.html
- j3/fruit-encyclopedia/38-a.html => /j3/j3/fruit-encyclopedia/38-a.html (wrong!)
- /j3/fruit-encyclopedia/38-a.html => will not be changed
- http://<ServerName>/j3/fruit-encyclopedia/38-a.html => will not be changed

I know that there are other components in Joomla which also allow to enter URLs, e.g. the contact manager. It is probably also in those components of interest to allow internal URLs beside the external URLs currently only allowed there. If you enter a relative URL (means: URL without protocol etc.) the library routines do their best to convert this URL into an external URL (see libraries/joomla/form/form.php for details) but by principle it cannot work well always though I found an error in this part and corrected it as part of my changes.

If you now have a sort of deja-vu this is no wonder! The above PR description is nearly identical to PR #4309 since it covers the same topic but for the Joomla 2.5.x branch. There are some differences though which are caused by the punycode support introduced with Joomla 3 and the support of some HTML 5 attributes, especially the type="url" attribute for input fields.