示例#1
0
 function register_dataspace($dataspace_def)
 {
     $ds_name = $dataspace_def->get_name();
     if (isset($this->dataspace_defs[$ds_name])) {
         trigger_error("Duplicate dataspace definition: " . $ds_name, E_USER_ERROR);
     }
     if ($dataspace_def->get_content_type() === MW_RESOURCE_CONTENT_TYPE_BINARY) {
         if (isset($this->binary_dataspace)) {
             trigger_error("Only one dataspace with binary content allowed: " . $this->binary_dataspace . ", " . $ds_name, E_USER_ERROR);
         }
         $this->binary_dataspace = $ds_name;
     }
     if ($dataspace_def->get_content_type() === MW_RESOURCE_CONTENT_TYPE_TEXT) {
         if (isset($this->text_dataspace)) {
             trigger_error("Only one dataspace with text content allowed: " . $this->text_dataspace . ", " . $ds_name, E_USER_ERROR);
         }
         $this->text_dataspace = $ds_name;
     }
     if ($dataspace_def->get_content_type() !== MW_RESOURCE_CONTENT_TYPE_NONE) {
         if (sizeof($dataspace_def->get_custom_keys()) > 0) {
             trigger_error("No custom keys allows in dataspace with content: " . $ds_name, E_USER_ERROR);
         }
     }
     if (config('install_mode')) {
         if ($this->binary_dataspace === $ds_name) {
             $root = $this->get_ds_dirname_url($this->text_dataspace);
         } else {
             $root = $this->get_ds_dirname_url($ds_name);
         }
         show_install_message("Dataspace " . $ds_name . ": root directory " . $root);
         if (!is_dir($root)) {
             show_install_message("Creating root directory {$root} for dataspace {$ds_name}");
             if (!mkdir($root)) {
                 trigger_error("Error creating root directory {$root} for dataspace {$ds_name}", E_USER_ERROR);
             }
         }
     }
     $this->dataspace_defs[$ds_name] = $dataspace_def;
 }
示例#2
0
function import_with_check($file, $ds_name = null, $res_name = null)
{
    if ($ds_name !== null) {
        $storage =& get_storage();
        if ($storage->exists($ds_name, $res_name)) {
            show_install_message('NOT importing data from ' . $file . ', because ' . $res_name . ' exists');
            return;
        }
    }
    show_install_message('Importing data from ' . $file);
    $status = import($file);
    global $import_with_errors;
    if ($status === null) {
        trigger_error("Unable to import {$file} - is required extension missing?", E_USER_ERROR);
        $import_with_errors = true;
    } else {
        if ($status !== true) {
            trigger_error("Error occurred while importing {$file}: {$status}", E_USER_ERROR);
            $import_with_errors = true;
        }
    }
}
示例#3
0
 function register_dataspace($dataspace_def)
 {
     $ds_name = $dataspace_def->get_name();
     if (config('install_mode')) {
         show_install_message("Dataspace " . $ds_name . ": MySQL database " . $this->dbname . "@" . $this->host . ", table " . $ds_name);
         if (!$this->exists_table($ds_name)) {
             $this->create_dataspace_table($dataspace_def);
         } else {
             $this->alter_dataspace_table($dataspace_def);
         }
     }
     if (isset($this->dataspace_defs[$ds_name])) {
         trigger_error("Duplicate dataspace definition: " . $ds_name, E_USER_ERROR);
     }
     $this->dataspace_defs[$ds_name] = $dataspace_def;
 }