admin: change global theme settings

This commit is contained in:
Fabio Comuni 2012-04-13 11:20:05 +02:00
parent 8be7b5c65b
commit 138a0e06b8
3 changed files with 74 additions and 10 deletions

View File

@ -40,6 +40,20 @@ function admin_post(&$a){
goaway($a->get_baseurl(true) . '/admin/plugins/' . $a->argv[2] ); goaway($a->get_baseurl(true) . '/admin/plugins/' . $a->argv[2] );
return; // NOTREACHED return; // NOTREACHED
break; break;
case 'themes':
$theme = $a->argv[2];
if (is_file("view/theme/$theme/config.php")){
require_once("view/theme/$theme/config.php");
if (function_exists("theme_admin_post")){
theme_admin_post($a);
}
}
info(t('Theme settings updated.'));
if(is_ajax()) return;
goaway($a->get_baseurl(true) . '/admin/themes/' . $theme );
return;
break;
case 'logs': case 'logs':
admin_page_logs_post($a); admin_page_logs_post($a);
break; break;
@ -129,7 +143,13 @@ function admin_content(&$a) {
} else { } else {
$o = admin_page_summary($a); $o = admin_page_summary($a);
} }
return $o;
if(is_ajax()) {
echo $o;
killme();
} else {
return $o;
}
} }
@ -362,7 +382,7 @@ function admin_page_site(&$a) {
'$sitename' => array('sitename', t("Site name"), htmlentities($a->config['sitename'], ENT_QUOTES), ""), '$sitename' => array('sitename', t("Site name"), htmlentities($a->config['sitename'], ENT_QUOTES), ""),
'$banner' => array('banner', t("Banner/Logo"), $banner, ""), '$banner' => array('banner', t("Banner/Logo"), $banner, ""),
'$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices), '$language' => array('language', t("System language"), get_config('system','language'), "", $lang_choices),
'$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles"), $theme_choices), '$theme' => array('theme', t("System theme"), get_config('system','theme'), t("Default system theme - may be over-ridden by user profiles - <a href='#' id='cnftheme'>change theme settings</a>"), $theme_choices),
'$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices), '$ssl_policy' => array('ssl_policy', t("SSL link policy"), (string) intval(get_config('system','ssl_policy')), t("Determines whether generated links should be forced to use SSL"), $ssl_choices),
'$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")), '$maximagesize' => array('maximagesize', t("Maximum image size"), get_config('system','maximagesize'), t("Maximum size in bytes of uploaded images. Default is 0, which means no limits.")),
@ -768,14 +788,22 @@ function admin_page_themes(&$a){
} }
$readme=Null; $readme=Null;
if (is_file("view/$theme/README.md")){ if (is_file("view/theme/$theme/README.md")){
$readme = file_get_contents("view/$theme/README.md"); $readme = file_get_contents("view/theme/$theme/README.md");
$readme = Markdown($readme); $readme = Markdown($readme);
} else if (is_file("view/$theme/README")){ } else if (is_file("view/theme/$theme/README")){
$readme = "<pre>". file_get_contents("view/$theme/README") ."</pre>"; $readme = "<pre>". file_get_contents("view/theme/$theme/README") ."</pre>";
} }
$admin_form=""; $admin_form="";
if (is_file("view/theme/$theme/config.php")){
require_once("view/theme/$theme/config.php");
if(function_exists("theme_admin")){
$admin_form = theme_admin($a);
}
}
$screenshot = array( get_theme_screenshot($theme), t('Screenshot')); $screenshot = array( get_theme_screenshot($theme), t('Screenshot'));
if(! stristr($screenshot[0],$theme)) if(! stristr($screenshot[0],$theme))
@ -793,10 +821,10 @@ function admin_page_themes(&$a){
'$status' => $status, '$status' => $status,
'$action' => $action, '$action' => $action,
'$info' => get_theme_info($theme), '$info' => get_theme_info($theme),
'$function' => 'themes', '$function' => 'themes',
'$admin_form' => $admin_form, '$admin_form' => $admin_form,
'$str_author' => t('Author: '), '$str_author' => t('Author: '),
'$str_maintainer' => t('Maintainer: '), '$str_maintainer' => t('Maintainer: '),
'$screenshot' => $screenshot, '$screenshot' => $screenshot,
'$readme' => $readme '$readme' => $readme
)); ));
@ -805,7 +833,7 @@ function admin_page_themes(&$a){
/** /**
* List plugins * List themes
*/ */
$xthemes = array(); $xthemes = array();

View File

@ -17,7 +17,7 @@
</p> </p>
{{ if $screenshot }} {{ if $screenshot }}
<a href="$screenshot.0" ><img src="$screenshot.0" width="320" height="240" alt="$screenshot.1" /></a> <a href="$screenshot.0" class='screenshot'><img src="$screenshot.0" alt="$screenshot.1" /></a>
{{ endif }} {{ endif }}
{{ if $admin_form }} {{ if $admin_form }}

View File

@ -1,3 +1,39 @@
<script>
$(function(){
$("#cnftheme").fancybox({
width: 800,
autoDimensions: false,
onStart: function(){
var theme = $("#id_theme :selected").val();
$("#cnftheme").attr('href',"$baseurl/admin/themes/"+theme);
},
onComplete: function(){
$("div#fancybox-content form").submit(function(e){
var url = $(this).attr('action');
// can't get .serialize() to work...
var data={};
$(this).find("input").each(function(){
data[$(this).attr('name')] = $(this).val();
});
$(this).find("select").each(function(){
data[$(this).attr('name')] = $(this).children(":selected").val();
});
console.log(":)", url, data);
$.post(url, data, function(data) {
if(timer) clearTimeout(timer);
NavUpdate();
$.fancybox.close();
})
return false;
});
}
});
});
</script>
<div id='adminpage'> <div id='adminpage'>
<h1>$title - $page</h1> <h1>$title - $page</h1>