protected function get_page_number()
	{
		$page = URLDecode::getPiece(3);
		if(isset($page) && is_numeric($page))
			return $page;
		return 1;
	}
	final private function get_list_posts()
	{
		$post_array = array();
		foreach($this->get_list_results() as $post)
		{
			$post_array[] = $this->format_post($post, true);
		}
		if(count($post_array) < 1 && URLDecode::getPiece(1) !== 'search')
			$this->eject();
		return $post_array;
	}
 protected function get_menu()
 {
     $menu = [['name' => 'About', 'link' => Loader::getRootURL()], ['name' => 'Projects', 'link' => Loader::getRootURL() . 'projects/'], ['name' => 'Résumé', 'link' => Loader::getRootURL() . 'resume/'], ['name' => 'Contact', 'link' => Loader::getRootURL() . 'contact/']];
     if (!URLDecode::getPiece(1)) {
         $active_page = 'About';
     } else {
         $active_page = ucfirst(URLDecode::getPiece(1));
     }
     return array_map(function ($row) use($active_page) {
         $row = (object) $row;
         $row->active = $row->name == $active_page;
         return $row;
     }, $menu);
 }
	private function get_active_page()
	{
		$current_uri = URLDecode::getPiece(1);
		
		if(!isset($current_uri))
			return 'About';
		
		$menu = self::$MENU;
		foreach($menu as $link)
		{
			if($link['uri'] == $current_uri)
				return $link['name'];
		}
		
		return 'About';
	}
	public function __construct()
	{
		parent::__construct();
		
		$id = URLDecode::getPiece(2);
		if(!$id || !is_numeric($id))
			$this->eject();
		
		$post = $this->activityRepository->getActivityById($id);
		if(!$post)
			$this->eject();
		
		if(URLDecode::getPiece(1) != $post['type'])
			$this->eject();
		
		$this->post = $post;
	}
 private function save(array $data)
 {
     $path = $_SERVER['REQUEST_URI'];
     $path = explode('/', $path);
     $path = array_filter($path);
     $path = array_slice($path, 0, 2);
     $path = implode('/', $path);
     $body = ['commenter' => ['name' => $data['name'], 'email' => $data['email'], 'website' => $data['website']], 'body' => $data['comment'], 'should_notify' => isset($data['notify']) && $data['notify'] == 'check', 'domain' => URLDecode::getSite() == 'blog' ? 'blog.jacobemerick.com' : 'waterfallsofthekeweenaw.com', 'path' => $path, 'url' => "{$this->fullPath}#comment-{{id}}", 'thread' => 'comments', 'reply_to' => $data['type'] == 'new' ? 0 : $data['type'], 'ip_address' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'referrer' => $_SERVER['HTTP_REFERER']];
     global $container;
     $repository = new ServiceCommentRepository($container['comment_service_api']);
     try {
         $response = $repository->createComment($body);
     } catch (Exception $e) {
         $container['logger']->warning("CommentService | Create | {$e->getMessage()}");
         return null;
     }
     return $response['id'];
 }
	protected function check_for_special_redirect($uri)
	{
		if(preg_match('@^/post_([0-9]{4}-[0-9]{2}-[0-9]{2})_([a-z0-9-]+)(/?)$@', $uri, $matches))
		{
        global $container;
        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
        $post = $repository->findPostByPath($matches[2]);

			if(!$post)
			{
				Loader::loadNew('controller', '/Error404Controller')
					->activate();
			}
			
			Loader::load('utility', 'Content');
			$uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate();
		}
		else
		{
			$post_uri = URLDecode::getPiece(1);
			if($post_uri !== null)
			{
        global $container;
        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
        $post = $repository->findPostByPath($post_uri);

				if($post != false)
				{
					Loader::load('utility', 'Content');
					$uri = Content::instance('URLSafe', "/{$post['category']}/{$post['path']}/")->activate();
				}
			}
		}
		if($uri == '/search/')
		{
			if(Request::getGet('submit') == 'Submit Search' && Request::getGet('search'))
			{
				$uri .= Request::getGet('search');
				$uri .= '/';
			}
		}
		return $uri;
	}
 private function get_thumb($string, $is_absolute, $size)
 {
     list($category, $file_name) = explode('/', $string);
     list($photo, $extension) = explode('.', $file_name);
     $file_path = $this->get_file_path($category, $photo, $size, $extension);
     $file_size = getimagesize($file_path);
     Loader::load('collector', 'image/PhotoCollector');
     $photo_result = PhotoCollector::fetchRow($category, $photo);
     if ($photo_result == false) {
         return '';
     }
     $height = $file_size[1];
     $width = $file_size[0];
     $description = $photo_result->description;
     $domain = '/';
     if ($is_absolute) {
         $domain = Loader::getRootURL(URLDecode::getSite());
     }
     return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description);
 }
    public function __construct()
    {
        parent::__construct();
        
        $log_path = URLDecode::getPiece(2);
        
        $this->log = LogCollector::getByAlias($log_path);
        if(!$this->log)
            $this->eject();

        $this->parent_navigation_item = 'journal';
        
        $this->handle_comment_submit(
            self::$WATERFALL_SITE_ID,
            $this->log->alias,
            Loader::getRootUrl('waterfalls') . self::$JOURNAL_DIRECTORY . '/' . $this->log->alias . '/',
            $this->log->title);
        
        $this->add_waterfall_js();
    }
    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();
    }
	public function __construct()
	{
		parent::__construct();
		
        global $container;
        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
        $this->post = $repository->findPostByPath(URLDecode::getPiece(2));

		if($this->post == null)
			$this->eject();
		
		$this->handle_comment_submit(
			self::$BLOG_SITE_ID,
			$this->post['path'],
			Loader::getRootUrl('blog') . $this->post['category'] . '/' . $this->post['path'] . '/',
			$this->post['title']);

        global $container;
        $repository = new Jacobemerick\Web\Domain\Blog\Tag\MysqlTagRepository($container['db_connection_locator']);
        $this->tags = $repository->getTagsForPost($this->post['id']);
	}
	protected function get_page_number_piece()
	{
		return URLDecode::getPiece(2);
	}
