| Current Path : /var/www/html/administrator/components/com_jchat/Field/ |
| Current File : /var/www/html/administrator/components/com_jchat/Field/LoadtonesField.php |
<?php
namespace JExtstore\Component\JChat\Administrator\Field;
/**
* @package JCHAT::CONFIG::administrator::components::com_jchat
* @subpackage Field
* @author Joomla! Extensions Store
* @copyright (C) 2024 - Joomla! Extensions Store
* @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html
*/
defined ( '_JEXEC' ) or die ( 'Restricted access' );
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\HTML\HTMLHelper;
/**
* Ringtones selector
* @package JCHAT::CONFIG::administrator::components::com_jchat
* @subpackage Field
* @since 2.0
*/
class LoadtonesField extends ListField {
/**
* The form field type.
*
* @var string
* @since 11.1
*/
protected $type = 'loadtones';
function getOptions() {
$options = array ();
$path = JPATH_SITE . '/components/com_jchat/sounds/mp3/ringtones';
$iterator = new \DirectoryIterator ( $path );
foreach ( $iterator as $fileEntity ) {
$fileName = $fileEntity->getFilename ();
if (! $fileEntity->isDot () && ! $fileEntity->isDir () && $fileName !== 'index.html' && $fileName !== 'skype.mp3' && strpos($fileName, 'default') !== 0) {
$name = str_replace('_', ' ', ucfirst ( $fileEntity->getBasename ( '.mp3' ) ) );
$name = preg_replace('/\d+/i', '', $name);
$options [] = HTMLHelper::_ ( 'select.option', $fileEntity->getFilename (), $name );
}
}
$options = array_merge ( $options, parent::getOptions () );
return $options;
}
}