0byt3m1n1
Path:
/
home
/
mgatv524
/
vision.mgaplay.com.br
/
custom
/
[
Home
]
File: XiboForLinuxMiddleware.php
<?php namespace Xibo\Custom; use Slim\Middleware; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\EventDispatcher; use Xibo\Event\DisplayProfileLoadedEvent; use Xibo\Storage\StorageServiceInterface; /** * Class XiboForLinuxMiddleware * @package Xibo\custom * * Included by instantiation in `settings.php` */ class XiboForLinuxMiddleware extends Middleware { public function call() { $app = $this->getApplication(); $app->hook('slim.before.dispatch', function() use($app) { $app->logService->debug('Loading additional Middleware - XiboForLinuxMiddleware'); // Check to see if we have a LG profile, if we don't then add one /** @var StorageServiceInterface $db */ $db = $app->store; $results = $db->select('SELECT displayProfileId FROM displayprofile WHERE type = :type', ['type' => 'linux']); if (count($results) <= 0) { $app->logService->debug('Creating a new display profile to use with Linux'); $db->insert('INSERT INTO displayprofile (name, type, config, isdefault, userId) VALUES (:name, :type, :config, :isDefault, :userId)', [ 'name' => 'Linux', 'type' => 'linux', 'config' => '{}', 'isDefault' => 1, 'userId' => $app->userFactory->getSuperAdmins()[0]->userId ]); } self::registerDispatcher($app); }); // Next middleware $this->next->call(); } /** * Register dispatcher * @param $app */ public static function registerDispatcher($app) { /** @var EventDispatcher $dispatcher */ $dispatcher = $app->dispatcher; $dispatcher->addListener(DisplayProfileLoadedEvent::NAME, function(Event $event) use ($app) { /** @var DisplayProfileLoadedEvent $event */ $displayProfile = $event->getDisplayProfile(); $app->logService->debug("Loaded DisplayProfile: " . $displayProfile->name . ' for ' . $displayProfile->getClientType()); if ($displayProfile->getClientType() != 'linux') return; // Augment this with our own settings and call load again. $displayProfile->configTabs = [ array('id' => 'general', 'name' => __('General')), array('id' => 'location', 'name' => __('Location')), array('id' => 'trouble', 'name' => __('Troubleshooting')), array('id' => 'advanced', 'name' => __('Advanced')), ]; $displayProfile->configDefault = [ array( 'name' => 'collectInterval', 'tabId' => 'general', 'title' => __('Collect interval'), 'type' => 'int', 'fieldType' => 'dropdown', 'options' => array( array('id' => 60, 'value' => __('1 minute')), array('id' => 300, 'value' => __('5 minutes')), array('id' => 600, 'value' => __('10 minutes')), array('id' => 900, 'value' => __('15 minutes')), array('id' => 1800, 'value' => __('30 minutes')), array('id' => 3600, 'value' => __('1 hour')), array('id' => 14400, 'value' => __('4 hours')), array('id' => 43200, 'value' => __('12 hours')), array('id' => 86400, 'value' => __('24 hours')) ), 'default' => 900, 'helpText' => __('How often should the Player check for new content.'), 'validation' => 'numeric', 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'downloadStartWindow', 'tabId' => 'general', 'title' => __('Download Window Start Time'), 'type' => 'string', 'fieldType' => 'timePicker', 'default' => '00:00', 'helpText' => __('The start of the time window to connect to the CMS and download updates.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'downloadEndWindow', 'tabId' => 'general', 'title' => __('Download Window End Time'), 'type' => 'string', 'fieldType' => 'timePicker', 'default' => '00:00', 'helpText' => __('The end of the time window to connect to the CMS and download updates.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'statsEnabled', 'tabId' => 'general', 'title' => __('Enable stats reporting?'), 'type' => 'checkbox', 'fieldType' => 'checkbox', 'default' => 0, 'helpText' => __('Should the application send proof of play stats to the CMS.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'xmrNetworkAddress', 'tabId' => 'general', 'title' => __('XMR Public Address'), 'type' => 'string', 'fieldType' => 'text', 'default' => '', 'helpText' => __('Please enter the public address for XMR.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'sizeX', 'tabId' => 'location', 'title' => __('Width'), 'type' => 'double', 'fieldType' => 'number', 'default' => '0', 'helpText' => __('The Width of the Display Window. 0 means full width.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'sizeY', 'tabId' => 'location', 'title' => __('Height'), 'type' => 'double', 'fieldType' => 'number', 'default' => '0', 'helpText' => __('The Height of the Display Window. 0 means full height.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'offsetX', 'tabId' => 'location', 'title' => __('Left Coordinate'), 'type' => 'double', 'fieldType' => 'number', 'default' => '0', 'helpText' => __('The left pixel position the display window should be sized from.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'offsetY', 'tabId' => 'location', 'title' => __('Top Coordinate'), 'type' => 'double', 'fieldType' => 'number', 'default' => '0', 'helpText' => __('The top pixel position the display window should be sized from.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'logLevel', 'tabId' => 'trouble', 'title' => __('Log Level'), 'type' => 'string', 'fieldType' => 'dropdown', 'options' => array( array('id' => 'audit', 'value' => 'Audit'), array('id' => 'info', 'value' => 'Information'), array('id' => 'error', 'value' => 'Error'), array('id' => 'off', 'value' => 'Off') ), 'default' => 'error', 'helpText' => __('The logging level that should be recorded by the Player.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'enableShellCommands', 'tabId' => 'advanced', 'title' => __('Enable Shell Commands'), 'type' => 'checkbox', 'fieldType' => 'checkbox', 'default' => 0, 'helpText' => __('Enable the Shell Command module.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'expireModifiedLayouts', 'tabId' => 'advanced', 'title' => __('Expire Modified Layouts'), 'type' => 'checkbox', 'fieldType' => 'checkbox', 'default' => 1, 'helpText' => __('Expire Modified Layouts immediately on change. This means a layout can be cut during playback if it receives an update from the CMS'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'maxConcurrentDownloads', 'tabId' => 'advanced', 'title' => __('Maximum concurrent downloads'), 'type' => 'int', 'fieldType' => 'text', 'default' => '2', 'helpText' => __('The maximum number of concurrent downloads the client will attempt.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'shellCommandAllowList', 'tabId' => 'advanced', 'title' => __('Shell Command Allow List'), 'type' => 'string', 'fieldType' => 'text', 'default' => '', 'helpText' => __('Which shell commands should the client execute?'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'sendCurrentLayoutAsStatusUpdate', 'tabId' => 'advanced', 'title' => __('Notify current layout'), 'type' => 'checkbox', 'fieldType' => 'checkbox', 'default' => 0, 'helpText' => __('When enabled the client will send the current layout to the CMS each time it changes. Warning: This is bandwidth intensive and should be disabled unless on a LAN.'), 'enabled' => false, 'groupClass' => NULL ), array( 'name' => 'screenShotRequestInterval', 'tabId' => 'advanced', 'title' => __('Screen shot interval'), 'type' => 'int', 'fieldType' => 'number', 'default' => 0, 'helpText' => __('The duration between status screen shots in minutes. 0 to disable. Warning: This is bandwidth intensive.'), 'enabled' => false, 'groupClass' => NULL ), array( 'name' => 'screenShotSize', 'tabId' => 'advanced', 'title' => __('Screen Shot Size'), 'type' => 'int', 'fieldType' => 'number', 'default' => 200, 'helpText' => __('The size of the largest dimension. Empty or 0 means the screen size.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'maxLogFileUploads', 'tabId' => 'advanced', 'title' => __('Limit the number of log files uploaded concurrently'), 'type' => 'int', 'fieldType' => 'number', 'default' => 3, 'helpText' => __('The number of log files to upload concurrently. The lower the number the longer it will take, but the better for memory usage.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'embeddedServerPort', 'tabId' => 'advanced', 'title' => __('Embedded Web Server Port'), 'type' => 'int', 'fieldType' => 'number', 'default' => 9696, 'helpText' => __('The port number to use for the embedded web server on the Player. Only change this if there is a port conflict reported on the status screen.'), 'enabled' => true, 'groupClass' => NULL ), array( 'name' => 'preventSleep', 'tabId' => 'advanced', 'title' => __('Prevent Sleep?'), 'type' => 'checkbox', 'fieldType' => 'checkbox', 'default' => 1, 'helpText' => __('Stop the player PC power management from Sleeping the PC'), 'enabled' => true, 'groupClass' => NULL ) ]; }); } }