Skip to content

Commit

Permalink
Support webosCommand xibosignage/xibo#1508
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMis committed May 8, 2018
1 parent 00c2ccf commit 2c93b65
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
18 changes: 16 additions & 2 deletions lib/Widget/ShellCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ShellCommand extends ModuleWidget
{
public function validate()
{
if ($this->getOption('windowsCommand') == '' && $this->getOption('linuxCommand') == '' && $this->getOption('commandCode') == '')
if ($this->getOption('windowsCommand') == '' && $this->getOption('linuxCommand') == '' && $this->getOption('commandCode') == '' && $this->getOption('webosCommand' == ''))
throw new InvalidArgumentException(__('You must enter a command'));
}

Expand Down Expand Up @@ -81,6 +81,13 @@ public function validate()
* required=false
* ),
* @SWG\Parameter(
* name="webosCommand",
* in="formData",
* description="Enter a webOS Command Line compatible command. Supported from R11 onward",
* type="string",
* required=false
* ),
* @SWG\Parameter(
* name="launchThroughCmd",
* in="formData",
* description="flag (0,1) Windows only, Should the player launch this command through the windows command line (cmd.exe)? This is useful for batch files, if you try to terminate this command only the command line will be terminated",
Expand Down Expand Up @@ -130,13 +137,15 @@ public function add()
// Commands
$windows = $this->getSanitizer()->getString('windowsCommand');
$linux = $this->getSanitizer()->getString('linuxCommand');
$webos = $this->getSanitizer()->getString('webosCommand');

$this->setOption('launchThroughCmd', $this->getSanitizer()->getCheckbox('launchThroughCmd'));
$this->setOption('terminateCommand', $this->getSanitizer()->getCheckbox('terminateCommand'));
$this->setOption('useTaskkill', $this->getSanitizer()->getCheckbox('useTaskkill'));
$this->setOption('commandCode', $this->getSanitizer()->getString('commandCode'));
$this->setOption('windowsCommand', urlencode($windows));
$this->setOption('linuxCommand', urlencode($linux));
$this->setOption('webosCommand', urlencode($webos));

// Save the widget
$this->validate();
Expand All @@ -156,13 +165,15 @@ public function edit()
// Commands
$windows = $this->getSanitizer()->getString('windowsCommand');
$linux = $this->getSanitizer()->getString('linuxCommand');
$webos = $this->getSanitizer()->getString('webosCommand');

$this->setOption('launchThroughCmd', $this->getSanitizer()->getCheckbox('launchThroughCmd'));
$this->setOption('terminateCommand', $this->getSanitizer()->getCheckbox('terminateCommand'));
$this->setOption('useTaskkill', $this->getSanitizer()->getCheckbox('useTaskkill'));
$this->setOption('commandCode', $this->getSanitizer()->getString('commandCode'));
$this->setOption('windowsCommand', urlencode($windows));
$this->setOption('linuxCommand', urlencode($linux));
$this->setOption('webosCommand', urlencode($webos));

// Save the widget
$this->validate();
Expand All @@ -176,14 +187,17 @@ public function preview($width, $height, $scaleOverride = 0)

$windows = $this->getOption('windowsCommand');
$linux = $this->getOption('linuxCommand');
$webos = $this->getOption('webosCommand');

if ($windows == '' && $linux == '') {
if ($windows == '' && $linux == '' && $webos == '') {
return __('Stored Command: %s', $this->getOption('commandCode'));
}
else {

$preview = '<p>' . __('Windows Command') . ': ' . urldecode($windows) . '</p>';
$preview .= '<p>' . __('Linux Command') . ': ' . urldecode($linux) . '</p>';
$preview .= '<p>' . __('webOS Command') . ': ' . urldecode($webos) . '</p>';


return $preview;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/shellcommand-form-add.twig
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@
{{ forms.input("linuxCommand", title, "", helpText, "non-command-fields") }}

{% set title %}{% trans "webOS Command" %}{% endset %}
{% set helpText %}{% trans "Enter a webOS Command Line compatible command" %}{% endset %}
{{ forms.hidden("webosCommand", title, "", helpText, "non-command-fields") }}
{% set helpText %}{% trans "Enter a webOS Command Line compatible command. Supported from R11 onward" %}{% endset %}
{{ forms.input("webosCommand", title, "", helpText, "non-command-fields") }}

{% set title %}{% trans "Set a duration?" %}{% endset %}
{% set helpText %}{% trans "Select to provide a specific duration for this Widget" %}{% endset %}
Expand Down
4 changes: 2 additions & 2 deletions modules/shellcommand-form-edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@
{{ forms.input("linuxCommand", title, module.getOption("linuxCommand")|url_decode, helpText, "non-command-fields") }}

{% set title %}{% trans "webOS Command" %}{% endset %}
{% set helpText %}{% trans "Enter a webOS Command Line compatible command" %}{% endset %}
{{ forms.hidden("webosCommand", title, module.getOption('webosCommand'), helpText, "non-command-fields") }}
{% set helpText %}{% trans "Enter a webOS Command Line compatible command. Supported from R11 onward" %}{% endset %}
{{ forms.input("webosCommand", title, module.getOption('webosCommand'), helpText, "non-command-fields") }}

{% set title %}{% trans "Set a duration?" %}{% endset %}
{% set helpText %}{% trans "Select to provide a specific duration for this Widget" %}{% endset %}
Expand Down

0 comments on commit 2c93b65

Please sign in to comment.