CoreFiles by mySites.guru
NewsfeedsField.php71 lines, 1,366 bytes, from Joomla_4.2.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 4.2.0-alpha1
md5
a2904a42e59b1f2374327b14330b9761
sha1
5bdf4c99f4e024504964af43a7e73bbb113f1bf5
sha256
51cb1b1435583cca90b71417fd48cc0d8a9fa1b3c88fca848cd2e2d38680c9c7
<?php
/**
 * @package     Joomla.Administrator
 * @subpackage  com_newsfeeds
 *
 * @copyright   (C) 2009 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\Component\Newsfeeds\Administrator\Field;

\defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\ListField;

/**
 * News Feed List field.
 *
 * @since  1.6
 */
class NewsfeedsField extends ListField
{
	/**
	 * The form field type.
	 *
	 * @var		string
	 * @since   1.6
	 */
	protected $type = 'Newsfeeds';

	/**
	 * Method to get the field options.
	 *
	 * @return  array  The field option objects.
	 *
	 * @since   1.6
	 */
	protected function getOptions()
	{
		$options = array();

		$db    = Factory::getDbo();
		$query = $db->getQuery(true)
			->select(
				[
					$db->quoteName('id', 'value'),
					$db->quoteName('name', 'text'),
				]
			)
			->from($db->quoteName('#__newsfeeds', 'a'))
			->order($db->quoteName('a.name'));

		// Get the options.
		$db->setQuery($query);

		try
		{
			$options = $db->loadObjectList();
		}
		catch (\RuntimeException $e)
		{
			Factory::getApplication()->enqueueMessage($e->getMessage(), 'error');
		}

		// Merge any additional options in the XML definition.
		$options = array_merge(parent::getOptions(), $options);

		return $options;
	}
}

The same content is in 13 releases, Joomla 4.1.1-rc1 to 4.2.0-alpha2. See them all, or every version of this file.