public function render() { if (!$this->links) { throw new Kohana_User_Exception("Navbar not implemented correctly", "Links have not been set. Please call <code>$navbar->set_links({$links})</code>"); } else { if ($this->view) { return $this->render_to_view($this->view); } else { $html = ""; $i = 0; foreach ($this->links as $link) { $class = ""; if ($link->get_parent_id() == Page_Model::get_by_url()->id) { $class .= "selected"; } if ($i == 0) { $class .= " first"; } if ($i == count($this->links) - 1) { $class .= " last"; } $x = $this->template; $x = str_replace('{CLASS}', $class, $x); $x = str_replace('{TITLE}', $link->get_definition()->title, $x); $x = str_replace('{URL}', $link->get_url(), $x); $html .= $x; $i++; } # $html .= "</ul>"; return $html; } } }
public function __construct() { socialFeed::get_favicon_from('http://www.delicious.com/sydlawrence'); $this->session = Session::instance(); $this->db = new Database(); parent::__construct(); $_POST = $this->input->xss_clean($_POST); if ($this->input->post('attempt_login')) { $return = login::attempt_login(); if (isset($return->id) && $return->id > 0) { $this->user = $return; } else { $this->__set_options(array('error' => $return)); } if (isset($_GET['redirect'])) { url::redirect(urldecode($_GET['redirect'])); } } $this->user = login::check_login(); if ($this->input->get('logout')) { Auth::instance()->logout(TRUE); url::redirect(); } $this->page = Page_Model::get_by_url(); $this->feed = Feed_Model::get_by_url(); $this->feedpost = Feedpost_Model::get_by_url(); $this->__setup(); $this->header = new View('includes/header'); $this->footer = new View('includes/footer'); $this->__binds(); }
public static function get_by_url() { $uri = uri::instance(); $title = urldecode($uri->segment(1)); $feed = ORM::factory('feed')->where('title', $title)->find(); if ($feed->id > 0 && $title != "") { return $feed; } $title = str_replace('-', ' ', $title); $feed = ORM::factory('feed')->where('title', $title)->find(); if ($feed->id > 0 && $title != "") { return $feed; } if ($p = Page_Model::get_by_url()) { $feed = ORM::factory('feed')->where('title', $p->title)->find(); if ($feed->id > 0) { return $feed; } } return null; }