ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilImageLinkButton.php
Go to the documentation of this file.
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
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
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
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}
An exception for terminatinating execution or to throw for unit testing.
renderAttributesHelper(array $a_attr)
Render HTML node attributes.
getCaption($a_translate=true)
Get caption.
prepareRender()
Prepare render.
renderCaption()
Prepare caption for render.
static getInstance()
Factory.
setImage($a_value, $a_is_internal=true)
Set image.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)