Skip to content

Commit

Permalink
SSP: add SSP widget.
Browse files Browse the repository at this point in the history
  • Loading branch information
dasgarner committed Aug 14, 2023
1 parent 44ba412 commit 9582ad3
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
35 changes: 35 additions & 0 deletions lib/Connector/XiboSspConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
use Xibo\Event\ConnectorDeletingEvent;
use Xibo\Event\ConnectorEnabledChangeEvent;
use Xibo\Event\MaintenanceRegularEvent;
use Xibo\Event\WidgetEditOptionRequestEvent;
use Xibo\Support\Exception\GeneralException;
use Xibo\Support\Exception\InvalidArgumentException;
use Xibo\Support\Exception\NotFoundException;
use Xibo\Support\Sanitizer\SanitizerInterface;

class XiboSspConnector implements ConnectorInterface
Expand Down Expand Up @@ -61,6 +63,7 @@ public function registerWithDispatcher(EventDispatcherInterface $dispatcher): Co
$dispatcher->addListener(MaintenanceRegularEvent::$NAME, [$this, 'onRegularMaintenance']);
$dispatcher->addListener(ConnectorDeletingEvent::$NAME, [$this, 'onDeleting']);
$dispatcher->addListener(ConnectorEnabledChangeEvent::$NAME, [$this, 'onEnabledChange']);
$dispatcher->addListener(WidgetEditOptionRequestEvent::$NAME, [$this, 'onWidgetEditOption']);
return $this;
}

Expand Down Expand Up @@ -500,5 +503,37 @@ public function onEnabledChange(ConnectorEnabledChangeEvent $event)
$event->getConfigService()->changeSetting('isAdspaceEnabled', $event->getConnector()->isEnabled);
}

public function onWidgetEditOption(WidgetEditOptionRequestEvent $event)
{
$this->getLogger()->debug('onWidgetEditOption');

// Pull the widget we're working with.
$widget = $event->getWidget();
if ($widget === null) {
throw new NotFoundException();
}

// We handle the dashboard widget and the property with id="type"
if ($widget->type === 'ssp' && $event->getPropertyId() === 'partnerId') {
// Pull in existing information
$partnerFilter = $event->getPropertyValue();
$options = $event->getOptions();

foreach ($this->getAvailablePartners() as $partnerId => $partner) {
if ((empty($partnerFilter) || $partnerId === $partnerFilter)
&& $this->getPartnerSetting($partnerId, 'enabled') == 1
) {
$options[] = [
'id' => $partnerId,
'type' => $partnerId,
'name' => $partner['name'],
];
}
}

$event->setOptions($options);
}
}

// </editor-fold>
}
41 changes: 41 additions & 0 deletions modules/ssp.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!--
~ Copyright (C) 2023 Xibo Signage Ltd
~
~ Xibo - Digital Signage - https://xibosignage.com
~
~ This file is part of Xibo.
~
~ Xibo is free software: you can redistribute it and/or modify
~ it under the terms of the GNU Affero General Public License as published by
~ the Free Software Foundation, either version 3 of the License, or
~ any later version.
~
~ Xibo is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU Affero General Public License for more details.
~
~ You should have received a copy of the GNU Affero General Public License
~ along with Xibo. If not, see <http://www.gnu.org/licenses/>.
-->
<module>
<id>core-ssp</id>
<name>SSP</name>
<author>Core</author>
<description>Manually schedule SSP content from the SSP connector via select partners.</description>
<type>ssp</type>
<dataType></dataType>
<schemaVersion>1</schemaVersion>
<assignable>1</assignable>
<regionSpecific>1</regionSpecific>
<renderAs>native</renderAs>
<defaultDuration>10</defaultDuration>
<settings></settings>
<properties>
<property id="partnerId" type="connectorProperties">
<title>Partner</title>
<helpText>Choose from the partners that support this type of scheduling.</helpText>
</property>
</properties>
<preview></preview>
</module>

0 comments on commit 9582ad3

Please sign in to comment.