ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ReadingTimeManager.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Blog\ReadingTime;
22 
27 {
28  protected \ILIAS\COPage\ReadingTime\ReadingTimeManager $page_manager;
30  protected \ilSetting $blog_set;
31 
32  public function __construct()
33  {
34  $this->blog_set = new \ilSetting("blga");
35  $this->repo = new ReadingTimeDBRepo();
36  $this->page_manager = new \ILIAS\COPage\ReadingTime\ReadingTimeManager();
37  }
38 
39  public function isGloballyActivated(): bool
40  {
41  return (bool) $this->blog_set->get("est_reading_time");
42  }
43 
44  public function isActivated(int $blog_id): bool
45  {
46  return $this->repo->isActivated($blog_id);
47  }
48 
49  public function activate(int $blog_id, bool $activate): void
50  {
51  $is_active = $this->repo->isActivated($blog_id);
52  $this->repo->activate($blog_id, $activate);
53  if (!$is_active && $activate) {
54  $this->page_manager->setMissingReadingTimes("blp", $blog_id);
55  }
56  }
57 
61  public function getReadingTime(int $blog_id, int $bl_page_id): ?int
62  {
63  if (!$this->isActivated($blog_id)) {
64  return null;
65  }
66  return max(1, $this->page_manager->getTimeForId("blp", $bl_page_id));
67  }
68 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
ILIAS COPage ReadingTime ReadingTimeManager $page_manager