Re: Re: [PEPr] Comment on Console::Console_Getargs
| From: | Clay Loveless | Date: | Thu, 29 Apr 2004 11:27:37 +0000 |
| Subject: | Re: Re: [PEPr] Comment on Console::Console_Getargs | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-28547@lists.php.net to get a copy of this message | ||
On 4/29/04 3:58 AM Pacific Time, Lukas Smith (smith@backendmedia.com) wrote:
> Sergio Carvalho wrote:
>
>> Lukas Smith wrote:
>>
>>> this can be quite cool. for example my www parser can handle
>>> mod_rewrite as well as get/post. with a single change in my config
>>> file i can make my entire system use mod_rewrite for parameter passing.
>>
>>
>> What do you mean handle mod_rewrite? Extract information from 'nice'
>> URLs? Such as when you rewrite:
>> /xpto/pear.php?f=foo --> /xpto/foo/
>> That'd be quite cool.
>
> something along those lines ..
>
> usually you work with key value pairs however.
> my system can however also be configured to expect a certain param order
> for part of the url string and in this case the key can be omitted
This is really funny -- I had a brainstorm just this evening and was just
writing up a little spec document for myself that I planned to turn into a
proposal for "Tools_UrlTransform".
The idea is to use output buffering to convert all URLs on a page from this:
/path/to/script.php?f=foo&b=bar&abc=xyz
To this:
/path/to/script.php/f!foo/b!bar/abc!xyz/throwaway.html
Two basic methods:
Tools_UrlTransform::Encode()
----------------------------
Does conversion along the lines of the above with an output buffering
callback.
Settable public properties include:
- key-val separator (one of "-" | "_" | "." | "!" |
"~" | "*" | "'" | "(" |
")") (whatever separator is chosen would then be encoded in the values to
retain them within if they happen to be in there).
- key to ignore
(in above example, setting "ignore_key" to "abc" would result in a URL like
this: /path/to/script.php/f!foo/b!bar/throwaway.html?abc=xyz)
- throwaway
(something to tack on the end of a generated URL for asthetic purposes that
would be discarded in the Tools_UrlTransform::Decode() method)
Tools_UrlTransform::Decode()
-----------------------------
Takes the "made up" URL and converts it back to what was originally
intended.
For example:
/path/to/script.php/f!foo/b!bar/throwaway.html?abc=xyz
Would parse $_SERVER['PATH_INFO'] out to:
$_REQUEST['f'] = 'foo';
$_REQUEST['b'] = 'bar';
$_REQUEST['abc'] = 'xyz';
$_SERVER['QUERY_STRING'] = 'f=foo&b=bar&abc=xyz';
... Ignoring the throwaway aspect of PATH_INFO.
This could be dropped into the top of any script/page to convert URLs.
(Ha -- just as I finish writing this, I see Bertrand's e-mail pointing to
the Ismo framework, which has Ismo_Core_Url, which does almost exactly what
I just described.) Heh.
Anyway, this seems like it would be a cool and handy standalone package.
Worth pursuing to a full proposal?
-Clay
--
Killersoft.com