PageRenderTime 81ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/halogy/modules/blog/controllers/blog.php

https://gitlab.com/intelij/Halogy
PHP | 624 lines | 421 code | 100 blank | 103 comment | 36 complexity | dfbcb5eb8dcc3cb83b829a326c781977 MD5 | raw file
  1. <?php
  2. /**
  3. * Halogy
  4. *
  5. * A user friendly, modular content management system for PHP 5.0
  6. * Built on CodeIgniter - http://codeigniter.com
  7. *
  8. * @package Halogy
  9. * @author Haloweb Ltd
  10. * @copyright Copyright (c) 2012, Haloweb Ltd
  11. * @license http://halogy.com/license
  12. * @link http://halogy.com/
  13. * @since Version 1.0
  14. * @filesource
  15. */
  16. // ------------------------------------------------------------------------
  17. class Blog extends MX_Controller {
  18. var $partials = array();
  19. var $sitePermissions = array();
  20. var $num = 10;
  21. function __construct()
  22. {
  23. parent::__construct();
  24. // get siteID, if available
  25. if (defined('SITEID'))
  26. {
  27. $this->siteID = SITEID;
  28. }
  29. // get site permissions and redirect if it don't have access to this module
  30. if (!$this->permission->sitePermissions)
  31. {
  32. show_error('You do not have permission to view this page');
  33. }
  34. if (!in_array($this->uri->segment(1), $this->permission->sitePermissions))
  35. {
  36. show_error('You do not have permission to view this page');
  37. }
  38. // load models and modules
  39. $this->load->library('tags');
  40. $this->load->model('blog_model', 'blog');
  41. $this->load->module('pages');
  42. // load partials - categories
  43. if ($cats = $this->blog->get_cats())
  44. {
  45. foreach($cats as $cat)
  46. {
  47. $this->partials['blog:categories'][] = array(
  48. 'category:link' => site_url('/blog/'.$cat['catSafe']),
  49. 'category:title' => $cat['catName'],
  50. 'category:count' => $cat['numPosts']
  51. );
  52. }
  53. }
  54. // load partials - archive
  55. if ($archive = $this->blog->get_archive())
  56. {
  57. foreach($archive as $date)
  58. {
  59. $this->partials['blog:archive'][] = array(
  60. 'archive:link' => site_url('/blog/'.$date['year'].'/'.$date['month'].'/'),
  61. 'archive:title' => $date['dateStr'],
  62. 'archive:count' => $date['numPosts']
  63. );
  64. }
  65. }
  66. // load partials - latest
  67. if ($latest = $this->blog->get_headlines())
  68. {
  69. foreach($latest as $post)
  70. {
  71. $this->partials['blog:latest'][] = array(
  72. 'latest:link' => site_url('blog/'.dateFmt($post['dateCreated'], 'Y/m').'/'.$post['uri']),
  73. 'latest:title' => $post['postTitle'],
  74. 'latest:date' => dateFmt($post['dateCreated'], ($this->site->config['dateOrder'] == 'MD') ? 'M jS Y' : 'jS M Y'),
  75. );
  76. }
  77. }
  78. // get tags
  79. if ($popularTags = $this->tags->get_popular_tags('blog_posts'))
  80. {
  81. foreach($popularTags as $tag)
  82. {
  83. $this->partials['blog:tags'][] = array(
  84. 'tag' => $tag['tag'],
  85. 'tag:link' => site_url('/blog/tag/'.$tag['safe_tag']),
  86. 'tag:count' => $tag['count']
  87. );
  88. }
  89. }
  90. }
  91. function index()
  92. {
  93. // get partials
  94. $output = $this->partials;
  95. // get latest posts
  96. $posts = $this->blog->get_posts($this->num);
  97. $output['blog:posts'] = $this->_populate_posts($posts);
  98. // set title
  99. $output['page:title'] = 'Blog'.(($this->site->config['siteName']) ? ' - '.$this->site->config['siteName'] : '');
  100. // set pagination and breadcrumb
  101. $output['blog:newer'] = ($this->pagination->offset) ?
  102. (($this->pagination->offset - $this->num > 0) ?
  103. anchor('/blog/more/page/'.($this->pagination->offset - $this->num), '&laquo; Newer') :
  104. anchor('/blog', '&laquo; Newer'))
  105. : '';
  106. $output['blog:older'] = ($this->pagination->total_rows > ($this->pagination->offset + $this->num)) ? anchor('/blog/more/page/'.($this->pagination->offset + $this->num), 'Older &raquo;') : '';
  107. // display with cms layer
  108. $this->pages->view('blog', $output, TRUE);
  109. }
  110. function more()
  111. {
  112. // get partials
  113. $output = $this->partials;
  114. // get latest posts
  115. $posts = $this->blog->get_posts($this->num);
  116. $output['blog:posts'] = $this->_populate_posts($posts);
  117. // set title
  118. $output['page:title'] = 'Blog'.(($this->site->config['siteName']) ? ' - '.$this->site->config['siteName'] : '');
  119. // set pagination and breadcrumb
  120. $output['blog:newer'] = ($this->pagination->offset) ?
  121. (($this->pagination->offset - $this->num > 0) ?
  122. anchor('/blog/more/page/'.($this->pagination->offset - $this->num), '&laquo; Newer') :
  123. anchor('/blog', '&laquo; Newer'))
  124. : '';
  125. $output['blog:older'] = ($this->pagination->total_rows > ($this->pagination->offset + $this->num)) ? anchor('/blog/more/page/'.($this->pagination->offset + $this->num), 'Older &raquo;') : '';
  126. // display with cms layer
  127. $this->pages->view('blog', $output, TRUE);
  128. }
  129. function read()
  130. {
  131. // get partials
  132. $output = $this->partials;
  133. // get post based on uri
  134. $year = $this->uri->segment(2);
  135. $month = $this->uri->segment(3);
  136. $uri = $this->uri->segment(4);
  137. if ($post = $this->blog->get_post($year, $month, $uri))
  138. {
  139. // add comment
  140. if (count($_POST))
  141. {
  142. // required
  143. $this->core->required = array(
  144. 'fullName' => 'Full name',
  145. 'comment' => 'Comment',
  146. );
  147. // check for spam
  148. preg_match_all('/http:\/\//i', $this->input->post('comment'), $urlMatches);
  149. preg_match_all('/viagra|levitra|cialis/i', $this->input->post('comment'), $spamMatches);
  150. if (count($urlMatches[0]) > 2 || (count($urlMatches[0]) > 0 && count($spamMatches[0]) > 0))
  151. {
  152. $this->form_validation->set_error('Sorry but your comment looks like spam. Please remove links and try again.');
  153. }
  154. elseif (isset($_POST['captcha']) && !$this->_captcha_check())
  155. {
  156. $this->form_validation->set_error('Sorry you didn\'t pass the spam check. Please contact us to post a comment.');
  157. }
  158. else
  159. {
  160. // set date
  161. $this->core->set['dateCreated'] = date("Y-m-d H:i:s");
  162. $this->core->set['postID'] = $post['postID'];
  163. // awaiting moderation
  164. if ($this->session->userdata('session_admin'))
  165. {
  166. $this->core->set['active'] = 1;
  167. }
  168. else
  169. {
  170. $this->core->set['active'] = 0;
  171. }
  172. // update
  173. if ($this->core->update('blog_comments'))
  174. {
  175. // get insertID
  176. $commentID = $this->db->insert_id();
  177. // get details on post poster
  178. $user = $this->blog->get_user($post['userID']);
  179. // construct URL
  180. $url = '/blog/'.$year.'/'.$month.'/'.$uri.'/';
  181. if ($user['notifications'] && !$this->session->userdata('session_admin'))
  182. {
  183. // set header and footer
  184. $emailHeader = str_replace('{name}', $user['firstName'].' '.$user['lastName'], $this->site->config['emailHeader']);
  185. $emailHeader = str_replace('{email}', $user['email'], $emailHeader);
  186. $emailFooter = str_replace('{name}', $user['firstName'].' '.$user['lastName'], $this->site->config['emailFooter']);
  187. $emailFooter = str_replace('{email}', $user['email'], $emailFooter);
  188. // send email
  189. $this->load->library('email');
  190. $this->email->from($this->site->config['siteEmail'], $this->site->config['siteName']);
  191. $this->email->to($user['email']);
  192. $this->email->subject('New Blog Comment on '.$this->site->config['siteName']);
  193. $this->email->message($emailHeader."\n\nSomeone has just commented on your blog post titled \"".$post['postTitle']."\".\n\nYou can either approve or delete this comment by clicking on the following URL:\n\n".site_url('/admin/blog/comments')."\n\nThey said:\n\"".$this->input->post('comment')."\"\n\n".$emailFooter);
  194. $this->email->send();
  195. }
  196. // output message
  197. $output['message'] = 'Thank you, your comment has been posted and is awaiting moderation.';
  198. // disable form
  199. $post['allowComments'] = 0;
  200. }
  201. }
  202. }
  203. // set page title
  204. $output['page:title'] = $post['postTitle'].(($this->site->config['siteName']) ? ' - '.$this->site->config['siteName'] : '');
  205. // set meta description
  206. if ($post['excerpt'])
  207. {
  208. $output['page:description'] = $post['excerpt'];
  209. }
  210. // get author details
  211. $author = $this->blog->lookup_user($post['userID']);
  212. // populate template
  213. $output['post:title'] = $post['postTitle'];
  214. $output['post:link'] = site_url('blog/'.dateFmt($post['dateCreated'], 'Y/m').'/'.$post['uri']);
  215. $output['post:date'] = dateFmt($post['dateCreated'], ($this->site->config['dateOrder'] == 'MD') ? 'M jS Y' : 'jS M Y');
  216. $output['post:day'] = dateFmt($post['dateCreated'], 'd');
  217. $output['post:month'] = dateFmt($post['dateCreated'], 'M');
  218. $output['post:year'] = dateFmt($post['dateCreated'], 'y');
  219. $output['post:body'] = $this->template->parse_body($post['body']);
  220. $output['post:excerpt'] = $this->template->parse_body($post['excerpt']);
  221. $output['post:comments-count'] = $post['numComments'];
  222. $output['post:author'] = (($author['displayName']) ? $author['displayName'] : $author['firstName'].' '.$author['lastName']);
  223. $output['post:author-id'] = $author['userID'];
  224. $output['post:author-email'] = $author['email'];
  225. $output['post:author-gravatar'] = 'http://www.gravatar.com/avatar.php?gravatar_id='.md5(trim($author['email'])).'&default='.urlencode(site_url('/static/uploads/avatars/noavatar.gif'));
  226. $output['post:author-bio'] = $author['bio'];
  227. $output['post:allow-comments'] = ($post['allowComments']) ? TRUE : FALSE;
  228. $output['form:name'] = set_value('fullName', $this->session->userdata('firstName').' '.$this->session->userdata('lastName'));
  229. $output['form:email'] = set_value('email', $this->session->userdata('email'));
  230. $output['form:website'] = $this->input->post('website');
  231. $output['form:comment'] = $this->input->post('comment');
  232. // get cats
  233. if ($cats = $this->blog->get_cats_for_post($post['postID']))
  234. {
  235. $i = 0;
  236. foreach ($cats as $cat)
  237. {
  238. $output['post:categories'][$i]['category:link'] = site_url('blog/'.url_title(strtolower(trim($cat))));
  239. $output['post:categories'][$i]['category'] = $cat;
  240. $i++;
  241. }
  242. }
  243. // get tags
  244. if ($post['tags'])
  245. {
  246. $tags = explode(',', $post['tags']);
  247. $i = 0;
  248. foreach ($tags as $tag)
  249. {
  250. $output['post:tags'][$i]['tag:link'] = site_url('blog/tag/'.$this->tags->make_safe_tag($tag));
  251. $output['post:tags'][$i]['tag'] = $tag;
  252. $i++;
  253. }
  254. }
  255. // get comments
  256. if ($comments = $this->blog->get_comments($post['postID']))
  257. {
  258. $i = 0;
  259. foreach ($comments as $comment)
  260. {
  261. $output['post:comments'][$i]['comment:class'] = ($i % 2) ? ' alt ' : '';
  262. $output['post:comments'][$i]['comment:id'] = $comment['commentID'];
  263. $output['post:comments'][$i]['comment:gravatar'] = 'http://www.gravatar.com/avatar.php?gravatar_id='.md5(trim($comment['email'])).'&default='.urlencode(site_url('/static/uploads/avatars/noavatar.gif'));
  264. $output['post:comments'][$i]['comment:author'] = (!empty($comment['website'])) ? anchor(prep_url($comment['website']), $comment['fullName']) : $comment['fullName'];
  265. $output['post:comments'][$i]['comment:date'] = dateFmt($comment['dateCreated'], ($this->site->config['dateOrder'] == 'MD') ? 'M jS Y' : 'jS M Y');
  266. $output['post:comments'][$i]['comment:body'] = nl2br(auto_link(strip_tags($comment['comment'])));
  267. $i++;
  268. }
  269. }
  270. // load errors
  271. $output['errors'] = (validation_errors()) ? validation_errors() : FALSE;
  272. // add view
  273. $this->blog->add_view($post['postID']);
  274. // output post ID for CMS
  275. $output['postID'] = $post['postID'];
  276. // display with cms layer
  277. $this->pages->view('blog_single', $output, TRUE);
  278. }
  279. else
  280. {
  281. show_404();
  282. }
  283. }
  284. function tag($tag = '')
  285. {
  286. // get partials
  287. $output = $this->partials;
  288. // get posts
  289. $posts = $this->blog->get_posts_by_tag($tag);
  290. $output['blog:posts'] = $this->_populate_posts($posts);
  291. // output tag tags
  292. $output['tag:title'] = ucwords(str_replace('-', ' ', $tag));
  293. $output['tag:link'] = '/blog/tag/'.$tag;
  294. // set pagination and breadcrumb
  295. $output['blog:newer'] = ($this->pagination->offset) ?
  296. (($this->pagination->offset - $this->num > 0) ?
  297. anchor('/blog/tag/'.$tag.'/page/'.($this->pagination->offset - $this->num), '&laquo; Newer') :
  298. anchor('/blog/tag/'.$tag, '&laquo; Newer'))
  299. : '';
  300. $output['blog:older'] = ($this->pagination->total_rows > ($this->pagination->offset + $this->num)) ? anchor('/blog/tag/'.$tag.'/page/'.($this->pagination->offset + $this->num), 'Older &raquo;') : '';
  301. // set title
  302. $output['page:title'] = ucwords(str_replace('-', ' ', $tag)).(($this->site->config['siteName']) ? ' - '.$this->site->config['siteName'] : '');
  303. $output['page:heading'] = '<small>Tag:</small> '.ucfirst(str_replace('-', ' ', $tag));
  304. // display with cms layer
  305. $this->pages->view('blog', $output, TRUE);
  306. }
  307. function category($cat = '')
  308. {
  309. // get partials
  310. $output = $this->partials;
  311. // get posts
  312. $posts = $this->blog->get_posts_by_category($cat);
  313. $output['blog:posts'] = $this->_populate_posts($posts);
  314. // output category tags
  315. $output['category:title'] = ucwords(str_replace('-', ' ', $cat));
  316. $output['category:link'] = '/blog/'.$cat;
  317. // set pagination and breadcrumb
  318. $output['blog:newer'] = ($this->pagination->offset) ?
  319. (($this->pagination->offset - $this->num > 0) ?
  320. anchor('/blog/'.$cat.'/page/'.($this->pagination->offset - $this->num), '&laquo; Newer') :
  321. anchor('/blog/'.$cat, '&laquo; Newer'))
  322. : '';
  323. $output['blog:older'] = ($this->pagination->total_rows > ($this->pagination->offset + $this->num)) ? anchor('/blog/'.$cat.'/page/'.($this->pagination->offset + $this->num), 'Older &raquo;') : '';
  324. // set title
  325. $output['page:title'] = ucwords(str_replace('-', ' ', $cat)).(($this->site->config['siteName']) ? ' - '.$this->site->config['siteName'] : '');
  326. $output['page:heading'] = '<small>Category:</small> '.ucwords(str_replace('-', ' ', $cat));
  327. // display with cms layer
  328. $this->pages->view('blog', $output, TRUE);
  329. }
  330. function month()
  331. {
  332. // get partials
  333. $output = $this->partials;
  334. // get post based on uri
  335. $year = $this->uri->segment(2);
  336. $month = $this->uri->segment(3);
  337. // get posts
  338. $posts = $this->blog->get_posts_by_date($year, $month);
  339. $output['blog:posts'] = $this->_populate_posts($posts);
  340. // set title
  341. $output['page:title'] = 'Posts For '.date('F Y', mktime(0,0,0,$month,1,$year)).(($this->site->config['siteName']) ? ' - '.$this->site->config['siteName'] : '');
  342. $output['page:heading'] = '<small>Archive:</small> '.date('F Y', mktime(0,0,0,$month,1,$year));
  343. // set pagination and breadcrumb
  344. $output['blog:newer'] = ($this->pagination->offset) ?
  345. (($this->pagination->offset - $this->num > 0) ?
  346. anchor('/blog/'.$year.'/'.$month.'/page/'.($this->pagination->offset - $this->num), '&laquo; Newer') :
  347. anchor('/blog/'.$year.'/'.$month, '&laquo; Newer'))
  348. : '';
  349. $output['blog:older'] = ($this->pagination->total_rows > ($this->pagination->offset + $this->num)) ? anchor('/blog/'.$year.'/'.$month.'/page/'.($this->pagination->offset + $this->num), 'Older &raquo;') : '';
  350. // display with cms layer
  351. $this->pages->view('blog', $output, TRUE);
  352. }
  353. function year()
  354. {
  355. // get partials
  356. $output = $this->partials;
  357. // get post based on uri
  358. $year = $this->uri->segment(2);
  359. // get tags
  360. $posts = $this->blog->get_posts_by_date($year);
  361. $output['blog:posts'] = $this->_populate_posts($posts);
  362. // set title
  363. $output['page:title'] = 'Posts For '.date('Y', mktime(0,0,0,1,1,$year)).(($this->site->config['siteName']) ? ' - '.$this->site->config['siteName'] : '');
  364. $output['page:heading'] = '<small>Archive:</small> '.date('Y', mktime(0,0,0,1,1,$year));
  365. // set pagination and breadcrumb
  366. $output['blog:newer'] = ($this->pagination->offset) ?
  367. (($this->pagination->offset - $this->num > 0) ?
  368. anchor('/blog/'.$year.'/page/'.($this->pagination->offset - $this->num), '&laquo; Newer') :
  369. anchor('/blog/'.$year, '&laquo; Newer'))
  370. : '';
  371. $output['blog:older'] = ($this->pagination->total_rows > ($this->pagination->offset + $this->num)) ? anchor('/blog/'.$year.'/page/'.($this->pagination->offset + $this->num), 'Older &raquo;') : '';
  372. // display with cms layer
  373. $this->pages->view('blog', $output, TRUE);
  374. }
  375. function search($query = '')
  376. {
  377. // get partials
  378. $output = $this->partials;
  379. // set tags
  380. $query = ($query) ? $query : $this->input->post('query');
  381. // get result from tags
  382. $objectIDs = $this->tags->search('blog_posts', $query);
  383. $posts = $this->blog->search_posts($query, $objectIDs);
  384. $output['blog:posts'] = $this->_populate_posts($posts);
  385. $output['query'] = $query;
  386. // set title
  387. $output['page:title'] = 'Search the Blog'.(($this->site->config['siteName']) ? ' - '.$this->site->config['siteName'] : '');
  388. $output['page:heading'] = 'Search for "'.$output['query'].'"';
  389. // set pagination and breadcrumb
  390. $output['blog:older'] = ($this->pagination->offset) ? anchor('/blog/more/page/'.($this->pagination->offset - $this->num), 'Older &raquo;') : '';
  391. $output['blog:newer'] = ($this->pagination->total_rows > ($this->pagination->offset + $this->num)) ? anchor('/blog/more/page/'.($this->pagination->offset + $this->num), '&laquo; Newer') : '';
  392. // display with cms layer
  393. $this->pages->view('blog_search', $output, TRUE);
  394. }
  395. function feed($cat = '')
  396. {
  397. // rss feed
  398. $this->load->helper('xml');
  399. $data['encoding'] = 'utf-8';
  400. $data['page_language'] = 'en';
  401. $data['creator_email'] = $this->site->config['siteEmail'];
  402. // get posts by category
  403. if ($cat)
  404. {
  405. $category = ucwords(str_replace('-', ' ', $cat));
  406. $data['feed_name'] = $this->site->config['siteName'].' - '.$category;
  407. $data['feed_url'] = site_url('/blog/'.$cat);
  408. $data['page_description'] = 'Blog Category RSS Feed for '.$this->site->config['siteName'].' - '.$category.'.';
  409. $data['posts'] = $this->blog->get_posts_by_category($cat);
  410. }
  411. // get latest posts
  412. else
  413. {
  414. $data['feed_name'] = $this->site->config['siteName'];
  415. $data['feed_url'] = site_url('/blog');
  416. $data['page_description'] = 'Blog RSS Feed for '.$this->site->config['siteName'].'.';
  417. $data['posts'] = $this->blog->get_posts(10);
  418. }
  419. $this->output->set_header('Content-Type: application/rss+xml');
  420. $this->load->view('blog/rss', $data);
  421. }
  422. function ac_search()
  423. {
  424. $tags = strtolower($_POST["q"]);
  425. if (!$tags)
  426. {
  427. return FALSE;
  428. }
  429. if ($objectIDs = $this->tags->search('blog_posts', $tags))
  430. {
  431. // form dropdown and myql get countries
  432. if ($searches = $this->blog->search_posts($objectIDs))
  433. {
  434. // go foreach
  435. foreach($searches as $search)
  436. {
  437. $items[$search['tags']] = array('id' => dateFmt($search['dateCreated'], 'Y/m').'/'.$search['uri'], 'name' => $search['postTitle']);
  438. }
  439. foreach ($items as $key=>$value)
  440. {
  441. $id = $value['id'];
  442. $name = $value['name'];
  443. /* If you want to force the results to the query
  444. if (strpos(strtolower($key), $tags) !== false)
  445. {
  446. echo "$key|$id|$name\n";
  447. }*/
  448. $this->output->set_output("$key|$id|$name\n");
  449. }
  450. }
  451. }
  452. }
  453. function _captcha_check()
  454. {
  455. // if captcha is posted, check its not a bot (requires js)
  456. if ($this->input->post('captcha') == 'notabot')
  457. {
  458. return TRUE;
  459. }
  460. elseif ($this->input->post('captcha') != 'notabot')
  461. {
  462. $this->form_validation->set_message('captcha_check', 'You didn\'t pass the spam check, please contact us to post a comment.');
  463. return FALSE;
  464. }
  465. }
  466. function _populate_posts($posts = '')
  467. {
  468. if ($posts && is_array($posts))
  469. {
  470. $x = 0;
  471. foreach($posts as $post)
  472. {
  473. // get author details
  474. $author = $this->blog->lookup_user($post['userID']);
  475. // populate template array
  476. $data[$x] = array(
  477. 'post:link' => site_url('blog/'.dateFmt($post['dateCreated'], 'Y/m').'/'.$post['uri']),
  478. 'post:title' => $post['postTitle'],
  479. 'post:date' => dateFmt($post['dateCreated'], ($this->site->config['dateOrder'] == 'MD') ? 'M jS Y' : 'jS M Y'),
  480. 'post:day' => dateFmt($post['dateCreated'], 'd'),
  481. 'post:month' => dateFmt($post['dateCreated'], 'M'),
  482. 'post:year' => dateFmt($post['dateCreated'], 'y'),
  483. 'post:body' => $this->template->parse_body($post['body'], TRUE, site_url('blog/'.dateFmt($post['dateCreated'], 'Y/m').'/'.$post['uri'])),
  484. 'post:excerpt' => $this->template->parse_body($post['excerpt'], TRUE, site_url('blog/'.dateFmt($post['dateCreated'], 'Y/m').'/'.$post['uri'])),
  485. 'post:author' => (($author['displayName']) ? $author['displayName'] : $author['firstName'].' '.$author['lastName']),
  486. 'post:author-id' => $author['userID'],
  487. 'post:author-email' => $author['email'],
  488. 'post:author-gravatar' => 'http://www.gravatar.com/avatar.php?gravatar_id='.md5(trim($author['email'])).'&default='.urlencode(site_url('/static/uploads/avatars/noavatar.gif')),
  489. 'post:author-bio' => $author['bio'],
  490. 'post:comments-count' => $post['numComments']
  491. );
  492. // get cats
  493. if ($cats = $this->blog->get_cats_for_post($post['postID']))
  494. {
  495. $i = 0;
  496. foreach ($cats as $cat)
  497. {
  498. $data[$x]['post:categories'][$i]['category:link'] = site_url('blog/'.url_title(strtolower(trim($cat))));
  499. $data[$x]['post:categories'][$i]['category'] = $cat;
  500. $i++;
  501. }
  502. }
  503. // get tags
  504. if ($post['tags'])
  505. {
  506. $tags = explode(',', $post['tags']);
  507. $i = 0;
  508. foreach ($tags as $tag)
  509. {
  510. $data[$x]['post:tags'][$i]['tag:link'] = site_url('blog/tag/'.$this->tags->make_safe_tag($tag));
  511. $data[$x]['post:tags'][$i]['tag'] = $tag;
  512. $i++;
  513. }
  514. }
  515. $x++;
  516. }
  517. return $data;
  518. }
  519. else
  520. {
  521. return FALSE;
  522. }
  523. }
  524. }