<?php
/**
 * menu_factory.php - Menu config factory
 *
 * @author $Author: dtong $
 * @version $Id: menu_factory.php,v 1.2 2010/09/06 04:39:02 dtong Exp $
 * @copyright Copyright (c) 2010, Tiller Software Co., Ltd.
*/

class menu_factory {

   public static function factory($folder,$file=FALSE) {
   	if ( empty($folder) ){
   		osa_errorlog(__METHOD__ . " -  Invalid folder in factory ", $folder);
			echo osa_ajaxmsg(lang('menu_nofoldermsg'));
			exit;
   	}
   	$CI =& get_instance();
   	if ( $file == FALSE )
   		$template = $folder . '_' . $CI->config->item('cms_unit_org');
   	else
   		$template = $folder . '_' . $file;
		if ( @include_once CMS_TEMPLATEPATH_MENU . $folder . '/' . $template . '.php') {
			$data = menu_config_data::get();
			return $data;
		}
		return FALSE;
   }
}