ILIAS  trunk Revision v12.0_alpha-33-ge186251a14d
ILIAS\Administration\HeaderTitleGUI Class Reference

GUI to change the header title of the installation. More...

+ Collaboration diagram for ILIAS\Administration\HeaderTitleGUI:

Public Member Functions

 __construct (private ilCtrl $ctrl, private ilGlobalTemplateInterface $tpl, private ilLanguage $lng, private ServerRequestInterface $request, private HeaderTitleRepo $repo, private bool $has_write_access,)
 
 executeCommand ()
 
 view ( $a_get_post_values=false, bool $add_entry=false)
 Show header title. More...
 
 add ()
 Add a header title. More...
 
 save (bool $delete=false)
 Save header titles. More...
 
 delete ()
 Remove header titles. More...
 

Detailed Description

GUI to change the header title of the installation.

@ilCtrl_isCalledBy ILIAS\Administration\HeaderTitleGUI: ilObjGeneralSettingsGUI

Definition at line 36 of file HeaderTitleGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Administration\HeaderTitleGUI::__construct ( private ilCtrl  $ctrl,
private ilGlobalTemplateInterface  $tpl,
private ilLanguage  $lng,
private ServerRequestInterface  $request,
private HeaderTitleRepo  $repo,
private bool  $has_write_access 
)

Definition at line 38 of file HeaderTitleGUI.php.

45 {
46 }

Member Function Documentation

◆ add()

ILIAS\Administration\HeaderTitleGUI::add ( )

Add a header title.

Definition at line 113 of file HeaderTitleGUI.php.

113 : void
114 {
115 $this->view(true, true);
116 }
view( $a_get_post_values=false, bool $add_entry=false)
Show header title.

◆ delete()

ILIAS\Administration\HeaderTitleGUI::delete ( )

Remove header titles.

Definition at line 174 of file HeaderTitleGUI.php.

174 : void
175 {
176 $this->save(true);
177 }
save(bool $delete=false)
Save header titles.

◆ executeCommand()

ILIAS\Administration\HeaderTitleGUI::executeCommand ( )

Definition at line 48 of file HeaderTitleGUI.php.

49 {
50 $cmd = $this->ctrl->getCmd("view");
51 switch ($cmd) {
52 case 'view':
53 $this->view();
54 break;
55
56 case 'add':
57 case 'save':
58 case 'delete':
59 if ($this->has_write_access) {
60 $this->$cmd();
61 }
62 break;
63 }
64 }

References ILIAS\Repository\ctrl(), and ILIAS\Administration\HeaderTitleGUI\view().

+ Here is the call graph for this function:

◆ save()

ILIAS\Administration\HeaderTitleGUI::save ( bool  $delete = false)

Save header titles.

Definition at line 121 of file HeaderTitleGUI.php.

122 {
123 $post = $this->request->getParsedBody();
124 foreach ($post["title"] as $k => $v) {
125 if ($delete && ($post["check"][$k] ?? false)) {
126 unset($post["title"][$k]);
127 unset($post["desc"][$k]);
128 unset($post["lang"][$k]);
129 if ($k == $post["default"]) {
130 unset($post["default"]);
131 }
132 }
133 }
134
135 // default language set?
136 if (!isset($post["default"]) && count($post["lang"]) > 0) {
137 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_default_language"));
138 $this->view(true);
139 return;
140 }
141
142 // all languages set?
143 if (array_key_exists("", $post["lang"])) {
144 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_no_language_selected"));
145 $this->view(true);
146 return;
147 }
148
149 // no single language is selected more than once?
150 if (count(array_unique($post["lang"])) < count($post["lang"])) {
151 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_multi_language_selected"));
152 $this->view(true);
153 return;
154 }
155
156 // save the stuff
157 $this->repo->removeHeaderTitleTranslations();
158 foreach ($post["title"] as $k => $v) {
159 $desc = $post["desc"][$k] ?? "";
160 $this->repo->addHeaderTitleTranslation(
162 ilUtil::stripSlashes($post["lang"][$k]),
163 ($post["default"] == $k)
164 );
165 }
166
167 $this->tpl->setOnScreenMessage(GlobalTemplate::MESSAGE_TYPE_SUCCESS, $this->lng->txt("msg_obj_modified"), true);
168 $this->ctrl->redirect($this, "view");
169 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
$post
Definition: ltitoken.php:46

References $post, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ILIAS\UICore\GlobalTemplate\MESSAGE_TYPE_SUCCESS, and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ view()

ILIAS\Administration\HeaderTitleGUI::view (   $a_get_post_values = false,
bool  $add_entry = false 
)

Show header title.

Definition at line 69 of file HeaderTitleGUI.php.

72 : void {
73 $table = new ilInstallationHeadingTableGUI($this, "view", $this->has_write_access);
74 $post = $this->request->getParsedBody();
75
76 if ($a_get_post_values) {
77 $vals = array();
78 foreach (($post["title"] ?? []) as $k => $v) {
79 $def = $post["default"] ?? "";
80 $vals[] = array("title" => $v,
81 "desc" => ($post["desc"][$k] ?? ""),
82 "lang" => ($post["lang"][$k] ?? ""),
83 "default" => ($def == $k));
84 }
85 if ($add_entry) {
86 $vals[] = array("title" => "",
87 "desc" => "",
88 "lang" => "",
89 "default" => false);
90 }
91 $table->setData($vals);
92 } else {
93 $data = $this->repo->getHeaderTitleTranslations();
94 if (isset($data["Fobject"]) && is_array($data["Fobject"])) {
95 foreach ($data["Fobject"] as $k => $v) {
96 if ($k == $data["default_language"]) {
97 $data["Fobject"][$k]["default"] = true;
98 } else {
99 $data["Fobject"][$k]["default"] = false;
100 }
101 }
102 } else {
103 $data["Fobject"] = array();
104 }
105 $table->setData($data["Fobject"]);
106 }
107 $this->tpl->setContent($table->getHTML());
108 }
TableGUI class for title/description translations.

References $post.

Referenced by ILIAS\Administration\HeaderTitleGUI\executeCommand().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: