1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
url.php
См. документацию.
1<?php
3{
4
9 class Templates
10 {
11 protected $directory = "marketplace/";
12 protected $directoryAdmin = '/bitrix/admin/';
13 protected $pages = [
14 "index" => "",
15 "list" => "list/",
16 "detail" => "detail/#ID#/",
17 "edit" => "edit/#ID#/",
18 ];
19 protected $pageListAdmin = [];
20 protected $adminSectionMode = false;
21 private static $localDir = null;
22 private static array $instance = [];
23
24 private function __construct()
25 {
26 if (defined('ADMIN_SECTION'))
27 {
28 $this->adminSectionMode = true;
29 }
30 }
32 protected function getPage(string $code): string
33 {
34 return $this->adminSectionMode && !empty($this->pageListAdmin[$code])
35 ? $this->directoryAdmin . $this->pageListAdmin[$code]
36 : $this->getDir() . $this->pages[$code]
37 ;
38 }
40 final public static function getInstance()
41 {
42 if (!array_key_exists(static::class, static::$instance))
43 {
44 static::$instance[static::class] = new static();
45 }
46
47 return static::$instance[static::class];
48 }
49
55 */
56 public function addUrlFrom($url, $from) : string
57 {
58 if($from !== '')
59 {
60 if (mb_strpos($url, '?') === false)
61 {
62 $url .= '?from=' . $from;
63 }
64 else
65 {
66 $url .= '&from=' . $from;
67 }
68 }
69
70 return $url;
71 }
73 public function getIndexUrl($from = '')
74 {
75 $url = $this->getDir() . $this->pages["index"];
76 $url = $this->addUrlFrom($url, $from);
77
78 return $url;
79 }
81 public function getDetailUrl($id = null, $from = '')
82 {
83 $url = $this->getReplacedId($this->pages["detail"], $id);
84 $url = $this->addUrlFrom($url, $from);
85
86 return $url;
87 }
89 public function getEditUrl($id = null)
90 {
91 return $this->getReplacedId($this->pages["edit"], $id);
92 }
94 public function getDir()
95 {
96 if (null === self::$localDir)
97 {
99 $site = \Bitrix\Main\Context::getCurrent()->getSiteObject();
100 if ($site && $site->getDir() != '')
101 {
102 $siteId = $site->getLid();
104 $dir = new \Bitrix\Main\IO\Directory(\Bitrix\Main\IO\Path::combine($path), $siteId);
105 if ($dir->isExists())
106 {
107 self::$localDir = \Bitrix\Main\IO\Path::combine([self::$localDir, $site->getDir()]);
108 }
109 }
110 }
111 $res = \Bitrix\Main\IO\Path::combine([self::$localDir, $this->directory]);
112 if (mb_substr($res, 0, -1) !== \Bitrix\Main\IO\Path::DIRECTORY_SEPARATOR)
114 return $res;
115 }
117 protected function getReplacedId(string $url, $id = null)
118 {
119 $url = $this->getDir().$url;
120 if (!is_null($id))
121 $url = str_replace("#ID#", $id, $url);
122 return $url;
123 }
125 protected function getReplaced(string $url, $replace = null, $subject = null)
126 {
127 $url = $this->getDir().$url;
128 if (!is_null($replace) && !is_null($subject))
129 $url = str_replace($replace, $subject, $url);
130 return $url;
131 }
132 }
134 class Marketplace extends Templates
136 protected $directory = "marketplace/";
137 protected $pages = [
138 "index" => "",
139 "list" => "installed/",
140 "detail" => "detail/#ID#/",
141 "category" => "category/#ID#/",
142 "category_placement" => "?placement=#CODE#",
143 "placement_view" => "view/#APP#/",
144 "placement" => "placement/#PLACEMENT_ID#/",
145 "booklet" => "booklet/#CODE#/"
146 ];
148 public function getCategoryUrl($id = null, $from = '')
149 {
150 if ($id === null)
151 {
152 $url = $this->getReplacedId($this->pages['index']);
153 }
154 else
155 {
156 $url = $this->getReplacedId($this->pages['category'], $id);
157 }
158
159 return $this->addUrlFrom($url, $from);
160 }
162 public function getCategoryByPlacement($code, $from = '')
163 {
164 $url = $this->getReplaced($this->pages['category_placement'], '#CODE#', $code);
165
166 return $this->addUrlFrom($url, $from);
167 }
169 public function getSubscriptionBuyUrl()
170 {
171 $result = '';
172 if (ModuleManager::isModuleInstalled('bitrix24'))
173 {
174 $result = '/settings/license_all.php?subscr=o';
175 }
176 else
177 {
178 $region = Option::get('main', '~PARAM_CLIENT_LANG', LANGUAGE_ID);
179
180 if ($region === 'ru')
181 {
182 $result = 'https://www.1c-bitrix.ru/buy/products/b24.php?subscr=y';
183 }
184 elseif ($region === 'by')
185 {
186 $result = 'https://www.1c-bitrix.by/buy/products/b24.php?subscr=y';
187 }
188 }
189
190 return $result;
191 }
193 public function getPlacementUrl($placementId, $params)
194 {
195 $placementId = intval($placementId);
196 $replace = null;
197 $subject = null;
198 if ($placementId > 0)
199 {
200 $replace = [
201 '#PLACEMENT_ID#'
202 ];
203 $subject = [
204 $placementId
205 ];
206 }
207 $url = $this->getReplaced($this->pages["placement"], $replace, $subject);
208
209 if(is_array($params))
210 {
211 $uri = new \Bitrix\Main\Web\Uri($url);
212 $uri->addParams(
213 [
214 'params' => $params
215 ]
216 );
217 $url = $uri->getUri();
218 }
219 return $url;
220 }
222 public function getBooklet($code = null, $from = '')
223 {
224 $replace = null;
225 $subject = null;
226 if (!is_null($code))
227 {
228 $replace = [
229 "#CODE#"
230 ];
231 $subject = [
232 $code
233 ];
234 }
235 $url = $this->getReplaced($this->pages["booklet"], $replace, $subject);
236
237 $url = $this->addUrlFrom($url, $from);
238
239 return $url;
240 }
242 public function getPlacementViewUrl($appCode, $params)
243 {
244 $replace = null;
245 $subject = null;
246 if ($appCode)
247 {
248 $replace = [
249 '#APP#'
250 ];
251 $subject = [
252 $appCode
253 ];
254 }
255 $url = $this->getReplaced($this->pages["placement_view"], $replace, $subject);
256
257 if (is_array($params))
258 {
259 $uri = new \Bitrix\Main\Web\Uri($url);
260 $uri->addParams(
261 [
262 'params' => $params
263 ]
264 );
265 $url = $uri->getUri();
266 }
267
268 return $url;
269 }
271 class Application extends Templates
273 protected $directory = "marketplace/app/";
274 protected $pages = [
275 "index" => "",
276 "list" => "",
277 "detail" => "#ID#/",
278 "edit" => "edit/#ID#/"
279 ];
280 }
282 class Configuration extends Templates
284 protected $directory = 'marketplace/configuration/';
285 protected $pages = [
286 'index' => '',
287 'placement' => 'placement/#PLACEMENT_CODE#/',
288 'section' => 'section/#MANIFEST_CODE#/',
289 'import' => 'import/',
290 'import_app' => 'import/#APP_CODE#/',
291 'import_rollback' => 'import_rollback/#APP#/',
292 'import_zip' => 'import_zip/#ZIP_ID#/',
293 'import_manifest' => 'import_#MANIFEST_CODE#/',
294 'export' => 'export_#MANIFEST_CODE#/',
295 'export_element' => 'export_#MANIFEST_CODE#/#ITEM_CODE#/'
296 ];
298 protected $pageListAdmin = [
299 'import_zip' => 'rest_import_zip.php?id=#ZIP_ID#',
300 ];
302 public function getPlacement($code = null, $context = null)
303 {
304 $replace = null;
305 $subject = null;
306 if (!is_null($code))
307 {
308 $replace = [
309 '#PLACEMENT_CODE#'
310 ];
311 $subject = [
312 $code
313 ];
314 }
315 $url = $this->getReplaced($this->getPage('placement'), $replace, $subject);
316
317 if(!is_null($context))
318 {
319 $uri = new \Bitrix\Main\Web\Uri($url);
320 $uri->addParams(
321 [
322 "from" => $context
323 ]
324 );
325 $url = $uri->getUri();
326 }
327 return $url;
328 }
330 public function getSection($manifestCode = null)
331 {
332 $replace = null;
333 $subject = null;
334 if (!is_null($manifestCode))
335 {
336 $replace = [
337 '#MANIFEST_CODE#'
338 ];
339 $subject = [
340 $manifestCode
341 ];
342 }
343 return $this->getReplaced($this->getPage('section'), $replace, $subject);
344 }
346 public function getImport()
347 {
348 return $this->getReplaced($this->getPage('import'));
349 }
351 public function getImportManifest($manifestCode)
352 {
353 $replace = null;
354 $subject = null;
355 if (!is_null($manifestCode))
356 {
357 $replace = [
358 '#MANIFEST_CODE#'
359 ];
360 $subject = [
361 $manifestCode
362 ];
363 }
364 return $this->getReplaced($this->getPage('import_manifest'), $replace, $subject);
365 }
367 public function getImportApp($code = null)
368 {
369 $replace = null;
370 $subject = null;
371 if (!is_null($code))
372 {
373 $replace = [
374 '#APP_CODE#'
375 ];
376 $subject = [
377 $code
378 ];
379 }
380 return $this->getReplaced($this->getPage('import_app'), $replace, $subject);
381 }
383 public function getImportRollback($appCode)
384 {
385 $replace = [
386 '#APP#'
387 ];
388 $subject = [
389 $appCode
390 ];
391
392 return $this->getReplaced($this->getPage('import_rollback'), $replace, $subject);
393 }
395 public function getImportZip($zipId, $from)
396 {
397 $replace = [
398 '#ZIP_ID#'
399 ];
400 $subject = [
401 (int) $zipId
402 ];
403 $url = $this->getReplaced($this->getPage('import_zip'), $replace, $subject);
404
405 return $this->addUrlFrom($url, $from);
406 }
408 public function getExport($manifestCode = null)
409 {
410 $replace = null;
411 $subject = null;
412 if (!is_null($manifestCode))
413 {
414 $replace = [
415 '#MANIFEST_CODE#'
416 ];
417 $subject = [
418 $manifestCode
419 ];
420 }
421 return $this->getReplaced($this->getPage('export'), $replace, $subject);
422 }
424 public function getExportElement($manifestCode = null, $itemCode = null)
425 {
426 $replace = null;
427 $subject = null;
428 if (!is_null($manifestCode))
429 {
430 $replace = [
431 '#MANIFEST_CODE#',
432 '#ITEM_CODE#'
433 ];
434 $subject = [
435 $manifestCode,
436 $itemCode
437 ];
438 }
439 return $this->getReplaced($this->getPage('export_element'), $replace, $subject);
440 }
442 protected function getReplaced(string $url, $replace = null, $subject = null)
443 {
444 if (!is_null($replace) && !is_null($subject))
445 {
446 $url = str_replace($replace, $subject, $url);
447 }
448
449 return $url;
450 }
451 }
452}
454{
455
456 use Bitrix\Rest\Marketplace\Urls\Marketplace as MarketplaceUrls;
457 use Bitrix\Rest\Marketplace\Urls\Application as ApplicationUrls;
461 class Url
463 public static function getCategoryUrl($id = null, $from = '')
464 {
465 return MarketplaceUrls::getInstance()->getCategoryUrl($id, $from);
466 }
468 public static function getCategoryByPlacement($code, $from = '')
469 {
470 return MarketplaceUrls::getInstance()->getCategoryByPlacement($code, $from);
471 }
473 public static function getApplicationDetailUrl($id = null, $from = '')
474 {
475 return MarketplaceUrls::getInstance()->getDetailUrl($id, $from);
477 public static function getApplicationUrl($id = null)
478 {
479 return ApplicationUrls::getInstance()->getDetailUrl($id);
481 public static function getWidgetAddUrl()
482 {
483 return "";
484 }
485
492 */
493 public static function getApplicationPlacementUrl($placementId = null, $params = null)
494 {
495 return DevOps::getInstance()->getPlacementUrl((int)$placementId, $params);
496 }
498 public static function getApplicationPlacementViewUrl($appCode = null, $params = null)
499 {
500 return MarketplaceUrls::getInstance()->getPlacementViewUrl($appCode, $params);
501 }
503 public static function getMarketplaceUrl($from = '')
504 {
505 return MarketplaceUrls::getInstance()->getIndexUrl($from);
506 }
508 public static function getBookletUrl($code = null, $from = '')
509 {
510 return MarketplaceUrls::getInstance()->getBooklet($code, $from);
511 }
513 public static function getConfigurationUrl()
514 {
515 return Configuration::getInstance()->getIndexUrl();
516 }
518 public static function getConfigurationPlacementUrl($code = null, $context = null)
519 {
520 return Configuration::getInstance()->getPlacement($code, $context);
521 }
523 public static function getConfigurationSectionUrl($manifestCode = null)
524 {
525 return Configuration::getInstance()->getSection($manifestCode);
526 }
528 public static function getConfigurationImportUrl()
529 {
530 return Configuration::getInstance()->getImport();
531 }
533 public static function getConfigurationImportManifestUrl($code)
534 {
535 return Configuration::getInstance()->getImportManifest($code);
536 }
538 public static function getConfigurationImportAppUrl($code = null)
539 {
540 return Configuration::getInstance()->getImportApp($code);
541 }
543 public static function getConfigurationImportRollbackUrl($appCode)
544 {
545 return Configuration::getInstance()->getImportRollback($appCode);
546 }
548 public static function getConfigurationImportZipUrl($zipId, $from = '')
549 {
550 return Configuration::getInstance()->getImportZip($zipId, $from);
551 }
553 public static function getConfigurationExportUrl($manifestCode = null)
554 {
555 return Configuration::getInstance()->getExport($manifestCode);
556 }
558 public static function getConfigurationExportElementUrl($manifestCode = null, $itemCode = null)
559 {
560 return Configuration::getInstance()->getExportElement($manifestCode, $itemCode);
561 }
563 public static function getSubscriptionBuyUrl() : string
564 {
565 return MarketplaceUrls::getInstance()->getSubscriptionBuyUrl();
566 }
567 }
568}
569
$path
Определения access_edit.php:21
static getInstance()
Определения application.php:98
const DIRECTORY_SEPARATOR
Определения path.php:13
static combine(... $args)
Определения path.php:254
static isModuleInstalled($moduleName)
Определения modulemanager.php:125
static getDocumentRoot($siteId=null)
Определения site.php:36
static getBookletUrl($code=null, $from='')
Определения url.php:507
static getConfigurationImportAppUrl($code=null)
Определения url.php:537
static getConfigurationUrl()
Определения url.php:512
static getConfigurationImportRollbackUrl($appCode)
Определения url.php:542
static getConfigurationImportZipUrl($zipId, $from='')
Определения url.php:547
static getConfigurationSectionUrl($manifestCode=null)
Определения url.php:522
static getConfigurationPlacementUrl($code=null, $context=null)
Определения url.php:517
static getMarketplaceUrl($from='')
Определения url.php:502
static getApplicationPlacementViewUrl($appCode=null, $params=null)
Определения url.php:497
static getConfigurationExportUrl($manifestCode=null)
Определения url.php:552
static getConfigurationExportElementUrl($manifestCode=null, $itemCode=null)
Определения url.php:557
static getApplicationUrl($id=null)
Определения url.php:476
static getApplicationPlacementUrl($placementId=null, $params=null)
Определения url.php:492
static getCategoryByPlacement($code, $from='')
Определения url.php:467
static getApplicationDetailUrl($id=null, $from='')
Определения url.php:472
static getCategoryUrl($id=null, $from='')
Определения url.php:462
static getConfigurationImportManifestUrl($code)
Определения url.php:532
static getSubscriptionBuyUrl()
Определения url.php:562
static getWidgetAddUrl()
Определения url.php:480
static getConfigurationImportUrl()
Определения url.php:527
getImportRollback($appCode)
Определения url.php:382
getExport($manifestCode=null)
Определения url.php:407
getSection($manifestCode=null)
Определения url.php:329
getReplaced(string $url, $replace=null, $subject=null)
Определения url.php:441
getImportZip($zipId, $from)
Определения url.php:394
getImportApp($code=null)
Определения url.php:366
getExportElement($manifestCode=null, $itemCode=null)
Определения url.php:423
getImportManifest($manifestCode)
Определения url.php:350
getPlacement($code=null, $context=null)
Определения url.php:301
getBooklet($code=null, $from='')
Определения url.php:221
getCategoryUrl($id=null, $from='')
Определения url.php:147
getPlacementViewUrl($appCode, $params)
Определения url.php:241
getPlacementUrl($placementId, $params)
Определения url.php:192
getCategoryByPlacement($code, $from='')
Определения url.php:161
getReplacedId(string $url, $id=null)
Определения url.php:116
getEditUrl($id=null)
Определения url.php:88
getPage(string $code)
Определения url.php:31
getReplaced(string $url, $replace=null, $subject=null)
Определения url.php:124
getIndexUrl($from='')
Определения url.php:72
addUrlFrom($url, $from)
Определения url.php:55
static getInstance()
Определения url.php:39
getDetailUrl($id=null, $from='')
Определения url.php:80
static getInstance()
Определения base.php:13
Определения devops.php:6
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$region
Определения .description.php:13
$context
Определения csv_new_setup.php:223
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
if(file_exists($_SERVER['DOCUMENT_ROOT'] . "/urlrewrite.php")) $uri
Определения urlrewrite.php:61
$siteId
Определения ajax.php:8
Определения directory.php:3
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$dir
Определения quickway.php:303
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799
$url
Определения iframe.php:7
$site
Определения yandex_run.php:614