Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
conversionhandlers.php
1
<?php
2
3
namespace
Bitrix\Forum\Internals
;
4
5
use
Bitrix\Conversion\Config
;
6
use
Bitrix\Conversion\DayContext
;
7
use
Bitrix\Main\Loader
;
8
use
Bitrix\Main\Localization\Loc
;
9
10
Loc::loadMessages
(__FILE__);
11
12
final
class
ConversionHandlers
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
}
Bitrix\Conversion\Config
Definition
config.php:9
Bitrix\Conversion\DayContext
Definition
daycontext.php:14
Bitrix\Forum\Internals\ConversionHandlers
Definition
conversionhandlers.php:13
Bitrix\Forum\Internals\ConversionHandlers\onMessageAdd
static onMessageAdd($id, $message, $topicInfo, $forumInfo, $fields)
Definition
conversionhandlers.php:103
Bitrix\Forum\Internals\ConversionHandlers\onGetRateTypes
static onGetRateTypes()
Definition
conversionhandlers.php:33
Bitrix\Forum\Internals\ConversionHandlers\onTopicAdd
static onTopicAdd($id, $fields)
Definition
conversionhandlers.php:84
Bitrix\Forum\Internals\ConversionHandlers\onGetCounterTypes
static onGetCounterTypes()
Definition
conversionhandlers.php:20
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Forum\Internals
Definition
conversionhandlers.php:3
modules
forum
lib
internals
conversionhandlers.php
Создано системой
1.10.0