Renders theme links for switching between default and other themes.

@return string
188291
protected function theme_switch_links() {

        $actualdevice = core_useragent::get_device_type();
        $currentdevice = $this->page->devicetypeinuse;
        $switched = ($actualdevice != $currentdevice);

        if (!$switched && $currentdevice == 'default' && $actualdevice == 'default') {
            // The user is using the a default device and hasn't switched so don't shown the switch
            // device links.
            return '';
        }

        if ($switched) {
            $linktext = get_string('switchdevicerecommended');
            $devicetype = $actualdevice;
        } else {
            $linktext = get_string('switchdevicedefault');
            $devicetype = 'default';
        }
        $linkurl = new moodle_url('/theme/switchdevice.php', array('url' => $this->page->url, 'device' => $devicetype, 'sesskey' => sesskey()));

        $content  = html_writer::start_tag('div', array('id' => 'theme_switch_link'));
        $content .= html_writer::link($linkurl, $linktext, array('rel' => 'nofollow'));
        $content .= html_writer::end_tag('div');

        return $content;
    }
954904
private static function buildLinksTags() :string {
		// this is where formatted links tags go
		$links = [];
		// pack and minify
		self::packAndMinifyLinks();
		// for each available link
		foreach(self::$_links as $href => $attributes) {
			// sort the attributes (compulse order needs)
			ksort($attributes);
			// build as base stylesheet link and merge its attributes
			$links[] = new \Polyfony\Element('link', $attributes);
		}
		return implode('', $links);
	}
77200
public function getThemeAttribute()
    {
        if ($this->themeCache !== null) {
            return $this->themeCache;
        }

        $themeName = $this->getDatasourceName()
            ?: static::getDatasourceResolver()->getDefaultDatasource();

        return $this->themeCache = Theme::load($themeName);
    }
770665
public function render()
    {
        if (!$this->grid->usePagination()) {
            return '';
        }

        return $this->paginationRanger().
            $this->paginationLinks().
            $this->perPageSelector();
    }
906957
public static function get_themes()
    {
        $default = [self::PUBLIC_THEME, self::DEFAULT_THEME];

        if (!SSViewer::config()->uninherited('theme_enabled')) {
            return $default;
        }

        // Explicit list is assigned
        $themes = static::$current_themes;
        if (!isset($themes)) {
            $themes = SSViewer::config()->uninherited('themes');
        }
        if ($themes) {
            return $themes;
        }

        // Support legacy behaviour
        if ($theme = SSViewer::config()->uninherited('theme')) {
            return [self::PUBLIC_THEME, $theme, self::DEFAULT_THEME];
        }

        return $default;
    }
527112
public function render()
    {
        $htmlContent = '';
        foreach (self::$linkList->toArray() as $link) {
            $htmlContent .= '<link href="' . $link[0] . '"';
            if (!empty($link[1])) {
                $htmlContent .= ' rel="' . $link[1] . '"';
            }
            if (!empty($link[2])) {
                $htmlContent .= ' type="' . $link[2] . '"';
            }
            if (!empty($link[3])) {
                $htmlContent .= ' media="' . $link[3] . '"';
            }
            $htmlContent .= '>' . PHP_EOL;
        }
        return $htmlContent;
    }
767915
public function render()
    {
        $converter          = new CssSelectorConverter();
        $this->css          = $this->getCSS();
        foreach ($this->css->getAllRuleSets() as $ruleSet) {
            $selector = $ruleSet->getSelector();
            foreach ($this->domCrawler->evaluate($converter->toXPath($selector[0])) as $node) {
                $rules = $node->getAttribute('style') ? $node->getAttribute('style') . implode(' ',$ruleSet->getRules()) : implode(' ', $ruleSet->getRules());
                $node->setAttribute('style', $rules);
            }
        }
        return preg_replace('/\s+/', ' ', str_replace("\r\n", '',$this->domCrawler->html()));
    }
1268070
public function renderStyleAssets()
    {
        return implode(
            "\n",
            array_map(
                function ($asset, $parameters) {
                    return '<link rel="' . e(array_get($parameters, 'rel')) . '" href="' . $asset . '"'
                        . (array_get($parameters, 'type') ? ' type="' . e(array_get($parameters, 'type')) . '"' : '')
                        . (array_get($parameters, 'media') ? ' media="' . e(array_get($parameters, 'media')) . '"' : '')
                        . '>';
                },
                array_keys($this->styleAssets),
                array_values($this->styleAssets)
            )
        );
    }
