mirror of
https://github.com/kvazar-network/webapp.git
synced 2025-03-12 13:41:43 +00:00
add formatType filter
This commit is contained in:
parent
326866e6d7
commit
335f4e8fcd
@ -17,6 +17,13 @@ class AppExtension extends AbstractExtension
|
|||||||
$this,
|
$this,
|
||||||
'jIdenticon'
|
'jIdenticon'
|
||||||
]
|
]
|
||||||
|
),
|
||||||
|
new TwigFilter(
|
||||||
|
'format_type',
|
||||||
|
[
|
||||||
|
$this,
|
||||||
|
'formatType'
|
||||||
|
]
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -50,4 +57,71 @@ class AppExtension extends AbstractExtension
|
|||||||
$format
|
$format
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function formatType(
|
||||||
|
mixed $value,
|
||||||
|
int $code
|
||||||
|
): string
|
||||||
|
{
|
||||||
|
switch ($code)
|
||||||
|
{
|
||||||
|
case \Kvazar\Index\Manticore::TYPE_NULL:
|
||||||
|
|
||||||
|
return '[null]';
|
||||||
|
|
||||||
|
case \Kvazar\Index\Manticore::TYPE_BOOL:
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'[bool:%s]',
|
||||||
|
$value ? 'true' : 'false'
|
||||||
|
);
|
||||||
|
|
||||||
|
case \Kvazar\Index\Manticore::TYPE_INT:
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'[int:%d]',
|
||||||
|
$value
|
||||||
|
);
|
||||||
|
|
||||||
|
case \Kvazar\Index\Manticore::TYPE_FLOAT:
|
||||||
|
|
||||||
|
return sprintf(
|
||||||
|
'[float:%s]',
|
||||||
|
$value
|
||||||
|
);
|
||||||
|
|
||||||
|
case \Kvazar\Index\Manticore::TYPE_STRING:
|
||||||
|
|
||||||
|
return (string) nl2br(
|
||||||
|
$value
|
||||||
|
);
|
||||||
|
|
||||||
|
case \Kvazar\Index\Manticore::TYPE_BIN:
|
||||||
|
|
||||||
|
return '[binary]';
|
||||||
|
|
||||||
|
case \Kvazar\Index\Manticore::TYPE_JSON:
|
||||||
|
|
||||||
|
return '[json]';
|
||||||
|
|
||||||
|
case \Kvazar\Index\Manticore::TYPE_XML:
|
||||||
|
|
||||||
|
return '[xml]';
|
||||||
|
|
||||||
|
case \Kvazar\Index\Manticore::TYPE_BASE_64:
|
||||||
|
|
||||||
|
return '[base64]';
|
||||||
|
|
||||||
|
case \Kvazar\Index\Manticore::TYPE_ARRAY:
|
||||||
|
|
||||||
|
return '[array]';
|
||||||
|
|
||||||
|
case \Kvazar\Index\Manticore::TYPE_OBJECT:
|
||||||
|
|
||||||
|
return '[array]';
|
||||||
|
|
||||||
|
default:
|
||||||
|
return '[undefined]';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -24,10 +24,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<a class="d-block" href="{{ path('main_transaction',{'transaction':record.transaction}) }}">
|
<a class="d-block" href="{{ path('main_transaction',{'transaction':record.transaction}) }}">
|
||||||
<div class="f-s-16 mb-16 of-a">
|
<div class="f-s-16 mb-16 of-a">
|
||||||
{{ record.key }}
|
{{ record.key | format_type(record.type.key) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-20 of-a">
|
<div class="mb-20 of-a">
|
||||||
{{ record.value | nl2br }}
|
{{ record.value | format_type(record.type.value) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="f-s-12">
|
<div class="f-s-12">
|
||||||
{{ record.time | format_date }} {{ 'in' | trans }} {{ record.block }}
|
{{ record.time | format_date }} {{ 'in' | trans }} {{ record.block }}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<link>{{ url('main_index') }}</link>
|
<link>{{ url('main_index') }}</link>
|
||||||
{% for record in records %}
|
{% for record in records %}
|
||||||
<item>
|
<item>
|
||||||
<title>{{ record.key }}</title>
|
<title>{{ record.key | format_type(record.type.key) }}</title>
|
||||||
<author>{{ record.namespace }}</author>
|
<author>{{ record.namespace }}</author>
|
||||||
<pubDate>{{ record.time | date('D, d M Y h:i:s O') }}</pubDate>
|
<pubDate>{{ record.time | date('D, d M Y h:i:s O') }}</pubDate>
|
||||||
<guid>{{ url('main_transaction',{'transaction':record.transaction}) }}</guid>
|
<guid>{{ url('main_transaction',{'transaction':record.transaction}) }}</guid>
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
<div class="mx-a mw-560 px-16">
|
<div class="mx-a mw-560 px-16">
|
||||||
<a class="d-block" href="{{ path('main_transaction',{'transaction':record.transaction}) }}">
|
<a class="d-block" href="{{ path('main_transaction',{'transaction':record.transaction}) }}">
|
||||||
<div class="f-s-16 mb-16 of-a">
|
<div class="f-s-16 mb-16 of-a">
|
||||||
{{ record.key }}
|
{{ record.key | format_type(record.type.key) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-20 of-a">
|
<div class="mb-20 of-a">
|
||||||
{{ record.value | nl2br }}
|
{{ record.value | format_type(record.type.value) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="f-s-12">
|
<div class="f-s-12">
|
||||||
{{ record.time | format_date }} {{ 'in' | trans }} {{ record.block }}
|
{{ record.time | format_date }} {{ 'in' | trans }} {{ record.block }}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<link>{{ url('main_namespace',{'namespace':request.get('namespace')}) }}</link>
|
<link>{{ url('main_namespace',{'namespace':request.get('namespace')}) }}</link>
|
||||||
{% for record in records %}
|
{% for record in records %}
|
||||||
<item>
|
<item>
|
||||||
<title>{{ record.key }}</title>
|
<title>{{ record.key | format_type(record.type.key) }}</title>
|
||||||
<author>{{ record.namespace }}</author>
|
<author>{{ record.namespace }}</author>
|
||||||
<pubDate>{{ record.time | date('D, d M Y h:i:s O') }}</pubDate>
|
<pubDate>{{ record.time | date('D, d M Y h:i:s O') }}</pubDate>
|
||||||
<guid>{{ url('main_transaction',{'transaction':record.transaction}) }}</guid>
|
<guid>{{ url('main_transaction',{'transaction':record.transaction}) }}</guid>
|
||||||
|
@ -25,10 +25,10 @@
|
|||||||
<div class="t-center px-16">
|
<div class="t-center px-16">
|
||||||
<div class="mx-a mw-560 px-16">
|
<div class="mx-a mw-560 px-16">
|
||||||
<div class="f-s-16 mb-16 of-a">
|
<div class="f-s-16 mb-16 of-a">
|
||||||
{{ record.key }}
|
{{ record.key | format_type(record.type.key) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-20 of-a">
|
<div class="mb-20 of-a">
|
||||||
{{ record.value | nl2br }}
|
{{ record.value | format_type(record.type.value) }}
|
||||||
</div>
|
</div>
|
||||||
<div class="f-s-12">
|
<div class="f-s-12">
|
||||||
{{ record.time | format_date }} {{ 'in' | trans }} {{ record.block }}
|
{{ record.time | format_date }} {{ 'in' | trans }} {{ record.block }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user