[Solar-talk] Helper_Script mod
Paul M Jones
pmjones at solarphp.com
Thu Sep 7 07:11:27 PDT 2006
On Sep 6, 2006, at 1:12 PM, Paul M Jones wrote:
>> Rodrigo Moraes wrote:
>>> Yes, that's what I need: to call the scripts using the full url, to
>>> avoid repeated loading in different subdomains, and I think in the
>>> future also for different domains.
>>>
>>
>> I think both are likely scenarios since a significant number of sites
>> serve static content this way.
>
> Clay's plan is to modify publicHref() to look for an 'http' prefix on
> href strings, and use the absolute href in that case; otherwise,
> it'll be regarded as a relative local href.
>
> Hm, perhaps I should modify the underlying Solar_Uri class to
> recognize the difference; e.g., have it look at HTTP_HOST and compare
> to the requested URI...
I have just committed a change to branches/dev Solar_Uri that makes
it a little bit smarter when it comes to off-site URIs.
1. Solar_Uri now uses SERVER_NAME now instead of HTTP_HOST. My
understanding is that SERVER_NAME is determined by PHP/webserver, and
HTTP_HOST is sent by the client, so SERVER_NAME should be more
reliable and secure.
2. Solar_Uri::fetch() now compares Solar_Uri::$host to SERVER_NAME.
If they are the same, fetch() returns a partial/relative URI. If
they are different, fetch() returns a full/absolute URI. You can
still force a full URI with fetch(true) and force a partial URI with
fetch(false).
Because Solar_Uri_Action and Solar_Uri_Public descend from Solar_Uri,
the new behavior exists in them as well. And because the publicHref
() helper uses Solar_Uri_Public, *it* should have the new behavior too.
Had to modify one Solar_Uri test to make it pass, by forcing fetch
(false) where I used to do fetch(null).
Try it out, let me know if it works the way you expect it should.
--
Paul M. Jones <http://paul-m-jones.com>
Solar: Simple Object Library and Application Repository
for PHP5. <http://solarphp.com>
Savant: The simple, elegant, and powerful solution for
templates in PHP. <http://phpsavant.com>
More information about the solar-talk
mailing list