remove call to app in templates

This commit is contained in:
Nicolas Le Goff
2013-07-10 20:14:03 +02:00
parent 77961f5636
commit a6a9a93b05
17 changed files with 88 additions and 71 deletions

View File

@@ -106,9 +106,9 @@ class Account implements ControllerProviderInterface
}
}
return $app['twig']->render('account/change-password.html.twig', array(
'form' => $form->createView(),
'login' => new \login(),
return $app['twig']->render('account/change-password.html.twig', array_merge(
Login::getDefaultTemplateVariables($app),
array('form' => $form->createView())
));
}
@@ -195,7 +195,7 @@ class Account implements ControllerProviderInterface
}
}
return $app['twig']->render('account/reset-email.html.twig');
return $app['twig']->render('account/reset-email.html.twig', Login::getDefaultTemplateVariables($app));
}
/**

View File

@@ -162,7 +162,7 @@ class Login implements ControllerProviderInterface
// Displays Terms of use
$controllers->get('/cgus', function(PhraseaApplication $app, Request $request) {
return $app['twig']->render('login/cgus.html.twig');
return $app['twig']->render('login/cgus.html.twig', self::getDefaultTemplateVariables($app));
})->bind('login_cgus');
$controllers->get('/language.json', 'login.controller:getLanguage')
@@ -381,11 +381,11 @@ class Login implements ControllerProviderInterface
)));
}
return $app['twig']->render('login/register-classic.html.twig', array(
return $app['twig']->render('login/register-classic.html.twig', array_merge(
self::getDefaultTemplateVariables($app),
array(
'form' => $form->createView(),
'home_title' => $app['phraseanet.registry']->get('GV_homeTitle'),
'recaptcha_display' => $app->isCaptchaRequired(),
));
)));
}
private function attachProviderToUser(EntityManager $em, ProviderInterface $provider, \User_Adapter $user)
@@ -561,8 +561,9 @@ class Login implements ControllerProviderInterface
}
}
return $app['twig']->render('login/renew-password.html.twig', array(
'form' => $form->createView(),
return $app['twig']->render('login/renew-password.html.twig', array_merge(
self::getDefaultTemplateVariables($app),
array('form' => $form->createView())
));
}
@@ -618,9 +619,11 @@ class Login implements ControllerProviderInterface
$app->addFlash('error', $e->getMessage());
}
return $app['twig']->render('login/forgot-password.html.twig', array(
return $app['twig']->render('login/forgot-password.html.twig', array_merge(
self::getDefaultTemplateVariables($app),
array(
'form' => $form->createView(),
));
)));
}
/**
@@ -637,7 +640,7 @@ class Login implements ControllerProviderInterface
}
if (0 < count($app['authentication.providers'])) {
return $app['twig']->render('login/register.html.twig');
return $app['twig']->render('login/register.html.twig', self::getDefaultTemplateVariables($app));
} else {
return $app->redirectPath('login_register_classic');
}
@@ -692,13 +695,12 @@ class Login implements ControllerProviderInterface
$form = $app->form(new PhraseaAuthenticationForm());
return $app['twig']->render('login/index.html.twig', array(
'module_name' => _('Accueil'),
'redirect' => ltrim($request->query->get('redirect'), '/'),
'feeds' => $feeds,
'form' => $form->createView(),
'recaptcha_display' => $app->isCaptchaRequired(),
));
return $app['twig']->render('login/index.html.twig', array_merge(
self::getDefaultTemplateVariables($app),
array(
'feeds' => $feeds,
'form' => $form->createView(),
)));
}
/**
@@ -1015,4 +1017,29 @@ class Login implements ControllerProviderInterface
return $event->getResponse();
}
public static function getDefaultTemplateVariables(Application $app)
{
return array(
'instance_title' => $app['phraseanet.registry'].get('GV_homeTitle'),
'has_terms_of_use' => $app->hasTermsOfUse(),
'display_google_chrome_frame' => $app['phraseanet.registry']->get('GV_display_gcf'),
'meta_description' => $app['phraseanet.registry']->get('GV_metaDescription'),
'meta_keywords' => $app['phraseanet.registry']->get('GV_metakeywords'),
'browser_name' => $app['browser']->getBrowser(),
'browser_version' => $app['browser']->getVersion(),
'available_language' => $app->getAvailableLanguages(),
'locale' => $app['locale'],
'current_url' => $app['request']->getUri(),
'flash_types' => $app->getAvailableFlashTypes(),
'recaptcha_display' => $app->isCaptchaRequired(),
'unlock_usr_id' => $app->getUnlockAccountData(),
'guest_allowed' => $app->isGuestAllowed(),
'register_enable' => $app['registration.enabled'],
'display_layout' => $app['phraseanet.registry']->get('GV_home_publi'),
'authentication_providers' => $app['authentication.providers'],
'registration_fields' => $app['registration.fields'],
'registration_optional_fields' => $app['registration.optional-fields']
);
}
}

View File

@@ -2,7 +2,7 @@
{% set input_name = field.vars.name %}
{% set attributes = custom_attributes|default({})|merge({
'class': app['browser'].getBrowser() == constant('Browser::BROWSER_IE') and app['browser'].getVersion() <= 8 ? '' : 'input-block-level',
'class': browser_name == constant('Browser::BROWSER_IE') and browser_version <= 8 ? '' : 'input-block-level',
})
%}
@@ -54,7 +54,7 @@
{% macro providerList() %}
<ul class="unstyled inline provider-list">
{% for provider in app['authentication.providers'] %}
{% for provider in authentication_providers %}
<li>
<a href="{{ path('login_authentication_provider_authenticate', { 'providerId' : provider.getId() } ) }}">
<img src="{{ provider.getIconURI() }}" />
@@ -139,7 +139,7 @@
{% endmacro %}
{% macro flashes() %}
{% for type in app.getAvailableFlashTypes %}
{% for type in flash_types %}
{% for message in app.getFlash(type) %}
<div class="alert alert-{{ type }}">
{% set sign = "icon-exclamation-sign" %}

View File

@@ -1,4 +1,4 @@
{% if app.isGuestAllowed() %}
{% if guest_allowed %}
<div class="well-large sidebar-block">
<div class="row-fluid">
<div class="span12 text-center">

View File

@@ -1,24 +1,13 @@
{% set languages = app.getAvailableLanguages() %}
{% set qs = app['request'].getQueryString() %}
{% if qs is not none %}
{% set qs = '?' ~ qs %}
{% endif %}
{% set currentUrl = app['request'].getBaseUrl() ~ app['request'].getPathInfo() ~ qs %}
<div id="authentication-sidebar-language" class="text-right well-small clearfix">
<div class="pull-left">
<a href="{{ path("homepage") }}" title="{% trans "Home" %}"><i class="icon-home icon-white"></i></a>
</div>
<div class="pull-right btn-group">
<button id="language-button" class="btn btn-mini btn-flat dropdown-toggle" data-toggle="dropdown" type="button">
{{ attribute(languages, app['locale']) }}
<div id="authentication-sidebar-language" class="text-right well-small">
<span class="language"><b>{% trans "language" %}</b></span>
<div class="btn-group">
<button id="language-button" class="btn btn-mini btn-flat dropdown-toggle" data-toggle="dropdown">
{{ attribute(available_language, locale) }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right">
{% for code, language in languages if code != app['locale'] %}
<li><a href="{{ path('set_locale', {'locale' : code, 'redirect' : currentUrl }) }}" data-country-code="{{ code }}">{{ language }}</a></li>
{% for code, language in available_language if code != locale %}
<li><a href="{{ path('set_locale', {'locale' : code, 'redirect' : current_url }) }}" data-country-code="{{ code }}">{{ language }}</a></li>
{% endfor %}
</ul>
</div>

View File

@@ -1,4 +1,4 @@
{% if app['registration.enabled'] %}
{% if register_enable %}
<div class="well-large sidebar-block">
<div class="row-fluid">
<div class="span12 text-center">

View File

@@ -4,7 +4,7 @@
{% import "login/common/macros.html.twig" as auth_macro %}
{% block title %}
{{ app['phraseanet.registry'].get('GV_homeTitle') }}
{{ instance_title }}
{% endblock %}
{% block header_rss %}
@@ -30,11 +30,11 @@
<div class="span12">
{{ auth_macro.flashes() }}
{% if app.getUnlockAccountData() is not empty %}
{% if unlock_usr_id is not empty %}
<div class="row-fluid">
<div class="span12">
{% trans 'Your account is locked, please follow the following link to unlock it' %}<br/>
<a href="{{ path('login_send_mail', { 'usr_id' : app.getUnlockAccountData() }) }}" target ="_self">
<a href="{{ path('login_send_mail', { 'usr_id' : unlock_usr_id }) }}" target ="_self">
{% trans 'login:: Envoyer a nouveau le mail de confirmation' %}
</a>
</div>
@@ -70,7 +70,7 @@
{% trans "Forgot password?" %}
</a>
</div>
{% if app.isCaptchaRequired() %}
{% if recaptcha_display %}
<div class="row-fluid">
<div class="span12">
{{ macro.captcha() }}
@@ -95,7 +95,7 @@
</div>
</div>
</div><!-- /sidebar block -->
{% if app['authentication.providers'] | count > 0 %}
{% if authentication_providers | count > 0 %}
<div class="well-large sidebar-block">
<div class="row-fluid">
<div class="span12 text-center">
@@ -111,14 +111,12 @@
{% endif %}
{% include "login/include/register-link-block.html.twig" %}
{% include "login/include/guest-access-block.html.twig" %}
{% include "login/include/guest-access-block.html.twig" with {"guest_allowed": guest_allowed} %}
{% endblock %}
{% block left_content %}
{{ parent() }}
{% set display_layout = app['phraseanet.registry'].get('GV_home_publi') %}
{% if display_layout == 'DISPLAYx1' %}
{% include 'login/include/x1-content.html.twig' %}
{% elseif display_layout == "COOLIRIS" %}

View File

@@ -14,9 +14,9 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta content="{{ app['phraseanet.registry'].get('GV_metaDescription') }}" name="description"/>
<meta content="{{ meta_description }}" name="description"/>
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta content="{{ app['phraseanet.registry'].get('GV_metaKeywords') }}" name="keywords"/>
<meta content="{{ meta_keywords }}" name="keywords"/>
<meta content="phraseanet" name="generator"/>
{% endblock header_meta %}
@@ -48,9 +48,9 @@
</head>
<body>
{% block google_chrome_frame %}
{% if app['phraseanet.registry'].get('GV_display_gcf') %}
{% if display_google_chrome_frame %}
<!--[if lt IE 7]>
{% set browserLink = "<a href='http://browsehappy.com/'>" ~ app['browser'].getBrowser() ~ "</a>"|raw %}
{% set browserLink = "<a href='http://browsehappy.com/'>" ~ browser_name ~ "</a>"|raw %}
{% set GCFLink = "<a href='http://www.google.com/chromeframe/?redirect=true'>Google Chrome Frame</a>"|raw %}
<p class="alert alert-warning text-center">
<strong>{% trans %}You are using an outdated browser.{% endtrans %}</strong>
@@ -78,7 +78,7 @@
<li>
<a href="#">{% trans "Help" %}</a>
</li>
{% if app.hasTermsOfUse() %}
{% if has_terms_of_use %}
<li>
{% block tou_link %}
<a href="{{ path("login_cgus") }}">{% trans "Terms of use" %}</a>
@@ -106,7 +106,10 @@
</div>
{% endblock footer_scaffholding %}
</div><!--/.fluid-container-->
{% include 'common/analytics.html.twig' %}
{% block analytics %}
{% include 'common/analytics.html.twig' %}
{% endblock analytics %}
{% block scripts %}{% endblock scripts %}
</body>
</html>

View File

@@ -1,7 +1,7 @@
{% extends "login/layout/base-layout.html.twig" %}
{% block title %}
{{ app['phraseanet.registry'].get('GV_homeTitle')|default('Phraseanet') }}
{{ instance_title|default('Phraseanet') }}
{% endblock %}
{% block content_scaffholding %}

View File

@@ -58,7 +58,7 @@
{% trans "Forgot password?" %}
</a>
</div>
{% if app.isCaptchaRequired() %}
{% if recaptcha_display %}
<div class="row-fluid">
<div class="span12">
{{ macro.captcha() }}
@@ -84,7 +84,7 @@
</div>
</div>
</div>
{% if app['authentication.providers'] | count > 0 %}
{% if authentication_providers | count > 0 %}
<div class="well-large sidebar-block">
<div class="row-fluid">
<div class="span12 text-center">

View File

@@ -57,7 +57,7 @@
<div class="text-right">
<a class="forget-password-link" href="{{ path("login_forgot_password") }}">{% trans "Forgot password?" %}</a>
</div>
{% if app.isCaptchaRequired() %}
{% if recaptcha_display %}
<div class="row-fluid">
<div class="span12">
{{ macro.captcha() }}
@@ -78,7 +78,7 @@
</div>
</div>
</div>
{% include "login/include/register-link-block.html.twig" with {"login" : login, "last_item" : app['registration.enabled']} %}
{% include "login/include/register-link-block.html.twig" with {"last_item" : register_enable} %}
{% endblock %}
{% block scripts %}

View File

@@ -75,7 +75,7 @@
<div class="text-right">
<a class="forget-password-link" href="{{ path("login_forgot_password") }}">{% trans "Forgot password?" %}</a>
</div>
{% if app.isCaptchaRequired() %}
{% if recaptcha_display %}
<div class="row-fluid">
<div class="span12">
{{ macro.captcha() }}
@@ -110,7 +110,7 @@
</div>
</div>
</div>
{% include "login/include/register-link-block.html.twig" with {"login" : login, "last_item" : app['registration.enabled']} %}
{% include "login/include/register-link-block.html.twig" with {"last_item" : register_enable} %}
{% endblock %}
{% block scripts %}

View File

@@ -48,9 +48,9 @@
{{ auth_macro.repeatedInput(form.password, "registerForm", 'icon-lock') }}
{% for field in app['registration.fields'] %}
{% for field in registration_fields %}
{% set name = field['name'] %}
{% if name in app['registration.optional-fields']|keys %}
{% if name in registration_optional_fields|keys %}
<div class="row-fluid">
<div class="span12">
{{ auth_macro.fieldInput(attribute(form, name|camelize), "registerForm") }}
@@ -79,7 +79,7 @@
{{ form_rest(form) }}
{% if app.isCaptchaRequired() %}
{% if recaptcha_display %}
<div class="row-fluid">
<div class="span12">
{{ macro.captcha() }}

View File

@@ -45,9 +45,9 @@
</div>
</div>
{% for field in app['registration.fields'] %}
{% for field in registration_fields %}
{% set name = field['name'] %}
{% if name in app['registration.optional-fields']|keys %}
{% if name in registration_optional_fields|keys %}
<div class="row-fluid">
<div class="span12">
{{ auth_macro.fieldInput(attribute(form, name|camelize), "registerForm") }}

View File

@@ -29,7 +29,7 @@
</div>
</div>
{% if app['authentication.providers'] | count > 0 %}
{% if authentication_providers | count > 0 %}
<div class="well-large sidebar-block">
<div class="row-fluid">
<div class="span12 text-center">