Commit 6f96cbe8 authored by Son Nguyen's avatar Son Nguyen Committed by Gerrit Code Review
Browse files

Merge "Bug 1598962: Styling the choose template .tpl"

parents ba16996a c021f20b
......@@ -163,7 +163,7 @@ $viewbeingwatched = (int)record_exists('usr_watchlist_view', 'usr', $USER->get('
// Set up theme
$viewtheme = $view->get('theme');
if ($viewtheme && $THEME->basename != $viewtheme) {
$THEME = new Theme($viewtheme);
$THEME = new Theme($view);
}
$headers = array();
......
......@@ -2803,7 +2803,7 @@ class View {
public function set_user_theme() {
global $THEME;
if ($this->theme && $THEME->basename != $this->theme) {
$THEME = new Theme($this->theme);
$THEME = new Theme($this);
}
return $this->theme;
}
......
......@@ -985,6 +985,18 @@ class Theme {
else if ($arg instanceof User) {
$themedata = $arg->get_themedata();
}
else if ($arg instanceof View) {
$themename = $arg->get('theme');
$themedata = null;
$userid = $arg->get('owner');
if ($userid) {
$user = new User();
$user->find_by_id($userid);
$themedata = $user->get_themedata();
$themedata->viewbasename = $themedata->basename;
unset($themedata->basename);
}
}
else if (is_int($arg)) {
$user = new User();
$user->find_by_id($arg);
......@@ -994,7 +1006,7 @@ class Theme {
throw new SystemException("Argument to Theme::__construct was not a theme name, user object or user ID");
}
if (isset($themedata)) {
if (isset($themedata) && isset($themedata->basename)) {
$themename = $themedata->basename;
}
......@@ -1042,10 +1054,17 @@ class Theme {
$themeconfig = $getthemeconfig($themename);
if (!$themeconfig) {
// We can safely assume that the default theme is installed, users
// should never be able to remove it
$themename ='default';
$themeconfig = $getthemeconfig($themename);
// We can check if we have been given a viewbasename
if (!empty($themedata->viewbasename)) {
$themename = $themedata->viewbasename;
$themeconfig = $getthemeconfig($themename);
}
if (!$themeconfig) {
// We can safely assume that the default theme is installed, users
// should never be able to remove it
$themename = 'default';
$themeconfig = $getthemeconfig($themename);
}
}
$this->basename = $themename;
......
{include file="header.tpl"}
<h1>{$maintitle}</h1>
<div class="center">
<p>{str tag=changeviewtheme section=view}</p>
<form action="{$formurl}" method="post">
<p class="alert alert-warning">{str tag=changeviewtheme section=view}</p>
<form action="{$formurl}" method="post" class="pieform form-inline">
<input type="hidden" id="viewid" name="id" value="{$view}">
<input type="hidden" name="sesskey" value="{$SESSKEY}">
<label for="viewtheme-select">{str tag=theme}: </label>
<select id="viewtheme-select" name="viewtheme">
{foreach from=$viewthemes key=themeid item=themename}
<option value="{$themeid}"{if $themeid == $viewtheme} selected="selected" style="font-weight: bold;"{/if}>{$themename}</option>
{/foreach}
</select>
<input class="submit btn btn-primary" type="submit" value="{str tag=submit}">
<div class="select form-group">
<label for="viewtheme-select">{str tag=theme}: </label>
<span class="picker">
<select id="viewtheme-select" name="viewtheme" class="form-control select autofocus">
{foreach from=$viewthemes key=themeid item=themename}
<option value="{$themeid}"{if $themeid == $viewtheme} selected="selected" style="font-weight: bold;"{/if}>{$themename}</option>
{/foreach}
</select>
</span>
<input class="submit btn btn-primary" type="submit" value="{str tag=submit}">
</div>
</form>
</div>
......
......@@ -103,7 +103,7 @@ $inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs'])
// Set up theme
$viewtheme = $view->get('theme');
if ($viewtheme && $THEME->basename != $viewtheme) {
$THEME = new Theme($viewtheme);
$THEME = new Theme($view);
}
$stylesheets = array();
$stylesheets = array_merge($stylesheets, $view->get_all_blocktype_css());
......
......@@ -135,7 +135,7 @@ $stylesheets = array_merge($stylesheets, $view->get_all_blocktype_css());
// longer available to them.
if ($viewtheme && !isset($allowedthemes[$viewtheme])) {
$smarty = smarty(array(), $stylesheets, false, $extraconfig);
$smarty->assign('maintitle', TITLE);
$smarty->assign('PAGEHEADING', get_string('choosetheme'));
$smarty->assign('formurl', get_config('wwwroot') . 'view/blocks.php');
$smarty->assign('view', $view->get('id'));
$smarty->assign('viewtitle', $view->get('title'));
......
......@@ -238,7 +238,7 @@ $feedback = ArtefactTypeComment::get_comments($commentoptions);
// Set up theme
$viewtheme = $view->get('theme');
if ($viewtheme && $THEME->basename != $viewtheme) {
$THEME = new Theme($viewtheme);
$THEME = new Theme($view);
}
$headers = array();
$headers[] = '<link rel="stylesheet" type="text/css" href="' . append_version_number(get_config('wwwroot') . 'js/jquery/jquery-ui/css/smoothness/jquery-ui.min.css') . '">';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment