Update twig templates

This commit is contained in:
Romain Neutron
2012-07-17 15:01:12 +02:00
parent 71e2e53d34
commit ca1341b55a
23 changed files with 101 additions and 103 deletions

View File

@@ -105,6 +105,7 @@ class Twig extends ServiceAbstract
$this->twig->addExtension(new \Twig_Extensions_Extension_Intl());
// add filters truncate, wordwrap, nl2br
$this->twig->addExtension(new \Twig_Extensions_Extension_Text());
$this->twig->addExtension(new \Alchemy\Phrasea\Twig\JSUniqueID());
}
private function loadTests()
@@ -119,36 +120,23 @@ class Twig extends ServiceAbstract
private function loadFilters()
{
$this->twig->addFilter('serialize', new \Twig_Filter_Function('serialize'));
$this->twig->addFilter('sbas_names', new \Twig_Filter_Function('phrasea::sbas_names'));
$this->twig->addFilter('sbas_name', new \Twig_Filter_Function('phrasea::sbas_names'));
$this->twig->addFilter('unite', new \Twig_Filter_Function('p4string::format_octets'));
$this->twig->addFilter('stristr', new \Twig_Filter_Function('stristr'));
$this->twig->addFilter('implode', new \Twig_Filter_Function('implode'));
$this->twig->addFilter('get_class', new \Twig_Filter_Function('get_class'));
$this->twig->addFilter('stripdoublequotes', new \Twig_Filter_Function('stripdoublequotes'));
$this->twig->addFilter('phraseadate', new \Twig_Filter_Function('phraseadate::getPrettyString'));
$this->twig->addFilter('format_octets', new \Twig_Filter_Function('p4string::format_octets'));
$this->twig->addFilter('geoname_display', new \Twig_Filter_Function('geonames::name_from_id'));
$this->twig->addFilter('get_collection_logo', new \Twig_Filter_Function('collection::getLogo'));
$this->twig->addFilter('nl2br', new \Twig_Filter_Function('nl2br'));
$this->twig->addFilter('floor', new \Twig_Filter_Function('floor'));
$this->twig->addFilter('bas_name', new \Twig_Filter_Function('phrasea::bas_names'));
$this->twig->addFilter('bas_names', new \Twig_Filter_Function('phrasea::bas_names'));
$this->twig->addFilter('basnames', new \Twig_Filter_Function('phrasea::bas_names'));
$this->twig->addFilter('sbas_names', new \Twig_Filter_Function('phrasea::sbas_names'));
$this->twig->addFilter('urlencode', new \Twig_Filter_Function('urlencode'));
$this->twig->addFilter('sbasFromBas', new \Twig_Filter_Function('phrasea::sbasFromBas'));
$this->twig->addFilter('str_replace', new \Twig_Filter_Function('str_replace'));
$this->twig->addFilter('strval', new \Twig_Filter_Function('strval'));
$this->twig->addFilter('key_exists', new \Twig_Filter_Function('array_key_exists'));
$this->twig->addFilter('array_keys', new \Twig_Filter_Function('array_keys'));
$this->twig->addFilter('round', new \Twig_Filter_Function('round'));
$this->twig->addFilter('dump', new \Twig_Filter_Function('var_dump'));
$this->twig->addFilter('formatdate', new \Twig_Filter_Function('phraseadate::getDate'));
$this->twig->addFilter('getPrettyDate', new \Twig_Filter_Function('phraseadate::getPrettyString'));
$this->twig->addFilter('formatDate', new \Twig_Filter_Function('phraseadate::getDate'));
$this->twig->addFilter('prettyDate', new \Twig_Filter_Function('phraseadate::getPrettyString'));
$this->twig->addFilter('prettyString', new \Twig_Filter_Function('phraseadate::getPrettyString'));
$this->twig->addFilter('formatoctet', new \Twig_Filter_Function('p4string::format_octets'));
$this->twig->addFilter('getDate', new \Twig_Filter_Function('phraseadate::getDate'));
$this->twig->addFilter('formatOctets', new \Twig_Filter_Function('p4string::format_octets'));
$this->twig->addFilter('geoname_name_from_id', new \Twig_Filter_Function('geonames::name_from_id'));
}

View File

