function characterDataHandler($parser, $data)
 {
     if (end($this->_tagstack) == 'GRANULARITY') {
         if ($data == "YYYY-MM-DDThh:mm:ssZ") {
             $this->_dateFormat = "Y-m-d\\TH:i:s\\Z";
         } else {
             if ($data == "YYYY-MM-DD") {
                 $this->_dateFormat = "Y-m-d";
             } else {
                 $this->_dateFormat = false;
             }
         }
     } else {
         if (end($this->_tagstack) == 'EARLIESTDATESTAMP') {
             $this->_earliestDatestamp = ISO8601toUTC($data);
         } else {
             if (end($this->_tagstack) == 'REPOSITORYNAME') {
                 $this->_repositoryName .= $data;
             }
         }
     }
 }
コード例 #2
0
 /**
  * 
  * process demand of ListRecords, and return part of <LifeRecords> in the result.
  * making of <record> uses record function.
  * @see record
  * 
  * @param args: hash contained demand of arguments. array( 'identifier' => identifier of items )
  * @return <ListRecords> in XML  success
  * @return <error> in XML  failure
  * 
  */
 function ListRecords($args)
 {
     $xconfig_handler =& xoonips_getormhandler('xoonips', 'config');
     $from = 0;
     $until = 0;
     $set = null;
     $start_iid = 0;
     $limit_row = REPOSITORY_RESPONSE_LIMIT_ROW;
     $expire_term = REPOSITORY_RESUMPTION_TOKEN_EXPIRE_TERM;
     foreach (array('from', 'until', 'resumptionToken', 'set') as $k) {
         if (isset($args[$k])) {
             ${$k} = $args[$k];
         }
     }
     if ($from != 0) {
         $from = ISO8601toUTC($from);
     }
     if ($until != 0) {
         $until = ISO8601toUTC($until);
     }
     if (isset($resumptionToken)) {
         $result = getResumptionToken($resumptionToken);
         if (!$result) {
             return parent::error('badResumptionToken', '');
         }
         if (isset($result['args']['from'])) {
             $from = ISO8601toUTC($result['args']['from']);
         }
         if (isset($result['args']['until'])) {
             $until = ISO8601toUTC($result['args']['until']);
         }
         if (isset($result['last_item_id'])) {
             $start_iid = $result['last_item_id'] + 1;
         }
         if (isset($result['limit_row'])) {
             $limit_row = $result['limit_row'];
         }
         if (isset($result['args']['set'])) {
             $set = $result['args']['set'];
         }
         if (isset($result['publish_date'])) {
             //expire resumptionToken if repository is modified after resumptionToken has published
             $iids = array();
             if (RES_OK == xnp_selective_harvesting((int) $result['publish_date'], 0, null, 0, 1, $iids)) {
                 if (count($iids) > 0) {
                     expireResumptionToken($resumptionToken);
                     return parent::error('badResumptionToken', 'repository has been modified');
                 }
             }
         }
     }
     $identifiers = array();
     if (RES_OK != xnp_selective_harvesting((int) $from, (int) $until, $set, (int) $start_iid, (int) $limit_row, $identifiers) || count($identifiers) == 0) {
         return parent::error('noRecordsMatch', '');
     }
     $iids = array();
     foreach ($identifiers as $i) {
         $iids[] = $i['item_id'];
     }
     if (isset($resumptionToken) && count($iids) < $limit_row) {
         expireResumptionToken($resumptionToken);
     } else {
         if (count($iids) == 0) {
             return parent::error('noRecordsMatch', '');
         }
     }
     if (count($iids) == $limit_row) {
         $resumptionToken = session_id();
         setResumptionToken($resumptionToken, $this->metadataPrefix, 'ListRecords', $args, max($iids), $limit_row, time() + $expire_term);
         $resumptionToken = "<resumptionToken>{$resumptionToken}</resumptionToken>\n";
     } else {
         $resumptionToken = "";
     }
     $index_tree_list = xnpListIndexTree(XOONIPS_LISTINDEX_PUBLICONLY, true);
     $nijc_code = $xconfig_handler->getValue('repository_nijc_code');
     if (!empty($nijc_code)) {
         $records = array();
         $errors = array();
         foreach ($identifiers as $item) {
             list($xml, $result) = $this->record($item, $index_tree_list);
             if ($result) {
                 $records[] = $xml;
             } else {
                 $errors[] = $xml;
             }
         }
         if (count($identifiers) == 0) {
             return parent::error('noRecordsMatch', '');
         } else {
             return "<ListRecords>\n" . implode("\n", $records) . $resumptionToken . "</ListRecords>\n";
         }
     } else {
         return parent::error('idDoesNotExist', 'nijc_code is not configured');
     }
 }