Closed GoogleCodeExporter closed 9 years ago
sorry for my bad english and lame pasting text of code
Original comment by Unloved....@gmail.com
on 12 Feb 2010 at 1:27
found some bugs, here is new version (recursion is slowing but it's my only
version
how to solve the problem)
public static function recursivePathInfoArrayParser($key,$val)
{
while (($pos=strpos($key,'['))!==false &&
($pos2=strpos($key,']',$pos+1))!==false)
{
if($pos2!=$pos+1)
{
$ckey=substr($key,$pos+1,$pos2-$pos-1);
}
if ($ckey)
{
return
$result=array($ckey=>self::recursivePathInfoArrayParser(substr($key,$pos2+1,strl
en($key)-$pos2),$val));
}
else
{
return
$result=array($ckey=>self::recursivePathInfoArrayParser(substr($key,$pos2+1,strl
en($key)-$pos2),$val));
}
}
return $val;
}
/**
* Parses a path info into URL segments and saves them to $_GET and $_REQUEST.
* @param string path info
* @since 1.0.3
*/
public static function parsePathInfo($pathInfo)
{
if($pathInfo==='') return;
$segs=explode('/',$pathInfo.'/');
$n=count($segs);
for($i=0;$i<$n-1;$i+=2)
{
$key=$segs[$i];
if($key==='') continue;
$value=$segs[$i+1];
if(($pos=strpos($key,'['))!==false &&
($pos2=strpos($key,']',$pos+1))!==false)
{
$name=substr($key,0,$pos);
$value=self::recursivePathInfoArrayParser(substr($key,substr($key,$pos2+1,strlen
($key)-$pos2)),$value);
if (!is_array($_REQUEST[$name])) {$_REQUEST[$name]=array();};
$value=array_merge_recursive($_REQUEST[$name],$value);
$_REQUEST[$name]=$_GET[$name]=$value;
}
else
$_REQUEST[$key]=$_GET[$key]=$value;
}
}
Original comment by Unloved....@gmail.com
on 12 Feb 2010 at 2:57
Original comment by qiang.xue
on 27 Feb 2010 at 3:44
Move to 1.1.3 release.
Original comment by qiang.xue
on 2 May 2010 at 2:19
Original comment by qiang.xue
on 6 Jul 2010 at 4:57
Move to 1.1.4.
Original comment by qiang.xue
on 2 Sep 2010 at 4:09
1.1.5
Original comment by qiang.xue
on 2 Sep 2010 at 4:09
Out of time. Set for 1.1.6 milestone.
Original comment by qiang.xue
on 12 Nov 2010 at 1:54
Another option would be to use something like:
preg_match_all('/\[(.*?)\]/',$name,$m);
i'm just not sure about how bad this would affect performace, though. Maybe
first test for a '[' in $key and only use the regex if it contains one.
Original comment by haertl.mike@gmail.com
on 15 Dec 2010 at 9:02
The other question is, if we need to do full recursion, or if 2 levels would be
sufficient. The most common scenario i have is a filter form (method=get) with
a checkboxlist to select multiple filter values for an attribute. If there's a
grid view on that page, the pager links will contain path-encoded filter
attributes.
More details here:
http://www.yiiframework.com/forum/index.php?/topic/14178-allow-array-attributes-
with-urlformat-path/
Original comment by haertl.mike@gmail.com
on 15 Dec 2010 at 9:08
Set for next milestone.
Original comment by qiang.xue
on 15 Jan 2011 at 7:25
This issue was closed by revision r3100.
Original comment by qiang.xue
on 19 Mar 2011 at 6:10
Original issue reported on code.google.com by
Unloved....@gmail.com
on 12 Feb 2010 at 1:25