Merge branch 'admin'

Conflicts:
	composer.lock
This commit is contained in:
Manuel Raynaud
2013-06-26 11:05:48 +02:00
2032 changed files with 22850 additions and 1397 deletions

6
.gitignore vendored Normal file → Executable file
View File

@@ -11,3 +11,9 @@ bin/*
local/session/*
coverage
.idea
.buildpath
.project
.settings/
local/cache/*
composer.lock
web/assets/*

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "core/lib/Thelia/Tpex"]
path = core/lib/Thelia/Tpex
url = https://github.com/thelia/Tpex.git

0
COPYING.txt Normal file → Executable file
View File

0
COPYRIGHT.txt Normal file → Executable file
View File

0
Licence.txt Normal file → Executable file
View File

0
Readme.md Normal file → Executable file
View File

16
composer.json Normal file → Executable file
View File

@@ -7,7 +7,7 @@
"wiki" : "http://thelia.net/wiki"
},
"require":{
"php": ">=5.4",
"php": ">=5.3",
"ezyang/htmlpurifier": "dev-master",
"ircmaxell/password-compat": "dev-master",
"propel/propel1" : "1.6.*",
@@ -21,7 +21,19 @@
"symfony/routing" : "2.2.*",
"symfony/filesystem" : "2.2.*",
"symfony/yaml" : "2.2.*",
"symfony-cmf/routing": "1.0.0"
"symfony/translation" : "2.2.*",
"symfony-cmf/routing": "1.0.0",
"symfony/form": "2.2.*",
"symfony/validator": "2.2.*",
"symfony/security": "2.2.*",
"symfony/templating": "2.2.*",
"smarty/smarty": "v3.1.13",
"kriswallsmith/assetic": "1.2.*@dev",
"leafo/lessphp": "0.3.*@dev",
"ptachoire/cssembed": "dev-master"
},
"require-dev" : {
"fzaninotto/faker": "dev-master"

878
composer.lock generated
View File

@@ -1,878 +0,0 @@
{
"_readme": [
"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": "70ffc474830be26b4d7e156dd2aa5c31",
"packages": [
{
"name": "ezyang/htmlpurifier",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/ezyang/htmlpurifier.git",
"reference": "v4.5.0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/v4.5.0",
"reference": "v4.5.0",
"shasum": ""
},
"require": {
"php": ">=5.2"
},
"type": "library",
"autoload": {
"psr-0": {
"HTMLPurifier": "library/"
},
"files": [
"library/HTMLPurifier.composer.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"LGPL"
],
"authors": [
{
"name": "Edward Z. Yang",
"email": "admin@htmlpurifier.org",
"homepage": "http://ezyang.com"
}
],
"description": "Standards compliant HTML filter written in PHP",
"homepage": "http://htmlpurifier.org/",
"keywords": [
"html"
],
"time": "2013-02-18 00:04:08"
},
{
"name": "ircmaxell/password-compat",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/ircmaxell/password_compat.git",
"reference": "6925da603b31bfff9488480c0a9db48a0feeadf1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/6925da603b31bfff9488480c0a9db48a0feeadf1",
"reference": "6925da603b31bfff9488480c0a9db48a0feeadf1",
"shasum": ""
},
"type": "library",
"autoload": {
"files": [
"lib/password.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Anthony Ferrara",
"email": "ircmaxell@php.net",
"homepage": "http://blog.ircmaxell.com"
}
],
"description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash",
"homepage": "https://github.com/ircmaxell/password_compat",
"keywords": [
"hashing",
"password"
],
"time": "2013-05-10 11:19:13"
},
{
"name": "phing/phing",
"version": "2.5.0",
"source": {
"type": "git",
"url": "https://github.com/phingofficial/phing.git",
"reference": "2.5.0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phingofficial/phing/zipball/2.5.0",
"reference": "2.5.0",
"shasum": ""
},
"require": {
"php": ">=5.2.0"
},
"bin": [
"bin/phing"
],
"type": "library",
"autoload": {
"classmap": [
"classes/phing/"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"classes"
],
"license": [
"LGPL3"
],
"authors": [
{
"name": "Michiel Rook",
"email": "mrook@php.net"
},
{
"name": "Phing Community",
"homepage": "http://www.phing.info/trac/wiki/Development/Contributors"
}
],
"description": "PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.",
"homepage": "http://www.phing.info/",
"keywords": [
"build",
"task",
"tool"
],
"time": "2013-02-16 14:23:57"
},
{
"name": "propel/propel1",
"version": "1.6.9",
"source": {
"type": "git",
"url": "https://github.com/propelorm/Propel.git",
"reference": "1.6.9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/propelorm/Propel/zipball/1.6.9",
"reference": "1.6.9",
"shasum": ""
},
"require": {
"phing/phing": ">=2.4,<3.0",
"php": ">=5.2.4"
},
"bin": [
"generator/bin/propel-gen",
"generator/bin/propel-gen.bat"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6-dev"
}
},
"autoload": {
"classmap": [
"runtime/lib",
"generator/lib"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"runtime/lib",
"generator/lib"
],
"license": [
"MIT"
],
"authors": [
{
"name": "William Durand",
"email": "william.durand1@gmail.com",
"homepage": "http://www.willdurand.fr"
}
],
"description": "Propel is an open-source Object-Relational Mapping (ORM) for PHP5.",
"homepage": "http://www.propelorm.org/",
"keywords": [
"Active Record",
"database",
"mapping",
"orm",
"persistence"
],
"time": "2013-03-31 17:20:51"
},
{
"name": "psr/log",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log",
"reference": "1.0.0"
},
"dist": {
"type": "zip",
"url": "https://github.com/php-fig/log/archive/1.0.0.zip",
"reference": "1.0.0",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-0": {
"Psr\\Log\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"keywords": [
"log",
"psr",
"psr-3"
],
"time": "2012-12-21 11:40:51"
},
{
"name": "symfony-cmf/routing",
"version": "1.0.0",
"target-dir": "Symfony/Cmf/Component/Routing",
"source": {
"type": "git",
"url": "https://github.com/symfony-cmf/Routing.git",
"reference": "1.0.0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony-cmf/Routing/zipball/1.0.0",
"reference": "1.0.0",
"shasum": ""
},
"require": {
"php": ">=5.3.2",
"symfony/http-kernel": ">=2.1,<2.3-dev",
"symfony/routing": ">=2.1,<2.3-dev"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Cmf\\Component\\Routing": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Symfony CMF Community",
"homepage": "https://github.com/symfony-cmf/Routing/contributors"
}
],
"description": "Extends the Symfony2 routing component for dynamic routes and chaining several routers",
"homepage": "http://cmf.symfony.com",
"keywords": [
"database",
"routing"
],
"time": "2013-03-25 15:02:40"
},
{
"name": "symfony/class-loader",
"version": "v2.2.2",
"target-dir": "Symfony/Component/ClassLoader",
"source": {
"type": "git",
"url": "https://github.com/symfony/ClassLoader.git",
"reference": "v2.2.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/ClassLoader/zipball/v2.2.2",
"reference": "v2.2.2",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"symfony/finder": ">=2.0,<3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\ClassLoader\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony ClassLoader Component",
"homepage": "http://symfony.com",
"time": "2013-05-06 20:02:13"
},
{
"name": "symfony/config",
"version": "v2.2.2",
"target-dir": "Symfony/Component/Config",
"source": {
"type": "git",
"url": "https://github.com/symfony/Config.git",
"reference": "v2.2.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Config/zipball/v2.2.2",
"reference": "v2.2.2",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\Config\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony Config Component",
"homepage": "http://symfony.com",
"time": "2013-05-10 18:08:31"
},
{
"name": "symfony/console",
"version": "v2.2.2",
"target-dir": "Symfony/Component/Console",
"source": {
"type": "git",
"url": "https://github.com/symfony/Console.git",
"reference": "v2.2.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Console/zipball/v2.2.2",
"reference": "v2.2.2",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\Console\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony Console Component",
"homepage": "http://symfony.com",
"time": "2013-05-27 14:47:40"
},
{
"name": "symfony/dependency-injection",
"version": "v2.2.2",
"target-dir": "Symfony/Component/DependencyInjection",
"source": {
"type": "git",
"url": "https://github.com/symfony/DependencyInjection.git",
"reference": "v2.2.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/v2.2.2",
"reference": "v2.2.2",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"symfony/config": ">=2.2,<2.3-dev",
"symfony/yaml": ">=2.0,<3.0"
},
"suggest": {
"symfony/config": "2.2.*",
"symfony/yaml": "2.2.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\DependencyInjection\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony DependencyInjection Component",
"homepage": "http://symfony.com",
"time": "2013-05-06 08:37:50"
},
{
"name": "symfony/event-dispatcher",
"version": "v2.2.2",
"target-dir": "Symfony/Component/EventDispatcher",
"source": {
"type": "git",
"url": "https://github.com/symfony/EventDispatcher.git",
"reference": "v2.2.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/v2.2.2",
"reference": "v2.2.2",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"symfony/dependency-injection": ">=2.0,<3.0"
},
"suggest": {
"symfony/dependency-injection": "2.2.*",
"symfony/http-kernel": "2.2.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\EventDispatcher\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony EventDispatcher Component",
"homepage": "http://symfony.com",
"time": "2013-02-11 11:26:43"
},
{
"name": "symfony/filesystem",
"version": "v2.2.2",
"target-dir": "Symfony/Component/Filesystem",
"source": {
"type": "git",
"url": "https://github.com/symfony/Filesystem.git",
"reference": "v2.2.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/v2.2.2",
"reference": "v2.2.2",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\Filesystem\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony Filesystem Component",
"homepage": "http://symfony.com",
"time": "2013-05-06 20:02:13"
},
{
"name": "symfony/http-foundation",
"version": "v2.2.2",
"target-dir": "Symfony/Component/HttpFoundation",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpFoundation.git",
"reference": "v2.2.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/v2.2.2",
"reference": "v2.2.2",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\HttpFoundation\\": ""
},
"classmap": [
"Symfony/Component/HttpFoundation/Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony HttpFoundation Component",
"homepage": "http://symfony.com",
"time": "2013-05-27 14:47:40"
},
{
"name": "symfony/http-kernel",
"version": "v2.2.2",
"target-dir": "Symfony/Component/HttpKernel",
"source": {
"type": "git",
"url": "https://github.com/symfony/HttpKernel.git",
"reference": "v2.2.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/HttpKernel/zipball/v2.2.2",
"reference": "v2.2.2",
"shasum": ""
},
"require": {
"php": ">=5.3.3",
"psr/log": ">=1.0,<2.0",
"symfony/event-dispatcher": ">=2.1,<3.0",
"symfony/http-foundation": ">=2.2,<2.3-dev"
},
"require-dev": {
"symfony/browser-kit": "2.2.*",
"symfony/class-loader": ">=2.1,<3.0",
"symfony/config": ">=2.0,<3.0",
"symfony/console": "2.2.*",
"symfony/dependency-injection": ">=2.0,<3.0",
"symfony/finder": ">=2.0,<3.0",
"symfony/process": ">=2.0,<3.0",
"symfony/routing": ">=2.2,<2.3-dev",
"symfony/stopwatch": ">=2.2,<2.3-dev"
},
"suggest": {
"symfony/browser-kit": "2.2.*",
"symfony/class-loader": "2.2.*",
"symfony/config": "2.2.*",
"symfony/console": "2.2.*",
"symfony/dependency-injection": "2.2.*",
"symfony/finder": "2.2.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\HttpKernel\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony HttpKernel Component",
"homepage": "http://symfony.com",
"time": "2013-06-02 13:03:09"
},
{
"name": "symfony/routing",
"version": "v2.2.2",
"target-dir": "Symfony/Component/Routing",
"source": {
"type": "git",
"url": "https://github.com/symfony/Routing.git",
"reference": "v2.2.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Routing/zipball/v2.2.2",
"reference": "v2.2.2",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"doctrine/common": ">=2.2,<3.0",
"psr/log": ">=1.0,<2.0",
"symfony/config": ">=2.2,<2.3-dev",
"symfony/yaml": ">=2.0,<3.0"
},
"suggest": {
"doctrine/common": "~2.2",
"symfony/config": "2.2.*",
"symfony/yaml": "2.2.*"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\Routing\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony Routing Component",
"homepage": "http://symfony.com",
"time": "2013-05-10 16:49:00"
},
{
"name": "symfony/yaml",
"version": "v2.2.2",
"target-dir": "Symfony/Component/Yaml",
"source": {
"type": "git",
"url": "https://github.com/symfony/Yaml.git",
"reference": "v2.2.2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/Yaml/zipball/v2.2.2",
"reference": "v2.2.2",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
}
},
"autoload": {
"psr-0": {
"Symfony\\Component\\Yaml\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"description": "Symfony Yaml Component",
"homepage": "http://symfony.com",
"time": "2013-05-10 18:08:31"
}
],
"packages-dev": [
{
"name": "fzaninotto/faker",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/fzaninotto/Faker.git",
"reference": "v1.2.0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/v1.2.0",
"reference": "v1.2.0",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
}
},
"autoload": {
"psr-0": {
"Faker": "src/",
"Faker\\PHPUnit": "test/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "François Zaninotto"
}
],
"description": "Faker is a PHP library that generates fake data for you.",
"keywords": [
"data",
"faker",
"fixtures"
],
"time": "2013-06-09 18:05:57"
}
],
"aliases": [
],
"minimum-stability": "stable",
"stability-flags": {
"ezyang/htmlpurifier": 20,
"ircmaxell/password-compat": 20,
"fzaninotto/faker": 20
},
"platform": {
"php": ">=5.4"
},
"platform-dev": [
]
}

11
core/bootstrap.php Normal file → Executable file
View File

@@ -5,10 +5,13 @@
* @file
* Functions needed for Thelia bootstrap
*/
define('THELIA_ROOT', realpath(__DIR__ .'/../') . "/");
define('THELIA_CONF_DIR', THELIA_ROOT . '/local/config');
define('THELIA_MODULE_DIR', THELIA_ROOT . '/local/modules');
define('THELIA_TEMPLATE_DIR', THELIA_ROOT . 'templates/');
define('THELIA_ROOT' , rtrim(realpath(__DIR__ .'/../'),'/') . "/");
define('THELIA_LOCAL_DIR' , THELIA_ROOT . '/local/');
define('THELIA_CONF_DIR' , THELIA_LOCAL_DIR . 'config/');
define('THELIA_MODULE_DIR' , THELIA_LOCAL_DIR . 'modules/');
define('THELIA_WEB_DIR' , THELIA_ROOT . '/web/');
define('THELIA_TEMPLATE_DIR' , THELIA_ROOT . '/templates/');
$loader = require __DIR__ . "/vendor/autoload.php";

