/** * * @param * @return void */ function xmlEndElementHandler($parser, $name) { global $xoopsDB; $binder_item_links =& $this->_import_item->getVar('binder_item_links'); $unicode =& xoonips_getutility('unicode'); switch (implode('/', $this->_tag_stack)) { case "ITEM/DETAIL": if (count($binder_item_links) == 0) { $this->_import_item->setErrors(E_XOONIPS_TAG_NOT_FOUND, " no binder_item_link" . $this->_get_parser_error_at()); } break; case "ITEM/DETAIL/BINDER_ITEM_LINK": $handler =& xoonips_getormhandler('xnpbinder', 'binder_item_link'); $link =& $handler->create(); $link->set('item_id', intval($unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'))); $binder_item_links[] =& $link; break; } parent::xmlEndElementHandler($parser, $name); }
/** * * @param * @return void */ function xmlEndElementHandler($parser, $name) { global $xoopsDB; $detail =& $this->_import_item->getVar('detail'); $unicode =& xoonips_getutility('unicode'); switch (implode('/', $this->_tag_stack)) { case "ITEM/DETAIL": foreach (array('model_type', 'rights', 'readme', 'use_cc', 'cc_commercial_use', 'cc_modification') as $key) { if (is_null($detail->get($key, 'n'))) { $this->_import_item->setErrors(E_XOONIPS_TAG_NOT_FOUND, " no {$key}" . $this->_get_parser_error_at()); } } //error if no creators if (count($this->_import_item->getVar('creator')) == 0) { $this->_import_item->setErrors(E_XOONIPS_TAG_NOT_FOUND, " no creator" . $this->_get_parser_error_at()); } break; case "ITEM/DETAIL/MODEL_TYPE": case "ITEM/DETAIL/RIGHTS": case "ITEM/DETAIL/README": case "ITEM/DETAIL/USE_CC": case "ITEM/DETAIL/CC_MODIFICATION": case "ITEM/DETAIL/CC_COMMERCIAL_USE": $detail->set(strtolower(end($this->_tag_stack)), $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'), true); break; case 'ITEM/DETAIL/CREATORS/CREATOR': if ($this->_detail_version != '1.03') { break; } $creators =& $this->_import_item->getVar('creator'); $creator_handler =& xoonips_getormhandler('xnpmodel', 'creator'); $creator =& $creator_handler->create(); $creator->set('creator', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h')); $creator->set('creator_order', count($creators)); $creators[] = $creator; break; case "ITEM/DETAIL/CREATOR": if ($this->_detail_version != '1.00' && $this->_detail_version != '1.01' && $this->_detail_version != '1.02') { //<creator> is only for 1.00, 1.01 and 1.02 break; } $creator_handler =& xoonips_getormhandler('xnpmodel', 'creator'); $creators =& $this->_import_item->getVar('creator'); $creator =& $creator_handler->create(); $creator->set('creator', trim($unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'))); $creator->set('creator_order', 0); $creators[0] = $creator; break; case "ITEM/DETAIL/ATTACHMENT_DL_LIMIT": if ($this->_attachment_dl_limit_flag) { $this->_import_item->setErrors(E_XOONIPS_TAG_REDUNDANT, "attachment_dl_limit is redundant" . $this->_get_parser_error_at()); } else { if (ctype_digit($this->_cdata)) { $detail->set('attachment_dl_limit', intval($this->_cdata)); $this->_attachment_dl_limit_flag = true; } else { $this->_import_item->setErrors(E_XOONIPS_INVALID_VALUE, "invalid value(" . $this->_cdata . ") of attachment_dl_limit" . $this->_get_parser_error_at()); } } break; case "ITEM/DETAIL/ATTACHMENT_DL_NOTIFY": if ($this->_attachment_dl_notify_limit_flag) { $this->_import_item->setErrors(E_XOONIPS_TAG_REDUNDANT, "attachment_dl_notify is redundant" . $this->_get_parser_error_at()); } else { if (ctype_digit($this->_cdata)) { $detail->set('attachment_dl_notify', intval($this->_cdata)); $this->_attachment_dl_notify_limit_flag = true; } else { $this->_import_item->setErrors(E_XOONIPS_INVALID_VALUE, "invalid value(" . $this->_cdata . ") of attachment_dl_notify" . $this->_get_parser_error_at()); } } break; case "ITEM/DETAIL/FILE": $file_handler =& xoonips_getormhandler('xoonips', 'file'); if ($this->_file_type_attribute == 'model_data') { $this->_model_data_flag = true; if (!$file_handler->insert($this->_model_data)) { global $xoopsDB; $this->_import_item->setErrors(E_XOONIPS_DB_QUERY, "can't insert attachment file:" . $this->_model_data->get('original_file_name') . $this->_get_parser_error_at()); trigger_error($xoopsDB->error()); } $this->_model_data = $file_handler->get($this->_model_data->get('file_id')); $this->_import_item->setVar('model_data', $this->_model_data); $this->_import_item->setHasModelData(); $this->_file_type_attribute = null; } else { if ($this->_file_type_attribute == 'preview') { $this->_preview_flag = true; if (!$file_handler->insert($this->_preview)) { $this->_import_item->setErrors(E_XOONIPS_DB_QUERY, "can't insert attachment file:" . $this->_preview->get('original_file_name') . $this->_get_parser_error_at()); } $this->_preview = $file_handler->get($this->_preview->get('file_id')); $previews =& $this->_import_item->getVar('preview'); $previews[] = $this->_preview; $this->_import_item->setHasPreview(); $this->_file_type_attribute = null; } else { die('unknown file type:' . $this->_file_type_attribute); } } break; case 'ITEM/DETAIL/FILE/CAPTION': if ($this->_file_type_attribute == 'model_data') { $this->_model_data->set('caption', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h')); } else { if ($this->_file_type_attribute == 'preview') { $this->_preview->set('caption', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h')); } } break; break; case 'ITEM/DETAIL/FILE/THUMBNAIL': if ($this->_file_type_attribute == 'model_data') { $this->_model_data->set('thumbnail_file', base64_decode($this->_cdata)); } else { if ($this->_file_type_attribute == 'preview') { $this->_preview->set('thumbnail_file', base64_decode($this->_cdata)); } } break; } parent::xmlEndElementHandler($parser, $name); }
/** * * @param * @return void */ function xmlEndElementHandler($parser, $name) { global $xoopsDB; $detail =& $this->_import_item->getVar('detail'); $unicode =& xoonips_getutility('unicode'); switch (implode('/', $this->_tag_stack)) { case "ITEM/DETAIL": if (is_null($detail->get('url', 'n'))) { $this->_import_item->setErrors(E_XOONIPS_TAG_NOT_FOUND, " no item_link" . $this->_get_parser_error_at()); } break; case "ITEM/DETAIL/URL": $detail->set('url', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'), true); break; case "ITEM/DETAIL/FILE": $this->_url_banner_file_flag = true; $file_handler =& xoonips_getormhandler('xoonips', 'file'); if (!$file_handler->insert($this->_url_banner_file)) { $this->_import_item->setErrors(E_XOONIPS_DB_QUERY, "can't insert attachment file:" . $this->_url_banner_file->get('original_file_name') . $this->_get_parser_error_at()); } $this->_url_banner_file = $file_handler->get($this->_url_banner_file->get('file_id')); $this->_import_item->setVar('url_banner_file', $this->_url_banner_file); $this->_import_item->setHasUrlBannerFile(); break; case 'ITEM/DETAIL/FILE/CAPTION': $this->_url_banner_file->set('caption', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h')); break; case 'ITEM/DETAIL/FILE/THUMBNAIL': $this->_url_banner_file->set('thumbnail_file', base64_decode($this->_cdata)); break; } parent::xmlEndElementHandler($parser, $name); }
/** * * @param * @return void */ function xmlEndElementHandler($parser, $name) { global $xoopsDB; $detail =& $this->_import_item->getVar('detail'); $unicode =& xoonips_getutility('unicode'); switch (implode('/', $this->_tag_stack)) { case "ITEM/DETAIL": foreach (array('editor', 'publisher', 'isbn', 'url') as $key) { if (is_null($detail->get($key, 'n'))) { $this->_import_item->setErrors(E_XOONIPS_TAG_NOT_FOUND, " no {$key}" . $this->_get_parser_error_at()); } } if (is_null($detail->get('attachment_dl_limit'))) { if ($this->_detail_version == '1.00') { // // set zero to attachment_dl_limit // if it is not declared in xml // $detail->set('attachment_dl_limit', 0); } else { $this->_import_item->setErrors(E_XOONIPS_TAG_NOT_FOUND, " no attachment_dl_limit tag " . $this->_get_parser_error_at()); } } if (is_null($detail->get('attachment_dl_notify'))) { if ($this->_detail_version == '1.00' || $this->_detail_version == '1.01') { $detail->set('attachment_dl_notify', 0); } else { $this->_import_item->setErrors(E_XOONIPS_TAG_NOT_FOUND, " no attachment_dl_notify tag " . $this->_get_parser_error_at()); } } break; case 'ITEM/DETAIL/AUTHOR': if ($this->_detail_version != '1.00' && $this->_detail_version != '1.01' && $this->_detail_version != '1.02') { //<author> is only for 1.00, 1.01 and 1.02 break; } $cdata = $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'); if (trim($cdata) == '') { break; } $author_handler =& xoonips_getormhandler('xnpbook', 'author'); $authors =& $this->_import_item->getVar('author'); $author =& $author_handler->create(); $author->set('author', $cdata); $author->set('author_order', 0); $authors[0] = $author; break; case 'ITEM/DETAIL/AUTHORS/AUTHOR': if ($this->_detail_version != '1.03') { break; } $cdata = $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'); if (trim($cdata) == '') { break; } $authors =& $this->_import_item->getVar('author'); $author_handler =& xoonips_getormhandler('xnpbook', 'author'); $author =& $author_handler->create(); $author->set('author', $cdata); $author->set('author_order', count($authors)); $authors[] = $author; break; case "ITEM/DETAIL/EDITOR": $detail->set('editor', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'), true); break; case "ITEM/DETAIL/PUBLISHER": $detail->set('publisher', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'), true); break; case "ITEM/DETAIL/ISBN": $detail->set('isbn', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'), true); break; case "ITEM/DETAIL/URL": $detail->set('url', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'), true); break; case "ITEM/DETAIL/ATTACHMENT_DL_LIMIT": if ($this->_attachment_dl_limit_flag) { $this->_import_item->setErrors(E_XOONIPS_TAG_REDUNDANT, "attachment_dl_limit is redundant" . $this->_get_parser_error_at()); } else { if (ctype_digit($this->_cdata)) { $detail->set('attachment_dl_limit', intval($this->_cdata)); $this->_attachment_dl_limit_flag = true; } else { $this->_import_item->setErrors(E_XOONIPS_INVALID_VALUE, "invalid value(" . $this->_cdata . ") of attachment_dl_limit" . $this->_get_parser_error_at()); } } break; case "ITEM/DETAIL/ATTACHMENT_DL_NOTIFY": if ($this->_attachment_dl_notify_limit_flag) { $this->_import_item->setErrors(E_XOONIPS_TAG_REDUNDANT, "attachment_dl_notify is redundant" . $this->_get_parser_error_at()); } else { if (ctype_digit($this->_cdata)) { $detail->set('attachment_dl_notify', intval($this->_cdata)); $this->_attachment_dl_notify_limit_flag = true; } else { $this->_import_item->setErrors(E_XOONIPS_INVALID_VALUE, "invalid value(" . $this->_cdata . ") of attachment_dl_notify" . $this->_get_parser_error_at()); } } break; case "ITEM/DETAIL/FILE": $this->_book_pdf_file_flag = true; $file_handler =& xoonips_getormhandler('xoonips', 'file'); if (!$file_handler->insert($this->_book_pdf_file)) { $this->_import_item->setErrors(E_XOONIPS_DB_QUERY, "can't insert attachment file:" . $this->_book_pdf_file->get('original_file_name') . $this->_get_parser_error_at()); } $this->_book_pdf_file = $file_handler->get($this->_book_pdf_file->get('file_id')); $this->_import_item->setVar('book_pdf', $this->_book_pdf_file); $this->_import_item->setHasBookPdf(); break; case 'ITEM/DETAIL/FILE/CAPTION': $unicode =& xoonips_getutility('unicode'); $this->_book_pdf_file->set('caption', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h')); break; case 'ITEM/DETAIL/FILE/THUMBNAIL': $this->_book_pdf_file->set('thumbnail_file', base64_decode($this->_cdata)); break; } parent::xmlEndElementHandler($parser, $name); }
/** * * @param * @return void */ function xmlEndElementHandler($parser, $name) { global $xoopsDB; $detail =& $this->_import_item->getVar('detail'); $unicode =& xoonips_getutility('unicode'); switch (implode('/', $this->_tag_stack)) { case "ITEM/DETAIL": foreach (array('journal', 'volume', 'number', 'page', 'abstract', 'pubmed_id') as $key) { if (is_null($detail->get($key, 'n'))) { $this->_import_item->setErrors(E_XOONIPS_TAG_NOT_FOUND, " no {$key}" . $this->_get_parser_error_at()); } } //error is no authors if (count($this->_import_item->getVar('author')) == 0) { $this->_import_item->setErrors(E_XOONIPS_TAG_NOT_FOUND, " no author" . $this->_get_parser_error_at()); } break; case "ITEM/DETAIL/AUTHORS/AUTHOR": $authors =& $this->_import_item->getVar('author'); $author_handler =& xoonips_getormhandler('xnppaper', 'author'); $author =& $author_handler->create(); $author->set('author', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h')); $author->set('author_order', count($authors)); $authors[] = $author; break; case "ITEM/DETAIL/JOURNAL": case "ITEM/DETAIL/VOLUME": case "ITEM/DETAIL/NUMBER": case "ITEM/DETAIL/PAGE": case "ITEM/DETAIL/ABSTRACT": case "ITEM/DETAIL/PUBMED_ID": $detail->set(strtolower(end($this->_tag_stack)), $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'), true); break; case "ITEM/DETAIL/FILE": $this->_paper_pdf_reprint_file_flag = true; $file_handler =& xoonips_getormhandler('xoonips', 'file'); if (!$file_handler->insert($this->_paper_pdf_reprint_file)) { $this->_import_item->setErrors(E_XOONIPS_DB_QUERY, "can't insert attachment file:" . $this->_paper_pdf_reprint_file->get('original_file_name') . $this->_get_parser_error_at()); } $this->_paper_pdf_reprint_file = $file_handler->get($this->_paper_pdf_reprint_file->get('file_id')); $this->_import_item->setVar('paper_pdf_reprint', $this->_paper_pdf_reprint_file); $this->_import_item->setHasPaperPdfReprint(); break; case 'ITEM/DETAIL/FILE/CAPTION': $this->_paper_pdf_reprint_file->set('caption', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h')); break; case 'ITEM/DETAIL/FILE/THUMBNAIL': $this->_paper_pdf_reprint_file->set('thumbnail_file', base64_decode($this->_cdata)); break; } parent::xmlEndElementHandler($parser, $name); }
/** * * @param * @return void */ function xmlEndElementHandler($parser, $name) { global $xoopsDB; $detail =& $this->_import_item->getVar('detail'); $unicode =& xoonips_getutility('unicode'); switch (implode('/', $this->_tag_stack)) { case "ITEM/DETAIL": if ($this->_detail_version == '1.00') { } else { if ($this->_detail_version == '1.01') { $keys[] = 'attachment_dl_limit'; } else { $keys[] = 'attachment_dl_limit'; $keys[] = 'attachment_dl_notify'; } } foreach (array('presentation_type', 'conference_title', 'place', 'abstract', 'conference_from_year', 'conference_from_month', 'conference_from_mday', 'conference_to_year', 'conference_to_month', 'conference_to_mday') as $key) { if (is_null($detail->get($key, 'n'))) { $this->_import_item->setErrors(E_XOONIPS_TAG_NOT_FOUND, " no {$key}" . $this->_get_parser_error_at()); } } //error if no authors if (count($this->_import_item->getVar('author')) == 0) { $this->_import_item->setErrors(E_XOONIPS_TAG_NOT_FOUND, " no author" . $this->_get_parser_error_at()); } break; case "ITEM/DETAIL/AUTHORS/AUTHOR": if ($this->_detail_version != '1.01' && $this->_detail_version != '1.02') { break; } $authors =& $this->_import_item->getVar('author'); $author_handler =& xoonips_getormhandler('xnpconference', 'author'); $author =& $author_handler->create(); $author->set('author', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h')); $author->set('author_order', count($authors)); $authors[] = $author; break; case "ITEM/DETAIL/AUTHOR": // /item/detail/author is only available in ver 1.00 if ($this->_detail_version != '1.00') { break; } $authors =& $this->_import_item->getVar('author'); $author_handler =& xoonips_getormhandler('xnpconference', 'author'); $author =& $author_handler->create(); $author->set('author', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h')); $author->set('author_order', 0); $authors[0] = $author; break; case "ITEM/DETAIL/PRESENTATION_TYPE": case "ITEM/DETAIL/CONFERENCE_TITLE": case "ITEM/DETAIL/PLACE": case "ITEM/DETAIL/ABSTRACT": case "ITEM/DETAIL/CONFERENCE_FROM_YEAR": case "ITEM/DETAIL/CONFERENCE_FROM_MONTH": case "ITEM/DETAIL/CONFERENCE_FROM_MDAY": case "ITEM/DETAIL/CONFERENCE_TO_YEAR": case "ITEM/DETAIL/CONFERENCE_TO_MONTH": case "ITEM/DETAIL/CONFERENCE_TO_MDAY": $unicode =& xoonips_getutility('unicode'); $detail->set(strtolower(end($this->_tag_stack)), $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h'), true); break; case "ITEM/DETAIL/ATTACHMENT_DL_LIMIT": if ($this->_attachment_dl_limit_flag) { $this->_import_item->setErrors(E_XOONIPS_TAG_REDUNDANT, "attachment_dl_limit is redundant" . $this->_get_parser_error_at()); } else { if (ctype_digit($this->_cdata)) { $detail->set('attachment_dl_limit', intval($this->_cdata)); $this->_attachment_dl_limit_flag = true; } else { $this->_import_item->setErrors(E_XOONIPS_INVALID_VALUE, "invalid value(" . $this->_cdata . ") of attachment_dl_limit" . $this->_get_parser_error_at()); } } break; case "ITEM/DETAIL/ATTACHMENT_DL_NOTIFY": if ($this->_attachment_dl_notify_limit_flag) { $this->_import_item->setErrors(E_XOONIPS_TAG_REDUNDANT, "attachment_dl_notify is redundant" . $this->_get_parser_error_at()); } else { if (ctype_digit($this->_cdata)) { $detail->set('attachment_dl_notify', intval($this->_cdata)); $this->_attachment_dl_notify_limit_flag = true; } else { $this->_import_item->setErrors(E_XOONIPS_INVALID_VALUE, "invalid value(" . $this->_cdata . ") of attachment_dl_notify" . $this->_get_parser_error_at()); } } break; case "ITEM/DETAIL/FILE": $file_handler =& xoonips_getormhandler('xoonips', 'file'); if ($this->_file_type_attribute == 'conference_file') { $this->_conference_file_flag = true; if (!$file_handler->insert($this->_conference_file)) { $this->_import_item->setErrors(E_XOONIPS_DB_QUERY, "can't insert attachment file:" . $this->_conference_file->get('original_file_name') . $this->_get_parser_error_at()); } $this->_conference_file = $file_handler->get($this->_conference_file->get('file_id')); $this->_import_item->setVar('conference_file', $this->_conference_file); $this->_import_item->setHasConferenceFile(); $this->_file_type_attribute = null; } else { if ($this->_file_type_attribute == 'conference_paper') { $this->_conference_paper_flag = true; if (!$file_handler->insert($this->_conference_paper)) { $this->_import_item->setErrors(E_XOONIPS_DB_QUERY, "can't insert attachment file:" . $this->_conference_paper->get('original_file_name') . $this->_get_parser_error_at()); } $this->_conference_paper = $file_handler->get($this->_conference_paper->get('file_id')); $this->_import_item->setVar('conference_paper', $this->_conference_paper); $this->_import_item->setHasConferencePaper(); $this->_file_type_attribute = null; } else { die('unknown file type:' . $this->_file_type_attribute); } } break; case 'ITEM/DETAIL/FILE/CAPTION': $unicode =& xoonips_getutility('unicode'); if ($this->_file_type_attribute == 'conference_file') { $this->_conference_file->set('caption', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h')); } else { if ($this->_file_type_attribute == 'conference_paper') { $this->_conference_paper->set('caption', $unicode->decode_utf8($this->_cdata, xoonips_get_server_charset(), 'h')); } } break; case 'ITEM/DETAIL/FILE/THUMBNAIL': if ($this->_file_type_attribute == 'conference_file') { $this->_conference_file->set('thumbnail_file', base64_decode($this->_cdata)); } else { if ($this->_file_type_attribute == 'conference_paper') { $this->_conference_paper->set('thumbnail_file', base64_decode($this->_cdata)); } } break; } parent::xmlEndElementHandler($parser, $name); }