1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
view.php
См. документацию.
1<?php
2namespace Bitrix\Landing\Landing;
3
4use Bitrix\Landing\PublicAction\Block;
5use \Bitrix\Main\Entity;
6use \Bitrix\Main\Type\DateTime;
7use \Bitrix\Landing\Manager;
8use \Bitrix\Landing\Landing;
9use \Bitrix\Landing\Rights;
10use \Bitrix\Landing\Internals\ViewTable;
11use \Bitrix\Landing\Controller;
12
13class View
14{
18 const SESSION_VIEWS_KEY = 'LANDING_VIEWS';
19
25 protected static function incViewsPage($lid)
26 {
27 $lid = (int)$lid;
28 $res = ViewTable::getList([
29 'select' => [
30 'SUM'
31 ],
32 'filter' => [
33 'LID' => $lid
34 ],
35 'runtime' => [
37 'SUM', 'SUM(%s)', ['VIEWS']
38 )
39 ]
40 ]);
41 if ($row = $res->fetch())
42 {
44 Landing::update($lid, [
45 'VIEWS' => $row['SUM'],
46 'DATE_MODIFY' => false
47 ]);
49 }
50 }
51
58 public static function inc($lid, $uid = null)
59 {
60 if (!$uid)
61 {
63 }
64 $lid = (int)$lid;
65 $uid = (int)$uid;
66 $date = new DateTime;
67
68 if ($uid <= 0)
69 {
70 return;
71 }
72 if (!isset($_SESSION[self::SESSION_VIEWS_KEY]))
73 {
74 $_SESSION[self::SESSION_VIEWS_KEY] = [];
75 }
76
77 if (!in_array($lid, $_SESSION[self::SESSION_VIEWS_KEY]))
78 {
79 $res = ViewTable::getList([
80 'select' => [
81 'ID', 'VIEWS'
82 ],
83 'filter' => [
84 'LID' => $lid,
85 'USER_ID' => $uid
86 ]
87 ]);
88 if ($row = $res->fetch())
89 {
90 $result = ViewTable::update($row['ID'], [
91 'VIEWS' => $row['VIEWS'] + 1,
92 'LAST_VIEW' => $date
93 ]);
94 }
95 else
96 {
97 $result = ViewTable::add([
98 'VIEWS' => 1,
99 'LID' => $lid,
100 'USER_ID' => $uid,
101 'FIRST_VIEW' => $date,
102 'LAST_VIEW' => $date,
103 ]);
104 }
105 if ($result->isSuccess())
106 {
107 self::incViewsPage($lid);
108 $_SESSION[self::SESSION_VIEWS_KEY][] = $lid;
109 }
110 }
111 }
112
113 public static function getNumberUniqueViews(int $lid): int
114 {
115 $lid = (int)$lid;
116 $res = ViewTable::getList([
117 'select' => [
118 'COUNT'
119 ],
120 'filter' => [
121 'LID' => $lid
122 ],
123 'runtime' => [
125 'COUNT', 'COUNT(*)'
126 )
127 ]
128 ]);
129
130 if ($row = $res->fetch())
131 {
132 $views = (int)$row['COUNT'];
133 }
134
135 if (isset($views) && is_int($views))
136 {
137 return $views;
138 }
139
140 return 0;
141 }
142
143 public static function getUniqueUserData(int $lid): array
144 {
145 $res = ViewTable::getList([
146 'select' => [
147 'USER_ID'
148 ],
149 'filter' => [
150 'LID' => $lid
151 ]
152 ]);
153 $data = [];
154 while ($row = $res->fetch())
155 {
156 $data['id'][] = $row['USER_ID'];
157 }
158 $usersInfo = Controller\User::getUsersInfoAction($data['id']);
159 $data['name'] = $usersInfo['name'];
160 $countUsers = count($usersInfo['name']);
161 for ($i = 0; $i < $countUsers; $i++)
162 {
163 if ($usersInfo['personalPhoto'][$i])
164 {
165 $avatar = \CFile::ResizeImageGet(
166 $usersInfo['personalPhoto'][$i],
167 ['width' => 58, 'height' => 58],
169 );
170 }
171 if (isset($avatar['src']))
172 {
173 $data['avatar'][] = $avatar['src'];
174 }
175 else
176 {
177 $data['avatar'][] = '';
178 }
179 unset($avatar);
180 }
181
182 return $data;
183 }
184}
static getUniqueUserData(int $lid)
Определения view.php:143
static incViewsPage($lid)
Определения view.php:25
static getNumberUniqueViews(int $lid)
Определения view.php:113
static inc($lid, $uid=null)
Определения view.php:58
const SESSION_VIEWS_KEY
Определения view.php:18
static getUserId()
Определения manager.php:107
static setOff()
Определения rights.php:89
static setOn()
Определения rights.php:98
static update($primary, array $data)
Определения file.php:228
$data['IS_AVAILABLE']
Определения .description.php:13
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$uid
Определения hot_keys_act.php:8
const BX_RESIZE_IMAGE_EXACT
Определения constants.php:12
Определения ufield.php:9
$i
Определения factura.php:643
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936