TinyMce initializations

@param array $options

@return string
19652
public function tinymceInit($options = array())
    {
        $config = $this->getParameter('zicht_tinymce.config');
        $config = array_merge_recursive($config, $options);

        $this->baseUrl = (!isset($config['base_url']) ? null : $config['base_url']);
        $version = array_key_exists('version', $config) ? $config['version'] : ZichtTinymceBundle::BASE_VERSION;

        // Asset package name
        $assetPackageName = (!isset($config['asset_package_name']) ? null : $config['asset_package_name']);
        unset($config['asset_package_name']);

        /** @var $assets \Symfony\Component\Templating\Helper\CoreAssetsHelper */
        $assets = $this->getService('assets.packages');

        // Get path to tinymce script for the jQuery version of the editor
        if ($config['tinymce_jquery']) {
            $config['jquery_script_url'] = $assets->getUrl(
                $this->baseUrl . sprintf('bundles/zichttinymce/js/vendor/tinymce/%s/tinymce.min.js', $version),
                $assetPackageName
            );
        }

        // Get local button's image
        foreach ($config['tinymce_buttons'] as &$customButton) {
            if ($customButton['image']) {
                $customButton['image'] = $this->getAssetsUrl($customButton['image']);
            } else {
                unset($customButton['image']);
            }

            if ($customButton['icon']) {
                $customButton['icon'] = $this->getAssetsUrl($customButton['icon']);
            } else {
                unset($customButton['icon']);
            }
        }

        // Update URL to external plugins
        foreach ($config['external_plugins'] as &$extPlugin) {
            $extPlugin['url'] = $this->getAssetsUrl($extPlugin['url']);
        }

        // If the language is not set in the config...
        if (!isset($config['language']) || empty($config['language'])) {
            // get it from the request
            $config['language'] = $this->container->get('request_stack')->getCurrentRequest()->getLocale();
        }

        $config['language'] = LocaleHelper::getLanguage($config['language']);

        $langDirectory = __DIR__ . sprintf('/../../Resources/public/js/vendor/tinymce/%s/langs/', $version);

        // A language code coming from the locale may not match an existing language file
        if (!file_exists($langDirectory . $config['language'] . '.js')) {
            unset($config['language']);
        }

        if (isset($config['language']) && $config['language']) {
            // TinyMCE does not allow to set different languages to each instance
            foreach ($config['theme'] as $themeName => $themeOptions) {
                $config['theme'][$themeName]['language'] = $config['language'];
            }
        }

        if (isset($config['theme']) && $config['theme']) {
            // Parse the content_css of each theme so we can use 'asset[path/to/asset]' in there
            foreach ($config['theme'] as $themeName => $themeOptions) {
                if (isset($themeOptions['content_css'])) {
                    // As there may be multiple CSS Files specified we need to parse each of them individually
                    $cssFiles = $themeOptions['content_css'];
                    if (!is_array($themeOptions['content_css'])) {
                        $cssFiles = explode(',', $themeOptions['content_css']);
                    }

                    foreach ($cssFiles as $idx => $file) {
                        $cssFiles[$idx] = $this->getAssetsUrl(trim($file)); // we trim to be sure we get the file without spaces.
                    }

                    // After parsing we add them together again.
                    $config['theme'][$themeName]['content_css'] = implode(',', $cssFiles);
                }
            }
        }

        $tinymceConfiguration = preg_replace(
            array(
                '/"file_browser_callback":"([^"]+)"\s*/',
                '/"file_picker_callback":"([^"]+)"\s*/',
                '/"paste_preprocess":"([^"]+)"\s*/',
            ),
            array(
                'file_browser_callback:$1',
                'file_picker_callback:$1',
                '"paste_preprocess":$1',
            ),
            json_encode($config)
        );

        return $this->getService('templating')->render('ZichtTinymceBundle:Script:init.html.twig', array(
            'version' => $version,
            'tinymce_config' => $tinymceConfiguration,
            'include_jquery' => $config['include_jquery'],
            'tinymce_jquery' => $config['tinymce_jquery'],
            'asset_package_name' => $assetPackageName,
            'base_url' => $this->baseUrl,
        ));
    }
