@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'); /** * Sermonsfilterlinktype Form Field class for the Sermondistributor component */ class JFormFieldSermonsfilterlinktype extends JFormFieldList { /** * The sermonsfilterlinktype field type. * * @var string */ public $type = 'sermonsfilterlinktype'; /** * 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('link_type')); $query->from($db->quoteName('#__sermondistributor_sermon')); $query->order($db->quoteName('link_type') . ' 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_DOWNLOAD_LINK_OPTION') . ' -'); if ($results) { // get sermonsmodel $model = SermondistributorHelper::getModel('sermons'); $results = array_unique($results); foreach ($results as $link_type) { // Translate the link_type selection $text = $model->selectionTranslation($link_type,'link_type'); // Now add the link_type and its text to the options array $_filter[] = JHtml::_('select.option', $link_type, JText::_($text)); } } return $_filter; } }