Performs share button rendering.

@param array $options

@return string

@throws \InvalidArgumentException if template engine is not set
@throws \InvalidArgumentException if provider label is not set
420070
protected function doRender(array $options)
    {
        if (!isset($this->templateEngine)) {
            throw new InvalidArgumentException('Missing template engine');
        }

        if (!isset($this->label)) {
            throw new InvalidArgumentException('Missing provider label');
        }

        if (isset($options[$this->label])) {
            $options = array_merge($this->options, $options[$this->label], $options);
            unset($options[$this->label]);
        } else {
            $options = $options + $this->options;
        }

        $template = sprintf(
            'EzSystemsShareButtonsBundle::%s/%s',
            $this->templateName,
            $options['template']
        );

        return $this->templateEngine->render($template, $options);
    }
33040
public function getShareLink($url, array $options = array())
    {
        $options['url'] = $url;

        return sprintf(self::SHARE_URL, http_build_query($options));
    }
186312
protected function renderOptionTags($options)
    {
        $output = '';
        if ($this->hasArgument('prependOptionLabel')) {
            $value = $this->hasArgument('prependOptionValue') ? $this->arguments['prependOptionValue'] : '';
            if ($this->hasArgument('translate')) {
                $label = $this->getTranslatedLabel($value, $this->arguments['prependOptionLabel']);
            } else {
                $label = $this->arguments['prependOptionLabel'];
            }
            $output .= $this->renderOptionTag($value, $label) . chr(10);
        }
        $output .= $this->renderOptionTagsInternal($options);

        return $output;
    }
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]);
	}
1112176
public function render($options = array())
    {
        $pattern = $options['pattern'];
        $data = $options['data'];

        return $this->renderTpl($pattern, $data);
    }
633315
public static function renderCss($options = []) {
		$result = '';
		$list = [];
		$css = Application::get(array('layout', 'css'));
		if (!empty($css)) {
			asort($css);
			foreach ($css as $k=>$v) {
				$script = $k . (strpos($k, '?') !== false ? '&' : '?') . self::getVersion();
				$list[] = $script;
				$result.= '<link href="' . $script . '" rel="stylesheet" type="text/css" />';
			}
		}
		// list is needed for ajax form reloads
		if (!empty($options['return_list'])) {
			return $list;
		}
		return $result;
	}
