View Single Post
  #6  
Old 08-05-2004, 11:28 PM
CarCdr CarCdr is offline
 
Join Date: Apr 2004
Posts: 242
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

To give you a flavour of what I am proposing, take a look at this code. Note that it is not meant to suggest syntax per-se, but the flavour of what is being proposed. Nor is it meant to be complete or proper PHP. It is a prototype.

The key is that this file is read by itself, before the inclusion of 'global.php', either though $PHP_SELF or passing the file name to the include though a global.

The use of color here is gratuitous, meant only to highlight VBMOD usage.
Code:
<?php

/**VBMOD:

A special comment that begins with "VBMOD:". When this file is read by the
the mod-support SDK (read by ourselves below actually), it will look in
this comment for information.

The information in this comment is very similar to that supported by HTL.
The principal difference is that all information required to install,
administrate (options, phrases, etc), and run the mod are contained in
a single source file. One simply places this file in the home directory
and we are done.

@title: Index With Options

@status: alpha

@description:
 This mod replaces index.php with a fancier display with more options.

 The user-visible options are:

 (1) Display forums with new posts before forums with no new posts.
 (2) Suppress display of forum descriptions, making the individual forums
 take far less vertical space so that you can see more without scrolling.

 Both options are remembered using cookies.

@version:         1.1

@compatibility:   3.0.0, 3.0.1

@page_options:    navbar, forumjump

@default_action:  list

@usergroups_disallowed:   12,13
@users_disallowed:        131,192
@user_requires:           registration,post_minimum=10

@phrases, group=iwo_phrases:
iwo_display_new_first,     text=Display new forums first
iwo_display_descriptions,  text=Display forum descriptions

@admin_options:
iwo_controls_top,          title=Controls at top,
                           type=yesno,
                           default=1
                           help=Select this option to place the display controls at the top of the page.

@templates:
iwo_short_forumbit,        text=@@Text of template
here, in php-heredoc-like syntax.
@@

*/

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'iwo_index');

// vB SDK and mod support
require_once('./VBMOD_support.php');

// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array( blah, blah );
...etc...

// ########################## REQUIRE BACK-END ############################
VBMOD_pre_global();     //read this file and setup variables
require_once('./global.php');
VBMOD_post_global();        // check user access and finish variables

...
some code
...

// Here is a reference to a phrase. This would have been set
// by VBMOD if there is not a custom one installed by
// the administrator using our admin install option. There
// is no need to install anything if the defaults are OK.
$tmp = $vbphrase['iwo_display_new_first'];

// Here is a reference to an option. This would have been
// set by VBMOD if there is not a custom value
// installed by the administrator using our admin install
// option.
if ($vboptions['iwo_controls_top']) {
     some code here;
}

...
and so on
...

// Here is a convenience function made available to mod's.
// This particular example, VBMOD_eval_template, makes code more readable,
// offers some protection against changes to vB release, and has the small
// added advantage of making variables visible to Xref tools like PHPXref.
//
// This template is either available in its default form, which appeared
// earlier in this file, or it is a custom installed version. We just write
// the code as if it is installed.
$collect_bits .= VBMOD_eval_template('iwo_short_forumbit');

...
and so on, until:
...

VBMOD_finish_page();      // navbar, forumjump, etc.
print_output( ... );


// ADMINISTRATION:
//
// And here is something in pretty well every mod...
//
else if ($do === 'VBMOD_admin') {

     - check for administrator privs, change into admin dir,
       fire-up menu to allow for any of:
         (1) install/uninstall one or more options (only if the
             administrator wants to customize the defaults)
         (2) ditto phrases and templates
         (3) run the AdminCP for this mod's options
}

?>
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01312 seconds
  • Memory Usage 1,800KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete