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; }
} $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>"; } else { $aPostValues = $_POST; unset($aPostValues["__closed_sections"]); 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) == '}') {
} } if (StrLen($arResult["FatalError"]) <= 0) { $arResult["Perms"] = __InTaskInitPerms($taskType, $ownerId); if (!$arResult["Perms"]["view"]) { $arResult["FatalError"] .= GetMessage("INTV_NO_SONET_PERMS") . "."; } } if (StrLen($arResult["FatalError"]) <= 0) { $arResult["TaskFields"] = __IntaskInitTaskFields($iblockId, $taskType, $ownerId, $arParams["TASKS_FIELDS_SHOW"]); if (!$arResult["TaskFields"] || !Is_Array($arResult["TaskFields"]) || Count($arResult["TaskFields"]) <= 0) { $arResult["FatalError"] = GetMessage("INTV_INTERNAL_ERROR") . "."; } } if (StrLen($arResult["FatalError"]) <= 0) { $arUserTemplatesList = CComponentUtil::GetTemplatesList("bitrix:intranet.tasks.view", SITE_TEMPLATE_ID); $userTemplateId = Trim($_REQUEST["user_template_id"]); $userSettingsId = $action == "edit" ? $viewId : IntVal($_REQUEST["user_settings_id"]); if (StrLen($userTemplateId) > 0) { $bCorrectTemplate = false; foreach ($arUserTemplatesList as $arUserTemplate) { if ($arUserTemplate["NAME"] == $userTemplateId) { $bCorrectTemplate = true; break; } } if (!$bCorrectTemplate) { $userTemplateId = ""; } } $arUserSettings = false;
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; }
public static function AddPagerSettings(&$arComponentParameters, $pager_title, $bDescNumbering=true, $bShowAllParam=false) { $arHiddenTemplates = array( 'js' => true ); if (!isset($arComponentParameters['GROUPS'])) $arComponentParameters['GROUPS'] = array(); $arComponentParameters["GROUPS"]["PAGER_SETTINGS"] = array( "NAME" => GetMessage("T_IBLOCK_DESC_PAGER_SETTINGS"), ); $arTemplateInfo = CComponentUtil::GetTemplatesList('freetrix:system.pagenavigation'); if (empty($arTemplateInfo)) { $arComponentParameters["PARAMETERS"]["PAGER_TEMPLATE"] = Array( "PARENT" => "PAGER_SETTINGS", "NAME" => GetMessage("T_IBLOCK_DESC_PAGER_TEMPLATE"), "TYPE" => "STRING", "DEFAULT" => "", ); } else { sortByColumn($arTemplateInfo, array('TEMPLATE' => SORT_ASC, 'NAME' => SORT_ASC)); $arTemplateList = array(); $arSiteTemplateList = array( '.default' => GetMessage('T_IBLOCK_DESC_PAGER_TEMPLATE_SITE_DEFAULT') ); $arTemplateID = array(); foreach ($arTemplateInfo as &$template) { if ('' != $template["TEMPLATE"] && '.default' != $template["TEMPLATE"]) $arTemplateID[] = $template["TEMPLATE"]; if (!isset($template['TITLE'])) $template['TITLE'] = $template['NAME']; } unset($template); if (!empty($arTemplateID)) { $rsSiteTemplates = CSiteTemplate::GetList( array(), array("ID"=>$arTemplateID), array() ); while ($arSitetemplate = $rsSiteTemplates->Fetch()) { $arSiteTemplateList[$arSitetemplate['ID']] = $arSitetemplate['NAME']; } } foreach ($arTemplateInfo as &$template) { if (isset($arHiddenTemplates[$template['NAME']])) continue; $strDescr = $template["TITLE"].' ('.('' != $template["TEMPLATE"] && '' != $arSiteTemplateList[$template["TEMPLATE"]] ? $arSiteTemplateList[$template["TEMPLATE"]] : GetMessage("T_IBLOCK_DESC_PAGER_TEMPLATE_SYSTEM")).')'; $arTemplateList[$template['NAME']] = $strDescr; } unset($template); $arComponentParameters["PARAMETERS"]["PAGER_TEMPLATE"] = array( "PARENT" => "PAGER_SETTINGS", "NAME" => GetMessage("T_IBLOCK_DESC_PAGER_TEMPLATE_EXT"), "TYPE" => "LIST", "VALUES" => $arTemplateList, "DEFAULT" => ".default", "ADDITIONAL_VALUES" => "Y" ); } $arComponentParameters["PARAMETERS"]["DISPLAY_TOP_PAGER"] = Array( "PARENT" => "PAGER_SETTINGS", "NAME" => GetMessage("T_IBLOCK_DESC_TOP_PAGER"), "TYPE" => "CHECKBOX", "DEFAULT" => "N", ); $arComponentParameters["PARAMETERS"]["DISPLAY_BOTTOM_PAGER"] = Array( "PARENT" => "PAGER_SETTINGS", "NAME" => GetMessage("T_IBLOCK_DESC_BOTTOM_PAGER"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y", ); $arComponentParameters["PARAMETERS"]["PAGER_TITLE"] = Array( "PARENT" => "PAGER_SETTINGS", "NAME" => GetMessage("T_IBLOCK_DESC_PAGER_TITLE"), "TYPE" => "STRING", "DEFAULT" => $pager_title, ); $arComponentParameters["PARAMETERS"]["PAGER_SHOW_ALWAYS"] = Array( "PARENT" => "PAGER_SETTINGS", "NAME" => GetMessage("T_IBLOCK_DESC_PAGER_SHOW_ALWAYS"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y", ); if($bDescNumbering) { $arComponentParameters["PARAMETERS"]["PAGER_DESC_NUMBERING"] = Array( "PARENT" => "PAGER_SETTINGS", "NAME" => GetMessage("T_IBLOCK_DESC_PAGER_DESC_NUMBERING"), "TYPE" => "CHECKBOX", "DEFAULT" => "N", ); $arComponentParameters["PARAMETERS"]["PAGER_DESC_NUMBERING_CACHE_TIME"] = Array( "PARENT" => "PAGER_SETTINGS", "NAME" => GetMessage("T_IBLOCK_DESC_PAGER_DESC_NUMBERING_CACHE_TIME"), "TYPE" => "STRING", "DEFAULT" => "36000", ); } if($bShowAllParam) { $arComponentParameters["PARAMETERS"]["PAGER_SHOW_ALL"] = Array( "PARENT" => "PAGER_SETTINGS", "NAME" => GetMessage("T_IBLOCK_DESC_SHOW_ALL"), "TYPE" => "CHECKBOX", "DEFAULT" => "Y" ); } }
} $arResult["AvailableTemplates"] = array(); if ($handle = @opendir($pathToTemplates)) { while (($file = readdir($handle)) !== false) { if ($file == "." || $file == ".." || !is_file($pathToTemplates . "/" . $file)) { continue; } $bpTemplateObject = null; include $pathToTemplates . "/" . $file; if ($bpTemplateObject && is_object($bpTemplateObject) && method_exists($bpTemplateObject, "GetName")) { $arResult["AvailableTemplates"][$file] = $bpTemplateObject->GetName(); } } @closedir($handle); } $arResult["ComponentTemplates"] = array("Start" => CComponentUtil::GetTemplatesList("bitrix:bizproc.wizards.start"), "List" => CComponentUtil::GetTemplatesList("bitrix:bizproc.wizards.list"), "View" => CComponentUtil::GetTemplatesList("bitrix:bizproc.wizards.view")); } elseif ($arResult["Step"] == 2) { $runtime = CBPRuntime::GetRuntime(); $runtime->StartRuntime(); $arResult["DocumentService"] = $runtime->GetService("DocumentService"); $arResult["TemplateParameters"] = $bpTemplateObject->GetVariables(); } } $this->IncludeComponentTemplate(); if (strlen($arResult["FatalErrorMessage"]) <= 0) { if ($arParams["SET_TITLE"] == "Y") { $APPLICATION->SetTitle(str_replace("#NAME#", $arResult["BlockType"]["NAME"], GetMessage("BPWC_WNC_PAGE_TITLE"))); } if ($arParams["SET_NAV_CHAIN"] == "Y") { $APPLICATION->AddChainItem($arResult["BlockType"]["NAME"], $arParams["PATH_TO_INDEX"]); $APPLICATION->AddChainItem(GetMessage("BPWC_WNC_PAGE_NAV_CHAIN"));
><?php echo GetMessage("ADV_BANNER_FLASH"); ?> </option> <option id="AD_TYPE_HTML" value="html"<?php if ($ID && $str_AD_TYPE == 'html' || isset($AD_TYPE) && $AD_TYPE == 'html') { ?> selected<?php } ?> ><?php echo GetMessage("ADV_BANNER_HTML"); ?> </option> <?php $arTemplates = CComponentUtil::GetTemplatesList('bitrix:advertising.banner.view'); ?> <?php foreach ($arTemplates as $k => $template) { ?> <option id="AD_TYPE_TEMPLATE[<?php echo $k; ?> ]" value="template" data-name="<?php echo $template['NAME']; ?> " <?php if (($ID && $str_AD_TYPE == 'template' || isset($AD_TYPE) && $AD_TYPE == 'template') && $template['NAME'] == $templateName) { ?> selected<?php }
<?php } ?> </script><?php //__GetTemplateProps($_GET['cname'], $_GET['tname'], $_GET['stid'],$arCurrentValues); } else { if (isset($_GET['stid']) && isset($_GET['mode']) && $_GET['mode'] == 'list') { ?> <script> window.arComp2TemplateLists = {}; <?php $arComponents = isset($_POST['complist']) ? CEditorUtils::UnJSEscapeArray($_POST['complist']) : array(); $len = count($arComponents); for ($i = 0; $i < $len; $i++) { $cName = $arComponents[$i]; $arTemplates = CComponentUtil::GetTemplatesList($cName, $siteTemplate); $tempLen = count($arTemplates); ?> window.arComp2TemplateLists['<?php echo CUtil::JSEscape($cName); ?> '] = {}; <?php for ($j = 0; $j < $tempLen; $j++) { ?> window.arComp2TemplateLists['<?php echo CUtil::JSEscape($cName); ?> ']['<?php echo CUtil::JSEscape($arTemplates[$j]["NAME"]);
} 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]; } } //check template name $sTemplateName = ""; $arComponentTemplates = CComponentUtil::GetTemplatesList($componentName, $templateId); foreach ($arComponentTemplates as $templ) { if ($templ["NAME"] == $_POST["COMPONENT_TEMPLATE"]) { $sTemplateName = $templ["NAME"]; break; } } $functionParams = ""; if (!empty($arComponent["DATA"]["FUNCTION_PARAMS"])) { $functionParams = ",\n" . "\tarray(\n" . "\t\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"]) . "\n" . "\t)"; } $code = ($arComponent["DATA"]["VARIABLE"] ? $arComponent["DATA"]["VARIABLE"] . " = " : "") . "\$APPLICATION->IncludeComponent(\n" . "\t\"" . $arComponent["DATA"]["COMPONENT_NAME"] . "\", \n" . "\t\"" . $sTemplateName . "\", \n" . "\tarray(\n" . "\t\t" . PHPParser::ReturnPHPStr2($aPostValues) . "\n" . "\t),\n" . "\t" . ($arComponent["DATA"]["PARENT_COMP"] != '' ? $arComponent["DATA"]["PARENT_COMP"] : "false") . $functionParams . "\n);"; $filesrc_for_save = substr($filesrc, 0, $arComponent["START"]) . $code . substr($filesrc, $arComponent["END"]); $f = $io->GetFile($abs_path); $arUndoParams = array('module' => 'fileman', 'undoType' => 'edit_component_props', 'undoHandler' => 'CFileman::UndoEditFile', 'arContent' => array('absPath' => $abs_path, 'content' => $f->GetContents())); if ($APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) {