errorMessages = array(); } private function getNotifications() : array { $req = new \Api\Notifications\Fetch($this->getDocument()->getUser()); if(!$req->execute()) { $this->errorMessages[] = $req->getLastError(); return array(); } else { return $req->getResult()['notifications']; } } private function getUsers() : array { $req = new \Api\User\Fetch($this->getDocument()->getUser()); if(!$req->execute()) { $this->errorMessages[] = $req->getLastError(); return array(); } else { return $req->getResult()['users']; } } private function getHeader() { // Locale $home = L("Home"); $search = L("Search"); // Icons $iconMenu = $this->createIcon("bars"); $iconNotification = $this->createIcon("bell", "far"); $iconSearch = $this->createIcon("search"); $iconMail = $this->createIcon("envelope", "fas"); // Notifications $notifications = $this->getNotifications(); $numNotifications = count($notifications); if ($numNotifications === 0) { $notificationText = L("No new notifications"); } else if($numNotifications === 1) { $notificationText = L("1 new notification"); } else { $notificationText = sprintf(L("%d new notification"), $numNotifications); } $html = ""; return $html; } private function getSidebar() { $menuEntries = array( "dashboard" => array( "name" => "Dashboard", "icon" => "tachometer-alt" ), "users" => array( "name" => "Users", "icon" => "users" ), "settings" => array( "name" => "Settings", "icon" => "tools" ), "help" => array( "name" => "Help", "icon" => "question-circle" ), ); $currentView = $_GET["view"] ?? "dashboard"; $html = ""; return $html; } private function getContent() { $this->getUsers(); $html = "
"; foreach($this->errorMessages as $errorMessage) { $html .= $this->createErrorText($errorMessage); } $html .= "
"; return $html; } public function getCode() { $head = $this->getDocument()->getHead(); $head->addJS(Script::BOOTSTRAP); $head->loadAdminlte(); $header = $this->getHeader(); $sidebar = $this->getSidebar(); $content = $this->getContent(); $html = "
$header $sidebar $content
"; return $html; } }