CoreFiles by mySites.guru
workflowstage.php86 lines, 2,057 bytes, from Joomla_4.0.0-alpha7-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha6
md5
64bff82f87bc5461dd1b8a8294fd348d
sha1
dfd07af95265a39c1a0f57d64cc72d664e79b788
sha256
dae6c5c577541521e114313c2eb6c8695ee7123ac4665cd5e221e5ad98a1de80
<?php
/**
 * @package     Joomla.Libraries
 * @subpackage  HTML
 *
 * @copyright   Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

/**
 * Utility class working with workflow states select lists
 *
 * @since  4.0.0
 */
abstract class JHtmlWorkflowstage
{

	/**
	 * Get a list of the available workflow stages.
	 *
	 * @param   array  $options  An array of options for the control
	 *
	 * @return  array
	 *
	 * @since   4.0.0
	 */
	public static function existing($options)
	{
		// Get the database object and a new query object.
		$db    = Factory::getDbo();
		$query = $db->getQuery(true);

		// Build the query.
		$query->select(
					$db->quoteName(
						[
							'ws.id',
							'ws.title',
							'w.id',
							'w.title'
						],
						[
							'workflow_stage_id',
							'workflow_stage_title',
							'workflow_id',
							'workflow_title'
						]
					)
				)
			->from($db->quoteName('#__workflow_stages', 'ws'))
			->leftJoin($db->quoteName('#__workflows', 'w') . ' ON w.id = ws.workflow_id')
			->where('w.published = 1')
			->order('ws.ordering');

		// Set the query and load the options.
		$stages = $db->setQuery($query)->loadObjectList();

		$workflowStages = array();

		// Grouping the stages by workflow
		foreach ($stages as $stage)
		{
			// Using workflow ID to differentiate workflows having same title
			$workflowStageKey = Text::_($stage->workflow_title) . ' (' . $stage->workflow_id . ')';

			if (!array_key_exists($workflowStageKey, $workflowStages))
			{
				$workflowStages[$workflowStageKey] = array();
			}

			$workflowStages[$workflowStageKey][] = HTMLHelper::_('select.option', $stage->workflow_stage_id, Text::_($stage->workflow_stage_title));
		}

		$prefix[] = array(
			HTMLHelper::_('select.option', '', $options['title'])
		);

		return array_merge($prefix, $workflowStages);
	}
}

The same content is in 4 releases, Joomla 4.0.0-alpha7 to 4.0.0-alpha10. See them all, or every version of this file.