[vhffs-dev] [829] Moved themesdir and default_theme to <panel> block instead of global block

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 829
Author:   gradator
Date:     2007-08-30 13:58:31 +0000 (Thu, 30 Aug 2007)

Log Message:
-----------
Moved themesdir and default_theme to <panel> block instead of global block
Created some accessors to main parts of the configuration

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Conf.pm
    trunk/vhffs-api/src/Vhffs/Panel/Main.pm
    trunk/vhffs-api/src/Vhffs/Panel/User.pm
    trunk/vhffs-backend/conf/vhffs.conf.dist.in
    trunk/vhffs-tests/conf/vhffs.conf


Modified: trunk/vhffs-api/src/Vhffs/Conf.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Conf.pm	2007-08-30 13:34:47 UTC (rev 828)
+++ trunk/vhffs-api/src/Vhffs/Conf.pm	2007-08-30 13:58:31 UTC (rev 829)
@@ -81,25 +81,41 @@
     return \%Config;
 }
 
+
 #return a reference to a hash with the configuration of the backend
-sub get_backend
+sub get_global
 {
-    return $Config{"backend"};
+	return $Config{'global'};
 }
 
+sub get_panel
+{
+	return $Config{'global'}{'panel'};
+}
 
+sub get_backend
+{
+	return $Config{'backend'};
+}
+
 sub get_database
 {
-    return $Config{"database"};
+	return $Config{'database'};
 }
 
+sub get_users
+{
+	return $Config{'users'};
+}
 
+sub get_group
+{
+	return $Config{'group'};
+}
 
-
-#return the host configuration
-sub get_host
+sub get_listengine
 {
-    return $Config{"host"};
+	return $Config{'listengine'};
 }
 
 
@@ -108,13 +124,9 @@
 # if not, it returns the whole configuration for all services
 sub get_service
 {
-    my $service;
-    my $self;
-    ($self , $service ) = @_;
-
-    return $Config{"services"}{$service} if( defined $service ) ;
-
-    return $Config{"services"};    
+	my ( $self , $service ) = @_;
+	return $Config{"services"}{$service} if( defined $service );
+	return $Config{"services"};    
 }
 
 
@@ -127,6 +139,9 @@
 }
 
 
+
+
+
 sub get_default_apache_domain
 {
 	my $self = shift;
@@ -164,17 +179,7 @@
     }
 }
 
-sub get_users
-{
-    return $Config{"users"};    
-}
 
-sub get_group
-{
-    return $Config{"group"};    
-}
-
-
 #Open the file of bad username, fill a table with them and return a reference to it
 sub get_bad_username
 {
@@ -265,12 +270,6 @@
 }
 
 
-sub get_default_theme
-{
-        return $Config{"global"}{"default_theme"};
-}
-
-
 sub get_intldir
 {
     return $Config{"global"}{"intldir"};
@@ -368,18 +367,6 @@
 }
 
 
-sub get_themesdir
-{
-	if( defined $Config{"global"}{"themesdir"} )
-	{
-		return $Config{"global"}{"themesdir"};
-	}
-	else
-	{
-		return undef;
-	}
-}
-
 sub get_panel_public
 {
 	if( $Config{"global"}{"panel"}{use_public} )
@@ -547,12 +534,6 @@
 }
 
 
-sub get_listengine
-{
-	return $Config{'listengine'};
-}
-
-
 sub get_cvsweburl
 {
 	if( defined $Config{"services"}{"cvs"}{"cvsweb_url"} )

Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2007-08-30 13:34:47 UTC (rev 828)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm	2007-08-30 13:58:31 UTC (rev 829)
@@ -165,18 +165,15 @@
 sub list_themes
 {
 	my $vhffs = shift;
-	return -1 if( ! defined $vhffs );
+	return -1 unless defined $vhffs;
 
 	my @themes;
 	
-	my $dir = $vhffs->get_config->get_themesdir;
+	my $dir = $vhffs->get_config->get_panel->{'themesdir'};
+	return undef unless defined $dir;
 
-	return undef if( ! ( defined $dir ) );
-
 	opendir( DIR , $dir) or return -2;
-	
 	my @files = readdir( DIR );
-
 	foreach( @files )
 	{
 		next if( /\./);
@@ -187,7 +184,6 @@
 	}
 
 	closedir( DIR );
-
 	return @themes;
 }
 
@@ -202,11 +198,11 @@
 	$vhffs = shift;
 	$cgi = shift;
 
-	$theme = $cgi->param( "theme" ) if ( defined $cgi );
-	$cookie = CGI->cookie( -name=>"theme", -value=>$theme, -expires=>'+10y' ) if ( defined $theme );
-	$theme = CGI->cookie( "theme" ) if ( ! defined $theme );
-	$theme = $vhffs->get_config->get_default_theme() if ( ! defined $theme );
-	$theme = "vhffs" if ( ! defined $theme  ||  ! -f $vhffs->get_config->get_themesdir . "/" . $theme . "/main.css" );
+	$theme = $cgi->param( 'theme' ) if defined $cgi;
+	$cookie = CGI->cookie( -name=>'theme', -value=>$theme, -expires=>'+10y' ) if defined $theme;
+	$theme = CGI->cookie( 'theme' ) unless defined $theme;
+	$theme = $vhffs->get_config->get_panel->{'default_theme'} unless defined $theme;
+	$theme = 'vhffs' unless( defined $theme  &&  -f $vhffs->get_config->get_panel->{'themesdir'}.'/'.$theme.'/main.css' );
 
 	return ( $theme, $cookie );
 }
