@@ -67,6 +67,9 @@ discard block |
||
67 | 67 | return $this; |
68 | 68 | } |
69 | 69 | |
70 | + /** |
|
71 | + * @return string |
|
72 | + */ |
|
70 | 73 | public function getLabel() { |
71 | 74 | return $this->getAttrib('label'); |
72 | 75 | } |
@@ -98,6 +101,9 @@ discard block |
||
98 | 101 | return $this->getDataFromRequest($data); |
99 | 102 | } |
100 | 103 | |
104 | + /** |
|
105 | + * @param boolean $isRequired |
|
106 | + */ |
|
101 | 107 | public function setRequired($isRequired) { |
102 | 108 | $this->_isRequired = (bool) $isRequired; |
103 | 109 | return $this; |
@@ -107,6 +113,9 @@ discard block |
||
107 | 113 | return (bool) $this->_isRequired; |
108 | 114 | } |
109 | 115 | |
116 | + /** |
|
117 | + * @param boolean $isRendered |
|
118 | + */ |
|
110 | 119 | public function setRendered($isRendered) { |
111 | 120 | $this->_isRendered = (bool) $isRendered; |
112 | 121 | return $this; |
@@ -226,6 +235,9 @@ discard block |
||
226 | 235 | return $this->_attribs[$key]; |
227 | 236 | } |
228 | 237 | |
238 | + /** |
|
239 | + * @param string $key |
|
240 | + */ |
|
229 | 241 | public function delAttrib($key) { |
230 | 242 | $key = (string) $key; |
231 | 243 | unset($this->_attribs[$key]); |
@@ -264,6 +276,9 @@ discard block |
||
264 | 276 | return $this; |
265 | 277 | } |
266 | 278 | |
279 | + /** |
|
280 | + * @param string $key |
|
281 | + */ |
|
267 | 282 | public function getOption($key) |
268 | 283 | { |
269 | 284 | $key = (string) $key; |
@@ -288,6 +303,9 @@ discard block |
||
288 | 303 | return $this; |
289 | 304 | } |
290 | 305 | |
306 | + /** |
|
307 | + * @param boolean $position |
|
308 | + */ |
|
291 | 309 | public function getDecoratorsByPosition($position) { |
292 | 310 | return $this->_decorators[$position]; |
293 | 311 | } |
@@ -144,13 +144,13 @@ |
||
144 | 144 | public function validate() { |
145 | 145 | if ($this->isRequired() && !$this->getValue()) { |
146 | 146 | $message = $this->getForm()->getMessageTemplate('no-' . $this->getName()); |
147 | - if (!$message) { |
|
148 | - $translateSlug = 'general.form.errors.required'; |
|
149 | - $message = nip__($translateSlug, array('label' => $this->getLabel())); |
|
150 | - if ($message == $translateSlug) { |
|
151 | - $message = $message ? $message : 'The field `' . $this->getLabel() . '` is mandatory.'; |
|
152 | - } |
|
153 | - } |
|
147 | + if (!$message) { |
|
148 | + $translateSlug = 'general.form.errors.required'; |
|
149 | + $message = nip__($translateSlug, array('label' => $this->getLabel())); |
|
150 | + if ($message == $translateSlug) { |
|
151 | + $message = $message ? $message : 'The field `' . $this->getLabel() . '` is mandatory.'; |
|
152 | + } |
|
153 | + } |
|
154 | 154 | $this->addError($message); |
155 | 155 | } |
156 | 156 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public function getJSID() |
51 | 51 | { |
52 | 52 | $name = $this->getUniqueId(); |
53 | - return str_replace(array('][','[',']'), array('-','-',''), $this->getUniqueId()); |
|
53 | + return str_replace(array('][', '[', ']'), array('-', '-', ''), $this->getUniqueId()); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | public function setName($name) { |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | /** |
192 | 192 | * @return Nip_Form_Element_Abstract |
193 | 193 | */ |
194 | - public function setAttrib($key, $value) { |
|
194 | + public function setAttrib($key, $value) { |
|
195 | 195 | $key = (string) $key; |
196 | 196 | $this->_attribs[$key] = $value; |
197 | 197 | return $this; |
@@ -25,6 +25,9 @@ |
||
25 | 25 | return $this->getAttrib('checked') == 'checked'; |
26 | 26 | } |
27 | 27 | |
28 | + /** |
|
29 | + * @param boolean $checked |
|
30 | + */ |
|
28 | 31 | public function setChecked($checked) { |
29 | 32 | if ($checked === true) { |
30 | 33 | $this->setAttrib('checked', 'checked'); |
@@ -8,17 +8,17 @@ |
||
8 | 8 | $this->setAttrib('type', 'checkbox'); |
9 | 9 | } |
10 | 10 | |
11 | - public function getDataFromRequest($request) { |
|
12 | - $this->setChecked($request != null); |
|
11 | + public function getDataFromRequest($request) { |
|
12 | + $this->setChecked($request != null); |
|
13 | 13 | return parent::getDataFromRequest($request); |
14 | 14 | } |
15 | 15 | |
16 | 16 | public function getDataFromModel($value) { |
17 | - $inputValue = $this->getValue(); |
|
18 | - if ($inputValue == null && $value) { |
|
19 | - $this->setChecked(true); |
|
20 | - } |
|
21 | - return parent::getDataFromModel($data); |
|
17 | + $inputValue = $this->getValue(); |
|
18 | + if ($inputValue == null && $value) { |
|
19 | + $this->setChecked(true); |
|
20 | + } |
|
21 | + return parent::getDataFromModel($data); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function isChecked() { |
@@ -46,6 +46,9 @@ |
||
46 | 46 | return $this->_hasTime; |
47 | 47 | } |
48 | 48 | |
49 | + /** |
|
50 | + * @return string |
|
51 | + */ |
|
49 | 52 | public function getValue($requester = 'abstract') |
50 | 53 | { |
51 | 54 | $value = parent::getValue($requester); |
@@ -10,7 +10,6 @@ discard block |
||
10 | 10 | |
11 | 11 | |
12 | 12 | /** |
13 | - * @param Nip_Form_DisplayGroup $form |
|
14 | 13 | * @return Nip_Form_Renderer_DisplayGroup |
15 | 14 | */ |
16 | 15 | public function setGroup(Nip_Form_DisplayGroup $group) |
@@ -20,7 +19,7 @@ discard block |
||
20 | 19 | } |
21 | 20 | |
22 | 21 | /** |
23 | - * @return Nip_Form_Renderer_DisplayGroup|null |
|
22 | + * @return Nip_Form_DisplayGroup |
|
24 | 23 | */ |
25 | 24 | public function getGroup() |
26 | 25 | { |
@@ -29,7 +29,7 @@ |
||
29 | 29 | |
30 | 30 | public function render() |
31 | 31 | { |
32 | - $return = '<fieldset'.$this->renderAttributes().'>'; |
|
32 | + $return = '<fieldset' . $this->renderAttributes() . '>'; |
|
33 | 33 | $return .= '<legend>' . $this->getGroup()->getLegend() . '</legend>'; |
34 | 34 | |
35 | 35 | $renderer = clone $this->getGroup()->getForm()->getRenderer(); |
@@ -84,7 +84,6 @@ discard block |
||
84 | 84 | * Transforms a date's string representation into $format |
85 | 85 | * |
86 | 86 | * @param string $format |
87 | - * @param string|int $datetime |
|
88 | 87 | * @return string/bool |
89 | 88 | */ |
90 | 89 | function _strtotime($date, $format = false) |
@@ -111,6 +110,9 @@ discard block |
||
111 | 110 | |
112 | 111 | if (!function_exists("pluck")) { |
113 | 112 | |
113 | + /** |
|
114 | + * @param Nip_RecordCollection $array |
|
115 | + */ |
|
114 | 116 | function pluck($array, $property) |
115 | 117 | { |
116 | 118 | return Nip_Helper_Array::instance()->pluck($array, $property); |
@@ -275,6 +277,10 @@ discard block |
||
275 | 277 | } |
276 | 278 | |
277 | 279 | if (!function_exists("money_format")) { |
280 | + |
|
281 | + /** |
|
282 | + * @param string $format |
|
283 | + */ |
|
278 | 284 | function money_format($format, $number) |
279 | 285 | { |
280 | 286 | $regex = '/%((?:[\^!\-]|\+|\(|\=.)*)([0-9]+)?' . |
@@ -366,7 +366,7 @@ |
||
366 | 366 | if (!function_exists("json_decode")) { |
367 | 367 | |
368 | 368 | function json_decode($json, $assoc = FALSE, /* emu_args */ |
369 | - $n = 0, $state = 0, $waitfor = 0) |
|
369 | + $n = 0, $state = 0, $waitfor = 0) |
|
370 | 370 | { |
371 | 371 | |
372 | 372 | #-- result var |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | |
126 | 126 | $unit = strtoupper(substr($post_max_size, -1)); |
127 | 127 | $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1))); |
128 | - $post_max_size = ((int)$post_max_size) * $multiplier; |
|
128 | + $post_max_size = ((int) $post_max_size) * $multiplier; |
|
129 | 129 | |
130 | 130 | $unit = strtoupper(substr($upload_max_filesize, -1)); |
131 | 131 | $multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1))); |
132 | - $upload_max_filesize = ((int)$upload_max_filesize) * $multiplier; |
|
132 | + $upload_max_filesize = ((int) $upload_max_filesize) * $multiplier; |
|
133 | 133 | |
134 | 134 | return round((min($post_max_size, $upload_max_filesize) / 1048576), 2) . 'MB'; |
135 | 135 | } |
@@ -220,8 +220,7 @@ discard block |
||
220 | 220 | } |
221 | 221 | /* Split digits and add. */ |
222 | 222 | $checksum += $current_num % 10; |
223 | - if |
|
224 | - ($current_num > 9 |
|
223 | + if ($current_num > 9 |
|
225 | 224 | ) { |
226 | 225 | $checksum += 1; |
227 | 226 | } |
@@ -295,9 +294,9 @@ discard block |
||
295 | 294 | 'nosimbol' => preg_match('/\!/', $fmatch[1]) > 0, |
296 | 295 | 'isleft' => preg_match('/\-/', $fmatch[1]) > 0 |
297 | 296 | ); |
298 | - $width = trim($fmatch[2]) ? (int)$fmatch[2] : 0; |
|
299 | - $left = trim($fmatch[3]) ? (int)$fmatch[3] : 0; |
|
300 | - $right = trim($fmatch[4]) ? (int)$fmatch[4] : $locale['int_frac_digits']; |
|
297 | + $width = trim($fmatch[2]) ? (int) $fmatch[2] : 0; |
|
298 | + $left = trim($fmatch[3]) ? (int) $fmatch[3] : 0; |
|
299 | + $right = trim($fmatch[4]) ? (int) $fmatch[4] : $locale['int_frac_digits']; |
|
301 | 300 | $conversion = $fmatch[5]; |
302 | 301 | |
303 | 302 | $positive = true; |
@@ -416,7 +415,7 @@ discard block |
||
416 | 415 | } |
417 | 416 | } #-> end of sub-call (array/object) |
418 | 417 | elseif ($waitfor && (strpos($waitfor, $c) !== false)) { |
419 | - return array($val, $n); // return current value and state |
|
418 | + return array($val, $n); // return current value and state |
|
420 | 419 | } #-= in-array |
421 | 420 | elseif ($state === ']') { |
422 | 421 | list($v, $n) = json_decode($json, 0, $n, 0, ",]"); |
@@ -426,7 +425,7 @@ discard block |
||
426 | 425 | } |
427 | 426 | } #-= in-object |
428 | 427 | elseif ($state === '}') { |
429 | - list($i, $n) = json_decode($json, 0, $n, 0, ":"); // this allowed non-string indicies |
|
428 | + list($i, $n) = json_decode($json, 0, $n, 0, ":"); // this allowed non-string indicies |
|
430 | 429 | list($v, $n) = json_decode($json, 0, $n + 1, 0, ",}"); |
431 | 430 | $val[$i] = $v; |
432 | 431 | if ($json[$n] == "}") { |
@@ -464,15 +463,15 @@ discard block |
||
464 | 463 | $val = $uu[1]; |
465 | 464 | $n += strlen($uu[0]) - 1; |
466 | 465 | if (strpos($val, ".")) { // float |
467 | - $val = (float)$val; |
|
466 | + $val = (float) $val; |
|
468 | 467 | } elseif ($val[0] == "0") { // oct |
469 | 468 | $val = octdec($val); |
470 | 469 | } else { |
471 | - $val = (int)$val; |
|
470 | + $val = (int) $val; |
|
472 | 471 | } |
473 | 472 | // exponent? |
474 | 473 | if (isset($uu[2])) { |
475 | - $val *= pow(10, (int)$uu[2]); |
|
474 | + $val *= pow(10, (int) $uu[2]); |
|
476 | 475 | } |
477 | 476 | } #-> boolean or null |
478 | 477 | elseif (preg_match("#^(true|false|null)\b#", substr($json, $n), $uu)) { |
@@ -177,7 +177,6 @@ |
||
177 | 177 | * |
178 | 178 | * @param array $array |
179 | 179 | * @param array $params |
180 | - * @param string $key |
|
181 | 180 | * @return array |
182 | 181 | */ |
183 | 182 | public function findAll($array, $params, $returnKey = false) |
@@ -237,8 +237,9 @@ discard block |
||
237 | 237 | public function toXML($data, $rootNodeName = 'ResultSet', &$xml = null) |
238 | 238 | { |
239 | 239 | // turn off compatibility mode as simple xml throws a wobbly if you don't. |
240 | - if (ini_get('zend.ze1_compatibility_mode') == 1) |
|
241 | - ini_set('zend.ze1_compatibility_mode', 0); |
|
240 | + if (ini_get('zend.ze1_compatibility_mode') == 1) { |
|
241 | + ini_set('zend.ze1_compatibility_mode', 0); |
|
242 | + } |
|
242 | 243 | |
243 | 244 | if (is_null($xml)) { |
244 | 245 | $xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$rootNodeName />"); |
@@ -260,8 +261,9 @@ discard block |
||
260 | 261 | $node = $this->isAssoc($value) || $numeric ? $xml->addChild($key) : $xml; |
261 | 262 | |
262 | 263 | // recursive call |
263 | - if ($numeric) |
|
264 | - $key = 'anon'; |
|
264 | + if ($numeric) { |
|
265 | + $key = 'anon'; |
|
266 | + } |
|
265 | 267 | $this->toXML($value, $key, $node); |
266 | 268 | } else { |
267 | 269 | // add single node. |
@@ -41,6 +41,9 @@ discard block |
||
41 | 41 | } |
42 | 42 | |
43 | 43 | |
44 | + /** |
|
45 | + * @param string $color |
|
46 | + */ |
|
44 | 47 | public function hsl($color) |
45 | 48 | { |
46 | 49 | list($r, $g, $b) = $this->rgb($color); |
@@ -135,7 +138,7 @@ discard block |
||
135 | 138 | * |
136 | 139 | * @param string|array $color1 |
137 | 140 | * @param string|array $color2 |
138 | - * @return int |
|
141 | + * @return double |
|
139 | 142 | */ |
140 | 143 | public function lumDiff($color1, $color2) |
141 | 144 | { |
@@ -39,7 +39,7 @@ |
||
39 | 39 | /** |
40 | 40 | * Singleton |
41 | 41 | * |
42 | - * @return Nip_Helper_Date |
|
42 | + * @return Nip_Helper_Time |
|
43 | 43 | */ |
44 | 44 | static public function instance() |
45 | 45 | { |
@@ -12,42 +12,42 @@ |
||
12 | 12 | return $minutes; |
13 | 13 | } |
14 | 14 | |
15 | - public function secondsInStringTime($seconds) |
|
16 | - { |
|
17 | - if ($days = intval((floor($seconds / 86400)))) { |
|
15 | + public function secondsInStringTime($seconds) |
|
16 | + { |
|
17 | + if ($days = intval((floor($seconds / 86400)))) { |
|
18 | 18 | $seconds = $seconds - $days*86400; |
19 | - $return .= ($return ? ' ' : '') . str_pad($days, 2, 0,STR_PAD_LEFT).'d'; |
|
20 | - } |
|
21 | - if ($hours = intval((floor($seconds / 3600))) OR $return) { |
|
19 | + $return .= ($return ? ' ' : '') . str_pad($days, 2, 0,STR_PAD_LEFT).'d'; |
|
20 | + } |
|
21 | + if ($hours = intval((floor($seconds / 3600))) OR $return) { |
|
22 | 22 | $seconds = $seconds - $hours*3600; |
23 | - $return .= ($return ? ' ' : '') . str_pad($hours, 2, 0,STR_PAD_LEFT).'h'; |
|
24 | - } |
|
25 | - if ($minutes = intval((floor($seconds / 60))) OR $return) { |
|
26 | - $seconds = $seconds - $minutes*60; |
|
27 | - $return .= ($return ? ' ' : '') . str_pad($minutes, 2, 0, STR_PAD_LEFT).'m'; |
|
28 | - } |
|
23 | + $return .= ($return ? ' ' : '') . str_pad($hours, 2, 0,STR_PAD_LEFT).'h'; |
|
24 | + } |
|
25 | + if ($minutes = intval((floor($seconds / 60))) OR $return) { |
|
26 | + $seconds = $seconds - $minutes*60; |
|
27 | + $return .= ($return ? ' ' : '') . str_pad($minutes, 2, 0, STR_PAD_LEFT).'m'; |
|
28 | + } |
|
29 | 29 | |
30 | - $seconds = round($seconds, 2); |
|
30 | + $seconds = round($seconds, 2); |
|
31 | 31 | if ($seconds) { |
32 | 32 | $return .= ($return ? ' ' : '') . str_pad($seconds, 2, 0, STR_PAD_LEFT).'s'; |
33 | 33 | } |
34 | 34 | |
35 | - return $return; |
|
36 | - } |
|
35 | + return $return; |
|
36 | + } |
|
37 | 37 | |
38 | 38 | |
39 | - /** |
|
40 | - * Singleton |
|
41 | - * |
|
42 | - * @return Nip_Helper_Date |
|
43 | - */ |
|
44 | - static public function instance() |
|
45 | - { |
|
46 | - static $instance; |
|
47 | - if (!($instance instanceof self)) { |
|
48 | - $instance = new self(); |
|
49 | - } |
|
50 | - return $instance; |
|
51 | - } |
|
39 | + /** |
|
40 | + * Singleton |
|
41 | + * |
|
42 | + * @return Nip_Helper_Date |
|
43 | + */ |
|
44 | + static public function instance() |
|
45 | + { |
|
46 | + static $instance; |
|
47 | + if (!($instance instanceof self)) { |
|
48 | + $instance = new self(); |
|
49 | + } |
|
50 | + return $instance; |
|
51 | + } |
|
52 | 52 | |
53 | 53 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | $minutes = false; |
8 | 8 | if (strpos($time, ':')) { |
9 | 9 | list($hours, $minutes) = explode(':', $time); |
10 | - $minutes += $hours*60; |
|
10 | + $minutes += $hours * 60; |
|
11 | 11 | } |
12 | 12 | return $minutes; |
13 | 13 | } |
@@ -15,21 +15,21 @@ discard block |
||
15 | 15 | public function secondsInStringTime($seconds) |
16 | 16 | { |
17 | 17 | if ($days = intval((floor($seconds / 86400)))) { |
18 | - $seconds = $seconds - $days*86400; |
|
19 | - $return .= ($return ? ' ' : '') . str_pad($days, 2, 0,STR_PAD_LEFT).'d'; |
|
18 | + $seconds = $seconds - $days * 86400; |
|
19 | + $return .= ($return ? ' ' : '') . str_pad($days, 2, 0, STR_PAD_LEFT) . 'd'; |
|
20 | 20 | } |
21 | 21 | if ($hours = intval((floor($seconds / 3600))) OR $return) { |
22 | - $seconds = $seconds - $hours*3600; |
|
23 | - $return .= ($return ? ' ' : '') . str_pad($hours, 2, 0,STR_PAD_LEFT).'h'; |
|
22 | + $seconds = $seconds - $hours * 3600; |
|
23 | + $return .= ($return ? ' ' : '') . str_pad($hours, 2, 0, STR_PAD_LEFT) . 'h'; |
|
24 | 24 | } |
25 | 25 | if ($minutes = intval((floor($seconds / 60))) OR $return) { |
26 | - $seconds = $seconds - $minutes*60; |
|
27 | - $return .= ($return ? ' ' : '') . str_pad($minutes, 2, 0, STR_PAD_LEFT).'m'; |
|
26 | + $seconds = $seconds - $minutes * 60; |
|
27 | + $return .= ($return ? ' ' : '') . str_pad($minutes, 2, 0, STR_PAD_LEFT) . 'm'; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | $seconds = round($seconds, 2); |
31 | 31 | if ($seconds) { |
32 | - $return .= ($return ? ' ' : '') . str_pad($seconds, 2, 0, STR_PAD_LEFT).'s'; |
|
32 | + $return .= ($return ? ' ' : '') . str_pad($seconds, 2, 0, STR_PAD_LEFT) . 's'; |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | return $return; |
@@ -26,6 +26,9 @@ |
||
26 | 26 | return Nip_Config::instance()->ANALYTICS->domain; |
27 | 27 | } |
28 | 28 | |
29 | + /** |
|
30 | + * @param string $method |
|
31 | + */ |
|
29 | 32 | public function addOperation($method, $params, $position = 'below') |
30 | 33 | { |
31 | 34 | if ($position == 'prepend') { |
@@ -28,13 +28,13 @@ discard block |
||
28 | 28 | |
29 | 29 | public function addOperation($method, $params, $position = 'below') |
30 | 30 | { |
31 | - if ($position == 'prepend') { |
|
32 | - array_unshift($this->_operations, array($method, $params)); |
|
33 | - } else { |
|
34 | - $this->_operations[] = array($method, $params); |
|
35 | - } |
|
31 | + if ($position == 'prepend') { |
|
32 | + array_unshift($this->_operations, array($method, $params)); |
|
33 | + } else { |
|
34 | + $this->_operations[] = array($method, $params); |
|
35 | + } |
|
36 | 36 | |
37 | - return $this; |
|
37 | + return $this; |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -81,36 +81,36 @@ discard block |
||
81 | 81 | public function parseTransactions($prefix = '') { |
82 | 82 | $transactions = $this->getTransactions(); |
83 | 83 | |
84 | - $prefix = $prefix ? $prefix.'.' : ''; |
|
84 | + $prefix = $prefix ? $prefix.'.' : ''; |
|
85 | 85 | |
86 | - if ($this->transactions) { |
|
87 | - foreach ($this->transactions as $transaction) { |
|
88 | - $this->addOperation($prefix.'_addTrans', array( |
|
89 | - $transaction->orderId, |
|
90 | - $transaction->affiliation, |
|
91 | - $transaction->total, |
|
92 | - $transaction->tax, |
|
93 | - $transaction->shipping, |
|
94 | - $transaction->city, |
|
95 | - $transaction->state, |
|
96 | - $transaction->country |
|
97 | - )); |
|
98 | - |
|
99 | - if ($transaction->items) { |
|
100 | - foreach ($transaction->items as $item) { |
|
101 | - $this->addOperation($prefix.'_addItem', array( |
|
102 | - $item->orderId, |
|
103 | - $item->sku, |
|
104 | - $item->name, |
|
105 | - $item->category, |
|
106 | - $item->price, |
|
107 | - $item->quantity |
|
108 | - )); |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
112 | - $this->addOperation($prefix.'_trackTrans'); //submits transaction to the Analytics servers |
|
113 | - } |
|
86 | + if ($this->transactions) { |
|
87 | + foreach ($this->transactions as $transaction) { |
|
88 | + $this->addOperation($prefix.'_addTrans', array( |
|
89 | + $transaction->orderId, |
|
90 | + $transaction->affiliation, |
|
91 | + $transaction->total, |
|
92 | + $transaction->tax, |
|
93 | + $transaction->shipping, |
|
94 | + $transaction->city, |
|
95 | + $transaction->state, |
|
96 | + $transaction->country |
|
97 | + )); |
|
98 | + |
|
99 | + if ($transaction->items) { |
|
100 | + foreach ($transaction->items as $item) { |
|
101 | + $this->addOperation($prefix.'_addItem', array( |
|
102 | + $item->orderId, |
|
103 | + $item->sku, |
|
104 | + $item->name, |
|
105 | + $item->category, |
|
106 | + $item->price, |
|
107 | + $item->quantity |
|
108 | + )); |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | + $this->addOperation($prefix.'_trackTrans'); //submits transaction to the Analytics servers |
|
113 | + } |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | public function setPage($page) |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $this->addOperation('_setDomainName', $this->getDomain(), 'prepend'); |
132 | 132 | $this->addOperation('_setAccount', $this->getUA(), 'prepend'); |
133 | 133 | |
134 | - $this->parseTransactions(''); |
|
134 | + $this->parseTransactions(''); |
|
135 | 135 | |
136 | 136 | $return = '<script type="text/javascript">'; |
137 | 137 | $return .= 'var _gaq = _gaq || [];'; |
@@ -139,19 +139,19 @@ discard block |
||
139 | 139 | foreach ($this->_operations as $operation) { |
140 | 140 | $return .= "_gaq.push(["; |
141 | 141 | $return .= "'{$operation[0]}'"; |
142 | - if (isset($operation[1]) && $operation[1] !== null) { |
|
143 | - $return .= ","; |
|
144 | - $params = array(); |
|
145 | - if (is_array($operation[1])) { |
|
146 | - foreach ($operation[1] as $param) { |
|
147 | - $params[] = $this->renderOperationParam($param); |
|
148 | - } |
|
149 | - } else { |
|
150 | - $params[] = $this->renderOperationParam($operation[1]); |
|
151 | - } |
|
142 | + if (isset($operation[1]) && $operation[1] !== null) { |
|
143 | + $return .= ","; |
|
144 | + $params = array(); |
|
145 | + if (is_array($operation[1])) { |
|
146 | + foreach ($operation[1] as $param) { |
|
147 | + $params[] = $this->renderOperationParam($param); |
|
148 | + } |
|
149 | + } else { |
|
150 | + $params[] = $this->renderOperationParam($operation[1]); |
|
151 | + } |
|
152 | 152 | |
153 | - $return .= implode(',', $params); |
|
154 | - } |
|
153 | + $return .= implode(',', $params); |
|
154 | + } |
|
155 | 155 | $return .= "]);"; |
156 | 156 | } |
157 | 157 | |
@@ -165,11 +165,11 @@ discard block |
||
165 | 165 | return $return; |
166 | 166 | } |
167 | 167 | |
168 | - public function renderOperationParam($param) |
|
169 | - { |
|
170 | - if (is_bool($param)) { |
|
171 | - return $param=== true ? 'true' : 'false'; |
|
172 | - } |
|
173 | - return "'{$param}'"; |
|
174 | - } |
|
168 | + public function renderOperationParam($param) |
|
169 | + { |
|
170 | + if (is_bool($param)) { |
|
171 | + return $param=== true ? 'true' : 'false'; |
|
172 | + } |
|
173 | + return "'{$param}'"; |
|
174 | + } |
|
175 | 175 | } |
176 | 176 | \ No newline at end of file |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | public function parseTransactions($prefix = '') { |
82 | 82 | $transactions = $this->getTransactions(); |
83 | 83 | |
84 | - $prefix = $prefix ? $prefix.'.' : ''; |
|
84 | + $prefix = $prefix ? $prefix . '.' : ''; |
|
85 | 85 | |
86 | 86 | if ($this->transactions) { |
87 | 87 | foreach ($this->transactions as $transaction) { |
88 | - $this->addOperation($prefix.'_addTrans', array( |
|
88 | + $this->addOperation($prefix . '_addTrans', array( |
|
89 | 89 | $transaction->orderId, |
90 | 90 | $transaction->affiliation, |
91 | 91 | $transaction->total, |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | |
99 | 99 | if ($transaction->items) { |
100 | 100 | foreach ($transaction->items as $item) { |
101 | - $this->addOperation($prefix.'_addItem', array( |
|
101 | + $this->addOperation($prefix . '_addItem', array( |
|
102 | 102 | $item->orderId, |
103 | 103 | $item->sku, |
104 | 104 | $item->name, |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } |
110 | 110 | } |
111 | 111 | } |
112 | - $this->addOperation($prefix.'_trackTrans'); //submits transaction to the Analytics servers |
|
112 | + $this->addOperation($prefix . '_trackTrans'); //submits transaction to the Analytics servers |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | public function renderOperationParam($param) |
169 | 169 | { |
170 | 170 | if (is_bool($param)) { |
171 | - return $param=== true ? 'true' : 'false'; |
|
171 | + return $param === true ? 'true' : 'false'; |
|
172 | 172 | } |
173 | 173 | return "'{$param}'"; |
174 | 174 | } |