/bitrix/modules/main/interface/top_panel.php

https://bitbucket.org/Dezer32/test_bitrix · PHP · 307 lines · 230 code · 69 blank · 8 comment · 56 complexity · fc7e55750cd7188483be5f9d17b973fa MD5 · raw file

  1. <?
  2. if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true) die();
  3. IncludeModuleLangFile(__FILE__);
  4. if($_GET["back_url_pub"] <> "" && !is_array($_GET["back_url_pub"]) && strpos($_GET["back_url_pub"], "/") === 0)
  5. $_SESSION["BACK_URL_PUB"] = $_GET["back_url_pub"];
  6. $params = DeleteParam(array("logout", "back_url_pub"));
  7. $arPanelButtons = array();
  8. function _showTopPanelButtonsSection($arPanelButtons, $hkInstance, $section = null)
  9. {
  10. global $USER;
  11. foreach ($arPanelButtons as $item):
  12. if($item["SEPARATOR"] == true)
  13. continue;
  14. if ($section == null && isset($item['SECTION']))
  15. continue;
  16. if ($section != null && $item['SECTION'] != $section)
  17. continue;
  18. $id = isset($item['ID']) ? $item['ID'] : 'bx_top_panel_button_'.RandString();
  19. $bHasMenu = (is_array($item["MENU"]) && !empty($item["MENU"]));
  20. if($USER->IsAuthorized())
  21. echo $hkInstance->PrintTPButton($item);
  22. if ($item['LINK']):
  23. ?><a id="<?=htmlspecialcharsEx($id)?>" href="<?=htmlspecialcharsEx($item['LINK'])?>" class="<?=$item['ICON']?>"<?=isset($item["TITLE"])?' title="'.htmlspecialcharsEx($item["TITLE"]).'"':''?><?=isset($item["TARGET"])?' target="'.htmlspecialcharsEx($item["TARGET"]).'"':''?> hidefocus="true" onfocus="this.blur();"><?=htmlspecialcharsbx($item["TEXT"])?></a><?
  24. else:
  25. ?><span id="<?=htmlspecialcharsEx($id)?>" class="<?=$item['ICON']?>"<?=isset($item["TITLE"])?'title="'.htmlspecialcharsEx($item["TITLE"]).'"':''?>><?=htmlspecialcharsbx($item["TEXT"])?></span><?
  26. endif;
  27. if ($bHasMenu || $item['TOOLTIP'] && $item['TOOLTIP_ID']):
  28. ?><script type="text/javascript"><?
  29. if ($item['TOOLTIP']):
  30. if ($item['TOOLTIP_ID']):
  31. ?>
  32. BX.ready(function() {BX.hint(BX('<?=CUtil::JSEscape($id)?>'), '<?=CUtil::JSEscape($item["TITLE"])?>', '<?=CUtil::JSEscape($item['TOOLTIP'])?>', '<?=CUtil::JSEscape($item['TOOLTIP_ID'])?>')});
  33. <?
  34. endif;
  35. endif;
  36. if ($bHasMenu):
  37. ?>
  38. BX.adminPanel.registerButton('<?=CUtil::JSEscape($id)?>', {MENU: <?=CUtil::PhpToJsObject($item['MENU'])?>});
  39. <?
  40. endif;
  41. ?></script><?
  42. endif;
  43. endforeach;
  44. }
  45. if($USER->IsAuthorized())
  46. {
  47. $bCanViewSettings = (is_callable(array($USER,'CanDoOperation')) && ($USER->CanDoOperation('view_other_settings') || $USER->CanDoOperation('edit_other_settings')));
  48. if($bCanViewSettings)
  49. {
  50. //Settings
  51. $settingsUrl = BX_ROOT."/admin/settings.php?lang=".LANG."&mid=".(defined("ADMIN_MODULE_NAME")? ADMIN_MODULE_NAME:"main").($APPLICATION->GetCurPage() <> BX_ROOT."/admin/settings.php"? "&back_url_settings=".urlencode($_SERVER["REQUEST_URI"]):"");
  52. $arPanelButtons[] = array(
  53. "TEXT"=>GetMessage("top_panel_settings"),
  54. "TITLE"=>GetMessage("button_settings"),
  55. "LINK"=>$settingsUrl,
  56. "ICON"=>"adm-header-setting-btn",
  57. "HK_ID"=>"top_panel_settings",
  58. );
  59. }
  60. //Help
  61. $module = (defined("ADMIN_MODULE_NAME")? ADMIN_MODULE_NAME: "main");
  62. $page = (defined("HELP_FILE") && strpos(HELP_FILE, '/') === false? HELP_FILE : basename($APPLICATION->GetCurPage()));
  63. $aActiveSection = $adminMenu->ActiveSection();
  64. $section = $aActiveSection["help_section"]."/";
  65. if (defined("HELP_FILE") && strpos(HELP_FILE, $section) === 0)
  66. $section = "";
  67. }
  68. /*
  69. * @global \CAdminPage $adminPage
  70. */
  71. $arLangs = CLanguage::GetLangSwitcherArray();
  72. $arLangButton = array();
  73. $arLangMenu = array();
  74. foreach($arLangs as $adminLang)
  75. {
  76. if ($adminLang['SELECTED'])
  77. {
  78. $arLangButton = array(
  79. "TEXT"=>ToUpper($adminLang["LID"]),
  80. "TITLE"=>GetMessage("top_panel_lang")." ".$adminLang["NAME"],
  81. "LINK"=>htmlspecialcharsback($adminLang["PATH"]),
  82. "SECTION" => 1,
  83. "ICON" => "adm-header-language",
  84. );
  85. }
  86. $arLangMenu[] = array(
  87. "TEXT" => '('.$adminLang["LID"].') '.$adminLang["NAME"],
  88. "TITLE"=> GetMessage("top_panel_lang")." ".$adminLang["NAME"],
  89. "LINK"=>htmlspecialcharsback($adminLang["PATH"]),
  90. );
  91. }
  92. if (count($arLangMenu) > 1)
  93. {
  94. CJSCore::Init(array('admin_interface'));
  95. $arLangButton['MENU'] = $arLangMenu;
  96. }
  97. $arPanelButtons[] = $arLangButton;
  98. $sPubUrl = ($_SESSION["BACK_URL_PUB"] <> ""?
  99. htmlspecialcharsbx($_SESSION["BACK_URL_PUB"]).(strpos($_SESSION["BACK_URL_PUB"], "?") !== false? "&amp;":"?") : '/?').
  100. 'back_url_admin='.urlencode($APPLICATION->GetCurPage().($params<>""? "?".$params:""));
  101. $aUserOptGlobal = CUserOptions::GetOption("global", "settings");
  102. if($USER->IsAuthorized())
  103. {
  104. $hkInstance = CHotKeys::getInstance();
  105. $Execs=$hkInstance->GetCodeByClassName("top_panel_menu",GetMessage("admin_panel_menu"));
  106. echo $hkInstance->PrintJSExecs($Execs);
  107. $Execs=$hkInstance->GetCodeByClassName("admin_panel_site",GetMessage("admin_panel_site"));
  108. echo $hkInstance->PrintJSExecs($Execs);
  109. $Execs=$hkInstance->GetCodeByClassName("admin_panel_admin",GetMessage("admin_panel_admin"));
  110. echo $hkInstance->PrintJSExecs($Execs);
  111. }
  112. ?>
  113. <div id="bx-panel" class="adm-header"><div class="adm-header-left"><a hidefocus="true" href="<?=$sPubUrl?>" id="bx-panel-view-tab" class="adm-header-btn adm-header-btn-site" title="<?=GetMessage("adm_top_panel_view_title")?>"><?=GetMessage("admin_panel_site")?></a><a hidefocus="true" href="<?=BX_ROOT."/admin/index.php?lang=".LANGUAGE_ID?>" class="adm-header-btn adm-header-btn-admin"><?echo GetMessage("admin_panel_admin")?></a><?
  114. $informerItemsCount = CAdminInformer::InsertMainItems();
  115. if ($USER->IsAuthorized() && $informerItemsCount>0):
  116. ?><span class="adm-header-notif-block" id="adm-header-notif-block" onclick="BX.adminInformer.Toggle(this);" title="<?=GetMessage("admin_panel_notif_block_title")?>"><span class="adm-header-notif-icon"></span><span class="adm-header-notif-counter" id="adm-header-notif-counter"><?=CAdminInformer::$alertCounter?></span></span><?
  117. endif;
  118. _showTopPanelButtonsSection($arPanelButtons, $hkInstance)
  119. ?></div><div class="adm-header-right"><?
  120. if($USER->IsAuthorized() && IsModuleInstalled("search")):
  121. ?><div class="adm-header-search-block" id="bx-search-box"><input class="adm-header-search" id="bx-search-input" onfocus="if (this.value=='<?=GetMessage("top_panel_search_def")?>') {this.value=''; BX.addClass(this.parentNode,'adm-header-search-block-active');}" value="<?=GetMessage("top_panel_search_def")?>" onblur="if (this.value==''){this.value='<?=GetMessage("top_panel_search_def")?>'; BX.removeClass(this.parentNode,'adm-header-search-block-active');}" type="text" autocomplete="off" /><a href="#" onclick="BX('bx-search-input').value=''; BX('bx-search-input').onblur();" class="adm-header-search-block-btn"></a></div><script type="text/javascript">
  122. var jsControl = new JCAdminTitleSearch({
  123. 'AJAX_PAGE' : '/bitrix/admin/get_search.php?lang=<?=LANGUAGE_ID?>',
  124. 'CONTAINER_ID': 'bx-search-box',
  125. 'INPUT_ID': 'bx-search-input',
  126. 'MIN_QUERY_LEN': 1
  127. });
  128. </script><?
  129. $Execs = $hkInstance->GetCodeByClassName("bx-search-input", GetMessage("top_panel_search_def"));
  130. echo $hkInstance->PrintJSExecs($Execs);
  131. endif;
  132. ?><div class="adm-header-right-block"><?
  133. if ($USER->IsAuthorized()):
  134. /*
  135. * @global \CAdminPage $adminPage
  136. */
  137. $ssoSwitcher = $adminPage->getSSOSwitcherButton();
  138. $bShowSSO = is_array($ssoSwitcher) && count($ssoSwitcher) > 0;
  139. $userName = $USER->GetFormattedName();
  140. if($bShowSSO)
  141. {
  142. $userName = '<span class="adm-header-separate-left">'.$userName.'</span><span class="adm-header-separate-right" id="bx-panel-sso"></span>';
  143. }
  144. if ($USER->CanDoOperation('view_own_profile') || $USER->CanDoOperation('edit_own_profile')):
  145. ?><a hidefocus="true" href="/bitrix/admin/user_edit.php?lang=<?=LANGUAGE_ID?>&amp;ID=<?=$USER->GetID()?>" class="adm-header-user-block<?=$bShowSSO ? ' adm-header-separate' : ''?>" onfocus="this.blur()"><?=$userName;?></a><?
  146. else:
  147. ?><span class="adm-header-user-block<?=$bShowSSO ? ' adm-header-separate' : ''?>" id="bx-panel-user"><?=$userName?></span><?
  148. endif;
  149. if($bShowSSO)
  150. {
  151. ?>
  152. <script>BX.adminPanel.registerButton('bx-panel-sso', {MENU: <?=CUtil::PhpToJsObject($ssoSwitcher)?>});</script>
  153. <?
  154. }
  155. ?><a hidefocus="true" href="<?=htmlspecialcharsbx((defined('BX_ADMIN_SECTION_404') && BX_ADMIN_SECTION_404 == 'Y' ? '/bitrix/admin/' : $APPLICATION->GetCurPage())).'?logout=yes'.htmlspecialcharsbx(($s=DeleteParam(array("logout"))) == ""? "":"&".$s)?>" class="adm-header-exit" id="bx-panel-logout" title="<?=GetMessage('admin_panel_logout_title')?>"><?=GetMessage("admin_panel_logout")?></a><?
  156. $Execs = $hkInstance->GetCodeByClassName("bx-panel-logout",GetMessage('admin_panel_logout'));
  157. echo $hkInstance->PrintJSExecs($Execs);
  158. endif;
  159. _showTopPanelButtonsSection($arPanelButtons, $hkInstance, 1);
  160. if ($USER->IsAuthorized()):
  161. if($hkInstance->IsActive()):
  162. ?><a hidefocus="true" id="bx-panel-hotkeys" href="javascript:void(0)" onclick="BXHotKeys.ShowSettings();" class="header-keyboard" title="<?=GetMessage('admin_panel_hotkeys_title')?>"></a><?
  163. endif;
  164. $aUserOpt = CUserOptions::GetOption("admin_panel", "settings");
  165. ?><a hidefocus="true" href="javascript:void(0)" id="bx-panel-pin" class="adm-header-pin" onclick="BX.adminPanel.Fix(this)" title="<?=GetMessage('top_panel_pin_'.($aUserOpt['fix'] == 'on' ? 'off' : 'on'))?>"></a><?
  166. if(LANGUAGE_ID == "ru")
  167. {
  168. CJSCore::Init(array('helper'));
  169. $helpUrl = CHTTP::urlAddParams('https://helpdesk.bitrix24.ru/widget2/dev/', array(
  170. "url" => urlencode("https://".$_SERVER["HTTP_HOST"].$APPLICATION->GetCurPageParam()),
  171. "user_id" => $USER->GetID(),
  172. "is_admin" => $USER->IsAdmin() ? 1 : 0,
  173. "help_url" => urlencode("http://dev.1c-bitrix.ru/user_help/".$section.(defined("HELP_FILE") && strpos(HELP_FILE, '/') !== false? HELP_FILE : $module."/".$page))
  174. )
  175. );
  176. $frameOpenUrl = CHTTP::urlAddParams($helpUrl, array(
  177. "action" => "open",
  178. )
  179. );
  180. $frameCloseUrl = CHTTP::urlAddParams($helpUrl, array(
  181. "action" => "close",
  182. )
  183. );
  184. $helperHeroOption = CUserOptions::GetOption("main", "helper_hero_admin");
  185. $showHelperHero = true;
  186. if (!empty($helperHeroOption))
  187. {
  188. if (
  189. isset($helperHeroOption["show"])
  190. || (isset($helperHeroOption["time"]) && time() - $helperHeroOption["time"] < 3600)
  191. )
  192. $showHelperHero = false;
  193. }
  194. ?>
  195. <span class="adm-header-help-btn" id="bx_top_panel_button_helper" <?if (!isset($helperHeroOption["show"])):?>onclick="BX.userOptions.save('main', 'helper_hero_admin', 'show', 'Y');"<?endif?>>
  196. <span class="adm-header-help-btn-icon"></span>
  197. <span class="adm-header-help-btn-text"><?=GetMessage("top_panel_help")?></span>
  198. </span>
  199. <script>
  200. BX.message({
  201. HELPER_LOADER: '<?=GetMessageJS('top_panel_help_loader')?>',
  202. HELPER_TITLE: '<?=GetMessageJS('top_panel_help_title')?>'
  203. });
  204. BX.Helper.init({
  205. frameOpenUrl : '<?=$frameOpenUrl?>',
  206. helpBtn : BX('bx_top_panel_button_helper'),
  207. langId: '<?=LANGUAGE_ID?>',
  208. needCheckNotify: 'N',
  209. isAdmin: 'Y'
  210. });
  211. <?if ($showHelperHero):?>
  212. BX.Helper.showAnimatedHero();
  213. BX.userOptions.save('main', 'helper_hero_admin', 'time', '<?=time()?>');
  214. <?endif?>
  215. </script>
  216. <?
  217. }
  218. else
  219. {
  220. $helpLink = "http://www.bitrixsoft.com/help/index.html?page=" . urlencode("source/" . $module . "/help/en/" . $page . ".html");
  221. ?>
  222. <span onclick="document.location.href = '<?=$helpLink?>';" class="adm-header-help-btn" id="bx_top_panel_button_helper">
  223. <span class="adm-header-help-btn-icon"></span>
  224. <span class="adm-header-help-btn-text"><?=GetMessage("top_panel_help")?></span>
  225. </span>
  226. <?
  227. }
  228. ?>
  229. <?
  230. $Execs = $hkInstance->GetCodeByClassName("bx-panel-pin",GetMessage('top_panel_pin'));
  231. echo $hkInstance->PrintJSExecs($Execs);
  232. endif;
  233. ?></div></div><div class="adm-header-bottom"></div><?
  234. if ($USER->IsAdmin())
  235. echo CAdminNotify::GetHtml();
  236. ?></div><?
  237. echo $GLOBALS["adminPage"]->ShowSound();
  238. ?>