Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
urlrewrite.php
1<?php
2namespace Bitrix\Landing;
3
5use \Bitrix\Landing\Internals\UrlRewriteTable;
6
8{
16 public static function set($siteId, $rule, $landingId = null)
17 {
18 $rule = trim($rule);
19
20 // check for exist
21 $check = SiteTable::getList([
22 'select' => [
23 'ID'
24 ],
25 'filter' => [
26 'ID' => $siteId,
27 '=DELETED' => ['Y', 'N']
28 ]
29 ])->fetch();
30 if (!$check)
31 {
32 return;
33 }
34 if ($landingId)
35 {
36 $check = SiteTable::getList([
37 'select' => [
38 'ID'
39 ],
40 'filter' => [
41 'ID' => $landingId,
42 '=DELETED' => ['Y', 'N']
43 ]
44 ])->fetch();
45 if (!$check)
46 {
47 return;
48 }
49 }
50
51 // set or unset
52 $filter = [
53 'SITE_ID' => $siteId,
54 '=RULE' => $rule
55 ];
56 if ($landingId)
57 {
58 $filter['!LANDING_ID'] = $landingId;
59 }
60
61 $res = UrlRewriteTable::getList([
62 'select' => [
63 'ID'
64 ],
65 'filter' => $filter
66 ]);
67 if ($row = $res->fetch())
68 {
69 if ($landingId)
70 {
71 UrlRewriteTable::update($row['ID'], [
72 'LANDING_ID' => $landingId
73 ]);
74 }
75 else
76 {
77 UrlRewriteTable::delete(
78 $row['ID']
79 );
80 }
81 }
82 else if ($landingId)
83 {
85 'SITE_ID' => $siteId,
86 'RULE' => $rule,
87 'LANDING_ID' => $landingId
88 ]);
89 }
90 }
91
98 public static function remove($siteId, $rule)
99 {
100 self::set($siteId, $rule);
101 }
102
109 public static function matchUrl($siteId, $url)
110 {
111 //
112 }
113
119 public static function removeForSite($siteId)
120 {
121 $res = UrlRewriteTable::getList([
122 'select' => [
123 'ID'
124 ],
125 'filter' => [
126 'SITE_ID' => $siteId
127 ]
128 ]);
129 while ($row = $res->fetch())
130 {
131 UrlRewriteTable::delete($row['ID']);
132 }
133 }
134
140 public static function removeForLanding($landingId)
141 {
142 $res = UrlRewriteTable::getList([
143 'select' => [
144 'ID'
145 ],
146 'filter' => [
147 'LANDING_ID' => $landingId
148 ]
149 ]);
150 while ($row = $res->fetch())
151 {
152 UrlRewriteTable::delete($row['ID']);
153 }
154 }
155}
static update($id, array $fields=array())
static removeForLanding($landingId)
static removeForSite($siteId)
static set($siteId, $rule, $landingId=null)
static matchUrl($siteId, $url)