Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
searchhelper.php
1
<?
9
namespace
Bitrix\Sale\Location\Admin
;
10
11
use
Bitrix\Main\Localization\Loc
;
12
use
Bitrix\Main\Config\Option
;
13
14
//use Bitrix\Sale\Location;
15
use
Bitrix\Sale\Location\Search\Finder
;
16
use
Bitrix\Sale\Location\Import\ImportProcess
;
17
use
Bitrix\Sale\Location\DB
;
18
19
Loc::loadMessages
(__FILE__);
20
21
final
class
SearchHelper
22
{
23
const
INDEX_RECHECK_COUNTER_OPT
=
'sale.location.index_recheck_counter'
;
24
const
INDEX_VALID_OPT
=
'sale.location.db_index_valid'
;
25
const
HITS_BETWEEN_RECHECKS
= 20;
26
27
protected
static
function
setCounter
($value)
28
{
29
Option::set(
'sale'
, self::INDEX_RECHECK_COUNTER_OPT, $value,
''
);
30
}
31
32
protected
static
function
getCounter
()
33
{
34
return
intval(Option::get(
'sale'
, self::INDEX_RECHECK_COUNTER_OPT,
''
,
''
));
35
}
36
37
protected
static
function
showSearchNotification
()
38
{
39
$reindexUrl =
Helper::getReindexUrl
();
40
global $adminSidePanelHelper;
41
$reindexUrl = $adminSidePanelHelper->editUrlToPublicPage($reindexUrl);
42
$params = array(
'MESSAGE'
=>
Loc::getMessage
(
43
'SALE_LOCATION_ADMIN_SEARCH_HELPER_ENTITY_INVALID_SINDEX'
,
44
array(
'#ANCHOR_INDEX_RESTORE#'
=>
'<a href="'
.$reindexUrl.
'" target="_blank">'
,
"#ANCHOR_END#"
=>
'</a>'
)
45
),
'type'
=>
'ERROR'
,
'HTML'
=>
true
);
46
if
(defined(
'PUBLIC_MODE'
) && PUBLIC_MODE == 1)
47
{
48
$params[
"SKIP_PUBLIC_MODE"
] =
true
;
49
}
50
\CAdminMessage::ShowMessage($params);
51
}
52
53
public
static
function
checkIndexValid
()
54
{
55
return
Option::get(
'sale'
, self::INDEX_VALID_OPT,
''
,
''
) !=
'N'
;
56
}
57
58
public
static
function
setIndexValid
()
59
{
60
Option::set(
'sale'
, self::INDEX_VALID_OPT,
'Y'
,
''
);
61
}
62
63
public
static
function
setIndexInvalid
()
64
{
65
Option::set(
'sale'
, self::INDEX_VALID_OPT,
'N'
,
''
);
66
}
67
68
protected
static
function
showDBIndexNotification
()
69
{
70
$importUrl =
Helper::getImportUrl
();
71
global $adminSidePanelHelper;
72
$importUrl = $adminSidePanelHelper->editUrlToPublicPage($importUrl);
73
$params = array(
'MESSAGE'
=>
Loc::getMessage
(
74
'SALE_LOCATION_ADMIN_SEARCH_HELPER_ENTITY_INVALID_DBINDEX'
,
75
array(
'#ANCHOR_INDEX_RESTORE#'
=>
'<a href="'
.$importUrl.
'" target="_blank">'
,
"#ANCHOR_END#"
=>
'</a>'
)
76
),
'type'
=>
'ERROR'
,
'HTML'
=>
true
);
77
if
(defined(
'PUBLIC_MODE'
) && PUBLIC_MODE == 1)
78
{
79
$params[
"SKIP_PUBLIC_MODE"
] =
true
;
80
}
81
\CAdminMessage::ShowMessage($params);
82
}
83
84
public
static
function
checkIndexesValid
()
85
{
86
if
(!
Finder::checkIndexValid
())
87
static::showSearchNotification();
88
89
$cnt = static::getCounter();
90
91
if
($cnt > static::HITS_BETWEEN_RECHECKS || !static::checkIndexValid())
92
{
93
$allOk =
true
;
94
$map =
ImportProcess::getIndexMap
();
95
if
(is_array($map))
96
{
97
foreach
($map as $ixName => $ixInfo)
98
{
99
$ixInfo[
'DROP_ONLY'
] ??=
false
;
100
if
(!$ixInfo[
'DROP_ONLY'
] && !DB\Helper::checkIndexNameExists($ixName, $ixInfo[
'TABLE'
]))
101
{
102
$allOk =
false
;
103
break
;
104
}
105
}
106
}
107
else
108
$allOk =
false
;
109
110
if
($allOk)
111
static::setIndexValid();
112
else
113
static::setIndexInvalid();
114
115
static::setCounter(0);
116
}
117
else
118
static::setCounter($cnt + 1);
119
120
if
(!static::checkIndexValid())
121
static::showDBIndexNotification();
122
}
123
}
Bitrix\Main\Config\Option
Definition
option.php:15
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\Sale\Location\Admin\Helper\getImportUrl
static getImportUrl()
Definition
helper.php:567
Bitrix\Sale\Location\Admin\Helper\getReindexUrl
static getReindexUrl()
Definition
helper.php:572
Bitrix\Sale\Location\Admin\SearchHelper
Definition
searchhelper.php:22
Bitrix\Sale\Location\Admin\SearchHelper\checkIndexesValid
static checkIndexesValid()
Definition
searchhelper.php:84
Bitrix\Sale\Location\Admin\SearchHelper\checkIndexValid
static checkIndexValid()
Definition
searchhelper.php:53
Bitrix\Sale\Location\Admin\SearchHelper\HITS_BETWEEN_RECHECKS
const HITS_BETWEEN_RECHECKS
Definition
searchhelper.php:25
Bitrix\Sale\Location\Admin\SearchHelper\showDBIndexNotification
static showDBIndexNotification()
Definition
searchhelper.php:68
Bitrix\Sale\Location\Admin\SearchHelper\INDEX_VALID_OPT
const INDEX_VALID_OPT
Definition
searchhelper.php:24
Bitrix\Sale\Location\Admin\SearchHelper\setIndexValid
static setIndexValid()
Definition
searchhelper.php:58
Bitrix\Sale\Location\Admin\SearchHelper\setIndexInvalid
static setIndexInvalid()
Definition
searchhelper.php:63
Bitrix\Sale\Location\Admin\SearchHelper\INDEX_RECHECK_COUNTER_OPT
const INDEX_RECHECK_COUNTER_OPT
Definition
searchhelper.php:23
Bitrix\Sale\Location\Admin\SearchHelper\setCounter
static setCounter($value)
Definition
searchhelper.php:27
Bitrix\Sale\Location\Admin\SearchHelper\getCounter
static getCounter()
Definition
searchhelper.php:32
Bitrix\Sale\Location\Admin\SearchHelper\showSearchNotification
static showSearchNotification()
Definition
searchhelper.php:37
Bitrix\Sale\Location\Import\ImportProcess
Definition
importprocess.php:20
Bitrix\Sale\Location\Import\ImportProcess\getIndexMap
static getIndexMap()
Definition
importprocess.php:1830
Bitrix\Sale\Location\Search\Finder
Definition
finder.php:21
Bitrix\Sale\Location\Search\Finder\checkIndexValid
static checkIndexValid()
Definition
finder.php:30
Bitrix\Sale\Location\Admin
Definition
defaultsitehelper.php:9
Bitrix\Sale\Location\DB
Definition
blockinserter.php:9
modules
sale
lib
location
admin
searchhelper.php
Создано системой
1.10.0