1 <?php
2 /**
3 * @package Joomla.Libraries
4 * @subpackage Toolbar
5 *
6 * @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('JPATH_PLATFORM') or die;
11
12 /**
13 * Renders a link button
14 *
15 * @since 3.0
16 */
17 class JToolbarButtonLink extends JToolbarButton
18 {
19 /**
20 * Button type
21 * @var string
22 */
23 protected $_name = 'Link';
24
25 /**
26 * Fetch the HTML for the button
27 *
28 * @param string $type Unused string.
29 * @param string $name Name to be used as apart of the id
30 * @param string $text Button text
31 * @param string $url The link url
32 *
33 * @return string HTML string for the button
34 *
35 * @since 3.0
36 */
37 public function fetchButton($type = 'Link', $name = 'back', $text = '', $url = null)
38 {
39 // Store all data to the options array for use with JLayout
40 $options = array();
41 $options['text'] = JText::_($text);
42 $options['class'] = $this->fetchIconClass($name);
43 $options['doTask'] = $this->_getCommand($url);
44
45 // Instantiate a new JLayoutFile instance and render the layout
46 $layout = new JLayoutFile('joomla.toolbar.link');
47
48 return $layout->render($options);
49 }
50
51 /**
52 * Get the button CSS Id
53 *
54 * @param string $type The button type.
55 * @param string $name The name of the button.
56 *
57 * @return string Button CSS Id
58 *
59 * @since 3.0
60 */
61 public function fetchId($type = 'Link', $name = '')
62 {
63 return $this->_parent->getName() . '-' . $name;
64 }
65
66 /**
67 * Get the JavaScript command for the button
68 *
69 * @param object $url Button definition
70 *
71 * @return string JavaScript command string
72 *
73 * @since 3.0
74 */
75 protected function _getCommand($url)
76 {
77 return $url;
78 }
79 }
80