<commit_before><?php

// include the config file
if(!isset($config))
	require_once '../util/configLoader.inc';
$config =&configLoader::getInstance();

require_once $config->get('sysRoot').'alpha/controller/Controller.inc';
require_once $config->get('sysRoot').'alpha/util/Logger.inc';
require_once $config->get('sysRoot').'alpha/util/convertors/BO2Excel.inc';

/**
 *
 * Controller for viewing Business Objects as Excel spreadsheets
 * 
 * @package alpha::controller
 * @author <NAME> <<EMAIL>>
 * @copyright 2008 <NAME>
 * @version $Id$
 * 
 */
class ViewExcel extends Controller {
	/**
	 * Trace logger
	 * 
	 * @var Logger
	 */
	private static $logger = null;
	
	/**
	 * Constructor
	 *
	 */
	public function __construct() {
		if(self::$logger == null)
			self::$logger = new Logger('ViewExcel');
		self::$logger->debug('>>__construct()');
		
		// ensure to call the parent constructor
		parent::__construct();
		
		if (!empty($_GET['bo']) && !empty($_GET['oid'])) {
			$this->doGet($_GET);
		}else{			
			self::$logger->fatal('No BO and/or OID parameter available for ViewExcel controller!');
			exit;
		}
		
		self::$logger->debug('<<__construct');
	}
	
	/**
	 * Loads the BO indicated in the GET request and handles the conversion to Excel 
	 *
	 * @param array $params
	 */
	public function doGet($params) {
		self::$logger->debug('>>doGet(params=['.print_r($params, true).'])');
		
		try {
			$BOname = $params['bo'];
			$OID = $params['oid'];
		}catch (Exception $e) {
			self::$logger->fatal('No BO and/or OID parameter available for ViewExcel controller!');
			self::$logger->debug('<<__doGet');
			exit;
		}
		
		try {
			DAO::loadClassDef($BOname);
			$BO = new $BOname();
			$BO->load($OID);
			
			$convertor = new BO2Excel($BO);
			$convertor->render();
		}catch (BONotFoundException $e) {
			self::$logger->fatal($e->getMessage());
			self::$logger->debug('<<__doGet');
			exit;
		}catch (IllegalArguementException $e) {
			self::$logger->fatal($e->getMessage());
			self::$logger->debug('<<__doGet');
			exit;
		}
		self::$logger->debug('<<__doGet');
	}
	
}

// now build the new controller
if(basename($_SERVER['PHP_SELF']) == 'ViewExcel.php')
	$controller = new ViewExcel();

?><commit_msg>Upgraded ViewExcel controller to use new interface and fixed some bugs<commit_after><?php

// include the config file
if(!isset($config))
	require_once '../util/configLoader.inc';
$config =&configLoader::getInstance();

require_once $config->get('sysRoot').'alpha/util/db_connect.inc';
require_once $config->get('sysRoot').'alpha/controller/Controller.inc';
require_once $config->get('sysRoot').'alpha/util/Logger.inc';
require_once $config->get('sysRoot').'alpha/util/convertors/BO2Excel.inc';
require_once $config->get('sysRoot').'alpha/controller/AlphaControllerInterface.inc';

/**
 *
 * Controller for viewing Business Objects as Excel spreadsheets
 * 
 * @package alpha::controller
 * @author <NAME> <<EMAIL>>
 * @copyright 2009 <NAME>
 * @version $Id$
 * 
 */
class ViewExcel extends Controller implements AlphaControllerInterface {
	/**
	 * Trace logger
	 * 
	 * @var Logger
	 */
	private static $logger = null;
	
	/**
	 * Constructor
	 */
	public function __construct() {
		if(self::$logger == null)
			self::$logger = new Logger('ViewExcel');
		self::$logger->debug('>>__construct()');
		
		// ensure that the super class constructor is called, indicating the rights group
		parent::__construct('Public');
		
		self::$logger->debug('<<__construct');
	}
	
	/**
	 * Loads the BO indicated in the GET request and handles the conversion to Excel 
	 *
	 * @param array $params
	 */
	public function doGet($params) {
		self::$logger->debug('>>doGet(params=['.print_r($params, true).'])');
		
		try {
			$BOname = $params['bo'];
			$OID = $params['oid'];
		}catch (Exception $e) {
			self::$logger->fatal('No BO and/or OID parameter available for ViewExcel controller!');
			self::$logger->debug('<<__doGet');
			exit;
		}
		
		try {
			DAO::loadClassDef($BOname);
			$BO = new $BOname();
			$BO->load($OID);
			
			$convertor = new BO2Excel($BO);
			$convertor->render();
		}catch (BONotFoundException $e) {
			self::$logger->fatal($e->getMessage());
			self::$logger->debug('<<__doGet');
			exit;
		}catch (IllegalArguementException $e) {
			self::$logger->fatal($e->getMessage());
			self::$logger->debug('<<__doGet');
			exit;
		}
		self::$logger->debug('<<__doGet');
	}
	
	/**
	 * Handle POST requests
	 * 
	 * @param array $params
	 */
	public function doPOST($params) {
		self::$logger->debug('>>doPOST($params=['.print_r($params, true).'])');		
		
		self::$logger->debug('<<doPOST');
	}
	
}

// now build the new controller if this file is called directly
if ('ViewExcel.php' == basename($_SERVER['PHP_SELF'])) {
	$controller = new ViewExcel();
	
	if(!empty($_POST)) {			
		$controller->doPOST($_POST);
	}else{
		$controller->doGET($_GET);
	}
}

?>
{'fraction_non_alphanumeric': 0.19285274183610598, 'fraction_numerical': 0.0024645717806531116, 'mean_word_length': 4.230934479054779, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2325396', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1560, 'n_words': 336}