1012129
public static function select(array $options = []) : string {
		if (!empty($options['searchable'])) {
			$options['searchable'] = 'searchable';
		}
		if (!empty($options['preset'])) {
			$options['preset'] = 'preset';
		}
		if (!empty($options['tree'])) {
			$options['tree'] = 'tree';
		}
		if (!empty($options['color_picker'])) {
			$options['color_picker'] = 'color_picker';
		}
		return Factory::delegate('flag.numbers.framework.html', 'select', [$options]);
	}
231407
public function getAsHtml($options = [])
    {
        $defaults = [
            'table_id' => null,
            'table_class' => null,
            'translations' => [
                'title' => 'Transaction Details'
            ],
        ];

        $options = array_merge($defaults, $options);
        $translations = $options['translations'];

        $html = "<table id='{$options['table_id']}' class='{$options['table_class']}'><tbody>";
        foreach ($this->getAllSetData() as $key => $value) {
            $html .= "<tr><td>" . $this->translate($key, $translations) . "</td><td>" . $value . "</td></tr>";
        }

        $html .= "</tbody></table>";
        return $html;
    }
1080161
public static function get_tinymce_lang()
    {
        $lang = static::config()->get('tinymce_lang');
        $locale = i18n::get_locale();
        if (isset($lang[$locale])) {
            return $lang[$locale];
        }
        return 'en';
    }
760513
public function render($vimeo, array $options = array()) {
        $this->_setDefaultAttribs($options);
        $_attribs = $options['attribs'];
        $_attribs['width']  = $options['width'];
        $_attribs['height'] = $options['height'];

        unset($options['width']);
        unset($options['height']);
        unset($options['attribs']);

        $playerUrl = $this->getPlayerUrl($vimeo, $options);

        $_attribs['frameborder'] = 0;
        $_attribs['src'] = $playerUrl;

        $html = '<iframe' . $this->_htmlAttribs($_attribs) . '></iframe>';
        return $html;
    }
1018386
public function render(array $options = []): string
    {
        $html = $this->format['menuStart'];
        $html .= !empty($options['title']) ? $options['title'] : '';

        /**
         * @var MenuItemInterface $menuItem
         */
        foreach ($this->menu->getMenuItems() as $menuItem) {
            if ($menuItem->isEnabled()) {
                $html .= $this->renderMenuItem($menuItem);
            }
        }
        $html .= $this->format['menuEnd'];

        return $html;
    }
