| View previous topic :: View next topic |
| Author |
Message |
ddn
Joined: 17 Jan 2007 Posts: 8
|
Posted: Wed Jan 17, 2007 10:20 am Post subject: $_POST instead of $_GET |
|
|
Hi,
The datagrid makes use, for the datagrid sorting & pager parameters, of the $_GET session being visible in the URL.
Is it possible to switch this to the $_POST session?
With the "form method post" html syntax, it did not switch.
Consequently when looking into the source of "renderer.php" the function "_buildSortingHttpQuery" tells that $_POST is foreseen but not yet fully implemented.
Is this foreseen in a future version or did I overlook something?
Many thanks.
With kind regards.
ddn |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1003
|
Posted: Wed Jan 17, 2007 12:49 pm Post subject: |
|
|
| Hmm, doesn't the 'extraVars' option already solve your problem? |
|
| Back to top |
|
 |
ddn
Joined: 17 Jan 2007 Posts: 8
|
Posted: Wed Jan 17, 2007 1:31 pm Post subject: |
|
|
Basically I was asked to hide all parameters in $_POST.
This to avoid visible $_GET url parameters.
While extraVars adds parameters to $_GET.
Already thx anyway. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1003
|
Posted: Wed Jan 17, 2007 2:31 pm Post subject: |
|
|
| ddn wrote: | | Basically I was asked to hide all parameters in $_POST. |
Ah, okay, I haven't got this fact from your first post.
But how should this work? For paging this might be easy because the Pager class offers a select box with all pages. But how would you implement this for the column headers (= the sorting links).
If you have a good idea, we might implement it. |
|
| Back to top |
|
 |
ddn
Joined: 17 Jan 2007 Posts: 8
|
Posted: Wed Jan 17, 2007 4:20 pm Post subject: |
|
|
Well,
The current code parses all parameters stored in the URL by the $_GET session.
Additionally if setRequestPrefix() is set, it processes only the parameters with the defined prefix.
The current Datagrid package structure has already foreseen the expansion with boolean flag implementation for either $_GET or $_POST array processing.
Followed by this logical handling to be added to the current package structure.
At initialisation time of request arguments:
If ($Flag == 'Flag_POST'){
When chosen for $_POST:
Create an multidimensional array in the $_POST array
(with a PEAR-DataGrid reserved name).
Here named "_RequestArguments" for sake of documentation.
$_POST['_RequestArguments'] = array();
Add all parameters to this array $_POST['_RequestArguments']
}
ElseIf ($Flag == 'Flag_GET' || $Flag == ''){
When chosen for '$_GET':
Just execute current code.
};
At processing time of request arguments:
If ($Flag == 'Flag_GET'){
//If chosen for '$_GET':
Just execute current code.
Parse all parameters stored in here.
Additionally if setRequestPrefix() is set,
it processes only the parameters with the defined prefix.
}
ElseIf ($Flag == 'Flag_POST'){
// If chosen for $_POST:
Foreach ($_POST['_RequestArguments'] as $Key => $Value){
Parse all parameters stored in here.
Additionally if setRequestPrefix() is set,
it processes only the parameters with the defined prefix.
};
};
Applying these changes, as you indicated in your post, do require a knowleadgable person (as yourself) who is aware or can become aware well enough of the package internals and implications.
With kind regards.
DDN |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1003
|
Posted: Wed Jan 17, 2007 4:44 pm Post subject: |
|
|
| My question was more how you would implement the "links". In the column headers we have currently normal links (using some GET params) for sorting. How do you want to replace them? |
|
| Back to top |
|
 |
ddn
Joined: 17 Jan 2007 Posts: 8
|
Posted: Wed Jan 17, 2007 5:06 pm Post subject: |
|
|
In pseudocode not having investigated in too much detail the package and without pretending anything at all something like this:
| Code: | $Str = '<a href="'
.'http://'
.$_SERVER['HTTP_HOST'];
Foreach ($_POST['_RequestArguments'] as $Key => $Value){
// Parse all parameters stored in here.
// Additionally if setRequestPrefix() is set,
// it processes only the parameters with the defined prefix.
$Str .= .'?'
.$Key
.'='
.$Value
.'&'
};
$Str .= .'">Column Header Text</a>'; |
[/code]
Hopefully this answers your question.
With kind regards.
ddn |
|
| Back to top |
|
 |
