SitePoint Sponsor |
|
User Tag List
Results 26 to 46 of 46
-
Feb 13, 2006, 14:32 #26
Originally Posted by Ren
-
Feb 19, 2006, 14:10 #27
After some sunday hacking, added named wildcard support, turned out fairly easy.
Also included a simple example dealing with dates.
PHP Code:function testWildcardWithDefault()
{
$route = new Route('userblog', '*url/:username',
array('controller' => 'blog', 'action' => 'view', 'username' => 'george'));
/*
Due to the default username, the whole path is treated as part of the wildcard.
*/
$url = new Url('some/long/url/george');
$this->assertEqual($route->isMatch($url),
array('controller' => 'blog', 'action' => 'view', 'username' => 'george',
'url' => 'some/long/url/george'));
$url = new Url('some/other/stuff/fred');
$this->assertEqual($route->isMatch($url),
array('controller' => 'blog', 'action' => 'view', 'username' => 'george',
'url' => 'some/other/stuff/fred'));
}
function testWildcardWithoutDefault()
{
$route = new Route('userblog', '*url/:username',
array('controller' => 'blog', 'action' => 'view'));
/*
Because the username now doesn't have a default, it is always extracted from path.
*/
$url = new Url('some/long/url/george');
$this->assertEqual($route->isMatch($url),
array('controller' => 'blog', 'action' => 'view',
'username' => 'george',
'url' => 'some/long/url'));
$url = new Url('some/other/stuff/fred');
$this->assertEqual($route->isMatch($url),
array('controller' => 'blog', 'action' => 'view', 'username' => 'fred',
'url' => 'some/other/stuff'));
}
Last edited by Ren; Feb 19, 2006 at 19:40. Reason: Slight bug squashed.
-
Feb 19, 2006, 14:43 #28
- Join Date
- May 2005
- Location
- Finland
- Posts
- 608
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Ren
-
Feb 19, 2006, 15:09 #29
- Join Date
- Jan 2003
- Posts
- 5,748
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Well, not had a look at the ZIP yet, I hope to find some time this week, but I agree that this is very interesting, and hope to gleam something from it myself, now...
As for hailing Ren, I'm a God so I'm just as about the highest being that there is possible? Surely there can't be anyone who is above a God?
-
Feb 19, 2006, 15:16 #30
- Join Date
- May 2005
- Location
- Finland
- Posts
- 608
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Dr Livingston
-
Feb 19, 2006, 17:05 #31
- Join Date
- Sep 2005
- Posts
- 122
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Umm,
hahaha!
-
Feb 19, 2006, 18:40 #32
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Dr Livingston
Jason Sweat ZCE - jsweat_php@yahoo.com
Book: PHP Patterns
Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
Detestable (adjective): software that isn't testable.
-
Feb 20, 2006, 02:29 #33
- Join Date
- Jul 2004
- Location
- The Netherlands
- Posts
- 170
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by sweatje
-
Feb 20, 2006, 04:30 #34
Ren: Looked thru your code, nice work
. About the whole route thing tho - great idea but won't it leave to kinda duplicated code? If I need to create an instance on every page I wanna generate an URL to the news archive and then call the kinda bulky route constructor with the correct params to get my route object/link/url - and how does the generated URLs look(Is some type of mod_rewrite required?) ?
-
Feb 20, 2006, 04:44 #35
Originally Posted by thr
-
Feb 20, 2006, 04:48 #36
ok, ah the 404-hack - if you rewrite the header sent it's perfectly viable tho :]. The code looks realy sleak, I'll give the route thingy a shot later tonight maybee and hack some myself - realy nice work tho
-
Feb 20, 2006, 04:51 #37
- Join Date
- Jul 2004
- Location
- The Netherlands
- Posts
- 170
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Ren
Just had a look at your tests. What if you want to distinguish a wildcard from a static component? I can imagine routes with mixed dynamic and static components like /static/:dynamic:/another_static/:another_dynamic.
-
Feb 20, 2006, 04:57 #38
Originally Posted by michel
-
Feb 20, 2006, 05:04 #39
- Join Date
- Jul 2004
- Location
- The Netherlands
- Posts
- 170
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by thr
-
Feb 20, 2006, 05:10 #40Off Topic:
michel: All hosts don't give you the ability to install mod_rewrite, etc. - I just made a remark that it's possible to work around - now let's stay on topic as this is realy intereseting.
-
Feb 20, 2006, 05:11 #41
Originally Posted by michel
PHP Code:function testTwoDynamicsSeperatedByStatic()
{
$route = new Route('a', '/static/:dynamic/another_static/:another_dynamic');
$url = new Url('/static/first_dynamic/another_static/second_dynamic');
$this->assertEqual($route->isMatch($url), array('dynamic' => 'first_dynamic',
'another_dynamic' => 'second_dynamic'));
}
-
Feb 20, 2006, 05:54 #42
- Join Date
- Jul 2004
- Location
- The Netherlands
- Posts
- 170
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Ren
PHP Code:function testUrlCreationWithMixedDynamicsAndStatics()
{
$route = new Route('test', '/static/:dynamic/another_static/:another_dynamic');
$url = $route->createUrl(array('dynamic' => 'one', 'another_dynamic' => 'two'));
$this->assertEqual('/static/one/another_static/two', $url->toString());
}
Off Topic:
Originally Posted by thr
Nevertheless an important aspect to consider when choosing a technique.
-
Feb 20, 2006, 06:59 #43
Originally Posted by michel
(
0 => '/static'
1 => ':'
2 => 'dynamic'
3 => '/another_static/'
4 => ':'
5 => 'another_dynamic'
6 => ''
)
Which is a repeating pattern, static bit, type of match (dynamic (:) or wildcard (*) ), and the name of wildcard/dynamic. Just matter of pieceing it back together replacing the type&name with something else.
-
Feb 25, 2006, 18:37 #44
Originally Posted by 33degrees
-
Feb 25, 2006, 19:13 #45
- Join Date
- Jun 2003
- Location
- Iowa, USA
- Posts
- 3,749
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by Ren
Jason Sweat ZCE - jsweat_php@yahoo.com
Book: PHP Patterns
Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
Detestable (adjective): software that isn't testable.
-
Feb 26, 2006, 06:11 #46
Originally Posted by sweatje
# The person has to already have a password attribute (a column in the people table), but the password_confirmation is virtual.
# It exists only as an in-memory variable for validating the password. This check is performed only if password_confirmation
# is not nil and by default on save.
Bookmarks