function get_banner($position, $options = array()) { $banner = false; $options['class'] = !empty($options['class']) ? $options['class'] : 'banner-place'; if ($position > 0 or !empty($position)) { if (is_numeric($position) > 0 and !ctype_alpha($position)) { $banner = Banner::bannercat($position)->select('url', 'banner', 'size_x', 'size_y')->bannerdate()->orderBy('finished_at', 'desc')->first(); } else { $banner = Banner::bannerposition($position)->select('url', 'banner', 'size_x', 'size_y')->bannerdate()->orderBy('finished_at', 'desc')->first(); } if ($banner != null) { $options['width'] = $banner->size_x > 0 ? $banner->size_x . 'px' : (empty($options['width']) ? '100%' : $options['width'] . 'px'); $options['height'] = $banner->size_y > 0 ? $banner->size_y . 'px' : (empty($options['height']) ? '100%' : $options['height'] . 'px'); $banner = '<div style="position:relative;" class="' . $options['class'] . '"><a href="' . $banner->url . '" target="_blank" style="position:absolute;display:block;width:' . $options['width'] . ';height:' . $options['height'] . ';"></a><object data="' . $banner->banner . '" type="application/x-shockwave-flash" width="' . $options['width'] . '" height="' . $options['height'] . '"><param name="wmode" value="opaque" /></object></div>'; } else { $options['width'] = $options['width'] > 0 ? $options['width'] . 'px' : '100%'; $options['height'] = $options['height'] > 0 ? $options['height'] . 'px' : '100%'; $banner = '<div style="position:relative;" class="' . $options['class'] . '"><object data="' . url() . '/uploads/all/Banners/default_' . $options['width'] . '_x_' . $options['height'] . '.png" type="application/x-shockwave-flash" width="' . $options['width'] . '" height="' . $options['height'] . '"><param name="wmode" value="opaque" /></object></div>'; } } return $banner; }