-
dockx thibault authored
Removes filter tasks method and simplifies the class
Verified94aad523
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2011-2022 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*!
* \brief Column rendering Tasks
* Important that a "query method" must be defined in order to have the listing
*/
class tasksColumn extends Column
{
protected function renderSingleValue (ListingEntry $entry, string $value): string
{
if ($value == '') {
return ' ';
} else {
switch ($this->attributes[0]) {
case 'TYPE':
return static::filterTypes();
case 'TIMESTAMP':
return static::filterSchedule($value);
case 'STATUS':
return static::filterStatus($entry->row, $value, $entry['SUBSTATUS']);
default:
return parent::renderSingleValue($entry, $value);
}
}
}
static function filterTypes (): string
{
//A method retriving the type of the tasks.
return '';
}
static function filterSchedule (string $stamp): string
{
if ($stamp == '19700101000000') {
return htmlescape(_('immediately'));
} else {
return htmlescape(date('d.m.Y H:i:s', strtotime($stamp)));
}
}
static function filterStatus (int $row, string $status, string $substatus): string
{
if ($status == 'waiting') {
$status = '<img class="center" src="geticon.php?context=status&icon=task-waiting&size=16" alt="clock"/> '.htmlescape(_('Waiting'));
}
if ($status == 'error') {
$status = '<input class="center" type="image" src="geticon.php?context=status&icon=task-failure&size=16" title="'.htmlescape(_('Show error')).'" '.
'name="listing_showError_'.$row.'" style="padding:1px"/>'.htmlescape(_('Error'));
717273747576777879808182838485868788
}
if ($status == 'processed') {
$status = '<img class="center" src="geticon.php?context=status&icon=task-complete&size=16" alt=""/> '.htmlescape(_('Processed'));
}
/* Special handling for all entries that have
STATUS == "processing" && PROGRESS == NUMERIC
*/
if ($status == 'processing' && $substatus) {
$status = $substatus;
} elseif ($status == 'processing') {
$status = preg_replace('/ /', ' ', htmlescape(_('in progress')));
}
return $status;
}
}