@@ -0,0 +1,32 @@
<?php
namespace Alchemy\Phrasea\Twig;
class JSUniqueID extends \Twig_Extension
{
/**
*
* @return string
*/
public function getName()
{
return 'alchemy_phrasea_jsuniqueid';
}
/**
*
* @return array
*/
public function getFilters()
{
return array(
'JSUniqueID' => new \Twig_Filter_Method($this, 'JSUniqueID'),
);
}
public function JSUniqueID($prefix = null, $suffix = null)
{
return $prefix . 'id' . str_replace(array(',', '.'), '-', microtime(true)) . base_convert(mt_rand(0x19A100, 0x39AA3FF), 10, 36) . $suffix;
}
}

View File

@@ -56,41 +56,27 @@ class module_console_systemTemplateGenerator extends Command
));
$twig->addExtension(new Twig_Extensions_Extension_I18n());
$twig->addExtension(new \Alchemy\Phrasea\Twig\JSUniqueID());
/**
* @todo clean all duplicate filters
*/
$twig->addFilter('serialize', new Twig_Filter_Function('serialize'));
$twig->addFilter('sbas_names', new Twig_Filter_Function('phrasea::sbas_names'));
$twig->addFilter('sbas_name', new Twig_Filter_Function('phrasea::sbas_names'));
$twig->addFilter('unite', new Twig_Filter_Function('p4string::format_octets'));
$twig->addFilter('stristr', new Twig_Filter_Function('stristr'));
$twig->addFilter('implode', new Twig_Filter_Function('implode'));
$twig->addFilter('stripdoublequotes', new Twig_Filter_Function('stripdoublequotes'));
$twig->addFilter('phraseadate', new Twig_Filter_Function('phraseadate::getPrettyString'));
$twig->addFilter('format_octets', new Twig_Filter_Function('p4string::format_octets'));
$twig->addFilter('geoname_display', new Twig_Filter_Function('geonames::name_from_id'));
$twig->addFilter('get_collection_logo', new Twig_Filter_Function('collection::getLogo'));
$twig->addFilter('nl2br', new Twig_Filter_Function('nl2br'));
$twig->addFilter('floor', new Twig_Filter_Function('floor'));
$twig->addFilter('bas_name', new Twig_Filter_Function('phrasea::bas_names'));
$twig->addFilter('bas_names', new Twig_Filter_Function('phrasea::bas_names'));
$twig->addFilter('basnames', new Twig_Filter_Function('phrasea::bas_names'));
$twig->addFilter('urlencode', new Twig_Filter_Function('urlencode'));
$twig->addFilter('sbasFromBas', new Twig_Filter_Function('phrasea::sbasFromBas'));
$twig->addFilter('str_replace', new Twig_Filter_Function('str_replace'));
$twig->addFilter('strval', new Twig_Filter_Function('strval'));
$twig->addFilter('key_exists', new Twig_Filter_Function('array_key_exists'));
$twig->addFilter('array_keys', new Twig_Filter_Function('array_keys'));
$twig->addFilter('round', new Twig_Filter_Function('round'));
$twig->addFilter('get_class', new Twig_Filter_Function('get_class'));
$twig->addFilter('formatdate', new Twig_Filter_Function('phraseadate::getDate'));
$twig->addFilter('getPrettyDate', new Twig_Filter_Function('phraseadate::getPrettyString'));
$twig->addFilter('prettyDate', new Twig_Filter_Function('phraseadate::getPrettyString'));
$twig->addFilter('prettyString', new Twig_Filter_Function('phraseadate::getPrettyString'));
$twig->addFilter('formatoctet', new Twig_Filter_Function('p4string::format_octet'));
$twig->addFilter('getDate', new Twig_Filter_Function('phraseadate::getDate'));
$twig->addFilter('geoname_name_from_id', new Twig_Filter_Function('geonames::name_from_id'));
$twig->addFilter('serialize', new \Twig_Filter_Function('serialize'));
$twig->addFilter('stristr', new \Twig_Filter_Function('stristr'));
$twig->addFilter('implode', new \Twig_Filter_Function('implode'));
$twig->addFilter('get_class', new \Twig_Filter_Function('get_class'));
$twig->addFilter('stripdoublequotes', new \Twig_Filter_Function('stripdoublequotes'));
$twig->addFilter('geoname_display', new \Twig_Filter_Function('geonames::name_from_id'));
$twig->addFilter('get_collection_logo', new \Twig_Filter_Function('collection::getLogo'));
$twig->addFilter('floor', new \Twig_Filter_Function('floor'));
$twig->addFilter('bas_names', new \Twig_Filter_Function('phrasea::bas_names'));
$twig->addFilter('sbas_names', new \Twig_Filter_Function('phrasea::sbas_names'));
$twig->addFilter('urlencode', new \Twig_Filter_Function('urlencode'));
$twig->addFilter('sbasFromBas', new \Twig_Filter_Function('phrasea::sbasFromBas'));
$twig->addFilter('key_exists', new \Twig_Filter_Function('array_key_exists'));
$twig->addFilter('array_keys', new \Twig_Filter_Function('array_keys'));
$twig->addFilter('round', new \Twig_Filter_Function('round'));
$twig->addFilter('formatDate', new \Twig_Filter_Function('phraseadate::getDate'));
$twig->addFilter('prettyDate', new \Twig_Filter_Function('phraseadate::getPrettyString'));
$twig->addFilter('formatOctets', new \Twig_Filter_Function('p4string::format_octets'));
$twig->addFilter('geoname_name_from_id', new \Twig_Filter_Function('geonames::name_from_id'));
$finder = new Symfony\Component\Finder\Finder();
foreach ($finder->files()->in(array($tplDir))->exclude('Mustache') as $file) {

View File

@@ -197,7 +197,7 @@
{% for key, value in dashboard_array.dashboard.top_ten_user.poiddoc %}
<tr>
<td>{{ value.user|e }}</td>
<td>{{ value.poiddoc|unite }}</td>
<td>{{ value.poiddoc | formatOctets }}</td>
</tr>
{% endfor %}
</tbody>
@@ -228,7 +228,7 @@
{% for key, value in dashboard_array.dashboard.top_ten_user.poidprev %}
<tr>
<td>{{ value.user|e }}</td>
<td>{{ value.poidprev|unite }}</td>
<td>{{ value.poidprev | formatOctets }}</td>
</tr>
{% endfor %}
</tbody>

View File

@@ -203,7 +203,7 @@
<tr>
<td style="width:122px;overflow:hidden;white-space:nowrap;">
{{rights['sbas_id']|sbas_name}}
{{rights['sbas_id']|sbas_names}}
</td>
<td class="users_col options">
<div>
@@ -353,7 +353,7 @@
{% endif %}
<tr>
<td style="overflow:hidden;white-space:nowrap;">
{{rights['base_id']|bas_name}}
{{rights['base_id']|bas_names}}
</td>
<td class="users_col case_right_access" title="{% trans 'Access' %}">
{{_self.format_checkbox(user, rights, 'access', users, 'base')}}

View File

@@ -1,9 +1,9 @@
<h1>Masks</h1>
<div>
Base {{base_id|sbasFromBas|sbas_name}}
Base {{base_id|sbasFromBas|sbas_names}}
</div>
<div>
Collection {{base_id|bas_name}}
Collection {{base_id|bas_names}}
</div>
<form>
<table style="table-layout:fixed; width:280px;position:relative;left:10px;" width="280px">

View File

@@ -38,11 +38,11 @@
<h1>{% trans 'Quotas' %}</h1>
<div>
{% set base = base_id|sbasFromBas|sbas_name %}
{% set base = base_id|sbasFromBas|sbas_names %}
{% trans %}Base {{base}}{% endtrans %}
</div>
<div>
{% set collection = base_id|bas_name %}
{% set collection = base_id|bas_names %}
{% trans %}Collection {{collection}}{% endtrans %}
</div>
<form>

View File

@@ -1,10 +1,10 @@
<h1>{% trans 'Limite temporelle' %}</h1>
<div>
{% set base = base_id|sbasFromBas|sbas_name %}
{% set base = base_id|sbasFromBas|sbas_names %}
{% trans %}Base {{base}}{% endtrans %}
</div>
<div>
{% set collection = base_id|bas_name %}
{% set collection = base_id|bas_names %}
{% trans %}Collection {{collection}}{% endtrans %}
</div>
<form>

View File

@@ -63,7 +63,7 @@
</div>
</td>
<td><a href="/admin/publications/feed/{{ feed.get_id() }}/">{{ feed.get_title() }}</a></td>
<td>{{ feed.get_created_on()|formatdate }}</td>
<td>{{ feed.get_created_on()| formatDate }}</td>
<td>
{% if feed.get_collection() != null %}
{{ feed.get_collection().get_databox().get_viewname() }} /

View File

@@ -184,7 +184,7 @@
{{usr.get_applied_template()}}
</td>
<td>
{{usr.get_creation_date()|getDate}}
{{usr.get_creation_date() | formatDate}}
</td>
</tr>
{% endfor %}

View File

@@ -7,9 +7,11 @@
<div style="width:{{ displayWidth | round }}px;height:{{ displayHeight | round }}px;" class="thumb_wrapper {{ extraclass | default('') }}">
{% endif %}
{% set unique_id = '' | JSUniqueID %}
<div class="record record_video imgTips" style="position:relative;width:{{ displayWidth | round }}px;height:{{ displayHeight | round }}px;">
<video id="video_preview_tooltip" class="videoTips video-js vjs-default-skin" controls autoplay
preload="auto" xposter="my_video_poster.png" width="{{ displayWidth|round }}" height="{{ displayHeight | round }}"
<video id="{{ unique_id }}" class="videoTips video-js vjs-default-skin" controls autoplay
preload="auto" width="{{ displayWidth|round }}" height="{{ displayHeight | round }}"
data-setup="{}">
{% for name, subdef in arraySubdefs %}
{% if loop.first %}
@@ -29,12 +31,17 @@
<script type="text/javascript">
$(document).ready(function(){
try {
_V_("video_preview_tooltip", {}, function(){
_V_("{{ unique_id }}", {}, function(){
var player = this;
$('#video_preview_tooltip').parent().bind('resize-video-js', function(){
$('#{{ unique_id }}').parent().bind('resize-video-js', function(){
player.width($(this).width());
player.height($(this).height());
});
$('#{{ unique_id }}').bind('unload-video-js', function(){
player.destroy();
});
});
} catch(err) {
console.error('An error has been catched during the execution of VideoJS', err);

View File

@@ -111,7 +111,7 @@
<input class="{{values.class}}" type="checkbox" id="download_{{name}}" name="obj[]" value="{{name}}" />
<input type="hidden" name="download_{{name}}" value="{{values.size}}" />
<input type="hidden" name="count_{{name}}" value="{{values.available}}" />
{{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}})
{{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size | formatOctets}})
</label>
{% set title%}
{% trans 'Documents indisponibles' %}
@@ -178,7 +178,7 @@
<div style="margin: 10px 0 20px 0; padding: 0 10px;">
<label for="sendmail_{{name}}" class="checkbox">
<input class="{{values.class}}" type="checkbox" id="sendmail_{{name}}" name="obj[]" value="{{name}}" />
{{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}})
{{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size | formatOctets}})
</label>
{% set title%}
{% trans 'Documents indisponibles' %}
@@ -399,7 +399,7 @@
<div style="margin: 10px 0 20px 0; padding: 0 10px;">
<label for="ftp_{{name}}" class="checkbox">
<input class="{{values.class}}" type="checkbox" id="ftp_{{name}}" name="obj[]" value="{{name}}" />
{{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}}))
{{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size | formatOctets}}))
</label>
{% set title%}
{% trans 'Documents indisponibles' %}

