Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
a946a863
Commit
a946a863
authored
Feb 11, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed parseUrl.
parent
f31369e7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
13 deletions
+23
-13
UrlRule.php
framework/web/UrlRule.php
+23
-13
No files found.
framework/web/UrlRule.php
View file @
a946a863
...
@@ -77,9 +77,9 @@ class UrlRule extends Object
...
@@ -77,9 +77,9 @@ class UrlRule extends Object
$length
=
strlen
(
$match
[
0
][
0
]);
$length
=
strlen
(
$match
[
0
][
0
]);
$offset
=
$match
[
0
][
1
];
$offset
=
$match
[
0
][
1
];
if
(
$this
->
pattern
[
$offset
-
1
]
===
'/'
&&
$this
->
pattern
[
$offset
+
$length
]
===
'/'
)
{
if
(
$this
->
pattern
[
$offset
-
1
]
===
'/'
&&
$this
->
pattern
[
$offset
+
$length
]
===
'/'
)
{
$tr
[
"
<
$name
>"
]
=
"(?P<
$name
>(?:/
$pattern
)?)
"
;
$tr
[
"
/<
$name
>"
]
=
"(/(?P<
$name
>
$pattern
))?
"
;
}
else
{
}
else
{
$tr
[
"<
$name
>"
]
=
"(?P<
$name
>
(?:
$pattern
)?)
"
;
$tr
[
"<
$name
>"
]
=
"(?P<
$name
>
$pattern
)?
"
;
}
}
}
else
{
}
else
{
$tr
[
"<
$name
>"
]
=
"(?P<
$name
>
$pattern
)"
;
$tr
[
"<
$name
>"
]
=
"(?P<
$name
>
$pattern
)"
;
...
@@ -93,7 +93,7 @@ class UrlRule extends Object
...
@@ -93,7 +93,7 @@ class UrlRule extends Object
}
}
$this
->
template
=
preg_replace
(
'/<(\w+):?([^>]+)?>/'
,
'<$1>'
,
$this
->
pattern
);
$this
->
template
=
preg_replace
(
'/<(\w+):?([^>]+)?>/'
,
'<$1>'
,
$this
->
pattern
);
$this
->
pattern
=
'#^'
.
strtr
(
$this
->
template
,
$tr
)
.
'$#u'
;
$this
->
pattern
=
'#^'
.
trim
(
strtr
(
$this
->
template
,
$tr
),
'/'
)
.
'$#u'
;
if
(
$this
->
routeParams
!==
array
())
{
if
(
$this
->
routeParams
!==
array
())
{
$this
->
routeRule
=
'#^'
.
strtr
(
$this
->
route
,
$tr2
)
.
'$#u'
;
$this
->
routeRule
=
'#^'
.
strtr
(
$this
->
route
,
$tr2
)
.
'$#u'
;
...
@@ -102,7 +102,26 @@ class UrlRule extends Object
...
@@ -102,7 +102,26 @@ class UrlRule extends Object
public
function
parseUrl
(
$pathInfo
)
public
function
parseUrl
(
$pathInfo
)
{
{
if
(
!
preg_match
(
$this
->
pattern
,
$pathInfo
,
$matches
))
{
return
false
;
}
$params
=
$this
->
defaults
;
$tr
=
array
();
foreach
(
$matches
as
$name
=>
$value
)
{
if
(
$value
!==
''
)
{
if
(
isset
(
$this
->
routeParams
[
$name
]))
{
$tr
[
$this
->
routeParams
[
$name
]]
=
$value
;
}
elseif
(
isset
(
$this
->
paramRules
[
$name
]))
{
$params
[
$name
]
=
$value
;
}
}
}
if
(
$this
->
routeRule
!==
null
)
{
$route
=
strtr
(
$this
->
route
,
$tr
);
}
else
{
$route
=
$this
->
route
;
}
return
array
(
$route
,
$params
);
}
}
public
function
createUrl
(
$route
,
$params
)
public
function
createUrl
(
$route
,
$params
)
...
@@ -115,7 +134,6 @@ class UrlRule extends Object
...
@@ -115,7 +134,6 @@ class UrlRule extends Object
foreach
(
$this
->
routeParams
as
$name
=>
$token
)
{
foreach
(
$this
->
routeParams
as
$name
=>
$token
)
{
if
(
isset
(
$this
->
defaults
[
$name
])
&&
strcmp
(
$this
->
defaults
[
$name
],
$matches
[
$name
])
===
0
)
{
if
(
isset
(
$this
->
defaults
[
$name
])
&&
strcmp
(
$this
->
defaults
[
$name
],
$matches
[
$name
])
===
0
)
{
$tr
[
$token
]
=
''
;
$tr
[
$token
]
=
''
;
$tr
[
"/
$token
/"
]
=
'/'
;
}
else
{
}
else
{
$tr
[
$token
]
=
$matches
[
$name
];
$tr
[
$token
]
=
$matches
[
$name
];
}
}
...
@@ -137,7 +155,6 @@ class UrlRule extends Object
...
@@ -137,7 +155,6 @@ class UrlRule extends Object
unset
(
$params
[
$name
]);
unset
(
$params
[
$name
]);
if
(
isset
(
$this
->
paramRules
[
$name
]))
{
if
(
isset
(
$this
->
paramRules
[
$name
]))
{
$tr
[
"<
$name
>"
]
=
''
;
$tr
[
"<
$name
>"
]
=
''
;
$tr
[
"/<
$name
>/"
]
=
'/'
;
}
}
}
elseif
(
!
isset
(
$this
->
paramRules
[
$name
]))
{
}
elseif
(
!
isset
(
$this
->
paramRules
[
$name
]))
{
return
false
;
return
false
;
...
@@ -163,11 +180,4 @@ class UrlRule extends Object
...
@@ -163,11 +180,4 @@ class UrlRule extends Object
}
}
return
$url
;
return
$url
;
}
}
public
function
parse
(
$pathInfo
)
{
$route
=
''
;
$params
=
array
();
return
array
(
$route
,
$params
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment