protected function set_body_data($page_type = 'wide')
 {
     parent::set_body_data($page_type);
     
     $photo = PhotoCollector::getRow(self::$BANNER_IMAGE);
     $photo_obj = (object) array(
         'file'         => "/photo/{$photo->category}/{$photo->name}-size-full.jpg",
         'description'  => $photo->description,
     );
     $this->set_body('photo', $photo_obj);
     
     $recent_log_container;
     $recent_logs = LogCollector::getRecentList(4);
     foreach ($recent_logs as $log) {
         $recent_log_container[] = (object) array(
             'photo'  => (object) array(
                 'file'         => "/photo/{$log->photo_category}/{$log->photo}-size-thumb.jpg",
                 'description'  => $log->photo_description,
             ),
             'title'  => $log->title,
             'link'   => "/journal/{$log->alias}/",
             'date'   => date('F j, Y', strtotime($log->publish_date)),
         );
     }
     $this->set_body('logs', $recent_log_container);
     $this->set_body('comments', $this->get_comments());
     
     $this->set_body('view', 'Home');
 }
 protected function check_for_special_redirect($uri)
 {
     if (preg_match('@^/falls/([a-z\'-]+)(/?)$@', $uri, $matches)) {
         $alias = $matches[1];
         $alias = str_replace("'", '', $alias);
         $alias .= '-falls';
         $result = WaterfallCollector::getByOldAlias($alias);
         if ($result !== null) {
             return "/{$result->watercourse_alias}/{$result->alias}/";
         } else {
             Loader::loadNew('controller', '/Error404Controller')->activate();
         }
     }
     if (preg_match('@^/photos/([a-z\'-]+)-([^/]+)(/?)$@', $uri, $matches)) {
         $alias = $matches[1];
         $alias = explode('-', $alias);
         array_pop($alias);
         $alias = implode('-', $alias);
         $alias = str_replace("'", '', $alias);
         $alias .= '-falls';
         $result = WaterfallCollector::getByOldAlias($alias);
         if ($result !== null) {
             return "/{$result->watercourse_alias}/{$result->alias}/";
         } else {
             Loader::loadNew('controller', '/Error404Controller')->activate();
         }
     }
     if (preg_match('@/log/([a-z]+-\\d{2}-\\d{4})(/?)$@', $uri, $matches)) {
         $date = $matches[1];
         $date = explode('-', $date);
         $date = mktime(0, 0, 0, date('n', strtotime($date[0])), $date[1], $date[2]);
         $date = date('Y-m-d', $date);
         $result = LogCollector::getByDate($date);
         if ($result !== null) {
             return "/journal/{$result->alias}/";
         } else {
             Loader::loadNew('controller', '/Error404Controller')->activate();
         }
     }
     if (preg_match('@/map/([a-z\'-]+)(/?)$@', $uri, $matches)) {
         $alias = $matches[1];
         $alias = str_replace("'", '', $alias);
         $alias .= '-falls';
         $result = WaterfallCollector::getByOldAlias($alias);
         if ($result !== null) {
             return "/map/#{$result->watercourse_alias}/{$result->alias}";
         } else {
             Loader::loadNew('controller', '/Error404Controller')->activate();
         }
     }
     return $uri;
 }
	final protected function format_item($item)
	{
		$item_array = array();
		
		$item_array['title'] = $item->title;
		$item_array['image'] = $this->get_image_element($item->photo_category, $item->photo, $item->photo_description);
		$item_array['waterfall_list'] = LogCollector::getWaterfallListForLog($item->id);
		$item_array['introduction'] = $item->introduction;
		$item_array['path'] = "/journal/{$item->alias}/";
		$item_array['comment_count'] = 0; // todo - this
		$item_array['date'] = $this->get_parsed_date($item->date);
		
		return $item_array;
	}
	protected function set_head_data()
	{
		parent::set_head_data();
		
		$this->set_title(sprintf(self::$TITLE, $this->post['title']));
		$this->set_description($this->get_post_description());
		$this->set_keywords($this->get_post_keywords());
		$this->set_author(self::$AUTHOR);

    $photo = Content::instance('FetchFirstPhoto', $this->post['body'])->activate(true);
    $photo = preg_match('/^<img src="([a-z-:\.\/]+)" [^>]+>$/', $photo, $matches);
    $this->set_head('thumbnail', $matches[1]);

		if (array_key_exists($this->post['id'], self::$DEPRECATED_BLOGS)) {
			$log_id = self::$DEPRECATED_BLOGS[$this->post['id']];
			$log = LogCollector::getById($log_id);
			if (!empty($log)) {
				$log_url = Loader::getRootUrl('waterfalls') . "journal/{$log->alias}/";
				$this->set_canonical($log_url);
			}
		}
	}
	protected function get_item_count_result()
	{
		return LogCollector::getListCount();
	}
 private function get_sidebar()
 {
     $sidebar = array();
     
     $sidebar['companion_list'] = array();
     $companions = LogCollector::getCompanionListForLog($this->log->id);
     foreach($companions as $companion)
     {
         $sidebar['companion_list'][] = (object) array(
             'title' => $companion->name,
             'path' => "/companion/{$companion->alias}/");
     }
     
     $sidebar['tag_list'] = array();
     $tags = LogCollector::getTagListForLog($this->log->id);
     foreach($tags as $tag)
     {
         $sidebar['tag_list'][] = (object) array(
             'title' => $tag->name,
             'path' => "/journal/tag/{$tag->alias}/");
     }
     
     $sidebar['waterfall_list'] = array();
     $waterfalls = LogCollector::getWaterfallListForLog($this->log->id);
     foreach($waterfalls as $waterfall)
     {
         $sidebar['waterfall_list'][] = (object) array(
             'title' => $waterfall->name,
             'path' => "/{$waterfall->watercourse_alias}/{$waterfall->alias}/");
     }
     
     return $sidebar;
 }
 private function get_journal_list($waterfall)
 {
     $list = array();
     $log_result = LogCollector::getLogListForWaterfall($waterfall);
     foreach ($log_result as $log_row) {
         $list[] = (object) array(
             'date' => date('F j, Y', strtotime($log_row->date)),
             'title' => $log_row->title,
             'url' => "/journal/{$log_row->alias}/",
         );
     }
     
     return $list;
 }
	private function get_link($string, $is_absolute, $anchor = '')
	{
		list($type, $uri) = explode('/', $string, 2);
		
		$link = '';
		
		switch($type)
		{
			case 'blog' :
        global $container;
        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
        $post = $repository->findPostByPath($uri);

				if($post === NULL)
					return;
				
				$link .= ($is_absolute) ? Loader::getRootURL('blog') : '/';
				$link .= "{$post['category']}/{$post['path']}/";
				
				if($anchor == '')
					$anchor = $post['title'];
				
				break;
			case 'blog-tag' :
				$link .= ($is_absolute) ? Loader::getRootURL('blog') : '/';
				$link .= "tag/{$uri}/";
				
				if($anchor == '')
				{
					$anchor = $uri;
					$anchor = str_replace('-', ' ', $anchor);
					$anchor = ucwords($anchor);
				}
				
				break;
			case 'journal' :
				Loader::load('collector', 'waterfall/LogCollector');
				$log = LogCollector::getByAlias($uri);
				
				if($log === NULL)
					return;
				
				$link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/';
				$link .= "journal/{$log->alias}/";
				
				if($anchor == '')
					$anchor = $log->title;
				
				break;
			case 'falls' :
                $pieces = explode('/', $uri);
                if (count($pieces) == 1) {
                    Loader::load('collector', 'waterfall/WatercourseCollector');
                    list ($watercourse_alias) = $pieces;
                    $watercourse = WatercourseCollector::getByAlias($watercourse_alias);
                    
                    if ($watercourse == null) {
                        return;
                    }
                    
                    $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/';
                    $link .= "{$watercourse->alias}/";
                    
                    if ($anchor == '') {
                        $anchor = $watercourse->name;
                    }
                } else if (count($pieces) == 2) {
                    Loader::load('collector', 'waterfall/WaterfallCollector');
                    list ($watercourse_alias, $waterfall_alias) = $pieces;
                    $waterfall = WaterfallCollector::getByAlias($watercourse_alias, $waterfall_alias);
                    
                    if ($waterfall == null) {
                        return;
                    }
                    
                    $link .= ($is_absolute) ? Loader::getRootURL('waterfalls') : '/';
                    $link .= "{$waterfall->watercourse_alias}/{$waterfall->alias}/";
                    
                    if ($anchor == '') {
                        $anchor = $waterfall->name;
                    }
                }
				break;
			default :
				break;
		}
		
		return sprintf(self::$LINK_CONTENT, $link, $anchor);
	}