Merge branch 'master' of git://github.com/thelia/thelia

* 'master' of git://github.com/thelia/thelia:
  undo removing Response::prepare call
  HttpCache can not be activated as default
  remove specific code testing esi integration
  create smarty tag for smarty renderer
  remove Thelia ResponseListener
  add new route for testing esi tag
  tweak httpFoundation cache part for compatibility with Thelia\HttpFoundation part
  add httpcache into index_dev.php file
  start using symfony 2 reverse proxy
  update wiki url in composer file
  create smarty tag for smarty renderer
  remove Thelia ResponseListener
  add new route for testing esi tag
  Added some translations in the Customer Creation Form
  tweak httpFoundation cache part for compatibility with Thelia\HttpFoundation part
  add httpcache into index_dev.php file
  start using symfony 2 reverse proxy
This commit is contained in:
gmorel
2013-11-23 01:36:12 +01:00
17 changed files with 221 additions and 45 deletions

View File

@@ -5,7 +5,7 @@
"homepage" : "http://thelia.net/v2",
"support" : {
"forum" : "http://thelia.net/forum",
"wiki" : "http://thelia.net/wiki"
"wiki" : "http://doc.thelia.net"
},
"require":{
"php": ">=5.4",

2
composer.lock generated
View File

@@ -3,7 +3,7 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "009aced8b279e1c14558460fff2cc993",
"hash": "6dee359d61c06345d0e4cc045b19dc4e",
"packages": [
{
"name": "ensepar/html2pdf",

View File

@@ -63,8 +63,6 @@ class ModuleActivateCommand extends BaseModuleGenerate
}
try {
new \TheliaDebugBar\TheliaDebugBar();
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
$moduleInstance = $moduleReflection->newInstance();

View File

@@ -4,12 +4,6 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<parameters>
<parameter key="thelia.actionEvent" type="collection">
</parameter>
</parameters>
<services>
<service id="thelia.action.cart" class="Thelia\Action\Cart">

View File

@@ -4,11 +4,15 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://thelia.net/schema/dic/config http://thelia.net/schema/dic/config/thelia-1.0.xsd">
<parameters>
<parameter key="esi.class">Symfony\Component\HttpKernel\HttpCache\Esi</parameter>
<parameter key="esi_listener.class">Symfony\Component\HttpKernel\EventListener\EsiListener</parameter>
<parameter key="fragment.renderer.esi.class">Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer</parameter>
<parameter key="fragment.renderer.inline.class">Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer</parameter>
</parameters>
<services>
<!-- URL maganement -->
<service id="thelia.url.manager" class="Thelia\Tools\URL">
<argument type="service" id="service_container" />
</service>
@@ -17,6 +21,20 @@
<argument type="service" id="service_container" />
</service>
<service id="esi" class="%esi.class%" />
<service id="esi_listener" class="%esi_listener.class%">
<tag name="kernel.event_subscriber" />
<argument type="service" id="esi" on-invalid="ignore" />
</service>
<service id="fragment.renderer.inline" class="%fragment.renderer.inline.class%">
<argument type="service" id="http_kernel" />
</service>
<service id="fragment.renderer.esi" class="%fragment.renderer.esi.class%">
<argument type="service" id="esi" />
<argument type="service" id="fragment.renderer.inline" />
</service>
<!--
A ControllerResolver that supports "a:b:c", "service:method" and class::method" notations,
thus allowing the definition of controllers as service (see http://symfony.com/fr/doc/current/cookbook/controller/service.html)
@@ -70,8 +88,6 @@
<service id="mailer" class="Thelia\Mailer\MailerFactory">
<argument type="service" id="event_dispatcher"/>
</service>
</services>
</config>

View File

@@ -91,7 +91,11 @@
<argument type="service" id="request" />
</service>
<service id="smarty.plugin.esi" class="Thelia\Core\Template\Smarty\Plugins\Esi" scope="request">
<tag name="thelia.parser.register_plugin"/>
<argument type="service" id="fragment.renderer.esi" />
<argument type="service" id="request" />
</service>
</services>

View File

@@ -22,6 +22,7 @@
/*************************************************************************************/
namespace Thelia\Core\Bundle;
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Scope;
@@ -61,7 +62,7 @@ class TheliaBundle extends Bundle
$container
->addCompilerPass(new TranslatorPass())
->addCompilerPass(new RegisterListenersPass())
->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_AFTER_REMOVING)
->addCompilerPass(new RegisterParserPluginPass())
->addCompilerPass(new RegisterRouterPass())
->addCompilerPass(new RegisterCouponPass())

View File

@@ -85,19 +85,11 @@ class ViewListener implements EventSubscriberInterface
$content = $parser->render($request->attributes->get('_view').".html");
if ($content instanceof Response) {
$response = $content;$event->setResponse($content);
$response = $content;
} else {
$response = new Response($content, $parser->getStatus() ?: 200);
}
/* $response->setCache(array(
'last_modified' => new \DateTime(),
'max_age' => 600,
's_maxage' => 600,
'private' => false,
'public' => true,
));*/
$event->setResponse($response);
} catch (ResourceNotFoundException $e) {
throw new NotFoundHttpException();

View File

@@ -0,0 +1,71 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\HttpKernel\HttpCache;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpCache\Esi;
use Symfony\Component\HttpKernel\HttpCache\HttpCache as BaseHttpCache;
use Symfony\Component\HttpKernel\HttpCache\Store;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Thelia\Core\HttpFoundation\Request as TheliaRequest;
/**
* Class HttpCache
* @package Thelia\Core\HttpKernel\HttpCache
* @author manuel raynaud <mraynaud@openstudio.fr>
*/
class HttpCache extends BaseHttpCache implements HttpKernelInterface
{
public function __construct(HttpKernelInterface $kernel, $options = array())
{
parent::__construct(
$kernel,
new Store($kernel->getCacheDir().'/http_cache'),
new Esi(),
array_merge(
array('debug' => $kernel->isDebug()),
$options
)
);
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
if (!($request instanceof \Thelia\Core\HttpFoundation\Request)) {
$request = TheliaRequest::create(
$request->getUri(),
$request->getMethod(),
$request->getMethod() == 'GET' ? $request->query->all() : $request->request->all(),
$request->cookies->all(),
$request->files->all(),
$request->server->all(),
$request->getContent()
);
}
return parent::handle($request, $type, $catch);
}
}

View File

@@ -0,0 +1,82 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Smarty\Plugins;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Fragment\EsiFragmentRenderer;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Smarty\an;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
/**
* Class Esi
* @package Thelia\Core\Template\Smarty\Plugins
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Esi extends AbstractSmartyPlugin
{
protected $esiFragmentRender;
protected $request;
public function __construct(EsiFragmentRenderer $esiFragmentRenderer, Request $request)
{
$this->esiFragmentRender = $esiFragmentRenderer;
$this->request = $request;
}
public function renderEsi($params, $template = null)
{
$path = $this->getParam($params, 'path');
$alt = $this->getParam($params, 'alt');
$ignore_errors = $this->getParam($params, 'ignore_errors');
$comment = $this->getParam($params, 'comment');
if(null === $path) {
return;
}
$response = $this->esiFragmentRender->render($path, $this->request, array(
'alt' => $alt,
'ignore_errors' => $ignore_errors,
'comment' => $comment
));
if (!$response->isSuccessful()) {
return null;
}
return $response->getContent();
}
/**
* @return an array of SmartyPluginDescriptor
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor('function', 'render_esi', $this, 'renderEsi')
);
}
}

View File

@@ -43,6 +43,7 @@ use Thelia\Model;
class TheliaHttpKernel extends HttpKernel
{
protected static $session;
protected $container;
@@ -79,8 +80,11 @@ class TheliaHttpKernel extends HttpKernel
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
//$request->headers->set('X-Php-Ob-Level', ob_get_level());
$request = $this->initSession($request);
$this->initParam($request);
if ($type == HttpKernelInterface::MASTER_REQUEST) {
$request = $this->initSession($request);
$this->initParam($request);
}
$this->container->enterScope('request');
$this->container->set('request', $request, 'request');
@@ -211,26 +215,29 @@ class TheliaHttpKernel extends HttpKernel
protected function initSession(Request $request)
{
if(null === self::$session) {
$storage = new Session\Storage\NativeSessionStorage();
$storage = new Session\Storage\NativeSessionStorage();
if (Model\ConfigQuery::read("session_config.default")) {
$storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_ROOT . '/local/session/')));
} else {
$handlerString = Model\ConfigQuery::read("session_config.handlers", 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler');
if (Model\ConfigQuery::read("session_config.default")) {
$storage->setSaveHandler(new Session\Storage\Handler\NativeFileSessionHandler(Model\ConfigQuery::read("session_config.save_path", THELIA_LOCAL_DIR . 'session/')));
$handler = new $handlerString;
$storage->setSaveHandler($handler);
}
if (Model\ConfigQuery::read("session_config.config", null)) {
$storage->setOptions(json_decode(Model\ConfigQuery::read("session_config.config")));
}
self::$session = $session = new \Thelia\Core\HttpFoundation\Session\Session($storage);
} else {
$handlerString = Model\ConfigQuery::read("session_config.handlers", 'Symfony\Component\HttpFoundation\Session\Storage\Handler\NativeFileSessionHandler');
$handler = new $handlerString;
$storage->setSaveHandler($handler);
$session = self::$session;
}
if (Model\ConfigQuery::read("session_config.config", null)) {
$storage->setOptions(json_decode(Model\ConfigQuery::read("session_config.config")));
}
$session = new \Thelia\Core\HttpFoundation\Session\Session($storage);
$session->start();
$request->setSession($session);
return $request;

View File

@@ -84,7 +84,7 @@ class CustomerCreateForm extends AddressCreateForm
array($this, "verifyPasswordField")
)))
),
"label" => "Password confirmation",
"label" => Translator::getInstance()->trans("Password confirmation"),
"label_attr" => array(
"for" => "password_confirmation"
)
@@ -102,6 +102,7 @@ class CustomerCreateForm extends AddressCreateForm
"constraints" => array(
new Constraints\True(array("message" => "Please accept the Terms and conditions in order to register."))
),
"label"=>"Test",
"label_attr" => array(
"for" => "agreed"
)

View File

@@ -8,12 +8,12 @@
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">includes/mini-cart</default>
</route>
<route id="ajax.addCartMessage" path="/ajax/addCartMessage">
<default key="_controller">Thelia\Controller\Front\DefaultController::noAction</default>
<default key="_view">includes/addedToCart</default>
</route>
<!-- Register -->
<route id="customer.create.process" path="/register" methods="post">
<default key="_controller">Front\Controller\CustomerController::createAction</default>

View File

@@ -13,6 +13,7 @@ return array(
'Address %nb' => 'Adresse n°',
'Address Update' => 'Mise à jour de l\'adresse',
'Address' => 'Adresse',
'Address Line 2'=>'Complément d\'adresse',
'Amount' => 'Montant',
'Availability' => 'Disponibilité',
'Available' => 'Disponible',
@@ -22,6 +23,7 @@ return array(
'Cancel' => 'Annuler',
'Cart' => 'Panier',
'Categories' => 'Catégories',
'Cellphone'=> 'Portable',
'Change address' => 'Changer d\'adresse',
'Change my account information' => 'Modifier mes informations personnelles',
'Change my password' => 'Changer mon mot de passe',
@@ -32,6 +34,7 @@ return array(
'Choose your delivery method' => 'Choisissez votre moyen de livraison',
'Choose your payment method' => 'Choisissez voter moyen de paiement',
'Code :' => 'Code',
'Company Name'=>'Entreprise',
'Complementary address' => 'Résidence secondaire',
'Contact Us' => 'Contactez-nous',
'Continue Shopping' => 'Continuer mes achats',
@@ -53,6 +56,7 @@ return array(
'Edit this address' => 'Editer cette adresse',
'Edit' => 'Editer',
'Email address' => 'Adresse e-mail',
'Email Address' => 'Adresse e-mail',
'Follow us' => 'Suivez-nous',
'Forgot your Password?' => 'Mot de passé oublié ?',
'Free shipping' => 'Livraison gratuite',
@@ -63,6 +67,7 @@ return array(
'In Stock' => 'Disponible',
'instead of' => 'au lieu de',
'Item(s)' => 'Produit(s)',
'I would like to receive the newsletter or the latest news.' => 'Je veux m\'inscrire à la newsletter pour rester informé.',
'Language:' => 'Langue',
'Latest articles' => 'Nouveaux articles',
'Latest products' => 'Derniers produits',
@@ -106,6 +111,7 @@ return array(
'Pagination' => 'Pagination',
'Password Forgotten' => 'Mot de passe oublié',
'Password' => 'Mot de passe',
'Password confirmation'=>"Confirmer le mot de passe",
'per page' => 'par page',
'Personal Information' => 'Informations personnelles',
'Placeholder address label' => 'Maison, Domicile, Travail...',
@@ -170,6 +176,7 @@ return array(
'Sort By' => 'Trier par',
'Special Price:' => 'Prix en promotion :',
'Status' => 'Etat',
'Street Address'=>"Adresse",
'Subscribe' => 'Inscription',
'Tax Inclusive' => 'TVA incluse',
'Thank you for the trust you place in us.' => 'Merci pour votre confiance. ',

View File

@@ -265,7 +265,7 @@
<div class="control-input">
<div class="checkbox">
<label class="control-label" for="{$label_attr.for}">
<input type="checkbox" name="{$name}" id="{$label_attr.for}" value="{$value}"{if $checked} checked{/if} {if $required} aria-required="true" required{/if}>I've read and agreed on <a href="#">Terms &amp; Conditions</a></a>.
<input type="checkbox" name="{$name}" id="{$label_attr.for}" value="{$value}"{if $checked} checked{/if} {if $required} aria-required="true" required{/if}>I've read and agreed on <a href="#">Terms &amp; Conditions</a>.
</label>
{if $error }
<span class="help-block">{$message}</span>

View File

@@ -1,4 +1,5 @@
<?php
use Thelia\Core\HttpKernel\HttpCache\HttpCache;
use Thelia\Core\Thelia;
use Thelia\Core\HttpFoundation\Request;
@@ -10,7 +11,7 @@ require __DIR__ . '/../core/bootstrap.php';
$request = Request::createFromGlobals();
$thelia = new Thelia("prod", false);
//$thelia = new HttpCache($thelia);
$response = $thelia->handle($request)->prepare($request)->send();
$thelia->terminate($request, $response);

View File

@@ -24,6 +24,7 @@
use Thelia\Core\Thelia;
use Thelia\Core\HttpFoundation\Response;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Core\HttpKernel\HttpCache\HttpCache;
//use Symfony\Component\DependencyInjection;
@@ -45,6 +46,7 @@ if ( false === in_array($request->getClientIp(), $trustedIp)) {
} else {
$response = $thelia->handle($request)->prepare($request)->send();
$thelia->terminate($request, $response);
}