1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
ratings_components.php
См. документацию.
1
<?php
2
3
IncludeModuleLangFile
(
$_SERVER
[
"DOCUMENT_ROOT"
].
BX_ROOT
.
"/modules/forum/classes/general/ratings_components.php"
);
4
5
class
CAllRatingsComponentsForum
6
{
7
// return configs of component-rating
8
public
static
function
OnGetRatingConfigs
()
9
{
10
$arConfigs =
array
(
11
'MODULE_ID'
=>
'FORUM'
,
12
'MODULE_NAME'
=>
GetMessage
(
'FORUM_RATING_NAME'
)
13
);
14
$arConfigs[
"COMPONENT"
][
"USER"
][
"VOTE"
][] =
array
(
15
"ID"
=>
'TOPIC'
,
16
"REFRESH_TIME"
=>
'3600'
,
17
"CLASS"
=>
'CRatingsComponentsForum'
,
18
"CALC_METHOD"
=>
'CalcUserVoteForumTopic'
,
19
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_VOTE_TOPIC_NAME'
),
20
"DESC"
=>
GetMessage
(
'FORUM_RATING_USER_VOTE_TOPIC_DESC'
),
21
"FIELDS"
=>
array
(
22
array
(
23
"ID"
=>
'COEFFICIENT'
,
24
"DEFAULT"
=>
'0.5'
,
25
),
26
array
(
27
"ID"
=>
'LIMIT'
,
28
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_VOTE_TOPIC_LIMIT_NAME'
),
29
"DEFAULT"
=>
'30'
,
30
),
31
)
32
);
33
$arConfigs[
"COMPONENT"
][
"USER"
][
"VOTE"
][] =
array
(
34
"ID"
=>
'POST'
,
35
"REFRESH_TIME"
=>
'3600'
,
36
"CLASS"
=>
'CRatingsComponentsForum'
,
37
"CALC_METHOD"
=>
'CalcUserVoteForumPost'
,
38
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_VOTE_POST_NAME'
),
39
"DESC"
=>
GetMessage
(
'FORUM_RATING_USER_VOTE_POST_DESC'
),
40
"FIELDS"
=>
array
(
41
array
(
42
"ID"
=>
'COEFFICIENT'
,
43
"DEFAULT"
=>
'0.1'
,
44
),
45
array
(
46
"ID"
=>
'LIMIT'
,
47
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_VOTE_POST_LIMIT_NAME'
),
48
"DEFAULT"
=>
'30'
,
49
),
50
)
51
);
52
$arConfigs[
"COMPONENT"
][
"USER"
][
"RATING"
][] =
array
(
53
"ID"
=>
'ACTIVITY'
,
54
"REFRESH_TIME"
=>
'7200'
,
55
"CLASS"
=>
'CRatingsComponentsForum'
,
56
"CALC_METHOD"
=>
'CalcUserRatingForumActivity'
,
57
"EXCEPTION_METHOD"
=>
'ExceptionUserRatingForumActivity'
,
58
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_RATING_ACTIVITY_NAME'
),
59
"DESC"
=>
GetMessage
(
'FORUM_RATING_USER_RATING_ACTIVITY_DESC'
),
60
"FORMULA"
=>
'T<sub>1</sub> * K<sub>T1</sub> + T<sub>7</sub> * K<sub>T7</sub> + T<sub>30</sub> * K<sub>T30</sub>+ T<sub>all</sub> * K<sub>Tall</sub> + P<sub>1</sub> * K<sub>P1</sub> + P<sub>7</sub> * K<sub>P7</sub> + P<sub>30</sub> * K<sub>P30</sub> + P<sub>all</sub> * K<sub>Pall</sub>'
,
61
"FORMULA_DESC"
=>
GetMessage
(
'FORUM_RATING_USER_RATING_ACTIVITY_FORMULA_DESC'
),
62
"FIELDS"
=>
array
(
63
array
(
64
"ID"
=>
'TODAY_TOPIC_COEF'
,
65
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_RATING_ACTIVITY_FIELDS_TODAY_TOPIC_COEF'
),
66
"DEFAULT"
=>
'0.4'
,
67
),
68
array
(
69
"ID"
=>
'WEEK_TOPIC_COEF'
,
70
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_RATING_ACTIVITY_FIELDS_WEEK_TOPIC_COEF'
),
71
"DEFAULT"
=>
'0.2'
,
72
),
73
array
(
74
"ID"
=>
'MONTH_TOPIC_COEF'
,
75
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_RATING_ACTIVITY_FIELDS_MONTH_TOPIC_COEF'
),
76
"DEFAULT"
=>
'0.1'
,
77
),
78
array
(
79
"ID"
=>
'ALL_TOPIC_COEF'
,
80
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_RATING_ACTIVITY_FIELDS_ALL_TOPIC_COEF'
),
81
"DEFAULT"
=>
'0'
,
82
),
83
array
(
84
"ID"
=>
'TODAY_POST_COEF'
,
85
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_RATING_ACTIVITY_FIELDS_TODAY_POST_COEF'
),
86
"DEFAULT"
=>
'0.2'
,
87
),
88
array
(
89
"ID"
=>
'WEEK_POST_COEF'
,
90
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_RATING_ACTIVITY_FIELDS_WEEK_POST_COEF'
),
91
"DEFAULT"
=>
'0.1'
,
92
),
93
array
(
94
"ID"
=>
'MONTH_POST_COEF'
,
95
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_RATING_ACTIVITY_FIELDS_MONTH_POST_COEF'
),
96
"DEFAULT"
=>
'0.05'
,
97
),
98
array
(
99
"ID"
=>
'ALL_POST_COEF'
,
100
"NAME"
=>
GetMessage
(
'FORUM_RATING_USER_RATING_ACTIVITY_FIELDS_ALL_POST_COEF'
),
101
"DEFAULT"
=>
'0'
,
102
),
103
)
104
);
105
106
return
$arConfigs;
107
}
108
109
// return support object
110
public
static
function
OnGetRatingObject
()
111
{
112
$arRatingConfigs =
CRatingsComponentsForum::OnGetRatingConfigs
();
113
foreach
($arRatingConfigs[
"COMPONENT"
] as $SupportType => $value)
114
$arSupportType[] = $SupportType;
115
116
return
$arSupportType;
117
}
118
119
// check the value of the component-rating which relate to the module
120
public
static
function
OnAfterAddRating
(
$ID
,
$arFields
)
121
{
122
$arFields
[
'CONFIGS'
][
'FORUM'
] =
CRatingsComponentsForum::__CheckFields
(
$arFields
[
'ENTITY_ID'
],
$arFields
[
'CONFIGS'
][
'FORUM'
]);
123
124
return
$arFields
;
125
}
126
127
// check the value of the component-rating which relate to the module
128
public
static
function
OnAfterUpdateRating
(
$ID
,
$arFields
)
129
{
130
$arFields
[
'CONFIGS'
][
'FORUM'
] =
CRatingsComponentsForum::__CheckFields
(
$arFields
[
'ENTITY_ID'
],
$arFields
[
'CONFIGS'
][
'FORUM'
]);
131
132
return
$arFields
;
133
}
134
135
// Utilities
136
137
// check input values, if value does not validate, set the default value
138
public
static
function
__CheckFields
(
$entityId
, $arConfigs)
139
{
140
$arDefaultConfig =
CRatingsComponentsForum::__AssembleConfigDefault
(
$entityId
);
141
if
(
$entityId
==
"USER"
) {
142
if
(isset($arConfigs[
'VOTE'
][
'TOPIC'
]))
143
{
144
if
(!preg_match(
'/^\d{1,7}\.?\d{0,4}$/'
, $arConfigs[
'VOTE'
][
'TOPIC'
][
'COEFFICIENT'
]))
145
$arConfigs[
'VOTE'
][
'TOPIC'
][
'COEFFICIENT'
] = $arDefaultConfig[
'VOTE'
][
'TOPIC'
][
'COEFFICIENT'
][
'DEFAULT'
];
146
if
(!preg_match(
'/^\d{1,5}$/'
, $arConfigs[
'VOTE'
][
'TOPIC'
][
'LIMIT'
]))
147
$arConfigs[
'VOTE'
][
'TOPIC'
][
'LIMIT'
] = $arDefaultConfig[
'VOTE'
][
'TOPIC'
][
'LIMIT'
][
'DEFAULT'
];
148
}
149
150
if
(isset($arConfigs[
'VOTE'
][
'POST'
]))
151
{
152
if
(!preg_match(
'/^\d{1,7}\.?\d{0,4}$/'
, $arConfigs[
'VOTE'
][
'POST'
][
'COEFFICIENT'
]))
153
$arConfigs[
'VOTE'
][
'POST'
][
'COEFFICIENT'
] = $arDefaultConfig[
'VOTE'
][
'POST'
][
'COEFFICIENT'
][
'DEFAULT'
];
154
if
(!preg_match(
'/^\d{1,5}$/'
, $arConfigs[
'VOTE'
][
'POST'
][
'LIMIT'
]))
155
$arConfigs[
'VOTE'
][
'POST'
][
'LIMIT'
] = $arDefaultConfig[
'VOTE'
][
'POST'
][
'LIMIT'
][
'DEFAULT'
];
156
}
157
158
if
(isset($arConfigs[
'RATING'
][
'ACTIVITY'
]))
159
{
160
if
(!preg_match(
'/^\d{1,7}\.?\d{0,4}$/'
, $arConfigs[
'RATING'
][
'ACTIVITY'
][
'TODAY_TOPIC_COEF'
]))
161
$arConfigs[
'RATING'
][
'ACTIVITY'
][
'TODAY_TOPIC_COEF'
] = $arDefaultConfig[
'RATING'
][
'ACTIVITY'
][
'TODAY_TOPIC_COEF'
][
'DEFAULT'
];
162
163
if
(!preg_match(
'/^\d{1,7}\.?\d{0,4}$/'
, $arConfigs[
'RATING'
][
'ACTIVITY'
][
'WEEK_TOPIC_COEF'
]))
164
$arConfigs[
'RATING'
][
'ACTIVITY'
][
'WEEK_TOPIC_COEF'
] = $arDefaultConfig[
'RATING'
][
'ACTIVITY'
][
'WEEK_TOPIC_COEF'
][
'DEFAULT'
];
165
166
if
(!preg_match(
'/^\d{1,7}\.?\d{0,4}$/'
, $arConfigs[
'RATING'
][
'ACTIVITY'
][
'MONTH_TOPIC_COEF'
]))
167
$arConfigs[
'RATING'
][
'ACTIVITY'
][
'MONTH_TOPIC_COEF'
] = $arDefaultConfig[
'RATING'
][
'ACTIVITY'
][
'MONTH_TOPIC_COEF'
][
'DEFAULT'
];
168
169
if
(!preg_match(
'/^\d{1,7}\.?\d{0,4}$/'
, $arConfigs[
'RATING'
][
'ACTIVITY'
][
'ALL_TOPIC_COEF'
]))
170
$arConfigs[
'RATING'
][
'ACTIVITY'
][
'ALL_TOPIC_COEF'
] = $arDefaultConfig[
'RATING'
][
'ACTIVITY'
][
'ALL_TOPIC_COEF'
][
'DEFAULT'
];
171
172
if
(!preg_match(
'/^\d{1,7}\.?\d{0,4}$/'
, $arConfigs[
'RATING'
][
'ACTIVITY'
][
'TODAY_POST_COEF'
]))
173
$arConfigs[
'RATING'
][
'ACTIVITY'
][
'TODAY_POST_COEF'
] = $arDefaultConfig[
'RATING'
][
'ACTIVITY'
][
'TODAY_POST_COEF'
][
'DEFAULT'
];
174
175
if
(!preg_match(
'/^\d{1,7}\.?\d{0,4}$/'
, $arConfigs[
'RATING'
][
'ACTIVITY'
][
'WEEK_POST_COEF'
]))
176
$arConfigs[
'RATING'
][
'ACTIVITY'
][
'WEEK_POST_COEF'
] = $arDefaultConfig[
'RATING'
][
'ACTIVITY'
][
'WEEK_POST_COEF'
][
'DEFAULT'
];
177
178
if
(!preg_match(
'/^\d{1,7}\.?\d{0,4}$/'
, $arConfigs[
'RATING'
][
'ACTIVITY'
][
'MONTH_POST_COEF'
]))
179
$arConfigs[
'RATING'
][
'ACTIVITY'
][
'MONTH_POST_COEF'
] = $arDefaultConfig[
'RATING'
][
'ACTIVITY'
][
'MONTH_POST_COEF'
][
'DEFAULT'
];
180
181
if
(!preg_match(
'/^\d{1,7}\.?\d{0,4}$/'
, $arConfigs[
'RATING'
][
'ACTIVITY'
][
'ALL_POST_COEF'
]))
182
$arConfigs[
'RATING'
][
'ACTIVITY'
][
'ALL_POST_COEF'
] = $arDefaultConfig[
'RATING'
][
'ACTIVITY'
][
'ALL_POST_COEF'
][
'DEFAULT'
];
183
}
184
}
185
186
return
$arConfigs;
187
}
188
189
// collect the default and regular expressions for the fields component-rating
190
public
static
function
__AssembleConfigDefault
($objectType =
null
)
191
{
192
$arConfigs =
array
();
193
$arRatingConfigs =
CRatingsComponentsForum::OnGetRatingConfigs
();
194
if
(is_null($objectType))
195
{
196
foreach
($arRatingConfigs[
"COMPONENT"
] as $OBJ_TYPE => $TYPE_VALUE)
197
foreach
($TYPE_VALUE as $RAT_TYPE => $RAT_VALUE)
198
foreach
($RAT_VALUE as $VALUE_CONFIG)
199
foreach
($VALUE_CONFIG[
'FIELDS'
] as $VALUE_FIELDS)
200
$arConfigs[$OBJ_TYPE][$RAT_TYPE][$VALUE_CONFIG[
'ID'
]][$VALUE_FIELDS[
'ID'
]][
'DEFAULT'
] = $VALUE_FIELDS[
'DEFAULT'
];
201
}
202
else
203
{
204
foreach
($arRatingConfigs[
"COMPONENT"
][$objectType] as $RAT_TYPE => $RAT_VALUE)
205
foreach
($RAT_VALUE as $VALUE_CONFIG)
206
foreach
($VALUE_CONFIG[
'FIELDS'
] as $VALUE_FIELDS)
207
$arConfigs[$RAT_TYPE][$VALUE_CONFIG[
'ID'
]][$VALUE_FIELDS[
'ID'
]][
'DEFAULT'
] = $VALUE_FIELDS[
'DEFAULT'
];
208
209
}
210
211
return
$arConfigs;
212
}
213
214
public
static
function
OnGetRatingContentOwner
(
$arParams
)
215
{
216
if
(
$arParams
[
'ENTITY_TYPE_ID'
] ==
'FORUM_TOPIC'
)
217
{
218
$arTopic =
CForumTopic::GetByID
(intval(
$arParams
[
'ENTITY_ID'
]));
219
return
$arTopic[
'USER_START_ID'
];
220
}
221
elseif
(
$arParams
[
'ENTITY_TYPE_ID'
] ==
'FORUM_POST'
)
222
{
223
$arMessage =
CForumMessage::GetByID
(intval(
$arParams
[
'ENTITY_ID'
]));
224
return
$arMessage[
'AUTHOR_ID'
];
225
}
226
return
false
;
227
}
228
}
$arParams
$arParams
Определения
access_dialog.php:21
BX_ROOT
const BX_ROOT
Определения
bx_root.php:3
CAllForumMessage\GetByID
static GetByID($ID, $arAddParams=array())
Определения
message.php:591
CAllForumTopic\GetByID
static GetByID($ID, $arAddParams=array())
Определения
topic.php:431
CAllRatingsComponentsForum
Определения
ratings_components.php:6
CAllRatingsComponentsForum\OnAfterAddRating
static OnAfterAddRating($ID, $arFields)
Определения
ratings_components.php:120
CAllRatingsComponentsForum\__CheckFields
static __CheckFields($entityId, $arConfigs)
Определения
ratings_components.php:138
CAllRatingsComponentsForum\OnGetRatingContentOwner
static OnGetRatingContentOwner($arParams)
Определения
ratings_components.php:214
CAllRatingsComponentsForum\__AssembleConfigDefault
static __AssembleConfigDefault($objectType=null)
Определения
ratings_components.php:190
CAllRatingsComponentsForum\OnAfterUpdateRating
static OnAfterUpdateRating($ID, $arFields)
Определения
ratings_components.php:128
CAllRatingsComponentsForum\OnGetRatingConfigs
static OnGetRatingConfigs()
Определения
ratings_components.php:8
CAllRatingsComponentsForum\OnGetRatingObject
static OnGetRatingObject()
Определения
ratings_components.php:110
$arFields
$arFields
Определения
dblapprove.php:5
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$ID
if($ajaxMode) $ID
Определения
get_user.php:27
$_SERVER
$_SERVER["DOCUMENT_ROOT"]
Определения
cron_frame.php:9
IncludeModuleLangFile
IncludeModuleLangFile($filepath, $lang=false, $bReturnArray=false)
Определения
tools.php:3778
GetMessage
GetMessage($name, $aReplace=null)
Определения
tools.php:3397
$entityId
$entityId
Определения
payment.php:4
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
bitrix
modules
forum
classes
general
ratings_components.php
Создано системой
1.14.0