Exemple #13
0
	private function requires_trailing_slash()
	{
		return (
			URLDecode::getExtension() != 'json' &&
            strstr(URLDecode::getURI(), '#') === false);
	}
Exemple #14
0
		<li><a href="<?php 
echo $domain_container->home;
?>
" title="Jacob Emerick's Home"><span class="title">Home</span> <span class="description">the main site for Jacob Emerick</span></a></li>
<? endif ?>
<? if(URLDecode::getSite() !== 'blog') : ?>
		<li><a href="<?php 
echo $domain_container->blog;
?>
" title="Jacob's Blog about programming and hiking"><span class="title">Blog</span> <span class="description">posts on hiking, web development, and me</span></a></li>
<? endif ?>
		<li><a href="<?php 
echo $domain_container->lifestream;
?>
" title="Combination of Jacob's online activities"><span class="title">Lifestream</span> <span class="description">combination of online tomfoolery</span></a></li>
		<li><a href="<?php 
echo $domain_container->map;
?>
" title="Hiking map of Jacob's wanderings"><span class="title">Map</span> <span class="description">summary of upper peninsula adventures</span></a></li>
		<li><a href="<?php 
echo $domain_container->portfolio;
?>
" title="Jacob's portfolio of programming and design work"><span class="title">Portfolio</span> <span class="description">examples of my previous work</span></a></li>
<? if(URLDecode::getSite() !== 'waterfalls') : ?>
		<li><a href="<?php 
echo $domain_container->waterfalls;
?>
" title="Waterfalls of the Keweenaw"><span class="title">Waterfalls</span> <span class="description">resource of Keweenaw waterfalls</span></a></li>
<? endif ?>
	</ul>
</div>
        return self::$array['base'];
    }
    static function getURI()
    {
        return self::$array['uri'];
    }
    static function getExtension()
    {
        $file = self::getPiece(-1);
        if (substr($file, -1) == '/') {
            return false;
        }
        return substr($file, strrpos($file, '.') + 1);
    }
    static function getPiece($piece = null)
    {
        if (!$piece) {
            return self::$array['pieces'];
        }
        if ($piece == -1) {
            return end(self::$array['pieces']);
        }
        $piece = $piece - 1;
        if (array_key_exists($piece, self::$array['pieces'])) {
            return self::$array['pieces'][$piece];
        }
        return;
    }
}
URLDecode::init();
	public function activate()
	{
		$this->set_head_data();
		$this->set_body_data();
		$this->set_data();
		
		$this->load_assets();
		
		$headers = $this->headers;
		Header::$headers();
		Loader::load('view', '/Head', $this->data_array['head']);
		foreach($this->body_view_array as $view)
		{
			if(substr($view, 0, 1) == '/')
				Loader::load('view', $view, $this->data_array['body']);
			else
				Loader::load('view', URLDecode::getSite() . '/' . $view, $this->data_array['body']);
		}
        
        if (URLDecode::getSite() == 'waterfalls') {
            Loader::load('view', '/WaterfallFoot');
        } else {
            Loader::load('view', '/Foot', array('tracking_code' => self::$TRACKING_CODE));
        }
		
		if($view == '/404' || $view == '/503')
			exit;
	}