View File

@@ -11,7 +11,7 @@
{{ record.get_mime() }}
{% if document and document.get_size() %}
- {{document.get_size()|formatoctet}}
- {{document.get_size()| formatOctets}}
{% endif %}
<br/>

View File

@@ -13,7 +13,7 @@
</div>
<div style="margin:5px 0;text-align:right;font-style:italic;position:relative;">
{% set nb_records = basket.getElements()|length %}
{% set date = basket.getUpdated()|prettyString %}
{% set date = basket.getUpdated() | prettyDate %}
{% trans %}
{{ nb_records }} records
{% endtrans %}

View File

@@ -10,7 +10,7 @@
<div class="noToolTipResize" style="margin:5px;width:{{ width - 40 }}px;height:300px;position:relative;">
<div style="margin:5px 0;text-align:right;font-style:italic;position:relative;">
{% set nb_records = Story.get_children().get_elements()|length %}
{% set date = Story.get_modification_date()|prettyString %}
{% set date = Story.get_modification_date() | prettyDate %}
{% trans %}
{{ nb_records }} records
{% endtrans %}

View File

@@ -78,7 +78,7 @@
{{ user.get_login() }}
</td>
<td>
{{ user.get_creation_date()|getDate }}
{{ user.get_creation_date() | formatDate }}
</td>
</tr>
{% endfor %}

