- Модуль: iblock
- Путь к файлу: ~/bitrix/modules/iblock/classes/general/iblock.php
- Класс: CAllIBlock
- Вызов: CAllIBlock::AddPanelButtons
static function AddPanelButtons($mode, $componentName, $arButtons)
{
/** @global CMain $APPLICATION */
global $APPLICATION;
$arImages = array(
"add_element" => (defined("PANEL_ADD_ELEMENT_BTN")) ? PANEL_ADD_ELEMENT_BTN : "/bitrix/images/iblock/icons/new_element.gif",
"edit_element" => (defined("PANEL_EDIT_ELEMENT_BTN")) ? PANEL_EDIT_ELEMENT_BTN : "/bitrix/images/iblock/icons/edit_element.gif",
"edit_iblock" => (defined("PANEL_EDIT_IBLOCK_BTN")) ? PANEL_EDIT_IBLOCK_BTN : "/bitrix/images/iblock/icons/edit_iblock.gif",
"history_element" => (defined("PANEL_HISTORY_ELEMENT_BTN")) ? PANEL_HISTORY_ELEMENT_BTN : "/bitrix/images/iblock/icons/history.gif",
"edit_section" => (defined("PANEL_EDIT_SECTION_BTN")) ? PANEL_EDIT_SECTION_BTN : "/bitrix/images/iblock/icons/edit_section.gif",
"add_section" => (defined("PANEL_ADD_SECTION_BTN")) ? PANEL_ADD_SECTION_BTN : "/bitrix/images/iblock/icons/new_section.gif",
"element_list" => "/bitrix/themes/.default/icons/iblock/mnu_iblock_el.gif",
"section_list" => "/bitrix/themes/.default/icons/iblock/mnu_iblock_sec.gif",
);
$componentName = (string)$componentName;
if (!empty($arButtons[$mode]) && is_array($arButtons[$mode]))
{
//Try to detect component via backtrace
if ($componentName === '')
{
$arTrace = debug_backtrace();
foreach($arTrace as $arCallInfo)
{
if (isset($arCallInfo["file"]))
{
$file = mb_strtolower(str_replace("\", "/", $arCallInfo["file"]));
if(preg_match("#.*/bitrix/components/(.+?)/(.+?)/#", $file, $match))
{
$componentName = $match[1].":".$match[2];
break;
}
}
}
}
if ($componentName !== '')
{
$arComponentDescription = CComponentUtil::GetComponentDescr($componentName);
if(is_array($arComponentDescription) && mb_strlen($arComponentDescription["NAME"]))
$componentName = $arComponentDescription["NAME"];
}
else
{
$componentName = GetMessage("IBLOCK_PANEL_UNKNOWN_COMPONENT");
}
$arPanelButton = array(
"SRC" => "/bitrix/images/iblock/icons/iblock.gif",
"ALT" => $componentName,
"TEXT" => $componentName,
"MAIN_SORT" => 300,
"SORT" => 30,
"MENU" => array(),
"MODE" => $mode,
);
foreach($arButtons[$mode] as $i=>$arSubButton)
{
if (isset($arImages[$i]))
$arSubButton['IMAGE'] = $arImages[$i];
if($arSubButton["DEFAULT"])
$arPanelButton["HREF"] = $arSubButton["ACTION"];
$arPanelButton["MENU"][] = $arSubButton;
}
if (!empty($arButtons["submenu"]) && is_array($arButtons["submenu"]))
{
$arSubMenu = array(
"SRC" => "/bitrix/images/iblock/icons/iblock.gif",
"ALT" => GetMessage("IBLOCK_PANEL_CONTROL_PANEL_ALT"),
"TEXT" => GetMessage("IBLOCK_PANEL_CONTROL_PANEL"),
"MENU" => array(),
"MODE" => $mode,
);
foreach($arButtons["submenu"] as $i=>$arSubButton)
{
if (isset($arImages[$i]))
$arSubButton['IMAGE'] = $arImages[$i];
$arSubMenu["MENU"][] = $arSubButton;
}
$arPanelButton["MENU"][] = array("SEPARATOR" => "Y");
$arPanelButton["MENU"][] = $arSubMenu;
}
$APPLICATION->AddPanelButton($arPanelButton);
}
if (!empty($arButtons["intranet"]) && is_array($arButtons["intranet"]) && CModule::IncludeModule("intranet"))
{
/** @global CIntranetToolbar $INTRANET_TOOLBAR */
global $INTRANET_TOOLBAR;
foreach($arButtons["intranet"] as $arButton)
$INTRANET_TOOLBAR->AddButton($arButton);
}
}