|
@@ -0,0 +1,516 @@
|
|
1
|
+<?php
|
|
2
|
+defined('BASEPATH') or exit('No direct script access allowed');
|
|
3
|
+
|
|
4
|
+class ParserFile extends CI_Controller
|
|
5
|
+{
|
|
6
|
+ protected $rutaDiaria = FCPATH . "DOWNLOADS/DAILY/format";
|
|
7
|
+ protected $rutaMensual = FCPATH . "DOWNLOADS/MONTH/format";
|
|
8
|
+ protected $esquema = array('cbc-place-ext', 'cac-place-ext', 'cbc', 'cac', 'ns1');
|
|
9
|
+
|
|
10
|
+ public function __construct()
|
|
11
|
+ {
|
|
12
|
+ parent::__construct();
|
|
13
|
+ $this->load->helper('file');
|
|
14
|
+ }
|
|
15
|
+
|
|
16
|
+ public function index()
|
|
17
|
+ {
|
|
18
|
+ $files = get_filenames($this->rutaDiaria, true);
|
|
19
|
+
|
|
20
|
+ $contadorArchivos = 0;
|
|
21
|
+ foreach ($files as $file) {
|
|
22
|
+
|
|
23
|
+ $entrada = file_get_contents($file);
|
|
24
|
+ $xml = simplexml_load_string($entrada);
|
|
25
|
+
|
|
26
|
+ $aux = 0;
|
|
27
|
+ $resultEntries = array();
|
|
28
|
+ foreach ($xml->entry as $clave => $row) {
|
|
29
|
+ $arrayDeletedEntries = $xml->children('at', true);
|
|
30
|
+
|
|
31
|
+ $resultEntries[$aux]['contractInfo'] = $this->nodoContractFolderStatus($row);
|
|
32
|
+
|
|
33
|
+ $resultEntries[$aux]['locatedContractingParty'] = $this->nodoLocatedContractingParty($row);
|
|
34
|
+
|
|
35
|
+ $resultEntries[$aux]['party'] = $this->nodoParty($row);
|
|
36
|
+
|
|
37
|
+ //$resultEntries[] = $this->nodoParentLocatedParty($row);
|
|
38
|
+
|
|
39
|
+ $resultEntries[$aux]['procurementProject'] = $this->nodoPresupuesto($row);
|
|
40
|
+
|
|
41
|
+ $resultEntries[$aux]['procurementProjectLot'] = $this->nodoProcurementProjectLot($row);
|
|
42
|
+
|
|
43
|
+ $resultEntries[$aux]['tenderingTerms'] = $this->nodoTenderingTerms($row);
|
|
44
|
+
|
|
45
|
+ $resultEntries[$aux]['tenderingProcess'] = $this->nodoTenderingProcess($row);
|
|
46
|
+
|
|
47
|
+ $resultEntries[$aux]['tenderingResult'] = $this->nodoTenderResult($row);
|
|
48
|
+
|
|
49
|
+ $resultEntries[$aux]['legalDocs'] = $this->nodoLegalDoc($row);
|
|
50
|
+
|
|
51
|
+ $resultEntries[$aux]['techicalDocs'] = $this->nodoTechnicalDocumentReference($row);
|
|
52
|
+
|
|
53
|
+ $resultEntries[$aux]['validNoticeInfo'] = $this->nodoValidNoticeInfo($row);
|
|
54
|
+
|
|
55
|
+ $resultEntries[$aux]['generalDocs'] = $this->nodoGeneralDocuments($row);
|
|
56
|
+
|
|
57
|
+ $resultEntries[$aux]['additionalDocs'] = $this->nodoAdditionalDocumentReference($row);
|
|
58
|
+
|
|
59
|
+ $aux++;
|
|
60
|
+ }
|
|
61
|
+
|
|
62
|
+ $str = print_r($resultEntries, true);
|
|
63
|
+
|
|
64
|
+ file_put_contents($this->rutaDiaria . "/text" . $contadorArchivos . ".txt", $str);
|
|
65
|
+
|
|
66
|
+ $contadorArchivos++;
|
|
67
|
+
|
|
68
|
+ }
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ private function nodoContractFolderStatus($xml)
|
|
72
|
+ {
|
|
73
|
+ $resultEntries = array();
|
|
74
|
+ if (isset($xml->ContractFolderStatus)) {
|
|
75
|
+ $resultEntries['ContractFolderID'] = (string) $xml->ContractFolderStatus->ContractFolderID;
|
|
76
|
+ $resultEntries['ContractFolderStatusCode'] = (string) $xml->ContractFolderStatus->ContractFolderStatusCode;
|
|
77
|
+ $resultEntries['ContractFolderStatusCodeAttr'] = (string) $xml->ContractFolderStatus->ContractFolderStatusCode->attributes()['listURI'];
|
|
78
|
+ }
|
|
79
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
80
|
+ return $resultFinal;
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ private function nodoLocatedContractingParty($xml)
|
|
84
|
+ {
|
|
85
|
+ $resultEntries = array();
|
|
86
|
+ if (isset($xml->ContractFolderStatus->LocatedContractingParty)) {
|
|
87
|
+ $LocatedContractingParty = $xml->ContractFolderStatus->LocatedContractingParty;
|
|
88
|
+
|
|
89
|
+ $resultEntries['contractingPartyTypeCode'] = $this->existNodo($LocatedContractingParty, "ContractingPartyTypeCode", 'string');
|
|
90
|
+ $resultEntries['activityCode'] = $this->existNodo($LocatedContractingParty, "ActivityCode", 'string');
|
|
91
|
+ $resultEntries['buyerProfileURIID'] = $this->existNodo($LocatedContractingParty, "BuyerProfileURIID", 'string');
|
|
92
|
+
|
|
93
|
+ if (isset($LocatedContractingParty->ParentLocatedParty)) {
|
|
94
|
+ //$resultEntries['activityCode'] = $this->existNodo($LocatedContractingParty->ParentLocatedParty, "PartyName", 'string');
|
|
95
|
+
|
|
96
|
+ $this->RecurseXML($LocatedContractingParty->ParentLocatedParty);
|
|
97
|
+ }
|
|
98
|
+ }
|
|
99
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
100
|
+ return $resultFinal;
|
|
101
|
+ }
|
|
102
|
+
|
|
103
|
+ private function nodoParty($xml)
|
|
104
|
+ {
|
|
105
|
+ $resultEntries = array();
|
|
106
|
+ $contractFolder = $xml->ContractFolderStatus->LocatedContractingParty;
|
|
107
|
+
|
|
108
|
+ if (isset($contractFolder->Party)) {
|
|
109
|
+ //Datos Empresa -> direccion,nif, etc
|
|
110
|
+ //LocatedContractingParty->Party
|
|
111
|
+ $party = $contractFolder->Party;
|
|
112
|
+ $resultEntries['websiteURI'] = $this->existNodo($party, "WebsiteURI", 'string');
|
|
113
|
+ $resultEntries['partyIdentification'] = $this->existNodo($party, "PartyIdentification", 'array');
|
|
114
|
+ $resultEntries['partyName'] = $this->existNodo($party->PartyName, "Name", 'string');
|
|
115
|
+ $resultEntries['address']['city'] = $this->existNodo($party->PostalAddress, "CityName", 'string');
|
|
116
|
+ $resultEntries['address']['codpostal'] = $this->existNodo($party->PostalAddress, "PostalZone", 'string');
|
|
117
|
+ $resultEntries['address']['direccion'] = $this->existNodo($party->PostalAddress->AddressLine, "Line", 'string');
|
|
118
|
+ $resultEntries['address']['country'] = $this->existNodo($party->PostalAddress->Country, "Name", 'string');
|
|
119
|
+ $resultEntries['contact']['name'] = $this->existNodo($party->Contact, "Name", 'string');
|
|
120
|
+ $resultEntries['contact']['email'] = $this->existNodo($party->Contact, "ElectronicMail", 'string');
|
|
121
|
+ }
|
|
122
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
123
|
+ return $resultFinal;
|
|
124
|
+ }
|
|
125
|
+
|
|
126
|
+ private function nodoPresupuesto($xml)
|
|
127
|
+ {
|
|
128
|
+ $resultEntries = array();
|
|
129
|
+
|
|
130
|
+ $procurementProject = $xml->ContractFolderStatus->ProcurementProject;
|
|
131
|
+
|
|
132
|
+ if (isset($procurementProject)) {
|
|
133
|
+ //ProcurementProject
|
|
134
|
+
|
|
135
|
+ $resultEntries['name'] = $this->existNodo($procurementProject, 'Name', 'string');
|
|
136
|
+ $resultEntries['typeCode'] = $this->existNodo($procurementProject, 'TypeCode', 'string');
|
|
137
|
+ $resultEntries['subTypeCode'] = $this->existNodo($procurementProject, 'SubTypeCode', 'string');
|
|
138
|
+
|
|
139
|
+ if (isset($procurementProject->BudgetAmount)) {
|
|
140
|
+ $resultEntries['estimatedOverallContractAmount'] = $this->existNodo($procurementProject->BudgetAmount, 'EstimatedOverallContractAmount', 'string');
|
|
141
|
+ $resultEntries['totalAmount'] = $this->existNodo($procurementProject->BudgetAmount, 'TotalAmount', 'string');
|
|
142
|
+ $resultEntries['taxExclusiveAmount'] = $this->existNodo($procurementProject->BudgetAmount, 'TaxExclusiveAmount', 'string');
|
|
143
|
+ }
|
|
144
|
+
|
|
145
|
+ if (isset($procurementProject->RequiredCommodityClassification)) {
|
|
146
|
+ for ($i = 0; $i < count($procurementProject->RequiredCommodityClassification); $i++) {
|
|
147
|
+ $resultEntries['itemClassification']['value'] = $this->existNodo($procurementProject->RequiredCommodityClassification[$i], 'ItemClassificationCode', 'string');
|
|
148
|
+ $resultEntries['itemClassification']['attr'] = $procurementProject->RequiredCommodityClassification[$i]->ItemClassificationCode->attributes();
|
|
149
|
+ }
|
|
150
|
+ }
|
|
151
|
+
|
|
152
|
+ if (isset($procurementProject->RealizedLocation)) {
|
|
153
|
+ $resultEntries['countrySubentity'] = $this->existNodo($procurementProject->RealizedLocation, 'CountrySubentity', 'string');
|
|
154
|
+ $resultEntries['countrySubentityCode'] = $this->existNodo($procurementProject->RealizedLocation, 'CountrySubentityCode', 'string');
|
|
155
|
+ if (isset($procurementProject->RealizedLocation->Address)) {
|
|
156
|
+ $resultEntries['cityName'] = $this->existNodo($procurementProject->RealizedLocation->Address->Country, 'CityName', 'string');
|
|
157
|
+ $resultEntries['IdentificationCode'] = $this->existNodo($procurementProject->RealizedLocation->Address->Country, 'IdentificationCode', 'string');
|
|
158
|
+ $resultEntries['countryName'] = $this->existNodo($procurementProject->RealizedLocation->Address->Country, 'Name', 'string');
|
|
159
|
+ }
|
|
160
|
+ }
|
|
161
|
+
|
|
162
|
+ $resultEntries['durationMesure'] = $this->existNodo($procurementProject->PlannedPeriod, 'DurationMeasure', 'string');
|
|
163
|
+ if (isset($procurementProject->PlannedPeriod->DurationMeasure)) {
|
|
164
|
+ $resultEntries['medida'] = $procurementProject->PlannedPeriod->DurationMeasure->attributes();
|
|
165
|
+ }
|
|
166
|
+
|
|
167
|
+ $resultEntries['contractExtension'] = $this->existNodo($procurementProject->ContractExtension, 'OptionsDescription', 'string');
|
|
168
|
+ }
|
|
169
|
+
|
|
170
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
171
|
+ return $resultFinal;
|
|
172
|
+ }
|
|
173
|
+
|
|
174
|
+ private function nodoProcurementProjectLot($xml)
|
|
175
|
+ {
|
|
176
|
+ $resultEntries = array();
|
|
177
|
+ $procurementProjectLot = $xml->ContractFolderStatus->ProcurementProjectLot;
|
|
178
|
+
|
|
179
|
+ if (isset($procurementProjectLot)) {
|
|
180
|
+ for ($i = 0; $i < count($procurementProjectLot); $i++) {
|
|
181
|
+ $resultEntries[$i]['id'] = $this->existNodo($procurementProjectLot[$i], 'ID', 'string');
|
|
182
|
+ $resultEntries[$i]['name'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject, 'Name', 'string');
|
|
183
|
+ $resultEntries[$i]['totalAmount'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->BudgetAmount, 'TotalAmount', 'string');
|
|
184
|
+ $resultEntries[$i]['taxExclusiveAmount'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->BudgetAmount, 'TaxExclusiveAmount', 'string');
|
|
185
|
+ $resultEntries[$i]['itemClassificationCode'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->RequiredCommodityClassification, 'ItemClassificationCode', 'string');
|
|
186
|
+ if (isset($procurementProjectLot[$i]->RealizedLocation)) {
|
|
187
|
+ $resultEntries[$i]['countrySubentity'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->RealizedLocation, 'CountrySubentity', 'string');
|
|
188
|
+ $resultEntries[$i]['countrySubentityCode'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->RealizedLocation, 'CountrySubentityCode', 'string');
|
|
189
|
+ $resultEntries[$i]['identificationCode'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->RealizedLocation->Address->Country, 'IdentificationCode', 'string');
|
|
190
|
+ $resultEntries[$i]['name'] = $this->existNodo($procurementProjectLot[$i]->ProcurementProject->RealizedLocation->Address->Country, 'Name', 'string');
|
|
191
|
+ }
|
|
192
|
+ }
|
|
193
|
+ }
|
|
194
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
195
|
+ return $resultFinal;
|
|
196
|
+ }
|
|
197
|
+
|
|
198
|
+ private function nodoTenderResult($xml)
|
|
199
|
+ {
|
|
200
|
+ $resultEntries = array();
|
|
201
|
+ $tenderResult = $xml->ContractFolderStatus->TenderResult;
|
|
202
|
+ for ($i = 0; $i < count($tenderResult); $i++) {
|
|
203
|
+ $resultEntries[$i]['resultCode'] = $this->existNodo($tenderResult[$i], 'ResultCode', 'string');
|
|
204
|
+ $resultEntries[$i]['description'] = $this->existNodo($tenderResult[$i], 'Description', 'string');
|
|
205
|
+ $resultEntries[$i]['awardDate'] = $this->existNodo($tenderResult[$i], 'AwardDate', 'string');
|
|
206
|
+ $resultEntries[$i]['receivedTenderQuantity'] = $this->existNodo($tenderResult[$i], 'ReceivedTenderQuantity', 'string');
|
|
207
|
+ $resultEntries[$i]['lowerTenderAmount'] = $this->existNodo($tenderResult[$i], 'LowerTenderAmount', 'string');
|
|
208
|
+ $resultEntries[$i]['higherTenderAmount'] = $this->existNodo($tenderResult[$i], 'HigherTenderAmount', 'string');
|
|
209
|
+ $resultEntries[$i]['startDate'] = $this->existNodo($tenderResult[$i], 'StartDate', 'string');
|
|
210
|
+ $resultEntries[$i]['smeawardedIndicator'] = $this->existNodo($tenderResult[$i], 'SMEAwardedIndicator', 'string');
|
|
211
|
+ //AwardedTenderedProject
|
|
212
|
+ $resultEntries[$i]['contract']['id'] = $this->existNodo($tenderResult[$i]->Contract, 'ID', 'string');
|
|
213
|
+ $resultEntries[$i]['contract']['issueDate'] = $this->existNodo($tenderResult[$i]->Contract, 'IssueDate', 'string');
|
|
214
|
+
|
|
215
|
+ $winningParty = $tenderResult[$i]->WinningParty;
|
|
216
|
+ if (isset($winningParty)) {
|
|
217
|
+ $resultEntries[$i]['partyIdentification'] = $this->existNodo($winningParty->PartyIdentification, 'ID', 'string');
|
|
218
|
+ $resultEntries[$i]['partyName'] = $this->existNodo($winningParty->PartyName, 'Name', 'string');
|
|
219
|
+ }
|
|
220
|
+ $awardedTenderedProject = $tenderResult[$i]->AwardedTenderedProject;
|
|
221
|
+ if (isset($awardedTenderedProject)) {
|
|
222
|
+ $resultEntries[$i]['procurementProjectLotID'] = $this->existNodo($awardedTenderedProject, 'ProcurementProjectLotID', 'string');
|
|
223
|
+ $resultEntries[$i]['TaxExclusiveAmount'] = $this->existNodo($awardedTenderedProject->LegalMonetaryTotal, 'TaxExclusiveAmount', 'string');
|
|
224
|
+ $resultEntries[$i]['PayableAmount'] = $this->existNodo($awardedTenderedProject->LegalMonetaryTotal, 'PayableAmount', 'string');
|
|
225
|
+ }
|
|
226
|
+ }
|
|
227
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
228
|
+ return $resultFinal;
|
|
229
|
+ }
|
|
230
|
+
|
|
231
|
+ private function nodoTenderingTerms($xml)
|
|
232
|
+ {
|
|
233
|
+ $resultEntries = array();
|
|
234
|
+ $TenderingTerms = $xml->ContractFolderStatus->TenderingTerms;
|
|
235
|
+
|
|
236
|
+ if (isset($TenderingTerms)) {
|
|
237
|
+
|
|
238
|
+ $resultEntries['requiredCurriculaIndicator'] = $this->existNodo($TenderingTerms, 'RequiredCurriculaIndicator', 'string');
|
|
239
|
+ $resultEntries['variantConstraintIndicator'] = $this->existNodo($TenderingTerms, 'VariantConstraintIndicator', 'string');
|
|
240
|
+ $resultEntries['fundingProgramCode'] = $this->existNodo($TenderingTerms, 'FundingProgramCode', 'string');
|
|
241
|
+ $resultEntries['requiredFinancialGuarantee']['guaranteeTypeCode'] = $this->existNodo($TenderingTerms->RequiredFinancialGuarantee, 'GuaranteeTypeCode', 'string');
|
|
242
|
+ $resultEntries['requiredFinancialGuarantee']['amountRate'] = $this->existNodo($TenderingTerms->RequiredFinancialGuarantee, 'AmountRate', 'string');
|
|
243
|
+ $resultEntries['procurementLegislationDocumentReference'] = $this->existNodo($TenderingTerms->ProcurementLegislationDocumentReference, 'ID', 'string');
|
|
244
|
+
|
|
245
|
+ $tendererQualificationRequest = $TenderingTerms->TendererQualificationRequest;
|
|
246
|
+ if (isset($tendererQualificationRequest)) {
|
|
247
|
+ for ($i = 0; $i < count($tendererQualificationRequest); $i++) {
|
|
248
|
+ $resultEntries['tendererQualificationRequest']['evaluationCriteriaTypeCode'] = $this->existNodo($tendererQualificationRequest[$i]->TechnicalEvaluationCriteria, 'EvaluationCriteriaTypeCode', 'string');
|
|
249
|
+ $resultEntries['tendererQualificationRequest']['description'] = $this->existNodo($tendererQualificationRequest[$i]->TechnicalEvaluationCriteria, 'Description', 'string');
|
|
250
|
+ }
|
|
251
|
+ }
|
|
252
|
+
|
|
253
|
+ $financialEvaluationCriteria = $TenderingTerms->TendererQualificationRequest->FinancialEvaluationCriteria;
|
|
254
|
+ if (isset($financialEvaluationCriteria)) {
|
|
255
|
+ for ($i = 0; $i < count($financialEvaluationCriteria); $i++) {
|
|
256
|
+ $resultEntries['financialEvaluationCriteria']['evaluationCriteriaTypeCode'] = $this->existNodo($financialEvaluationCriteria[$i]->EvaluationCriteriaTypeCode, 'EvaluationCriteriaTypeCode', 'string');
|
|
257
|
+ $resultEntries['financialEvaluationCriteria']['description'] = $this->existNodo($financialEvaluationCriteria[$i]->EvaluationCriteriaTypeCode, 'Description', 'string');
|
|
258
|
+ }
|
|
259
|
+ }
|
|
260
|
+
|
|
261
|
+ $specificTendererRequirement = $TenderingTerms->TendererQualificationRequest->SpecificTendererRequirement;
|
|
262
|
+ if (isset($specificTendererRequirement)) {
|
|
263
|
+ for ($i = 0; $i < count($specificTendererRequirement); $i++) {
|
|
264
|
+ $resultEntries['financialEvaluationCriteria']['evaluationCriteriaTypeCode'] = $this->existNodo($specificTendererRequirement[$i]->SpecificTendererRequirement, 'RequirementTypeCode', 'string');
|
|
265
|
+ }
|
|
266
|
+ }
|
|
267
|
+
|
|
268
|
+ //$Language = $this->existNodo($contractFolderCac->TenderingTerms->children('cac', true)->Language, 'cbc', 'array');
|
|
269
|
+ }
|
|
270
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
271
|
+ return $resultFinal;
|
|
272
|
+ }
|
|
273
|
+
|
|
274
|
+ private function nodoTenderingProcess($xml)
|
|
275
|
+ {
|
|
276
|
+ $resultEntries = array();
|
|
277
|
+ $tenderingProcess = $xml->ContractFolderStatus->TenderingProcess;
|
|
278
|
+
|
|
279
|
+ if (isset($tenderingProcess)) {
|
|
280
|
+ //TenderingProcess
|
|
281
|
+ $resultEntries['procedureCode'] = $this->existNodo($tenderingProcess, 'ProcedureCode', 'string');
|
|
282
|
+ $resultEntries['urgencyCode'] = $this->existNodo($tenderingProcess, 'UrgencyCode', 'string');
|
|
283
|
+ $resultEntries['partPresentationCode'] = $this->existNodo($tenderingProcess, 'PartPresentationCode', 'string');
|
|
284
|
+ $resultEntries['contractingSystemCode'] = $this->existNodo($tenderingProcess, 'ContractingSystemCode', 'string');
|
|
285
|
+ $resultEntries['submissionMethodCode'] = $this->existNodo($tenderingProcess, 'SubmissionMethodCode', 'string');
|
|
286
|
+ $resultEntries['deadLineEndDate'] = $this->existNodo($tenderingProcess->TenderSubmissionDeadlinePeriod, 'EndDate', 'string');
|
|
287
|
+ $resultEntries['deadLineEndTime'] = $this->existNodo($tenderingProcess->TenderSubmissionDeadlinePeriod, 'EndTime', 'string');
|
|
288
|
+ $resultEntries['documentAvailablePeriod_EndDate'] = $this->existNodo($tenderingProcess->DocumentAvailabilityPeriod, 'EndDate', 'string');
|
|
289
|
+ $resultEntries['documentAvailablePeriod_EndTime'] = $this->existNodo($tenderingProcess->DocumentAvailabilityPeriod, 'EndTime', 'string');
|
|
290
|
+ }
|
|
291
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
292
|
+ return $resultFinal;
|
|
293
|
+ }
|
|
294
|
+
|
|
295
|
+ private function nodoLegalDoc($xml)
|
|
296
|
+ {
|
|
297
|
+ $resultEntries = array();
|
|
298
|
+ $legalDocumentReference = $xml->ContractFolderStatus->LegalDocumentReference;
|
|
299
|
+
|
|
300
|
+ if (isset($legalDocumentReference)) {
|
|
301
|
+
|
|
302
|
+ for ($i = 0; $i < count($legalDocumentReference); $i++) {
|
|
303
|
+ $resultEntries[$i]['id'] = $this->existNodo($legalDocumentReference[$i], 'ID', 'string');
|
|
304
|
+ $resultEntries[$i]['attachment'] = $this->existNodo($legalDocumentReference[$i]->Attachment->ExternalReference, 'URI', 'string');
|
|
305
|
+ $resultEntries[$i]['documentHash'] = $this->existNodo($legalDocumentReference[$i]->Attachment->ExternalReference, 'DocumentHash', 'string');
|
|
306
|
+ }
|
|
307
|
+
|
|
308
|
+ }
|
|
309
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
310
|
+ return $resultFinal;
|
|
311
|
+ }
|
|
312
|
+
|
|
313
|
+ private function nodoTechnicalDocumentReference($xml)
|
|
314
|
+ {
|
|
315
|
+ $resultEntries = array();
|
|
316
|
+ $technicalDocumentReference = $xml->ContractFolderStatus->TechnicalDocumentReference;
|
|
317
|
+
|
|
318
|
+ if (isset($technicalDocumentReference)) {
|
|
319
|
+
|
|
320
|
+ for ($i = 0; $i < count($technicalDocumentReference); $i++) {
|
|
321
|
+ $resultEntries[$i]['id'] = $this->existNodo($technicalDocumentReference[$i], 'ID', 'string');
|
|
322
|
+ $resultEntries[$i]['attachment'] = $this->existNodo($technicalDocumentReference[$i]->Attachment->ExternalReference, 'URI', 'string');
|
|
323
|
+ $resultEntries[$i]['documentHash'] = $this->existNodo($technicalDocumentReference[$i]->Attachment->ExternalReference, 'DocumentHash', 'string');
|
|
324
|
+ }
|
|
325
|
+
|
|
326
|
+ }
|
|
327
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
328
|
+ return $resultFinal;
|
|
329
|
+ }
|
|
330
|
+
|
|
331
|
+ private function nodoAdditionalDocumentReference($xml)
|
|
332
|
+ {
|
|
333
|
+ $resultEntries = array();
|
|
334
|
+ $additionalDocumentReference = $xml->ContractFolderStatus->AdditionalDocumentReference;
|
|
335
|
+
|
|
336
|
+ if (isset($additionalDocumentReference)) {
|
|
337
|
+
|
|
338
|
+ for ($i = 0; $i < count($additionalDocumentReference); $i++) {
|
|
339
|
+ $resultEntries[$i]['id'] = $this->existNodo($additionalDocumentReference[$i], 'ID', 'string');
|
|
340
|
+ $resultEntries[$i]['attachment'] = $this->existNodo($additionalDocumentReference[$i]->Attachment->ExternalReference, 'URI', 'string');
|
|
341
|
+ $resultEntries[$i]['documentHash'] = $this->existNodo($additionalDocumentReference[$i]->Attachment->ExternalReference, 'DocumentHash', 'string');
|
|
342
|
+ }
|
|
343
|
+
|
|
344
|
+ }
|
|
345
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
346
|
+ return $resultFinal;
|
|
347
|
+ }
|
|
348
|
+
|
|
349
|
+ private function nodoValidNoticeInfo($xml)
|
|
350
|
+ {
|
|
351
|
+ $resultEntries = array();
|
|
352
|
+ $validNoticeInfo = $xml->ContractFolderStatus->ValidNoticeInfo;
|
|
353
|
+
|
|
354
|
+ if (isset($validNoticeInfo)) {
|
|
355
|
+ for ($i = 0; $i < count($validNoticeInfo); $i++) {
|
|
356
|
+ $resultEntries[$i]['NoticeTypeCode'] = $this->existNodo($validNoticeInfo[$i], 'NoticeTypeCode', 'string');
|
|
357
|
+ $resultEntries[$i]['PublicationMediaName'] = $this->existNodo($validNoticeInfo[$i]->AdditionalPublicationStatus, 'PublicationMediaName', 'string');
|
|
358
|
+ $resultEntries[$i]['IssueDate'] = $this->existNodo($validNoticeInfo[$i]->AdditionalPublicationStatus->AdditionalPublicationDocumentReference, 'IssueDate', 'string');
|
|
359
|
+ }
|
|
360
|
+ }
|
|
361
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
362
|
+ return $resultFinal;
|
|
363
|
+ }
|
|
364
|
+
|
|
365
|
+ private function nodoGeneralDocuments($xml)
|
|
366
|
+ {
|
|
367
|
+ $resultEntries = array();
|
|
368
|
+ $generalDocument = $xml->ContractFolderStatus->GeneralDocument->GeneralDocumentDocumentReference;
|
|
369
|
+
|
|
370
|
+ if (isset($generalDocument)) {
|
|
371
|
+
|
|
372
|
+ for ($i = 0; $i < count($generalDocument); $i++) {
|
|
373
|
+ $resultEntries[$i]['id'] = $this->existNodo($generalDocument[$i], 'ID', 'string');
|
|
374
|
+ $resultEntries[$i]['attachment'] = $this->existNodo($generalDocument[$i]->Attachment->ExternalReference, 'URI', 'string');
|
|
375
|
+ $resultEntries[$i]['documentHash'] = $this->existNodo($generalDocument[$i]->Attachment->ExternalReference, 'DocumentHash', 'string');
|
|
376
|
+ }
|
|
377
|
+
|
|
378
|
+ }
|
|
379
|
+ $resultFinal = $this->array_remove_empty($resultEntries);
|
|
380
|
+ return $resultFinal;
|
|
381
|
+ }
|
|
382
|
+
|
|
383
|
+ private function existNodo($nodo, $nodoHijo, $tipo)
|
|
384
|
+ {
|
|
385
|
+
|
|
386
|
+ if (isset($nodo) && @count($nodo) > 0) {
|
|
387
|
+ return $this->switchTipo($tipo, $nodo->{$nodoHijo});
|
|
388
|
+ } else {
|
|
389
|
+ return "";
|
|
390
|
+ }
|
|
391
|
+ }
|
|
392
|
+
|
|
393
|
+ private function switchTipo($tipo, $nodo)
|
|
394
|
+ {
|
|
395
|
+ switch ($tipo) {
|
|
396
|
+ case 'string':
|
|
397
|
+ return (string) $nodo;
|
|
398
|
+ break;
|
|
399
|
+ case 'int':
|
|
400
|
+ return (int) $nodo;
|
|
401
|
+ break;
|
|
402
|
+ case 'array':
|
|
403
|
+ return (array) $nodo;
|
|
404
|
+ break;
|
|
405
|
+ }
|
|
406
|
+ }
|
|
407
|
+
|
|
408
|
+ public function RecurseXML($xml, $parent = "")
|
|
409
|
+ {
|
|
410
|
+ $child_count = 0;
|
|
411
|
+ $result = array();
|
|
412
|
+ foreach ($xml as $key => $value) {
|
|
413
|
+ $child_count++;
|
|
414
|
+ if ($this->RecurseXML($value, $parent . "." . $key) == 0) // no childern, aka "leaf node"
|
|
415
|
+ {
|
|
416
|
+ //print($parent . "." . (string) $key . " = " . (string) $value . "<BR>\n");
|
|
417
|
+
|
|
418
|
+ }
|
|
419
|
+ }
|
|
420
|
+ return $child_count;
|
|
421
|
+ }
|
|
422
|
+
|
|
423
|
+ public function array_remove_empty($haystack)
|
|
424
|
+ {
|
|
425
|
+ foreach ($haystack as $key => $value) {
|
|
426
|
+ if (is_array($value)) {
|
|
427
|
+ $haystack[$key] = $this->array_remove_empty($haystack[$key]);
|
|
428
|
+ }
|
|
429
|
+
|
|
430
|
+ if (empty($haystack[$key])) {
|
|
431
|
+ unset($haystack[$key]);
|
|
432
|
+ }
|
|
433
|
+ }
|
|
434
|
+
|
|
435
|
+ return $haystack;
|
|
436
|
+ }
|
|
437
|
+
|
|
438
|
+ /* public function xml2array($xml)
|
|
439
|
+ {
|
|
440
|
+ $arr = array();
|
|
441
|
+
|
|
442
|
+ foreach ($xml->getNamespaces() + array(null) as $prefix => $namespace) {
|
|
443
|
+ foreach ($xml->attributes($namespace) as $key => $value) {
|
|
444
|
+ // Add prefixes to prefixed attributes
|
|
445
|
+ if (is_string($prefix)) {
|
|
446
|
+ $key = $prefix . '.' . $key;
|
|
447
|
+ }
|
|
448
|
+ $arr['@attributes'][$key] = (string) $value;
|
|
449
|
+ }
|
|
450
|
+ }
|
|
451
|
+
|
|
452
|
+ foreach ($xml as $name => $element) {
|
|
453
|
+ $value = $element->children() ? $this->xml2array($element) : trim($element);
|
|
454
|
+ if ($value) {
|
|
455
|
+ if (!isset($arr[$name])) {
|
|
456
|
+ $arr[$name] = $value;
|
|
457
|
+ } else {
|
|
458
|
+ foreach ((array) $value as $k => $v) {
|
|
459
|
+ if (is_numeric($k)) {
|
|
460
|
+ $arr[$name][] = $v;
|
|
461
|
+ } else {
|
|
462
|
+ $arr[$name][$k] = array_merge(
|
|
463
|
+ (array) $arr[$name][$k],
|
|
464
|
+ (array) $v
|
|
465
|
+ );
|
|
466
|
+ }
|
|
467
|
+ }
|
|
468
|
+ }
|
|
469
|
+ }
|
|
470
|
+ }
|
|
471
|
+
|
|
472
|
+ if ($content = trim((string) $xml)) {
|
|
473
|
+ $arr[] = $content;
|
|
474
|
+ }
|
|
475
|
+
|
|
476
|
+ return $arr;
|
|
477
|
+ }
|
|
478
|
+ $reader = new \XMLReader;
|
|
479
|
+ $reader->open($file); // where $path is the file path to the xml file
|
|
480
|
+
|
|
481
|
+ // using a dirty trick to skip most of the xml that is irrelevant where $nodeName is the node im looking for
|
|
482
|
+ // then in the next while loop i skip to the next node
|
|
483
|
+ $data = array();
|
|
484
|
+ while ($reader->read() && $reader->name !== "data");
|
|
485
|
+ while ($reader->name === "data") {
|
|
486
|
+ $doc = new \DOMDocument;
|
|
487
|
+ $dom = $doc->importNode($reader->expand(), true);
|
|
488
|
+ $data = $this->processDom($dom);
|
|
489
|
+ $reader->next($dom->localName);
|
|
490
|
+ }
|
|
491
|
+
|
|
492
|
+ public function processDom(\DOMNode $node)
|
|
493
|
+ {
|
|
494
|
+ $data = [];
|
|
495
|
+ /** @var \DomNode $childNode
|
|
496
|
+ foreach ($node->childNodes as $childNode) {
|
|
497
|
+ // child nodes include of a lot of #text nodes which are irrelevant for me, so i just skip them
|
|
498
|
+ if ($childNode->nodeName === '#text') {
|
|
499
|
+ continue;
|
|
500
|
+ }
|
|
501
|
+ $childData = $this->processDom($childNode);
|
|
502
|
+ if ($childData === null || $childData === []) {
|
|
503
|
+ $data[$childNode->localName] = $childNode->nodeValue;
|
|
504
|
+ } else {
|
|
505
|
+ $data[$childNode->localName] = $childData;
|
|
506
|
+ }
|
|
507
|
+ }
|
|
508
|
+ return $data;
|
|
509
|
+ }
|
|
510
|
+
|
|
511
|
+ */
|
|
512
|
+
|
|
513
|
+}
|
|
514
|
+
|
|
515
|
+/* End of file ParserFile.php */
|
|
516
|
+/* Location: ./application/controllers/ParserFile.php */
|