/
CommentsAppController.php
109 lines (105 loc) · 4.04 KB
/
CommentsAppController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* @page Comments-Plugin Comments plugin
*
* @section charts-overview What is it
*
* The Comments plugin allows you to add comments to any row of data for your
* entire application by simply adding some fields to your database and including
* the elements where needed.
*
* The comments can be anything, not only comments in the sence of blogs. For
* example they could also be used for notes on shop orders, communication in
* a bugtracker etc.
*
* The fields used in the comments are flexible, having only the comment field
* and the users email address as required fields for the form. Adding extra
* fields to the form will be saved in a EAV table handled by the ExpandableBehavior
*
* @section categories-usage How to use it
*
* To get comments running in your plugin you will need to do a few things, first
* of which is adding a field to the table you wish to allow users to comment on
* The field should be called 'comment_count' and should be of type INT() MEDIUMINT()
* or any other integer type field you would require.
*
* After that has been done you will need to include the element for the comment
* form and latest comments in your views where you would like to see it. Example
* usage is below.
*
* The comments plugin uses a nifty rating system that checks a number of
* configurable details of the comment and gives it a score. If the score is
* too low it is regarded as spam. If it is below the threshold it will not
* even be saved. A number of factors are included in the score such as the lenght
* of the comment, the number of previous comments that were accepted and number
* of links that are in the comment body.
*
* @code
* // simple when using the correct conventions
* // infinitas will figure out the title, and where to save the comment
* echo $this->element('modules/comment', array('plugin' => 'comments'));
*
* // more advanced for wierd setups
* // when you dont use conventions you will need to tell infinitas what is what
* $this->element(
* 'modules/comment',
* array(
* 'plugin' => 'comments',
* 'content' => $model,
* 'modelName' => 'Model'
* )
* );
* @endcode
*
* That is all there is to it. Should you wish to do something really different
* you can overlaod the comment module in a theme. you can also change the
* plugin that is passed in the second param to anything you like should you
* overload it, just remember where and create the file in the corresponding
* directory. The other option is to just define your own comment element and
* call it in your view. Take note of the core one as there are some conditions
* that need to be met like setting the action of the form and the data that
* should be passed in.
*
*
* @section categories-code How it works
*
* Currently the comments are saved by a method in AppController::comment() so
* that you can just set the action to 'comment' and it will work as all controllers
* extend AppController they inherit the method.
*
* After the comment is submitted it under goes a rating and a score is determined
* for. It can then based on the configuration be accepted and marked as active
* automatically if it has passed, or if its edge case will be marked as pending
* for admin to later activte it. Comments with very low scores can be set to
* not save.
*
* @image html sql_comments_plugin.png "Comments Plugin table structure"
*
* @section categories-see-also Also see
* @ref EventCore
* @ref FilterHelper
* @ref GravatarHelper
* @ref ExpandableBehavior
*/
App::uses('AppController', 'Controller');
/**
* CommentsAppController is the base class that all comments controllers extend
*
* @copyright Copyright (c) 2010 Carl Sutton ( dogmatic69 )
* @link http://www.infinitas-cms.org
* @package Infinitas.Comments
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* @since 0.8a
*
* @author Carl Sutton <dogmatic69@infinitas-cms.org>
*/
class CommentsAppController extends AppController{
/**
* some helpers to load for this plugin
*
* @var array
*/
public $helpers = array(
'Libs.Gravatar'
);
}