/** * * @param * @return void */ function xmlStartElementHandler($parser, $name, $attribs) { global $xoopsDB; parent::xmlStartElementHandler($parser, $name, $attribs); switch (implode('/', $this->_tag_stack)) { case "ITEM/DETAIL": // // validate version and set it to 'version' variable // if (!empty($attribs['VERSION'])) { if (in_array($attribs['VERSION'], $this->_import_file_version)) { $this->_detail_version = $attribs['VERSION']; } else { $this->_import_item->setErrors(E_XOONIPS_INVALID_VALUE, "unsupported version(" . $attribs['VERSION'] . ") " . $this->_get_parser_error_at()); } } else { $this->_detail_version = '1.00'; } break; case "ITEM/DETAIL/FILE": $this->_file_type_attribute = $attribs['FILE_TYPE_NAME']; $file_type_handler =& xoonips_getormhandler('xoonips', 'file_type'); $file_handler =& xoonips_getormhandler('xoonips', 'file'); $criteria = new Criteria('name', addslashes($attribs['FILE_TYPE_NAME'])); $file_type =& $file_type_handler->getObjects($criteria); if (count($file_type) == 0) { $this->_import_item->setErrors(E_XOONIPS_ATTR_NOT_FOUND, "file_type_id is not found:" . $attribs['FILE_TYPE_NAME'] . $this->_get_parser_error_at()); break; } $unicode =& xoonips_getutility('unicode'); if ($this->_file_type_attribute == 'model_data') { if ($this->_model_data_flag) { $this->_import_item->setErrors(E_XOONIPS_ATTACHMENT_HAS_REDUNDANT, "multiple {$name} attachments is not allowed" . $this->_get_parser_error_at()); break; } $this->_model_data =& $file_handler->create(); $this->_model_data->setFilepath($this->_attachment_dir . '/' . $attribs['FILE_NAME']); $this->_model_data->set('original_file_name', $unicode->decode_utf8($attribs['ORIGINAL_FILE_NAME'], xoonips_get_server_charset(), 'h')); $this->_model_data->set('mime_type', $attribs['MIME_TYPE']); $this->_model_data->set('file_size', $attribs['FILE_SIZE']); $this->_model_data->set('sess_id', session_id()); $this->_model_data->set('file_type_id', $file_type[0]->get('file_type_id')); } else { if ($this->_file_type_attribute == 'preview') { $this->_preview =& $file_handler->create(); $this->_preview->setFilepath($this->_attachment_dir . '/' . $attribs['FILE_NAME']); $this->_preview->set('original_file_name', $unicode->decode_utf8($attribs['ORIGINAL_FILE_NAME'], xoonips_get_server_charset(), 'h')); $this->_preview->set('mime_type', $attribs['MIME_TYPE']); $this->_preview->set('file_size', $attribs['FILE_SIZE']); $this->_preview->set('sess_id', session_id()); $this->_preview->set('file_type_id', $file_type[0]->get('file_type_id')); } else { $this->_import_item->setErrors(E_XOONIPS_ATTR_NOT_FOUND, "file_type_id is not found:" . $attribs['FILE_TYPE_NAME'] . $this->_get_parser_error_at()); break; } } break; case 'ITEM/DETAIL/FILE/CAPTION': case 'ITEM/DETAIL/FILE/THUMBNAIL': break; } }
/** * * @param * @return void */ function xmlStartElementHandler($parser, $name, $attribs) { global $xoopsDB; parent::xmlStartElementHandler($parser, $name, $attribs); switch (implode('/', $this->_tag_stack)) { case "ITEM/DETAIL": break; case "ITEM/DETAIL/FILE": if ($this->_url_banner_file_flag) { $this->_import_item->setErrors(E_XOONIPS_ATTACHMENT_HAS_REDUNDANT, "multiple {$name} attachments is not allowed" . $this->_get_parser_error_at()); break; } $file_type_handler =& xoonips_getormhandler('xoonips', 'file_type'); $file_handler =& xoonips_getormhandler('xoonips', 'file'); $criteria = new Criteria('name', addslashes($attribs['FILE_TYPE_NAME'])); $file_type =& $file_type_handler->getObjects($criteria); if (count($file_type) == 0) { $this->_import_item->setErrors(E_XOONIPS_ATTR_NOT_FOUND, "file_type_id is not found:" . $attribs['FILE_TYPE_NAME'] . $this->_get_parser_error_at()); break; } $unicode =& xoonips_getutility('unicode'); $this->_url_banner_file =& $file_handler->create(); $this->_url_banner_file->setFilepath($this->_attachment_dir . '/' . $attribs['FILE_NAME']); $this->_url_banner_file->set('original_file_name', $unicode->decode_utf8($attribs['ORIGINAL_FILE_NAME'], xoonips_get_server_charset(), 'h')); $this->_url_banner_file->set('mime_type', $attribs['MIME_TYPE']); $this->_url_banner_file->set('file_size', $attribs['FILE_SIZE']); $this->_url_banner_file->set('sess_id', session_id()); $this->_url_banner_file->set('file_type_id', $file_type[0]->get('file_type_id')); break; case 'ITEM/DETAIL/FILE/CAPTION': case 'ITEM/DETAIL/FILE/THUMBNAIL': break; } }