structImport.module
Go to the documentation of this file.
00001 <?php 00002 00003 00004 00007 00017 // Include the utilities function used by the hooks and tools 00018 include_once('./' . drupal_get_path('module', 'conStruct') . '/framework/utilities.php'); 00019 00020 00036 function structImport_main() 00037 { 00038 global $base_url; 00039 00040 drupal_set_html_head("<link type=\"text/css\" rel=\"stylesheet\" media=\"all\" href=\"" . $base_url . "/" 00041 . drupal_get_path("module", "structImport") . "/css/style.css\" />"); 00042 00043 return (conStruct_import()); 00044 } 00045 00046 00078 function structImport_access($op, $node, $account) 00079 { 00080 return TRUE; 00081 } 00082 00100 function structImport_access_callback() 00101 { 00102 return TRUE; 00103 } 00104 00105 00136 function structImport_block($op = 'list', $delta = 0, $edit = array()) 00137 { 00138 global $base_url; 00139 00140 // The $op parameter determines what piece of information is being requested. 00141 switch ($op) 00142 { 00143 case 'list': 00144 00145 // If $op is "list", we just need to return a list of block descriptions. 00146 // This is used to provide a list of possible blocks to the administrator, 00147 // end users will not see these descriptions. 00148 $blocks[0]['info'] = t('conStruct Import Tool'); 00149 return $blocks; 00150 00151 case 'configure': 00152 // If $op is "configure", we need to provide the administrator with a 00153 // configuration form. The $delta parameter tells us which block is being 00154 // configured. In this example, we'll allow the administrator to customize 00155 // the text of the first block. 00156 $form = array(); 00157 if ($delta == 0) 00158 { 00159 // All we need to provide is a text field, Drupal will take care of 00160 // the other block configuration options and the save button. 00161 $form['block_example_string'] = array( 00162 '#type' => 'textfield', 00163 '#title' => t('Block contents'), 00164 '#size' => 100, 00165 '#description' => t('This string will appear in the conStruct Tools menu'), 00166 '#default_value' => variable_get('conStruct_string', t('')) 00167 ); 00168 } 00169 00170 return $form; 00171 00172 case 'save': 00173 00174 // If $op is "save", we need to save settings from the configuration form. 00175 // Since the first block is the only one that allows configuration, we 00176 // need to check $delta to make sure we only save it. 00177 if ($delta == 0) 00178 { 00179 // Have Drupal save the string to the database. 00180 variable_set('structImport_string', $edit['structImport_string']); 00181 } 00182 return; 00183 00184 case 'view': 00185 00186 default: 00187 00188 // If $op is "view", then we need to generate the block for display 00189 // purposes. The $delta parameter tells us which block is being requested. 00190 switch ($delta) 00191 { 00192 case 0: 00193 // The subject is displayed at the top of the block. Note that it 00194 // should be passed through t() for translation. 00195 $block['subject'] = t('conStruct Import Tool'); 00196 // The content of the block is typically generated by calling a custom 00197 // function. 00198 $block['content'] = structImport_contents(1); 00199 break; 00200 } 00201 return $block; 00202 } 00203 } 00204 00216 function structImport_contents($which_block) 00217 { 00218 global $base_url; 00219 00220 if ($which_block == 1) 00221 { 00222 // Get the base path of the Drupal installation folder on the file system of the server 00223 $menuItems = ""; 00224 00225 if (user_access('access conStruct import')) 00226 { 00227 $localPath = $base_url . "/" . drupal_get_path("module", "structImport") . "/imgs/"; 00228 00229 // For all users 00230 $menuItems .= "<img src=\"" . $localPath . "view_detailed.png\" style=\"padding-right:5px;\" alt=\"\" /><a href=\"" 00231 . $base_url . "/conStruct/import/\">Import</a><br />"; 00232 } 00233 00234 return variable_get('structImport_menu', t($menuItems)); 00235 } 00236 } 00237 00255 function structImport_menu() 00256 { 00257 $items = array(); 00258 00259 // Registration of the conStruct module settings page path 00260 /* 00261 $items['admin/settings/structImport'] = array( 'title' => '', 00262 'description' => '', 00263 'page callback' => 'drupal_get_form', 00264 'page arguments' => array('structImport_admin'), 00265 'access arguments' => array('access administration pages'), 00266 'type' => MENU_NORMAL_ITEM); 00267 */ 00268 // Registration of the main conStruct module page path 00269 $items['conStruct/import'] = array( 00270 'page callback' => 'structImport_main', 00271 'access callback' => 'structImport_access_callback', 00272 'type' => MENU_CALLBACK 00273 ); 00274 00275 return $items; 00276 } 00277 00278 00306 function structImport_perm() 00307 { 00308 return array( 00309 'access conStruct import', 00310 'administer conStruct import' 00311 ); 00312 } 00313 00314 00327 function conStruct_import() 00328 { 00329 // Make sure the user has access to this tool 00330 if (!user_access('access conStruct import')) 00331 { 00332 return "<h2>" . t("You don't have access to this tool, sorry.") . "</h2>"; 00333 } 00334 else 00335 { 00336 // Display errors when in debug mode 00337 /* 00338 if (!isset($_GET['debug']) || $_GET['debug'] != 1) 00339 { 00340 ini_set("error_reporting", 0); 00341 } 00342 */ 00343 00344 // always display errors for this module 00345 ini_set("display_errors", "On"); 00346 error_reporting(E_ALL); 00347 00348 $html = ""; 00349 00350 // Check if a file has been uploaded 00351 if (isset($_FILES) && count($_FILES) > 0) 00352 { 00353 // Check if the upload of the file is sucessful 00354 if ($_FILES['file']['error'] == UPLOAD_ERR_OK) 00355 { 00356 // Once we start the importation process, we have to make sure that even if the server 00357 // loose the connection with the user the process will still finish. 00358 ignore_user_abort(true); 00359 00360 // However, maybe there is an issue with the server handling that file tht lead to some kind of infinite or near 00361 // infinite loop; so we have to limit the execution time of this procedure to 45 mins. 00362 set_time_limit(2700); 00363 00364 // upload ok 00365 include_once('./' . drupal_get_path('module', 'conStruct') . '/framework/WebServiceQuerier.php'); 00366 include_once('./' . drupal_get_path('module', 'conStruct') . '/framework/ProcessorXML.php'); 00367 00368 $contentType = ""; 00369 00370 if (isset($_POST["ctype"])) 00371 { 00372 $contentType = $_POST["ctype"]; 00373 } 00374 00375 $datasetName = "Unnamed dataset"; 00376 00377 if (isset($_POST["dname"])) 00378 { 00379 $datasetName = $_POST["dname"]; 00380 } 00381 00382 $datasetDescription = "Unnamed dataset"; 00383 00384 if (isset($_POST["ddescription"])) 00385 { 00386 $datasetDescription = $_POST["ddescription"]; 00387 } 00388 00389 $wsfAddress = "http://localhost/ws/"; 00390 00391 if (isset($_POST["structwsf"])) 00392 { 00393 $wsfAddress = $_POST["structwsf"]; 00394 } 00395 00396 $rdfDocument = ""; 00397 00398 if (!move_uploaded_file($_FILES['userfile']['tmp_name'], "/tmp/" . $_FILES['userfile']['name'])) 00399 { 00400 return ""; 00401 } 00402 00403 // Read file form the server 00404 $file = fopen("/tmp/" . $_FILES['userfile']['name'], "r"); 00405 00406 while (!feof($file)) 00407 { 00408 $fileContent .= fread($file, 8192); 00409 } 00410 00411 fclose($file); 00412 00413 unlink("/tmp/" . $_FILES['userfile']['name']); 00414 00415 global $user; 00416 00417 // Create a new dataset where to index the imported data. 00418 // We create a new dataset by creating a OG group which mean 00419 // creating a new drupal Node which is a Group Node... 00420 00421 $node = array('type' => 'dataset'); 00422 00423 // Create a new Dataset where to index the imported dataset 00424 $form_state = array(); 00425 module_load_include('inc', 'node', 'node.pages'); 00426 $node = array('type' => 'dataset'); 00427 $form_state['values']['title'] = $datasetName; 00428 $form_state['values']['og_description'] = $datasetDescription; 00429 $form_state['values']['name'] = $user->name; 00430 $form_state['values']['field_wsf'][0]['value'] = 00431 substr(get_domain($wsfAddress), 7, strlen(get_domain($wsfAddress)) - 7); 00432 00433 $form_state['values']['op'] = t('Save'); 00434 00435 drupal_execute('dataset_node_form', $form_state, (object)$node); 00436 00437 $datasetDomain = variable_get("conStruct_UrisDomain", "localhost"); 00438 00439 $userIP = variable_get("conStruct_AccessUser" . $user->uid, ""); 00440 00441 if ($userIP == "") 00442 { 00443 // If there is no IP for that user, we overload the IP of the node with "::" 00444 $userIP = "self::$user->uid"; 00445 } 00446 00447 $dataset = urlencode("http://" . $datasetDomain . "/wsf/datasets/" . $form_state["nid"] . "/"); 00448 00449 // Handle conversion of the dataset if needed 00450 switch ($contentType) 00451 { 00452 case "bibjson": 00453 00454 case "irjson": 00455 $wsq = new WebServiceQuerier($wsfAddress . "converter/irjson/", "post", "application/rdf+xml", 00456 "document=" . urlencode($fileContent) . 00457 "&docmime=" . urlencode("application/iron+json") . 00458 "®istered_ip=" . urlencode($userIP)); 00459 if ($wsq->getStatus() != 200) 00460 { 00461 // In case of error, we have to delete the node we created above. 00462 node_delete($form_state["nid"]); 00463 00464 $wsq->displayError(); 00465 00466 return (""); 00467 } 00468 00469 $rdfDocument = $wsq->getResultset(); 00470 00471 $contentType = "application/rdf+xml"; 00472 00473 unset($wsq); 00474 break; 00475 00476 case "common": 00477 $wsq = new WebServiceQuerier($wsfAddress . "converter/common/", "post", "application/rdf+n3", 00478 "document=" . urlencode($fileContent) . 00479 "&docmime=" . urlencode("application/iron+csv") . 00480 "®istered_ip=" . urlencode($userIP)); 00481 00482 if ($wsq->getStatus() != 200) 00483 { 00484 // In case of error, we have to delete the node we created above. 00485 node_delete($form_state["nid"]); 00486 00487 $wsq->displayError(); 00488 00489 return (""); 00490 } 00491 00492 $rdfDocument = $wsq->getResultset(); 00493 00494 $contentType = "application/rdf+n3"; 00495 00496 unset($wsq); 00497 00498 break; 00499 00500 case "bibtex": 00501 $wsq = new WebServiceQuerier($wsfAddress . "converter/bibtex/", "post", "application/rdf+xml", 00502 "document=" . urlencode($fileContent) . 00503 "&docmime=" . urlencode("application/x-bibtex") . 00504 "®istered_ip=" . urlencode($userIP) . 00505 "&base_uri=" . $dataset . "resource/"); 00506 if ($wsq->getStatus() != 200) 00507 { 00508 // In case of error, we have to delete the node we created above. 00509 node_delete($form_state["nid"]); 00510 00511 $wsq->displayError(); 00512 00513 return (""); 00514 } 00515 00516 $rdfDocument = $wsq->getResultset(); 00517 $contentType = "application/rdf+xml"; 00518 00519 unset($wsq); 00520 break; 00521 00522 case "tsv": 00523 $wsq = new WebServiceQuerier($wsfAddress . "converter/tsv/", "post", "application/rdf+xml", 00524 "document=" . urlencode($fileContent) . 00525 "&docmime=" . urlencode("text/csv") . 00526 "&delimiter=\t" . 00527 "®istered_ip=" . urlencode($userIP) . 00528 "&base_uri=" . $dataset . "resource/"); 00529 if ($wsq->getStatus() != 200) 00530 { 00531 // In case of error, we have to delete the node we created above. 00532 node_delete($form_state["nid"]); 00533 00534 $wsq->displayError(); 00535 00536 return (""); 00537 } 00538 00539 $rdfDocument = $wsq->getResultset(); 00540 $contentType = "application/rdf+xml"; 00541 00542 unset($wsq); 00543 break; 00544 00545 case "csv": 00546 $wsq = new WebServiceQuerier($wsfAddress . "converter/tsv/", "post", "application/rdf+xml", 00547 "document=" . urlencode($fileContent) . 00548 "&docmime=" . urlencode("text/csv") . 00549 "&delimiter=" . urlencode(","), "®istered_ip=" . urlencode($userIP) . 00550 "&base_uri=" . $dataset . "resource/"); 00551 if ($wsq->getStatus() != 200) 00552 { 00553 // In case of error, we have to delete the node we created above. 00554 node_delete($form_state["nid"]); 00555 00556 $wsq->displayError(); 00557 00558 return (""); 00559 } 00560 00561 $rdfDocument = $wsq->getResultset(); 00562 $contentType = "application/rdf+xml"; 00563 00564 unset($wsq); 00565 break; 00566 00567 case "rdf_xml": 00568 $rdfDocument = $fileContent; 00569 $contentType = "application/rdf+xml"; 00570 break; 00571 00572 case "rdf_n3": 00573 $rdfDocument = $fileContent; 00574 $contentType = "application/rdf+n3"; 00575 break; 00576 00577 default: 00578 00579 // In case of error, we have to delete the node we created above. 00580 node_delete($form_state["nid"]); 00581 00582 drupal_set_message(t("Unknown content type"), "error", TRUE); 00583 00584 return ""; 00585 break; 00586 } 00587 00588 // Now check if some of the attributes/types imported are not currently defined in the 00589 // internal ontological structure. 00590 if(isset($_POST["checkAT"]) && $_POST["checkAT"] == "on") 00591 { 00592 include_once('./' . drupal_get_path('module', 'conStruct') . '/framework/arc2/ARC2.php'); 00593 00594 $parser = ARC2::getRDFParser(); 00595 $parser->parse("", $rdfDocument); 00596 00597 if($contentType == "application/rdf+xml") 00598 { 00599 $rdfxmlSerializer = ARC2::getRDFXMLSerializer(); 00600 } 00601 00602 if($contentType == "application/rdf+n3") 00603 { 00604 $rdfxmlSerializer = ARC2::getNTriplesSerializer(); 00605 } 00606 00607 $resourceIndex = $parser->getSimpleIndex(0); 00608 00609 $usedProperties = array(); 00610 00611 $usedTypes = array(); 00612 00613 // If we can read the generated rdf document with ARC2, we try to figure out if some 00614 // types/properties have been used which are not in the ontological structure. 00615 if(count($parser->getErrors()) <= 0 && $rdfxmlSerializer) 00616 { 00617 foreach($resourceIndex as $resource => $description) 00618 { 00619 foreach($description as $predicate => $values) 00620 { 00621 if($predicate == "http://www.w3.org/1999/02/22-rdf-syntax-ns#type") 00622 { 00623 foreach($values as $value) 00624 { 00625 if($value["type"] == "uri") 00626 { 00627 if(array_search($value["value"], $usedTypes) === FALSE) 00628 { 00629 array_push($usedTypes, $value["value"]); 00630 } 00631 } 00632 } 00633 } 00634 else 00635 { 00636 if(array_search($predicate, $usedProperties) === FALSE) 00637 { 00638 array_push($usedProperties, $predicate); 00639 } 00640 } 00641 } 00642 00643 if($break) 00644 { 00645 break; 00646 } 00647 } 00648 } 00649 unset($parser); 00650 } 00651 00652 // Import dataset by using the CrudCreate web service 00653 00654 $wsq = new WebServiceQuerier($wsfAddress . "crud/create/", "post", "text/xml", 00655 "document=" . urlencode($rdfDocument) . 00656 "&dataset=" . $dataset . 00657 "®istered_ip=" . urlencode($userIP) . 00658 "&mime=" . urlencode($contentType) . 00659 "&mode=full"); 00660 00661 if($wsq->getStatus() != 200) 00662 { 00663 // In case of error, we have to delete the node we created above. 00664 node_delete($form_state["nid"]); 00665 00666 // The size of the converted document is too big. 00667 if($wsq->error->id == "WSF-600") 00668 { 00669 // In case of error, we have to delete the node we created above. 00670 node_delete($form_state["nid"]); 00671 00672 $uploadMaxFileSize = ini_get("post_max_size"); 00673 $uploadMaxFileSize = str_replace("M", "000000", $uploadMaxFileSize); 00674 00675 // The converted dataset is too big to be processed by this tool 00676 drupal_set_message(t("The converted dataset file is too big to be processed by 00677 this import tool. You will have to split the file in multiple 00678 slices that you will import using this tool, and then append 00679 using the Append tool. Or you will have to create a new 00680 procedure that can handle files of that size. The size of the 00681 converted file is @sizeConverted bytes, and the autorized 00682 file size is @sizeAuthorized bytes", 00683 array("@sizeConverted" => number_format(strlen($rdfDocument), 0, " ", " "), 00684 "@sizeAuthorized" => number_format($uploadMaxFileSize, 0, " ", " "))), 00685 "error", TRUE); 00686 } 00687 else 00688 { 00689 $wsq->displayError(); 00690 } 00691 00692 return (""); 00693 } 00694 00695 unset($wsq); 00696 00697 $undefinedPredicates = array(); 00698 $undefinedTypes = array(); 00699 00700 if(isset($_POST["checkAT"]) && $_POST["checkAT"] == "on") 00701 { 00702 // Now check to make sure that all the predicates and types are in the ontological structure. 00703 include_once('./' . drupal_get_path('module', 'conStruct') . '/framework/ClassHierarchy.php'); 00704 include_once('./' . drupal_get_path('module', 'conStruct') . '/framework/PropertyHierarchy.php'); 00705 include_once(drupal_get_path('module', 'structBrowse') . '/settings.php'); 00706 00707 $userIP = variable_get("conStruct_AccessUser" . $user->uid, ""); 00708 $filename = './' . drupal_get_path('module', 'conStruct') . '/framework/ontologies/classHierarchySerialized.srz'; 00709 $file = fopen($filename, "r"); 00710 $classHierarchy = fread($file, filesize($filename)); 00711 $classHierarchy = unserialize($classHierarchy); 00712 fclose($file); 00713 00714 $filename = './' . drupal_get_path('module', 'conStruct') . '/framework/ontologies/propertyHierarchySerialized.srz'; 00715 $file = fopen($filename, "r"); 00716 $propertyHierarchy = fread($file, filesize($filename)); 00717 $propertyHierarchy = unserialize($propertyHierarchy); 00718 fclose($file); 00719 00720 foreach($usedProperties as $usedPredicate) 00721 { 00722 $found = FALSE; 00723 foreach($propertyHierarchy->properties as $property) 00724 { 00725 if($property->name == $usedPredicate) 00726 { 00727 $found = TRUE; 00728 break; 00729 } 00730 } 00731 00732 if($found === FALSE) 00733 { 00734 array_push($undefinedPredicates, $usedPredicate); 00735 } 00736 } 00737 00738 foreach($usedTypes as $type) 00739 { 00740 $found = FALSE; 00741 foreach($classHierarchy->classes as $class) 00742 { 00743 if($class->name == $type) 00744 { 00745 $found = TRUE; 00746 break; 00747 } 00748 } 00749 00750 if($found === FALSE) 00751 { 00752 array_push($undefinedTypes, $type); 00753 } 00754 } 00755 } 00756 else 00757 { 00758 drupal_set_message(t("Checking of un-handled attributes and types has been disabled by the importer. 00759 Make sure that all the types and attributes used to describe the imported 00760 dataset are defined in the ontological structure of this node. Otherwise 00761 unwelcome behaviors could happen."), "warning", TRUE); 00762 00763 return("<form><input type=\"button\" value=\"Browse Imported Dataset\" onClick=\"parent.location='../browse/?browse=1&page=0&attribute=all&type=all&dataset=$dataset'\" /></form>"); 00764 } 00765 00766 if(count($undefinedPredicates) == 0 && count($undefinedTypes) == 0) 00767 { 00768 // Redirect to its browse page 00769 header("Location: ../browse/?browse=1&page=0&attribute=all&type=all&dataset=" . $dataset); 00770 } 00771 else 00772 { 00773 // We display the missing predicates & classes notices with a button 00774 00775 $pErrors = ""; 00776 00777 if(count($undefinedPredicates) > 0) 00778 { 00779 $pErrors = "<h2>Undefined Attributes</h2><ol>"; 00780 foreach($undefinedPredicates as $p) 00781 { 00782 $pErrors .= "<li>$p</li>"; 00783 } 00784 $pErrors .= "</ol>"; 00785 } 00786 00787 $errorMsg = "Warning: some types and attributes were used in the file that you were importing that are not 00788 currently defined in the ontological structure of this system. Everything will works 00789 fine, but some unexpected display behaviors could occurs for some usecase. We 00790 suggest to take these attributes and types in node to define them in the ontological 00791 structure in the future."; 00792 00793 drupal_set_message(t("@warning", array("@warning" => $errorMsg)), "warning", TRUE); 00794 00795 foreach($undefinedPredicates as $p) 00796 { 00797 drupal_set_message(t("Undefined attributes: @warning", array("@warning" => $p)), "warning", TRUE); 00798 } 00799 00800 foreach($undefinedTypes as $t) 00801 { 00802 drupal_set_message(t("Undefined types: @warning", array("@warning" => $t)), "warning", TRUE); 00803 } 00804 00805 return("<form><input type=\"button\" value=\"Browse Imported Dataset\" onClick=\"parent.location='../browse/?browse=1&page=0&attribute=all&type=all&dataset=$dataset'\" /></form>"); 00806 } 00807 } 00808 else 00809 { 00810 drupal_set_message(t("File upload failed with error: @error", 00811 array("@error" => file_upload_error_message($_FILES['file']['error']))), "error", TRUE); 00812 00813 return(""); 00814 } 00815 } 00816 else 00817 { 00818 $html .= "<h2>Import Dataset</h2>"; 00819 00820 // Get all available structWSF instances available to this conStruct node 00821 00822 /* 00823 $sidRegistry = variable_get("SID-Registry", array()); 00824 00825 $sidHtml = ""; 00826 00827 foreach ($sidRegistry as $s => $wsfs) 00828 { 00829 $sidHtml .= "<option value=\"" . $wsfs[0] . "\" /> " . $wsfs[0]; 00830 } 00831 */ 00832 00833 $wsfRegistry = variable_get("WSF-Registry", array()); 00834 00835 $sidHtml = ""; 00836 00837 foreach ($wsfRegistry as $s => $wsfs) 00838 { 00839 $sidHtml .= "<option value=\"" . $wsfs . "\" /> " . $wsfs; 00840 } 00841 00842 // If no SID are available, lets test if there is a local structWSF instance available 00843 if ($sidHtml == "") 00844 { 00845 $ch = curl_init(); 00846 00847 curl_setopt($ch, CURLOPT_HEADER, 0); 00848 curl_setopt($ch, CURLOPT_URL, "http://localhost/ws/index.php"); 00849 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 00850 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); 00851 00852 $data = curl_exec($ch); 00853 00854 if (curl_errno($ch)) 00855 { 00856 curl_close($ch); 00857 00858 // no local SID are existing, so we send an error to the user. 00859 drupal_set_message(t("No structWSF instance are available for this conStruct node. Please" . 00860 "contact the system administrator to link this conStruct instance" . 00861 "to a structWSF instance."), "error", TRUE); 00862 00863 return (""); 00864 } 00865 else 00866 { 00867 $sidHtml .= "<option value=\"http://localhost/ws/\" /> http://localhost/ws/"; 00868 } 00869 00870 curl_close($ch); 00871 } 00872 00873 $html 00874 .= " <form enctype=\"multipart/form-data\" action=\"\" method=\"POST\"> 00875 00876 <!--<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"30000\" />--> 00877 00878 <table width=\"100%\" border=\"0\"> 00879 <tr><td> </td><td> </td></tr> 00880 <tr> 00881 <td> 00882 Dataset file to import: 00883 </td> 00884 <td> 00885 <input name=\"userfile\" type=\"file\" size=\"61\" /> 00886 </td> 00887 </tr> 00888 <tr> 00889 <td> 00890 Content type: 00891 </td> 00892 <td> 00893 <select name=\"ctype\" size=\"1\" style=\"width: 400px;\"> 00894 <!--<option value=\"bibjson\" /> BibJSON--> 00895 <option value=\"common\" /> commON (csv) 00896 <option value=\"irjson\" /> irJSON 00897 <!--<option value=\"bibtex\" /> BibTex--> 00898 <option value=\"tsv\" /> N-Triples/TSV 00899 <option value=\"csv\" /> N-Triples/CSV 00900 <option value=\"rdf_xml\" /> RDF+XML 00901 <option value=\"rdf_n3\" /> RDF+N3 00902 </select> 00903 </td> 00904 </tr> 00905 <tr> 00906 <td> 00907 Dataset name: 00908 </td> 00909 <td> 00910 <input name=\"dname\" type=\"text\" size=\"64\" maxlength=\"256\" /> 00911 </td> 00912 </tr> 00913 <tr> 00914 <td> 00915 Dataset description: 00916 </td> 00917 <td> 00918 <input name=\"ddescription\" type=\"text\" size=\"64\" maxlength=\"256\" /> 00919 </td> 00920 </tr> 00921 <tr> 00922 <td> 00923 Save dataset on this network: 00924 </td> 00925 <td> 00926 <select name=\"structwsf\" size=\"1\" style=\"width: 400px;\"> 00927 $sidHtml 00928 </select> 00929 </td> 00930 </tr> 00931 <tr> 00932 <td style=\"padding-top: 15px;\"> 00933 Check attributes and types existance: <br> 00934 <b>Time consuming</b> 00935 </td> 00936 <td style=\"padding-top: 15px;\"> 00937 <input type=\"checkbox\" name=\"checkAT\" checked> Check for missing attributes and types 00938 in the imported dataset. <br />This should be unchecked for big datasets because of 00939 the resources needed to make this check. 00940 </td> 00941 </tr> 00942 <tr><td> </td><td> </td></tr> 00943 <tr> 00944 <td colspan=\"2\" align=\"center\"> 00945 <input type=\"submit\" value=\"Import Dataset\" /> 00946 </td> 00947 </tr> 00948 </table> 00949 </form> 00950 "; 00951 } 00952 00953 return ($html); 00954 } 00955 } 00956 00957 function file_upload_error_message($error_code) 00958 { 00959 switch ($error_code) 00960 { 00961 case UPLOAD_ERR_INI_SIZE: 00962 00963 { 00964 return 'File size is too big. The maximum file size is 8mb.'; 00965 } 00966 00968 case UPLOAD_ERR_FORM_SIZE: 00969 00970 { 00971 return 'File size is too big. The maximum file size is 8mb.'; 00972 } 00973 00974 case UPLOAD_ERR_PARTIAL: 00975 00976 { 00977 return 'The uploaded file was only partially uploaded'; 00978 } 00979 00980 case UPLOAD_ERR_NO_FILE: 00981 00982 { 00983 return 'No file was uploaded'; 00984 } 00985 00986 case UPLOAD_ERR_NO_TMP_DIR: 00987 00988 { 00989 return 'Missing a temporary folder'; 00990 } 00991 00992 case UPLOAD_ERR_CANT_WRITE: 00993 00994 { 00995 return 'Failed to write file to disk'; 00996 } 00997 00998 case UPLOAD_ERR_EXTENSION: 00999 01000 { 01001 return 'File upload stopped by extension'; 01002 } 01003 01004 default: 01005 return 'Unknown upload error'; 01006 } 01007 } 01009 ?>
