/** * Function executes parcel point request and prepares the $points array. * @access private * @return Void */ private function doSimpleRequest($type) { $source = parent::doRequest(); /* Uncomment if ou want to display the XML content */ //echo '<textarea>'.$source.'</textarea>'; /* We make sure there is an XML answer and try to parse it */ if ($source !== false) { parent::parseResponse($source); $point = $this->xpath->query('/' . $type)->item(0); $pointDetail = array('code' => $this->xpath->query('./code', $point)->item(0)->nodeValue, 'name' => $this->xpath->query('./name', $point)->item(0)->nodeValue, 'address' => $this->xpath->query('./address', $point)->item(0)->nodeValue, 'city' => $this->xpath->query('./city', $point)->item(0)->nodeValue, 'zipcode' => $this->xpath->query('./zipcode', $point)->item(0)->nodeValue, 'country' => $this->xpath->query('./country', $point)->item(0)->nodeValue, 'phone' => $this->xpath->query('./phone', $point)->item(0)->nodeValue, 'description' => $this->xpath->query('./description', $point)->item(0)->nodeValue); /* We get open and close informations */ $schedule = array(); foreach ($this->xpath->query('./schedule/day', $point) as $d => $dayNode) { foreach ($dayNode->childNodes as $c => $childNode) { if ($childNode->nodeName != '#text') { $schedule[$d][$childNode->nodeName] = $childNode->nodeValue; } } } $pointDetail['schedule'] = $schedule; /* We store the data in the right array (defined by $type) */ if ($this->constructList) { if (!isset($this->points[$type])) { $this->points[$type] = array(); } $this->points[$type][count($this->points[$type])] = $pointDetail; } else { $this->points[$type] = $pointDetail; } } }
private function doSimpleRequest($type) { $source = parent::doRequest(); if ($source !== false) { parent::parseResponse($source); $point = $this->xpath->query('/' . $type)->item(0); $pointDetail = array('code' => $this->xpath->query('./code', $point)->item(0)->nodeValue, 'name' => $this->xpath->query('./name', $point)->item(0)->nodeValue, 'address' => $this->xpath->query('./address', $point)->item(0)->nodeValue, 'city' => $this->xpath->query('./city', $point)->item(0)->nodeValue, 'zipcode' => $this->xpath->query('./zipcode', $point)->item(0)->nodeValue, 'country' => $this->xpath->query('./country', $point)->item(0)->nodeValue, 'phone' => $this->xpath->query('./phone', $point)->item(0)->nodeValue, 'description' => $this->xpath->query('./description', $point)->item(0)->nodeValue); $schedule = array(); foreach ($this->xpath->query('./schedule/day', $point) as $d => $dayNode) { foreach ($dayNode->childNodes as $c => $childNode) { if ($childNode->nodeName != '#text') { $schedule[$d][$childNode->nodeName] = $childNode->nodeValue; } } } $pointDetail['schedule'] = $schedule; if ($this->constructList) { if (!isset($this->points[$type])) { $this->points[$type] = array(); } $this->points[$type][count($this->points[$type])] = $pointDetail; } else { $this->points[$type] = $pointDetail; } } }
private function doSimpleRequest() { $source = parent::doRequest(); if ($source !== false) { parent::parseResponse($source); return count($this->respErrorsList) == 0; } return false; }
/** * Parses API response and puts the values into e-mail configuration array. * @access private * @return Void */ private function setEmailConfiguration() { $source = parent::doRequest(); if ($source !== false) { parent::parseResponse($source); foreach ($this->xpath->evaluate('/user/mails')->item(0)->childNodes as $configLine) { if (!$configLine instanceof DOMText) { $this->userConfiguration['emails'][$configLine->nodeName] = $configLine->nodeValue; } } } }
/** * Function which gets carriers list details. * @access private * @return false if server response isn't correct; true if it is */ private function doSimpleRequest() { $source = parent::doRequest(); /* Uncomment if ou want to display the XML content */ //echo "<textarea>".print_r($source,true)."</textarea>"; /* We make sure there is an XML answer and try to parse it */ if ($source !== false) { parent::parseResponse($source); return count($this->respErrorsList) == 0; } return false; }
private function doCtrRequest() { $source = parent::doRequest(); if ($source !== false) { parent::parseResponse($source); if (count($this->respErrorsList) == 0) { $countries = $this->xpath->query("/countries/country"); foreach ($countries as $c => $country) { $code = $this->xpath->query("./code", $country)->item(0)->nodeValue; $this->countries[$code] = array('label' => $this->xpath->query('./label', $country)->item(0)->nodeValue, 'code' => $code); } } } }
private function doCarrierRequest() { $source = $this->doRequest(); if ($source !== false) { parent::parseResponse($source); if (count($this->respErrorsList) == 0) { $carriers = $this->xpath->query("/operators/operator"); foreach ($carriers as $c => $carrier) { $result = $this->parseCarrierNode($carrier); $code = $this->xpath->query('./code', $carrier)->item(0)->nodeValue; $this->carriers[$result['code']] = $result; } } } }
private function doStatusRequest() { $source = parent::doRequest(); if ($source !== false) { parent::parseResponse($source); if (count($this->respErrorsList) == 0) { $labels = array(); $orderLabels = $this->xpath->evaluate("/order/labels"); foreach ($orderLabels as $labelIndex => $label) { $labels[$labelIndex] = $label->nodeValue; } $this->orderInfo = array('emcRef' => $this->xpath->evaluate("/order/emc_reference")->item(0)->nodeValue, 'state' => $this->xpath->evaluate("/order/state")->item(0)->nodeValue, 'opeRef' => $this->xpath->evaluate("/order/carrier_reference")->item(0)->nodeValue, 'labelAvailable' => (bool) $this->xpath->evaluate("/order/label_available")->item(0)->nodeValue, 'labelUrl' => $this->xpath->evaluate("/order/label_url")->item(0)->nodeValue, 'labels' => $labels); } } }
private function doConRequest() { $source = parent::doRequest(); if ($source !== false) { parent::parseResponse($source); if (count($this->respErrorsList) == 0) { $contents = $this->xpath->query("/contents/content"); foreach ($contents as $c => $content) { $categoryId = $this->xpath->query('./category', $content)->item(0)->nodeValue; $i = count($this->contents[$categoryId]); $this->contents[$categoryId][$i] = array('code' => $this->xpath->query('./code', $content)->item(0)->nodeValue, 'label' => $this->xpath->query('./label', $content)->item(0)->nodeValue, 'category' => $categoryId); } } } }
/** * Function executes countries request and prepares the $countries array. * @access private * @return Void */ private function doCtrRequest() { $source = parent::doRequest(); /* Uncomment if ou want to display the XML content */ //echo '<textarea>'.$source.'</textarea>'; /* We make sure there is an XML answer and try to parse it */ if ($source !== false) { parent::parseResponse($source); if (count($this->respErrorsList) == 0) { /* The XML file is loaded, we now gather the datas */ $countries = $this->xpath->query("/countries/country"); foreach ($countries as $c => $country) { $code = $this->xpath->query("./code", $country)->item(0)->nodeValue; $this->countries[$code] = array('label' => $this->xpath->query('./label', $country)->item(0)->nodeValue, 'code' => $code); } } } }
private function doListRequest() { $source = parent::doRequest(); if ($source !== false) { parent::parseResponse($source); if (count($this->respErrorsList) == 0) { $points = $this->xpath->query("/points/point"); foreach ($points as $pointIndex => $point) { $pointInfo = array('code' => $this->xpath->query('./code', $point)->item(0)->nodeValue, 'name' => $this->xpath->query('./name', $point)->item(0)->nodeValue, 'address' => $this->xpath->query('./address', $point)->item(0)->nodeValue, 'city' => $this->xpath->query('./city', $point)->item(0)->nodeValue, 'zipcode' => $this->xpath->query('./zipcode', $point)->item(0)->nodeValue, 'country' => $this->xpath->query('./country', $point)->item(0)->nodeValue, 'phone' => $this->xpath->query('./phone', $point)->item(0)->nodeValue, 'description' => $this->xpath->query('./description', $point)->item(0)->nodeValue, 'days' => array()); $days = $this->xpath->query('./schedule/day', $point); foreach ($days as $dayIndex => $day) { $pointInfo['days'][$dayIndex] = array('weekday' => $this->xpath->query('./weekday', $day)->item(0)->nodeValue, 'open_am' => $this->xpath->query('./open_am', $day)->item(0)->nodeValue, 'close_am' => $this->xpath->query('./close_am', $day)->item(0)->nodeValue, 'open_pm' => $this->xpath->query('./open_pm', $day)->item(0)->nodeValue, 'close_pm' => $this->xpath->query('./close_pm', $day)->item(0)->nodeValue); } $this->listPoints[$pointIndex] = $pointInfo; } } } }
/** * Function executes order request and prepares the $orderInfo array. * @access private * @return Void */ private function doStatusRequest() { $source = parent::doRequest(); /* Uncomment if ou want to display the XML content */ //echo '<textarea>'.$source.'</textarea>'; /* We make sure there is an XML answer and try to parse it */ if ($source !== false) { parent::parseResponse($source); if (count($this->respErrorsList) == 0) { /* The XML file is loaded, we now gather the datas */ $labels = array(); $orderLabels = $this->xpath->evaluate("/order/labels"); foreach ($orderLabels as $labelIndex => $label) { $labels[$labelIndex] = $label->nodeValue; } $this->orderInfo = array('emcRef' => $this->xpath->evaluate("/order/emc_reference")->item(0)->nodeValue, 'state' => $this->xpath->evaluate("/order/state")->item(0)->nodeValue, 'opeRef' => $this->xpath->evaluate("/order/carrier_reference")->item(0)->nodeValue, 'labelAvailable' => (bool) $this->xpath->evaluate("/order/label_available")->item(0)->nodeValue, 'labelUrl' => $this->xpath->evaluate("/order/label_url")->item(0)->nodeValue, 'labels' => $labels); } } }
/** * Function executes carrier request and prepares the $listPoints array. * @access private * @return Void */ private function doCarrierRequest() { $source = $this->doRequest(); /* Uncomment if ou want to display the XML content */ //echo '<textarea>'.$source.'</textarea>'; /* We make sure there is an XML answer and try to parse it */ if ($source !== false) { parent::parseResponse($source); if (count($this->respErrorsList) == 0) { /* The XML file is loaded, we now gather the datas */ $carriers = $this->xpath->query("/operators/operator"); foreach ($carriers as $c => $carrier) { $result = $this->parseCarrierNode($carrier); /* We usr the 'code' data as index (maybe using the $c index is better) */ $code = $this->xpath->query('./code', $carrier)->item(0)->nodeValue; $this->carriers[$result['code']] = $result; } } } }
/** * Function executes points request and prepares the $listPoints array. * @access private * @return Void */ private function doListRequest() { $source = parent::doRequest(); /* Uncomment if ou want to display the XML content */ //echo '<textarea>'.$source.'</textarea>'; /* We make sure there is an XML answer and try to parse it */ if ($source !== false) { parent::parseResponse($source); if (count($this->respErrorsList) == 0) { /* The XML file is loaded, we now gather the datas */ $points = $this->xpath->query("/points/point"); foreach ($points as $pointIndex => $point) { $pointInfo = array('code' => $this->xpath->query('./code', $point)->item(0)->nodeValue, 'name' => $this->xpath->query('./name', $point)->item(0)->nodeValue, 'address' => $this->xpath->query('./address', $point)->item(0)->nodeValue, 'city' => $this->xpath->query('./city', $point)->item(0)->nodeValue, 'zipcode' => $this->xpath->query('./zipcode', $point)->item(0)->nodeValue, 'country' => $this->xpath->query('./country', $point)->item(0)->nodeValue, 'phone' => $this->xpath->query('./phone', $point)->item(0)->nodeValue, 'description' => $this->xpath->query('./description', $point)->item(0)->nodeValue, 'days' => array()); $days = $this->xpath->query('./schedule/day', $point); foreach ($days as $dayIndex => $day) { $pointInfo['days'][$dayIndex] = array('weekday' => $this->xpath->query('./weekday', $day)->item(0)->nodeValue, 'open_am' => $this->xpath->query('./open_am', $day)->item(0)->nodeValue, 'close_am' => $this->xpath->query('./close_am', $day)->item(0)->nodeValue, 'open_pm' => $this->xpath->query('./open_pm', $day)->item(0)->nodeValue, 'close_pm' => $this->xpath->query('./close_pm', $day)->item(0)->nodeValue); } $this->listPoints[$pointIndex] = $pointInfo; } } } }