1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4/**
5*
6* @author Jan Posselt <jposselt@databay.de>
7* @version $Id$
8*
9*
10* @ingroup ServicesMail
11*/
12include_once 'Services/Form/classes/class.ilFormPropertyGUI.php';
13
14class ilMailFormAttachmentPropertyGUI extends ilFormPropertyGUI
15{
16    public $buttonLabel;
17    public $items = array();
18
19    /**
20     * @var \ilLanguage
21     */
22    protected $lng;
23
24    /**
25     * Form Element for showing Mail Attachments
26     * @param	string	Buttonlabel (e.g. edit or add)
27     */
28    public function __construct($buttonLabel)
29    {
30        global $DIC;
31
32        $this->lng = $DIC->language();
33
34        $this->buttonLabel = $buttonLabel;
35        parent::__construct($this->lng->txt('attachments'));
36    }
37
38    /**
39     * Add Attachment Item to list
40     * @param	string	Label for item including additional information
41     *			like Filesize.
42     */
43    public function addItem($label)
44    {
45        $this->items[] = $label;
46    }
47
48    public function insert($a_tpl)
49    {
50        $tpl = new ilTemplate('tpl.mail_new_attachments.html', true, true, 'Services/Mail');
51
52        foreach ($this->items as $item) {
53            $tpl->setCurrentBlock('attachment_list_item');
54            $tpl->setVariable('ATTACHMENT_LABEL', $item);
55            $tpl->parseCurrentBlock();
56        }
57        $tpl->setVariable('ATTACHMENT_BUTTON_LABEL', $this->buttonLabel);
58
59        $a_tpl->setCurrentBlock("prop_generic");
60        $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
61        $a_tpl->parseCurrentBlock();
62    }
63}
64