Skip to content

Commit

Permalink
Merge pull request #2560 from xibosignage/develop
Browse files Browse the repository at this point in the history
Release 4.0.12
  • Loading branch information
dasgarner authored Jun 11, 2024
2 parents 33d8176 + 6e9f12e commit 129f92b
Show file tree
Hide file tree
Showing 110 changed files with 1,405 additions and 496 deletions.
13 changes: 3 additions & 10 deletions lib/Connector/OpenWeatherMapConnector.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
Expand Down Expand Up @@ -43,7 +43,6 @@ class OpenWeatherMapConnector implements ConnectorInterface
private $forecastCurrent = '2.5/weather';
private $forecast3Hourly = '2.5/forecast';
private $forecastDaily = '2.5/forecast/daily';
private $forecastCombined = '2.5/onecall';
private $forecastCombinedV3 = '3.0/onecall';
private $forecastUv = 'uvi';

Expand Down Expand Up @@ -195,14 +194,8 @@ private function getWeatherData(DataProviderInterface $dataProvider)
$cacheExpire->copy()->addDay()->startOfDay()
)['list'];
} else {
// We use one call
if (($this->getSetting('owmApiVersion') ?? '2.5') === '2.5') {
$forecastCombined = $this->forecastCombined;
} else {
$forecastCombined = $this->forecastCombinedV3;
}

$data = $this->queryApi($this->apiUrl . $forecastCombined . $url, $cacheExpire);
// We use one call API 3.0
$data = $this->queryApi($this->apiUrl . $this->forecastCombinedV3 . $url, $cacheExpire);

$this->timezone = $data['timezone'];

Expand Down
5 changes: 4 additions & 1 deletion lib/Controller/DataSet.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
Expand Down Expand Up @@ -1223,6 +1223,9 @@ public function import(Request $request, Response $response, $id)

$this->setNoOutput(true);

// Explicitly set the Content-Type header to application/json
$response = $response->withHeader('Content-Type', 'application/json');

return $this->render($request, $response);
}

Expand Down
5 changes: 4 additions & 1 deletion lib/Controller/Font.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
Expand Down Expand Up @@ -439,6 +439,9 @@ public function add(Request $request, Response $response)
// all done, refresh fonts.css
$this->getMediaService()->updateFontsCss();

// Explicitly set the Content-Type header to application/json
$response = $response->withHeader('Content-Type', 'application/json');

return $this->render($request, $response);
}

Expand Down
3 changes: 3 additions & 0 deletions lib/Controller/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -2578,6 +2578,9 @@ public function import(Request $request, Response $response)
// Hand off to the Upload Handler provided by jquery-file-upload
new LayoutUploadHandler($options);

// Explicitly set the Content-Type header to application/json
$response = $response->withHeader('Content-Type', 'application/json');

return $response;
}

Expand Down
22 changes: 18 additions & 4 deletions lib/Controller/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,9 @@ public function add(Request $request, Response $response)
// Hand off to the Upload Handler provided by jquery-file-upload
new XiboUploadHandler($options);

// Explicitly set the Content-Type header to application/json
$response = $response->withHeader('Content-Type', 'application/json');

return $this->render($request, $response);
}

Expand Down Expand Up @@ -1660,6 +1663,9 @@ public function download(Request $request, Response $response, $id)
}

/**
* Thumbnail for the libary page
* this is called by library-page datatable
*
* @SWG\Get(
* path="/library/thumbnail/{mediaId}",
* operationId="libraryThumbnail",
Expand Down Expand Up @@ -1699,19 +1705,23 @@ public function download(Request $request, Response $response, $id)
*/
public function thumbnail(Request $request, Response $response, $id)
{
$this->setNoOutput();

// We can download by mediaId or by mediaName.
if (is_numeric($id)) {
$media = $this->mediaFactory->getById($id);
} else {
$media = $this->mediaFactory->getByName($id);
}

$this->getLog()->debug('Thumbnail request for mediaId ' . $id
$this->getLog()->debug('thumbnail: Thumbnail request for mediaId ' . $id
. '. Media is a ' . $media->mediaType);

// Permissions.
if (!$this->getUser()->checkViewable($media)) {
throw new AccessDeniedException();
// Output a 1px image if we're not allowed to see the media.
echo Img::make($this->getConfig()->uri('img/1x1.png', true))->encode();
return $this->render($request, $response);
}

// Hand over to the widget downloader
Expand All @@ -1721,9 +1731,13 @@ public function thumbnail(Request $request, Response $response, $id)
$this->getConfig()->getSetting('DEFAULT_RESIZE_LIMIT', 6000)
);
$downloader->useLogger($this->getLog()->getLoggerInterface());
$response = $downloader->thumbnail($media, $response, $this->getConfig()->uri('img/error.png', true));

$this->setNoOutput(true);
$response = $downloader->thumbnail(
$media,
$response,
$this->getConfig()->uri('img/error.png', true)
);

return $this->render($request, $response);
}