427162
protected function _change()
    {
        $disabledThemes = plugin()
            ->filter(function ($theme) {
                return $theme->isTheme && !in_array($theme->name, [option('front_theme'), option('back_theme')]);
            })
            ->toArray();

        if (!count($disabledThemes)) {
            $this->err(__d('installer', '<info>There are no disabled themes!</info>'));
            $this->out();

            return;
        }

        $index = 1;
        $this->out();
        foreach ($disabledThemes as $theme) {
            $disabledThemes[$index] = $theme;
            $this->out(
                __d('installer', '[{0, number, integer}] {1} [{2}]', [
                    $index,
                    $theme->humanName,
                    ($theme->isAdmin ? __d('installer', 'backend') : __d('installer', 'frontend')),
                ])
            );
            $index++;
        }
        $this->out();

        $message = __d('installer', "Which theme would you like to activate?\n[Q]uit");
        while (true) {
            $in = $this->in($message);
            if (strtoupper($in) === 'Q') {
                $this->err(__d('installer', 'Operation aborted'));
                break;
            } elseif (intval($in) < 1 || !isset($disabledThemes[intval($in)])) {
                $this->err(__d('installer', 'Invalid option'));
            } else {
                $task = $this->dispatchShell("Installer.themes change -t {$disabledThemes[$in]->name}");

                if ($task === 0) {
                    $this->out(__d('installer', 'Theme changed!'));
                    Plugin::dropCache();
                } else {
                    $this->err(__d('installer', 'Theme could not be changed.'), 2);
                    $this->out();
                }
                break;
            }
        }

        $this->out();
    }
233826
public function defaultAction()
    {
        $themeName = $this->params()->fromRoute('theme');
        if (! $themeName) {
            $this->flashMessenger()->addMessage(
                $this->scTranslate('Theme was not specified.')
            );
            return $this->redirect()
                ->toRoute('sc-admin/theme')
                ->setStatusCode(303);
        }
        $side = $this->params()->fromRoute('side', 'frontend');
        $service = $this->getThemeService();
        if (! $service->setDefault($themeName, $side)) {
            foreach ($service->getMessages() as $message) {
                $this->flashMessenger()->addMessage($message);
            }
        }
        return $this->redirect()->toRoute('sc-admin/theme');
    }
397901
public function getThemeConfig()
    {
        if (empty($this->_themeConfig)) {
            $file = $this->getThemeFolder() . 'theme.json';
            $this->_themeConfig = Helper::getConfigFile($file);
        }
        return $this->_themeConfig;
    }
530383
protected function getFrontendThemesSettings()
    {
        $themes = $this->module->getByType('theme', true);
        unset($themes[$this->theme_backend]);
        return $themes;
    }
798037
private function render(): string
    {
        switch ($this->mode) {
            case 'button':
                $html = '<button class="btn' . $this->classes() . '" type="submit" ' .
                    (($this->disabled === true) ? 'disabled ' : null) .
                    '>' . $this->view->escapeHtml($this->label) . '</button>';
                break;

            case 'input':
                $html = '<input class="btn' . $this->classes() . '" type="' .
                    $this->input_type . '" value="' .
                    $this->view->escapeHtml($this->label) . '" ' .
                    (($this->disabled === true) ? ' disabled ' : null) . '/>';
                break;

            default:
                $html = '<a href="' . (($this->link !== null) ? $this->view->escapeUrl($this->link) : '#') .
                    '" class="btn' . $this->classes() .
                    (($this->disabled === true) ? ' disabled' : null) .
                    '" role="button">' . $this->view->escapeHtml($this->label) . '</a>';
                break;
        }

        return $html;
    }
328218
private function themes(): Generator
    {
        $themes = $this->module_service->findByInterface(ModuleThemeInterface::class);

        // Last theme used
        yield $themes->get(Session::get('theme', ''));

        // Default for tree
        $tree = app(Tree::class);

        if ($tree instanceof Tree) {
            yield $themes->get($tree->getPreference('THEME_DIR'));
        }

        // Default for site
        yield $themes->get(Site::getPreference('THEME_DIR'));

        // Default for application
        yield app(WebtreesTheme::class);
    }
458830
public function sectionStyles()
	{
		$result = '';
			Eresus_Kernel::app()->getPage()->title .= ADM_T_DIV.ADM_THEMES_STYLES;
		switch (arg('action'))
		{
			case 'update':
				$this->sectionStylesUpdate();
				break;

			case 'insert':
				$this->sectionStylesInsert();
				break;

			case 'add':
				$result = $this->sectionStylesAdd();
				break;

			default:
				if (arg('delete'))
				{
					$this->sectionStylesDelete();
				}
				elseif (arg('id'))
				{
					$result = $this->sectionStylesEdit();
				}
				else
				{
					$result = $this->sectionStylesList();
				}
		}
		return $result;
	}
811115
private function autoRender($links)
	{
		$list = "<div class=\"{$this->defaults['container_class']}\">\n\t";

		$list .= "<ul class=\"{$this->defaults['ul_class']}\">\n\t";

		foreach ($links as $l)
		{

			$active = ($l['active']) ? 'class="active"' : '';

			$list .= "<li {$active}>{$l['link']}</li>";
		}

		$list .= "</ul>\n";

		$list .= "</div>\n";

		return $list;
	}
1128775
protected function renderActionLinks() : string
    {
        $links = "";
        foreach ($this->getActionLinks() as $url => $label) {
            $links .= H::a($label, ["data-url" => $url])." ";
        }
        return $links;
    }