Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
DocumentLib.php
1<?php
2
4
8
9class DocumentLib extends BaseLib
10{
11 public function getFunctions(): array
12 {
13 return [
14 'getdocumenturl' => [
15 'args' => true,
16 'func' => 'callGetDocumentUrl',
17 'description' => Loc::getMessage('BIZPROC_CALC_FUNCTION_GETDOCUMENTURL_DESCRIPTION'),
18 ],
19 ];
20 }
21
22 public function callGetDocumentUrl(Arguments $args)
23 {
24 $format = $args->getFirst();
25 $external = $args->getSecond();
26 $activity = $args->getParser()->getActivity();
27
28 $url = $activity->workflow->getRuntime()->getDocumentService()->getDocumentAdminPage(
29 $activity->getDocumentId()
30 );
31 $name = null;
32
33 if ($external)
34 {
35 $url = Main\Engine\UrlManager::getInstance()->getHostUrl() . $url;
36 }
37
38 if ($format === 'bb' || $format === 'html')
39 {
40 $name = $activity->workflow->getService('DocumentService')->getDocumentName(
41 $activity->getDocumentId()
42 );
43 }
44
45 if ($format === 'bb')
46 {
47 return sprintf(
48 '[url=%s]%s[/url]',
49 $url,
50 $name
51 );
52 }
53
54 if ($format === 'html')
55 {
56 return sprintf(
57 '<a href="%s" target="_blank">%s</a>',
58 $url,
59 htmlspecialcharsbx($name)
60 );
61 }
62
63 return $url;
64 }
65}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29