Error Page for e107

Formally submitted my three-part fix for the error page distribution with e107.

If you (1) setup the e107 error.php file as your ErrorDocument and (2) try to fetch a page NOT in your e107 installation root that causes an error, the display of the resulting error page is mangled because the server doesn't know where to get all the bits of your theme.

Here's the fix - in three parts.

1) class2.php defines a special constant if it is called by error.php

590a591,598
+ // This will set a constant to indicate that we are displaying the error page.
+ // This triggers a conditional in templates/header_default.php which will add
+ // a <base href= ...> header, which is necessary for the error page to display
+ // correctly if the error was triggered by a page located anywhere other than
+ // the root directory of the installation.
+ if (strstr($_SERVER['PHP_SELF'], 'error.php')) {
+ define("ISERRORPAGE", TRUE);
+ }

2) e107_themes/templates/header_default.php checks for that new constant and if present, adds a <base href=...> tag to the page header. This allows the server to find all the bits of your theme.

40a41,44
+ // This line will add a <base href= ...> header, which is necessary for the error
+ // page to display correctly if the error was triggered by a page located anywhere
+ // other than the root directory of the installation.
+ echo (defined("ISERRORPAGE") ? "<base href='".$e107->http_abs_location("e_BASE","")."' />" : "");

3) error.php had two errors. The first was a typo under the 404 case that displayed the same string (LAN_16) twice. The second was a repetition of LAN_2 in every case, which was completely silly (but not actually an error).

36c36
- <br /><div class='installh'>".LAN_2."<a href='index.php'>".LAN_20."</a></div>";
---
+ <br /><div class='installh'><a href='index.php'>".LAN_20."</a></div>";
40c40
- <br /><div class='installh'>".LAN_2."<a href='index.php'>".LAN_20."</a></div>";
---
+ <br /><div class='installh'><a href='index.php'>".LAN_20."</a></div>";
45,46c45
- <br /><div class='installh'>".LAN_2."
- <br />".LAN_16." <b>{$errTo}</b> ".LAN_16;
---
+ <br /><div class='installh'>".LAN_16." <b>{$errTo}</b> ".LAN_17;
52c51
- <br /><div class='installh'>".LAN_2."<a href='index.php'>".LAN_20."</a></div>";
---
+ <br /><div class='installh'><a href='index.php'>".LAN_20."</a></div>";
55c54
-; <br /><div class='installh'>".LAN_2."<a href='index.php'>".LAN_20."</a></div>";
---
+ <br /><div class='installh'><a href='index.php'>".LAN_20."</a></div>";

Bugtracker