60 lines
1.8 KiB
PHP
60 lines
1.8 KiB
PHP
<?php
|
|
/**
|
|
* Smarty plugin.
|
|
*/
|
|
|
|
/**
|
|
* Smarty {insert_file_browse} plugin.
|
|
*
|
|
* Type: function<br>
|
|
* Name: url<br>
|
|
* Purpose: insert file browser
|
|
*
|
|
* @param array $params parameters
|
|
* @param Smarty_Internal_Template $template template object
|
|
*
|
|
* @return string
|
|
*/
|
|
function smarty_function_insert_file_browse($params, $template)
|
|
{
|
|
static $inserted = false;
|
|
if (!$inserted) {
|
|
?>
|
|
<script src="/web/bundles/cksourceckfinder/ckfinder/ckfinder.js"></script>
|
|
<script type="application/javascript">
|
|
CKFinder.config({connectorPath: '/ckfinder/connector'});
|
|
CKFinder.basePath = '/web/bundles/cksourceckfinder/ckfinder/';
|
|
//############### BROWSE FILES #####################//
|
|
$(document).on('click', '[data-file-browse]', function () {
|
|
var $input = $(this).closest('.input-group').find('input');
|
|
if (!$input)
|
|
return true;
|
|
|
|
CKFinder.popup({
|
|
language: 'cs',
|
|
resourceType: 'Soubory',
|
|
chooseFiles: true,
|
|
width: 800,
|
|
height: 600,
|
|
onInit: function (finder) {
|
|
finder.config.resourceType = 'Soubory';
|
|
finder.on('files:choose', function (evt) {
|
|
var file = evt.data.files.first();
|
|
$input.val(decodeURIComponent(file.getUrl()));
|
|
$input.change();
|
|
});
|
|
},
|
|
});
|
|
|
|
return false;
|
|
});
|
|
</script>
|
|
<?php
|
|
$inserted = true;
|
|
} ?>
|
|
<a class="btn btn-primary btn-sm" data-file-browse href="#" title="<?php echo getTextString('products', 'findFile'); ?>">
|
|
<span class="glyphicon glyphicon-folder-open"></span>
|
|
</a>
|
|
<?php
|
|
}
|