210649
public function renderToggleButton($content, $options = [])
    {
        if (!isset($options['id'])) {
            $options['id'] = $this->getId() . '-button';
        }

        $this->getView()->registerJs('
        jQuery("#' . $options['id'] . '").on("click", function(event) {
            event.preventDefault();
            jQuery("#' . $this->getId() . '").modal("show");
        });
        ');

        return Elements::button($content, $options);
    }
460519
protected function renderEntityWidget($entities, array $options = [])
    {
        if (!array_key_exists('field', $options)) {
            // throw new \InvalidArgumentException('Missing "field" option for entity widget.');
            $options['field'] = null;
        }
        if (!array_key_exists('route', $options)) {
            $options['route'] = null;
        }
        if (!array_key_exists('route_params', $options)) {
            $options['route_params'] = [];
        }
        if (!array_key_exists('route_params_map', $options)) {
            $options['route_params_map'] = ['id' => 'id'];
        }

        if (null !== $entities && !($entities instanceof Collection)) {
            $entities = new ArrayCollection([$entities]);
        }

        $vars = [
            'route' => $options['route'],
            'field' => $options['field'],
            'route_params'     => $options['route_params'],
            'route_params_map' => $options['route_params_map'],
            'entities' => $entities
        ];

        return $this->renderBlock('show_widget_entity', $vars);
    }
883930
protected function renderOptionTags($options)
    {
        $output = '';
        if ($this->hasArgument('prependOptionLabel')) {
            $value = $this->hasArgument('prependOptionValue') ? $this->arguments['prependOptionValue'] : '';
            if ($this->hasArgument('translate')) {
                $label = $this->getTranslatedLabel($value, $this->arguments['prependOptionLabel']);
            } else {
                $label = $this->arguments['prependOptionLabel'];
            }

            $output .= $this->renderOptionTag($value, $label) . chr(10);
        } elseif (empty($options)) {
            $options = array('' => '');
        }
        foreach ($options as $value => $label) {
            $output .= $this->renderOptionTag($value, $label) . chr(10);
        }
        return $output;
    }
426520
public function autoload(array $autoloads, $provider, $options = [])
    {
        foreach ($autoloads as $name => $alias) {
            if (is_int($name)) {
                $name = $alias;
            }
            if (empty($name)) {
                throw new \InvalidArgumentException("Cannot not autoload empty service");
            }
            if (!empty($options['prefix'])) {
                $alias = $options['prefix'] . ucfirst($alias);
            }
            $shared = true;
            if (isset($options['shared'])) {
                if (is_array($options['shared'])) {
                    $shared = in_array($name, $options['shared']);
                } else {
                    $shared = $options['shared'];
                }
            } elseif (isset($options['instances'])) {
                $shared = !in_array($name, $options['instances']);
            }
            $this->set($alias, function () use ($name, $provider) {
                if (!is_object($provider)) {
                    $provider = $this->getShared($provider);
                }
                return $provider->provide($name, func_get_args());
            }, $shared);
        }
        return $this;
    }
1316534
protected function renderOptionTags($options)
    {
        if ($this->arguments['nothingSelectedLabel'] !== null) {
            $this->arguments['prependOptionLabel'] = $this->arguments['nothingSelectedLabel'];
        }
        if ($this->arguments['required']) {
            $this->tag->addAttribute('required', 'required');
        }
        return parent::renderOptionTags($options);
    }
780967
protected function _groupTemplate($options)
    {
        $groupTemplate = $options['options']['type'] . 'FormGroup';
        if (!$this->templater()->get($groupTemplate)) {
            $groupTemplate = 'formGroup';
        }

        return $this->formatTemplate($groupTemplate, [
            'input' => $options['input'],
            'label' => $options['label'],
            'error' => $options['error'],
            'templateVars' => $this->_processTemplateVars($options)
        ]);
    }
803685
public function render(array $options, $name, $selected = array(), array $attrs = array(), $tpl = false)
    {
        $selected = (array) $selected;

        $attrs = array_merge(array('multiple' => false), $attrs);

        if ($attrs['multiple'] === true) {
            $attrs['multiple'] = 'multiple';
        }

        if ($attrs['multiple'] === 'multiple' && !strpos($name, '[]')) {
            $name .= '[]';
        }

        $attrs['name'] = $name;

        $attrs   = $this->_mergeAttr($attrs, $this->_jbSrt('select'));
        $options = $this->_getOptions($options, $selected, $attrs['multiple']);

        return '<select ' . $this->buildAttrs($attrs) . '>' . $options . '</select>';
    }
1363945
public function render(array $options = [])
    {
        if (profiler() !== false) {
            profiler()->watch('Starting View Rendering');
        }

        parser()->loadVars(presenter()->getArrayCopy());

        if (presenter()->page->file instanceof \SplFileInfo) {

            if (false === ($pagePresets = presenter()->page->getPresets())) {
                if (presenter()->page->file->getFilename() === 'index') {
                    $title = presenter()->page->file->getDirectoryInfo()->getDirName();
                } else {
                    $titles[] = presenter()->page->file->getDirectoryInfo()->getDirName();
                    $titles[] = presenter()->page->file->getFilename();

                    $title = implode(' - ', array_unique($titles));
                }

                $pagePresets = new SplArrayObject([
                    'title'  => readable($title, true),
                    'access' => 'public',
                ]);
            }

            /**
             * Sets Page Theme
             */
            if ($pagePresets->offsetExists('theme')) {
                presenter()->setTheme($pagePresets->theme);
            } elseif (false !== ($theme = presenter()->getConfig('theme'))) {
                if (modules()->top()->hasTheme($theme)) {
                    presenter()->setTheme($theme);
                }
            }

            /**
             * Sets Page Layout
             */
            if (presenter()->theme !== false) {
                if ($pagePresets->offsetExists('layout')) {
                    presenter()->theme->setLayout($pagePresets->layout);
                }

                /**
                 * Autoload Theme Assets
                 */
                presenter()->theme->load();

                if (false !== ($modulePresets = modules()->top()->getPresets())) {

                    /**
                     * Autoload Module Assets
                     */
                    if ($modulePresets->offsetExists('assets')) {
                        presenter()->assets->autoload($modulePresets->assets);
                    }

                    /**
                     * Sets Module Meta
                     */
                    if ($modulePresets->offsetExists('title')) {
                        presenter()->meta->title->append(language()->getLine($modulePresets->title));
                    }

                    if ($modulePresets->offsetExists('pageTitle')) {
                        presenter()->meta->title->replace(language()->getLine($modulePresets->pageTitle));
                    }

                    if ($modulePresets->offsetExists('browserTitle')) {
                        presenter()->meta->title->replace(language()->getLine($modulePresets->browserTitle));
                    }

                    if ($modulePresets->offsetExists('meta')) {
                        foreach ($modulePresets->meta as $name => $content) {
                            presenter()->meta->store($name, $content);
                        }
                    }
                }

                $moduleAssets = [
                    'app',
                    'module',
                    modules()->top()->getParameter(),
                ];

                // Autoload Assets
                presenter()->assets->loadCss($moduleAssets);
                presenter()->assets->loadJs($moduleAssets);

                /**
                 * Autoload Page Assets
                 */
                if ($pagePresets->offsetExists('assets')) {
                    presenter()->assets->autoload($pagePresets->assets);
                }

                if (presenter()->page->file instanceof \SplFileInfo) {
                    $pageDir = presenter()->page->file->getRealPath();
                    $pageDir = str_replace('.' . pathinfo($pageDir, PATHINFO_EXTENSION), '', $pageDir);

                    $pageDirParts = explode('pages' . DIRECTORY_SEPARATOR,
                        str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $pageDir));
                    $pageDir = end($pageDirParts);

                    presenter()->assets->addFilePath(reset($pageDirParts) . 'pages' . DIRECTORY_SEPARATOR);

                    $pageDir = rtrim($pageDir, DIRECTORY_SEPARATOR);
                    $pageDirParts = explode(DIRECTORY_SEPARATOR, $pageDir);

                    $totalParts = count($pageDirParts);

                    for ($i = 0; $i < $totalParts; $i++) {
                        $pageAssets[] = implode(DIRECTORY_SEPARATOR, array_slice($pageDirParts, 0, ($totalParts - $i)));
                    }

                    $pageAssets[] = implode(DIRECTORY_SEPARATOR, [end($pageAssets), end($pageAssets)]);

                    // Autoload Assets
                    presenter()->assets->loadCss($pageAssets);
                    presenter()->assets->loadJs($pageAssets);
                }

                /**
                 * Sets Page Meta
                 */
                if ($pagePresets->offsetExists('title')) {
                    presenter()->meta->title->append(language()->getLine($pagePresets->title));
                }

                if ($pagePresets->offsetExists('pageTitle')) {
                    presenter()->meta->title->replace(language()->getLine($pagePresets->pageTitle));
                }

                if ($pagePresets->offsetExists('browserTitle')) {
                    presenter()->meta->title->replace(language()->getLine($pagePresets->browserTitle));
                }

                if ($pagePresets->offsetExists('meta')) {
                    foreach ($pagePresets->meta as $name => $content) {
                        presenter()->meta->store($name, $content);
                    }
                }

                if (false !== ($layout = presenter()->theme->getLayout())) {
                    parser()->loadFile($layout->getRealPath());

                    $htmlOutput = parser()->parse();
                    $htmlOutput = presenter()->assets->parseSourceCode($htmlOutput);

                    $this->document->loadHTML($htmlOutput);
                }
            } else {
                output()->sendError(204, language()->getLine('E_THEME_NOT_FOUND', [$theme]));
            }
        } elseif (presenter()->theme instanceof Theme) {
            /**
             * Autoload Theme Assets
             */
            presenter()->theme->load();

            if (false !== ($modulePresets = modules()->top()->getPresets())) {

                /**
                 * Autoload Module Assets
                 */
                if ($modulePresets->offsetExists('assets')) {
                    presenter()->assets->autoload($modulePresets->assets);
                }

                /**
                 * Sets Module Meta
                 */
                if ($modulePresets->offsetExists('title')) {
                    presenter()->meta->title->append(language()->getLine($modulePresets->title));
                }

                if ($modulePresets->offsetExists('pageTitle')) {
                    presenter()->meta->title->replace(language()->getLine($modulePresets->pageTitle));
                }

                if ($modulePresets->offsetExists('browserTitle')) {
                    presenter()->meta->title->replace(language()->getLine($modulePresets->browserTitle));
                }

                if ($modulePresets->offsetExists('meta')) {
                    foreach ($modulePresets->meta as $name => $content) {
                        presenter()->meta->store($name, $content);
                    }
                }
            }

            $moduleAssets = [
                'app',
                'module',
                modules()->top()->getParameter(),
            ];

            // Autoload Assets
            presenter()->assets->loadCss($moduleAssets);
            presenter()->assets->loadJs($moduleAssets);

            /**
             * Autoload Controller Assets
             */
            $controllerFilename = str_replace([modules()->top()->getDir('Controllers'), '.php'], '',
                controller()->getFileInfo()->getRealPath());
            $controllerFilename = dash($controllerFilename);
            $controllerAssets[] = $controllerFilename;
            $controllerAssets[] = implode('/', [
                $controllerFilename,
                controller()->getRequestMethod(),
            ]);

            presenter()->assets->loadCss($controllerAssets);
            presenter()->assets->loadJs($controllerAssets);

            if (false !== ($layout = presenter()->theme->getLayout())) {
                parser()->loadFile($layout->getRealPath());

                $htmlOutput = parser()->parse();
                $htmlOutput = presenter()->assets->parseSourceCode($htmlOutput);

                $this->document->loadHTML($htmlOutput);
            }
        } elseif (false !== ($theme = presenter()->getConfig('theme'))) {
            if (modules()->top()->hasTheme($theme)) {
                presenter()->setTheme($theme);

                /**
                 * Autoload Theme Assets
                 */
                presenter()->theme->load();

                if (false !== ($modulePresets = modules()->top()->getPresets())) {

                    /**
                     * Autoload Module Assets
                     */
                    if ($modulePresets->offsetExists('assets')) {
                        presenter()->assets->autoload($modulePresets->assets);
                    }

                    /**
                     * Sets Module Meta
                     */
                    if ($modulePresets->offsetExists('title')) {
                        presenter()->meta->title->append(language()->getLine($modulePresets->title));
                    }

                    if ($modulePresets->offsetExists('pageTitle')) {
                        presenter()->meta->title->replace(language()->getLine($modulePresets->pageTitle));
                    }

                    if ($modulePresets->offsetExists('browserTitle')) {
                        presenter()->meta->title->replace(language()->getLine($modulePresets->browserTitle));
                    }

                    if ($modulePresets->offsetExists('meta')) {
                        foreach ($modulePresets->meta as $name => $content) {
                            presenter()->meta->store($name, $content);
                        }
                    }
                }

                $moduleAssets = [
                    'app',
                    'module',
                    modules()->top()->getParameter(),
                ];

                // Autoload Assets
                presenter()->assets->loadCss($moduleAssets);
                presenter()->assets->loadJs($moduleAssets);

                /**
                 * Autoload Controller Assets
                 */
                $controllerFilename = str_replace([modules()->top()->getDir('Controllers'), '.php'], '',
                    controller()->getFileInfo()->getRealPath());
                $controllerFilename = dash($controllerFilename);
                $controllerAssets[] = $controllerFilename;
                $controllerAssets[] = implode('/', [
                    $controllerFilename,
                    controller()->getRequestMethod(),
                ]);

                if (false !== ($layout = presenter()->theme->getLayout())) {
                    parser()->loadFile($layout->getRealPath());

                    $htmlOutput = parser()->parse();
                    $htmlOutput = presenter()->assets->parseSourceCode($htmlOutput);

                    $this->document->loadHTML($htmlOutput);
                }
            } else {
                output()->sendError(204, language()->getLine('E_THEME_NOT_FOUND', [$theme]));
            }
        } else {
            $this->document->find('body')->append(presenter()->partials->__get('content'));
        }

        /**
         * Set Document Meta Title
         */
        if (presenter()->meta->title instanceof Meta\Title) {
            $this->document->title->text(presenter()->meta->title->__toString());
        }

        /**
         * Injecting Meta Opengraph
         */
        if (presenter()->meta->opengraph instanceof Meta\Opengraph) {
            // set opengraph title
            if (presenter()->meta->title instanceof Meta\Title) {
                presenter()->meta->opengraph->setTitle(presenter()->meta->title->__toString());
            }

            // set opengraph site name
            if (presenter()->exists('siteName')) {
                presenter()->meta->opengraph->setSiteName(presenter()->offsetGet('siteName'));
            }

            if (presenter()->meta->opengraph->count()) {
                $htmlElement = $this->document->getElementsByTagName('html')->item(0);
                $htmlElement->setAttribute('prefix', 'og: ' . presenter()->meta->opengraph->prefix);

                if (presenter()->meta->opengraph->exists('og:type') === false) {
                    presenter()->meta->opengraph->setType('website');
                }

                $opengraph = presenter()->meta->opengraph->getArrayCopy();

                foreach ($opengraph as $tag) {
                    $this->document->metaNodes->createElement($tag->attributes->getArrayCopy());
                }
            }
        }

        if (presenter()->meta->count()) {
            $meta = presenter()->meta->getArrayCopy();

            foreach ($meta as $tag) {
                $this->document->metaNodes->createElement($tag->attributes->getArrayCopy());
            }
        }

        /**
         * Inject body attributes
         */
        $body = $this->document->getElementsByTagName('body');
        $body->item(0)->setAttribute('module', modules()->top()->getParameter());

        /**
         * Injecting Single Sign-On (SSO) iFrame
         */
        if (services()->has('user')) {
            $iframe = services()->get('user')->getIframeCode();

            if ( ! empty($iframe)) {
                $this->document->find('body')->append($iframe);
            }
        }

        if (input()->env('DEBUG_STAGE') === 'DEVELOPER' and
            presenter()->getConfig('debugToolBar') === true and
            services()->has('profiler')
        ) {
            $this->document->find('body')->append((new Toolbar())->__toString());
        }

        /**
         * Injecting Progressive Web Application (PWA) Manifest
         */
        $this->document->linkNodes->createElement([
            'rel'  => 'manifest',
            'href' => '/manifest.json',
        ]);

        $htmlOutput = $this->document->saveHTML();

        // Uglify Output
        if ($this->config->output[ 'uglify' ] === true) {
            $htmlOutput = preg_replace(
                [
                    '/\>[^\S ]+/s',     // strip whitespaces after tags, except space
                    '/[^\S ]+\</s',     // strip whitespaces before tags, except space
                    '/(\s)+/s',         // shorten multiple whitespace sequences
                    '/<!--(.|\s)*?-->/', // Remove HTML comments
                    '/<!--(.*)-->/Uis',
                    "/[[:blank:]]+/",
                ],
                [
                    '>',
                    '<',
                    '\\1',
                    '',
                    '',
                    ' ',
                ],
                str_replace(["\n", "\r", "\t"], '', $htmlOutput));
        }

        // Beautify Output
        if ($this->config->output[ 'beautify' ] === true) {
            $beautifier = new Html\Dom\Beautifier();
            $htmlOutput = $beautifier->format($htmlOutput);
        }

        if (profiler() !== false) {
            profiler()->watch('Ending View Rendering');
        }

        return $htmlOutput;
    }
