aboutsummaryrefslogtreecommitdiffstats
path: root/lib/public/Dashboard/Model
diff options
context:
space:
mode:
Diffstat (limited to 'lib/public/Dashboard/Model')
-rw-r--r--lib/public/Dashboard/Model/IWidgetConfig.php127
-rw-r--r--lib/public/Dashboard/Model/IWidgetRequest.php137
-rw-r--r--lib/public/Dashboard/Model/WidgetButton.php77
-rw-r--r--lib/public/Dashboard/Model/WidgetItem.php63
-rw-r--r--lib/public/Dashboard/Model/WidgetItems.php81
-rw-r--r--lib/public/Dashboard/Model/WidgetOptions.php46
-rw-r--r--lib/public/Dashboard/Model/WidgetSetting.php243
-rw-r--r--lib/public/Dashboard/Model/WidgetSetup.php274
-rw-r--r--lib/public/Dashboard/Model/WidgetTemplate.php326
9 files changed, 239 insertions, 1135 deletions
diff --git a/lib/public/Dashboard/Model/IWidgetConfig.php b/lib/public/Dashboard/Model/IWidgetConfig.php
deleted file mode 100644
index b117660c441..00000000000
--- a/lib/public/Dashboard/Model/IWidgetConfig.php
+++ /dev/null
@@ -1,127 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Maxence Lange <maxence@artificial-owl.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program 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 (at your option) any later version.
- *
- * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCP\Dashboard\Model;
-
-use OCP\Dashboard\IDashboardWidget;
-
-/**
- * Interface IWidgetConfig
- *
- * This object contains the configuration of a widget for a userId
- *
- * @see IDashboardWidget::loadWidget
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- */
-interface IWidgetConfig {
-
-
- /**
- * Returns the userId
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getUserId(): string;
-
-
- /**
- * Returns the widgetId
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getWidgetId(): string;
-
-
- /**
- * Returns the current position and the current size of the widget as
- * displayed on the user's dashboard
- *
- * The returned value is an array:
- * [
- * 'x' => (int) position on the X axis,
- * 'y' => (int) position on the Y axis,
- * 'width' => (int) width of the widget,
- * 'height' => (int) height of the widget
- * ]
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return array
- */
- public function getPosition(): array;
-
-
- /**
- * Returns an array with the settings defined by the user for the widget.
- * The returned value is an array, with setting used as keys:
- *
- * [
- * 'setting1' => 'any value',
- * 'setting2' => 'other value'
- * ]
- *
- * Each setting that can be edited by a user should be defined in a
- * WidgetSetting.
- *
- * @see WidgetSetting
- *
- * Those WidgetSetting are in the WidgetTemplate defined during the setup
- * of the widget in the IDashboardWidget.
- *
- * @see IDashboardWidget::getWidgetTemplate
- * @see WidgetTemplate
- *
- * When using this framework, the settings interface is generated by the
- * Dashboard app.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return array
- */
- public function getSettings(): array;
-
-
- /**
- * Returns if the widget is enabled/displayed in this user's dashboard.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return bool
- */
- public function isEnabled(): bool;
-}
diff --git a/lib/public/Dashboard/Model/IWidgetRequest.php b/lib/public/Dashboard/Model/IWidgetRequest.php
deleted file mode 100644
index 73fe5fc5c2c..00000000000
--- a/lib/public/Dashboard/Model/IWidgetRequest.php
+++ /dev/null
@@ -1,137 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Maxence Lange <maxence@artificial-owl.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program 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 (at your option) any later version.
- *
- * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCP\Dashboard\Model;
-
-use OCP\Dashboard\IDashboardWidget;
-
-/**
- * Interface IWidgetRequest
- *
- * WidgetRequest are created by the Dashboard App and used to communicate from
- * the frontend to the backend.
- * The object is send to the WidgetClass using IDashboardWidget::requestWidget
- *
- * @see IDashboardWidget::requestWidget
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- */
-interface IWidgetRequest {
-
- /**
- * Get the widgetId.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getWidgetId(): string;
-
-
- /**
- * Get the WidgetClass.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return IDashboardWidget
- */
- public function getWidget(): IDashboardWidget;
-
-
- /**
- * Get the 'request' string sent by the request from the front-end with
- * the format:
- *
- * net.requestWidget(
- * {
- * widget: widgetId,
- * request: request,
- * value: value
- * },
- * callback);
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getRequest(): string;
-
-
- /**
- * Get the 'value' string sent by the request from the front-end.
- *
- * @see getRequest
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getValue(): string;
-
-
- /**
- * Returns the result.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return array
- */
- public function getResult(): array;
-
-
- /**
- * add a result (as string)
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $key
- * @param string $result
- *
- * @return $this
- */
- public function addResult(string $key, string $result): IWidgetRequest;
-
- /**
- * add a result (as array)
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $key
- * @param array $result
- *
- * @return $this
- */
- public function addResultArray(string $key, array $result): IWidgetRequest;
-}
diff --git a/lib/public/Dashboard/Model/WidgetButton.php b/lib/public/Dashboard/Model/WidgetButton.php
new file mode 100644
index 00000000000..1c9ea6266a9
--- /dev/null
+++ b/lib/public/Dashboard/Model/WidgetButton.php
@@ -0,0 +1,77 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Dashboard\Model;
+
+/**
+ * Button for a dashboard widget
+ *
+ * @since 25.0.0
+ */
+class WidgetButton {
+ /**
+ * @since 25.0.0
+ */
+ public const TYPE_NEW = 'new';
+
+ /**
+ * @since 25.0.0
+ */
+ public const TYPE_MORE = 'more';
+
+ /**
+ * @since 25.0.0
+ */
+ public const TYPE_SETUP = 'setup';
+
+ private string $type;
+ private string $link;
+ private string $text;
+
+ /**
+ * @param string $type
+ * @param string $link
+ * @param string $text
+ * @since 25.0.0
+ */
+ public function __construct(string $type, string $link, string $text) {
+ $this->type = $type;
+ $this->link = $link;
+ $this->text = $text;
+ }
+
+ /**
+ * Get the button type, either "new", "more" or "setup"
+ *
+ * @return string
+ * @since 25.0.0
+ */
+ public function getType(): string {
+ return $this->type;
+ }
+
+ /**
+ * Get the absolute url the buttons links to
+ *
+ * @return string
+ * @since 25.0.0
+ */
+ public function getLink(): string {
+ return $this->link;
+ }
+
+ /**
+ * Get the translated text for the button
+ *
+ * @return string
+ * @since 25.0.0
+ */
+ public function getText(): string {
+ return $this->text;
+ }
+}
diff --git a/lib/public/Dashboard/Model/WidgetItem.php b/lib/public/Dashboard/Model/WidgetItem.php
index 2bea9b93226..680daf1b114 100644
--- a/lib/public/Dashboard/Model/WidgetItem.php
+++ b/lib/public/Dashboard/Model/WidgetItem.php
@@ -3,25 +3,8 @@
declare(strict_types=1);
/**
- * @copyright 2021, Julien Veyssier <eneiluj@posteo.net>
- *
- * @author Julien Veyssier <eneiluj@posteo.net>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program 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 (at your option) any later version.
- *
- * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCP\Dashboard\Model;
@@ -33,7 +16,7 @@ use JsonSerializable;
*
* This class is used by IAPIWidget interface.
* It represents an widget item data that can be provided to clients via the Dashboard API
- * @see IAPIWidget::getWidgetItems
+ * @see IAPIWidget::getItems
*
* @since 22.0.0
*
@@ -56,24 +39,30 @@ final class WidgetItem implements JsonSerializable {
*/
private $sinceId = '';
+ /**
+ * Overlay icon to show in the bottom right corner of {@see $iconUrl}
+ *
+ * @since 27.1.0
+ */
+ private string $overlayIconUrl = '';
/**
* WidgetItem constructor
*
* @since 22.0.0
- *
- * @param string $type
*/
public function __construct(string $title = '',
- string $subtitle = '',
- string $link = '',
- string $iconUrl = '',
- string $sinceId = '') {
+ string $subtitle = '',
+ string $link = '',
+ string $iconUrl = '',
+ string $sinceId = '',
+ string $overlayIconUrl = '') {
$this->title = $title;
$this->subtitle = $subtitle;
$this->iconUrl = $iconUrl;
$this->link = $link;
$this->sinceId = $sinceId;
+ $this->overlayIconUrl = $overlayIconUrl;
}
/**
@@ -133,9 +122,26 @@ final class WidgetItem implements JsonSerializable {
}
/**
- * @since 22.0.0
+ * Get the overlay icon url
+ *
+ * @since 27.1.0
*
- * @return array
+ * @return string
+ */
+ public function getOverlayIconUrl(): string {
+ return $this->overlayIconUrl;
+ }
+
+ /**
+ * @since 22.0.0
+ * @return array{
+ * subtitle: string,
+ * title: string,
+ * link: string,
+ * iconUrl: string,
+ * overlayIconUrl: string,
+ * sinceId: string,
+ * }
*/
public function jsonSerialize(): array {
return [
@@ -143,6 +149,7 @@ final class WidgetItem implements JsonSerializable {
'title' => $this->getTitle(),
'link' => $this->getLink(),
'iconUrl' => $this->getIconUrl(),
+ 'overlayIconUrl' => $this->getOverlayIconUrl(),
'sinceId' => $this->getSinceId(),
];
}
diff --git a/lib/public/Dashboard/Model/WidgetItems.php b/lib/public/Dashboard/Model/WidgetItems.php
new file mode 100644
index 00000000000..87491175964
--- /dev/null
+++ b/lib/public/Dashboard/Model/WidgetItems.php
@@ -0,0 +1,81 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+namespace OCP\Dashboard\Model;
+
+use JsonSerializable;
+use OCP\Dashboard\IAPIWidgetV2;
+
+/**
+ * Interface WidgetItems
+ *
+ * This class is used by {@see IAPIWidgetV2} interface.
+ * It represents an array of widget items and additional context information that can be provided to clients via the Dashboard API
+ *
+ * @see IAPIWidgetV2::getItemsV2
+ *
+ * @since 27.1.0
+ */
+class WidgetItems implements JsonSerializable {
+ /**
+ * @param $items WidgetItem[]
+ *
+ * @since 27.1.0
+ */
+ public function __construct(
+ private array $items = [],
+ private string $emptyContentMessage = '',
+ private string $halfEmptyContentMessage = '',
+ ) {
+ }
+
+ /**
+ * Items to render in the widgets
+ *
+ * @since 27.1.0
+ *
+ * @return WidgetItem[]
+ */
+ public function getItems(): array {
+ return $this->items;
+ }
+
+ /**
+ * The "half" empty content message to show above the list of items.
+ *
+ * A non-empty string enables this feature.
+ * An empty string hides the message and disables this feature.
+ *
+ * @since 27.1.0
+ */
+ public function getEmptyContentMessage(): string {
+ return $this->emptyContentMessage;
+ }
+
+ /**
+ * The empty content message to show in case of no items at all
+ *
+ * @since 27.1.0
+ */
+ public function getHalfEmptyContentMessage(): string {
+ return $this->halfEmptyContentMessage;
+ }
+
+ /**
+ * @since 27.1.0
+ */
+ public function jsonSerialize(): array {
+ $items = array_map(static function (WidgetItem $item) {
+ return $item->jsonSerialize();
+ }, $this->getItems());
+ return [
+ 'items' => $items,
+ 'emptyContentMessage' => $this->getEmptyContentMessage(),
+ 'halfEmptyContentMessage' => $this->getHalfEmptyContentMessage(),
+ ];
+ }
+}
diff --git a/lib/public/Dashboard/Model/WidgetOptions.php b/lib/public/Dashboard/Model/WidgetOptions.php
new file mode 100644
index 00000000000..7d0f567ca15
--- /dev/null
+++ b/lib/public/Dashboard/Model/WidgetOptions.php
@@ -0,0 +1,46 @@
+<?php
+
+declare(strict_types=1);
+/**
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+namespace OCP\Dashboard\Model;
+
+/**
+ * Option for displaying a widget
+ *
+ * @since 25.0.0
+ */
+class WidgetOptions {
+ private bool $roundItemIcons;
+
+ /**
+ * @param bool $roundItemIcons
+ * @since 25.0.0
+ */
+ public function __construct(bool $roundItemIcons) {
+ $this->roundItemIcons = $roundItemIcons;
+ }
+
+ /**
+ * Get the default set of options
+ *
+ * @return WidgetOptions
+ * @since 25.0.0
+ */
+ public static function getDefault(): WidgetOptions {
+ return new WidgetOptions(false);
+ }
+
+ /**
+ * Whether the clients should render icons for widget items as round icons
+ *
+ * @return bool
+ * @since 25.0.0
+ */
+ public function withRoundItemIcons(): bool {
+ return $this->roundItemIcons;
+ }
+}
diff --git a/lib/public/Dashboard/Model/WidgetSetting.php b/lib/public/Dashboard/Model/WidgetSetting.php
deleted file mode 100644
index fce59a4350b..00000000000
--- a/lib/public/Dashboard/Model/WidgetSetting.php
+++ /dev/null
@@ -1,243 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Maxence Lange <maxence@artificial-owl.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program 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 (at your option) any later version.
- *
- * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCP\Dashboard\Model;
-
-use JsonSerializable;
-
-/**
- * Interface WidgetSetting
- *
- * Each setting that can be edited by a user should be defined in a
- * WidgetSetting.
- *
- * When using this framework, the settings interface is generated by the
- * Dashboard app.
- *
- * Each WidgetSetting must be generated and declared in the WidgetTemplate
- * during the setup of the widget in the IDashboardWidget using addSetting().
- *
- * @see IDashboardWidget::getWidgetTemplate
- * @see WidgetTemplate::addSetting
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- */
-final class WidgetSetting implements JsonSerializable {
- public const TYPE_INPUT = 'input';
- public const TYPE_CHECKBOX = 'checkbox';
-
-
- /** @var string */
- private $name = '';
-
- /** @var string */
- private $title = '';
-
- /** @var string */
- private $type = '';
-
- /** @var string */
- private $placeholder = '';
-
- /** @var string */
- private $default = '';
-
-
- /**
- * WidgetSetting constructor.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $type
- */
- public function __construct(string $type = '') {
- $this->type = $type;
- }
-
-
- /**
- * Set the name of the setting (full string, no space)
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $name
- *
- * @return WidgetSetting
- */
- public function setName(string $name): WidgetSetting {
- $this->name = $name;
-
- return $this;
- }
-
- /**
- * Get the name of the setting
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getName(): string {
- return $this->name;
- }
-
-
- /**
- * Set the title/display name of the setting.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $title
- *
- * @return WidgetSetting
- */
- public function setTitle(string $title): WidgetSetting {
- $this->title = $title;
-
- return $this;
- }
-
- /**
- * Get the title of the setting
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getTitle(): string {
- return $this->title;
- }
-
-
- /**
- * Set the type of the setting (input, checkbox, ...)
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $type
- *
- * @return WidgetSetting
- */
- public function setType(string $type): WidgetSetting {
- $this->type = $type;
-
- return $this;
- }
-
- /**
- * Get the type of the setting.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getType(): string {
- return $this->type;
- }
-
-
- /**
- * Set the placeholder (in case of type=input)
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $text
- *
- * @return WidgetSetting
- */
- public function setPlaceholder(string $text): WidgetSetting {
- $this->placeholder = $text;
-
- return $this;
- }
-
- /**
- * Get the placeholder.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getPlaceholder(): string {
- return $this->placeholder;
- }
-
-
- /**
- * Set the default value of the setting.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $value
- *
- * @return WidgetSetting
- */
- public function setDefault(string $value): WidgetSetting {
- $this->default = $value;
-
- return $this;
- }
-
- /**
- * Get the default value.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getDefault(): string {
- return $this->default;
- }
-
-
- /**
- * @since 15.0.0
- * @deprecated 20.0.0
- */
- public function jsonSerialize(): array {
- return [
- 'name' => $this->getName(),
- 'title' => $this->getTitle(),
- 'type' => $this->getTitle(),
- 'default' => $this->getDefault(),
- 'placeholder' => $this->getPlaceholder()
- ];
- }
-}
diff --git a/lib/public/Dashboard/Model/WidgetSetup.php b/lib/public/Dashboard/Model/WidgetSetup.php
deleted file mode 100644
index f3e09dcc71b..00000000000
--- a/lib/public/Dashboard/Model/WidgetSetup.php
+++ /dev/null
@@ -1,274 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Maxence Lange <maxence@artificial-owl.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program 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 (at your option) any later version.
- *
- * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCP\Dashboard\Model;
-
-use JsonSerializable;
-
-/**
- * Interface WidgetSetup
- *
- * A widget must create an WidgetSetup object and returns it in the
- * IDashboardWidget::getWidgetSetup method.
- *
- * @see IDashboardWidget::getWidgetSetup
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- */
-final class WidgetSetup implements JsonSerializable {
- public const SIZE_TYPE_MIN = 'min';
- public const SIZE_TYPE_MAX = 'max';
- public const SIZE_TYPE_DEFAULT = 'default';
-
-
- /** @var array */
- private $sizes = [];
-
- /** @var array */
- private $menus = [];
-
- /** @var array */
- private $jobs = [];
-
- /** @var string */
- private $push = '';
-
- /** @var array */
- private $settings = [];
-
-
- /**
- * Get the defined size for a specific type (min, max, default)
- * Returns an array:
- * [
- * 'width' => width,
- * 'height' => height
- * ]
- *
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $type
- *
- * @return array
- */
- public function getSize(string $type): array {
- if (array_key_exists($type, $this->sizes)) {
- return $this->sizes[$type];
- }
-
- return [];
- }
-
- /**
- * Returns all sizes defined for the widget.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return array
- */
- public function getSizes(): array {
- return $this->sizes;
- }
-
- /**
- * Add a new size to the setup.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $type
- * @param int $width
- * @param int $height
- *
- * @return WidgetSetup
- */
- public function addSize(string $type, int $width, int $height): WidgetSetup {
- $this->sizes[$type] = [
- 'width' => $width,
- 'height' => $height
- ];
-
- return $this;
- }
-
- /**
- * Returns menu entries.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return array
- */
- public function getMenuEntries(): array {
- return $this->menus;
- }
-
- /**
- * Add a menu entry to the widget.
- * $function is the Javascript function to be called when clicking the
- * menu entry.
- * $icon is the css class of the icon.
- * $text is the display name of the menu entry.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $function
- * @param string $icon
- * @param string $text
- *
- * @return WidgetSetup
- */
- public function addMenuEntry(string $function, string $icon, string $text): WidgetSetup {
- $this->menus[] = [
- 'function' => $function,
- 'icon' => $icon,
- 'text' => $text
- ];
-
- return $this;
- }
-
-
- /**
- * Add a delayed job to the widget.
- *
- * $function is the Javascript function to be called.
- * $delay is the time in seconds between each call.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $function
- * @param int $delay
- *
- * @return WidgetSetup
- */
- public function addDelayedJob(string $function, int $delay): WidgetSetup {
- $this->jobs[] = [
- 'function' => $function,
- 'delay' => $delay
- ];
-
- return $this;
- }
-
- /**
- * Get delayed jobs.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return array
- */
- public function getDelayedJobs(): array {
- return $this->jobs;
- }
-
-
- /**
- * Get the push function, called when an event is send to the front-end
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getPush(): string {
- return $this->push;
- }
-
- /**
- * Set the Javascript function to be called when an event is pushed to the
- * frontend.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $function
- *
- * @return WidgetSetup
- */
- public function setPush(string $function): WidgetSetup {
- $this->push = $function;
-
- return $this;
- }
-
-
- /**
- * Returns the default settings for a widget.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return array
- */
- public function getDefaultSettings(): array {
- return $this->settings;
- }
-
- /**
- * Set the default settings for a widget.
- * This method is used by the Dashboard app, using the settings created
- * using WidgetSetting
- *
- * @see WidgetSetting
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param array $settings
- *
- * @return WidgetSetup
- */
- public function setDefaultSettings(array $settings): WidgetSetup {
- $this->settings = $settings;
-
- return $this;
- }
-
-
- /**
- * @since 15.0.0
- * @deprecated 20.0.0
- */
- public function jsonSerialize(): array {
- return [
- 'size' => $this->getSizes(),
- 'menu' => $this->getMenuEntries(),
- 'jobs' => $this->getDelayedJobs(),
- 'push' => $this->getPush(),
- 'settings' => $this->getDefaultSettings()
- ];
- }
-}
diff --git a/lib/public/Dashboard/Model/WidgetTemplate.php b/lib/public/Dashboard/Model/WidgetTemplate.php
deleted file mode 100644
index 3521960c303..00000000000
--- a/lib/public/Dashboard/Model/WidgetTemplate.php
+++ /dev/null
@@ -1,326 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-/**
- * @copyright 2018, Maxence Lange <maxence@artificial-owl.com>
- *
- * @author Julius Härtl <jus@bitgrid.net>
- * @author Maxence Lange <maxence@artificial-owl.com>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program 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 (at your option) any later version.
- *
- * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-namespace OCP\Dashboard\Model;
-
-use JsonSerializable;
-
-/**
- * Interface WidgetTemplate
- *
- * A widget must create an WidgetTemplate object and returns it in the
- * IDashboardWidget::getWidgetTemplate method.
- *
- * @see IDashboardWidget::getWidgetTemplate
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- */
-final class WidgetTemplate implements JsonSerializable {
-
-
- /** @var string */
- private $icon = '';
-
- /** @var array */
- private $css = [];
-
- /** @var array */
- private $js = [];
-
- /** @var string */
- private $content = '';
-
- /** @var string */
- private $function = '';
-
- /** @var WidgetSetting[] */
- private $settings = [];
-
-
- /**
- * Get the icon class of the widget.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getIcon(): string {
- return $this->icon;
- }
-
- /**
- * Set the icon class of the widget.
- * This class must be defined in one of the CSS file used by the widget.
- *
- * @see addCss
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $icon
- *
- * @return WidgetTemplate
- */
- public function setIcon(string $icon): WidgetTemplate {
- $this->icon = $icon;
-
- return $this;
- }
-
- /**
- * Get CSS files to be included when displaying a widget
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return array
- */
- public function getCss(): array {
- return $this->css;
- }
-
- /**
- * path and name of CSS files
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param array $css
- *
- * @return WidgetTemplate
- */
- public function setCss(array $css): WidgetTemplate {
- $this->css = $css;
-
- return $this;
- }
-
- /**
- * Add a CSS file to be included when displaying a widget.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $css
- *
- * @return WidgetTemplate
- */
- public function addCss(string $css): WidgetTemplate {
- $this->css[] = $css;
-
- return $this;
- }
-
- /**
- * Get JS files to be included when loading a widget
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return array
- */
- public function getJs(): array {
- return $this->js;
- }
-
- /**
- * Set an array of JS files to be included when loading a widget.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param array $js
- *
- * @return WidgetTemplate
- */
- public function setJs(array $js): WidgetTemplate {
- $this->js = $js;
-
- return $this;
- }
-
- /**
- * Add a JS file to be included when loading a widget.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $js
- *
- * @return WidgetTemplate
- */
- public function addJs(string $js): WidgetTemplate {
- $this->js[] = $js;
-
- return $this;
- }
-
- /**
- * Get the HTML file that contains the content of the widget.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getContent(): string {
- return $this->content;
- }
-
- /**
- * Set the HTML file that contains the content of the widget.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $content
- *
- * @return WidgetTemplate
- */
- public function setContent(string $content): WidgetTemplate {
- $this->content = $content;
-
- return $this;
- }
-
- /**
- * Get the JS function to be called when loading the widget.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return string
- */
- public function getInitFunction(): string {
- return $this->function;
- }
-
- /**
- * JavaScript function to be called when loading the widget on the
- * dashboard
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $function
- *
- * @return WidgetTemplate
- */
- public function setInitFunction(string $function): WidgetTemplate {
- $this->function = $function;
-
- return $this;
- }
-
- /**
- * Get all WidgetSetting defined for the widget.
- *
- * @see WidgetSetting
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @return WidgetSetting[]
- */
- public function getSettings(): array {
- return $this->settings;
- }
-
- /**
- * Define all WidgetSetting for the widget.
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @see WidgetSetting
- *
- * @param WidgetSetting[] $settings
- *
- * @return WidgetTemplate
- */
- public function setSettings(array $settings): WidgetTemplate {
- $this->settings = $settings;
-
- return $this;
- }
-
- /**
- * Add a WidgetSetting.
- *
- * @see WidgetSetting
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param WidgetSetting $setting
- *
- * @return WidgetTemplate
- */
- public function addSetting(WidgetSetting $setting): WidgetTemplate {
- $this->settings[] = $setting;
-
- return $this;
- }
-
- /**
- * Get a WidgetSetting by its name
- *
- * @see WidgetSetting::setName
- *
- * @since 15.0.0
- * @deprecated 20.0.0
- *
- * @param string $key
- *
- * @return WidgetSetting
- */
- public function getSetting(string $key): WidgetSetting {
- if (!array_key_exists($key, $this->settings)) {
- return null;
- }
-
- return $this->settings[$key];
- }
-
-
- /**
- * @since 15.0.0
- * @deprecated 20.0.0
- */
- public function jsonSerialize(): array {
- return [
- 'icon' => $this->getIcon(),
- 'css' => $this->getCss(),
- 'js' => $this->getJs(),
- 'content' => $this->getContent(),
- 'function' => $this->getInitFunction(),
- 'settings' => $this->getSettings()
- ];
- }
-}