@copyright Copyright (C) 2020 Vast Development Method. All rights reserved. @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html Portal for mobile health clinics /-----------------------------------------------------------------------------------------------------------------------------*/ // No direct access to this file defined('_JEXEC') or die('Restricted access'); use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; // import the list field type jimport('joomla.form.helper'); JFormHelper::loadFieldClass('list'); /** * Healtheducationsfiltereducationtype Form Field class for the Ehealthportal component */ class JFormFieldHealtheducationsfiltereducationtype extends JFormFieldList { /** * The healtheducationsfiltereducationtype field type. * * @var string */ public $type = 'healtheducationsfiltereducationtype'; /** * Method to get a list of options for a list input. * * @return array An array of Html options. */ protected function getOptions() { // Get a db connection. $db = Factory::getDbo(); // Create a new query object. $query = $db->getQuery(true); // Select the text. $query->select($db->quoteName('education_type')); $query->from($db->quoteName('#__ehealthportal_health_education')); $query->order($db->quoteName('education_type') . ' ASC'); // Reset the query using our newly populated query object. $db->setQuery($query); $_results = $db->loadColumn(); $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_EHEALTHPORTAL_FILTER_SELECT_TYPE') . ' -'); if ($_results) { // get health_educationsmodel $_model = EhealthportalHelper::getModel('health_educations'); $_results = array_unique($_results); foreach ($_results as $education_type) { // Translate the education_type selection $_text = $_model->selectionTranslation($education_type,'education_type'); // Now add the education_type and its text to the options array $_filter[] = Html::_('select.option', $education_type, Text::_($_text)); } } return $_filter; } }