Module refers to the part of the CMS "Interactive" and can be installed optionally.
Module "Rating" is connected to the other modules. The standard DIAFAN.CMS «Rating» connected to the following modules: Photogallery, News, Articles, Online shop, Files, Question-Answer, Ads. As part of the rating module is connected to a specific module settings.
The user of the site passes the vote with Ajax technology, ie without reloading the whole page.
Подключаемая часть – файл modules/rating/rating.inc.php. В нем описан класс
Rating_inc. В модуле к объекту класса можно обратиться через переменную $this->diafan->_rating
. Экземпляр класса создается при первом вызове
переменной.
string get ([integer $element_id = 0], [string $module_name = ''], [string $element_type = 'element'], [integer $site_id = 0], [boolean $full = false]) – Показывает рейтинг для элемента.
Example:
// get product rating
// in the file modules/shop/shop.model.php
$rating = $this->diafan->_rating->get($id, 'shop');
// output rating in the template modules/shop/views/shop.view.id.php
echo $rating;
void prepare ([integer $element_id = 0], [strint $module_name = ''], [string $element_type = 'element']) – Запоминает данные элемента, которому нужно будет вывести рейтинг.
Example:
// in this example will be send 3 SQL-queries to DB
// to get ratings of all determ products
$ids = array(3, 5, 7);
foreach($ids as $id)
{
$rating[$id] = $this->diafan->_rating->get($id, 'shop');
}
Example:
// in this example will be send 1 SQL-query to DB
// to get ratings of all determ products
$ids = array(3, 5, 7);
foreach($ids as $id)
{
$this->diafan->_rating->prepare($id, 'shop');
}
foreach($ids as $id)
{
$rating[$id] = $this->diafan->_rating->get($id, 'shop');
}
void delete (integer|array $element_ids, strint $module_name, [string $element_type = 'element']) – Удаляет рейтинг для одного или нескольких элементов.
Example:
// delete rating of news category ID=3
$this->diafan->_rating->delete(3, 'news', 'cat');
// delete ratings of news ID=3,4,5
$this->diafan->_rating->delete(array(3, 4, 5) 'news');
void delete_module (string $module_name) – Удаляет все рейтинги элементов модуля.
Example:
// delete ratings of all news and news categories
$this->diafan->_rating->delete_module('news');
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
'rating'
:
Example:
public $variables = array(
'main' => array(
'rating' => 'module',
…
),
…
);
The administrative part of the module going to the mean scores for all elements of the different modules in one table and displayed as an update. Rating individual module elements can be seen without visiting the section "Rating" in the administrative part, as the average rating and the number of votes for the item is displayed when editing the module element connected to the rating.
When you delete an item, that item is deleted evaluation.
Rating has the following characteristics.
The list displays the name of the estimates and the estimated unit cell.
{rating} – Рейтинг элементов модулей
modules/rating/admin/js/rating.admin.inc.config.js – Поле "Рейтинг", JS-сценарий;
modules/rating/admin/rating.admin.php – Редактирование рейтигов;
modules/rating/admin/rating.admin.config.php – Module settings;
modules/rating/admin/rating.admin.inc.php – Connecting the module to the administrative part of other modules;
modules/rating/img/* – images;
modules/rating/js/rating.get.js – JS-сценарий модуля;
modules/rating/rating.php – Controller;
modules/rating/rating.action.php – Processes the received data from the form;
modules/rating/rating.inc.php – Подключение модуля;
modules/rating/rating.install.php – Module installation;
modules/rating/views/rating.view.get.php – Шаблон рейтинга элемента.