1 <?php
2 /**
3 * @package Joomla.Libraries
4 * @subpackage Form
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 JFormHelper::loadFieldClass('list');
13
14 /**
15 * Form Field class for the Joomla Platform.
16 * Provides a select list of help sites.
17 *
18 * @since 1.6
19 */
20 class JFormFieldHelpsite extends JFormFieldList
21 {
22 /**
23 * The form field type.
24 *
25 * @var string
26 * @since 1.6
27 */
28 public $type = 'Helpsite';
29
30 /**
31 * Method to get the help site field options.
32 *
33 * @return array The field option objects.
34 *
35 * @since 1.6
36 */
37 protected function getOptions()
38 {
39 // Merge any additional options in the XML definition.
40 $options = array_merge(parent::getOptions(), JHelp::createSiteList(JPATH_ADMINISTRATOR . '/help/helpsites.xml', $this->value));
41
42 return $options;
43 }
44
45 /**
46 * Override to add refresh button
47 *
48 * @return string The field input markup.
49 *
50 * @since 3.2
51 */
52 protected function getInput()
53 {
54 JHtml::_('script', 'system/helpsite.js', array('version' => 'auto', 'relative' => true));
55
56 $showDefault = $this->getAttribute('showDefault') === 'false' ? 'false' : 'true';
57
58 $html = parent::getInput();
59 $button = '<button
60 type="button"
61 class="btn btn-small"
62 id="helpsite-refresh"
63 rel="' . $this->id . '"
64 showDefault="' . $showDefault . '"
65 >
66 <span>' . JText::_('JGLOBAL_HELPREFRESH_BUTTON') . '</span>
67 </button>';
68
69 return $html . $button;
70 }
71 }
72