mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
theme.xml now include <stylesheet> tags for determining which stylesheets should be options in the theme-manager.
Theme-Convert updated to include <stylesheet> tags.
This commit is contained in:
parent
50e71fb6a6
commit
8d7971ec69
@ -317,6 +317,9 @@ class theme_builder
|
||||
$mes = e107::getMessage();
|
||||
$frm = e107::getForm();
|
||||
|
||||
|
||||
|
||||
|
||||
$data = array(
|
||||
'main' => array('name','lang','version','date', 'compatibility'),
|
||||
'author' => array('name','url'),
|
||||
@ -324,7 +327,8 @@ class theme_builder
|
||||
'description' => array('description'),
|
||||
'keywords' => array('one','two'),
|
||||
'category' => array('category'),
|
||||
'copyright' => array('copyright')
|
||||
'copyright' => array('copyright'),
|
||||
'stylesheets' => array('stylesheets')
|
||||
// 'adminLinks' => array('url','description','icon','iconSmall','primary'),
|
||||
// 'sitelinks' => array('url','description','icon','iconSmall')
|
||||
);
|
||||
@ -473,7 +477,7 @@ class theme_builder
|
||||
if(vartrue($newArray['CUSTOMPAGES']))
|
||||
{
|
||||
$newArray['CUSTOMPAGES'] = trim($newArray['CUSTOMPAGES']);
|
||||
$LAYOUTS = "<layout name='custom' title='Custom'>\n";
|
||||
$LAYOUTS = "\n<layout name='custom' title='Custom'>\n";
|
||||
$LAYOUTS .= " <custompages>{CUSTOMPAGES}</custompages>\n";
|
||||
$LAYOUTS .= " </layout>";
|
||||
}
|
||||
@ -482,6 +486,26 @@ class theme_builder
|
||||
$LAYOUTS = "";
|
||||
}
|
||||
|
||||
if(vartrue($newArray['STYLESHEETS_STYLESHEETS']))
|
||||
{
|
||||
$STYLESHEETS = "\n\t<stylesheets>\n";
|
||||
foreach($newArray['STYLESHEETS_STYLESHEETS'] as $val)
|
||||
{
|
||||
$STYLESHEETS .= "\t\t<css file=\"".$val['file']."\" name=\"".$val['name']."\" />\n";
|
||||
}
|
||||
$STYLESHEETS .= "\t</stylesheets>";
|
||||
|
||||
unset($newArray['STYLESHEETS_STYLESHEETS']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$STYLESHEETS = "";
|
||||
}
|
||||
|
||||
$newArray['STYLESHEETS'] = $STYLESHEETS;
|
||||
|
||||
// print_a($newArray);
|
||||
|
||||
|
||||
$template = <<<TEMPLATE
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
@ -498,10 +522,9 @@ $template = <<<TEMPLATE
|
||||
<screenshots>
|
||||
<image>preview.jpg</image>
|
||||
<image>fullpreview.jpg</image>
|
||||
</screenshots>
|
||||
</screenshots>{STYLESHEETS}
|
||||
<layouts>
|
||||
<layout name='default' title='Default' default='true' />
|
||||
{LAYOUTS}
|
||||
<layout name='default' title='Default' default='true' />{LAYOUTS}
|
||||
</layouts>
|
||||
</e107Theme>
|
||||
TEMPLATE;
|
||||
@ -512,6 +535,15 @@ TEMPLATE;
|
||||
$result = e107::getParser()->simpleParse($template, $newArray);
|
||||
$path = e_THEME.$this->themeName."/theme.xml";
|
||||
|
||||
|
||||
if(E107_DEBUG_LEVEL > 0)
|
||||
{
|
||||
$mes->addDebug("Debug Mode active - no file saved. ");
|
||||
return htmlentities($result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(file_put_contents($path,$result))
|
||||
{
|
||||
$mes->addSuccess("Saved: ".$path);
|
||||
@ -530,7 +562,7 @@ TEMPLATE;
|
||||
|
||||
|
||||
|
||||
function xmlInput($name, $info, $default='')
|
||||
function xmlInput($name, $info, $default='')
|
||||
{
|
||||
$frm = e107::getForm();
|
||||
list($cat,$type) = explode("-",$info);
|
||||
@ -633,6 +665,32 @@ TEMPLATE;
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
|
||||
case 'stylesheets':
|
||||
$fl = e107::getFile();
|
||||
|
||||
$fl->setMode('full');
|
||||
$stylesheets = $fl->get_files(e_THEME.$this->themeName."/", "\.css", $reject, 1);
|
||||
foreach($stylesheets as $key=>$path)
|
||||
{
|
||||
$file = str_replace(e_THEME.$this->themeName."/",'',$path);
|
||||
$text .= "<div class='row-fluid'>";
|
||||
$text .= "<div class='controls'>";
|
||||
$text .= "<div class='span3'>".$frm->checkbox($name.'['.$key.'][file]',$file, false, array('label'=>$file))."
|
||||
<div class='field-help'>Enable this stylesheet as a selectable option in the Theme Manager.</div></div>";
|
||||
$text .= "<div class='span3'>".$frm->text($name.'['.$key.'][name]', $default, $size, 'placeholder='.$file . $req. $pat)."
|
||||
<div class='field-help'>Give this stylesheet a name</div></div>";
|
||||
// $text .= "<div class='span2'>".$frm->checkbox('css['.$key.'][file]',$file, false, array('label'=>$file))."</div>";
|
||||
// $text .= "<div class='span2'>".$frm->text('css['.$key.'][name]', $default, $size, 'placeholder='.$placeholder . $req. $pat)."</div>";
|
||||
$text .= "</div>";
|
||||
$text .= "</div>";
|
||||
}
|
||||
|
||||
|
||||
return $text;
|
||||
break;
|
||||
|
||||
|
||||
case 'date':
|
||||
$text = $frm->datepicker($name, time(), 'format=yyyy-mm-dd'.$req);
|
||||
break;
|
||||
|
@ -217,59 +217,45 @@ class themeHandler
|
||||
|
||||
function getThemeInfo($file)
|
||||
{
|
||||
$STYLESHEET = FALSE;
|
||||
|
||||
$mes = e107::getMessage();
|
||||
|
||||
$reject = array('e_.*');
|
||||
|
||||
$handle2 = e107::getFile()->get_files(e_THEME.$file."/", ".php|.css|.xml|preview.jpg|preview.png", $reject, 1);
|
||||
|
||||
$handle2 = e107::getFile()->get_files(e_THEME.$file."/", "\.php|\.css|\.xml|preview\.jpg|preview\.png", $reject, 1);
|
||||
|
||||
foreach ($handle2 as $fln)
|
||||
{
|
||||
$file2 = str_replace(e_THEME.$file."/", "", $fln['path']).$fln['fname'];
|
||||
|
||||
$themeArray[$file]['files'][] = $file2;
|
||||
|
||||
if(strstr($file2, "preview."))
|
||||
{
|
||||
$themeArray[$file]['preview'] = e_THEME.$file."/".$file2;
|
||||
}
|
||||
|
||||
// ---------------- get information string for css file
|
||||
// ---------------- get information string for css file - Legacy mode (no theme.xml)
|
||||
|
||||
if(strstr($file2, "css") && !strstr($file2, "menu.css") && strpos($file2, "e_") !== 0)
|
||||
if(strstr($file2, ".css") && !strstr($file2, "menu.css") && strpos($file2, "e_") !== 0)
|
||||
{
|
||||
if($cssContents = file_get_contents(e_THEME.$file."/".$file2))
|
||||
{
|
||||
$nonadmin = preg_match('/\* Non-Admin(.*?)\*\//', $cssContents) ? true : false;
|
||||
preg_match('/\* info:(.*?)\*\//', $cssContents, $match);
|
||||
$match[1] = varset($match[1], '');
|
||||
$themeArray[$file]['css'][] = array("name"=>$file2,
|
||||
"info"=>$match[1],
|
||||
"nonadmin"=>$nonadmin);
|
||||
if($STYLESHEET)
|
||||
{
|
||||
$themeArray[$file]['multipleStylesheets'] = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$STYLESHEET = TRUE;
|
||||
}
|
||||
$themeArray[$file]['css'][] = array("name"=>$file2, "info"=>$match[1], "nonadmin"=>$nonadmin);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// $mes->addDebug("Couldn't read file: ".e_THEME.$file."/".$file2);
|
||||
// $mes->addDebug("Couldn't read file: ".e_THEME.$file."/".$file2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} // end while..
|
||||
|
||||
|
||||
// echo "<hr />";
|
||||
// closedir($handle2);
|
||||
// Load Theme information and merge with existing array. theme.xml (v2.x theme) is given priority over theme.php (v1.x).
|
||||
|
||||
// Load Theme information and merge with existing array. theme.xml (0.8 themes) is given priority over theme.php (0.7).
|
||||
if(in_array("theme.xml", $themeArray[$file]['files']))
|
||||
{
|
||||
$themeArray[$file] = array_merge($themeArray[$file], $this->parse_theme_xml($file));
|
||||
@ -279,7 +265,11 @@ class themeHandler
|
||||
$themeArray[$file] = array_merge($themeArray[$file], $this->parse_theme_php($file));
|
||||
}
|
||||
|
||||
|
||||
if(count($themeArray[$file]['css']) > 1)
|
||||
{
|
||||
$themeArray[$file]['multipleStylesheets'] = TRUE;
|
||||
}
|
||||
|
||||
return $themeArray[$file];
|
||||
|
||||
|
||||
@ -1937,6 +1927,22 @@ class themeHandler
|
||||
$vars['layouts'] = $lays;
|
||||
$vars['path'] = $path;
|
||||
$vars['custompages'] = $custom;
|
||||
|
||||
if(vartrue($vars['stylesheets']['css']))
|
||||
{
|
||||
$vars['css'] = array();
|
||||
|
||||
foreach($vars['stylesheets']['css'] as $val)
|
||||
{
|
||||
$notadmin = vartrue($val['@attributes']['admin']) ? false : true;
|
||||
|
||||
$vars['css'][] = array("name" => $val['@attributes']['file'], "info"=> $val['@attributes']['name'], "nonadmin"=>$notadmin);
|
||||
}
|
||||
|
||||
unset($vars['stylesheets']);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
$mes = e107::getMessage(); // DEBUG
|
||||
|
||||
|
9
e107_themes/bootstrap/css/superhero.css
Normal file
9
e107_themes/bootstrap/css/superhero.css
Normal file
File diff suppressed because one or more lines are too long
BIN
e107_themes/bootstrap/img/glyphicons-halflings-white.png
Normal file
BIN
e107_themes/bootstrap/img/glyphicons-halflings-white.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.6 KiB |
BIN
e107_themes/bootstrap/img/glyphicons-halflings.png
Normal file
BIN
e107_themes/bootstrap/img/glyphicons-halflings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
@ -12,6 +12,12 @@
|
||||
<image>preview.jpg</image>
|
||||
<image>fullpreview.jpg</image>
|
||||
</screenshots>
|
||||
<stylesheets>
|
||||
<css file="style.css" name="Default" />
|
||||
<css file="css/superhero.css" name="Superhero" />
|
||||
<css file="admin_light.css" name="Light" admin="true" />
|
||||
<css file="admin_dark.css" name="Dark" admin="true" />
|
||||
</stylesheets>
|
||||
<layouts>
|
||||
<layout name='default' title='Default' default='true' />
|
||||
<layout name='default-home' title='Default Home'>
|
||||
|
Loading…
x
Reference in New Issue
Block a user