本文整理汇总了PHP中CBitrixComponent::GetTemplate方法的典型用法代码示例。如果您正苦于以下问题:PHP CBitrixComponent::GetTemplate方法的具体用法?PHP CBitrixComponent::GetTemplate怎么用?PHP CBitrixComponent::GetTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBitrixComponent
的用法示例。
在下文中一共展示了CBitrixComponent::GetTemplate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetIcons
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);
}
//.........这里部分代码省略.........
示例2: substr
}
if (CComponentUtil::CopyTemplate($arComponent["DATA"]["COMPONENT_NAME"], $arComponent["DATA"]["TEMPLATE_NAME"], strlen($templateSiteTemplate) > 0 ? $templateSiteTemplate : false, $_POST["SITE_TEMPLATE"], $sTemplateName, false)) {
if ($_POST["USE_TEMPLATE"] == "Y") {
$code = ($arComponent["DATA"]["VARIABLE"] ? $arComponent["DATA"]["VARIABLE"] . "=" : "") . "\$APPLICATION->IncludeComponent(\"" . $arComponent["DATA"]["COMPONENT_NAME"] . "\", " . "\"" . $sTemplateName . "\", " . "Array(\n\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["PARAMS"], $arParameters) . "\n\t)" . ",\n\t" . (strlen($arComponent["DATA"]["PARENT_COMP"]) > 0 ? $arComponent["DATA"]["PARENT_COMP"] : "false") . (!empty($arComponent["DATA"]["FUNCTION_PARAMS"]) ? ",\n\t" . "array(\n\t" . PHPParser::ReturnPHPStr2($arComponent["DATA"]["FUNCTION_PARAMS"]) . "\n\t)" : "") . "\n);";
$filesrc_for_save = substr($filesrc, 0, $arComponent["START"]) . $code . substr($filesrc, $arComponent["END"]);
if (!$APPLICATION->SaveFileContent($abs_path, $filesrc_for_save)) {
$strWarning .= GetMessage("comp_prop_err_save") . "<br>";
}
}
if ($strWarning == "") {
$strJSText = 'window.location = window.location.href;';
if ($_POST["EDIT_TEMPLATE"] == "Y") {
$component = new CBitrixComponent();
if ($component->InitComponent($arComponent["DATA"]["COMPONENT_NAME"], $_POST["TEMPLATE_NAME"])) {
if ($component->InitComponentTemplate($_REQUEST["edit_file"], $_POST["SITE_TEMPLATE"])) {
$template =& $component->GetTemplate();
if (!is_null($template)) {
$strJSText = $APPLICATION->GetPopupLink(array('URL' => '/bitrix/admin/public_file_edit_src.php?lang=' . LANGUAGE_ID . '&site=' . SITE_ID . '&back_url=' . urlencode($_REQUEST["back_path"]) . '&path=' . urlencode($template->GetFile()), "PARAMS" => array("width" => 770, "height" => 570, "resize" => true, "dialog_type" => 'EDITOR', "min_width" => 700, "min_height" => 400)));
}
}
}
}
?>
<script>
<?php
echo $obJSPopup->jsPopup;
?>
.Close();
//setTimeout(BX.showWait(), 30);
<?php