ddn
Joined: 17 Jan 2007 Posts: 8
|
Posted: Wed Jan 17, 2007 5:10 pm Post subject: |
|
|
Oops typo.
Please find below correction.
| Code: | $Str = '<a href="'
.'http://'
.$_SERVER['HTTP_HOST'];
.'?'
Foreach ($_POST['_RequestArguments'] as $Key => $Value){
// Parse all parameters stored in here.
// Additionally if setRequestPrefix() is set,
// it processes only the parameters with the defined prefix.
$Str .= .$Key
.'='
.$Value
.'&'
};
$Str .= .'">Column Header Text</a>'; |
For wellformedness reasons one could retrieve and re-append a ("regexed") $_SERVER['REQUEST_URI'] also. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1003
|
Posted: Wed Jan 17, 2007 8:18 pm Post subject: |
|
|
Now I'm really confused. In your first answer you wrote: "This to avoid visible $_GET url parameters." And now you show code which generates new $_GET parameters.
If your only idea is to put some $_POST params into the links for sorting (and paging), then it is likely that we decline this idea. For only some of such params, you can easily use the 'extraVars' option. And for params with huge contents (which are no problem with POST), you might get trouble anyway (GET is not meant for such things). Therefore, I don't see a need for adding *all* $_POST params to the query string.
But maybe you want to clarify what your real request is? |
|
| Back to top |
|
 |
ddn
Joined: 17 Jan 2007 Posts: 8
|
Posted: Thu Jan 18, 2007 10:21 am Post subject: |
|
|
Hi,
Sorry for any confusion. Let's resynchronise.
| Quote: | Basically I was asked to hide all parameters in $_POST.
This to avoid visible $_GET url parameters.
While extraVars adds parameters to $_GET. |
Within the current datagrid packages, the structure herefore is already
partially foreseen.
Within the function _getRequestArgument the if structure checking
$_GET,$_POST, $_COOKIE is already present.
| Code: |
DataGrid.php
-->Structures_DataGrid()
-->_parseHttpRequest()
-->_getRequestArgument()
|
Now I get at the columnheader issue you mention.
Currently the columnheader generation is located in the HTMLTable.php:
| Code: |
HTMLTable.php
-->function buildHeader(&$columns)
-->_buildSortingHttpQuery(..){create $_GET URL for column header}
|
Here it becomes indeed an opportunity since $_POST session management
with a boolean comes into play. When the flag for POST usage is set, the link here created should resubmit thereby checking for and triggering the POST handling code.
| Quote: | | If your only idea is to put some $_POST params into the links for sorting (and paging), then it is likely that we decline this idea. |
The request made to me was to make use of $_POST & "non-visible"
php session management in general for all inhouse php development.
| Quote: | | For only some of such params, you can easily use the 'extraVars' option. |
Unfortunately 'extraVars' adds params to the uri where the request is to hide them.
Apparently this package "works as designed" only with $_GET.
So this question can be closed.
Perhaps we will have time in the future to work on this together once
I can get more intricately acquainted with the PEAR Library packages.
Sincere many thanks for the time you invested in answering and teaching me more about PEAR.
With kind regards.
ddn |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1003
|
Posted: Thu Jan 18, 2007 12:48 pm Post subject: |
|
|
I'm sorry, but I'm still not sure what your real goal is. You wrote about "$_POST session management". I assume that you wanted to write $_SESSION?
Anyway, this seems to be a very special and custom request. Wouldn't just overloading the existing HTML_Table renderer work for you? You could overload some methods and implement the handling there as you need it. If needed, you could also overload the core Structures_DataGrid class. |
|
| Back to top |
|
 |
ddn
Joined: 17 Jan 2007 Posts: 8
|
Posted: Tue Jan 23, 2007 6:12 pm Post subject: |
|
|
Hi,
Well thanks, I'll follow up the advice.
Meanwhile the address bar url is now clean through the use of an iframe.
If circumstances allow me, I'll do and post later on the research results.
Many thx anyway for the support.
Cheers.
DDN |
|
| Back to top |
|
 |
|