Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
sitelink.php
1
<?php
8
namespace
Bitrix\Sale\Location\Search
;
9
10
use
Bitrix\Main
;
11
use
Bitrix\Main\DB
;
12
use
Bitrix\Main\Entity
;
13
use
Bitrix\Main\Localization\Loc
;
14
15
use
Bitrix\Sale\Location
;
16
use
Bitrix\Sale\Location\DB\Helper
;
17
18
Loc::loadMessages
(__FILE__);
19
36
final
class
SiteLinkTable
extends
Entity\DataManager
37
{
38
public
static
function
getFilePath
()
39
{
40
return
__FILE__;
41
}
42
43
public
static
function
getTableName
()
44
{
45
return
'b_sale_loc_search_sitlnk'
;
46
}
47
48
public
static
function
checkTableExists
()
49
{
50
static
$tableExists;
51
52
if
($tableExists ===
null
)
53
$tableExists = Main\HttpApplication::getConnection()->isTableExists(static::getTableName());
54
55
return
$tableExists;
56
}
57
58
public
static
function
cleanUpData
()
59
{
60
Helper::dropTable(static::getTableName());
61
62
// ORACLE: OK, MSSQL: OK
63
$sql =
"create table "
.static::getTableName().
"
64
(
65
LOCATION_ID "
.Helper::getSqlForDataType(
'int'
).
",
66
SITE_ID "
.Helper::getSqlForDataType(
'char'
, 2).
",
67
68
primary key (LOCATION_ID, SITE_ID)
69
)"
;
70
71
Main\HttpApplication::getConnection()->query($sql);
72
}
73
74
public
static
function
initializeData
()
75
{
76
$locationTable = Location\LocationTable::getTableName();
77
$groupLocationTable = Location\GroupLocationTable::getTableName();
78
$siteLocationTable = Location\SiteLocationTable::getTableName();
79
80
// ORACLE: OK, MSSQL: OK
81
$sql =
"
82
insert into "
.static::getTableName().
"
83
(LOCATION_ID, SITE_ID)
84
select LC.ID, LS.SITE_ID
85
from "
.$siteLocationTable.
" LS
86
inner join "
.$locationTable.
" L on LS.LOCATION_ID = L.ID and LS.LOCATION_TYPE = 'L'
87
inner join "
.$locationTable.
" LC on LC.LEFT_MARGIN >= L.LEFT_MARGIN and LC.RIGHT_MARGIN <= L.RIGHT_MARGIN
88
union
89
select LC.ID, LS.SITE_ID
90
from "
.$siteLocationTable.
" LS
91
inner join "
.$groupLocationTable.
" LG on LS.LOCATION_ID = LG.LOCATION_GROUP_ID and LS.LOCATION_TYPE = 'G'
92
inner join "
.$locationTable.
" L on LG.LOCATION_ID = L.ID
93
inner join "
.$locationTable.
" LC on LC.LEFT_MARGIN >= L.LEFT_MARGIN and LC.RIGHT_MARGIN <= L.RIGHT_MARGIN
94
"
;
95
96
Main\HttpApplication::getConnection()->query($sql);
97
}
98
99
public
static
function
createIndex
()
100
{
101
Helper::createIndex(static::getTableName(),
'S'
, array(
'SITE_ID'
));
102
}
103
104
public
static
function
getMap
()
105
{
106
return
array(
107
108
'LOCATION_ID'
=> array(
109
'data_type'
=>
'integer'
,
110
'required'
=>
true
,
111
'primary'
=>
true
112
),
113
'SITE_ID'
=> array(
114
'data_type'
=>
'integer'
,
115
'required'
=>
true
,
116
'primary'
=>
true
117
),
118
);
119
}
120
}
121
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Sale\Location\DB\Helper
Definition
helper.php:19
Bitrix\Sale\Location\Search\SiteLinkTable
Definition
sitelink.php:37
Bitrix\Sale\Location\Search\SiteLinkTable\getMap
static getMap()
Definition
sitelink.php:104
Bitrix\Sale\Location\Search\SiteLinkTable\createIndex
static createIndex()
Definition
sitelink.php:99
Bitrix\Sale\Location\Search\SiteLinkTable\cleanUpData
static cleanUpData()
Definition
sitelink.php:58
Bitrix\Sale\Location\Search\SiteLinkTable\getFilePath
static getFilePath()
Definition
sitelink.php:38
Bitrix\Sale\Location\Search\SiteLinkTable\initializeData
static initializeData()
Definition
sitelink.php:74
Bitrix\Sale\Location\Search\SiteLinkTable\checkTableExists
static checkTableExists()
Definition
sitelink.php:48
Bitrix\Sale\Location\Search\SiteLinkTable\getTableName
static getTableName()
Definition
sitelink.php:43
Bitrix\Main\DB
Definition
arrayresult.php:2
Bitrix\Main
Bitrix\Sale\Location\Search
Definition
chain.php:8
Bitrix\Sale\Location
modules
sale
lib
location
search
sitelink.php
Создано системой
1.10.0