title = $title; if ($url instanceof Url) { $this->url = $url; } else { $this->url = Url::create($url); } } /** * Retrieve this components title * * @return string */ public function getTitle() { return $this->title; } /** * Retrieve my url * * @return Url */ public function getUrl() { return $this->url; } /** * Set this components URL * * @param string|Url $url Component URL * @return self */ public function setUrl($url) { if ($url instanceof Url) { $this->url = $url; } else { $this->url = Url::create($url); } return $this; } protected function iniPair($key, $val) { return sprintf( "%s = %s\n", $key, $this->quoteIni($val) ); } protected function quoteIni($str) { return '"' . $str . '"'; } public function toIni() { $ini = $this->iniPair('base_url', $this->url->getScript()); foreach ($this->url->getParams() as $key => $val) { $ini .= $this->iniPair($key, $val); } return $ini; } /** * Render this components HTML */ public function __toString() { $url = clone($this->url); $url->addParams(array('view' => 'compact')); if (isset($_GET['layout'])) { $url->addParams(array('layout' => $_GET['layout'])); } $htm = '
' . "\n" . '

' . htmlspecialchars($this->title) . "

\n" . '' . "\n
\n"; return $htm; } }