207484
public function tinymce($instance = 'default', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0'))
    {
        if (!is_string($instance)) {
            throw new \Twig_Error_Runtime('The function can be applied to strings only.');
        }

        return $this->twig->render('@FMElfinder/Elfinder/helper/_tinymce.html.twig',
            array(
                'instance' => $instance,
                'width'    => $parameters['width'],
                'height'   => $parameters['height'],
                'title'    => $parameters['title'],
            ));
    }
1248535
protected function set_textarea_size( $options ) {
		if ( isset( $options['size'] ) ) {
			list( $cols, $rows ) = explode( 'x', $options['size'] );
		} else {
			// If the "size" attribute was not specified, we will just look for the regular
			// columns and rows attributes, using sane defaults if these do not exist on
			// the attributes array. We'll then return this entire options array back.
			$cols = Arr::get( $options, 'cols', 50 );

			$rows = Arr::get( $options, 'rows', 10 );
		}

		return array_merge( $options, compact( 'cols', 'rows' ) );
	}
116799
public static function shortCodeAsciinema($options)
    {
        // Merge incoming options with default and expose as variables
        $options= array_merge(
            [
                "id" => null,
                "class" => null,
                "src" => null,
                "title" => null,
                "caption" => null,
            ],
            self::ShortCodeInit($options)
        );
        extract($options, EXTR_SKIP);

        $id = $id ? " id=\"$id\"" : null;
        $class = $class ? " class=\"figure asciinema $class\"" : " class=\"figure asciinema\"";
        $title = $title ? " title=\"$title\"" : null;

        $html = <<<EOD
<figure{$id}{$class}$title>
<script type="text/javascript" src="https://asciinema.org/a/{$src}.js" id="asciicast-{$src}" async></script>
<figcaption markdown=1>{$caption}</figcaption>
</figure>
EOD;

        return $html;
    }
2236
public static function get($options = array())
    {
        if (!isset(self::$_instances[md5(serialize($options))])) {
            return new HTML($options);
        }

        return self::$_instances[md5(serialize($options))];
    }
299307
public function prepare($options = [])
    {
        if (request()->ajax()) {
            return $this->getArray($options);
        }

        return $this->getHtml($options);
    }
601494
public function tinymce4($instance = 'default', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0'))
    {
        if (!is_string($instance)) {
            throw new \Twig_Error_Runtime('The function can be applied to strings only.');
        }

        return $this->twig->render('@FMElfinder/Elfinder/helper/_tinymce4.html.twig',
            array(
                'instance' => $instance,
                'width'    => $parameters['width'],
                'height'   => $parameters['height'],
                'title'    => $parameters['title'],
            ));
    }
1205499
public function openFormActions($options = array())
    {
        $options = $this->appendClassToOptions('form-actions', $options);

        return '<div' . $this->html->attributes($options) . '>';
    }
566394
protected function _createIconAttr(array $options = [])
    {
        $iconOptions = ['class' => ''];

        if (Arr::key('icon', $options)) {
            if (Arr::key('iconClass', $options)) {
                $iconOptions = $this->_addClass($iconOptions, $options['iconClass']);
                unset($options['iconClass']);
            }

            list ($options, $iconOptions) = $this->_setIconOptions($options, $iconOptions);
        }

        return [$options, $iconOptions];
    }
780628
public function amd($options = array())
    {
        $knownOptions = array(
            'initialSilence', 'greeting', 'afterGreetingSilence', 'totalAnalysisTime',
            'miniumWordLength', 'betweenWordSilence', 'maximumNumberOfWords',
            'silenceThreshold', 'maximumWordLength'
        );
        $args = array();
        $total = count($knownOptions);
        for ($i = 0; $i < $total; $i++) {
            $key = $knownOptions[$i];
            if (isset($options[$key])) {
                $args[] = $options[$key];
            } else {
                $args[] = '';
            }
        }
        $result = new AmdResult($this->exec('AMD', $args));
        $result->setStatus($this->getFullVariable('AMDSTATUS'));
        $result->setCause($this->getFullVariable('AMDCAUSE'));
        return $result;
    }
485935
public function initialise($options = array())
	{
		// Set the language in the class.
		$config = JFactory::getConfig();

		// Check that we were given a language in the array (since by default may be blank).
		if (isset($options['language']))
		{
			$config->set('language', $options['language']);
		}

		// Set user specific editor.
		$user = JFactory::getUser();
		$editor = $user->getParam('editor', $this->getCfg('editor'));

		if (!JPluginHelper::isEnabled('editors', $editor))
		{
			$editor = $this->getCfg('editor');

			if (!JPluginHelper::isEnabled('editors', $editor))
			{
				$editor = 'none';
			}
		}

		$config->set('editor', $editor);

		// Trigger the onAfterInitialise event.
		JPluginHelper::importPlugin('system');
		$this->triggerEvent('onAfterInitialise');
	}
632202
public static function init($options = []) {
		// initialize mbstring
		mb_internal_encoding('UTF-8');
		mb_regex_encoding('UTF-8');
		// if we are from command line we exit here
		if (!empty($options['__run_only_bootstrap'])) {
			// format
			\Format::init();
			return;
		}
		// enforcing https
		$enforce_https = \Application::get('application.https.enforce');
		if (!empty($enforce_https)) {
			if (!\Request::isSSL()) {
				$url = \Request::host(['protocol' => 'https', 'request' => true]);
				\Request::redirect($url);
			}
		}
		// get flags & backend
		$flags = \Application::get('flag');
		$backend = \Application::get('Numbers.Backend', ['backend_exists' => true]);
		// alive
		if (!empty($flags['alive']['autoconnect'])) {
			\Alive::start();
		}
		// initialize cryptography
		$crypt = \Application::get('crypt');
		if (!empty($crypt) && $backend) {
			foreach ($crypt as $crypt_link => $crypt_settings) {
				if (!empty($crypt_settings['submodule']) && !empty($crypt_settings['autoconnect'])) {
					$crypt_object = new \Crypt($crypt_link, $crypt_settings['submodule'], $crypt_settings);
				}
			}
		}
		// including libraries that we need to auto include
		if (!empty($flags['global']['library'])) {
			foreach ($flags['global']['library'] as $k => $v) {
				// we need to skip certain keys
				if ($k == 'submodule' || $k == 'options') continue;
				// we only include if autoconnect is on
				if (!empty($v['autoconnect'])) {
					\Factory::submodule('flag.global.library.' . $k . '.submodule')->add();
				}
			}
		}
		// check if we need to include system files from frontend
		if (\Application::get('dep.submodule.Numbers.Frontend.System')) {
			\Numbers\Frontend\System\Model\Base::start();
		}
		// application structure
		$application_structure_model = \Application::get('application.structure.model');
		if (!empty($application_structure_model)) {
			\Factory::model($application_structure_model, true)->settings();
		}
		$application_structure = \Application::get('application.structure');
		// create database connections
		$db = Application::get('db');
		if (!empty($db) && $backend) {
			foreach ($db as $db_link => $db_settings) {
				if (empty($db_settings['autoconnect']) || empty($db_settings['servers']) || empty($db_settings['submodule'])) continue;
				// establish connection
				$db_result = \Db::connectToServers($db_link, $db_settings);
				// checking if not connected
				if (!$db_result['success']) {
					// if wrong database name is provided we redirect to special url
					if (!empty($application_structure['db_not_found_url']) && isset($application_structure['settings']['db'][$db_link])) {
						\Request::redirect($application_structure['db_not_found_url']);
					} else {
						Throw new \Exception('Unable to open database connection!');
					}
				}
			}
		}
		// initialize caches
		$cache = Application::get('cache');
		if (!empty($cache) && $backend) {
			foreach ($cache as $cache_link => $cache_settings) {
				if (empty($cache_settings['submodule']) || empty($cache_settings['autoconnect'])) continue;
				$cache_result = \Cache::connectToServers($cache_link, $cache_settings);
				if (!$cache_result['success']) {
					Throw new \Exception(implode(', ', $cache_result['error']));
				}
			}
		}
		// initialize session
		$session = \Application::get('flag.global.session');
		if (!empty($session['start']) && $backend && !\Application::get('flag.global.__skip_session')) {
			\Session::start($session['options'] ?? []);
		}
		// load tenant
		if (!empty($application_structure_model) && !empty($application_structure['tenant_multiple'])) {
			\Factory::model($application_structure_model, true)->tenant();
		}
		// we need to get overrides from session and put them back to flag array
		$flags = array_merge_hard($flags, \Session::get('numbers.flag'));
		\Application::set('flag', $flags);
		// custom destroy methods
		$temp = \Object\ACL\Resources::getStatic('initialize');
		if (!empty($temp)) {
			foreach ($temp as $v) {
				$method = \Factory::method($v['method'], null, true);
				call_user_func_array($method, []);
			}
		}
		// initialize i18n
		if ($backend) {
			$temp_result = \I18n::init();
			if (!$temp_result['success']) {
				Throw new \Exception('Could not initialize i18n.');
			}
		}
		// format
		\Format::init();
		// default actions
		\Layout::addAction('refresh', ['value' => 'Refresh', 'icon' => 'fas fa-sync', 'onclick' => 'location.reload();', 'order' => -32000]);
		\Layout::addAction('print', ['value' => 'Print', 'icon' => 'fas fa-print', 'onclick' => 'window.print();', 'order' => -31000]);
		// include constants
		require('Constants.php');
	}