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;
 }
	protected function get_item_count_result()
	{
		return WaterfallCollector::getListCount();
	}
 private function fetch_waterfall_list()
 {
     $list = WaterfallCollector::getMapList();
     array_walk($list, array($this, 'parse_waterfall'));
     return $list;
 }
 private function get_nearby_list($waterfall)
 {
     $nearby_list = array();
     
     $result = WaterfallCollector::getNearbyList($waterfall);
     foreach ($result as $row) {
         $nearby_list[] = (object) array(
             'url' => "/{$row->watercourse_alias}/{$row->alias}/",
             'anchor' => $row->name,
             'title' => "{$row->name} of {$row->watercourse}",
             'distance' => Content::instance('ImperialUnit', $row->distance)->activate(false),
         );
     }
     
     return $nearby_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);
	}