Merge branch 'master' of https://github.com/thelia/thelia into coupon

# By Manuel Raynaud (19) and others
# Via Manuel Raynaud (5) and others
* 'master' of https://github.com/thelia/thelia: (37 commits)
  add PropelDataCollector to debugbar, still missing some informations
  remove unused class
  integrate debugbar module
  remove htmlpurifier
  modify insert.sql including debugBar module
  add new event and new tag
  Started category modification
  Factorized modal dialogs javascript
  Factorized creation and confirmation modal dialogs
  create controller adding delivery module in session
  create Delivery loop
  Working :
  Continuing categories administration...
  Working :
  create base loop for delivery and payment entities
  remove htmlpurifier dependency
  country id can be an argument for calculate method
  Working :
  Working :
  fix typo
  ...

Conflicts:
	composer.lock
	core/lib/Thelia/Controller/Admin/CategoryController.php
	templates/admin/default/assets/less/thelia/variables.less
This commit is contained in:
gmorel
2013-09-08 00:08:02 +02:00
99 changed files with 3456 additions and 1551 deletions

View File

@@ -605,6 +605,7 @@
<column name="description" type="CLOB" />
<column name="chapo" type="LONGVARCHAR" />
<column name="postscriptum" type="LONGVARCHAR" />
<column name="full_namespace" size="255" type="VARCHAR" />
<unique name="code_UNIQUE">
<unique-column name="code" />
</unique>

View File

@@ -0,0 +1,83 @@
<?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 Colissimo;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Module\BaseModule;
use Thelia\Module\DeliveryModuleInterface;
class Colissimo extends BaseModule implements DeliveryModuleInterface
{
protected $request;
protected $dispatcher;
public function setRequest(Request $request)
{
$this->request = $request;
}
public function getRequest()
{
return $this->request;
}
public function setDispatcher(EventDispatcherInterface $dispatcher)
{
$this->dispatcher = $dispatcher;
}
public function getDispatcher()
{
return $this->dispatcher;
}
/**
*
* calculate and return delivery price
*
* @param null $country
* @return mixed
*/
public function calculate($country = null)
{
// TODO: Implement calculate() method.
return 2;
}
/**
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class
* Like install and destroy
*/
public function install()
{
// TODO: Implement install() method.
}
public function destroy()
{
// TODO: Implement destroy() method.
}
}

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config"
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">
<loops>
<!-- sample definition
<loop name="MySuperLoop" class="MyModule\Loop\MySuperLoop" />
-->
</loops>
<forms>
<!--
<form name="MyFormName" class="MyModule\Form\MySuperForm" />
-->
</forms>
<commands>
<!--
<command class="MyModule\Command\MySuperCommand" />
-->
</commands>
<templateDirectives>
<!-- Sample definition
<templateDirectives class="MyModule\Directive\MyTemplateDirective" name="my_filter"/>
-->
</templateDirectives>
<!--
<services>
</services>
-->
</config>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="thelia" namespace="Colissimo\Model">
<!--
See propel documentation on http://propelorm.org for all information about schema file
-->
<external-schema filename="/home/manu/dev/www/thelia/local/config/schema.xml" referenceOnly="true" />
</database>

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8" ?>
<config xmlns="http://thelia.net/schema/dic/config"
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">
<loops>
<!-- sample definition
<loop name="MySuperLoop" class="MyModule\Loop\MySuperLoop" />
-->
</loops>
<forms>
<!--
<form name="MyFormName" class="MyModule\Form\MySuperForm" />
-->
</forms>
<commands>
<!--
<command class="MyModule\Command\MySuperCommand" />
-->
</commands>
<templateDirectives>
<!-- Sample definition
<templateDirectives class="MyModule\Directive\MyTemplateDirective" name="my_filter"/>
-->
</templateDirectives>
<services>
<service id="debugBar" class="DebugBar\StandardDebugBar"/>
<service id="smarty.debugbar" class="DebugBar\Smarty\Plugin\DebugBar">
<argument type="service" id="debugBar"/>
<argument >%kernel.debug%</argument>
<tag name="thelia.parser.register_plugin"/>
</service>
<service id="debugBar.listener" class="DebugBar\Listeners\DebugBarListeners">
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>
</services>
</config>

View File

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<database defaultIdMethod="native" name="thelia" namespace="DebugBar\Model">
<!--
See propel documentation on http://propelorm.org for all information about schema file
-->
<external-schema filename="/home/manu/dev/www/thelia/local/config/schema.xml" referenceOnly="true" />
</database>

View File

