From b7ad64152d434c6a6188c7c75a2d538432c44371 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 21 Apr 2017 12:31:25 +0200 Subject: [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. --- .../locationinfo/inc/coursebackend.inc.php | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'modules-available/locationinfo/inc/coursebackend.inc.php') 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; } -- cgit v1.2.3-55-g7522