Subversion Repositories cheapmusic

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
103 - 1
<?php
2
 
3
/***************************************************************************
4
 *   Copyright (C) 2009-2011 by Geo Varghese(www.seopanel.in)  	   *
5
 *   sendtogeo@gmail.com   												   *
6
 *                                                                         *
7
 *   This program is free software; you can redistribute it and/or modify  *
8
 *   it under the terms of the GNU General Public License as published by  *
9
 *   the Free Software Foundation; either version 2 of the License, or     *
10
 *   (at your option) any later version.                                   *
11
 *                                                                         *
12
 *   This program is distributed in the hope that it will be useful,       *
13
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
14
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
15
 *   GNU General Public License for more details.                          *
16
 *                                                                         *
17
 *   You should have received a copy of the GNU General Public License     *
18
 *   along with this program; if not, write to the                         *
19
 *   Free Software Foundation, Inc.,                                       *
20
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
21
 ***************************************************************************/
22
 
23
# class defines all blog controller functions
24
class BlogController extends Controller{
25
 
26
	# func to show all blogs
27
	function listBlogs($info=''){
28
		$whereCond = "status=1 and link_page=''";
29
		$whereCond .= !empty($info['tag']) ? " and tags like '%".addslashes(trim(urldecode($info['tag'])))."%'" : "";
30
		$whereCond .= !empty($info['search']) ? " and blog_content like '%".addslashes($info['search'])."%'" : "";
31
		$countInfo = $this->dbHelper->getRow("cust_blogs", $whereCond, "count(*) count");
32
		$totalPageCount = ceil(($countInfo['count'] / SP_PAGINGNO));
33
		$currPage = intval($info['page']);
34
		$currPage = $currPage ? $currPage : 1;
35
 
36
		$whereCond .= " order by created_time desc";
37
		$start = ($currPage - 1) * SP_PAGINGNO;
38
		$whereCond .= " limit $start," . SP_PAGINGNO;
39
		$blogList = $this->dbHelper->getAllRows("cust_blogs", $whereCond);
40
		$blogBaseLink = SP_WEBPATH . "/blog.php?search=".$info['search']."&tag=".$info['tag'];
41
		$this->set("blogBaseLink", $blogBaseLink);
42
		$this->set("post", $info);
43
 
44
		$olderPage = ($currPage < $totalPageCount) ? $currPage + 1 : 0;
45
		$newerPage = ($currPage > 1) ? $currPage - 1 : 0;
46
		$this->set('olderPage', $olderPage);
47
		$this->set('newerPage', $newerPage);
48
		$this->set('blogList', $blogList);
49
		$this->render('blog/blog_list');
50
	}
51
 
52
	# func to show a blog
53
	function showBlog($blogId){
54
		$whereCond = "status=1 and id=" . intval($blogId);
55
		$blogInfo = $this->dbHelper->getRow("cust_blogs", $whereCond);
56
		$this->set('spTitle', $blogInfo['meta_title']);
57
		$this->set('spDescription', $blogInfo['meta_description']);
58
		$this->set('spKeywords', $blogInfo['meta_keywords']);
59
		$this->set('blogInfo', $blogInfo);
60
		$this->render('blog/blog_show');
61
	}
62
 
63
}
64
?>