widgetName = JText::translate('VBO_W_AITOOLS_TITLE'); $this->widgetDescr = JText::translate('VBO_W_AITOOLS_DESCR'); $this->widgetId = basename(__FILE__, '.php'); $this->widgetIcon = ''; $this->widgetStyleName = 'violet'; } /** * @inheritDoc */ public function getPriority() { // give this widget a higher priority return 15; } /** * @inheritDoc */ public function preflight() { if (VBOPlatformDetection::isJoomla()) { // can be used only if VCM is installed and the AI channel is supported (not necessarily active) return class_exists('VikChannelManager') && defined('VikChannelManagerConfig::AI'); } return parent::preflight(); } /** * @inheritDoc */ public function preload() { $options = [ 'version' => defined('VIKCHANNELMANAGER_SOFTWARE_VERSION') ? VIKCHANNELMANAGER_SOFTWARE_VERSION : VIKBOOKING_SOFTWARE_VERSION, ]; if (class_exists('VikChannelManager')) { // manually load required dependencies JHtml::fetch('script', VCM_ADMIN_URI . 'layouts/ai/assistant/aitools.js', $options); JHtml::fetch('stylesheet', VCM_ADMIN_URI . 'layouts/ai/assistant/aitools.css', $options); JHtml::fetch('script', VCM_ADMIN_URI . 'assets/js/katex/katex.min.js', $options); JHtml::fetch('script', VCM_ADMIN_URI . 'assets/js/katex/auto-render.min.js', $options); JHtml::fetch('stylesheet', VCM_ADMIN_URI . 'assets/js/katex/katex.min.css', $options); // language definitions JText::script('VBO_AI_ASSISTANT_DISCLAIMER'); JText::script('VBO_AI_ASSISTANT_DISCOVER_HINT'); JText::script('VBO_AI_ASSISTANT_DISCOVER_TITLE'); } } /** * @inheritDoc */ public function render(?VBOMultitaskData $data = null) { $auto_focus = false; $prompt = null; $scope = null; // if we are rendering the widget on a modal, register a script to prevent the latter // from dismissing whenever the ESC key is pressed if ($data && $data->isModalRendering()) { $auto_focus = true; $prompt = (array) $this->getOption('prompt', null); $scope = $this->getOption('scope'); ?> false, // auto-focus textarea 'auto_focus' => $auto_focus, // default prompt 'prompt' => $prompt, // default scope 'scope' => $scope, // show widget title (VBO dashboard only) 'widget_title' => is_null($data), // widget icon 'widget_icon' => $this->widgetIcon, // widget name 'widget_name' => $this->widgetName, ], null, [ 'component' => 'com_vikchannelmanager', 'client' => 'admin', ] ); } }