Merge branch 'master' into modules

This commit is contained in:
Etienne Roudeix
2013-11-25 10:05:01 +01:00
29 changed files with 242 additions and 53 deletions

11
CHANGELOG.txt Normal file
View File

@@ -0,0 +1,11 @@
2.0.0-beta2
http://doc.thelia.net is available in beta.
Increase performance in prod mode.
Front part (routes and controller) are now a dedicated module.
allow to create a customer in admin panel
translation is implemented :
- I18n directory in template or module.
- multiple extensions are available. We choose to used php but you can use other.
- You can translate your template or module from the admin.
Admin hook exists. With this hooks, a module can insert code in admin pages

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

@@ -52,7 +52,7 @@ class CacheClear extends ContainerAwareCommand
"without-assets",
null,
InputOption::VALUE_NONE,
"remove cache assets"
"do not clear the assets cache in the web space"
)
;
}
@@ -82,17 +82,17 @@ class CacheClear extends ContainerAwareCommand
} catch (\UnexpectedValueException $e) {
// throws same exception code for does not exist and permission denied ...
if (!file_exists($dir)) {
$output->writeln(sprintf("<info>%s cache dir already clear</info>", $dir));
$output->writeln(sprintf("<info>%s cache dir already cleared</info>", $dir));
return;
}
throw $e;
} catch (IOException $e) {
$output->writeln(sprintf("Error during clearing cache : %s", $e->getMessage()));
$output->writeln(sprintf("Error during clearing of cache : %s", $e->getMessage()));
}
$output->writeln(sprintf("<info>%s cache dir cleared successfully</info>", $dir));
$output->writeln(sprintf("<info>%s cache directory cleared successfully</info>", $dir));
}
}

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

@@ -159,7 +159,7 @@ function createProduct($faker, $categories, $template, $attribute, $feature, $co
}
$stock->setNewness($faker->randomNumber(0,1));
$stock->setWeight($faker->randomFloat(2, 100,10000));
$stock->setWeight($faker->randomFloat(2, 1,30));
$stock->save($con);
$productPrice = new \Thelia\Model\ProductPrice();

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. ',

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 248 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

View File

@@ -49,6 +49,7 @@
}
// Message if no order or no address
.deliveries-warning,
.address-warning,
.orders-warning {
clear: both;

View File

@@ -12,13 +12,13 @@
<div class="carousel-wrapper">
<div class="carousel-inner">
<figure class="item active">
{images file='assets/img/carousel/slider1.png'}<img src="{$asset_url}" alt="img1">{/images}
{images file='assets/img/carousel/slider1.jpg'}<img src="{$asset_url}" alt="Slider image 1">{/images}
</figure>
<figure class="item">
{images file='assets/img/carousel/slider2.png'}<img src="{$asset_url}" alt="img2">{/images}
{images file='assets/img/carousel/slider2.jpg'}<img src="{$asset_url}" alt="Slider image 2">{/images}
</figure>
<figure class="item">
{images file='assets/img/carousel/slider3.png'}<img src="{$asset_url}" alt="img3">{/images}
{images file='assets/img/carousel/slider3.jpg'}<img src="{$asset_url}" alt="Slider image 3">{/images}
</figure>
</div>
</div>

View File

@@ -139,6 +139,7 @@
{/form_field}
</div>
{/loop}
{elseloop rel="deliveries"}<div class="deliveries-warning">{intl l="<strong>Sorry!</strong> We are not able to give you a delivery method for your order."}</div>{/elseloop}
</div>
</div>

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);
}