1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
pay_system_helper.php
См. документацию.
1<?
6{
7 private static function getTarifClassName($actionFile)
8 {
9 if($actionFile == '' )
10 return '';
11
12 static $arClassNames = array();
13
14 if(!isset($arClassNames[$actionFile]))
15 {
16 $PSTarifClassName = ''; //must be defined in file tarif.php and contain class
17 $tarifFileName = $_SERVER["DOCUMENT_ROOT"].$actionFile."/tarif.php";
18
19 if(file_exists($tarifFileName))
20 include_once($tarifFileName);
21
22 $arClassNames[$actionFile] = $PSTarifClassName; // todo: may be object/instance instead name ?
23 }
24
25 return $arClassNames[$actionFile];
26 }
27
28 public static function prepareTarifForSaving($actionFile, $arTarif)
29 {
30 $arResult = array();
31
32 $PSTarifClassName = self::getTarifClassName($actionFile);
33
34 if($PSTarifClassName <> '' && is_callable($PSTarifClassName.'::prepareToField'))
35 $arResult = call_user_func($PSTarifClassName.'::prepareToField', $arTarif);
36
37 return $arResult;
38 }
39
40 public static function getPaySystemTarif($actionFile, $psId, $persId = 0)
41 {
42 $arTarif = array();
43 $PSTarifClassName = self::getTarifClassName($actionFile);
44
45 if($PSTarifClassName <> '' && is_callable($PSTarifClassName.'::getStructure'))
46 $arTarif = call_user_func($PSTarifClassName.'::getStructure', $psId, $persId);
47
48 return $arTarif;
49 }
50
51 public static function getPSPrice($arPaySystem, $orderPrice, $deliveryPrice, $buyerLocationId)
52 {
53 $result = 0;
54
56 $oldHandler = array_search($arPaySystem["PSA_ACTION_FILE"], $map);
57 if ($oldHandler !== false)
58 $arPaySystem["PSA_ACTION_FILE"] = $oldHandler;
59
60 $PSTarifClassName = self::getTarifClassName($arPaySystem["PSA_ACTION_FILE"]);
61
62 if($PSTarifClassName <> '' && is_callable($PSTarifClassName.'::getPrice'))
63 $result = call_user_func_array(
64 $PSTarifClassName.'::getPrice',
65 array(
66 &$arPaySystem,
67 $orderPrice,
68 $deliveryPrice,
69 $buyerLocationId
70 )
71 );
72
73 return $result;
74 }
75
76 public static function checkPSCompability($actionFile, &$arOrder, $orderPrice, $deliveryPrice, $buyerLocationId)
77 {
78 $PSTarifClassName = self::getTarifClassName($actionFile);
79
80 if($PSTarifClassName <> '' && is_callable($PSTarifClassName.'::checkCompability'))
81 {
82 $result = call_user_func_array(
83 $PSTarifClassName.'::checkCompability',
84 array(
85 &$arOrder,
86 $orderPrice,
87 $deliveryPrice,
88 $buyerLocationId
89 )
90 );
91 }
92 else
93 {
94 $result = true;
95 }
96
97 return $result;
98 }
99
100 public static function getPSActionTitle($fileName)
101 {
102 $psTitle = "";
103
104 if (file_exists($fileName) && is_file($fileName))
105 include($fileName);
106
107 return $psTitle;
108 }
109
110 public static function getPSActionTitle_old($fileName)
111 {
112 if (!file_exists($fileName))
113 return false;
114
115 $handle = fopen($fileName, "r");
116 $contents = fread($handle, filesize($fileName));
117 fclose($handle);
118
119 $rep_title = "";
120
121 $arMatches = array();
122 if (preg_match("#<title_".LANGUAGE_ID."[^>]*>([^<]*?)</title_".LANGUAGE_ID."[\s]*>#i", $contents, $arMatches))
123 {
124 $arMatches[1] = Trim($arMatches[1]);
125 if ($arMatches[1] <> '') $rep_title = $arMatches[1];
126 }
127 if ($rep_title == ''
128 && preg_match("#<title[^>]*>([^<]*?)</title[\s]*>#i", $contents, $arMatches))
129 {
130 $arMatches[1] = Trim($arMatches[1]);
131 if ($arMatches[1] <> '') $rep_title = $arMatches[1];
132 }
133 if ($rep_title == '')
134 $rep_title = basename($strPathFull, ".php");
135
136 return $rep_title;
137 }
138
139 public static function isPSActionAffordPdf($actionFile)
140 {
141 $isAffordPdf = false;
142
143 $descriptionFile = $_SERVER['DOCUMENT_ROOT'] . $actionFile . '/.description.php';
144
145 if (is_file($descriptionFile))
146 include($descriptionFile);
147
148 return $isAffordPdf;
149 }
150
155 public static function addMissingKeysToParams()
156 {
157 $result = array();
159 array(),
160 array("PS_ACTIVE" => "Y"),
161 false,
162 false,
163 array("ID", "ACTION_FILE", "PARAMS")
164 );
165
166 while($ps = $res->Fetch())
167 {
168 $descriptionFile = $_SERVER["DOCUMENT_ROOT"].$ps["ACTION_FILE"]."/.description.php";
169
170 if(!file_exists($descriptionFile) || !is_file($descriptionFile))
171 continue;
172
174 include($descriptionFile);
175
176 if(!is_array($arPSCorrespondence) || empty($arPSCorrespondence))
177 continue;
178
179 $arCorrespondence = CSalePaySystemAction::UnSerializeParams($ps["PARAMS"]);
180
181 if(!is_array($arCorrespondence))
182 continue;
183
184 $missingKeys = array_keys(array_diff_key($arPSCorrespondence, $arCorrespondence));
185
186 if(!empty($missingKeys))
187 {
188 $result[$ps["ID"]] = $missingKeys;
189
190 foreach($missingKeys as $key)
191 $arCorrespondence[$key] = array_intersect_key(
193 array("TYPE" => true, "VALUE" => true)
194 );
195
196 $updRes = CSalePaySystemAction::update(
197 $ps["ID"],
198 array("PARAMS" => CSalePaySystemAction::SerializeParams($arCorrespondence)
199 ));
200
201 if($updRes <= 0)
202 $result[$ps["ID"]]["UPDATE_ERROR"] = true;
203 }
204 }
205
207 "SEVERITY" => "INFO",
208 "AUDIT_TYPE_ID" => "PS_PARAMS_CONVERT_RESULT",
209 "MODULE_ID" => "sale",
210 "ITEM_ID" => "PaySystems",
211 "DESCRIPTION" => serialize($result),
212 ));
213
214 return "";
215 }
216}
217?>
$arResult
Определения generate_coupon.php:16
static UnSerializeParams($strParams)
Определения pay_system_action.php:66
static getOldToNewHandlersMap()
Определения pay_system_action.php:1631
static GetList($arOrder=array(), $arFilter=array(), $arGroupBy=false, $arNavStartParams=false, $arSelectFields=array())
Определения pay_system_action.php:528
static SerializeParams($arParams)
Определения pay_system_action.php:61
static Add($arFields)
Определения event_log.php:44
static getPSActionTitle_old($fileName)
Определения pay_system_helper.php:110
static prepareTarifForSaving($actionFile, $arTarif)
Определения pay_system_helper.php:28
static getPSPrice($arPaySystem, $orderPrice, $deliveryPrice, $buyerLocationId)
Определения pay_system_helper.php:51
static isPSActionAffordPdf($actionFile)
Определения pay_system_helper.php:139
static checkPSCompability($actionFile, &$arOrder, $orderPrice, $deliveryPrice, $buyerLocationId)
Определения pay_system_helper.php:76
static addMissingKeysToParams()
Определения pay_system_helper.php:155
static getPaySystemTarif($actionFile, $psId, $persId=0)
Определения pay_system_helper.php:40
static getPSActionTitle($fileName)
Определения pay_system_helper.php:100
$contents
Определения commerceml2.php:57
$isAffordPdf
Определения .description.php:9
</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
$handle
Определения include.php:55
$result
Определения get_property_values.php:14
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
$map
Определения config.php:5
$arPSCorrespondence
Определения .description.php:6
$psTitle
Определения .description.php:3
$fileName
Определения quickway.php:305
if(empty($signedUserToken)) $key
Определения quickway.php:257
$PSTarifClassName
Определения tarif.php:315