2013-10-27 01:06:58 +02:00
|
|
|
<?php
|
|
|
|
class AdvertisementsHelper extends Rails\ActionView\Helper
|
|
|
|
{
|
|
|
|
public function print_advertisement($ad_type)
|
|
|
|
{
|
|
|
|
if (CONFIG()->can_see_ads(current_user())) {
|
2013-11-21 20:08:11 +01:00
|
|
|
$ad = Advertisement::random($ad_type);
|
|
|
|
if ($ad) {
|
2013-12-02 03:26:35 +01:00
|
|
|
if ($ad->html) {
|
|
|
|
return $ad->html;
|
|
|
|
} else {
|
2013-12-04 21:19:11 +01:00
|
|
|
return $this->linkTo(
|
|
|
|
$this->imageTag(
|
|
|
|
$ad->image_url,
|
|
|
|
['alt' => "Advertisement", 'width' => $ad->width, 'height' => $ad->height]
|
2013-11-21 20:08:11 +01:00
|
|
|
),
|
2013-12-04 21:19:11 +01:00
|
|
|
$this->redirectAdvertisementPath($ad),
|
|
|
|
['target' => '_blank']
|
2013-12-02 03:26:35 +01:00
|
|
|
);
|
|
|
|
}
|
2013-11-21 20:08:11 +01:00
|
|
|
}
|
2013-10-27 01:06:58 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-04 21:19:11 +01:00
|
|
|
}
|