| 1 |
<?php |
|---|
| 2 |
sfLoader::loadHelpers('Url'); |
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
function link_to_person($person, $options = null) |
|---|
| 12 |
{ |
|---|
| 13 |
if (is_null($person)) |
|---|
| 14 |
{ |
|---|
| 15 |
return __('<Removed profile>'); |
|---|
| 16 |
} |
|---|
| 17 |
|
|---|
| 18 |
$options = _parse_attributes($options); |
|---|
| 19 |
|
|---|
| 20 |
if (isset($options['label'])) |
|---|
| 21 |
{ |
|---|
| 22 |
$label = $options['label']; |
|---|
| 23 |
unset($options['label']); |
|---|
| 24 |
} |
|---|
| 25 |
else |
|---|
| 26 |
{ |
|---|
| 27 |
$label = $person->getDisplayName(); |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
$append = ''; |
|---|
| 31 |
if (isset($options['include_flag'])) |
|---|
| 32 |
{ |
|---|
| 33 |
if (flag_image_tag($person->getCountry()) != '') |
|---|
| 34 |
{ |
|---|
| 35 |
$append = ' '.flag_image_tag($person->getCountry()); |
|---|
| 36 |
} |
|---|
| 37 |
unset($options['include_flag']); |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
if (!isset($options['title'])) |
|---|
| 41 |
{ |
|---|
| 42 |
$options['title'] = __('Access %person%\'s profile', |
|---|
| 43 |
array('%person%' => $person->getDisplayName())); |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
return link_to($label, |
|---|
| 47 |
'@person_page?username='.$person->getUsername(), |
|---|
| 48 |
$options).$append; |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 |
function link_to_company($company, $options = null) |
|---|
| 59 |
{ |
|---|
| 60 |
if (is_null($company)) |
|---|
| 61 |
{ |
|---|
| 62 |
return __('<Removed company>'); |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
$options = _parse_attributes($options); |
|---|
| 66 |
|
|---|
| 67 |
if (isset($options['label'])) |
|---|
| 68 |
{ |
|---|
| 69 |
$label = $options['label']; |
|---|
| 70 |
unset($options['label']); |
|---|
| 71 |
} |
|---|
| 72 |
else |
|---|
| 73 |
{ |
|---|
| 74 |
$label = $company->getName(); |
|---|
| 75 |
} |
|---|
| 76 |
|
|---|
| 77 |
$append = ''; |
|---|
| 78 |
if (isset($options['include_flag'])) |
|---|
| 79 |
{ |
|---|
| 80 |
if (flag_image_tag($company->getCountry()) != '') |
|---|
| 81 |
{ |
|---|
| 82 |
$append = ' '.flag_image_tag($company->getCountry()); |
|---|
| 83 |
} |
|---|
| 84 |
unset($options['include_flag']); |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
if (!isset($options['title'])) |
|---|
| 88 |
{ |
|---|
| 89 |
$options['title'] = __('Access %company% page', |
|---|
| 90 |
array('%company%' => $company->getName())); |
|---|
| 91 |
} |
|---|
| 92 |
|
|---|
| 93 |
return link_to($label, |
|---|
| 94 |
'@company_page?slug='.$company->getSlug(), |
|---|
| 95 |
$options).$append; |
|---|
| 96 |
} |
|---|
| 97 |
|
|---|
| 98 |
|
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
function link_to_application($application, $options = null) |
|---|
| 106 |
{ |
|---|
| 107 |
if (is_null($application)) |
|---|
| 108 |
{ |
|---|
| 109 |
return __('<Removed application>'); |
|---|
| 110 |
} |
|---|
| 111 |
|
|---|
| 112 |
$options = _parse_attributes($options); |
|---|
| 113 |
|
|---|
| 114 |
if (isset($options['label'])) |
|---|
| 115 |
{ |
|---|
| 116 |
$label = $options['label']; |
|---|
| 117 |
unset($options['label']); |
|---|
| 118 |
} |
|---|
| 119 |
else |
|---|
| 120 |
{ |
|---|
| 121 |
$label = $application->getName(); |
|---|
| 122 |
} |
|---|
| 123 |
|
|---|
| 124 |
$append = ''; |
|---|
| 125 |
if (isset($options['include_flag'])) |
|---|
| 126 |
{ |
|---|
| 127 |
if (flag_image_tag($application->getCountry()) != '') |
|---|
| 128 |
{ |
|---|
| 129 |
$append = ' '.flag_image_tag($application->getCountry()); |
|---|
| 130 |
} |
|---|
| 131 |
unset($options['include_flag']); |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
if (!isset($options['title'])) |
|---|
| 135 |
{ |
|---|
| 136 |
$options['title'] = __('Access %app% application\'s details page', |
|---|
| 137 |
array('%app%' => $application->getName())); |
|---|
| 138 |
} |
|---|
| 139 |
|
|---|
| 140 |
return link_to($label, |
|---|
| 141 |
'@application_page?slug='.$application->getSlug(), |
|---|
| 142 |
$options).$append; |
|---|
| 143 |
} |
|---|
| 144 |
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 |
|
|---|
| 148 |
|
|---|
| 149 |
|
|---|
| 150 |
|
|---|
| 151 |
|
|---|
| 152 |
function link_to_job($job, $options = null) |
|---|
| 153 |
{ |
|---|
| 154 |
if (is_null($job)) |
|---|
| 155 |
{ |
|---|
| 156 |
return __('<Removed job offer>'); |
|---|
| 157 |
} |
|---|
| 158 |
|
|---|
| 159 |
$options = _parse_attributes($options); |
|---|
| 160 |
|
|---|
| 161 |
if (isset($options['label'])) |
|---|
| 162 |
{ |
|---|
| 163 |
$label = $options['label']; |
|---|
| 164 |
unset($options['label']); |
|---|
| 165 |
} |
|---|
| 166 |
else |
|---|
| 167 |
{ |
|---|
| 168 |
$label = $job->getTitle(); |
|---|
| 169 |
} |
|---|
| 170 |
|
|---|
| 171 |
$append = ''; |
|---|
| 172 |
if (isset($options['include_flag'])) |
|---|
| 173 |
{ |
|---|
| 174 |
if (flag_image_tag($job->getCountry()) != '') |
|---|
| 175 |
{ |
|---|
| 176 |
$append = ' '.flag_image_tag($job->getCountry()); |
|---|
| 177 |
} |
|---|
| 178 |
unset($options['include_flag']); |
|---|
| 179 |
} |
|---|
| 180 |
|
|---|
| 181 |
if (!isset($options['title'])) |
|---|
| 182 |
{ |
|---|
| 183 |
$options['title'] = __('Access %jobtitle% offer page', |
|---|
| 184 |
array('%jobtitle%' => $job->getTitle())); |
|---|
| 185 |
} |
|---|
| 186 |
|
|---|
| 187 |
return link_to($label, |
|---|
| 188 |
'@job_page?slug='.$job->getSlug(), |
|---|
| 189 |
$options).$append; |
|---|
| 190 |
} |
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
function link_thumb_to_person($format, $person, $options = null) |
|---|
| 203 |
{ |
|---|
| 204 |
$options = _parse_attributes($options); |
|---|
| 205 |
$image_src = null; |
|---|
| 206 |
|
|---|
| 207 |
if (isset($options['imgclass'])) |
|---|
| 208 |
{ |
|---|
| 209 |
$imgclass = $options['imgclass']; |
|---|
| 210 |
unset($options['imgclass']); |
|---|
| 211 |
} |
|---|
| 212 |
else |
|---|
| 213 |
{ |
|---|
| 214 |
$imgclass = 'avatar'; |
|---|
| 215 |
} |
|---|
| 216 |
|
|---|
| 217 |
$force_reload = false; |
|---|
| 218 |
if (isset($options['force_reload'])) |
|---|
| 219 |
{ |
|---|
| 220 |
$force_reload = $options['force_reload']; |
|---|
| 221 |
unset($options['force_reload']); |
|---|
| 222 |
} |
|---|
| 223 |
|
|---|
| 224 |
if (isset($options['route'])) |
|---|
| 225 |
{ |
|---|
| 226 |
$route = $options['route']; |
|---|
| 227 |
unset($options['route']); |
|---|
| 228 |
} |
|---|
| 229 |
else |
|---|
| 230 |
{ |
|---|
| 231 |
$route = '@person_page?username='.$person->getUsername(); |
|---|
| 232 |
} |
|---|
| 233 |
|
|---|
| 234 |
if (!$content = person_image_tag($person, $format, 'alt='.$person->getDisplayName().' class='.$imgclass)) |
|---|
| 235 |
{ |
|---|
| 236 |
$content = $person->getDisplayName(); |
|---|
| 237 |
} |
|---|
| 238 |
|
|---|
| 239 |
return link_to($content, $route, $options); |
|---|
| 240 |
} |
|---|
| 241 |
|
|---|
| 242 |
|
|---|
| 243 |
|
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
function blog_post_url($local_event, $absolute = false) |
|---|
| 248 |
{ |
|---|
| 249 |
$route = _gen_local_event_route($local_event); |
|---|
| 250 |
return url_for($route, $absolute); |
|---|
| 251 |
} |
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
|
|---|
| 255 |
|
|---|
| 256 |
|
|---|
| 257 |
|
|---|
| 258 |
|
|---|
| 259 |
|
|---|
| 260 |
function link_to_local_event($local_event, $options = null) |
|---|
| 261 |
{ |
|---|
| 262 |
$local_event_route = _gen_local_event_route($local_event); |
|---|
| 263 |
return link_to($local_event->getTitle(), $local_event_route, $options); |
|---|
| 264 |
} |
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 |
|
|---|
| 270 |
|
|---|
| 271 |
|
|---|
| 272 |
function _gen_local_event_route($local_event) |
|---|
| 273 |
{ |
|---|
| 274 |
if (is_null($local_event)) |
|---|
| 275 |
{ |
|---|
| 276 |
return null; |
|---|
| 277 |
} |
|---|
| 278 |
if (!$local_event instanceof LocalEvent) |
|---|
| 279 |
{ |
|---|
| 280 |
$local_event = $local_event->getRawValue(); |
|---|
| 281 |
} |
|---|
| 282 |
return $local_event->getRoute(); |
|---|
| 283 |
} |
|---|
| 284 |
|
|---|