本文整理汇总了PHP中CBitrixComponent::InitComponent方法的典型用法代码示例。如果您正苦于以下问题:PHP CBitrixComponent::InitComponent方法的具体用法?PHP CBitrixComponent::InitComponent怎么用?PHP CBitrixComponent::InitComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CBitrixComponent
的用法示例。
在下文中一共展示了CBitrixComponent::InitComponent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getComponentTemplatePath
/**
* По Битрикс-имени шаблона возвращает путь к его файлу
*
* @param string $name
* @return string
* @throws \Twig_Error_Loader
*/
private function getComponentTemplatePath($name)
{
$name = $this->normalizeName($name);
list($namespace, $component, $template, $file) = explode(':', $name);
$componentName = "{$namespace}:{$component}";
$component = new \CBitrixComponent();
$component->InitComponent($componentName, $template);
$component->__templatePage = $file;
$obTemplate = new \CBitrixComponentTemplate();
$obTemplate->Init($component);
$templatePath = $_SERVER['DOCUMENT_ROOT'] . $obTemplate->GetFile();
if (!file_exists($templatePath)) {
throw new \Twig_Error_Loader("Не удалось найти шаблон '{$name}'");
}
return $templatePath;
}
示例2: array
function __bx_share_get_handlers($template = false)
{
if (trim($template) == ".default") {
$template = "";
}
$arBookmarkHandlerDropdown = array();
$arBookmarkHandlerDropdownDefault = array();
$shareComponent = new CBitrixComponent();
$shareComponent->InitComponent("bitrix:main.share", $template);
$shareComponent->InitComponentTemplate($template);
if (strlen($shareComponent->__template->__folder) > 0) {
$path2Handlers = $_SERVER["DOCUMENT_ROOT"] . "/" . $shareComponent->__template->__folder . "/handlers/";
CheckDirPath($path2Handlers);
$arHandlers = array();
if ($handle = opendir($path2Handlers)) {
while (($file = readdir($handle)) !== false) {
if ($file == "." || $file == "..") {
continue;
}
if (is_file($path2Handlers . $file) && strtoupper(substr($file, strlen($file) - 4)) == ".PHP") {
$name = $title = $icon_url_template = "";
$sort = 0;
include $path2Handlers . $file;
if (strlen($name) > 0) {
$arHandlers[$name] = array("TITLE" => $title, "ICON" => $icon_url_template, "SORT" => intval($sort));
}
}
}
}
foreach ($arHandlers as $name => $arSystem) {
if (strlen($arSystem["TITLE"]) > 0) {
$arBookmarkHandlerDropdown[$name] = $arSystem["TITLE"];
}
}
$arBookmarkHandlerDropdownTmp = $arBookmarkHandlerDropdown;
if (LANGUAGE != 'ru') {
if (array_key_exists("vk", $arBookmarkHandlerDropdownTmp)) {
unset($arBookmarkHandlerDropdownTmp["vk"]);
}
if (array_key_exists("mailru", $arBookmarkHandlerDropdownTmp)) {
unset($arBookmarkHandlerDropdownTmp["mailru"]);
}
}
$arBookmarkHandlerDropdownDefault = array_keys($arBookmarkHandlerDropdownTmp);
}
return array("HANDLERS" => $arBookmarkHandlerDropdown, "HANDLERS_DEFAULT" => $arBookmarkHandlerDropdownDefault);
}
示例3: IncludeComponent
function IncludeComponent($componentName, $componentTemplate, $arParams = array(), $parentComponent = null, $arFunctionParams = array())
{
/** @global CMain $APPLICATION */
global $APPLICATION, $USER;
if (is_array($this->arComponentMatch)) {
$skipComponent = true;
foreach ($this->arComponentMatch as $cValue) {
if (strpos($componentName, $cValue) !== false) {
$skipComponent = false;
break;
}
}
if ($skipComponent) {
return false;
}
}
$componentRelativePath = CComponentEngine::MakeComponentPath($componentName);
if (StrLen($componentRelativePath) <= 0) {
return False;
}
if ($_SESSION["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y" && ($USER->CanDoOperation('edit_php') || $_SESSION["SHOW_SQL_STAT"] == "Y")) {
$debug = new CDebugInfo();
$debug->Start();
} elseif ($APPLICATION->ShowIncludeStat) {
$debug = new CDebugInfo();
$debug->Start();
} else {
$debug = null;
}
if (is_object($parentComponent)) {
if (!$parentComponent instanceof cbitrixcomponent) {
$parentComponent = null;
}
}
$bDrawIcons = (!isset($arFunctionParams["HIDE_ICONS"]) || $arFunctionParams["HIDE_ICONS"] != "Y") && $APPLICATION->GetShowIncludeAreas();
if ($bDrawIcons) {
echo $this->IncludeStringBefore();
}
$result = null;
$bComponentEnabled = !isset($arFunctionParams["ACTIVE_COMPONENT"]) || $arFunctionParams["ACTIVE_COMPONENT"] != "N";
$component = new CBitrixComponent();
if ($component->InitComponent($componentName)) {
$obAjax = null;
if ($bComponentEnabled) {
if ($arParams['AJAX_MODE'] == 'Y') {
$obAjax = new CComponentAjax($componentName, $componentTemplate, $arParams, $parentComponent);
}
$result = $component->IncludeComponent($componentTemplate, $arParams, $parentComponent);
}
if ($bDrawIcons) {
$panel = new CComponentPanel($component, $componentName, $componentTemplate, $parentComponent, $bComponentEnabled);
$arIcons = $panel->GetIcons();
echo $s = $this->IncludeStringAfter($arIcons["icons"], $arIcons["parameters"]);
}
if ($bComponentEnabled && $obAjax) {
$obAjax->Process();
}
}
if ($_SESSION["SESS_SHOW_INCLUDE_TIME_EXEC"] == "Y" && ($USER->CanDoOperation('edit_php') || $_SESSION["SHOW_SQL_STAT"] == "Y")) {
echo $debug->Output($componentName, "/bitrix/components" . $componentRelativePath . "/component.php", $arParams["CACHE_TYPE"] . $arParams["MENU_CACHE_TYPE"]);
} elseif (is_object($debug)) {
$debug->Stop($componentName, "/bitrix/components" . $componentRelativePath . "/component.php", $arParams["CACHE_TYPE"] . $arParams["MENU_CACHE_TYPE"]);
}
return $result;
}
示例4: unserialize
//Да!
//Забираем параметры "подключения"
$arParams = unserialize($arCache["CACHE"]);
//18*
//Добиваем теми, которые доступны "снаружи"
foreach ($arParams["PAGE_PARAMS"] as $param_name) {
if (!array_key_exists($param_name, $arParams)) {
$arParams[$param_name] = $_REQUEST["PAGE_PARAMS"][$param_name];
}
}
//24*
//Эта магия позволяет нам правильно определить
//текущий шаблон компонента (с учетом темы)
if (array_key_exists("PARENT_NAME", $arParams)) {
$component = new CBitrixComponent();
$component->InitComponent($arParams["PARENT_NAME"], $arParams["PARENT_TEMPLATE_NAME"]);
$component->InitComponentTemplate($arParams["PARENT_TEMPLATE_PAGE"]);
} else {
$component = null;
}
//25*
//Подключаем компонент
//Результат его работы (div) заменит тот, что сейчас у клиента в браузере
$APPLICATION->IncludeComponent($arParams["COMPONENT_NAME"], $arParams["TEMPLATE_NAME"], $arParams, $component);
}
}
require_once $_SERVER["DOCUMENT_ROOT"] . BX_ROOT . "/modules/main/include/epilog_after.php";
die;
}
if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
die;
示例5: includeComponent
public static function includeComponent($componentName, $componentTemplate, $arParams = array(), $parentComponent = null, $arFunctionParams = array())
{
$componentRelativePath = \CComponentEngine::MakeComponentPath($componentName);
if (StrLen($componentRelativePath) <= 0) {
return False;
}
if (is_object($parentComponent)) {
if (!$parentComponent instanceof \cbitrixcomponent) {
$parentComponent = null;
}
}
$result = null;
$bComponentEnabled = !isset($arFunctionParams["ACTIVE_COMPONENT"]) || $arFunctionParams["ACTIVE_COMPONENT"] != "N";
$component = new \CBitrixComponent();
if ($component->InitComponent($componentName)) {
$obAjax = null;
if ($bComponentEnabled) {
$component->setSiteId(static::getInstance()->getSiteId());
$component->setLanguageId(static::getInstance()->getLanguageId());
$component->setSiteTemplateId(static::getInstance()->getSiteTemplateId());
$result = $component->IncludeComponent($componentTemplate, $arParams, $parentComponent);
$arThemeCss = array();
// TODO: use styles array from $component
foreach ($arThemeCss as $cssPath) {
static::getInstance()->setStyle($cssPath);
}
}
}
return $result;
}
示例6: substr
if ($_POST["SITE_TEMPLATE"] != $_GET["template_id"] && $_POST["SITE_TEMPLATE"] != ".default") {
$_POST["USE_TEMPLATE"] = "N";
}
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);