2016-10-23 22:48:26 +00:00
|
|
|
<?php
|
2021-03-05 03:08:47 +00:00
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 30th April, 2015
|
2022-07-09 15:45:08 +00:00
|
|
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
|
|
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
2021-03-05 03:08:47 +00:00
|
|
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
2024-03-02 20:10:30 +00:00
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
use Joomla\CMS\Language\Text;
|
|
|
|
use Joomla\CMS\HTML\HTMLHelper as Html;
|
|
|
|
use VDM\Joomla\Utilities\StringHelper;
|
2024-07-26 16:33:01 +00:00
|
|
|
use Joomla\CMS\Filesystem\Folder;
|
2024-03-02 20:10:30 +00:00
|
|
|
|
2021-03-05 03:08:47 +00:00
|
|
|
// import the list field type
|
|
|
|
jimport('joomla.form.helper');
|
|
|
|
JFormHelper::loadFieldClass('list');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Siteviewfolderlist Form Field class for the Componentbuilder component
|
|
|
|
*/
|
|
|
|
class JFormFieldSiteviewfolderlist extends JFormFieldList
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The siteviewfolderlist field type.
|
|
|
|
*
|
2024-03-02 20:10:30 +00:00
|
|
|
* @var string
|
2021-03-05 03:08:47 +00:00
|
|
|
*/
|
|
|
|
public $type = 'siteviewfolderlist';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to get a list of options for a list input.
|
|
|
|
*
|
2024-03-02 20:10:30 +00:00
|
|
|
* @return array An array of Html options.
|
2021-03-05 03:08:47 +00:00
|
|
|
*/
|
|
|
|
protected function getOptions()
|
|
|
|
{
|
2018-04-13 20:11:35 +00:00
|
|
|
// get custom folder files
|
2024-03-02 20:10:30 +00:00
|
|
|
$localfolders = [];
|
|
|
|
$localfolders[] = JPATH_SITE . '/components/com_componentbuilder/views';
|
|
|
|
$localfolders[] = JPATH_SITE . '/components/com_componentbuilder/src/View';
|
2018-04-13 20:11:35 +00:00
|
|
|
// set the default
|
2024-03-02 20:10:30 +00:00
|
|
|
$options = [];
|
2018-04-13 20:11:35 +00:00
|
|
|
// now check if there are files in the folder
|
2024-03-02 20:10:30 +00:00
|
|
|
foreach ($localfolders as $localfolder)
|
2018-04-13 20:11:35 +00:00
|
|
|
{
|
2024-07-26 16:33:01 +00:00
|
|
|
if (is_dir($localfolder) && $folders = Folder::folders($localfolder))
|
2018-04-13 20:11:35 +00:00
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
if ($this->multiple === false)
|
|
|
|
{
|
|
|
|
$options[] = Html::_('select.option', '', Text::_('COM_COMPONENTBUILDER_SELECT_A_SITE_VIEW'));
|
|
|
|
}
|
|
|
|
foreach ($folders as $folder)
|
|
|
|
{
|
2024-07-26 16:33:01 +00:00
|
|
|
$options[] = Html::_('select.option', StringHelper::safe($folder), StringHelper::safe($folder, 'W'));
|
2024-03-02 20:10:30 +00:00
|
|
|
}
|
2018-04-13 20:11:35 +00:00
|
|
|
}
|
|
|
|
}
|
2021-03-05 03:08:47 +00:00
|
|
|
return $options;
|
|
|
|
}
|
|
|
|
}
|