- md5
- 0e7565adf13905552e7ffc77e94750c2
- sha1
- ae5beb9ca8c0e52f73dc9baa15e240cf5ba8562f
- sha256
- b878f8af89695db7441ea55dbb0f9a2058c8f93e8cb862c8e869dbaabe33c56a
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
<?php
/**
* @package Joomla.Installation
*
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Installation\Form\Field\Installation;
defined('JPATH_BASE') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\RadioField;
/**
* Install Sample Data field.
*
* @since 1.6
*/
class SampleField extends RadioField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'Sample';
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.6
*/
protected function getOptions()
{
$options = array();
$type = $this->form->getValue('db_type');
// Some database drivers share DDLs; point these drivers to the correct parent
if ($type === 'mysqli' || $type === 'pdomysql')
{
$type = 'mysql';
}
// Get a list of files in the search path with the given filter.
$files = \JFolder::files(JPATH_INSTALLATION . '/sql/' . $type, '^sample.*\.sql$');
// Add option to not install sample data.
$options[] = \JHtml::_('select.option', '',
\JHtml::_('tooltip', \JText::_('INSTL_SITE_INSTALL_SAMPLE_NONE_DESC'), '', '', \JText::_('JNO'))
);
// Build the options list from the list of files.
if (is_array($files))
{
foreach ($files as $file)
{
$options[] = \JHtml::_('select.option', $file, Factory::getLanguage()->hasKey($key = 'INSTL_' . ($file = \JFile::stripExt($file)) . '_SET') ?
\JHtml::_('tooltip', \JText::_('INSTL_' . strtoupper($file = \JFile::stripExt($file)) . '_SET_DESC'), '', '',
\JText::_('JYES')
) : $file
);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
/**
* Method to get the field input markup.
*
* @return string The field input markup.
*
* @since 1.6
*/
protected function getInput()
{
if (!$this->value)
{
$conf = Factory::getConfig();
if ($conf->get('sampledata'))
{
$this->value = $conf->get('sampledata');
}
else
{
$this->value = '';
}
}
if (empty($this->layout))
{
throw new \UnexpectedValueException(sprintf('%s has no layout assigned.', $this->name));
}
return $this->getRenderer($this->layout)->render($this->getLayoutData());
}
}
No other release has this exact content. See every version of this file.