Expand Down
35 changes: 11 additions & 24 deletions lib/Controller/MenuBoard.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,20 @@
use Xibo\Support\Exception\InvalidArgumentException;
use Xibo\Support\Exception\NotFoundException;

/**
* Menu Board Controller
*/
class MenuBoard extends Base
{
/**
* @var MenuBoardFactory
*/
private $menuBoardFactory;

/**
* @var UserFactory
*/
private $userFactory;

/**
* @var FolderFactory
*/
private $folderFactory;

/**
* Set common dependencies.
* @param MenuBoardFactory $menuBoardFactory
* @param UserFactory $userFactory
* @param FolderFactory $folderFactory
*/
public function __construct(
$menuBoardFactory,
$userFactory,
$folderFactory
private readonly MenuBoardFactory $menuBoardFactory,
private readonly FolderFactory $folderFactory
) {
$this->menuBoardFactory = $menuBoardFactory;
$this->userFactory = $userFactory;
$this->folderFactory = $folderFactory;
}

/**
Expand Down Expand Up @@ -329,11 +312,15 @@ public function add(Request $request, Response $response): Response
$this->checkRootFolderAllowSave();
}

if (empty($folderId) || $this->getUser()->featureEnabled('folder.view')) {
if (empty($folderId) || !$this->getUser()->featureEnabled('folder.view')) {
$folderId = $this->getUser()->homeFolderId;
}

$menuBoard = $this->menuBoardFactory->create($name, $description, $code, $folderId);
$folder = $this->folderFactory->getById($folderId, 0);

$menuBoard = $this->menuBoardFactory->create($name, $description, $code);
$menuBoard->folderId = $folder->getId();
$menuBoard->permissionsFolderId = $folder->getPermissionFolderIdOrThis();
$menuBoard->save();

// Return
Expand Down
5 changes: 4 additions & 1 deletion lib/Controller/Notification.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
Expand Down Expand Up @@ -420,6 +420,9 @@ public function addAttachment(Request $request, Response $response)
// Hand off to the Upload Handler provided by jquery-file-upload
new AttachmentUploadHandler($options);

// Explicitly set the Content-Type header to application/json
$response = $response->withHeader('Content-Type', 'application/json');

return $this->render($request, $response);
}

Expand Down
5 changes: 4 additions & 1 deletion lib/Controller/PlayerSoftware.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
Expand Down Expand Up @@ -645,6 +645,9 @@ public function add(Request $request, Response $response)

$uploadHandler->post();

// Explicitly set the Content-Type header to application/json
$response = $response->withHeader('Content-Type', 'application/json');

return $this->render($request, $response);
}

Expand Down
5 changes: 3 additions & 2 deletions lib/Controller/Preview.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php
/*
* Copyright (C) 2022 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
Expand Down Expand Up @@ -127,6 +127,7 @@ public function getXlf(Request $request, Response $response, $id)
// Release lock
$this->layoutFactory->concurrentRequestRelease($layout);
}

return $this->render($request, $response);
}

Expand Down
4 changes: 3 additions & 1 deletion lib/Controller/Task.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
Expand Down Expand Up @@ -472,6 +472,7 @@ public function run(Request $request, Response $response, $id)
. Carbon::now()->format(DateFormatHelper::getSystemFormat()));

$this->setNoOutput();

return $this->render($request, $response);
}

Expand Down Expand Up @@ -573,6 +574,7 @@ public function poll(Request $request, Response $response)

$this->getLog()->debug('XTR poll stopped');
$this->setNoOutput();

return $this->render($request, $response);
}

Expand Down
3 changes: 1 addition & 2 deletions lib/Dependencies/Controllers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/*
* Copyright (C) 2023 Xibo Signage Ltd
* Copyright (C) 2024 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
Expand Down Expand Up @@ -306,7 +306,6 @@ public static function registerControllersWithDi()
'\Xibo\Controller\MenuBoard' => function (ContainerInterface $c) {
$controller = new \Xibo\Controller\MenuBoard(
$c->get('menuBoardFactory'),
$c->get('userFactory'),
$c->get('folderFactory')
);
$controller->useBaseDependenciesService($c->get('ControllerBaseDependenciesService'));
Expand Down
8 changes: 8 additions & 0 deletions lib/Entity/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,10 @@ public function toXlf()
$this->config->getSetting('DEFAULT_TRANSITION_DURATION')
)
));
$optionsNode->appendChild($document->createElement(
'transInDirection',
$widget->getOptionValue('transInDirection', 'E')
));
}

$transOut = $widget->getOptionValue('transOut', null);
Expand All @@ -1715,6 +1719,10 @@ public function toXlf()
$this->config->getSetting('DEFAULT_TRANSITION_DURATION')
)
));
$optionsNode->appendChild($document->createElement(
'transOutDirection',
$widget->getOptionValue('transOutDirection', 'E')
));
}

// If we do not have an update interval, should we set a default one?
Expand Down
13 changes: 7 additions & 6 deletions lib/Factory/MenuBoardFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
use Xibo\Service\DisplayNotifyServiceInterface;
use Xibo\Support\Exception\NotFoundException;

/**
* Menu Board Factory
*/
class MenuBoardFactory extends BaseFactory
{
/** @var ConfigServiceInterface */
Expand Down Expand Up @@ -97,21 +100,19 @@ public function createEmpty()
}

/**
* Create a new action
* Create a new menuboard
* @param string $name
* @param string $description
* @param string $code
* @param int $folderId
* @param string|null $description
* @param string|null $code
* @return MenuBoard
*/
public function create($name, $description, $code, $folderId)
public function create(string $name, ?string $description, ?string $code): MenuBoard
{
$menuBoard = $this->createEmpty();
$menuBoard->name = $name;
$menuBoard->description = $description;
$menuBoard->code = $code;
$menuBoard->userId = $this->getUser()->userId;
$menuBoard->folderId = $folderId;

return $menuBoard;
}
Expand Down
19 changes: 15 additions & 4 deletions lib/Factory/ModuleFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,7 @@ public function determineCacheKey(
?WidgetProviderInterface $widgetInterface
): string {
// Determine the cache key
$cacheKey = null;
if ($widgetInterface !== null) {
$cacheKey = $widgetInterface->getDataCacheKey($dataProvider);
}
$cacheKey = $widgetInterface?->getDataCacheKey($dataProvider);

if ($cacheKey === null) {
// Determinthe cache key from the setting in XML.
Expand All @@ -165,6 +162,16 @@ public function determineCacheKey(
$module->decorateProperties($widget, true);
$properties = $module->getPropertyValues(false);

// Is display location in use?
// We should see if the display location property is set (this is a special property), and if it is
// update the lat/lng with the details stored on the display
$latitude = $properties['latitude'] ?? '';
$longitude = $properties['longitude'] ?? '';
if ($dataProvider->getProperty('useDisplayLocation') == 1) {
$latitude = $dataProvider->getDisplayLatitude() ?: $latitude;
$longitude = $dataProvider->getDisplayLongitude() ?: $longitude;
}

// Parse the cache key for variables.
$matches = [];
preg_match_all('/%(.*?)%/', $cacheKey, $matches);
Expand All @@ -173,6 +180,10 @@ public function determineCacheKey(
$cacheKey = str_replace('%displayId%', $displayId, $cacheKey);
} else if ($match === 'widgetId') {
$cacheKey = str_replace('%widgetId%', $widget->widgetId, $cacheKey);
} else if ($match === 'latitude') {
$cacheKey = str_replace('%latitude%', $latitude, $cacheKey);
} else if ($match === 'longitude') {
$cacheKey = str_replace('%longitude%', $longitude, $cacheKey);
} else {
$this->getLog()->debug($match);
$cacheKey = str_replace(
Expand Down
Loading

0 comments on commit 129f92b

Please sign in to comment.