CoreFiles by mySites.guru
workflowstage.php86 lines, 2,027 bytes, from Joomla_4.0.0-alpha11-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha10
md5
c184eb0e5b630077fe1e0664aef587cf
sha1
765144b04f1bdc1f61ddaa00baea63ed09232691
sha256
0143cdfac541342a6ca2f4374e929e420e9bdd1cff5da95417e7fa5f2e04d1f0
<?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 2 releases, Joomla 4.0.0-alpha11 to 4.0.0-alpha12. See them all, or every version of this file.