|
Revision 2, 0.9 kB
(checked in by nperriault, 10 months ago)
|
First commit of the extracted code from production, I hope no passwd has been forgotten :-)
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
sfLoader::loadHelpers('Url'); |
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
function blog_post_url($post, $absolute = false) |
|---|
| 12 |
{ |
|---|
| 13 |
$route = _gen_blog_post_route($post); |
|---|
| 14 |
return url_for($route, $absolute); |
|---|
| 15 |
} |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
function link_to_post($post, $options = null) |
|---|
| 25 |
{ |
|---|
| 26 |
$post_route = _gen_blog_post_route($post); |
|---|
| 27 |
return link_to($post->getTitle(), $post_route, $options); |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
function _gen_blog_post_route($post) |
|---|
| 38 |
{ |
|---|
| 39 |
if (is_null($post)) |
|---|
| 40 |
{ |
|---|
| 41 |
return null; |
|---|
| 42 |
} |
|---|
| 43 |
if (!$post instanceof BlogPost) |
|---|
| 44 |
{ |
|---|
| 45 |
$post = $post->getRawValue(); |
|---|
| 46 |
} |
|---|
| 47 |
return $post->getRoute(); |
|---|
| 48 |
} |
|---|