Example #1
0
    header('Content-type: text/html; charset=utf-8');
    $template->pparse('root');
    exit(1);
}
// Identification de l'utilisateur
$utilisateur = new Utilisateur();
// Choix du module
if (isset($_GET['mod'])) {
    $mod = $_GET['mod'];
} else {
    $mod = 'index';
}
// Initialisation du moteur de template
$template = new Template('data/templates/' . $utilisateur->template());
$template->set_filenames(array('root' => 'root.tpl', 'index' => 'index.tpl', 'projet' => 'projet.tpl', 'edit_projet' => 'edit_projet.tpl', 'liste_projets' => 'liste_projets.tpl', 'demande' => 'demande.tpl', 'edit_demande' => 'edit_demande.tpl', 'liste_demandes' => 'liste_demandes.tpl', 'versions' => 'versions.tpl', 'connexion' => 'connexion.tpl', 'deconnexion' => 'deconnexion.tpl', 'perso' => 'perso.tpl', 'admin' => 'admin.tpl', 'edit_user' => 'edit_user.tpl'));
$template->set_rootdir('inc');
$template->set_filenames(array('rss' => 'rss.tpl'));
// Fonction d'erreur utilisant le template
$erreur = false;
function erreur_fatale($msg)
{
    global $template;
    $template->assign_block_vars('MSG_ERREUR', array('DESCR' => $msg));
    header('Content-type: text/html; charset=utf-8');
    $template->pparse('root');
    exit(0);
}
// Variables globales, ie communes à tous les modules
$template->assign_var('TITRE', $conf['titre']);
$template->assign_var('TEMPLATE_URL', 'data/templates/' . $utilisateur->template());
// Menu
Example #2
0
function setup_style($style)
{
    global $db, $board_config, $template, $images, $phpbb_root_path, $template;
    // V: let's just query all the themes ...
    $sql = "SELECT * FROM " . THEMES_TABLE;
    if (!($result = $db->sql_query($sql, 0, 'style_'))) {
        message_die(CRITICAL_ERROR, 'Could not query database for theme info');
    }
    $style_names = array();
    while ($row = $db->sql_fetchrow($result)) {
        $style_names[] = $row['style_name'];
        if ($style == $row['style_name'] || $style == $row['themes_id']) {
            $selected_style = $row;
        } else {
            if ($row['themes_id'] == $board_config['default_style']) {
                $default_style = $row;
            }
        }
    }
    $db->sql_freeresult($result);
    if (empty($selected_style)) {
        // We are trying to setup a style which does not exist in the database
        // Try to fallback to the board default (if the user had a custom style)
        // and then any users using this style to the default if it succeeds
        if ($style != $board_config['default_style']) {
            if (!empty($default_style)) {
                // we're safe, default style exists.
                $sql = 'UPDATE ' . USERS_TABLE . '
					SET user_style = ' . (int) $board_config['default_style'] . "\r\n\t\t\t\t\tWHERE user_style = '{$style}'";
                if (!$db->sql_query($sql)) {
                    message_die(CRITICAL_ERROR, 'Could not update user theme info');
                }
                $row = $default_style;
            } else {
                message_die(CRITICAL_ERROR, "No default theme is available");
            }
        } else {
            // style is board's default but not available. We're in big trouble !
            message_die(CRITICAL_ERROR, "Could not get default style data for themes_id [{$style}]");
        }
    } else {
        $row = $selected_style;
    }
    $template_path = 'templates/';
    $template_name = $row['template_name'];
    $style_name = $row['style_name'];
    $template = new Template($phpbb_root_path . $template_path . $template_name);
    //------------------------------------------------------------------------------
    // Global Admin Template - Begin Code Alteration
    //
    if (defined('IN_ADMIN')) {
        // V: mod -- Force subSilver for admin
        $template_name = 'phpbb';
        $style_name = 'subSilver';
        // V: mod end -- Force subSilver for admin
        $template->set_rootdir($phpbb_root_path . 'admin/templates');
    }
    //
    // Global Admin Template - End Code Alteration
    //------------------------------------------------------------------------------
    foreach ($style_names as $s) {
        $template->assign_block_vars('style_list', array('NAME' => $s));
    }
    if ($template) {
        $current_template_path = $template_path . $template_name;
        @(include $phpbb_root_path . $template_path . $template_name . '/' . $template_name . '.cfg');
        //-- mod : bbcode box reloaded -------------------------------------------------
        //-- add
        $style = $board_config['bbc_style_path'];
        $bbcb_path = $phpbb_root_path . $current_template_path . '/bbc_box.cfg';
        // V: remember about stuff not being as clever as XS :) ?
        // try to find it in current template's dir, else in tpldef's one
        if (file_exists($bbcb_path)) {
            include $bbcb_path;
        } else {
            include str_replace($template_name, $template->tpldef, $bbcb_path);
        }
        //-- fin mod : bbcode box reloaded ---------------------------------------------
        if (!defined('TEMPLATE_CONFIG')) {
            message_die(CRITICAL_ERROR, "Could not open {$template_name} template config file", '', __LINE__, __FILE__);
        }
        $img_lang = file_exists(@phpbb_realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ? $board_config['default_lang'] : 'french';
        $tpl_images = array();
        foreach ($images as $k => &$v) {
            $v = str_replace('{LANG}', 'lang_' . $img_lang, $v);
            $tpl_images['I_' . strtoupper($k)] = $v;
        }
        $template->assign_vars($tpl_images);
    }
    return $row;
}