ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjContentPageListGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
9 
14 {
17 
22  public function __construct($a_context = self::CONTEXT_REPOSITORY)
23  {
24  global $DIC;
25 
26  parent::__construct($a_context);
27  $this->pageMetricsService = new PageMetricsService(
28  new PageMetricsRepositoryImp($DIC->database()),
29  $DIC->refinery()
30  );
31  }
32 
36  public function init()
37  {
38  $this->static_link_enabled = true;
39  $this->delete_enabled = true;
40  $this->cut_enabled = true;
41  $this->copy_enabled = true;
42  $this->subscribe_enabled = true;
43  $this->link_enabled = true;
44  $this->info_screen_enabled = true;
45  $this->type = self::OBJ_TYPE;
46  $this->gui_class_name = 'ilObjContentPageGUI';
47 
48  $this->commands = ilObjContentPageAccess::_getCommands();
49 
50  $this->lng->loadLanguageModule('copa');
51  }
52 
56  public function getInfoScreenStatus()
57  {
59  $this->obj_id,
61  true
62  )) {
64  }
65 
66  return false;
67  }
68 
72  public function getProperties()
73  {
74  $properties = [];
75 
76  $settingsStorage = new StorageImpl($this->settings);
77  if (!$settingsStorage->getSettings()->isReadingTimeEnabled()) {
78  return $properties;
79  }
80 
81  if (!$this->access->checkAccess('read', '', $this->ref_id)) {
82  return $properties;
83  }
84 
85  try {
86  $ot = ilObjectTranslation::getInstance($this->obj_id);
87  $language = $ot->getEffectiveContentLang($this->user->getCurrentLanguage(), $this->type);
88 
89  $pageMetrics = $this->pageMetricsService->get(
90  new GetPageMetricsCommand($this->obj_id, $language)
91  );
92 
93  $readingTimePropertyValue = sprintf(
94  $this->lng->txt('copa_value_reading_time_f_p'),
95  (string) $pageMetrics->readingTime()->minutes()
96  );
97  if (1 === $pageMetrics->readingTime()->minutes()) {
98  $readingTimePropertyValue = sprintf(
99  $this->lng->txt('copa_value_reading_time_f_s'),
100  (string) $pageMetrics->readingTime()->minutes()
101  );
102  }
103 
104  $properties[] = [
105  'alert' => false,
106  'property' => $this->lng->txt('copa_prop_reading_time'),
107  'value' => $readingTimePropertyValue,
108  ];
109  } catch (CouldNotFindPageMetrics $e) {
110  }
111 
112  return $properties;
113  }
114 
118  public function checkInfoPageOnAsynchronousRendering() : bool
119  {
120  return true;
121  }
122 }
settings()
Definition: settings.php:2
Class ilObjContentPageListGUI.
__construct($a_context=self::CONTEXT_REPOSITORY)
ilObjContentPageListGUI constructor.
user()
Definition: user.php:4
Class ilObjectListGUI.
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
static getInstance($a_obj_id)
Get instance.
static _lookupContainerSetting($a_id, $a_keyword, $a_default_value=null)
Lookup a container setting.