Example #1
0
 public function populyar_post_by_visits()
 {
     $post = new Post();
     $posts = $post->order_by('time_created', 'desc');
     $posts = $posts->get();
     $res = $this->like('page', 'blog/post/', 'after')->get();
     $sluge = array();
     foreach ($res->all as $key => $value) {
         $post = explode('/', $value->page);
         if ($post[1] == 'post') {
             if (array_key_exists($post[2], $sluge)) {
                 $sluge[$post[2]]++;
             } else {
                 $sluge[$post[2]] = 1;
             }
         }
     }
     foreach ($posts->all as $post_key => $post_value) {
         if (!array_key_exists($post_value->slug, $sluge)) {
             $sluge[$post_value->slug] = 0;
         }
     }
     arsort($sluge);
     return $sluge;
 }
Example #2
0
 public function all_posts()
 {
     $posts = new Post();
     $page_number = 1;
     if (isset($_GET['page'])) {
         $page_number = $_GET['page'];
     }
     if (!$this->BuilderEngine->get_option('be_blog_num_posts_displayed')) {
         $posts_per_page = 6;
     } else {
         $posts_per_page = $this->BuilderEngine->get_option('be_blog_num_posts_displayed');
     }
     $data['posts'] = $posts->order_by('time_created', 'desc')->get_paged($page_number, $posts_per_page);
     $data['categories'] = $this->get_categories();
     $this->load->view('frontend/all_posts', $data);
 }
Example #3
0
						      else
						        $(".child" + i).addClass('visible-li');
						  }
						}
						</script>
					</div>

					<!-- recent posts -->
					<div class="widget">

						<h4>RECENT POSTS</h4>

						<ul class="nav nav-list">
						<?php 
$all_posts = new Post();
$recent_posts = $all_posts->order_by('time_created', 'desc');
$recent_post_limit = $this->BuilderEngine->get_option('be_blog_num_recent_posts_displayed');
if ($recent_post_limit == '' || $recent_post_limit == 0) {
    $recent_post_limit = 5;
}
$j = 1;
?>
						<?php 
