芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/mctv/lib/Widget/Spacer.php
. */ namespace Xibo\Widget; use Slim\Http\Response as Response; use Slim\Http\ServerRequest as Request; /** * Class Spacer * @package Xibo\Widget */ class Spacer extends ModuleWidget { public $codeSchemaVersion = 1; /** * @inheritDoc */ public function installOrUpdate($moduleFactory) { if ($this->module == null) { // Install $module = $moduleFactory->createEmpty(); $module->name = 'Spacer'; $module->type = 'spacer'; $module->class = 'Xibo\Widget\Spacer'; $module->description = 'Make a Region empty for a specified duration'; $module->enabled = 1; $module->previewEnabled = 0; $module->assignable = 1; $module->regionSpecific = 1; $module->renderAs = 'html'; $module->schemaVersion = $this->codeSchemaVersion; $module->defaultDuration = 60; $module->validExtensions = ''; $module->settings = []; $module->installName = 'spacer'; $this->setModule($module); $this->installModule(); } // Check we are all installed $this->installFiles(); } /** * @inheritDoc */ public function layoutDesignerJavaScript() { // We use the same javascript as the data set view designer return 'spacer-designer-javascript'; } /** * Edit Widget * * @SWG\Put( * path="/playlist/widget/{widgetId}?spacer", * operationId="WidgetSpacerEdit", * tags={"widget"}, * summary="Edit a Spacer Widget", * description="Edit Spacer Widget. This call will replace existing Widget object, all not supplied parameters will be set to default.", * @SWG\Parameter( * name="widgetId", * in="path", * description="The WidgetId to Edit", * type="integer", * required=true * ), * @SWG\Parameter( * name="name", * in="formData", * description="Optional Widget Name", * type="string", * required=false * ), * @SWG\Parameter( * name="useDuration", * in="formData", * description="Select only if you will provide duration parameter as well", * type="integer", * required=false * ), * @SWG\Parameter( * name="duration", * in="formData", * description="The Widget Duration", * type="integer", * required=false * ), * @SWG\Parameter( * name="enableStat", * in="formData", * description="The option (On, Off, Inherit) to enable the collection of Widget Proof of Play statistics", * type="string", * required=false * ), * @SWG\Response( * response=204, * description="successful operation" * ) * ) * * @inheritDoc */ public function edit(Request $request, Response $response): Response { $sanitizedParams = $this->getSanitizer($request->getParams()); // Set the properties specific to this module $this->setDuration($sanitizedParams->getInt('duration', ['default' => $this->getDuration()])); $this->setUseDuration($sanitizedParams->getCheckbox('useDuration')); $this->setOption('name', $sanitizedParams->getString('name')); $this->setOption('enableStat', $sanitizedParams->getString('enableStat')); $this->saveWidget(); return $response; } /** * @inheritdoc */ public function isValid() { // this is empty html, always valid return 1; } /** @inheritdoc */ public function getResource($displayId = 0) { // Construct the response HTML $this->initialiseGetResource() ->appendViewPortWidth($this->region->width); return $this->finaliseGetResource(); } /** @inheritdoc */ public function getCacheDuration() { // We have a long cache interval because we don't depend on any external data. return 86400 * 365; } }