Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/components/bitrix/main.post.form/ |
Upload File : |
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die(); } use Bitrix\AI; use Bitrix\Main; /* @note To turn on Copilot in the main.post.form component, please, execute code: \COption::SetOptionString('socialnetwork', 'ai_base_enabled', 'N'); */ final class MainPostForm extends CBitrixComponent { const STATUS_SCOPE_MOBILE = 'mobile'; const STATUS_SCOPE_WEB = 'web'; private $scope; public function __construct($component = null) { parent::__construct($component); $this->scope = self::STATUS_SCOPE_WEB; if (is_callable(array('\Bitrix\MobileApp\Mobile', 'getApiVersion')) && \Bitrix\MobileApp\Mobile::getApiVersion() >= 1 && defined("BX_MOBILE") && BX_MOBILE === true) $this->scope = self::STATUS_SCOPE_MOBILE; $templateName = $this->getTemplateName(); if ((empty($templateName) || $templateName == ".default" || $templateName == "bitrix24")) { if ($this->isWeb()) $this->setTemplateName(".default"); else $this->setTemplateName("mobile_app"); } } protected function isWeb() { return ($this->scope == self::STATUS_SCOPE_WEB); } private function prepareParams(&$arParams) { if (empty($arParams["FORM_ID"])) { $arParams["FORM_ID"] = "POST_FORM_".RandString(3); } $arParams['NAME_TEMPLATE'] = empty($arParams['NAME_TEMPLATE']) ? \CSite::GetNameFormat(false) : str_replace(array("#NOBR#","#/NOBR#"), "", $arParams["NAME_TEMPLATE"]); $arParams['COPILOT_AVAILABLE'] = $this->isCopilotEnabled(); $arParams['isAiImageEnabled'] ??= true; $arParams['isDnDEnabled'] ??= true; if ( $arParams['isAiImageEnabled'] && $this->iaAIAvailable() ) { $arParams["PARSER"][] = 'AIImage'; } } public function executeComponent() { $this->prepareParams($this->arParams); $this->includeComponentTemplate(); } private function iaAIAvailable(): bool { if (!Main\Loader::includeModule('ai')) { return false; } $engine = AI\Engine::getByCategory('image', new AI\Context('main', '')); return !is_null($engine); } public function isCopilotEnabled(): bool { if (!Main\Loader::includeModule('ai')) { return false; } $engine = AI\Engine::getByCategory(AI\Engine::CATEGORIES['text'], AI\Context::getFake()); return !is_null($engine); } }