Comments

Module refers to the part of the CMS "Interactive" and can be installed optionally.

The module "Comments" is connected to the other modules. The standard DIAFAN.CMS "Comments" are connected to the following modules: Photogallery, News, Articles, Question-Answer, Online shop, Files, Site pages, Ads. The comments are connected to a specific module within the module settings.

The user of the site comments are added using Ajax technology, ie without reloading the whole page. Comments containing the words longer than 20 characters are not skipped.

Connection

Подключаемая часть – файл modules/comments/comments.inc.php. В нем описан класс Comments_inc. В модуле к объекту класса можно обратиться через переменную $this->diafan->_comments. Экземпляр класса создается при первом вызове переменной.

Методы

string get ([integer $element_id = 0], [string $module_name = ''], [string $element_type = 'element'], [integer $site_id = 0]) – Показывает комментарии, прикрепленные к элементу, и форму добавления комментария.

  • integer $element_id: element ID, по умолчанию текущий элемент модуля
  • string $module_name: название модуля, по умолчанию текущий модуль
  • string $element_type: тип данных
  • integer $site_id: страница сайта, к которой прикреплен элемент, по умолчанию текущая страница сайта

Example:

// get comments to news and form to add a comment
// in the file modules/news/news.model.php
$comments = $this->diafan->_comments->get();

