Initial Upload
This commit is contained in:
76
lib/Widget/Compatibility/CalendarWidgetCompatibility.php
Normal file
76
lib/Widget/Compatibility/CalendarWidgetCompatibility.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
|
||||
/**
|
||||
* Convert a v3 calendar or calendaradvanced widget to its v4 counterpart.
|
||||
*/
|
||||
class CalendarWidgetCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
/** @inheritDoc */
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
// Track if we've been upgraded.
|
||||
$upgraded = false;
|
||||
|
||||
// Did we originally come from an agenda (the old calendar widget)
|
||||
if ($widget->getOriginalValue('type') === 'calendar') {
|
||||
$newTemplateId = 'event_custom_html';
|
||||
|
||||
// New options names.
|
||||
$widget->changeOption('template', 'text');
|
||||
} else {
|
||||
// We are a calendaradvanced
|
||||
// Calendar type is either 1=schedule, 2=daily, 3=weekly or 4=monthly.
|
||||
$newTemplateId = match ($widget->getOptionValue('calendarType', 1)) {
|
||||
2 => 'daily',
|
||||
3 => 'weekly',
|
||||
4 => 'monthly',
|
||||
default => 'schedule',
|
||||
};
|
||||
|
||||
// Apply the theme
|
||||
$newTemplateId .= '_' . $widget->getOptionValue('templateTheme', 'light');
|
||||
}
|
||||
|
||||
if (!empty($newTemplateId)) {
|
||||
$widget->setOptionValue('templateId', 'attrib', $newTemplateId);
|
||||
$upgraded = true;
|
||||
}
|
||||
|
||||
return $upgraded;
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
66
lib/Widget/Compatibility/ClockWidgetCompatibility.php
Normal file
66
lib/Widget/Compatibility/ClockWidgetCompatibility.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2024 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
|
||||
/**
|
||||
* Convert widget from an old schema to a new schema
|
||||
*/
|
||||
class ClockWidgetCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
/** @inheritdoc
|
||||
*/
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
// The old clock widget had a `clockTypeId` option which determines the template
|
||||
// we must make a choice here.
|
||||
$widget->type = match ($widget->getOptionValue('clockTypeId', 1)) {
|
||||
2 => 'clock-digital',
|
||||
3 => 'clock-flip',
|
||||
default => 'clock-analogue',
|
||||
};
|
||||
|
||||
// in v3 this option used to ba called theme, now it is themeId
|
||||
if ($widget->type === 'clock-analogue') {
|
||||
$widget->setOptionValue('themeId', 'attrib', $widget->getOptionValue('theme', 1));
|
||||
}
|
||||
|
||||
// We don't need the old options anymore
|
||||
$widget->removeOption('clockTypeId');
|
||||
$widget->removeOption('theme');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
71
lib/Widget/Compatibility/CountDownWidgetCompatibility.php
Normal file
71
lib/Widget/Compatibility/CountDownWidgetCompatibility.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
|
||||
/**
|
||||
* Convert widget from an old schema to a new schema
|
||||
*/
|
||||
class CountDownWidgetCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
/** @inheritdoc
|
||||
*/
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
$countdownType = $widget->getOptionValue('countdownType', 1);
|
||||
$overrideTemplate = $widget->getOptionValue('overrideTemplate', 0);
|
||||
|
||||
// Old countdown had countdownType.
|
||||
if ($overrideTemplate == 1) {
|
||||
$widget->type = 'countdown-custom';
|
||||
} else {
|
||||
$widget->type = match ($countdownType) {
|
||||
2 => 'countdown-clock',
|
||||
3 => 'countdown-table',
|
||||
4 => 'countdown-days',
|
||||
default => 'countdown-text',
|
||||
};
|
||||
}
|
||||
|
||||
// If overriden, we need to tranlate the legacy options to the new values
|
||||
if ($overrideTemplate == 1) {
|
||||
$widget->changeOption('widgetOriginalWidth', 'widgetDesignWidth');
|
||||
$widget->changeOption('widgetOriginalHeight', 'widgetDesignHeight');
|
||||
$widget->removeOption('templateId');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
66
lib/Widget/Compatibility/CurrenciesWidgetCompatibility.php
Normal file
66
lib/Widget/Compatibility/CurrenciesWidgetCompatibility.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
|
||||
/**
|
||||
* Convert widget from an old schema to a new schema
|
||||
*/
|
||||
class CurrenciesWidgetCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
/** @inheritdoc
|
||||
*/
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
$upgraded = false;
|
||||
$overrideTemplate = $widget->getOptionValue('overrideTemplate', 0);
|
||||
|
||||
// If the widget has override template
|
||||
if ($overrideTemplate == 1) {
|
||||
$widget->setOptionValue('templateId', 'attrib', 'currencies_custom_html');
|
||||
$upgraded = true;
|
||||
|
||||
// We need to tranlate the legacy options to the new values
|
||||
$widget->changeOption('widgetOriginalWidth', 'widgetDesignWidth');
|
||||
$widget->changeOption('widgetOriginalHeight', 'widgetDesignHeight');
|
||||
}
|
||||
|
||||
// We need to change duration per page to duration per item
|
||||
$widget->changeOption('durationIsPerPage', 'durationIsPerItem');
|
||||
|
||||
return $upgraded;
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
78
lib/Widget/Compatibility/DatasetWidgetCompatibility.php
Normal file
78
lib/Widget/Compatibility/DatasetWidgetCompatibility.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
|
||||
/**
|
||||
* Convert widget from an old schema to a new schema
|
||||
*/
|
||||
class DatasetWidgetCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
/** @inheritdoc
|
||||
*/
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
// Did we originally come from a dataset ticker?
|
||||
if ($widget->getOriginalValue('type') === 'datasetticker') {
|
||||
$newTemplateId = 'dataset_custom_html';
|
||||
$widget->changeOption('css', 'styleSheet');
|
||||
} else {
|
||||
if ($widget->getOptionValue('overrideTemplate', 0) == 0) {
|
||||
$newTemplateId = match ($widget->getOptionValue('templateId', '')) {
|
||||
'light-green' => 'dataset_table_2',
|
||||
'simple-round' => 'dataset_table_3',
|
||||
'transparent-blue' => 'dataset_table_4',
|
||||
'orange-grey-striped' => 'dataset_table_5',
|
||||
'split-rows' => 'dataset_table_6',
|
||||
'dark-round' => 'dataset_table_7',
|
||||
'pill-colored' => 'dataset_table_8',
|
||||
default => 'dataset_table_1',
|
||||
};
|
||||
} else {
|
||||
$newTemplateId = 'dataset_table_custom_html';
|
||||
}
|
||||
|
||||
// We have changed the format of columns to be an array in v4.
|
||||
$columns = $widget->getOptionValue('columns', '');
|
||||
if (!empty($columns)) {
|
||||
$widget->setOptionValue('columns', 'attrib', '[' . $columns . ']');
|
||||
}
|
||||
}
|
||||
|
||||
$widget->setOptionValue('templateId', 'attrib', $newTemplateId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
52
lib/Widget/Compatibility/NotificationViewCompatibility.php
Normal file
52
lib/Widget/Compatibility/NotificationViewCompatibility.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
|
||||
class NotificationViewCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
$upgraded = false;
|
||||
|
||||
if ($fromSchema <= 1) {
|
||||
// Add a templateId.
|
||||
$widget->setOptionValue('templateId', 'attrib', 'message_custom_html');
|
||||
$upgraded = true;
|
||||
}
|
||||
|
||||
return $upgraded;
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
157
lib/Widget/Compatibility/RssWidgetCompatibility.php
Normal file
157
lib/Widget/Compatibility/RssWidgetCompatibility.php
Normal file
@@ -0,0 +1,157 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
|
||||
/**
|
||||
* Convert RSS old kebab-case properties to camelCase
|
||||
*/
|
||||
class RssWidgetCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
/** @inheritdoc
|
||||
*/
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
// Decode URL (always make sure we save URLs decoded)
|
||||
$widget->setOptionValue('uri', 'attrib', urldecode($widget->getOptionValue('uri', '')));
|
||||
|
||||
// Swap to new template names.
|
||||
$overrideTemplate = $widget->getOptionValue('overrideTemplate', 0);
|
||||
|
||||
if ($overrideTemplate) {
|
||||
$newTemplateId = 'article_custom_html';
|
||||
} else {
|
||||
$newTemplateId = match ($widget->getOptionValue('templateId', '')) {
|
||||
'media-rss-image-only' => 'article_image_only',
|
||||
'media-rss-with-left-hand-text' => 'article_with_left_hand_text',
|
||||
'media-rss-with-title' => 'article_with_title',
|
||||
'prominent-title-with-desc-and-name-separator' => 'article_with_desc_and_name_separator',
|
||||
default => 'article_title_only',
|
||||
};
|
||||
|
||||
// If template id is "article_with_desc_and_name_separator"
|
||||
// set showSideBySide to 1 to replicate behaviour in v3 for marquee
|
||||
$effect = $widget->getOptionValue('effect', null);
|
||||
if (
|
||||
$newTemplateId === 'article_with_desc_and_name_separator' &&
|
||||
$effect === 'marqueeLeft' ||
|
||||
$effect === 'marqueeRight' ||
|
||||
$effect === 'marqueeUp' ||
|
||||
$effect === 'marqueeDown'
|
||||
) {
|
||||
$widget->setOptionValue('showSideBySide', 'attrib', 1);
|
||||
}
|
||||
}
|
||||
$widget->setOptionValue('templateId', 'attrib', $newTemplateId);
|
||||
|
||||
// If the new templateId is custom, we need to parse the old template for image enclosures
|
||||
if ($newTemplateId === 'article_custom_html') {
|
||||
$template = $widget->getOptionValue('template', null);
|
||||
if (!empty($template)) {
|
||||
$modified = false;
|
||||
$matches = [];
|
||||
preg_match_all('/\[(.*?)\]/', $template, $matches);
|
||||
|
||||
for ($i = 0; $i < count($matches[1]); $i++) {
|
||||
// We have a [Link] or a [xxx|image] tag
|
||||
$match = $matches[1][$i];
|
||||
if ($match === 'Link' || $match === 'Link|image') {
|
||||
// This is a straight-up enclosure (which is the default).
|
||||
$template = str_replace($matches[0][$i], '<img src="[image]" alt="Image" />', $template);
|
||||
$modified = true;
|
||||
} else if (str_contains($match, '|image')) {
|
||||
// [tag|image|attribute]
|
||||
// Set the necessary options depending on how our tag is made up
|
||||
$parts = explode('|', $match);
|
||||
$tag = $parts[0];
|
||||
$attribute = $parts[2] ?? null;
|
||||
|
||||
$widget->setOptionValue('imageSource', 'attrib', 'custom');
|
||||
$widget->setOptionValue('imageSourceTag', 'attrib', $tag);
|
||||
if (!empty($attribute)) {
|
||||
$widget->setOptionValue('imageSourceAttribute', 'attrib', $attribute);
|
||||
}
|
||||
|
||||
$template = str_replace($matches[0][$i], '<img src="[image]" alt="Image"/>', $template);
|
||||
$modified = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($modified) {
|
||||
$widget->setOptionValue('template', 'cdata', $template);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change some other options if they have been set.
|
||||
foreach ($widget->widgetOptions as $option) {
|
||||
$widgetChangeOption = null;
|
||||
switch ($option->option) {
|
||||
case 'background-color':
|
||||
$widgetChangeOption = 'itemBackgroundColor';
|
||||
break;
|
||||
|
||||
case 'title-color':
|
||||
$widgetChangeOption = 'itemTitleColor';
|
||||
break;
|
||||
|
||||
case 'name-color':
|
||||
$widgetChangeOption = 'itemNameColor';
|
||||
break;
|
||||
|
||||
case 'description-color':
|
||||
$widgetChangeOption = 'itemDescriptionColor';
|
||||
break;
|
||||
|
||||
case 'font-size':
|
||||
$widgetChangeOption = 'itemFontSize';
|
||||
break;
|
||||
|
||||
case 'image-fit':
|
||||
$widgetChangeOption = 'itemImageFit';
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($widgetChangeOption)) {
|
||||
$widget->changeOption($option->option, $widgetChangeOption);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
77
lib/Widget/Compatibility/SocialMediaWidgetCompatibility.php
Normal file
77
lib/Widget/Compatibility/SocialMediaWidgetCompatibility.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
|
||||
/**
|
||||
* Convert widget from an old schema to a new schema
|
||||
*/
|
||||
class SocialMediaWidgetCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
/** @inheritdoc
|
||||
*/
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
$overrideTemplate = $widget->getOptionValue('overrideTemplate', 0);
|
||||
if ($overrideTemplate == 1) {
|
||||
$newTemplateId = 'social_media_custom_html';
|
||||
} else {
|
||||
$newTemplateId = match ($widget->getOptionValue('templateId', '')) {
|
||||
'full-timeline-np' => 'social_media_static_1',
|
||||
'full-timeline' => 'social_media_static_2',
|
||||
'tweet-with-profileimage-left' => 'social_media_static_4',
|
||||
'tweet-with-profileimage-right' => 'social_media_static_5',
|
||||
'tweet-1' => 'social_media_static_6',
|
||||
'tweet-2' => 'social_media_static_7',
|
||||
'tweet-4' => 'social_media_static_8',
|
||||
'tweet-6NP' => 'social_media_static_9',
|
||||
'tweet-6PL' => 'social_media_static_10',
|
||||
'tweet-7' => 'social_media_static_11',
|
||||
'tweet-8' => 'social_media_static_12',
|
||||
default => 'social_media_static_3',
|
||||
};
|
||||
}
|
||||
$widget->setOptionValue('templateId', 'attrib', $newTemplateId);
|
||||
|
||||
// If overriden, we need to tranlate the legacy options to the new values
|
||||
if ($overrideTemplate == 1) {
|
||||
$widget->changeOption('widgetOriginalWidth', 'widgetDesignWidth');
|
||||
$widget->changeOption('widgetOriginalHeight', 'widgetDesignHeight');
|
||||
$widget->changeOption('widgetOriginalPadding', 'widgetDesignGap');
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
66
lib/Widget/Compatibility/StocksWidgetCompatibility.php
Normal file
66
lib/Widget/Compatibility/StocksWidgetCompatibility.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
|
||||
/**
|
||||
* Convert widget from an old schema to a new schema
|
||||
*/
|
||||
class StocksWidgetCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
/** @inheritdoc
|
||||
*/
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
$upgraded = false;
|
||||
$overrideTemplate = $widget->getOptionValue('overrideTemplate', 0);
|
||||
|
||||
// If the widget has override template
|
||||
if ($overrideTemplate == 1) {
|
||||
$widget->setOptionValue('templateId', 'attrib', 'stocks_custom_html');
|
||||
$upgraded = true;
|
||||
|
||||
// We need to tranlate the legacy options to the new values
|
||||
$widget->changeOption('widgetOriginalWidth', 'widgetDesignWidth');
|
||||
$widget->changeOption('widgetOriginalHeight', 'widgetDesignHeight');
|
||||
}
|
||||
|
||||
// We need to change duration per page to duration per item
|
||||
$widget->changeOption('durationIsPerPage', 'durationIsPerItem');
|
||||
|
||||
return $upgraded;
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
109
lib/Widget/Compatibility/SubPlaylistWidgetCompatibility.php
Normal file
109
lib/Widget/Compatibility/SubPlaylistWidgetCompatibility.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
use Xibo\Widget\SubPlaylistItem;
|
||||
|
||||
/**
|
||||
* Convert widget from an old schema to a new schema
|
||||
*/
|
||||
class SubPlaylistWidgetCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
/** @inheritdoc
|
||||
*/
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
$upgraded = false;
|
||||
$playlists = [];
|
||||
$playlistIds = [];
|
||||
|
||||
// subPlaylistOptions and subPlaylistIds are no longer in use from 2.3
|
||||
// we need to capture these options to support Layout with sub-playlist import from older CMS
|
||||
foreach ($widget->widgetOptions as $option) {
|
||||
if ($option->option === 'subPlaylists') {
|
||||
$playlists = json_decode($widget->getOptionValue('subPlaylists', '[]'), true);
|
||||
}
|
||||
|
||||
if ($option->option === 'subPlaylistIds') {
|
||||
$playlistIds = json_decode($widget->getOptionValue('subPlaylistIds', '[]'), true);
|
||||
}
|
||||
|
||||
if ($option->option === 'subPlaylistOptions') {
|
||||
$subPlaylistOptions = json_decode($widget->getOptionValue('subPlaylistOptions', '[]'), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($playlists) <= 0) {
|
||||
$i = 0;
|
||||
foreach ($playlistIds as $playlistId) {
|
||||
$i++;
|
||||
$playlists[] = [
|
||||
'rowNo' => $i,
|
||||
'playlistId' => $playlistId,
|
||||
'spotFill' => $subPlaylistOptions[$playlistId]['subPlaylistIdSpotFill'] ?? null,
|
||||
'spotLength' => $subPlaylistOptions[$playlistId]['subPlaylistIdSpotLength'] ?? null,
|
||||
'spots' => $subPlaylistOptions[$playlistId]['subPlaylistIdSpots'] ?? null,
|
||||
];
|
||||
}
|
||||
|
||||
$playlistItems = [];
|
||||
foreach ($playlists as $playlist) {
|
||||
$item = new SubPlaylistItem();
|
||||
$item->rowNo = intval($playlist['rowNo']);
|
||||
$item->playlistId = $playlist['playlistId'];
|
||||
$item->spotFill = $playlist['spotFill'] ?? '';
|
||||
$item->spotLength = $playlist['spotLength'] !== '' ? intval($playlist['spotLength']) : '';
|
||||
$item->spots = $playlist['spots'] !== '' ? intval($playlist['spots']) : '';
|
||||
|
||||
$playlistItems[] = $item;
|
||||
}
|
||||
|
||||
if (count($playlistItems) > 0) {
|
||||
$widget->setOptionValue('subPlaylists', 'attrib', json_encode($playlistItems));
|
||||
$widget->removeOption('subPlaylistIds');
|
||||
$widget->removeOption('subPlaylistOptions');
|
||||
$upgraded = true;
|
||||
}
|
||||
} else {
|
||||
$this->getLog()->debug(
|
||||
'upgradeWidget : subplaylist ' . $widget->widgetId .
|
||||
' with already updated widget options, save to update schema version'
|
||||
);
|
||||
$upgraded = true;
|
||||
}
|
||||
|
||||
return $upgraded;
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
100
lib/Widget/Compatibility/WeatherWidgetCompatibility.php
Normal file
100
lib/Widget/Compatibility/WeatherWidgetCompatibility.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
|
||||
/**
|
||||
* Convert widget from an old schema to a new schema
|
||||
*/
|
||||
class WeatherWidgetCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
/** @inheritdoc
|
||||
*/
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
$overrideTemplate = $widget->getOptionValue('overrideTemplate', 0);
|
||||
if ($overrideTemplate == 1) {
|
||||
$newTemplateId = 'weather_custom_html';
|
||||
} else {
|
||||
$newTemplateId = match ($widget->getOptionValue('templateId', '')) {
|
||||
'weather-module0-singleday' => 'weather_2',
|
||||
'weather-module0-singleday2' => 'weather_3',
|
||||
'weather-module1l' => 'weather_4',
|
||||
'weather-module1p' => 'weather_5',
|
||||
'weather-module2l' => 'weather_6',
|
||||
'weather-module2p' => 'weather_7',
|
||||
'weather-module3l' => 'weather_8',
|
||||
'weather-module3p' => 'weather_9',
|
||||
'weather-module4l' => 'weather_10',
|
||||
'weather-module4p' => 'weather_11',
|
||||
'weather-module5l' => 'weather_12',
|
||||
'weather-module6h' => 'weather_13',
|
||||
'weather-module6v' => 'weather_14',
|
||||
'weather-module-7s' => 'weather_15',
|
||||
'weather-module-8s' => 'weather_16',
|
||||
'weather-module-9' => 'weather_17',
|
||||
'weather-module-10l' => 'weather_18',
|
||||
default => 'weather_1',
|
||||
};
|
||||
}
|
||||
$widget->setOptionValue('templateId', 'attrib', $newTemplateId);
|
||||
|
||||
// If overriden, we need to tranlate the legacy options to the new values
|
||||
if ($overrideTemplate == 1) {
|
||||
$widget->changeOption('widgetOriginalWidth', 'widgetDesignWidth');
|
||||
$widget->changeOption('widgetOriginalHeight', 'widgetDesignHeight');
|
||||
}
|
||||
|
||||
// Process the background image properties so that they are removed if empty
|
||||
$this->removeOptionIfEquals($widget, 'cloudy-image');
|
||||
$this->removeOptionIfEquals($widget, 'day-cloudy-image');
|
||||
$this->removeOptionIfEquals($widget, 'day-sunny-image');
|
||||
$this->removeOptionIfEquals($widget, 'fog-image');
|
||||
$this->removeOptionIfEquals($widget, 'hail-image');
|
||||
$this->removeOptionIfEquals($widget, 'night-clear-image');
|
||||
$this->removeOptionIfEquals($widget, 'night-partly-cloudy-image');
|
||||
$this->removeOptionIfEquals($widget, 'rain-image');
|
||||
$this->removeOptionIfEquals($widget, 'snow-image');
|
||||
$this->removeOptionIfEquals($widget, 'windy-image');
|
||||
return true;
|
||||
}
|
||||
|
||||
private function removeOptionIfEquals(Widget $widget, string $option): void
|
||||
{
|
||||
if ($widget->getOptionValue($option, null) === $option) {
|
||||
$widget->removeOption($option);
|
||||
}
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
78
lib/Widget/Compatibility/WorldClockWidgetCompatibility.php
Normal file
78
lib/Widget/Compatibility/WorldClockWidgetCompatibility.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
/*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
namespace Xibo\Widget\Compatibility;
|
||||
|
||||
use Xibo\Entity\Widget;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityInterface;
|
||||
use Xibo\Widget\Provider\WidgetCompatibilityTrait;
|
||||
|
||||
/**
|
||||
* Convert widget from an old schema to a new schema
|
||||
*/
|
||||
class WorldClockWidgetCompatibility implements WidgetCompatibilityInterface
|
||||
{
|
||||
use WidgetCompatibilityTrait;
|
||||
|
||||
/** @inheritdoc
|
||||
*/
|
||||
public function upgradeWidget(Widget $widget, int $fromSchema, int $toSchema): bool
|
||||
{
|
||||
$this->getLog()->debug('upgradeWidget: ' . $widget->getId() . ' from: ' . $fromSchema . ' to: ' . $toSchema);
|
||||
|
||||
$overrideTemplate = $widget->getOptionValue('overrideTemplate', 0);
|
||||
if ($overrideTemplate) {
|
||||
$widget->type = 'worldclock-digital-custom';
|
||||
} else {
|
||||
$widget->type = match ($widget->getOptionValue('clockType', 1)) {
|
||||
2 => 'worldclock-analogue',
|
||||
default => match ($widget->getOptionValue('templateId', '')) {
|
||||
'worldclock1' => 'worldclock-digital-text',
|
||||
'worldclock2' => 'worldclock-digital-date',
|
||||
default => 'worldclock-digital-custom',
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
// We need to tranlate the legacy options to the new values
|
||||
$widget->changeOption('clockCols', 'numCols');
|
||||
$widget->changeOption('clockRows', 'numRows');
|
||||
|
||||
if ($overrideTemplate == 1) {
|
||||
$widget->changeOption('mainTemplate', 'template_html');
|
||||
$widget->changeOption('styleSheet', 'template_style');
|
||||
$widget->changeOption('widgetOriginalWidth', 'widgetDesignWidth');
|
||||
$widget->changeOption('widgetOriginalHeight', 'widgetDesignHeight');
|
||||
}
|
||||
|
||||
// Always remove template id / clockType from world clock
|
||||
$widget->removeOption('templateId');
|
||||
$widget->removeOption('clockType');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function saveTemplate(string $template, string $fileName): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user