public static function ProcessRequest() { if (isset($_REQUEST['component_params_manager'])) { $reqId = intVal($_REQUEST['component_params_manager']); $result = self::GetComponentProperties( $_REQUEST['component_name'], $_REQUEST['component_template'], $_REQUEST['site_template'], $_REQUEST['current_values'] ); $result['description'] = CComponentUtil::GetComponentDescr($_REQUEST['component_name']); ?> <script> window.__bxResult['<?php echo $reqId; ?> '] = <?php echo CUtil::PhpToJSObject($result); ?> ; </script> <? self::DisplayFileDialogsScripts(); } }
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"); if (count($arButtons[$mode]) > 0) { //Try to detect component via backtrace if (strlen($componentName) <= 0 && function_exists("debug_backtrace")) { $arTrace = debug_backtrace(); foreach ($arTrace as $arCallInfo) { if (array_key_exists("file", $arCallInfo)) { $file = strtolower(str_replace("\\", "/", $arCallInfo["file"])); if (preg_match("#.*/bitrix/components/(.+?)/(.+?)/#", $file, $match)) { $componentName = $match[1] . ":" . $match[2]; break; } } } } if (strlen($componentName)) { $arComponentDescription = CComponentUtil::GetComponentDescr($componentName); if (is_array($arComponentDescription) && 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) { $arSubButton['IMAGE'] = $arImages[$i]; if ($arSubButton["DEFAULT"]) { $arPanelButton["HREF"] = $arSubButton["ACTION"]; } $arPanelButton["MENU"][] = $arSubButton; } if (count($arButtons["submenu"]) > 0) { $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) { $arSubButton['IMAGE'] = $arImages[$i]; $arSubMenu["MENU"][] = $arSubButton; } $arPanelButton["MENU"][] = array("SEPARATOR" => "Y"); $arPanelButton["MENU"][] = $arSubMenu; } $APPLICATION->AddPanelButton($arPanelButton); } if (count($arButtons["intranet"]) > 0 && CModule::IncludeModule("intranet")) { /** @global CIntranetToolbar $INTRANET_TOOLBAR */ global $INTRANET_TOOLBAR; foreach ($arButtons["intranet"] as $arButton) { $INTRANET_TOOLBAR->AddButton($arButton); } } }
$arComponent = PHPParser::FindComponent($_GET["component_name"], $filesrc, $src_line); if ($arComponent === false) { $strWarning .= GetMessage("comp_prop_err_comp") . "<br>"; } else { $arValues = $arComponent["DATA"]["PARAMS"]; } } } if ($strWarning == "") { if ($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "refresh") { // parameters were changed by "ok" button // we need to refresh the component description with new values $arValues = array_merge($arValues, $_POST); } $curTemplate = isset($_POST["NEW_COMPONENT_TEMPLATE"]) ? $_POST["NEW_COMPONENT_TEMPLATE"] : $_GET["component_template"]; $arComponentDescription = CComponentUtil::GetComponentDescr($_GET["component_name"]); $arComponentParameters = CComponentUtil::GetComponentProps($_GET["component_name"], $arValues); $arTemplateParameters = CComponentUtil::GetTemplateProps($_GET["component_name"], $curTemplate, $_GET["template_id"], $arValues); if (isset($arComponentParameters["GROUPS"]) && is_array($arComponentParameters["GROUPS"])) { $arParameterGroups = $arParameterGroups + $arComponentParameters["GROUPS"]; } $arParameters = array(); if (isset($arComponentParameters["PARAMETERS"]) && is_array($arComponentParameters["PARAMETERS"])) { $arParameters = $arParameters + $arComponentParameters["PARAMETERS"]; } if (isset($arTemplateParameters) && is_array($arTemplateParameters)) { $arParameters = $arParameters + $arTemplateParameters; } $arComponentTemplates = CComponentUtil::GetTemplatesList($_GET["component_name"], $_GET["template_id"]); /* save parameters to file */ if ($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "save" && $arComponent !== false && $arComponentDescription !== false) {
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' => "/freetrix/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 = "/freetrix/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' => "/freetrix/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'))), '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' => "/freetrix/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'))), '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' => "/freetrix/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'))), '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' => "/freetrix/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'))), '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 . "&" . freetrix_sessid_get() . "');", "ICON" => "del-cache", "TITLE" => GetMessage("MAIN_FX_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') . '&' . freetrix_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); }
${"parser_" . LANGUAGE_ID} = new forumTextParser(LANGUAGE_ID); } $POST_MESSAGE = ${"parser_" . LANGUAGE_ID}->convert4mail(str_replace("#SERVER_NAME#", SITE_SERVER_NAME, $_REQUEST["POST_MESSAGE"])); $arFields = array("FROM_NAME" => $res["AUTHOR_NAME"], "FROM_USER_ID" => $USER->GetID(), "FROM_EMAIL" => $USER->GetEmail(), "TO_NAME" => $res["RECIPIENT_NAME"], "TO_USER_ID" => $res["RECIPIENT_ID"], "TO_EMAIL" => $res["RECIPIENT_EMAIL"], "SUBJECT" => $_REQUEST["POST_SUBJ"], "MESSAGE" => $POST_MESSAGE, "MESSAGE_DATE" => date("d.m.Y H:i:s"), "MESSAGE_LINK" => "http://" . SITE_SERVER_NAME . CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PM_READ"], array("FID" => "1", "MID" => $arParams["MID"])) . " \n"); $event->Send("NEW_FORUM_PRIVATE_MESSAGE", SITE_ID, $arFields, "N"); } } if ($arParams['AUTOSAVE']) { $arParams['AUTOSAVE']->Reset(); } // Clear cache. BXClearCache(true, "/bitrix/forum/user/" . $res["RECIPIENT_ID"] . "/"); $arComponentPath = array("bitrix:forum"); foreach ($arComponentPath as $path) { $componentRelativePath = CComponentEngine::MakeComponentPath($path); $arComponentDescription = CComponentUtil::GetComponentDescr($path); if (strLen($componentRelativePath) <= 0 || !is_array($arComponentDescription)) { continue; } elseif (!array_key_exists("CACHE_PATH", $arComponentDescription)) { continue; } $path = str_replace("//", "/", $componentRelativePath . "/user" . $res["RECIPIENT_ID"]); if ($arComponentDescription["CACHE_PATH"] == "Y") { $path = "/" . SITE_ID . $path; } if (!empty($path)) { BXClearCache(true, $path); } } } }
die(GetMessage("ACCESS_DENIED")); if($_GET["site_id"] == '') die("Empty site_id."); $sites = CSite::GetByID($_GET["site_id"]); if(!($site = $sites->Fetch())) die("Incorrect site_id."); $aComponents = explode(",", $_GET["component_name"]); foreach($aComponents as $component_name) { $componentRelativePath = CComponentEngine::MakeComponentPath($component_name); if (strlen($componentRelativePath) > 0) { $arComponentDescription = CComponentUtil::GetComponentDescr($component_name); if (isset($arComponentDescription) && is_array($arComponentDescription)) { if (array_key_exists("CACHE_PATH", $arComponentDescription)) { if($arComponentDescription["CACHE_PATH"] == "Y") $arComponentDescription["CACHE_PATH"] = "/".$site["ID"].$componentRelativePath; if(strlen($arComponentDescription["CACHE_PATH"]) > 0) { $obCache = new CPHPCache; $obCache->CleanDir($arComponentDescription["CACHE_PATH"], "cache"); BXClearCache(true, $arComponentDescription["CACHE_PATH"]); } } } if(defined("BX_COMP_MANAGED_CACHE"))
/** * Function clears entire component cache. * * <p>Note: parameters must exactly match to startResultCache call.</p> * @param string $componentName * @param string $siteId * @return void * */ public static final function clearComponentCache($componentName, $siteId = "") { /** @global CCacheManager $CACHE_MANAGER */ global $CACHE_MANAGER; $componentRelativePath = CComponentEngine::MakeComponentPath($componentName); if ($componentRelativePath != "") { $componentDescription = CComponentUtil::GetComponentDescr($componentName); if (isset($componentDescription) && is_array($componentDescription)) { if (isset($componentDescription["CACHE_PATH"]) && $componentDescription["CACHE_PATH"] == "Y") { if ($siteId == "") { $rsSite = CSite::GetList($by = "sort", $order = "asc"); while ($site = $rsSite->Fetch()) { $componentCachePath = "/" . $site["ID"] . $componentRelativePath; $obCache = new CPHPCache(); $obCache->CleanDir($componentCachePath, "cache"); BXClearCache(true, $componentCachePath); } } else { $componentCachePath = "/" . $siteId . $componentRelativePath; $obCache = new CPHPCache(); $obCache->CleanDir($componentCachePath, "cache"); BXClearCache(true, $componentCachePath); } } } if (defined("BX_COMP_MANAGED_CACHE")) { $CACHE_MANAGER->ClearByTag($componentName); } } }
function ForumClearComponentCache($components) { if (empty($components)) { return false; } $aComponents = is_array($components) ? $components : explode(",", $components); foreach ($aComponents as $component_name) { $componentRelativePath = CComponentEngine::MakeComponentPath($component_name); if (strlen($componentRelativePath) > 0) { $arComponentDescription = CComponentUtil::GetComponentDescr($component_name); if (is_array($arComponentDescription) && array_key_exists("CACHE_PATH", $arComponentDescription)) { if ($arComponentDescription["CACHE_PATH"] == "Y") { $arComponentDescription["CACHE_PATH"] = "/" . SITE_ID . $componentRelativePath; } if (strlen($arComponentDescription["CACHE_PATH"]) > 0) { BXClearCache(true, $arComponentDescription["CACHE_PATH"]); } } } } }
if ($arComponent === false) { $strWarning .= GetMessage("comp_prop_err_comp") . "<br>"; } else { $arValues = $arComponent["DATA"]["PARAMS"]; } } } if ($strWarning == "") { if ($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "refresh") { // parameters were changed by "ok" button // we need to refresh the component description with new values $arValues = array_merge($arValues, $_POST); } $curTemplate = isset($_POST["COMPONENT_TEMPLATE"]) ? $_POST["COMPONENT_TEMPLATE"] : $componentTemplate; $data = CComponentParamsManager::GetComponentProperties($componentName, $curTemplate, $templateId, $arValues); $data['description'] = CComponentUtil::GetComponentDescr($componentName); /* save parameters to file */ if ($_SERVER["REQUEST_METHOD"] == "POST" && $_GET["action"] == "save" && $arComponent !== false) { if (!check_bitrix_sessid()) { $strWarning .= GetMessage("comp_prop_err_save") . "<br>"; } else { $aPostValues = array_merge($arValues, $_POST); unset($aPostValues["sessid"]); unset($aPostValues["bxpiheight"]); unset($aPostValues["bxpiwidth"]); CComponentUtil::PrepareVariables($aPostValues); foreach ($aPostValues as $name => $value) { if (is_array($value) && count($value) == 1 && isset($value[0]) && $value[0] == "") { $aPostValues[$name] = array(); } elseif ($bLimitPhpAccess && substr($value, 0, 2) == '={' && substr($value, -1) == '}') { $aPostValues[$name] = $arValues[$name];