├── views ├── themes │ └── default │ │ ├── _blocks │ │ ├── comment_form.php │ │ ├── about.php │ │ ├── sidemenu.php │ │ ├── author.php │ │ ├── comment_thanks.php │ │ ├── header.php │ │ ├── post_unpublished.php │ │ ├── links.php │ │ ├── tags.php │ │ ├── authors.php │ │ ├── search.php │ │ ├── archives.php │ │ ├── categories.php │ │ ├── comment.php │ │ └── posts.php │ │ ├── tag.php │ │ ├── category.php │ │ ├── index.php │ │ ├── posts.php │ │ ├── authors.php │ │ ├── tags.php │ │ ├── categories.php │ │ ├── archives.php │ │ ├── search.php │ │ ├── author.php │ │ ├── _layouts │ │ └── blog.php │ │ └── post.php ├── _docs │ ├── fuel_blog.php │ ├── blog_helper.php │ ├── links.php │ ├── categories.php │ ├── authors.php │ ├── index.php │ ├── settings.php │ ├── configuration.php │ ├── themes.php │ ├── comments.php │ └── posts.php ├── index.html ├── _admin │ ├── dashboard.php │ └── settings.php └── feed │ ├── rss_posts.php │ └── atom_posts.php ├── fonts ├── VeraBd.ttf ├── arialbd.ttf └── verdanab.ttf ├── assets ├── images │ ├── ico_user.png │ ├── ico_comment.png │ ├── ico_folder_page.png │ ├── ico_table_gear.png │ ├── ico_world_link.png │ └── ico_page_white_edit.png ├── cache │ └── index.html ├── captchas │ └── index.html ├── css │ └── blog.css └── js │ └── comment_reply.js ├── config ├── blog_constants.php ├── index.html ├── blog_routes.php ├── blog_hooks.php ├── blog_fuel_modules.php ├── language_codes.php └── blog.php ├── helpers ├── index.html └── blog_helper.php ├── models ├── index.html ├── Blog_links_model.php ├── Blog_categories_model.php ├── Blog_users_model.php ├── Blog_tags_model.php ├── Blog_comments_model.php └── Blog_posts_model.php ├── controllers ├── index.html ├── Dashboard.php ├── Feed.php ├── Archives.php ├── Authors.php ├── Search.php ├── Tags.php ├── Categories.php └── Blog.php ├── libraries ├── index.html ├── Blog_base_controller.php ├── Captcha.php ├── Akismet.php └── Stopforumspam.php ├── language └── english │ ├── index.html │ └── blog_lang.php ├── install ├── fuel_blog_uninstall.sql ├── install.php ├── fuel_blog_permissions_install.sql ├── upgrade │ ├── fuel_blog_1.1_schema_changes.sql │ └── fuel_blog_1.0_schema_changes.sql ├── fuel_blog_install.sql └── archive │ └── fuel_blog_v.9.3.sql └── README.md /views/themes/default/_blocks/comment_form.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /views/_docs/fuel_blog.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /fonts/VeraBd.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daylightstudio/FUEL-CMS-Blog-Module/HEAD/fonts/VeraBd.ttf -------------------------------------------------------------------------------- /fonts/arialbd.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daylightstudio/FUEL-CMS-Blog-Module/HEAD/fonts/arialbd.ttf -------------------------------------------------------------------------------- /fonts/verdanab.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daylightstudio/FUEL-CMS-Blog-Module/HEAD/fonts/verdanab.ttf -------------------------------------------------------------------------------- /views/themes/default/tag.php: -------------------------------------------------------------------------------- 1 |

name?> Posts

2 | 3 | fuel->blog->block('posts')?> -------------------------------------------------------------------------------- /views/themes/default/category.php: -------------------------------------------------------------------------------- 1 |

name?> Posts

2 | 3 | fuel->blog->block('posts')?> -------------------------------------------------------------------------------- /views/themes/default/index.php: -------------------------------------------------------------------------------- 1 | load->module_view(BLOG_FOLDER, $this->fuel->blog->theme_path().'posts'); ?> -------------------------------------------------------------------------------- /assets/images/ico_user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daylightstudio/FUEL-CMS-Blog-Module/HEAD/assets/images/ico_user.png -------------------------------------------------------------------------------- /views/themes/default/posts.php: -------------------------------------------------------------------------------- 1 |

fuel->blog->config('title')?>

2 | 3 | fuel->blog->block('posts')?> -------------------------------------------------------------------------------- /assets/images/ico_comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daylightstudio/FUEL-CMS-Blog-Module/HEAD/assets/images/ico_comment.png -------------------------------------------------------------------------------- /assets/images/ico_folder_page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daylightstudio/FUEL-CMS-Blog-Module/HEAD/assets/images/ico_folder_page.png -------------------------------------------------------------------------------- /assets/images/ico_table_gear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daylightstudio/FUEL-CMS-Blog-Module/HEAD/assets/images/ico_table_gear.png -------------------------------------------------------------------------------- /assets/images/ico_world_link.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daylightstudio/FUEL-CMS-Blog-Module/HEAD/assets/images/ico_world_link.png -------------------------------------------------------------------------------- /assets/images/ico_page_white_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/daylightstudio/FUEL-CMS-Blog-Module/HEAD/assets/images/ico_page_white_edit.png -------------------------------------------------------------------------------- /config/blog_constants.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /helpers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /models/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /views/themes/default/_blocks/about.php: -------------------------------------------------------------------------------- 1 |
2 |

3 |

fuel->blog->config('description')?>

4 |
-------------------------------------------------------------------------------- /views/themes/default/_blocks/sidemenu.php: -------------------------------------------------------------------------------- 1 | 2 |
3 | fuel->blog->block($block)?> 4 |
5 | -------------------------------------------------------------------------------- /assets/cache/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /controllers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /libraries/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /assets/captchas/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /language/english/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /views/themes/default/_blocks/author.php: -------------------------------------------------------------------------------- 1 |
2 |

3 | author->get_avatar_img_tag(array('class' => 'img_left'))?> 4 | author->about_formatted?> 5 |
-------------------------------------------------------------------------------- /views/themes/default/_blocks/comment_thanks.php: -------------------------------------------------------------------------------- 1 |

2 | fuel->blog->config('monitor_comments')){ ?> 3 |

4 | 5 | -------------------------------------------------------------------------------- /views/themes/default/_blocks/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /views/_admin/dashboard.php: -------------------------------------------------------------------------------- 1 |
2 |

Recent Blog Posts

3 | 8 |
-------------------------------------------------------------------------------- /install/fuel_blog_uninstall.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `fuel_blog_users`; 2 | DROP TABLE IF EXISTS `fuel_blog_posts`; 3 | DROP TABLE IF EXISTS `fuel_blog_links`; 4 | DROP TABLE IF EXISTS `fuel_blog_comments`; 5 | DROP TABLE IF EXISTS `fuel_blog_categories`; 6 | DELETE FROM `fuel_permissions` WHERE `name` LIKE 'blog/%'; -------------------------------------------------------------------------------- /views/themes/default/_blocks/post_unpublished.php: -------------------------------------------------------------------------------- 1 | is_published()) : ?> 2 |
3 |
4 | This post is currently not published and is only viewable to you because you are currently logged into FUEL. 5 |
6 |
7 | -------------------------------------------------------------------------------- /views/themes/default/authors.php: -------------------------------------------------------------------------------- 1 |

Authors

2 | 3 | 4 |
5 | avatar_image)) : ?> 6 | get_avatar_img_tag(array('class' => 'img_left', 'alt' => $author->name))?> 7 | 8 | url, $author->name)?> 9 |
10 | 11 | -------------------------------------------------------------------------------- /views/themes/default/_blocks/links.php: -------------------------------------------------------------------------------- 1 | fuel_blog->get_links()?> 2 | 3 |
4 |

5 | 13 |
14 | -------------------------------------------------------------------------------- /controllers/Dashboard.php: -------------------------------------------------------------------------------- 1 | config->module_load('blog', 'blog'); 9 | $this->view_location = 'blog'; 10 | } 11 | 12 | function index() 13 | { 14 | $vars['posts'] = $this->fuel->blog->get_recent_posts(); 15 | $this->load->view('_admin/dashboard', $vars); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /views/themes/default/tags.php: -------------------------------------------------------------------------------- 1 |

Tags

2 | posts; 4 | if (!empty($posts)) : 5 | ?> 6 |

id, 'Edit Category', 'blog/tags')?>url, $tag->name)?>

7 | 12 | 13 | -------------------------------------------------------------------------------- /views/themes/default/_blocks/tags.php: -------------------------------------------------------------------------------- 1 | fuel->blog->get_published_tags(); ?> 2 | 3 |
4 |

5 | 17 |
18 | -------------------------------------------------------------------------------- /assets/css/blog.css: -------------------------------------------------------------------------------- 1 | .ico_blog { background-image: url(../images/ico_page_white_edit.png); } 2 | .ico_blog_posts { background-image: url(../images/ico_page_white_edit.png); } 3 | .ico_blog_categories { background-image: url(../images/ico_folder_page.png); } 4 | .ico_blog_comments { background-image: url(../images/ico_comment.png); } 5 | .ico_blog_links { background-image: url(../images/ico_world_link.png); } 6 | .ico_blog_users { background-image: url(../images/ico_user.png); } 7 | .ico_blog_settings { background-image: url(../images/ico_table_gear.png); } -------------------------------------------------------------------------------- /views/themes/default/_blocks/authors.php: -------------------------------------------------------------------------------- 1 | fuel->blog->get_users()?> 2 | 3 |
4 |

Authors

5 | 14 |
15 | -------------------------------------------------------------------------------- /views/themes/default/_blocks/search.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /views/themes/default/categories.php: -------------------------------------------------------------------------------- 1 |

Categories

2 | posts; 4 | if (!empty($posts)) : 5 | ?> 6 |

id, 'Edit Category', 'blog/categories')?>url, $category->name)?>

7 | 12 | 13 | -------------------------------------------------------------------------------- /views/themes/default/_blocks/archives.php: -------------------------------------------------------------------------------- 1 | fuel->blog->get_post_archives(); ?> 2 | 3 |
4 |

5 | 14 |
15 | 16 | -------------------------------------------------------------------------------- /views/themes/default/_blocks/categories.php: -------------------------------------------------------------------------------- 1 | fuel->blog->get_published_categories(); ?> 2 | 3 |
4 |

5 | 17 |
18 | -------------------------------------------------------------------------------- /views/themes/default/archives.php: -------------------------------------------------------------------------------- 1 |

2 | 3 | $archives) : 4 | $month_str = date('F Y', strtotime(str_replace('/', '-', $month).'-01')); 5 | ?> 6 | 7 |

8 | 16 | 17 | 18 |

There is currently nothing in the archives.

19 | -------------------------------------------------------------------------------- /views/_docs/blog_helper.php: -------------------------------------------------------------------------------- 1 |

Blog Helper

2 | 3 |

Contains blog related functions to use in your blog's theme pages.

4 | 5 |

This helper is loaded using the following code:

6 | 7 |
 8 | $this->load->module_helper(BLOG_FOLDER, 'blog');
 9 | 
10 | 11 |

The following function is available:

12 | 13 | 14 |

blog_url(uri)

15 |

Returns a blog specific URI. Convience function that maps to Fuel_blog->url() method.

16 | 17 | 18 |

blog_block(view, [vars], [return])

19 |

Returns an HTML block from the specified theme's _block.

-------------------------------------------------------------------------------- /views/_admin/settings.php: -------------------------------------------------------------------------------- 1 |
2 | 3 |
The blog is currently using a configuration file to control the settings. 4 | You may save settings but they will not effect the site until the configuration file reliquishes control by changing the 5 | blog_use_db_table_settings configuration parameter to TRUE.
6 | 7 |
8 | 9 |
10 | 11 | 12 |

13 | Configure the blog settings below: 14 |

15 | 16 |
17 | 18 |
19 |
20 | -------------------------------------------------------------------------------- /config/blog_routes.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |

4 | 5 | 6 | 7 |

title, $q, '', '')?>

8 | get_excerpt_formatted(50, '', TRUE)), $q, '', '')?> 9 | 10 | 11 | 12 |

There were no search results returned.

13 | 14 | 15 | 16 | 17 |

Search

18 |

Input your search below:

19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /controllers/Feed.php: -------------------------------------------------------------------------------- 1 | fuel->blog->uri_segment(3) == 'atom') 14 | { 15 | $this->atom(); 16 | } 17 | else 18 | { 19 | $this->rss(); 20 | } 21 | } 22 | 23 | function atom() 24 | { 25 | // set the header type 26 | $this->fuel->blog->feed_header(); 27 | print($this->fuel->blog->feed_output('atom')); 28 | } 29 | 30 | function rss() 31 | { 32 | // set the header type 33 | $this->fuel->blog->feed_header(); 34 | print($this->fuel->blog->feed_output('rss')); 35 | } 36 | 37 | } -------------------------------------------------------------------------------- /views/themes/default/author.php: -------------------------------------------------------------------------------- 1 | id, 'Edit Author: '.$author->name, 'blog/users')?> 2 |

name?>

3 | avatar_image)) : ?> 4 | get_avatar_img_tag(array('class' => 'img_right', 'alt' => $author->name))?> 5 | 6 | about_formatted?> 7 | 8 | 17 | 18 | posts; ?> 19 | 20 |

Posts By name?>

21 | 26 | 27 | -------------------------------------------------------------------------------- /install/install.php: -------------------------------------------------------------------------------- 1 | 'Blog Settings'); 13 | $config['migration_version'] = 0; 14 | $config['install_sql'] = 'fuel_blog_install.sql'; 15 | $config['uninstall_sql'] = 'fuel_blog_uninstall.sql'; 16 | $config['repo'] = 'git://github.com/daylightstudio/FUEL-CMS-Blog-Module.git'; -------------------------------------------------------------------------------- /views/themes/default/_layouts/blog.php: -------------------------------------------------------------------------------- 1 | fuel->blog->current_post(); 4 | if (isset($current_post) AND !$is_home) 5 | { 6 | fuel_set_var('canonical', $post->url); 7 | if ($post->has_page_title()) fuel_set_var('page_title', $post->page_title); 8 | if ($post->has_meta_description()) fuel_set_var('meta_description', $post->meta_description); 9 | if ($post->has_meta_keywords()) fuel_set_var('meta_keywords', $post->meta_keywords); 10 | } 11 | ?> 12 | load->module_view('app', '_blocks/header')?> 13 | 14 | 17 | 18 |
19 | 20 |
21 | 22 |
23 | 24 | load->module_view('app', '_blocks/footer')?> 25 | -------------------------------------------------------------------------------- /views/themes/default/_blocks/comment.php: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | is_by_post_author()) :?> 5 | post->author->get_avatar_img_tag(array('class' => 'img_left'))?> 6 | 7 | content_formatted?> 8 |
9 | 10 |
11 | author_and_link?>, get_date_formatted('h:iA / M d, Y')?> 12 |
13 | 14 | For displaying the reply form 15 |
16 | depth <= 3 AND $post->allow_comments AND $post->is_within_comment_time_limit()) : ?> 17 |
Reply
18 | 19 | 20 |
-------------------------------------------------------------------------------- /config/blog_hooks.php: -------------------------------------------------------------------------------- 1 | 'Blog_hooks', 14 | 'function' => 'before_posts_by_date', 15 | 'filename' => 'Blog_hooks.php', 16 | 'filepath' => 'hooks', 17 | 'params' => array(), 18 | 'module' => 'app', 19 | */ 20 | 21 | 22 | $hook['blog_before_posts_by_date'][] = array(); 23 | $hook['blog_before_posts_by_page'][] = array(); 24 | $hook['blog_before_post'][] = array(); 25 | $hook['blog_before_posts_by_category'][] = array(); 26 | $hook['blog_before_posts_by_author'][] = array(); 27 | 28 | 29 | /* End of file fuel_hooks.php */ 30 | /* Location: ./modules/fuel/config/fuel_hooks.php */ -------------------------------------------------------------------------------- /controllers/Archives.php: -------------------------------------------------------------------------------- 1 | fuel->blog->uri_segment(3); 15 | 16 | $cache_id = fuel_cache_id(); 17 | $vars = $this->_common_vars(); 18 | if ($cache = $this->fuel->blog->get_cache($cache_id)) 19 | { 20 | $output =& $cache; 21 | } 22 | else 23 | { 24 | $where = array(); 25 | if (!empty($slug) AND $slug != 'index') 26 | { 27 | $tables = $this->config->item('tables'); 28 | $where[$tables['blog_categories'].'.slug'] = $category; 29 | } 30 | $vars['archives_by_month'] = $this->fuel->blog->get_post_archives($where); 31 | $vars['page_title'] = lang('blog_archives_page_title'); 32 | $output = $this->_render('archives', $vars, TRUE); 33 | $this->fuel->blog->save_cache($cache_id, $output); 34 | } 35 | 36 | $this->output->set_output($output); 37 | } 38 | } -------------------------------------------------------------------------------- /views/themes/default/_blocks/posts.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | 5 |
6 | 7 | 8 | $post))?> 9 | 10 |

title?>

11 | 12 | 16 | 17 |
18 | excerpt_formatted?> 19 |
20 | 23 |
24 |
25 | 26 | 27 |
28 | 29 | Looking for older posts? View our Archives 30 |
31 | 32 | 33 |
34 |

There are no posts available.

35 |
36 | 37 |
-------------------------------------------------------------------------------- /views/_docs/links.php: -------------------------------------------------------------------------------- 1 |

Links

2 |

The Blog Links module stores link information to be displayed on your blog. 3 | Links are powered by a blog_links_model and have a grandparent class of MY_Model. 4 |

5 | 6 |

Link Fields

7 |

Below are the fields to fill out for a link:

8 | 16 | 17 |

The Link Model Properties

18 |

The link object has the following properties:

19 | 28 | 29 |

The Link Model Methods

30 |

The link object model has the following method:

31 | 32 |

get_link()

33 |

Returns the link.

34 | -------------------------------------------------------------------------------- /views/_docs/categories.php: -------------------------------------------------------------------------------- 1 |

Categories

2 |

Categories allow you to group your posts together. A post can belong to more then one category. 3 | To create a category, you can either add it directly within the post, or you can create them under 4 | the categories menu item. Categories are powered by a blog_categories_model and have a grandparent class of MY_Model. 5 |

6 | 7 |

Category Fields

8 |

Below are the fields to fill out for a category:

9 | 14 | 15 |
16 |

The Category Model Properties

17 |

The category object has the following properties:

18 | 24 | 25 |
26 |

The Category Model Methods

27 |

The category object model has the following methods:

28 | 29 |

get_posts()

30 |

Returns an array of posts associated with a category.

31 | 32 | 33 |

get_posts_count()

34 |

Returns the number of posts associated with the category.

35 | 36 | 37 |

get_url()

38 |

Returns a url to that category.

39 | 40 | -------------------------------------------------------------------------------- /views/feed/rss_posts.php: -------------------------------------------------------------------------------- 1 | '); ?> 2 | 8 | 9 | <?php echo $title; ?> 10 | 11 | ]]> 12 | 13 | fuel->blog->language(TRUE)?> 14 | 15 | http://blogs.law.harvard.edu/tech/rss 16 | 17 | Copyright 18 | 19 | 20 | 21 | 22 | <?php echo xml_convert($post->title); ?> 23 | url; ?> 24 | url; ?> 25 | rss_date; ?> 26 | excerpt_formatted); ?> 28 | ]]> 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /install/fuel_blog_permissions_install.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO `fuel_permissions` (`id`, `description`, `name`, `active`) 2 | VALUES 3 | (NULL, 'Blog Categories', 'blog_categories', 'yes'), 4 | (NULL, 'Blog Categories: Create', 'blog_categories/create', 'yes'), 5 | (NULL, 'Blog Categories: Delete', 'blog_categories/delete', 'yes'), 6 | (NULL, 'Blog Categories: Edit', 'blog_categories/edit', 'yes'), 7 | (NULL, 'Blog Categories: Publish', 'blog_categories/publish', 'yes'), 8 | (NULL, 'Blog Comments', 'blog_comments', 'yes'), 9 | (NULL, 'Blog Comments: Create', 'blog_comments/create', 'yes'), 10 | (NULL, 'Blog Comments: Delete', 'blog_comments/delete', 'yes'), 11 | (NULL, 'Blog Comments: Edit', 'blog_comments/edit', 'yes'), 12 | (NULL, 'Blog Comments: Publish', 'blog_comments/publish', 'yes'), 13 | (NULL, 'Blog Links', 'blog_links', 'yes'), 14 | (NULL, 'Blog Links: Create', 'blog_links/create', 'yes'), 15 | (NULL, 'Blog Links: Delete', 'blog_links/delete', 'yes'), 16 | (NULL, 'Blog Links: Edit', 'blog_links/edit', 'yes'), 17 | (NULL, 'Blog Links: Publish', 'blog_links/publish', 'yes'), 18 | (NULL, 'Blog Posts', 'blog_posts', 'yes'), 19 | (NULL, 'Blog Posts: Create', 'blog_posts/create', 'yes'), 20 | (NULL, 'Blog Posts: Delete', 'blog_posts/delete', 'yes'), 21 | (NULL, 'Blog Posts: Edit', 'blog_posts/edit', 'yes'), 22 | (NULL, 'Blog Posts: Publish', 'blog_posts/publish', 'yes'), 23 | (NULL, 'Blog Users', 'blog_users', 'yes'), 24 | (NULL, 'Blog Users: Create', 'blog_users/create', 'yes'), 25 | (NULL, 'Blog Users: Delete', 'blog_users/delete', 'yes'), 26 | (NULL, 'Blog Users: Edit', 'blog_users/edit', 'yes'), 27 | (NULL, 'Blog Users: Publish', 'blog_users/publish', 'yes'), 28 | (NULL, 'Blog Settings', 'blog/settings', 'yes'); 29 | -------------------------------------------------------------------------------- /views/feed/atom_posts.php: -------------------------------------------------------------------------------- 1 | '); ?> 2 | 3 | <?php echo $title; ?> 4 | 5 | 6 | 7 | 8 | fuel->blog->feed('atom')?> 9 | 10 | 11 | 12 | 13 | 14 | 15 | <?php echo $post->title; ?> 16 | 17 | tag:fuel->blog->domain() ?>,publish_date)); ?>:article/permalink; ?> 18 | 19 | publish_date)); ?> 20 | excerpt, 100, '...')), ENT_COMPAT, 'UTF-8'); ?>]]> 21 | 22 | author_name; ?> 23 | 24 | 25 | excerpt_formatted); ?>]]> 26 | 27 | last_modified)); ?> 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /views/_docs/authors.php: -------------------------------------------------------------------------------- 1 |

Authors

2 |

Blog Authors (Users) must have general access to the FUEL admin and permissions for the blog module. 3 | Blog Authors are powered by a blog_users_model and have a grandparent class of MY_Model class 4 |

5 | 6 |

Author Fields

7 |

Below are the fields to fill out for an author:

8 | 15 | 16 |
17 | 18 |

The Authors (User) Model Properties

19 |

The author object has the following properties:

20 | 35 | 36 |
37 | 38 |

The Authors (User) Model Methods

39 |

The author object model has the following specific methods:

40 | 41 |

get_url()

42 |

Returns the link.

43 | 44 |

get_posts_url('[full_path]')

45 |

Returns posts the link.

46 | 47 |

get_avatar_image_path()

48 |

Returns image path to the avatar.

49 | 50 |

get_avatar_img_tag()

51 |

Returns image tag to the avatar.