@@ -622,7 +618,7 @@
 
     # Allows each theme to have its own Jscripts
 
-    my $jsglob = File::Spec->catfile($config->get_themesdir(), $theme, '/js/*.js');
+    my $jsglob = File::Spec->catfile($config->get_panel->{'themesdir'}, $theme, '/js/*.js');
     my $jswebpath = "/themes/$theme/js/";
     my @jscripts;
     # Common scripts
@@ -723,7 +719,7 @@
 
     # Allows each theme to have its own Jscripts
 
-    my $jsglob = File::Spec->catfile($panel->{config}->get_themesdir(), $theme, '/js/*.js');
+    my $jsglob = File::Spec->catfile($panel->{config}->get_panel->{'themesdir'}, $theme, '/js/*.js');
     my $jswebpath = "/themes/$theme/js/";
     my @jscripts;
     # Common scripts

Modified: trunk/vhffs-api/src/Vhffs/Panel/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/User.pm	2007-08-30 13:34:47 UTC (rev 828)
+++ trunk/vhffs-api/src/Vhffs/Panel/User.pm	2007-08-30 13:58:31 UTC (rev 829)
@@ -160,7 +160,7 @@
 	my $user = shift;
 	return -1 if( ! defined $user );
 	my $theme = $user->get_theme;
-	$theme = $user->get_main->get_config->get_default_theme unless(defined $theme);
+	$theme = $user->get_main->get_config->get_panel->{'default_theme'} unless defined $theme;
 	return $theme;
 }
 

Modified: trunk/vhffs-backend/conf/vhffs.conf.dist.in
===================================================================
--- trunk/vhffs-backend/conf/vhffs.conf.dist.in	2007-08-30 13:34:47 UTC (rev 828)
+++ trunk/vhffs-backend/conf/vhffs.conf.dist.in	2007-08-30 13:58:31 UTC (rev 829)
@@ -19,15 +19,9 @@
 	#The directory where you store ALL data
 	datadir			=	/data
 
-	#Directory which contains templates for the vhffs panel
+	#Directory which contains templates
 	templatedir		=	@TEMPLATESDIR@
 
-	#Directory which contains themes
-	themesdir		=	@PANELDIR@/themes
-
-	#The default theme
-	default_theme		=	vhffs
-
 	#Directory which contains internationalisation stuff
 	intldir			=	@INTLDIR@/
 
@@ -64,24 +58,30 @@
 	####################
 	#Panel configuration
 	<panel>
+		#Is the panel open or not ?
+		open			=	yes
+
 		#URL of the panel
 		url			=	http://your.panel.url
 
+		#Use the public section of VHFFS
+		use_public		=	yes
+
+		#The URL to the public part
+		url_public		=	http://projects.vhffs.org/
+
+		#Directory which contains themes
+		themesdir		=	@PANELDIR@/themes
+
+		#The default theme
+		default_theme		=	vhffs
+
 		#Obfuscation technique for emails (none, simple, entities or javascript)
 		mail_obfuscation	=	simple
 
 		#This is the URL display for the "Help" link in the panel
 		help_url		=	http://help.hoster
 
-		#Is the panel open or not ?
-		open			=	yes
-
-		#Use the public section of VHFFS
-		use_public		=	yes
-
-		#The URL to the public part
-		url_public		=	http://projects.vhffs.org/
-
 		#Use avatar or not ? If yes, you must create a /data/avatar and change owner/permissions
 		#so that the webserver can write into this directory
 		use_avatar		=	yes

Modified: trunk/vhffs-tests/conf/vhffs.conf
===================================================================
--- trunk/vhffs-tests/conf/vhffs.conf	2007-08-30 13:34:47 UTC (rev 828)
+++ trunk/vhffs-tests/conf/vhffs.conf	2007-08-30 13:58:31 UTC (rev 829)
@@ -13,12 +13,6 @@
 	#Directory which contains templates for the vhffs panel
 	templatedir		=	/usr/share/vhffs/templates/
 
-	#Directory which contains themes
-	themesdir		=	/usr/share/vhffs/panel/themes/
-
-	#The default theme
-	default_theme		=	vhffs
-
 	#Directory which contains internationalisation stuff
 	intldir			=	/usr/share/vhffs/intl/
 
@@ -66,6 +60,12 @@
 		#Print statistics in the main page of VHFFS ?
 		stats_on_home		=	yes
 
+		#Directory which contains themes
+		themesdir		=	/usr/share/vhffs/panel/themes/
+
+		#The default theme
+		default_theme		=	vhffs
+
 		#Notation is useful to handle aggressive users
 		#If a project is refused by moderation, the note os the user if decreased
 		#If a project or service is accepted, the note is increased


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/