Files
sterivein/local/modules/DebugBar/Smarty/Plugin/DebugBar.php
gmorel 9338cdb472 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
2013-09-16 22:05:33 +02:00

82 lines
3.5 KiB
PHP
Executable File

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