IPB 2.1: Migrating from IPB 2.0 Code - NBS






 

 

IPB 2.1: Migrating from IPB 2.0 Code - NBS

View Full Version : IPB 2.1: Migrating from IPB 2.0 Code


Will78
28-Jan-2006, 02:25 AM
IPB 2.1: Migrating from 2.0 code
This document serves as a primer for the structural changes to IPB from v2.x to v2.1.x

GLOBAL CHANGES VARIABLES / CLASSES:
$ibforums is now $this->ipsclass
$std is now $this->ipsclass
$DB is now $this->ipsclass->DB

$print is now $this->ipsclass->print
$sess is now $this->ipsclass->sess
$forums is now $this->ipsclass->forums

$ibforums->input['IP_ADDRESS'] is now $this->ipsclass->ip_address

FUNCTION NAMES:
$std->clean_value is now $this->ipsclass->parse_clean_value

CLASS NAMES:
modfunctions.php is now func_mod.php
msg_functions.php is now func_msg.php
usercp_functions.php is now func_usercp.php
chat_functions.php is now func_chat_legacy.php
chat04_functions.php is now func_chat.php

CLASS CALLS:
new chat_functions() is now new func_chat()
new modfunctions() is now new func_mod()
new msg_functions() is now new func_msg()
new usercp_functions() is now new func_usercp()

Recommended Class Loading:

It is recommended that you load classes as follows, being sure to pass ipsclass to the module

require_once( ROOT_PATH.'sources/module.php' );
$class = new module();
$class->ipsclass =& $this->ipsclass;

Note the =& which ensures we pass a reference to $this->ipsclass to ensure that any changes to the ipsclass method is reflected in all instances.

Loading language files

IPB 2.1 introduces a new cleaner method of loading language files:

$this->ipsclass->load_language('lang_calendar');

The changes to the $this->ipsclass->lang array is handled internally and the member's language ID is handled internally.

Member Management

When you're dealing with the member's name for display purposes (when showing in a post, quote, topic starter, etc) be sure to use "members_display_name" inplace of "name". members_display_name is populated even if the admin chooses not to use the display name feature.

Using Skins

Unless legacy mode is enabled, skins no longer return the class identifier from "load_template". You can access skin classes via the: $this->ipsclass->compiled_skins[ {skin_name} ] array.
For example:

$this->ipsclass->load_template( 'skin_boards' );
print $this->ipsclass->compiled_templates[ 'skin_boards' ]->page_top( $data );