0
core/lib/Thelia/Action/Cart.php Normal file → Executable file
View File

0
core/lib/Thelia/Action/Customer.php Normal file → Executable file
View File

View File

@@ -0,0 +1,67 @@
<?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\Admin\Controller;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Form\AdminLogin;
class AdminController extends BaseAdminController {
public function indexAction()
{
$form = $this->getLoginForm();
$request = $this->getRequest();
if($request->isMethod("POST")) {
$form->bind($request);
if($form->isValid()) {
echo "valid"; exit;
}
}
return $this->render("login.html", array(
"form" => $form->createView()
));
}
protected function getLoginForm()
{
$form = $this->getFormBuilder();
$adminLogin = new AdminLogin();
return $adminLogin->buildForm($form, array())->getForm();
}
public function lostAction()
{
return new Response(
$this->renderRaw("404.html"),
404
);
}
}

View File

@@ -0,0 +1,94 @@
<?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\Admin\Controller;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Form\BaseForm;
use Thelia\Model\ConfigQuery;
/**
*
* The defaut administration controller. Basically, display the login form if
* user is not yet logged in, or back-office home page if the user is logged in.
*
* @author Franck Allimant <franck@cqfdev.fr>
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class BaseAdminController extends ContainerAware
{
/**
* @param $templateName
* @param array $args
* @return \Symfony\Component\HttpFoundation\Response
*/
public function render($templateName, $args = array())
{
$args = array_merge($args, array('lang' => 'fr'));
$response = new Response();
return $response->setContent($this->renderRaw($templateName, $args));
}
public function renderRaw($templateName, $args = array())
{
$args = array_merge($args, array('lang' => 'fr'));
return $this->getParser()->render($templateName, $args);
}
/**
* @return \Symfony\Component\HttpFoundation\Request
*/
public function getRequest()
{
return $this->container->get('request');
}
public function getParser()
{
$parser = $this->container->get("thelia.parser");
// FIXME: should be read from config
$parser->setTemplate('admin/default');
return $parser;
}
public function getFormFactory()
{
return BaseForm::getFormFactory($this->getRequest(), ConfigQuery::read("form.secret.admin", md5(__DIR__)));
}
public function getFormBuilder()
{
return $this->getFormFactory()->createBuilder("form");
}
}

0
core/lib/Thelia/Command/CacheClear.php Normal file → Executable file
View File

0
core/lib/Thelia/Command/ContainerAwareCommand.php Normal file → Executable file
View File

0
core/lib/Thelia/Command/Install.php Normal file → Executable file
View File

0
core/lib/Thelia/Config/DatabaseConfiguration.php Normal file → Executable file
View File

0
core/lib/Thelia/Config/DefinePropel.php Normal file → Executable file
View File

0
core/lib/Thelia/Config/Resources/action.xml Normal file → Executable file
View File

92
core/lib/Thelia/Config/Resources/config.xml Normal file → Executable file
View File