@@ -0,0 +1,236 @@
<?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 DebugBar\DataCollector;
use Propel\Runtime\Propel;
use Psr\Log\LoggerInterface;
/**
* Class PropelCollector
* @package DebugBar\DataCollector
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class PropelCollector extends DataCollector implements Renderable, LoggerInterface
{
protected $statements = array();
protected $accumulatedTime = 0;
protected $peakMemory = 0;
public function __construct()
{
$serviceContainer = Propel::getServiceContainer();
$serviceContainer->setLogger('defaultLogger', $this);
$con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
$con->setLogMethods(array(
'exec',
'query',
'execute', // these first three are the default
'beginTransaction',
'commit',
'rollBack',
));
}
/**
* Called by the DebugBar when data needs to be collected
*
* @return array Collected data
*/
function collect()
{
return array(
'nb_statements' => count($this->statements),
'nb_failed_statements' => 0,
'accumulated_duration' => '10',
'accumulated_duration_str' => $this->formatDuration(1),
'peak_memory_usage' => $this->peakMemory,
'peak_memory_usage_str' => $this->formatBytes($this->peakMemory),
'statements' => $this->statements
);
}
/**
* Returns the unique name of the collector
*
* @return string
*/
public function getName()
{
return 'propel';
}
/**
* Returns a hash where keys are control names and their values
* an array of options as defined in {@see DebugBar\JavascriptRenderer::addControl()}
*
* @return array
*/
public function getWidgets()
{
return array(
"propel" => array(
"widget" => "PhpDebugBar.Widgets.SQLQueriesWidget",
"map" => "propel",
"default" => "[]"
),
"propel:badge" => array(
"map" => "propel.nb_statements",
"default" => 0
)
);
}
/**
* Logs with an arbitrary level.
*
* @param mixed $level
* @param string $message
* @param array $context
* @return null
*/
public function log($level, $message, array $context = array())
{
$this->statements[] = array(
'sql' => $message,
'is_success' => true,
'duration' => 0,
'duration_str' => $this->formatDuration(1),
'memory' => 1,
'memory_str' => $this->formatBytes(1)
);
}
/**
* System is unusable.
*
* @param string $message
* @param array $context
* @return null
*/
public function emergency($message, array $context = array())
{
$this->log(null, $message, $context);
}
/**
* Action must be taken immediately.
*
* Example: Entire website down, database unavailable, etc. This should
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param array $context
* @return null
*/
public function alert($message, array $context = array())
{
$this->log(null, $message, $context);
}
/**
* Critical conditions.
*
* Example: Application component unavailable, unexpected exception.
*
* @param string $message
* @param array $context
* @return null
*/
public function critical($message, array $context = array())
{
$this->log(null, $message, $context);
}
/**
* Runtime errors that do not require immediate action but should typically
* be logged and monitored.
*
* @param string $message
* @param array $context
* @return null
*/
public function error($message, array $context = array())
{
$this->log(null, $message, $context);
}
/**
* Exceptional occurrences that are not errors.
*
* Example: Use of deprecated APIs, poor use of an API, undesirable things
* that are not necessarily wrong.
*
* @param string $message
* @param array $context
* @return null
*/
public function warning($message, array $context = array())
{
$this->log(null, $message, $context);
}
/**
* Normal but significant events.
*
* @param string $message
* @param array $context
* @return null
*/
public function notice($message, array $context = array())
{
$this->log(null, $message, $context);
}
/**
* Interesting events.
*
* Example: User logs in, SQL logs.
*
* @param string $message
* @param array $context
* @return null
*/
public function info($message, array $context = array())
{
$this->log(null, $message, $context);
}
/**
* Detailed debug information.
*
* @param string $message
* @param array $context
* @return null
*/
public function debug($message, array $context = array())
{
$this->log(null, $message, $context);
}
}

View File

@@ -0,0 +1,44 @@
<?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 DebugBar;
use Thelia\Module\BaseModule;
class DebugBar extends BaseModule
{
/**
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class
* Like install and destroy
*/
public function install()
{
// TODO: Implement install() method.
}
public function destroy()
{
// TODO: Implement destroy() method.
}
}

View File

@@ -0,0 +1,72 @@
<?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 DebugBar\Listeners;
use DebugBar\DataCollector\PropelCollector;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Thelia\Action\BaseAction;
use Thelia\Core\Event\TheliaEvents;
/**
* Class DebugBarListeners
* @package DebugBar\Listeners
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class DebugBarListeners extends BaseAction implements EventSubscriberInterface {
public function initDebugBar()
{
$debugBar = $this->container->get("debugBar");
$debugBar->addCollector(new PropelCollector());
}
/**
* Returns an array of event names this subscriber wants to listen to.
*
* The array keys are event names and the value can be:
*
* * The method name to call (priority defaults to 0)
* * An array composed of the method name to call and the priority
* * An array of arrays composed of the method names to call and respective
* priorities, or 0 if unset
*
* For instance:
*
* * array('eventName' => 'methodName')
* * array('eventName' => array('methodName', $priority))
* * array('eventName' => array(array('methodName1', $priority), array('methodName2'))
*
* @return array The event names to listen to
*
* @api
*/
public static function getSubscribedEvents()
{
return array(
TheliaEvents::BOOT => array("initDebugBar", 128)
);
}
}

View File

@@ -0,0 +1,82 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace DebugBar\Smarty\Plugin;
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
use Thelia\Core\Template\Smarty\an;
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
use DebugBar\DebugBar as BaseDebugBar;
/**
* Class DebugBar
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class DebugBar extends AbstractSmartyPlugin
{
protected $debugBar;
protected $debugMode;
public function __construct(BaseDebugBar $debugbar, $debugMode)
{
$this->debugBar = $debugbar;
$this->debugMode = $debugMode;
}
public function render($params, \Smarty_Internal_Template $template)
{
$render = "";
if ($this->debugMode) {
$render = $this->debugBar->getJavascriptRenderer()->render();
}
return $render;
}
public function renderHead($params, \Smarty_Internal_Template $template)
{
$render = "";
if ($this->debugMode) {
$javascriptRenderer = $this->debugBar->getJavascriptRenderer();
$assets = $javascriptRenderer->getAsseticCollection();
$cssCollection = $assets[0];
$jsCollection = $assets[1];
$render .= sprintf('<style media="screen" type="text/css">%s</style>', $cssCollection->dump());
$render .= sprintf('<script>%s</script>', $jsCollection->dump());
}
return $render;
}
/**
* @return an array of SmartyPluginDescriptor
*/
public function getPluginDescriptors()
{
return array(
new SmartyPluginDescriptor("function", "debugbar_renderHead", $this, "renderHead"),
new SmartyPluginDescriptor("function", "debugbar_render", $this, "render")
);
}
}