Get Involved m2f
connecting communities
m2f @ SourceForge.net  

v2.0 Design

Main Concepts

  • Channel: Import and export messages to and from a 3rd-party format, for example, phpBB, email, RSS feeds, etc. Modular system, so channels can be user-contributed.
  • ‘Generic Message’: A generic (i.e. channel-agnostic) data structure that adapts to every channel. It is capable of integrating every channel’s special data in order to properly convert one format to another.
  • Filters: Functions that change the data of the message in some way, for example, stripping html code from the body of the message, adding/removing subject field tags, etc.
  • Routers: Conditional functions that can branch the processing of messages. For example, if the imported message subject contains the word “Forum 1″, export the message to phpBB3 forum 1; else export the message to phpBB3 forum 2.
  • Chain: A sequence of channels, filters and routers which starts with the importing of messages and finishes with the exporting of messages. For example, you could build a chain like this: “phpBB -> Remove HTML -> smtp” in order to send phpBB posts to a mailserver after stripping any HTML.

So, m2f 2.0 works like this:

  • The admin user builds two chains in order to bind to channels together. In this example, “phpBB3->smtp” and “pop3->phpBB3″.
  • The first chain will be run every time a user posts a message on the forum.
  • The second chain must be run manually or by the use of a cron script.
  • m2f is designed to accept multiple import and export channels, so you could, for example, import mail from a POP mailbox, and export the message to both a phpBB2 forum and a phpBB3 forum.

You can learn more on the use cases page.

Directory structure

The following list refers to the root of a standard m2f download:

/application
the web User Interface for the administration control panel
/cache
um… the cache
/config
contains the configuration file for the Admin CP (N.B. this is different to the config file for running the tests)
/di
configuration files for Dependency Injection
/external
The files needed for 3rd-party software such as phpBB to communicate with m2f.
/includes
3rd-party library files used by m2f
/lib
the core m2f code
/models
database models, used by Doctrine ORM system
/test-suite
JavaScript-enabled test runner
/tests
contains all the test files

m2f Library Files

Let’s have a look at the contents of the /lib directory. We use ZEND-style naming conventions for all m2f library classes, so the class names directly map to files in the /lib directory:
M2f => /lib/M2f.php
M2f_Message => /lib/M2f/Message.php
M2f_Module_Channel_Phpbb2_Export => /lib/M2f/Module/Channel/Phpbb2/Export.php

I will now talk through the major areas of the m2f library, using class names as reference. (N.B. as of Jan 2009, this is a little out-of-date. Sorry - we’ll fix it soon!).

M2f
static helper function, such as autoload()
M2f_Cache
interface to Zend Framework’s Cache system. Stores cache files in /cache
M2f_Chain
the ‘guts’ of m2f. Like a Distribution List in v1.2. Add import and export channels to a chain, and everything happens when the chain is run.
M2f_Db
interface to Doctrine ORM system. Sets up a PDO object, passes it to Doctrine. Also responsible for installing the m2f tables
M2f_Di
interface to Crafty Dependency Injection system
M2f_Element
base class for objects which may be added to a chain (Channel, Filter, etc.)
M2f_Element_Config
configuration object for each instance of M2f_Element
M2f_Filter_Parser_Tokenizer
splits message text strings into tokens based on rules (such as BBCode)
M2f_Filter_Parser_Assembler
assemble tokenized string into M2f_Message style XML
M2f_Message
basic message class, passed between elements in a chain
M2f_Message_List
Container for instances of M2f_Message. Each Chain, Channel and Filter is passed a Message List
M2f_Model
base class for Doctrine Models (each model corresponds to a database table)
M2f_Persistable
base class for objects which need to be saved in the database
M2f_Receiver
receives and decodes cURL connections from 3rd-party software, such as phpBB
M2f_TransferObject
basic objects which hold an array of data
M2f_Transport
initiates cURL connections with 3rd-party software, such as phpBB

The directory I have missed out is the big one! Inside /modules you will find all the Channels, Filters (and more later!) which give m2f its functionality.

Share this post:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Slashdot