示例#1
0
 function handle()
 {
     $output = array();
     // Get and handle a comma-seperated list of valid params which we will forward to the indexer
     $permitted_forwarding_params = explode(',', $this->options['valid_solr_params']);
     $forwarded_params = array_intersect_key(array_flip($permitted_forwarding_params), $this->params);
     $fields = array();
     foreach ($forwarded_params as $param_name => $_) {
         $fields[$param_name] = $this->params[$param_name];
     }
     $fields = array_merge($this->default_params, $fields);
     $CI =& get_instance();
     $CI->load->library('solr');
     foreach ($fields as $key => $field) {
         $CI->solr->setOpt($key, $field);
     }
     // Get back a list of IDs for matching registry objects
     $result = $CI->solr->executeSearch(true);
     $rifcsOutput = array();
     if (isset($result['response']['docs']) && is_array($result['response']['docs'])) {
         foreach ($result['response']['docs'] as $result) {
             $CI->load->model('registry_object/registry_objects', 'ro');
             $registryObject = $CI->ro->getByID($result['id']);
             if ($registryObject) {
                 $rifcsOutput[] .= str_repeat(" ", 8) . trim(unWrapRegistryObjects($registryObject->getExtRif()));
             }
         }
     }
     // Bubble back the output status
     return $this->formatter->display($rifcsOutput);
 }
 function extractRIFCSfromQueue($pullback_queue)
 {
     $fragments = '';
     if (is_array($pullback_queue)) {
         foreach ($pullback_queue as $identifier) {
             $fragment = $this->pullbackRIFCSfromNLA(trim($identifier));
             if ($fragment) {
                 $fragments .= unWrapRegistryObjects($fragment);
             }
         }
         $fragments = wrapRegistryObjects($fragments);
     }
     return $fragments;
 }
 function exportDataSource($id)
 {
     parse_str($_SERVER['QUERY_STRING'], $_GET);
     $as = 'xml';
     $formatString = 'rif-cs';
     $statusString = '';
     $classString = '';
     $data = json_decode($this->input->get('data'));
     foreach ($data as $param) {
         if ($param->name == 'ro_class') {
             $classString .= $param->value;
         }
         if ($param->name == 'as') {
             $as = $param->value;
         }
         if ($param->name == 'ro_status') {
             $statusString .= $param->value;
         }
         if ($param->name == 'format') {
             $formatString = $param->value;
         }
     }
     $this->load->model("data_sources", "ds");
     $this->load->model("registry_object/registry_objects", "ro");
     $dataSource = $this->ds->getByID($id);
     $dsSlug = $dataSource->getAttribute('slug');
     $rifcs = '';
     $dciOutput = '';
     $ids = $this->ro->getIDsByDataSourceID($id, false, 'All');
     if ($ids) {
         $i = 0;
         foreach ($ids as $idx => $ro_id) {
             try {
                 $ro = $this->ro->getByID($ro_id);
                 if ($formatString == 'dci') {
                     $dciOutput .= $ro->transformToDCI(false);
                 } elseif ($ro && strpos($classString, $ro->class) !== false && strpos($statusString, $ro->status) !== false) {
                     $rifcs .= unWrapRegistryObjects($ro->getRif()) . NL;
                 }
             } catch (Exception $e) {
             }
             if ($idx % 100 == 0) {
                 unset($ro);
                 gc_collect_cycles();
             }
         }
     }
     if ($formatString == 'dci') {
         $result = '<?xml version="1.0"?>' . NL;
         $result .= '<DigitalContentData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DCI_schema_providers_V4.1.xsd">' . NL;
         $result .= $dciOutput;
         $result .= '</DigitalContentData>';
     } else {
         $result = wrapRegistryObjects($rifcs);
     }
     if ($as == 'file') {
         $this->load->helper('download');
         force_download($dsSlug . '-' . strtoupper($formatString) . '-Export.xml', $result);
     } else {
         header('Cache-Control: no-cache, must-revalidate');
         header('Content-type: application/xml');
         echo $result;
     }
 }
 public function init()
 {
     acl_enforce('REGISTRY_STAFF');
     $this->load->library('importer');
     $slogTitle = 'Import from URL completed successfully' . NL;
     $elogTitle = 'An error occurred whilst importing from the specified URL' . NL;
     $log = 'IMPORT LOG' . NL;
     //$log .= 'URI: ' . $this->input->post('url') . NL;
     $log .= 'Harvest Method: Direct import from URL' . NL;
     $this->load->model('data_source/data_sources', 'ds');
     $data_source = $this->ds->getByKey($this->config->item('example_ds_key'));
     if (!$this->config->item('example_ds_key')) {
         echo "Example DataSource Key is required to complete the task" . NL;
         return;
     }
     if (!$data_source) {
         $data_source = $this->ds->create($this->config->item('example_ds_key'), url_title($this->config->item('example_ds_title')));
         $data_source->setAttribute('title', $this->config->item('example_ds_title'));
         $data_source->setAttribute('record_owner', 'superuser');
         $data_source->save();
         $data_source->updateStats();
         $data_source = $this->ds->getByKey($this->config->item('example_ds_key'));
     }
     $sampleRecordUrls = array('http://services.ands.org.au/documentation/rifcs/1.6/examples/eg-collection-1.xml', 'http://services.ands.org.au/documentation/rifcs/1.6/examples/eg-party-1.xml', 'http://services.ands.org.au/documentation/rifcs/1.6/examples/eg-service-1.xml', 'http://services.ands.org.au/documentation/rifcs/1.6/examples/eg-activity-1.xml');
     $xml = '';
     foreach ($sampleRecordUrls as $recUrl) {
         $xml .= unWrapRegistryObjects(file_get_contents($recUrl));
     }
     $this->importer->setXML(wrapRegistryObjects($xml));
     $this->importer->setDatasource($data_source);
     $this->importer->commit(false);
     $this->importer->finishImportTasks();
     $data_source->updateStats();
     if ($error_log = $this->importer->getErrors()) {
         $log .= $elogTitle . $log . $error_log;
         $data_source->append_log($log, HARVEST_ERROR, "HARVEST_ERROR");
     }
     //else{
     $log .= $slogTitle . $log . $this->importer->getMessages();
     $data_source->append_log($log, HARVEST_INFO, "HARVEST_INFO");
     header('Location: ' . registry_url('data_source/manage_records/' . $data_source->id));
     exit;
 }
示例#5
0
 function cleanRIFCSofEmptyTags($rifcs, $removeFormAttributes = 'true')
 {
     if (strlen($rifcs) > 50000) {
         $rifcs = preg_replace('/<relatedObject.*?<\\/relatedObject>|\\s{2,}/ms', '', $rifcs);
     }
     $xslt_processor = Transforms::get_form_to_cleanrif_transformer();
     $dom = new DOMDocument();
     //$dom->loadXML($this->ro->getXML());
     $dom->loadXML(wrapRegistryObjects(unWrapRegistryObjects($rifcs)));
     //$dom->loadXML($rifcs);
     $xslt_processor->setParameter('', 'removeFormAttributes', $removeFormAttributes);
     return $xslt_processor->transformToXML($dom);
 }