public static function GetComponentProperties($name = '', $template = '', $siteTemplate = '', $currentValues = array()) { $template = !$template || $template == '.default' ? '' : $template; $arTemplates = CComponentUtil::GetTemplatesList($name, $siteTemplate); $result = array('templates' => array()); $arSiteTemplates = array(".default" => GetMessage("PAR_MAN_DEFAULT")); if (!empty($siteTemplate)) { $dbst = CSiteTemplate::GetList(array(), array("ID" => $siteTemplate), array()); while ($siteTempl = $dbst->Fetch()) { $arSiteTemplates[$siteTempl['ID']] = $siteTempl['NAME']; } } foreach ($arTemplates as $k => $templ) { $showTemplateName = $templ["TEMPLATE"] !== '' && $arSiteTemplates[$templ["TEMPLATE"]] != '' ? $arSiteTemplates[$templ["TEMPLATE"]] : GetMessage("PAR_MAN_DEF_TEMPLATE"); $arTemplates[$k]['DISPLAY_NAME'] = $templ['NAME'] . ' (' . $showTemplateName . ')'; } $arTemplateProps = array(); if (is_array($arTemplates)) { foreach ($arTemplates as $arTemplate) { $result['templates'][] = $arTemplate; $tName = !$arTemplate['NAME'] || $arTemplate['NAME'] == '.default' ? '' : $arTemplate['NAME']; if ($tName == $template) { $arTemplateProps = CComponentUtil::GetTemplateProps($name, $arTemplate['NAME'], $siteTemplate, $currentValues); } } } $result['parameters'] = array(); $arProps = CComponentUtil::GetComponentProps($name, $currentValues, $arTemplateProps); $result['tooltips'] = self::FetchHelp($name); if (!isset($arProps['GROUPS']) || !is_array($arProps['GROUPS'])) { $arProps['GROUPS'] = array(); } if (!isset($arProps['PARAMETERS']) || !is_array($arProps['PARAMETERS'])) { $arProps['PARAMETERS'] = array(); } $result['groups'] = array(); foreach ($arProps['GROUPS'] as $k => $arGroup) { $arGroup['ID'] = $k; $result['groups'][] = $arGroup; } foreach ($arProps['PARAMETERS'] as $k => $arParam) { $arParam['ID'] = preg_replace("/[^a-zA-Z0-9_-]/is", "_", $k); if (!isset($arParam['PARENT'])) { $arParam['PARENT'] = 'ADDITIONAL_SETTINGS'; } $result['parameters'][] = $arParam; if ($arParam['TYPE'] == 'FILE') { self::$fileDialogs[] = array('NAME' => $arParam['ID'], 'TARGET' => isset($arParam['FD_TARGET']) ? $arParam['FD_TARGET'] : 'F', 'EXT' => isset($arParam['FD_EXT']) ? $arParam['FD_EXT'] : '', 'UPLOAD' => isset($arParam['FD_UPLOAD']) && $arParam['FD_UPLOAD'] && $arParam['FD_TARGET'] == 'F', 'USE_ML' => isset($arParam['FD_USE_MEDIALIB']) && $arParam['FD_USE_MEDIALIB'], 'ONLY_ML' => isset($arParam['FD_USE_ONLY_MEDIALIB']) && $arParam['FD_USE_ONLY_MEDIALIB'], 'ML_TYPES' => isset($arParam['FD_MEDIALIB_TYPES']) ? $arParam['FD_MEDIALIB_TYPES'] : false); } // TOOLTIPS FROM .parameters langs if (!isset($result['tooltips'][$arParam['ID'] . '_TIP'])) { $tip = GetMessage($arParam['ID'] . '_TIP'); if ($tip) { $result['tooltips'][$arParam['ID'] . '_TIP'] = $tip; } } } return $result; }
function GetProperties($componentName, $curTemplate = '') { $stid = (isset($_GET['stid'])) ? $_GET['stid'] : ''; $curTemplate = (!$curTemplate || $curTemplate == '.default') ? '' : CUtil::JSEscape($curTemplate); $arTemplates = CComponentUtil::GetTemplatesList($componentName, $stid); $arCurVals = isset($_POST['curval']) ? CEditorUtils::UnJSEscapeArray($_POST['curval']) : Array(); $loadHelp = (isset($_GET['loadhelp']) && $_GET['loadhelp']=="Y") ? true : false; if (is_array($arTemplates)) { foreach ($arTemplates as $k => $arTemplate) { push2arComp2Templates($arTemplate['NAME'], $arTemplate['TEMPLATE'], $arTemplate['TITLE'], $arTemplate['DESCRIPTION']); $tName = (!$arTemplate['NAME'] || $arTemplate['NAME'] == '.default') ? '' : $arTemplate['NAME']; if ($tName == $curTemplate) { $arTemplateProps = CComponentUtil::GetTemplateProps($componentName, $arTemplate['NAME'], $stid, $arCurVals); if (is_array($arTemplateProps)) foreach ($arTemplateProps as $k => $arTemplateProp) push2arComp2TemplateProps($componentName,$k,$arTemplateProp); } } } $arProps = CComponentUtil::GetComponentProps($componentName, $arCurVals); if ($loadHelp && is_array($arProps['PARAMETERS'])) fetchPropsHelp($componentName); $bGroup = (isset($arProps['GROUPS']) && count($arProps['GROUPS']) > 0); if (is_array($arProps['GROUPS'])) { foreach ($arProps['GROUPS'] as $k => $arGroup) { ?>window.arComp2Groups.push({name: '<?php echo CUtil::JSEscape($k); ?> ', title: '<?php echo CUtil::JSEscape($arGroup['NAME']); ?> '});<? } } if (is_array($arProps['PARAMETERS'])) foreach ($arProps['PARAMETERS'] as $k => $arParam) push2arComp2Props($k, $arParam, (($bGroup) ? $arProps['GROUPS'] : false)); }
public static function GetComponentProperties($name = '', $template = '', $siteTemplate = '', $currentValues = array()) { $template = !$template || $template == '.default' ? '' : $template; $arTemplates = CComponentUtil::GetTemplatesList($name, $siteTemplate); $result = array('templates' => array()); $arTemplateProps = array(); if (is_array($arTemplates)) { foreach ($arTemplates as $arTemplate) { $result['templates'][] = $arTemplate; $tName = !$arTemplate['NAME'] || $arTemplate['NAME'] == '.default' ? '' : $arTemplate['NAME']; if ($tName == $template) { $arTemplateProps = CComponentUtil::GetTemplateProps($name, $arTemplate['NAME'], $siteTemplate, $currentValues); } } } $result['parameters'] = array(); $arProps = CComponentUtil::GetComponentProps($name, $currentValues, $arTemplateProps); $result['tooltips'] = self::FetchHelp($name); if (!isset($arProps['GROUPS']) || !is_array($arProps['GROUPS'])) { $arProps['GROUPS'] = array(); } if (!isset($arProps['PARAMETERS']) || !is_array($arProps['PARAMETERS'])) { $arProps['PARAMETERS'] = array(); } $result['groups'] = array(); foreach ($arProps['GROUPS'] as $k => $arGroup) { $arGroup['ID'] = $k; $result['groups'][] = $arGroup; } foreach ($arProps['PARAMETERS'] as $k => $arParam) { $arParam['ID'] = preg_replace("/[^a-zA-Z0-9_-]/is", "_", $k); if (!isset($arParam['PARENT'])) { $arParam['PARENT'] = 'ADDITIONAL_SETTINGS'; } $result['parameters'][] = $arParam; if ($arParam['TYPE'] == 'FILE') { self::$fileDialogs[] = array('NAME' => $arParam['ID'], 'TARGET' => isset($arParam['FD_TARGET']) ? $arParam['FD_TARGET'] : 'F', 'EXT' => isset($arParam['FD_EXT']) ? $arParam['FD_EXT'] : '', 'UPLOAD' => isset($arParam['FD_UPLOAD']) && $arParam['FD_UPLOAD'] && $arParam['FD_TARGET'] == 'F', 'USE_ML' => isset($arParam['FD_USE_MEDIALIB']) && $arParam['FD_USE_MEDIALIB'], 'ONLY_ML' => isset($arParam['FD_USE_ONLY_MEDIALIB']) && $arParam['FD_USE_ONLY_MEDIALIB'], 'ML_TYPES' => isset($arParam['FD_MEDIALIB_TYPES']) ? $arParam['FD_MEDIALIB_TYPES'] : false); } } return $result; }
$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) { if (!check_bitrix_sessid()) { $strWarning .= GetMessage("comp_prop_err_save") . "<br>";
function GetCompProperties($name, $template = '', $siteTemplateId = '', $arCurVals = array()) { $stid = $siteTemplateId; $arProps = CComponentUtil::GetComponentProps($name, $arCurVals); $arTemplateProps = CComponentUtil::GetTemplateProps($name, $template, $stid, $arCurVals); return $arProps['PARAMETERS'] + $arTemplateProps; }
public static function GetComponentParams($name, $siteTemplate = '', $template = '', $curValues = array(), $loadHelp = true) { $template = (!$template || $template == '.default') ? '' : CUtil::JSEscape($template); $arTemplates = CComponentUtil::GetTemplatesList($name, $siteTemplate); $result = array( 'groups' => array(), 'templates' => array(), 'props' => array(), 'template_props' => array() ); $arProps = CComponentUtil::GetComponentProps($name, $curValues); if (is_array($arTemplates)) { foreach ($arTemplates as $k => $arTemplate) { $result['templates'][] = array( 'name' => $arTemplate['NAME'], 'template' => $arTemplate['TEMPLATE'], 'title' => $arTemplate['TITLE'], 'description' => $arTemplate['DESCRIPTION'], ); $tName = (!$arTemplate['NAME'] || $arTemplate['NAME'] == '.default') ? '' : $arTemplate['NAME']; if ($tName == $template) { $arTemplateProps = CComponentUtil::GetTemplateProps($name, $arTemplate['NAME'], $siteTemplate, $curValues); if (is_array($arTemplateProps)) { foreach ($arTemplateProps as $k => $arTemplateProp) { $result['templ_props'][] = self::_HandleComponentParam($k, $arTemplateProp, $arProps['GROUPS']); } } } } } //if ($loadHelp && is_array($arProps['PARAMETERS'])) // fetchPropsHelp($name); if (is_array($arProps['GROUPS'])) { foreach ($arProps['GROUPS'] as $k => $arGroup) { $result['templ_props'][] = array( 'name' => $k, 'title' => $arGroup['NAME'] ); } } if (is_array($arProps['PARAMETERS'])) { foreach ($arProps['PARAMETERS'] as $k => $arParam) { $result['properties'][] = self::_HandleComponentParam($k, $arParam, $arProps['GROUPS']); } } return $result; }
$arParams = $arRes['PARAMS']; $arPHPparams = array(); //all php fragments wraped by ={} foreach ($arParams as $param_name => $paramval) { if (substr($paramval, 0, 2) == '={' && substr($paramval, -1) == '}') { $arPHPparams[] = $param_name; } } $len = count($arPHPparams); $br = "\r\n"; $code = '$APPLICATION->IncludeComponent(' . $br . "\t" . '"' . $comp_name . '",' . $br . "\t" . '"' . $template_name . '",' . $br; // If exist at least one parameter with php code inside if (count($arParams) > 0) { // Get array with description of component params $arCompParams = CComponentUtil::GetComponentProps($comp_name); $arTemplParams = CComponentUtil::GetTemplateProps($comp_name, $template_name, $template); $arParameters = array(); if (isset($arCompParams["PARAMETERS"]) && is_array($arCompParams["PARAMETERS"])) { $arParameters = $arParameters + $arCompParams["PARAMETERS"]; } if (is_array($arTemplParams)) { $arParameters = $arParameters + $arTemplParams; } // Replace values from 'DEFAULT' for ($e = 0; $e < $len; $e++) { $par_name = $arPHPparams[$e]; $arParams[$par_name] = isset($arParameters[$par_name]['DEFAULT']) ? $arParameters[$par_name]['DEFAULT'] : ''; } CComponentUtil::PrepareVariables($arParams); //ReturnPHPStr $params = PHPParser::ReturnPHPStr2($arParams, $arParameters);
function ProcessLPA($filesrc = false, $old_filesrc = false) { if ($filesrc === false) { return ''; } // Find all php fragments in $filesrc and: // 1. Kill all non-component 2.0 fragments // 2. Get and check params of components $arPHP = PHPParser::ParseFile($filesrc); $l = count($arPHP); if ($l > 0) { $new_filesrc = ''; $end = 0; for ($n = 0; $n < $l; $n++) { $start = $arPHP[$n][0]; $new_filesrc .= CMain::EncodePHPTags(substr($filesrc, $end, $start - $end)); $end = $arPHP[$n][1]; //Trim php tags $src = $arPHP[$n][2]; if (substr($src, 0, 5) == "<?php") { $src = '<?' . substr($src, 5); } //If it's Component 2 - we handle it's params, non components2 will be erased $comp2_begin = '<?$APPLICATION->INCLUDECOMPONENT('; if (strtoupper(substr($src, 0, strlen($comp2_begin))) == $comp2_begin) { $arRes = PHPParser::CheckForComponent2($src); if ($arRes) { $comp_name = CMain::_ReplaceNonLatin($arRes['COMPONENT_NAME']); $template_name = CMain::_ReplaceNonLatin($arRes['TEMPLATE_NAME']); $arParams = $arRes['PARAMS']; $arPHPparams = array(); CMain::LPAComponentChecker($arParams, $arPHPparams); $len = count($arPHPparams); $br = "\r\n"; $code = '$APPLICATION->IncludeComponent(' . $br . "\t" . '"' . $comp_name . '",' . $br . "\t" . '"' . $template_name . '",' . $br; // If exist at least one parameter with php code inside if (count($arParams) > 0) { // Get array with description of component params $arCompParams = CComponentUtil::GetComponentProps($comp_name); $arTemplParams = CComponentUtil::GetTemplateProps($comp_name, $template_name); $arParameters = array(); if (isset($arCompParams["PARAMETERS"]) && is_array($arCompParams["PARAMETERS"])) { $arParameters = $arParameters + $arCompParams["PARAMETERS"]; } if (is_array($arTemplParams)) { $arParameters = $arParameters + $arTemplParams; } // Replace values from 'DEFAULT' for ($e = 0; $e < $len; $e++) { $par_name = $arPHPparams[$e]; $arParams[$par_name] = isset($arParameters[$par_name]['DEFAULT']) ? $arParameters[$par_name]['DEFAULT'] : ''; } //ReturnPHPStr $params = PHPParser::ReturnPHPStr2($arParams, $arParameters); $code .= "\t" . 'array(' . $br . "\t" . $params . $br . "\t" . ')'; } else { $code .= "\t" . 'array()'; } $parent_comp = CMain::_ReplaceNonLatin($arRes['PARENT_COMP']); $arExParams_ = $arRes['FUNCTION_PARAMS']; $bEx = isset($arExParams_) && is_array($arExParams_) && count($arExParams_) > 0; if (!$parent_comp || strtolower($parent_comp) == 'false') { $parent_comp = false; } if ($parent_comp) { if ($parent_comp == 'true' || intVal($parent_comp) == $parent_comp) { $code .= ',' . $br . "\t" . $parent_comp; } else { $code .= ',' . $br . "\t\"" . $parent_comp . '"'; } } if ($bEx) { if (!$parent_comp) { $code .= ',' . $br . "\tfalse"; } $arExParams = array(); foreach ($arExParams_ as $k => $v) { $k = CMain::_ReplaceNonLatin($k); $v = CMain::_ReplaceNonLatin($v); if (strlen($k) > 0 && strlen($v) > 0) { $arExParams[$k] = $v; } } //CComponentUtil::PrepareVariables($arExParams); $exParams = PHPParser::ReturnPHPStr2($arExParams); $code .= ',' . $br . "\tarray(" . $exParams . ')'; } $code .= $br . ');'; $code = '<?' . $code . '?>'; $new_filesrc .= $code; } } } $new_filesrc .= CMain::EncodePHPTags(substr($filesrc, $end)); $filesrc = $new_filesrc; } else { $filesrc = CMain::EncodePHPTags($filesrc); } if (strpos($filesrc, '#PHP') !== false && $old_filesrc !== false) { // Get array of PHP scripts from old saved file $arPHP = PHPParser::ParseFile($old_filesrc); $arPHPscripts = array(); $l = count($arPHP); if ($l > 0) { $new_filesrc = ''; $end = 0; for ($n = 0; $n < $l; $n++) { $start = $arPHP[$n][0]; $new_filesrc .= substr($old_filesrc, $end, $start - $end); $end = $arPHP[$n][1]; $src = $arPHP[$n][2]; $src = SubStr($src, SubStr($src, 0, 5) == "<?" . "php" ? 5 : 2, -2); // Trim php tags $comp2_begin = '$APPLICATION->INCLUDECOMPONENT('; if (strtoupper(substr($src, 0, strlen($comp2_begin))) != $comp2_begin) { $arPHPscripts[] = $src; } } } // Ok, so we already have array of php scripts lets check our new content // LPA-users CAN delete PHP fragments and swap them but CAN'T add new or modify existent: while (preg_match('/#PHP\\d{4}#/i' . BX_UTF_PCRE_MODIFIER, $filesrc, $res)) { $php_begin = strpos($filesrc, $res[0]); $php_fr_num = intval(substr($filesrc, $php_begin + 4, 4)) - 1; // Number of PHP fragment from #PHPXXXX# conctruction if (isset($arPHPscripts[$php_fr_num])) { $filesrc = substr($filesrc, 0, $php_begin) . '<?' . $arPHPscripts[$php_fr_num] . '?>' . substr($filesrc, $php_begin + 9); } else { $filesrc = substr($filesrc, 0, $php_begin) . substr($filesrc, $php_begin + 9); } } } return $filesrc; }
} if ($str_AD_TYPE == 'template') { $arCurVal = isset($str_TEMPLATE['PROPS']) ? $str_TEMPLATE['PROPS'] : $_POST['TEMPLATE_PROP']; $templateName = $str_TEMPLATE["NAME"] ? $str_TEMPLATE["NAME"] : $_POST['TEMPLATE_NAME']; $templateMode = $str_TEMPLATE['MODE'] ? $str_TEMPLATE['MODE'] : $_POST['EXTENDED_MODE']; if (count($arCurVal) > 0) { foreach ($arCurVal as $id => $prop) { $arCurVal[$id]['EXTENDED_MODE'] = $templateMode; $arPropsTemplate[$id] = CComponentUtil::GetTemplateProps('bitrix:advertising.banner.view', $templateName, '', $arCurVal[$id]); uasort($arPropsTemplate[$id]["PARAMETERS"], 'pr_comp'); } } else { if (empty($arCurVal)) { $arCurVal = array('EXTENDED_MODE' => $templateMode); } $arPropsTemplate[0] = CComponentUtil::GetTemplateProps('bitrix:advertising.banner.view', $templateName, '', $arCurVal); uasort($arPropsTemplate[0]["PARAMETERS"], 'pr_comp'); } $defaultProps = array(); foreach ($arPropsTemplate as $i => $k) { foreach ($k['PARAMETERS'] as $name => $prop) { $html = ''; $defaultProps[$name] = $prop['DEFAULT']; if ($prop['TYPE'] == 'IMAGE') { $file_ID = is_array($str_TEMPLATE_FILES) && isset($str_TEMPLATE_FILES[$i][$name]) && $str_TEMPLATE_FILES[$i][$name] !== 'null' ? intVal($str_TEMPLATE_FILES[$i][$name]) : 0; if ($bCopy) { $html .= '<input type=\'hidden\' name=\'TEMPLATE_FILES_copy[' . $i . '_' . $name . ']\' value=\'' . $file_ID . '\'>'; } ob_start(); if (class_exists('\\Bitrix\\Main\\UI\\FileInput', true)) { echo \Bitrix\Main\UI\FileInput::createInstance(array("name" => "TEMPLATE_FILES[" . $i . '_' . $name . "]", "description" => true, "allowUpload" => "I", "maxCount" => 1) + ($isEditMode ? array("medialib" => true, "fileDialog" => true, "cloud" => true, "upload" => true) : array("delete" => false, "edit" => false)))->show($file_ID);
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php"; require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/fileman/prolog.php"; if (!$USER->CanDoOperation('fileman_view_file_structure') && !$USER->CanDoOperation('edit_other_settings')) { $APPLICATION->AuthForm(GetMessage("ACCESS_DENIED")); } require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/fileman/include.php"; if (CModule::IncludeModule("compression")) { CCompress::Disable2048Spaces(); } if (isset($_GET['cname']) && isset($_GET['stid']) && isset($_GET['tname']) && isset($_GET['mode']) && $_GET['mode'] == 'params') { ?> <script> window.arComp2TemplateProps = []; <?php $arCurrentValues = isset($_POST['curval']) ? $_POST['curval'] : array(); $arTemplateProps = CComponentUtil::GetTemplateProps($_GET['cname'], $_GET['tname'], $_GET['stid'], $arCurrentValues); foreach ($arTemplateProps as $paramName => $arTemplateProp) { ?> var tempAr2 = {}; tempAr2.param_name = '<?php echo CUtil::JSEscape($paramName); ?> '; <?php foreach ($arTemplateProp as $k => $prop) { if (is_array($prop)) { ?> tempAr2.<?php echo $k; ?> = {<?php
} if ($nLineTo > $src_line) { break; } } } if ($arComponent === false) { $strWarning .= GetMessage("comp_prop_err_comp") . "<br>"; } $arComponentDescription = array(); $arTemplatesList = array(); $templateSiteTemplate = ""; if ($strWarning == "") { $arComponentDescription = CComponentUtil::GetComponentDescr($_GET["component_name"]); $arComponentParameters = CComponentUtil::GetComponentProps($_GET["component_name"], $arComponent["DATA"]["PARAMS"]); $arTemplateParameters = CComponentUtil::GetTemplateProps($_GET["component_name"], $_GET["component_template"], $_GET["template_id"], $arComponent["DATA"]["PARAMS"]); $arParameterGroups = array(); if (isset($arComponentParameters["GROUPS"]) && is_array($arComponentParameters["GROUPS"])) { $arParameterGroups = $arParameterGroups + $arComponentParameters["GROUPS"]; } if (isset($arTemplateParameters) && is_array($arTemplateParameters)) { $arParameterGroups = $arParameterGroups + array("TEMPLATE" => array("NAME" => GetMessage("comp_templ_template"))); } $arParameters = array(); if (isset($arComponentParameters["PARAMETERS"]) && is_array($arComponentParameters["PARAMETERS"])) { $arParameters = $arParameters + $arComponentParameters["PARAMETERS"]; } if (isset($arTemplateParameters) && is_array($arTemplateParameters)) { $arParameters = $arParameters + $arTemplateParameters; } $arTemplatesList = CComponentUtil::GetTemplatesList($_GET["component_name"], $_GET["template_id"]);