mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-24 10:21:32 +01:00
New: add external theme with a module
This commit is contained in:
@@ -159,9 +159,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
{
|
||||
global $conf,$langs,$bc;
|
||||
|
||||
|
||||
$dirtheme=dol_buildpath($conf->global->MAIN_FORCETHEMEDIR.'/theme',0);
|
||||
$urltheme=dol_buildpath($conf->global->MAIN_FORCETHEMEDIR.'/theme',1);
|
||||
$dirthemes=array_merge(array($conf->global->MAIN_FORCETHEMEDIR.'/theme'),(array) $conf->modules_parts['themes']);
|
||||
|
||||
$selected_theme=$conf->global->MAIN_THEME;
|
||||
if (! empty($fuser)) $selected_theme=$fuser->conf->MAIN_THEME;
|
||||
@@ -216,47 +214,62 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
|
||||
print '<tr '.$bc[$var].'><td colspan="'.$colspan.'">';
|
||||
|
||||
print '<table class="nobordernopadding" width="100%">';
|
||||
$handle=opendir($dirtheme);
|
||||
|
||||
$i=0;
|
||||
while (($subdir = readdir($handle))!==false)
|
||||
|
||||
foreach($dirthemes as $dir)
|
||||
{
|
||||
if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
|
||||
&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
|
||||
{
|
||||
// Disable not stable themes
|
||||
//if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/bureau2crea/i',$subdir)) continue;
|
||||
|
||||
if ($i % $thumbsbyrow == 0)
|
||||
{
|
||||
print '<tr '.$bc[$var].'>';
|
||||
}
|
||||
|
||||
print '<td align="center">';
|
||||
$file=$dirtheme."/".$subdir."/thumb.png";
|
||||
$url=$urltheme."/".$subdir."/thumb.png";
|
||||
if (! file_exists($file)) $url=$urltheme."/common/nophoto.jpg";
|
||||
print '<table><tr><td>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST("optioncss")?'&optioncss='.GETPOST("optioncss",'alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
|
||||
if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
|
||||
else $title=$langs->trans("ShowPreview");
|
||||
print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'">';
|
||||
print '</a>';
|
||||
print '</td></tr><tr><td align="center">';
|
||||
if ($subdir == $selected_theme)
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
|
||||
}
|
||||
print '</td></tr></table></td>';
|
||||
|
||||
$i++;
|
||||
|
||||
if ($i % $thumbsbyrow == 0) print '</tr>';
|
||||
}
|
||||
$dirtheme=dol_buildpath($dir,0);
|
||||
$urltheme=dol_buildpath($dir,1);
|
||||
|
||||
if (is_dir($dirtheme))
|
||||
{
|
||||
$handle=opendir($dirtheme);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($subdir = readdir($handle))!==false)
|
||||
{
|
||||
if (is_dir($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
|
||||
&& substr($subdir, 0, 3) <> 'CVS' && ! preg_match('/common|phones/i',$subdir))
|
||||
{
|
||||
// Disable not stable themes
|
||||
//if ($conf->global->MAIN_FEATURES_LEVEL < 1 && preg_match('/bureau2crea/i',$subdir)) continue;
|
||||
|
||||
if ($i % $thumbsbyrow == 0)
|
||||
{
|
||||
print '<tr '.$bc[$var].'>';
|
||||
}
|
||||
|
||||
print '<td align="center">';
|
||||
$file=$dirtheme."/".$subdir."/thumb.png";
|
||||
$url=$urltheme."/".$subdir."/thumb.png";
|
||||
if (! file_exists($file)) $url=$urltheme."/common/nophoto.jpg";
|
||||
print '<table><tr><td>';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].($edit?'?action=edit&theme=':'?theme=').$subdir.(GETPOST("optioncss")?'&optioncss='.GETPOST("optioncss",'alpha',1):'').($fuser?'&id='.$fuser->id:'').'" style="font-weight: normal;" alt="'.$langs->trans("Preview").'">';
|
||||
if ($subdir == $conf->global->MAIN_THEME) $title=$langs->trans("ThemeCurrentlyActive");
|
||||
else $title=$langs->trans("ShowPreview");
|
||||
print '<img src="'.$url.'" border="0" width="80" height="60" alt="'.$title.'" title="'.$title.'">';
|
||||
print '</a>';
|
||||
print '</td></tr><tr><td align="center">';
|
||||
if ($subdir == $selected_theme)
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" checked name="main_theme" value="'.$subdir.'"> <b>'.$subdir.'</b>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input '.($edit?'':'disabled').' type="radio" '.$bc[$var].' style="border: 0px;" name="main_theme" value="'.$subdir.'"> '.$subdir;
|
||||
}
|
||||
print '</td></tr></table></td>';
|
||||
|
||||
$i++;
|
||||
|
||||
if ($i % $thumbsbyrow == 0) print '</tr>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($i % $thumbsbyrow != 0)
|
||||
{
|
||||
while ($i % $thumbsbyrow != 0)
|
||||
|
||||
Reference in New Issue
Block a user