<?php
/**
 * This file is the main file of the mobileOK Pythia plug-in for Moodle.
 * 
 * @author Sylvain Lequeux
 * @author Francois Daoust <fd@w3.org>
 * @package mobileOKPythia
 * @subpackage Moodle
 * @version $Revision: 1.2 $
 * @link http://www.w3.org/2009/11/mobileOKPythia/plugin-moodle.html mobileOK Pythia for Moodle
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3 or later
 * @copyright Copyright (c) 2009, W3C (MIT, ERCIM, Keio)
 */


/**
 * Keep a pointer to the global mobileOKPythia instance used throughout the plugin.
 */
global $mobileOKPythiaForMoodle;

mobileOKPythia_init();


/**
 * Initializes the functionalities of the mobileOK Pythia plugin.
 * 
 * @author Sylvain Lequeux
 * @author Francois Daoust <fd@w3.org>
 * @package mobileOKPythia
 * @subpackage Moodle
 * @version $Revision: 1.2 $
 * @link http://www.w3.org/2009/11/mobileOKPythia/plugin-moodle.html mobileOK Pythia for Moodle
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3 or later
 * @copyright Copyright (c) 2009, W3C (MIT, ERCIM, Keio)
 */
function mobileOKPythia_init() {
	global $mobileOKPythiaForMoodle;
	
	// Include required class definition
	require_once(dirname(__FILE__) . '/includes/mobileOKPythiaForMoodle.php');
	
	if (!$mobileOKPythiaForMoodle) {
		$mobileOKPythiaForMoodle = new mobileOKPythiaForMoodle();
		$mobileOKPythiaForMoodle->init();
	}
}


/**
 * Filters text
 * 
 * @author Sylvain Lequeux
 * @author Francois Daoust <fd@w3.org>
 * @package mobileOKPythia
 * @subpackage Moodle
 * @version $Revision: 1.2 $
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3 or later
 * @copyright Copyright (c) 2009, W3C (MIT, ERCIM, Keio)
 */
function mobileOKPythia_filter($courseid, $text) {
	global $mobileOKPythiaForMoodle;
	
	if (!is_string($text)) {
        // non string data can not be filtered anyway
        return $text;
    }
    
	return $mobileOKPythiaForMoodle->filter($text);
}

?>