ILIAS  release_8 Revision v8.24
class.ReadingTimeManager.php
Go to the documentation of this file.
1<?php
2
20
25{
29 protected $page_manager;
30
34 protected $repo;
35
39 protected $blog_set;
40
41 public function __construct()
42 {
43 $this->blog_set = new \ilSetting("blga");
44 $this->repo = new ReadingTimeDBRepo();
45 $this->page_manager = new \ILIAS\COPage\ReadingTime\ReadingTimeManager();
46 }
47
48 public function isGloballyActivated(): bool
49 {
50 return (bool) $this->blog_set->get("est_reading_time");
51 }
52
53 public function isActivated(int $blog_id): bool
54 {
55 return $this->repo->isActivated($blog_id);
56 }
57
58 public function activate(int $blog_id, bool $activate): void
59 {
60 $is_active = $this->repo->isActivated($blog_id);
61 $this->repo->activate($blog_id, $activate);
62 if (!$is_active && $activate) {
63 $this->page_manager->setMissingReadingTimes("blp", $blog_id);
64 }
65 }
66
70 public function getReadingTime(int $blog_id, int $bl_page_id): ?int
71 {
72 if (!$this->isActivated($blog_id)) {
73 return null;
74 }
75 return max(1, $this->page_manager->getTimeForId("blp", $bl_page_id));
76 }
77}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...