1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Form/classes/class.ilSelectInputGUI.php';
5require_once 'Services/JSON/classes/class.ilJsonUtil.php';
6
7/**
8 * Class ilMailTemplateSelectInputGUI
9 */
10class ilMailTemplateSelectInputGUI extends ilSelectInputGUI
11{
12    /**
13     * @var array
14     */
15    protected $fields = array();
16
17    /**
18     * @var string
19     */
20    protected $url;
21
22    /**
23     * @param string $a_title
24     * @param string $a_postvar
25     * @param string $url
26     * @param array  $fields
27     */
28    public function __construct($a_title = '', $a_postvar = '', $url = '', array $fields = array())
29    {
30        parent::__construct($a_title, $a_postvar);
31
32        $this->url = $url;
33        $this->fields = $fields;
34    }
35
36    /**
37     * @param string $a_mode
38     * @return string
39     */
40    public function render($a_mode = '')
41    {
42        $html = parent::render($a_mode);
43
44        $tpl = new ilTemplate('tpl.prop_template_select_container.html', true, true, 'Services/Mail');
45        $tpl->setVariable('CONTENT', $html);
46        $tpl->setVariable('FIELDS', ilJsonUtil::encode($this->fields));
47        $tpl->setVariable('URL', $this->url);
48        $tpl->setVariable('ID', $this->getFieldId());
49
50        return $tpl->get();
51    }
52}
53