27
27
use Xibo\Exception\ConfigurationException;
28
28
use Xibo\Exception\LibraryFullException;
29
29
use Xibo\Factory\DataSetFactory;
30
use Xibo\Factory\DisplayFactory;
31
30
use Xibo\Factory\DisplayGroupFactory;
32
31
use Xibo\Factory\LayoutFactory;
33
32
use Xibo\Factory\MediaFactory;
35
34
use Xibo\Factory\PermissionFactory;
36
35
use Xibo\Factory\PlaylistFactory;
37
36
use Xibo\Factory\RegionFactory;
38
use Xibo\Factory\ScheduleFactory;
39
37
use Xibo\Factory\TagFactory;
40
38
use Xibo\Factory\UserFactory;
41
39
use Xibo\Factory\UserGroupFactory;
116
114
/** @var DataSetFactory */
117
115
private $dataSetFactory;
119
/** @var DisplayFactory */
120
private $displayFactory;
122
/** @var ScheduleFactory */
123
private $scheduleFactory;
126
118
* Set common dependencies.
127
119
* @param LogServiceInterface $log
145
137
* @param DisplayGroupFactory $displayGroupFactory
146
138
* @param RegionFactory $regionFactory
147
139
* @param DataSetFactory $dataSetFactory
148
* @param DisplayFactory $displayFactory
149
* @param ScheduleFactory $scheduleFactory
151
public function __construct($log, $sanitizerService, $state, $user, $help, $date, $config, $store, $pool, $userFactory, $moduleFactory, $tagFactory, $mediaFactory, $widgetFactory, $permissionFactory, $layoutFactory, $playlistFactory, $userGroupFactory, $displayGroupFactory, $regionFactory, $dataSetFactory, $displayFactory, $scheduleFactory)
141
public function __construct($log, $sanitizerService, $state, $user, $help, $date, $config, $store, $pool, $userFactory, $moduleFactory, $tagFactory, $mediaFactory, $widgetFactory, $permissionFactory, $layoutFactory, $playlistFactory, $userGroupFactory, $displayGroupFactory, $regionFactory, $dataSetFactory)
153
143
$this->setCommonDependencies($log, $sanitizerService, $state, $user, $help, $date, $config);
166
156
$this->displayGroupFactory = $displayGroupFactory;
167
157
$this->regionFactory = $regionFactory;
168
158
$this->dataSetFactory = $dataSetFactory;
169
$this->displayFactory = $displayFactory;
170
$this->scheduleFactory = $scheduleFactory;
263
* @return DisplayFactory
265
public function getDisplayFactory()
267
return $this->displayFactory;
271
* @return ScheduleFactory
273
public function getScheduleFactory()
275
return $this->scheduleFactory;
279
251
* Displays the page logic
281
253
function displayPage()
284
256
$this->getState()->template = 'library-page';
285
257
$this->getState()->setData([
286
258
'users' => $this->userFactory->query(),
287
'modules' => $this->moduleFactory->query(['module'], ['regionSpecific' => 0, 'enabled' => 1]),
288
'groups' => $this->userGroupFactory->query()
259
'modules' => $this->moduleFactory->query(['module'], ['regionSpecific' => 0, 'enabled' => 1])
333
304
* type="integer",
339
* description="Filter by Tags - comma seperated",
346
* description="Filter by Duration - a number or less-than,greater-than,less-than-equal or great-than-equal followed by a | followed by a number",
353
* description="Filter by File Size - a number or less-than,greater-than,less-than-equal or great-than-equal followed by a | followed by a number",
358
* name="ownerUserGroupId",
360
* description="Filter by users in this UserGroupId",
366
309
* description="successful operation",
382
325
'type' => $this->getSanitizer()->getString('type'),
383
326
'tags' => $this->getSanitizer()->getString('tags'),
384
327
'ownerId' => $this->getSanitizer()->getInt('ownerId'),
385
'retired' => $this->getSanitizer()->getInt('retired'),
386
'duration' => $this->getSanitizer()->getString('duration'),
387
'fileSize' => $this->getSanitizer()->getString('fileSize'),
388
'ownerUserGroupId' => $this->getSanitizer()->getInt('ownerUserGroupId')
328
'retired' => $this->getSanitizer()->getInt('retired')
391
331
// Add some additional row content
462
402
if (!$this->getUser()->checkDeleteable($media))
463
403
throw new AccessDeniedException();
465
$media->setChildObjectDependencies($this->layoutFactory, $this->widgetFactory, $this->displayGroupFactory, $this->displayFactory, $this->scheduleFactory);
405
$media->setChildObjectDependencies($this->layoutFactory, $this->widgetFactory, $this->displayGroupFactory);
466
406
$media->load(['deleting' => true]);
468
408
$this->getState()->template = 'library-form-delete';
510
450
throw new AccessDeniedException();
513
$media->setChildObjectDependencies($this->layoutFactory, $this->widgetFactory, $this->displayGroupFactory, $this->displayFactory, $this->scheduleFactory);
453
$media->setChildObjectDependencies($this->layoutFactory, $this->widgetFactory, $this->displayGroupFactory);
514
454
$media->load(['deleting' => true]);
516
456
if ($media->isUsed() && $this->getSanitizer()->getCheckbox('forceDelete') == 0)
580
520
$validExt = $this->moduleFactory->getValidExtensions();
582
// Make sure there is room in the library
583
$libraryLimit = $this->getConfig()->GetSetting('LIBRARY_SIZE_LIMIT_KB') * 1024;
585
522
$options = array(
586
523
'userId' => $this->getUser()->userId,
587
524
'controller' => $this,
596
533
'script_url' => $this->urlFor('library.add'),
597
534
'upload_url' => $this->urlFor('library.add'),
598
535
'image_versions' => array(),
599
'accept_file_types' => '/\.' . implode('|', $validExt) . '$/i',
600
'libraryLimit' => $libraryLimit,
601
'libraryQuotaFull' => ($libraryLimit > 0 && $this->libraryUsage() > $libraryLimit)
536
'accept_file_types' => '/\.' . implode('|', $validExt) . '$/i'
604
// Output handled by UploadHandler
539
// Make sure there is room in the library
540
$libraryLimit = $this->getConfig()->GetSetting('LIBRARY_SIZE_LIMIT_KB') * 1024;
542
if ($libraryLimit > 0 && $this->libraryUsage() > $libraryLimit)
543
throw new LibraryFullException(sprintf(__('Your library is full. Library Limit: %s K'), $libraryLimit));
545
// Check for a user quota
546
$this->getUser()->isQuotaFullByUser();
605
547
$this->setNoOutput(true);
607
$this->getLog()->debug('Hand off to Upload Handler with options: %s', json_encode($options));
609
// Hand off to the Upload Handler provided by jquery-file-upload
610
new XiboUploadHandler($options);
550
$this->getLog()->debug('Hand off to Upload Handler with options: %s', json_encode($options));
551
// Hand off to the Upload Handler provided by jquery-file-upload
552
new XiboUploadHandler($options);
554
catch (\Exception $e) {
555
// We must not issue an error, the file upload return should have the error object already
984
929
// Separate out the display name and the referenced name (referenced name cannot contain any odd characters or numbers)
985
930
$displayName = $font->name;
986
$familyName = strtolower(preg_replace('/\s+/', ' ', preg_replace('/\d+/u', '', $font->name)));
931
$familyName = preg_replace('/\s+/', ' ', preg_replace('/\d+/u', '', $font->name));
988
933
// Css for the client contains the actual stored as location of the font.
989
934
$css .= str_replace('[url]', $font->storedAs, str_replace('[family]', $familyName, $fontTemplate));
1007
952
$media = $this->mediaFactory->createModuleSystemFile('fonts.css', $tempUrl);
1008
953
$media->expires = 0;
1009
954
$media->moduleSystemFile = true;
1010
$media->isSaveRequired = true;
955
$media->force = true;
1013
// We can remove the temp file
1017
959
'css' => $localCss,
1018
960
'ckeditor' => $ckEditorString
1048
990
$moduleObject = $this->moduleFactory->create($module->type);
1049
991
$moduleObject->installFiles();
1052
// Dump the cache on all displays
1053
foreach ($this->displayFactory->query() as $display) {
1054
/** @var \Xibo\Entity\Display $display */
1087
1023
/* @var \Xibo\Entity\Media $entry */
1088
1024
// If the media type is a module, then pretend its a generic file
1089
1025
$this->getLog()->info('Removing Expired File %s', $entry->name);
1090
$entry->setChildObjectDependencies($this->layoutFactory, $this->widgetFactory, $this->displayGroupFactory, $this->displayFactory, $this->scheduleFactory);
1026
$entry->setChildObjectDependencies($this->layoutFactory, $this->widgetFactory, $this->displayGroupFactory);
1091
1027
$entry->delete();
1124
* path="/library/{mediaId}/tag",
1060
* path="/media/{mediaId}/tag",
1125
1061
* operationId="mediaTag",
1127
1063
* summary="Tag Media",
1128
1064
* description="Tag a Media with one or more tags",
1129
1065
* @SWG\Parameter(
1185
* path="/library/{mediaId}/untag",
1121
* path="/media/{mediaId}/tag",
1186
1122
* operationId="mediaUntag",
1188
1124
* summary="Untag Media",
1189
1125
* description="Untag a Media with one or more tags",
1190
1126
* @SWG\Parameter(
1225
1161
$tags = $this->getSanitizer()->getStringArray('tag');
1227
1163
if (count($tags) <= 0)
1228
throw new \InvalidArgumentException(__('No tags to unassign'));
1164
throw new \InvalidArgumentException(__('No tags to assign'));
1230
1166
foreach ($tags as $tag) {
1231
1167
$media->unassignTag($this->tagFactory->tagFromString($tag));
1234
$media->save(['validate' => false]);
1237
1173
$this->getState()->hydrate([