20 $this->scriptPath = $_SERVER[
'DOCUMENT_ROOT'] .
"/bitrix/modules/sale/lib/tradingplatform/vk/api/scripts";
31 private function getScript($name)
33 $filePath = $this->scriptPath .
'/' . $name .
'.vks';
34 if (
IO\File::isFileExists($filePath))
36 $script = IO\File::getFileContents($filePath);
53 public function __call($methodName, $arguments)
56 $methodName = mb_strtolower($methodName);
57 if (mb_strpos($methodName,
'execute') == 0)
59 $methodName = str_replace(
"execute",
"", $methodName);
62 $script = $this->getScript($methodName);
63 if (count($arguments))
65 $script = $this->prepareParams($script, $arguments[0]);
67 $response = $this->api->run(
'execute', array(
'code' => $script));
81 private function prepareParams($script, $params)
83 foreach ($params as $key => $value)
87 $value = \CUtil::PhpToJSObject($value);
89 $script = str_replace(
'%'.mb_strtoupper($key) .
'%', $value, $script);
101 private function decodeMultibyteUnicode($str)
103 $str = preg_replace_callback(
'/\\\\u(\w{4})/',
function ($matches)
105 return html_entity_decode(
'&#x' . $matches[1] .
';',
null,
'UTF-8');