All pastes #161755 Raw Edit

Something

public text v1 · immutable
·published 2006-09-05 19:49 UTC
rendered paste body
class libmodule {

		function loadTheme( $modules ) {
		
			global $libsession;
			
			// Choose what theme to load
			if ( $_GET['usetheme'] != NULL && is_dir( 'themes/'.$_GET['usetheme'] ) ) {
				$templateTheme = $_GET['usetheme'];
			} else if ( $this->siteType == 'admin' ) {
			
				if ( $libsession->LoggedIn == 1 ) {
					$templateTheme = "themes/"._CONFIG_THEME."/main_template.html";
				} else {
					$templateTheme = "themes/"._CONFIG_THEME."/login_template.html";
				}
				
			} else { 
				$templateTheme = "themes/"._CONFIG_THEME_MAIN."/main_template.html";
			}
			
			// Loop every module to be replace into the correct Sectors of the template file
			// While doing this, we need to check for Permission, Module File Existing and Class exisitng
			foreach( $modules as $tmpkey=>$val ) {
			
				foreach( $val as $key ) {
				
					// First we check if the user has permission to load this module
					if ( libPermission( $key['permission'] ) == 1 ) {
					
						// Ok so user has permission, next thing we do is see if the module file exists
						$tmpFile = 'modules/'.$key['name'].'/'.$key['name'].'_mod.php';
						if ( file_exists( $tmpFile ) ) {
						
							// Ok so the file exists - now we need to see if the class exists
							if ( $key['sector'] == 'SC' ) {

								$className = 'mod'.ucfirst( strtolower( $key['name'] ) ).'_sec'._URLSEC;								

							} else {						

								$className = 'mod'.ucfirst( strtolower( $key['name'] ) ).'_sec'.$key['sector'];

							}
							
							if ( class_exists( $className ) ) {
							
								// Start output buffering
								ob_start();
									new $className();
								$buffer = ob_get_clean();
								
								$templateTags[ $key['sector'] ] .= $buffer;
							
							} else {
								global $libehc;
								$templateTags[ $key['sector'] ] .= $libehc->ErReport( 15 );
							}						
						
						} else {
							global $libehc;
							$templateTags[ $key['sector'] ] .= $libehc->ErReport( 15 );
						}
					
					} else {
					
						// If the module should be running in SC, we shall display a No Permission error
						if ( $key['sector'] == 'SC' ) {
							global $libehc;
							$templateTags[ $key['sector'] ] = $libehc->ErReport( 14 );
						} else {
							$templateTags[ $key['sector'] ] = '';
						
					}
					
				}					
			
			}
			
			$template = new libtemplate( $templateTheme );
			$template->replace_tags( $templateTags );
			echo $template->page; 
		
		} 			

						

	}



?>