require_once CCTM_PATH . '/includes/CCTM_ImportExport.php';
$data = array();
$data['page_title'] = __('Import Definition', CCTM_TXTDOMAIN);
$data['help'] = 'http://code.google.com/p/wordpress-custom-content-type-manager/wiki/Import';
$data['menu'] = sprintf('<a href="' . get_admin_url(false, 'admin.php') . '?page=cctm_tools&a=tools" title="%s" class="button">%s</a>', __('Back'), __('Back')) . ' ' . sprintf('<a href="' . get_admin_url(false, 'admin.php') . '?page=cctm_tools&a=export_def" title="%s" class="button">%s</a>', __('Export'), __('Export'));
$data['msg'] = CCTM::get_flash();
$data['content'] = '';
$data['defs_array'] = array();
// We reference this in a couple places.
$upload_dir = wp_upload_dir();
$dir = $upload_dir['basedir'] . '/' . self::base_storage_dir . '/' . self::def_dir;
// Check to see if the library directory exists...
if (file_exists($dir) && is_dir($dir)) {
    //	$data['msg'] = ''; // do nothing
    // Read the files
    $data['defs_array'] = CCTM_ImportExport::get_defs();
} elseif (!@mkdir($dir, self::new_dir_perms, true)) {
    $data['msg'] = sprintf('<div class="error"><p>%s</p></div>', sprintf(__('Failed to create the CCTM base storage directory: <code>%s</code></p>
		<p><a href="http://code.google.com/p/wordpress-custom-content-type-manager/wiki/Permissions" target="_blank">Click here</a> for more information about correcting permissions errors on your server.</p>', $dir)));
    $data['defs_array'] = array();
}
// We have up-to 3 forms on this page....
if (!empty($_POST)) {
    // && check_admin_referer($data['action_name'], $data['nonce_name']) ) {
    // We use the 'cctm_nonce' field to determine which form was submitted.
    $nonce = CCTM::get_value($_POST, 'cctm_nonce');
    // If properly submitted, Proceed with importing
    if (wp_verify_nonce($nonce, 'cctm_upload_def')) {
        // A little cleanup before we sanitize
        unset($_POST['cctm_nonce']);
        unset($_POST['_wp_http_referer']);