// выводим комментарии в шаблоне модуля
// in the file modules/news/views/news.view.id.php
echo $comments; `

void element (array &$row, array $params_list, integer $element_id, string $module_name, string $element_type, array $params_form, [boolean $hide_form = false]) – Формирует данные об одном комментарие.

  • array $row: массив данных о комментарии
  • array $params_list: дополнительные поля для списка
  • integer $element_id: element ID, по умолчанию текущий элемент модуля
  • string $module_name: название модуля, по умолчанию текущий модуль
  • string $element_type: тип данных
  • array $params_form: дополнительные поля для формы
  • boolean $hide_form: скрыть форму ответа на добавленный комментарий

Example:

// get data about comment from db
$row = DB::query_fetch_array("SELECT * FROM {comments} WHWRE id=5");

// get fields for comments in list
$params_list = DB::query_fetch_all("SELECT * FROM {comments_param} WHERE show_in_list='1'");

// get fields for form to add a comment
$params_form = DB::query_fetch_all("SELECT * FROM {comments_param} WHERE show_in_form_auth='1' OR show_in_form_no_auth='1'");

// preapre data about comments for template
// and add form to add a comment
$this->diafan->_comments->element($row, $params_list, $params_form);

array get_param_values (integer $id, array $params) – Получает дополнительные поля комментариев.

  • integer $id: номер комментария
  • array $params: дополнительные поля комментариев

Example:

// get fields for comments in list
$params_list = DB::query_fetch_all("SELECT * FROM {comments_param} WHERE show_in_list='1'");

// get values of fields for comment ID=15
$row["params"] = $this->diafan->_comments->get_param_values(15, $params_list);

void prepare_param_values (integer $id) – Запоминает номера комментариев, для которых понядобятся значения доп. полей.

  • integer $id: номер комментария

Example:

// in this example, 3 SQL-request to the database
// for getting values of fields for comments
$ids = array(3, 5, 7);
foreach(
$ids as $id)
{
    
$params[$id] = $this->diafan->_comments->get_param_values($id, $params_list);
}

Example:

// in this example, 1 SQL-request to the database
// for getting values of fields for comments
$ids = array(3, 5, 7);
foreach(
$ids as $id)
{
    
$this->diafan->_comments->prepare($id);
}
foreach(
$ids as $id)
{
    
$params[$id] = $this->diafan->_comments->get_param_values($id, $params_list);
}

void delete (integer|array $element_ids, string $module_name, [string $element_type = 'element']) – Удаляет комментарий для одного или нескольких элементов.

  • integer|array $element_ids: номер одного или нескольких элементов
  • string $module_name: название модуля
  • string $element_type: тип данных

Example:

// remove comments to news category ID=3
$this->diafan->_comments->delete(3, 'news', 'cat');

// remove comments to news ID=3,4,5
$this->diafan->_comments->delete(array(3, 4, 5) 'news');

void delete_module (string $module_name) – Удаляет все комментарии модуля.

  • string $module_name: название модуля

Example:

// remove comments to all news and news categories
$this->diafan->_comments->delete_module('news');

How to add comments to the module

In the file of module settings (modules/модуль/admin/модуль.admin.config.php) and in the file of editing elements of the module (modules/модуль/admin/модуль.admin.php) you must add the parameter 'comments':

Example:

public $variables = array(
    
'main' => array(
        
'comments' => 'module',
        

    
),
    

);

Comments

List of comments

The administrative part of the module all the comments collected in one table and displayed in order of receipt. Comments can be sorted by belonging to a particular element. To do this, links are provided "Comments" in the administrative part of the modules, which connect comment. For example, when the link "Comments" photo editing appears in the comments to this picture or message "Comments" in their absence.

When you delete an item, delete all comments attached to it.

Edit of comment

Comments have the following characteristics.

Основные:

  • Date of addition – In dd.mm.yyyy hh:mm format.
  • User – User who has added a comment (if the comment was added by the registered user).
  • Comment.
  • Additional fields – Fields added in form builder.
  • Published – If unchecking the comment will not be publish on a site.
  • Comment to – Object to which comments are attached, link to all comments to this page.
  • Nesting: belongs to – Comment of top level.

Form builder

List of field

The number and content of the comment fields may be different. This provides a form builder.

Form builder – a additional fields in the form of comments additing.

Edit of field

Fields have the following characteristics.

Основные:

  • Name – The parameter has different values for different language versions of the site.
  • Module – Possibility to limit use of the field by comments attached to the selected module.
  • Type – Possible values:
    • input,
    • number,
    • date,
    • date and time,
    • textarea with editor,
    • checkbox,
    • combobox,
    • select,
    • select multiple,
    • e-mail,
    • phone,
    • title of features group,
    • files,
    • images.
  • Maximum files to add – Quantity of added files. No form of files addition is shown if the value is zero. Parameter is shown if the characteristic type is set as "files".
  • Accessible types of files (through a comma) – Parameter is shown if the characteristic type is set as "files".
  • Recognize images – Allows to display the attached files in JPEG, GIF, PNG format as images. Parameter is shown if the characteristic type is set as "files".
  • Size for large image – Size of the image displayed in the user part of a site when increasing preview image. Parameter is shown if the characteristic type is set as "files" and "Recognize images" option is enabled.
  • Size for small image – Size of preview image. Parameter is shown if the characteristic type is set as "files" and "Recognize images" option is enabled.
  • Use animation when increasing images – Parameter adds JavaScript code, allowing to enable animation when increasing images. Parameter is shown if "Recognize images" option is enabled. Parameter is shown if the characteristic type is set as "files" and "Recognize images" option is enabled.
  • Maximum size of uploaded files – Parameter shows maximum admissible size of uploaded files set in hosting settings. Parameter is shown if the characteristic type is set as "files".
  • Generate sizes of images – Sizes of images set in "Image" module. Parameter is shown if the characteristic type is set as "image".
  • Required.
  • Show in the list – Shows a field for comments on a site in the comments list
  • Show in a form for the authorised users.
  • Show in a form for unauthorised users.
  • Sorting: set before – Editing of sequence of field in a form
  • Description – The parameter has different values for different language versions of the site.

Settings

Settings

  • Date format – Format date in the module. Possible values:
    • 01.05.2016,
    • 01.05.2016 14:45,
    • 1 may 2016,
    • 1 may,
    • 1 may 2016, monday,
    • yesterday 15:30,
    • do not show.
  • Maximum nesting – Limits nesting of comments tree.
  • Quantity of comments on page – Quantity of comments of the first level shown on one page.
  • Use bbCode – Allow formatting of comments using bbCode.
  • Show name of the user who has added the comment – Shows user name who has added the comment on a site
  • For registered users only – Parameter allows to forbid adding comments by unauthorized users.
  • Use safety code (captcha) – User should enter capcha in order to add the comment.
  • Messages moderation – If checked comments will be shown on a site only after the administrator will activate them manually. If the user who has added the comment has the rights of module administrator, the comment will be posted on a site at once.
  • Your message already exists in the base – Message to the user at attempt of repeated addition of the message. The parameter has different values for different language versions of the site.
  • Thank you! Your comment will be checked and posted on a site soon. – Message to the user at successful addition of the comment. The parameter has different values for different language versions of the site.
  • Subscribe for new comments – Possibility to specify e-mail when commenting, in order to receive notifications about new comments in a site section.
  • E-mail subject for notification about new comments – You can add:
    • %title – site name,
    • %url – the address of the site (for example, site.ru).
    The parameter has different values for different language versions of the site. This parameter appears if the option marked "Subscribe for new comments".

    Example:

    New comment on the site %title (%url)
  • Message for notification about new comments – You can add:
    • %title – site name,
    • %url – the address of the site (for example, site.ru),
    • %message – comments,
    • %urlpage – link to a page on the site where the comment is displayed,
    • %actlink – link to unsubscribe.
    The parameter has different values for different language versions of the site. This parameter appears if the option marked "Subscribe for new comments".

    Example:

    Hello! You have subscribed to comments on the site %title (%url).<br> On the page there's <a href="%link">a new comment</a>:<br>%message <br><br> Can unsubscribe <a href="%actlink">link</a>.
  • E-mail sender – Possible values:
    • e-mail, specified as a parameter of the site;
    • other (when selected, an additional field appears register e-mail).
    This parameter appears if the option marked "Subscribe for new comments".
  • Notify about new comments by e-mail – Possibility to inform the administrator about new comments from the form in the user site part.
  • E-mail for administrator notifications – Possible values:
    • e-mail, specified as a parameter of the site;
    • other (when selected, an additional field appears register e-mail).
    This parameter appears if the option marked "Notify about new comments by e-mail".
  • Subject of notification e-mail – You can add:
    • %title – site name,
    • %url – the address of the site (for example, site.ru).
    This parameter appears if the option marked "Notify about new comments by e-mail".

    Example:

    %title (%url). New comment
  • Notification message – You can add:
    • %title – site name,
    • %url – the address of the site (for example, site.ru),
    • %message – comments,
    • %urlpage – link to a page on the site where the comment is displayed.
    This parameter appears if the option marked "Notify about new comments by e-mail".

    Example:

    Hello, admin of %title (%url)!<br>On page <a href="%urlpage">%urlpage</a> appeared new comment:<br>%message.
  • Notify about new comments by SMS – Possibility to send SMS to the administrator about posting of comment. Parameter can be enabled if SMS notification are set in Site parameters.
  • Phone number in federal format – Phone for SMS notifications of the administrator about a new comment. This parameter appears if the option marked "Notify about new comments by SMS".
  • Notification message – Text of the message for SMS notifications of the administrator about a new comment. Maximum 800 characters. This parameter appears if the option marked "Notify about new comments by SMS".

Template tags

Для работы с модулем «Comments» служат следующие шаблонные теги:

show_block – shows latest comments.

Атрибуты:

count – number of displayed comments (by default 3);

modules – модули (разделенные запятой), к которым подключены комментарии;

element_id – идентификаторы элементов модулей (разделенные запятой), к которым подключены комментарии;

element_type – type of elements (element – element (by default), cat – category);

sort – sorting comments: date – by date (by default), rand – randomly;

defer – deferred load tag template tag: event – load content only at the request of the user when you click "Upload", emergence – load content only when the client window appears in the browser window, async – asynchronous (simultaneous) content loading together with the content of template tags with the same marker, sync – synchronous (sequential) load of content in conjunction with the content of template tags with the same marker, by default, downloading content only at the request of the user;

defer_title – text string displayed at the point where the loadable content appears with the help of delayed loading of the template tag;

template – tag template (file modules/comments/views/comments.view.show_block_template.php; default - file modules/comments/views/comments.view.show_block.php).

Example:

<insert name="show_block" module="comments" modules="shop" count="2">

выведет 2 последних комментария к товарам

В шаблоне тега можно получить значение любого атрибута через переменную $result["attributes"]["название атрибута"].

Database

{comments} – Comments

{comments_mail} – Подписка пользователей на новые комментарии

{comments_param} – Дополнительные поля комментариев

{comments_param_element} – Значения дополнительных полей комментариев

{comments_param_select} – Варианты значения дополнительных полей комментариев с типом список

{comments_parents} – Parents relations of comments

Files

  1. modules/comments/admin/comments.admin.php – Editing comments;

  2. modules/comments/admin/comments.admin.config.php – Module settings;

  3. modules/comments/admin/comments.admin.count.php – Количество непроверенных коммментариев, если подключено модерирование комментариев, для меню административной панели;

  4. modules/comments/admin/comments.admin.dashboard.php – Комментарии для событий;

  5. modules/comments/admin/comments.admin.inc.php – Connecting the module to the administrative part of other modules;

  6. modules/comments/admin/comments.admin.param.php – Конструктор комментариев;

  7. modules/comments/admin/js/comments.admin.inc.config.js – Поле "Комментарии", JS-сценарий;

  8. modules/comments/admin/js/comments.admin.param.js – Конструктор комментариев, JS-сценарий;

  9. modules/comments/comments.php – Controller;

  10. modules/comments/comments.action.php – Обработка запроса при добавления комментария;

  11. modules/comments/comments.inc.php – Подключение модуля;

  12. modules/comments/comments.install.php – Module installation;

  13. modules/comments/comments.model.php – Model;

  14. modules/comments/comments.rss.php – RSS comments feed;

  15. modules/comments/js/comments.get.js – JS-сценарий модуля;

  16. modules/comments/views/comments.view.form.php – Шаблон формы добавления комментария;

  17. modules/comments/views/comments.view.get.php – Шаблон вывода комментариев;

  18. modules/comments/views/comments.view.id.php – Шаблон одного комментария;

  19. modules/comments/views/comments.view.images.php – Шаблон прикрепленных к комментарию изображения, выводимых в форме добавления комментария;

  20. modules/comments/views/comments.view.list.php – Шаблон списка комментариев;

  21. modules/comments/views/comments.view.rows_block.php – Шаблон блока комментариев;

  22. modules/comments/views/comments.view.show_block.php – Template of comments block;

  23. modules/comments/views/comments.view.show_block_main.php – Template of comments block.