Пример #1
0
 protected static function write($decodedArray)
 {
     // Update Version
     if (isset($decodedArray[0]['attribs']['version'])) {
         $versionNumberStr = $decodedArray[0]['attribs']['version'];
         if (@intval($versionNumberStr) != null) {
             // Increment Version Number
             $versionNumberInt = intval($versionNumberStr) + 1;
             $decodedArray[0]['attribs']['version'] = $versionNumberInt;
         }
     }
     // Encode XML
     $xmlEncoder = new XMLEncoder();
     $xmlFileContent = $xmlEncoder->encode($decodedArray);
     // Write To File
     $file = fopen('sites.xml', 'w+');
     fputs($file, iconv('UTF-8', 'ISO-8859-1//TRANSLIT//IGNORE', $xmlFileContent));
     fclose($file);
     // Commit New Changes
     svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_USERNAME, SITES_XML_SVN_USERNAME);
     svn_auth_set_parameter(SVN_AUTH_PARAM_DEFAULT_PASSWORD, SITES_XML_SVN_PASSWORD);
     svn_commit('PHP Commit', './');
 }
Пример #2
0
 private function callAPI($request, $URL, $SerializeOption = null)
 {
     $response = null;
     $isError = false;
     $reqObject = $request;
     try {
         switch (X_PAYPAL_REQUEST_DATA_FORMAT) {
             case "JSON":
                 $request = JSONEncoder::Encode($request);
                 $response = parent::callWebService($request, $URL);
                 break;
             case "SOAP11":
                 $request = SoapEncoder::Encode($request, $SerializeOption);
                 $response = parent::call($request, $URL);
                 break;
             case "XML":
                 $request = XMLEncoder::Encode($request, $SerializeOption);
                 $response = parent::callWebService($request, $URL);
                 break;
         }
         if (X_PAYPAL_RESPONSE_DATA_FORMAT == 'XML' || X_PAYPAL_RESPONSE_DATA_FORMAT == 'JSON') {
             switch (X_PAYPAL_RESPONSE_DATA_FORMAT) {
                 case "JSON":
                     $strObjName = get_class($reqObject);
                     $strObjName = str_replace('Request', 'Response', $strObjName);
                     $response = JSONEncoder::Decode($response, $isError, $strObjName);
                     break;
                 case "XML":
                     $response = XMLEncoder::Decode($response, $isError);
                     break;
             }
             if ($isError) {
                 $this->isSuccess = 'Failure';
                 $this->setLastError($response);
                 $response = null;
             } else {
                 $this->isSuccess = 'Success';
             }
         }
     } catch (Exception $ex) {
         throw new FatalException('Error occurred in callAPI method');
     }
     return $response;
 }
Пример #3
0
 function encode($array, $indent = 0)
 {
     $output = "";
     foreach ($array as $tag) {
         // Tag Open
         $output .= XMLEncoder::indentation($indent) . "<" . $tag['tag'];
         // Attributes
         if (isset($tag['attribs']) && count($tag['attribs']) > 0) {
             foreach ($tag['attribs'] as $attribKey => $attribValue) {
                 $output .= " {$attribKey}=\"{$attribValue}\"";
             }
         }
         $output .= ">";
         // Data
         if (isset($tag['data'])) {
             // (Inline with Tag)
             $output .= $tag['data'];
         }
         // Children
         if (isset($tag['child'])) {
             if (count($tag['child']) > 0) {
                 // Recursively Concatenate with Children
                 $output .= "\r\n";
                 // New Line for Children
                 $output .= $this->encode($tag['child'], $indent + 1);
                 $output .= XMLEncoder::indentation($indent);
                 // New INDENTED Line for Tag Close
             }
         }
         // Tag Close
         $output .= "</" . $tag['tag'] . ">" . "\r\n";
     }
     return $output;
 }