30 lines
652 B
PHP
30 lines
652 B
PHP
<?php
|
|
|
|
/**
|
|
* Smarty plugin.
|
|
*/
|
|
use KupShop\ContentBundle\Util\InlineEdit;
|
|
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
|
|
|
/**
|
|
* Smarty {translate} function plugin.
|
|
*/
|
|
function smarty_modifier_inline_edit($block, $editable = true)
|
|
{
|
|
if (is_string($block) || is_null($block)) {
|
|
return $block;
|
|
}
|
|
|
|
/** @var InlineEdit $inlineEdit */
|
|
$inlineEdit = ServiceContainer::getService(InlineEdit::class);
|
|
$wrapped = $inlineEdit->wrapBlock($block);
|
|
|
|
if (!$editable && getAdminUser()) {
|
|
return $wrapped['unwrapped_content'];
|
|
}
|
|
|
|
if (isset($wrapped['content'])) {
|
|
return $wrapped['content'];
|
|
}
|
|
}
|