summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/inc/coursebackend.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2017-04-21 12:31:25 +0200
committerSimon Rettberg2017-04-21 12:31:25 +0200
commitb7ad64152d434c6a6188c7c75a2d538432c44371 (patch)
tree6407f1a3e803c4c204518593f5f3d7375256c930 /modules-available/locationinfo/inc/coursebackend.inc.php
parent[locationinfo] Properly support certificate and hostname verification (diff)
downloadslx-admin-b7ad64152d434c6a6188c7c75a2d538432c44371.tar.gz
slx-admin-b7ad64152d434c6a6188c7c75a2d538432c44371.tar.xz
slx-admin-b7ad64152d434c6a6188c7c75a2d538432c44371.zip
[locationinfo] Generate credentials in server-settings server side
There's no need to generate parameters server side that get passed to the template engine which generates javascript code that generates html snippets in the browser. We now generate everything server side right away.
Diffstat (limited to 'modules-available/locationinfo/inc/coursebackend.inc.php')
-rw-r--r--modules-available/locationinfo/inc/coursebackend.inc.php39
1 files changed, 39 insertions, 0 deletions
diff --git a/modules-available/locationinfo/inc/coursebackend.inc.php b/modules-available/locationinfo/inc/coursebackend.inc.php
index 3e95a170..447a5598 100644
--- a/modules-available/locationinfo/inc/coursebackend.inc.php
+++ b/modules-available/locationinfo/inc/coursebackend.inc.php
@@ -323,4 +323,43 @@ class BackendProperty {
$this->type = $type;
$this->default = $default;
}
+
+ /**
+ * Initialize additional fields of this class that are only required
+ * for rendering the server configuration dialog.
+ *
+ * @param string $backendId target backend id
+ * @param mixed $current current value of this property.
+ */
+ public function initForRender($current = null) {
+ if (is_array($this->type)) {
+ $this->template = 'dropdown';
+ $this->select_list = [];
+ foreach ($this->type as $item) {
+ $this->select_list[] = [
+ 'option' => $item,
+ 'active' => $item == $current,
+ ];
+ }
+ } elseif ($this->type === 'bool') {
+ $this->template = $this->type;
+ } else {
+ $this->template = 'generic';
+ }
+ if ($this->type === 'string') {
+ $this->inputtype = 'text';
+ } elseif ($this->type === 'int') {
+ $this->inputtype = 'number';
+ } elseif ($this->type === 'password') {
+ $this->inputtype = Property::getPasswordFieldType();
+ }
+ $this->currentvalue = $current === null ? $this->default : $current;
+ }
+ public $inputtype;
+ public $template;
+ public $title;
+ public $helptext;
+ public $currentvalue;
+ public $select_list;
+ public $credentialsHtml;
}