Example #1
0
 public function GetIcons()
 {
     /** @global CMain $APPLICATION */
     global $USER, $APPLICATION;
     $arIcons = array();
     $arPanelParams = array();
     $arComponentDescription = CComponentUtil::GetComponentDescr($this->componentName);
     $bComponentAccess = $USER->CanDoOperation('edit_php') || $this->bSrcFound && $USER->CanDoFileOperation('fm_lpa', array(SITE_ID, $this->sSrcFile));
     if ($bComponentAccess && !$this->parentComponent && $this->bSrcFound) {
         $url = $APPLICATION->GetPopupLink(array('URL' => "/bitrix/admin/component_props.php?" . "component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&component_template=" . urlencode(CUtil::addslashes($this->componentTemplate)) . "&template_id=" . urlencode(CUtil::addslashes(SITE_TEMPLATE_ID)) . "&lang=" . urlencode(CUtil::addslashes(LANGUAGE_ID)) . "&src_path=" . urlencode(CUtil::addslashes($this->sSrcFile)) . "&src_line=" . $this->iSrcLine . "&src_page=" . urlencode(CUtil::addslashes($APPLICATION->GetCurPage())) . "&src_site=" . urlencode(CUtil::addslashes(SITE_ID)), "PARAMS" => array("min_width" => 450)));
         $arIcons[] = array('URL' => 'javascript:' . $url, 'TYPE' => 'components2_props', 'ICON' => "bx-context-toolbar-settings-icon", 'TITLE' => GetMessage("main_incl_file_comp_param"), 'DEFAULT' => true);
         $aMenuItem = array("TEXT" => $arComponentDescription["NAME"], "TITLE" => GetMessage("main_comp_button_menu_title") . ' ' . $this->componentName, "ICON" => "parameters-2", "ACTION" => $url);
         $APPLICATION->AddPanelButtonMenu("components", $aMenuItem);
     }
     if ($bComponentAccess) {
         $template = $this->component->GetTemplate();
         if (is_null($template)) {
             if ($this->component->InitComponentTemplate()) {
                 $template = $this->component->GetTemplate();
             }
         }
         if (!is_null($template)) {
             $urlCopy = '';
             if ($this->bSrcFound && $template->IsInTheme() == false) {
                 //copy template dialog
                 $urlCopy = "/bitrix/admin/template_copy.php?" . "lang=" . urlencode(CUtil::addslashes(LANGUAGE_ID)) . "&component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&component_template=" . urlencode(CUtil::addslashes($this->componentTemplate)) . "&template_id=" . urlencode(CUtil::addslashes(SITE_TEMPLATE_ID)) . "&template_site_template=" . urlencode(CUtil::addslashes($template->GetSiteTemplate())) . "&src_path=" . urlencode(CUtil::addslashes($this->sSrcFile)) . "&src_line=" . $this->iSrcLine . "&src_site=" . urlencode(CUtil::addslashes(SITE_ID)) . "&edit_file=" . urlencode($template->GetPageName()) . "&back_path=" . urlencode($_SERVER["REQUEST_URI"]);
                 $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => $urlCopy, "PARAMS" => array("min_width" => 450))), 'ICON' => "copy-2", 'TITLE' => GetMessage("main_comp_copy_templ"), 'IN_MENU' => true);
             }
             if ($USER->CanDoOperation('edit_php') && strlen($template->GetSiteTemplate()) > 0) {
                 //edit template copied to site template
                 $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/bitrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFile()) . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR', "min_width" => 700, "min_height" => 400))), 'ICON' => 'edit-2', 'TITLE' => GetMessage("main_comp_edit_templ"), 'IN_MENU' => true);
                 if (strlen($template->GetFolder()) > 0) {
                     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $template->GetFolder() . "/style.css")) {
                         //edit template CSS copied to site template
                         $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/bitrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFolder() . "/style.css") . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR', "min_width" => 700, "min_height" => 400))), 'ICON' => 'edit-css', 'TITLE' => GetMessage("main_comp_edit_css"), 'IN_MENU' => true);
                     }
                     $bWasSep = false;
                     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $template->GetFolder() . "/result_modifier.php")) {
                         $bWasSep = true;
                         $arIcons[] = array('SEPARATOR' => true);
                         $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/bitrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFolder() . "/result_modifier.php") . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR', "min_width" => 700, "min_height" => 400))), 'TITLE' => GetMessage("main_comp_edit_res_mod"), 'IN_MENU' => true);
                     }
                     if (file_exists($_SERVER["DOCUMENT_ROOT"] . $template->GetFolder() . "/component_epilog.php")) {
                         if (!$bWasSep) {
                             $arIcons[] = array('SEPARATOR' => true);
                         }
                         $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => "/bitrix/admin/public_file_edit_src.php?site=" . SITE_ID . "&" . 'path=' . urlencode($template->GetFolder() . "/component_epilog.php") . "&back_url=" . urlencode($_SERVER["REQUEST_URI"]) . "&lang=" . LANGUAGE_ID, 'PARAMS' => array('width' => 770, 'height' => 470, 'resize' => true, "dialog_type" => 'EDITOR', "min_width" => 700, "min_height" => 400))), 'TITLE' => GetMessage("main_comp_edit_epilog"), 'IN_MENU' => true);
                     }
                 }
             } elseif ($urlCopy != '') {
                 //copy template for future editing
                 $urlCopy .= '&system_template=Y';
                 $arIcons[] = array('URL' => 'javascript:' . $APPLICATION->GetPopupLink(array('URL' => $urlCopy, "PARAMS" => array("min_width" => 450))), 'ICON' => "edit-2", 'TITLE' => GetMessage("main_comp_edit_templ"), 'ALT' => GetMessage("main_comp_copy_title"), 'IN_MENU' => true);
             }
         }
     }
     $aAddIcons = array();
     $arPanelParams['COMPONENT'] = $this->componentName;
     if ($arComponentDescription && is_array($arComponentDescription)) {
         $arPanelParams['COMPONENT_DESCRIPTION'] = $arComponentDescription;
         //component bar tooltip
         $arPanelParams['TOOLTIP'] = array('TITLE' => $arComponentDescription["NAME"], 'TEXT' => '(' . GetMessage('main_incl_comp_component') . ' ' . $this->componentName . ')' . (isset($arComponentDescription["DESCRIPTION"]) && $arComponentDescription["DESCRIPTION"] != "" ? '<br />' . $arComponentDescription["DESCRIPTION"] : ''));
         //clear cache
         if (array_key_exists("CACHE_PATH", $arComponentDescription) && $USER->CanDoOperation('cache_control')) {
             if (strlen($arComponentDescription["CACHE_PATH"]) > 0) {
                 $arIcons[] = array("URL" => "javascript:jsComponentUtils.ClearCache('component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&site_id=" . SITE_ID . "&" . bitrix_sessid_get() . "');", "ICON" => "del-cache", "TITLE" => GetMessage("MAIN_BX_COMPONENT_CACHE_CLEAR"), 'IN_MENU' => true);
                 $APPLICATION->aCachedComponents[] = $this->componentName;
             }
         }
         //additional buttons from component description
         if (array_key_exists("AREA_BUTTONS", $arComponentDescription)) {
             $componentRelativePath = CComponentEngine::MakeComponentPath($this->componentName);
             $localPath = getLocalPath("components" . $componentRelativePath);
             foreach ($arComponentDescription["AREA_BUTTONS"] as $value) {
                 if (array_key_exists("SRC", $value)) {
                     $value["SRC"] = $localPath . $value["SRC"];
                 }
                 $aAddIcons[] = $value;
             }
         }
     }
     if (!empty($arIcons) && !empty($aAddIcons)) {
         $arIcons[] = array("SEPARATOR" => true);
     }
     $arIcons = array_merge($arIcons, $aAddIcons);
     $aAddIcons = $this->component->GetIncludeAreaIcons();
     if (!empty($arIcons) && !empty($aAddIcons)) {
         $arIcons[] = array("SEPARATOR" => true);
     }
     $arIcons = array_merge($arIcons, $aAddIcons);
     // enable/disable menu item
     if ($bComponentAccess && !$this->parentComponent && $this->bSrcFound) {
         if (!empty($arIcons)) {
             $arIcons[] = array("SEPARATOR" => true);
         }
         $arIcons[] = array("URL" => "javascript:jsComponentUtils.EnableComponent('component_name=" . urlencode(CUtil::addslashes($this->componentName)) . "&lang=" . urlencode(CUtil::addslashes(LANGUAGE_ID)) . "&src_path=" . urlencode(CUtil::addslashes($this->sSrcFile)) . "&src_line=" . $this->iSrcLine . "&src_site=" . urlencode(CUtil::addslashes(SITE_ID)) . '&active=' . ($this->bComponentEnabled ? 'N' : 'Y') . '&' . bitrix_sessid_get() . "');", "TITLE" => $this->bComponentEnabled ? GetMessage("main_comp_disable") : GetMessage("main_comp_enable"), "ALT" => $this->bComponentEnabled ? GetMessage("main_comp_disable_title") : GetMessage("main_comp_enable_title"), 'IN_MENU' => true);
     }
     if ($this->bSrcFound) {
         $arPanelParams['COMPONENT_ID'] = md5($arPanelParams['COMPONENT'] . '|' . $this->sSrcFile . ':' . $this->iSrcLine);
     }
     return array("icons" => $arIcons, "parameters" => $arPanelParams);
 }