芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/cms.mgaplay.com.br/lib/Widget/Dashboard.php
. */ namespace Xibo\Widget; use Slim\Http\Response; use Slim\Http\ServerRequest as Request; use Xibo\Event\XmdsConnectorTokenEvent; use Xibo\Helper\DateFormatHelper; use Xibo\Support\Exception\ConfigurationException; use Xibo\Support\Exception\InvalidArgumentException; use Xibo\Xmds\Wsdl; class Dashboard extends ModuleWidget { public function getTimezoneList(): array { $timeZones = []; $timeZones[] = ['id' => '', 'value' => null]; foreach (DateFormatHelper::timezoneList() as $key => $value) { $timeZones[] = ['id' => $key, 'value' => $value]; } return $timeZones; } public function edit(Request $request, Response $response): Response { $sanitizedParams = $this->getSanitizer($request->getParams()); $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->setOption('type', $sanitizedParams->getString('type')); // URL $url = $sanitizedParams->getString('url'); $this->setOption('url', urlencode($url)); if (empty($url)) { throw new InvalidArgumentException(__('Please supply a URL.'), 'url'); } // Interval $interval = $sanitizedParams->getInt('updateInterval', ['default' => 60]); if ($interval < 5) { throw new InvalidArgumentException(__('5 minutes is the lowest update interval allowed'), 'updateInterval'); } $this->setOption('updateInterval', $interval); // Save the widget $this->isValid(); $this->saveWidget(); return $response; } /** @inheritDoc */ public function isValid() { // We're going to assume this is always valid. if (empty($this->getOption('url'))) { $this->statusMessage = __('Please set a URL'); return self::$STATUS_INVALID; } else { return self::$STATUS_VALID; } } /** @inheritdoc */ public function preview($width, $height, $scaleOverride = 0) { if ($this->module->previewEnabled == 0) { return parent::preview($width, $height, $scaleOverride); } if ($this->isValid() === self::$STATUS_VALID) { $widthPx = $width . 'px'; $heightPx = $height . 'px'; $url = $this->urlFor('module.getResource', ['regionId' => $this->region->regionId, 'id' => $this->getWidgetId()]); return '
'; } else { return '
'; } } /** @inheritDoc */ public function getResource($displayId = 0) { // Always generate a token $event = new XmdsConnectorTokenEvent(); $event->setTargets($displayId, $this->getWidgetId()); $event->setTtl($this->getCacheDuration() * 2); $this->getDispatcher()->dispatch($event, XmdsConnectorTokenEvent::$NAME); $token = $event->getToken(); if (empty($token)) { throw new ConfigurationException(__('No token returned')); } if ($this->isPreview()) { $url = $this->urlFor('layout.preview.connector', [], ['token' => $token]); } else { // This is fallback HTML for the player. // so output a link to the XMDS file request. $url = Wsdl::getRoot() . '?connector=true&token=' . $token; } // Construct the response HTML $this ->initialiseGetResource() ->appendViewPortWidth($this->region->width) ->appendJavaScriptFile('vendor/jquery.min.js') ->appendJavaScript('var xiboICTargetId = ' . $this->getWidgetId() . ';') ->appendJavaScriptFile('xibo-interactive-control.min.js') ->appendCss(' #loader { display: block; margin-left: auto; margin-right: auto; margin-top: 50px; } #dashboard { position: fixed; top: 0; left: 0; width: 100%; height: 100%; } #dashboard img { margin: auto; width: 100%; height: 100%; } ') ->appendOptions([ 'originalWidth' => $this->region->width, 'originalHeight' => $this->region->height, 'url' => $url, 'interval' => $this->getOption('updateInterval', 60), 'isPreview' => $this->isPreview() ]) ->appendJavaScript(' var interval; $(function() { loadImage(); }); function loadImage() { $("#dashboard").html(""); var image = new Image(); image.onload = function() { $("#dashboard").append($("
")); $("#loader").hide(); if (interval) { clearInterval(interval) } interval = setInterval(loadImage, options.interval * 60 * 1000); } image.onerror = function() { $("#loader").show(); if (interval) { clearInterval(interval) } interval = setInterval(loadImage, 60 * 1000); } if (options.url) { if (options.isPreview) { var queryParams = new URLSearchParams(window.location.search) if(queryParams.has("debug")) { var debug = queryParams.get("debug") if (debug == 1) { options.url = options.url.concat("&isDebug=1") } } } image.src = options.url; } } ') ->appendBody('
'); return $this->finaliseGetResource(); } private function getSpinner(): string { return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBzdGFuZGFsb25lPSJubyI/Pgo8IURPQ1RZUEUgc3ZnIFBVQkxJQy AiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPgo8c3ZnIH dpZHRoPSI0MHB4IiBoZWlnaHQ9IjQwcHgiIHZpZXdCb3g9IjAgMCA0MCA0MCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcm cvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4bWw6c3BhY2U9InByZXNlcnZlIiBzdHlsZT0iZm lsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjEuNDE0MjE7Ii B4PSIwcHgiIHk9IjBweCI+CiAgICA8ZGVmcz4KICAgICAgICA8c3R5bGUgdHlwZT0idGV4dC9jc3MiPjwhW0NEQVRBWwogICAgICAgICAgICBALX dlYmtpdC1rZXlmcmFtZXMgc3BpbiB7CiAgICAgICAgICAgICAgZnJvbSB7CiAgICAgICAgICAgICAgICAtd2Via2l0LXRyYW5zZm9ybTogcm90YX RlKDBkZWcpCiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRvIHsKICAgICAgICAgICAgICAgIC13ZWJraXQtdHJhbnNmb3JtOiByb3RhdG UoLTM1OWRlZykKICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgQGtleWZyYW1lcyBzcGluIHsKICAgICAgICAgICAgIC Bmcm9tIHsKICAgICAgICAgICAgICAgIHRyYW5zZm9ybTogcm90YXRlKDBkZWcpCiAgICAgICAgICAgICAgfQogICAgICAgICAgICAgIHRvIHsKIC AgICAgICAgICAgICAgIHRyYW5zZm9ybTogcm90YXRlKC0zNTlkZWcpCiAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIH N2Zy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5MzksNS44NTc4NloiIHN0eWxlPSJmaWxsOn JnYig1MCw1MCw1MCk7Ii8+CiAgICAgICAgPC9nPgogICAgPC9nPgo8L3N2Zz4K'; } /** * This is how often our token gets refreshed. * @inheritDoc */ public function getCacheDuration() { // 24 hours return 3600 * 24; } /** * Our links are per-display, so we need to cache per display too. * @inheritDoc */ public function getCacheKey($displayId) { return $this->getWidgetId() . '_' . $displayId; } /** @inheritDoc */ public function installOrUpdate($moduleFactory) { if ($this->module == null) { // Install $module = $moduleFactory->createEmpty(); $module->name = 'Dashboards'; $module->type = 'dashboard'; $module->class = 'Xibo\Widget\Dashboard'; $module->description = 'Securely connect to services like Microsoft PowerBI and display dashboards'; $module->enabled = 1; $module->previewEnabled = 1; $module->assignable = 1; $module->regionSpecific = 1; $module->renderAs = 'html'; $module->schemaVersion = $this->codeSchemaVersion; $module->defaultDuration = 60; $module->settings = []; $module->viewPath = '../modules'; $module->installName = 'dashboard'; // Set the newly created module and then call install $this->setModule($module); $this->installModule(); } // Install and additional module files that are required. $this->installFiles(); } }