Beispiel #1
0
 private function loadSearchData($searchData)
 {
     \okapi\OkapiErrorHandler::reenable();
     // We need to transform OC's "searchdata" into OKAPI's "search set".
     // First, we need to determine if we ALREADY did that.
     // Note, that this is not exactly thread-efficient. Multiple threads may
     // do this transformation in the same time. However, this is done only once
     // for each searchdata, so we will ignore it.
     $cache_key = "OC_searchdata_" . $searchData;
     $set_id = \okapi\Cache::get($cache_key);
     if ($set_id === null) {
         // Read the searchdata file into a temporary table.
         $filepath = \okapi\Settings::get('VAR_DIR') . "/searchdata/" . $searchData;
         \okapi\Db::execute("\n            create temporary table temp_" . $searchData . " (\n                cache_id integer primary key\n            ) engine=memory\n        ");
         if (file_exists($filepath)) {
             \okapi\Db::execute("\n                        load data local infile '{$filepath}'\n                        into table temp_" . $searchData . "\n                fields terminated by ' '\n                lines terminated by '\\n'\n                (cache_id)\n            ");
         }
         // Tell OKAPI to import the table into its own internal structures.
         // Cache it for two hours.
         $set_info = \okapi\Facade::import_search_set("temp_" . $searchData, 7200, 7200);
         $set_id = $set_info['set_id'];
         \okapi\Cache::set($cache_key, $set_id, 7200);
     }
     $this->search_params['set_and'] = $set_id;
     $this->search_params['status'] = "Available|Temporarily unavailable|Archived";
     \okapi\OkapiErrorHandler::disable();
     return true;
 }
Beispiel #2
0
    # First, we need to determine if we ALREADY did that.
    # Note, that this is not exactly thread-efficient. Multiple threads may
    # do this transformation in the same time. However, this is done only once
    # for each searchdata, so we will ignore it.
    $cache_key = "OC_searchdata_" . $searchdata;
    $set_id = \okapi\Cache::get($cache_key);
    if ($set_id === null) {
        # Read the searchdata file into a temporary table.
        $filepath = \okapi\Settings::get('VAR_DIR') . "/searchdata/" . $searchdata;
        \okapi\Db::execute("\n            create temporary table temp_" . $searchdata . " (\n                cache_id integer primary key\n            ) engine=memory\n        ");
        if (file_exists($filepath)) {
            \okapi\Db::execute("\n                load data local infile '{$filepath}'\n                into table temp_" . $searchdata . "\n                fields terminated by ' '\n                lines terminated by '\\n'\n                (cache_id)\n            ");
        }
        # Tell OKAPI to import the table into its own internal structures.
        # Cache it for two hours.
        $set_info = \okapi\Facade::import_search_set("temp_" . $searchdata, 7200, 7200);
        $set_id = $set_info['set_id'];
        \okapi\Cache::set($cache_key, $set_id, 7200);
    }
    $params['set_and'] = $set_id;
    $params['status'] = "Available|Temporarily unavailable|Archived";
    \okapi\OkapiErrorHandler::disable();
} else {
    # Mode 1 - without "searchdata".
    # h_ignored - convert to OKAPI's "exclude_ignored".
    if ($_GET['h_ignored'] == "true") {
        $params['exclude_ignored'] = "true";
    }
    # h_avail, h_temp_unavail, h_arch ("hide available" etc.) - convert to
    # OKAPI's "status" filter.
    $tmp = array();