1<?php
2/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
5
6/**
7 * Image Link Button GUI
8 *
9 * @author Jörg Lützenkirchen <luetzenkirchen@leifos.com>
10 * @version $Id: class.ilTabsGUI.php 45109 2013-09-30 15:46:28Z akill $
11 * @package ServicesUIComponent
12 */
13class ilImageLinkButton extends ilLinkButton
14{
15    protected $src; // [string]
16    protected $force_title; // [bool]
17
18    public static function getInstance()
19    {
20        return new self(self::TYPE_LINK);
21    }
22
23
24    //
25    // properties
26    //
27
28    /**
29     * Set image
30     *
31     * @param string $a_value
32     * @param bool $a_is_internal
33     */
34    public function setImage($a_value, $a_is_internal = true)
35    {
36        if ((bool) $a_is_internal) {
37            $a_value = ilUtil::getImagePath($a_value);
38        }
39        $this->src = trim($a_value);
40    }
41
42    /**
43     * Get image
44     *
45     * @return string
46     */
47    public function getImage()
48    {
49        return $this->src;
50    }
51
52    public function forceTitle($a_value)
53    {
54        $this->force_title = (bool) $a_value;
55    }
56
57    public function hasForceTitle()
58    {
59        return $this->force_title;
60    }
61
62
63    //
64    // render
65    //
66
67    protected function prepareRender()
68    {
69        // get rid of parent "submit" css class...
70    }
71
72    protected function renderCaption()
73    {
74        $attr = array();
75        $attr["src"] = $this->getImage();
76        $attr["alt"] = $this->getCaption();
77        if ($this->hasForceTitle()) {
78            $attr["title"] = $this->getCaption();
79        }
80        return '<img' . $this->renderAttributesHelper($attr) . ' />';
81    }
82}
83