ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjContentPageListGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26
28{
30
31 public function __construct(int $a_context = self::CONTEXT_REPOSITORY)
32 {
33 global $DIC;
34
35 parent::__construct($a_context);
36 $this->pageMetricsService = new PageMetricsService(
37 new PageMetricsRepositoryImp($DIC->database()),
38 $DIC->refinery()
39 );
40 }
41
42 public function init(): void
43 {
44 $this->static_link_enabled = true;
45 $this->delete_enabled = true;
46 $this->cut_enabled = true;
47 $this->copy_enabled = true;
48 $this->subscribe_enabled = true;
49 $this->link_enabled = true;
50 $this->info_screen_enabled = true;
51 $this->type = self::OBJ_TYPE;
52 $this->gui_class_name = 'ilObjContentPageGUI';
53
54 $this->commands = ilObjContentPageAccess::_getCommands();
55
56 $this->lng->loadLanguageModule('copa');
57 }
58
59 public function getInfoScreenStatus(): bool
60 {
62 $this->obj_id,
64 "1"
65 )) {
67 }
68
69 return false;
70 }
71
72 public function getProperties(): array
73 {
74 $properties = [];
75
76 $maySee = $this->rbacsystem->checkAccess('visible', $this->ref_id);
77 $mayRead = $this->rbacsystem->checkAccess('read', $this->ref_id);
78
79 if (!$maySee && !$mayRead) {
80 return $properties;
81 }
82
83 $properties = parent::getProperties();
84
85 if (!$mayRead || ilObject::lookupOfflineStatus($this->obj_id)) {
86 return $properties;
87 }
88
89 $settingsStorage = new StorageImpl($this->settings);
90 if (!$settingsStorage->getSettings()->isReadingTimeEnabled()) {
91 return $properties;
92 }
93
94 try {
95 $language = $this->object_properties->getPropertyTranslations()
96 ->getEffectiveCOPageLang($this->user->getCurrentLanguage(), $this->type);
97
98 $pageMetrics = $this->pageMetricsService->get(
99 new GetPageMetricsCommand($this->obj_id, $language)
100 );
101
102 $readingTimePropertyValue = sprintf(
103 $this->lng->txt('copa_value_reading_time_f_p'),
104 (string) $pageMetrics->readingTime()->minutes()
105 );
106 if (1 === $pageMetrics->readingTime()->minutes()) {
107 $readingTimePropertyValue = sprintf(
108 $this->lng->txt('copa_value_reading_time_f_s'),
109 (string) $pageMetrics->readingTime()->minutes()
110 );
111 }
112
113 $properties[] = [
114 'alert' => false,
115 'property' => $this->lng->txt('copa_prop_reading_time'),
116 'value' => $readingTimePropertyValue,
117 ];
118 } catch (CouldNotFindPageMetrics) {
119 }
120
121 return $properties;
122 }
123
125 {
126 return true;
127 }
128}
static _lookupContainerSetting(int $a_id, string $a_keyword, ?string $a_default_value=null)
readonly PageMetricsService $pageMetricsService
__construct(int $a_context=self::CONTEXT_REPOSITORY)
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
Interface ilContentPageObjectConstants.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26