@@ -4,20 +4,35 @@
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">
<testLoops>
<testLoop name="equal" class="Thelia\Core\Template\TestLoop\Equal"/>
</testLoops>
<loops>
<loop class="Thelia\Core\Template\Loop\Category" name="category"/>
</loops>
<filters>
<!-- Sample definition
<filter class="Thelia\Core\Template\Filter\SomeFilterClass" name="my_filter"/>
-->
</filters>
<templateDirectives>
<!-- Sample definition
<templateDirectives class="Thelia\Core\Template\Filter\SomeFilterClass" name="my_filter"/>
-->
</templateDirectives>
<forms>
<form name="thelia.customer.creation" class="Thelia\Form\CustomerCreation"/>
</forms>
<commands>
<command class="Thelia\Command\CacheClear"/>
<command class="Thelia\Command\Install"/>
</commands>
<services>
<service id="event_dispatcher" class="Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher">
<argument type="service" id="service_container" />
</service>
@@ -26,10 +41,56 @@
<tag name="kernel.event_subscriber"/>
</service>
<service id="controller_resolver" class="Symfony\Component\HttpKernel\Controller\ControllerResolver"/>
<!--
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)
We use it here to inject the servi ce container in the admin base controller.
-->
<service id="controller_resolver" class="Thelia\Core\Controller\ControllerResolver">
<argument type="service" id="service_container"/>
</service>
<service id="parser" class="Thelia\Core\Template\Parser">
<argument type="service" id="service_container"/>
<!-- Parser configuration -->
<service id="thelia.parser" class="Thelia\Core\Template\Smarty\SmartyParser" scope="request">
<argument type="service" id="request" />
<argument type="service" id="event_dispatcher"/>
<argument >false</argument>
<argument >%kernel.environment%</argument>
<argument >%kernel.debug%</argument>
</service>
<!-- Smarty parser plugins -->
<service id="smarty.plugin.assetic" class="Thelia\Core\Template\Smarty\Plugins\Assetic" >
<tag name="thelia.parser.register_plugin"/>
</service>
<service id="smarty.plugin.thelialoop" class="Thelia\Core\Template\Smarty\Plugins\TheliaLoop" scope="request">
<tag name="thelia.parser.register_plugin"/>
<argument type="service" id="request" />
<argument type="service" id="event_dispatcher"/>
<call method="setLoopList">
<argument>%thelia.parser.loops%</argument>
</call>
</service>
<service id="smart.plugin.form" class="Thelia\Core\Template\Smarty\Plugins\Form" scope="request">
<tag name="thelia.parser.register_plugin"/>
<argument type="service" id="request"/>
<call method="setFormDefinition">
<argument>%thelia.parser.forms%</argument>
</call>
</service>
<service id="smarty.plugin.translation" class="Thelia\Core\Template\Smarty\Plugins\Translation" >
<tag name="thelia.parser.register_plugin"/>
</service>
<service id="smarty.plugin.module" class="Thelia\Core\Template\Smarty\Plugins\Module" >
<tag name="thelia.parser.register_plugin"/>
</service>
<service id="http_kernel" class="Thelia\Core\TheliaHttpKernel">
@@ -38,23 +99,6 @@
<argument type="service" id="controller_resolver" />
</service>
<service id="template" class="Thelia\Tpex\Tpex" scope="request">
<argument type="service" id="request" />
<argument type="service" id="event_dispatcher"/>
<call method="setLoop">
<argument>%tpex.loop%</argument>
</call>
<call method="setFilter">
<argument>%tpex.filter%</argument>
</call>
<call method="setBaseParams">
<argument>%tpex.baseParam%</argument>
</call>
<call method="setTestLoop">
<argument>%tpex.testLoop%</argument>
</call>
</service>
<service id="request" scope="request" synthetic="true" />
<service id="service_container" synthetic="true" />

6
core/lib/Thelia/Config/Resources/routing.xml Normal file → Executable file
View File

@@ -20,6 +20,10 @@
<service id="controller.default" class="Thelia\Controller\DefaultController"/>
<service id="thelia.admin.base_controller" class="Thelia\Admin\Controller\BaseAdminController" scope="request">
<argument type="service" id="thelia.parser"/>
</service>
<service id="matcher.default" class="Thelia\Routing\Matcher\DefaultMatcher">
<argument type="service" id="controller.default"/>
</service>
@@ -44,7 +48,7 @@
<service id="router.admin" class="%router.class%">
<argument type="service" id="router.admin.xmlLoader"/>
<argument>routing.xml</argument>
<argument>admin.xml</argument>
<argument type="collection">
<argument key="cache_dir">%kernel.cache_dir%</argument>
<argument key="debug">%kernel.debug%</argument>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="admin" path="/admin">
<default key="_controller">Thelia\Admin\Controller\AdminController::indexAction</default>
</route>
<route id="admin.login" path="/admin/login">
<default key="_controller">Thelia\Admin\Controller\AdminController::loginAction</default>
</route>
<route id="admin.lost" path="/admin/{everything}">
<default key="_controller">Thelia\Admin\Controller\AdminController::lostAction</default>
<requirement key="everything">.*</requirement>
</route>
</routes>

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="blog" path="/">
<default key="_controller">Thelia\Controller\Admin</default>
</route>
</routes>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<import resource="admin_routing.xml" prefix="/admin" />
</routes>

0
core/lib/Thelia/Controller/DefaultController.php Normal file → Executable file
View File

0
core/lib/Thelia/Controller/NullControllerInterface.php Normal file → Executable file
View File

5
core/lib/Thelia/Core/Application.php Normal file → Executable file
View File

@@ -29,7 +29,6 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpKernel\KernelInterface;
class Application extends BaseApplication
{
@@ -68,8 +67,7 @@ class Application extends BaseApplication
$container = $this->kernel->getContainer();
foreach($container->getParameter("command.definition") as $command)
{
foreach ($container->getParameter("command.definition") as $command) {
$r = new \ReflectionClass($command);
if ($r->isSubclassOf('Symfony\\Component\\Console\\Command\\Command') && !$r->isAbstract()) {
@@ -77,6 +75,5 @@ class Application extends BaseApplication
}
}
}
}

7
core/lib/Thelia/Core/Bundle/TheliaBundle.php Normal file → Executable file
View File

@@ -4,7 +4,7 @@
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
@@ -17,17 +17,17 @@
/* 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/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core\Bundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Scope;
use Thelia\Core\DependencyInjection\Compiler\RegisterListenersPass;
use Thelia\Core\DependencyInjection\Compiler\RegisterParserPluginPass;
/**
* First Bundle use in Thelia
@@ -56,5 +56,6 @@ class TheliaBundle extends Bundle
$container->addScope(new Scope('request'));
$container->addCompilerPass(new RegisterListenersPass());
$container->addCompilerPass(new RegisterParserPluginPass());
}
}

View File

@@ -0,0 +1,73 @@
<?php
namespace Thelia\Core\Controller;
use Symfony\Component\HttpKernel\Controller\ControllerResolver as BaseControllerResolver;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
/**
* ControllerResolver that supports "a:b:c", "service:method" and class::method" notations in routes definition
* thus allowing the definition of controllers as service (see http://symfony.com/fr/doc/current/cookbook/controller/service.html)
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Franck Allimant <franck@cqfdev.fr>
*/
class ControllerResolver extends BaseControllerResolver
{
protected $container;
/**
* Constructor.
*
* @param ContainerInterface $container A ContainerInterface instance
* @param LoggerInterface $logger A LoggerInterface instance
*/
public function __construct(ContainerInterface $container, LoggerInterface $logger = null)
{
$this->container = $container;
parent::__construct($logger);
}
/**
* Returns a callable for the given controller.
*
* @param string $controller A Controller string
*
* @return mixed A PHP callable
*
* @throws \LogicException When the name could not be parsed
* @throws \InvalidArgumentException When the controller class does not exist
*/
protected function createController($controller)
{
if (false === strpos($controller, '::')) {
$count = substr_count($controller, ':');
if (2 == $count) {
// controller in the a:b:c notation then
$controller = $this->parser->parse($controller);
} elseif (1 == $count) {
// controller in the service:method notation
list($service, $method) = explode(':', $controller, 2);
return array($this->container->get($service), $method);
} else {
throw new \LogicException(sprintf('Unable to parse the controller name "%s".', $controller));
}
}
list($class, $method) = explode('::', $controller, 2);
if (!class_exists($class)) {
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
}
$controller = new $class();
if ($controller instanceof ContainerAwareInterface) {
$controller->setContainer($this->container);
}
return array($controller, $method);
}
}

View File

@@ -0,0 +1,59 @@
<?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\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
/**
* Register parser plugins. These plugins shouild be tagged thelia.parser.register_plugin
* in the configuration.
*
*
*/
class RegisterParserPluginPass implements CompilerPassInterface
{
/**
* You can modify the container here before it is dumped to PHP code.
*
* @param ContainerBuilder $container
*
* @api
*/
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition("thelia.parser")) {
return;
}
$smarty = $container->getDefinition("thelia.parser");
foreach ($container->findTaggedServiceIds("thelia.parser.register_plugin") as $id => $plugin) {
$smarty->addMethodCall("addPlugins", array(new Reference($id)));
}
$smarty->addMethodCall("registerPlugins");
}
}

View File

