| @@ -46,10 +46,14 @@ | ||
| 46 | 46 | * @inheritDoc |
| 47 | 47 | */ |
| 48 | 48 | public function preflight() |
| 49 | 49 | { |
| 50 | - // can be used only if VCM is installed and the account has the AI channel | |
| 51 | - return class_exists('VikChannelManager') && defined('VikChannelManagerConfig::AI') && VikChannelManager::getChannel(VikChannelManagerConfig::AI); | |
| 50 | + if (VBOPlatformDetection::isJoomla()) { | |
| 51 | + // can be used only if VCM is installed and the AI channel is supported (not necessarily active) | |
| 52 | + return class_exists('VikChannelManager') && defined('VikChannelManagerConfig::AI'); | |
| 53 | + } | |
| 54 | + | |
| 55 | + return parent::preflight(); | |
| 52 | 56 | } |
| 53 | 57 | |
| 54 | 58 | /** |
| 55 | 59 | * @inheritDoc |
| @@ -56,28 +60,35 @@ | ||
| 56 | 60 | */ |
| 57 | 61 | public function preload() |
| 58 | 62 | { |
| 59 | 63 | $options = [ |
| 60 | - 'version' => VIKCHANNELMANAGER_SOFTWARE_VERSION ?? VIKBOOKING_SOFTWARE_VERSION, | |
| 64 | + 'version' => defined('VIKCHANNELMANAGER_SOFTWARE_VERSION') ? VIKCHANNELMANAGER_SOFTWARE_VERSION : VIKBOOKING_SOFTWARE_VERSION, | |
| 61 | 65 | ]; |
| 62 | 66 | |
| 63 | - // manually load required dependencies | |
| 64 | - JHtml::fetch('script', VCM_ADMIN_URI . 'layouts/ai/assistant/aitools.js', $options); | |
| 65 | - JHtml::fetch('stylesheet', VCM_ADMIN_URI . 'layouts/ai/assistant/aitools.css', $options); | |
| 67 | + if (class_exists('VikChannelManager')) { | |
| 68 | + // manually load required dependencies | |
| 69 | + JHtml::fetch('script', VCM_ADMIN_URI . 'layouts/ai/assistant/aitools.js', $options); | |
| 70 | + JHtml::fetch('stylesheet', VCM_ADMIN_URI . 'layouts/ai/assistant/aitools.css', $options); | |
| 66 | 71 | |
| 67 | - // language definitions | |
| 68 | - JText::script('VBO_AI_ASSISTANT_DISCLAIMER'); | |
| 69 | - JText::script('VBO_AI_ASSISTANT_DISCOVER_HINT'); | |
| 70 | - JText::script('VBO_AI_ASSISTANT_DISCOVER_TITLE'); | |
| 72 | + JHtml::fetch('script', VCM_ADMIN_URI . 'assets/js/katex/katex.min.js', $options); | |
| 73 | + JHtml::fetch('script', VCM_ADMIN_URI . 'assets/js/katex/auto-render.min.js', $options); | |
| 74 | + JHtml::fetch('stylesheet', VCM_ADMIN_URI . 'assets/js/katex/katex.min.css', $options); | |
| 75 | + | |
| 76 | + // language definitions | |
| 77 | + JText::script('VBO_AI_ASSISTANT_DISCLAIMER'); | |
| 78 | + JText::script('VBO_AI_ASSISTANT_DISCOVER_HINT'); | |
| 79 | + JText::script('VBO_AI_ASSISTANT_DISCOVER_TITLE'); | |
| 80 | + } | |
| 71 | 81 | } |
| 72 | 82 | |
| 73 | 83 | /** |
| 74 | 84 | * @inheritDoc |
| 75 | 85 | */ |
| 76 | - public function render(VBOMultitaskData $data = null) | |
| 86 | + public function render(?VBOMultitaskData $data = null) | |
| 77 | 87 | { |
| 78 | 88 | $auto_focus = false; |
| 79 | 89 | $prompt = null; |
| 90 | + $scope = null; | |
| 80 | 91 | |
| 81 | 92 | // if we are rendering the widget on a modal, register a script to prevent the latter |
| 82 | 93 | // from dismissing whenever the ESC key is pressed |
| 83 | 94 | if ($data && $data->isModalRendering()) { |
| @@ -82,8 +93,9 @@ | ||
| 82 | 93 | // from dismissing whenever the ESC key is pressed |
| 83 | 94 | if ($data && $data->isModalRendering()) { |
| 84 | 95 | $auto_focus = true; |
| 85 | 96 | $prompt = (array) $this->getOption('prompt', null); |
| 97 | + $scope = $this->getOption('scope'); | |
| 86 | 98 | ?> |
| 87 | 99 | <script> |
| 88 | 100 | (function() { |
| 89 | 101 | const vbo_modal_ai_assistant_dismiss = (event) => { |
| @@ -114,13 +126,21 @@ | ||
| 114 | 126 | // auto-focus textarea |
| 115 | 127 | 'auto_focus' => $auto_focus, |
| 116 | 128 | // default prompt |
| 117 | 129 | 'prompt' => $prompt, |
| 130 | + // default scope | |
| 131 | + 'scope' => $scope, | |
| 132 | + // show widget title (VBO dashboard only) | |
| 133 | + 'widget_title' => is_null($data), | |
| 134 | + // widget icon | |
| 135 | + 'widget_icon' => $this->widgetIcon, | |
| 136 | + // widget name | |
| 137 | + 'widget_name' => $this->widgetName, | |
| 118 | 138 | ], |
| 119 | 139 | null, |
| 120 | 140 | [ |
| 121 | - 'client' => 'administrator', | |
| 122 | 141 | 'component' => 'com_vikchannelmanager', |
| 142 | + 'client' => 'admin', | |
| 123 | 143 | ] |
| 124 | 144 | ); |
| 125 | 145 | } |
| 126 | 146 | } |