Merge branch 'master' of https://github.com/thelia/thelia into coupon
# By Manuel Raynaud (92) and others # Via Manuel Raynaud (28) and others * 'master' of https://github.com/thelia/thelia: (212 commits) fix typo add some php doc integrate swiftMailer as mailer solution add swiftmailer in composer use dump autoloader in all compser scripts remove script part of composer.json file fix typo add some information for OSX requirements No alert bloc default country Autofocus on username field for better use Beautiful login page feed loop is now countable Change error page design Add validation button on form - Edit country view creation - Delete and edit modalbox creation - Countries routes management Completed template management fix faker fix faker script Working : Fixture : cleaning ...
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<database defaultIdMethod="native" name="thelia">
|
||||
<table name="category" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
@@ -28,15 +28,22 @@
|
||||
<column name="description" type="CLOB" />
|
||||
<column name="chapo" type="LONGVARCHAR" />
|
||||
<column name="postscriptum" type="LONGVARCHAR" />
|
||||
<column name="template_id" required="true" type="INTEGER" />
|
||||
<foreign-key foreignTable="tax_rule" name="fk_product_tax_rule_id" onDelete="SET NULL" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="tax_rule_id" />
|
||||
</foreign-key>
|
||||
<foreign-key foreignTable="template" name="fk_product_template1">
|
||||
<reference foreign="id" local="template_id" />
|
||||
</foreign-key>
|
||||
<unique name="ref_UNIQUE">
|
||||
<unique-column name="ref" />
|
||||
</unique>
|
||||
<index name="idx_product_tax_rule_id">
|
||||
<index-column name="tax_rule_id" />
|
||||
</index>
|
||||
<index name="fk_product_template_id">
|
||||
<index-column name="template_id" />
|
||||
</index>
|
||||
<behavior name="timestampable" />
|
||||
<behavior name="i18n">
|
||||
<parameter name="i18n_columns" value="title, description, chapo, postscriptum" />
|
||||
@@ -73,6 +80,7 @@
|
||||
<column name="description" type="CLOB" />
|
||||
<column name="chapo" type="LONGVARCHAR" />
|
||||
<column name="postscriptum" type="LONGVARCHAR" />
|
||||
<column name="by_default" type="TINYINT" />
|
||||
<foreign-key foreignTable="area" name="fk_country_area_id" onDelete="SET NULL" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="area_id" />
|
||||
</foreign-key>
|
||||
@@ -86,7 +94,8 @@
|
||||
</table>
|
||||
<table name="tax" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="rate" required="true" type="FLOAT" />
|
||||
<column name="type" required="true" size="255" type="VARCHAR" />
|
||||
<column name="serialized_requirements" required="true" type="LONGVARCHAR" />
|
||||
<column name="title" size="255" type="VARCHAR" />
|
||||
<column name="description" type="LONGVARCHAR" />
|
||||
<behavior name="timestampable" />
|
||||
@@ -96,19 +105,19 @@
|
||||
</table>
|
||||
<table name="tax_rule" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="code" size="45" type="VARCHAR" />
|
||||
<column name="title" size="255" type="VARCHAR" />
|
||||
<column name="description" type="LONGVARCHAR" />
|
||||
<behavior name="timestampable" />
|
||||
<behavior name="i18n" />
|
||||
<behavior name="i18n">
|
||||
<parameter name="i18n_columns" value="title, description" />
|
||||
</behavior>
|
||||
</table>
|
||||
<table name="tax_rule_country" namespace="Thelia\Model">
|
||||
<column name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="tax_rule_id" type="INTEGER" />
|
||||
<column name="country_id" type="INTEGER" />
|
||||
<column name="tax_id" type="INTEGER" />
|
||||
<column name="none" type="TINYINT" />
|
||||
<foreign-key foreignTable="tax" name="fk_tax_rule_country_tax_id" onDelete="SET NULL" onUpdate="RESTRICT">
|
||||
<column name="tax_rule_id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="country_id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="tax_id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="position" required="true" type="INTEGER" />
|
||||
<foreign-key foreignTable="tax" name="fk_tax_rule_country_tax_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="tax_id" />
|
||||
</foreign-key>
|
||||
<foreign-key foreignTable="tax_rule" name="fk_tax_rule_country_tax_rule_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
@@ -187,22 +196,22 @@
|
||||
</index>
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
<table isCrossRef="true" name="feature_category" namespace="Thelia\Model">
|
||||
<table isCrossRef="true" name="feature_template" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="feature_id" required="true" type="INTEGER" />
|
||||
<column name="category_id" required="true" type="INTEGER" />
|
||||
<foreign-key foreignTable="category" name="fk_feature_category_category_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="category_id" />
|
||||
</foreign-key>
|
||||
<foreign-key foreignTable="feature" name="fk_feature_category_feature_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<column name="template_id" required="true" type="INTEGER" />
|
||||
<foreign-key foreignTable="feature" name="fk_feature_template_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="feature_id" />
|
||||
</foreign-key>
|
||||
<index name="idx_feature_category_category_id">
|
||||
<index-column name="category_id" />
|
||||
</index>
|
||||
<index name="idx_feature_category_feature_id">
|
||||
<foreign-key foreignTable="template" name="fk_feature_template">
|
||||
<reference foreign="id" local="template_id" />
|
||||
</foreign-key>
|
||||
<index name="idx_feature_template_id">
|
||||
<index-column name="feature_id" />
|
||||
</index>
|
||||
<index name="fk_feature_template_idx">
|
||||
<index-column name="template_id" />
|
||||
</index>
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
<table name="attribute" namespace="Thelia\Model">
|
||||
@@ -263,6 +272,7 @@
|
||||
<table name="product_sale_elements" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="product_id" required="true" type="INTEGER" />
|
||||
<column name="ref" required="true" size="45" type="VARCHAR" />
|
||||
<column name="quantity" required="true" type="FLOAT" />
|
||||
<column defaultValue="0" name="promo" type="TINYINT" />
|
||||
<column defaultValue="0" name="newness" type="TINYINT" />
|
||||
@@ -273,24 +283,27 @@
|
||||
<index name="idx_product_sale_element_product_id">
|
||||
<index-column name="product_id" />
|
||||
</index>
|
||||
<unique name="ref_UNIQUE">
|
||||
<unique-column name="ref" />
|
||||
</unique>
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
<table isCrossRef="true" name="attribute_category" namespace="Thelia\Model">
|
||||
<table isCrossRef="true" name="attribute_template" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="category_id" required="true" type="INTEGER" />
|
||||
<column name="attribute_id" required="true" type="INTEGER" />
|
||||
<foreign-key foreignTable="category" name="fk_attribute_category_category_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="category_id" />
|
||||
</foreign-key>
|
||||
<foreign-key foreignTable="attribute" name="fk_attribute_category_attribute_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<column name="template_id" required="true" type="INTEGER" />
|
||||
<foreign-key foreignTable="attribute" name="fk_attribute_template_id" onDelete="CASCADE" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="attribute_id" />
|
||||
</foreign-key>
|
||||
<index name="idx_attribute_category_category_id">
|
||||
<index-column name="category_id" />
|
||||
</index>
|
||||
<index name="idx_attribute_category_attribute_id">
|
||||
<foreign-key foreignTable="template" name="fk_attribute_template">
|
||||
<reference foreign="id" local="template_id" />
|
||||
</foreign-key>
|
||||
<index name="idx_attribute_template_id">
|
||||
<index-column name="attribute_id" />
|
||||
</index>
|
||||
<index name="fk_attribute_template_idx">
|
||||
<index-column name="template_id" />
|
||||
</index>
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
<table name="config" namespace="Thelia\Model">
|
||||
@@ -324,6 +337,8 @@
|
||||
<column name="lang" size="10" type="VARCHAR" />
|
||||
<column name="sponsor" size="50" type="VARCHAR" />
|
||||
<column name="discount" type="FLOAT" />
|
||||
<column name="remember_me_token" size="255" type="VARCHAR" />
|
||||
<column name="remember_me_serial" size="255" type="VARCHAR" />
|
||||
<foreign-key foreignTable="customer_title" name="fk_customer_customer_title_id" onDelete="RESTRICT" onUpdate="RESTRICT">
|
||||
<reference foreign="id" local="title_id" />
|
||||
</foreign-key>
|
||||
@@ -689,6 +704,8 @@
|
||||
<column name="password" required="true" size="128" type="VARCHAR" />
|
||||
<column name="algo" size="128" type="VARCHAR" />
|
||||
<column name="salt" size="128" type="VARCHAR" />
|
||||
<column name="remember_me_token" size="255" type="VARCHAR" />
|
||||
<column name="remember_me_serial" size="255" type="VARCHAR" />
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
<table isCrossRef="true" name="admin_group" namespace="Thelia\Model">
|
||||
@@ -865,6 +882,7 @@
|
||||
<column name="address_delivery_id" type="INTEGER" />
|
||||
<column name="address_invoice_id" type="INTEGER" />
|
||||
<column name="currency_id" type="INTEGER" />
|
||||
<column defaultValue="0" name="discount" type="FLOAT" />
|
||||
<foreign-key foreignTable="customer" name="fk_cart_customer_id">
|
||||
<reference foreign="id" local="customer_id" />
|
||||
</foreign-key>
|
||||
@@ -903,6 +921,8 @@
|
||||
<column name="price" type="FLOAT" />
|
||||
<column name="promo_price" type="FLOAT" />
|
||||
<column name="price_end_of_life" type="TIMESTAMP" />
|
||||
<column defaultValue="0" name="discount" type="FLOAT" />
|
||||
<column name="promo" type="INTEGER" />
|
||||
<foreign-key foreignTable="cart" name="fk_cart_item_cart_id">
|
||||
<reference foreign="id" local="cart_id" />
|
||||
</foreign-key>
|
||||
@@ -924,9 +944,8 @@
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
<table name="product_price" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="product_sale_elements_id" required="true" type="INTEGER" />
|
||||
<column name="currency_id" required="true" type="INTEGER" />
|
||||
<column name="product_sale_elements_id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="currency_id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="price" required="true" type="FLOAT" />
|
||||
<column name="promo_price" type="FLOAT" />
|
||||
<foreign-key foreignTable="product_sale_elements" name="fk_product_price_product_sale_elements_id" onDelete="CASCADE">
|
||||
@@ -1134,4 +1153,12 @@
|
||||
</index>
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
<table name="template" namespace="Thelia\Model">
|
||||
<column autoIncrement="true" name="id" primaryKey="true" required="true" type="INTEGER" />
|
||||
<column name="name" size="255" type="VARCHAR" />
|
||||
<behavior name="i18n">
|
||||
<parameter name="i18n_columns" value="name" />
|
||||
</behavior>
|
||||
<behavior name="timestampable" />
|
||||
</table>
|
||||
</database>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
|
||||
<services>
|
||||
<service id="debugBar" class="DebugBar\StandardDebugBar"/>
|
||||
<service id="debugBar" class="DebugBar\DebugBar"/>
|
||||
|
||||
<service id="smarty.debugbar" class="DebugBar\Smarty\Plugin\DebugBar">
|
||||
<argument type="service" id="debugBar"/>
|
||||
|
||||
@@ -40,7 +40,9 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
|
||||
protected $peakMemory = 0;
|
||||
|
||||
public function __construct()
|
||||
protected $alternativeLogger;
|
||||
|
||||
public function __construct(LoggerInterface $alternativeLogger = null)
|
||||
{
|
||||
$serviceContainer = Propel::getServiceContainer();
|
||||
$serviceContainer->setLogger('defaultLogger', $this);
|
||||
@@ -54,6 +56,8 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
'commit',
|
||||
'rollBack',
|
||||
));
|
||||
|
||||
$this->alternativeLogger = $alternativeLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -66,8 +70,8 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
return array(
|
||||
'nb_statements' => count($this->statements),
|
||||
'nb_failed_statements' => 0,
|
||||
'accumulated_duration' => '10',
|
||||
'accumulated_duration_str' => $this->formatDuration(1),
|
||||
'accumulated_duration' => $this->accumulatedTime,
|
||||
'accumulated_duration_str' => $this->formatDuration($this->accumulatedTime),
|
||||
'peak_memory_usage' => $this->peakMemory,
|
||||
'peak_memory_usage_str' => $this->formatBytes($this->peakMemory),
|
||||
'statements' => $this->statements
|
||||
@@ -115,14 +119,56 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
*/
|
||||
public function log($level, $message, array $context = array())
|
||||
{
|
||||
list($sql, $duration_str) = $this->parseAndLogSqlQuery($message);
|
||||
|
||||
$message = "$sql ($duration_str)";
|
||||
|
||||
if ($this->alternativeLogger) {
|
||||
$this->alternativeLogger->log($level, $message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a log line to extract query information
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
protected function parseAndLogSqlQuery($message)
|
||||
{
|
||||
$parts = explode('|', $message, 3);
|
||||
$duration = 0;
|
||||
$memory = 0;
|
||||
if (count($parts) > 1) {
|
||||
$sql = trim($parts[2]);
|
||||
|
||||
if (preg_match('/([0-9]+\.[0-9]+)/', $parts[0], $matches)) {
|
||||
$duration = (float) $matches[1];
|
||||
}
|
||||
|
||||
if (preg_match('/([0-9]+\.[0-9]+)([A-Z]{1,2})/', $parts[1], $matches)) {
|
||||
$memory = (float) $matches[1];
|
||||
if ($matches[2] == 'KB') {
|
||||
$memory *= 1024;
|
||||
} else if ($matches[2] == 'MB') {
|
||||
$memory *= 1024 * 1024;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sql = $parts[0];
|
||||
}
|
||||
|
||||
|
||||
$this->statements[] = array(
|
||||
'sql' => $message,
|
||||
'sql' => $sql,
|
||||
'is_success' => true,
|
||||
'duration' => 0,
|
||||
'duration_str' => $this->formatDuration(1),
|
||||
'memory' => 1,
|
||||
'memory_str' => $this->formatBytes(1)
|
||||
'duration' => $duration,
|
||||
'duration_str' => $this->formatDuration($duration),
|
||||
'memory' => $memory,
|
||||
'memory_str' => $this->formatBytes($memory)
|
||||
);
|
||||
$this->accumulatedTime += $duration;
|
||||
$this->peakMemory = max($this->peakMemory, $memory);
|
||||
return array($sql, $this->formatDuration($duration));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -134,7 +180,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
*/
|
||||
public function emergency($message, array $context = array())
|
||||
{
|
||||
$this->log(null, $message, $context);
|
||||
$this->log(\Thelia\Log\Tlog::EMERGENCY, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,7 +195,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
*/
|
||||
public function alert($message, array $context = array())
|
||||
{
|
||||
$this->log(null, $message, $context);
|
||||
$this->log(\Thelia\Log\Tlog::ALERT, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,7 +209,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
*/
|
||||
public function critical($message, array $context = array())
|
||||
{
|
||||
$this->log(null, $message, $context);
|
||||
$this->log(\Thelia\Log\Tlog::CRITICAL, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +222,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
*/
|
||||
public function error($message, array $context = array())
|
||||
{
|
||||
$this->log(null, $message, $context);
|
||||
$this->log(\Thelia\Log\Tlog::ERROR, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,7 +237,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
*/
|
||||
public function warning($message, array $context = array())
|
||||
{
|
||||
$this->log(null, $message, $context);
|
||||
$this->log(\Thelia\Log\Tlog::WARNING, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,7 +249,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
*/
|
||||
public function notice($message, array $context = array())
|
||||
{
|
||||
$this->log(null, $message, $context);
|
||||
$this->log(\Thelia\Log\Tlog::NOTICE, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -217,7 +263,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
*/
|
||||
public function info($message, array $context = array())
|
||||
{
|
||||
$this->log(null, $message, $context);
|
||||
$this->log(\Thelia\Log\Tlog::INFO, $message, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,7 +275,7 @@ class PropelCollector extends DataCollector implements Renderable, LoggerInterfa
|
||||
*/
|
||||
public function debug($message, array $context = array())
|
||||
{
|
||||
$this->log(null, $message, $context);
|
||||
$this->log(\Thelia\Log\Tlog::DEBUG, $message, $context);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,11 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace DebugBar\Listeners;
|
||||
use DebugBar\DataCollector\MemoryCollector;
|
||||
use DebugBar\DataCollector\MessagesCollector;
|
||||
use DebugBar\DataCollector\PhpInfoCollector;
|
||||
use DebugBar\DataCollector\PropelCollector;
|
||||
use DebugBar\DataCollector\TimeDataCollector;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
use Thelia\Action\BaseAction;
|
||||
@@ -40,7 +44,13 @@ class DebugBarListeners extends BaseAction implements EventSubscriberInterface {
|
||||
{
|
||||
$debugBar = $this->container->get("debugBar");
|
||||
|
||||
$debugBar->addCollector(new PropelCollector());
|
||||
|
||||
$debugBar->addCollector(new PhpInfoCollector());
|
||||
//$debugBar->addCollector(new MessagesCollector());
|
||||
//$debugBar->addCollector(new RequestDataCollector());
|
||||
$debugBar->addCollector(new TimeDataCollector());
|
||||
$debugBar->addCollector(new MemoryCollector());
|
||||
$debugBar->addCollector(new PropelCollector(\Thelia\Log\Tlog::getInstance()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,6 +26,7 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Template\Smarty\an;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use DebugBar\DebugBar as BaseDebugBar;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
/**
|
||||
* Class DebugBar
|
||||
@@ -52,20 +53,54 @@ class DebugBar extends AbstractSmartyPlugin
|
||||
return $render;
|
||||
}
|
||||
|
||||
public function renderHead($params, \Smarty_Internal_Template $template)
|
||||
public function renderCss($params, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$render = "";
|
||||
if ($this->debugMode) {
|
||||
$javascriptRenderer = $this->debugBar->getJavascriptRenderer();
|
||||
$assets = $javascriptRenderer->getAsseticCollection();
|
||||
if($this->debugMode)
|
||||
{
|
||||
$webFile = "cache/debugbar.css";
|
||||
$cssFile = THELIA_WEB_DIR ."/".$webFile;
|
||||
|
||||
$cssCollection = $assets[0];
|
||||
$jsCollection = $assets[1];
|
||||
if(!file_exists($cssFile)) {
|
||||
$javascriptRenderer = $this->debugBar->getJavascriptRenderer();
|
||||
$assetCss = $javascriptRenderer->getAsseticCollection("css");
|
||||
|
||||
$render .= sprintf('<style media="screen" type="text/css">%s</style>', $cssCollection->dump());
|
||||
$render .= sprintf('<script>%s</script>', $jsCollection->dump());
|
||||
foreach($assetCss->all() as $asset) {
|
||||
if(strpos($asset->getSourcePath(), "font-awesome") !== false) {
|
||||
$assetCss->removeLeaf($asset);
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($cssFile, $assetCss->dump());
|
||||
}
|
||||
$render = sprintf('<link rel="stylesheet" href="%s">', URL::getInstance()->absoluteUrl($webFile, array(), URL::PATH_TO_FILE));
|
||||
}
|
||||
return $render;
|
||||
}
|
||||
|
||||
public function renderJs($params, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$render = "";
|
||||
if($this->debugMode)
|
||||
{
|
||||
$webFile = "cache/debugbar.js";
|
||||
$cacheFile = THELIA_WEB_DIR ."/".$webFile;
|
||||
|
||||
if (!file_exists($cacheFile)) {
|
||||
$javascriptRenderer = $this->debugBar->getJavascriptRenderer();
|
||||
$assetJs = $javascriptRenderer->getAsseticCollection("js");
|
||||
|
||||
foreach($assetJs->all() as $asset) {
|
||||
if(strpos($asset->getSourcePath(), "jquery") !== false) {
|
||||
$assetJs->removeLeaf($asset);
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($cacheFile, $assetJs->dump());
|
||||
}
|
||||
|
||||
$render = sprintf('<script src="%s"></script>', URL::getInstance()->absoluteUrl($webFile, array(), URL::PATH_TO_FILE));
|
||||
}
|
||||
return $render;
|
||||
}
|
||||
|
||||
@@ -75,8 +110,9 @@ class DebugBar extends AbstractSmartyPlugin
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
return array(
|
||||
new SmartyPluginDescriptor("function", "debugbar_renderHead", $this, "renderHead"),
|
||||
new SmartyPluginDescriptor("function", "debugbar_render", $this, "render")
|
||||
new SmartyPluginDescriptor("function", "debugbar_rendercss", $this, "renderCss"),
|
||||
new SmartyPluginDescriptor("function", "debugbar_renderjs", $this, "renderJs"),
|
||||
new SmartyPluginDescriptor("function", "debugbar_renderresult", $this, "render")
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user