View File

@@ -27,8 +27,8 @@
</tr>
</table>
<div class="post_date">
{% set updated_on = entry.get_updated_on()|getPrettyDate %}
{% set created_on = entry.get_created_on()|getPrettyDate %}
{% set updated_on = entry.get_updated_on() | prettyDate %}
{% set created_on = entry.get_created_on() | prettyDate %}
<span class="created_on">
{{ created_on }}
</span>
@@ -60,5 +60,5 @@
{% endfor %}
</div>
</div>
{% endmacro %}

View File

@@ -26,10 +26,10 @@
</thead>
<tbody>
{% for order in ordermanager %}
{% set deadline = order.get_deadline()|phraseadate%}
{% set deadline = order.get_deadline() | prettyDate %}
<tr id="order_{{order.get_order_id()}}" class="order_row">
<td>{{order.get_user().get_display_name()}}</td>
<td>{{order.get_created_on()|phraseadate}}</td>
<td>{{order.get_created_on() | prettyDate }}</td>
<td>
{% if deadline != '' %}
{{deadline}}

View File

@@ -12,11 +12,11 @@
</tr>
<tr>
<td>{% trans 'Date de commande' %}</td>
<td>{{ order.get_created_on()|phraseadate }}</td>
<td>{{ order.get_created_on() | prettyDate }}</td>
</tr>
<tr>
<td>{% trans 'Deadline' %}</td>
<td>{{ order.get_deadline()|phraseadate }}</td>
<td>{{ order.get_deadline() | prettyDate }}</td>
</tr>
<tr>
<td>{% trans 'Utilisation prevue' %}</td>