-------------------------------------------------------------------------------- /controllers/Authors.php: -------------------------------------------------------------------------------- 1 | fuel->blog->get_cache($cache_id)) 15 | { 16 | $output =& $cache; 17 | } 18 | else 19 | { 20 | $vars = $this->_common_vars(); 21 | 22 | // get the category this way in case there is a language parameter 23 | $id = $this->fuel->blog->uri_segment(3); 24 | 25 | if ($id == 'posts') 26 | { 27 | $author_id = (int) $this->fuel->blog->uri_segment(3); 28 | 29 | $author = $this->fuel->blog->get_user($author_id); 30 | if (empty($author)) redirect_404(); 31 | $where['author_id'] = $author_id; 32 | 33 | // run before_posts_by_date hook 34 | $hook_params = array('author' => $author); 35 | $this->fuel->blog->run_hook('before_posts_by_author', $hook_params); 36 | 37 | $vars['posts'] = $this->fuel->blog->get_posts($where); 38 | $vars['page_title'] = lang('blog_author_posts_page_title', $author->name); 39 | $output = $this->_render('posts', $vars, TRUE); 40 | } 41 | else if (!empty($id) && $id != 'index') 42 | { 43 | $author = $this->fuel->blog->get_user($id); 44 | if (empty($author)) redirect_404(); 45 | $vars['author'] = $author; 46 | $vars['page_title'] = $author->name; 47 | $output = $this->_render('author', $vars, TRUE); 48 | } 49 | else 50 | { 51 | $vars['authors'] = $this->fuel->blog->get_users(); 52 | $vars['page_title'] = lang('blog_authors_list_page_title'); 53 | $output = $this->_render('authors', $vars, TRUE); 54 | } 55 | $this->fuel->blog->save_cache($cache_id, $output); 56 | } 57 | $this->output->set_output($output); 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /helpers/blog_helper.php: -------------------------------------------------------------------------------- 1 | url() 34 | * 35 | * @access public 36 | * @param string 37 | * @return string 38 | */ 39 | function blog_url($uri = '') 40 | { 41 | $CI =& get_instance(); 42 | return $CI->fuel->blog->url($uri); 43 | } 44 | 45 | // -------------------------------------------------------------------- 46 | 47 | /** 48 | * Returns an HTML block from the specified theme's _block 49 | * 50 | * @access public 51 | * @param string 52 | * @param array 53 | * @param boolean 54 | * @return string 55 | */ 56 | function blog_block($view, $vars = array(), $return = TRUE) 57 | { 58 | $CI =& get_instance(); 59 | $view_folder = $CI->fuel->blog->theme_path(); 60 | $block = $CI->load->module_view(BLOG_FOLDER, $view_folder.'_blocks/'.$view, $vars, TRUE); 61 | if ($return) 62 | { 63 | return $block; 64 | } 65 | echo $block; 66 | } 67 | 68 | /* End of file blog_helper.php */ 69 | /* Location: ./modules/blog/helpers/blog_helper.php */ -------------------------------------------------------------------------------- /views/themes/default/post.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 | $post))?> 5 | 6 |

title?>

7 |
8 | 9 | 10 | 11 | 12 |
13 | 14 |
15 | content_formatted?> 16 |
17 | 18 |
19 | 20 | 21 | comments_count > 0) : ?> 22 |

23 |
24 | 25 | comments_formatted?> 26 | 27 | 28 | 29 | comments as $comment) : ?> 30 | 31 |
32 | 33 |
34 | content_formatted?> 35 |
36 | 37 |
38 | author_and_link?>, get_date_formatted('h:iA / M d, Y')?> 39 |
40 |
41 | 42 | 43 | 44 | 45 |
46 | 47 | 48 | allow_comments) : ?> 49 |
50 | 51 | is_within_comment_time_limit()) : ?> 52 | 53 |

54 | 55 | 56 | 58 | 59 | 60 |

61 | 62 |
63 | 64 | 65 |

