Please, look that the snippet of code below.
As you can see, the contents of an html file is being echo'd:
Note, the following line found in the code above changes the current directory to the directory that contains the static html file:PHP Code:class statichtmlViewstatichtml extends JView
{
function display($tpl = null){
:
:
:
if ( $htmlFile ){
$fileContents = @file_get_contents($htmlFile);
if ( !empty($fileContents) ){
$contents = $fileContents;
$source_path = dirname($htmlFile);
//set the current directory to the html file's directory
$chng = chdir($source_path);
echo $contents;
}
}
$chng = chdir($source_path);
The line above is moving the 'current dirctory' to the following:
C:\Programs\Tools\PHP\XAMPP\htdocs\joomla_development\Production\PHPXref_Framework\libraries\joomla
Again, that's where the html document referenced in the variable, $htmlFile, is actually stored:
C:\Programs\Tools\PHP\XAMPP\htdocs\joomla_development\Production\PHPXref_Framework\libraries\joomla\factory.php.source.html
$contents = JComponentHelper::renderComponent($component);
What comes out of the above variable, $contents, is the following:
Changing the current directory is an attempt to satisfy the 'relative' url references, href="../../, found in the html code above.HTML Code:<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>PHPXRef 0.7 : Joomla! Framework : /libraries/joomla/factory.php source</title> <link rel="stylesheet" href="../../sample.css" type="text/css"> <link rel="stylesheet" href="../../sample-print.css" type="text/css" media="print"> <style id="hilight" type="text/css"></style> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> </head> <body bgcolor="#ffffff" text="#000000" link="#801800" vlink="#300540" alink="#ffffff"> <table class="pagetitle" width="100%"> <tr> <td valign="top" class="pagetitle"> [ <a href="../../index.html">Index</a> ] </td> </td> <td align="right" class="pagetitle"> <h2 style="margin-bottom: 0px">Joomla! Framework</h2> </td> </tr> </table>
Below is the result wheb I actually run the Joomla! website the static html is displayed:
As you can see, it makes an effort to resolve the URL 'relative' references and changes them to the following:HTML Code:<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd"> <html> <head> <title>PHPXRef 0.7 : Joomla! Framework : /libraries/joomla/factory.php source</title> <link rel="stylesheet" href="/joomla_development/Production/../../sample.css" type="text/css"> <link rel="stylesheet" href="/joomla_development/Production/../../sample-print.css" type="text/css" media="print"> <style id="hilight" type="text/css"></style> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> </head> <body bgcolor="#ffffff" text="#000000" link="#801800" vlink="#300540" alink="#ffffff"> <table class="pagetitle" width="100%"> <tr> <td valign="top" class="pagetitle"> [ <a href="/joomla_development/Production/../../index.html">Index</a> ] </td> <td align="right" class="pagetitle"> <h2 style="margin-bottom: 0px">Joomla! Framework</h2> </td> </tr> </table>
href="/joomla_development/Production/../../
As a result, the CSS references and Anchor elements are all wrong the so the page doesn't work when clicking on links, and the layout is just plain ugly!
But it is close....all I need to do is resolve the URL relative references.
I thought maybe changing to the directory that actually contains the html file would help resolve the relative URL references, but it does not.
Would I have to go through the document with preg_replace() for example and explicitly update the URL's?
You see, how Joomla! works as a CMS is that it will take the 'buffered' content (currently being echo'd from the routine you see above), it then sets the response header and echo's it all back as a response.
Now, at some point an effort is made to resolve the relative URL references but it only gets as close as prefixing the 'root directory' to the relative URL references. (i.e. href="/joomla_development/Production/../../ )
It should actually be the following:
/joomla_development/Production/PHPXref_Framework/libraries/joomla
Any ideas?
Maybe I should post this question on an 'HTML' forum??
Cheers.




Bookmarks