fix CS and add start Form plugin for smarty
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ 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;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Thelia\Core\Controller;
|
||||
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolver as BaseControllerResolver;
|
||||
@@ -21,14 +20,14 @@ class ControllerResolver extends BaseControllerResolver
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ContainerInterface $container A ContainerInterface instance
|
||||
* @param LoggerInterface $logger A LoggerInterface instance
|
||||
* @param ContainerInterface $container A ContainerInterface instance
|
||||
* @param LoggerInterface $logger A LoggerInterface instance
|
||||
*/
|
||||
public function __construct(ContainerInterface $container, LoggerInterface $logger = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
$this->container = $container;
|
||||
|
||||
parent::__construct($logger);
|
||||
parent::__construct($logger);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -38,7 +37,7 @@ class ControllerResolver extends BaseControllerResolver
|
||||
*
|
||||
* @return mixed A PHP callable
|
||||
*
|
||||
* @throws \LogicException When the name could not be parsed
|
||||
* @throws \LogicException When the name could not be parsed
|
||||
* @throws \InvalidArgumentException When the controller class does not exist
|
||||
*/
|
||||
protected function createController($controller)
|
||||
|
||||
@@ -74,4 +74,4 @@ class RegisterListenersPass implements CompilerPassInterface
|
||||
$definition->addMethodCall('addSubscriberService', array($id, $class));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace Thelia\Core\DependencyInjection\Compiler;
|
||||
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
@@ -34,8 +33,8 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
*
|
||||
*
|
||||
*/
|
||||
class RegisterParserPluginPass implements CompilerPassInterface {
|
||||
|
||||
class RegisterParserPluginPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* You can modify the container here before it is dumped to PHP code.
|
||||
*
|
||||
@@ -57,4 +56,4 @@ class RegisterParserPluginPass implements CompilerPassInterface {
|
||||
|
||||
$smarty->addMethodCall("registerPlugins");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
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;
|
||||
@@ -334,7 +333,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
|
||||
@@ -343,4 +342,4 @@ EOF
|
||||
{
|
||||
// TODO: Implement supports() method.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<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>
|
||||
|
||||
@@ -74,6 +75,17 @@
|
||||
<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="0" maxOccurs="unbounded">
|
||||
<xsd:element name="filter" type="filter" />
|
||||
|
||||
@@ -26,48 +26,49 @@ namespace Thelia\Core\Event;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Class thrown on Thelia.action event
|
||||
*
|
||||
*
|
||||
* call setAction if action match yours
|
||||
*
|
||||
*
|
||||
*/
|
||||
abstract class ActionEvent extends Event
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $action;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAction()
|
||||
{
|
||||
return $this->action;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
public function getRequest()
|
||||
|
||||
@@ -11,6 +11,6 @@ namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class DefaultActionEvent extends ActionEvent {
|
||||
|
||||
}
|
||||
class DefaultActionEvent extends ActionEvent
|
||||
{
|
||||
}
|
||||
|
||||
@@ -24,27 +24,27 @@
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Class containing all Thelia events name using in Thelia Core
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
|
||||
final class TheliaEvents
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* ACTION event
|
||||
*
|
||||
*
|
||||
* Send if no action are already present in Thelia action process ( see Thelia\Routing\Matcher\ActionMatcher)
|
||||
*/
|
||||
const ACTION = "thelia.action";
|
||||
|
||||
|
||||
/**
|
||||
* INCLUDE event
|
||||
*
|
||||
*
|
||||
* Send before starting thelia inclusion
|
||||
*/
|
||||
const INCLUSION = "thelia.include";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -78,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));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
@@ -74,4 +72,4 @@ class ActionEventFactory
|
||||
|
||||
return $class->newInstance($this->request, $this->action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,22 +37,22 @@ use Assetic\Cache\FilesystemCache;
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class AsseticHelper {
|
||||
|
||||
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
|
||||
* @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.
|
||||
* @return string The URL to the generated asset file.
|
||||
*/
|
||||
public function asseticize($asset_path, $output_path, $output_url, $asset_type, $filters, $debug) {
|
||||
|
||||
public function asseticize($asset_path, $output_path, $output_url, $asset_type, $filters, $debug)
|
||||
{
|
||||
$asset_name = basename($asset_path);
|
||||
$asset_dir = dirname($asset_path);
|
||||
|
||||
@@ -62,11 +62,11 @@ class AsseticHelper {
|
||||
if (! empty($filters)) {
|
||||
$filter_list = explode(',', $filters);
|
||||
|
||||
foreach($filter_list as $filter_name) {
|
||||
foreach ($filter_list as $filter_name) {
|
||||
|
||||
$filter_name = trim($filter_name);
|
||||
|
||||
switch($filter_name) {
|
||||
switch ($filter_name) {
|
||||
case 'less' :
|
||||
$fm->set('less', new Filter\LessphpFilter());
|
||||
break;
|
||||
@@ -92,8 +92,7 @@ class AsseticHelper {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$filter_list = array();
|
||||
}
|
||||
|
||||
@@ -120,4 +119,4 @@ class AsseticHelper {
|
||||
|
||||
return rtrim($output_url, '/').'/'.$asset->getTargetPath();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,10 +31,9 @@ class Secure extends BaseParam
|
||||
public function exec()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
|
||||
|
||||
if (!$request->getSession()->get('connected') && $this->baseParamValue) {
|
||||
Redirect::unauthorize();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,4 +105,4 @@ class LoopResult implements \Iterator
|
||||
{
|
||||
$this->position = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
|
||||
namespace Thelia\Core\Template\Element;
|
||||
|
||||
|
||||
class LoopResultRow {
|
||||
|
||||
class LoopResultRow
|
||||
{
|
||||
protected $substitution = array();
|
||||
|
||||
public function set($key, $value)
|
||||
@@ -43,4 +42,4 @@ class LoopResultRow {
|
||||
return $this->substitution;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Core\Template\Exception;
|
||||
|
||||
|
||||
class ResourceNotFoundException extends \RuntimeException {
|
||||
|
||||
}
|
||||
class ResourceNotFoundException extends \RuntimeException
|
||||
{
|
||||
}
|
||||
|
||||
@@ -21,14 +21,11 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
|
||||
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\Log\Tlog;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
|
||||
/**
|
||||
@@ -61,8 +58,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;
|
||||
@@ -105,13 +102,13 @@ class Category extends BaseLoop {
|
||||
$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 (null !== $this->current && $this->current == 0) {
|
||||
} elseif (null !== $this->current && $this->current == 0) {
|
||||
$search->filterById($this->request->get("category_id"), \Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
@@ -123,14 +120,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;
|
||||
@@ -145,7 +141,7 @@ class Category extends BaseLoop {
|
||||
break;
|
||||
}
|
||||
|
||||
if($this->random == 1) {
|
||||
if ($this->random == 1) {
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
}
|
||||
@@ -182,4 +178,4 @@ class Category extends BaseLoop {
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ namespace Thelia\Core\Template\Smarty\Assets;
|
||||
|
||||
use Thelia\Core\Template\Assets\AsseticHelper;
|
||||
|
||||
class SmartyAssetsManager {
|
||||
|
||||
class SmartyAssetsManager
|
||||
{
|
||||
const ASSET_TYPE_AUTO = '';
|
||||
|
||||
private $assetic_manager;
|
||||
@@ -37,50 +37,49 @@ class SmartyAssetsManager {
|
||||
/**
|
||||
* 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
|
||||
* @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) {
|
||||
|
||||
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) {
|
||||
|
||||
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;
|
||||
$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 template base path
|
||||
$tpl_path = $template->source->filepath;
|
||||
|
||||
// Get basedir
|
||||
$tpl_dir = dirname($tpl_path);
|
||||
// Get basedir
|
||||
$tpl_dir = dirname($tpl_path);
|
||||
|
||||
// Create absolute dir path
|
||||
$asset_dir = realpath($tpl_dir.'/'.dirname($file));
|
||||
$asset_file = basename($file);
|
||||
// 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)."'");
|
||||
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
|
||||
);
|
||||
$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);
|
||||
}
|
||||
else if (isset($content)) {
|
||||
return $content;
|
||||
$template->assign('asset_url', $url);
|
||||
} elseif (isset($content)) {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,12 @@
|
||||
|
||||
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 {
|
||||
|
||||
class Assetic implements SmartyPluginInterface
|
||||
{
|
||||
public $asset_manager;
|
||||
|
||||
public function __construct()
|
||||
@@ -42,7 +40,6 @@ class Assetic implements SmartyPluginInterface {
|
||||
$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);
|
||||
@@ -71,4 +68,4 @@ class Assetic implements SmartyPluginInterface {
|
||||
new SmartyPluginDescriptor('block', 'images' , $this, 'theliaBlockImages')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
66
core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php
Normal file
66
core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Core\Template\Smarty\Plugins;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
|
||||
|
||||
class Form implements SmartyPluginInterface
|
||||
{
|
||||
|
||||
protected $request;
|
||||
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, $template, &$repeat)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an array of SmartyPluginDescriptor
|
||||
*/
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
return array(
|
||||
new SmartyPluginDescriptor("block", "form", $this, "generateForm")
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -23,17 +23,16 @@
|
||||
|
||||
namespace Thelia\Core\Template\Smarty\Plugins;
|
||||
|
||||
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
|
||||
|
||||
class Module implements SmartyPluginInterface {
|
||||
|
||||
class Module implements SmartyPluginInterface
|
||||
{
|
||||
/**
|
||||
* Process theliaModule template inclusion function
|
||||
*
|
||||
* @param unknown $params
|
||||
* @param unknown $smarty
|
||||
* @param unknown $params
|
||||
* @param unknown $smarty
|
||||
* @return string
|
||||
*/
|
||||
public function theliaModule($params, &$smarty)
|
||||
@@ -53,4 +52,4 @@ class Module implements SmartyPluginInterface {
|
||||
new SmartyPluginDescriptor('function', 'module_include', $this, 'theliaModule'),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,15 +32,16 @@ use Thelia\Core\Template\Element\Exception\InvalidElementException;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
class TheliaLoop implements SmartyPluginInterface {
|
||||
|
||||
class TheliaLoop implements SmartyPluginInterface
|
||||
{
|
||||
protected $loopDefinition = array();
|
||||
|
||||
protected $request;
|
||||
|
||||
protected $dispatcher;
|
||||
|
||||
public function __construct(Request $request, EventDispatcherInterface $dispatcher) {
|
||||
public function __construct(Request $request, EventDispatcherInterface $dispatcher)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
@@ -48,128 +49,125 @@ class TheliaLoop implements SmartyPluginInterface {
|
||||
/**
|
||||
* Process {loop name="loop name" type="loop type" ... } ... {/loop} block
|
||||
*
|
||||
* @param unknown $params
|
||||
* @param unknown $content
|
||||
* @param unknown $template
|
||||
* @param unknown $repeat
|
||||
* @param unknown $params
|
||||
* @param unknown $content
|
||||
* @param unknown $template
|
||||
* @param unknown $repeat
|
||||
* @throws \InvalidArgumentException
|
||||
* @return string
|
||||
*/
|
||||
public function theliaLoop($params, $content, $template, &$repeat) {
|
||||
public function theliaLoop($params, $content, $template, &$repeat)
|
||||
{
|
||||
if (empty($params['name']))
|
||||
throw new \InvalidArgumentException("Missing 'name' parameter in loop arguments");
|
||||
|
||||
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");
|
||||
|
||||
if (empty($params['type']))
|
||||
throw new \InvalidArgumentException("Missing 'type' parameter in loop arguments");
|
||||
$name = $params['name'];
|
||||
|
||||
$name = $params['name'];
|
||||
if ($content === null) {
|
||||
|
||||
if ($content === null) {
|
||||
$loop = $this->createLoopInstance(strtolower($params['type']));
|
||||
|
||||
$loop = $this->createLoopInstance(strtolower($params['type']));
|
||||
$this->getLoopArgument($loop, $params);
|
||||
|
||||
$this->getLoopArgument($loop, $params);
|
||||
$loopResults = $loop->exec();
|
||||
|
||||
$loopResults = $loop->exec();
|
||||
$template->assignByRef($name, $loopResults);
|
||||
} else {
|
||||
|
||||
$template->assignByRef($name, $loopResults);
|
||||
}
|
||||
else {
|
||||
$loopResults = $template->getTemplateVars($name);
|
||||
|
||||
$loopResults = $template->getTemplateVars($name);
|
||||
$loopResults->next();
|
||||
}
|
||||
|
||||
$loopResults->next();
|
||||
}
|
||||
if ($loopResults->valid()) {
|
||||
|
||||
if ($loopResults->valid()) {
|
||||
$loopResultRow = $loopResults->current();
|
||||
|
||||
$loopResultRow = $loopResults->current();
|
||||
foreach ($loopResultRow->getVarVal() as $var => $val) {
|
||||
|
||||
foreach($loopResultRow->getVarVal() as $var => $val) {
|
||||
$template->assign(substr($var, 1), $val);
|
||||
|
||||
$template->assign(substr($var, 1), $val);
|
||||
$template->assign('__COUNT__', 1 + $loopResults->key());
|
||||
$template->assign('__TOTAL__', $loopResults->getCount());
|
||||
}
|
||||
|
||||
$template->assign('__COUNT__', 1 + $loopResults->key());
|
||||
$template->assign('__TOTAL__', $loopResults->getCount());
|
||||
}
|
||||
$repeat = $loopResults->valid();
|
||||
}
|
||||
|
||||
$repeat = $loopResults->valid();
|
||||
}
|
||||
if ($content !== null) {
|
||||
|
||||
if ($content !== null) {
|
||||
|
||||
if ($loopResults->isEmpty()) $content = "";
|
||||
|
||||
return $content;
|
||||
}
|
||||
if ($loopResults->isEmpty()) $content = "";
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Process {elseloop rel="loopname"} ... {/elseloop} block
|
||||
*
|
||||
* @param unknown $params
|
||||
* @param unknown $content
|
||||
* @param unknown $template
|
||||
* @param unknown $repeat
|
||||
* @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 : '';
|
||||
}
|
||||
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
|
||||
* @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;
|
||||
}
|
||||
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
|
||||
* @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");
|
||||
protected function checkEmptyLoop($params, $template)
|
||||
{
|
||||
if (empty($params['rel']))
|
||||
throw new \InvalidArgumentException("Missing 'rel' parameter in ifloop/elseloop arguments");
|
||||
|
||||
$loopName = $params['rel'];
|
||||
$loopName = $params['rel'];
|
||||
|
||||
// Find loop results in the current template vars
|
||||
$loopResults = $template->getTemplateVars($loopName);
|
||||
// Find loop results in the current template vars
|
||||
$loopResults = $template->getTemplateVars($loopName);
|
||||
|
||||
if (empty($loopResults)) {
|
||||
throw new \InvalidArgumentException("Loop $loopName is not defined.");
|
||||
}
|
||||
if (empty($loopResults)) {
|
||||
throw new \InvalidArgumentException("Loop $loopName is not defined.");
|
||||
}
|
||||
|
||||
return $loopResults->isEmpty();
|
||||
return $loopResults->isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* find the loop class with his name and construct an instance of this class
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $name
|
||||
* @return \Thelia\Core\Template\Element\BaseLoop
|
||||
* @throws \Thelia\Tpex\Exception\InvalidElementException
|
||||
* @throws \Thelia\Tpex\Exception\ElementNotFoundException
|
||||
@@ -177,76 +175,74 @@ class TheliaLoop implements SmartyPluginInterface {
|
||||
protected function createLoopInstance($name)
|
||||
{
|
||||
|
||||
if (! isset($this->loopDefinition[$name])) {
|
||||
throw new ElementNotFoundException(sprintf("%s loop does not exists", $name));
|
||||
}
|
||||
if (! isset($this->loopDefinition[$name])) {
|
||||
throw new ElementNotFoundException(sprintf("%s loop does not exists", $name));
|
||||
}
|
||||
|
||||
$class = new \ReflectionClass($this->loopDefinition[$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));
|
||||
}
|
||||
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
|
||||
);
|
||||
return $class->newInstance(
|
||||
$this->request,
|
||||
$this->dispatcher
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the value of a loop argument.
|
||||
*
|
||||
* @param unknown $loop a BaseLoop instance
|
||||
* @param unknown $smartyParam
|
||||
* @param unknown $loop a BaseLoop instance
|
||||
* @param unknown $smartyParam
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
protected function getLoopArgument($loop, $smartyParam)
|
||||
{
|
||||
$defaultItemsParams = array('required' => true);
|
||||
$defaultItemsParams = array('required' => true);
|
||||
|
||||
$shortcutItemParams = array('optional' => array('required' => false));
|
||||
$shortcutItemParams = array('optional' => array('required' => false));
|
||||
|
||||
$errorCode = 0;
|
||||
$faultActor = array();
|
||||
$faultDetails = array();
|
||||
$errorCode = 0;
|
||||
$faultActor = array();
|
||||
$faultDetails = array();
|
||||
|
||||
foreach($loop->defineArgs() as $name => $param){
|
||||
if(is_integer($name)){
|
||||
$name = $param;
|
||||
$param = $defaultItemsParams;
|
||||
}
|
||||
foreach ($loop->defineArgs() as $name => $param) {
|
||||
if (is_integer($name)) {
|
||||
$name = $param;
|
||||
$param = $defaultItemsParams;
|
||||
}
|
||||
|
||||
if(is_string($param) && array_key_exists($param, $shortcutItemParams)){
|
||||
$param = $shortcutItemParams[$param];
|
||||
}
|
||||
if (is_string($param) && array_key_exists($param, $shortcutItemParams)) {
|
||||
$param = $shortcutItemParams[$param];
|
||||
}
|
||||
|
||||
if(!is_array($param)){
|
||||
$param = array('default' => $param);
|
||||
}
|
||||
if (!is_array($param)) {
|
||||
$param = array('default' => $param);
|
||||
}
|
||||
|
||||
$value = isset($smartyParam[$name]) ? $smartyParam[$name] : null;
|
||||
$value = isset($smartyParam[$name]) ? $smartyParam[$name] : null;
|
||||
|
||||
if($value == null){
|
||||
if(isset($param['default'])){
|
||||
$value = $param['default'];
|
||||
}
|
||||
else if($param['required'] === true){
|
||||
$faultActor[] = $name;
|
||||
$faultDetails[] = sprintf('"%s" parameter is missing', $name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ($value == null) {
|
||||
if (isset($param['default'])) {
|
||||
$value = $param['default'];
|
||||
} elseif ($param['required'] === true) {
|
||||
$faultActor[] = $name;
|
||||
$faultDetails[] = sprintf('"%s" parameter is missing', $name);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$loop->{$name} = $value;
|
||||
}
|
||||
$loop->{$name} = $value;
|
||||
}
|
||||
|
||||
if(!empty($faultActor)){
|
||||
if (!empty($faultActor)) {
|
||||
|
||||
$complement = sprintf('[%s]', implode(', ', $faultDetails));
|
||||
throw new \InvalidArgumentException($complement);
|
||||
}
|
||||
$complement = sprintf('[%s]', implode(', ', $faultDetails));
|
||||
throw new \InvalidArgumentException($complement);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,13 +265,13 @@ class TheliaLoop implements SmartyPluginInterface {
|
||||
*/
|
||||
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));
|
||||
}
|
||||
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;
|
||||
}
|
||||
$this->loopDefinition[$name] = $className;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -286,9 +282,9 @@ class TheliaLoop implements SmartyPluginInterface {
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
return array(
|
||||
new SmartyPluginDescriptor('block', 'loop' , $this, 'theliaLoop'),
|
||||
new SmartyPluginDescriptor('block', 'elseloop' , $this, 'theliaElseloop'),
|
||||
new SmartyPluginDescriptor('block', 'ifloop' , $this, 'theliaIfLoop')
|
||||
new SmartyPluginDescriptor('block', 'loop' , $this, 'theliaLoop'),
|
||||
new SmartyPluginDescriptor('block', 'elseloop' , $this, 'theliaElseloop'),
|
||||
new SmartyPluginDescriptor('block', 'ifloop' , $this, 'theliaIfLoop')
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,32 +23,28 @@
|
||||
|
||||
namespace Thelia\Core\Template\Smarty\Plugins;
|
||||
|
||||
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
|
||||
|
||||
class Translation implements SmartyPluginInterface {
|
||||
|
||||
|
||||
class Translation implements SmartyPluginInterface
|
||||
{
|
||||
/**
|
||||
* Process translate function
|
||||
*
|
||||
* @param unknown $params
|
||||
* @param unknown $smarty
|
||||
* @param unknown $params
|
||||
* @param unknown $smarty
|
||||
* @return string
|
||||
*/
|
||||
public function theliaTranslate($params, &$smarty)
|
||||
{
|
||||
if (isset($params['l'])) {
|
||||
$string = str_replace('\'', '\\\'', $params['l']);
|
||||
}
|
||||
else {
|
||||
$string = '';
|
||||
}
|
||||
if (isset($params['l'])) {
|
||||
$string = str_replace('\'', '\\\'', $params['l']);
|
||||
} else {
|
||||
$string = '';
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
||||
return "[$string]";
|
||||
// TODO
|
||||
return "[$string]";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,4 +58,4 @@ class Translation implements SmartyPluginInterface {
|
||||
new SmartyPluginDescriptor('function', 'intl', $this, 'theliaTranslate'),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,18 +8,16 @@ use \Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use \Smarty;
|
||||
|
||||
use Thelia\Core\Template\ParserInterface;
|
||||
use Thelia\Core\Template\Loop\Category;
|
||||
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginInterface;
|
||||
use Thelia\Core\Template\Smarty\Assets\SmartyAssetsManager;
|
||||
use Thelia\Core\Template\Exception\ResourceNotFoundException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class SmartyParser extends Smarty implements ParserInterface {
|
||||
|
||||
class SmartyParser extends Smarty implements ParserInterface
|
||||
{
|
||||
public $plugins = array();
|
||||
|
||||
protected $request, $dispatcher;
|
||||
@@ -29,10 +27,10 @@ class SmartyParser extends Smarty implements ParserInterface {
|
||||
protected $status = 200;
|
||||
|
||||
/**
|
||||
* @param \Symfony\Component\HttpFoundation\Request $request
|
||||
* @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
|
||||
* @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)
|
||||
{
|
||||
@@ -68,107 +66,108 @@ class SmartyParser extends Smarty implements ParserInterface {
|
||||
$this->status = 200;
|
||||
}
|
||||
|
||||
public function setTemplate($template_path_from_template_base) {
|
||||
|
||||
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;
|
||||
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
|
||||
* @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) {
|
||||
public function render($realTemplateName, array $parameters)
|
||||
{
|
||||
$this->assign($parameters);
|
||||
|
||||
$this->assign($parameters);
|
||||
|
||||
return $this->fetch($realTemplateName);
|
||||
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());
|
||||
}
|
||||
/**
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* status HTTP of the response
|
||||
*
|
||||
* @param int $status
|
||||
*/
|
||||
public function setStatus($status)
|
||||
{
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
public function addPlugins(SmartyPluginInterface $plugin)
|
||||
{
|
||||
$this->plugins[] = $plugin;
|
||||
$this->plugins[] = $plugin;
|
||||
}
|
||||
|
||||
public function registerPlugins()
|
||||
{
|
||||
foreach ($this->plugins as $register_plugin) {
|
||||
$plugins = $register_plugin->getPluginDescriptors();
|
||||
foreach ($this->plugins as $register_plugin) {
|
||||
$plugins = $register_plugin->getPluginDescriptors();
|
||||
|
||||
if(!is_array($plugins)) {
|
||||
$plugins = array($plugins);
|
||||
}
|
||||
if (!is_array($plugins)) {
|
||||
$plugins = array($plugins);
|
||||
}
|
||||
|
||||
foreach ($plugins as $plugin) {
|
||||
$this->registerPlugin(
|
||||
$plugin->getType(),
|
||||
$plugin->getName(),
|
||||
array(
|
||||
$plugin->getClass(),
|
||||
$plugin->getMethod()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
foreach ($plugins as $plugin) {
|
||||
$this->registerPlugin(
|
||||
$plugin->getType(),
|
||||
$plugin->getName(),
|
||||
array(
|
||||
$plugin->getClass(),
|
||||
$plugin->getMethod()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function getTemplateFilePath()
|
||||
{
|
||||
$file = $this->request->attributes->get('_view');
|
||||
$file = $this->request->attributes->get('_view');
|
||||
|
||||
$fileName = THELIA_TEMPLATE_DIR . rtrim($this->template, "/") . "/" . $file . ".html";
|
||||
$fileName = THELIA_TEMPLATE_DIR . rtrim($this->template, "/") . "/" . $file . ".html";
|
||||
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
|
||||
throw new ResourceNotFoundException(sprintf("%s file not found in %s template", $file, $this->template));
|
||||
throw new ResourceNotFoundException(sprintf("%s file not found in %s template", $file, $this->template));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ namespace Thelia\Core\Template\Smarty;
|
||||
* Class SmartyPluginDescriptor
|
||||
* @package Thelia\Core\Template\Smarty
|
||||
*/
|
||||
class SmartyPluginDescriptor {
|
||||
|
||||
class SmartyPluginDescriptor
|
||||
{
|
||||
/**
|
||||
* @var string Smarty plugin type (block, function, etc.)
|
||||
*/
|
||||
@@ -59,35 +59,43 @@ class SmartyPluginDescriptor {
|
||||
$this->method = $method;
|
||||
}
|
||||
|
||||
public function setType($type) {
|
||||
$this->type = $type;
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
}
|
||||
|
||||
public function getType() {
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function setName($name) {
|
||||
$this->name = $name;
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setClass($class) {
|
||||
$this->class = $class;
|
||||
public function setClass($class)
|
||||
{
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
public function getClass() {
|
||||
public function getClass()
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
public function setMethod($method) {
|
||||
$this->method = $method;
|
||||
public function setMethod($method)
|
||||
{
|
||||
$this->method = $method;
|
||||
}
|
||||
|
||||
public function getMethod() {
|
||||
public function getMethod()
|
||||
{
|
||||
return $this->method;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,10 @@ namespace Thelia\Core\Template\Smarty;
|
||||
* Interface SmartyPluginInterface
|
||||
* @package Thelia\Core\Template\Smarty
|
||||
*/
|
||||
interface SmartyPluginInterface {
|
||||
interface SmartyPluginInterface
|
||||
{
|
||||
/**
|
||||
* @return an array of SmartyPluginDescriptor
|
||||
*/
|
||||
public function getPluginDescriptors();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,4 +48,4 @@ class Equal extends BaseTestLoop
|
||||
{
|
||||
return $variable == $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,8 +121,7 @@ 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,4 +35,4 @@ class TheliaContainerBuilder extends ContainerBuilder
|
||||
parent::compile();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -149,4 +148,4 @@ class TheliaHttpKernel extends HttpKernel
|
||||
|
||||
return $request;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user