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 help popup window button
14 *
15 * @since 3.0
16 */
17 class JToolbarButtonHelp extends JToolbarButton
18 {
19 /**
20 * @var string Button type
21 */
22 protected $_name = 'Help';
23
24 /**
25 * Fetches the button HTML code.
26 *
27 * @param string $type Unused string.
28 * @param string $ref The name of the help screen (its key reference).
29 * @param boolean $com Use the help file in the component directory.
30 * @param string $override Use this URL instead of any other.
31 * @param string $component Name of component to get Help (null for current component)
32 *
33 * @return string
34 *
35 * @since 3.0
36 */
37 public function fetchButton($type = 'Help', $ref = '', $com = false, $override = null, $component = null)
38 {
39 // Store all data to the options array for use with JLayout
40 $options = array();
41 $options['text'] = JText::_('JTOOLBAR_HELP');
42 $options['doTask'] = $this->_getCommand($ref, $com, $override, $component);
43
44 // Instantiate a new JLayoutFile instance and render the layout
45 $layout = new JLayoutFile('joomla.toolbar.help');
46
47 return $layout->render($options);
48 }
49
50 /**
51 * Get the button id
52 *
53 * Redefined from JButton class
54 *
55 * @return string Button CSS Id
56 *
57 * @since 3.0
58 */
59 public function fetchId()
60 {
61 return $this->_parent->getName() . '-help';
62 }
63
64 /**
65 * Get the JavaScript command for the button
66 *
67 * @param string $ref The name of the help screen (its key reference).
68 * @param boolean $com Use the help file in the component directory.
69 * @param string $override Use this URL instead of any other.
70 * @param string $component Name of component to get Help (null for current component)
71 *
72 * @return string JavaScript command string
73 *
74 * @since 3.0
75 */
76 protected function _getCommand($ref, $com, $override, $component)
77 {
78 // Get Help URL
79 $url = JHelp::createUrl($ref, $com, $override, $component);
80 $url = htmlspecialchars($url, ENT_QUOTES);
81 $cmd = "Joomla.popupWindow('$url', '" . JText::_('JHELP', true) . "', 700, 500, 1)";
82
83 return $cmd;
84 }
85 }
86