@@ -28,46 +28,46 @@ |
||
28 | 28 | |
29 | 29 | class Email |
30 | 30 | { |
31 | - const EMAIL_PRIORITY_HIGHEST = 'Highest'; |
|
32 | - const EMAIL_PRIORITY_HIGH = 'High'; |
|
33 | - const EMAIL_PRIORITY_NORMAL = 'Normal'; |
|
34 | - const EMAIL_PRIORITY_LOW = 'Low'; |
|
35 | - const EMAIL_PRIORITY_LOWEST = 'Lowest'; |
|
31 | + const EMAIL_PRIORITY_HIGHEST = 'Highest'; |
|
32 | + const EMAIL_PRIORITY_HIGH = 'High'; |
|
33 | + const EMAIL_PRIORITY_NORMAL = 'Normal'; |
|
34 | + const EMAIL_PRIORITY_LOW = 'Low'; |
|
35 | + const EMAIL_PRIORITY_LOWEST = 'Lowest'; |
|
36 | 36 | |
37 | - public function setBccSender($bccSender) |
|
38 | - { |
|
39 | - $this->bccSender = $bccSender; |
|
40 | - } |
|
37 | + public function setBccSender($bccSender) |
|
38 | + { |
|
39 | + $this->bccSender = $bccSender; |
|
40 | + } |
|
41 | 41 | |
42 | - public function setEmailPriority($priority) |
|
43 | - { |
|
44 | - $this->emailPriority = $priority; |
|
45 | - } |
|
42 | + public function setEmailPriority($priority) |
|
43 | + { |
|
44 | + $this->emailPriority = $priority; |
|
45 | + } |
|
46 | 46 | |
47 | - public function setSubject($subject) |
|
48 | - { |
|
49 | - $this->subject = $subject; |
|
50 | - } |
|
47 | + public function setSubject($subject) |
|
48 | + { |
|
49 | + $this->subject = $subject; |
|
50 | + } |
|
51 | 51 | |
52 | - public function setSaveAsActivity($saveAsActivity) |
|
53 | - { |
|
54 | - $this->saveAsActivity = $saveAsActivity; |
|
55 | - } |
|
52 | + public function setSaveAsActivity($saveAsActivity) |
|
53 | + { |
|
54 | + $this->saveAsActivity = $saveAsActivity; |
|
55 | + } |
|
56 | 56 | |
57 | - public function setReplyTo($replyTo) |
|
58 | - { |
|
59 | - $this->replyTo = $replyTo; |
|
60 | - } |
|
57 | + public function setReplyTo($replyTo) |
|
58 | + { |
|
59 | + $this->replyTo = $replyTo; |
|
60 | + } |
|
61 | 61 | |
62 | - public function setUseSignature($useSignature) |
|
63 | - { |
|
64 | - $this->useSignature = $useSignature; |
|
65 | - } |
|
62 | + public function setUseSignature($useSignature) |
|
63 | + { |
|
64 | + $this->useSignature = $useSignature; |
|
65 | + } |
|
66 | 66 | |
67 | - public function setSenderDisplayName($name) |
|
68 | - { |
|
69 | - $this->senderDisplayName = $name; |
|
70 | - } |
|
67 | + public function setSenderDisplayName($name) |
|
68 | + { |
|
69 | + $this->senderDisplayName = $name; |
|
70 | + } |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | ?> |
@@ -27,70 +27,70 @@ |
||
27 | 27 | */ |
28 | 28 | class SingleEmailMessage extends Email |
29 | 29 | { |
30 | - public $ccAddresses; |
|
30 | + public $ccAddresses; |
|
31 | 31 | |
32 | - public function __construct() |
|
33 | - { |
|
32 | + public function __construct() |
|
33 | + { |
|
34 | 34 | |
35 | - } |
|
35 | + } |
|
36 | 36 | |
37 | - public function setBccAddresses($addresses) |
|
38 | - { |
|
39 | - $this->bccAddresses = $addresses; |
|
40 | - } |
|
37 | + public function setBccAddresses($addresses) |
|
38 | + { |
|
39 | + $this->bccAddresses = $addresses; |
|
40 | + } |
|
41 | 41 | |
42 | - public function setCcAddresses($addresses) |
|
43 | - { |
|
44 | - $this->ccAddresses = $addresses; |
|
45 | - } |
|
42 | + public function setCcAddresses($addresses) |
|
43 | + { |
|
44 | + $this->ccAddresses = $addresses; |
|
45 | + } |
|
46 | 46 | |
47 | - public function setCharset($charset) |
|
48 | - { |
|
49 | - $this->charset = $charset; |
|
50 | - } |
|
47 | + public function setCharset($charset) |
|
48 | + { |
|
49 | + $this->charset = $charset; |
|
50 | + } |
|
51 | 51 | |
52 | - public function setHtmlBody($htmlBody) |
|
53 | - { |
|
54 | - $this->htmlBody = $htmlBody; |
|
55 | - } |
|
52 | + public function setHtmlBody($htmlBody) |
|
53 | + { |
|
54 | + $this->htmlBody = $htmlBody; |
|
55 | + } |
|
56 | 56 | |
57 | - public function setOrgWideEmailAddressId($orgWideEmailAddressId) |
|
58 | - { |
|
59 | - $this->orgWideEmailAddressId = $orgWideEmailAddressId; |
|
60 | - } |
|
57 | + public function setOrgWideEmailAddressId($orgWideEmailAddressId) |
|
58 | + { |
|
59 | + $this->orgWideEmailAddressId = $orgWideEmailAddressId; |
|
60 | + } |
|
61 | 61 | |
62 | - public function setPlainTextBody($plainTextBody) |
|
63 | - { |
|
64 | - $this->plainTextBody = $plainTextBody; |
|
65 | - } |
|
62 | + public function setPlainTextBody($plainTextBody) |
|
63 | + { |
|
64 | + $this->plainTextBody = $plainTextBody; |
|
65 | + } |
|
66 | 66 | |
67 | - public function setTargetObjectId($targetObjectId) |
|
68 | - { |
|
69 | - $this->targetObjectId = $targetObjectId; |
|
70 | - } |
|
67 | + public function setTargetObjectId($targetObjectId) |
|
68 | + { |
|
69 | + $this->targetObjectId = $targetObjectId; |
|
70 | + } |
|
71 | 71 | |
72 | - public function setTemplateId($templateId) |
|
73 | - { |
|
74 | - $this->templateId = $templateId; |
|
75 | - } |
|
72 | + public function setTemplateId($templateId) |
|
73 | + { |
|
74 | + $this->templateId = $templateId; |
|
75 | + } |
|
76 | 76 | |
77 | - public function setToAddresses($array) |
|
78 | - { |
|
79 | - $this->toAddresses = $array; |
|
80 | - } |
|
77 | + public function setToAddresses($array) |
|
78 | + { |
|
79 | + $this->toAddresses = $array; |
|
80 | + } |
|
81 | 81 | |
82 | - public function setWhatId($whatId) |
|
83 | - { |
|
84 | - $this->whatId = $whatId; |
|
85 | - } |
|
82 | + public function setWhatId($whatId) |
|
83 | + { |
|
84 | + $this->whatId = $whatId; |
|
85 | + } |
|
86 | 86 | |
87 | - public function setFileAttachments($array) |
|
88 | - { |
|
89 | - $this->fileAttachments = $array; |
|
90 | - } |
|
87 | + public function setFileAttachments($array) |
|
88 | + { |
|
89 | + $this->fileAttachments = $array; |
|
90 | + } |
|
91 | 91 | |
92 | - public function setDocumentAttachments($array) |
|
93 | - { |
|
94 | - $this->documentAttachments = $array; |
|
95 | - } |
|
92 | + public function setDocumentAttachments($array) |
|
93 | + { |
|
94 | + $this->documentAttachments = $array; |
|
95 | + } |
|
96 | 96 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | { |
137 | 137 | $str = preg_replace('{sf:}', '', $any); |
138 | 138 | |
139 | - $array = $this->xml2array('<Object xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . $str . '</Object>', |
|
139 | + $array = $this->xml2array('<Object xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$str.'</Object>', |
|
140 | 140 | 2); |
141 | 141 | |
142 | 142 | $xml = new stdClass(); |
@@ -185,11 +185,11 @@ discard block |
||
185 | 185 | $current = &$xml_array; |
186 | 186 | |
187 | 187 | foreach ($xml_values as $data) { |
188 | - unset($attributes, $value);//Remove existing values, or there will be trouble |
|
188 | + unset($attributes, $value); //Remove existing values, or there will be trouble |
|
189 | 189 | |
190 | 190 | //This command will extract these variables into the foreach scope |
191 | 191 | // tag(string), type(string), level(int), attributes(array). |
192 | - extract($data);//We could use the array by itself, but this cooler. |
|
192 | + extract($data); //We could use the array by itself, but this cooler. |
|
193 | 193 | |
194 | 194 | $result = ''; |
195 | 195 | if ($get_attributes) { |
@@ -31,261 +31,261 @@ |
||
31 | 31 | |
32 | 32 | class SObject |
33 | 33 | { |
34 | - public $type; |
|
35 | - public $fields; |
|
36 | - |
|
37 | - // public $sobject; |
|
38 | - |
|
39 | - public function __construct($response = null) |
|
40 | - { |
|
41 | - if (!isset($response) && !$response) { |
|
42 | - return; |
|
43 | - } |
|
44 | - |
|
45 | - foreach ($response as $responseKey => $responseValue) { |
|
46 | - if (in_array($responseKey, array('Id', 'type', 'any'))) { |
|
47 | - continue; |
|
48 | - } |
|
49 | - $this->$responseKey = $responseValue; |
|
50 | - } |
|
51 | - |
|
52 | - if (isset($response->Id)) { |
|
53 | - $this->Id = is_array($response->Id) ? $response->Id[0] : $response->Id; |
|
54 | - } |
|
55 | - |
|
56 | - if (isset($response->type)) { |
|
57 | - $this->type = $response->type; |
|
58 | - } |
|
59 | - |
|
60 | - if (isset($response->any)) { |
|
61 | - try { |
|
62 | - if ($response->any instanceof stdClass) { |
|
63 | - if ($this->isSObject($response->any)) { |
|
64 | - $anArray = array(); |
|
65 | - $sobject = new SObject($response->any); |
|
66 | - $anArray[] = $sobject; |
|
67 | - $this->sobjects = $anArray; |
|
68 | - } else { |
|
69 | - $this->queryResult = new QueryResult($response->any); |
|
70 | - } |
|
71 | - } else { |
|
72 | - if (is_array($response->any)) { |
|
73 | - $anArray = array(); |
|
74 | - foreach ($response->any as $key => $item) { |
|
75 | - if ($item instanceof stdClass) { |
|
76 | - if ($this->isSObject($item)) { |
|
77 | - $sobject = new SObject($item); |
|
78 | - $anArray[$key] = $sobject; |
|
79 | - } else { |
|
80 | - if (!isset($this->queryResult)) { |
|
81 | - $this->queryResult = array(); |
|
82 | - } |
|
83 | - array_push($this->queryResult, new QueryResult($item)); |
|
84 | - } |
|
85 | - } else { |
|
86 | - if (strpos($item, 'sf:') === false) { |
|
87 | - $currentXmlValue = sprintf('<sf:%s>%s</sf:%s>', $key, $item, $key); |
|
88 | - } else { |
|
89 | - $currentXmlValue = $item; |
|
90 | - } |
|
91 | - |
|
92 | - if (!isset($fieldsToConvert)) { |
|
93 | - $fieldsToConvert = $currentXmlValue; |
|
94 | - } else { |
|
95 | - $fieldsToConvert .= $currentXmlValue; |
|
96 | - } |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - if (isset($fieldsToConvert)) { |
|
101 | - $this->fields = $this->convertFields($fieldsToConvert); |
|
102 | - } |
|
103 | - |
|
104 | - if (count($anArray) > 0) { |
|
105 | - foreach ($anArray as $key => $children_sobject) { |
|
106 | - $this->fields->$key = $children_sobject; |
|
107 | - } |
|
108 | - } |
|
109 | - } else { |
|
110 | - $this->fields = $this->convertFields($response->any); |
|
111 | - } |
|
112 | - } |
|
113 | - } catch (Exception $e) { |
|
114 | - error_log('salesforce exception: ', $e->getMessage()); |
|
115 | - error_log('salesforce exception: ', $e->getTraceAsString()); |
|
116 | - } |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - public function __get($name) |
|
121 | - { |
|
122 | - return (isset($this->fields->$name)) ? $this->fields->$name : false; |
|
123 | - } |
|
124 | - |
|
125 | - public function __isset($name) |
|
126 | - { |
|
127 | - return isset($this->fields->$name); |
|
128 | - } |
|
129 | - |
|
130 | - /** |
|
131 | - * Parse the "any" string from an sObject. First strip out the sf: and then |
|
132 | - * enclose string with <Object></Object>. Load the string using |
|
133 | - * simplexml_load_string and return an array that can be traversed. |
|
134 | - */ |
|
135 | - public function convertFields($any) |
|
136 | - { |
|
137 | - $str = preg_replace('{sf:}', '', $any); |
|
138 | - |
|
139 | - $array = $this->xml2array('<Object xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . $str . '</Object>', |
|
140 | - 2); |
|
141 | - |
|
142 | - $xml = new stdClass(); |
|
143 | - if (!count($array['Object'])) { |
|
144 | - return $xml; |
|
145 | - } |
|
146 | - |
|
147 | - foreach ($array['Object'] as $k => $v) { |
|
148 | - $xml->$k = $v; |
|
149 | - } |
|
150 | - |
|
151 | - return $xml; |
|
152 | - } |
|
153 | - |
|
154 | - /** |
|
155 | - * |
|
156 | - * @param string $contents |
|
157 | - * @return array |
|
158 | - */ |
|
159 | - public function xml2array($contents, $get_attributes = 1) |
|
160 | - { |
|
161 | - if (!$contents) { |
|
162 | - return array(); |
|
163 | - } |
|
164 | - |
|
165 | - if (!function_exists('xml_parser_create')) { |
|
166 | - return array('not found'); |
|
167 | - } |
|
168 | - |
|
169 | - $parser = xml_parser_create(); |
|
170 | - xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); |
|
171 | - xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
172 | - xml_parse_into_struct($parser, $contents, $xml_values); |
|
173 | - xml_parser_free($parser); |
|
174 | - |
|
175 | - if (!$xml_values) { |
|
176 | - return; |
|
177 | - } |
|
178 | - |
|
179 | - //Initializations |
|
180 | - $xml_array = array(); |
|
181 | - $parents = array(); |
|
182 | - $opened_tags = array(); |
|
183 | - $arr = array(); |
|
184 | - |
|
185 | - $current = &$xml_array; |
|
186 | - |
|
187 | - foreach ($xml_values as $data) { |
|
188 | - unset($attributes, $value);//Remove existing values, or there will be trouble |
|
189 | - |
|
190 | - //This command will extract these variables into the foreach scope |
|
191 | - // tag(string), type(string), level(int), attributes(array). |
|
192 | - extract($data);//We could use the array by itself, but this cooler. |
|
193 | - |
|
194 | - $result = ''; |
|
195 | - if ($get_attributes) { |
|
196 | - switch ($get_attributes) { |
|
197 | - case 1: |
|
198 | - $result = array(); |
|
199 | - if (isset($value)) { |
|
200 | - $result['value'] = $value; |
|
201 | - } |
|
202 | - |
|
203 | - //Set the attributes too. |
|
204 | - if (isset($attributes)) { |
|
205 | - foreach ($attributes as $attr => $val) { |
|
206 | - if ($get_attributes == 1) { |
|
207 | - $result['attr'][$attr] = $val; |
|
208 | - } //Set all the attributes in a array called 'attr' |
|
209 | - /** :TODO: should we change the key name to '_attr'? Someone may use the tagname 'attr'. Same goes for 'value' too */ |
|
210 | - } |
|
211 | - } |
|
212 | - break; |
|
213 | - |
|
214 | - case 2: |
|
215 | - $result = array(); |
|
216 | - if (isset($value)) { |
|
217 | - $result = $value; |
|
218 | - } |
|
219 | - |
|
220 | - //Check for nil and ignore other attributes. |
|
221 | - if (isset($attributes) && isset($attributes['xsi:nil']) && !strcasecmp($attributes['xsi:nil'], |
|
222 | - 'true') |
|
223 | - ) { |
|
224 | - $result = null; |
|
225 | - } |
|
226 | - break; |
|
227 | - } |
|
228 | - } elseif (isset($value)) { |
|
229 | - $result = $value; |
|
230 | - } |
|
231 | - |
|
232 | - //See tag status and do the needed. |
|
233 | - if ($type == "open") {//The starting of the tag '<tag>' |
|
234 | - $parent[$level - 1] = &$current; |
|
235 | - |
|
236 | - if (!is_array($current) || (!in_array($tag, array_keys($current)))) { //Insert New tag |
|
237 | - $current[$tag] = $result; |
|
238 | - $current = &$current[$tag]; |
|
239 | - |
|
240 | - } else { //There was another element with the same tag name |
|
241 | - if (isset($current[$tag][0])) { |
|
242 | - array_push($current[$tag], $result); |
|
243 | - } else { |
|
244 | - $current[$tag] = array($current[$tag], $result); |
|
245 | - } |
|
246 | - $last = count($current[$tag]) - 1; |
|
247 | - $current = &$current[$tag][$last]; |
|
248 | - } |
|
249 | - |
|
250 | - } elseif ($type == "complete") { //Tags that ends in 1 line '<tag />' |
|
251 | - //See if the key is already taken. |
|
252 | - if (!isset($current[$tag])) { //New Key |
|
253 | - $current[$tag] = $result; |
|
254 | - |
|
255 | - } else { //If taken, put all things inside a list(array) |
|
256 | - if ((is_array($current[$tag]) && $get_attributes == 0)//If it is already an array... |
|
257 | - || (isset($current[$tag][0]) && is_array($current[$tag][0]) && ($get_attributes == 1 || $get_attributes == 2)) |
|
258 | - ) { |
|
259 | - array_push($current[$tag], $result); // ...push the new element into that array. |
|
260 | - } else { //If it is not an array... |
|
261 | - $current[$tag] = array( |
|
262 | - $current[$tag], |
|
263 | - $result |
|
264 | - ); //...Make it an array using using the existing value and the new value |
|
265 | - } |
|
266 | - } |
|
267 | - |
|
268 | - } elseif ($type == 'close') { //End of tag '</tag>' |
|
269 | - $current = &$parent[$level - 1]; |
|
270 | - } |
|
271 | - } |
|
272 | - |
|
273 | - return ($xml_array); |
|
274 | - } |
|
275 | - |
|
276 | - /* |
|
34 | + public $type; |
|
35 | + public $fields; |
|
36 | + |
|
37 | + // public $sobject; |
|
38 | + |
|
39 | + public function __construct($response = null) |
|
40 | + { |
|
41 | + if (!isset($response) && !$response) { |
|
42 | + return; |
|
43 | + } |
|
44 | + |
|
45 | + foreach ($response as $responseKey => $responseValue) { |
|
46 | + if (in_array($responseKey, array('Id', 'type', 'any'))) { |
|
47 | + continue; |
|
48 | + } |
|
49 | + $this->$responseKey = $responseValue; |
|
50 | + } |
|
51 | + |
|
52 | + if (isset($response->Id)) { |
|
53 | + $this->Id = is_array($response->Id) ? $response->Id[0] : $response->Id; |
|
54 | + } |
|
55 | + |
|
56 | + if (isset($response->type)) { |
|
57 | + $this->type = $response->type; |
|
58 | + } |
|
59 | + |
|
60 | + if (isset($response->any)) { |
|
61 | + try { |
|
62 | + if ($response->any instanceof stdClass) { |
|
63 | + if ($this->isSObject($response->any)) { |
|
64 | + $anArray = array(); |
|
65 | + $sobject = new SObject($response->any); |
|
66 | + $anArray[] = $sobject; |
|
67 | + $this->sobjects = $anArray; |
|
68 | + } else { |
|
69 | + $this->queryResult = new QueryResult($response->any); |
|
70 | + } |
|
71 | + } else { |
|
72 | + if (is_array($response->any)) { |
|
73 | + $anArray = array(); |
|
74 | + foreach ($response->any as $key => $item) { |
|
75 | + if ($item instanceof stdClass) { |
|
76 | + if ($this->isSObject($item)) { |
|
77 | + $sobject = new SObject($item); |
|
78 | + $anArray[$key] = $sobject; |
|
79 | + } else { |
|
80 | + if (!isset($this->queryResult)) { |
|
81 | + $this->queryResult = array(); |
|
82 | + } |
|
83 | + array_push($this->queryResult, new QueryResult($item)); |
|
84 | + } |
|
85 | + } else { |
|
86 | + if (strpos($item, 'sf:') === false) { |
|
87 | + $currentXmlValue = sprintf('<sf:%s>%s</sf:%s>', $key, $item, $key); |
|
88 | + } else { |
|
89 | + $currentXmlValue = $item; |
|
90 | + } |
|
91 | + |
|
92 | + if (!isset($fieldsToConvert)) { |
|
93 | + $fieldsToConvert = $currentXmlValue; |
|
94 | + } else { |
|
95 | + $fieldsToConvert .= $currentXmlValue; |
|
96 | + } |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + if (isset($fieldsToConvert)) { |
|
101 | + $this->fields = $this->convertFields($fieldsToConvert); |
|
102 | + } |
|
103 | + |
|
104 | + if (count($anArray) > 0) { |
|
105 | + foreach ($anArray as $key => $children_sobject) { |
|
106 | + $this->fields->$key = $children_sobject; |
|
107 | + } |
|
108 | + } |
|
109 | + } else { |
|
110 | + $this->fields = $this->convertFields($response->any); |
|
111 | + } |
|
112 | + } |
|
113 | + } catch (Exception $e) { |
|
114 | + error_log('salesforce exception: ', $e->getMessage()); |
|
115 | + error_log('salesforce exception: ', $e->getTraceAsString()); |
|
116 | + } |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + public function __get($name) |
|
121 | + { |
|
122 | + return (isset($this->fields->$name)) ? $this->fields->$name : false; |
|
123 | + } |
|
124 | + |
|
125 | + public function __isset($name) |
|
126 | + { |
|
127 | + return isset($this->fields->$name); |
|
128 | + } |
|
129 | + |
|
130 | + /** |
|
131 | + * Parse the "any" string from an sObject. First strip out the sf: and then |
|
132 | + * enclose string with <Object></Object>. Load the string using |
|
133 | + * simplexml_load_string and return an array that can be traversed. |
|
134 | + */ |
|
135 | + public function convertFields($any) |
|
136 | + { |
|
137 | + $str = preg_replace('{sf:}', '', $any); |
|
138 | + |
|
139 | + $array = $this->xml2array('<Object xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' . $str . '</Object>', |
|
140 | + 2); |
|
141 | + |
|
142 | + $xml = new stdClass(); |
|
143 | + if (!count($array['Object'])) { |
|
144 | + return $xml; |
|
145 | + } |
|
146 | + |
|
147 | + foreach ($array['Object'] as $k => $v) { |
|
148 | + $xml->$k = $v; |
|
149 | + } |
|
150 | + |
|
151 | + return $xml; |
|
152 | + } |
|
153 | + |
|
154 | + /** |
|
155 | + * |
|
156 | + * @param string $contents |
|
157 | + * @return array |
|
158 | + */ |
|
159 | + public function xml2array($contents, $get_attributes = 1) |
|
160 | + { |
|
161 | + if (!$contents) { |
|
162 | + return array(); |
|
163 | + } |
|
164 | + |
|
165 | + if (!function_exists('xml_parser_create')) { |
|
166 | + return array('not found'); |
|
167 | + } |
|
168 | + |
|
169 | + $parser = xml_parser_create(); |
|
170 | + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); |
|
171 | + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
172 | + xml_parse_into_struct($parser, $contents, $xml_values); |
|
173 | + xml_parser_free($parser); |
|
174 | + |
|
175 | + if (!$xml_values) { |
|
176 | + return; |
|
177 | + } |
|
178 | + |
|
179 | + //Initializations |
|
180 | + $xml_array = array(); |
|
181 | + $parents = array(); |
|
182 | + $opened_tags = array(); |
|
183 | + $arr = array(); |
|
184 | + |
|
185 | + $current = &$xml_array; |
|
186 | + |
|
187 | + foreach ($xml_values as $data) { |
|
188 | + unset($attributes, $value);//Remove existing values, or there will be trouble |
|
189 | + |
|
190 | + //This command will extract these variables into the foreach scope |
|
191 | + // tag(string), type(string), level(int), attributes(array). |
|
192 | + extract($data);//We could use the array by itself, but this cooler. |
|
193 | + |
|
194 | + $result = ''; |
|
195 | + if ($get_attributes) { |
|
196 | + switch ($get_attributes) { |
|
197 | + case 1: |
|
198 | + $result = array(); |
|
199 | + if (isset($value)) { |
|
200 | + $result['value'] = $value; |
|
201 | + } |
|
202 | + |
|
203 | + //Set the attributes too. |
|
204 | + if (isset($attributes)) { |
|
205 | + foreach ($attributes as $attr => $val) { |
|
206 | + if ($get_attributes == 1) { |
|
207 | + $result['attr'][$attr] = $val; |
|
208 | + } //Set all the attributes in a array called 'attr' |
|
209 | + /** :TODO: should we change the key name to '_attr'? Someone may use the tagname 'attr'. Same goes for 'value' too */ |
|
210 | + } |
|
211 | + } |
|
212 | + break; |
|
213 | + |
|
214 | + case 2: |
|
215 | + $result = array(); |
|
216 | + if (isset($value)) { |
|
217 | + $result = $value; |
|
218 | + } |
|
219 | + |
|
220 | + //Check for nil and ignore other attributes. |
|
221 | + if (isset($attributes) && isset($attributes['xsi:nil']) && !strcasecmp($attributes['xsi:nil'], |
|
222 | + 'true') |
|
223 | + ) { |
|
224 | + $result = null; |
|
225 | + } |
|
226 | + break; |
|
227 | + } |
|
228 | + } elseif (isset($value)) { |
|
229 | + $result = $value; |
|
230 | + } |
|
231 | + |
|
232 | + //See tag status and do the needed. |
|
233 | + if ($type == "open") {//The starting of the tag '<tag>' |
|
234 | + $parent[$level - 1] = &$current; |
|
235 | + |
|
236 | + if (!is_array($current) || (!in_array($tag, array_keys($current)))) { //Insert New tag |
|
237 | + $current[$tag] = $result; |
|
238 | + $current = &$current[$tag]; |
|
239 | + |
|
240 | + } else { //There was another element with the same tag name |
|
241 | + if (isset($current[$tag][0])) { |
|
242 | + array_push($current[$tag], $result); |
|
243 | + } else { |
|
244 | + $current[$tag] = array($current[$tag], $result); |
|
245 | + } |
|
246 | + $last = count($current[$tag]) - 1; |
|
247 | + $current = &$current[$tag][$last]; |
|
248 | + } |
|
249 | + |
|
250 | + } elseif ($type == "complete") { //Tags that ends in 1 line '<tag />' |
|
251 | + //See if the key is already taken. |
|
252 | + if (!isset($current[$tag])) { //New Key |
|
253 | + $current[$tag] = $result; |
|
254 | + |
|
255 | + } else { //If taken, put all things inside a list(array) |
|
256 | + if ((is_array($current[$tag]) && $get_attributes == 0)//If it is already an array... |
|
257 | + || (isset($current[$tag][0]) && is_array($current[$tag][0]) && ($get_attributes == 1 || $get_attributes == 2)) |
|
258 | + ) { |
|
259 | + array_push($current[$tag], $result); // ...push the new element into that array. |
|
260 | + } else { //If it is not an array... |
|
261 | + $current[$tag] = array( |
|
262 | + $current[$tag], |
|
263 | + $result |
|
264 | + ); //...Make it an array using using the existing value and the new value |
|
265 | + } |
|
266 | + } |
|
267 | + |
|
268 | + } elseif ($type == 'close') { //End of tag '</tag>' |
|
269 | + $current = &$parent[$level - 1]; |
|
270 | + } |
|
271 | + } |
|
272 | + |
|
273 | + return ($xml_array); |
|
274 | + } |
|
275 | + |
|
276 | + /* |
|
277 | 277 | * If the stdClass has a done, we know it is a QueryResult |
278 | 278 | */ |
279 | - public function isQueryResult($param) |
|
280 | - { |
|
281 | - return isset($param->done); |
|
282 | - } |
|
279 | + public function isQueryResult($param) |
|
280 | + { |
|
281 | + return isset($param->done); |
|
282 | + } |
|
283 | 283 | |
284 | - /* |
|
284 | + /* |
|
285 | 285 | * If the stdClass has a type, we know it is an SObject |
286 | 286 | */ |
287 | - public function isSObject($param) |
|
288 | - { |
|
289 | - return isset($param->type); |
|
290 | - } |
|
287 | + public function isSObject($param) |
|
288 | + { |
|
289 | + return isset($param->type); |
|
290 | + } |
|
291 | 291 | } |
@@ -28,89 +28,89 @@ |
||
28 | 28 | |
29 | 29 | class QueryResult implements \Iterator |
30 | 30 | { |
31 | - public $queryLocator; |
|
32 | - public $done; |
|
33 | - public $records; |
|
34 | - public $size; |
|
31 | + public $queryLocator; |
|
32 | + public $done; |
|
33 | + public $records; |
|
34 | + public $size; |
|
35 | 35 | |
36 | - public $pointer; // Current iterator location |
|
37 | - private $sf; // SOAP Client |
|
36 | + public $pointer; // Current iterator location |
|
37 | + private $sf; // SOAP Client |
|
38 | 38 | |
39 | - public function __construct($response) |
|
40 | - { |
|
41 | - $this->queryLocator = $response->queryLocator; |
|
42 | - $this->done = $response->done; |
|
43 | - $this->size = $response->size; |
|
39 | + public function __construct($response) |
|
40 | + { |
|
41 | + $this->queryLocator = $response->queryLocator; |
|
42 | + $this->done = $response->done; |
|
43 | + $this->size = $response->size; |
|
44 | 44 | |
45 | - $this->pointer = 0; |
|
46 | - $this->sf = false; |
|
45 | + $this->pointer = 0; |
|
46 | + $this->sf = false; |
|
47 | 47 | |
48 | - if ($response instanceof QueryResult) { |
|
49 | - $this->records = $response->records; |
|
50 | - } else { |
|
51 | - $this->records = array(); |
|
52 | - if (isset($response->records)) { |
|
53 | - if (is_array($response->records)) { |
|
54 | - foreach ($response->records as $record) { |
|
55 | - array_push($this->records, $record); |
|
56 | - } |
|
57 | - } else { |
|
58 | - array_push($this->records, $record); |
|
59 | - } |
|
60 | - } |
|
61 | - } |
|
62 | - } |
|
48 | + if ($response instanceof QueryResult) { |
|
49 | + $this->records = $response->records; |
|
50 | + } else { |
|
51 | + $this->records = array(); |
|
52 | + if (isset($response->records)) { |
|
53 | + if (is_array($response->records)) { |
|
54 | + foreach ($response->records as $record) { |
|
55 | + array_push($this->records, $record); |
|
56 | + } |
|
57 | + } else { |
|
58 | + array_push($this->records, $record); |
|
59 | + } |
|
60 | + } |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - // Dependency Injection |
|
65 | - public function setSf(SforceBaseClient $sf) |
|
66 | - { |
|
67 | - $this->sf = $sf; |
|
68 | - } |
|
64 | + // Dependency Injection |
|
65 | + public function setSf(SforceBaseClient $sf) |
|
66 | + { |
|
67 | + $this->sf = $sf; |
|
68 | + } |
|
69 | 69 | |
70 | - // Basic Iterator implementation functions |
|
71 | - public function rewind() |
|
72 | - { |
|
73 | - $this->pointer = 0; |
|
74 | - } |
|
70 | + // Basic Iterator implementation functions |
|
71 | + public function rewind() |
|
72 | + { |
|
73 | + $this->pointer = 0; |
|
74 | + } |
|
75 | 75 | |
76 | - public function next() |
|
77 | - { |
|
78 | - ++$this->pointer; |
|
79 | - } |
|
76 | + public function next() |
|
77 | + { |
|
78 | + ++$this->pointer; |
|
79 | + } |
|
80 | 80 | |
81 | - public function key() |
|
82 | - { |
|
83 | - return $this->pointer; |
|
84 | - } |
|
81 | + public function key() |
|
82 | + { |
|
83 | + return $this->pointer; |
|
84 | + } |
|
85 | 85 | |
86 | - public function current() |
|
87 | - { |
|
88 | - return new SObject($this->records[$this->pointer]); |
|
89 | - } |
|
86 | + public function current() |
|
87 | + { |
|
88 | + return new SObject($this->records[$this->pointer]); |
|
89 | + } |
|
90 | 90 | |
91 | - public function valid() |
|
92 | - { |
|
93 | - while ($this->pointer >= count($this->records)) { |
|
94 | - // Pointer is larger than (current) result set; see if we can fetch more |
|
95 | - if ($this->done === false) { |
|
96 | - if ($this->sf === false) { |
|
97 | - throw new \Exception("Dependency not met!"); |
|
98 | - } |
|
99 | - $response = $this->sf->queryMore($this->queryLocator); |
|
100 | - $this->records = array_merge($this->records, $response->records); // Append more results |
|
101 | - $this->done = $response->done; |
|
102 | - $this->queryLocator = $response->queryLocator; |
|
103 | - } else { |
|
104 | - return false; // No more records to fetch |
|
105 | - } |
|
106 | - } |
|
91 | + public function valid() |
|
92 | + { |
|
93 | + while ($this->pointer >= count($this->records)) { |
|
94 | + // Pointer is larger than (current) result set; see if we can fetch more |
|
95 | + if ($this->done === false) { |
|
96 | + if ($this->sf === false) { |
|
97 | + throw new \Exception("Dependency not met!"); |
|
98 | + } |
|
99 | + $response = $this->sf->queryMore($this->queryLocator); |
|
100 | + $this->records = array_merge($this->records, $response->records); // Append more results |
|
101 | + $this->done = $response->done; |
|
102 | + $this->queryLocator = $response->queryLocator; |
|
103 | + } else { |
|
104 | + return false; // No more records to fetch |
|
105 | + } |
|
106 | + } |
|
107 | 107 | |
108 | - if (isset($this->records[$this->pointer])) { |
|
109 | - return true; |
|
110 | - } |
|
108 | + if (isset($this->records[$this->pointer])) { |
|
109 | + return true; |
|
110 | + } |
|
111 | 111 | |
112 | - throw new \Exception("QueryResult has gaps in the record data?"); |
|
113 | - } |
|
112 | + throw new \Exception("QueryResult has gaps in the record data?"); |
|
113 | + } |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | ?> |
@@ -28,7 +28,7 @@ |
||
28 | 28 | |
29 | 29 | class ProcessSubmitRequest extends ProcessRequest |
30 | 30 | { |
31 | - public $objectId; |
|
31 | + public $objectId; |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | ?> |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php namespace Davispeixoto\ForceDotComToolkitForPhp; |
2 | 2 | |
3 | - /* |
|
3 | + /* |
|
4 | 4 | * Copyright (c) 2007, salesforce.com, inc. |
5 | 5 | * All rights reserved. |
6 | 6 | * |
@@ -33,13 +33,13 @@ discard block |
||
33 | 33 | */ |
34 | 34 | class MruHeader |
35 | 35 | { |
36 | - // boolean that Indicates whether to update the list of most recently used items (True) or not (False). |
|
37 | - public $updateMruFlag; |
|
36 | + // boolean that Indicates whether to update the list of most recently used items (True) or not (False). |
|
37 | + public $updateMruFlag; |
|
38 | 38 | |
39 | - public function __construct($bool) |
|
40 | - { |
|
41 | - $this->updateMruFlag = $bool; |
|
42 | - } |
|
39 | + public function __construct($bool) |
|
40 | + { |
|
41 | + $this->updateMruFlag = $bool; |
|
42 | + } |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | ?> |
@@ -28,80 +28,80 @@ |
||
28 | 28 | |
29 | 29 | class SforceCustomObject |
30 | 30 | { |
31 | - public function setDeploymentStatus($deploymentStatus) |
|
32 | - { |
|
33 | - $this->deploymentStatus = $deploymentStatus; |
|
34 | - } |
|
35 | - |
|
36 | - public function setDescription($description) |
|
37 | - { |
|
38 | - $this->description = $description; |
|
39 | - } |
|
40 | - |
|
41 | - public function setEnableActivities($enableActivities) |
|
42 | - { |
|
43 | - $this->enableActivities = $enableActivities; |
|
44 | - } |
|
45 | - |
|
46 | - public function setEnableDivisions($enableDivisions) |
|
47 | - { |
|
48 | - $this->enableDivisions = $enableDivisions; |
|
49 | - } |
|
50 | - |
|
51 | - public function setEnableHistory($enableHistory) |
|
52 | - { |
|
53 | - $this->enableHistory = $enableHistory; |
|
54 | - } |
|
55 | - |
|
56 | - public function setEnableReports($enableReports) |
|
57 | - { |
|
58 | - $this->enableReports = $enableReports; |
|
59 | - } |
|
60 | - |
|
61 | - public function setFields($fields) |
|
62 | - { |
|
63 | - $this->fields = $fields; |
|
64 | - } |
|
65 | - |
|
66 | - public function setFullName($fullName) |
|
67 | - { |
|
68 | - $this->fullName = $fullName; |
|
69 | - } |
|
70 | - |
|
71 | - public function setGender($gender) |
|
72 | - { |
|
73 | - $this->gender = $gender; |
|
74 | - } |
|
75 | - |
|
76 | - public function setHousehold($household) |
|
77 | - { |
|
78 | - $this->household = $household; |
|
79 | - } |
|
80 | - |
|
81 | - public function setLabel($label) |
|
82 | - { |
|
83 | - $this->label = $label; |
|
84 | - } |
|
85 | - |
|
86 | - public function setNameField($nameField) |
|
87 | - { |
|
88 | - $this->nameField = $nameField; |
|
89 | - } |
|
90 | - |
|
91 | - public function setPluralLabel($pluralLabel) |
|
92 | - { |
|
93 | - $this->pluralLabel = $pluralLabel; |
|
94 | - } |
|
95 | - |
|
96 | - public function setSharingModel($sharingModel) |
|
97 | - { |
|
98 | - $this->sharingModel = $sharingModel; |
|
99 | - } |
|
100 | - |
|
101 | - public function setStartsWith($startsWith) |
|
102 | - { |
|
103 | - $this->startsWith = $startsWith; |
|
104 | - } |
|
31 | + public function setDeploymentStatus($deploymentStatus) |
|
32 | + { |
|
33 | + $this->deploymentStatus = $deploymentStatus; |
|
34 | + } |
|
35 | + |
|
36 | + public function setDescription($description) |
|
37 | + { |
|
38 | + $this->description = $description; |
|
39 | + } |
|
40 | + |
|
41 | + public function setEnableActivities($enableActivities) |
|
42 | + { |
|
43 | + $this->enableActivities = $enableActivities; |
|
44 | + } |
|
45 | + |
|
46 | + public function setEnableDivisions($enableDivisions) |
|
47 | + { |
|
48 | + $this->enableDivisions = $enableDivisions; |
|
49 | + } |
|
50 | + |
|
51 | + public function setEnableHistory($enableHistory) |
|
52 | + { |
|
53 | + $this->enableHistory = $enableHistory; |
|
54 | + } |
|
55 | + |
|
56 | + public function setEnableReports($enableReports) |
|
57 | + { |
|
58 | + $this->enableReports = $enableReports; |
|
59 | + } |
|
60 | + |
|
61 | + public function setFields($fields) |
|
62 | + { |
|
63 | + $this->fields = $fields; |
|
64 | + } |
|
65 | + |
|
66 | + public function setFullName($fullName) |
|
67 | + { |
|
68 | + $this->fullName = $fullName; |
|
69 | + } |
|
70 | + |
|
71 | + public function setGender($gender) |
|
72 | + { |
|
73 | + $this->gender = $gender; |
|
74 | + } |
|
75 | + |
|
76 | + public function setHousehold($household) |
|
77 | + { |
|
78 | + $this->household = $household; |
|
79 | + } |
|
80 | + |
|
81 | + public function setLabel($label) |
|
82 | + { |
|
83 | + $this->label = $label; |
|
84 | + } |
|
85 | + |
|
86 | + public function setNameField($nameField) |
|
87 | + { |
|
88 | + $this->nameField = $nameField; |
|
89 | + } |
|
90 | + |
|
91 | + public function setPluralLabel($pluralLabel) |
|
92 | + { |
|
93 | + $this->pluralLabel = $pluralLabel; |
|
94 | + } |
|
95 | + |
|
96 | + public function setSharingModel($sharingModel) |
|
97 | + { |
|
98 | + $this->sharingModel = $sharingModel; |
|
99 | + } |
|
100 | + |
|
101 | + public function setStartsWith($startsWith) |
|
102 | + { |
|
103 | + $this->startsWith = $startsWith; |
|
104 | + } |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | ?> |
@@ -28,27 +28,27 @@ |
||
28 | 28 | |
29 | 29 | class SforceSearchResult |
30 | 30 | { |
31 | - public $searchRecords; |
|
31 | + public $searchRecords; |
|
32 | 32 | |
33 | - public function __construct($response) |
|
34 | - { |
|
35 | - if ($response instanceof SforceSearchResult) { |
|
36 | - $this->searchRecords = $response->searchRecords; |
|
37 | - } else { |
|
38 | - $this->searchRecords = array(); |
|
39 | - if (isset($response->searchRecords)) { |
|
40 | - if (is_array($response->searchRecords)) { |
|
41 | - foreach ($response->searchRecords as $record) { |
|
42 | - $sobject = new SObject($record->record); |
|
43 | - array_push($this->searchRecords, $sobject); |
|
44 | - } |
|
45 | - } else { |
|
46 | - $sobject = new SObject($response->searchRecords->record); |
|
47 | - array_push($this->records, $sobject); |
|
48 | - } |
|
49 | - } |
|
50 | - } |
|
51 | - } |
|
33 | + public function __construct($response) |
|
34 | + { |
|
35 | + if ($response instanceof SforceSearchResult) { |
|
36 | + $this->searchRecords = $response->searchRecords; |
|
37 | + } else { |
|
38 | + $this->searchRecords = array(); |
|
39 | + if (isset($response->searchRecords)) { |
|
40 | + if (is_array($response->searchRecords)) { |
|
41 | + foreach ($response->searchRecords as $record) { |
|
42 | + $sobject = new SObject($record->record); |
|
43 | + array_push($this->searchRecords, $sobject); |
|
44 | + } |
|
45 | + } else { |
|
46 | + $sobject = new SObject($response->searchRecords->record); |
|
47 | + array_push($this->records, $sobject); |
|
48 | + } |
|
49 | + } |
|
50 | + } |
|
51 | + } |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | ?> |
@@ -28,8 +28,8 @@ |
||
28 | 28 | |
29 | 29 | class ProcessWorkitemRequest extends ProcessRequest |
30 | 30 | { |
31 | - public $action; |
|
32 | - public $workitemId; |
|
31 | + public $action; |
|
32 | + public $workitemId; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | ?> |