Open GoogleCodeExporter opened 9 years ago
Original comment by crazy4ch...@gmail.com
on 22 May 2014 at 8:58
Just an idea to help in this direction: some kind of URL 'renderer' that
accepts an associative array and builds the matching GET string. Something
along these lines:
$params = new SmartParams( array( 'currentDB' => $_GET['currentDB'], ... ) );
$params->sort = 'ASC';
// ...
$params->getString( array('table' => 'some_table', 'sort' => 'DESC') );
// produces '?currentDB=...&table=some_table&sort=DESC'
$params->getHTML( array('table' => 'some_table', 'sort' => 'DESC') );
// produces '?currentDB=...&table=some_table&sort=DESC'
It would also cut down on the 100+ occurrences of urlencode and & :)
Original comment by dreadnaut
on 30 May 2014 at 9:00
Yes, agreed. Maybe we should differentiate between 2 kinds of parameters:
1. Kind of "state" parameters, that are in _every_ link like currentDB and
table. We probably set these once and not every time we create a link.
2. The parameters that are changed in this link. This can be "table" when
switching the table, but usually it is some parameter that triggers an action
or something. These parameters are adjusted for every link.
$params= new SmartParams();
// add parameters that are used for all links
$params->add('table'=>'mytable');
$params->add('currentDB'=>'mydb');
//when building a link
$params->getHTML(array('sort'=>'DESC'));
// produces '?currentDB=mydb&table=mytable&sort=DESC'
$params->getHTML(array('table'=>'mytable2'));
// produces '?currentDB=mydb&table=mytable2'
I think it is stupid to add stuff like table and currentDB every time we create
a link. It is very likely that at some point, we forget something otherwise.
Original comment by crazy4ch...@gmail.com
on 30 May 2014 at 9:17
Some short code implementing the above. 'SmartParams' doesn't have to be the
name by the way, we could come up with something better :-p
Original comment by dreadnaut
on 12 Jun 2014 at 1:47
Attachments:
Original issue reported on code.google.com by
crazy4ch...@gmail.com
on 4 Jan 2014 at 7:22