23
23
use InvalidArgumentException;
24
24
use Respect\Validation\Validator as v;
25
use Xibo\Factory\MediaFactory;
26
use Xibo\Helper\Sanitize;
28
* @package Xibo\Widget
30
class WebPage extends ModuleWidget
28
class WebPage extends Module
35
33
public function installFiles()
37
$this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/modules/vendor/jquery-1.11.1.min.js')->save();
38
$this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/modules/xibo-layout-scaler.js')->save();
39
$this->mediaFactory->createModuleSystemFile(PROJECT_ROOT . '/modules/xibo-webpage-render.js')->save();
35
MediaFactory::createModuleFile('modules/vendor/jquery-1.11.1.min.js')->save();
36
MediaFactory::createModuleFile('modules/xibo-layout-scaler.js')->save();
37
MediaFactory::createModuleFile('modules/xibo-webpage-render.js')->save();
42
40
public function validate()
44
if (!v::url()->notEmpty()->validate(urldecode($this->getOption('uri'))))
42
if (!v::url()->notEmpty()->validate($this->getOption('uri')))
45
43
throw new InvalidArgumentException(__('Please enter a link'));
47
if ($this->getUseDuration() == 1 && $this->getDuration() == 0)
45
if ($this->getDuration() == 0)
48
46
throw new InvalidArgumentException(__('You must enter a duration.'));
50
if ($this->getOption('modeid') == null)
51
throw new InvalidArgumentException(__('You must select a mode.'));
55
* Adds a Webpage Widget
57
* path="/playlist/widget/webpage/{playlistId}",
58
* operationId="WidgetWebpageAdd",
60
* summary="Add a Web page Widget",
61
* description="Add a new Web page Widget to the specified playlist",
65
* description="The playlist ID to add a Web page to",
72
* description="Optional Widget Name",
79
* description="The Web page Duration",
86
* description="(0, 1) Select 1 only if you will provide duration parameter as well",
91
* name="transparency",
93
* description=" flag (0,1) should the HTML be shown with a transparent background?",
100
* description=" string containing the location (URL) of the web page",
107
* description="For Manual position the percentage to scale the Web page (0-100)",
114
* description="For Manual position, the starting point from the left in pixels",
121
* description="For Manual position, the starting point from the Top in pixels",
128
* description="For Manual Position and Best Fit, The width of the page - if empty it will use region width",
135
* description="For Manual Position and Best Fit, The height of the page - if empty it will use region height",
142
* description="The mode option for Web page, 1- Open Natively, 2- Manual Position, 3- Best Ft",
148
* description="successful operation",
149
* @SWG\Schema(ref="#/definitions/Widget"),
152
* description="Location of the new widget",
158
52
public function add()
160
54
$this->setOption('xmds', true);
161
$this->setUseDuration($this->getSanitizer()->getCheckbox('useDuration'));
162
$this->setDuration($this->getSanitizer()->getInt('duration', $this->getDuration()));
163
$this->setOption('name', $this->getSanitizer()->getString('name'));
164
$this->setOption('transparency', $this->getSanitizer()->getCheckbox('transparency'));
165
$this->setOption('uri', urlencode($this->getSanitizer()->getString('uri')));
166
$this->setOption('scaling', $this->getSanitizer()->getInt('scaling'));
167
$this->setOption('offsetLeft', $this->getSanitizer()->getInt('offsetLeft'));
168
$this->setOption('offsetTop', $this->getSanitizer()->getInt('offsetTop'));
169
$this->setOption('pageWidth', $this->getSanitizer()->getInt('pageWidth'));
170
$this->setOption('pageHeight', $this->getSanitizer()->getInt('pageHeight'));
171
$this->setOption('modeid', $this->getSanitizer()->getInt('modeId'));
55
$this->setDuration(Sanitize::getInt('duration'));
56
$this->setOption('name', Sanitize::getString('name'));
57
$this->setOption('transparency', Sanitize::getCheckbox('transparency'));
58
$this->setOption('uri', Sanitize::getString('uri'));
59
$this->setOption('scaling', Sanitize::getInt('scaling'));
60
$this->setOption('offsetLeft', Sanitize::getInt('offsetLeft'));
61
$this->setOption('offsetTop', Sanitize::getInt('offsetTop'));
62
$this->setOption('pageWidth', Sanitize::getInt('pageWidth'));
63
$this->setOption('pageHeight', Sanitize::getInt('pageHeight'));
64
$this->setOption('modeid', Sanitize::getInt('modeId'));
173
66
// Save the widget
174
67
$this->validate();
175
68
$this->saveWidget();
179
* Edit a Webpage Widget
181
74
public function edit()
183
76
$this->setOption('xmds', true);
184
$this->setUseDuration($this->getSanitizer()->getCheckbox('useDuration'));
185
$this->setDuration($this->getSanitizer()->getInt('duration', $this->getDuration()));
186
$this->setOption('name', $this->getSanitizer()->getString('name'));
187
$this->setOption('transparency', $this->getSanitizer()->getCheckbox('transparency'));
188
$this->setOption('uri', urlencode($this->getSanitizer()->getString('uri')));
189
$this->setOption('scaling', $this->getSanitizer()->getInt('scaling'));
190
$this->setOption('offsetLeft', $this->getSanitizer()->getInt('offsetLeft'));
191
$this->setOption('offsetTop', $this->getSanitizer()->getInt('offsetTop'));
192
$this->setOption('pageWidth', $this->getSanitizer()->getInt('pageWidth'));
193
$this->setOption('pageHeight', $this->getSanitizer()->getInt('pageHeight'));
194
$this->setOption('modeid', $this->getSanitizer()->getInt('modeId'));
77
$this->setDuration(Sanitize::getInt('duration'));
78
$this->setOption('name', Sanitize::getString('name'));
79
$this->setOption('transparency', Sanitize::getCheckbox('transparency'));
80
$this->setOption('uri', Sanitize::getString('uri'));
81
$this->setOption('scaling', Sanitize::getInt('scaling'));
82
$this->setOption('offsetLeft', Sanitize::getInt('offsetLeft'));
83
$this->setOption('offsetTop', Sanitize::getInt('offsetTop'));
84
$this->setOption('pageWidth', Sanitize::getInt('pageWidth'));
85
$this->setOption('pageHeight', Sanitize::getInt('pageHeight'));
86
$this->setOption('modeid', Sanitize::getInt('modeId'));
196
88
// Save the widget
197
89
$this->validate();