GenericTable: rename 'parse' option to 'format'

This commit is contained in:
Aaron van Geffen 2025-01-08 17:19:09 +01:00
parent cc0ff71ef7
commit 77809faada
6 changed files with 22 additions and 22 deletions

View File

@ -35,7 +35,7 @@ class ManageAlbums extends HTMLController
'tag' => [ 'tag' => [
'header' => 'Album', 'header' => 'Album',
'is_sortable' => true, 'is_sortable' => true,
'parse' => [ 'format' => [
'link' => BASEURL . '/editalbum/?id={ID_TAG}', 'link' => BASEURL . '/editalbum/?id={ID_TAG}',
'data' => 'tag', 'data' => 'tag',
], ],
@ -43,7 +43,7 @@ class ManageAlbums extends HTMLController
'slug' => [ 'slug' => [
'header' => 'Slug', 'header' => 'Slug',
'is_sortable' => true, 'is_sortable' => true,
'parse' => [ 'format' => [
'link' => BASEURL . '/editalbum/?id={ID_TAG}', 'link' => BASEURL . '/editalbum/?id={ID_TAG}',
'data' => 'slug', 'data' => 'slug',
], ],

View File

@ -38,7 +38,7 @@ class ManageAssets extends HTMLController
'checkbox' => [ 'checkbox' => [
'header' => '<input type="checkbox" id="selectall">', 'header' => '<input type="checkbox" id="selectall">',
'is_sortable' => false, 'is_sortable' => false,
'parse' => [ 'format' => [
'type' => 'function', 'type' => 'function',
'data' => function($row) { 'data' => function($row) {
return '<input type="checkbox" class="asset_select" name="delete[]" value="' . $row['id_asset'] . '">'; return '<input type="checkbox" class="asset_select" name="delete[]" value="' . $row['id_asset'] . '">';
@ -49,7 +49,7 @@ class ManageAssets extends HTMLController
'header' => '&nbsp;', 'header' => '&nbsp;',
'is_sortable' => false, 'is_sortable' => false,
'cell_class' => 'text-center', 'cell_class' => 'text-center',
'parse' => [ 'format' => [
'type' => 'function', 'type' => 'function',
'data' => function($row) { 'data' => function($row) {
$asset = Image::byRow($row); $asset = Image::byRow($row);
@ -87,7 +87,7 @@ class ManageAssets extends HTMLController
'value' => 'filename', 'value' => 'filename',
'header' => 'Filename', 'header' => 'Filename',
'is_sortable' => true, 'is_sortable' => true,
'parse' => [ 'format' => [
'type' => 'value', 'type' => 'value',
'link' => BASEURL . '/editasset/?id={ID_ASSET}', 'link' => BASEURL . '/editasset/?id={ID_ASSET}',
'data' => 'filename', 'data' => 'filename',
@ -96,7 +96,7 @@ class ManageAssets extends HTMLController
'id_user_uploaded' => [ 'id_user_uploaded' => [
'header' => 'User uploaded', 'header' => 'User uploaded',
'is_sortable' => true, 'is_sortable' => true,
'parse' => [ 'format' => [
'type' => 'function', 'type' => 'function',
'data' => function($row) { 'data' => function($row) {
if (!empty($row['id_user'])) if (!empty($row['id_user']))
@ -110,7 +110,7 @@ class ManageAssets extends HTMLController
'dimensions' => [ 'dimensions' => [
'header' => 'Dimensions', 'header' => 'Dimensions',
'is_sortable' => false, 'is_sortable' => false,
'parse' => [ 'format' => [
'type' => 'function', 'type' => 'function',
'data' => function($row) { 'data' => function($row) {
if (!empty($row['image_width'])) if (!empty($row['image_width']))

View File

@ -45,7 +45,7 @@ class ManageErrors extends HTMLController
'is_sortable' => true, 'is_sortable' => true,
], ],
'message' => [ 'message' => [
'parse' => [ 'format' => [
'type' => 'function', 'type' => 'function',
'data' => function($row) { 'data' => function($row) {
return $row['message'] . '<br>' . return $row['message'] . '<br>' .
@ -71,7 +71,7 @@ class ManageErrors extends HTMLController
'is_sortable' => true, 'is_sortable' => true,
], ],
'time' => [ 'time' => [
'parse' => [ 'format' => [
'type' => 'timestamp', 'type' => 'timestamp',
'data' => [ 'data' => [
'timestamp' => 'time', 'timestamp' => 'time',
@ -89,7 +89,7 @@ class ManageErrors extends HTMLController
'uid' => [ 'uid' => [
'header' => 'UID', 'header' => 'UID',
'is_sortable' => true, 'is_sortable' => true,
'parse' => [ 'format' => [
'link' => BASEURL . '/edituser/?id={ID_USER}', 'link' => BASEURL . '/edituser/?id={ID_USER}',
'data' => 'id_user', 'data' => 'id_user',
], ],

View File

@ -37,7 +37,7 @@ class ManageTags extends HTMLController
'tag' => [ 'tag' => [
'header' => 'Tag', 'header' => 'Tag',
'is_sortable' => true, 'is_sortable' => true,
'parse' => [ 'format' => [
'link' => BASEURL . '/edittag/?id={ID_TAG}', 'link' => BASEURL . '/edittag/?id={ID_TAG}',
'data' => 'tag', 'data' => 'tag',
], ],
@ -45,7 +45,7 @@ class ManageTags extends HTMLController
'slug' => [ 'slug' => [
'header' => 'Slug', 'header' => 'Slug',
'is_sortable' => true, 'is_sortable' => true,
'parse' => [ 'format' => [
'link' => BASEURL . '/edittag/?id={ID_TAG}', 'link' => BASEURL . '/edittag/?id={ID_TAG}',
'data' => 'slug', 'data' => 'slug',
], ],
@ -53,7 +53,7 @@ class ManageTags extends HTMLController
'id_user_owner' => [ 'id_user_owner' => [
'header' => 'Owning user', 'header' => 'Owning user',
'is_sortable' => true, 'is_sortable' => true,
'parse' => [ 'format' => [
'type' => 'function', 'type' => 'function',
'data' => function($row) { 'data' => function($row) {
if (!empty($row['id_user'])) if (!empty($row['id_user']))

View File

@ -37,7 +37,7 @@ class ManageUsers extends HTMLController
'surname' => [ 'surname' => [
'header' => 'Last name', 'header' => 'Last name',
'is_sortable' => true, 'is_sortable' => true,
'parse' => [ 'format' => [
'link' => BASEURL . '/edituser/?id={ID_USER}', 'link' => BASEURL . '/edituser/?id={ID_USER}',
'data' => 'surname', 'data' => 'surname',
], ],
@ -45,7 +45,7 @@ class ManageUsers extends HTMLController
'first_name' => [ 'first_name' => [
'header' => 'First name', 'header' => 'First name',
'is_sortable' => true, 'is_sortable' => true,
'parse' => [ 'format' => [
'link' => BASEURL . '/edituser/?id={ID_USER}', 'link' => BASEURL . '/edituser/?id={ID_USER}',
'data' => 'first_name', 'data' => 'first_name',
], ],
@ -53,7 +53,7 @@ class ManageUsers extends HTMLController
'slug' => [ 'slug' => [
'header' => 'Slug', 'header' => 'Slug',
'is_sortable' => true, 'is_sortable' => true,
'parse' => [ 'format' => [
'link' => BASEURL . '/edituser/?id={ID_USER}', 'link' => BASEURL . '/edituser/?id={ID_USER}',
'data' => 'slug', 'data' => 'slug',
], ],
@ -64,7 +64,7 @@ class ManageUsers extends HTMLController
'is_sortable' => true, 'is_sortable' => true,
], ],
'last_action_time' => [ 'last_action_time' => [
'parse' => [ 'format' => [
'type' => 'timestamp', 'type' => 'timestamp',
'data' => [ 'data' => [
'timestamp' => 'last_action_time', 'timestamp' => 'last_action_time',
@ -82,7 +82,7 @@ class ManageUsers extends HTMLController
'is_admin' => [ 'is_admin' => [
'is_sortable' => true, 'is_sortable' => true,
'header' => 'Admin?', 'header' => 'Admin?',
'parse' => [ 'format' => [
'type' => 'function', 'type' => 'function',
'data' => function($row) { 'data' => function($row) {
return $row['is_admin'] ? 'yes' : 'no'; return $row['is_admin'] ? 'yes' : 'no';

View File

@ -191,9 +191,9 @@ class GenericTable
foreach ($options['columns'] as $column) foreach ($options['columns'] as $column)
{ {
// Process data for this particular cell. // Process formatting
if (isset($column['parse'])) if (isset($column['format']))
$value = self::processCell($column['parse'], $row); $value = self::processFormatting($column['format'], $row);
else else
$value = $row[$column['value']]; $value = $row[$column['value']];
@ -209,7 +209,7 @@ class GenericTable
} }
} }
private function processCell($options, $rowData) private function processFormatting($options, $rowData)
{ {
if (!isset($options['type'])) if (!isset($options['type']))
$options['type'] = 'value'; $options['type'] = 'value';