@copyright Copyright (C) 2015. All Rights Reserved @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html A sermon distributor that links to Dropbox. /----------------------------------------------------------------------------------------------------------------------------------*/ // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import the list field type jimport('joomla.form.helper'); JFormHelper::loadFieldClass('list'); /** * Externalsourcesfilterupdatemethod Form Field class for the Sermondistributor component */ class JFormFieldExternalsourcesfilterupdatemethod extends JFormFieldList { /** * The externalsourcesfilterupdatemethod field type. * * @var string */ public $type = 'externalsourcesfilterupdatemethod'; /** * Method to get a list of options for a list input. * * @return array An array of JHtml options. */ protected function getOptions() { // Get a db connection. $db = JFactory::getDbo(); // Create a new query object. $query = $db->getQuery(true); // Select the text. $query->select($db->quoteName('update_method')); $query->from($db->quoteName('#__sermondistributor_external_source')); $query->order($db->quoteName('update_method') . ' ASC'); // Reset the query using our newly populated query object. $db->setQuery($query); $results = $db->loadColumn(); $_filter = array(); $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_SERMONDISTRIBUTOR_FILTER_SELECT_UPDATE_METHOD') . ' -'); if ($results) { // get external_sourcesmodel $model = SermondistributorHelper::getModel('external_sources'); $results = array_unique($results); foreach ($results as $update_method) { // Translate the update_method selection $text = $model->selectionTranslation($update_method,'update_method'); // Now add the update_method and its text to the options array $_filter[] = JHtml::_('select.option', $update_method, JText::_($text)); } } return $_filter; } }