getRootServiceURI('TEST') . '/mystore/delivery'; else $serviceURL = $dejalaConfig->getRootServiceURI('PROD') . '/mystore/delivery'; $responseArray = $this->makeRequest($dejalaConfig, $serviceURL, $delivery, 'POST', TRUE); if (!($xml = strstr($responseArray['response'], 'loadXML($xml); $nodeList = $doc->getElementsByTagName('delivery'); if ($nodeList->length > 0) $this->getNodeValue($nodeList->item(0), $delivery); } return ($responseArray); } /** * Quick creates a store account at dejala.fr * only works on Dejala test platform * @returns the HTTP status code of the request **/ public function createInstantStore($dejalaConfig, $storeName) { $serviceURL = $dejalaConfig->getRootServiceURI('TEST') . '/instantstore'; $postargs['login']=$dejalaConfig->login; $postargs['password']=$dejalaConfig->password; $postargs['store_url']=$dejalaConfig->storeUrl; $postargs['store_name'] = $storeName; $postargs['platform'] = 'prestashop'; $responseArray = $this->makeRequest($dejalaConfig, $serviceURL, $postargs, 'POST', FALSE); return ($responseArray); } static public function wtf($var, $arrayOfObjectsToHide=null, $fontSize=11) { $text = print_r($var, true); if (is_array($arrayOfObjectsToHide)) { foreach ($arrayOfObjectsToHide as $objectName) { $searchPattern = '#('.$objectName.' Object\n(\s+)\().*?\n\2\)\n#s'; $replace = "$1--> HIDDEN - courtesy of wtf() <--)"; $text = preg_replace($searchPattern, $replace, $text); } } // color code objects $text = preg_replace('#(\w+)(\s+Object\s+\()#s', '$1$2', $text); // color code object properties $text = preg_replace('#\[(\w+)\:(public|private|protected)\]#', '[$1:$2]', $text); echo '
'.$text.''; } public function getStoreLocation($dejalaConfig, &$location) { $serviceURL = $dejalaConfig->getRootServiceURI() . '/mystore'; $postargs = array(); $responseArray = $this->makeRequest($dejalaConfig, $serviceURL, $postargs, 'GET', TRUE); if (!($xml = strstr($responseArray['response'], 'loadXML($xml); $locationNodes=$doc->getElementsByTagName('location'); if ($locationNodes->length > 0) { $locationNode = $locationNodes->item(0); $nodeList = $locationNode->childNodes; foreach ($nodeList as $element){ $location[$element->nodeName] = $element->textContent; } } } return ($responseArray); } public function getStoreCalendar($dejalaConfig, &$calendar) { $serviceURL = $dejalaConfig->getRootServiceURI() . '/mystore/calendar/'; $responseArray = $this->makeRequest($dejalaConfig, $serviceURL, array(), 'GET', TRUE); if (!($xml = strstr($responseArray['response'], 'loadXML($xml); $nodeList = $doc->getElementsByTagName('entry'); if ($nodeList->length > 0) { foreach ($nodeList as $element) { $calendarNode = $this->getNodeValue($element); $calendar['entries'][(int)($calendarNode['weekday'])] = $calendarNode; } } $nodeList = $doc->getElementsByTagName('exception'); $calendar['exceptions'] = array(); if ($nodeList->length > 0) { foreach ($nodeList as $element) { $calendar['exceptions'][] = $this->getNodeValue($element); } } } return ($responseArray); } public function getStoreContacts($dejalaConfig, &$contacts) { $serviceURL = $dejalaConfig->getRootServiceURI() . '/mystore'; $postargs = array(); $responseArray = $this->makeRequest($dejalaConfig, $serviceURL, $postargs, 'GET', TRUE); if (!($xml = strstr($responseArray['response'], 'loadXML($xml); $contactsNodeList = $doc->getElementsByTagName('contacts'); if ($contactsNodeList->length > 0) { $contactNodes = $contactsNodeList->item(0)->childNodes; if ($contactNodes) foreach ($contactNodes as $contactNode) { $name = $contactNode->nodeName; $nodeList = $contactNode->childNodes; $currentContactNode = array(); if ($nodeList) foreach ($nodeList as $element) { $currentContactNode[$element->nodeName] = $element->textContent; } $contacts[$name] = $currentContactNode; } } } return ($responseArray); } public function getStoreProducts($dejalaConfig, &$products) { $serviceURL = $dejalaConfig->getRootServiceURI() . '/mystore/products'; $postargs = array(); $responseArray = $this->makeRequest($dejalaConfig, $serviceURL, $postargs, 'GET', TRUE); if (!($xml = strstr($responseArray['response'], 'loadXML($xml); $productsNodeList = $doc->getElementsByTagName('product'); foreach ($productsNodeList as $productNode) { $currentProduct = array(); $nodeList = $productNode->childNodes; foreach ($nodeList as $element) { $currentProduct[$element->nodeName] = $element->textContent; } if (count($currentProduct)) $products[] = $currentProduct; } } usort($products, array("DejalaUtils", "cmpProducts")); return ($responseArray); } private static function cmpProducts($a, $b) { if ($a['priority'] == $b['priority']) { if (($a['price'] == $b['price'])) { return ($a['id'] < $b['id']) ? -1 : 1 ; } return ($a['price'] < $b['price']) ? -1 : 1 ; } return ($a['priority'] < $b['priority']) ? -1 : 1; } public function getStoreQuotation($dejalaConfig, $quotationElements, &$products) { $serviceURL = $dejalaConfig->getRootServiceURI() . '/mystore/quotation'; $postargs = $quotationElements; $responseArray = $this->makeRequest($dejalaConfig, $serviceURL, $postargs, 'GET', TRUE); if (!($xml = strstr($responseArray['response'], 'loadXML($xml); $productsNodeList = $doc->getElementsByTagName('product'); foreach ($productsNodeList as $productNode) { $currentProduct = $this->getNodeValue($productNode); unset($currentProduct['calendar']['entries']['entry']); $calendarNodeList = $doc->getElementsByTagName('entry'); foreach ($calendarNodeList as $calendarNode) { $calendarEntry = $this->getNodeValue($calendarNode); $currentProduct['calendar']['entries'][$calendarEntry['weekday']] = $calendarEntry; } $exceptionNodeList = $doc->getElementsByTagName('exception'); $currentProduct['calendar']['exceptions'] = array(); foreach ($exceptionNodeList as $exceptionNode) { $currentProduct['calendar']['exceptions'][] = $this->getNodeValue($exceptionNode); } /*$currentProduct = array(); $nodeList = $productNode->childNodes; foreach ($nodeList as $element) { $currentProduct[$element->nodeName] = $element->textContent; } */ if (count($currentProduct)) $products[] = $currentProduct; } } usort($products, array("DejalaUtils", "cmpProducts")); return ($responseArray); } public function getStoreAttributes($dejalaConfig, &$store) { $serviceURL = $dejalaConfig->getRootServiceURI() . '/mystore'; $postargs = array(); $responseArray = $this->makeRequest($dejalaConfig, $serviceURL, $postargs, 'GET', TRUE); if (!($xml = strstr($responseArray['response'], 'loadXML($xml); $fatherNodeList = $doc->getElementsByTagName('store'); if ($fatherNodeList->length > 0) { $childNodes = $fatherNodeList->item(0)->childNodes; foreach ($childNodes as $childNode) { $store[$childNode->nodeName] = $childNode->textContent; } } $nodeList = $doc->getElementsByTagName('attributes'); $store['attributes'] = array(); if ($nodeList->length > 0) { $store['attributes'] = $this->getNodeValue($nodeList->item(0)); } } return ($responseArray); } public function getStoreProcesses($dejalaConfig, &$processes) { $serviceURL = $dejalaConfig->getRootServiceURI() . '/mystore'; $postargs = array(); $responseArray = $this->makeRequest($dejalaConfig, $serviceURL, $postargs, 'GET', TRUE); if (!($xml = strstr($responseArray['response'], 'loadXML($xml); $fatherNodeList = $doc->getElementsByTagName('processes'); if ($fatherNodeList->length > 0) { $childNodes = $fatherNodeList->item(0)->childNodes; foreach ($childNodes as $childNode) { $processes[$childNode->nodeName] = $childNode->textContent; } } } return ($responseArray); } public function getStoreProductByID($dejalaConfig, $productID, &$product) { $serviceURL = $dejalaConfig->getRootServiceURI() . '/mystore/products/' . $productID; $postargs = array(); $responseArray = $this->makeRequest($dejalaConfig, $serviceURL, $postargs, 'GET', TRUE); if (!($xml = strstr($responseArray['response'], 'loadXML($xml); $productsNodeList = $doc->getElementsByTagName('product'); if ($productsNodeList->length > 0) { $nodeList = $productsNodeList->item(0)->childNodes; foreach ($nodeList as $element) { $product[$element->nodeName] = $element->textContent; } } } return ($responseArray); } public function getDelivery($dejalaConfig, &$delivery, $mode) { if ($mode !== 'PROD') $serviceURL = $dejalaConfig->getRootServiceURI('TEST') . '/mystore/delivery/' . $delivery['id']; else $serviceURL = $dejalaConfig->getRootServiceURI('PROD') . '/mystore/delivery/' . $delivery['id']; $responseArray = $this->makeRequest($dejalaConfig, $serviceURL, array(), 'GET', TRUE); if (!($xml = strstr($responseArray['response'], 'loadXML($xml); //echo 'xml='.$xml.'