Login   Register  
PHP Classes
elePHPant
Icontem

File: bt-header.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Michael Dale  >  Bluetrait  >  bt-header.php  >  Download  
File: bt-header.php
Role: Auxiliary script
Content type: text/plain
Description: Main Header File
Class: Bluetrait
A multi-user blog system
Author: By
Last change:
Date: 2008-10-26 03:32
Size: 4,699 bytes
 

Contents

Class file image Download
<?php
    
include('bt-common.php');
    
    if (!isset(
$_SESSION['bt_page']) || $_SESSION['bt_page'] != $_SERVER['REQUEST_URI']) {
        
$_SESSION['bt_page'] = $_SERVER['REQUEST_URI'];
    }

    
$bt_content_identifier bt_get_content_identifier();
    
    
$bt_error '';
    
$bt_input_error '';
    
    if (isset(
$_SESSION['bt_input_error']) && !empty($_SESSION['bt_input_error'])) {
        
$bt_input_error $_SESSION['bt_input_error'];
        
$_SESSION['bt_input_error'] = '';
    }
    
//default title
    
bt_set_title(bt_get_config('description'));
    
/*
    This section is where we start the process of getting data based on the content type
    */
    
bt_set_404();
    switch(
$bt_content_identifier['type']) {
        case 
'blog':
            
bt_unset_404();
            
$bt_post_categories = new bt_categories($bt_tb->categories);
            
$bt_posts = new bt_posts();
            
$bt_content_identifier['limit'] = (int) bt_get_config('limit_posts');
            
$bt_content_identifier['comment_count'] = 1;
            
$bt_content_identifier['post_type'] = 'published';
            
//paging support.
            
$bt_content_identifier['offset'] = $bt_content_identifier['limit'] * $bt_content_identifier['page'] - $bt_content_identifier['limit'];
            if (
$bt_content_identifier['offset'] < 0) {
                
$bt_content_identifier['offset'] = 0;
            }
            
$bt_post_array $bt_posts->get_posts($bt_content_identifier);
            
$bt_content_identifier['theme_type'] = 'blog';

            
//if no posts found trigger not found message (only used if no posts were found in a category)
            
if (empty($bt_post_array)) $bt_error '<h2>This category is currently empty.</h2>';

            if (isset(
$bt_post_array[0])) {
                
$bt_post $bt_post_array[0];
                if (
$bt_posts->matches_permalink()) {
                    
bt_set_title(bt_run_content_filter('post_title'$bt_post['post_title']));
                }
                unset(
$bt_post);
            }
        break;
        
        case 
'cms':
            
bt_unset_404();
            
$bt_post_categories = new bt_categories($bt_tb->categories);
            
$bt_posts = new bt_posts();
            
$bt_content_identifier['limit'] = 1;
            unset(
$bt_content_identifier['comment_count']);
            
$bt_content_identifier['post_type'] = 'published_content';
            
//paging support.
            
$bt_content_identifier['offset'] = $bt_content_identifier['limit'] * $bt_content_identifier['page'] - $bt_content_identifier['limit'];
            if (
$bt_content_identifier['offset'] < 0) {
                
$bt_content_identifier['offset'] = 0;
            }
            
$bt_post_array $bt_posts->get_posts($bt_content_identifier);
            
$bt_content_identifier['theme_type'] = 'cms';

            if (isset(
$bt_post_array[0])) {
                
$bt_post $bt_post_array[0];
                if (
$bt_posts->matches_permalink_content()) {
                    
bt_set_title(bt_run_content_filter('post_title'$bt_post['post_title']));
                }
                unset(
$bt_post);
            }
        break;
        
        case 
'rss':
            
bt_unset_404();
            
$bt_content_identifier['limit'] = (int) bt_get_config('limit_posts');
            
$bt_content_identifier['post_type'] = 'published';
            
$bt_post_categories = new bt_categories($bt_tb->categories);
            
$bt_posts = new bt_posts();
            
$bt_post_array $bt_posts->get_posts($bt_content_identifier);
            
$bt_content_identifier['theme_type'] = '';
            
bt_set_title('');
        
        break;
        
        case 
'rss_comments':
            
bt_unset_404();
            
$bt_post_categories = new bt_categories($bt_tb->categories);
            
$bt_posts = new bt_posts();
            
$bt_post_array $bt_posts->get_posts($bt_content_identifier);
            if (
count($bt_post_array) == 1) {
                
$bt_post $bt_post_array[0];
                
$bt_content_identifier['get_posts'] = true;
                
$bt_content_identifier['order'] = 1;
                
bt_post_comments_setup();
                
//unset($bt_post);
            
}
            else {
                
bt_feed_comments_setup();
            }
            
            
$bt_content_identifier['theme_type'] = '';
            
bt_set_title('');
        
        break;
        
        
        default:
        
            
//pass all other content types to plugins that might handle them
            
bt_run_section_ref('other_content_' $bt_content_identifier['type'], $bt_content_identifier);
    }
    
    
/*
    we can do real 404s now :)
    */
    
if (bt_is_404()) {
        
bt_run_section('404');
    }
    
    
bt_send_headers();

    
bt_run_section('header_loaded');
    
/*
        Theme Support
    */
    
if (bt_get_config('themes') && !empty($bt_content_identifier['theme_type'])) {
        
$bt_theme bt_check_current_theme();
        
$bt_theme_type bt_check_theme_type($bt_theme$bt_content_identifier['theme_type']);
        
define('BT_CURRENT_THEME'$bt_theme);
        
define('BT_CURRENT_THEME_TYPE'$bt_theme_type);
        
        
//Themes can over the Bluetrait default 'theme_handle' (without the need to use a plugin) if they need to load themes in a different manner
        
include(BT_ROOT BT_CONTENT '/bt-themes/' $bt_theme '/' $bt_theme '.theme.php');
        
        
bt_run_section('theme_type_' BT_CURRENT_THEME_TYPE);
    }
?>