| Current Path : /home/purehotels/public_html/modules/mod_easyfolderlisting/elements/ |
| Current File : /home/purehotels/public_html/modules/mod_easyfolderlisting/elements/fixedfolderlist.php |
<?php
/**
* @version 3.0.4
* @author Michael A. Gilkes (jaido7@yahoo.com)
* @copyright Michael Albert Gilkes
* @license GNU/GPLv2
*/
/*
Easy Folder Listing Module for Joomla!
Copyright (C) 2010-2021 Michael Albert Gilkes
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// no direct access
defined('_JEXEC') or die();
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\Filesystem\Folder;
use Joomla\Filesystem\Path;
\Joomla\CMS\Form\FormHelper::loadFieldClass('folderlist');
class JFormFieldFixedFolderlist extends \JFormFieldFolderList
{
/**
* The form field type.
*/
protected $type = 'fixedfolderlist';
/**
* Method to get the field options.
*
* @return array The field option objects.
*/
protected function getOptions()
{
$options = array();
$path = $this->directory;
if (!is_dir($path))
{
$path = JPATH_ROOT . '/' . $path;
}
$path = Path::clean($path);
// Prepend some default options based on field attributes.
if (!$this->hideNone)
{
$options[] = HTMLHelper::_('select.option', '-1', Text::alt('JOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)));
}
if (!$this->hideDefault)
{
$options[] = HTMLHelper::_('select.option', '', Text::alt('JOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)));
}
// Get a list of folders in the search path with the given filter.
$folders = Folder::folders($path, $this->filter, $this->recursive, true);
// Build the options list from the list of folders.
if (is_array($folders))
{
foreach ($folders as $folder)
{
// Remove the root part and the leading /
$folder = trim(str_replace($path, '', $folder), '/');
// Check to see if the file is in the exclude mask.
if ($this->exclude)
{
if (preg_match(chr(1) . $this->exclude . chr(1), $folder))
{
continue;
}
}
$options[] = HTMLHelper::_('select.option', $folder, $folder);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(\JFormFieldList::getOptions(), $options);
return $options;
}
}