Максим Смирнов в своем блоге писал про поддержку ООП в компонентах .
будем использовать только class.php и перепишем вывод кнопочек для панели из стандартного компонента, например так:
то на текущий момент панельки для управления элементом инфоблока мы не увидем ).
Таблетка:
bitrix/modules/main/classes/general/component.php
Нам нужно final public function includeComponent($componentTemplate, $arParams, $parentComponent)
кусок
изменить на
Объяснение:
bitrix/modules/main/classes/general/main.php функция function IncludeComponent($componentName, $componentTemplate, $arParams = array(), $parentComponent = null, $arFunctionParams = array())
** создаем объект $component класса CBitrixComponent() и в дальнейшем вызываем у этого объекта член-функцию $component->includeComponent($componentTemplate, $arParams, $parentComponent),
** которая в свою очередь создает новый объект $component класса, описанного Вами в файле class.php (new $this->classOfComponent($this)) и не передает в текущий объект $component результаты работы объекта $component (те-же иконки __arIncludeAreaIcons, шаблон, кеш и т.п. ).
Решение для иконок: - перебросить после выполнения их в текущий объект $component , которые в последующем будут вызваны через
В ТП сообщил.
будем использовать только class.php и перепишем вывод кнопочек для панели из стандартного компонента, например так:
$this->includeComponentTemplate(); ..... if(isset($this->arResult["ID"])) global $APPLICATION, $USER, $DB; if($GLOBALS['USER']->IsAuthorized()) { if( $APPLICATION->GetShowIncludeAreas() || $this->arParams["SET_TITLE"] || isset($this->arResult[$this->arParams["BROWSER_TITLE"]]) ) { $arReturnUrl = array( "add_element" => CIBlock::GetArrayByID($this->arParams["IBLOCK_ID"], "DETAIL_PAGE_URL"), "delete_element" => ( isset($this->arResult["SECTION"])? $this->arResult["SECTION_URL"]: $this->arResult["LIST_PAGE_URL"] ), ); $arButtons = CIBlock::GetPanelButtons( $this->arParams["IBLOCK_ID"], $this->arResult["ID"], $this->arResult["IBLOCK_SECTION_ID"], Array( "RETURN_URL" => $arReturnUrl, "CATALOG"=>true ) ); if($APPLICATION->GetShowIncludeAreas()) $this->addIncludeAreaIcons(CIBlock::GetComponentMenu($APPLICATION->GetPublicShowMode(), $arButtons)); if($this->arParams["SET_TITLE"] || isset($this->arResult[$this->arParams["BROWSER_TITLE"]])) { $arTitleOptions = array( 'ADMIN_EDIT_LINK' => $arButtons["submenu"]["edit_element"]["ACTION"], 'PUBLIC_EDIT_LINK' => $arButtons["edit"]["edit_element"]["ACTION"], 'COMPONENT_NAME' => $this->getName(), ); } } .... |
то на текущий момент панельки для управления элементом инфоблока мы не увидем ).
Таблетка:
bitrix/modules/main/classes/general/component.php
Нам нужно final public function includeComponent($componentTemplate, $arParams, $parentComponent)
кусок
if($this->classOfComponent) { /** @var CBitrixComponent $component */ $component = new $this->classOfComponent($this); $component->arParams = $component->onPrepareComponentParams($arParams); $component->__prepareComponentParams($component->arParams); $component->onIncludeComponentLang(); return = $component->executeComponent(); } |
изменить на
{ /** @var CBitrixComponent $component */ $component = new $this->classOfComponent($this); $component->arParams = $component->onPrepareComponentParams($arParams); $component->__prepareComponentParams($component->arParams); $component->onIncludeComponentLang(); $return = $component->executeComponent(); $this->__arIncludeAreaIcons = $component->getIncludeAreaIcons(); return $return; } |
bitrix/modules/main/classes/general/main.php функция function IncludeComponent($componentName, $componentTemplate, $arParams = array(), $parentComponent = null, $arFunctionParams = array())
** создаем объект $component класса CBitrixComponent() и в дальнейшем вызываем у этого объекта член-функцию $component->includeComponent($componentTemplate, $arParams, $parentComponent),
** которая в свою очередь создает новый объект $component класса, описанного Вами в файле class.php (new $this->classOfComponent($this)) и не передает в текущий объект $component результаты работы объекта $component (те-же иконки __arIncludeAreaIcons, шаблон, кеш и т.п. ).
Решение для иконок: - перебросить после выполнения их в текущий объект $component , которые в последующем будут вызваны через
$panel = new CComponentPanel($component, $componentName, $componentTemplate, $parentComponent, $bComponentEnabled); $arIcons = $panel->GetIcons(); |