function xnpImportIndexCheck($str, &$indexes)
{
    global $parser_hash;
    $textutil =& xoonips_getutility('text');
    $xnpsid = $_SESSION['XNPSID'];
    $item = array();
    $str = mb_decode_numericentity($str, xoonips_get_conversion_map(), 'UTF-8');
    $parser = xml_parser_create('UTF-8');
    if (!$parser) {
        return NULL;
    }
    $parser_hash[$parser] = array('tagstack' => array(), 'indexes' => array(), 'handler' => array(), 'handlerstack' => array());
    // XooNIps processes following tags.
    $parser_hash[$parser]['handler']['/INDEXES'] = array('_xoonips_import_indexcheckStartElement', '_xoonips_import_indexcheckEndElement', '_xoonips_import_indexcheckCharacterData');
    xml_set_element_handler($parser, '_xoonips_import_startElement', '_xoonips_import_endElement');
    xml_set_character_data_handler($parser, '_xoonips_import_CharacterData');
    if (!xml_parse($parser, $str, true)) {
        $lines = preg_split("/[\r\n]+/", $str);
        die(xml_error_string(xml_get_error_code($parser)) . ' at column ' . xml_get_current_column_number($parser) . ' of line ' . $textutil->html_special_chars($lines[xml_get_current_line_number($parser) - 1]));
    }
    xml_parser_free($parser);
    $indexes = $parser_hash[$parser]['indexes'];
    $parser_hash[$parser] = NULL;
    return true;
}
function xoonips_get_download_filename($file_id)
{
    $file_handler =& xoonips_getormhandler('xoonips', 'file');
    $file = $file_handler->get($file_id);
    if ($file == NULL) {
        return NULL;
    }
    $item_basic_handler =& xoonips_getormhandler('xoonips', 'item_basic');
    $item_basic = $item_basic_handler->get($file->get('item_id'));
    if ($item_basic == NULL) {
        return NULL;
    }
    $item_type_handler =& xoonips_getormhandler('xoonips', 'item_type');
    $item_type = $item_type_handler->get($item_basic->get('item_type_id'));
    if ($item_type == NULL) {
        return NULL;
    }
    $xconfig_handler =& xoonips_getormhandler('xoonips', 'config');
    $download_file_compression = $xconfig_handler->getValue('download_file_compression');
    if (is_null($download_file_compression)) {
        return NULL;
    }
    if ($download_file_compression == 'on') {
        return $item_type->get('display_name') . '_' . $file->get('file_id') . '.zip';
    } else {
        $unicode =& xoonips_getutility('unicode');
        return mb_decode_numericentity($unicode->encode_utf8($file->get('original_file_name'), xoonips_get_server_charset()), xoonips_get_conversion_map(), 'UTF-8');
    }
}