ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjContentPageListGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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  $ot = ilObjectTranslation::getInstance($this->obj_id);
96  $language = $ot->getEffectiveContentLang($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 $e) {
119  }
120 
121  return $properties;
122  }
123 
124  public function checkInfoPageOnAsynchronousRendering(): bool
125  {
126  return true;
127  }
128 }
__construct(int $a_context=self::CONTEXT_REPOSITORY)
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache.
global $DIC
Definition: feed.php:28
static getInstance(int $obj_id)
__construct(Container $dic, ilPlugin $plugin)