Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
conversionhandlers.php
1<?php
2
4
9
10Loc::loadMessages(__FILE__);
11
13{
14
20 public static function onGetCounterTypes()
21 {
22 return array(
23 'forum_post_add_day' => array('MODULE' => 'forum', 'GROUP' => 'day', 'NAME' => 'Post'),
24 'forum_topic_add_day' => array('MODULE' => 'forum', 'GROUP' => 'day', 'NAME' => 'Topic'),
25 );
26 }
27
33 public static function onGetRateTypes()
34 {
35 $scale = array(0.5, 1, 1.5, 2, 5);
36
37 return array(
38 'forum_topic' => array(
39 'NAME' => Loc::getMessage('FORUM_CONVERSION_RATE_TOPIC_TITLE'),
40 'SCALE' => $scale,
41 'MODULE' => 'forum',
42 'SORT' => 3000,
43 'COUNTERS' => array('conversion_visit_day', 'forum_topic_add_day'),
44 'CALCULATE' => function(array $counters)
45 {
46 $denominator = $counters['conversion_visit_day'] ?: 0;
47 $numerator = $counters['forum_topic_add_day'] ?: 0;
48
49 return array(
50 'DENOMINATOR' => $denominator,
51 'NUMERATOR' => $numerator,
52 'RATE' => $denominator ? $numerator / $denominator : 0,
53 );
54 },
55 ),
56 'forum_post' => array(
57 'NAME' => Loc::getMessage('FORUM_CONVERSION_RATE_POST_TITLE'),
58 'SCALE' => $scale,
59 'MODULE' => 'forum',
60 'SORT' => 3100,
61 'COUNTERS' => array('conversion_visit_day', 'forum_post_add_day'),
62 'CALCULATE' => function(array $counters)
63 {
64 $denominator = $counters['conversion_visit_day'] ?: 0;
65 $numerator = $counters['forum_post_add_day'] ?: 0;
66
67 return array(
68 'DENOMINATOR' => $denominator,
69 'NUMERATOR' => $numerator,
70 'RATE' => $denominator ? $numerator / $denominator : 0,
71 );
72 },
73 ),
74 );
75 }
76
84 public static function onTopicAdd($id, $fields)
85 {
86 if (Loader::includeModule('conversion'))
87 {
88 $context = DayContext::getInstance();
89 $context->addDayCounter('forum_topic_add_day', 1);
90 }
91 }
92
103 public static function onMessageAdd($id, $message, $topicInfo, $forumInfo, $fields)
104 {
105 if (Loader::includeModule('conversion'))
106 {
107 $context = DayContext::getInstance();
108 $context->addDayCounter('forum_post_add_day', 1);
109 }
110 }
111
112}
static onMessageAdd($id, $message, $topicInfo, $forumInfo, $fields)
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29