[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_scheduler 6 * 7 * @copyright (C) 2021 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 // Restrict direct access 12 defined('_JEXEC') or die; 13 14 use Joomla\CMS\Application\CMSWebApplicationInterface; 15 use Joomla\CMS\Factory; 16 use Joomla\CMS\HTML\HTMLHelper; 17 use Joomla\CMS\Language\Text; 18 use Joomla\CMS\Layout\LayoutHelper; 19 use Joomla\CMS\Router\Route; 20 use Joomla\CMS\Session\Session; 21 use Joomla\Component\Scheduler\Administrator\Task\Status; 22 use Joomla\Component\Scheduler\Administrator\View\Tasks\HtmlView; 23 24 /** @var HtmlView $this*/ 25 26 /** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */ 27 $wa = $this->document->getWebAssetManager(); 28 $wa->useScript('table.columns') 29 ->useScript('multiselect') 30 ->useScript('com_scheduler.test-task') 31 ->useStyle('com_scheduler.admin-view-tasks-css'); 32 33 Text::script('COM_SCHEDULER_TEST_RUN_TITLE'); 34 Text::script('COM_SCHEDULER_TEST_RUN_TASK'); 35 Text::script('COM_SCHEDULER_TEST_RUN_DURATION'); 36 Text::script('COM_SCHEDULER_TEST_RUN_OUTPUT'); 37 Text::script('COM_SCHEDULER_TEST_RUN_STATUS_STARTED'); 38 Text::script('COM_SCHEDULER_TEST_RUN_STATUS_COMPLETED'); 39 Text::script('COM_SCHEDULER_TEST_RUN_STATUS_TERMINATED'); 40 Text::script('JLIB_JS_AJAX_ERROR_OTHER'); 41 Text::script('JLIB_JS_AJAX_ERROR_CONNECTION_ABORT'); 42 Text::script('JLIB_JS_AJAX_ERROR_TIMEOUT'); 43 Text::script('JLIB_JS_AJAX_ERROR_NO_CONTENT'); 44 Text::script('JLIB_JS_AJAX_ERROR_PARSE'); 45 46 try { 47 /** @var CMSWebApplicationInterface $app */ 48 $app = Factory::getApplication(); 49 } catch (Exception $e) { 50 die('Failed to get app'); 51 } 52 53 $user = $app->getIdentity(); 54 $userId = $user->get('id'); 55 $listOrder = $this->escape($this->state->get('list.ordering')); 56 $listDirn = $this->escape($this->state->get('list.direction')); 57 $saveOrder = $listOrder == 'a.ordering'; 58 $section = null; 59 $mode = false; 60 61 if ($saveOrder && !empty($this->items)) { 62 $saveOrderingUrl = 'index.php?option=com_scheduler&task=tasks.saveOrderAjax&tmpl=component&' . Session::getFormToken() . '=1'; 63 HTMLHelper::_('draggablelist.draggable'); 64 } 65 66 $this->document->addScriptOptions('com_scheduler.test-task.token', Session::getFormToken()); 67 ?> 68 69 <form action="<?php echo Route::_('index.php?option=com_scheduler&view=tasks'); ?>" method="post" name="adminForm" 70 id="adminForm"> 71 <div id="j-main-container" class="j-main-container"> 72 <?php 73 // Search tools bar 74 echo LayoutHelper::render('joomla.searchtools.default', array('view' => $this)); 75 ?> 76 77 <!-- If no tasks --> 78 <?php if (empty($this->items)) : ?> 79 <!-- No tasks --> 80 <div class="alert alert-info"> 81 <span class="icon-info-circle" aria-hidden="true"></span><span 82 class="visually-hidden"><?php echo Text::_('INFO'); ?></span> 83 <?php echo Text::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> 84 </div> 85 <?php endif; ?> 86 87 <!-- If there are tasks, we start with the table --> 88 <?php if (!empty($this->items)) : ?> 89 <!-- Tasks table starts here --> 90 <table class="table" id="categoryList"> 91 92 <caption class="visually-hidden"> 93 <?php echo Text::_('COM_SCHEDULER_TABLE_CAPTION'); ?>, 94 <span id="orderedBy"><?php echo Text::_('JGLOBAL_SORTED_BY'); ?> </span>, 95 <span id="filteredBy"><?php echo Text::_('JGLOBAL_FILTERED_BY'); ?></span> 96 </caption> 97 98 <!-- Tasks table header --> 99 <thead> 100 <tr> 101 102 <!-- Select all --> 103 <td class="w-1 text-center"> 104 <?php echo HTMLHelper::_('grid.checkall'); // "Select all" checkbox 105 ?> 106 </td> 107 108 <!-- Ordering?--> 109 <th scope="col" class="w-1 d-none d-md-table-cell text-center"> 110 <!-- Might need to adjust method args here --> 111 <?php echo HTMLHelper::_('searchtools.sort', '', 'a.ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-sort'); ?> 112 </th> 113 <!-- Task State --> 114 <th scope="col" class="w-1 text-center"> 115 <?php echo HTMLHelper::_('searchtools.sort', 'JSTATUS', 'a.state', $listDirn, $listOrder); ?> 116 </th> 117 118 <!-- Task title header --> 119 <th scope="col"> 120 <?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?> 121 </th> 122 123 <!-- Task type header --> 124 <th scope="col" class="d-none d-md-table-cell"> 125 <?php echo HTMLHelper::_('searchtools.sort', 'COM_SCHEDULER_TASK_TYPE', 'j.type_title', $listDirn, $listOrder) ?> 126 </th> 127 128 <!-- Last runs --> 129 <th scope="col" class="d-none d-lg-table-cell"> 130 <?php echo HTMLHelper::_('searchtools.sort', 'COM_SCHEDULER_LAST_RUN_DATE', 'a.last_execution', $listDirn, $listOrder) ?> 131 </th> 132 133 <!-- Test task --> 134 <th scope="col" class="d-none d-md-table-cell"> 135 <?php echo Text::_('COM_SCHEDULER_TEST_TASK'); ?> 136 </th> 137 138 <!-- Priority --> 139 <th scope="col" class="d-none d-lg-table-cell"> 140 <?php echo HTMLHelper::_('searchtools.sort', 'COM_SCHEDULER_TASK_PRIORITY', 'a.priority', $listDirn, $listOrder) ?> 141 </th> 142 143 <!-- Task ID --> 144 <th scope="col" class="w-5 d-none d-md-table-cell"> 145 <?php echo HTMLHelper::_('searchtools.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?> 146 </th> 147 </tr> 148 </thead> 149 150 <!-- Table body begins --> 151 <tbody <?php if ($saveOrder) : ?> 152 class="js-draggable" data-url="<?php echo $saveOrderingUrl; ?>" data-direction="<?php echo strtolower($listDirn); ?>" data-nested="true" <?php 153 endif; ?>> 154 <?php foreach ($this->items as $i => $item) : 155 $canCreate = $user->authorise('core.create', 'com_scheduler'); 156 $canEdit = $user->authorise('core.edit', 'com_scheduler'); 157 $canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || is_null($item->checked_out); 158 $canChange = $user->authorise('core.edit.state', 'com_scheduler') && $canCheckin; 159 ?> 160 161 <!-- Row begins --> 162 <tr class="row<?php echo $i % 2; ?>" 163 data-draggable-group="none" 164 > 165 <!-- Item Checkbox --> 166 <td class="text-center"> 167 <?php echo HTMLHelper::_('grid.id', $i, $item->id, false, 'cid', 'cb', $item->title); ?> 168 </td> 169 170 <!-- Draggable handle --> 171 <td class="text-center d-none d-md-table-cell"> 172 <?php 173 $iconClass = ''; 174 if (!$canChange) { 175 $iconClass = ' inactive'; 176 } elseif (!$saveOrder) { 177 $iconClass = ' inactive" title="' . Text::_('JORDERINGDISABLED'); 178 } 179 ?> 180 181 <span class="sortable-handler <?php echo $iconClass ?>"> 182 <span class="icon-ellipsis-v" aria-hidden="true"></span> 183 </span> 184 185 <?php if ($canChange && $saveOrder) : ?> 186 <input type="text" class="hidden text-area-order" name="order[]" size="5" 187 value="<?php echo $item->ordering; ?>" 188 > 189 <?php endif; ?> 190 </td> 191 192 <!-- Item State --> 193 <td class="text-center"> 194 <?php echo HTMLHelper::_('jgrid.published', $item->state, $i, 'tasks.', $canChange); ?> 195 </td> 196 197 <!-- Item name, edit link, and note (@todo: should it be moved?) --> 198 <th scope="row"> 199 <?php if ($item->checked_out) : ?> 200 <?php echo HTMLHelper::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'tasks.', $canCheckin); ?> 201 <?php endif; ?> 202 <?php if ($item->locked) : ?> 203 <?php echo HTMLHelper::_('jgrid.action', $i, 'unlock', ['enabled' => $canChange, 'prefix' => 'tasks.', 204 'active_class' => 'none fa fa-running border-dark text-body', 205 'inactive_class' => 'none fa fa-running', 'tip' => true, 'translate' => false, 206 'active_title' => Text::sprintf('COM_SCHEDULER_RUNNING_SINCE', HTMLHelper::_('date', $item->last_execution, 'DATE_FORMAT_LC5')), 207 'inactive_title' => Text::sprintf('COM_SCHEDULER_RUNNING_SINCE', HTMLHelper::_('date', $item->last_execution, 'DATE_FORMAT_LC5')), 208 ]); ?> 209 <?php endif; ?> 210 <span class="task-title"> 211 <?php if ($canEdit) : ?> 212 <a href="<?php echo Route::_('index.php?option=com_scheduler&task=task.edit&id=' . $item->id); ?>" 213 title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo $this->escape($item->title); ?>"> <?php echo $this->escape($item->title); ?> 214 </a> 215 <?php else : ?> 216 <?php echo $this->escape($item->title); ?> 217 <?php endif; ?> 218 <?php if (!in_array($item->last_exit_code, [Status::OK, Status::WILL_RESUME])) : ?> 219 <span class="failure-indicator icon-exclamation-triangle" aria-hidden="true"></span> 220 <div role="tooltip"> 221 <?php echo Text::sprintf("COM_SCHEDULER_MANAGER_TOOLTIP_TASK_FAILING", $item->last_exit_code); ?> 222 </div> 223 <?php endif; ?> 224 </span> 225 226 <?php if ($item->note) : ?> 227 <span class="small"> 228 <?php echo Text::sprintf('JGLOBAL_LIST_NOTE', $this->escape($item->note)); ?> 229 </span> 230 <?php endif; ?> 231 </th> 232 233 <!-- Item type --> 234 <td class="small d-none d-md-table-cell"> 235 <?php echo $this->escape($item->safeTypeTitle); ?> 236 </td> 237 238 <!-- Last run date --> 239 <td class="small d-none d-lg-table-cell"> 240 <?php echo $item->last_execution ? HTMLHelper::_('date', $item->last_execution, 'DATE_FORMAT_LC5') : '-'; ?> 241 </td> 242 243 <!-- Test task --> 244 <td class="small d-none d-md-table-cell"> 245 <button type="button" class="btn btn-sm btn-warning" <?php echo $item->state < 0 ? 'disabled' : ''; ?> data-id="<?php echo (int) $item->id; ?>" data-title="<?php echo htmlspecialchars($item->title); ?>" data-bs-toggle="modal" data-bs-backdrop="static" data-bs-target="#scheduler-test-modal"> 246 <span class="fa fa-play fa-sm me-2"></span> 247 <?php echo Text::_('COM_SCHEDULER_TEST_RUN'); ?> 248 </button> 249 </td> 250 251 <!-- Priority --> 252 <td class="small d-none d-lg-table-cell"> 253 <?php if ($item->priority === -1) : ?> 254 <span class="badge bg-info"><?php echo Text::_('COM_SCHEDULER_LABEL_TASK_PRIORITY_LOW'); ?></span> 255 <?php elseif ($item->priority === 0) : ?> 256 <span class="badge bg-success"><?php echo Text::_('COM_SCHEDULER_LABEL_TASK_PRIORITY_NORMAL'); ?></span> 257 <?php elseif ($item->priority === 1) : ?> 258 <span class="badge bg-danger"><?php echo Text::_('COM_SCHEDULER_LABEL_TASK_PRIORITY_HIGH'); ?></span> 259 <?php endif; ?> 260 </td> 261 262 <!-- Item ID --> 263 <td class="d-none d-md-table-cell"> 264 <?php echo (int) $item->id; ?> 265 </td> 266 </tr> 267 <?php endforeach; ?> 268 </tbody> 269 </table> 270 271 <?php 272 // Load the pagination. (@todo: testing) 273 echo $this->pagination->getListFooter(); 274 275 // Modal for test runs 276 $modalparams = [ 277 'title' => '', 278 ]; 279 280 $modalbody = '<div class="p-3"></div>'; 281 282 echo HTMLHelper::_('bootstrap.renderModal', 'scheduler-test-modal', $modalparams, $modalbody); 283 284 ?> 285 286 <?php endif; ?> 287 288 <input type="hidden" name="task" value=""> 289 <input type="hidden" name="boxchecked" value="0"> 290 <?php echo HTMLHelper::_('form.token'); ?> 291 </div> 292 </form>
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 |