66 | 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BLOG MODULE FOR FUEL CMS 2 | This is a [FUEL CMS](http://www.getfuelcms.com) blog module for adding blog like functionality including posts, categories, and commenting. 3 | 4 | ## INSTALLATION 5 | There are a couple ways to install the module. If you are using GIT you can use the following method 6 | to create a submodule: 7 | 8 | ### USING GIT 9 | 1. Open up a Terminal window, "cd" to your FUEL CMS installation then type in: 10 | Type in: 11 | ``php index.php fuel/installer/add_git_submodule https://github.com/daylightstudio/FUEL-CMS-Blog-Module.git blog`` 12 | 13 | 2. Then to install, type in: 14 | ``php index.php fuel/installer/install blog`` 15 | 16 | 17 | ### MANUAL 18 | 1. Download the zip file from GitHub: 19 | [https://github.com/daylightstudio/FUEL-CMS-Blog-Module](https://github.com/daylightstudio/FUEL-CMS-Blog-Module) 20 | 21 | 2. Create a "blog" folder in fuel/modules/ and place the contents of the blog module folder in there. 22 | 23 | 3. Import the fuel_blog_install.sql and fuel_blog_permissions_install.sql from the blog/install folder into your database 24 | 25 | 4. Add "blog" to the `$config['modules_allowed']` in fuel/application/config/MY_fuel.php 26 | 27 | ## UNINSTALL 28 | 29 | To uninstall the module which will remove any permissions and database information: 30 | ``php index.php fuel/installer/uninstall blog`` 31 | 32 | ### TROUBLESHOOTING 33 | 1. You may need to put in your full path to the "php" interpreter when using the terminal. 34 | 2. You must have access to an internet connection to install using GIT. 35 | 36 | 37 | ## DOCUMENTATION 38 | To access the documentation, you can visit it [here](http://docs.getfuelcms.com/modules/blog). 39 | 40 | ## TEAM 41 | * David McReynolds, Daylight Studio, Main Developer 42 | 43 | ## BUGS 44 | To file a bug report, go to the [issues](https://github.com/daylightstudio/FUEL-CMS-Blog-Module/issues) page. 45 | 46 | ## LICENSE 47 | The blog Module for FUEL CMS is licensed under [APACHE 2](http://www.apache.org/licenses/LICENSE-2.0). -------------------------------------------------------------------------------- /assets/js/comment_reply.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | 3 | // status message 4 | var changeStatus = function(msg, $context){ 5 | if (!msg || !msg.length){ 6 | $context.parent().find('.status').hide(); 7 | } else { 8 | $context.parent().find('.status').html(msg); 9 | } 10 | } 11 | 12 | // setup handler for reply to comments 13 | $('.comment_reply_form').on('click', 'form .submit', function(){ 14 | 15 | var $formHolder = $(this).closest('.comment_reply_form'); 16 | 17 | $form = $(this).closest('form'); 18 | 19 | changeStatus('Submitting comment...', $formHolder); 20 | var url = $form.attr('action'); 21 | var formData = $form.serializeArray(); 22 | 23 | $.post(url, formData).done(function(html) { 24 | $formHolder.html(html); 25 | $formHolder.find('form').remove(); 26 | 27 | }).fail(function(data) { 28 | changeStatus('', $formHolder); 29 | $formHolder.prepend(data.responseText); 30 | return false; 31 | }); 32 | 33 | return false; 34 | }); 35 | 36 | // reply link toggle 37 | $('.comments').on('click', '.comment_reply', function(e){ 38 | e.preventDefault(); 39 | 40 | var $this = $(this); 41 | var $formHolder = $this.closest('.comment').find('.comment_reply_form'); 42 | 43 | if ($formHolder.data('visible')){ 44 | 45 | $formHolder.slideUp('fast'); 46 | $(this).html('Reply') 47 | .removeClass('reply-close') 48 | .addClass('reply-open'); 49 | $formHolder.data('visible', false) 50 | 51 | } else { 52 | var url = $(this).attr('href'); 53 | var insertElem = $this.next(); 54 | 55 | $formHolder.hide(); 56 | $formHolder.parent().append('
'); 57 | changeStatus('Loading form...', $formHolder); 58 | 59 | $.get(url, function(html){ 60 | 61 | changeStatus('', $formHolder); 62 | 63 | $formHolder.html(html).show().slideUp(0).slideDown('fast'); 64 | $this.html('Close') 65 | .addClass('reply-close') 66 | .removeClass('reply-open'); 67 | $formHolder.data('visible', true) 68 | } 69 | ); 70 | 71 | } 72 | }); 73 | 74 | 75 | }) -------------------------------------------------------------------------------- /install/upgrade/fuel_blog_1.1_schema_changes.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `fuel_blog_posts` CHANGE `language` `language` VARCHAR(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'english'; 2 | ALTER TABLE `fuel_blog_links` ADD `language` VARCHAR(30) NOT NULL DEFAULT 'english' AFTER `precedence`; 3 | ALTER TABLE `fuel_blog_categories` ADD `language` VARCHAR(30) NOT NULL DEFAULT 'english' AFTER `precedence`; 4 | ALTER TABLE `fuel_blog_posts` ADD `page_title` VARCHAR(255) NOT NULL DEFAULT '' AFTER `post_date`; 5 | ALTER TABLE `fuel_blog_posts` ADD `meta_description` VARCHAR(255) NOT NULL DEFAULT '' AFTER `page_title`; 6 | ALTER TABLE `fuel_blog_posts` ADD `meta_keywords` VARCHAR(255) NOT NULL DEFAULT '' AFTER `meta_description`; 7 | ALTER TABLE `fuel_blog_posts` ADD `canonical` VARCHAR(255) NOT NULL DEFAULT '' AFTER `meta_keywords`; 8 | ALTER TABLE `fuel_blog_posts` ADD `og_title` VARCHAR(255) NOT NULL DEFAULT '' AFTER `canonical`; 9 | ALTER TABLE `fuel_blog_posts` ADD `og_description` VARCHAR(255) NOT NULL DEFAULT '' AFTER `og_title`; 10 | ALTER TABLE `fuel_blog_posts` ADD `og_image` VARCHAR(255) NOT NULL DEFAULT '' AFTER `og_description`; 11 | ALTER TABLE `fuel_blog_posts` ADD `category_id` INT(10) UNSIGNED NOT NULL AFTER `og_image`; 12 | 13 | ALTER TABLE `fuel_blog_users` CHANGE `twitter` `social_media_links` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; 14 | ALTER TABLE `fuel_blog_posts` CHANGE `post_date` `publish_date` DATETIME NOT NULL; 15 | 16 | ALTER TABLE `fuel_blog_categories` DROP INDEX `permalink`; 17 | ALTER TABLE `fuel_blog_categories` DROP INDEX `name`; 18 | ALTER TABLE `fuel_blog_categories` ADD UNIQUE INDEX (`name`, `language`); 19 | ALTER TABLE `fuel_blog_categories` ADD UNIQUE INDEX (`slug`, `language`); 20 | 21 | ALTER TABLE `fuel_blog_users` ADD `about_excerpt` TEXT NOT NULL AFTER `about`; 22 | 23 | 24 | # Uncomment these if you don't want those fields in the Admin anymore since they've been rolled into the social_media_links field 25 | #ALTER TABLE `fuel_blog_users` DROP `facebook`; 26 | #ALTER TABLE `fuel_blog_users` DROP `linkedin`; 27 | #ALTER TABLE `fuel_blog_users` DROP `google`; 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /controllers/Search.php: -------------------------------------------------------------------------------- 1 | load->library('pagination'); 14 | $this->load->helper('text'); 15 | 16 | $q = $this->fuel->blog->uri_segment(3); 17 | $use_get = FALSE; 18 | 19 | if (empty($q)) 20 | { 21 | $q = $this->input->post('q', TRUE); 22 | } 23 | 24 | if (empty($q)) 25 | { 26 | $use_get = TRUE; 27 | $q = $this->input->get('q', TRUE); 28 | } 29 | 30 | // initiate this here first 31 | $vars = $this->_common_vars(); 32 | $vars['posts'] = array(); 33 | $vars['page_title'] = lang('blog_search_page_title', '“'.$q.'”'); 34 | if (!empty($q)) 35 | { 36 | $limit = $this->fuel->blog->config('per_page'); 37 | if ($use_get) 38 | { 39 | //$this->config->set_item('enable_query_strings', TRUE); 40 | $config['base_url'] = $this->fuel->blog->url('search?q='.$q); 41 | } 42 | else 43 | { 44 | $config['base_url'] = $this->fuel->blog->url('search'); 45 | } 46 | $config['total_rows'] = count($this->fuel->blog->search_posts($q)); 47 | $config['uri_segment'] = 3; 48 | $config['page_query_string'] = $use_get; 49 | $config['per_page'] = $limit; 50 | $config['prev_link'] = lang('blog_prev_page'); 51 | $config['next_link'] = lang('blog_next_page'); 52 | $config['first_link'] = lang('blog_first_link'); 53 | $config['last_link'] = lang('blog_last_link');; 54 | 55 | $this->pagination->initialize($config); 56 | 57 | $offset = ($use_get) ? $this->input->get('per_page') : $this->uri->segment($config['uri_segment']); 58 | 59 | $vars['posts'] = $this->fuel->blog->search_posts($q, 'date_added desc', $limit, $offset); 60 | $vars['limit'] = $limit; 61 | $vars['offset'] = $offset; 62 | $vars['pagination'] = $this->pagination->create_links(); 63 | } 64 | $vars['q'] = $q; 65 | $vars['searched'] = (!empty($q)); 66 | $vars['search_input'] = $this->fuel->blog->block('search'); 67 | $this->_render('search', $vars); 68 | } 69 | } -------------------------------------------------------------------------------- /views/_docs/index.php: -------------------------------------------------------------------------------- 1 |

Blog Documentation

2 |

This Blog documentation is for version .

3 | 4 |

Overview

5 |

The FUEL Blog is a module that allows you to have blog functionality without the need 6 | of installing a 3rd party application like Wordpress. It allows you to create posts, categorize and search them as well as allow others to comment on them. 7 | There are various setting options to taylor the blog to your liking. Read below for more information. 8 |

9 | 10 |

Basic Configuration

11 |

The following are the steps to configuring the FUEL Blog module:

12 |
    13 |
  1. Change the Blog settings to have a proper Blog title and configure your comment security options
  2. 14 |
  3. Create a new theme for your blog (see Creating Themes)
  4. 15 |
  5. The blog can be found at /blog of your website (you can use routes to change that though)
  6. 16 |
  7. Create your authors (they must first have general access to the FUEL admin)
  8. 17 |
18 | 19 |

Sub-Modules

20 | 28 | 29 |

Libraries and Helpers

30 | 34 | 35 |

Misc.

36 | 40 | -------------------------------------------------------------------------------- /models/Blog_links_model.php: -------------------------------------------------------------------------------- 1 | fuel->language->has_multiple()) 19 | { 20 | $this->db->select('id, name, url, language, published'); 21 | } 22 | else 23 | { 24 | $this->db->select('id, name, url, published'); 25 | } 26 | $data = parent::list_items($limit, $offset, $col, $order, $just_count); 27 | return $data; 28 | } 29 | 30 | function form_fields($values = array(), $related = array()) 31 | { 32 | $fields = parent::form_fields($values, $related); 33 | 34 | // set language field 35 | $fields['language'] = array('type' => 'select', 'options' => $this->fuel->language->options(), 'value' => $this->fuel->language->default_option(), 'hide_if_one' => TRUE); 36 | 37 | $fields['url']['label'] = 'URL'; 38 | return $fields; 39 | } 40 | 41 | function _common_query($display_unpublished_if_logged_in = NULL) 42 | { 43 | parent::_common_query($display_unpublished_if_logged_in); 44 | 45 | if (!defined('FUEL_ADMIN') AND $this->fuel->language->has_multiple()) 46 | { 47 | $language = $this->fuel->language->detect(); 48 | $this->db->where($this->_tables['blog_links'].'.language', $language); 49 | } 50 | } 51 | 52 | } 53 | 54 | class Blog_link_model extends Base_module_record { 55 | 56 | function get_link() 57 | { 58 | $url = $this->url; 59 | if (preg_match('#^www\..+#', $url) OR (preg_match('#(\.com|\.net)/?$#', $url) AND !is_http_path($url))) 60 | { 61 | $url = prep_url($url); 62 | } 63 | else 64 | { 65 | $url = site_url($url); 66 | } 67 | $label = (!empty($this->name)) ? $this->name : $this->url; 68 | $attrs = (!empty($this->target)) ? 'target="_'.$this->target.'"' : ''; 69 | return anchor($url, $label, $attrs); 70 | } 71 | } 72 | ?> -------------------------------------------------------------------------------- /install/upgrade/fuel_blog_1.0_schema_changes.sql: -------------------------------------------------------------------------------- 1 | ALTER TABLE `fuel_blog_posts` ADD `main_image` VARCHAR(100) NOT NULL DEFAULT '' AFTER `author_id`; 2 | ALTER TABLE `fuel_blog_posts` ADD `thumbnail_image` VARCHAR(100) NOT NULL DEFAULT '' AFTER `main_image`; 3 | ALTER TABLE `fuel_blog_categories` ADD `precedence` INT(11) UNSIGNED DEFAULT 0 AFTER `permalink`; 4 | UPDATE `fuel_blog_settings` SET `value` = '0' WHERE `name` = 'use_captchas'; 5 | ALTER TABLE `fuel_blog_categories` CHANGE `permalink` `slug` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'If left blank, the slug will automatically be created for you.'; 6 | ALTER TABLE `fuel_blog_posts` CHANGE `permalink` `slug` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'This is the last part of the url string. If left blank, the slug will automatically be created for you.'; 7 | ALTER TABLE `fuel_blog_posts` ADD `list_image` VARCHAR(100) NOT NULL DEFAULT '' AFTER `main_image`; 8 | ALTER TABLE `fuel_blog_posts` ADD `post_date` DATETIME NOT NULL AFTER `allow_comments`; 9 | INSERT INTO `fuel_blog_settings` (`name`, `value`) VALUES ('page_title_separator', '«'); 10 | ALTER TABLE `fuel_blog_comments` CHANGE `author_ip` `author_ip` VARCHAR(50) NOT NULL DEFAULT ''; 11 | ALTER TABLE `fuel_blog_users` ADD `linkedin` VARCHAR(255) NOT NULL DEFAULT '' AFTER `facebook`; 12 | ALTER TABLE `fuel_blog_users` ADD `google` VARCHAR(255) NOT NULL DEFAULT '' AFTER `linkedin`; 13 | 14 | ALTER TABLE `fuel_blog_users` CHANGE `fuel_user_id` `fuel_user_id` INT(10) UNSIGNED NOT NULL; 15 | ALTER TABLE `fuel_blog_users` DROP PRIMARY KEY; 16 | ALTER TABLE `fuel_blog_users` ADD `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; 17 | UPDATE `fuel_blog_users` SET `id` = `fuel_user_id`; 18 | 19 | 20 | 21 | # Migrate Fuel Blog Categories to Fuel Relationships 22 | 23 | INSERT INTO `fuel_relationships` (`candidate_table`, `candidate_key`, `foreign_table`, `foreign_key`) 24 | (SELECT 'fuel_blog_posts', `post_id`, 'fuel_blog_categories', `category_id` FROM `fuel_blog_posts_to_categories`); 25 | 26 | DROP TABLE `fuel_blog_posts_to_categories`; 27 | 28 | 29 | # Migrate Fuel Blog Settings to Fuel Settings 30 | 31 | INSERT INTO `fuel_settings` (`module`, `key`, `value`) 32 | (SELECT 'blog', `name`, `value` FROM `fuel_blog_settings`); 33 | 34 | DROP TABLE `fuel_blog_settings`; 35 | -------------------------------------------------------------------------------- /views/_docs/settings.php: -------------------------------------------------------------------------------- 1 |

Settings

2 |

The blog.php config file determines whether your blog settings are controlled by the admin interface or through the configuration settings.

3 | 4 |

Setting Options

5 |

Below are the fields you can control in the CMS:

6 | 28 | -------------------------------------------------------------------------------- /libraries/Blog_base_controller.php: -------------------------------------------------------------------------------- 1 | fuel->auth->accessible_module('blog')) 8 | { 9 | show_404(); 10 | } 11 | $this->load->module_helper(BLOG_FOLDER, 'blog'); 12 | } 13 | 14 | function _common_vars() 15 | { 16 | $vars['blog'] =& $this->fuel->blog; 17 | $vars['is_blog'] = TRUE; 18 | $vars['page_title'] = ''; 19 | $vars['is_home'] = $this->fuel->blog->is_home(); 20 | //$this->load->vars($vars); 21 | return $vars; 22 | } 23 | 24 | function _render($view, $vars = array(), $return = FALSE, $layout = '') 25 | { 26 | if (empty($layout)) $layout = $this->fuel->blog->layout(); 27 | 28 | // get any global variables for the headers and footers 29 | $uri_path = trim($this->fuel->blog->config('uri'), '/'); 30 | $_vars = $this->fuel->pagevars->retrieve($uri_path); 31 | 32 | if (is_array($_vars)) 33 | { 34 | $vars = array_merge($_vars, $vars); 35 | } 36 | 37 | $view_folder = $this->fuel->blog->theme_path(); 38 | $view_layout = $this->fuel->blog->layout(); 39 | 40 | $vars['CI'] =& get_instance(); 41 | 42 | $page = $this->fuel->pages->create(); 43 | 44 | $theme_module = $this->fuel->blog->config('theme_module'); 45 | $layout_theme_module = $theme_module; 46 | 47 | $in_app_folder = ($theme_module == 'app' OR $theme_module == 'application'); 48 | $view_path = ($in_app_folder) ? 49 | APPPATH.'views/'.$view_folder.$view.'.php' 50 | : MODULES_PATH.$this->fuel->blog->config('theme_module').'/views/'.$view_folder.$view.'.php'; 51 | 52 | // check that a view file exists and if not, do one last check that it exists in the default theme folder and if not, redirect it 53 | if (!file_exists($view_path)) 54 | { 55 | // if the view file isn't found in the main theme folder, then look in the default theme area 56 | $view_path = BLOG_PATH.'views/themes/default/'.$view.'.php'; 57 | if (file_exists($view_path)) 58 | { 59 | $theme_module = BLOG_FOLDER; 60 | $view_folder = 'themes/default/'; 61 | } 62 | else 63 | { 64 | redirect_404(); 65 | } 66 | } 67 | 68 | if (!empty($layout)) 69 | { 70 | $vars['body'] = $this->load->module_view($theme_module, $view_folder.$view, $vars, TRUE); 71 | $view = $this->fuel->blog->theme_path().$this->fuel->blog->layout(); 72 | } 73 | else 74 | { 75 | $view = $view_folder.$view; 76 | } 77 | 78 | $vars = array_merge($vars, $this->load->get_vars()); 79 | 80 | $output = $this->load->module_view($layout_theme_module, $view, $vars, TRUE); 81 | $output = $page->fuelify($output); 82 | 83 | if ($return) 84 | { 85 | return $output; 86 | } 87 | else 88 | { 89 | $this->output->set_output($output); 90 | } 91 | } 92 | } -------------------------------------------------------------------------------- /controllers/Tags.php: -------------------------------------------------------------------------------- 1 | load->module_helper('blog', 'blog'); 10 | } 11 | 12 | function _remap($method = NULL) 13 | { 14 | // get the tag this way in case there is a language parameter 15 | $tag = $this->fuel->blog->uri_segment(3); 16 | 17 | $cache_id = fuel_cache_id(); 18 | if ($cache = $this->fuel->blog->get_cache($cache_id)) 19 | { 20 | $output =& $cache; 21 | } 22 | else 23 | { 24 | $vars = $this->_common_vars(); 25 | $vars['pagination'] = ''; 26 | 27 | // check if RSS feed 28 | if ($this->fuel->blog->uri_segment(3) == 'feed') 29 | { 30 | 31 | $type = ($this->fuel->blog->uri_segment(4) == 'atom') ? 'atom' : 'rss'; 32 | 33 | // set the header type 34 | $this->fuel->blog->feed_header(); 35 | 36 | // set the output 37 | $output = $this->fuel->blog->feed_output($type, $tag); 38 | } 39 | else if (!empty($tag) AND $tag != 'index') 40 | { 41 | 42 | $year = (int) $this->fuel->blog->uri_segment(4); 43 | $month = (int) $this->fuel->blog->uri_segment(5); 44 | $day = (int) $this->fuel->blog->uri_segment(6); 45 | 46 | $tag_obj = $this->fuel->blog->get_tag($tag); 47 | if (!isset($tag_obj->id)) redirect_404(); 48 | 49 | // run before_posts_by_date hook 50 | $hook_params = array('tag' => $tag_obj, 'tag_slug' => $tag); 51 | $this->fuel->blog->run_hook('before_posts_by_tag', $hook_params); 52 | 53 | $vars = array_merge($vars, $hook_params); 54 | 55 | $limit = $this->fuel->blog->config('per_page'); 56 | $offset = (((int)$this->input->get('page') - 1) * $limit); 57 | $offset = ($offset < 0 ? 0 : $offset); 58 | 59 | if (!empty($offset)) 60 | { 61 | $vars['page_title'] = array($tag_obj->name, lang('blog_tags_num_title', $offset, $offset + $limit)); 62 | } 63 | else 64 | { 65 | $vars['page_title'] = array($tag_obj->name, lang('blog_tags_page_title')); 66 | } 67 | 68 | $vars['offset'] = $offset; 69 | $vars['limit'] = $limit; 70 | $vars['posts'] = $this->fuel->blog->get_tag_posts_by_date($tag, $year, $month, $day, $limit, $offset); 71 | $vars['post_count'] = count($this->fuel->blog->get_tag_posts_by_date($tag, $year, $month, $day)); 72 | 73 | // create pagination 74 | $url_segs = array(); 75 | if (!empty($year)) $url_segs[] = $year; 76 | if (!empty($month)) $url_segs[] = sprintf("%02d", $month); 77 | if (!empty($day)) $url_segs[] = sprintf("%02d", $day); 78 | $base_url = 'tags/' . $tag . '/'.implode('/', $url_segs); 79 | 80 | $vars['pagination'] = $this->fuel->blog->pagination($vars['post_count'], $base_url); 81 | $output = $this->_render('tag', $vars, TRUE); 82 | } 83 | else 84 | { 85 | $vars['tags'] = $this->fuel->blog->get_tags(); 86 | $vars['page_title'] = lang('blog_tags_page_title'); 87 | $output = $this->_render('tags', $vars, TRUE); 88 | } 89 | $this->fuel->blog->save_cache($cache_id, $output); 90 | } 91 | $this->output->set_output($output); 92 | } 93 | 94 | } -------------------------------------------------------------------------------- /views/_docs/configuration.php: -------------------------------------------------------------------------------- 1 | 2

Other Configurations

2 |

The blog config file has additional configuration parameters to control the blog. You can

3 | 33 | 34 |

Programmer specific

35 |

The config file also contains several programmer specific configurations:

36 | -------------------------------------------------------------------------------- /controllers/Categories.php: -------------------------------------------------------------------------------- 1 | load->module_helper('blog', 'blog'); 10 | } 11 | 12 | function _remap($method = NULL) 13 | { 14 | // get the category this way in case there is a language parameter 15 | $category = $this->fuel->blog->uri_segment(3); 16 | 17 | $cache_id = fuel_cache_id(); 18 | if ($cache = $this->fuel->blog->get_cache($cache_id)) 19 | { 20 | $output =& $cache; 21 | } 22 | else 23 | { 24 | $vars = $this->_common_vars(); 25 | $vars['pagination'] = ''; 26 | 27 | // check if RSS feed 28 | if ($this->fuel->blog->uri_segment(3) == 'feed') 29 | { 30 | 31 | $type = ($this->fuel->blog->uri_segment(4) == 'atom') ? 'atom' : 'rss'; 32 | 33 | // set the header type 34 | $this->fuel->blog->feed_header(); 35 | 36 | $category = $this->fuel->blog->uri_segment(4); 37 | 38 | // set the output 39 | $output = $this->fuel->blog->feed_output($type, $category); 40 | } 41 | else if (!empty($category) AND $category != 'index') 42 | { 43 | $year = (int) $this->fuel->blog->uri_segment(4); 44 | $month = (int) $this->fuel->blog->uri_segment(5); 45 | $day = (int) $this->fuel->blog->uri_segment(6); 46 | 47 | $category_obj = $this->fuel->blog->get_category($category); 48 | if (!isset($category_obj->id)) redirect_404(); 49 | 50 | // run before_posts_by_date hook 51 | $hook_params = array('category' => $category_obj, 'category_slug' => $category); 52 | $this->fuel->blog->run_hook('before_posts_by_category', $hook_params); 53 | 54 | $vars = array_merge($vars, $hook_params); 55 | 56 | 57 | $limit = $this->fuel->blog->config('per_page'); 58 | $offset = (((int)$this->input->get('page') - 1) * $limit); 59 | $offset = ($offset < 0 ? 0 : $offset); 60 | 61 | if (!empty($offset)) 62 | { 63 | $vars['page_title'] = array($category_obj->name, lang('blog_categories_num_title', $offset, $offset + $limit)); 64 | } 65 | else 66 | { 67 | $vars['page_title'] = array($category_obj->name, lang('blog_categories_page_title')); 68 | } 69 | 70 | $vars['offset'] = $offset; 71 | $vars['limit'] = $limit; 72 | $vars['posts'] = $this->fuel->blog->get_category_posts_by_date($category, $year, $month, $day, $limit, $offset); 73 | $vars['post_count'] = count($this->fuel->blog->get_category_posts_by_date($category, $year, $month, $day)); 74 | 75 | // create pagination 76 | $url_segs = array(); 77 | if (!empty($year)) $url_segs[] = $year; 78 | if (!empty($month)) $url_segs[] = sprintf("%02d", $month); 79 | if (!empty($day)) $url_segs[] = sprintf("%02d", $day); 80 | $base_url = 'categories/' . $category . '/'.implode('/', $url_segs); 81 | 82 | $vars['pagination'] = $this->fuel->blog->pagination($vars['post_count'], $base_url); 83 | $output = $this->_render('category', $vars, TRUE); 84 | } 85 | else 86 | { 87 | $vars['categories'] = $this->fuel->blog->get_categories(); 88 | $vars['page_title'] = lang('blog_categories_page_title'); 89 | $output = $this->_render('categories', $vars, TRUE); 90 | } 91 | $this->fuel->blog->save_cache($cache_id, $output); 92 | } 93 | $this->output->set_output($output); 94 | } 95 | 96 | } -------------------------------------------------------------------------------- /views/_docs/themes.php: -------------------------------------------------------------------------------- 1 |

Creating Themes

2 |

Themes are a set of view files used to render your blog. Because you actually 3 | have access to the CodeIgniter super object, your theme files can act like 4 | any other CodeIgniter view file. The $blog variable, which is an instance of the 5 | Fuel_blog class, is passed to 6 | each main view file as well. You could even load in directly any of the blog's models 7 | (posts, 8 | categories, 9 | comments, 10 | links and 11 | author). 12 |

13 | 14 |

Below are steps to creating a new theme:

15 |
    16 |
  1. Duplicate the default theme and rename the folder
  2. 17 |
  3. In the settings module, change the Theme location parameter to the path to your new theme folder
  4. 18 |
  5. Edit the files listed below to your liking
  6. 19 |
20 | 21 |

View Files

22 |

The following files can be found in your renamed theme folder for you to begin editing to your liking:

23 | 24 |

Main View Files

25 | 36 | 37 |

Blocks View Files

38 | 52 | -------------------------------------------------------------------------------- /views/_docs/comments.php: -------------------------------------------------------------------------------- 1 |

Comments

2 |

Blog comments are created from people commenting on your posts. After a person has commented, the author is sent an email notification. 3 | He can then login to FUEL and publish the comment (assuming the monitor_comments setting is set) and reply to the comment. 4 | Comments are powered by a blog_comments_model and have a grandparent class of MY_Model. 5 |

6 | 7 |

Comment Fields

8 |

Below are the fields to fill out to submit a comment from the blog (note that author in this case refers to the comment and not the post):

9 | 14 | 15 |

Comment Security

16 |

The Blog Settings module has several security options for comments:

17 | 26 | 27 |
28 | 29 |

The Comment Model Properties

30 |

The comment object model has the following properties:

31 | 46 | 47 |
48 | 49 |

The Comment Model Methods

50 |

The comment object model has the following specific methods:

51 | 52 |

content_formatted()

53 |

Returns the content of the comment.

54 | 55 |

get_post()

56 |

Returns the post associate with the comment.

57 | 58 |

is_duplicate()

59 |

Returns boolean value whether the comment is considered a duplicate of an existing.

60 | 61 |

is_by_post_author()

62 |

Returns a boolean as to whether the comment is by the post's author or not.

63 | 64 |

is_child()

65 |

Returns a boolean as to whether the comment is a child of another comment.

66 | 67 |

get_author_and_link()

68 |

Returns the comments author and link if a website was specified in the comment.

69 | 70 |

get_date_formatted('[format]')

71 |

Returns a formatted version of the date of the comment. 72 | Takes a date format. Default is 'M d, Y'. 73 |

74 | 75 |

is_spam()

76 |

Returns a boolean value if the comment should be considered as SPAM.

77 | 78 |

check_is_spam()

79 |

Performs a spam check on the comment using stopforumspam or AKISMET (if a key is provided in the settings).

80 | 81 |

is_savable()

82 |

Returns a boolean value depending on if the comment can be saved based on the SPAM settings.

83 | -------------------------------------------------------------------------------- /config/blog_fuel_modules.php: -------------------------------------------------------------------------------- 1 | 'Posts', 4 | 'module_uri' => 'blog/posts', 5 | 'model_name' => 'blog_posts_model', 6 | 'model_location' => 'blog', 7 | 'display_field' => 'title', 8 | 'preview_path' => 'blog/{year}/{month}/{day}/{slug}', 9 | 'permission' => array('blog_posts', 'create' => 'blog_posts/create', 'edit' => 'blog_posts/edit', 'publish' => 'blog_posts/publish', 'delete' => 'blog_posts/delete'), 10 | 'instructions' => lang('module_instructions_default', 'blog posts'), 11 | 'archivable' => TRUE, 12 | 'configuration' => array('blog' => 'blog'), 13 | 'nav_selected' => 'blog/posts', 14 | // 'language' => array('blog' => 'blog'), 15 | 'default_col' => 'publish_date', 16 | 'default_order' => 'desc', 17 | 'sanitize_input' => array('template','php'), 18 | 'filters' => array( 19 | 'category_id' => array('label' => lang('form_label_category'), 'type' => 'select', 'model' => array(FUEL_FOLDER => 'fuel_categories_model'), 'first_option' => lang('label_select_one')), 20 | 'author_id' => array('label' => lang('form_label_author'), 'type' => 'select', 'model' => array(BLOG_FOLDER => 'blog_users_model'), 'first_option' => lang('label_select_one')) 21 | 22 | ), 23 | 'advanced_search' => TRUE 24 | ); 25 | 26 | // $config['modules']['blog_categories'] = array( 27 | // 'module_name' => 'Categories', 28 | // 'module_uri' => 'blog/categories', 29 | // 'model_name' => 'blog_categories_model', 30 | // 'model_location' => 'blog', 31 | // // 'table_headers' => array( 32 | // // 'id', 33 | // // 'name', 34 | // // 'precedence', 35 | // // 'published', 36 | // // ), 37 | // 'display_field' => 'name', 38 | // 'preview_path' => 'blog/categories/{slug}', 39 | // 'permission' => 'blog_categories', 40 | // 'instructions' => lang('module_instructions_default', 'blog categories'), 41 | // 'archivable' => TRUE, 42 | // 'configuration' => array('blog' => 'blog'), 43 | // 'nav_selected' => 'blog/categories', 44 | // // 'language' => array('blog' => 'blog') 45 | // 'hidden' => TRUE, 46 | 47 | // ); 48 | 49 | $config['modules']['blog_comments'] = array( 50 | 'module_name' => 'Comments', 51 | 'module_uri' => 'blog/comments', 52 | 'model_name' => 'blog_comments_model', 53 | 'model_location' => 'blog', 54 | 'table_headers' => array( 55 | 'id', 56 | 'post_title', 57 | 'comment', 58 | 'comment_author_name', 59 | 'is_spam', 60 | 'date_submitted', 61 | 'published', 62 | ), 63 | 'display_field' => 'author_name', 64 | 'default_col' => 'date_submitted', 65 | 'default_order' => 'desc', 66 | 'preview_path' => 'blog/{year}/{month}/{day}/{slug}', 67 | 'permission' => array('blog_comments', 'create' => 'blog_comments/create', 'edit' => 'blog_comments/edit', 'publish' => 'blog_comments/publish', 'delete' => 'blog_comments/delete'), 68 | 'instructions' => lang('module_instructions_default', 'blog comments'), 69 | 'archivable' => TRUE, 70 | 'configuration' => array('blog' => 'blog'), 71 | 'nav_selected' => 'blog/comments', 72 | // 'language' => array('blog' => 'blog'), 73 | ); 74 | 75 | $config['modules']['blog_links'] = array( 76 | 'module_name' => 'Links', 77 | 'module_uri' => 'blog/links', 78 | 'model_name' => 'blog_links_model', 79 | 'model_location' => 'blog', 80 | 'display_field' => 'url', 81 | 'default_col' => 'name', 82 | 'preview_path' => '', 83 | 'permission' => array('blog_links', 'create' => 'blog_links/create', 'edit' => 'blog_links/edit', 'publish' => 'blog_links/publish', 'delete' => 'blog_links/delete'), 84 | 'instructions' => lang('module_instructions_default', 'blog links'), 85 | 'archivable' => TRUE, 86 | 'configuration' => array('blog' => 'blog'), 87 | 'nav_selected' => 'blog/links', 88 | // 'language' => array('blog' => 'blog') 89 | ); 90 | 91 | $config['modules']['blog_users'] = array( 92 | 'module_name' => 'Authors', 93 | 'module_uri' => 'blog/users', 94 | 'model_name' => 'blog_users_model', 95 | 'model_location' => 'blog', 96 | 'table_headers' => array( 97 | 'id', 98 | 'name', 99 | 'display_name', 100 | 'active' 101 | ), 102 | 103 | 'display_field' => 'display_name', 104 | 'preview_path' => 'blog/authors/{fuel_user_id}', 105 | 'permission' => array('blog_users', 'create' => 'blog_users/create', 'edit' => 'blog_users/edit', 'publish' => 'blog_users/publish', 'delete' => 'blog_users/delete'), 106 | 'instructions' => lang('module_instructions_default', 'blog authors'), 107 | 'archivable' => TRUE, 108 | 'configuration' => array('blog' => 'blog'), 109 | 'nav_selected' => 'blog/users', 110 | // 'language' => array('blog' => 'blog') 111 | ); -------------------------------------------------------------------------------- /install/fuel_blog_install.sql: -------------------------------------------------------------------------------- 1 | # Dump of table fuel_blog_comments 2 | # ------------------------------------------------------------ 3 | 4 | CREATE TABLE `fuel_blog_comments` ( 5 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 6 | `post_id` int(10) unsigned NOT NULL, 7 | `parent_id` int(10) unsigned NOT NULL, 8 | `author_id` int(10) unsigned NOT NULL, 9 | `author_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, 10 | `author_email` varchar(255) COLLATE utf8_unicode_ci NOT NULL, 11 | `author_website` varchar(255) COLLATE utf8_unicode_ci NOT NULL, 12 | `author_ip` varchar(50) COLLATE utf8_unicode_ci NOT NULL, 13 | `is_spam` enum('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'no', 14 | `content` text COLLATE utf8_unicode_ci NOT NULL, 15 | `published` enum('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'yes', 16 | `date_added` datetime NOT NULL, 17 | `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 18 | PRIMARY KEY (`id`) 19 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 20 | 21 | 22 | 23 | # Dump of table fuel_blog_links 24 | # ------------------------------------------------------------ 25 | 26 | CREATE TABLE `fuel_blog_links` ( 27 | `id` int(11) NOT NULL AUTO_INCREMENT, 28 | `name` varchar(255) DEFAULT NULL, 29 | `url` varchar(255) DEFAULT NULL, 30 | `target` enum('blank','self','parent') DEFAULT 'blank', 31 | `description` varchar(100) DEFAULT NULL, 32 | `precedence` int(11) NOT NULL DEFAULT '0', 33 | `language` varchar(30) NOT NULL DEFAULT 'english', 34 | `published` enum('yes','no') DEFAULT 'yes', 35 | PRIMARY KEY (`id`) 36 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 37 | 38 | 39 | 40 | # Dump of table fuel_blog_posts 41 | # ------------------------------------------------------------ 42 | 43 | CREATE TABLE `fuel_blog_posts` ( 44 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 45 | `title` varchar(255) COLLATE utf8_unicode_ci NOT NULL, 46 | `language` varchar(30) COLLATE utf8_unicode_ci NOT NULL DEFAULT 'english', 47 | `content` text COLLATE utf8_unicode_ci NOT NULL, 48 | `content_filtered` text COLLATE utf8_unicode_ci NOT NULL, 49 | `formatting` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, 50 | `excerpt` text COLLATE utf8_unicode_ci NOT NULL COMMENT 'A condensed version of the content', 51 | `slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT 'This is the last part of the url string. If left blank, the slug will automatically be created for you.', 52 | `author_id` int(10) unsigned NOT NULL COMMENT 'If left blank, you will assumed be the author.', 53 | `main_image` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 54 | `list_image` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 55 | `thumbnail_image` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 56 | `sticky` enum('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'no', 57 | `allow_comments` enum('yes','no') COLLATE utf8_unicode_ci DEFAULT 'no', 58 | `publish_date` datetime NOT NULL, 59 | `page_title` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 60 | `meta_description` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 61 | `meta_keywords` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 62 | `canonical` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 63 | `og_title` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 64 | `og_description` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 65 | `og_image` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', 66 | `category_id` int(10) unsigned NOT NULL, 67 | `date_added` datetime DEFAULT NULL, 68 | `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, 69 | `published` enum('yes','no') COLLATE utf8_unicode_ci NOT NULL DEFAULT 'yes', 70 | PRIMARY KEY (`id`), 71 | UNIQUE KEY `permalink` (`slug`) 72 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 73 | 74 | 75 | 76 | # Dump of table fuel_blog_users 77 | # ------------------------------------------------------------ 78 | 79 | CREATE TABLE `fuel_blog_users` ( 80 | `id` int(10) unsigned NOT NULL AUTO_INCREMENT, 81 | `fuel_user_id` int(10) unsigned NOT NULL, 82 | `display_name` varchar(50) NOT NULL, 83 | `website` varchar(100) NOT NULL, 84 | `about` text NOT NULL, 85 | `avatar_image` varchar(255) NOT NULL DEFAULT '', 86 | `social_media_links` text NOT NULL, 87 | `date_added` datetime DEFAULT NULL, 88 | `active` enum('yes','no') NOT NULL DEFAULT 'yes', 89 | PRIMARY KEY (`id`) 90 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 91 | 92 | # Needed for Dashboard 93 | # ------------------------------------------------------------ 94 | INSERT INTO `fuel_permissions` (`id`, `description`, `name`, `active`) VALUES (NULL, 'Blog', 'blog', 'yes'); 95 | 96 | -------------------------------------------------------------------------------- /config/language_codes.php: -------------------------------------------------------------------------------- 1 | "afar", 5 | "ab" => "abkhazian", 6 | "ae" => "avestan", 7 | "af" => "afrikaans", 8 | "ak" => "akan", 9 | "am" => "amharic", 10 | "an" => "aragonese", 11 | "ar" => "arabic", 12 | "as" => "assamese", 13 | "av" => "avaric", 14 | "ay" => "aymara", 15 | "az" => "azerbaijani", 16 | "ba" => "bashkir", 17 | "be" => "belarusian", 18 | "bg" => "bulgarian", 19 | "bh" => "bihari", 20 | "bi" => "bislama", 21 | "bm" => "bambara", 22 | "bn" => "bengali", 23 | "bo" => "tibetan", 24 | "br" => "breton", 25 | "bs" => "bosnian", 26 | "ca" => "catalan", 27 | "ce" => "chechen", 28 | "ch" => "chamorro", 29 | "co" => "corsican", 30 | "cr" => "cree", 31 | "cs" => "czech", 32 | "cu" => "church slavic", 33 | "cv" => "chuvash", 34 | "cy" => "welsh", 35 | "da" => "danish", 36 | "de" => "german", 37 | "dv" => "divehi", 38 | "dz" => "dzongkha", 39 | "ee" => "ewe", 40 | "el" => "greek", 41 | "en" => "english", 42 | "eo" => "esperanto", 43 | "es" => "spanish", 44 | "et" => "estonian", 45 | "eu" => "basque", 46 | "fa" => "persian", 47 | "ff" => "fulah", 48 | "fi" => "finnish", 49 | "fj" => "fijian", 50 | "fo" => "faroese", 51 | "fr" => "french", 52 | "fy" => "western frisian", 53 | "ga" => "irish", 54 | "gd" => "scottish gaelic", 55 | "gl" => "galician", 56 | "gn" => "guarani", 57 | "gu" => "gujarati", 58 | "gv" => "manx", 59 | "ha" => "hausa", 60 | "he" => "hebrew", 61 | "hi" => "hindi", 62 | "ho" => "hiri motu", 63 | "hr" => "croatian", 64 | "ht" => "haitian", 65 | "hu" => "hungarian", 66 | "hy" => "armenian", 67 | "hz" => "herero", 68 | "ia" => "interlingua (international auxiliary language association)", 69 | "id" => "indonesian", 70 | "ie" => "interlingue", 71 | "ig" => "igbo", 72 | "ii" => "sichuan yi", 73 | "ik" => "inupiaq", 74 | "io" => "ido", 75 | "is" => "icelandic", 76 | "it" => "italian", 77 | "iu" => "inuktitut", 78 | "ja" => "japanese", 79 | "jv" => "javanese", 80 | "ka" => "georgian", 81 | "kg" => "kongo", 82 | "ki" => "kikuyu", 83 | "kj" => "kwanyama", 84 | "kk" => "kazakh", 85 | "kl" => "kalaallisut", 86 | "km" => "khmer", 87 | "kn" => "kannada", 88 | "ko" => "korean", 89 | "kr" => "kanuri", 90 | "ks" => "kashmiri", 91 | "ku" => "kurdish", 92 | "kv" => "komi", 93 | "kw" => "cornish", 94 | "ky" => "kirghiz", 95 | "la" => "latin", 96 | "lb" => "luxembourgish", 97 | "lg" => "ganda", 98 | "li" => "limburgish", 99 | "ln" => "lingala", 100 | "lo" => "lao", 101 | "lt" => "lithuanian", 102 | "lu" => "luba-katanga", 103 | "lv" => "latvian", 104 | "mg" => "malagasy", 105 | "mh" => "marshallese", 106 | "mi" => "maori", 107 | "mk" => "macedonian", 108 | "ml" => "malayalam", 109 | "mn" => "mongolian", 110 | "mr" => "marathi", 111 | "ms" => "malay", 112 | "mt" => "maltese", 113 | "my" => "burmese", 114 | "na" => "nauru", 115 | "nb" => "norwegian bokmal", 116 | "nd" => "north ndebele", 117 | "ne" => "nepali", 118 | "ng" => "ndonga", 119 | "nl" => "dutch", 120 | "nn" => "norwegian nynorsk", 121 | "no" => "norwegian", 122 | "nr" => "south ndebele", 123 | "nv" => "navajo", 124 | "ny" => "chichewa", 125 | "oc" => "occitan", 126 | "oj" => "ojibwa", 127 | "om" => "oromo", 128 | "or" => "oriya", 129 | "os" => "ossetian", 130 | "pa" => "panjabi", 131 | "pi" => "pali", 132 | "pl" => "polish", 133 | "ps" => "pashto", 134 | "pt" => "portuguese", 135 | "qu" => "quechua", 136 | "rm" => "raeto-romance", 137 | "rn" => "kirundi", 138 | "ro" => "romanian", 139 | "ru" => "russian", 140 | "rw" => "kinyarwanda", 141 | "sa" => "sanskrit", 142 | "sc" => "sardinian", 143 | "sd" => "sindhi", 144 | "se" => "northern sami", 145 | "sg" => "sango", 146 | "si" => "sinhala", 147 | "sk" => "slovak", 148 | "sl" => "slovenian", 149 | "sm" => "samoan", 150 | "sn" => "shona", 151 | "so" => "somali", 152 | "sq" => "albanian", 153 | "sr" => "serbian", 154 | "ss" => "swati", 155 | "st" => "southern sotho", 156 | "su" => "sundanese", 157 | "sv" => "swedish", 158 | "sw" => "swahili", 159 | "ta" => "tamil", 160 | "te" => "telugu", 161 | "tg" => "tajik", 162 | "th" => "thai", 163 | "ti" => "tigrinya", 164 | "tk" => "turkmen", 165 | "tl" => "tagalog", 166 | "tn" => "tswana", 167 | "to" => "tonga", 168 | "tr" => "turkish", 169 | "ts" => "tsonga", 170 | "tt" => "tatar", 171 | "tw" => "twi", 172 | "ty" => "tahitian", 173 | "ug" => "uighur", 174 | "uk" => "ukrainian", 175 | "ur" => "urdu", 176 | "uz" => "uzbek", 177 | "ve" => "venda", 178 | "vi" => "vietnamese", 179 | "vo" => "volapuk", 180 | "wa" => "walloon", 181 | "wo" => "wolof", 182 | "xh" => "xhosa", 183 | "yi" => "yiddish", 184 | "yo" => "yoruba", 185 | "za" => "zhuang", 186 | "zh" => "chinese", 187 | "zu" => "zulu" 188 | ); -------------------------------------------------------------------------------- /models/Blog_categories_model.php: -------------------------------------------------------------------------------- 1 | array('name' => 'url_title')); 11 | 12 | // public $belongs_to = array( 13 | // 'posts' => array('model' => array(BLOG_FOLDER => 'blog_posts_model'), 'where' => 'language = "{language}" OR language = ""') 14 | // ); 15 | 16 | function __construct() 17 | { 18 | parent::__construct('blog_categories', BLOG_FOLDER); // table name 19 | } 20 | 21 | /* NO LONGER USED BECAUSE fuel_categeries_model IS replacing this functionality. LEFT HERE FOR POSTERITY 22 | 23 | // used for the FUEL admin 24 | function list_items($limit = NULL, $offset = NULL, $col = 'name', $order = 'asc', $just_count = FALSE) 25 | { 26 | $this->db->where(array('id !=' => 1)); // Uncategorized category 27 | 28 | if ($this->fuel->language->has_multiple()) 29 | { 30 | $this->db->select('id, name, precedence, language, published'); 31 | } 32 | else 33 | { 34 | $this->db->select('id, name, precedence, published'); 35 | } 36 | 37 | $data = parent::list_items($limit, $offset, $col, $order, $just_count); 38 | return $data; 39 | } 40 | 41 | function on_before_clean($values) 42 | { 43 | if (empty($values['slug']) && !empty($values['name'])) $values['slug'] = url_title($values['name'], 'dash', TRUE); 44 | return $values; 45 | } 46 | 47 | // check if it is the "Uncategorized" category so we don't delete it' 48 | function on_before_delete($where) 49 | { 50 | $CI =& get_instance(); 51 | $CI->load->module_language('blog', 'blog'); 52 | if (is_array($where) && isset($where['id'])) 53 | { 54 | if ($where['id'] == 1) 55 | { 56 | $this->add_error(lang('blog_error_delete_uncategorized')); 57 | $CI->session->set_flashdata('error', lang('blog_error_delete_uncategorized')); 58 | return; 59 | } 60 | } 61 | } 62 | 63 | function form_fields($values = array(), $related = array()) 64 | { 65 | $fields = parent::form_fields($values); 66 | 67 | // set language field 68 | $fields['language'] = array('type' => 'select', 'options' => $this->fuel->language->options(), 'value' => $this->fuel->language->default_option(), 'hide_if_one' => TRUE); 69 | $fields['description']['editor'] = FALSE; 70 | return $fields; 71 | }*/ 72 | 73 | function _common_query($display_unpublished_if_logged_in = NULL) 74 | { 75 | parent::_common_query($display_unpublished_if_logged_in); 76 | $this->db->order_by('precedence, name asc'); 77 | } 78 | 79 | function get_published_categories($language = NULL) 80 | { 81 | $CI =& get_instance(); 82 | $posts = $CI->fuel->blog->model('blog_posts')->find_all_array_assoc('category_id'); 83 | $published_categories = array_keys($posts); 84 | 85 | //$published_categories = $this->get_related_keys(array(), $this->belongs_to['posts'], 'belongs_to'); 86 | $categories_query_params = array(); 87 | if (!empty($published_categories)) 88 | { 89 | $categories_query_params = array('where_in' => array('id' => $published_categories), 'where' => 'published = "yes"'); 90 | if (!empty($language)) 91 | { 92 | $categories_query_params['where'] .= ' AND language="'.$language.'" OR language=""'; 93 | } 94 | $categories_query = $this->query($categories_query_params); 95 | return $categories_query->result(); 96 | } 97 | return array(); 98 | } 99 | 100 | public function ajax_options($where = array()) 101 | { 102 | if (!empty($where['language'])) 103 | { 104 | $this->db->where($where); 105 | $this->db->or_where('language = ""'); 106 | $options = $this->options_list(); 107 | } 108 | else 109 | { 110 | $options = $this->options_list(NULL, NULL, $where); 111 | } 112 | $str = ''; 113 | foreach($options as $key => $val) 114 | { 115 | $str .= "\n"; 116 | } 117 | return $str; 118 | } 119 | } 120 | 121 | class Blog_category_model extends Base_module_record { 122 | 123 | protected $_tables; 124 | 125 | function on_init() 126 | { 127 | $this->_tables = $this->_CI->config->item('tables'); 128 | } 129 | 130 | function get_posts() 131 | { 132 | return $this->lazy_load(array($this->_tables['blog_posts'].'.category_id' => $this->id), 'blog_posts_model', TRUE); 133 | } 134 | 135 | function get_posts_count() 136 | { 137 | $this->_CI->load->module_model('blog', 'blog_posts_model'); 138 | $where = array('published' => 'yes', 'category_id' => $this->id); 139 | $count = $this->_CI->blog_posts_model->record_count($where); 140 | return $count; 141 | } 142 | 143 | function get_url($full_path = TRUE) 144 | { 145 | $url = 'categories/'.$this->slug; 146 | if ($full_path) 147 | { 148 | return $this->_CI->fuel_blog->url($url); 149 | } 150 | return $url; 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /views/_docs/posts.php: -------------------------------------------------------------------------------- 1 |

Posts

2 |

Posts are where you create articles for your blog. 3 | Posts are powered by a blog_posts_model and have a grandparent class of MY_Model.

4 | 5 |

Post Fields

6 |

Below are the fields to fill out for a post:

7 | 19 | 20 |
21 | 22 |

The Post Model Properties

23 |

The post model has the following properties:

24 | 39 | 40 |
41 | 42 |

The Post Model Properties and Methods

43 |

The post model has the following relationship properties:

44 | 49 | 50 |

The post model has the following specific methods:

51 | 52 |

get_content_formatted(strip_images)

53 |

Gets the post content with the selected formatting settings applied. You can optionally strip all HTML tags from the excerpt.

54 | 55 |

get_excerpt_formatted(char_limit, '[readmore]')

56 |

Gets the post excerpt. 57 | The char_limit parameter will return only a certain character limit (if so, strip_tags is applied). 58 | The readmore parameter will be appended to the end of the excerpt with a link to the full post. 59 |

60 | 61 |

is_published()

62 |

Returns a boolean of whether the post is published

63 | 64 |

get_comments('[order]', [limit])

65 |

66 | Returns an array of comment objects. 67 | Default order is date added in ascending order. 68 |

69 | 70 |

get_comments_count('[order]', [limit])

71 |

72 | Returns the number of comments for the post 73 | Default order is date added in ascending order. 74 |

75 | 76 |

get_comments_formatted('[block]', [parent_id], [container_class])

77 |

78 | Creates the HTML for the comments of the post using the comments block and properly nesting comments if their is a hierarchical structure. 79 |

80 | 81 |

get_categories('[order]')

82 |

83 | Returns an array of category objects associated with the post 84 | Default ordering is by name in ascending order. 85 |

86 | 87 | belongs_to_category 88 | 89 |

get_tags_linked('[order]', '[join]')

90 |

91 | Returns a string of category links. 92 | Default ordering is by name in ascending order. 93 | Default join parameter is ', '. 94 |

95 | 96 |

get_author()

97 |

Returns the author object.

98 | 99 |

get_url('full_path')

100 |

101 | Returns the url of the post. 102 | The default for full_path is set to TRUE. 103 |

104 | 105 |

get_rss_date()

106 |

Returns an rss formatted date for the post.

107 | 108 |

get_atom_date()

109 |

Returns an atom formatted date for the post.

110 | 111 |

get_date_formatted('[format]')

112 |

113 | Returns the date of the post. 114 | Takes a date format. Default is 'M d, Y'. 115 |

116 | 117 |

get_allow_comments()

118 |

Returns a boolean as to whether comments are allowed.

119 | 120 |

is_within_comment_time_limit()

121 |

Returns a boolean as to whether the current time is within the time limits specified by the post to comment.

122 | 123 |

get_prev_post()

124 |

Returns the previous post based on date.

125 | 126 |

get_prev_post_url()

127 |

Returns the previous post URL based on date.

128 | 129 |

get_next_post()

130 |

Returns the next post based on date.

131 | 132 |

get_next_post_url()

133 |

Returns the next post URL based on date.

134 | 135 | 136 | -------------------------------------------------------------------------------- /install/archive/fuel_blog_v.9.3.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 2.10.2 3 | -- http://www.phpmyadmin.net 4 | -- 5 | -- Host: localhost 6 | -- Generation Time: Jun 10, 2010 at 11:19 AM 7 | -- Server version: 5.0.45 8 | -- PHP Version: 5.3.1 9 | 10 | SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; 11 | 12 | -- -------------------------------------------------------- 13 | 14 | -- 15 | -- Table structure for table `fuel_blog_categories` 16 | -- 17 | 18 | CREATE TABLE `fuel_blog_categories` ( 19 | `id` int(10) unsigned NOT NULL auto_increment, 20 | `name` varchar(255) collate utf8_unicode_ci NOT NULL, 21 | `permalink` varchar(255) collate utf8_unicode_ci NOT NULL default '', COMMENT 'If left blank, the permalink will automatically be created for you.', 22 | `published` enum('yes','no') collate utf8_unicode_ci NOT NULL default 'yes', 23 | PRIMARY KEY (`id`), 24 | UNIQUE KEY `permalink` (`permalink`), 25 | UNIQUE KEY `name` (`name`) 26 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 27 | 28 | -- 29 | -- Dumping data for table `fuel_blog_categories` 30 | -- 31 | 32 | INSERT INTO `fuel_blog_categories` (`id`, `name`, `permalink`, `published`) VALUES 33 | (1, 'Uncategorized', 'uncategorized', 'yes'); 34 | 35 | -- -------------------------------------------------------- 36 | 37 | -- 38 | -- Table structure for table `fuel_blog_comments` 39 | -- 40 | 41 | CREATE TABLE `fuel_blog_comments` ( 42 | `id` int(10) unsigned NOT NULL auto_increment, 43 | `post_id` int(10) unsigned NOT NULL, 44 | `author_id` int(10) unsigned NOT NULL, 45 | `author_name` varchar(255) collate utf8_unicode_ci NOT NULL, 46 | `author_email` varchar(255) collate utf8_unicode_ci NOT NULL, 47 | `author_website` varchar(255) collate utf8_unicode_ci NOT NULL default '', 48 | `author_ip` varchar(32) collate utf8_unicode_ci NOT NULL, 49 | `is_spam` enum('yes','no') collate utf8_unicode_ci NOT NULL default 'no', 50 | `content` text collate utf8_unicode_ci NOT NULL, 51 | `published` enum('yes','no') collate utf8_unicode_ci NOT NULL default 'yes', 52 | `date_added` datetime NOT NULL, 53 | `last_modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, 54 | PRIMARY KEY (`id`) 55 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 56 | 57 | -- 58 | -- Table structure for table `fuel_blog_links` 59 | -- 60 | 61 | CREATE TABLE `fuel_blog_links` ( 62 | `id` int(11) NOT NULL auto_increment, 63 | `name` varchar(255) default NULL, 64 | `url` varchar(255) default NULL, 65 | `target` enum('blank','self','parent') default 'blank', 66 | `description` varchar(100) default NULL, 67 | `precedence` int(11) NOT NULL default '0', 68 | `published` enum('yes','no') default 'yes', 69 | PRIMARY KEY (`id`) 70 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 71 | 72 | -- -------------------------------------------------------- 73 | 74 | -- 75 | -- Table structure for table `fuel_blog_posts` 76 | -- 77 | 78 | CREATE TABLE `fuel_blog_posts` ( 79 | `id` int(10) unsigned NOT NULL auto_increment, 80 | `title` varchar(255) collate utf8_unicode_ci NOT NULL, 81 | `permalink` varchar(255) collate utf8_unicode_ci NOT NULL COMMENT 'This is the last part of the url string. If left blank, the permalink will automatically be created for you.', 82 | `content` text collate utf8_unicode_ci NOT NULL, 83 | `content_filtered` text collate utf8_unicode_ci NOT NULL, 84 | `formatting` varchar(100) collate utf8_unicode_ci NOT NULL default 'auto_typography', 85 | `excerpt` text collate utf8_unicode_ci NOT NULL COMMENT 'A condensed version of the content', 86 | `author_id` int(10) unsigned NOT NULL COMMENT 'If left blank, you will assumed be the author.', 87 | `sticky` enum('yes','no') collate utf8_unicode_ci NOT NULL default 'no' COMMENT 'Sticky posts will always be sorted toward the top on the homepage regardless of date', 88 | `allow_comments` enum('yes','no') collate utf8_unicode_ci default 'no' COMMENT 'Checking yes will allow comments to be displayed but only if they are enabled in the global settings', 89 | `date_added` datetime default NULL, 90 | `last_modified` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, 91 | `published` enum('yes','no') collate utf8_unicode_ci NOT NULL, 92 | PRIMARY KEY (`id`), 93 | UNIQUE KEY `permalink` (`permalink`) 94 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 95 | -- 96 | -- Dumping data for table `fuel_blog_posts` 97 | -- 98 | 99 | 100 | -- -------------------------------------------------------- 101 | 102 | -- 103 | -- Table structure for table `fuel_blog_settings` 104 | -- 105 | 106 | CREATE TABLE `fuel_blog_settings` ( 107 | `name` varchar(100) collate utf8_unicode_ci NOT NULL, 108 | `value` text collate utf8_unicode_ci NOT NULL, 109 | PRIMARY KEY (`name`) 110 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; 111 | 112 | -- 113 | -- Dumping data for table `fuel_blog_settings` 114 | -- 115 | 116 | INSERT INTO `fuel_blog_settings` (`name`, `value`) VALUES 117 | ('title', 'My Blog'), 118 | ('uri', 'blog/'), 119 | ('theme_layout', 'blog'), 120 | ('theme_path', 'themes/default/'), 121 | ('theme_module', 'blog'), 122 | ('use_cache', '0'), 123 | ('cache_ttl', '3600'), 124 | ('per_page', '2'), 125 | ('description', ''), 126 | ('use_captchas', '1'), 127 | ('monitor_comments', '1'), 128 | ('save_spam', '1'), 129 | ('allow_comments', '1'), 130 | ('akismet_api_key', ''), 131 | ('comments_time_limit', ''), 132 | ('multiple_comment_submission_time_limit', '30'), 133 | ('asset_upload_path', 'images/blog/'); 134 | 135 | -- -------------------------------------------------------- 136 | 137 | -- 138 | -- Table structure for table `fuel_blog_users` 139 | -- 140 | 141 | CREATE TABLE `fuel_blog_users` ( 142 | `fuel_user_id` int(10) unsigned NOT NULL, 143 | `display_name` varchar(50) NOT NULL default '', 144 | `avatar` varchar(255) NOT NULL, 145 | `website` varchar(100) NOT NULL, 146 | `about` text NOT NULL, 147 | `date_added` datetime default NULL, 148 | `active` enum('yes','no') NOT NULL default 'yes', 149 | PRIMARY KEY (`fuel_user_id`) 150 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 151 | 152 | -- 153 | -- Dumping data for table `fuel_blog_users` 154 | -- 155 | 156 | -------------------------------------------------------------------------------- /config/blog.php: -------------------------------------------------------------------------------- 1 | lang('module_blog_posts'), 9 | //'blog/categories' => lang('module_blog_categories'), 10 | 'blog/comments' => lang('module_blog_comments'), 11 | 'blog/links' => lang('module_blog_links'), 12 | 'blog/users' => lang('module_blog_authors'), 13 | ); 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Configurable in settings if blog_use_db_table_settings is set 18 | |-------------------------------------------------------------------------- 19 | */ 20 | 21 | // deterines whether to use this configuration below or the database for controlling the blogs behavior 22 | $config['blog_use_db_table_settings'] = TRUE; 23 | 24 | // set as defaults 25 | $config['blog'] = array(); 26 | $config['blog']['title'] = 'Blog'; 27 | $config['blog']['description'] = ''; 28 | $config['blog']['uri'] = 'blog'; 29 | $config['blog']['theme_path'] = 'themes/default'; 30 | $config['blog']['theme_layout'] = 'blog'; 31 | $config['blog']['theme_module'] = 'blog'; 32 | $config['blog']['use_cache'] = FALSE; 33 | $config['blog']['allow_comments'] = FALSE; 34 | $config['blog']['monitor_comments'] = TRUE; 35 | $config['blog']['use_captchas'] = FALSE; 36 | $config['blog']['save_spam'] = FALSE; 37 | $config['blog']['akismet_api_key'] = ''; 38 | $config['blog']['multiple_comment_submission_time_limit'] = ''; 39 | $config['blog']['comments_time_limit'] = ''; 40 | $config['blog']['cache_ttl'] = 3600; 41 | $config['blog']['asset_upload_path'] = 'images/blog/'; 42 | $config['blog']['per_page'] = 10; 43 | $config['blog']['page_title_separator'] = '«'; 44 | $config['blog']['multiple_authors'] = FALSE; 45 | $config['blog']['limit_to_user'] = FALSE; 46 | $config['blog']['social_media'] = array('twitter' => 'Twitter', 'linkedin' => 'LinkedIn', 'rdio' => 'Rdio', 'googleplus' => 'Google+', 'instagram' => 'Instagram', 'pinterest' => 'Pinterest', 'flickr' => 'Flickr'); 47 | $config['blog']['image_sizes'] = array( 48 | 'main' => array('width' => 515, 'resize_method' => 'resize_and_crop', 'resize_and_crop' => TRUE), 49 | 'list' => array('width' => 300, 'height' => 175, 'resize_method' => 'resize_and_crop', 'resize_and_crop' => TRUE), 50 | 'thumbnail' => array('width' => 100, 'height' => 100, 'resize_method' => 'resize_and_crop', 'resize_and_crop' => TRUE), 51 | 'avatar' => array('width' => 100, 'height' => 95, 'resize_method' => 'resize_and_crop', 'resize_and_crop' => TRUE) 52 | ); 53 | $config['blog']['stopforumspam'] = array( 54 | 'ip_threshold_flag' => 5, 55 | 'email_threshold_flag' => 20, 56 | 'ip_threshold_ignore' => 20, 57 | 'email_threshold_ignore' => 50, 58 | ); 59 | $config['blog']['email_notify_comment_reply'] = TRUE; 60 | 61 | // used for Settings area 62 | $config['blog']['settings']['title'] = array(); 63 | $config['blog']['settings']['description'] = array('size' => '80'); 64 | $config['blog']['settings']['uri'] = array('value' => 'blog'); 65 | $config['blog']['settings']['theme_path'] = array('value' => 'themes/default'); 66 | $config['blog']['settings']['theme_layout'] = array('value' => 'blog', 'size' => '20'); 67 | $config['blog']['settings']['theme_module'] = array('value' => 'blog', 'size' => '20'); 68 | $config['blog']['settings']['use_cache'] = array('type' => 'checkbox', 'value' => '1'); 69 | $config['blog']['settings']['allow_comments'] = array('type' => 'checkbox', 'value' => '1'); 70 | $config['blog']['settings']['monitor_comments'] = array('type' => 'checkbox', 'value' => '1'); 71 | $config['blog']['settings']['use_captchas'] = array('type' => 'checkbox', 'value' => '1'); 72 | $config['blog']['settings']['save_spam'] = array('type' => 'checkbox', 'value' => '1'); 73 | $config['blog']['settings']['akismet_api_key'] = array('value' => '', 'size' => '80'); 74 | $config['blog']['settings']['multiple_comment_submission_time_limit'] = array('size' => '5', 'after_html' => lang('form_label_multiple_comment_submission_time_limit_after_html')); 75 | $config['blog']['settings']['comments_time_limit'] = array('size' => '5', 'after_html' => lang('form_label_comments_time_limit_after_html')); 76 | $config['blog']['settings']['cache_ttl'] = array('value' => 3600, 'size' => 5); 77 | $config['blog']['settings']['asset_upload_path'] = array('default' => 'images/blog/'); 78 | $config['blog']['settings']['per_page'] = array('value' => 10, 'size' => 3); 79 | $config['blog']['settings']['page_title_separator'] = array('value' => '«', 'size' => 10); 80 | $config['blog']['settings']['multiple_authors'] = array('type' => 'checkbox', 'value' => '1'); 81 | $config['blog']['settings']['limit_to_user'] = array('type' => 'checkbox', 'value' => '1'); 82 | $config['blog']['settings']['social_media'] = array('type' => 'keyval'); 83 | $config['blog']['settings']['email_notify_comment_reply'] = array('type' => 'checkbox', 'value' => '1'); 84 | 85 | 86 | // the cache folder to hold blog cache files 87 | $config['blog_cache_group'] = 'blog'; 88 | 89 | /* 90 | |-------------------------------------------------------------------------- 91 | | Programmer specific config (not exposed in settings) 92 | |-------------------------------------------------------------------------- 93 | */ 94 | // content formatting options 95 | $config['blog']['formatting'] = array( 96 | 'auto_typography' => 'Automatic', 97 | 'Markdown' => 'Markdown', 98 | '' => 'None' 99 | ); 100 | 101 | // captcha options 102 | $config['blog']['captcha'] = array( 103 | 'img_width' => 120, 104 | 'img_height' => 26, 105 | 'expiration' => 600, // 10 minutes 106 | 'bg_color' => '#4b4b4b', 107 | 'char_color' => '#ffffff,#cccccc,#ffffff,#999999,#ffffff,#cccccc', 108 | 'line_color' => '#ff9900,#414141,#ea631d,#aaaaaa,#f0a049,#ff9900' 109 | ); 110 | 111 | // comment form 112 | $config['blog']['comment_form'] = array(); 113 | $config['blog']['comment_form']['fields'] = array(); 114 | 115 | // pagination 116 | $config['blog']['pagination'] = array( 117 | 'prev_link' => 'Prev', 118 | 'next_link' => 'Next', 119 | 'first_link' => '', 120 | 'last_link' => '', 121 | ); 122 | 123 | 124 | // tables for blog 125 | $config['tables']['blog_posts'] = 'fuel_blog_posts'; 126 | $config['tables']['blog_categories'] = 'fuel_categories'; 127 | $config['tables']['blog_tags'] = 'fuel_tags'; 128 | $config['tables']['blog_users'] = 'fuel_blog_users'; 129 | $config['tables']['blog_comments'] = 'fuel_blog_comments'; 130 | $config['tables']['blog_links'] = 'fuel_blog_links'; 131 | $config['tables']['blog_settings'] = 'fuel_blog_settings'; 132 | $config['tables']['blog_relationships'] = 'fuel_relationships'; 133 | -------------------------------------------------------------------------------- /models/Blog_users_model.php: -------------------------------------------------------------------------------- 1 | add_validation('email', 'valid_email', 'Please enter in a valid email'); 15 | } 16 | 17 | // used for the FUEL admin 18 | function list_items($limit = NULL, $offset = NULL, $col = 'name', $order = 'asc', $just_count = FALSE) 19 | { 20 | $this->db->select('fuel_blog_users.id, CONCAT(first_name, " ", last_name) as name, display_name, fuel_blog_users.active', FALSE); 21 | //$this->db->join('fuel_users', 'fuel_users.id = fuel_blog_users.fuel_user_id', 'left'); 22 | $data = parent::list_items($limit, $offset, $col, $order, $just_count); 23 | return $data; 24 | } 25 | 26 | function options_list($key = 'fuel_user_id', $val = 'name', $where = array(), $order = 'first_name') 27 | { 28 | if (empty($key) OR $key == 'id') 29 | { 30 | //$key = $this->table_name.'.fuel_user_id'; 31 | $key = $this->table_name.'.id'; 32 | } 33 | if (empty($key) OR empty($val) OR $val == 'name') 34 | { 35 | //$val = 'IF(display_name = "", fuel_users.email, display_name) AS name'; 36 | $val = 'CONCAT(first_name, " ", last_name) as name'; 37 | $order = 'first_name'; 38 | } 39 | 40 | //$this->db->join('fuel_users', 'fuel_users.id = fuel_blog_users.fuel_user_id', 'left'); 41 | $return = parent::options_list($key, $val, $where, $order); 42 | return $return; 43 | } 44 | 45 | function form_fields($values = array(), $related_fields = array()) 46 | { 47 | $fields = parent::form_fields($values, $related_fields); 48 | $CI =& get_instance(); 49 | $CI->load->module_model(FUEL_FOLDER, 'fuel_users_model'); 50 | $CI->load->module_library(BLOG_FOLDER, 'fuel_blog'); 51 | 52 | $fields['avatar_image']['folder'] = $CI->fuel->blog->config('asset_upload_path'); 53 | //use only fuel users not already chosen 54 | $where = (!empty($values['fuel_user_id'])) ? array('fuel_user_id !=' => $values['fuel_user_id']) : array(); 55 | $already_used = array_keys($this->options_list('fuel_user_id', 'display_name', $where)); 56 | if (!empty($already_used)) 57 | { 58 | $CI->fuel_users_model->db()->where_not_in('id', $already_used); 59 | } 60 | 61 | 62 | $options = $CI->fuel_users_model->options_list(); 63 | $upload_image_path = assets_server_path($CI->fuel->blog->settings('asset_upload_path')); 64 | $fields['fuel_user_id'] = array('label' => 'User', 'type' => 'select', 'options' => $options, 'module' => 'users', 'required' => TRUE); 65 | 66 | $socialfields = $this->fuel->blog->config('social_media'); 67 | $fields['social_media_links'] = array('ignore_representative' => TRUE, 68 | 'type' => 'template', 69 | 'repeatable' => TRUE, 70 | 'fields' => array( 71 | 'link' => array(), 72 | 'type' => array('type' => 'select', 'options' => $socialfields), 73 | )); 74 | return $fields; 75 | } 76 | 77 | function on_before_clean($values = array()) 78 | { 79 | if (!(int) $values['date_added']) 80 | { 81 | $values['date_added'] = datetime_now(); 82 | } 83 | return $values; 84 | } 85 | 86 | function _common_query($display_unpublished_if_logged_in = NULL) 87 | { 88 | parent::_common_query($display_unpublished_if_logged_in); 89 | $this->db->select($this->_tables['blog_users'].'.*, CONCAT(first_name, " ", last_name) as name, '.$this->_tables['fuel_users'].'.first_name, '.$this->_tables['fuel_users'].'.last_name, '.$this->_tables['fuel_users'].'.email, '.$this->_tables['fuel_users'].'.user_name, '.$this->_tables['fuel_users'].'.active as users_active', FALSE); 90 | $this->db->select('posts_count'); // for temp table to get posts count 91 | $this->db->group_by($this->_tables['fuel_users'].'.id, '.$this->_tables['blog_users'].'.id, temp.posts_count'); 92 | } 93 | 94 | function _common_joins() 95 | { 96 | $this->db->join($this->_tables['fuel_users'], $this->_tables['fuel_users'].'.id = '.$this->_tables['blog_users'].'.fuel_user_id', 'left'); 97 | //$this->db->join('fuel_blog_posts', $this->_tables['blog_posts'].'.author_id = '.$this->_tables['fuel_users'].'.id', 'left'); // left or inner???? 98 | $this->db->join('(SELECT COUNT(*) AS posts_count, '.$this->_tables['blog_posts'].'.author_id FROM '.$this->_tables['blog_posts'].' GROUP BY '.$this->_tables['blog_posts'].'.author_id) AS temp', 'temp.author_id= fuel_users.id', 'left'); 99 | } 100 | 101 | } 102 | 103 | class Blog_user_model extends Base_module_record { 104 | 105 | public $user_id; 106 | public $first_name; 107 | public $last_name; 108 | public $name; 109 | public $email; 110 | public $user_name; 111 | public $active; 112 | public $posts_count; 113 | 114 | protected $_parsed_fields = array('about'); 115 | 116 | function get_url() 117 | { 118 | return $this->_CI->fuel_blog->url('authors/'.$this->fuel_user_id); 119 | } 120 | 121 | function get_website_link() 122 | { 123 | return ''.$this->website.''; 124 | } 125 | 126 | function get_posts() 127 | { 128 | $params['order_by'] ='publish_date desc'; 129 | return $this->lazy_load(array($this->_parent_model->tables('blog_posts').'.author_id' => $this->fuel_user_id, $this->_parent_model->tables('blog_posts').'.published' => 'yes'), array(BLOG_FOLDER => 'blog_posts_model'), TRUE, $params); 130 | } 131 | 132 | function get_posts_url($full_path = TRUE) 133 | { 134 | $url = 'authors/posts/'.$this->fuel_user_id; 135 | if ($full_path) 136 | { 137 | return $this->_CI->fuel_blog->url($url); 138 | } 139 | return $url; 140 | } 141 | 142 | function get_avatar_image_path() 143 | { 144 | $path = $this->_CI->fuel->blog->config('asset_upload_path').$this->avatar_image; 145 | return assets_path($path); 146 | } 147 | 148 | function get_avatar_img_tag($attrs = array()) 149 | { 150 | $CI =& get_instance(); 151 | $CI->load->helper('html'); 152 | $src = $this->get_avatar_image_path(); 153 | $attrs = html_attrs($attrs); 154 | if (!empty($this->avatar_image)) 155 | { 156 | return ''; 157 | } 158 | return ''; 159 | } 160 | 161 | function get_about_excerpt() 162 | { 163 | $content = (empty($this->_fields['about_excerpt'])) ? $this->_fields['about'] : $this->_fields['about_excerpt']; 164 | $content = $this->_parse($content); 165 | return $content; 166 | } 167 | 168 | function get_about_excerpt_formatted() 169 | { 170 | $this->_CI->load->helper('typography'); 171 | return auto_typography($this->get_about_excerpt()); 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /models/Blog_tags_model.php: -------------------------------------------------------------------------------- 1 | array('name' => 'url_title')); 11 | 12 | public $belongs_to = array( 13 | 'posts' => array('model' => array(BLOG_FOLDER => 'blog_posts_model'), 'where' => 'language = "{language}" OR language = ""') 14 | ); 15 | 16 | function __construct() 17 | { 18 | parent::__construct('blog_tags', BLOG_FOLDER); // table name 19 | } 20 | 21 | // used for the FUEL admin 22 | function list_items($limit = NULL, $offset = NULL, $col = 'name', $order = 'asc', $just_count = FALSE) 23 | { 24 | $this->db->where(array('id !=' => 1)); // Uncategorized category 25 | 26 | if ($this->fuel->language->has_multiple()) 27 | { 28 | $this->db->select('id, name, precedence, language, published'); 29 | } 30 | else 31 | { 32 | $this->db->select('id, name, precedence, published'); 33 | } 34 | 35 | $data = parent::list_items($limit, $offset, $col, $order, $just_count); 36 | return $data; 37 | } 38 | 39 | function on_before_clean($values) 40 | { 41 | if (empty($values['slug']) && !empty($values['name'])) $values['slug'] = url_title($values['name'], 'dash', TRUE); 42 | return $values; 43 | } 44 | 45 | // check if it is the "Uncategorized" category so we don't delete it' 46 | function on_before_delete($where) 47 | { 48 | $CI =& get_instance(); 49 | $CI->load->module_language('blog', 'blog'); 50 | if (is_array($where) && isset($where['id'])) 51 | { 52 | if ($where['id'] == 1) 53 | { 54 | $this->add_error(lang('blog_error_delete_uncategorized')); 55 | $CI->session->set_flashdata('error', lang('blog_error_delete_uncategorized')); 56 | return; 57 | } 58 | } 59 | } 60 | 61 | function form_fields($values = array(), $related = array()) 62 | { 63 | $fields = parent::form_fields($values, $related); 64 | 65 | // set language field 66 | $fields['language'] = array('type' => 'select', 'options' => $this->fuel->language->options(), 'value' => $this->fuel->language->default_option(), 'hide_if_one' => TRUE); 67 | $fields['description']['editor'] = FALSE; 68 | return $fields; 69 | } 70 | 71 | function _common_query($display_unpublished_if_logged_in = NULL) 72 | { 73 | parent::_common_query(); 74 | $this->db->join($this->_tables['fuel_categories'], $this->_tables['fuel_categories'].'.id = '.$this->_tables['fuel_tags'].'.category_id', 'LEFT'); 75 | $this->db->order_by('precedence, name asc'); 76 | } 77 | 78 | function get_published_tags($language = NULL) 79 | { 80 | $CI =& get_instance(); 81 | $published_tags = $CI->fuel->blog->model('blog_posts')->get_related_keys('tags', array(), $CI->fuel->blog->model('posts')->has_many['tags'], 'has_many'); 82 | 83 | //$published_categories = $this->get_related_keys(array(), $this->belongs_to['posts'], 'belongs_to'); 84 | $tags_query_params = array(); 85 | if (!empty($published_tags)) 86 | { 87 | $tags_query_params = array('where_in' => array($this->table_name.'.id' => $published_tags), 'where' => $this->table_name.'.published = "yes"'); 88 | if (!empty($language)) 89 | { 90 | $tags_query_params['where'] .= ' AND '.$this->table_name.'.language="'.$language.'" OR '.$this->table_name.'.language=""'; 91 | } 92 | $tags_query = $this->query($tags_query_params); 93 | return $tags_query->result(); 94 | } 95 | return array(); 96 | } 97 | 98 | function options_list($key = NULL, $val = NULL, $where = array(), $order = TRUE) 99 | { 100 | $this->db->join($this->_tables['fuel_categories'], $this->_tables['fuel_categories'].'.id = '.$this->_tables['fuel_tags'].'.category_id', 'LEFT'); 101 | 102 | // if (empty($key)) $key = $this->_tables['fuel_categories'].'.id'; 103 | // if (empty($val)) $val = $this->_tables['fuel_categories'].'.name'; 104 | if (empty($key)) $key = $this->_tables['fuel_tags'].'.id'; 105 | if (empty($val)) $val = $this->_tables['fuel_tags'].'.name'; 106 | 107 | // needed to prevent ambiguity 108 | if (strpos($key, '.') === FALSE AND strpos($key, '(') === FALSE) 109 | { 110 | $key = $this->_tables['fuel_tags'].'.'.$key; 111 | } 112 | 113 | // needed to prevent ambiguity 114 | if (strpos($val, '.') === FALSE AND strpos($val, '(') === FALSE) 115 | { 116 | $val = $this->_tables['fuel_tags'].'.'.$val; 117 | } 118 | 119 | $options = parent::options_list($key, $val, $where, $order); 120 | return $options; 121 | } 122 | 123 | function ajax_options($where = array()) 124 | { 125 | if (!empty($where['language'])) 126 | { 127 | $this->db->where($where); 128 | $this->db->or_where('language = ""'); 129 | $options = $this->options_list(); 130 | } 131 | else 132 | { 133 | $options = $this->options_list(NULL, NULL, $where); 134 | } 135 | $str = ''; 136 | foreach($options as $key => $val) 137 | { 138 | $str .= "\n"; 139 | } 140 | return $str; 141 | } 142 | } 143 | 144 | class Blog_tag_model extends Base_module_record { 145 | 146 | protected $_tables; 147 | protected $_tag_posts; 148 | 149 | function on_init() 150 | { 151 | $this->_tables = $this->_CI->config->item('tables'); 152 | } 153 | 154 | protected function _get_tag_posts() 155 | { 156 | if (empty($this->_tag_posts)) 157 | { 158 | $this->_tag_posts = $this->_parent_model->get_related_keys('posts', array('id' => $this->id), $this->_parent_model->belongs_to['posts'], 'belongs_to', $this->_parent_model->table_name()); 159 | } 160 | return $this->_tag_posts; 161 | } 162 | 163 | function get_posts() 164 | { 165 | $this->_CI->load->module_model(BLOG_FOLDER, 'blog_posts_model'); 166 | $cat_posts = $this->_get_tag_posts(); 167 | if (empty($cat_posts)) return array(); 168 | 169 | $category_posts_query_params = array('where_in' => array($this->_tables['blog_posts'].'.id' => $cat_posts)); 170 | $posts = $this->_CI->blog_posts_model->query($category_posts_query_params); 171 | return $posts->result(); 172 | } 173 | 174 | function get_posts_count() 175 | { 176 | //return sizeof($this->_get_tag_posts()); 177 | $blog_posts_model = $this->_get_relationship('posts', TRUE, 'belongs_to'); 178 | if ($blog_posts_model) 179 | { 180 | $where = array('published' => 'yes'); 181 | $count = $blog_posts_model->record_count($where); 182 | return $count; 183 | } 184 | return 0; 185 | } 186 | 187 | function get_url($full_path = TRUE) 188 | { 189 | $url = 'tags/'.$this->slug; 190 | if ($full_path) 191 | { 192 | return $this->_CI->fuel_blog->url($url); 193 | } 194 | return $url; 195 | } 196 | 197 | } 198 | -------------------------------------------------------------------------------- /libraries/Captcha.php: -------------------------------------------------------------------------------- 1 | 6 | Source Link : http://gscripts.net/free-php-scripts/Anti_Spam_Scripts/Image_Validator/details.html 7 | 8 | CodeIgniter library created by : 9 | Mohammad Amzad Hossain 10 | http://tohin.wordpress.com 11 | 12 | 13 | License: Have Fun 14 | 15 | # How To Use In CodeIgniter 16 | 17 | // First Store Some fonts in fonts folder 18 | // You can choose a font_name by overriding default value or this 19 | // will randomly select a font. 20 | 21 | 22 | // In Controller 23 | 24 | $this->load->library('antispam'); 25 | $configs = array( 26 | 'img_path' => './captcha/', 27 | 'img_url' => base_url() . 'captcha/', 28 | 'img_height' => '50', 29 | ); 30 | $captcha = $this->antispam->get_antispam_image($configs); 31 | 32 | // $captcha is an array exmaple 33 | // array('word' => 'sfsdf', 'time' => time , 'image' => ' $value) { 88 | 89 | if( isset( $this->$key )) 90 | $this->$key = $value; 91 | } 92 | } 93 | 94 | $this->clean_dir(); 95 | 96 | $this->line_colors = preg_split("/,\s*?/", $this->line_color ); 97 | $this->char_colors = preg_split("/,\s*?/", $this->char_color ); 98 | 99 | $this->fonts = $this->collect_files( $this->font_path, "ttf"); 100 | 101 | 102 | $img = imagecreatetruecolor( $this->img_width, $this->img_height); 103 | imagefilledrectangle($img, 0, 0, $this->img_width - 1, $this->img_height - 1, $this->gd_color( $this->bg_color )); 104 | 105 | 106 | // Draw lines 107 | for ($i = 0; $i < $this->line_count; $i++) 108 | imageline($img, 109 | rand(0, $this->img_width - 1), 110 | rand(0, $this->img_height - 1), 111 | rand(0, $this->img_width - 1), 112 | rand(0, $this->img_height - 1), 113 | $this->gd_color($this->line_colors[rand(0, count($this->line_colors) - 1)]) 114 | ); 115 | 116 | // Draw code 117 | 118 | $code = ""; 119 | $y = ($this->img_height / 2) + ( $this->font_size / 2); 120 | 121 | $char_length = (!empty($this->word)) ? strlen($this->word) : $this->char_length; 122 | 123 | for ($i = 0; $i < $char_length ; $i++) { 124 | 125 | $color = $this->gd_color( $this->char_colors[rand(0, count($this->char_colors) - 1)] ); 126 | $angle = rand(-30, 30); 127 | 128 | if (!empty($this->word)) 129 | { 130 | $char = substr($this->word, $i, 1); 131 | } 132 | else 133 | { 134 | $char = substr( $this->char_set, rand(0, strlen($this->char_set) - 1), 1); 135 | } 136 | 137 | $sel_font = $this->font_name; 138 | 139 | if( $this->font_name == FALSE ) 140 | $sel_font = $this->fonts[rand(0, count($this->fonts) - 1)]; 141 | 142 | 143 | 144 | $font = $this->font_path . "/" . $sel_font; 145 | 146 | $use_font = ($font != '' && file_exists($font) AND function_exists('imagettftext')) ? TRUE : FALSE; 147 | 148 | 149 | $x = (intval(( $this->img_width / $this->char_length) * $i) + ( $this->font_size / 2)); 150 | $code .= $char; 151 | 152 | 153 | if ($use_font == FALSE) 154 | { 155 | $y = rand(0 , $this->img_height/2); 156 | imagestring($img, $this->font_size, $x, $y, substr($this->word, $i, 1), $color); 157 | } 158 | else 159 | { 160 | imagettftext($img, $this->font_size, $angle, $x, $y, $color, $font, $char); 161 | } 162 | } 163 | 164 | // Storing Image 165 | 166 | list($usec, $sec) = explode(" ", microtime()); 167 | $now = ((float)$usec + (float)$sec); 168 | 169 | $img_name = $now . '.jpg'; 170 | 171 | ImageJPEG( $img, $this->img_path.$img_name); 172 | 173 | $img_markup = ' '; 175 | 176 | ImageDestroy($img); 177 | 178 | return array('word' => $code, 'time' => $now, 'image' => $img_markup); 179 | 180 | } 181 | 182 | 183 | function gd_color($html_color) { 184 | return preg_match('/^#?([\dA-F]{6})$/i', $html_color, $rgb) 185 | ? hexdec($rgb[1]) : false; 186 | } 187 | 188 | 189 | function collect_files($dir, $ext) { 190 | if (false !== ($dir = opendir($dir))) { 191 | $files = array(); 192 | 193 | while (false !== ($file = readdir($dir))) 194 | if (preg_match("/\\.$ext\$/i", $file)) 195 | $files[] = $file; 196 | 197 | return $files; 198 | 199 | } else 200 | return false; 201 | } 202 | 203 | function clean_dir() 204 | { 205 | list($usec, $sec) = explode(" ", microtime()); 206 | $now = ((float)$usec + (float)$sec); 207 | 208 | $current_dir = @opendir($this->img_path); 209 | 210 | while($filename = @readdir($current_dir)) 211 | { 212 | if ($filename != "." and $filename != ".." and $filename != "index.html") 213 | { 214 | 215 | $name = str_replace(".jpg", "", $filename); 216 | 217 | if (($name + $this->expiration) < $now) 218 | { 219 | @unlink($this->img_path.$filename); 220 | } 221 | } 222 | } 223 | 224 | @closedir($current_dir); 225 | } 226 | 227 | 228 | 229 | } 230 | -------------------------------------------------------------------------------- /libraries/Akismet.php: -------------------------------------------------------------------------------- 1 | $value) 47 | { 48 | $this->$key = $value; 49 | } 50 | 51 | $this->set_comment($this->comment); 52 | 53 | $this->_connect(); 54 | 55 | if($this->errors_exist()) 56 | { 57 | $this->errors = array_merge($this->errors, $this->get_errors()); 58 | } 59 | 60 | // Check if the API key is valid 61 | if(!$this->_is_valid_api_key($this->api_key)) 62 | { 63 | $this->set_error('AKISMET_INVALID_KEY', "Your Akismet API key is not valid."); 64 | } 65 | } 66 | 67 | // Connect to the Akismet server and store that connection in the instance variable $con 68 | function _connect() 69 | { 70 | if(!($this->con = @fsockopen($this->akismet_server, $this->api_port))) 71 | { 72 | $this->set_error('AKISMET_SERVER_NOT_FOUND', "Could not connect to akismet server."); 73 | } 74 | } 75 | 76 | // Close the connection to the Akismet server 77 | function _disconnect() 78 | { 79 | @fclose($this->con); 80 | } 81 | 82 | function get_response($request, $path, $type = "post", $response_length = 1160) 83 | { 84 | $this->_connect(); 85 | 86 | if($this->con && !$this->is_error('AKISMET_SERVER_NOT_FOUND')) 87 | { 88 | $request = 89 | strtoupper($type)." /{$this->akismet_version}/$path HTTP/1.0\r\n" . 90 | "Host: ".((!empty($this->api_key)) ? $this->api_key."." : null)."{$this->akismet_server}\r\n" . 91 | "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" . 92 | "Content-Length: ".strlen($request)."\r\n" . 93 | "User-Agent: Akismet CodeIgniter Library\r\n" . 94 | "\r\n" . 95 | $request 96 | ; 97 | $response = ""; 98 | 99 | @fwrite($this->con, $request); 100 | 101 | while(!feof($this->con)) 102 | { 103 | $response .= @fgets($this->con, $response_length); 104 | } 105 | 106 | $response = explode("\r\n\r\n", $response, 2); 107 | return $response[1]; 108 | } 109 | else 110 | { 111 | $this->set_error('AKISMET_RESPONSE_FAILED', "The response could not be retrieved."); 112 | } 113 | 114 | $this->_disconnect(); 115 | } 116 | 117 | function set_error($name, $message) 118 | { 119 | $this->errors[$name] = $message; 120 | } 121 | 122 | function get_error($name) 123 | { 124 | if($this->is_error($name)) 125 | { 126 | return $this->errors[$name]; 127 | } 128 | else 129 | { 130 | return false; 131 | } 132 | } 133 | 134 | function get_errors() 135 | { 136 | return (array)$this->errors; 137 | } 138 | 139 | function is_error($name) 140 | { 141 | return isset($this->errors[$name]); 142 | } 143 | 144 | function errors_exist() 145 | { 146 | return (count($this->errors) > 0); 147 | } 148 | 149 | function is_spam() 150 | { 151 | $response = $this->get_response($this->_get_query_string(), 'comment-check'); 152 | 153 | return ($response == "true"); 154 | } 155 | 156 | 157 | function submit_spam() 158 | { 159 | $this->get_response($this->_get_query_string(), 'submit-spam'); 160 | } 161 | 162 | 163 | function submit_ham() 164 | { 165 | $this->get_response($this->_get_query_string(), 'submit-ham'); 166 | } 167 | 168 | function set_comment($comment) 169 | { 170 | $this->comment = $comment; 171 | 172 | if(!empty($comment)) 173 | { 174 | $this->_format_comment_array(); 175 | $this->_fill_comment_values(); 176 | } 177 | } 178 | 179 | function get_comment() 180 | { 181 | return $this->comment; 182 | } 183 | 184 | function _is_valid_api_key($key) 185 | { 186 | $key_check = $this->get_response("key=".$this->api_key."&blog=".$this->blog_url, 'verify-key'); 187 | 188 | return ($key_check == "valid"); 189 | } 190 | 191 | function _format_comment_array() { 192 | 193 | $format = array( 194 | 'type' => 'comment_type', 195 | 'author' => 'comment_author', 196 | 'email' => 'comment_author_email', 197 | 'website' => 'comment_author_url', 198 | 'body' => 'comment_content' 199 | ); 200 | 201 | foreach($format as $short => $long) 202 | { 203 | if(isset($this->comment[$short])) 204 | { 205 | $this->comment[$long] = $this->comment[$short]; 206 | unset($this->comment[$short]); 207 | } 208 | } 209 | } 210 | 211 | 212 | /** 213 | * Fill any values not provided by the developer with available values. 214 | * 215 | * @return void 216 | */ 217 | 218 | function _fill_comment_values() 219 | { 220 | if(!isset($this->comment['user_ip'])) 221 | { 222 | $this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR'); 223 | } 224 | 225 | if(!isset($this->comment['user_agent'])) 226 | { 227 | $this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT']; 228 | } 229 | 230 | if(!isset($this->comment['referrer']) && !empty($_SERVER['HTTP_REFERER'])) 231 | { 232 | $this->comment['referrer'] = $_SERVER['HTTP_REFERER']; 233 | } 234 | 235 | if(!isset($this->comment['blog'])) 236 | { 237 | $this->comment['blog'] = $this->blog_url; 238 | } 239 | } 240 | 241 | 242 | function _get_query_string() 243 | { 244 | foreach($_SERVER as $key => $value) 245 | { 246 | if(!in_array($key, $this->ignore)) 247 | { 248 | if($key == 'REMOTE_ADDR') 249 | { 250 | $this->comment[$key] = $this->comment['user_ip']; 251 | } 252 | else 253 | { 254 | $this->comment[$key] = $value; 255 | } 256 | } 257 | } 258 | 259 | $query_string = ''; 260 | 261 | foreach($this->comment as $key => $data) 262 | { 263 | $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&'; 264 | } 265 | 266 | return $query_string; 267 | } 268 | } 269 | 270 | ?> 271 | -------------------------------------------------------------------------------- /libraries/Stopforumspam.php: -------------------------------------------------------------------------------- 1 | _config = $this->fuel->blog->config('stopforumspam'); 49 | } 50 | 51 | /** 52 | * Performs CURL request to stopforumspam.com and checks results to determine if the data sent is SPAM or not. Returns TRUE/FALSE. 53 | * 54 | * @access public 55 | * @param array The array should contain keys of "ip", "username" and "email" 56 | * @return boolean 57 | */ 58 | public function check($data) 59 | { 60 | $this->CI->load->library('curl'); 61 | $this->CI->load->helper('array'); 62 | 63 | // make the request 64 | $get = array(); 65 | 66 | if (isset($data['ip'])) 67 | { 68 | $add_ip = TRUE; 69 | 70 | // don't check against the localhost 71 | foreach ($this->localhost_ips as $local_cidr) 72 | { 73 | if (self::cidr_check($data['ip'], $local_cidr)) 74 | { 75 | $add_ip = FALSE; 76 | break; 77 | } 78 | } 79 | 80 | if ($add_ip) 81 | { 82 | $get['ip'] = $data['ip']; 83 | } 84 | } 85 | 86 | if (isset($data['username'])) 87 | { 88 | $get['username'] = $data['username']; 89 | } 90 | 91 | if (isset($data['email'])) 92 | { 93 | $get['email'] = $data['email']; 94 | } 95 | 96 | if (empty($get)) 97 | { 98 | return FALSE; 99 | } 100 | 101 | $get['f'] = 'json'; 102 | 103 | $url = $this->url."?" . http_build_query($get); 104 | 105 | $opts = array( 106 | 'CURLOPT_RETURNTRANSFER' => TRUE, 107 | 'CURLOPT_TIMEOUT' => 4, 108 | 'CURLOPT_FAILONERROR' => 1, 109 | ); 110 | $this->CI->curl->add_session($url, $opts); 111 | $result = $this->CI->curl->exec(); 112 | 113 | if (!$this->CI->curl->has_error()) 114 | { 115 | if (empty($result)) 116 | { 117 | $this->_add_error(lang('error_curl_page')); 118 | } 119 | else 120 | { 121 | $this->_result = json_decode($result, TRUE); 122 | 123 | $is_spam = FALSE; 124 | 125 | if (isset($this->_result['error'])) 126 | { 127 | $this->_add_error($result['error']); 128 | } 129 | else 130 | { 131 | 132 | $this->_ip_frequency = $this->result('ip.frequency', 0); 133 | $this->_email_frequency = $this->result('email.frequency', 0); 134 | 135 | // Flag registrations as spam above a certain threshold. 136 | if ($this->is_above_threshold()) 137 | { 138 | $is_spam = TRUE; 139 | } 140 | } 141 | return $is_spam; 142 | } 143 | } 144 | else 145 | { 146 | $this->_add_error($this->CI->curl->error(0)); 147 | return FALSE; 148 | } 149 | } 150 | 151 | /** 152 | * Returns TRUE/FALSE depending on if the SPAM score is above the specified threshold and should be considered SPAM (but possibly monitored as such). 153 | * 154 | * @access public 155 | * @param string The IP frequency threshold to check (optional) 156 | * @param mixed The email frequency threshold to check (optional) 157 | * @return boolean 158 | */ 159 | public function is_above_threshold($ip_frequency = NULL, $email_frequency = NULL) 160 | { 161 | if (is_null($ip_frequency)) 162 | { 163 | $ip_frequency = $this->result('ip.frequency', 0); 164 | } 165 | if (is_null($email_frequency)) 166 | { 167 | $email_frequency = $this->result('email.frequency', 0); 168 | } 169 | 170 | if ($ip_frequency >= $this->config('ip_threshold_flag') || $email_frequency >= $this->config('email_threshold_flag')) 171 | { 172 | return TRUE; 173 | } 174 | return FALSE; 175 | } 176 | 177 | /** 178 | * Returns TRUE/FALSE depending on if the SPAM score is so high based on the configuration values set that it should just be ignored and is definitely SPAM. 179 | * 180 | * @access public 181 | * @param string The IP frequency threshold to check (optional) 182 | * @param mixed The email frequency threshold to check (optional) 183 | * @return boolean 184 | */ 185 | public function is_ignorable($ip_frequency = NULL, $email_frequency = NULL) 186 | { 187 | if (is_null($ip_frequency)) 188 | { 189 | $ip_frequency = $this->result('ip.frequency', 0); 190 | } 191 | if (is_null($email_frequency)) 192 | { 193 | $email_frequency = $this->result('email.frequency', 0); 194 | } 195 | 196 | if ($ip_frequency >= $this->config('ip_threshold_ignore') || $email_frequency >= $this->config('email_threshold_ignore')) 197 | { 198 | return TRUE; 199 | } 200 | return FALSE; 201 | } 202 | 203 | /** 204 | * Returns the results from the check CURL request. 205 | * 206 | * @access public 207 | * @param string The path to the array value using dot notation (optional) 208 | * @param mixed The default value to use if not value exists at the specified key (optional) 209 | * @return array The complete curl results if no key is passed. If key is passed, it will return that specified key value 210 | */ 211 | public function result($key = NULL, $default = 0) 212 | { 213 | if (is_null($this->_result)) return NULL; 214 | 215 | if (isset($key)) 216 | { 217 | return array_get($this->_result, $key, $default); 218 | } 219 | else 220 | { 221 | return $this->_result; 222 | } 223 | } 224 | 225 | /** 226 | * Returns TRUE/FALSE depending on if a result exists yet. 227 | * 228 | * @access public 229 | * @return boolean 230 | */ 231 | public function has_result() 232 | { 233 | return !empty($this->result); 234 | } 235 | 236 | /** 237 | * Sets the configuration parameters such as the thresholds 'ip_threshold_flag', 'email_threshold_flag', 'ip_threshold_ignore', 'email_threshold_ignore' 238 | * 239 | * @access public 240 | * @return boolean 241 | */ 242 | public function set_config() 243 | { 244 | $this->_config = array_merge($this->_config, $config); 245 | return $this; 246 | } 247 | 248 | /** 249 | * Returns configuration value(s) for stopforumspam. 250 | * 251 | * @access public 252 | * @param string The config key value to return (optional) 253 | * @return mixed If no key value is supplied, the entire config array is returned 254 | */ 255 | public function config($key = NULL) 256 | { 257 | if (isset($key)) 258 | { 259 | if (isset($this->_config[$key])) 260 | { 261 | return $this->_config[$key]; 262 | } 263 | return FALSE; 264 | } 265 | return $this->_config; 266 | } 267 | 268 | /** 269 | * Returns a query string formatted 270 | * credit: claudiu(at)cnixs.com via php.net/manual/en/ref.network.php 271 | * 272 | * @access public 273 | * @param string The IP address to test 274 | * @param boolean The IP address list to test against 275 | * @return boolean 276 | */ 277 | static function cidr_check($ip, $cidr) 278 | { 279 | list ($net, $mask) = explode("/", $cidr); 280 | 281 | // Allow non-standard /0 syntax 282 | if ($mask == 0) 283 | { 284 | if (ip2long($ip) == ip2long($net)) 285 | { 286 | return TRUE; 287 | } 288 | else 289 | { 290 | return FALSE; 291 | } 292 | } 293 | 294 | $ip_net = ip2long ($net); 295 | $ip_mask = ~((1 << (32 - $mask)) - 1); 296 | 297 | $ip_ip = ip2long ($ip); 298 | 299 | $ip_ip_net = $ip_ip & $ip_mask; 300 | 301 | return ($ip_ip_net == $ip_net); 302 | } 303 | 304 | } 305 | -------------------------------------------------------------------------------- /language/english/blog_lang.php: -------------------------------------------------------------------------------- 1 | If you cannot read the text, refresh the page."; 100 | 101 | $lang['blog_comment_is_spam'] = "The comment posted cannot be submitted as is because it was flagged as spam."; 102 | $lang['blog_error_captcha_mismatch'] = "The text you inputted for the image did not match."; 103 | 104 | $lang['blog_email_flagged_as_spam'] = 'FLAGGED AS SPAM!!!'; 105 | $lang['blog_email_published'] = 'Published'; 106 | $lang['blog_email_author_name'] = 'Author Name'; 107 | $lang['blog_email_author_email'] = 'Author Email'; 108 | $lang['blog_email_author_website'] = 'Website'; 109 | $lang['blog_email_author_ip'] = 'Author IP'; 110 | $lang['blog_email_content'] = 'Content'; 111 | $lang['form_label_post_title'] = 'Post Title'; 112 | $lang['form_label_comment'] = 'Comment'; 113 | $lang['form_label_comment_author_name'] = 'Comment Author Name'; 114 | $lang['form_label_is_spam'] = 'Is Spam'; 115 | $lang['form_label_post_published'] = 'Post Published'; 116 | $lang['form_label_date_submitted'] = 'Date Submitted'; 117 | $lang['form_label_ip_host'] = 'IP/Host'; 118 | $lang['form_label_replies'] = 'Replies'; 119 | $lang['form_label_reply'] = 'Reply'; 120 | $lang['form_label_commentor'] = 'Commentor'; 121 | $lang['form_label_reply_notify'] = 'Notify'; 122 | $lang['form_label_author_ip'] = 'Author IP Address'; 123 | 124 | 125 | /* 126 | |-------------------------------------------------------------------------- 127 | | Settings 128 | |-------------------------------------------------------------------------- 129 | */ 130 | $lang['form_label_uri'] = 'URI'; 131 | $lang['form_label_theme_path'] = 'Theme Location'; 132 | $lang['form_label_theme_layout'] = 'Theme Layout'; 133 | $lang['form_label_theme_module'] = 'Theme module'; 134 | $lang['form_label_use_cache'] = 'Use Cache'; 135 | $lang['form_label_allow_comments'] = 'Allow Comments'; 136 | $lang['form_label_monitor_comments'] = 'Monitor Comments'; 137 | $lang['form_label_use_captchas'] = 'Use Captchas'; 138 | $lang['form_label_save_spam'] = 'Save Spam'; 139 | $lang['form_label_akismet_api_key'] = 'Akismet Key'; 140 | $lang['form_label_multiple_comment_submission_time_limit'] = 'Comment Submission Time Limit'; 141 | $lang['form_label_multiple_comment_submission_time_limit_after_html'] = ' (in seconds)'; 142 | $lang['form_label_comments_time_limit'] = 'Allow comments for how long'; 143 | $lang['form_label_comments_time_limit_after_html'] = ' after post date (in days)'; 144 | $lang['form_label_cache_ttl'] = 'Cache Time to Live'; 145 | $lang['form_label_asset_upload_path'] = 'Asset Upload Path'; 146 | $lang['form_label_per_page'] = 'Per Page'; 147 | $lang['form_label_page_title_separator'] = 'Page Title Separator'; 148 | $lang['form_label_email_notify_comment_reply'] = 'E-mail notifications on comment replies'; 149 | 150 | 151 | /* 152 | |-------------------------------------------------------------------------- 153 | | Front-end 154 | |-------------------------------------------------------------------------- 155 | */ 156 | $lang['blog_blog'] = 'Block'; 157 | $lang['blog_archives'] = 'Archives'; 158 | $lang['blog_categories'] = 'Categories'; 159 | $lang['blog_category_posts'] = '%1s Posts'; 160 | $lang['blog_tags'] = 'Tags'; 161 | $lang['blog_tags_posts'] = '%1s Posts'; 162 | $lang['blog_publish_date_format'] = 'F d, Y'; 163 | $lang['blog_post_published'] = 'Published'; 164 | $lang['blog_post_published_by'] = 'by'; 165 | $lang['blog_post_read_more'] = 'Read More'; 166 | $lang['blog_search'] = '%1s Search Result(s) Returned for “%2s”'; 167 | $lang['blog_pagination_all'] = 'Back to All Posts'; 168 | $lang['blog_pagination_next'] = 'Next'; 169 | $lang['blog_pagination_prev'] = 'Previous'; 170 | $lang['blog_comment_heading'] = 'Comment'; 171 | $lang['blog_leave_comment_heading'] = 'Leave a Comment'; 172 | $lang['blog_comments_off'] = 'Comments have been turned off for this post.'; 173 | $lang['blog_comment_thanks'] = 'Thanks for the comment'; 174 | $lang['blog_comments_monitored'] = 'Comments for this posting are being monitored and will be published upon the author\'s approval.'; 175 | $lang['blog_share'] = 'Share this post'; 176 | $lang['blog_related_posts'] = 'Related Posts'; 177 | $lang['blog_links'] = 'Featured Links'; 178 | $lang['blog_about_author'] = 'About Author'; 179 | $lang['blog_post_date_format'] = 'F j, Y'; 180 | -------------------------------------------------------------------------------- /models/Blog_comments_model.php: -------------------------------------------------------------------------------- 1 | 'Please fill out the required field Name', 8 | 'author_email' => 'Please fill out the required field Email', 9 | 'content' => 'Please fill out the required field Comment' 10 | ); 11 | public $hidden_fields = array('parent_id', 'last_modified'); 12 | 13 | function __construct() 14 | { 15 | parent::__construct('blog_comments', BLOG_FOLDER); // table name 16 | $this->add_validation('author_email', 'valid_email', lang('blog_error_invalid_comment_email')); 17 | $this->add_filter($this->_tables['blog_posts'].'.title'); 18 | } 19 | 20 | // used for the FUEL admin 21 | function list_items($limit = NULL, $offset = NULL, $col = 'date_added', $order = 'desc', $just_count = FALSE) 22 | { 23 | if ($col == 'date_added') $col = $this->_tables['blog_comments'].'.date_added'; 24 | $this->db->select($this->_tables['blog_comments'].'.id, title AS post_title, '.$this->_tables['blog_comments'].'.content AS comment, author_name AS comment_author_name, '.$this->_tables['blog_comments'].'.is_spam, '.$this->_tables['blog_comments'].'.date_added as date_submitted, '.$this->_tables['blog_comments'].'.published', FALSE); 25 | $this->db->join($this->_tables['blog_posts'], $this->_tables['blog_comments'].'.post_id = '.$this->_tables['blog_posts'].'.id', 'inner'); 26 | $data = parent::list_items($limit, $offset, $col, $order, $just_count); 27 | if (empty($just_count)) 28 | { 29 | foreach($data as $key => $val) 30 | { 31 | $data[$key]['date_submitted'] = english_date($data[$key]['date_submitted'], TRUE); 32 | } 33 | } 34 | return $data; 35 | } 36 | 37 | function tree($just_published = FALSE) 38 | { 39 | $CI =& get_instance(); 40 | $CI->load->module_model(BLOG_FOLDER, 'blog_posts_model'); 41 | $CI->load->helper('array'); 42 | 43 | $return = array(); 44 | 45 | $where = ($just_published) ? $where = array('published' => 'yes') : array(); 46 | $comments = $this->find_all($where, 'title asc'); 47 | foreach($comments as $comment) 48 | { 49 | if (!isset($return[$comment->post_id])) 50 | { 51 | $return['p_'.$comment->post_id] = array('id' => 'p_'.$comment->post_id, 'label' => $comment->title, 'location' => fuel_url('blog/posts/edit/'.$comment->post_id)); 52 | } 53 | $label = (!empty($comment->author_name)) ? $comment->author_name : $comment->author_email; 54 | $attributes = ($comment->published == 'no') ? array('class' => 'unpublished', 'title' => 'unpublished') : NULL; 55 | $return['c_'.$comment->id] = array('id' => $comment->id, 'label' => $label, 'parent_id' => 'p_'.$comment->post_id, 'location' => fuel_url('blog/posts/edit/'.$comment->post_id), 'attributes' => $attributes); 56 | } 57 | $return = array_sorter($return, 'label', 'asc'); 58 | return $return; 59 | } 60 | 61 | function form_fields($values = array(), $related = array()) 62 | { 63 | $fields = parent::form_fields($values, $related); 64 | $CI =& get_instance(); 65 | $CI->load->module_model(BLOG_FOLDER, 'blog_users_model'); 66 | $CI->load->module_model(BLOG_FOLDER, 'blog_posts_model'); 67 | 68 | $post_title = ''; 69 | 70 | $post_options = $CI->blog_posts_model->options_list('id', 'title', array(), 'publish_date desc'); 71 | if (empty($post_options)) 72 | { 73 | $fields = array(); 74 | $fields['error'] = array('type' => 'copy', 'value' => lang('blog_error_no_posts_to_comment')); 75 | $fields['__FORM_BUILDER__'] = array('submit_value' => ''); 76 | return $fields; 77 | } 78 | 79 | $fields['post_id'] = array('type' => 'select', 'options' => $post_options, 'label' => 'Post'); 80 | 81 | if (!empty($values['id'])) 82 | { 83 | $post = $CI->blog_posts_model->find_by_key($values['post_id']); 84 | if (isset($post->id)) 85 | { 86 | $post_title = $post->title; 87 | 88 | if (!$post->is_published()) 89 | { 90 | add_error(lang('blog_post_is_not_published')); 91 | } 92 | } 93 | 94 | $fields['post_id'] = array('type' => 'hidden', 'value' => $post_title, 'displayonly' => TRUE); 95 | 96 | $fields['post_title'] = array('value' => $post_title, 'order' => 1); 97 | 98 | $fields['post_title']['displayonly'] = TRUE; 99 | $fields['post_published']['displayonly'] = TRUE; 100 | $fields['author_email']['displayonly'] = TRUE; 101 | $fields['author_name']['displayonly'] = TRUE; 102 | $fields['post_title']['displayonly'] = TRUE; 103 | $fields['author_website']['displayonly'] = TRUE; 104 | $fields['ip_host']['displayonly'] = TRUE; 105 | $fields['date_submitted'] = array('displayonly' => TRUE, 'value' => english_date($values['date_added'], TRUE)); 106 | 107 | $ip_host = (!empty($values['author_ip'])) ? gethostbyaddr($values['author_ip']).' ('.$values['author_ip'].')' : ''; 108 | $fields['ip_host'] = array('value' => $ip_host, 'order' => 5, 'displayonly' => TRUE); 109 | 110 | $fields['Reply to this Comment'] = array('type' => 'section'); 111 | $replies = $this->find_all_array(array('parent_id' => $values['id'])); 112 | $reply_arr = array(); 113 | foreach($replies as $r) 114 | { 115 | $reply_arr[] = $r['content']; 116 | } 117 | $fields['replies'] = array('displayonly' => TRUE, 'value' => implode('

', $reply_arr)); 118 | 119 | // don't show the form if the email_notify_comment_reply setting is off 120 | // on_after_save checks if reply_notify has been posted before sending an email, so this will also stop the email from firing because of that 121 | if (isset($post->id) AND $post->author_id == $CI->fuel->auth->user_data('id') OR $CI->fuel->auth->is_super_admin()) 122 | { 123 | $fields['reply'] = array('type' => 'textarea'); 124 | if($CI->fuel->blog->config('email_notify_comment_reply')) { 125 | $notify_options = array('Commentor' => lang('blog_comment_notify_option2'), 'All' => lang('blog_comment_notify_option1'), 'None' => lang('blog_comment_notify_option3')); 126 | $fields['reply_notify'] = array('type' => 'enum', 'options' => $notify_options); 127 | } 128 | } 129 | 130 | // hidden 131 | $fields['author_ip'] = array('type' => 'hidden'); 132 | 133 | } 134 | else 135 | { 136 | $fields['author_ip'] = array('type' => 'hidden', 'value' => $_SERVER['REMOTE_ADDR'], 'label' => 'Author IP Address'); 137 | $fields['is_spam'] = array('type' => 'hidden'); 138 | $fields['date_added']['type'] = 'hidden'; // so it will auto add 139 | $fields['last_modified']['type'] = 'hidden'; // so it will auto add 140 | } 141 | 142 | // set author to current fuel user 143 | if (empty($fields['author_id']) AND $CI->fuel->auth->user_data('id')) 144 | { 145 | $fields['author_id']['value'] = $CI->fuel->auth->user_data('id'); 146 | } 147 | $fields['author_id'] = array('type' => 'hidden'); 148 | return $fields; 149 | } 150 | 151 | // need to notify commentor if author or admin comment 152 | function on_after_save($values) 153 | { 154 | 155 | $posted = $this->normalized_save_data; 156 | $CI =& get_instance(); 157 | $CI->load->module_model(BLOG_FOLDER, 'blog_posts_model'); 158 | $CI->load->module_model(BLOG_FOLDER, 'blog_users_model'); 159 | $post = $CI->blog_posts_model->find_by_key($posted['post_id']); 160 | // must be logged into FUEL, must be the author, must be in the admin pages, must have reply posted and be published 161 | if ($CI->fuel->auth->is_logged_in() AND ($post->author_id == $CI->fuel->auth->user_data('id') 162 | OR $CI->fuel->auth->is_super_admin()) AND in_fuel_admin() AND !empty($posted['reply']) 163 | ) 164 | { 165 | $comment = $this->create(); 166 | $comment->post_id = $post->id; 167 | $comment->parent_id = $values['id']; 168 | $comment->author_id = $CI->fuel->auth->user_data('id'); 169 | 170 | $user = $CI->blog_users_model->find_one(array('fuel_user_id' => $CI->fuel->auth->user_data('id'))); 171 | $display_name = ($user->has_display_name()) ? $user->display_name : $user->first_name.' '.$user->last_name; 172 | $comment->author_name = $display_name; 173 | $comment->author_email = $user->email; 174 | $comment->author_website = ''; 175 | $comment->author_ip = $_SERVER['REMOTE_ADDR']; 176 | $comment->content = trim($this->input->post('reply', TRUE)); 177 | $comment->date_added = NULL; // will automatically be added 178 | if (!empty($posted['reply_notify']) AND strtolower($posted['reply_notify']) != 'none' AND $comment->validate()) 179 | { 180 | // create comment object 181 | $config['wordwrap'] = TRUE; 182 | $CI->load->library('email', $config); 183 | $CI->load->module_library(BLOG_FOLDER, 'fuel_blog'); 184 | $CI->load->module_model(BLOG_FOLDER, 'blog_comments_model'); 185 | 186 | if (strtolower($posted['reply_notify']) == 'all') 187 | { 188 | $comments = $CI->blog_comments_model->find_all_array_assoc('author_email', array('published' => 'yes', 'post_id' => $comment->post_id)); 189 | $to = array_keys($comments); 190 | } 191 | else 192 | { 193 | $to = $values['author_email']; 194 | } 195 | 196 | // send email 197 | $CI->email->from($this->config->item('from_email', 'fuel'), $this->config->item('site_name', 'fuel')); 198 | $CI->email->to($to); 199 | $msg = $CI->email->subject(lang('blog_comment_reply_subject', $this->fuel->blog->config('title'))); 200 | $msg = lang('blog_comment_reply_msg', $CI->fuel->auth->user_data('email'), $post->title); 201 | $msg .= "\n\n".$comment->content; 202 | $msg .= "\n\n".$post->url."\n\n"; 203 | 204 | $this->email->message($msg); 205 | 206 | if (!$this->email->send()) 207 | { 208 | $this->add_error(lang('error_sending_email', $values['author_email'])); 209 | } 210 | } 211 | $comment->save(); 212 | 213 | } 214 | 215 | return $values; 216 | } 217 | 218 | function _common_query($display_unpublished_if_logged_in = NULL) 219 | { 220 | $this->db->select($this->_tables['blog_comments'].'.*, '.$this->_tables['blog_posts'].'.id as post_id, 221 | '.$this->_tables['blog_posts'].'.title as title, '.$this->_tables['blog_posts'].'.slug as slug, 222 | '.$this->_tables['blog_posts'].'.published AS post_published', FALSE); 223 | $this->db->select('YEAR('.$this->_tables['blog_posts'].'.publish_date) as year, DATE_FORMAT('.$this->_tables['blog_posts'].'.publish_date, "%m") as month, DATE_FORMAT('.$this->_tables['blog_posts'].'.publish_date, "%d") as day,', FALSE); 224 | $this->db->join($this->_tables['blog_posts'], $this->_tables['blog_comments'].'.post_id = '.$this->_tables['blog_posts'].'.id', 'inner'); 225 | } 226 | 227 | } 228 | 229 | class Blog_comment_model extends Base_module_record { 230 | 231 | public $title; 232 | public $slug; 233 | public $spam_checked = FALSE; 234 | 235 | // not using filtered fields because we don't want any PHP function translation' 236 | function get_content_formatted() 237 | { 238 | $this->_CI->load->helper('typography'); 239 | $output = auto_typography($this->_fields['content']); 240 | return $output; 241 | } 242 | 243 | function get_post() 244 | { 245 | $model = $this->_CI->fuel->blog->model('blog_posts'); 246 | return $model->find_by_key($this->post_id); 247 | } 248 | 249 | function is_duplicate() 250 | { 251 | $where['UPPER('.$this->_parent_model->tables('blog_comments').'.content)'] = strtoupper($this->content); 252 | $where['author_ip'] = $this->author_ip; 253 | $cnt = $this->_parent_model->record_count($where); 254 | return ($cnt > 0); 255 | } 256 | 257 | function is_by_post_author() 258 | { 259 | $post = $this->post; 260 | return (!empty($this->author_id) AND $post->author->id == $this->author_id); 261 | } 262 | 263 | function is_child() 264 | { 265 | return (!empty($this->parent_id)); 266 | } 267 | 268 | function get_author_and_link() 269 | { 270 | if (!empty($this->author_website)) 271 | { 272 | return anchor(prep_url($this->author_website), $this->author_name); 273 | } 274 | else 275 | { 276 | return $this->author_name; 277 | } 278 | } 279 | 280 | function get_date_formatted($format = 'M d, Y') 281 | { 282 | return date($format, strtotime($this->date_added)); 283 | } 284 | 285 | function is_spam() 286 | { 287 | if (!$this->spam_checked) 288 | { 289 | $this->check_is_spam(); 290 | } 291 | return is_true_val($this->_fields['is_spam']); 292 | } 293 | 294 | function check_is_spam() 295 | { 296 | $this->is_spam = ($this->_CI->fuel->blog->is_spam($this)) ? 'yes' : 'no'; 297 | $this->spam_checked = TRUE; 298 | return $this->is_spam; 299 | } 300 | 301 | function is_savable() 302 | { 303 | if (!isset($this->_CI->stopforumspam)) 304 | { 305 | $this->_CI->load->module_library(BLOG_FOLDER, 'stopforumspam'); 306 | } 307 | 308 | // if this has not been spam checked, we do so 309 | if (!$this->spam_checked) 310 | { 311 | $this->check_is_spam(); 312 | } 313 | 314 | if ($this->_CI->stopforumspam->is_ignorable()) 315 | { 316 | return FALSE; 317 | } 318 | 319 | return !$this->is_spam() OR ($this->is_spam() AND $this->_CI->fuel->blog->config('save_spam')); 320 | } 321 | 322 | } 323 | ?> -------------------------------------------------------------------------------- /controllers/Blog.php: -------------------------------------------------------------------------------- 1 | fuel->blog->uri_segment(2) != 'index') ? (int) $this->fuel->blog->uri_segment(2) : NULL; 15 | $month = (int) $this->fuel->blog->uri_segment(3); 16 | $day = (int) $this->fuel->blog->uri_segment(4); 17 | $slug = $this->fuel->blog->uri_segment(5); 18 | 19 | $view_by = 'page'; 20 | 21 | // if the first segment is id then treat the second segment as the id 22 | if ($this->fuel->blog->uri_segment(2) === 'id' && $this->fuel->blog->uri_segment(3)) 23 | { 24 | $view_by = 'slug'; 25 | $slug = (int) $this->fuel->blog->uri_segment(3); 26 | $post = $this->fuel->blog->get_post($slug); 27 | 28 | if (isset($post->id)) 29 | { 30 | redirect($post->url); 31 | } 32 | } 33 | // if the first segment is comment_reply 34 | else if ($this->fuel->blog->uri_segment(2) === 'comment_reply' AND $this->fuel->blog->uri_segment(3)) 35 | { 36 | $comment_id = (int) $this->uri->rsegment(3); 37 | $this->comment_reply($comment_id); 38 | return; 39 | } 40 | 41 | // check if the slug segment is there and then view by slug 42 | else if (!empty($slug)) 43 | { 44 | $view_by = 'slug'; 45 | } 46 | 47 | // we empty out year variable if it is page because we won't be querying on year 48 | else if (empty($slug)) 49 | { 50 | $view_by = 'date'; 51 | } 52 | 53 | // set this to false so that we can use segments for the limit 54 | $cache_id = fuel_cache_id(); 55 | $cache = $this->fuel->blog->get_cache($cache_id); 56 | 57 | if (!empty($cache)) 58 | { 59 | $output =& $cache; 60 | } 61 | else 62 | { 63 | $vars = $this->_common_vars(); 64 | 65 | if ($view_by == 'slug') 66 | { 67 | return $this->post($slug, $year, $month, $day); 68 | } 69 | else if ($view_by == 'date') 70 | { 71 | $page_title_arr = array(); 72 | $posts_date = mktime(0, 0, 0, $month, (empty($day)) ? 1 : $day, $year); 73 | if (!empty($day)) $page_title_arr[] = $day; 74 | if (!empty($month)) $page_title_arr[] = date('M', $posts_date); 75 | if (!empty($year)) $page_title_arr[] = $year; 76 | 77 | $limit = $this->fuel->blog->config('per_page'); 78 | $offset = (((int)$this->input->get('page') - 1) * $limit); 79 | $offset = ($offset < 0 ? 0 : $offset); 80 | 81 | if (!empty($offset)) 82 | { 83 | $page_title_arr[] = lang('blog_page_num_title', $offset, $offset + $limit); 84 | } 85 | 86 | // run before_posts_by_date hook 87 | $hook_params = array('year' => $year, 'month' => $month, 'day' => $day, 'slug' => $slug, 'limit' => $limit); 88 | $this->fuel->blog->run_hook('before_posts_by_date', $hook_params); 89 | $vars = array_merge($vars, $hook_params); 90 | $vars['page_title'] = $page_title_arr; 91 | $vars['posts'] = $this->fuel->blog->get_posts_by_date($year, (int) $month, $day, $slug, $limit, $offset); 92 | $vars['year'] = (!empty($year)) ? $year : NULL; 93 | $vars['month'] = (!empty($month)) ? $month : NULL; 94 | $vars['day'] = (!empty($day)) ? $day : NULL; 95 | $vars['offset'] = $offset; 96 | $vars['limit'] = $limit; 97 | 98 | // run hook again to get the proper count 99 | $hook_params['type'] = 'count'; 100 | $this->fuel->blog->run_hook('before_posts_by_date', $hook_params); 101 | $vars['post_count'] = $this->fuel->blog->get_posts_by_date_count($year, (int) $month, $day, $slug); 102 | 103 | // create pagination 104 | $url_segs = array(); 105 | if (!empty($year)) $url_segs[] = $year; 106 | if (!empty($month)) $url_segs[] = sprintf("%02d", $month); 107 | if (!empty($day)) $url_segs[] = sprintf("%02d", $day); 108 | $base_url = implode('/', $url_segs); 109 | $vars['pagination'] = $this->fuel->blog->pagination($vars['post_count'], $base_url); 110 | } 111 | 112 | // show the index page if the page doesn't have any uri_segment(3)' 113 | $view = ($this->fuel->blog->uri_segment(2) == 'index' OR ($this->fuel->blog->uri_segment(2) == 'page' AND !$this->fuel->blog->uri_segment(3))) ? 'index' : 'posts'; 114 | $output = $this->_render($view, $vars, TRUE); 115 | $this->fuel->blog->save_cache($cache_id, $output); 116 | } 117 | 118 | $this->output->set_output($output); 119 | } 120 | 121 | function post($slug = null, $year = null, $month = null, $day = null) 122 | { 123 | if (empty($slug)) 124 | { 125 | redirect_404(); 126 | } 127 | 128 | $this->load->library('session'); 129 | $blog_config = $this->fuel->blog->config(); 130 | 131 | // run before_posts_by_date hook 132 | $hook_params = array('slug' => $slug); 133 | $this->fuel->blog->run_hook('before_post', $hook_params); 134 | 135 | $post = $this->fuel->blog->get_post_by_date_slug($slug, $year, $month, $day); 136 | 137 | if (isset($post->id)) 138 | { 139 | $vars = $this->_common_vars(); 140 | $vars['post'] = $post; 141 | $vars['user'] = $this->fuel->blog->logged_in_user(); 142 | $vars['page_title'] = $post->page_title; 143 | if ($post->has_meta_description()) $vars['meta_description'] = $post->meta_description; 144 | if ($post->has_meta_keywords()) $vars['meta_keywords'] = $post->meta_keywords; 145 | $vars['next'] = $this->fuel->blog->get_next_post($post); 146 | $vars['prev'] = $this->fuel->blog->get_prev_post($post); 147 | $vars['slug'] = $slug; 148 | $vars['is_home'] = $this->fuel->blog->is_home(); 149 | 150 | $antispam = md5(random_string('unique')); 151 | 152 | $field_values = array(); 153 | 154 | // post comment 155 | if (!empty($_POST)) 156 | { 157 | $field_values = $_POST; 158 | 159 | // the id of "content" is a likely ID on the front end, so we use comment_content and need to remap 160 | $field_values['content'] = $field_values['new_comment']; 161 | unset($field_values['antispam']); 162 | 163 | if (!empty($_POST['new_comment'])) 164 | { 165 | $vars['processed'] = $this->_process_comment($post); 166 | } 167 | else 168 | { 169 | add_error(lang('blog_error_blank_comment')); 170 | } 171 | 172 | } 173 | 174 | $cache_id = fuel_cache_id(); 175 | if (!empty($cache) AND empty($_POST)) 176 | { 177 | $output =& $cache; 178 | } 179 | else 180 | { 181 | $vars['thanks'] = ($this->session->flashdata('thanks')) ? blog_block('comment_thanks', $vars, TRUE) : ''; 182 | $vars['comment_form'] = $this->fuel->blog->comment_form($post, NULL, $field_values, $blog_config['comment_form']); 183 | 184 | $output = $this->_render('post', $vars, TRUE); 185 | 186 | // save cache only if we are not posting data 187 | if (!empty($_POST)) 188 | { 189 | $this->fuel->blog->save_cache($cache_id, $output); 190 | } 191 | } 192 | if (!empty($output)) 193 | { 194 | $this->output->set_output($output); 195 | return; 196 | } 197 | } 198 | else 199 | { 200 | redirect_404(); 201 | } 202 | } 203 | 204 | function comment_reply($comment_id) 205 | { 206 | $this->load->library('session'); 207 | $this->load->module_model(BLOG_FOLDER, 'blog_comments_model'); 208 | $this->load->helper('ajax'); 209 | 210 | $comment = $this->blog_comments_model->find_by_key($comment_id); 211 | $output = ''; 212 | 213 | // check if comment even exists first to replay to 214 | if (!isset($comment->id)) 215 | { 216 | show_error(lang('blog_comment_does_not_exist')); 217 | } 218 | 219 | 220 | if (is_ajax()) 221 | { 222 | if (!empty($_POST)) 223 | { 224 | 225 | if (!empty($_POST['new_comment'])) 226 | { 227 | $post = $comment->post; 228 | $comment_id = $this->_process_comment($post); 229 | 230 | // wrap it in a div and class so it can be styled 231 | if (has_errors()) 232 | { 233 | // Set a 500 (bad) response code. 234 | set_status_header('500'); 235 | $output = '
'.get_error().'
'; 236 | } 237 | else 238 | { 239 | // set flash data so when the front end refreshes, it will be seen 240 | // Set a 200 (okay) response code. 241 | set_status_header('200'); 242 | $output = $this->fuel->blog->block('comment_thanks'); 243 | //$output = $comment_id; 244 | } 245 | } 246 | else 247 | { 248 | $output = '
'.lang('blog_error_blank_comment').'
'; 249 | } 250 | 251 | echo $output; 252 | exit(); 253 | } 254 | 255 | $form_defaults = array( 256 | 'form_attrs' => 'method="post" action="'.site_url($this->uri->uri_string()).'#comment_form'.$comment_id.'"', 257 | 'names_id_match' => FALSE, 258 | 'name_prefix' => 'comment_reply'.$comment_id, 259 | ); 260 | $output = $this->fuel->blog->comment_form($comment->post, $comment, $form_defaults); 261 | $this->output->set_output($output); 262 | } 263 | } 264 | 265 | function _process_comment($post) 266 | { 267 | if (!is_true_val($this->fuel->blog->config('allow_comments'))) return; 268 | $this->load->helper('ajax'); 269 | 270 | $notified = FALSE; 271 | 272 | // check captcha 273 | if (!$this->_is_valid_captcha()) 274 | { 275 | add_error(lang('blog_error_captcha_mismatch')); 276 | } 277 | 278 | // check that the site is submitted via the websit 279 | if (!$this->_is_site_submitted()) 280 | { 281 | add_error(lang('blog_error_comment_site_submit')); 282 | } 283 | 284 | // check consecutive posts 285 | if (!$this->_is_not_consecutive_post()) 286 | { 287 | add_error(lang('blog_error_consecutive_comments')); 288 | } 289 | 290 | $this->load->module_model(BLOG_FOLDER, 'blog_users_model'); 291 | $user = $this->blog_users_model->find_one(array('fuel_users.email' => $this->input->post('author_email', TRUE))); 292 | 293 | // create comment 294 | $this->load->module_model(BLOG_FOLDER, 'blog_comments_model'); 295 | $comment = $this->blog_comments_model->create(); 296 | $comment->post_id = $post->id; 297 | 298 | $comment->author_id = (!empty($user->id)) ? $user->id : NULL; 299 | $comment->author_name = $this->input->post('author_name', TRUE); 300 | $comment->author_email = $this->input->post('author_email', TRUE); 301 | $comment->author_website = $this->input->post('author_website', TRUE); 302 | $comment->author_ip = $_SERVER['REMOTE_ADDR']; 303 | $comment->content = trim($this->input->post('new_comment', TRUE)); 304 | $comment->parent_id = (int) $this->input->post('parent_id', TRUE); 305 | $comment->date_added = NULL; // will automatically be added 306 | 307 | //http://googleblog.blogspot.com/2005/01/preventing-comment-spam.html 308 | //http://en.wikipedia.org/wiki/Spam_in_blogs 309 | 310 | // check double posts by IP address 311 | if ($comment->is_duplicate()) 312 | { 313 | add_error(lang('blog_error_comment_already_submitted')); 314 | } 315 | 316 | // if no errors from above then proceed to submit 317 | if (!has_errors()) 318 | { 319 | 320 | // check if it's spam... 321 | // not necessary to run this here because of subsequent is_spam and is_savable calls that will run it if it hasn't run yet however makes the code a little clearer 322 | $comment->check_is_spam(); 323 | 324 | // process links and add no follow attribute 325 | $comment = $this->_filter_comment($comment); 326 | 327 | // set published status to yes automaticall if the comment is by the author (and isn't considered SPAM... just to be safe) 328 | if ($comment->is_by_post_author() AND !is_true_val($comment->is_spam)) 329 | { 330 | $comment->published = 'yes'; 331 | } 332 | // set published status to no if the commenter is not the author and either the comment is marked as spam or monitoring comments is on 333 | elseif (!$comment->is_by_post_author() AND (is_true_val($comment->is_spam) OR $this->fuel->blog->config('monitor_comments'))) 334 | { 335 | $comment->published = 'no'; 336 | } 337 | 338 | // save comment if saveable and redirect 339 | if (!is_true_val($comment->is_spam) OR (is_true_val($comment->is_spam) AND $this->fuel->blog->config('save_spam'))) 340 | { 341 | if ($comment->save()) 342 | { 343 | // if the blog setting is on, then attempt to notify the comment author through email 344 | if($this->fuel->blog->config('email_notify_comment_reply')) { 345 | $notified = $this->_notify($comment, $post); 346 | } 347 | 348 | $this->load->library('session'); 349 | $vars['post'] = $post; 350 | $vars['comment'] = $comment; 351 | $this->session->set_userdata('last_comment_ip', $_SERVER['REMOTE_ADDR']); 352 | $this->session->set_userdata('last_comment_time', time()); 353 | 354 | if (!is_ajax()) 355 | { 356 | $this->session->set_flashdata('thanks', TRUE); 357 | redirect($post->url); 358 | } 359 | } 360 | else 361 | { 362 | add_errors($comment->errors()); 363 | } 364 | } 365 | else 366 | { 367 | add_error(lang('blog_comment_is_spam')); 368 | } 369 | } 370 | return $notified; 371 | } 372 | 373 | // check captcha validity 374 | function _is_valid_captcha() 375 | { 376 | $valid = TRUE; 377 | 378 | // check captcha 379 | if (is_true_val($this->fuel->blog->config('use_captchas'))) 380 | { 381 | if (!$this->input->post('captcha')) 382 | { 383 | $valid = FALSE; 384 | } 385 | else if (!is_string($this->input->post('captcha'))) 386 | { 387 | $valid = FALSE; 388 | } 389 | else 390 | { 391 | 392 | $post_captcha_md5 = $this->_get_encryption($this->input->post('captcha')); 393 | $session_captcha_md5 = $this->session->userdata('comment_captcha'); 394 | if ($post_captcha_md5 != $session_captcha_md5) 395 | { 396 | $valid = FALSE; 397 | } 398 | } 399 | } 400 | return $valid; 401 | } 402 | 403 | // check to make sure the site issued a session variable to check against 404 | function _is_site_submitted() 405 | { 406 | return ($this->session->userdata('antispam') AND $this->input->post('antispam') == $this->session->userdata('antispam')); 407 | } 408 | 409 | // disallow multiple successive submissions 410 | function _is_not_consecutive_post() 411 | { 412 | $valid = TRUE; 413 | 414 | $time_exp_secs = $this->fuel->blog->config('multiple_comment_submission_time_limit'); 415 | $last_comment_time = ($this->session->userdata('last_comment_time')) ? $this->session->userdata('last_comment_time') : 0; 416 | $last_comment_ip = ($this->session->userdata('last_comment_ip')) ? $this->session->userdata('last_comment_ip') : 0; 417 | if ($_SERVER['REMOTE_ADDR'] == $last_comment_ip AND !empty($time_exp_secs)) 418 | { 419 | if (time() - $last_comment_time < $time_exp_secs) 420 | { 421 | $valid = FALSE; 422 | } 423 | } 424 | return $valid; 425 | } 426 | 427 | // process through akisment 428 | function _process_akismet($comment) 429 | { 430 | if ($this->fuel->blog->config('akismet_api_key')) 431 | { 432 | $this->load->module_library(BLOG_FOLDER, 'akismet'); 433 | 434 | $akisment_comment = array( 435 | 'author' => $comment->author_name, 436 | 'email' => $comment->author_email, 437 | 'body' => $comment->content 438 | ); 439 | 440 | $config = array( 441 | 'blog_url' => $this->fuel->blog->url(), 442 | 'api_key' => $this->fuel->blog->config('akismet_api_key'), 443 | 'comment' => $akisment_comment 444 | ); 445 | 446 | $this->akismet->init($config); 447 | 448 | if ( $this->akismet->errors_exist() ) 449 | { 450 | if ( $this->akismet->is_error('AKISMET_INVALID_KEY') ) 451 | { 452 | log_message('error', 'AKISMET :: Theres a problem with the api key'); 453 | } 454 | elseif ( $this->akismet->is_error('AKISMET_RESPONSE_FAILED') ) 455 | { 456 | log_message('error', 'AKISMET :: Looks like the servers not responding'); 457 | } 458 | elseif ( $this->akismet->is_error('AKISMET_SERVER_NOT_FOUND') ) 459 | { 460 | log_message('error', 'AKISMET :: Wheres the server gone?'); 461 | } 462 | } 463 | else 464 | { 465 | $comment->is_spam = ($this->akismet->is_spam()) ? 'yes' : 'no'; 466 | } 467 | } 468 | 469 | return $comment; 470 | } 471 | 472 | // strip out 473 | function _filter_comment($comment) 474 | { 475 | $this->load->helper('security'); 476 | $comment_attrs = array('content', 'author_name', 'author_email', 'author_website'); 477 | foreach($comment_attrs as $filter) 478 | { 479 | $text = $comment->$filter; 480 | 481 | // first remove any nofollow attributes to clean up... not perfect but good enough 482 | $text = preg_replace('//Umi', '', $text); 483 | // $text = str_replace('$filter = $text; 488 | } 489 | return $comment; 490 | } 491 | 492 | function _notify($comment, $post) 493 | { 494 | // send email to post author 495 | if (!empty($post->author)) 496 | { 497 | $config['wordwrap'] = TRUE; 498 | $this->load->library('email', $config); 499 | 500 | $this->email->from($this->fuel->config('from_email'), $this->fuel->config('site_name')); 501 | $this->email->to($post->author->email); 502 | $this->email->subject(lang('blog_comment_monitor_subject', $this->fuel->blog->config('title'))); 503 | 504 | $msg = lang('blog_comment_monitor_msg'); 505 | $msg .= "\n".fuel_url('blog/comments/edit/'.$comment->id)."\n\n"; 506 | 507 | $msg .= (is_true_val($comment->is_spam)) ? lang('blog_email_flagged_as_spam')."\n" : ''; 508 | $msg .= lang('blog_email_published').": ".$comment->published."\n"; 509 | $msg .= lang('blog_email_author_name').": ".$comment->author_name."\n"; 510 | $msg .= lang('blog_email_author_email').": ".$comment->author_email."\n"; 511 | $msg .= lang('blog_email_author_website').": ".$comment->author_website."\n"; 512 | $msg .= lang('blog_email_author_ip').": ".gethostbyaddr($comment->author_ip)." (".$comment->author_ip.")\n"; 513 | $msg .= lang('blog_email_content').": ".$comment->content."\n"; 514 | 515 | $this->email->message($msg); 516 | 517 | return $this->email->send(); 518 | } 519 | else 520 | { 521 | return FALSE; 522 | } 523 | } 524 | 525 | function _render_captcha() 526 | { 527 | $this->load->library('captcha'); 528 | $blog_config = $this->config->item('blog'); 529 | $assets_folders = $this->config->item('assets_folders'); 530 | $blog_folder = MODULES_PATH.BLOG_FOLDER.'/'; 531 | $captcha_path = $blog_folder.'assets/captchas/'; 532 | $word = strtoupper(random_string('alnum', 5)); 533 | 534 | $captcha_options = array( 535 | 'word' => $word, 536 | 'img_path' => $captcha_path, // system path to the image 537 | 'img_url' => captcha_path('', BLOG_FOLDER), // web path to the image 538 | 'font_path' => $blog_folder.'fonts/', 539 | ); 540 | $captcha_options = array_merge($captcha_options, $blog_config['captcha']); 541 | if (!empty($_POST['captcha']) AND $this->session->userdata('comment_captcha') == $this->input->post('captcha')) 542 | { 543 | $captcha_options['word'] = $this->input->post('captcha'); 544 | } 545 | $captcha = $this->captcha->get_captcha_image($captcha_options); 546 | $captcha_md5 = $this->_get_encryption($captcha['word']); 547 | $this->session->set_userdata('comment_captcha', $captcha_md5); 548 | 549 | return $captcha; 550 | } 551 | 552 | function _get_encryption($word) 553 | { 554 | $captcha_md5 = md5(strtoupper($word).$this->config->item('encryption_key')); 555 | return $captcha_md5; 556 | } 557 | } -------------------------------------------------------------------------------- /models/Blog_posts_model.php: -------------------------------------------------------------------------------- 1 | array('title' => 'url_title')); 15 | public $display_unpublished_if_logged_in = TRUE; // determines whether to display unpublished content on the front end if you are logged in to the CMS 16 | public $boolean_fields = array('sticky'); 17 | public $foreign_keys = array('category_id' => array(FUEL_FOLDER => 'fuel_categories_model', 'where' => '(context = "blog" OR context = "") AND language = "{language}" OR language = ""')); 18 | 19 | public $has_many = array( 20 | 'tags' => array( 21 | 'model' => array(BLOG_FOLDER => 'blog_tags_model'), 22 | //'where' => 'fuel_categories.context = "blog"', // added in constructor so that the the table name isn't hard coded in query 23 | ), 24 | 'related_posts' => array( 25 | 'model' => array(BLOG_FOLDER => 'blog_posts_model') 26 | ), 27 | 'blocks' => array( 28 | 'model' => array(FUEL_FOLDER => 'fuel_blocks_model') 29 | ) 30 | ); 31 | 32 | function __construct() 33 | { 34 | parent::__construct('blog_posts', BLOG_FOLDER); // table name 35 | $CI =& get_instance(); 36 | 37 | if ($CI->fuel->blog->config('multiple_authors')) 38 | { 39 | $authors = array('authors' => array('model' => array(BLOG_FOLDER => 'blog_users_model'))); 40 | $this->has_many = array_merge($authors, $this->has_many); 41 | } 42 | $this->has_many['tags']['where'] = '(FIND_IN_SET("blog", '.$this->_tables['fuel_tags'].'.context) OR '.$this->_tables['fuel_tags'].'.context="")'; 43 | $this->foreign_keys['category_id']['where'] = '(FIND_IN_SET("blog", '.$this->_tables['fuel_categories'].'.context) OR '.$this->_tables['fuel_categories'].'.context="")'; 44 | 45 | // set the filter again here just in case the table names are different 46 | $this->filters = array('title', 'content_filtered', $this->_tables['fuel_users'].'.first_name', $this->_tables['fuel_users'].'.last_name'); 47 | 48 | if ($this->fuel->blog->config('limit_to_user')) 49 | { 50 | $this->limit_to_user_field = 'author_id'; 51 | } 52 | 53 | } 54 | 55 | // used for the FUEL admin 56 | function list_items($limit = NULL, $offset = NULL, $col = 'publish_date', $order = 'desc', $just_count = FALSE) 57 | { 58 | $CI =& get_instance(); 59 | if ($CI->fuel->blog->config('multiple_authors')) 60 | { 61 | $select = $this->_tables['blog_posts'].'.id, title, '.$this->_tables['blog_posts'].'.publish_date'; 62 | } 63 | else 64 | { 65 | $select = $this->_tables['blog_posts'].'.id, '.$this->_tables['blog_posts'].'.title, IF('.$this->_tables['fuel_users'].'.first_name IS NULL, display_name, CONCAT('.$this->_tables['fuel_users'].'.first_name, " ", '.$this->_tables['fuel_users'].'.last_name)) AS author, '.$this->_tables['blog_posts'].'.publish_date'; 66 | } 67 | 68 | if ($CI->fuel->language->has_multiple()) $select .= ', '.$this->_tables['blog_posts'].'.language'; 69 | $select .= ', sticky, '.$this->_tables['blog_posts'].'.published'; 70 | $this->db->select($select, FALSE); 71 | 72 | $this->db->join($this->_tables['blog_users'], $this->_tables['blog_users'].'.id = '.$this->_tables['blog_posts'].'.author_id', 'left'); 73 | $this->db->join($this->_tables['fuel_users'], $this->_tables['blog_posts'].'.author_id = '.$this->_tables['fuel_users'].'.id', 'left'); 74 | 75 | $data = parent::list_items($limit, $offset, $col, $order, $just_count); 76 | return $data; 77 | } 78 | 79 | function tree($just_published = FALSE) 80 | { 81 | return $this->_tree('foreign_keys'); 82 | } 83 | 84 | function form_fields($values = array(), $related = array()) 85 | { 86 | $fields = parent::form_fields($values); 87 | $CI =& get_instance(); 88 | 89 | $blog_users = $CI->fuel->blog->model('blog_users'); 90 | $blog_config = $CI->fuel->blog->config(); 91 | 92 | $user_options = $blog_users->options_list(); 93 | $user = $this->fuel->auth->user_data(); 94 | 95 | $user_value = (!empty($values['author_id'])) ? $values['author_id'] : $user['id']; 96 | $author_comment = $fields['author_id']['comment']; 97 | 98 | $fields['author_id'] = array('label' => 'Author', 'type' => 'select', 'options' => $user_options, 'first_option' => 'Select an author...', 'value' => $user_value, 'comment' => $author_comment); 99 | 100 | if (!isset($values['allow_comments'])) 101 | { 102 | $fields['allow_comments']['value'] = ($CI->fuel->blog->config('allow_comments')) ? 'yes' : 'no'; 103 | } 104 | if (!empty($blog_config['formatting']) ) 105 | { 106 | 107 | $blog_config['formatting'] = (array) $blog_config['formatting']; 108 | if (count($blog_config['formatting']) == 1) 109 | { 110 | $fields['formatting'] = array('type' => 'hidden', 'options' => current($blog_config['formatting']), 'default' => $fields['formatting']['default']); 111 | if (strtolower($blog_config['formatting'][0]) == 'markdown') 112 | { 113 | $fields['content']['markdown'] = TRUE; 114 | $fields['excerpt']['markdown'] = TRUE; 115 | } 116 | } 117 | else 118 | { 119 | $fields['formatting'] = array('type' => 'select', 'options' => $blog_config['formatting'], 'default' => $fields['formatting']['default']); 120 | } 121 | } 122 | $fields['title']['style'] = 'width: 500px;'; 123 | $fields['slug']['style'] = 'width: 500px;'; 124 | $fields['language'] = array('type' => 'select', 'options' => $this->fuel->language->options(), 'value' => $this->fuel->language->default_option(), 'hide_if_one' => TRUE); 125 | $fields['content']['style'] = 'width: 680px; height: 400px'; 126 | $fields['excerpt']['style'] = 'width: 680px;'; 127 | 128 | if (!is_true_val($CI->fuel->blog->config('allow_comments'))) 129 | { 130 | unset($fields['allow_comments']); 131 | } 132 | 133 | unset($fields['content_filtered']); 134 | $fields['date_added']['type'] = 'hidden'; // so it will auto add 135 | //$fields['date_added']['type'] = 'datetime'; // so it will auto add 136 | $fields['last_modified']['type'] = 'hidden'; // so it will auto add 137 | 138 | $image_sizes = $CI->fuel->blog->config('image_sizes'); 139 | $image_types = array('main', 'list', 'thumbnail'); 140 | $images = array(); 141 | 142 | foreach($image_types as $type) 143 | { 144 | if ($image_sizes[$type] == FALSE) 145 | { 146 | unset($fields[$type.'_image']); 147 | continue; 148 | } 149 | if (!empty($image_sizes[$type])) 150 | { 151 | $fields[$type.'_image'] = array_merge($fields[$type.'_image'], $image_sizes[$type]); 152 | } 153 | $fields[$type.'_image']['folder'] = $CI->fuel->blog->config('asset_upload_path'); 154 | 155 | if (!empty($image_sizes[$type]['width']) OR !empty($image_sizes[$type]['height'])) 156 | { 157 | $image_comment = 'Recommended dimensions are '; 158 | if (!empty($image_sizes[$type]['width'])) $image_comment .= $image_sizes[$type]['width'].'w'; 159 | if (!empty($image_sizes[$type]['height'])) $image_comment .= ' x '; 160 | if (!empty($image_sizes[$type]['height'])) $image_comment .= $image_sizes[$type]['height'].'h'; 161 | $fields[$type.'_image']['comment'] = $image_comment; 162 | } 163 | $images[] = $type.'_image'; 164 | $fields[$type.'_image']['multiple'] = FALSE; 165 | } 166 | 167 | if(array_key_exists('main_image', $fields)) $fields['main_image']['img_styles'] = 'float: left; width: 200px;'; 168 | if(array_key_exists('list_image', $fields)) $fields['list_image']['img_styles'] = 'float: left; width: 100px;'; 169 | if(array_key_exists('thumbnail_image', $fields)) $fields['thumbnail_image']['img_styles'] = 'float: left; width: 60px;'; 170 | 171 | if (empty($fields['publish_date']['value'])) 172 | { 173 | $fields['publish_date']['value'] = datetime_now(); 174 | } 175 | 176 | $fields['blocks']['sorting'] = TRUE; 177 | 178 | 179 | if (!empty($values['id'])) 180 | { 181 | unset($fields['related_posts']['options'][$values['id']]); 182 | } 183 | 184 | if ($CI->fuel->blog->config('multiple_authors')) 185 | { 186 | unset($fields['author_id']); 187 | } 188 | 189 | // explicitly set labels for related fields to use the lang values 190 | $fields['category_id']['label'] = lang('form_label_category'); 191 | $fields['tags']['label'] = lang('form_label_tags'); 192 | $fields['related_posts']['label'] = lang('form_label_related_posts'); 193 | $fields['blocks']['label'] = lang('form_label_blocks'); 194 | 195 | $fields['category_id']['comment'] = lang('form_category_comment'); 196 | $fields['tags']['comment'] = lang('form_tags_comment'); 197 | if ($CI->fuel->language->has_multiple()) 198 | { 199 | $fields['tags']['type'] = 'dependent'; 200 | $fields['tags']['depends_on'] = 'language'; 201 | $fields['tags']['url'] = fuel_url('tags/ajax/options'); 202 | $fields['tags']['multiple'] = TRUE; 203 | 204 | $fields['related_posts']['type'] = 'dependent'; 205 | $fields['related_posts']['depends_on'] = 'language'; 206 | $fields['related_posts']['url'] = fuel_url('blog/posts/ajax/options'); 207 | if (!empty($values['id'])) 208 | { 209 | $fields['related_posts']['additional_ajax_data'] = array('exclude' => $values['id']); 210 | } 211 | 212 | 213 | $fields['related_posts']['multiple'] = TRUE; 214 | 215 | $fields['blocks']['type'] = 'dependent'; 216 | $fields['blocks']['depends_on'] = 'language'; 217 | $fields['blocks']['url'] = fuel_url('blocks/ajax/options'); 218 | $fields['blocks']['multiple'] = TRUE; 219 | } 220 | 221 | $fields['page_title'] = array('size' => 100, 'comment' => 'If no page title is provided, it will default to the title of the blog post'); 222 | $fields['meta_description'] = array('type' => 'textarea', 'class' => 'no_editor', 'rows' => 3); 223 | $fields['meta_keywords'] = array('type' => 'textarea', 'class' => 'no_editor', 'rows' => 3); 224 | $fields['canonical'] = array('size' => 100, 'comment' => 'This field is used to help prevent duplicate content issues for search engines'); 225 | 226 | $fields['Open Graph'] = array('type' => 'section'); 227 | $fields['og_title'] = array('size' => 100); 228 | $fields['og_description'] = array('size' => 100); 229 | $fields['og_image'] = array('img_styles' => 'float: left; width: 100px;', 'folder' => $CI->fuel->blog->config('asset_upload_path')); 230 | 231 | //$fields['category_id']['add_params'] = 'context=blog'; 232 | 233 | // find the first category with a context of "blog" 234 | $blog_category = current($CI->fuel->categories->find_by_context('blog')); 235 | if (isset($blog_category->id)) 236 | { 237 | $fields['tags']['add_params'] = 'category_id='.$blog_category->id; 238 | } 239 | //$fields['tags']['add_params'] = 'context=blog'; 240 | $fields['tags']['module'] = 'tags'; // must be set here since blog_tags is used as the module 241 | 242 | // setup tabs 243 | $fields['Content'] = array('type' => 'fieldset', 'class' => 'tab'); 244 | $fields['Images'] = array('type' => 'fieldset', 'class' => 'tab'); 245 | $fields['Settings'] = array('type' => 'fieldset', 'class' => 'tab'); 246 | $fields['Meta'] = array('type' => 'fieldset', 'class' => 'tab'); 247 | $fields['Associations'] = array('type' => 'fieldset', 'class' => 'tab'); 248 | 249 | // now set the order 250 | $order = array( 'Content', 251 | 'title', 252 | 'slug', 253 | 'language', 254 | 'content', 255 | 'formatting', 256 | 'excerpt', 257 | 'author_id', 258 | 'authors', 259 | 'published', 260 | 'Images', 261 | 'Settings', 262 | 'allow_comments', 263 | 'sticky', 264 | 'publish_date', 265 | 'Meta', 266 | 'page_title', 267 | 'meta_description', 268 | 'meta_keywords', 269 | 'canonical', 270 | 'Open Graph', 271 | 'og_title', 272 | 'og_description', 273 | 'og_image', 274 | 'Associations', 275 | 'category_id', 276 | 'tags', 277 | 'related_posts', 278 | 'blocks', 279 | ); 280 | //insert thumbnails into order array 281 | $i = 11; 282 | foreach($images as $image) 283 | { 284 | array_splice($order, $i, 0, $image); 285 | ++$i; 286 | } 287 | foreach($order as $key => $val) 288 | { 289 | if (isset($fields[$val])) 290 | { 291 | $fields[$val]['order'] = $key + 1; 292 | } 293 | } 294 | return $fields; 295 | } 296 | 297 | function on_before_clean($values) 298 | { 299 | $values['slug'] = (empty($values['slug']) && !empty($values['title'])) ? url_title($values['title'], 'dash', TRUE) : url_title($values['slug'], 'dash'); 300 | 301 | if (empty($values['publish_date'])) 302 | { 303 | $values['publish_date'] = datetime_now(); 304 | } 305 | 306 | // create author if it doesn't exists' 307 | $CI =& get_instance(); 308 | $id = (!empty($values['author_id'])) ? $values['author_id'] : $CI->fuel->auth->user_data('id'); 309 | $blog_users = $CI->fuel->blog->model('blog_users'); 310 | $author = $blog_users->find_one(array('fuel_user_id' => $id)); 311 | if (!isset($author->id)) 312 | { 313 | $author = $blog_users->create(); 314 | $author->fuel_user_id = $CI->fuel->auth->user_data('id'); 315 | 316 | // determine a display name if one isn't provided' 317 | if (trim($author->display_name) == '') 318 | { 319 | $display_name = $CI->fuel->auth->user_data('first_name').' '.$this->fuel->auth->user_data('last_name'); 320 | if (trim($display_name) == '') $display_name = $CI->fuel->auth->user_data('email'); 321 | if (empty($display_name)) $display_name = $CI->fuel->auth->user_data('user_name'); 322 | $author->display_name = $display_name; 323 | } 324 | 325 | // save author 326 | $author->save(); 327 | $values['author_id'] = $author->fuel_user_id; 328 | } 329 | 330 | return $values; 331 | } 332 | 333 | function on_before_save($values) 334 | { 335 | $values['title'] = strip_tags($values['title']); 336 | $values['content_filtered'] = strip_tags($values['content']); 337 | 338 | return $values; 339 | } 340 | 341 | function on_after_save($values) 342 | { 343 | parent::on_after_save($values); 344 | 345 | // remove cache 346 | $CI =& get_instance(); 347 | $CI->fuel->blog->remove_cache(); 348 | 349 | return $values; 350 | } 351 | 352 | function _common_query($display_unpublished_if_logged_in = NULL) 353 | { 354 | parent::_common_query(); 355 | 356 | $this->db->select($this->_tables['blog_posts'].'.*, '.$this->_tables['blog_users'].'.display_name, CONCAT('.$this->_tables['fuel_users'].'.first_name, " ", '.$this->_tables['fuel_users'].'.last_name) as author_name', FALSE); 357 | $this->db->select('YEAR('.$this->_tables['blog_posts'].'.publish_date) as year, DATE_FORMAT('.$this->_tables['blog_posts'].'.publish_date, "%m") as month, DATE_FORMAT('.$this->_tables['blog_posts'].'.publish_date, "%d") as day,', FALSE); 358 | $rel_join = $this->_tables['blog_relationships'].'.candidate_key = '.$this->_tables['blog_posts'].'.id AND '; 359 | $rel_join .= $this->_tables['blog_relationships'].'.candidate_table = "'.$this->_tables['blog_posts'].'" AND '; 360 | $rel_join .= $this->_tables['blog_relationships'].'.foreign_table = "'.$this->_tables['blog_tags'].'"'; 361 | $this->db->join($this->_tables['blog_categories'], $this->_tables['blog_categories'].'.id = '.$this->_tables['blog_posts'].'.category_id', 'left'); 362 | $this->db->join($this->_tables['blog_relationships'], $rel_join, 'left'); 363 | $this->db->join($this->_tables['blog_users'], $this->_tables['blog_users'].'.fuel_user_id = '.$this->_tables['blog_posts'].'.author_id', 'left'); 364 | $this->db->join($this->_tables['fuel_users'], $this->_tables['fuel_users'].'.id = '.$this->_tables['blog_posts'].'.author_id', 'left'); 365 | $this->db->join($this->_tables['blog_tags'], $this->_tables['blog_tags'].'.id = '.$this->_tables['blog_relationships'].'.foreign_key', 'left'); 366 | $this->db->group_by($this->_tables['blog_posts'].'.id, '.$this->_tables['blog_users'].'.display_name'); 367 | 368 | if (!defined('FUEL_ADMIN') AND $this->fuel->language->has_multiple()) 369 | { 370 | $language = $this->fuel->blog->language(); 371 | $this->db->where($this->_tables['blog_posts'].'.language', $language); 372 | } 373 | } 374 | 375 | function preview_path($values, $path) 376 | { 377 | extract($values); 378 | $CI =& get_instance(); 379 | $base_uri = $this->fuel->blog->uri(); 380 | if ($CI->fuel->language->has_multiple() AND $values['language'] != 'english') 381 | { 382 | return "{$language}/".$base_uri."{$year}/{$month}/{$day}/{$slug}"; 383 | } 384 | else 385 | { 386 | return $base_uri."{$year}/{$month}/{$day}/{$slug}"; 387 | } 388 | } 389 | 390 | } 391 | 392 | class Blog_post_model extends Base_module_record { 393 | 394 | private $_tables; 395 | public $author_name; 396 | 397 | function get_page_title() 398 | { 399 | if (empty($this->_fields['page_title'])) 400 | { 401 | return $this->title; 402 | } 403 | return $this->_fields['page_title']; 404 | } 405 | 406 | function get_content_formatted($strip_images = FALSE) 407 | { 408 | $this->_CI->load->module_helper(FUEL_FOLDER, 'fuel'); 409 | $content = $this->content; 410 | if ($strip_images) 411 | { 412 | $CI->load->helper('security'); 413 | $content = strip_image_tags($this->content); 414 | } 415 | $content = $this->_format($content); 416 | $content = $this->_parse($content); 417 | return $content; 418 | } 419 | 420 | function get_excerpt($char_limit = NULL, $end_char = '…') 421 | { 422 | $this->_CI->load->helper('text'); 423 | $excerpt = (empty($this->_fields['excerpt'])) ? $this->content : $this->_fields['excerpt']; 424 | 425 | if (!empty($char_limit)) 426 | { 427 | // must strip tags to get accruate character count 428 | $excerpt = strip_tags($excerpt); 429 | $excerpt = character_limiter($excerpt, $char_limit, $end_char); 430 | } 431 | return $excerpt; 432 | } 433 | 434 | function get_excerpt_formatted($char_limit = NULL, $readmore = '') 435 | { 436 | $excerpt = $this->get_excerpt($char_limit); 437 | if (!empty($readmore)) 438 | { 439 | $excerpt .= ' '.anchor($this->url, $readmore, 'class="readmore"'); 440 | } 441 | $excerpt = $this->_format($excerpt); 442 | $excerpt = $this->_parse($excerpt); 443 | return $excerpt; 444 | } 445 | 446 | function is_future_post() 447 | { 448 | return strtotime($this->publish_date) > time(); 449 | } 450 | 451 | function is_published() 452 | { 453 | return ($this->published === 'yes'); 454 | } 455 | 456 | function get_comments($order = 'date_added asc', $limit = NULL) 457 | { 458 | $blog_comments = $this->_CI->fuel->blog->model('blog_comments'); 459 | $where = array('post_id' => $this->id, $this->_parent_model->tables('blog_comments').'.published' => 'yes'); 460 | $order = $this->_parent_model->tables('blog_comments').'.'.$order; 461 | $comments = $blog_comments->find_all($where, $order, $limit); 462 | return $comments; 463 | } 464 | 465 | function get_comments_count($order = 'date_added asc', $limit = NULL) 466 | { 467 | $blog_comments = $this->_CI->fuel->blog->model('blog_comments'); 468 | $where = array('post_id' => $this->id, $this->_parent_model->tables('blog_comments').'.published' => 'yes'); 469 | $cnt = $blog_comments->record_count($where, $order, $limit); 470 | return $cnt; 471 | } 472 | 473 | function get_comments_formatted($block = 'comment', $parent_id = 0, $container_class = 'child') 474 | { 475 | 476 | // initialization... grab all comments 477 | $items = array(); 478 | $comments = $this->get_comments(); 479 | 480 | $str = ''; 481 | 482 | // get child comments 483 | foreach($comments as $key => $comment) 484 | { 485 | 486 | if ((int)$comment->parent_id === (int)$parent_id) 487 | { 488 | $items[] = $comment; 489 | unset($comments[$key]); 490 | } 491 | } 492 | 493 | if (!empty($items)) 494 | { 495 | 496 | // now loop through roots and get any children 497 | foreach($items as $item) 498 | { 499 | $str .= $this->_CI->fuel->blog->block($block, array('comment' => $item, 'post' => $this)); 500 | $children = $this->get_comments_formatted($block, $item->id); 501 | if (!empty($children)) 502 | { 503 | $str .= "
\n\t"; 504 | $str .= $children; 505 | $str .= "
\n"; 506 | } 507 | } 508 | } 509 | return $str; 510 | } 511 | 512 | function belongs_to_category($category) 513 | { 514 | $categories = $this->categories; 515 | 516 | if (in_array($category, $categories)) 517 | { 518 | return TRUE; 519 | } 520 | return FALSE; 521 | } 522 | 523 | function get_category() 524 | { 525 | $model = $this->_CI->fuel->blog->model('categories'); 526 | return $model->find_by_key($this->category_id); 527 | } 528 | 529 | function get_tags_linked($order = 'name asc', $join = ', ', $link_params = array()) 530 | { 531 | $tags = $this->tags; 532 | if ( ! empty($tags)) 533 | { 534 | $tags_linked = array(); 535 | foreach ($tags as $tag) 536 | { 537 | $tags_linked[] = anchor($this->_CI->fuel->blog->url($tag->get_url(FALSE)), $tag->name, $link_params); 538 | } 539 | $return = implode($tags_linked, $join); 540 | return $return; 541 | } 542 | return NULL; 543 | } 544 | 545 | function get_category_link($link_params = array()) 546 | { 547 | if ($this->has_category_id()) 548 | { 549 | $category = $this->category; 550 | if (isset($category->id)) 551 | { 552 | return anchor($this->_CI->fuel->blog->url($category->get_url(FALSE)), $category->name, $link_params); 553 | } 554 | } 555 | 556 | return NULL; 557 | 558 | } 559 | 560 | function get_author($all = FALSE) 561 | { 562 | $cache_key ='author'.$all; 563 | if (!isset($this->_objs[$cache_key])) 564 | { 565 | if ($this->_CI->fuel->blog->config('multiple_authors')) 566 | { 567 | $authors_model = $this->get_authors(TRUE); 568 | $where = array(); 569 | if (!$all) 570 | { 571 | $where[$this->_parent_model->tables('blog_users').'.active'] = 'yes'; 572 | } 573 | $this->_objs[$cache_key] = $this->find_one($where); 574 | } 575 | else 576 | { 577 | $where = array($this->_parent_model->tables('blog_users').'.fuel_user_id' => $this->author_id); 578 | if (!$all) 579 | { 580 | $where[$this->_parent_model->tables('blog_users').'.active'] = 'yes'; 581 | } 582 | $this->_objs[$cache_key] = $this->lazy_load($where, array(BLOG_FOLDER => 'blog_users_model'), FALSE); 583 | } 584 | } 585 | return $this->_objs[$cache_key]; 586 | } 587 | 588 | 589 | function has_author($active = FALSE) 590 | { 591 | $author = $this->get_author($active); 592 | return !empty($author); 593 | } 594 | 595 | function get_author_link() 596 | { 597 | $author = $this->get_author(TRUE); 598 | if(is_true_val($author->active)) 599 | { 600 | return '
'.$author->display_name.''; 601 | }else{ 602 | return $author->display_name; 603 | } 604 | } 605 | 606 | function get_image($type = 'main') 607 | { 608 | $img = $type.'_image'; 609 | return $this->$img; 610 | } 611 | 612 | function get_image_path($type = 'main') 613 | { 614 | $CI =& get_instance(); 615 | $img = $this->get_image($type); 616 | $path = trim($CI->fuel->blog->config('asset_upload_path'),'/').'/'.$img; 617 | 618 | return assets_path($path); 619 | } 620 | 621 | function get_main_image_path() 622 | { 623 | return $this->get_image_path('main'); 624 | } 625 | 626 | function get_list_image_path() 627 | { 628 | return $this->get_image_path('list'); 629 | } 630 | 631 | function get_thumbnail_image_path() 632 | { 633 | return $this->get_image_path('thumbnail'); 634 | } 635 | 636 | function get_url($full_path = TRUE) 637 | { 638 | $year = date('Y', strtotime($this->publish_date)); 639 | $month = date('m', strtotime($this->publish_date)); 640 | $day = date('d', strtotime($this->publish_date)); 641 | $url = $year.'/'.$month.'/'.$day.'/'.$this->slug; 642 | if ($full_path) 643 | { 644 | return $this->_CI->fuel->blog->url($url); 645 | } 646 | $base_uri = trim($this->_CI->fuel->blog->config('uri'), '/'); 647 | return $base_uri.'/'.$url; 648 | } 649 | 650 | function get_link_title($attrs = array()) 651 | { 652 | return anchor($this->url, $this->title, $attrs); 653 | } 654 | 655 | function get_rss_date() 656 | { 657 | return standard_date('DATE_RSS', strtotime($this->publish_date)); 658 | } 659 | 660 | function get_atom_date() 661 | { 662 | return standard_date('DATE_ATOM', strtotime($this->publish_date)); 663 | } 664 | 665 | function get_date_formatted($format = 'M d, Y') 666 | { 667 | return date($format, strtotime($this->publish_date)); 668 | } 669 | 670 | function get_allow_comments() 671 | { 672 | if (is_null($this->_fields['allow_comments'])) 673 | { 674 | return is_true_val($this->_CI->fuel->blog->config('allow_comments')); 675 | } 676 | else 677 | { 678 | return is_true_val($this->_fields['allow_comments']); 679 | } 680 | } 681 | function is_within_comment_time_limit() 682 | { 683 | $time_limit = (int) $this->_CI->fuel->blog->config('comments_time_limit') * (24 * 60 * 60); 684 | if (!empty($time_limit)) 685 | { 686 | $publish_date = strtotime($this->publish_date); 687 | return (time() - $publish_date < $time_limit); 688 | } 689 | return TRUE; 690 | } 691 | 692 | function get_prev_post() 693 | { 694 | return $this->_CI->fuel->blog->prev_post($this); 695 | } 696 | 697 | function get_prev_post_url() 698 | { 699 | $prev = $this->prev_post; 700 | if ($prev) 701 | { 702 | return $prev->url; 703 | } 704 | } 705 | 706 | function get_next_post() 707 | { 708 | return $this->_CI->fuel->blog->next_post($this); 709 | } 710 | 711 | function get_next_post_url() 712 | { 713 | $next = $this->next_post; 714 | if ($next) 715 | { 716 | return $next->url; 717 | } 718 | } 719 | 720 | private function _format($content) 721 | { 722 | $this->_CI->load->helper('typography'); 723 | $this->_CI->load->helper('markdown'); 724 | if (!empty($this->formatting) && !function_exists($this->formatting)) 725 | { 726 | $this->_CI->load->helper(strtolower($this->formatting)); 727 | } 728 | if (function_exists($this->formatting)) 729 | { 730 | $content = call_user_func($this->formatting, $content); 731 | } 732 | return $content; 733 | } 734 | } 735 | ?> 736 | --------------------------------------------------------------------------------