Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.0.5 issues part2 #2172

Merged
merged 4 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions lib/Controller/DisplayProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,14 @@ function grid(Request $request, Response $response)
'logicalOperatorName' => $parsedQueryParams->getString('logicalOperatorName'),
];

$embed = ($parsedQueryParams->getString('embed') != null) ? explode(',', $parsedQueryParams->getString('embed')) : [];
$profiles = $this->displayProfileFactory->query($this->gridRenderSort($parsedQueryParams), $this->gridRenderFilter($filter, $parsedQueryParams));
$embed = ($parsedQueryParams->getString('embed') != null)
? explode(',', $parsedQueryParams->getString('embed'))
: [];

if (count($profiles) <= 0)
throw new NotFoundException(__('Display Profile not found'), 'DisplayProfile');
$profiles = $this->displayProfileFactory->query(
$this->gridRenderSort($parsedQueryParams),
$this->gridRenderFilter($filter, $parsedQueryParams)
);

foreach ($profiles as $profile) {
// Load the config
Expand All @@ -189,20 +192,32 @@ function grid(Request $request, Response $response)
// Default Layout
$profile->buttons[] = array(
'id' => 'displayprofile_button_edit',
'url' => $this->urlFor($request,'displayProfile.edit.form', ['id' => $profile->displayProfileId]),
'url' => $this->urlFor(
$request,
'displayProfile.edit.form',
['id' => $profile->displayProfileId]
),
'text' => __('Edit')
);

$profile->buttons[] = array(
'id' => 'displayprofile_button_copy',
'url' => $this->urlFor($request,'displayProfile.copy.form', ['id' => $profile->displayProfileId]),
'url' => $this->urlFor(
$request,
'displayProfile.copy.form',
['id' => $profile->displayProfileId]
),
'text' => __('Copy')
);

if ($this->getUser()->checkDeleteable($profile)) {
$profile->buttons[] = array(
'id' => 'displayprofile_button_delete',
'url' => $this->urlFor($request,'displayProfile.delete.form', ['id' => $profile->displayProfileId]),
'url' => $this->urlFor(
$request,
'displayProfile.delete.form',
['id' => $profile->displayProfileId]
),
'text' => __('Delete')
);
}
Expand Down
25 changes: 17 additions & 8 deletions lib/Controller/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,14 +551,23 @@
try {
$module = $this->moduleFactory->getByType($media->mediaType);
if ($module->hasThumbnail) {
$media->setUnmatchedProperty(
'thumbnail',
$this->urlFor($request, 'library.download', [
'id' => $media->mediaId
], [
'preview' => 1
])
);
$renderThumbnail = true;
// for video, check if the cover image exists here.
if ($media->mediaType === 'video') {
$libraryLocation = $this->getConfig()->getSetting('LIBRARY_LOCATION');
$renderThumbnail = file_exists($libraryLocation . $media->mediaId . '_videocover.png');
}

if ($renderThumbnail) {
$media->setUnmatchedProperty(
'thumbnail',
$this->urlFor($request, 'library.download', [
'id' => $media->mediaId
], [
'preview' => 1
])
);
}
}
} catch (NotFoundException $notFoundException) {
$this->getLog()->error('Module ' . $media->mediaType . ' not found');
Expand Down Expand Up @@ -723,7 +732,7 @@
$media->buttons[] = array(
'id' => 'content_button_download',
'linkType' => '_self', 'external' => true,
'url' => $this->urlFor($request, 'library.download', ['id' => $media->mediaId]) . '?attachment=' . urlencode($media->fileName),

Check warning on line 735 in lib/Controller/Library.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 143 characters
'text' => __('Download')
);

Expand Down Expand Up @@ -1172,9 +1181,9 @@

// Get Valid Extensions
if ($parsedBody->getInt('oldMediaId', ['default' => $options['oldMediaId']]) !== null) {
$media = $this->mediaFactory->getById($parsedBody->getInt('oldMediaId', ['default' => $options['oldMediaId']]));

Check warning on line 1184 in lib/Controller/Library.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 124 characters
$folderId = $media->folderId;
$validExt = $this->moduleFactory->getValidExtensions(['type' => $media->mediaType, 'allowMediaTypeChange' => $options['allowMediaTypeChange']]);

Check warning on line 1186 in lib/Controller/Library.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 156 characters
} else {
$validExt = $this->moduleFactory->getValidExtensions();
}
Expand All @@ -1187,8 +1196,8 @@
'controller' => $this,
'oldMediaId' => $parsedBody->getInt('oldMediaId', ['default' => $options['oldMediaId']]),
'widgetId' => $parsedBody->getInt('widgetId'),
'updateInLayouts' => $parsedBody->getCheckbox('updateInLayouts', ['default' => $options['updateInLayouts']]),

Check warning on line 1199 in lib/Controller/Library.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 121 characters
'deleteOldRevisions' => $parsedBody->getCheckbox('deleteOldRevisions', ['default' => $options['deleteOldRevisions']]),

Check warning on line 1200 in lib/Controller/Library.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 130 characters
'allowMediaTypeChange' => $options['allowMediaTypeChange'],
'displayOrder' => $parsedBody->getInt('displayOrder'),
'playlistId' => $parsedBody->getInt('playlistId'),
Expand Down Expand Up @@ -1243,7 +1252,7 @@
$this->getState()->setData([
'media' => $media,
'validExtensions' => implode('|', $this->moduleFactory->getValidExtensions(['type' => $media->mediaType])),
'expiryDate' => ($media->expires == 0 ) ? null : Carbon::createFromTimestamp($media->expires)->format(DateFormatHelper::getSystemFormat(), $media->expires)

Check warning on line 1255 in lib/Controller/Library.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 167 characters
]);

return $this->render($request, $response);
Expand Down Expand Up @@ -1907,7 +1916,7 @@
}

// Get a list of displays that this mediaId is used on
$displays = $this->displayFactory->query($this->gridRenderSort($sanitizedParams), $this->gridRenderFilter(['disableUserCheck' => 1, 'mediaId' => $id], $sanitizedParams));

Check warning on line 1919 in lib/Controller/Library.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 178 characters

$this->getState()->template = 'library-form-usage';
$this->getState()->setData([
Expand Down Expand Up @@ -1957,7 +1966,7 @@
}

// Get a list of displays that this mediaId is used on by direct assignment
$displays = $this->displayFactory->query($this->gridRenderSort($sanitizedParams), $this->gridRenderFilter(['mediaId' => $id], $sanitizedParams));

Check warning on line 1969 in lib/Controller/Library.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 153 characters

// have we been provided with a date/time to restrict the scheduled events to?
$mediaFromDate = $sanitizedParams->getDate('mediaEventFromDate');
Expand Down Expand Up @@ -2664,7 +2673,7 @@

$media->folderId = $folderId;
$folder = $this->folderFactory->getById($media->folderId);
$media->permissionsFolderId = ($folder->getPermissionFolderId() == null) ? $folder->id : $folder->getPermissionFolderId();

Check warning on line 2676 in lib/Controller/Library.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 130 characters

$media->save(['saveTags' => false]);

Expand Down
130 changes: 63 additions & 67 deletions lib/Factory/DisplayProfileFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Copyright (C) 2023 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 @@ -169,7 +169,7 @@
['name' => 'downloadEndWindow', 'default' => '00:00', 'type' => 'string'],
['name' => 'dayPartId', 'default' => null],
['name' => 'xmrNetworkAddress', 'default' => '', 'type' => 'string'],
['name' => 'statsEnabled', 'default' => (int)$this->config->getSetting('DISPLAY_PROFILE_STATS_DEFAULT', 0), 'type' => 'checkbox'],

Check warning on line 172 in lib/Factory/DisplayProfileFactory.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 146 characters
['name' => 'aggregationLevel', 'default' => $this->config->getSetting('DISPLAY_PROFILE_AGGREGATION_LEVEL_DEFAULT'), 'type' => 'string'],
['name' => 'powerpointEnabled', 'default' => 0, 'type' => 'checkbox'],
['name' => 'sizeX', 'default' => 0, 'type' => 'double'],
Expand Down Expand Up @@ -363,93 +363,89 @@
$sortOrder = ['name'];
}

try {
$params = array();
$select = 'SELECT displayProfileId, name, type, config, isDefault, userId, isCustom ';

$body = ' FROM `displayprofile` WHERE 1 = 1 ';
$params = [];
$select = 'SELECT displayProfileId, name, type, config, isDefault, userId, isCustom ';

if ($parsedFilter->getInt('displayProfileId') !== null) {
$body .= ' AND displayProfileId = :displayProfileId ';
$params['displayProfileId'] = $parsedFilter->getInt('displayProfileId');
}
$body = ' FROM `displayprofile` WHERE 1 = 1 ';

if ($parsedFilter->getInt('isDefault') !== null) {
$body .= ' AND isDefault = :isDefault ';
$params['isDefault'] = $parsedFilter->getInt('isDefault');
}
if ($parsedFilter->getInt('displayProfileId') !== null) {
$body .= ' AND displayProfileId = :displayProfileId ';
$params['displayProfileId'] = $parsedFilter->getInt('displayProfileId');
}

// Filter by DisplayProfile Name?
if ($parsedFilter->getString('displayProfile') != null) {
$terms = explode(',', $parsedFilter->getString('displayProfile'));
$logicalOperator = $parsedFilter->getString('logicalOperatorName', ['default' => 'OR']);
$this->nameFilter(
'displayprofile',
'name',
$terms,
$body,
$params,
($parsedFilter->getCheckbox('useRegexForName') == 1),
$logicalOperator
);
}
if ($parsedFilter->getInt('isDefault') !== null) {
$body .= ' AND isDefault = :isDefault ';
$params['isDefault'] = $parsedFilter->getInt('isDefault');
}

if ($parsedFilter->getString('type') != null) {
$body .= ' AND type = :type ';
$params['type'] = $parsedFilter->getString('type');
}
// Filter by DisplayProfile Name?
if ($parsedFilter->getString('displayProfile') != null) {
$terms = explode(',', $parsedFilter->getString('displayProfile'));
$logicalOperator = $parsedFilter->getString('logicalOperatorName', ['default' => 'OR']);
$this->nameFilter(
'displayprofile',
'name',
$terms,
$body,
$params,
($parsedFilter->getCheckbox('useRegexForName') == 1),
$logicalOperator
);
}

if ($parsedFilter->getString('type') != null) {
$body .= ' AND type = :type ';
$params['type'] = $parsedFilter->getString('type');
}

if ($parsedFilter->getInt('commandId') !== null) {
$body .= '
if ($parsedFilter->getInt('commandId') !== null) {
$body .= '
AND `displayprofile`.displayProfileId IN (
SELECT `lkcommanddisplayprofile`.displayProfileId
FROM `lkcommanddisplayprofile`
WHERE `lkcommanddisplayprofile`.commandId = :commandId
)
';

$params['commandId'] = $parsedFilter->getInt('commandId');
}

if ($parsedFilter->getInt('userId') !== null) {
$body .= ' AND `displayprofile`.userId = :userId ';
$params['userId'] = $parsedFilter->getInt('userId');
}

// Sorting?
$order = '';
if (is_array($sortOrder)) {
$order .= 'ORDER BY ' . implode(',', $sortOrder);
}
$params['commandId'] = $parsedFilter->getInt('commandId');
}

$limit = '';
// Paging
if ($filterBy !== null && $parsedFilter->getInt('start') !== null && $parsedFilter->getInt('length') !== null) {
$limit = ' LIMIT ' . $parsedFilter->getInt('start', ['default' => 0]) . ', ' . $parsedFilter->getInt('length', ['default' => 10]);
}
if ($parsedFilter->getInt('userId') !== null) {
$body .= ' AND `displayprofile`.userId = :userId ';
$params['userId'] = $parsedFilter->getInt('userId');
}

$sql = $select . $body . $order . $limit;
// Sorting?
$order = '';
if (is_array($sortOrder)) {
$order .= 'ORDER BY ' . implode(',', $sortOrder);
}

foreach ($this->getStore()->select($sql, $params) as $row) {
$profile = $this->createEmpty()->hydrate($row, ['intProperties' => ['isDefault', 'isCustom']]);
$limit = '';
// Paging
if ($filterBy !== null && $parsedFilter->getInt('start') !== null && $parsedFilter->getInt('length') !== null) {
$limit = ' LIMIT ' . $parsedFilter->getInt('start', ['default' => 0]) .
', ' . $parsedFilter->getInt('length', ['default' => 10]);
}

$profile->excludeProperty('configDefault');
$profile->excludeProperty('configTabs');
$profiles[] = $profile;
}
$sql = $select . $body . $order . $limit;

// Paging
if ($limit != '' && count($profiles) > 0) {
$results = $this->getStore()->select('SELECT COUNT(*) AS total ' . $body, $params);
$this->_countLast = intval($results[0]['total']);
}
foreach ($this->getStore()->select($sql, $params) as $row) {
$profile = $this->createEmpty()->hydrate($row, ['intProperties' => ['isDefault', 'isCustom']]);

return $profiles;
} catch (\Exception $e) {
$this->getLog()->error($e);
$profile->excludeProperty('configDefault');
$profile->excludeProperty('configTabs');
$profiles[] = $profile;
}

throw new NotFoundException();
// Paging
if ($limit != '' && count($profiles) > 0) {
$results = $this->getStore()->select('SELECT COUNT(*) AS total ' . $body, $params);
$this->_countLast = intval($results[0]['total']);
}

return $profiles;
}

public function getAvailableTypes()
Expand Down
19 changes: 10 additions & 9 deletions ui/src/core/xibo-cms.js
Original file line number Diff line number Diff line change
Expand Up @@ -3682,7 +3682,7 @@ function initJsTreeAjax(container, id, isForm, ttl, onReady = null, onSelected =

$(container).jstree({
"state" : state,
"plugins" : ["contextmenu", "state", "unique", "sort", "themes", "types", 'search'].concat(plugins),
"plugins" : ["contextmenu", "state", "unique", "sort", "types", 'search'].concat(plugins),
"contextmenu":{
"items": function($node, checkContextMenuPermissions) {
// items in context menu need to check user permissions before we render them
Expand Down Expand Up @@ -3766,21 +3766,18 @@ function initJsTreeAjax(container, id, isForm, ttl, onReady = null, onSelected =
}
});
}},
"themes" : {
"responsive" : true
},
"types" : {
"root" : {
"icon" : "fa fa-file text-warning"
"icon" : "fa fa-file text-xibo-primary"
},
"home" : {
"icon" : "fa fa-home text-success"
"icon" : "fa fa-home text-xibo-primary"
},
"default" : {
"icon" : "fa fa-folder text-warning"
"icon" : "fa fa-folder text-xibo-primary"
},
"open" : {
"icon" : "fa fa-folder-open text-warning"
"icon" : "fa fa-folder-open text-xibo-primary"
}
},
'search' : {
Expand All @@ -3799,7 +3796,11 @@ function initJsTreeAjax(container, id, isForm, ttl, onReady = null, onSelected =
},
'data' : {
"url": foldersUrl + (homeFolderId ? '?homeFolderId='+homeFolderId : '')
}
},
"themes" : {
'responsive' : true,
'dots' : false,
},
}
}).bind('ready.jstree', function(e, data) {
// depending on the state of folder tree, hide/show as needed when we load the grid page
Expand Down
6 changes: 3 additions & 3 deletions views/applications-form-edit.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{#
/**
* Copyright (C) 2022 Xibo Signage Ltd
* Copyright (C) 2023 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 @@ -128,7 +128,7 @@
{% for scope in scopes %}
{% set title %}{{ scope.description }}{% endset %}
{% set id %}scope_{{ scope.id }}{% endset %}
{{ forms.checkbox(id, title, scope.selected) }}
{{ forms.checkbox(id, title, scope.getUnmatchedProperty('selected')) }}
{% endfor %}

{% set title %}{% trans "Owner" %}{% endset %}
Expand Down
2 changes: 1 addition & 1 deletion views/authed.twig
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@
</div>
<div class="modal-body">
<div class="form-group card p-3 mb-3 bg-light">
<input id="jstree-search-form" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search-form" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="folder-search-no-results d-none">
<p>{% trans 'No Folders matching the search term' %}</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion views/campaign-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@

<div class="row">
<div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
<label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
Expand Down
2 changes: 1 addition & 1 deletion views/dataset-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

<div class="row">
<div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
<label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
Expand Down
2 changes: 1 addition & 1 deletion views/display-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
</div>
<div class="row">
<div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
<label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
Expand Down
2 changes: 1 addition & 1 deletion views/displaygroup-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
</div>
<div class="row">
<div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
<label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
Expand Down
2 changes: 1 addition & 1 deletion views/folders-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="widget-body">
<div class="row">
<div class="col-md-3">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="folder-search-no-results d-none">
<p>{% trans 'No Folders matching the search term' %}</p>
</div>
Expand Down
2 changes: 1 addition & 1 deletion views/layout-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@

<div class="row">
<div class="col-sm-2 p-3 bg-light" id="grid-folder-filter">
<input id="jstree-search" type="text" placeholder="{% trans "Search" %}">
<input id="jstree-search" class="form-control" type="text" placeholder="{% trans "Search" %}">
<div class="form-check">
<input type="checkbox" class="form-check-input" id="folder-tree-clear-selection-button">
<label class="form-check-label" for="folder-tree-clear-selection-button" title="{% trans "Search in all folders" %}">{% trans "All Folders" %}</label>
Expand Down
Loading
Loading