public function __construct() { parent::__construct(); $path_watercourse = URLDecode::getPiece(1); $path_fall = URLDecode::getPiece(2); $this->waterfall = WaterfallCollector::getByAlias($path_watercourse, $path_fall); if (!$this->waterfall) { $this->eject(); } $this->handle_comment_submit( self::$WATERFALL_SITE_ID, "{$this->waterfall->watercourse_alias}/{$this->waterfall->alias}", Loader::getRootUrl('waterfalls') . "{$this->waterfall->watercourse_alias}/{$this->waterfall->alias}/", $this->waterfall->name); $this->add_waterfall_js(); }
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); }