@@ -24,12 +24,12 @@
namespace Thelia\Core\DependencyInjection\Loader;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader as XmlLoader;
use Symfony\Component\Config\Util\XmlUtils;
use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\SimpleXMLElement;
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
@@ -57,14 +57,14 @@ class XmlFileLoader extends FileLoader
$this->parseFilters($xml);
$this->parseBaseParams($xml);
$this->parseTestLoops($xml);
$this->parseTemplateDirectives($xml);
$this->parseParameters($xml);
$this->parseCommands($xml);
$this->parseForms($xml);
$this->parseDefinitions($xml, $path);
}
@@ -75,7 +75,7 @@ class XmlFileLoader extends FileLoader
}
try {
$commandConfig = $this->container->getParameter("command.definition");
} catch (\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) {
} catch (ParameterNotFoundException $e) {
$commandConfig = array();
}
@@ -112,8 +112,8 @@ class XmlFileLoader extends FileLoader
return;
}
try {
$loopConfig = $this->container->getParameter("Tpex.loop");
} catch (\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) {
$loopConfig = $this->container->getParameter("Thelia.parser.loops");
} catch (ParameterNotFoundException $e) {
$loopConfig = array();
}
@@ -121,7 +121,26 @@ class XmlFileLoader extends FileLoader
$loopConfig[$loop->getAttributeAsPhp("name")] = $loop->getAttributeAsPhp("class");
}
$this->container->setParameter("Tpex.loop", $loopConfig);
$this->container->setParameter("Thelia.parser.loops", $loopConfig);
}
protected function parseForms(SimpleXMLElement $xml)
{
if (false === $forms = $xml->xpath('//config:forms/config:form')) {
return;
}
try {
$formConfig = $this->container->getParameter("Thelia.parser.forms");
} catch (ParameterNotFoundException $e) {
$formConfig = array();
}
foreach ($forms as $form) {
$formConfig[$form->getAttributeAsPhp('name')] = $form->getAttributeAsPhp('class');
}
$this->container->setParameter('Thelia.parser.forms', $formConfig);
}
/**
@@ -135,8 +154,8 @@ class XmlFileLoader extends FileLoader
return;
}
try {
$filterConfig = $this->container->getParameter("Tpex.filter");
} catch (\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) {
$filterConfig = $this->container->getParameter("Thelia.parser.filters");
} catch (ParameterNotFoundException $e) {
$filterConfig = array();
}
@@ -144,7 +163,7 @@ class XmlFileLoader extends FileLoader
$filterConfig[$filter->getAttributeAsPhp("name")] = $filter->getAttributeAsPhp("class");
}
$this->container->setParameter("Tpex.filter", $filterConfig);
$this->container->setParameter("Thelia.parser.filters", $filterConfig);
}
/**
@@ -152,14 +171,14 @@ class XmlFileLoader extends FileLoader
*
* @param SimpleXMLElement $xml
*/
protected function parseBaseParams(SimpleXMLElement $xml)
protected function parseTemplateDirectives(SimpleXMLElement $xml)
{
if (false === $baseParams = $xml->xpath('//config:baseParams/config:baseParam')) {
if (false === $baseParams = $xml->xpath('//config:templateDirectives/config:templateDirective')) {
return;
}
try {
$baseParamConfig = $this->container->getParameter("Tpex.baseParam");
} catch (\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) {
$baseParamConfig = $this->container->getParameter("Thelia.parser.templateDirectives");
} catch (ParameterNotFoundException $e) {
$baseParamConfig = array();
}
@@ -167,30 +186,7 @@ class XmlFileLoader extends FileLoader
$baseParamConfig[$baseParam->getAttributeAsPhp("name")] = $baseParam->getAttributeAsPhp("class");
}
$this->container->setParameter("Tpex.baseParam", $baseParamConfig);
}
/**
* parse testLoops property
*
* @param SimpleXMLElement $xml
*/
protected function parseTestLoops(SimpleXMLElement $xml)
{
if (false === $testLoops = $xml->xpath('//config:testLoops/config:testLoop')) {
return;
}
try {
$baseParamConfig = $this->container->getParameter("Tpex.baseParam");
} catch (\Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException $e) {
$baseParamConfig = array();
}
foreach ($testLoops as $testLoop) {
$baseParamConfig[$testLoop->getAttributeAsPhp("name")] = $testLoop->getAttributeAsPhp("class");
}
$this->container->setParameter("Tpex.testLoop", $baseParamConfig);
$this->container->setParameter("Thelia.parser.templateDirectives", $baseParamConfig);
}
/**
@@ -359,7 +355,7 @@ EOF
/**
* Returns true if this class supports the given resource.
*
* @param mixed $resource A resource
* @param mixed $resource A resource
* @param string $type The resource type
*
* @return Boolean true if this class supports the given resource, false otherwise

View File

@@ -10,12 +10,12 @@
<xsd:complexType name="config">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="loops" type="loops" />
<xsd:element name="filters" type="filter" />
<xsd:element name="baseParams" type="baseParams" />
<xsd:element name="testLoops" type="testLoops" />
<xsd:element name="filters" type="filters" />
<xsd:element name="templateDirectives" type="templateDirectives" />
<xsd:element name="services" type="services" />
<xsd:element name="parameters" type="parameters"/>
<xsd:element name="commands" type="commands"/>
<xsd:element name="forms" type="forms" />
</xsd:choice>
</xsd:complexType>
@@ -55,7 +55,7 @@
</xsd:simpleType>
<xsd:complexType name="loops">
<xsd:choice minOccurs="1" maxOccurs="unbounded" >
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
<xsd:element name="loop" type="loop"/>
</xsd:choice>
</xsd:complexType>
@@ -66,7 +66,7 @@
</xsd:complexType>
<xsd:complexType name="commands">
<xsd:choice minOccurs="1" maxOccurs="unbounded" >
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
<xsd:element name="command" type="command"/>
</xsd:choice>
</xsd:complexType>
@@ -75,8 +75,19 @@
<xsd:attribute name="class" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="forms">
<xsd:choice minOccurs="0" maxOccurs="unbounded" >
<xsd:element name="form" type="form" />
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="form">
<xsd:attribute name="name" type="xsd:string" use="required" />
<xsd:attribute name="class" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="filters">
<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="filter" type="filter" />
</xsd:choice>
</xsd:complexType>
@@ -86,24 +97,13 @@
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="baseParams">
<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:element name="baseParam" type="baseParam" />
<xsd:complexType name="templateDirectives">
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="templateDirective" type="templateDirective" />
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="baseParam">
<xsd:attribute name="class" type="xsd:string" use="required" />
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
<xsd:complexType name="testLoops">
<xsd:choice minOccurs="1" maxOccurs="unbounded">
<xsd:element name="testLoop" type="testLoop" />
</xsd:choice>
</xsd:complexType>
<xsd:complexType name="testLoop">
<xsd:complexType name="templateDirective">
<xsd:attribute name="class" type="xsd:string" use="required" />
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>

5
core/lib/Thelia/Core/Event/ActionEvent.php Normal file → Executable file
View File

@@ -50,9 +50,10 @@ abstract class ActionEvent extends Event
/**
*
* @param \Symfony\Component\HttpFoundation\Request $request
* @param string $action
* @param string $action
*/
public function __construct(Request $request, $action) {
public function __construct(Request $request, $action)
{
$this->request = $request;
$this->action = $action;
}

4
core/lib/Thelia/Core/Event/DefaultActionEvent.php Normal file → Executable file
View File

@@ -11,6 +11,6 @@ namespace Thelia\Core\Event;
use Thelia\Core\Event\ActionEvent;
class DefaultActionEvent extends ActionEvent {
class DefaultActionEvent extends ActionEvent
{
}

0
core/lib/Thelia/Core/Event/TheliaEvents.php Normal file → Executable file
View File

View File

@@ -25,10 +25,8 @@ namespace Thelia\Core\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Factory\ActionEventFactory;
/**
*
* Action are dispatch here.
@@ -41,7 +39,6 @@ use Thelia\Core\Factory\ActionEventFactory;
class ControllerListener implements EventSubscriberInterface
{
public function onKernelController(FilterControllerEvent $event)
{
$dispatcher = $event->getDispatcher();

8
core/lib/Thelia/Core/EventListener/ViewListener.php Normal file → Executable file
View File

@@ -28,7 +28,7 @@ use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Thelia\Core\Template\Exception\ResourceNotFoundException;
use Thelia\Core\Template\ParserInterface;
/**
@@ -67,7 +67,9 @@ class ViewListener implements EventSubscriberInterface
*/
public function onKernelView(GetResponseForControllerResultEvent $event)
{
$parser = $this->container->get('parser');
$parser = $this->container->get('thelia.parser');
try {
$content = $parser->getContent();
@@ -76,7 +78,7 @@ class ViewListener implements EventSubscriberInterface
} else {
$event->setResponse(new Response($content, $parser->getStatus() ?: 200));
}
} catch(ResourceNotFoundException $e) {
} catch (ResourceNotFoundException $e) {
$event->setResponse(new Response($e->getMessage(), 404));
}

2
core/lib/Thelia/Core/Factory/ActionEventFactory.php Normal file → Executable file
View File

@@ -24,8 +24,6 @@
namespace Thelia\Core\Factory;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Event\ActionEventClass;
class ActionEventFactory
{

View File

@@ -0,0 +1,122 @@
<?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\Assets;
use Assetic\AssetManager;
use Assetic\FilterManager;
use Assetic\Filter;
use Assetic\Factory\AssetFactory;
use Assetic\Factory\Worker\CacheBustingWorker;
use Assetic\AssetWriter;
use Assetic\Asset\AssetCache;
use Assetic\Cache\FilesystemCache;
/**
* This class is a simple helper for generating assets using Assetic.
*
* @author Franck Allimant <franck@cqfdev.fr>
*/
class AsseticHelper
{
/**
* Generates assets from $asset_path in $output_path, using $filters.
*
* @param string $asset_path the full path to the asset file (or file collection)
* @param unknown $output_path the full disk path to the output directory (shoud be visible to web server)
* @param unknown $output_url the URL to the generated asset directory
* @param unknown $asset_type the asset type: css, js, ... The generated files will have this extension. Pass an empty string to use the asset source extension.
* @param unknown $filters a list of filters, as defined below (see switch($filter_name) ...)
* @param unknown $debug true / false
* @throws \InvalidArgumentException if an invalid filter name is found
* @return string The URL to the generated asset file.
*/
public function asseticize($asset_path, $output_path, $output_url, $asset_type, $filters, $debug)
{
$asset_name = basename($asset_path);
$asset_dir = dirname($asset_path);
$am = new AssetManager();
$fm = new FilterManager();
if (! empty($filters)) {
$filter_list = explode(',', $filters);
foreach ($filter_list as $filter_name) {
$filter_name = trim($filter_name);
switch ($filter_name) {
case 'less' :
$fm->set('less', new Filter\LessphpFilter());
break;
case 'sass' :
$fm->set('less', new Filter\Sass\SassFilter());
break;
case 'cssembed' :
$fm->set('cssembed', new Filter\PhpCssEmbedFilter());
break;
case 'cssrewrite':
$fm->set('cssrewrite', new Filter\CssRewriteFilter());
break;
case 'cssimport':
$fm->set('cssimport', new Filter\CssImportFilter());
break;
default :
throw new \InvalidArgumentException("Unsupported Assetic filter: '$filter_name'");
break;
}
}
} else {
$filter_list = array();
}
// Factory setup
$factory = new AssetFactory($asset_dir);
$factory->setAssetManager($am);
$factory->setFilterManager($fm);
$factory->setDefaultOutput('*'.(! empty($asset_type) ? '.' : '').$asset_type);
$factory->setDebug($debug);
$factory->addWorker(new CacheBustingWorker());
// Prepare the assets writer
$writer = new AssetWriter($output_path);
$asset = $factory->createAsset($asset_name, $filter_list);
$cache = new AssetCache($asset, new FilesystemCache($output_path));
$writer->writeAsset($cache);
return rtrim($output_url, '/').'/'.$asset->getTargetPath();
}
}

1
core/lib/Thelia/Core/Template/BaseParam/Secure.php Normal file → Executable file
View File

@@ -37,4 +37,3 @@ class Secure extends BaseParam
}
}
}

