isEligibleToBeDisplayed () || $force) { $macrophage = new Theme_Macrophage (); $image = $macrophage->run ($this->getBannerLocation ($mode)); $id_attribute = (! empty ($this->id_attribute)) ? ' id="'.$this->id_attribute.'"' : ''; switch ($this->getExtension ()) { case 'swf': { $result = << html; } break; default: { $target_blank = ($this->target_blank > 0) ? ' target="_blank"' : ''; $rel_nofollow = ($this->rel_nofollow > 0) ? ' rel="nofollow"' : ''; $target_href = $this->target_href; if (preg_match ('~^/~', $target_href)) { $target_href = SITE_DOMAIN . $target_href; } $target_href = $macrophage->run ($target_href); $target_href = $this->introduceAdditionalParams ($target_href, $additional_params); $result = << {$this->title} html; } break; } return $result; } } protected function introduceAdditionalParams ($href, $additional_params) { if (isset ($additional_params)) { $bit = parse_url ($href); $href = ''; if (isset ($bit ['scheme'])) $href .= $bit ['scheme'] . '://'; if (isset ($bit ['user'])) $href .= $bit ['user']; if (isset ($bit ['pass'])) $href .= ':' . $bit ['pass']; if (isset ($bit ['user']) || isset ($bit ['pass'])) $href .= '@'; if (isset ($bit ['host'])) $href .= $bit ['host']; if (isset ($bit ['port'])) $href .= ':' . $bit ['port']; if (isset ($bit ['path'])) $href .= $bit ['path']; $query = ''; if (isset ($bit ['query'])) $query = $bit ['query'] . '&'; $query .= http_build_query ($additional_params); $href .= '?' . $query; if (isset ($bit ['fragment'])) $href .= '#' . $bit ['fragment']; } return $href; } function isActive () { return $this->active > 0; } function isEligibleToBeDisplayed () { if ($this->isActive()) { $now = time(); $from = strtotime($this->show_from); $to = strtotime($this->show_to); if ($from > 0) { if ($from > $now) { return false; } } if ($to > 0) { if ($to <= $now) { return false; } } return true; } } function getBannerLocation ($mode = null) { if (!isset($mode)) { $mode = $this->mode; } switch ($mode) { case self::IMAGE_BY_URL: return $this->banner_href; break; case self::IMAGE_FROM_FILE: return url::href ('//' . Configuration::getBannerDir () . '/' . $this->banner_file); break; default: throw new Exception("Invalid banner mode."); } } function getExtension () { $pathinfo = pathinfo($this->getBannerLocation()); if (isset($pathinfo['extension'])) { return strtolower($pathinfo['extension']); } } }