| @@ -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 AI channel is supported (not necessarily active) | |
| 51 | - return class_exists('VikChannelManager') && defined('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 |
| @@ -59,29 +63,32 @@ | ||
| 59 | 63 | $options = [ |
| 60 | 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 | - JHtml::fetch('script', VCM_ADMIN_URI . 'assets/js/katex/katex.min.js', $options); | |
| 68 | - JHtml::fetch('script', VCM_ADMIN_URI . 'assets/js/katex/auto-render.min.js', $options); | |
| 69 | - JHtml::fetch('stylesheet', VCM_ADMIN_URI . 'assets/js/katex/katex.min.css', $options); | |
| 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); | |
| 70 | 75 | |
| 71 | - // language definitions | |
| 72 | - JText::script('VBO_AI_ASSISTANT_DISCLAIMER'); | |
| 73 | - JText::script('VBO_AI_ASSISTANT_DISCOVER_HINT'); | |
| 74 | - JText::script('VBO_AI_ASSISTANT_DISCOVER_TITLE'); | |
| 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 | + } | |
| 75 | 81 | } |
| 76 | 82 | |
| 77 | 83 | /** |
| 78 | 84 | * @inheritDoc |
| 79 | 85 | */ |
| 80 | - public function render(VBOMultitaskData $data = null) | |
| 86 | + public function render(?VBOMultitaskData $data = null) | |
| 81 | 87 | { |
| 82 | 88 | $auto_focus = false; |
| 83 | 89 | $prompt = null; |
| 90 | + $scope = null; | |
| 84 | 91 | |
| 85 | 92 | // if we are rendering the widget on a modal, register a script to prevent the latter |
| 86 | 93 | // from dismissing whenever the ESC key is pressed |
| 87 | 94 | if ($data && $data->isModalRendering()) { |
| @@ -86,8 +93,9 @@ | ||
| 86 | 93 | // from dismissing whenever the ESC key is pressed |
| 87 | 94 | if ($data && $data->isModalRendering()) { |
| 88 | 95 | $auto_focus = true; |
| 89 | 96 | $prompt = (array) $this->getOption('prompt', null); |
| 97 | + $scope = $this->getOption('scope'); | |
| 90 | 98 | ?> |
| 91 | 99 | <script> |
| 92 | 100 | (function() { |
| 93 | 101 | const vbo_modal_ai_assistant_dismiss = (event) => { |
| @@ -118,8 +126,10 @@ | ||
| 118 | 126 | // auto-focus textarea |
| 119 | 127 | 'auto_focus' => $auto_focus, |
| 120 | 128 | // default prompt |
| 121 | 129 | 'prompt' => $prompt, |
| 130 | + // default scope | |
| 131 | + 'scope' => $scope, | |
| 122 | 132 | // show widget title (VBO dashboard only) |
| 123 | 133 | 'widget_title' => is_null($data), |
| 124 | 134 | // widget icon |
| 125 | 135 | 'widget_icon' => $this->widgetIcon, |
| @@ -127,10 +137,10 @@ | ||
| 127 | 137 | 'widget_name' => $this->widgetName, |
| 128 | 138 | ], |
| 129 | 139 | null, |
| 130 | 140 | [ |
| 131 | - 'client' => 'administrator', | |
| 132 | 141 | 'component' => 'com_vikchannelmanager', |
| 142 | + 'client' => 'admin', | |
| 133 | 143 | ] |
| 134 | 144 | ); |
| 135 | 145 | } |
| 136 | 146 | } |