View File

@@ -0,0 +1,104 @@
<?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\Element;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
/**
*
* Class BaseLoop
* @package Thelia\Tpex\Element\Loop
*/
abstract class BaseLoop
{
/**
* @var \Symfony\Component\HttpFoundation\Request
*/
public $request;
/**
* @var \Symfony\Component\EventDispatcher\EventDispatcherInterface
*/
public $dispatcher;
/**
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
*/
public function __construct(Request $request, EventDispatcherInterface $dispatcher)
{
$this->request = $request;
$this->dispatcher = $dispatcher;
}
/**
*
* this function have to be implement in your own loop class.
*
* All your parameters are defined in defineArgs() and can be accessible like a class property.
*
* example :
*
* public function defineArgs()
* {
* return array (
* "ref",
* "id" => "optional",
* "stock" => array(
* "optional",
* "default" => 10
* )
* );
* }
*
* you can retrieve ref value using $this->ref
*
* @return mixed
*/
abstract public function exec();
/**
*
* define all args used in your loop
*
* array key is your arg name.
*
* example :
*
* return array (
* "ref",
* "id" => "optional",
* "stock" => array(
* "optional",
* "default" => 10
* )
* );
*
* @return ArgumentCollection
*/
abstract public function defineArgs();
}

View File

@@ -0,0 +1,29 @@
<?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\Element\Exception;
class ElementNotFoundException extends \RuntimeException
{
}

View File

@@ -0,0 +1,29 @@
<?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\Element\Exception;
class InvalidElementException extends \RuntimeException
{
}

View File

