PageRenderTime 46ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/modules/catalog/load/yandex_setup.php

https://gitlab.com/alexprowars/bitrix
PHP | 735 lines | 663 code | 60 blank | 12 comment | 155 complexity | aedff96b657489a1e013aef173beb2e8 MD5 | raw file
  1. <?
  2. //<title>Yandex</title>
  3. /** @global CDatabase $DB */
  4. /** @global CUser $USER */
  5. /** @global CMain $APPLICATION */
  6. /** @global string $ACTION */
  7. /** @global array $arOldSetupVars */
  8. /** @global int $IBLOCK_ID */
  9. /** @global string $SETUP_FILE_NAME */
  10. /** @global string $SETUP_SERVER_NAME */
  11. /** @global mixed $V */
  12. /** @global mixed $XML_DATA */
  13. /** @global string $SETUP_PROFILE_NAME */
  14. use Bitrix\Main,
  15. Bitrix\Iblock,
  16. Bitrix\Catalog;
  17. IncludeModuleLangFile($_SERVER['DOCUMENT_ROOT'].'/bitrix/modules/catalog/export_setup_templ.php');
  18. IncludeModuleLangFile(__FILE__);
  19. global $APPLICATION, $USER;
  20. $arSetupErrors = array();
  21. $strAllowExportPath = COption::GetOptionString("catalog", "export_default_path", "/bitrix/catalog_export/");
  22. if (($ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY') && $STEP == 1)
  23. {
  24. if (isset($arOldSetupVars['IBLOCK_ID']))
  25. $IBLOCK_ID = $arOldSetupVars['IBLOCK_ID'];
  26. if (isset($arOldSetupVars['SITE_ID']))
  27. $SITE_ID = $arOldSetupVars['SITE_ID'];
  28. if (isset($arOldSetupVars['SETUP_FILE_NAME']))
  29. $SETUP_FILE_NAME = str_replace($strAllowExportPath,'',$arOldSetupVars['SETUP_FILE_NAME']);
  30. if (isset($arOldSetupVars['COMPANY_NAME']))
  31. $COMPANY_NAME = $arOldSetupVars['COMPANY_NAME'];
  32. if (isset($arOldSetupVars['SETUP_PROFILE_NAME']))
  33. $SETUP_PROFILE_NAME = $arOldSetupVars['SETUP_PROFILE_NAME'];
  34. if (isset($arOldSetupVars['V']))
  35. $V = $arOldSetupVars['V'];
  36. if (isset($arOldSetupVars['XML_DATA']))
  37. {
  38. $XML_DATA = base64_encode($arOldSetupVars['XML_DATA']);
  39. }
  40. if (isset($arOldSetupVars['SETUP_SERVER_NAME']))
  41. $SETUP_SERVER_NAME = $arOldSetupVars['SETUP_SERVER_NAME'];
  42. if (isset($arOldSetupVars['USE_HTTPS']))
  43. $USE_HTTPS = $arOldSetupVars['USE_HTTPS'];
  44. if (isset($arOldSetupVars['FILTER_AVAILABLE']))
  45. $filterAvalable = $arOldSetupVars['FILTER_AVAILABLE'];
  46. if (isset($arOldSetupVars['DISABLE_REFERERS']))
  47. $disableReferers = $arOldSetupVars['DISABLE_REFERERS'];
  48. if (isset($arOldSetupVars['EXPORT_CHARSET']))
  49. $exportCharset = $arOldSetupVars['EXPORT_CHARSET'];
  50. if (isset($arOldSetupVars['MAX_EXECUTION_TIME']))
  51. $maxExecutionTime = $arOldSetupVars['MAX_EXECUTION_TIME'];
  52. if (isset($arOldSetupVars['CHECK_PERMISSIONS']))
  53. $checkPermissions = $arOldSetupVars['CHECK_PERMISSIONS'];
  54. }
  55. if ($STEP > 1)
  56. {
  57. $IBLOCK_ID = (int)$IBLOCK_ID;
  58. $rsIBlocks = CIBlock::GetByID($IBLOCK_ID);
  59. if ($IBLOCK_ID <= 0 || !($arIBlock = $rsIBlocks->Fetch()))
  60. {
  61. $arSetupErrors[] = GetMessage("CET_ERROR_NO_IBLOCK1")." #".$IBLOCK_ID." ".GetMessage("CET_ERROR_NO_IBLOCK2");
  62. }
  63. else
  64. {
  65. $bRightBlock = !CIBlockRights::UserHasRightTo($IBLOCK_ID, $IBLOCK_ID, "iblock_admin_display");
  66. if ($bRightBlock)
  67. {
  68. $arSetupErrors[] = str_replace('#IBLOCK_ID#',$IBLOCK_ID,GetMessage("CET_ERROR_IBLOCK_PERM"));
  69. }
  70. }
  71. $SITE_ID = trim($SITE_ID);
  72. if ($SITE_ID === '')
  73. {
  74. $arSetupErrors[] = GetMessage('BX_CATALOG_EXPORT_YANDEX_ERR_EMPTY_SITE');
  75. }
  76. else
  77. {
  78. $iterator = Main\SiteTable::getList(array(
  79. 'select' => array('LID'),
  80. 'filter' => array('=LID' => $SITE_ID, '=ACTIVE' => 'Y')
  81. ));
  82. $site = $iterator->fetch();
  83. if (empty($site))
  84. {
  85. $arSetupErrors[] = GetMessage('BX_CATALOG_EXPORT_YANDEX_ERR_BAD_SITE');
  86. }
  87. }
  88. if (!isset($SETUP_FILE_NAME) || $SETUP_FILE_NAME == '')
  89. {
  90. $arSetupErrors[] = GetMessage("CET_ERROR_NO_FILENAME");
  91. }
  92. elseif (preg_match(BX_CATALOG_FILENAME_REG, $strAllowExportPath.$SETUP_FILE_NAME))
  93. {
  94. $arSetupErrors[] = GetMessage("CES_ERROR_BAD_EXPORT_FILENAME");
  95. }
  96. elseif ($APPLICATION->GetFileAccessPermission($strAllowExportPath.$SETUP_FILE_NAME) < "W")
  97. {
  98. $arSetupErrors[] = str_replace("#FILE#", $strAllowExportPath.$SETUP_FILE_NAME, GetMessage('CET_YAND_RUN_ERR_SETUP_FILE_ACCESS_DENIED'));
  99. }
  100. $SETUP_SERVER_NAME = (isset($SETUP_SERVER_NAME) ? trim($SETUP_SERVER_NAME) : '');
  101. $COMPANY_NAME = (isset($COMPANY_NAME) ? trim($COMPANY_NAME) : '');
  102. if (empty($arSetupErrors))
  103. {
  104. $bAllSections = false;
  105. $arSections = array();
  106. if (!empty($V) && is_array($V))
  107. {
  108. foreach ($V as $key => $value)
  109. {
  110. if (trim($value) == "0")
  111. {
  112. $bAllSections = true;
  113. break;
  114. }
  115. $value = (int)$value;
  116. if ($value > 0)
  117. $arSections[] = $value;
  118. }
  119. }
  120. if (!$bAllSections && !empty($arSections))
  121. {
  122. $arCheckSections = array();
  123. $rsSections = CIBlockSection::GetList(array(), array('IBLOCK_ID' => $IBLOCK_ID, 'ID' => $arSections), false, array('ID'));
  124. while ($arOneSection = $rsSections->Fetch())
  125. {
  126. $arCheckSections[] = $arOneSection['ID'];
  127. }
  128. $arSections = $arCheckSections;
  129. }
  130. if (!$bAllSections && empty($arSections))
  131. {
  132. $arSetupErrors[] = GetMessage("CET_ERROR_NO_GROUPS");
  133. $V = array();
  134. }
  135. }
  136. if (is_array($V))
  137. {
  138. $V = array_unique(array_values($V));
  139. $_REQUEST['V'] = $V;
  140. }
  141. $arCatalog = CCatalogSku::GetInfoByIBlock($IBLOCK_ID);
  142. if (CCatalogSku::TYPE_PRODUCT == $arCatalog['CATALOG_TYPE'] || CCatalogSku::TYPE_FULL == $arCatalog['CATALOG_TYPE'])
  143. {
  144. if (!isset($XML_DATA) || $XML_DATA == '')
  145. {
  146. $arSetupErrors[] = GetMessage('YANDEX_ERR_SKU_SETTINGS_ABSENT');
  147. }
  148. }
  149. if (!isset($USE_HTTPS) || $USE_HTTPS != 'Y')
  150. $USE_HTTPS = 'N';
  151. if (isset($_POST['FILTER_AVAILABLE']) && is_string($_POST['FILTER_AVAILABLE']))
  152. $filterAvalable = $_POST['FILTER_AVAILABLE'];
  153. if (!isset($filterAvalable) || $filterAvalable != 'Y')
  154. $filterAvalable = 'N';
  155. if (isset($_POST['DISABLE_REFERERS']) && is_string($_POST['DISABLE_REFERERS']))
  156. $disableReferers = $_POST['DISABLE_REFERERS'];
  157. if (!isset($disableReferers) || $disableReferers != 'Y')
  158. $disableReferers = 'N';
  159. if (isset($_POST['EXPORT_CHARSET']) && is_string($_POST['EXPORT_CHARSET']))
  160. $exportCharset = $_POST['EXPORT_CHARSET'];
  161. if (!isset($exportCharset) || $exportCharset !== 'UTF-8')
  162. $exportCharset = 'windows-1251';
  163. if (isset($_POST['MAX_EXECUTION_TIME']) && is_string($_POST['MAX_EXECUTION_TIME']))
  164. $maxExecutionTime = $_POST['MAX_EXECUTION_TIME'];
  165. $maxExecutionTime = (!isset($maxExecutionTime) ? 0 : (int)$maxExecutionTime);
  166. if ($maxExecutionTime < 0)
  167. $maxExecutionTime = 0;
  168. if ($ACTION=="EXPORT_SETUP" || $ACTION=="EXPORT_EDIT" || $ACTION=="EXPORT_COPY")
  169. {
  170. if (!isset($SETUP_PROFILE_NAME) || $SETUP_PROFILE_NAME == '')
  171. $arSetupErrors[] = GetMessage("CET_ERROR_NO_PROFILE_NAME");
  172. }
  173. if (!empty($arSetupErrors))
  174. {
  175. $STEP = 1;
  176. }
  177. }
  178. $aMenu = array(
  179. array(
  180. "TEXT"=>GetMessage("CATI_ADM_RETURN_TO_LIST"),
  181. "TITLE"=>GetMessage("CATI_ADM_RETURN_TO_LIST_TITLE"),
  182. "LINK"=>"/bitrix/admin/cat_export_setup.php?lang=".LANGUAGE_ID,
  183. "ICON"=>"btn_list",
  184. )
  185. );
  186. $context = new CAdminContextMenu($aMenu);
  187. $context->Show();
  188. if (!empty($arSetupErrors))
  189. ShowError(implode('<br>', $arSetupErrors));
  190. $actionParams = "";
  191. if ($adminSidePanelHelper->isSidePanel())
  192. {
  193. $actionParams = "?IFRAME=Y&IFRAME_TYPE=SIDE_SLIDER";
  194. }
  195. ?>
  196. <!--suppress JSUnresolvedVariable -->
  197. <form method="post" action="<?echo $APPLICATION->GetCurPage().$actionParams ?>" name="yandex_setup_form" id="yandex_setup_form">
  198. <?
  199. $aTabs = array(
  200. array("DIV" => "yand_edit1", "TAB" => GetMessage("CAT_ADM_MISC_EXP_TAB1"), "ICON" => "store", "TITLE" => GetMessage("CAT_ADM_MISC_EXP_TAB1_TITLE")),
  201. array("DIV" => "yand_edit2", "TAB" => GetMessage("CAT_ADM_MISC_EXP_TAB2"), "ICON" => "store", "TITLE" => GetMessage("CAT_ADM_MISC_EXP_TAB2_TITLE")),
  202. );
  203. $tabControl = new CAdminTabControl("tabYandex", $aTabs, false, true);
  204. $tabControl->Begin();
  205. $tabControl->BeginNextTab();
  206. if ($STEP == 1)
  207. {
  208. if (!isset($SITE_ID))
  209. $SITE_ID = '';
  210. if (!isset($XML_DATA))
  211. $XML_DATA = '';
  212. if (!isset($filterAvalable) || $filterAvalable != 'Y')
  213. $filterAvalable = 'N';
  214. if (!isset($USE_HTTPS) || $USE_HTTPS != 'Y')
  215. $USE_HTTPS = 'N';
  216. if (!isset($disableReferers) || $disableReferers != 'Y')
  217. $disableReferers = 'N';
  218. if (!isset($exportCharset) || $exportCharset !== 'UTF-8')
  219. $exportCharset = 'windows-1251';
  220. if (!isset($SETUP_SERVER_NAME))
  221. $SETUP_SERVER_NAME = '';
  222. if (!isset($COMPANY_NAME))
  223. $COMPANY_NAME = '';
  224. if (!isset($SETUP_FILE_NAME))
  225. $SETUP_FILE_NAME = 'yandex_'.mt_rand(0, 999999).'.php';
  226. if (!isset($checkPermissions) || $checkPermissions != 'Y')
  227. $checkPermissions = 'N';
  228. $siteList = array();
  229. $iterator = Main\SiteTable::getList(array(
  230. 'select' => array('LID', 'NAME', 'SORT'),
  231. 'filter' => array('=ACTIVE' => 'Y'),
  232. 'order' => array('SORT' => 'ASC')
  233. ));
  234. while ($row = $iterator->fetch())
  235. $siteList[$row['LID']] = $row['NAME'];
  236. unset($row, $iterator);
  237. $iblockIds = array();
  238. $iblockSites = array();
  239. $iblockMultiSites = array();
  240. $iterator = Catalog\CatalogIblockTable::getList(array(
  241. 'select' => array(
  242. 'IBLOCK_ID',
  243. 'PRODUCT_IBLOCK_ID',
  244. 'IBLOCK_ACTIVE' => 'IBLOCK.ACTIVE',
  245. 'PRODUCT_IBLOCK_ACTIVE' => 'PRODUCT_IBLOCK.ACTIVE'
  246. ),
  247. 'filter' => array('')
  248. ));
  249. while ($row = $iterator->fetch())
  250. {
  251. $row['PRODUCT_IBLOCK_ID'] = (int)$row['PRODUCT_IBLOCK_ID'];
  252. $row['IBLOCK_ID'] = (int)$row['IBLOCK_ID'];
  253. if ($row['PRODUCT_IBLOCK_ID'] > 0)
  254. {
  255. if ($row['PRODUCT_IBLOCK_ACTIVE'] == 'Y')
  256. $iblockIds[$row['PRODUCT_IBLOCK_ID']] = true;
  257. }
  258. else
  259. {
  260. if ($row['IBLOCK_ACTIVE'] == 'Y')
  261. $iblockIds[$row['IBLOCK_ID']] = true;
  262. }
  263. }
  264. unset($row, $iterator);
  265. if (!empty($iblockIds))
  266. {
  267. $activeIds = array();
  268. $iterator = Iblock\IblockSiteTable::getList(array(
  269. 'select' => array('IBLOCK_ID', 'SITE_ID', 'SITE_SORT' => 'SITE.SORT'),
  270. 'filter' => array('@IBLOCK_ID' => array_keys($iblockIds), '=SITE.ACTIVE' => 'Y'),
  271. 'order' => array('IBLOCK_ID' => 'ASC', 'SITE_SORT' => 'ASC')
  272. ));
  273. while ($row = $iterator->fetch())
  274. {
  275. $id = (int)$row['IBLOCK_ID'];
  276. if (!isset($iblockSites[$id]))
  277. $iblockSites[$id] = array(
  278. 'ID' => $id,
  279. 'SITES' => array()
  280. );
  281. $iblockSites[$id]['SITES'][] = array(
  282. 'ID' => $row['SITE_ID'],
  283. 'NAME' => $siteList[$row['SITE_ID']]
  284. );
  285. if (!isset($iblockMultiSites[$id]))
  286. $iblockMultiSites[$id] = false;
  287. else
  288. $iblockMultiSites[$id] = true;
  289. $activeIds[$id] = true;
  290. }
  291. unset($id, $row, $iterator);
  292. if (empty($activeIds))
  293. {
  294. $iblockIds = array();
  295. $iblockSites = array();
  296. $iblockMultiSites = array();
  297. }
  298. else
  299. {
  300. $iblockIds = array_intersect_key($iblockIds, $activeIds);
  301. }
  302. unset($activeIds);
  303. }
  304. if (empty($iblockIds))
  305. {
  306. }
  307. $currentList = array();
  308. if ($IBLOCK_ID > 0 && isset($iblockIds[$IBLOCK_ID]))
  309. {
  310. $currentList = $iblockSites[$IBLOCK_ID]['SITES'];
  311. if ($SITE_ID === '')
  312. {
  313. $firstSite = reset($currentList);
  314. $SITE_ID = $firstSite['ID'];
  315. }
  316. }
  317. ?><tr>
  318. <td width="40%"><?=GetMessage('BX_CATALOG_EXPORT_IBLOCK'); ?></td>
  319. <td width="60%"><?
  320. echo GetIBlockDropDownListEx(
  321. $IBLOCK_ID, 'IBLOCK_TYPE_ID', 'IBLOCK_ID',
  322. array(
  323. 'ID' => array_keys($iblockIds),
  324. 'CHECK_PERMISSIONS' => 'Y',
  325. 'MIN_PERMISSION' => 'U'
  326. ),
  327. "ClearSelected(); changeIblockSites(0); BX('id_ifr').src='/bitrix/tools/catalog_export/yandex_util.php?IBLOCK_ID=0&'+'".bitrix_sessid_get()."';",
  328. "ClearSelected(); changeIblockSites(this[this.selectedIndex].value); BX('id_ifr').src='/bitrix/tools/catalog_export/yandex_util.php?IBLOCK_ID='+this[this.selectedIndex].value+'&'+'".bitrix_sessid_get()."';",
  329. 'class="adm-detail-iblock-types"',
  330. 'class="adm-detail-iblock-list"'
  331. );
  332. ?>
  333. <script type="text/javascript">
  334. var TreeSelected = [];
  335. <?
  336. $intCountSelected = 0;
  337. if (!empty($V) && is_array($V))
  338. {
  339. foreach ($V as $oneKey)
  340. {
  341. ?>TreeSelected[<? echo $intCountSelected ?>] = <? echo (int)$oneKey; ?>;
  342. <?
  343. $intCountSelected++;
  344. }
  345. }
  346. ?>
  347. function ClearSelected()
  348. {
  349. BX.showWait();
  350. TreeSelected = [];
  351. }
  352. </script>
  353. </td>
  354. </tr>
  355. <tr id="tr_SITE_ID" style="display: <?=(count($currentList) > 1 ? 'table-row' : 'none' ); ?>;">
  356. <td width="40%"><?=GetMessage('BX_CATALOG_EXPORT_YANDEX_SITE'); ?></td>
  357. <td width="60%">
  358. <script type="text/javascript">
  359. function changeIblockSites(iblockId)
  360. {
  361. var iblockSites = <?=CUtil::PhpToJSObject($iblockSites); ?>,
  362. iblockMultiSites = <?=CUtil::PhpToJSObject($iblockMultiSites); ?>,
  363. tableRow = null,
  364. siteControl = null,
  365. i,
  366. currentSiteList;
  367. tableRow = BX('tr_SITE_ID');
  368. siteControl = BX('SITE_ID');
  369. if (!BX.type.isElementNode(tableRow) || !BX.type.isElementNode(siteControl))
  370. return;
  371. for (i = siteControl.length-1; i >= 0; i--)
  372. siteControl.remove(i);
  373. if (typeof(iblockSites[iblockId]) !== 'undefined')
  374. {
  375. currentSiteList = iblockSites[iblockId]['SITES'];
  376. for (i = 0; i < currentSiteList.length; i++)
  377. {
  378. siteControl.appendChild(BX.create(
  379. 'option',
  380. {
  381. props: {value: BX.util.htmlspecialchars(currentSiteList[i].ID)},
  382. html: BX.util.htmlspecialchars('[' + currentSiteList[i].ID + '] ' + currentSiteList[i].NAME)
  383. }
  384. ));
  385. }
  386. }
  387. if (siteControl.length > 0)
  388. siteControl.selectedIndex = 0;
  389. else
  390. siteControl.selectedIndex = -1;
  391. BX.style(tableRow, 'display', (siteControl.length > 1 ? 'table-row' : 'none'));
  392. }
  393. </script>
  394. <select id="SITE_ID" name="SITE_ID">
  395. <?
  396. foreach ($currentList as $site)
  397. {
  398. $selected = ($site['ID'] == $SITE_ID ? ' selected' : '');
  399. $name = '['.$site['ID'].'] '.$site['NAME'];
  400. ?><option value="<?=htmlspecialcharsbx($site['ID']); ?>"<?=$selected; ?>><?=htmlspecialcharsbx($name); ?></option><?
  401. }
  402. unset($name, $selected, $site);
  403. ?>
  404. </select>
  405. </td>
  406. </tr>
  407. <tr>
  408. <td width="40%" valign="top"><?echo GetMessage("CET_SELECT_GROUP");?></td>
  409. <td width="60%"><?
  410. if ($intCountSelected)
  411. {
  412. foreach ($V as $oneKey)
  413. {
  414. $oneKey = (int)$oneKey;
  415. ?><input type="hidden" value="<? echo $oneKey; ?>" name="V[]" id="oldV<? echo $oneKey; ?>"><?
  416. }
  417. unset($oneKey);
  418. }
  419. ?><div id="tree"></div>
  420. <script type="text/javascript">
  421. BX.showWait();
  422. clevel = 0;
  423. function delOldV(obj)
  424. {
  425. if (!!obj)
  426. {
  427. var intSelKey = BX.util.array_search(obj.value, TreeSelected);
  428. if (obj.checked == false)
  429. {
  430. if (-1 < intSelKey)
  431. {
  432. TreeSelected = BX.util.deleteFromArray(TreeSelected, intSelKey);
  433. }
  434. var objOldVal = BX('oldV'+obj.value);
  435. if (!!objOldVal)
  436. {
  437. objOldVal.parentNode.removeChild(objOldVal);
  438. objOldVal = null;
  439. }
  440. }
  441. else
  442. {
  443. if (-1 == intSelKey)
  444. {
  445. TreeSelected[TreeSelected.length] = obj.value;
  446. }
  447. }
  448. }
  449. }
  450. function buildNoMenu()
  451. {
  452. var buffer;
  453. buffer = '<?echo GetMessageJS("CET_FIRST_SELECT_IBLOCK");?>';
  454. BX('tree', true).innerHTML = buffer;
  455. BX.closeWait();
  456. }
  457. function buildMenu()
  458. {
  459. var i,
  460. buffer,
  461. imgSpace,
  462. space;
  463. buffer = '<table border="0" cellspacing="0" cellpadding="0">';
  464. buffer += '<tr>';
  465. buffer += '<td colspan="2" valign="top" align="left"><input type="checkbox" name="V[]" value="0" id="v0"'+(BX.util.in_array(0,TreeSelected) ? ' checked' : '')+' onclick="delOldV(this);"><label for="v0"><font class="text"><b><?echo CUtil::JSEscape(GetMessage("CET_ALL_GROUPS"));?></b></font></label></td>';
  466. buffer += '</tr>';
  467. for (i in Tree[0])
  468. {
  469. if (!Tree[0][i])
  470. {
  471. space = '<input type="checkbox" name="V[]" value="'+i+'" id="V'+i+'"'+(BX.util.in_array(i,TreeSelected) ? ' checked' : '')+' onclick="delOldV(this);"><label for="V'+i+'"><span class="text">' + Tree[0][i][0] + '</span></label>';
  472. imgSpace = '';
  473. }
  474. else
  475. {
  476. space = '<input type="checkbox" name="V[]" value="'+i+'"'+(BX.util.in_array(i,TreeSelected) ? ' checked' : '')+' onclick="delOldV(this);"><a href="javascript: collapse(' + i + ')"><span class="text"><b>' + Tree[0][i][0] + '</b></span></a>';
  477. imgSpace = '<img src="/bitrix/images/catalog/load/plus.gif" width="13" height="13" id="img_' + i + '" OnClick="collapse(' + i + ')">';
  478. }
  479. buffer += '<tr>';
  480. buffer += '<td width="20" valign="top" align="center">' + imgSpace + '</td>';
  481. buffer += '<td id="node_' + i + '">' + space + '</td>';
  482. buffer += '</tr>';
  483. }
  484. buffer += '</table>';
  485. BX('tree', true).innerHTML = buffer;
  486. BX.adminPanel.modifyFormElements('yandex_setup_form');
  487. BX.closeWait();
  488. }
  489. function collapse(node)
  490. {
  491. if (!BX('table_' + node))
  492. {
  493. var i,
  494. buffer,
  495. imgSpace,
  496. space;
  497. buffer = '<table border="0" id="table_' + node + '" cellspacing="0" cellpadding="0">';
  498. for (i in Tree[node])
  499. {
  500. if (!Tree[node][i])
  501. {
  502. space = '<input type="checkbox" name="V[]" value="'+i+'" id="V'+i+'"'+(BX.util.in_array(i,TreeSelected) ? ' checked' : '')+' onclick="delOldV(this);"><label for="V'+i+'"><font class="text">' + Tree[node][i][0] + '</font></label>';
  503. imgSpace = '';
  504. }
  505. else
  506. {
  507. space = '<input type="checkbox" name="V[]" value="'+i+'"'+(BX.util.in_array(i,TreeSelected) ? ' checked' : '')+' onclick="delOldV(this);"><a href="javascript: collapse(' + i + ')"><font class="text"><b>' + Tree[node][i][0] + '</b></font></a>';
  508. imgSpace = '<img src="/bitrix/images/catalog/load/plus.gif" width="13" height="13" id="img_' + i + '" OnClick="collapse(' + i + ')">';
  509. }
  510. buffer += '<tr>';
  511. buffer += '<td width="20" align="center" valign="top">' + imgSpace + '</td>';
  512. buffer += '<td id="node_' + i + '">' + space + '</td>';
  513. buffer += '</tr>';
  514. }
  515. buffer += '</table>';
  516. BX('node_' + node).innerHTML += buffer;
  517. BX('img_' + node).src = '/bitrix/images/catalog/load/minus.gif';
  518. }
  519. else
  520. {
  521. var tbl = BX('table_' + node);
  522. tbl.parentNode.removeChild(tbl);
  523. BX('img_' + node).src = '/bitrix/images/catalog/load/plus.gif';
  524. }
  525. BX.adminPanel.modifyFormElements('yandex_setup_form');
  526. }
  527. </script>
  528. <iframe src="/bitrix/tools/catalog_export/yandex_util.php?IBLOCK_ID=<?=intval($IBLOCK_ID)?>&<? echo bitrix_sessid_get(); ?>" id="id_ifr" name="ifr" style="display:none"></iframe>
  529. </td>
  530. </tr>
  531. <tr>
  532. <td width="40%"><?=GetMessage('CAT_DETAIL_PROPS')?>:</td>
  533. <td width="60%">
  534. <script type="text/javascript">
  535. function showDetailPopup()
  536. {
  537. if (!obDetailWindow)
  538. {
  539. var s = BX('IBLOCK_ID');
  540. var dat = BX('XML_DATA');
  541. var obDetailWindow = new BX.CAdminDialog({
  542. 'content_url': '/bitrix/tools/catalog_export/yandex_detail.php?lang=<?=LANGUAGE_ID?>&bxpublic=Y&IBLOCK_ID=' + s[s.selectedIndex].value,
  543. 'content_post': 'XML_DATA='+BX.util.urlencode(dat.value)+'&'+'<?echo bitrix_sessid_get(); ?>',
  544. 'width': 900, 'height': 550,
  545. 'resizable': true
  546. });
  547. obDetailWindow.Show();
  548. }
  549. }
  550. function setDetailData(data)
  551. {
  552. BX('XML_DATA').value = data;
  553. }
  554. </script>
  555. <input type="button" onclick="showDetailPopup(); return false;" value="<? echo GetMessage('CAT_DETAIL_PROPS_RUN'); ?>">
  556. <input type="hidden" id="XML_DATA" name="XML_DATA" value="<?=htmlspecialcharsbx($XML_DATA); ?>">
  557. </td>
  558. </tr>
  559. <tr>
  560. <td width="40%"><? echo GetMessage('CAT_YANDEX_CHECK_PERMISSIONS'); ?></td>
  561. <td width="60%">
  562. <input type="hidden" name="CHECK_PERMISSIONS" value="N">
  563. <input type="checkbox" name="CHECK_PERMISSIONS" value="Y"<?=($checkPermissions == 'Y' ? ' checked' : ''); ?>
  564. </td>
  565. </tr>
  566. <tr>
  567. <td width="40%"><? echo GetMessage('CAT_YANDEX_FILTER_AVAILABLE'); ?></td>
  568. <td width="60%">
  569. <input type="hidden" name="FILTER_AVAILABLE" value="N">
  570. <input type="checkbox" name="FILTER_AVAILABLE" value="Y"<? echo ($filterAvalable == 'Y' ? ' checked' : ''); ?>
  571. </td>
  572. </tr>
  573. <tr>
  574. <td width="40%"><? echo GetMessage('CAT_YANDEX_USE_HTTPS'); ?></td>
  575. <td width="60%">
  576. <input type="hidden" name="USE_HTTPS" value="N">
  577. <input type="checkbox" name="USE_HTTPS" value="Y"<? echo ($USE_HTTPS == 'Y' ? ' checked' : ''); ?>
  578. </td>
  579. </tr>
  580. <tr>
  581. <td width="40%"><? echo GetMessage('CAT_YANDEX_DISABLE_REFERERS'); ?></td>
  582. <td width="60%">
  583. <input type="hidden" name="DISABLE_REFERERS" value="N">
  584. <input type="checkbox" name="DISABLE_REFERERS" value="Y"<? echo ($disableReferers == 'Y' ? ' checked' : ''); ?>
  585. </td>
  586. </tr>
  587. <tr>
  588. <td width="40%"><? echo GetMessage('BX_CATALOG_EXPORT_YANDEX_OPTION_CONVERT_TO_UTF'); ?></td>
  589. <td width="60%">
  590. <input type="hidden" name="EXPORT_CHARSET" value="windows-1251">
  591. <input type="checkbox" name="EXPORT_CHARSET" value="UTF-8"<? echo ($exportCharset == 'UTF-8' ? ' checked' : ''); ?>
  592. </td>
  593. </tr>
  594. <?
  595. $maxExecutionTime = (isset($maxExecutionTime) ? (int)$maxExecutionTime : 0);
  596. ?><tr>
  597. <td width="40%"><?=GetMessage('CAT_MAX_EXECUTION_TIME');?></td>
  598. <td width="60%">
  599. <input type="text" name="MAX_EXECUTION_TIME" size="40" value="<?=$maxExecutionTime; ?>">
  600. </td>
  601. </tr>
  602. <tr>
  603. <td width="40%" style="padding-top: 0;">&nbsp;</td>
  604. <td width="60%" style="padding-top: 0;"><small><?=GetMessage("CAT_MAX_EXECUTION_TIME_NOTE");?></small></td>
  605. </tr>
  606. <tr>
  607. <td width="40%"><?echo GetMessage("CET_SERVER_NAME");?></td>
  608. <td width="60%">
  609. <input type="text" name="SETUP_SERVER_NAME" value="<?=htmlspecialcharsbx($SETUP_SERVER_NAME); ?>" size="50"> <input type="button" onclick="this.form['SETUP_SERVER_NAME'].value = window.location.host;" value="<?echo htmlspecialcharsbx(GetMessage('CET_SERVER_NAME_SET_CURRENT'))?>">
  610. </td>
  611. </tr>
  612. <tr>
  613. <td width="40%"><?=GetMessage("BX_CATALOG_EXPORT_YANDEX_COMPANY_NAME");?></td>
  614. <td width="60%">
  615. <input type="text" name="COMPANY_NAME" value="<?=htmlspecialcharsbx($COMPANY_NAME); ?>" size="50">
  616. </td>
  617. </tr>
  618. <tr>
  619. <td width="40%"><?echo GetMessage("CET_SAVE_FILENAME");?></td>
  620. <td width="60%">
  621. <b><? echo htmlspecialcharsbx(COption::GetOptionString("catalog", "export_default_path", "/bitrix/catalog_export/"));?></b><input type="text" name="SETUP_FILE_NAME" value="<?=htmlspecialcharsbx($SETUP_FILE_NAME); ?>" size="50">
  622. </td>
  623. </tr>
  624. <?
  625. if ($ACTION=="EXPORT_SETUP" || $ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY')
  626. {
  627. ?><tr>
  628. <td width="40%"><?echo GetMessage("CET_PROFILE_NAME");?></td>
  629. <td width="60%">
  630. <input type="text" name="SETUP_PROFILE_NAME" value="<?echo htmlspecialcharsbx($SETUP_PROFILE_NAME) ?>" size="30">
  631. </td>
  632. </tr><?
  633. }
  634. }
  635. $tabControl->EndTab();
  636. $tabControl->BeginNextTab();
  637. if ($STEP==2)
  638. {
  639. $SETUP_FILE_NAME = $strAllowExportPath.$SETUP_FILE_NAME;
  640. if ($XML_DATA <> '')
  641. {
  642. $XML_DATA = base64_decode($XML_DATA);
  643. }
  644. $SETUP_SERVER_NAME = htmlspecialcharsbx($SETUP_SERVER_NAME);
  645. $_POST['SETUP_SERVER_NAME'] = htmlspecialcharsbx($_POST['SETUP_SERVER_NAME']);
  646. $_REQUEST['SETUP_SERVER_NAME'] = htmlspecialcharsbx($_REQUEST['SETUP_SERVER_NAME']);
  647. $FINITE = true;
  648. }
  649. $tabControl->EndTab();
  650. $tabControl->Buttons();
  651. ?><? echo bitrix_sessid_post();?><?
  652. if ($ACTION == 'EXPORT_EDIT' || $ACTION == 'EXPORT_COPY')
  653. {
  654. ?><input type="hidden" name="PROFILE_ID" value="<? echo intval($PROFILE_ID); ?>"><?
  655. }
  656. if (2 > $STEP)
  657. {
  658. ?><input type="hidden" name="lang" value="<?echo LANGUAGE_ID ?>">
  659. <input type="hidden" name="ACT_FILE" value="<?echo htmlspecialcharsbx($_REQUEST["ACT_FILE"]) ?>">
  660. <input type="hidden" name="ACTION" value="<?echo htmlspecialcharsbx($ACTION) ?>">
  661. <input type="hidden" name="STEP" value="<?echo intval($STEP) + 1 ?>">
  662. <input type="hidden" name="SETUP_FIELDS_LIST" value="V,IBLOCK_ID,SITE_ID,SETUP_SERVER_NAME,COMPANY_NAME,SETUP_FILE_NAME,XML_DATA,USE_HTTPS,FILTER_AVAILABLE,DISABLE_REFERERS,EXPORT_CHARSET,MAX_EXECUTION_TIME,CHECK_PERMISSIONS">
  663. <input type="submit" value="<?echo ($ACTION=="EXPORT")?GetMessage("CET_EXPORT"):GetMessage("CET_SAVE")?>"><?
  664. }
  665. $tabControl->End();
  666. ?></form>
  667. <script type="text/javascript">
  668. <?if ($STEP < 2):?>
  669. tabYandex.SelectTab("yand_edit1");
  670. tabYandex.DisableTab("yand_edit2");
  671. <?elseif ($STEP == 2):?>
  672. tabYandex.SelectTab("yand_edit2");
  673. tabYandex.DisableTab("yand_edit1");
  674. <?endif;?>
  675. </script>