Non-AJAX version helpers
Two helper functions are provided to quickly generate urls for parameters for the non-AJAX version of Lichen. They differ only in their output.
They are in include/interface.inc.php.
genLinkQuery
The genLinkQuery() function takes several associative arrays and generates the query part of a url based on the input.
Declaration:
genLinkQuery($baseData, $overData = array(), $killData = array())
Where:
- $baseData is the request parameters to include in the URL.
- $overData is the data to replace in $baseData - if a key exists in this array and in $baseData, it replaces the value in $baseData. If the key does not exist in $baseData, it is added to the request string.
- $killData is a list of keys that will be removed and not appear in the final output.
The parameters are escaped appropriately for a URL. The return value is a string, ready to be used directly after a "?" in a URL.
Examples:
genLinkQuery( array( "mailbox" => "INBOX", "sequence" => "list" ) );
returns "mailbox=INBOX&sequence=list"
genLinkQuery( array( "mailbox" => "INBOX", "sequence" => "list" ), array( "sequence" => "comp" ) );
returns "mailbox=INBOX&sequence=comp"
genLinkQuery( array( "mailbox" => "INBOX", "sequence" => "list" ), array( "page" => "10" );
returns "mailbox=INBOX&sequence=list&page=10"
genLinkQuery( array( "mailbox" => "INBOX", "sequence" => "list", "page" => "10", "search" => "slashdot" ),
array( "mailbox" => "Newsletters" ),
array( "page", "search" ) );
returns "mailbox=Newsletters&sequence=list"
genLinkForm
genLinkForm() does the same thing as genLinkQuery(), except that it returns <input type="hidden"> fields for all the data instead, ready to go inside a form to be posted back.
genLinkForm() takes two additional (optional) parameters:
- $formName - the name of a form to generate (and inserted as the name and id attributes of the form). If not present, no opening <form> tag is generated. (note, no </form> tag is ever generated).
- $formAction - the URL to post the form back to. Must be specified if $formName is given.
Quirk
This documentation is longer than the implementation of both of these functions.