@@ -0,0 +1,108 @@
<?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\Element;
use Thelia\Core\Template\Element\LoopResultRow;
class LoopResult implements \Iterator
{
private $position;
protected $collection = array();
public function __construct()
{
$this->position = 0;
}
public function isEmpty()
{
return count($this->collection) == 0;
}
public function addRow(LoopResultRow $row)
{
$this->collection[] = $row;
}
public function getCount()
{
return count($this->collection);
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
* @return \Thelia\Core\Template\Element\LoopResultRow
*/
public function current()
{
return $this->collection[$this->position];
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Move forward to next element
* @link http://php.net/manual/en/iterator.next.php
* @return void Any returned value is ignored.
*/
public function next()
{
++$this->position;
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
*/
public function key()
{
return $this->position;
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Checks if current position is valid
* @link http://php.net/manual/en/iterator.valid.php
* @return boolean The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
*/
public function valid()
{
return isset($this->collection[$this->position]);
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Rewind the Iterator to the first element
* @link http://php.net/manual/en/iterator.rewind.php
* @return void Any returned value is ignored.
*/
public function rewind()
{
$this->position = 0;
}
}

View File

@@ -0,0 +1,45 @@
<?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\Element;
class LoopResultRow
{
protected $substitution = array();
public function set($key, $value)
{
$this->substitution["#".$key] = $value;
}
public function get($key)
{
return $this->substitution["#".$key];
}
public function getVarVal()
{
return $this->substitution;
}
}

View File

@@ -0,0 +1,27 @@
<?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\Exception;
class ResourceNotFoundException extends \RuntimeException
{
}

View File

@@ -0,0 +1,45 @@
<?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\Loop\Argument;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class Argument
{
public $name;
public $type;
public $default;
public $mandatory;
public $empty;
public function __construct($name, \Thelia\Type\TypeCollection $type, $default = null, $mandatory = false, $empty = true)
{
$this->name = $name;
$this->type = $type;
$this->mandatory = $mandatory ? true : false;
$this->default = $default;
}
}

View File

@@ -0,0 +1,119 @@
<?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\Loop\Argument;
/**
*
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*
*/
class ArgumentCollection implements \Iterator
{
private $position;
protected $arguments = array();
public function __construct()
{
foreach(func_get_args() as $argument) {
$this->addArgument($argument);
}
}
public function isEmpty()
{
return count($this->arguments) == 0;
}
/**
* @param Argument $argument
*
* @return ArgumentCollection
*/
public function addArgument(Argument $argument)
{
$this->arguments[] = $argument;
return $this;
}
public function getCount()
{
return count($this->arguments);
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Return the current element
* @link http://php.net/manual/en/iterator.current.php
* @return Argument
*/
public function current()
{
return $this->arguments[$this->position];
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Move forward to next element
* @link http://php.net/manual/en/iterator.next.php
* @return void Any returned value is ignored.
*/
public function next()
{
$this->position++;
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Return the key of the current element
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
*/
public function key()
{
return $this->position;
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Checks if current position is valid
* @link http://php.net/manual/en/iterator.valid.php
* @return boolean The return value will be casted to boolean and then evaluated.
* Returns true on success or false on failure.
*/
public function valid()
{
return isset($this->arguments[$this->position]);
}
/**
* (PHP 5 &gt;= 5.0.0)<br/>
* Rewind the Iterator to the first element
* @link http://php.net/manual/en/iterator.rewind.php
* @return void Any returned value is ignored.
*/
public function rewind()
{
$this->position = 0;
}
}

118
core/lib/Thelia/Core/Template/Loop/Category.php Normal file → Executable file
View File

@@ -21,14 +21,19 @@
/* */
/*************************************************************************************/
namespace Thelia\Core\Template\Loop;
use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Tpex\Element\Loop\BaseLoop;
use Thelia\Tpex\Element\Loop\LoopResult;
use Thelia\Tpex\Element\Loop\LoopResultRow;
use Thelia\Model\CategoryQuery;
use Thelia\Type\TypeCollection;
use Thelia\Type;
/**
*
@@ -60,8 +65,8 @@ use Thelia\Model\CategoryQuery;
* @package Thelia\Core\Template\Loop
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Category extends BaseLoop {
class Category extends BaseLoop
{
public $id;
public $parent;
public $current;
@@ -76,41 +81,101 @@ class Category extends BaseLoop {
public function defineArgs()
{
return array(
"id" => "optional",
"parent" => "optional",
"current" => "optional",
"not_empty" => 0,
"visible" => 1,
"link" => "optional",
"order" => "optional",
"random" => 0,
"exclude" => "optional",
"limit" => 10,
"offset" => 0,
return new ArgumentCollection(
new Argument(
'id',
new TypeCollection(
new Type\IntListType()
)
),
new Argument(
'parent',
new TypeCollection(
new Type\IntType()
)
),
new Argument(
'current',
new TypeCollection(
new Type\IntType()
)
),
new Argument(
'not_empty',
new TypeCollection(
new Type\IntType()
),
0
),
new Argument(
'visible',
new TypeCollection(
new Type\IntType()
),
1
),
new Argument(
'link',
new TypeCollection(
new Type\AnyType()
)
),
new Argument(
'order',
new TypeCollection(
new Type\EnumType('alpha', 'alpha_reverse', 'reverse')
)
),
new Argument(
'random',
new TypeCollection(
new Type\AnyType()
),
0
),
new Argument(
'exclude',
new TypeCollection(
new Type\IntListType()
)
),
new Argument(
'limit',
new TypeCollection(
new Type\IntType()
),
10
),
new Argument(
'offset',
new TypeCollection(
new Type\IntType()
),
0
)
);
}
/**
*
*
* @return \Thelia\Tpex\Element\Loop\LoopResult
* @return \Thelia\Core\Template\Element\LoopResult
*/
public function exec()
{
$search = CategoryQuery::create();
if (!is_null($this->id)) {
$search->filterById($this->id, \Criteria::IN);
$search->filterById(explode(',', $this->id), \Criteria::IN);
}
if(!is_null($this->parent)) {
if (!is_null($this->parent)) {
$search->filterByParent($this->parent);
}
if($this->current == 1) {
if ($this->current == 1) {
$search->filterById($this->request->get("category_id"));
} else if ($this->current == 0) {
} elseif (null !== $this->current && $this->current == 0) {
$search->filterById($this->request->get("category_id"), \Criteria::NOT_IN);
}
@@ -122,14 +187,13 @@ class Category extends BaseLoop {
$search->filterByLink($this->link);
}
if($this->limit > -1) {
if ($this->limit > -1) {
$search->limit($this->limit);
}
$search->filterByVisible($this->visible);
$search->offset($this->offset);
switch($this->order) {
switch ($this->order) {
case "alpha":
$search->addAscendingOrderByColumn(\Thelia\Model\CategoryI18nPeer::TITLE);
break;
@@ -144,7 +208,7 @@ class Category extends BaseLoop {
break;
}
if($this->random == 1) {
if ($this->random == 1) {
$search->clearOrderByColumns();
$search->addAscendingOrderByColumn('RAND()');
}

View File

@@ -1,171 +0,0 @@
<?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;
use Symfony\Component\HttpFoundation\Response;
use Thelia\Core\Template\ParserInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Config\ConfigCache;
use Thelia\Tpex\Tpex;
use Thelia\Log\Tlog;
/**
*
* Master class of Thelia's parser. The loop mechanism depends of this parser
*
* From this class all the parser is lunch
*
*
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class Parser implements ParserInterface
{
const PREFIXE = 'prx';
const SHOW_TIME = true;
const ALLOW_DEBUG = true;
const USE_CACHE = true;
/**
*
* @var Symfony\Component\DependencyInjection\ContainerInterface
*/
protected $container;
protected $content;
protected $status = 200;
/**
*
* @var Thelia\Tpex\Tpex
*/
protected $tpex;
protected $template = "default";
/**
*
* @param type $container
*
* public function __construct(ContainerBuilder $container)
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
}
/**
*
* @return Symfony\Component\HttpFoundation\Request
*/
public function getRequest()
{
return $this->container->get('request');
}
/**
*
* @return Symfony\Component\EventDispatcher\EventDispatcher
*/
public function getDispatcher()
{
return $this->container->get('dispatcher');
}
/**
*
* This method must return a Symfony\Component\HttpFoudation\Response instance or the content of the response
*
*/
public function getContent()
{
$this->loadParser();
return $this->content;
}
/**
*
* set $content with the body of the response or the Response object directly
*
* @param string|Symfony\Component\HttpFoundation\Response $content
*/
public function setContent($content)
{
$this->content = $content;
}
/**
*
* @return type the status of the response
*/
public function getStatus()
{
return $this->status;
}
/**
*
* status HTTP of the response
*
* @param int $status
*/
public function setStatus($status)
{
$this->status = $status;
}
/**
* Main parser function, load the parser
*/
public function loadParser()
{
$content = $this->openFile($this->getRequest());
$tpex = $this->container->get("template");
$tpex->setBaseDir(THELIA_TEMPLATE_DIR . rtrim($this->template, "/") . "/");
$tpex->setContent($content);
$this->setContent($tpex->execute());
}
protected function openFile(Request $request)
{
$file = $request->attributes->get('_view');
$fileName = THELIA_TEMPLATE_DIR . rtrim($this->template, "/") . "/" . $file . ".html";
if (file_exists($fileName)) {
$content = file_get_contents($fileName);
} else {
throw new ResourceNotFoundException(sprintf("%s file not found in %s template", $file, $this->template));
}
return $content;
}
}

2
core/lib/Thelia/Core/Template/ParserInterface.php Normal file → Executable file
View File

@@ -23,8 +23,6 @@
namespace Thelia\Core\Template;
/**
*
*
*
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*

View File

@@ -0,0 +1,85 @@
<?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\Assets;
use Thelia\Core\Template\Assets\AsseticHelper;
class SmartyAssetsManager
{
const ASSET_TYPE_AUTO = '';
private $assetic_manager;
private $web_root;
private $path_relative_to_web_root;
/**
* Creates a new SmartyAssetsManager instance
*
* @param string $web_root the disk path to the web root
* @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated
*/
public function __construct($web_root, $path_relative_to_web_root)
{
$this->web_root = $web_root;
$this->path_relative_to_web_root = $path_relative_to_web_root;
$this->assetic_manager = new AsseticHelper();
}
public function processSmartyPluginCall($assetType, $params, $content, \Smarty_Internal_Template $template, &$repeat)
{
// Opening tag (first call only)
if ($repeat) {
$file = $params['file'];
$filters = isset($params['filters']) ? $params['filters'] : '';
$debug = isset($params['debug']) ? trim(strtolower($params['debug'])) == 'true' : false;
// Get template base path
$tpl_path = $template->source->filepath;
// Get basedir
$tpl_dir = dirname($tpl_path);
// Create absolute dir path
$asset_dir = realpath($tpl_dir.'/'.dirname($file));
$asset_file = basename($file);
if ($asset_dir === false) throw new \Exception("Failed to get real path of '".$tpl_dir.'/'.dirname($file)."'");
$url = $this->assetic_manager->asseticize(
$asset_dir.'/'.$asset_file,
$this->web_root."/".$this->path_relative_to_web_root,
$this->path_relative_to_web_root,
$assetType,
$filters,
$debug
);
$template->assign('asset_url', $url);
} elseif (isset($content)) {
return $content;
}
}
}

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\Template\Smarty\Plugins;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
use Thelia\Core\Template\Smarty\Assets\SmartyAssetsManager;
class Assetic implements SmartyPluginInterface
{
public $asset_manager;
public function __construct()
{
$web_root = THELIA_WEB_DIR;
$asset_dir_from_web_root = '/assets/admin/default'; // FIXME
$this->asset_manager = new SmartyAssetsManager($web_root, $asset_dir_from_web_root);
}
public function theliaBlockJavascripts($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
return $this->asset_manager->processSmartyPluginCall('js', $params, $content, $template, $repeat);
}
public function theliaBlockImages($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
return $this->asset_manager->processSmartyPluginCall(SmartyAssetsManager::ASSET_TYPE_AUTO, $params, $content, $template, $repeat);
}
public function theliaBlockStylesheets($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
return $this->asset_manager->processSmartyPluginCall('css', $params, $content, $template, $repeat);
}
/**
* Define the various smarty plugins hendled by this class
*
* @return an array of smarty plugin descriptors
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor('block', 'stylesheets', $this, 'theliaBlockStylesheets'),
new SmartyPluginDescriptor('block', 'javascripts', $this, 'theliaBlockJavascripts'),
new SmartyPluginDescriptor('block', 'images' , $this, 'theliaBlockImages')
);
}
}

View File

@@ -0,0 +1,199 @@
<?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\Form\FormView;
use Thelia\Form\BaseForm;
use Thelia\Core\Template\Element\Exception\ElementNotFoundException;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
use Thelia\Log\Tlog;
class Form implements SmartyPluginInterface
{
protected $request;
protected $form;
protected $formDefinition = array();
public function __construct(Request $request)
{
$this->request = $request;
}
public function setFormDefinition($formDefinition)
{
foreach ($formDefinition as $name => $className) {
if (array_key_exists($name, $this->formDefinition)) {
throw new \InvalidArgumentException(sprintf("%s form name already exists for %s class", $name,
$className));
}
$this->formDefinition[$name] = $className;
}
}
public function generateForm($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
if ($repeat) {
if (empty($params['name'])) {
throw new \InvalidArgumentException("Missing 'name' parameter in form arguments");
}
$form = BaseForm::getFormFactory($this->request);
$formBuilder = $form->createBuilder('form');
$instance = $this->getInstance($params['name']);
$instance = $instance->buildForm($formBuilder, array());
$template->assign("form", $instance->getForm()->createView());
} else {
return $content;
}
}
public function formRender($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
if ($repeat) {
$form = $params["form"];
if (! $form instanceof \Symfony\Component\Form\FormView) {
throw new \InvalidArgumentException("form parameter in form_field block must be an instance of
Symfony\Component\Form\FormView");
}
$template->assign("options", $form->vars);
$template->assign("name", $form->vars["full_name"]);
$template->assign("value", $form->vars["value"]);
$template->assign("label", $form->vars["label"]);
$template->assign("error", empty($form->vars["errors"]) ? false : true);
$attr = array();
foreach ($form->vars["attr"] as $key => $value) {
$attr[] = sprintf('%s="%s"', $key, $value);
}
$template->assign("attr", implode(" ", $attr));
$form->setRendered();
} else {
return $content;
}
}
public function formRenderHidden($params, \Smarty_Internal_Template $template)
{
$form = $params["form"];
$field = '<input type="hidden" name="%s" value="%s">';
if (! $form instanceof \Symfony\Component\Form\FormView) {
throw new \InvalidArgumentException("form parameter in form_field_hidden function must be an instance of
Symfony\Component\Form\FormView");
}
$return = "";
foreach ($form->getIterator() as $row) {
if ($this->isHidden($row) && $row->isRendered() === false) {
$return .= sprintf($field, $row->vars["full_name"], $row->vars["value"]);
}
}
return $return;
}
protected function isHidden(FormView $formView)
{
return array_search("hidden", $formView->vars["block_prefixes"]);
}
public function formEnctype($params, \Smarty_Internal_Template $template)
{
$form = $params["form"];
if (! $form instanceof \Symfony\Component\Form\FormView) {
throw new \InvalidArgumentException("form parameter in form_enctype function must be an instance of
Symfony\Component\Form\FormView");
}
if ($form->vars["multipart"]) {
return sprintf('%s="%s"',"enctype", "multipart/form-data");
}
}
public function formError($params, $content, \Smarty_Internal_Template $template, &$repeat)
{
$form = $params["form"];
if (! $form instanceof \Symfony\Component\Form\FormView) {
throw new \InvalidArgumentException("form parameter in form_error block must be an instance of
Symfony\Component\Form\FormView");
}
if (empty($form->vars["errors"])) {
return "";
}
if ($repeat) {
$error = $form->vars["errors"];
$template->assign("message", $error[0]->getMessage());
$template->assign("parameters", $error[0]->getMessageParameters());
$template->assign("pluralization", $error[0]->getMessagePluralization());
} else {
return $content;
}
}
public function getInstance($name)
{
if (!isset($this->formDefinition[$name])) {
throw new ElementNotFoundException(sprintf("%s form does not exists", $name));
}
return new $this->formDefinition[$name];
}
/**
* @return an array of SmartyPluginDescriptor
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor("block", "form", $this, "generateForm"),
new SmartyPluginDescriptor("block", "form_field", $this, "formRender"),
new SmartyPluginDescriptor("function", "form_field_hidden", $this, "formRenderHidden"),
new SmartyPluginDescriptor("function", "form_enctype", $this, "formEnctype"),
new SmartyPluginDescriptor("block", "form_error", $this, "formError")
);
}
}

View File

@@ -0,0 +1,55 @@
<?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 Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
class Module implements SmartyPluginInterface
{
/**
* Process theliaModule template inclusion function
*
* @param unknown $params
* @param unknown $smarty
* @return string
*/
public function theliaModule($params, &$smarty)
{
// TODO
return "";
}
/**
* Define the various smarty plugins hendled by this class
*
* @return an array of smarty plugin descriptors
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor('function', 'module_include', $this, 'theliaModule'),
);
}
}

View File

@@ -0,0 +1,303 @@
<?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 Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Element\Exception\ElementNotFoundException;
use Thelia\Core\Template\Element\Exception\InvalidElementException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class TheliaLoop implements SmartyPluginInterface
{
protected $loopDefinition = array();
protected $request;
protected $dispatcher;
public function __construct(Request $request, EventDispatcherInterface $dispatcher)
{
$this->request = $request;
$this->dispatcher = $dispatcher;
}
/**
* Process {loop name="loop name" type="loop type" ... } ... {/loop} block
*
* @param unknown $params
* @param unknown $content
* @param unknown $template
* @param unknown $repeat
* @throws \InvalidArgumentException
* @return string
*/
public function theliaLoop($params, $content, $template, &$repeat)
{
if (empty($params['name']))
throw new \InvalidArgumentException("Missing 'name' parameter in loop arguments");
if (empty($params['type']))
throw new \InvalidArgumentException("Missing 'type' parameter in loop arguments");
$name = $params['name'];
if ($content === null) {
$loop = $this->createLoopInstance(strtolower($params['type']));
$this->getLoopArgument($loop, $params);
$loopResults = $loop->exec();
$template->assignByRef($name, $loopResults);
} else {
$loopResults = $template->getTemplateVars($name);
$loopResults->next();
}
if ($loopResults->valid()) {
$loopResultRow = $loopResults->current();
foreach($loopResultRow->getVarVal() as $var => $val) {
$template->assign(substr($var, 1), $val);
}
$template->assign('__COUNT__', 1 + $loopResults->key());
$template->assign('__TOTAL__', $loopResults->getCount());
$repeat = $loopResults->valid();
}
if ($content !== null) {
if ($loopResults->isEmpty()) $content = "";
return $content;
}
}
/**
* Process {elseloop rel="loopname"} ... {/elseloop} block
*
* @param unknown $params
* @param unknown $content
* @param unknown $template
* @param unknown $repeat
* @return Ambigous <string, unknown>
*/
public function theliaElseloop($params, $content, $template, &$repeat)
{
// When encoutering close tag, check if loop has results.
if ($repeat === false) {
return $this->checkEmptyLoop($params, $template) ? $content : '';
}
}
/**
* Process {ifloop rel="loopname"} ... {/ifloop} block
*
* @param unknown $params
* @param unknown $content
* @param unknown $template
* @param unknown $repeat
* @return Ambigous <string, unknown>
*/
public function theliaIfLoop($params, $content, $template, &$repeat)
{
// When encountering close tag, check if loop has results.
if ($repeat === false) {
return $this->checkEmptyLoop($params, $template) ? '' : $content;
}
}
/**
* Check if a loop has returned results. The loop shoud have been executed before, or an
* InvalidArgumentException is thrown
*
* @param unknown $params
* @param unknown $template
* @throws \InvalidArgumentException
*/
protected function checkEmptyLoop($params, $template)
{
if (empty($params['rel']))
throw new \InvalidArgumentException("Missing 'rel' parameter in ifloop/elseloop arguments");
$loopName = $params['rel'];
// Find loop results in the current template vars
$loopResults = $template->getTemplateVars($loopName);
if (empty($loopResults)) {
throw new \InvalidArgumentException("Loop $loopName is not defined.");
}
return $loopResults->isEmpty();
}
/**
*
* find the loop class with his name and construct an instance of this class
*
* @param string $name
* @return \Thelia\Core\Template\Element\BaseLoop
* @throws \Thelia\Tpex\Exception\InvalidElementException
* @throws \Thelia\Tpex\Exception\ElementNotFoundException
*/
protected function createLoopInstance($name)
{
if (! isset($this->loopDefinition[$name])) {
throw new ElementNotFoundException(sprintf("%s loop does not exists", $name));
}
$class = new \ReflectionClass($this->loopDefinition[$name]);
if ($class->isSubclassOf("Thelia\Core\Template\Element\BaseLoop") === false) {
throw new InvalidElementException(sprintf("%s Loop class have to extends Thelia\Core\Template\Element\BaseLoop",
$name));
}
return $class->newInstance(
$this->request,
$this->dispatcher
);
}
/**
* Returns the value of a loop argument.
*
* @param unknown $loop a BaseLoop instance
* @param unknown $smartyParam
* @throws \InvalidArgumentException
*/
protected function getLoopArgument(BaseLoop $loop, $smartyParam)
{
$defaultItemsParams = array('required' => true);
$shortcutItemParams = array('optional' => array('required' => false));
$errorCode = 0;
$faultActor = array();
$faultDetails = array();
$argumentsCollection = $loop->defineArgs();
foreach( $argumentsCollection as $argument ) {
$value = isset($smartyParam[$argument->name]) ? $smartyParam[$argument->name] : null;
/* check if mandatory */
if($value === null && $argument->mandatory) {
$faultActor[] = $argument->name;
$faultDetails[] = sprintf('"%s" parameter is missing', $argument->name);
continue;
}
/* check if empty */
if($value === '' && !$argument->empty) {
$faultActor[] = $argument->name;
$faultDetails[] = sprintf('"%s" parameter cannot be empty', $argument->name);
continue;
}
/* check type */
if($value !== null && !$argument->type->isValid($value)) {
$faultActor[] = $argument->name;
$faultDetails[] = sprintf('Invalid value for "%s" argument', $argument->name);
continue;
}
/* set default */
/* did it as last checking for we consider default value is acceptable no matter type or empty restriction */
if($value === null) {
$value = $argument->default;
}
$loop->{$argument->name} = $value;
}
if (!empty($faultActor)) {
$complement = sprintf('[%s]', implode(', ', $faultDetails));
throw new \InvalidArgumentException($complement);
}
}
/**
*
* Injects an associative array containing information for loop execution
*
* key is loop name
* value is the class implementing/extending base loop classes
*
* ex :
*
* $loop = array(
* "product" => "Thelia\Loop\Product",
* "category" => "Thelia\Loop\Category",
* "myLoop" => "My\Own\Loop"
* );
*
* @param array $loops
* @throws \InvalidArgumentException if loop name already exists
*/
public function setLoopList(array $loopDefinition)
{
foreach ($loopDefinition as $name => $className) {
if (array_key_exists($name, $this->loopDefinition)) {
throw new \InvalidArgumentException(sprintf("%s loop name already exists for %s class name", $name, $className));
}
$this->loopDefinition[$name] = $className;
}
}
/**
* Defines the various smarty plugins hendled by this class
*
* @return an array of smarty plugin descriptors
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor('block', 'loop' , $this, 'theliaLoop'),
new SmartyPluginDescriptor('block', 'elseloop' , $this, 'theliaElseloop'),
new SmartyPluginDescriptor('block', 'ifloop' , $this, 'theliaIfLoop'),
);
}
}

View File

@@ -0,0 +1,61 @@
<?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 Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
class Translation implements SmartyPluginInterface
{
/**
* Process translate function
*
* @param unknown $params
* @param unknown $smarty
* @return string
*/
public function theliaTranslate($params, &$smarty)
{
if (isset($params['l'])) {
$string = str_replace('\'', '\\\'', $params['l']);
} else {
$string = '';
}
// TODO
return "[$string]";
}
/**
* Define the various smarty plugins hendled by this class
*
* @return an array of smarty plugin descriptors
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor('function', 'intl', $this, 'theliaTranslate'),
);
}
}

View File

@@ -0,0 +1,190 @@
<?php
namespace Thelia\Core\Template\Smarty;
use \Symfony\Component\HttpFoundation\Request;
use \Symfony\Component\EventDispatcher\EventDispatcherInterface;
use \Smarty;
use Thelia\Core\Template\ParserInterface;
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
use Thelia\Core\Template\Exception\ResourceNotFoundException;
/**
*
* @author Franck Allimant <franck@cqfdev.fr>
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class SmartyParser extends Smarty implements ParserInterface
{
public $plugins = array();
protected $request, $dispatcher;
protected $template = "";
protected $status = 200;
/**
* @param \Symfony\Component\HttpFoundation\Request $request
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher
* @param bool $template
* @param string $env Environment define for the kernel application. Used for the cache directory
*/
public function __construct(Request $request, EventDispatcherInterface $dispatcher, $template = false, $env = "prod", $debug = false)
{
parent::__construct();
$this->request = $request;
$this->dispatcher = $dispatcher;
// Configure basic Smarty parameters
$compile_dir = THELIA_ROOT . 'cache/'. $env .'/smarty/compile';
if (! is_dir($compile_dir)) @mkdir($compile_dir, 0777, true);
$cache_dir = THELIA_ROOT . 'cache/'. $env .'/smarty/cache';
if (! is_dir($cache_dir)) @mkdir($cache_dir, 0777, true);
$this->setTemplate($template ?: 'smarty-sample'); // FIXME: put this in configuration
$this->setCompileDir($compile_dir);
$this->setCacheDir($cache_dir);
$this->debugging = $debug;
// Prevent smarty ErrorException: Notice: Undefined index bla bla bla...
$this->error_reporting = E_ALL ^ E_NOTICE;
// Si on n'est pas en mode debug, activer le cache, avec une lifetime de 15mn, et en vérifiant que les templates sources n'ont pas été modifiés.
if($debug === false) {
$this->caching = Smarty::CACHING_LIFETIME_CURRENT;
$this->cache_lifetime = 300;
$this->compile_check = true;
} else {
$this->caching = Smarty::CACHING_OFF;
$this->force_compile = true;
}
// The default HTTP status
$this->status = 200;
$this->registerFilter('pre', array($this, "pretest"));
}
public function pretest($tpl_source, \Smarty_Internal_Template $template)
{
$new_source = preg_replace('`{#([a-zA-Z][a-zA-Z0-9\-_]*)(.*)}`', '{\$$1$2}', $tpl_source);
$new_source = preg_replace('`#([a-zA-Z][a-zA-Z0-9\-_]*)`', '{\$$1|default:\'#$1\'}', $new_source);
return $new_source;
}
public function setTemplate($template_path_from_template_base)
{
$this->template = $template_path_from_template_base;
$this->setTemplateDir(THELIA_TEMPLATE_DIR.$this->template);
}
public function getTemplate()
{
return $this->template;
}
/**
* Return a rendered template file
*
* @param string $realTemplateName the template name (from the template directory)
* @param array $parameters an associative array of names / value pairs
* @return string the rendered template text
*/
public function render($realTemplateName, array $parameters)
{
$this->assign($parameters);
return $this->fetch($realTemplateName);
}
/**
*
* This method must return a Symfony\Component\HttpFoudation\Response instance or the content of the response
*
*/
public function getContent()
{
return $this->fetch($this->getTemplateFilePath());
}
/**
*
* set $content with the body of the response or the Response object directly
*
* @param string|Symfony\Component\HttpFoundation\Response $content
*/
public function setContent($content)
{
$this->content = $content;
}
/**
*
* @return type the status of the response
*/
public function getStatus()
{
return $this->status;
}
/**
*
* status HTTP of the response
*
* @param int $status
*/
public function setStatus($status)
{
$this->status = $status;
}
public function addPlugins(SmartyPluginInterface $plugin)
{
$this->plugins[] = $plugin;
}
public function registerPlugins()
{
foreach ($this->plugins as $register_plugin) {
$plugins = $register_plugin->getPluginDescriptors();
if (!is_array($plugins)) {
$plugins = array($plugins);
}
foreach ($plugins as $plugin) {
$this->registerPlugin(
$plugin->getType(),
$plugin->getName(),
array(
$plugin->getClass(),
$plugin->getMethod()
)
);
}
}
}
protected function getTemplateFilePath()
{
$file = $this->request->attributes->get('_view');
$fileName = THELIA_TEMPLATE_DIR . rtrim($this->template, "/") . "/" . $file . ".html";
if (file_exists($fileName)) return $fileName;
throw new ResourceNotFoundException(sprintf("%s file not found in %s template", $file, $this->template));
}
}

View File

@@ -0,0 +1,101 @@
<?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;
/**
* Class allowing to describe a smarty plugin
*
* Class SmartyPluginDescriptor
* @package Thelia\Core\Template\Smarty
*/
class SmartyPluginDescriptor
{
/**
* @var string Smarty plugin type (block, function, etc.)
*/
protected $type;
/**
* @var string Smarty plugin name. This name will be used in Smarty templates.
*/
protected $name;
/**
* @var SmartyPluginInterface plugin implmentation class
*/
protected $class;
/**
* @var string plugin implmentation method in $class
*/
protected $method;
public function __construct($type, $name, $class, $method)
{
$this->type = $type;
$this->name = $name;
$this->class = $class;
$this->method = $method;
}
public function setType($type)
{
$this->type = $type;
}
public function getType()
{
return $this->type;
}
public function setName($name)
{
$this->name = $name;
}
public function getName()
{
return $this->name;
}
public function setClass($class)
{
$this->class = $class;
}
public function getClass()
{
return $this->class;
}
public function setMethod($method)
{
$this->method = $method;
}
public function getMethod()
{
return $this->method;
}
}

View File

@@ -0,0 +1,39 @@
<?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;
/**
*
* this interface must be implements when you want to add plugin to smarty using config process
*
* Interface SmartyPluginInterface
* @package Thelia\Core\Template\Smarty
*/
interface SmartyPluginInterface
{
/**
* @return an array of SmartyPluginDescriptor
*/
public function getPluginDescriptors();
}

0
core/lib/Thelia/Core/Template/TestLoop/Equal.php Normal file → Executable file
View File

17
core/lib/Thelia/Core/Thelia.php Normal file → Executable file
View File

@@ -35,14 +35,9 @@ namespace Thelia\Core;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Config\Util\XmlUtils;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Thelia\Core\Bundle;
use Thelia\Log\Tlog;
use Thelia\Config\DatabaseConfiguration;
@@ -64,7 +59,7 @@ class Thelia extends Kernel
public function init()
{
parent::init();
if($this->debug) {
if ($this->debug) {
ini_set('display_errors', 1);
}
$this->initPropel();
@@ -76,7 +71,7 @@ class Thelia extends Kernel
return ;
}
if(! Propel::isInit()) {
if (! Propel::isInit()) {
$definePropel = new DefinePropel(new DatabaseConfiguration(),
Yaml::parse(THELIA_ROOT . '/local/config/database.yml'));
@@ -126,12 +121,11 @@ class Thelia extends Kernel
try {
$loader = new XmlFileLoader($container, new FileLocator(THELIA_MODULE_DIR . "/" . ucfirst($module->getCode()) . "/Config"));
$loader->load("config.xml");
} catch(\InvalidArgumentException $e) {
} catch (\InvalidArgumentException $e) {
// FIXME: process module configuration exception
}
}
}
}
/**
@@ -166,6 +160,7 @@ class Thelia extends Kernel
$this->loadConfiguration($container);
$container->customCompile();
return $container;
}
@@ -229,7 +224,7 @@ class Thelia extends Kernel
{
$bundles = array(
/* TheliaBundle contain all the dependency injection description */
new Bundle\TheliaBundle()
new Bundle\TheliaBundle(),
);
/**

0
core/lib/Thelia/Core/TheliaContainerBuilder.php Normal file → Executable file
View File

5
core/lib/Thelia/Core/TheliaHttpKernel.php Normal file → Executable file
View File

@@ -4,7 +4,7 @@
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
@@ -17,7 +17,7 @@
/* 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/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Core;
@@ -141,7 +141,6 @@ class TheliaHttpKernel extends HttpKernel
$storage->setOptions(json_decode(Model\ConfigQuery::read("session_config.config")));
}
$session = new Session\Session($storage);
$session->start();

0
core/lib/Thelia/Exception/MemberAccessException.php Normal file → Executable file
View File

View File

@@ -0,0 +1,54 @@
<?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\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Length;
use Symfony\Component\Validator\Constraints\NotBlank;
class AdminLogin extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options)
{
return $builder
->add("username", "text", array(
"constraints" => array(
new NotBlank(),
new Length(array("min" => 3))
)
))
->add("password", "password");
}
/**
* Returns the name of this type.
*
* @return string The name of this type
*/
public function getName()
{
return "admin_login";
}
}

View File

@@ -0,0 +1,61 @@
<?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\Form;
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
use Symfony\Component\Form\Forms;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
use Symfony\Component\Validator\Validation;
use Thelia\Model\ConfigQuery;
class BaseForm {
/**
* @param Request $request
* @return \Symfony\Component\Form\FormFactoryInterface
*/
public static function getFormFactory(Request $request, $secret = null)
{
$validator = Validation::createValidator();
$form = Forms::createFormFactoryBuilder()
->addExtension(new HttpFoundationExtension())
->addExtension(
new CsrfExtension(
new SessionCsrfProvider(
$request->getSession(),
$secret ?: ConfigQuery::read("form.secret", md5(__DIR__))
)
)
)
->addExtension(new ValidatorExtension($validator))
->getFormFactory();
return $form;
}
}

View File

@@ -0,0 +1,54 @@
<?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\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class CustomerCreation extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
return $builder->add("name", "text")
->add("email", "email", array(
"attr" => array(
"class" => "field"
),
"label" => "email"
)
)
->add('age', 'integer');
}
/**
* Returns the name of this type.
*
* @return string The name of this type
*/
public function getName()
{
return "customer creation";
}
}

0
core/lib/Thelia/Log/AbstractTlogDestination.php Normal file → Executable file
View File

View File

View File

View File

View File

0
core/lib/Thelia/Log/Tlog.php Normal file → Executable file
View File

0
core/lib/Thelia/Log/TlogDestinationConfig.php Normal file → Executable file
View File

0
core/lib/Thelia/Log/TlogInterface.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Accessory.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AccessoryPeer.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AccessoryQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Address.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AddressPeer.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AddressQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Admin.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminGroup.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminGroupPeer.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminGroupQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminLog.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminLogPeer.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminLogQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminPeer.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AdminQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Area.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AreaPeer.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AreaQuery.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/Attribute.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeAv.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeAvI18n.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeAvI18nPeer.php Normal file → Executable file
View File

0
core/lib/Thelia/Model/AttributeAvI18nQuery.php Normal file → Executable file
View File

Some files were not shown because too many files have changed in this diff Show More