View File

@@ -23,7 +23,7 @@
{% trans 'report::Edition des meta-donnees' %}
{% elseif action == 'collection' %}
{% set dest = done['final']|implode(', ') %}
{% set coll_name = dest|bas_name %}
{% set coll_name = dest|bas_names %}
{% trans %}report::Changement de collection vers : {{coll_name}}{% endtrans %}
{% elseif action == 'status' %}
{% trans 'report::Edition des status' %}

View File

@@ -21,7 +21,7 @@
<td><a href="#" id= "id_{{ value.id }}" >{{ value.lib|e }}</a></td>
{% endif %}
{% endif %}
<td>{{ unite == "true" ? value.nb|unite : value.nb }}</td>
<td>{{ unite == "true" ? value.nb | formatOctets : value.nb }}</td>
</tr>
{% endfor %}
</tbody>

View File

@@ -529,7 +529,5 @@ function closePreview(){
$(this).dequeue();
});
$.each($('#PREVIEWBOX video'), function(i,el){
_V_($(el).attr('id')).destroy();
});
$('#PREVIEWBOX .videoTips.video-js').trigger('unload-video-js');
}

View File

@@ -248,7 +248,7 @@
ratio = width/height;
$imgTips.css({top:'0px',left:'0px'});
}
if ($videoTips[0] && $('#' + settings($.tooltip.current).id + ' .noToolTipResize').length === 0) {
resizeVideoTips = true;
width = parseInt($videoTips.attr('width'));
@@ -446,7 +446,7 @@
maxHeight: Math.round(height-70)
});
}
if(resizeVideoTips)
{
$videoTips.css({
@@ -594,15 +594,8 @@
{
$.tooltip.ajaxRequest.abort();
}
$.each($('#tooltip video'), function(i,el){
try {
_V_($(el).attr('id')).destroy();
} catch(err) {
console.error('An error has been catched during the execution of VideoJS', err);
}
});
$('#tooltip .videoTips.video-js').trigger('unload-video-js');
helper.body.empty();
$.tooltip.current = null;
function complete() {
@@ -628,13 +621,7 @@ function unfix_tooltip()
$.tooltip.visible = false;
$.tooltip.current = null;
$('#tooltip').hide();
$.each($('#tooltip video'), function(i,el){
try {
_V_($(el).attr('id')).destroy();
} catch(err) {
console.error('An error has been catched during the execution of VideoJS', err);
}
});
$('#tooltip .videoTips.video-js').trigger('unload-video-js');
$('#tooltip .tooltip_closer').hide();
hideOverlay('_tooltip');
}