| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/dijon/components/com_community/libraries/fields/ |
Upload File : |
<?php
/**
* @copyright (C) 2013 iJoomla, Inc. - All rights reserved.
* @license GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html)
* @author iJoomla.com <webmaster@ijoomla.com>
* @url https://www.jomsocial.com/license-agreement
* The PHP code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript *are NOT GPL, and are released under the IJOOMLA Proprietary Use License v1.0
* More info at https://www.jomsocial.com/license-agreement
*/
use Joomla\CMS\Language\Text;
// no direct access
defined('_JEXEC') or die('Restricted access');
require_once (COMMUNITY_COM_PATH.'/libraries/fields/profilefield.php');
class CFieldsSelect extends CProfileField
{
public function getFieldHTML( $field , $required, $isDropDown = true)
{
$required = ($field->required == 1) ? ' data-required="true"' : '';
$optionSize = 1; // the default 'select below'
if( !empty( $field->options ) )
{
$optionSize += count($field->options);
}
$dropDown = ($isDropDown) ? '' : ' size="'.$optionSize.'"';
//CFactory::load( 'helpers' , 'string' );
$html = '<select id="field'.$field->id.'" name="field' . $field->id . '"' . $dropDown . ' class="joms-select" title="' . CStringHelper::escape( Text::_( $field->tips ) ). '" style="'.$this->getStyle().'" size="'.$this->params->get('size').'" '.$required.'>';
$defaultSelected = '';
//@rule: If there is no value, we need to default to a default value
if(empty( $field->value ) )
{
$defaultSelected .= ' selected="selected"';
}
if($isDropDown)
{
$html .= '<option value="" ' . $defaultSelected . '>' . Text::_('COM_COMMUNITY_SELECT_BELOW') . '</option>';
}
if( !empty( $field->options ) )
{
$selectedElement = 0;
//CFactory::load( 'libraries' , 'template' );
foreach( $field->options as $option )
{
//for some reason,
$selected = ( $option == $field->value ||
$option == CTemplate::escape($field->value) ||
str_replace('&','&',html_entity_decode($field->value)) == $option) ? ' selected="selected"' : '';
if( !empty( $selected ) )
{
$selectedElement++;
}
$html .= '<option value="' . CTemplate::escape( $option ) . '"' . $selected . '>' . Text::_( $option ) . '</option>';
}
if($selectedElement == 0)
{
//if nothing is selected, we default the 1st option to be selected.
$eleName = 'field'.$field->id;
$html .=<<< HTML
<script type='text/javascript'>
var slt = document.getElementById('$eleName');
if(slt != null)
{
slt.options[0].selected = true;
}
</script>
HTML;
}
}
$html .= '</select>';
// $html .= '<span id="errfield'.$field->id.'msg" style="display:none;"> </span>';
return $html;
}
public function isValid( $value , $required )
{
if( ($required && empty($value)) )
{
return false;
}
return true;
}
}