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 'blog_post_add_day' => array('MODULE' => 'blog', 'GROUP' => 'day', 'NAME' => 'Post'),
24 );
25 }
26
32 public static function onGetRateTypes()
33 {
34 $scale = array(0.5, 1, 1.5, 2, 5);
35
36 return array(
37 'blog_post' => array(
38 'NAME' => Loc::getMessage('BLOG_CONVERSION_RATE_POST_TITLE'),
39 'SCALE' => $scale,
40 'MODULE' => 'blog',
41 'SORT' => 4000,
42 'COUNTERS' => array('conversion_visit_day', 'blog_post_add_day'),
43 'CALCULATE' => function(array $counters)
44 {
45 $denominator = $counters['conversion_visit_day'] ?: 0;
46 $numerator = $counters['blog_post_add_day'] ?: 0;
47
48 return array(
49 'DENOMINATOR' => $denominator,
50 'NUMERATOR' => $numerator,
51 'RATE' => $denominator ? $numerator / $denominator : 0,
52 );
53 },
54 ),
55 );
56 }
57
65 public static function onPostAdd($id, $fields)
66 {
67 if (Loader::includeModule('conversion'))
68 {
69 $context = DayContext::getInstance();
70 $context->addDayCounter('blog_post_add_day', 1);
71 }
72 }
73
74}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29