[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 namespace Joomla\CMS\HTML\Helpers; 11 12 use Joomla\CMS\Factory; 13 use Joomla\CMS\HTML\HTMLHelper; 14 use Joomla\CMS\Language\Text; 15 16 // phpcs:disable PSR1.Files.SideEffects 17 \defined('JPATH_PLATFORM') or die; 18 // phpcs:enable PSR1.Files.SideEffects 19 20 /** 21 * Utility class working with workflow states select lists 22 * 23 * @since 4.0.0 24 */ 25 abstract class WorkflowStage 26 { 27 /** 28 * Get a list of the available workflow stages. 29 * 30 * @param array $options An array of options for the control 31 * 32 * @return array 33 * 34 * @since 4.0.0 35 */ 36 public static function existing($options) 37 { 38 // Get the database object and a new query object. 39 $db = Factory::getDbo(); 40 $query = $db->getQuery(true); 41 42 // Build the query. 43 $query->select( 44 [ 45 $db->quoteName('ws.id', 'workflow_stage_id'), 46 $db->quoteName('ws.title', 'workflow_stage_title'), 47 $db->quoteName('w.id', 'workflow_id'), 48 $db->quoteName('w.title', 'workflow_title'), 49 ] 50 ) 51 ->from($db->quoteName('#__workflow_stages', 'ws')) 52 ->join('LEFT', $db->quoteName('#__workflows', 'w'), $db->quoteName('w.id') . ' = ' . $db->quoteName('ws.workflow_id')) 53 ->where($db->quoteName('w.published') . ' = 1') 54 ->order($db->quoteName('ws.ordering')); 55 56 // Set the query and load the options. 57 $stages = $db->setQuery($query)->loadObjectList(); 58 59 $workflowStages = array(); 60 61 // Grouping the stages by workflow 62 foreach ($stages as $stage) { 63 // Using workflow ID to differentiate workflows having same title 64 $workflowStageKey = Text::_($stage->workflow_title) . ' (' . $stage->workflow_id . ')'; 65 66 if (!array_key_exists($workflowStageKey, $workflowStages)) { 67 $workflowStages[$workflowStageKey] = array(); 68 } 69 70 $workflowStages[$workflowStageKey][] = HTMLHelper::_('select.option', $stage->workflow_stage_id, Text::_($stage->workflow_stage_title)); 71 } 72 73 $prefix[] = array( 74 HTMLHelper::_('select.option', '', $options['title']) 75 ); 76 77 return array_merge($prefix, $workflowStages); 78 } 79 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |