Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
searchcontent.php
1<?php
3
4use \Bitrix\Landing\Internals\LandingTable;
5use \Bitrix\Main\Update\Stepper;
6use \Bitrix\Main\Config\Option;
7
14{
18 const OPTION_CODE = 'update_landing_search_content';
19 const OPTION_CODE_SCOPES = 'update_landing_search_content_scopes';
20
25 protected static $moduleId = 'landing';
26
32 public function execute(array &$result)
33 {
34 $lastId = Option::get('landing', self::OPTION_CODE, 0);
35 $scopes = Option::get('landing', self::OPTION_CODE_SCOPES, '');
36 $scopes = unserialize($scopes, ['allowed_classes' => false]);
37 $finished = true;
38
39 \Bitrix\Landing\Rights::setGlobalOff();
40
41 if (!isset($result['steps']))
42 {
43 $result['steps'] = 0;
44 }
45
46 if (!is_array($scopes))
47 {
48 $scopes = [];
49 }
50
51 if (isset($scopes[0]))
52 {
53 \Bitrix\Landing\Site\Type::clearScope();
54 \Bitrix\Landing\Site\Type::setScope($scopes[0]);
55 }
56
57 // calculate count of records, which we need
59 'select' => [
61 'CNT', 'COUNT(*)'
62 )
63 ],
64 'filter' => [
65 '=DELETED' => ['Y', 'N'],
66 '=SITE.DELETED' => ['Y', 'N']
67 ]
68 ]);
69 if ($row = $res->fetch())
70 {
71 $result['count'] = $row['CNT'];
72 }
73
74 // one group for update
76 'select' => [
77 'ID',
78 'SITE_TYPE' => 'SITE.TYPE'
79 ],
80 'filter' => [
81 '>ID' => $lastId,
82 '=DELETED' => ['Y', 'N'],
83 '=SITE.DELETED' => ['Y', 'N']
84 ],
85 'order' => [
86 'ID' => 'ASC'
87 ],
88 'limit' => 20
89 ]);
90 while ($row = $res->fetch())
91 {
92 $finished = false;
93 $lastId = $row['ID'];
94 $result['steps']++;
95
96 \Bitrix\Landing\Hook::indexLanding(
97 $row['ID']
98 );
99 }
100
101 if ($finished && $scopes)
102 {
103 array_shift($scopes);
104 if ($scopes)
105 {
106 $finished = false;
107 $lastId = 0;
108 $result['steps'] = 0;
109 }
110 }
111
112 \Bitrix\Landing\Rights::setGlobalOn();
113
114 if (!$finished)
115 {
116 $scopes = array_values($scopes);
117 Option::set('landing', self::OPTION_CODE, $lastId);
118 Option::set('landing', self::OPTION_CODE_SCOPES, serialize($scopes));
119 return true;
120 }
121 else
122 {
123 Option::delete('landing', ['name' => self::OPTION_CODE]);
124 Option::delete('landing', ['name' => self::OPTION_CODE_SCOPES]);
125 return false;
126 }
127 }
128}
static getList(array $params=array())
Definition landing.php:602