mirror of
https://github.com/e107inc/e107.git
synced 2025-04-19 20:21:51 +02:00
Closes #4514 Theme developers can now set the default style, just as they would with the default layout.
This commit is contained in:
parent
8df5e187b3
commit
196f952db8
@ -433,12 +433,15 @@ class theme_admin_ui extends e_admin_ui
|
||||
{
|
||||
$mes->addError($message);
|
||||
}
|
||||
|
||||
$this->redirectAction('main');
|
||||
}
|
||||
|
||||
if(!empty($_POST['selectadmin']))
|
||||
{
|
||||
$id = key($_POST['selectadmin']);
|
||||
$this->setAdminTheme($id);
|
||||
$this->redirectAction('admin');
|
||||
}
|
||||
|
||||
|
||||
|
@ -7171,11 +7171,11 @@ var_dump($select_options);*/
|
||||
{
|
||||
|
||||
$thumbnail = $this->tp->toImage($val['thumbnail'], $parms);
|
||||
$active = ($key === $value) ? ' active' : '';
|
||||
// $active = ($key === $value) ? ' active' : '';
|
||||
|
||||
$text .= "<div class='e-image-radio " . $class . "' >
|
||||
<label" . $this->attributes([
|
||||
'class' => "theme-selection$active",
|
||||
'class' => "theme-selection",
|
||||
'title' => varset($val['title']),
|
||||
]) . "><input" . $this->attributes([
|
||||
'type' => 'radio',
|
||||
|
@ -1198,6 +1198,7 @@ class e_theme
|
||||
"name" => $val['@attributes']['file'],
|
||||
"info" => $val['@attributes']['name'],
|
||||
"nonadmin" => $notadmin,
|
||||
'default' => vartrue($val['@attributes']['default'], false),
|
||||
'scope' => vartrue($val['@attributes']['scope'], 'front'),
|
||||
'exclude' => vartrue($val['@attributes']['exclude']),
|
||||
'description' => vartrue($val['@attributes']['description']),
|
||||
@ -3102,15 +3103,16 @@ class themeHandler
|
||||
|
||||
$themeArray = e107::getTheme()->getList("id");
|
||||
|
||||
$name = ($name) ? $name : vartrue($themeArray[$this->id]);
|
||||
$layout = $pref['sitetheme_layouts'] = is_array($this->themeArray[$name]['layouts']) ? $this->themeArray[$name]['layouts'] : array();
|
||||
$deflayout = $this->findDefault($name);
|
||||
$name = ($name) ? $name : vartrue($themeArray[$this->id]);
|
||||
$layout = $pref['sitetheme_layouts'] = is_array($this->themeArray[$name]['layouts']) ? $this->themeArray[$name]['layouts'] : array();
|
||||
$deflayout = $this->findDefault($name);
|
||||
$customPages = $this->themeArray[$name]['custompages'];
|
||||
$version = $this->themeArray[$name]['version'];
|
||||
$glyphs = $this->themeArray[$name]['glyphs'];
|
||||
|
||||
$version = $this->themeArray[$name]['version'];
|
||||
$glyphs = $this->themeArray[$name]['glyphs'];
|
||||
$style = $this->findDefaultCSS($name);
|
||||
|
||||
$core->set('sitetheme', $name);
|
||||
$core->set('themecss', 'style.css');
|
||||
$core->set('themecss', $style);
|
||||
$core->set('sitetheme_layouts', $layout);
|
||||
$core->set('sitetheme_deflayout', $deflayout);
|
||||
$core->set('sitetheme_custompages', $customPages);
|
||||
@ -3167,6 +3169,7 @@ class themeHandler
|
||||
e107::getCache()->clearAll('js');
|
||||
e107::getCache()->clearAll('css');
|
||||
e107::getCache()->clearAll('library');
|
||||
e107::getCache()->clearAll('browser');
|
||||
|
||||
if($core->save())
|
||||
{
|
||||
@ -3260,6 +3263,7 @@ class themeHandler
|
||||
|
||||
|
||||
/**
|
||||
* Find the default layout as marked in theme.xml
|
||||
* @param $theme
|
||||
* @return int|string
|
||||
*/
|
||||
@ -3269,16 +3273,16 @@ class themeHandler
|
||||
{
|
||||
return e107::getParser()->filter($_POST['layout_default'], 'w');
|
||||
}
|
||||
|
||||
|
||||
// $l = $this->themeArray[$theme];
|
||||
|
||||
|
||||
// if(!$l)
|
||||
{
|
||||
$l = e107::getTheme($theme)->get(); // $this->getThemeInfo($theme);
|
||||
}
|
||||
|
||||
|
||||
if($l['layouts'])
|
||||
|
||||
if(!empty($l['layouts']))
|
||||
{
|
||||
foreach ($l['layouts'] as $key=>$val)
|
||||
{
|
||||
@ -3293,6 +3297,32 @@ class themeHandler
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the default css style as defined in theme.xml. When not found, use 'style.css'.
|
||||
* @param string $theme theme-folder name.
|
||||
* @return string
|
||||
*/
|
||||
function findDefaultCSS($theme)
|
||||
{
|
||||
$l = e107::getTheme($theme)->get();
|
||||
|
||||
if(empty($l['css']))
|
||||
{
|
||||
return 'style.css';
|
||||
}
|
||||
|
||||
foreach($l['css'] as $item)
|
||||
{
|
||||
if(!empty($item['default']) && $item['default'] === 'true')
|
||||
{
|
||||
return $item['name'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 'style.css';
|
||||
}
|
||||
/*
|
||||
function setAdminTheme()
|
||||
{
|
||||
|
@ -21,7 +21,7 @@
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$this->assertTrue(false, "Couldn't load themeHandler object");
|
||||
$this->fail("Couldn't load themeHandler object");
|
||||
}
|
||||
|
||||
}
|
||||
@ -67,12 +67,24 @@
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
public function testFindDefault()
|
||||
{
|
||||
$result = $this->th->findDefault('bootstrap3');
|
||||
$this->assertSame('jumbotron_sidebar_right', $result);
|
||||
|
||||
}
|
||||
|
||||
public function testFindDefaultCSS()
|
||||
{
|
||||
$result = $this->th->findDefaultCSS('voux');
|
||||
$this->assertSame('style.css', $result);
|
||||
|
||||
$result = $this->th->findDefaultCSS('bootstrap5');
|
||||
$this->assertSame('https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.1.3/quartz/bootstrap.min.css', $result);
|
||||
|
||||
}
|
||||
/*
|
||||
public function testGetThemes()
|
||||
{
|
||||
|
||||
|
@ -114,8 +114,8 @@ cursor: help;
|
||||
|
||||
.e-image-radio label > input { visibility: hidden; position: absolute; }
|
||||
.e-image-radio label > input + div{ cursor:pointer; border:3px solid silver; border-radius:4px;/*height: 60px;padding: 5px;*/ vertical-align: middle; }
|
||||
.e-image-radio label > input:checked + div { border:3px solid #337ab7; }
|
||||
.e-image-radio label > input + div span { visibility: hidden; float:right; margin-right:10px; color:#337ab7 }
|
||||
.e-image-radio label > input:checked + div { border:3px solid rgb(91, 192, 222); }
|
||||
.e-image-radio label > input + div span { visibility: hidden; float:right; margin-right:10px; color:rgb(91, 192, 222) }
|
||||
.e-image-radio label > input:checked + div span { visibility: initial; }
|
||||
|
||||
|
||||
|
@ -26,10 +26,10 @@
|
||||
<library name="animate.css" scope="front" />
|
||||
</libraries>
|
||||
<stylesheets>
|
||||
<css file="style.css" name="Default" thumbnail='preview_frontend.png' scope='front' />
|
||||
<css file="style.css" name="Basic" thumbnail='preview_frontend.png' scope='front' />
|
||||
<css file="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.1.3/lux/bootstrap.min.css" name="Lux" thumbnail='images/lux.png' scope='front' exclude='bootstrap' />
|
||||
<css file="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.1.3/sketchy/bootstrap.min.css" name="Sketchy" thumbnail='images/sketchy.png' scope='front' exclude='bootstrap' />
|
||||
<css file="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.1.3/quartz/bootstrap.min.css" name="Quartz" thumbnail='images/quartz.png' scope='front' exclude='bootstrap' />
|
||||
<css file="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.1.3/quartz/bootstrap.min.css" default="true" name="Quartz" thumbnail='images/quartz.png' scope='front' exclude='bootstrap' />
|
||||
<css file="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.1.3/slate/bootstrap.min.css" name="Slate" thumbnail='images/slate.png' scope='front' exclude='bootstrap' />
|
||||
<css file="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.1.3/superhero/bootstrap.min.css" name="Superhero" thumbnail='images/superhero.png' scope='front' exclude='bootstrap' />
|
||||
</stylesheets>
|
||||
|
@ -7,8 +7,6 @@ $sitetheme = e107::getPref('sitetheme');
|
||||
e107::themeLan('admin', $sitetheme, true);
|
||||
|
||||
|
||||
|
||||
|
||||
class theme_config implements e_theme_config
|
||||
{
|
||||
|
||||
@ -20,41 +18,11 @@ class theme_config implements e_theme_config
|
||||
|
||||
function config()
|
||||
{
|
||||
// v2.2.2
|
||||
$bootswatch = array(
|
||||
"cerulean" => 'Cerulean',
|
||||
"cosmo" => 'Cosmo',
|
||||
"cyborg" => 'Cyborg',
|
||||
"darkly" => 'Darkly',
|
||||
"flatly" => 'Flatly',
|
||||
"journal" => 'Journal',
|
||||
"litera" => 'Litera',
|
||||
"lumen" => 'Lumen',
|
||||
"lux" => 'Lux',
|
||||
"materia" => 'Materia',
|
||||
"minty" => 'Minty',
|
||||
'morph' => 'Morph',
|
||||
"pulse" => 'Pulse',
|
||||
'quartz' => 'Quartz',
|
||||
"sandstone" => 'Sandstone',
|
||||
"simplex" => 'Simplex',
|
||||
"sketchy" => 'Sketchy',
|
||||
"slate" => 'Slate',
|
||||
"solar" => 'Solar',
|
||||
"spacelab" => 'Spacelab',
|
||||
"superhero" => 'Superhero',
|
||||
"united" => 'United',
|
||||
"yeti" => 'Yeti',
|
||||
'zephyr' => 'Zephyr',
|
||||
);
|
||||
|
||||
$previewLink = " <a class='btn btn-default btn-secondary e-modal' data-modal-caption=\"Use the 'Themes' menu to view the selection.\" href='http://bootswatch.com/default/'>".LAN_PREVIEW."</a>";
|
||||
|
||||
return array(
|
||||
//'bootswatch' => array('title'=>LAN_THEMEPREF_01, 'type'=>'dropdown', 'writeParms'=>array('optArray'=> $bootswatch, 'post'=>$previewLink, 'default'=>LAN_DEFAULT)),
|
||||
'cardmenu_look' => array('title' => LAN_THEMEPREF_02, 'type'=>'boolean', 'writeParms'=>array(),'help'=>''),
|
||||
'login_iframe' => array('title' => LAN_THEMEPREF_03, 'type'=>'boolean', 'writeParms'=>array(),'help'=>''),
|
||||
);
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user