42 if (!
$USER->CanDoOperation(
'seo_tools'))
47 $currentDirPath = dirname(
$_SERVER[
"REAL_FILE_PATH"]);
48 $currentFilePath =
$_SERVER[
"REAL_FILE_PATH"];
56 $encCurrentDirPath = urlencode($currentDirPath);
57 $encCurrentFilePath = urlencode($currentFilePath);
58 $encRequestUri = urlencode(
$_SERVER[
"REQUEST_URI"]);
60 $encTitleChangerLink =
'';
61 $encWinTitleChangerLink =
'';
62 $encTitleChangerName =
'';
63 $encWinTitleChangerName =
'';
66 if (isset(
$APPLICATION->sDocTitleChanger[
'PUBLIC_EDIT_LINK']))
67 $encTitleChangerLink = urlencode(base64_encode(
$APPLICATION->sDocTitleChanger[
'PUBLIC_EDIT_LINK']));
68 if (isset(
$APPLICATION->sDocTitleChanger[
'COMPONENT_NAME']))
69 $encTitleChangerName = urlencode(
$APPLICATION->sDocTitleChanger[
'COMPONENT_NAME']);
72 $prop_code = mb_strtoupper(COption::GetOptionString(
'seo',
'property_window_title',
'title'));
74 if (isset(
$APPLICATION->arPagePropertiesChanger[$prop_code]) && is_array(
$APPLICATION->arPagePropertiesChanger[$prop_code]))
76 if (isset(
$APPLICATION->arPagePropertiesChanger[$prop_code][
'PUBLIC_EDIT_LINK']))
77 $encWinTitleChangerLink = urlencode(base64_encode(
$APPLICATION->arPagePropertiesChanger[$prop_code][
'PUBLIC_EDIT_LINK']));
78 if (isset(
$APPLICATION->arPagePropertiesChanger[$prop_code][
'COMPONENT_NAME']))
79 $encWinTitleChangerName = urlencode(
$APPLICATION->arPagePropertiesChanger[$prop_code][
'COMPONENT_NAME']);
82 $encTitle = urlencode(base64_encode(
$APPLICATION->sDocTitle));
83 $encWinTitle = urlencode(base64_encode(
$APPLICATION->arPageProperties[$prop_code] ??
''));
88 "URL"=>
"/bitrix/admin/public_seo_tools.php?lang=".LANGUAGE_ID.
"&bxpublic=Y&from_module=seo&site=".
SITE_ID
89 .
"&path=".$encCurrentFilePath
90 .
"&title_final=".$encTitle.
"&title_changer_name=".$encTitleChangerName.
'&title_changer_link='.$encTitleChangerLink
91 .
"&title_win_final=".$encWinTitle.
"&title_win_changer_name=".$encWinTitleChangerName.
'&title_win_changer_link='.$encWinTitleChangerLink
93 .
"&back_url=".$encRequestUri,
94 "PARAMS"=> Array(
"width"=>920,
"height" => 400,
'resize' =>
false)
97 "ICON" =>
"bx-panel-seo-icon",
111 if (COption::GetOptionString(
'main',
'vendor',
'') ==
'1c_bitrix' && defined(
'ADMIN_SECTION'))
116 var originalTextWnd =
null;
117 var originalTextBtn =
new BX.CWindowButton({
118 title:
'<?=GetMessageJS('SEO_UNIQUE_TEXT_YANDEX_SUBMIT
')?>',
119 className:
'adm-btn-save',
122 var content = document.forms.seo_original_text_form.original_text.value;
123 var domain = document.forms.seo_original_text_form.domain.options[document.forms.seo_original_text_form.domain.selectedIndex].value;
124 if(content.length < <?=\
Bitrix\Seo\Engine\Yandex::ORIGINAL_TEXT_MIN_LENGTH?>)
126 alert(
'<?=GetMessageJS('SEO_YANDEX_ORIGINAL_TEXT_TOO_SHORT
', array('#NUM#
' => \Bitrix\Seo\Engine\Yandex::ORIGINAL_TEXT_MIN_LENGTH))?>');
128 else if(content.length > <?=\
Bitrix\Seo\Engine\Yandex::ORIGINAL_TEXT_MAX_LENGTH?>)
130 alert(
'<?=GetMessageJS('SEO_YANDEX_ORIGINAL_TEXT_TOO_LONG
', array('#NUM#
' => \Bitrix\Seo\Engine\Yandex::ORIGINAL_TEXT_MAX_LENGTH))?>');
134 originalTextBtn.disable();
138 url:
'/bitrix/tools/seo_yandex.php',
140 action:
'original_text',
143 original_text: content,
144 sessid: BX.bitrix_sessid()
146 onsuccess:
function(res)
148 originalTextBtn.enable();
151 alert(BX.util.strip_tags(res.error.message));
155 BX(
'seo_original_text_form_form').style.display =
'none';
156 BX(
'seo_original_text_form_ok').style.display =
'block';
158 originalTextBtn.btn.disabled =
true;
160 originalTextWnd.adjustSizeEx();
161 BX.defer(originalTextWnd.adjustPos, originalTextWnd)();
169 var originalTextLoader =
function(res)
172 originalTextWnd =
new BX.CDialog({
177 title:
'<?=GetMessageJS('SEO_UNIQUE_TEXT_YANDEX
')?>',
182 originalTextHandler.apply(
this, arguments);
185 var originalTextHandler =
function()
190 BX.ajax.get(
'/bitrix/tools/seo_yandex.php?get=original_text_form&sessid=' + BX.bitrix_sessid(), BX.proxy(originalTextLoader,
this));
192 else if(!!document.forms.seo_original_text_form)
194 this.pMainObj.SaveContent();
196 var content = BX.util.strip_tags(
197 this.pMainObj.GetContent()
198 .replace(/<\?(.|[\r\n])*?\?>/g,
'')
199 .replace(/#PHP[^#]*#/ig,
'')
202 originalTextWnd.Show();
204 document.forms.seo_original_text_form.original_text.value = content;
205 BX(
'seo_original_text_form_form').style.display =
'block';
206 BX(
'seo_original_text_form_ok').style.display =
'none';
208 originalTextWnd.adjustSizeEx();
209 originalTextBtn.enable();
210 originalTextBtn.btn.disabled =
false;
211 BX.defer(originalTextWnd.adjustPos, originalTextWnd)();
215 originalTextWnd.Show();
216 originalTextBtn.btn.disabled =
true;
220 var seoEditorButton = [
'BXButton',
223 src :
'/bitrix/panel/seo/images/icon_editor_toolbar.png',
224 name :
'<?=CUtil::JSEscape(GetMessage('SEO_UNIQUE_TEXT_YANDEX
'))?>',
225 codeEditorMode :
true,
226 handler : originalTextHandler
229 if(typeof window.arToolbars !=
'undefined' && !window.bSeoToolbarButtonAdded)
231 if(typeof window.arToolbars[
'manage'] !=
'undefined')
233 window.arToolbars[
'manage'][1].push(seoEditorButton);
237 window.arToolbars[
'standart'][1].push(seoEditorButton);
240 window.bSeoToolbarButtonAdded =
true;
243 if(typeof window.arGlobalToolbar !=
'undefined' && !window.bSeoGlobalToolbarButtonAdded)
245 window.arGlobalToolbar.push(seoEditorButton);
246 window.bSeoGlobalToolbarButtonAdded =
true;
256 if (COption::GetOptionString(
'main',
'vendor',
'') ==
'1c_bitrix' && defined(
'ADMIN_SECTION'))
261 var originalTextWnd =
null;
262 var originalTextBtn =
new BX.CWindowButton({
263 title:
'<?=GetMessageJS('SEO_UNIQUE_TEXT_YANDEX_SUBMIT
')?>',
264 className:
'adm-btn-save',
267 var content = document.forms.seo_original_text_form.original_text.value;
268 var domain = document.forms.seo_original_text_form.domain.options[document.forms.seo_original_text_form.domain.selectedIndex].value;
269 if(content.length < <?=\
Bitrix\Seo\Engine\Yandex::ORIGINAL_TEXT_MIN_LENGTH?>)
271 alert(
'<?=GetMessageJS('SEO_YANDEX_ORIGINAL_TEXT_TOO_SHORT
', array('#NUM#
' => \Bitrix\Seo\Engine\Yandex::ORIGINAL_TEXT_MIN_LENGTH))?>');
273 else if(content.length > <?=\
Bitrix\Seo\Engine\Yandex::ORIGINAL_TEXT_MAX_LENGTH?>)
275 alert(
'<?=GetMessageJS('SEO_YANDEX_ORIGINAL_TEXT_TOO_LONG
', array('#NUM#
' => \Bitrix\Seo\Engine\Yandex::ORIGINAL_TEXT_MAX_LENGTH))?>');
279 originalTextBtn.disable();
283 url:
'/bitrix/tools/seo_yandex.php',
285 action:
'original_text',
288 original_text: content,
289 sessid: BX.bitrix_sessid()
291 onsuccess:
function(res)
293 originalTextBtn.enable();
296 alert(BX.util.strip_tags(res.error.message));
300 BX(
'seo_original_text_form_form').style.display =
'none';
301 BX(
'seo_original_text_form_ok').style.display =
'block';
303 originalTextBtn.btn.disabled =
true;
305 originalTextWnd.adjustSizeEx();
306 BX.defer(originalTextWnd.adjustPos, originalTextWnd)();
314 var originalTextHandler =
function(editor)
320 '/bitrix/tools/seo_yandex.php?get=original_text_form&sessid=' + BX.bitrix_sessid(),
321 BX.delegate(
function(res)
324 originalTextWnd = new BX.CDialog({
329 title:
'<?=GetMessageJS('SEO_UNIQUE_TEXT_YANDEX
')?>',
334 originalTextHandler.apply(
this, [editor]);
338 else if(!!document.forms.seo_original_text_form)
340 var content = BX.util.strip_tags(
342 .replace(/<\?(.|[\r\n])*?\?>/g,
'')
343 .replace(/#PHP[^#]*#/ig,
'')
346 originalTextWnd.Show();
348 document.forms.seo_original_text_form.original_text.value = content;
349 BX(
'seo_original_text_form_form').style.display =
'block';
350 BX(
'seo_original_text_form_ok').style.display =
'none';
352 originalTextWnd.adjustSizeEx();
353 originalTextBtn.enable();
354 originalTextBtn.btn.disabled = false;
355 BX.defer(originalTextWnd.adjustPos, originalTextWnd)();
359 originalTextWnd.Show();
360 originalTextBtn.btn.disabled = true;
364 function applyForEditor(editor)
369 src :
'/bitrix/panel/seo/images/icon_editor_toolbar_2.png',
370 name :
'<?=CUtil::JSEscape(GetMessage('SEO_UNIQUE_TEXT_YANDEX
'))?>',
371 codeEditorMode :
true,
372 handler :
function(){originalTextHandler(editor);},
378 if (window.BXHtmlEditor && window.BXHtmlEditor.editors)
380 for (var
id in window.BXHtmlEditor.editors)
382 if (window.BXHtmlEditor.editors.hasOwnProperty(
id))
384 applyForEditor(window.BXHtmlEditor.Get(
id))
389 BX.addCustomEvent(
"OnEditorInitedBefore", applyForEditor);