Michael Morris |
10-29-2004 12:36 AM |
Heh heh,
Well, another reason it's so long is I LOVE whitespace and making the code both nice to look at as well as functioning. Many of the lines are simply { because I leave those to themselves.
I also have a LOT of commentary text so that if anyone comes in after me they can see what it does.
As an example, here's the first section...
PHP Code:
/*==============================================*\
|| ############################################ ||
|| # Startup Proceedures for Vbulletin Boards # ||
|| # at Wizards of the Coast # ||
|| # ---------------------------------------- # ||
|| # Created for Wizards of the Coast by # ||
|| # Michael Lloyd Morris # ||
|| # email mlmorr0@uky.edu # ||
|| # ---------------------------------------- # ||
|| # This is a PHPINCLUDE_START template # ||
|| ############################################ ||
\*==============================================*/
// ###############################################
// ##### HANDLE $_REQUESTs #######################
// ###############################################
// Launch Did You Know Pop Up
if (($_REQUEST['do'] == 'didyouknow') AND (THIS_SCRIPT == 'index'))
{
$tip = rand(1,15);
$tip = 'didyouknow_' . $tip;
eval('$tipoftheday = "' . fetch_template($tip) . '";');
eval('print_output("' . fetch_template('DIDYOUKNOW') . '");');
}
// Move thread to Admin Forum preset
if (($_REQUEST['do'] == 'moveadmin') AND (THIS_SCRIPT == 'postings'))
{
$_REQUEST['do'] = 'domovethread';
$_POST['do'] = 'domovethread';
$_POST['forumid'] = '399';
$_POST['method'] = 'move';
}
I've found that since PHP_INCLUDE start runs before any other templates or the remainder of the various vbulletin scripts it's the perfect time to intercept special $_REQUEST and $_POST variables and reassign them. The pop-up launcher is the cleanest example of this since it terminates the execution of the rest of the index script immediately when it makes the Print Output call. You can actually create whole new pages that way if you really want to. From a processing standpoint the pop-up makes sense in the PHPINCLUDE_START template since it doesn't need the $header, $footer or any other templates - just the custom DIDYOUKNOW templates.
The second item more cleanly allows the move thread presets. It's actually the 2nd version of a hack I've released and if you make a lot of thread moves it comes highly recommended.
The rest of the script does these things (just copying the commentary text...)
PHP Code:
// ###############################################
// ##### DEFINE FUNCTIONS USED IN TEMPLATE #######
// ###############################################
// ###############################################
// ##### MAIN PAGES INITIALIZATION ##############
// ###############################################
// #### Prepare $banner array #########################
// #### Merge custom display information into $show ##########
// #### Set Defaults ################################
// ##### PARSE GLOBAL MENU TEMPLATE #################
// ###############################################
// ##### START ANNOUNCMENTS #####################
// ###############################################
// ###############################################
// ##### START USER SETTINGS ####################
// ###############################################
// #### Set Postbit ##########################
// #### Set Left Column ######################
// #### Set New Posts in Bold ################
// #### Set Subscribed in Italics ############
// #### Set Thread Previews ######################
// #### Set Display Member Info at top ###########
// #### Set Variable Display Width ###############
// #### Set Forum Icon Display ###################
// #### Set Tip Launcher ###################
// #### FORUMHOME User Info ######################
// ###############################################
// ##### MISC ACTIONS B4 PARSING HEADERS ########
// ###############################################
// Turn Left Columns off if we're on an editor interface
// ###############################################
// ##### START HEADERS ##########################
// ###############################################
// ##### Forumhome ###############################
// Parse the Forumhome greeting
//Set the left column to false - this page has a left colum, but unlike
//other pages the forumhome template creates the column without the header template doing so.
//This page is also unaffected by the status of $show['leftcolumn']
// ##### RPGA ####################################
//Set the Banner
//RPGA has multiple subforums with slightly different heights
//and not all allow the navbar to slide under them.
//Living Greyhawk
//Living Force
//RPGA Default
//Set Items which apply to all three banners
// ##### Dungeons & Dragons #######################
//Set the Banner
//Set the Left Column if required
//The D&D styleset has multiple left menus depending on the header
//The code below changes the left menu depending on the header called.
//Forgotten Realms
//Eberron
//D&D Miniatures
//D&D Main
// ##### Magic: The Gathering #####################
//This small program determines the date of the Monday that started this week.
//We need it to determine the file name of the MtG header used in most MtG areas.
//I think this is going to be good but it might screw up during a change of year.
// The file name requires leading zeros, so let's add them as necessary.
// Done. Spit out the filename and evaluate the rest of the MtG header.
// MtG: Online has a different header that doesn't change weekly.
// Now let's attend to the prep shared by MtG and MtG Online
//Parse the lower Magic Menu.
// ##### Duel Masters #############################
// ##### NeoPets ##################################
// ##### MLB Showdown ##############################
// ##### Star Wars TCG ##############################
// ##### Star Wars RPG ##############################
// ##### Star Wars Minis ##############################
// ##### d20 Modern #################################
// ##### d20 System #################################
// ##### GI Joe ##############################
// ##### Other banners #################################
And that's just the major commentary text. As I've said before, these boards are much like having 12 different boards tied at the hip - but somehow it works. I've very proud of my PHPINCLUDE_START template even if it's the one part of the boards the users never see.
|