1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: namespace Xmf\Template;
13:
14: /**
15: * Buttonbox
16: *
17: * @category Xmf\Template\Buttonbox
18: * @package Xmf
19: * @author Grégory Mage (Aka Mage)
20: * @author trabis <lusopoemas@gmail.com>
21: * @copyright 2011-2013 XOOPS Project (http://xoops.org)
22: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
23: * @version Release: 1.0
24: * @link http://xoops.org
25: * @since 1.0
26: */
27: class Buttonbox extends AbstractTemplate
28: {
29: /**
30: * @var array
31: */
32: private $_items = array();
33:
34: /**
35: * @var string
36: */
37: private $_delimiter = " ";
38:
39: /**
40: * @var string
41: */
42: private $_position = "right";
43:
44: /**
45: * @var string
46: */
47: private $_path = '';
48:
49: /**
50: * init
51: *
52: * @return void
53: */
54: protected function init()
55: {
56: }
57:
58: /**
59: * set position - alignment position
60: *
61: * @param string $position left, right, center
62: *
63: * @return void
64: */
65: public function setPosition($position)
66: {
67: $this->_position = $position;
68: }
69:
70: /**
71: * set path - path to image files. Do not set if icons are
72: * specified with absoulte URLs
73: *
74: * @param string $position left, right, center
75: *
76: * @return void
77: */
78: public function setImagePath($path)
79: {
80: $this->_path = $path;
81: }
82:
83: /**
84: * setDelimiter
85: *
86: * @param string $delimiter delimiter put between buttons
87: *
88: * @return void
89: */
90: public function setDelimiter($delimiter)
91: {
92: $this->_delimiter = $delimiter;
93: }
94:
95: /**
96: * addItem to button box
97: *
98: * @param string $title title string for button
99: * @param string $link link for button
100: * @param string $icon icon for button
101: * @param string $extra extra
102: *
103: * @return void
104: */
105: public function addItem($title, $link, $icon, $extra = '')
106: {
107: $item['title'] = $title;
108: $item['link'] = $link;
109: $item['icon'] = $icon;
110: $item['extra'] = $extra;
111: $this->_items[] = $item;
112: }
113:
114: /**
115: * render the buttonbox
116: *
117: * @return void
118: */
119: protected function render()
120: {
121: $ret = '';
122: $path = $this->_path;
123: switch ($this->_position) {
124: default:
125: case "right":
126: $ret = "<div class=\"floatright\">\n";
127: break;
128:
129: case "left":
130: $ret = "<div class=\"floatleft\">\n";
131: break;
132:
133: case "center":
134: $ret = "<div class=\"aligncenter\">\n";
135: }
136: $ret .= "<div class=\"xo-buttons\">\n";
137: foreach ($this->_items as $item) {
138: $ret .= "<a class='ui-corner-all tooltip' href='" . $item['link'] . "' title='" . $item['title'] . "'>";
139: $ret .= "<img src='" . $path . $item['icon'] . "' title='" . $item['title'] . "' />" . $item['title'] . ' ' . $item['extra'];
140: $ret .= "</a>\n";
141: $ret .= $this->_delimiter;
142: }
143: $ret .= "</div>\n</div>\n";
144: $this->tpl->assign('dummy_content', $ret);
145: }
146: }
147: