1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
yandexexception.php
См. документацию.
1
<?php
2
namespace
Bitrix\Seo\Engine;
3
4
use Bitrix\Main\Web;
5
use Bitrix\Main\Localization\Loc;
6
use Bitrix\Main\Web\Json;
7
8
Loc::loadMessages(__DIR__.
'/../../seo_search.php'
);
9
10
class
YandexException
11
extends
\Exception
12
{
13
protected
$code
;
14
protected
$message
;
15
16
protected
$result
;
17
protected
$status
;
18
19
public
function
__construct
($queryResult, \Exception $previous = NULL)
20
{
21
// exception use two classes - new and old. Define them
22
if
($queryResult)
23
{
24
if
($queryResult instanceof \
CHTTP
)
25
{
26
$this->result = $queryResult->result;
27
$this->status = $queryResult->status;
28
}
29
elseif
($queryResult instanceof
Web
\
HttpClient
)
30
{
31
$this->result = $queryResult->getResult();
32
$this->status = $queryResult->getStatus();
33
}
34
}
35
36
if
(!$queryResult)
37
{
38
parent::__construct(
'no result'
, 0, $previous);
39
}
40
elseif
($this->
parseError
())
41
{
42
$this->formatMessage();
//format and try translate message
43
parent::__construct($this->message, $this->status, $previous);
44
}
45
else
46
{
47
parent::__construct($this->result, $this->status, $previous);
48
}
49
}
50
51
public
function
getStatus
()
52
{
53
return
$this->status
;
54
}
55
56
protected
function
parseError
()
57
{
58
$matches
=
array
();
59
// old style dbg: maybe delete? In new webmaster API this format not using already
60
if
(preg_match(
"/<error code=\"([^\"]+)\"><message>([^<]+)<\/message><\/error>/"
, $this->result,
$matches
))
61
{
62
$this->code =
$matches
[1];
63
$this->message =
$matches
[2];
64
65
// Try translate error. If unknown error - write as is
66
$codeTranslated = Loc::getMessage(
'YANDEX_ERROR__'
.str_replace(
' '
,
'_'
,mb_strtoupper($this->code)));
67
$messageTranslated = Loc::getMessage(
'YANDEX_ERROR__'
.str_replace(
' '
,
'_'
,mb_strtoupper($this->message)));
68
$this->code = ($codeTranslated <>
''
) ? $codeTranslated :
$this->code
;
69
$this->message = ($messageTranslated <>
''
) ? $messageTranslated :
$this->message
;
70
71
return
true
;
72
}
73
74
// new style
75
if
($resultArray = Json::decode($this->result))
76
{
77
if
(array_key_exists(
'error_code'
, $resultArray))
78
$this->code = $resultArray[
"error_code"
];
79
if
(array_key_exists(
'error_message'
, $resultArray))
80
$this->message = $resultArray[
"error_message"
];
81
82
return
true
;
83
}
84
85
return
false
;
86
}
87
88
private
function
formatMessage()
89
{
90
$translateString = Loc::getMessage(
'SEO_ERROR_'
.$this->code);
91
if
($translateString <>
''
)
92
{
93
$this->message = $translateString.
' ('
.Loc::getMessage(
'SEO_ERROR_CODE'
).
': '
.$this->code.
').'
;
94
}
95
else
96
{
97
$this->message = $this->code .
': '
.
$this->message
;
98
}
99
}
100
}
Bitrix\Main\Web\HttpClient
Определения
httpclient.php:24
Bitrix\Seo\Engine\YandexException
Определения
yandexexception.php:12
Bitrix\Seo\Engine\YandexException\$result
$result
Определения
yandexexception.php:16
Bitrix\Seo\Engine\YandexException\__construct
__construct($queryResult, \Exception $previous=NULL)
Определения
yandexexception.php:19
Bitrix\Seo\Engine\YandexException\$status
$status
Определения
yandexexception.php:17
Bitrix\Seo\Engine\YandexException\parseError
parseError()
Определения
yandexexception.php:56
Bitrix\Seo\Engine\YandexException\$code
$code
Определения
yandexexception.php:13
Bitrix\Seo\Engine\YandexException\getStatus
getStatus()
Определения
yandexexception.php:51
Bitrix\Seo\Engine\YandexException\$message
$message
Определения
yandexexception.php:14
CHTTP
Определения
http.php:7
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
Bitrix\Main\Web
Определения
cookie.php:3
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$matches
$matches
Определения
index.php:22
bitrix
modules
seo
lib
engine
yandexexception.php
Создано системой
1.14.0