876384
protected function doRender(array $options)
    {
        $template = isset($options['template']) ? $options['template'] : $this->getDefaultTemplate();
        unset($options['template']);

        return $this->templateEngine->render($template, $options);
    }
65211
protected function render_sharethis_button(): string
    {
        \wp_enqueue_script(
            'sharethis',
            'https://ws.sharethis.com/button/buttons.js'
        );

        return '<span class="st_sharethis_hcount" st_url="'.
            \wp_get_shortlink($this->post->get()->ID).'" st_title="'.
            \esc_attr(\sanitize_text_field(\get_the_title($this->post->get()))).
            '" st_summary="'.\esc_attr($this->post->excerpt()).
            '" st_via=""></span>';
    }
349475
public function render(array $parameters = []): string
    {
        /** @var Location $location */
        $location = $parameters['location'];
        /** @var Content $content */
        $content = $parameters['content'];
        /** @var Language $language */
        $language = $parameters['language'];
        $versionNo = $content->getVersionInfo()->versionNo;

        // nonpublished content should use parent location instead because location doesn't exist yet
        if (!$content->contentInfo->published && null === $content->contentInfo->mainLocationId) {
            $parentLocations = $this->locationService->loadParentLocationsForDraftContent($content->getVersionInfo());
            $location = reset($parentLocations);
            $versionNo = null;
        }

        $siteaccesses = $this->siteaccessResolver->getSiteaccessesForLocation(
            $location,
            $versionNo,
            $language->languageCode
        );

        if (empty($siteaccesses)) {
            return $this->twig->render(
                '@ezdesign/content/content_edit/component/preview_unavailable.html.twig'
            );
        }

        return '';
    }