mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Fix caption display
This commit is contained in:
@@ -612,57 +612,31 @@ class Application extends SilexApplication
|
||||
$twig->addFilter('base_from_coll', new \Twig_Filter_Function('phrasea::baseFromColl'));
|
||||
$twig->addFilter('AppName', new \Twig_Filter_Function('Alchemy\Phrasea\Controller\Admin\ConnectedUsers::appName'));
|
||||
$twig->addFilter(new \Twig_SimpleFilter('escapeSimpleQuote', function ($value) {
|
||||
$ret = str_replace("'", "\\'", $value);
|
||||
|
||||
return $ret;
|
||||
return str_replace("'", "\\'", $value);
|
||||
}));
|
||||
$twig->addFilter(new \Twig_SimpleFilter('highlight', function (\Twig_Environment $twig, $argument) {
|
||||
if (is_string($argument)) {
|
||||
return str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), twig_escape_filter($twig, $argument));
|
||||
}
|
||||
|
||||
$values = array();
|
||||
if (is_array($argument) && isset($argument['values'])) {
|
||||
foreach ($argument['values'] as $value) {
|
||||
$values[] = str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), twig_escape_filter($twig, $value['value']));
|
||||
}
|
||||
$twig->addFilter(new \Twig_SimpleFilter('highlight', function (\Twig_Environment $twig, $string) {
|
||||
return str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), $string);
|
||||
}, array('needs_environment' => true,'is_safe' => array('html'))));
|
||||
|
||||
return implode(' ' . $argument['separator'] . ' ', $values);
|
||||
}
|
||||
|
||||
throw new LogicException('highlight filter must be applied on strings or highlighted fields.');
|
||||
$twig->addFilter(new \Twig_SimpleFilter('linkify', function (\Twig_Environment $twig, $string) {
|
||||
return preg_replace(
|
||||
"(([^']{1})((https?|file):((/{2,4})|(\\{2,4}))[\w:#%/;$()~_?/\-=\\\.&]*)([^']{1}))"
|
||||
, '$1 $2 <a title="' . _('Open the URL in a new window') . '" class="ui-icon ui-icon-extlink" href="$2" style="display:inline;padding:2px 5px;margin:0 4px 0 2px;" target="_blank"> </a>$7'
|
||||
, $string
|
||||
);
|
||||
}, array('needs_environment' => true, 'is_safe' => array('html'))));
|
||||
$twig->addFilter(new \Twig_SimpleFilter('bounce', function (\Twig_Environment $twig, $argument) {
|
||||
if (false === is_array($argument) || !isset($argument['values'])) {
|
||||
throw new LogicException('bounce filter must be applied on values that come from highlighted fields.');
|
||||
}
|
||||
|
||||
$display = array();
|
||||
foreach ($argument['values'] as $value) {
|
||||
// value of a caption string
|
||||
$toDisplay = $value['value'];
|
||||
$twig->addFilter(new \Twig_SimpleFilter('bounce', function (\Twig_Environment $twig, $fieldValue, $fieldName, $searchRequest, $sbasId) {
|
||||
// bounce value if it is present in thesaurus as well
|
||||
if ($value['from_thesaurus']) {
|
||||
$toDisplay = "<a class=\"bounce\" onclick=\"bounce('" . $argument['sbas_id'] . "','"
|
||||
. str_replace("'", "\\'", $value['qjs'])
|
||||
. "', '"
|
||||
. str_replace("'", "\\'", $argument['name'])
|
||||
. "');return(false);\">"
|
||||
. twig_escape_filter($twig, $toDisplay)
|
||||
. "</a>";
|
||||
}
|
||||
return "<a class=\"bounce\" onclick=\"bounce('" .$sbasId . "','"
|
||||
. str_replace("'", "\\'",$searchRequest)
|
||||
. "', '"
|
||||
. str_replace("'", "\\'", $fieldName)
|
||||
. "');return(false);\">"
|
||||
. $fieldValue
|
||||
. "</a>";
|
||||
|
||||
// checks for urls in value and wrap them into <a> tags
|
||||
$toDisplay = preg_replace(
|
||||
"(([^']{1})((https?|file):((/{2,4})|(\\{2,4}))[\w:#%/;$()~_?/\-=\\\.&]*)([^']{1}))"
|
||||
, '$1 $2 <a title="' . _('Open the URL in a new window') . '" class="ui-icon ui-icon-extlink" href="$2" style="display:inline;padding:2px 5px;margin:0 4px 0 2px;" target="_blank"> </a>$7'
|
||||
, $toDisplay
|
||||
);
|
||||
|
||||
$display[] = $toDisplay;
|
||||
}
|
||||
|
||||
return implode(' ' . $argument['separator'] . ' ', $display);
|
||||
}, array('needs_environment' => true, 'is_safe' => array('html'))));
|
||||
|
||||
$twig->addFilter(new \Twig_SimpleFilter('escapeDoubleQuote', function ($value) {
|
||||
|
@@ -1,26 +1,17 @@
|
||||
{% import 'common/caption_templates/answer.html.twig' as cap_ans %}
|
||||
{% import 'common/caption_templates/basket_element.html.twig' as cap_bas %}
|
||||
{% import 'common/caption_templates/internal_publi.html.twig' as cap_pub %}
|
||||
{% import 'common/caption_templates/lazaret.html.twig' as cap_laz %}
|
||||
{% import 'common/caption_templates/overview.html.twig' as cap_ovr %}
|
||||
{% import 'common/caption_templates/preview.html.twig' as cap_prev %}
|
||||
{% import 'common/macros.html.twig' as macro %}
|
||||
|
||||
{% if app['authentication'].getUser() %}
|
||||
{% set business = app['authentication'].getUser().ACL().has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
|
||||
{% else %}
|
||||
{% set business = false %}
|
||||
{% endif %}
|
||||
{% set business = app['authentication'].getUser().ACL().has_right_on_base(record.get_base_id(), 'canmodifrecord')|default(false) %}
|
||||
|
||||
{% if view == 'answer' %}
|
||||
{{cap_ans.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
|
||||
{{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, false, true) }}
|
||||
{% elseif view == 'lazaret' %}
|
||||
{{cap_laz.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
|
||||
{{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, true, true) }}
|
||||
{% elseif view == 'preview' %}
|
||||
{{cap_prev.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
|
||||
{{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, true, false) }}
|
||||
{% elseif view == 'basket' %}
|
||||
{{cap_bas.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
|
||||
{{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, true, false) }}
|
||||
{% elseif view == 'overview' %}
|
||||
{{cap_ovr.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
|
||||
{{ macro.format_caption(record, highlight|default(''), searchEngine|default(null), business, false, false) }}
|
||||
{% elseif view == 'publi' %}
|
||||
{{cap_pub.format_caption(record, '', null, business)}}
|
||||
{{ macro.format_caption(record, '', null, business, true, true) }}
|
||||
{% endif %}
|
@@ -1,9 +0,0 @@
|
||||
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
|
||||
{% for value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
|
||||
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{ value.label }}</b> : {{ value | highlight }}</div>
|
||||
{% endfor %}
|
||||
{% if app['authentication'].getUser().getPrefs('technical_display') == 'group' %}
|
||||
<hr/>
|
||||
{% include 'common/technical_datas.html.twig' %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
@@ -1,5 +0,0 @@
|
||||
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
|
||||
{% for value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
|
||||
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{ value.label }}</b> : {{ value | bounce | highlight }}</div>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
@@ -1,9 +0,0 @@
|
||||
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
|
||||
{% for value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
|
||||
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{ value.label }}</b> : {{ value | bounce | highlight }}</div>
|
||||
{% endfor %}
|
||||
{% if app['authentication'].getUser().getPrefs('technical_display') == 'group' %}
|
||||
<hr/>
|
||||
{% include 'common/technical_datas.html.twig' %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
@@ -1,9 +0,0 @@
|
||||
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
|
||||
{% for value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
|
||||
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{ value.label }}</b> : {{ value | bounce | highlight }}</div>
|
||||
{% endfor %}
|
||||
{% if app['authentication'].getUser().getPrefs('technical_display') == 'group' %}
|
||||
<hr/>
|
||||
{% include 'common/technical_datas.html.twig' %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
@@ -1,5 +0,0 @@
|
||||
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
|
||||
{% for value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
|
||||
<div><b>{{ value.label }}</b> : {{ value | highlight }}</div>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
@@ -1,5 +0,0 @@
|
||||
{% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
|
||||
{% for value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
|
||||
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{ value.label }}</b> : {{ value | bounce | highlight }}</div>
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
@@ -29,7 +29,7 @@
|
||||
<td style="width:70px;"class="text-right hidden-phone">
|
||||
<div class="btn-group">
|
||||
<a href="javascript:Recaptcha.reload()" class="btn btn-mini btn-info"><i class="icon-refresh"></i></a>
|
||||
<a href="javascript:Recaptcha.switch_type('image')" class="btn btn-mini btn-info"><i class="icon-volume-up"></i></i></a>
|
||||
<a href="javascript:Recaptcha.switch_type('image')" class="btn btn-mini btn-info"><i class="icon-volume-up"></i></a>
|
||||
<a href="javascript:Recaptcha.showhelp()" class="btn btn-mini btn-info"><i class="icon-question-sign"></i></a>
|
||||
</div>
|
||||
</td>
|
||||
@@ -39,7 +39,7 @@
|
||||
<div class="btn-toolbar">
|
||||
<div class="btn-group text-right">
|
||||
<a href="javascript:Recaptcha.reload()" class="btn btn-info"><i class="icon-refresh"></i></a>
|
||||
<a href="javascript:Recaptcha.switch_type('image')" class="btn btn-info"><i class="icon-volume-up"></i></i></a>
|
||||
<a href="javascript:Recaptcha.switch_type('image')" class="btn btn-info"><i class="icon-volume-up"></i></a>
|
||||
<a href="javascript:Recaptcha.showhelp()" class="btn btn-info"><i class="icon-question-sign"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -79,3 +79,39 @@
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro caption_value(field, bounceable) %}
|
||||
{% autoescape false %}
|
||||
{% set terms = [] %}
|
||||
{% for data in field.values %}
|
||||
{% if data.from_thesaurus and bounceable %}
|
||||
{% set value = data.value|e|bounce(field.name, data.qjs, field.sbas_id) %}
|
||||
{% else %}
|
||||
{% set value = data.value|e %}
|
||||
{% endif %}
|
||||
{% set terms = [value]|merge(terms) %}
|
||||
{% endfor %}
|
||||
{{ terms|join(' ' ~ field.separator ~ ' ') }}
|
||||
{% endautoescape %}
|
||||
{% endmacro %}
|
||||
|
||||
{% macro caption_field(field, bounceable, extra_classes) %}
|
||||
<div class="desc {{ extra_classes|join(' ') }}">
|
||||
<b>{{ field.label }}</b> :
|
||||
{{ _self.caption_value(field, bounceable|default(true))|highlight|linkify }}
|
||||
</div>
|
||||
{% endmacro %}
|
||||
|
||||
{% macro format_caption(record, highlight, search_engine, include_business, bounceable, technical_data) %}
|
||||
{% for field in record.get_caption().get_highlight_fields(highlight, null, search_engine, include_business) %}
|
||||
{% set extra_classes = ['pair'] %}
|
||||
{% if loop.index is odd %}
|
||||
{% set extra_classes = ['impair'] %}
|
||||
{% endif %}
|
||||
{{ _self.caption_field(field, bounceable|default(true), extra_classes) }}
|
||||
{% endfor %}
|
||||
{% if technical_data|default(true) and app['authentication'].getUser() is not none and app['authentication'].getUser().getPrefs('technical_display') == 'group' %}
|
||||
<hr/>
|
||||
{% include 'common/technical_datas.html.twig' %}
|
||||
{% endif %}
|
||||
{% endmacro %}
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{% extends "lightbox/index_layout.html.twig" %}
|
||||
|
||||
{% import 'common/thumbnail.html.twig' as thumbnail %}
|
||||
{% import 'common/caption_templates/preview.html.twig' as caption %}
|
||||
{% import 'common/macros.html.twig' as macro %}
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="{{ path('minifier', { 'g' : 'lightboxie6' }) }}"></script>
|
||||
@@ -83,7 +83,7 @@
|
||||
<div class="lightbox_container">
|
||||
{% set business = app['authentication'].getUser().ACL().has_right_on_base(first_item.get_record().get_base_id(), 'canmodifrecord') %}
|
||||
{% if first_item %}
|
||||
{{caption.format_caption(first_item.get_record(), '', null, business)}}
|
||||
{{ macro.format_caption(first_item.get_record(), '', null, business, false, false) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{% extends "lightbox/index_layout.html.twig" %}
|
||||
|
||||
{% import 'common/thumbnail.html.twig' as thumbnail %}
|
||||
{% import 'common/caption_templates/preview.html.twig' as caption %}
|
||||
{% import 'common/macros.html.twig' as macro %}
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="{{ path('minifier', { 'g' : 'lightboxie6' }) }}"></script>
|
||||
@@ -95,7 +95,7 @@
|
||||
<div class="lightbox_container">
|
||||
{% if basket_element %}
|
||||
{% set business = app['authentication'].getUser().ACL().has_right_on_base(basket_element.getRecord(app).get_base_id(), 'canmodifrecord') %}
|
||||
{{caption.format_caption(basket_element.getRecord(app), '', null, business)}}
|
||||
{{ macro.format_caption(basket_element.getRecord(app), '', null, business, false, false) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{% extends "lightbox/index_layout.html.twig" %}
|
||||
|
||||
{% import 'common/thumbnail.html.twig' as thumbnail %}
|
||||
{% import 'common/caption_templates/preview.html.twig' as caption %}
|
||||
{% import 'common/macros.html.twig' as macro %}
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="{{ path('minifier', { 'g' : 'lightbox' }) }}"></script>
|
||||
@@ -83,7 +83,7 @@
|
||||
<div class="lightbox_container PNB">
|
||||
{% set business = app['authentication'].getUser().ACL().has_right_on_base(first_item.get_record().get_base_id(), 'canmodifrecord') %}
|
||||
{% if first_item %}
|
||||
{{caption.format_caption(first_item.get_record(), '', null, business)}}
|
||||
{{ macro.format_caption(first_item.get_record(), '', null, business, false, false) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{% extends "lightbox/index_layout.html.twig" %}
|
||||
|
||||
{% import 'common/thumbnail.html.twig' as thumbnail %}
|
||||
{% import 'common/caption_templates/preview.html.twig' as caption %}
|
||||
{% import 'common/macros.html.twig' as macro %}
|
||||
|
||||
{% block javascript %}
|
||||
<script type="text/javascript" src="{{ path('minifier', { 'g' : 'lightbox' }) }}"></script>
|
||||
@@ -98,7 +98,7 @@
|
||||
<div class="lightbox_container PNB">
|
||||
{% if basket_element %}
|
||||
{% set business = app['authentication'].getUser().ACL().has_right_on_base(basket_element.getRecord(app).get_base_id(), 'canmodifrecord') %}
|
||||
{{caption.format_caption(basket_element.getRecord(app), '', null, business)}}
|
||||
{{ macro.format_caption(basket_element.getRecord(app), '', null, business, false, false) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{% import 'common/caption_templates/preview.html.twig' as caption %}
|
||||
{% import 'common/macros.html.twig' as macro %}
|
||||
|
||||
{% if app['authentication'].getUser().ACL().has_right_on_base(record.get_base_id, 'canmodifrecord') %}
|
||||
<div class="edit_button" style="text-align:right">
|
||||
@@ -13,9 +13,7 @@
|
||||
</div>
|
||||
{% set business = app['authentication'].getUser().ACL().has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
|
||||
{% if record.is_from_reg() %}
|
||||
{{caption.format_caption(record, '', null, business)}}
|
||||
{{ macro.format_caption(record, '', null, business, false, true) }}
|
||||
{% else %}
|
||||
{{caption.format_caption(record, highlight, searchEngine, business)}}
|
||||
{{ macro.format_caption(record, highlight, searchEngine, business, false, true) }}
|
||||
{% endif %}
|
||||
<hr style="margin:10px 0;"/>
|
||||
{% include 'common/technical_datas.html.twig' %}
|
@@ -1,22 +1,20 @@
|
||||
|
||||
{% extends "prod/results/answerabstract.html.twig" %}
|
||||
{% block content %}
|
||||
|
||||
{% import 'common/caption_templates/answer.html.twig' as caption %}
|
||||
{% import 'common/macros.html.twig' as macro %}
|
||||
|
||||
{% for record in results.getResults() %}
|
||||
<div class='list ui-corner-all'>
|
||||
<table style='width:100%;' cellspacing='0' cellpadding='0' border='0'>
|
||||
<tr>
|
||||
<td valign="top" style='width:{{th_size+50}}px'>
|
||||
{{record_format.block(record, highlight, searchEngine, 'IMGT', false)}}
|
||||
{{ record_format.block(record, highlight, searchEngine, 'IMGT', false) }}
|
||||
</td>
|
||||
<td valign="middle">
|
||||
<div class='desc' style='max-height:{{th_size+70}}px;overflow-y:auto;'>
|
||||
<div class="fixeddesc">
|
||||
{% set business = app['authentication'].getUser().ACL().has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
|
||||
{{caption.format_caption(record, highlight, searchEngine, business)}}
|
||||
{% if app['authentication'].getUser().getPrefs('technical_display') == 'group' %}<hr/>{{record.get_technical_infos|raw}}{% endif %}
|
||||
{{ macro.format_caption(record, highlight, searchEngine, business, true, true) }}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
Reference in New Issue
Block a user