diff --git a/includes/graydon/functions2.php b/includes/graydon/functions2.php deleted file mode 100644 index 32673b9aa..000000000 --- a/includes/graydon/functions2.php +++ /dev/null @@ -1,515 +0,0 @@ -preserveWhiteSpace = false; - $doc->loadxml($xml); - $xpath = new DOMXPath($doc); - $query = '/GraydonUKCompanySchema/CompanyReportPage/CompanyReport'; - $report = $xpath->query($query); - - //Liste des elements à parser - $elements = array( 'Company', 'Name', 'Address', 'Communication', 'Country', 'Credit_Rating', - 'Date', 'DirectorsDetail', 'Employees', 'Financial_Summary', 'Legal_Form', - 'Share_CapitalSummary', 'Taxonomy', 'FreeText' - ); - foreach($elements as $elementName){ - //Pour chaque element, nouvelle requete xpath - $queryElement = $query.'/'.$elementName; - switch($elementName){ - case "Company" : - $tabReport['Company'] = pxmlCompany($queryElement); - break; - case "Name" : - $name = pxmlName($queryElement); - if ($name) $tabReport['Name'] = $name; - break; - case "Address" : - $tabReport['Address'] = pxmlAddress($queryElement); - break; - case "Communication": - $tabReport['Communication'] = pxmlCommunication($queryElement); - break; - case "Country" : - $country = pxmlCountry($queryElement); - if($country) $tabReport['Country'] = $country; - break; - case "Credit_Rating" : - $creditRating = pxmlCreditRating($queryElement); - if($creditRating) $tabReport['CreditRating'] = $creditRating; - break; - case "Date" : - $tabReport['Date'] = pxmlDate($queryElement); - break; - case "DirectorsDetail" : - $directorsdetail = pxmlDirectorsDetail($queryElement); - if($directorsdetail){ $tabReport['DirectorsDetail'] = $directorsdetail; } - break; - case "Employees" : - $employees = pxmlEmployees($queryElement); - if($employees) $tabReport['Employees'] = $employees; - break; - case "Financial_Summary" : - $financialsummary = pxmlFinancialSummary($queryElement); - if($financialsummary) $tabReport['FinancialSummary'] = $financialsummary; - break; - case "Legal_Form" : - $legalform = pxmlLegalForm($queryElement); - if($legalform) $tabReport['LegalForm'] = $legalform; - break; - case "Share_CapitalSummary"; - $sharecapitalsummary = pxmlShareCapitalSummary($queryElement); - if($sharecapitalsummary) $tabReport['ShareCapitalSummary'] = $sharecapitalsummary; - break; - case "Taxonomy" : - $taxonomy = pxmlTaxonomy($queryElement); - if($taxonomy) $tabReport['Taxonomy'] = $taxonomy; - break; - case "FreeText" : - $freetext = pxmlFreeText($queryElement); - if($freetext) $tabReport['Text'] = $freetext; - break; - } - } - return $tabReport; -} - -function pxmlCompany($query){ - global $xpath; - global $firephp; - $tabCompany = array(); - $items = $xpath->query($query); - $countCompany = 0; - $oldType =''; - foreach ($items as $item){ - $type = $item->getAttribute('Type'); - if($type!=$oldType){$countCompany = 0;} - //Name - $name = $item->getElementsByTagName("Name")->item(0)->nodeValue; - $tabCompany[$type][$countCompany]['Name'] = $item->getElementsByTagName("Name")->item(0)->nodeValue; - //CompanyId - $tabCompanyId = pxmlCompanyId($query.'[@Type="'.$type.'"]/CompanyId'); - if($tabCompanyId){ $tabCompany[$type][$countCompany]['CompanyId'] = $tabCompanyId;} - //Country - //@TODO - //Address - $tabAddress = pxmlAddress($query.'[@Type="'.$type.'"]['.($countCompany+1).']/Address'); - if($tabAddress){ $tabCompany[$type][$countCompany]['Address'] = $tabAddress;} - //Amount - //@TODO - //FreeText - //@TODO - //Date - $tabDate = pxmlDate($query.'[@Type="'.$type.'"]/Date'); - if($tabDate){ $tabCompany[$type][$countCompany]['Date'] = $tabDate;} - - $oldType = $type; - $countCompany++; - } - return $tabCompany; -} - -function pxmlCompanyId($query){ - global $xpath; - global $firephp; - $tabCompanyId = array(); - $items = $xpath->query($query); - if($items->length>0){ - foreach ($items as $item){ - $type = $item->getAttribute('Type'); - $tabCompanyId[$type] = $item->nodeValue; - } - return $tabCompanyId; - }else{ - return false; - } -} - -function pxmlDate($query){ - global $xpath; - global $firephp; - $tabDate = array(); - $items = $xpath->query($query); - if($items->length>0){ - foreach ($items as $item){ - $type = $item->getAttribute('Type'); - $format = $item->getAttribute('Format'); - $value = $item->nodeValue; - - //Formattage de la date - switch($format){ - case "CCYY": - $date = $value; - break; - case "CCYYMMDD": - $date = substr($value,6,2).'/'.substr($value,4,2).'/'.substr($value,0,4); - break; - case "DD": - $date = $value; - break; - case "DDMM": - $date = $value; - break; - case "DDMMCCYY": - $date = $value; - break; - case "MM": - $timestamp = mktime(0, 0, 0, date("m")-$value, 1, date("Y")); - $date = date('m/Y',$timestamp); - break; - case "MMCCYY": - $date = $value; - break; - case "MMDDCCYY": - $date = substr($value,2,2).'/'.substr($value,0,2).'/'.substr($value,4,4); - break; - case "DD/MM/CCYY": - $date = $value; - break; - default: - $date = $value; - } - $tabDate[$type] = $date; - } - return $tabDate; - }else{ - return false; - } -} - -function pxmlName($query){ - global $xpath; - global $firephp; - $tabName = array(); - $items = $xpath->query($query); - $countName = 0; - if($items->length>0){ - foreach ($items as $item){ - $type = $item->getAttribute('Type'); - if($type !='' ){ $index = $type; }else{$index = $countName;} - $tabName[$index] = $item->nodeValue; - $countName++; - } - return $tabName; - }else{ - return false; - } -} - -function pxmlAddress($query){ - global $xpath; - global $firephp; - $tabAddress = array(); - $items = $xpath->query($query); - $countAddress = 0; - if($items->length>0){ - foreach ($items as $item){ - $type = $item->getAttribute('Type'); - if($type !='' ){ $index = $type; }else{$index = $countAddress;} - //Liste des elements à parser - $elements = array('EntireAddress', 'Building', 'Street', 'Town', 'City', 'County', 'PostCode', 'Country'); - foreach($elements as $elementName){ - if($emelmentName == 'Country'){ - - }else{ - $value = $item->getElementsByTagName($elementName)->item(0)->nodeValue; - if ($value) { $tabAddress[$index][$elementName] = $value; } - } - } - $countAddress++; - } - return $tabAddress; - }else{ - return false; - } -} - -function pxmlCommunication($query){ -global $xpath; - global $firephp; - $tabCommunication = array(); - $items = $xpath->query($query); - if($items->length>0){ - foreach ($items as $item){ - $type = $item->getAttribute('Type'); - if($type != '' ){ - $tabCommunication[$type] = $item->nodeValue; - } - } - return $tabCommunication; - }else{ - return false; - } -} - -function pxmlCountry($query){ - global $xpath; - global $firephp; - $tabCountry = array(); - $items = $xpath->query($query); - $countCountry = 0; - if($items->length>0){ - foreach ($items as $item){ - $type = $item->getAttribute('Type'); - if($type !='' ){ $tabName[$countCountry]['Type'] = $type; } - $dialcode = $item->getAttribute('DialCode'); - if($dialcode !='' ){ $tabName[$countCountry]['DialCode'] = $dialcode; } - $isocode = $item->getAttribute('ISOCode'); - if($isocode !='' ){ $tabName[$countCountry]['ISOCode'] = $isocode; } - $tabName[$countCountry]['Value'] = $item->nodeValue; - $countCountry++; - } - return $tabCountry; - }else{ - return false; - } -} - -function pxmlCreditRating($query){ - global $xpath; - global $firephp; - $tab = array(); - $items = $xpath->query($query); - $count = 0; - if($items->length>0){ - foreach ($items as $item){ - //Get type of Credit Rating - $type = $item->getAttribute('Type'); - $units = $item->getAttribute('Units'); - if($units !='' ){ $tab[$type]['Units'] = $units; } - switch($type){ - case "Credit_Score" : - $tab[$type]['Value'] = $item->firstChild->nodeValue; - $freetextList = $item->getElementsByTagName('FreeText'); - foreach ($freetextList as $freetext){ - $tab[$type]['Text'][$freetext->getAttribute('Type')] = $freetext->nodeValue; - } - break; - case "Previous_Credit_Score" : - $tab[$type]['Value'] = $item->firstChild->nodeValue; - $freetextList = $item->getElementsByTagName('FreeText'); - foreach ($freetextList as $freetext){ - $tab[$type]['Text'][$freetext->getAttribute('Type')] = $freetext->nodeValue; - } - break; - case "Maximum_Credit_Guide" : - $amount = $item->getElementsByTagName('Amount')->item(0)->nodeValue; - $tab[$type]['Currency']= $item->getElementsByTagName('Currency')->item(0)->nodeValue; - $tab[$type]['Value'] = $amount; - $freetextList = $item->getElementsByTagName('FreeText'); - foreach ($freetextList as $freetext){ - $tab[$type]['Text'][$freetext->getAttribute('Type')] = $freetext->nodeValue; - } - break; - } - $count++; - } - return $tab; - }else{ - return false; - } -} - -function pxmlDirectorsDetail($query){ - global $xpath; - global $firephp; - $tab = array(); - $items = $xpath->query($query); - if($items->length>0){ - $count = 0; - foreach ($items as $item) { - //Traitement des attributs - $type = $item->getAttribute('Type'); - if($type !='' ){ $tab[$count]['Type'] = $type; } - $title = $item->getAttribute('Title'); - if($title !='' ){ $tab[$count]['Title'] = $title; } - $nationality = $item->getAttribute('Nationality'); - if($nationality !='' ){ $tab[$count]['Nationality'] = $nationality; } - //Traitement des éléments - $name = pxmlName($query.'['.($count+1).']/Name'); - $firephp->log($name,'Name'); - if ($name) $tab[$count]['Name'] = $name; - $address = pxmlAddress($query.'['.($count+1).']/Address'); - if ($address) $tab[$count]['Address'] = $address; - $count++; - } - return $tab; - }else{ - return false; - } -} - -function pxmlEmployees($query){ - global $xpath; - $tab = array(); - $items = $xpath->query($query); - $count = 0; - if($items->length>0){ - foreach ($items as $item) { - //Traitement des attributs - $type = $item->getAttribute('Type'); - if($type !='' ){ $index = $type; }else{ $index = $count; } - $tab[$index] = $item->nodeValue; - $count++; - } - return $tab; - }else{ - return false; - } -} - -function pxmlFinancialSummary($query){ - global $xpath; - $tab = array(); - $items = $xpath->query($query); - $elements = array('FreeText', 'Amount', 'Date'); - if($items->length>0){ - foreach ($items as $item){ - foreach($elements as $elementName){ - switch($elementName){ - case 'FreeText': - $freetextList = $item->getElementsByTagName('FreeText'); - foreach ($freetextList as $freetext){ - $tab['Text'][$freetext->getAttribute('Type')] = $freetext->nodeValue; - } - break; - case 'Amount': - $amount = $item->getElementsByTagName('Amount')->item(0)->nodeValue; - $tab['Amount']['Currency']= $item->getElementsByTagName('Currency')->item(0)->nodeValue; - $tab['Amount']['Value'] = $amount; - break; - case 'Date': - $date = pxmlDate($query.'/Date'); - if($date) $tab['Date'] = $date; - break; - } - } - } - return $tab; - }else{ - return false; - } -} -function pxmlLegalForm($query){ - global $xpath; - $tab = array(); - $items = $xpath->query($query); - if($items->length>0){ - $count = 0; - foreach ($items as $item){ - $type = $item->getAttribute('Type'); - if($type !='' ){ $index = $type; }else{ $index = $count; } - $tab[$index] = $item->nodeValue; - $count++; - } - return $tab; - }else{ - return false; - } -} -function pxmlShareCapitalSummary($query){ - global $xpath; - $tab = array(); - $items = $xpath->query($query); - if($items->length>0){ - foreach ($items as $item){ - //FreeText - $freetextList = $item->getElementsByTagName('FreeText'); - foreach ($freetextList as $freetext){ - $tab['Text'][$freetext->getAttribute('Type')] = $freetext->nodeValue; - } - //ShareCapital - $sharecapitalList = $item->getElementsByTagName('Share_Capital'); - $countShareCapital = 0; - foreach ($sharecapitalList as $sharecapital){ - //Amount - $type = $sharecapital->getElementsByTagName('Amount')->item(0)->getAttribute('Type'); - $tab['ShareCapital'][$countShareCapital]['Amount'][$type] = $sharecapital->getElementsByTagName('Amount')->item(0)->nodeValue; - //Currency - $tab['ShareCapital'][$countShareCapital]['Currency'] = $sharecapital->getElementsByTagName('Currency')->item(0)->nodeValue; - $tab['ShareCapital'][$countShareCapital]['FreeText'] = $sharecapital->getElementsByTagName('FreeText')->item(0)->nodeValue; - $countShareCapital++; - } - } - return $tab; - }else{ - return false; - } -} - -function pxmlTaxonomy($query){ - global $xpath; - global $firephp; - $tab = array(); - $items = $xpath->query($query); - if($items->length>0){ - $count = 0; - foreach ($items as $item){ - $value = $item->nodeValue; - if($value){ $tab[$count]['Value'] = $value;} - - $type = $item->getAttribute('Type'); - if($type !='' ){ $tab[$count]['Type'] = $type;} - - $code = $item->getAttribute('Code'); - if($code !='' ){ $tab[$count]['Code'] = $code;} - - $item = $item->getAttribute('Item'); - if($item !='' ){ $tab[$count]['Item'] = $item;} - - $count++; - } - return $tab; - }else{ - return false; - } -} - -function pxmlFreeText($query){ - global $xpath; - global $firephp; - $tab = array(); - $items = $xpath->query($query); - if($items->length>0){ - $count = 0; - $oldType = ''; - foreach ($items as $item){ - $type = $item->getAttribute('Type'); - if($type != $oldType){ $count = 0; } - $value = $item->nodeValue; - if($value){ $tab[$type][$count] = $value;} - - $oldType = $type; - $count++; - } - return $tab; - }else{ - return false; - } -} - - -function parseReportHTML(){} - -function parseReportDOC(){} - - - - - - -?> \ No newline at end of file