Source of file Redactor.php
Size: 1,199 Bytes - Last Modified: 2017-11-08T13:54:24+00:00
/home/travis/build/bluzphp/framework/src/View/Helper/Redactor.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 | <?php /** * Bluz Framework Component * * @copyright Bluz PHP Team * @link https://github.com/bluzphp/framework */ declare(strict_types=1); namespace Bluz\View\Helper; use Bluz\View\View; /** * Generate HTML and JavaScript for WYSIWYG redactor * * @link http://imperavi.com/redactor/ * * @param string $selector * @param array $settings * * @return string */ return function ($selector, array $settings = []) { /** * @var View $this */ $defaultSettings = [ 'imageUpload' => $this->url('media', 'upload'), // default media upload controller 'imageManagerJson' => $this->url('media', 'list'), // default images list 'plugins' => ['imagemanager'] ]; $settings = array_replace_recursive($defaultSettings, $settings); $settings = json_encode($settings); $html = ''; $html .= $this->style('redactor/redactor.css'); $html .= $this->scriptBlock( 'require(["jquery", "redactor", "redactor.imagemanager"], function($) { $("' . $selector . '").redactor(' . $settings . '); });' ); return $html; }; |