Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
sitemap.php
1
<?php
8
namespace
Bitrix\Seo
;
9
10
use \Bitrix\Main;
11
use \Bitrix\Main\Entity;
12
use \Bitrix\Main\Localization\Loc;
13
14
Loc::loadMessages
(__FILE__);
15
16
// Table with settings
33
class
SitemapTable
extends
Entity\DataManager
34
{
35
const
SETTINGS_DEFAULT_FILE_MASK
=
'*.php,*.html'
;
36
37
const
ACTIVE
=
'Y'
;
38
const
INACTIVE
=
'N'
;
39
40
public
static
function
getFilePath
()
41
{
42
return
__FILE__;
43
}
44
45
public
static
function
getTableName
()
46
{
47
return
'b_seo_sitemap'
;
48
}
49
50
public
static
function
getMap
()
51
{
52
$fieldsMap = array(
53
'ID'
=> array(
54
'data_type'
=>
'integer'
,
55
'primary'
=>
true
,
56
'autocomplete'
=>
true
,
57
),
58
'TIMESTAMP_X'
=> array(
59
'data_type'
=>
'datetime'
60
),
61
'SITE_ID'
=> array(
62
'data_type'
=>
'string'
,
63
'required'
=>
true
,
64
),
65
'ACTIVE'
=> array(
66
'data_type'
=>
'boolean'
,
67
'values'
=> array(self::INACTIVE, self::ACTIVE)
68
),
69
'NAME'
=> array(
70
'data_type'
=>
'string'
,
71
'required'
=>
true
,
72
'title'
=>
Loc::getMessage
(
'SITEMAP_NAME_TITLE'
),
73
),
74
'DATE_RUN'
=> array(
75
'data_type'
=>
'datetime'
,
76
),
77
'SETTINGS'
=> array(
78
'data_type'
=>
'text'
,
79
),
80
);
81
82
return
$fieldsMap;
83
}
84
85
protected
static
function
compileMask
($mask)
86
{
87
if
($mask <>
''
)
88
{
89
$arMask = preg_split(
"/[\s,;]+/"
, $mask);
90
91
foreach
($arMask as $key => $subMask)
92
{
93
if
($subMask <>
''
)
94
{
95
$arMask[$key] = str_replace(
96
array(
"___ALL___"
,
"___ONE___"
),
97
array(
".*?"
,
"."
),
98
preg_quote(str_replace(
99
array(
"*"
,
"?"
),
100
array(
"___ALL___"
,
"___ONE___"
),
101
$subMask
102
))
103
);
104
}
105
else
106
{
107
unset($arMask[$key]);
108
}
109
}
110
111
return
"/^("
.implode(
'|'
, $arMask).
")$/i"
.BX_UTF_PCRE_MODIFIER;
112
}
113
else
114
{
115
return
"/.*/i"
.BX_UTF_PCRE_MODIFIER;
116
}
117
}
118
124
public
static
function
prepareSettings
($arSettings)
125
{
126
if
(is_array($arSettings))
127
{
128
$arSettings[
'FILE_MASK_REGEXP'
] =
self::compileMask
($arSettings[
'FILE_MASK'
]);
129
130
if
(!isset($arSettings[
'DIR'
]) || !is_array($arSettings[
'DIR'
]))
131
{
132
$arSettings[
'DIR'
] = array();
133
}
134
135
if
(isset($arSettings[
'FILE'
]) && is_array($arSettings[
'FILE'
]))
136
{
137
ksort($arSettings[
'FILE'
], SORT_STRING);
138
139
foreach
($arSettings[
'FILE'
] as $file => $value)
140
{
141
$pos = mb_strrpos($file,
'/'
);
142
$parentDir = $pos > 0? mb_substr($file, 0, $pos) :
'/'
;
143
144
if
(isset($arSettings[
'DIR'
][$parentDir]) && $arSettings[
'DIR'
][$parentDir] == $value)
145
{
146
unset($arSettings[
'FILE'
][$file]);
147
}
148
}
149
}
150
151
if
(isset($arSettings[
'DIR'
]) && is_array($arSettings[
'DIR'
]))
152
{
153
krsort($arSettings[
'DIR'
], SORT_STRING);
154
155
foreach
($arSettings[
'DIR'
] as $dir => $value)
156
{
157
if
($dir !=
'/'
)
158
{
159
$pos = mb_strrpos($dir,
'/'
);
160
$parentDir = mb_substr($dir, 0, $pos);
161
162
if
($parentDir ==
''
)
163
$parentDir =
'/'
;
164
165
if
(isset($arSettings[
'DIR'
][$parentDir]) && $arSettings[
'DIR'
][$parentDir] == $value)
166
{
167
unset($arSettings[
'DIR'
][$dir]);
168
}
169
}
170
}
171
172
$arSettings[
'DIR'
] = array_reverse($arSettings[
'DIR'
]);
173
}
174
175
if
(isset($arSettings[
'IBLOCK_ACTIVE'
]) && is_array($arSettings[
'IBLOCK_ACTIVE'
]))
176
{
177
foreach
($arSettings[
'IBLOCK_ACTIVE'
] as $iblockId => $value)
178
{
179
if
($value ==
'N'
)
180
{
181
unset($arSettings[
'IBLOCK_LIST'
][$iblockId]);
182
unset($arSettings[
'IBLOCK_SECTION'
][$iblockId]);
183
unset($arSettings[
'IBLOCK_ELEMENT'
][$iblockId]);
184
unset($arSettings[
'IBLOCK_SECTION_SECTION'
][$iblockId]);
185
unset($arSettings[
'IBLOCK_SECTION_ELEMENT'
][$iblockId]);
186
}
187
}
188
}
189
190
if
(isset($arSettings[
'FORUM_ACTIVE'
]) && is_array($arSettings[
'FORUM_ACTIVE'
]))
191
{
192
foreach
($arSettings[
'FORUM_ACTIVE'
] as $forumId => $value)
193
{
194
if
($value ==
'N'
)
195
{
196
unset($arSettings[
'FORUM_TOPIC'
][$forumId]);
197
}
198
}
199
}
200
}
201
202
return
$arSettings;
203
}
204
}
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\Seo\SitemapTable
Definition
sitemap.php:34
Bitrix\Seo\SitemapTable\compileMask
static compileMask($mask)
Definition
sitemap.php:85
Bitrix\Seo\SitemapTable\getMap
static getMap()
Definition
sitemap.php:50
Bitrix\Seo\SitemapTable\getFilePath
static getFilePath()
Definition
sitemap.php:40
Bitrix\Seo\SitemapTable\ACTIVE
const ACTIVE
Definition
sitemap.php:37
Bitrix\Seo\SitemapTable\INACTIVE
const INACTIVE
Definition
sitemap.php:38
Bitrix\Seo\SitemapTable\prepareSettings
static prepareSettings($arSettings)
Definition
sitemap.php:124
Bitrix\Seo\SitemapTable\SETTINGS_DEFAULT_FILE_MASK
const SETTINGS_DEFAULT_FILE_MASK
Definition
sitemap.php:35
Bitrix\Seo\SitemapTable\getTableName
static getTableName()
Definition
sitemap.php:45
Bitrix\Seo
modules
seo
lib
sitemap.php
Создано системой
1.10.0