foreach ($recent_posts->get() as $recent_post) {
    ?>
					        <?php 
    if ($j <= $recent_post_limit) {
        ?>
							    <li><a href="<?php 
        echo base_url();
        ?>
    public function generate_content()
    {
        $CI =& get_instance();
        $CI->load->model('visits');
        $sequence = $CI->visits->populyar_post_by_visits();
        $sections_font_color = $this->block->data('sections_font_color');
        $sections_font_weight = $this->block->data('sections_font_weight');
        $sections_font_size = $this->block->data('sections_font_size');
        $sections_background_color = $this->block->data('sections_background_color');
        $post_count = $this->block->data('post_count');
        $alphabetical_order = $this->block->data('alphabetical_order');
        $category = $this->block->data('category');
        $sections_animation_type = $this->block->data('sections_animation_type');
        $sections_animation_duration = $this->block->data('sections_animation_duration');
        $sections_animation_event = $this->block->data('sections_animation_event');
        $sections_animation_delay = $this->block->data('sections_animation_delay');
        $settings[0][0] = 'category' . $this->block->get_id();
        $settings[0][1] = $sections_animation_event;
        $settings[0][2] = $sections_animation_duration . ' ' . $sections_animation_delay . ' ' . $sections_animation_type;
        add_action("be_foot", generate_animation_events($settings));
        $section_style = 'style="
                    background-color: ' . $sections_background_color . ' !important;
                "';
        $section_link_style = 'style="
                    color: ' . $sections_font_color . ' !important;
                    font-weight: ' . $sections_font_weight . ' !important;
                    font-size: ' . $sections_font_size . ' !important;
                "';
        $users = new User();
        $all_posts = new Post();
        $all_category = new Category();
        $BuilderEngine = new BuilderEngine();
        $recent_posts = $all_posts->order_by('time_created', 'desc');
        if ($category == 'all' || intval($category) == 0) {
            $recent_posts = $recent_posts->get();
        } else {
            $recent_posts = $recent_posts->get_where(array('category_id' => intval($category)));
        }
        $recent_post_limit = $BuilderEngine->get_option('be_blog_posts_per_page');
        if ($recent_post_limit == '' || $recent_post_limit == 0) {
            $recent_post_limit = 5;
        }
        if (isset($post_count)) {
            if ($post_count == 'all') {
                $recent_post_limit = count($recent_posts->all);
            } else {
                $recent_post_limit = $post_count;
            }
        }
        if ($alphabetical_order == 'yes') {
            ksort($sequence);
        }
        $output = '<div class="row">
                <div ' . $section_style . ' class="masonry-list">';
        $i = 1;
        foreach ($sequence as $key => $value) {
            foreach ($recent_posts as $post) {
                if ($key == $post->slug) {
                    if ($i <= $recent_post_limit) {
                        $user = $users->get_by_id($post->user_id);
                        $output .= '
							<link href="' . base_url('blocks/category_posts/style.css') . '" rel="stylesheet">
							<link href="' . base_url('builderengine/public/animations/css/animate.min.css') . '" rel="stylesheet" />
							<div class="col-md-6" id="blog">
                                <li class="masonry-item-blog-category-post">
                                    <div class="item" id="category' . $this->block->get_id() . '">
                                        <div class="item-title blog-header-small">
                                            <h2><a ' . $section_link_style . ' href="' . base_url('/blog/post') . '/' . $post->slug . '"> ' . $post->title . '</a></h2>  
											<small class="space14">';
                        $post_comments = array();
                        $CI =& get_instance();
                        $CI->load->model('comment');
                        $comments = new Comment();
                        foreach ($comments->where('post_id', $post->id)->get() as $comment) {
                            array_push($post_comments, $comment->id);
                        }
                        $num_comments = count($post_comments);
                        $pluralizer = $num_comments == 1 ? 'Comment' : 'Comments';
                        $output .= '                                          
                                            <a href="/blog/post/' . $post->slug . '#comments" class="label label-default light"><i class="fa fa-comment-o"></i> ' . $num_comments . '' . $pluralizer . '</a>
                                            <span class="label label-default light">' . date('M d, Y', $post->time_created) . '</span> 
											<a class="label label-default light pull-right"><i>Post by: </i> ' . $user->username . ' </a>
                                        </div>

                                        <figure>
                                            <a href="/blog/post/' . $post->slug . '"><img src="' . $post->image . '" class="img-responsive thumbnail" alt="" /></a>
                                        </figure>';
                        $text_without_slashes = ChEditorfix($post->text);
                        if (strlen($post->text) > 300) {
                            $text = substr($text_without_slashes, 0, 300) . '...';
                        } else {
                            $text = $text_without_slashes;
                        }
                        $output .= '<div style="word-wrap: break-word;">' . $text . '</div>
                                        <a href="/blog/post/' . $post->slug . '" class="btn-primary btn-xs pull-right"><i class="fa fa-sign-out"></i> READ MORE..</a>
                                    </div>
                                
                                </li></div>';
                        $i++;
                    }
                }
            }
        }
        $output .= '
                </div></div>';
        return $output;
    }
Example #5
0
	function latest($page_number = 0)
	{
		
		
		$limit = 10;
		$offset = $page_number * $limit;
		
		$postObject = new Post;
		
		if(! $this->dx_auth->is_logged_in())
			$postObject->where("status", $this->_PUBLISHED)->order_by("published DESC")->limit($limit, $offset)->get();
		else
			$postObject->order_by("created DESC")->limit($limit, $offset)->get();
			
		foreach($postObject->all as $post)
		{
			$data["posts"][$post->id]["id"] = $post->id;
			$data["posts"][$post->id]["category"] = ($post->category_id > 0) ? $post->category->name : "Entry";
			$data["posts"][$post->id]["title"] = $post->title;
			$data["posts"][$post->id]["published"] = $post->published;
			$data["posts"][$post->id]["author"] = $post->author->name();
			$data["posts"][$post->id]["body"] = $post->body;
			$data["posts"][$post->id]["url"] = $post->url;
		}
		
		$this->load->view("chronicle/list", $data);
	}
Example #6
0
 private function slugger($title)
 {
     $a = explode(' ', $title);
     foreach ($a as &$t) {
         if (strpos($t, '-')) {
             explode(' ', $t);
         }
     }
     if (count($a) > 5) {
         $a = array_slice($a, 0, 4);
     }
     $f = implode('-', $a);
     $p = Post::order_by('created_at', 'desc')->first();
     $f .= "-" . ($p->id + 1);
     return $f;
 }
Example #7
0
    public function generate_content()
    {
        $sections_font_color = $this->block->data('sections_font_color');
        $sections_font_weight = $this->block->data('sections_font_weight');
        $sections_font_size = $this->block->data('sections_font_size');
        $sections_background_color = $this->block->data('sections_background_color');
        $post_count = $this->block->data('post_count');
        $animation = $this->block->data('animation');
        $animation_type = $this->block->data('animation_type');
        $animation_duration = $this->block->data('animation_duration');
        $animation_event = $this->block->data('animation_event');
        $animation_delay = $this->block->data('animation_delay');
        $settings[0][0] = 'recentitems' . $this->block->get_id();
        $settings[0][1] = $animation_event;
        $settings[0][2] = $animation_duration . ' ' . $animation_delay . ' ' . $animation_type;
        add_action("be_foot", generate_animation_events($settings));
        $section_style = 'style="
                    background-color: ' . $sections_background_color . ' !important;
                "';
        $section_link_style = 'style="
                    color: ' . $sections_font_color . ' !important;
                    font-weight: ' . $sections_font_weight . ' !important;
                    font-size: ' . $sections_font_size . ' !important;
                "';
        $CI =& get_instance();
        $CI->load->model('post');
        $all_posts = new Post();
        $BuilderEngine = new BuilderEngine();
        $recent_posts = $all_posts->order_by('time_created', 'desc');
        $recent_post_limit = $BuilderEngine->get_option('be_blog_num_recent_posts_displayed');
        if ($recent_post_limit == '' || $recent_post_limit == 0) {
            $recent_post_limit = 5;
        }
        if (isset($post_count)) {
            $recent_post_limit = $post_count;
        }
        $j = 1;
        $output = '
					<link href=\\"/builderengine/public/animations/css/animate.min.css\\" rel=\\"stylesheet\\" />
                     <link href="' . base_url('blocks/recent_posts/style.css') . '" rel="stylesheet">
					<div ' . $section_style . ' class="widgetblogrecent" id="blog">
					<div id="recentitems' . $this->block->get_id() . '" class="masonry-item-blog-recent">
                        <h4>RECENT BLOGS</h4>
                        <ul class="nav nav-list">';
        foreach ($recent_posts->get() as $recent_post) {
            if ($j <= $recent_post_limit) {
                $output .= '
                                    <li>
                                        <a ' . $section_link_style . ' href="' . base_url() . 'blog/post/' . $recent_post->slug . '">
                                            <i class="fa fa-sign-out"></i> 
                                        ' . $recent_post->title . '</a>
                                        <small>' . date('d.M.Y / h:i', $recent_post->time_created) . '</small>
                                    </li>';
                $j++;
            }
        }
        $output .= '
                        </ul>
                   </div> </div>';
        return $output;
    }
Example #8
0
 public function action_index()
 {
     $posts = Post::order_by('created_at', 'desc')->get();
     return View::make('posts.all')->with('posts', $posts);
 }
    public function generate_content()
    {
        $CI =& get_instance();
        $CI->load->model('visits');
        $sequence = $CI->visits->populyar_post_by_visits();
        $sections_font_color = $this->block->data('sections_font_color');
        $sections_font_weight = $this->block->data('sections_font_weight');
        $sections_font_size = $this->block->data('sections_font_size');
        $sections_background_color = $this->block->data('sections_background_color');
        $sections_animation_type = $this->block->data('sections_animation_type');
        $sections_animation_duration = $this->block->data('sections_animation_duration');
        $sections_animation_event = $this->block->data('sections_animation_event');
        $sections_animation_delay = $this->block->data('sections_animation_delay');
        $settings[0][0] = 'blog_list';
        $settings[0][1] = $sections_animation_event;
        $settings[0][2] = $sections_animation_duration . ' ' . $sections_animation_delay . ' ' . $sections_animation_type;
        add_action("be_foot", generate_animation_events($settings));
        $post_count = $this->block->data('post_count');
        $alphabetical_order = $this->block->data('alphabetical_order');
        $category = $this->block->data('category');
        $section_style = 'style="
                    background-color: ' . $sections_background_color . ' !important;
                "';
        $section_link_style = 'style="
                    color: ' . $sections_font_color . ' !important;
                    font-weight: ' . $sections_font_weight . ' !important;
                    font-size: ' . $sections_font_size . ' !important;
                "';
        $all_posts = new Post();
        $all_category = new Category();
        $BuilderEngine = new BuilderEngine();
        $recent_posts = $all_posts->order_by('time_created', 'desc');
        // out(intval($category));
        if ($category == 'all' || intval($category) == 0) {
            $recent_posts = $recent_posts->get();
        } else {
            $recent_posts = $recent_posts->get_where(array('category_id' => intval($category)));
        }
        $recent_post_limit = $BuilderEngine->get_option('be_blog_num_recent_posts_displayed');
        if ($recent_post_limit == '' || $recent_post_limit == 0) {
            $recent_post_limit = 5;
        }
        if (isset($post_count)) {
            if ($post_count == 'all') {
                $recent_post_limit = count($recent_posts->all);
            } else {
                $recent_post_limit = $post_count;
            }
        }
        if ($alphabetical_order == 'az') {
            //ok
            ksort($sequence);
        }
        if ($alphabetical_order == 'za') {
            //ok
            krsort($sequence);
        }
        if ($alphabetical_order == 'oldest') {
            $recent_posts = $all_posts->order_by('time_created', 'asc');
        }
        if ($alphabetical_order == 'latest') {
            //ok
            rsort($sequence);
        }
        if ($alphabetical_order == 'updated') {
            $recent_posts = $all_posts->order_by('time_created', 'desc');
        }
        if ($alphabetical_order == 'most_visited') {
            //ok
            arsort($sequence);
        }
        if ($alphabetical_order == 'less_visited') {
            //ok
            asort($sequence);
        }
        $output = '
                    <link href="' . base_url('blocks/blog_posts_list/style.css') . '" rel="stylesheet">
					<div ' . $section_style . ' class="widgetbloglist" id="blog_list">
					<div class="masonry-item-blog-list">
                        <h4>BLOG POSTS</h4>
                        <ul class="nav nav-list">';
        $j = 1;
        foreach ($sequence as $key => $value) {
            foreach ($recent_posts as $recent_post) {
                if ($key == $recent_post->slug) {
                    if ($j <= $recent_post_limit) {
                        $output .= '
                                            <li>
                                                <a ' . $section_link_style . ' href="' . base_url() . 'blog/post/' . $recent_post->slug . '">
                                                    <i class="fa fa-sign-out"></i>  
                                                ' . $recent_post->title . '</a>
                                                <small>' . date('d.M.Y / h:i', $recent_post->time_created) . '</small>
                                            </li>';
                        $j++;
                    }
                }
            }
        }
        $output .= '
                        </ul>
                  </div>   </div>';
        return $output;
    }