mirror of
https://github.com/e107inc/e107.git
synced 2025-07-27 01:40:22 +02:00
Fixes #2392 - Theme-Manager > Tools > Create (ie. theme-copy tool) updated to work with libraries, layouts, prefs etc.
This commit is contained in:
@@ -818,7 +818,7 @@ class theme_admin_ui extends e_admin_ui
|
|||||||
|
|
||||||
public function ChoosePage()
|
public function ChoosePage()
|
||||||
{
|
{
|
||||||
e107::getTheme()->clearCache();
|
e107::getTheme('front', true); // clear cache and reload from disk.
|
||||||
return $this->GridPage();
|
return $this->GridPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1267,7 +1267,6 @@ class theme_builder extends e_admin_ui
|
|||||||
if(vartrue($_GET['step']) == 3)
|
if(vartrue($_GET['step']) == 3)
|
||||||
{
|
{
|
||||||
return $this->step3();
|
return $this->step3();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(vartrue($_GET['step']) == 2)
|
if(vartrue($_GET['step']) == 2)
|
||||||
@@ -1360,8 +1359,6 @@ class theme_builder extends e_admin_ui
|
|||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'main' => array('name','lang','version','date', 'compatibility'),
|
'main' => array('name','lang','version','date', 'compatibility'),
|
||||||
'author' => array('name','url'),
|
'author' => array('name','url'),
|
||||||
@@ -1372,7 +1369,10 @@ class theme_builder extends e_admin_ui
|
|||||||
'category' => array('category'),
|
'category' => array('category'),
|
||||||
'livedemo' => array('livedemo'),
|
'livedemo' => array('livedemo'),
|
||||||
'copyright' => array('copyright'),
|
'copyright' => array('copyright'),
|
||||||
'stylesheets' => array('stylesheets')
|
// 'libraries' => array('libraries'),
|
||||||
|
// 'layouts' => array('layouts'),
|
||||||
|
// 'stylesheets' => array('stylesheets'),
|
||||||
|
|
||||||
// 'adminLinks' => array('url','description','icon','iconSmall','primary'),
|
// 'adminLinks' => array('url','description','icon','iconSmall','primary'),
|
||||||
// 'sitelinks' => array('url','description','icon','iconSmall')
|
// 'sitelinks' => array('url','description','icon','iconSmall')
|
||||||
);
|
);
|
||||||
@@ -1531,6 +1531,55 @@ class theme_builder extends e_admin_ui
|
|||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
|
$newArray = array(
|
||||||
|
'LIBRARIES' => '',
|
||||||
|
'PREFS' => '',
|
||||||
|
'STYLESHEETS' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
$LAYOUTS = '';
|
||||||
|
|
||||||
|
$source = e107::getTheme($this->themeSrc)->get();
|
||||||
|
|
||||||
|
if(!empty($source['library']))
|
||||||
|
{
|
||||||
|
$newArray['LIBRARIES'] = '<libraries>';
|
||||||
|
|
||||||
|
foreach($source['library'] as $val)
|
||||||
|
{
|
||||||
|
$newArray['LIBRARIES'] .= "\n\t\t".'<library name="'.$val['name'].'" version="'.$val['version'].'" scope="'.$val['scope'].'"/>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$newArray['LIBRARIES'] .= "\n\t</libraries>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($source['preferences']))
|
||||||
|
{
|
||||||
|
$newArray['PREFS'] = "\n\t<themePrefs>";
|
||||||
|
|
||||||
|
foreach($source['preferences'] as $key=>$val)
|
||||||
|
{
|
||||||
|
$newArray['PREFS'] .= "\n\t\t".'<pref name="'.$key.'">'.$val.'</pref>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$newArray['PREFS'] .= "\n\t</themePrefs>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($source['css']))
|
||||||
|
{
|
||||||
|
$newArray['STYLESHEETS'] = "\n\t<stylesheets>";
|
||||||
|
|
||||||
|
foreach($source['css'] as $val)
|
||||||
|
{
|
||||||
|
$newArray['STYLESHEETS'] .= "\n\t\t".'<css file="'.$val['name'].'" name="'.$val['info'].'" scope="'.$val['scope'].'"';
|
||||||
|
$newArray['STYLESHEETS'] .= !empty($val['exclude']) ? ' exclude="'.$val['exclude'].'"' : '';
|
||||||
|
$newArray['STYLESHEETS'] .= ' />';
|
||||||
|
}
|
||||||
|
|
||||||
|
$newArray['STYLESHEETS'] .= "\n\t</stylesheets>";
|
||||||
|
}
|
||||||
|
|
||||||
|
// customized data.
|
||||||
foreach($data as $key=>$val)
|
foreach($data as $key=>$val)
|
||||||
{
|
{
|
||||||
$key = strtoupper(str_replace("-","_",$key));
|
$key = strtoupper(str_replace("-","_",$key));
|
||||||
@@ -1544,41 +1593,26 @@ class theme_builder extends e_admin_ui
|
|||||||
$LAYOUTS .= " <custompages>{CUSTOMPAGES}</custompages>\n";
|
$LAYOUTS .= " <custompages>{CUSTOMPAGES}</custompages>\n";
|
||||||
$LAYOUTS .= " </layout>";
|
$LAYOUTS .= " </layout>";
|
||||||
}
|
}
|
||||||
else
|
elseif(!empty($source['layouts']))
|
||||||
{
|
{
|
||||||
$LAYOUTS = "";
|
foreach($source['layouts'] as $name=>$val)
|
||||||
}
|
|
||||||
|
|
||||||
if(!empty($newArray['STYLESHEETS_STYLESHEETS']))
|
|
||||||
{
|
|
||||||
$STYLESHEETS = '';
|
|
||||||
foreach($newArray['STYLESHEETS_STYLESHEETS'] as $val)
|
|
||||||
{
|
{
|
||||||
if(empty($val['file']))
|
$LAYOUTS .= "\n\t\t<layout name=\"".$name."\" title=\"".varset($val['@attributes']['title'])."\"";
|
||||||
{
|
$LAYOUTS .= !empty($val['@attributes']['default']) ? ' default="'.$val['@attributes']['default'].'"' : '';
|
||||||
continue;
|
$LAYOUTS .= ">\n";
|
||||||
}
|
$LAYOUTS .= "\t\t\t<custompages>".varset($val['custompages'])."</custompages>\n";
|
||||||
|
$LAYOUTS .= "\t\t</layout>";
|
||||||
$STYLESHEETS .= "\t\t<css file=\"".$val['file']."\" name=\"".$val['name']."\" />\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($STYLESHEETS))
|
|
||||||
{
|
|
||||||
$STYLESHEETS = "\n\t<stylesheets>\n".$STYLESHEETS."\t</stylesheets>";
|
|
||||||
}
|
|
||||||
|
|
||||||
unset($newArray['STYLESHEETS_STYLESHEETS']);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$STYLESHEETS = "";
|
$LAYOUTS = "<layout name='default' title='Default' default='true' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
$newArray['STYLESHEETS'] = $STYLESHEETS;
|
|
||||||
|
|
||||||
|
$newArray['MAIN_DATE'] = date('Y-m-d', $newArray['MAIN_DATE']);
|
||||||
// print_a($newArray);
|
// print_a($newArray);
|
||||||
|
|
||||||
|
|
||||||
$template = <<<TEMPLATE
|
$template = <<<TEMPLATE
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<e107Theme name="{MAIN_NAME}" lan="{MAIN_LANG}" version="{MAIN_VERSION}" date="{MAIN_DATE}" compatibility="{MAIN_COMPATIBILITY}" livedemo="{LIVEDEMO_LIVEDEMO}">
|
<e107Theme name="{MAIN_NAME}" lan="{MAIN_LANG}" version="{MAIN_VERSION}" date="{MAIN_DATE}" compatibility="{MAIN_COMPATIBILITY}" livedemo="{LIVEDEMO_LIVEDEMO}">
|
||||||
@@ -1595,9 +1629,9 @@ $template = <<<TEMPLATE
|
|||||||
<image>preview.jpg</image>
|
<image>preview.jpg</image>
|
||||||
<image>fullpreview.jpg</image>
|
<image>fullpreview.jpg</image>
|
||||||
</screenshots>{STYLESHEETS}
|
</screenshots>{STYLESHEETS}
|
||||||
<layouts>
|
{LIBRARIES}
|
||||||
<layout name='default' title='Default' default='true' />{LAYOUTS}
|
<layouts>{LAYOUTS}
|
||||||
</layouts>
|
</layouts>{PREFS}
|
||||||
</e107Theme>
|
</e107Theme>
|
||||||
TEMPLATE;
|
TEMPLATE;
|
||||||
|
|
||||||
@@ -1619,6 +1653,7 @@ TEMPLATE;
|
|||||||
if(file_put_contents($path,$result))
|
if(file_put_contents($path,$result))
|
||||||
{
|
{
|
||||||
$mes->addSuccess("Saved: ".$path);
|
$mes->addSuccess("Saved: ".$path);
|
||||||
|
e107::getTheme('front', true); // clear cache and reload.
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1749,18 +1784,27 @@ TEMPLATE;
|
|||||||
{
|
{
|
||||||
|
|
||||||
case 'stylesheets':
|
case 'stylesheets':
|
||||||
$fl = e107::getFile();
|
// $fl = e107::getFile();
|
||||||
|
|
||||||
$fl->setMode('full');
|
$source = e107::getTheme($this->themeSrc)->get();
|
||||||
$stylesheets = $fl->get_files(e_THEME.$this->themeName."/", "\.css", null, 1);
|
var_dump($source['css']);
|
||||||
foreach($stylesheets as $key=>$path)
|
// $fl->setMode('full');
|
||||||
|
// $stylesheets = $fl->get_files(e_THEME.$this->themeName."/", "\.css", null, 1);
|
||||||
|
|
||||||
|
|
||||||
|
foreach($source['css'] as $key=>$var)
|
||||||
{
|
{
|
||||||
$file = str_replace(e_THEME.$this->themeName."/",'',$path);
|
$file = $var['name'];
|
||||||
|
$default = varset($var['info']);
|
||||||
|
|
||||||
$text .= "<div class='row-fluid'>";
|
$text .= "<div class='row-fluid'>";
|
||||||
$text .= "<div class='controls'>";
|
$text .= "<div class='controls'>";
|
||||||
$text .= "<div class='col-md-3'>".$frm->checkbox($name.'['.$key.'][file]',$file, false, array('label'=>$file))."
|
$text .= "<div class='col-md-3'>".$frm->checkbox($name.'['.$key.'][file]',$file, false, array('label'=>$file))."
|
||||||
<div class='field-help'>".TPVLAN_CONV_14."</div></div>";
|
<div class='field-help'>".TPVLAN_CONV_14."</div></div>";
|
||||||
$text .= "<div class='col-md-3'>".$frm->text($name.'['.$key.'][name]', $default, $size, 'placeholder='.$file . $req. $pat)."
|
$text .= "<div class='col-md-3'>"
|
||||||
|
.$frm->text($name.'['.$key.'][name]', $default, $size, 'placeholder='.$file . $req. $pat)
|
||||||
|
.$frm->hidden($name.'['.$key.'][scope]', $var['scope'], $size, 'placeholder='.$file . $req. $pat).
|
||||||
|
"
|
||||||
<div class='field-help'>".TPVLAN_CONV_15."</div></div>";
|
<div class='field-help'>".TPVLAN_CONV_15."</div></div>";
|
||||||
// $text .= "<div class='span2'>".$frm->checkbox('css['.$key.'][file]',$file, false, array('label'=>$file))."</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 class='span2'>".$frm->text('css['.$key.'][name]', $default, $size, 'placeholder='.$placeholder . $req. $pat)."</div>";
|
||||||
@@ -1800,8 +1844,8 @@ TEMPLATE;
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$text .= ($help) ? "<span class='field-help'>".$help."</span>" : "";
|
$text .= ($help) ? "<span class='field-help'>".$help."</span>" : "";
|
||||||
|
// $text .= ($help) ? $frm->help($help) : '';
|
||||||
return $text;
|
return $text;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user