Exemplo n.º 1
0
 /**
  * You can pass in a locale parameter the first time you call getInstance('fr') in order to set the locale manually.
  */
 public static function getInstance($locale = null)
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
         self::$instance->setLocale($locale);
     }
     return self::$instance;
 }
	protected function get_initial_introduction()
	{
		$introduction = array();
		
		$introduction['title'] = $this->county->title;
		$introduction['description'] = Content::instance('FixInternalLink', $this->county->introduction)->activate();
		$introduction['image'] = $this->get_image_element($this->county->photo_category, $this->county->photo, $this->county->photo_description, 'medium');
		
		return $introduction;
	}
Exemplo n.º 3
0
 /**
  * Initializes plugin variables and sets up WordPress hooks/actions.
  */
 protected function __construct()
 {
     $this->plugin_path = trailingslashit(dirname(dirname(__FILE__)));
     $this->plugin_dir = trailingslashit(basename($this->plugin_path));
     $this->plugin_url = plugins_url($this->plugin_dir);
     $this->register_theme_directory();
     //debug('hi');
     self::$user = User::instance();
     self::$content = Content::instance();
     //self::$flash = Flash::instance();
     add_action('init', array($this, 'load_text_domain'), 1);
     $this->add_hooks();
 }
Exemplo n.º 4
0
 private function get_recent_posts()
 {
     global $container;
     $postRepository = new MysqlPostRepository($container['db_connection_locator']);
     $recentPosts = $postRepository->getActivePosts(3);
     $recent_post_array = array();
     foreach ($recentPosts as $postResult) {
         $post = new stdclass();
         $post->title = $postResult['title'];
         $post->url = Loader::getRootUrl('blog') . "{$postResult['category']}/{$postResult['path']}/";
         $post->category = ucwords(str_replace('-', ' ', $postResult['category']));
         $post->thumb = Content::instance('FetchFirstPhoto', $postResult['body'])->activate();
         $post->body = Content::instance('SmartTrim', $postResult['body'])->activate($post->thumb !== '' ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG);
         $recent_post_array[] = $post;
     }
     return $recent_post_array;
 }
Exemplo n.º 5
0
	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;
	}
Exemplo n.º 6
0
	protected function get_list_prev_link()
	{
		if(($this->page * self::$POSTS_PER_PAGE) >= $this->get_total_post_count())
			return;
		return Content::instance('URLSafe', "/tag/{$this->tag['tag']}/" . ($this->page + 1) . '/')->activate();
	}
Exemplo n.º 7
0
    protected function get_comments()
    {
        global $container;
        $repository = new Jacobemerick\Web\Domain\Comment\Comment\ServiceCommentRepository($container['comment_service_api']);
        $start = microtime(true);
        try {
            $comment_response = $repository->getComments(
                'waterfallsofthekeweenaw.com',
                null,
                1,
                5,
                '-date'
            );
        } catch (Exception $e) {
            $container['logger']->warning("CommentService | Sidebar | {$e->getMessage()}");
            return;
        }
 
        $elapsed = microtime(true) - $start;
        global $container;
        $container['logger']->info("CommentService | Sidebar | {$elapsed}");

        $array = array();
        foreach($comment_response as $comment)
        {
            $body = Content::instance('CleanComment', $comment['body'])->activate();
            $body = strip_tags($body);

            $comment_obj = new stdclass();
            $comment_obj->description = Content::instance('SmartTrim', $body)->activate(50);
            $comment_obj->commenter = $comment['commenter']['name'];
            $comment_obj->link = $comment['url'];
            $array[] = $comment_obj;
        }
        return $array;
    }
Exemplo n.º 8
0
 private function get_formatted_log_body()
 {
     $body = $this->log->body;
     
     $body = Content::instance('FixPhoto', $body)->activate(false, 'standard');
     $body = Content::instance('FixInternalLink', $body)->activate();
     
     return $body;
 }
 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;
 }
Exemplo n.º 10
0
	private function get_related_posts()
	{
		$tag_array = array();
		foreach($this->tags as $tag)
		{
			$tag_array[] = $tag['id'];
		}
		
		$series_posts = $this->fetch_series_posts();
		$exclude_post_array = array();
		foreach($series_posts as $series_post)
		{
			$exclude_post_array[] = $series_post['post'];
		}

        global $container;
        $repository = new Jacobemerick\Web\Domain\Blog\Post\MysqlPostRepository($container['db_connection_locator']);
        $post_result = $repository->getActivePostsByRelatedTags($this->post['id']);

        $post_array = array();
		
		foreach($post_result as $post_row)
		{
			$post = new stdclass();
			$post->title = $post_row['title'];
			$post->url = Loader::getRootUrl('blog') . "{$post_row['category']}/{$post_row['path']}/";
			$post->category = ucwords(str_replace('-', ' ', $post_row['category']));
			$post->thumb = Content::instance('FetchFirstPhoto', $post_row['body'])->activate();
			$post->body = Content::instance('SmartTrim', $post_row['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG);
			
			$post_array[] = $post;
		}
		
		return $post_array;
	}
Exemplo n.º 11
0
    protected function get_comment_array($site, $path)
    {
        global $container;
        $repository = new Jacobemerick\Web\Domain\Comment\Comment\ServiceCommentRepository($container['comment_service_api']);
        $start = microtime(true);
        try {
            $comment_response = $repository->getComments(
                $site,
                $path,
                1,
                null,
                'date'
            );
        } catch (Exception $e) {
            $container['logger']->warning("CommentService | Path | {$e->getMessage()}");
            return;
        }

        $elapsed = microtime(true) - $start;
        global $container;
        $container['logger']->info("CommentService | Path | {$elapsed}");

        $array = array();
        foreach((array) $comment_response as $comment)
        {
            $body = Content::instance('CleanComment', $comment['body'])->activate();
            $body = strip_tags($body);

            $comment_obj = new stdclass();
            $comment_obj->id = $comment['id'];
            $comment_obj->name = $comment['commenter']['name'];
            $comment_obj->url = $comment['commenter']['website'];
            $comment_obj->trusted = true;
            $comment_obj->date = $comment['date']->format('M j, \'y');
            $comment_obj->body = $body;

            if ($comment['reply_to']) {
                $array[$comment['reply_to']]->replies[$comment['id']] = $comment_obj;
                continue;
            }

            $comment_obj->replies = [];
            $array[$comment['id']] = $comment_obj;
        }

        // todo figure out commenter obj
        // todo figure out how to handle errors or whatever
        // todo why is this even doing all this
        return [
            'comments' => $array,
            'commenter' => [],
            'errors' => [],
            'comment_count' => count($comment_response),
        ];
    }