Google Analytics Dashboard for WP (GADWP) - Version 5.0

Version Description

This is a major update, please read the release notes first.

Download this release

Release Info

Developer deconf
Plugin Icon 128x128 Google Analytics Dashboard for WP (GADWP)
Version 5.0
Comparing to
See all releases

Code changes from version 4.9.6.2 to 5.0

Files changed (77) hide show
  1. admin/ajax-actions.php +14 -4
  2. admin/css/admin-widgets.css +1 -192
  3. admin/css/gadwp.css +1 -206
  4. admin/css/item-reports.css +1 -125
  5. admin/item-reports.php +9 -9
  6. admin/js/settings.js +1 -40
  7. admin/js/ui.js +1 -26
  8. admin/js/wp-color-picker-script.js +1 -11
  9. admin/settings.php +1356 -949
  10. admin/setup.php +3 -3
  11. common/js/reports.js +0 -1118
  12. common/js/reports5.js +1 -0
  13. common/nprogress/nprogress.css +1 -87
  14. common/nprogress/nprogress.js +1 -477
  15. common/realtime/jquery.ui.tooltip.html.css +1 -52
  16. common/realtime/jquery.ui.tooltip.html.js +1 -16
  17. config.php +182 -216
  18. front/ajax-actions.php +7 -2
  19. front/css/item-reports.css +1 -185
  20. front/css/widgets.css +1 -75
  21. front/js/tracking-analytics-events.js +1 -0
  22. front/js/tracking-scrolldepth.js +7 -0
  23. front/js/tracking-tagmanager-events.js +1 -0
  24. front/js/widgets.js +1 -13
  25. front/setup.php +2 -1
  26. front/tracking-analytics.php +349 -0
  27. front/tracking-tagmanager.php +167 -0
  28. front/tracking.php +23 -34
  29. front/tracking/code-classic.php +0 -34
  30. front/tracking/code-universal.php +0 -142
  31. front/tracking/events-classic.php +0 -55
  32. front/tracking/events-universal.php +0 -67
  33. front/views/analytics-code.php +10 -0
  34. front/views/optimize-code.php +12 -0
  35. front/views/tagmanager-code.php +16 -0
  36. front/widgets.php +2 -2
  37. gadwp.php +4 -4
  38. install/install.php +44 -12
  39. readme.txt +49 -50
  40. realtime/jquery/jquery.ui.tooltip.html.css +1 -55
  41. realtime/jquery/jquery.ui.tooltip.html.js +1 -16
  42. tools/gapi.php +81 -72
  43. tools/src/Google/Auth/Abstract.php +15 -17
  44. tools/src/Google/Auth/AppIdentity.php +81 -62
  45. tools/src/Google/Auth/AssertionCredentials.php +103 -110
  46. tools/src/Google/Auth/ComputeEngine.php +146 -0
  47. tools/src/Google/Auth/Exception.php +5 -2
  48. tools/src/Google/Auth/LoginTicket.php +42 -47
  49. tools/src/Google/Auth/OAuth2.php +600 -501
  50. tools/src/Google/Auth/Simple.php +36 -38
  51. tools/src/Google/Cache/Abstract.php +27 -32
  52. tools/src/Google/Cache/Apc.php +78 -73
  53. tools/src/Google/Cache/Exception.php +5 -2
  54. tools/src/Google/Cache/File.php +166 -143
  55. tools/src/Google/Cache/Memcache.php +145 -139
  56. tools/src/Google/Cache/Null.php +30 -27
  57. tools/src/Google/Client.php +693 -739
  58. tools/src/Google/Collection.php +71 -63
  59. tools/src/Google/Config.php +424 -415
  60. tools/src/Google/Exception.php +2 -2
  61. tools/src/Google/Http/Batch.php +115 -108
  62. tools/src/Google/Http/CacheParser.php +154 -151
  63. tools/src/Google/Http/MediaFileUpload.php +301 -275
  64. tools/src/Google/Http/REST.php +148 -113
  65. tools/src/Google/Http/Request.php +477 -471
  66. tools/src/Google/IO/Abstract.php +288 -289
  67. tools/src/Google/IO/Curl.php +159 -118
  68. tools/src/Google/IO/Exception.php +51 -3
  69. tools/src/Google/IO/Stream.php +196 -155
  70. tools/src/Google/Logger/Abstract.php +353 -355
  71. tools/src/Google/Logger/Exception.php +5 -2
  72. tools/src/Google/Logger/File.php +122 -113
  73. tools/src/Google/Logger/Null.php +18 -15
  74. tools/src/Google/Logger/Psr.php +59 -59
  75. tools/src/Google/Model.php +240 -228
  76. tools/src/Google/Service.php +38 -27
  77. tools/src/Google/Service/Analytics.php +294 -10296
admin/ajax-actions.php CHANGED
@@ -39,7 +39,7 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
39
  if ( ! isset( $_POST['gadwp_security_backend_item_reports'] ) || ! wp_verify_nonce( $_POST['gadwp_security_backend_item_reports'], 'gadwp_backend_item_reports' ) ) {
40
  wp_die( - 30 );
41
  }
42
- if ( isset( $_POST['projectId'] ) && $this->gadwp->config->options['switch_profile'] && $_POST['projectId'] !== 'false' ) {
43
  $projectId = $_POST['projectId'];
44
  } else {
45
  $projectId = false;
@@ -52,6 +52,16 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
52
  } else {
53
  $filter_id = false;
54
  }
 
 
 
 
 
 
 
 
 
 
55
  if ( ob_get_length() ) {
56
  ob_clean();
57
  }
@@ -66,7 +76,7 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
66
  } else {
67
  wp_die( - 24 );
68
  }
69
- if ( $projectId == false ) {
70
  $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
71
  }
72
  $profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_dash_profile_list'], $projectId );
@@ -90,7 +100,7 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
90
 
91
  $lastchar = substr( $filter, - 1 );
92
 
93
- if ( isset( $profile_info[6] ) && $profile_info[6] && $lastchar == '/' ) {
94
  $filter = $filter . $profile_info[6];
95
  }
96
 
@@ -105,7 +115,7 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
105
  $results = array();
106
 
107
  foreach ( $queries as $value ) {
108
- $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to, $filter );
109
  }
110
 
111
  wp_send_json( $results );
39
  if ( ! isset( $_POST['gadwp_security_backend_item_reports'] ) || ! wp_verify_nonce( $_POST['gadwp_security_backend_item_reports'], 'gadwp_backend_item_reports' ) ) {
40
  wp_die( - 30 );
41
  }
42
+ if ( isset( $_POST['projectId'] ) && $this->gadwp->config->options['switch_profile'] && 'false' !== $_POST['projectId'] ) {
43
  $projectId = $_POST['projectId'];
44
  } else {
45
  $projectId = false;
52
  } else {
53
  $filter_id = false;
54
  }
55
+ if ( isset( $_POST['metric'] ) ) {
56
+ $metric = $_POST['metric'];
57
+ } else {
58
+ $metric = 'sessions';
59
+ }
60
+
61
+ if ( $filter_id && $metric == 'sessions' ) { // Sessions metric is not available for item reports
62
+ $metric = 'pageviews';
63
+ }
64
+
65
  if ( ob_get_length() ) {
66
  ob_clean();
67
  }
76
  } else {
77
  wp_die( - 24 );
78
  }
79
+ if ( false == $projectId ) {
80
  $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
81
  }
82
  $profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_dash_profile_list'], $projectId );
100
 
101
  $lastchar = substr( $filter, - 1 );
102
 
103
+ if ( isset( $profile_info[6] ) && $profile_info[6] && '/' == $lastchar ) {
104
  $filter = $filter . $profile_info[6];
105
  }
106
 
115
  $results = array();
116
 
117
  foreach ( $queries as $value ) {
118
+ $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to, $filter, $metric );
119
  }
120
 
121
  wp_send_json( $results );
admin/css/admin-widgets.css CHANGED
@@ -1,192 +1 @@
1
- /**
2
- * Author: Alin Marcu
3
- * Author URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- /* Real-Time content */
10
- .gadwp-pline {
11
- width: 100%;
12
- margin: 0 0;
13
- padding: 5px 0 5px 0;
14
- background: #fff;
15
- -moz-box-shadow: 0px 0px 3px 0px #BBB;
16
- -webkit-box-shadow: 0px 0px 3px 0px #BBB;
17
- box-shadow: 0px 0px 3px 0px #BBB;
18
- display: table;
19
- overflow: hidden;
20
- }
21
-
22
- .gadwp-pleft {
23
- width: 90%;
24
- float: left;
25
- padding-left: 5px;
26
- }
27
-
28
- .gadwp-pright {
29
- width: 5%;
30
- float: right;
31
- padding-right: 5px;
32
- }
33
-
34
- [id^=gadwp-realtime-] {
35
- margin: 10px 0 0 0;
36
- width: 100%;
37
- }
38
-
39
- .gadwp-rt-box {
40
- width: 100%;
41
- margin: 0 0;
42
- background: #fff;
43
- text-align: center;
44
- -moz-box-shadow: 0px 0px 5px 0px #BBB;
45
- -webkit-box-shadow: 0px 0px 5px 0px #BBB;
46
- box-shadow: 0px 0px 5px 0px #BBB;
47
- display: table;
48
- }
49
-
50
- .gadwp-tdo-left {
51
- width: 60%;
52
- padding: 33px 0;
53
- float: left;
54
- text-align: center;
55
- }
56
-
57
- .gadwp-tdo-right {
58
- width: 35%;
59
- margin: 0px 10px 0px 0;
60
- text-align: left;
61
- font-weight: bold;
62
- vertical-align: middle;
63
- float: right;
64
- display: table;
65
- }
66
-
67
- .gadwp-online {
68
- font-size: 100px;
69
- font-weight: normal;
70
- line-height: 1em;
71
- margin: 0 auto;
72
- width: 80%;
73
- }
74
-
75
- .gadwp-bigtext {
76
- font-size: 14px;
77
- width: 100%;
78
- margin: 0 0;
79
- padding: 5px 5px 5px 5px;
80
- background: #fff;
81
- -moz-box-shadow: 0px 0px 3px 0px #BBB;
82
- -webkit-box-shadow: 0px 0px 3px 0px #BBB;
83
- box-shadow: 0px 0px 3px 0px #BBB;
84
- display: table;
85
- overflow: hidden;
86
- }
87
-
88
- .gadwp-bleft {
89
- float: left;
90
- width: 80%;
91
- }
92
-
93
- .gadwp-bright {
94
- float: right;
95
- width: 20%;
96
- }
97
-
98
- .gadwp-pgdetailsr {
99
- padding-left: 20px;
100
- text-align: right;
101
- }
102
-
103
- .gadwp-pgdetailsl {
104
- min-width: 250px;
105
- }
106
-
107
- [id^=gadwp-areachart-] {
108
- width: 98%;
109
- height: 100%;
110
- margin: 10px auto 10px 0;
111
- height: 250px;
112
- }
113
-
114
- .gadwp-floatwraper {
115
- display: table;
116
- width: 100%;
117
- height: 100%;
118
- }
119
-
120
- [id^=gadwp-piechart-].halfsize {
121
- width: 47%;
122
- margin: 10px 0 0 0;
123
- height: 200px;
124
- float: left;
125
- }
126
-
127
- [id^=gadwp-piechart-].floatleft {
128
- float: left;
129
- }
130
-
131
- [id^=gadwp-piechart-].floatright {
132
- float: right;
133
- }
134
-
135
- [id^=gadwp-tablechart-], [id^=gadwp-tablechart-] {
136
- width: 98%;
137
- height: 100%;
138
- margin: 10px auto 10px 0;
139
- }
140
-
141
- #dashboard-widgets-wrap .postbox {
142
- margin-right: 10px;
143
- }
144
-
145
- /* Admin Widget content */
146
- [id^=gadwp-progressbar-] {
147
- width: 100%;
148
- height: 3px;
149
- margin: 5px 0 0px 0;
150
- }
151
-
152
- [id^=gadwp-bottomstats-] {
153
- width: 100%;
154
- }
155
-
156
- [id^=gadwp-bottomstats-] .inside {
157
- display: table;
158
- margin: 0 auto;
159
- padding: 0px;
160
- }
161
-
162
- #gadwp-widget .inside .small-box {
163
- width: 30%;
164
- float: left;
165
- margin: 0 5px 10px 5px;
166
- background: #fff;
167
- text-align: center;
168
- -moz-box-shadow: 0px 0px 7px 0px #BBB;
169
- -webkit-box-shadow: 0px 0px 7px 0px #BBB;
170
- box-shadow: 0px 0px 7px 0px #BBB;
171
- }
172
-
173
- #gadwp-widget .inside .small-box h3 {
174
- font-size: 1em;
175
- color: #777;
176
- padding: 0px 5px 0px 5px;
177
- margin: 0px 0px 0px 0px;
178
- text-overflow: ellipsis;
179
- overflow: hidden;
180
- white-space: nowrap;
181
- }
182
-
183
- #gadwp-widget .inside .small-box p {
184
- font-size: 1.2em;
185
- margin: 0px 0px 2px 0px;
186
- }
187
-
188
- @media screen and (max-width: 410px) {
189
- [id^=gadwp-bottomstats-] .inside .small-box {
190
- width: 45%;
191
- }
192
- }
1
+ .gadwp-pline{width:100%;margin:0;padding:5px 0 5px 0;background:#fff;-moz-box-shadow:0 0 3px 0 #BBB;-webkit-box-shadow:0 0 3px 0 #BBB;box-shadow:0 0 3px 0 #BBB;display:table;overflow:hidden}.gadwp-pleft{width:90%;float:left;padding-left:5px}.gadwp-pright{width:5%;float:right;padding-right:5px}[id^=gadwp-realtime-]{margin:10px 0 0 0;width:100%}.gadwp-rt-box{width:100%;margin:0;background:#fff;text-align:center;-moz-box-shadow:0 0 5px 0 #BBB;-webkit-box-shadow:0 0 5px 0 #BBB;box-shadow:0 0 5px 0 #BBB;display:table}.gadwp-tdo-left{width:60%;padding:33px 0;float:left;text-align:center}.gadwp-tdo-right{width:35%;margin:0 10px 0 0;text-align:left;font-weight:bold;vertical-align:middle;float:right;display:table}.gadwp-online{font-size:100px;font-weight:normal;line-height:1em;margin:0 auto;width:80%}.gadwp-bigtext{font-size:14px;width:100%;margin:0;padding:5px 5px 5px 5px;background:#fff;-moz-box-shadow:0 0 3px 0 #BBB;-webkit-box-shadow:0 0 3px 0 #BBB;box-shadow:0 0 3px 0 #BBB;display:table;overflow:hidden}.gadwp-bleft{float:left;width:80%}.gadwp-bright{float:right;width:20%}.gadwp-pgdetailsr{padding-left:20px;text-align:right}.gadwp-pgdetailsl{min-width:250px}[id^=gadwp-areachart-]{width:98%;height:100%;margin:10px auto 10px 0;height:250px}.gadwp-floatwraper{display:table;width:100%;height:100%}[id^=gadwp-piechart-].halfsize{width:47%;margin:10px 0 0 0;height:200px;float:left}[id^=gadwp-piechart-].floatleft{float:left}[id^=gadwp-piechart-].floatright{float:right}[id^=gadwp-tablechart-],[id^=gadwp-tablechart-]{width:98%;height:100%;margin:10px auto 10px 0}#dashboard-widgets-wrap .postbox{margin-right:10px}[id^=gadwp-progressbar-]{width:100%;height:3px;margin:5px 0 0 0}[id^=gadwp-bottomstats-]{width:100%}[id^=gadwp-bottomstats-] .inside{display:table;margin:0 auto;padding:0}#gadwp-widget .inside .small-box{width:30%;float:left;margin:0 5px 10px 5px;background:#fff;text-align:center;-moz-box-shadow:0 0 7px 0 #BBB;-webkit-box-shadow:0 0 7px 0 #BBB;box-shadow:0 0 7px 0 #BBB}#gadwp-widget .inside .small-box h3{font-size:1em;color:#777;padding:0 5px 0 5px;margin:0;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}#gadwp-widget .inside .small-box p{font-size:1.2em;margin:0 0 2px 0}@media screen and (max-width:410px){[id^=gadwp-bottomstats-] .inside .small-box{width:45%}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/css/gadwp.css CHANGED
@@ -1,206 +1 @@
1
- /**
2
- * Author: Alin Marcu
3
- * Author URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- /* Tab navigation */
10
- #gadwp-events, #gadwp-custom, #gadwp-advanced, #gadwp-exclude, #gadwp-config {
11
- display: none;
12
- }
13
-
14
- /* Options pages */
15
- table.gadwp-settings-options {
16
- padding-left: 10px;
17
- width: 100%;
18
- }
19
-
20
- .gadwp-settings-options td {
21
- padding: 0px 5px 5px 5px;
22
- }
23
-
24
- td.gadwp-settings-title, td.info {
25
- width: 130px;
26
- padding-left: 20px;
27
- }
28
-
29
- td.gadwp-settings-title-s {
30
- width: 300px;
31
- }
32
-
33
- .gadwp-help {
34
- padding-left: 15px;
35
- }
36
-
37
- td.gadwp-settings-info {
38
- padding-bottom: 15px;
39
- }
40
-
41
- td.gadwp-settings-title label {
42
- font-weight: bold;
43
- }
44
-
45
- .gadash-title {
46
- float: left;
47
- margin-right: 10px;
48
- margin-top: 2px;
49
- clear: left;
50
- }
51
-
52
- .gadash-desc {
53
- font-size: 1em;
54
- }
55
-
56
- .gadash-top {
57
- vertical-align: top;
58
- }
59
-
60
- pre.gadwp-settings-logdata {
61
- white-space: pre-wrap;
62
- }
63
-
64
- td.gadwp-settings-roles {
65
- padding-bottom: 15px;
66
- }
67
-
68
- #ga_speed_samplerate, #ga_realtime_pages {
69
- width: 50px;
70
- }
71
-
72
- #gapi-access-code {
73
- color: red !important;
74
- }
75
-
76
- #poststuff.gadwp h2 {
77
- padding-bottom: 0;
78
- font-size: 19.5px;
79
- font-weight: normal;
80
- padding: 0;
81
- margin: 20px 0 15px 0;
82
- }
83
-
84
- #poststuff.gadwp h2.nav-tab-wrapper {
85
- border-bottom: 1px solid #ccc;
86
- padding-bottom: 0;
87
- }
88
-
89
- /* Options pages ON/OFF Switch */
90
- .button-primary.gadwp-settings-switchoo {
91
- position: relative;
92
- width: 50px;
93
- float: left;
94
- border: none;
95
- padding: 0;
96
- height: 22px;
97
- -moz-box-shadow: none;
98
- -webkit-box-shadow: none;
99
- -o-box-shadow: none;
100
- box-shadow: none;
101
- -webkit-user-select: none;
102
- -moz-user-select: none;
103
- -ms-user-select: none;
104
- }
105
-
106
- input.gadwp-settings-switchoo-checkbox {
107
- display: none;
108
- }
109
-
110
- .gadwp-settings-switchoo-label {
111
- display: block;
112
- overflow: hidden;
113
- cursor: pointer;
114
- background: transparent;
115
- border: 1px solid #ddd;
116
- border-radius: 2px;
117
- text-shadow: none;
118
- }
119
-
120
- .gadwp-settings-switchoo-inner {
121
- width: 200%;
122
- margin-left: -100%;
123
- border-radius: 2px;
124
- -moz-transition: margin 0.2s ease-in 0s;
125
- -webkit-transition: margin 0.2s ease-in 0s;
126
- -o-transition: margin 0.2s ease-in 0s;
127
- transition: margin 0.2s ease-in 0s;
128
- }
129
-
130
- .gadwp-settings-switchoo-inner:before, .gadwp-settings-switchoo-inner:after {
131
- float: left;
132
- width: 50%;
133
- font-weight: normal;
134
- -moz-box-sizing: border-box;
135
- -webkit-box-sizing: border-box;
136
- -o-box-sizing: border-box;
137
- box-sizing: border-box;
138
- height: 22px;
139
- line-height: 22px;
140
- font-size: 12px;
141
- text-shadow: none;
142
- }
143
-
144
- .gadwp-settings-switchoo-inner:before {
145
- content: "On";
146
- padding-left: 5px;
147
- border-bottom: none;
148
- /* background-color: #00a0d2;
149
- color: #fff; /* inherit from button props */
150
- }
151
-
152
- .gadwp-settings-switchoo-inner:after {
153
- content: "Off";
154
- padding-right: 5px;
155
- background-color: #ddd;
156
- text-align: right;
157
- }
158
-
159
- .gadwp-settings-switchoo-switch {
160
- width: 22px;
161
- height: 22px;
162
- background: #fff;
163
- color: #ddd;
164
- border: 1px solid #ddd;
165
- border-radius: 2px;
166
- position: absolute;
167
- top: 0;
168
- bottom: 0;
169
- right: 27px;
170
- -moz-transition: all 0.2s ease-in 0s;
171
- -webkit-transition: all 0.2s ease-in 0s;
172
- -o-transition: all 0.2s ease-in 0s;
173
- transition: all 0.2s ease-in 0s;
174
- }
175
-
176
- .gadwp-settings-switchoo-switch:hover {
177
- color: #aaa;
178
- border-color: #aaa;
179
- }
180
-
181
- .gadwp-settings-switchoo-switch:after {
182
- margin: 0;
183
- outline: 0;
184
- display: inline-block;
185
- font: 400 16px/16px dashicons;
186
- content: "\f228";
187
- padding: 3px 0 0 3px;
188
- text-align: left;
189
- text-decoration: none;
190
- -webkit-font-smoothing: antialiased;
191
- -moz-osx-font-smoothing: grayscale;
192
- }
193
-
194
- .gadwp-settings-switchoo-checkbox:checked+.gadwp-settings-switchoo-label .gadwp-settings-switchoo-inner {
195
- margin-left: 0;
196
- }
197
-
198
- .gadwp-settings-switchoo-checkbox:checked+.gadwp-settings-switchoo-label .gadwp-settings-switchoo-switch {
199
- right: 0px;
200
- }
201
-
202
- .switch-desc {
203
- float: left;
204
- margin-left: 10px;
205
- line-height: 20px;
206
- }
1
+ #gadwp-events,#gadwp-custom,#gadwp-advanced,#gadwp-exclude,#gadwp-config,#gadwp-tmdatalayervars,#gadwp-tmintegration,#gadwp-integration{display:none}table.gadwp-settings-options{padding-left:10px;width:100%}.gadwp-settings-options td{padding:0 5px 5px 5px}td.gadwp-settings-title,td.info{width:140px;padding-left:20px}td.gadwp-settings-title-s{width:300px}.gadwp-help{padding-left:15px}td.gadwp-settings-info{padding-bottom:15px}td.gadwp-settings-title label{font-size:1.1em}.gadash-title{float:left;margin-right:10px;margin-top:2px;clear:left}.gadash-desc{font-size:1em}.gadash-top{vertical-align:top}pre.gadwp-settings-logdata{white-space:pre-wrap}td.gadwp-settings-roles{padding-bottom:15px}#ga_speed_samplerate,#ga_realtime_pages{width:50px}#gapi-access-code{color:red !important}#poststuff.gadwp h2{padding-bottom:0;font-size:19.5px;font-weight:normal;padding:0;margin:20px 0 15px 0}#poststuff.gadwp h2.nav-tab-wrapper{border-bottom:1px solid #ccc;padding-bottom:0}.button-primary.gadwp-settings-switchoo{position:relative;width:50px;float:left;border:0;padding:0;height:22px;-moz-box-shadow:none;-webkit-box-shadow:none;-o-box-shadow:none;box-shadow:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}input.gadwp-settings-switchoo-checkbox{display:none}.gadwp-settings-switchoo-label{display:block;overflow:hidden;cursor:pointer;background:transparent;border:1px solid #ddd;border-radius:2px;text-shadow:none}.gadwp-settings-switchoo-inner{width:200%;margin-left:-100%;border-radius:2px;-moz-transition:margin .2s ease-in 0;-webkit-transition:margin .2s ease-in 0;-o-transition:margin .2s ease-in 0;transition:margin .2s ease-in 0}.gadwp-settings-switchoo-inner:before,.gadwp-settings-switchoo-inner:after{float:left;width:50%;font-weight:normal;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;height:22px;line-height:22px;font-size:12px;text-shadow:none}.gadwp-settings-switchoo-inner:before{content:"On";padding-left:5px;border-bottom:0}.gadwp-settings-switchoo-inner:after{content:"Off";padding-right:5px;background-color:#ddd;text-align:right}.gadwp-settings-switchoo-switch{width:22px;height:22px;background:#fff;color:#ddd;border:1px solid #ddd;border-radius:2px;position:absolute;top:0;bottom:0;right:27px;-moz-transition:all .2s ease-in 0;-webkit-transition:all .2s ease-in 0;-o-transition:all .2s ease-in 0;transition:all .2s ease-in 0}.gadwp-settings-switchoo-switch:hover{color:#aaa;border-color:#aaa}.gadwp-settings-switchoo-switch:after{margin:0;outline:0;display:inline-block;font:400 16px/16px dashicons;content:"\f228";padding:3px 0 0 3px;text-align:left;text-decoration:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.gadwp-settings-switchoo-checkbox:checked+.gadwp-settings-switchoo-label .gadwp-settings-switchoo-inner{margin-left:0}.gadwp-settings-switchoo-checkbox:checked+.gadwp-settings-switchoo-label .gadwp-settings-switchoo-switch{right:0}.switch-desc{float:left;margin-left:10px;line-height:20px}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/css/item-reports.css CHANGED
@@ -1,125 +1 @@
1
- /**
2
- * Author: Alin Marcu
3
- * Author URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- /* Backend Item Reports */
10
- .column-gadwp_stats {
11
- width: 70px;
12
- }
13
-
14
- .gadwp-icon {
15
- color: #555;
16
- }
17
-
18
- .gadwp-icon:hover {
19
- color: #2ea2cc;
20
- }
21
-
22
- .gadwp-icon-oldwp {
23
- padding-top: 5px;
24
- }
25
-
26
- [id^=gadwp-container-] {
27
- width: 480px;
28
- }
29
-
30
- [id^=gadwp-areachart-] {
31
- height: 280px;
32
- }
33
-
34
- [id^=gadwp-progressbar-] {
35
- width: 100%;
36
- height: 3px;
37
- margin: 5px 0 0px 0;
38
- }
39
-
40
- [id^=gadwp-bottomstats-] {
41
- width: 100%;
42
- }
43
-
44
- [id^=gadwp-bottomstats-] .inside {
45
- display: table;
46
- margin: 0 auto;
47
- padding: 0px;
48
- }
49
-
50
- [id^=gadwp-bottomstats-] .inside .small-box {
51
- width: 31.2%;
52
- float: left;
53
- margin: 10px 5px 10px 5px;
54
- background: #fff;
55
- text-align: center;
56
- -moz-box-shadow: 0px 0px 7px 0px #BBB;
57
- -webkit-box-shadow: 0px 0px 7px 0px #BBB;
58
- box-shadow: 0px 0px 7px 0px #BBB;
59
- }
60
-
61
- [id^=gadwp-bottomstats-] .inside .small-box h3 {
62
- font-size: 1em;
63
- font-weight: normal;
64
- color: #777;
65
- padding: 0px 5px 0px 5px;
66
- margin: 0px 0px 0px 0px;
67
- text-overflow: ellipsis;
68
- overflow: hidden;
69
- white-space: nowrap;
70
- }
71
-
72
- [id^=gadwp-bottomstats-] .inside .small-box p {
73
- font-size: 1.2em;
74
- margin: 0px 0px 2px 0px;
75
- color: black;
76
- }
77
-
78
- .gadwp-floatwraper {
79
- display: table;
80
- width: 100%;
81
- height: 100%;
82
- }
83
-
84
- [id^=gadwp-piechart-].halfsize {
85
- width: 47%;
86
- margin: 10px 0 0 0;
87
- height: 200px;
88
- float: left;
89
- }
90
-
91
- [id^=gadwp-piechart-].floatleft {
92
- float: left;
93
- }
94
-
95
- [id^=gadwp-piechart-].floatright {
96
- float: right;
97
- }
98
-
99
- [id^=gadwp-tablechart-], [id^=gadwp-tablechart-] {
100
- margin: 10px 0 0 0;
101
- }
102
-
103
- .gadwp .ui-dialog-titlebar {
104
- font-size: 1.1em;
105
- text-overflow: ellipsis;
106
- overflow: hidden;
107
- }
108
-
109
- @media screen and (max-width: 500px) {
110
- [id^=gadwp-container-] {
111
- width: 410px;
112
- }
113
- [id^=gadwp-bottomstats-] .inside .small-box {
114
- width: 30.8%;
115
- }
116
- }
117
-
118
- @media screen and (max-width: 410px) {
119
- [id^=gadwp-container-] {
120
- width: 260px;
121
- }
122
- [id^=gadwp-bottomstats-] .inside .small-box {
123
- width: 46%;
124
- }
125
- }
1
+ .column-gadwp_stats{width:70px}.gadwp-icon{color:#555}.gadwp-icon:hover{color:#2ea2cc}.gadwp-icon-oldwp{padding-top:5px}[id^=gadwp-container-]{width:480px}[id^=gadwp-areachart-]{height:280px}[id^=gadwp-progressbar-]{width:100%;height:3px;margin:5px 0 0 0}[id^=gadwp-bottomstats-]{width:100%}[id^=gadwp-bottomstats-] .inside{display:table;margin:0 auto;padding:0}[id^=gadwp-bottomstats-] .inside .small-box{width:31.2%;float:left;margin:10px 5px 10px 5px;background:#fff;text-align:center;-moz-box-shadow:0 0 7px 0 #BBB;-webkit-box-shadow:0 0 7px 0 #BBB;box-shadow:0 0 7px 0 #BBB}[id^=gadwp-bottomstats-] .inside .small-box h3{font-size:1em;font-weight:normal;color:#777;padding:0 5px 0 5px;margin:0;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}[id^=gadwp-bottomstats-] .inside .small-box p{font-size:1.2em;margin:0 0 2px 0;color:black}.gadwp-floatwraper{display:table;width:100%;height:100%}[id^=gadwp-piechart-].halfsize{width:47%;margin:10px 0 0 0;height:200px;float:left}[id^=gadwp-piechart-].floatleft{float:left}[id^=gadwp-piechart-].floatright{float:right}[id^=gadwp-tablechart-],[id^=gadwp-tablechart-]{margin:10px 0 0 0}.gadwp .ui-dialog-titlebar{font-size:1.1em;text-overflow:ellipsis;overflow:hidden}@media screen and (max-width:500px){[id^=gadwp-container-]{width:410px}[id^=gadwp-bottomstats-] .inside .small-box{width:30.8%}}@media screen and (max-width:410px){[id^=gadwp-container-]{width:260px}[id^=gadwp-bottomstats-] .inside .small-box{width:46%}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/item-reports.php CHANGED
@@ -1,8 +1,8 @@
1
  <?php
2
  /**
3
- * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
- * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
@@ -19,17 +19,17 @@ if ( ! class_exists( 'GADWP_Backend_Item_Reports' ) ) {
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
-
23
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && 1 == $this->gadwp->config->options['backend_item_reports'] ) {
24
  // Add custom column in Posts List
25
  add_filter( 'manage_posts_columns', array( $this, 'add_columns' ) );
26
-
27
  // Populate custom column in Posts List
28
  add_action( 'manage_posts_custom_column', array( $this, 'add_icons' ), 10, 2 );
29
-
30
  // Add custom column in Pages List
31
  add_filter( 'manage_pages_columns', array( $this, 'add_columns' ) );
32
-
33
  // Populate custom column in Pages List
34
  add_action( 'manage_pages_custom_column', array( $this, 'add_icons' ), 10, 2 );
35
  }
@@ -37,11 +37,11 @@ if ( ! class_exists( 'GADWP_Backend_Item_Reports' ) ) {
37
 
38
  public function add_icons( $column, $id ) {
39
  global $wp_version;
40
-
41
- if ( $column != 'gadwp_stats' ) {
42
  return;
43
  }
44
-
45
  if ( version_compare( $wp_version, '3.8.0', '>=' ) ) {
46
  echo '<a id="gadwp-' . $id . '" title="' . get_the_title( $id ) . '" href="#' . $id . '" class="gadwp-icon dashicons-before dashicons-chart-area"></a>';
47
  } else {
1
  <?php
2
  /**
3
+ * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
+
23
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && 1 == $this->gadwp->config->options['backend_item_reports'] ) {
24
  // Add custom column in Posts List
25
  add_filter( 'manage_posts_columns', array( $this, 'add_columns' ) );
26
+
27
  // Populate custom column in Posts List
28
  add_action( 'manage_posts_custom_column', array( $this, 'add_icons' ), 10, 2 );
29
+
30
  // Add custom column in Pages List
31
  add_filter( 'manage_pages_columns', array( $this, 'add_columns' ) );
32
+
33
  // Populate custom column in Pages List
34
  add_action( 'manage_pages_custom_column', array( $this, 'add_icons' ), 10, 2 );
35
  }
37
 
38
  public function add_icons( $column, $id ) {
39
  global $wp_version;
40
+
41
+ if ( 'gadwp_stats' != $column ) {
42
  return;
43
  }
44
+
45
  if ( version_compare( $wp_version, '3.8.0', '>=' ) ) {
46
  echo '<a id="gadwp-' . $id . '" title="' . get_the_title( $id ) . '" href="#' . $id . '" class="gadwp-icon dashicons-before dashicons-chart-area"></a>';
47
  } else {
admin/js/settings.js CHANGED
@@ -1,40 +1 @@
1
- /*-
2
- * Author: Alin Marcu
3
- * Author URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- /*
10
- * Navigation Tabs
11
- */
12
- jQuery( document ).ready( function () {
13
- if ( window.location.href.indexOf( "page=gadash_" ) != -1 ) {
14
- var ident = 'basic';
15
-
16
- if ( window.location.hash ) {
17
- ident = window.location.hash.split( '#' )[ 2 ].split( '-' )[ 1 ];
18
- } else if ( window.location.href.indexOf( "page=gadash_errors_debugging" ) != -1 ) {
19
- ident = 'errors';
20
- }
21
-
22
- jQuery( ".nav-tab-wrapper a" ).each( function ( index ) {
23
- jQuery( this ).removeClass( "nav-tab-active" );
24
- jQuery( "#" + this.hash.split( '#' )[ 2 ] ).hide();
25
- } );
26
- jQuery( "#tab-" + ident ).addClass( "nav-tab-active" );
27
- jQuery( "#gadwp-" + ident ).show();
28
- }
29
-
30
- jQuery( 'a[href^="#"]' ).click( function ( e ) {
31
- if ( window.location.href.indexOf( "page=gadash_" ) != -1 ) {
32
- jQuery( ".nav-tab-wrapper a" ).each( function ( index ) {
33
- jQuery( this ).removeClass( "nav-tab-active" );
34
- jQuery( "#" + this.hash.split( '#' )[ 2 ] ).hide();
35
- } );
36
- jQuery( this ).addClass( "nav-tab-active" );
37
- jQuery( "#" + this.hash.split( '#' )[ 2 ] ).show();
38
- }
39
- } );
40
- } );
1
+ jQuery(document).ready(function(){if(window.location.href.indexOf("page=gadash_")!=-1){var a="basic";if(window.location.hash){a=window.location.hash.split("#")[2].split("-")[1]}else{if(window.location.href.indexOf("page=gadash_errors_debugging")!=-1){a="errors"}}jQuery(".nav-tab-wrapper a").each(function(b){jQuery(this).removeClass("nav-tab-active");jQuery("#"+this.hash.split("#")[2]).hide()});jQuery("#tab-"+a).addClass("nav-tab-active");jQuery("#gadwp-"+a).show()}jQuery('a[href^="#"]').click(function(b){if(window.location.href.indexOf("page=gadash_")!=-1){jQuery(".nav-tab-wrapper a").each(function(c){jQuery(this).removeClass("nav-tab-active");jQuery("#"+this.hash.split("#")[2]).hide()});jQuery(this).addClass("nav-tab-active");jQuery("#"+this.hash.split("#")[2]).show()}})});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/js/ui.js CHANGED
@@ -1,26 +1 @@
1
- /*-
2
- * Author: Alin Marcu
3
- * Author URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- "use strict";
10
-
11
- jQuery( document ).ready( function () {
12
-
13
- var gadwp_ui = {
14
- action : 'gadwp_dismiss_notices',
15
- gadwp_security_dismiss_notices : gadwp_ui_data.security,
16
- }
17
-
18
- jQuery( "#gadwp-notice .notice-dismiss" ).click( function () {
19
- jQuery.post( gadwp_ui_data.ajaxurl, gadwp_ui );
20
- } );
21
-
22
- if ( gadwp_ui_data.ed_bubble != '' ) {
23
- jQuery( '#toplevel_page_gadash_settings li > a[href*="page=gadash_errors_debugging"]' ).append( '&nbsp;<span class="awaiting-mod count-1"><span class="pending-count" style="padding:0 7px;">' + gadwp_ui_data.ed_bubble + '</span></span>' );
24
- }
25
-
26
- } );
1
+ "use strict";jQuery(document).ready(function(){var a={action:"gadwp_dismiss_notices",gadwp_security_dismiss_notices:gadwp_ui_data.security};jQuery("#gadwp-notice .notice-dismiss").click(function(){jQuery.post(gadwp_ui_data.ajaxurl,a)});if(gadwp_ui_data.ed_bubble!=""){jQuery('#toplevel_page_gadash_settings li > a[href*="page=gadash_errors_debugging"]').append('&nbsp;<span class="awaiting-mod count-1"><span class="pending-count" style="padding:0 7px;">'+gadwp_ui_data.ed_bubble+"</span></span>")}});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/js/wp-color-picker-script.js CHANGED
@@ -1,11 +1 @@
1
- /*-
2
- * Author: Alin Marcu
3
- * Author URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- jQuery( document ).ready( function () {
10
- jQuery( '.ga_dash_style' ).wpColorPicker();
11
- } );
1
+ jQuery(document).ready(function(){jQuery(".ga_dash_style").wpColorPicker()});
 
 
 
 
 
 
 
 
 
 
admin/settings.php CHANGED
@@ -8,8 +8,9 @@
8
  */
9
 
10
  // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) )
12
  exit();
 
13
 
14
  final class GADWP_Settings {
15
 
@@ -17,42 +18,50 @@ final class GADWP_Settings {
17
  $gadwp = GADWP();
18
  $network_settings = false;
19
  $options = $gadwp->config->options; // Get current options
20
- if ( isset( $_POST['options']['ga_dash_hidden'] ) && isset( $_POST['options'] ) && ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) && $who != 'Reset' ) {
21
  $new_options = $_POST['options'];
22
- if ( $who == 'tracking' ) {
23
  $options['ga_dash_anonim'] = 0;
24
  $options['ga_event_tracking'] = 0;
25
  $options['ga_enhanced_links'] = 0;
26
  $options['ga_dash_remarketing'] = 0;
27
- $options['ga_dash_adsense'] = 0;
28
  $options['ga_event_bouncerate'] = 0;
29
  $options['ga_crossdomain_tracking'] = 0;
30
  $options['ga_aff_tracking'] = 0;
31
  $options['ga_hash_tracking'] = 0;
 
 
 
 
 
 
 
 
 
32
  if ( isset( $_POST['options']['ga_tracking_code'] ) ) {
33
  $new_options['ga_tracking_code'] = trim( $new_options['ga_tracking_code'], "\t" );
34
  }
35
  if ( empty( $new_options['ga_track_exclude'] ) ) {
36
  $new_options['ga_track_exclude'] = array();
37
  }
38
- } else if ( $who == 'backend' ) {
39
  $options['switch_profile'] = 0;
40
  $options['backend_item_reports'] = 0;
41
  $options['dashboard_widget'] = 0;
42
  if ( empty( $new_options['ga_dash_access_back'] ) ) {
43
  $new_options['ga_dash_access_back'][] = 'administrator';
44
  }
45
- } else if ( $who == 'frontend' ) {
46
  $options['frontend_item_reports'] = 0;
47
  if ( empty( $new_options['ga_dash_access_front'] ) ) {
48
  $new_options['ga_dash_access_front'][] = 'administrator';
49
  }
50
- } else if ( $who == 'general' ) {
51
  $options['ga_dash_userapi'] = 0;
52
  if ( ! is_multisite() ) {
53
  $options['automatic_updates_minorversion'] = 0;
54
  }
55
- } else if ( $who == 'network' ) {
56
  $options['ga_dash_userapi'] = 0;
57
  $options['ga_dash_network'] = 0;
58
  $options['ga_dash_excludesa'] = 0;
@@ -81,9 +90,9 @@ final class GADWP_Settings {
81
  }
82
  $options = self::update_options( 'frontend' );
83
  if ( isset( $_POST['options']['ga_dash_hidden'] ) ) {
84
- $message = "<div class='updated'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
85
  if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
86
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
87
  }
88
  }
89
  if ( ! $gadwp->config->options['ga_dash_tableid_jail'] || ! $gadwp->config->options['ga_dash_token'] ) {
@@ -91,69 +100,72 @@ final class GADWP_Settings {
91
  }
92
  ?>
93
  <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
94
- <div class="wrap">
95
  <?php echo "<h2>" . __( "Google Analytics Frontend Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?><hr>
96
- </div>
97
- <div id="poststuff" class="gadwp">
98
- <div id="post-body" class="metabox-holder columns-2">
99
- <div id="post-body-content">
100
- <div class="settings-wrapper">
101
- <div class="inside">
102
  <?php if (isset($message)) echo $message; ?>
103
  <table class="gadwp-settings-options">
104
- <tr>
105
- <td colspan="2"><?php echo "<h2>" . __( "Permissions", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
106
- </tr>
107
- <tr>
108
- <td class="roles gadwp-settings-title"><label for="ga_dash_access_front"><?php _e("Show stats to:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
109
- <td class="gadwp-settings-roles">
110
- <?php
111
- if ( ! isset( $wp_roles ) ) {
112
- $wp_roles = new WP_Roles();
113
- }
114
- $i = 0;
115
- ?>
116
- <table>
117
- <tr>
118
- <?php
119
- foreach ( $wp_roles->role_names as $role => $name ) {
120
- if ( $role != 'subscriber' ) {
121
- $i++;
122
- ?>
123
- <td><label> <input type="checkbox" name="options[ga_dash_access_front][]" value="<?php echo $role; ?>" <?php if (in_array($role,$options['ga_dash_access_front']) || $role=='administrator') echo 'checked="checked"'; if ($role=='administrator') echo 'disabled="disabled"';?> /><?php echo $name; ?>
124
- </label></td>
125
- <?php
126
- }
127
- if ( $i % 4 == 0 ) {
128
- ?>
129
- </tr>
130
- <tr>
131
- <?php
132
- }
133
- }
134
- ?>
135
- </table>
136
- </td>
137
- </tr>
138
- <tr>
139
- <td colspan="2" class="gadwp-settings-title">
140
- <div class="button-primary gadwp-settings-switchoo">
141
- <input type="checkbox" name="options[frontend_item_reports]" value="1" class="gadwp-settings-switchoo-checkbox" id="frontend_item_reports" <?php checked( $options['frontend_item_reports'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="frontend_item_reports">
142
- <div class="gadwp-settings-switchoo-inner"></div>
143
- <div class="gadwp-settings-switchoo-switch"></div>
144
- </label>
145
- </div>
146
- <div class="switch-desc"><?php echo " ".__("enable web page reports on frontend", 'google-analytics-dashboard-for-wp' );?></div>
147
- </td>
148
- </tr>
149
- <tr>
150
- <td colspan="2"><hr></td>
151
- </tr>
152
- <tr>
153
- <td colspan="2" class="submit"><input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" /></td>
154
- </tr>
155
- </table>
156
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
 
 
 
157
  <?php wp_nonce_field('gadash_form','gadash_security');?>
158
  </form>
159
  <?php
@@ -167,9 +179,9 @@ final class GADWP_Settings {
167
  }
168
  $options = self::update_options( 'backend' );
169
  if ( isset( $_POST['options']['ga_dash_hidden'] ) ) {
170
- $message = "<div class='updated'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
171
  if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
172
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
173
  }
174
  }
175
  if ( ! $gadwp->config->options['ga_dash_tableid_jail'] || ! $gadwp->config->options['ga_dash_token'] ) {
@@ -177,127 +189,132 @@ final class GADWP_Settings {
177
  }
178
  ?>
179
  <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
180
- <div class="wrap">
181
  <?php echo "<h2>" . __( "Google Analytics Backend Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?><hr>
182
- </div>
183
- <div id="poststuff" class="gadwp">
184
- <div id="post-body" class="metabox-holder columns-2">
185
- <div id="post-body-content">
186
- <div class="settings-wrapper">
187
- <div class="inside">
188
  <?php if (isset($message)) echo $message; ?>
189
  <table class="gadwp-settings-options">
190
- <tr>
191
- <td colspan="2"><?php echo "<h2>" . __( "Permissions", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
192
- </tr>
193
- <tr>
194
- <td class="roles gadwp-settings-title"><label for="ga_dash_access_back"><?php _e("Show stats to:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
195
- <td class="gadwp-settings-roles">
196
- <?php
197
- if ( ! isset( $wp_roles ) ) {
198
- $wp_roles = new WP_Roles();
199
- }
200
- $i = 0;
201
- ?>
202
  <table>
203
- <tr>
204
- <?php
205
-
206
- foreach ( $wp_roles->role_names as $role => $name ) {
207
- if ( $role != 'subscriber' ) {
208
- $i++;
209
- ?>
210
- <td><label> <input type="checkbox" name="options[ga_dash_access_back][]" value="<?php echo $role; ?>" <?php if (in_array($role,$options['ga_dash_access_back']) || $role=='administrator') echo 'checked="checked"'; if ($role=='administrator') echo 'disabled="disabled"';?> />
211
- <?php echo $name; ?>
212
- </label></td>
213
- <?php
214
- }
215
- if ( $i % 4 == 0 ) {
216
- ?>
217
- </tr>
218
- <tr>
219
- <?php
220
- }
221
- }
222
- ?>
223
- </table>
224
- </td>
225
- </tr>
226
- <tr>
227
- <td colspan="2" class="gadwp-settings-title">
228
- <div class="button-primary gadwp-settings-switchoo">
229
- <input type="checkbox" name="options[switch_profile]" value="1" class="gadwp-settings-switchoo-checkbox" id="switch_profile" <?php checked( $options['switch_profile'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="switch_profile">
230
- <div class="gadwp-settings-switchoo-inner"></div>
231
- <div class="gadwp-settings-switchoo-switch"></div>
232
- </label>
233
- </div>
234
- <div class="switch-desc"><?php _e ( "enable Switch View functionality", 'google-analytics-dashboard-for-wp' );?></div>
235
- </td>
236
- </tr>
237
- <tr>
238
- <td colspan="2" class="gadwp-settings-title">
239
- <div class="button-primary gadwp-settings-switchoo">
240
- <input type="checkbox" name="options[backend_item_reports]" value="1" class="gadwp-settings-switchoo-checkbox" id="backend_item_reports" <?php checked( $options['backend_item_reports'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="backend_item_reports">
241
- <div class="gadwp-settings-switchoo-inner"></div>
242
- <div class="gadwp-settings-switchoo-switch"></div>
243
- </label>
244
- </div>
245
- <div class="switch-desc"><?php _e ( "enable reports on Posts List and Pages List", 'google-analytics-dashboard-for-wp' );?></div>
246
- </td>
247
- </tr>
248
- <tr>
249
- <td colspan="2" class="gadwp-settings-title">
250
- <div class="button-primary gadwp-settings-switchoo">
251
- <input type="checkbox" name="options[dashboard_widget]" value="1" class="gadwp-settings-switchoo-checkbox" id="dashboard_widget" <?php checked( $options['dashboard_widget'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="dashboard_widget">
252
- <div class="gadwp-settings-switchoo-inner"></div>
253
- <div class="gadwp-settings-switchoo-switch"></div>
254
- </label>
255
- </div>
256
- <div class="switch-desc"><?php _e ( "enable the main Dashboard Widget", 'google-analytics-dashboard-for-wp' );?></div>
257
- </td>
258
- </tr>
259
- <tr>
260
- <td colspan="2"><hr><?php echo "<h2>" . __( "Real-Time Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
261
- </tr>
262
- <tr>
263
- <td colspan="2" class="gadwp-settings-title"> <?php _e("Maximum number of pages to display on real-time tab:", 'google-analytics-dashboard-for-wp'); ?>
264
- <input type="number" name="options[ga_realtime_pages]" id="ga_realtime_pages" value="<?php echo (int)$options['ga_realtime_pages']; ?>" size="3">
265
- </td>
266
- </tr>
267
- <tr>
268
- <td colspan="2"><hr><?php echo "<h2>" . __( "Location Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
269
- </tr>
270
- <tr>
271
- <td colspan="2" class="gadwp-settings-title">
 
 
 
 
272
  <?php echo __("Target Geo Map to country:", 'google-analytics-dashboard-for-wp'); ?>
273
  <input type="text" style="text-align: center;" name="options[ga_target_geomap]" value="<?php echo esc_attr($options['ga_target_geomap']); ?>" size="3">
274
- </td>
275
- </tr>
276
- <tr>
277
- <td colspan="2" class="gadwp-settings-title">
278
  <?php echo __("Maps API Key:", 'google-analytics-dashboard-for-wp'); ?>
279
  <input type="text" style="text-align: center;" name="options[maps_api_key]" value="<?php echo esc_attr($options['maps_api_key']); ?>" size="50">
280
- </td>
281
- </tr>
282
- <tr>
283
- <td colspan="2"><hr><?php echo "<h2>" . __( "404 Errors Report", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
284
- </tr>
285
- <tr>
286
- <td colspan="2" class="gadwp-settings-title">
 
287
  <?php echo __("404 Page Title contains:", 'google-analytics-dashboard-for-wp'); ?>
288
  <input type="text" style="text-align: center;" name="options[pagetitle_404]" value="<?php echo esc_attr($options['pagetitle_404']); ?>" size="20">
289
- </td>
290
- </tr>
291
- <tr>
292
- <td colspan="2"><hr></td>
293
- </tr>
294
- <tr>
295
- <td colspan="2" class="submit"><input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" /></td>
296
- </tr>
297
- </table>
298
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
 
 
 
 
299
  <?php wp_nonce_field('gadash_form','gadash_security'); ?>
300
-
301
  </form>
302
  <?php
303
  self::output_sidebar();
@@ -311,313 +328,629 @@ final class GADWP_Settings {
311
  }
312
  $options = self::update_options( 'tracking' );
313
  if ( isset( $_POST['options']['ga_dash_hidden'] ) ) {
314
- $message = "<div class='updated'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
315
  if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
316
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
317
  }
318
  }
319
  if ( ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
320
  $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
321
  }
322
- if ( ! $options['ga_dash_tracking'] ) {
323
- $message = "<div class='error'><p>" . __( "The tracking component is disabled. You should set <strong>Tracking Options</strong> to <strong>Enabled</strong>", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
324
- }
325
  ?>
326
  <form name="ga_dash_form" method="post" action="<?php esc_url($_SERVER['REQUEST_URI']); ?>">
327
- <div class="wrap">
328
  <?php echo "<h2>" . __( "Google Analytics Tracking Code", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
329
  </div>
330
- <div id="poststuff" class="gadwp">
331
- <div id="post-body" class="metabox-holder columns-2">
332
- <div id="post-body-content">
333
- <div class="settings-wrapper">
334
- <div class="inside">
335
- <?php
336
- $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ), 'events' => __( "Events Tracking", 'google-analytics-dashboard-for-wp' ), 'custom' => __( "Custom Definitions", 'google-analytics-dashboard-for-wp' ), 'exclude' => __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ), 'advanced' => __( "Advanced Settings", 'google-analytics-dashboard-for-wp' ) );
337
- self::navigation_tabs( $tabs );
338
- if ( isset( $message ) )
339
- echo $message;
340
- ?>
341
- <div id="gadwp-basic">
342
- <table class="gadwp-settings-options">
343
- <tr>
344
- <td colspan="2"><?php echo "<h2>" . __( "Tracking Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
345
- </tr>
346
- <tr>
347
- <td class="gadwp-settings-title"><label for="ga_dash_tracking"><?php _e("Tracking Options:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
348
- <td><select id="ga_dash_tracking" name="options[ga_dash_tracking]" onchange="this.form.submit()">
349
- <option value="0" <?php selected( $options['ga_dash_tracking'], 0 ); ?>><?php _e("Disabled", 'google-analytics-dashboard-for-wp');?></option>
350
- <option value="1" <?php selected( $options['ga_dash_tracking'], 1 ); ?>><?php _e("Enabled", 'google-analytics-dashboard-for-wp');?></option>
351
- </select></td>
352
- </tr>
353
- <?php if ($options['ga_dash_tracking']) {?>
354
  <tr>
355
- <td class="gadwp-settings-title"></td>
356
- <td>
357
- <?php $profile_info = GADWP_Tools::get_selected_profile($gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail']); ?>
358
- <?php echo '<pre>' . __("View Name:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[0]) . "<br />" . __("Tracking ID:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[2]) . "<br />" . __("Default URL:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[3]) . "<br />" . __("Time Zone:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[5]) . '</pre>';?>
359
- </td>
360
- </tr>
361
- <?php }?>
362
  <tr>
363
- <td colspan="2"><hr><?php echo "<h2>" . __( "Basic Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
364
- </tr>
365
- <tr>
366
- <td class="gadwp-settings-title"><label for="ga_dash_tracking_type"><?php _e("Tracking Type:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
367
- <td><select id="ga_dash_tracking_type" name="options[ga_dash_tracking_type]">
368
- <option value="classic" <?php selected( $options['ga_dash_tracking_type'], 'classic' ); ?>><?php _e("Classic Analytics", 'google-analytics-dashboard-for-wp');?></option>
369
- <option value="universal" <?php selected( $options['ga_dash_tracking_type'], 'universal' ); ?>><?php _e("Universal Analytics", 'google-analytics-dashboard-for-wp');?></option>
370
- </select></td>
371
- </tr>
372
- <tr>
373
- <td colspan="2" class="gadwp-settings-title">
374
- <div class="button-primary gadwp-settings-switchoo">
375
- <input type="checkbox" name="options[ga_dash_anonim]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_anonim" <?php checked( $options['ga_dash_anonim'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="ga_dash_anonim">
376
- <div class="gadwp-settings-switchoo-inner"></div>
377
- <div class="gadwp-settings-switchoo-switch"></div>
378
- </label>
379
- </div>
380
- <div class="switch-desc"><?php echo " ".__("anonymize IPs while tracking", 'google-analytics-dashboard-for-wp' );?></div>
381
- </td>
382
- </tr>
383
- <tr>
384
- <td colspan="2" class="gadwp-settings-title">
385
- <div class="button-primary gadwp-settings-switchoo">
386
- <input type="checkbox" name="options[ga_dash_remarketing]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_remarketing" <?php checked( $options['ga_dash_remarketing'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="ga_dash_remarketing">
387
- <div class="gadwp-settings-switchoo-inner"></div>
388
- <div class="gadwp-settings-switchoo-switch"></div>
389
- </label>
390
- </div>
391
- <div class="switch-desc"><?php echo " ".__("enable remarketing, demographics and interests reports", 'google-analytics-dashboard-for-wp' );?></div>
392
- </td>
393
- </tr>
394
- </table>
395
- </div>
396
- <div id="gadwp-events">
397
- <table class="gadwp-settings-options">
398
- <tr>
399
- <td colspan="2"><?php echo "<h2>" . __( "Events Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
400
- </tr>
401
- <tr>
402
- <td colspan="2" class="gadwp-settings-title">
403
- <div class="button-primary gadwp-settings-switchoo">
404
- <input type="checkbox" name="options[ga_event_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_event_tracking" <?php checked( $options['ga_event_tracking'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="ga_event_tracking">
405
- <div class="gadwp-settings-switchoo-inner"></div>
406
- <div class="gadwp-settings-switchoo-switch"></div>
407
- </label>
408
- </div>
409
- <div class="switch-desc"><?php echo " ".__("track downloads, mailto and outbound links", 'google-analytics-dashboard-for-wp' ); ?></div>
410
- </td>
411
- </tr>
412
- <tr>
413
- <td class="gadwp-settings-title"><label for="ga_event_downloads"><?php _e("Downloads Regex:", 'google-analytics-dashboard-for-wp'); ?></label></td>
414
- <td><input type="text" id="ga_event_downloads" name="options[ga_event_downloads]" value="<?php echo esc_attr($options['ga_event_downloads']); ?>" size="50"></td>
415
- </tr>
416
- <tr>
417
- <td colspan="2" class="gadwp-settings-title">
418
- <div class="button-primary gadwp-settings-switchoo">
419
- <input type="checkbox" name="options[ga_aff_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_aff_tracking" <?php checked( $options['ga_aff_tracking'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="ga_aff_tracking">
420
- <div class="gadwp-settings-switchoo-inner"></div>
421
- <div class="gadwp-settings-switchoo-switch"></div>
422
- </label>
423
- </div>
424
- <div class="switch-desc"><?php echo " ".__("track affiliate links matching this regex", 'google-analytics-dashboard-for-wp' ); ?></div>
425
- </td>
426
- </tr>
427
- <tr>
428
- <td class="gadwp-settings-title"><label for="ga_event_affiliates"><?php _e("Affiliates Regex:", 'google-analytics-dashboard-for-wp'); ?></label></td>
429
- <td><input type="text" id="ga_event_affiliates" name="options[ga_event_affiliates]" value="<?php echo esc_attr($options['ga_event_affiliates']); ?>" size="50"></td>
430
- </tr>
431
- <tr>
432
- <td colspan="2" class="gadwp-settings-title">
433
- <div class="button-primary gadwp-settings-switchoo">
434
- <input type="checkbox" name="options[ga_hash_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_hash_tracking" <?php checked( $options['ga_hash_tracking'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="ga_hash_tracking">
435
- <div class="gadwp-settings-switchoo-inner"></div>
436
- <div class="gadwp-settings-switchoo-switch"></div>
437
- </label>
438
- </div>
439
- <div class="switch-desc"><?php echo " ".__("track fragment identifiers, hashmarks (#) in URI links", 'google-analytics-dashboard-for-wp' ); ?></div>
440
- </td>
441
- </tr>
442
- </table>
443
- </div>
444
- <div id="gadwp-custom">
445
- <table class="gadwp-settings-options">
446
- <tr>
447
- <td colspan="2"><?php echo "<h2>" . __( "Custom Definitions", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
448
- </tr>
449
- <tr>
450
- <td class="gadwp-settings-title"><label for="ga_author_dimindex"><?php _e("Authors:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
451
- <td><select id="ga_author_dimindex" name="options[ga_author_dimindex]">
452
- <?php for ($i=0;$i<21;$i++){?>
453
- <option value="<?php echo $i;?>" <?php selected( $options['ga_author_dimindex'], $i ); ?>><?php echo $i==0?'Disabled':'dimension '.$i; ?></option>
454
- <?php }?>
455
- </select></td>
456
- </tr>
457
- <tr>
458
- <td class="gadwp-settings-title"><label for="ga_pubyear_dimindex"><?php _e("Publication Year:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
459
- <td><select id="ga_pubyear_dimindex" name="options[ga_pubyear_dimindex]">
460
- <?php for ($i=0;$i<21;$i++){?>
461
- <option value="<?php echo $i;?>" <?php selected( $options['ga_pubyear_dimindex'], $i ); ?>><?php echo $i==0?'Disabled':'dimension '.$i; ?></option>
462
- <?php }?>
463
- </select></td>
464
- </tr>
465
  <tr>
466
- <td class="gadwp-settings-title"><label for="ga_pubyearmonth_dimindex"><?php _e("Publication Month:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
467
- <td><select id="ga_pubyearmonth_dimindex" name="options[ga_pubyearmonth_dimindex]">
468
- <?php for ($i=0;$i<21;$i++){?>
469
- <option value="<?php echo $i;?>" <?php selected( $options['ga_pubyearmonth_dimindex'], $i ); ?>><?php echo $i==0?'Disabled':'dimension '.$i; ?></option>
470
- <?php }?>
471
- </select></td>
472
- </tr>
473
- <tr>
474
- <td class="gadwp-settings-title"><label for="ga_category_dimindex"><?php _e("Categories:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
475
- <td><select id="ga_category_dimindex" name="options[ga_category_dimindex]">
476
- <?php for ($i=0;$i<21;$i++){?>
477
- <option value="<?php echo $i;?>" <?php selected( $options['ga_category_dimindex'], $i ); ?>><?php echo $i==0?'Disabled':'dimension '.$i; ?></option>
478
- <?php }?>
479
- </select></td>
480
- </tr>
481
- <tr>
482
- <td class="gadwp-settings-title"><label for="ga_user_dimindex"><?php _e("User Type:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
483
- <td><select id="ga_user_dimindex" name="options[ga_user_dimindex]">
484
- <?php for ($i=0;$i<21;$i++){?>
485
- <option value="<?php echo $i;?>" <?php selected( $options['ga_user_dimindex'], $i ); ?>><?php echo $i==0?'Disabled':'dimension '.$i; ?></option>
486
- <?php }?>
487
- </select></td>
488
- </tr>
489
- <tr>
490
- <td class="gadwp-settings-title"><label for="ga_tag_dimindex"><?php _e("Tags:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
491
- <td><select id="ga_tag_dimindex" name="options[ga_tag_dimindex]">
492
- <?php for ($i=0;$i<21;$i++){?>
493
- <option value="<?php echo $i;?>" <?php selected( $options['ga_tag_dimindex'], $i ); ?>><?php echo $i==0?'Disabled':'dimension '.$i; ?></option>
494
- <?php }?>
495
- </select></td>
496
- </tr>
497
- </table>
498
- </div>
499
- <div id="gadwp-advanced">
500
- <table class="gadwp-settings-options">
501
- <tr>
502
- <td colspan="2"><?php echo "<h2>" . __( "Advanced Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
503
- </tr>
504
- <tr>
505
- <td class="gadwp-settings-title"><label for="ga_speed_samplerate"><?php _e("Page Speed SR:", 'google-analytics-dashboard-for-wp'); ?></label></td>
506
- <td><input type="number" id="ga_speed_samplerate" name="options[ga_speed_samplerate]" value="<?php echo (int)($options['ga_speed_samplerate']); ?>" max="100" min="1"> %</td>
507
- </tr>
508
- <tr>
509
- <td colspan="2" class="gadwp-settings-title">
510
- <div class="button-primary gadwp-settings-switchoo">
511
- <input type="checkbox" name="options[ga_event_bouncerate]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_event_bouncerate" <?php checked( $options['ga_event_bouncerate'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="ga_event_bouncerate">
512
- <div class="gadwp-settings-switchoo-inner"></div>
513
- <div class="gadwp-settings-switchoo-switch"></div>
514
- </label>
515
- </div>
516
- <div class="switch-desc"><?php echo " ".__("exclude events from bounce-rate calculation", 'google-analytics-dashboard-for-wp' );?></div>
517
- </td>
518
- </tr>
519
- <tr>
520
- <td colspan="2" class="gadwp-settings-title">
521
- <div class="button-primary gadwp-settings-switchoo">
522
- <input type="checkbox" name="options[ga_enhanced_links]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_enhanced_links" <?php checked( $options['ga_enhanced_links'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="ga_enhanced_links">
523
- <div class="gadwp-settings-switchoo-inner"></div>
524
- <div class="gadwp-settings-switchoo-switch"></div>
525
- </label>
526
- </div>
527
- <div class="switch-desc"><?php echo " ".__("enable enhanced link attribution", 'google-analytics-dashboard-for-wp' );?></div>
528
- </td>
529
- </tr>
530
- <tr>
531
- <td colspan="2" class="gadwp-settings-title">
532
- <div class="button-primary gadwp-settings-switchoo">
533
- <input type="checkbox" name="options[ga_dash_adsense]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_adsense" <?php checked( $options['ga_dash_adsense'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="ga_dash_adsense">
534
- <div class="gadwp-settings-switchoo-inner"></div>
535
- <div class="gadwp-settings-switchoo-switch"></div>
536
- </label>
537
- </div>
538
- <div class="switch-desc"><?php echo " ".__("enable AdSense account linking", 'google-analytics-dashboard-for-wp' );?></div>
539
- </td>
540
- </tr>
541
- <tr>
542
- <td colspan="2"><?php echo "<h2>" . __( "Cross-domain Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
543
- </tr>
544
- <tr>
545
- <td colspan="2" class="gadwp-settings-title">
546
- <div class="button-primary gadwp-settings-switchoo">
547
- <input type="checkbox" name="options[ga_crossdomain_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_crossdomain_tracking" <?php checked( $options['ga_crossdomain_tracking'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="ga_crossdomain_tracking">
548
- <div class="gadwp-settings-switchoo-inner"></div>
549
- <div class="gadwp-settings-switchoo-switch"></div>
550
- </label>
551
- </div>
552
- <div class="switch-desc"><?php echo " ".__("enable cross domain tracking", 'google-analytics-dashboard-for-wp' ); ?></div>
553
- </td>
554
- </tr>
555
- <tr>
556
- <td class="gadwp-settings-title"><label for="ga_crossdomain_list"><?php _e("Cross Domains:", 'google-analytics-dashboard-for-wp'); ?></label></td>
557
- <td><input type="text" id="ga_crossdomain_list" name="options[ga_crossdomain_list]" value="<?php echo esc_attr($options['ga_crossdomain_list']); ?>" size="50"></td>
558
- </tr>
559
- <tr>
560
- <td colspan="2"><?php echo "<h2>" . __( "Cookie Customization", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
561
- </tr>
562
- <tr>
563
- <td class="gadwp-settings-title"><label for="ga_cookiedomain"><?php _e("Cookie Domain:", 'google-analytics-dashboard-for-wp'); ?></label></td>
564
- <td><input type="text" id="ga_cookiedomain" name="options[ga_cookiedomain]" value="<?php echo esc_attr($options['ga_cookiedomain']); ?>" size="50"></td>
565
- </tr>
566
- <tr>
567
- <td class="gadwp-settings-title"><label for="ga_cookiename"><?php _e("Cookie Name:", 'google-analytics-dashboard-for-wp'); ?></label></td>
568
- <td><input type="text" id="ga_cookiename" name="options[ga_cookiename]" value="<?php echo esc_attr($options['ga_cookiename']); ?>" size="50"></td>
569
- </tr>
570
- <tr>
571
- <td class="gadwp-settings-title"><label for="ga_cookieexpires"><?php _e("Cookie Expires:", 'google-analytics-dashboard-for-wp'); ?></label></td>
572
- <td><input type="text" id="ga_cookieexpires" name="options[ga_cookieexpires]" value="<?php echo esc_attr($options['ga_cookieexpires']); ?>" size="10"> seconds</td>
573
- </tr>
574
- </table>
575
- </div>
576
- <div id="gadwp-exclude">
577
- <table class="gadwp-settings-options">
578
- <tr>
579
- <td colspan="2"><?php echo "<h2>" . __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
580
- </tr>
581
- <tr>
582
- <td class="roles gadwp-settings-title"><label for="ga_track_exclude"><?php _e("Exclude tracking for:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
583
- <td class="gadwp-settings-roles">
584
- <?php
585
- if ( ! isset( $wp_roles ) ) {
586
- $wp_roles = new WP_Roles();
587
- }
588
- $i = 0;
589
- ?> <table>
590
- <tr>
591
- <?php
592
- foreach ( $wp_roles->role_names as $role => $name ) {
593
- $i++;
594
- ?>
595
- <td><label> <input type="checkbox" name="options[ga_track_exclude][]" value="<?php echo $role; ?>" <?php if (in_array($role,$options['ga_track_exclude'])) echo 'checked="checked"'; ?> />
596
- <?php echo $name; ?>
597
- </label></td>
598
- <?php
599
- if ( $i % 4 == 0 ) {
600
- ?>
601
- </tr>
602
- <tr>
603
- <?php
604
- }
605
- }
606
- ?>
607
- </table>
608
- </td>
609
- </tr>
610
- </table>
611
- </div>
612
- <table class="gadwp-settings-options">
613
- <tr>
614
- <td colspan="2"><hr></td>
615
- </tr>
616
- <tr>
617
- <td colspan="2" class="submit"><input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" /></td>
618
- </tr>
619
- </table>
620
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
621
  <?php wp_nonce_field('gadash_form','gadash_security'); ?>
622
  </form>
623
  <?php
@@ -651,64 +984,76 @@ final class GADWP_Settings {
651
  }
652
  ?>
653
  <div class="wrap">
654
- <?php echo "<h2>" . __( "Google Analytics Errors & Debugging", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
655
- </div>
656
  <div id="poststuff" class="gadwp">
657
- <div id="post-body" class="metabox-holder columns-2">
658
- <div id="post-body-content">
659
- <div class="settings-wrapper">
660
- <div class="inside">
661
- <?php if (isset($message)) echo $message; ?>
662
- <?php
663
- $tabs = array( 'errors' => __( "Errors & Details", 'google-analytics-dashboard-for-wp' ), 'config' => __( "Plugin Settings", 'google-analytics-dashboard-for-wp' ) );
664
- self::navigation_tabs( $tabs );
665
- ?>
666
  <div id="gadwp-errors">
667
- <table class="gadwp-settings-options">
668
- <tr>
669
- <td>
670
- <?php echo "<h2>" . __( "Last Error detected", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
671
- </td>
672
- </tr>
673
- <tr>
674
- <td>
675
- <?php
676
- $errors = print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ? esc_html( print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) : __( "None", 'google-analytics-dashboard-for-wp' );
677
- echo '<pre class="gadwp-settings-logdata">Last Error: ';
678
- echo $errors;
679
- ?></pre>
680
- </td>
681
- </tr>
682
- <tr>
683
- <td colspan="2"><hr><?php echo "<h2>" . __( "Error Details", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
684
- </tr>
685
- <tr>
686
- <td>
687
- <?php
688
- echo '<pre class="gadwp-settings-logdata">Error Details: ';
689
- $error_details = print_r( GADWP_Tools::get_cache( 'gapi_errors' ), true ) ? "\n" . esc_html( print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) : __( "None", 'google-analytics-dashboard-for-wp' );
690
- echo $error_details;
691
- ?></pre><br />
692
- <hr>
693
- </td>
694
-
695
-
696
- <tr>
697
-
698
- </table>
699
- </div>
700
- <div id="gadwp-config">
701
- <table class="gadwp-settings-options">
702
- <tr>
703
- <td><?php echo "<h2>" . __( "Plugin Configuration", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
704
- </tr>
705
- <tr>
706
- <td><pre class="gadwp-settings-logdata"><?php echo esc_html(print_r($anonim, true));?></pre><br />
707
- <hr></td>
708
- </tr>
709
- </table>
710
- </div>
711
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
712
  self::output_sidebar();
713
  }
714
 
@@ -727,14 +1072,14 @@ final class GADWP_Settings {
727
  }
728
  echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
729
  if ( isset( $_POST['ga_dash_code'] ) ) {
730
- if ( ! stripos( 'x' . $_POST['ga_dash_code'], 'UA-', 1 ) == 1 ) {
731
  try {
732
  $gadwp->gapi_controller->client->authenticate( $_POST['ga_dash_code'] );
733
  $gadwp->config->options['ga_dash_token'] = $gadwp->gapi_controller->client->getAccessToken();
734
  $gadwp->config->options['automatic_updates_minorversion'] = 1;
735
  $gadwp->config->set_plugin_options();
736
  $options = self::update_options( 'general' );
737
- $message = "<div class='updated'><p>" . __( "Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
738
  GADWP_Tools::delete_cache( 'gapi_errors' );
739
  GADWP_Tools::delete_cache( 'last_error' );
740
  if ( $gadwp->config->options['ga_dash_token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
@@ -766,206 +1111,234 @@ final class GADWP_Settings {
766
  $gadwp->gapi_controller->reset_token( false );
767
  }
768
  } else {
769
- $message = "<div class='error'><p>" . __( "The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
770
  }
771
  }
772
  if ( isset( $_POST['Clear'] ) ) {
773
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
774
  GADWP_Tools::clear_cache();
775
- $message = "<div class='updated'><p>" . __( "Cleared Cache.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
776
  } else {
777
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
778
  }
779
  }
780
  if ( isset( $_POST['Reset'] ) ) {
781
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
782
  $gadwp->gapi_controller->reset_token( true );
783
  GADWP_Tools::clear_cache();
784
- $message = "<div class='updated'><p>" . __( "Token Reseted and Revoked.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
785
  $options = self::update_options( 'Reset' );
786
  } else {
787
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
788
  }
789
  }
790
  if ( isset( $_POST['Reset_Err'] ) ) {
791
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
792
  GADWP_Tools::delete_cache( 'last_error' );
793
  GADWP_Tools::delete_cache( 'gapi_errors' );
794
- $message = "<div class='updated'><p>" . __( "All errors reseted.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
795
  } else {
796
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
797
  }
798
  }
799
  if ( isset( $_POST['options']['ga_dash_hidden'] ) && ! isset( $_POST['Clear'] ) && ! isset( $_POST['Reset'] ) && ! isset( $_POST['Reset_Err'] ) ) {
800
- $message = "<div class='updated'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
801
  if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
802
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
803
  }
804
  }
805
  if ( isset( $_POST['Hide'] ) ) {
806
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
807
- $message = "<div class='updated'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
808
  $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] );
809
  $gadwp->config->options['ga_dash_profile_list'] = array( $lock_profile );
810
  $options = self::update_options( 'general' );
811
  } else {
812
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
813
  }
814
  }
815
  ?>
816
- <div class="wrap">
817
  <?php echo "<h2>" . __( "Google Analytics Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
818
- <hr>
819
- </div>
820
- <div id="poststuff" class="gadwp">
821
- <div id="post-body" class="metabox-holder columns-2">
822
- <div id="post-body-content">
823
- <div class="settings-wrapper">
824
- <div class="inside">
825
- <?php
826
- if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) {
827
- $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
828
- }
829
- if ( isset( $_POST['Authorize'] ) ) {
830
- GADWP_Tools::clear_cache();
831
- $gadwp->gapi_controller->token_request();
832
- echo "<div class='updated'><p>" . __( "Use the red link (see below) to generate and get your access code!", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
833
- } else {
834
- if ( isset( $message ) ) {
835
- echo $message;
836
- }
837
- ?>
838
- <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
839
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
840
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
841
- <table class="gadwp-settings-options">
842
- <tr>
843
- <td colspan="2">
844
- <?php echo "<h2>" . __( "Plugin Authorization", 'google-analytics-dashboard-for-wp' ) . "</h2>";?>
845
- </td>
846
- </tr>
847
- <tr>
848
- <td colspan="2" class="gadwp-settings-info">
849
- <?php printf(__('You should watch the %1$s and read this %2$s before proceeding to authorization. This plugin requires a properly configured Google Analytics account!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_video&utm_campaign=gadwp', __("video", 'google-analytics-dashboard-for-wp')), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_tutorial&utm_campaign=gadwp', __("tutorial", 'google-analytics-dashboard-for-wp')));?>
850
- </td>
851
- </tr>
852
- <?php if (! $options['ga_dash_token'] || $options['ga_dash_userapi']) {?>
853
- <tr>
854
- <td colspan="2" class="gadwp-settings-info"><input name="options[ga_dash_userapi]" type="checkbox" id="ga_dash_userapi" value="1" <?php checked( $options['ga_dash_userapi'], 1 ); ?> onchange="this.form.submit()" <?php echo ($options['ga_dash_network'])?'disabled="disabled"':''; ?> /><?php echo " ".__("use your own API Project credentials", 'google-analytics-dashboard-for-wp' );?>
855
- </td>
856
- </tr>
857
- <?php } if ($options['ga_dash_userapi']) { ?>
858
- <tr>
859
- <td class="gadwp-settings-title"><label for="options[ga_dash_clientid]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?></label></td>
860
- <td><input type="text" name="options[ga_dash_clientid]" value="<?php echo esc_attr($options['ga_dash_clientid']); ?>" size="40" required="required"></td>
861
- </tr>
862
- <tr>
863
- <td class="gadwp-settings-title"><label for="options[ga_dash_clientsecret]"><?php _e("Client Secret:", 'google-analytics-dashboard-for-wp'); ?></label></td>
864
- <td><input type="text" name="options[ga_dash_clientsecret]" value="<?php echo esc_attr($options['ga_dash_clientsecret']); ?>" size="40" required="required"> <input type="hidden" name="options[ga_dash_hidden]" value="Y">
865
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
866
- </td>
867
- </tr>
868
- <?php
869
- }
870
- if ( $options['ga_dash_token'] ) {
871
- ?>
872
- <tr>
873
- <td colspan="2"><input type="submit" name="Reset" class="button button-secondary" value="<?php _e( "Clear Authorization", 'google-analytics-dashboard-for-wp' ); ?>" <?php echo $options['ga_dash_network']?'disabled="disabled"':''; ?> /> <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" /> <input type="submit" name="Reset_Err" class="button button-secondary" value="<?php _e( "Reset Errors", 'google-analytics-dashboard-for-wp' ); ?>" /></td>
874
- </tr>
875
- <tr>
876
- <td colspan="2"><hr></td>
877
- </tr>
878
- <tr>
879
- <td colspan="2"><?php echo "<h2>" . __( "General Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
880
- </tr>
881
- <tr>
882
- <td class="gadwp-settings-title"><label for="ga_dash_tableid_jail"><?php _e("Select View:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
883
- <td><select id="ga_dash_tableid_jail" <?php disabled(empty($options['ga_dash_profile_list']) || 1 == count($options['ga_dash_profile_list']), true); ?> name="options[ga_dash_tableid_jail]">
884
- <?php
885
- if ( ! empty( $options['ga_dash_profile_list'] ) ) {
886
- foreach ( $options['ga_dash_profile_list'] as $items ) {
887
- if ( $items[3] ) {
888
- echo '<option value="' . esc_attr( $items[1] ) . '" ' . selected( $items[1], $options['ga_dash_tableid_jail'], false );
889
- echo ' title="' . __( "View Name:", 'google-analytics-dashboard-for-wp' ) . ' ' . esc_attr( $items[0] ) . '">' . esc_html( GADWP_Tools::strip_protocol( $items[3] ) ) . ' &#8658; ' . esc_attr( $items[0] ) . '</option>';
890
- }
891
- }
892
- } else {
893
- echo '<option value="">' . __( "Property not found", 'google-analytics-dashboard-for-wp' ) . '</option>';
894
- }
895
- ?>
896
- </select>
897
- <?php
898
- if ( count( $options['ga_dash_profile_list'] ) > 1 ) {
899
- ?>&nbsp;<input type="submit" name="Hide" class="button button-secondary" value="<?php _e( "Lock Selection", 'google-analytics-dashboard-for-wp' ); ?>" /><?php
900
- }
901
- ?>
902
- </td>
903
- </tr>
904
- <?php
905
- if ( $options['ga_dash_tableid_jail'] ) {
906
- ?>
907
- <tr>
908
- <td class="gadwp-settings-title"></td>
909
- <td><?php
910
- $profile_info = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] );
911
- echo '<pre>' . __( "View Name:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[0] ) . "<br />" . __( "Tracking ID:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[2] ) . "<br />" . __( "Default URL:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[3] ) . "<br />" . __( "Time Zone:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[5] ) . '</pre>';
912
- ?></td>
913
- </tr>
914
- <?php
915
- }
916
- ?>
917
- <tr>
918
- <td class="gadwp-settings-title"><label for="ga_dash_style"><?php _e("Theme Color:", 'google-analytics-dashboard-for-wp' ); ?></label></td>
919
- <td><input type="text" id="ga_dash_style" class="ga_dash_style" name="options[ga_dash_style]" value="<?php echo esc_attr($options['ga_dash_style']); ?>" size="10"></td>
920
- </tr>
921
- <tr>
922
- <td colspan="2"><hr></td>
923
- </tr>
924
- <?php if ( !is_multisite()) {?>
925
  <tr>
926
- <td colspan="2"><?php echo "<h2>" . __( "Automatic Updates", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
927
- </tr>
928
- <tr>
929
- <td colspan="2" class="gadwp-settings-title">
930
- <div class="button-primary gadwp-settings-switchoo">
931
- <input type="checkbox" name="options[automatic_updates_minorversion]" value="1" class="gadwp-settings-switchoo-checkbox" id="automatic_updates_minorversion" <?php checked( $options['automatic_updates_minorversion'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="automatic_updates_minorversion">
932
- <div class="gadwp-settings-switchoo-inner"></div>
933
- <div class="gadwp-settings-switchoo-switch"></div>
934
- </label>
935
- </div>
936
- <div class="switch-desc"><?php echo " ".__( "automatic updates for minor versions (security and maintenance releases only)", 'google-analytics-dashboard-for-wp' );?></div>
937
- </td>
938
- </tr>
939
- <tr>
940
- <td colspan="2"><hr></td>
941
- </tr>
942
- <?php }?>
943
- <tr>
944
- <td colspan="2" class="submit"><input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" /></td>
945
- </tr>
946
- <?php } else {?>
947
- <tr>
948
- <td colspan="2"><hr></td>
949
- </tr>
950
- <tr>
951
- <td colspan="2"><input type="submit" name="Authorize" class="button button-secondary" id="authorize" value="<?php _e( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ); ?>" <?php echo $options['ga_dash_network']?'disabled="disabled"':''; ?> /> <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" /></td>
952
- </tr>
953
- <tr>
954
- <td colspan="2"><hr></td>
955
- </tr>
956
- </table>
957
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
958
  <?php
959
- self::output_sidebar();
960
- return;
961
- }
962
- ?>
963
- </table>
964
- </form>
965
- <?php
966
- }
967
  self::output_sidebar();
968
  }
 
969
  // Network Settings
970
  public static function general_settings_network() {
971
  $gadwp = GADWP();
@@ -986,14 +1359,14 @@ final class GADWP_Settings {
986
 
987
  echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
988
  if ( isset( $_POST['ga_dash_code'] ) ) {
989
- if ( ! stripos( 'x' . $_POST['ga_dash_code'], 'UA-', 1 ) == 1 ) {
990
  try {
991
  $gadwp->gapi_controller->client->authenticate( $_POST['ga_dash_code'] );
992
  $gadwp->config->options['ga_dash_token'] = $gadwp->gapi_controller->client->getAccessToken();
993
  $gadwp->config->options['automatic_updates_minorversion'] = 1;
994
  $gadwp->config->set_plugin_options( true );
995
  $options = self::update_options( 'network' );
996
- $message = "<div class='updated'><p>" . __( "Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
997
  if ( is_multisite() ) { // Cleanup errors on the entire network
998
  foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
999
  switch_to_blog( $blog['blog_id'] );
@@ -1032,13 +1405,13 @@ final class GADWP_Settings {
1032
  $gadwp->gapi_controller->reset_token( false );
1033
  }
1034
  } else {
1035
- $message = "<div class='error'><p>" . __( "The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
1036
  }
1037
  }
1038
  if ( isset( $_POST['Refresh'] ) ) {
1039
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1040
  $gadwp->config->options['ga_dash_profile_list'] = array();
1041
- $message = "<div class='updated'><p>" . __( "Properties refreshed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1042
  $options = self::update_options( 'network' );
1043
  if ( $gadwp->config->options['ga_dash_token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1044
  if ( ! empty( $gadwp->config->options['ga_dash_profile_list'] ) ) {
@@ -1058,214 +1431,248 @@ final class GADWP_Settings {
1058
  }
1059
  }
1060
  } else {
1061
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1062
  }
1063
  }
1064
  if ( isset( $_POST['Clear'] ) ) {
1065
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1066
  GADWP_Tools::clear_cache();
1067
- $message = "<div class='updated'><p>" . __( "Cleared Cache.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1068
  } else {
1069
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1070
  }
1071
  }
1072
  if ( isset( $_POST['Reset'] ) ) {
1073
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1074
  $gadwp->gapi_controller->reset_token( true );
1075
  GADWP_Tools::clear_cache();
1076
- $message = "<div class='updated'><p>" . __( "Token Reseted and Revoked.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1077
  $options = self::update_options( 'Reset' );
1078
  } else {
1079
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1080
  }
1081
  }
1082
  if ( isset( $_POST['options']['ga_dash_hidden'] ) && ! isset( $_POST['Clear'] ) && ! isset( $_POST['Reset'] ) && ! isset( $_POST['Refresh'] ) ) {
1083
- $message = "<div class='updated'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1084
  if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
1085
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1086
  }
1087
  }
1088
  if ( isset( $_POST['Hide'] ) ) {
1089
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1090
- $message = "<div class='updated'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1091
  $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] );
1092
  $gadwp->config->options['ga_dash_profile_list'] = array( $lock_profile );
1093
  $options = self::update_options( 'network' );
1094
  } else {
1095
- $message = "<div class='error'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1096
  }
1097
  }
1098
  ?>
1099
- <div class="wrap">
1100
- <?php echo "<h2>" . __( "Google Analytics Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?><hr>
1101
- </div>
1102
- <div id="poststuff" class="gadwp">
1103
- <div id="post-body" class="metabox-holder columns-2">
1104
- <div id="post-body-content">
1105
- <div class="settings-wrapper">
1106
- <div class="inside">
1107
- <?php
1108
- if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) {
1109
- $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
1110
- }
1111
- if ( isset( $_POST['Authorize'] ) ) {
1112
- GADWP_Tools::clear_cache();
1113
- $gadwp->gapi_controller->token_request();
1114
- echo "<div class='updated'><p>" . __( "Use the red link (see below) to generate and get your access code!", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1115
- } else {
1116
- if ( isset( $message ) ) {
1117
- echo $message;
1118
- }
1119
- ?>
1120
- <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
1121
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
1122
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1123
- <table class="gadwp-settings-options">
1124
- <tr>
1125
- <td colspan="2"><?php echo "<h2>" . __( "Network Setup", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1126
- </tr>
1127
- <tr>
1128
- <td colspan="2" class="gadwp-settings-title">
1129
- <div class="button-primary gadwp-settings-switchoo">
1130
- <input type="checkbox" name="options[ga_dash_network]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_network" <?php checked( $options['ga_dash_network'], 1); ?> onchange="this.form.submit()"> <label class="gadwp-settings-switchoo-label" for="ga_dash_network">
1131
- <div class="gadwp-settings-switchoo-inner"></div>
1132
- <div class="gadwp-settings-switchoo-switch"></div>
1133
- </label>
1134
- </div>
1135
- <div class="switch-desc"><?php echo " ".__("use a single Google Analytics account for the entire network", 'google-analytics-dashboard-for-wp' );?></div>
1136
- </td>
1137
- </tr>
1138
- <?php if ($options['ga_dash_network']){ //Network Mode check?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1139
  <tr>
1140
- <td colspan="2"><hr></td>
1141
- </tr>
1142
- <tr>
1143
- <td colspan="2"><?php echo "<h2>" . __( "Plugin Authorization", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1144
- </tr>
1145
- <tr>
1146
- <td colspan="2" class="gadwp-settings-info">
1147
- <?php printf(__('You should watch the %1$s and read this %2$s before proceeding to authorization. This plugin requires a properly configured Google Analytics account!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_video&utm_campaign=gadwp', __("video", 'google-analytics-dashboard-for-wp')), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_tutorial&utm_campaign=gadwp', __("tutorial", 'google-analytics-dashboard-for-wp')));?>
1148
- </td>
1149
- </tr>
1150
- <?php
1151
- if ( ! $options['ga_dash_token'] || $options['ga_dash_userapi'] ) {
1152
- ?>
1153
- <tr>
1154
- <td colspan="2" class="gadwp-settings-info"><input name="options[ga_dash_userapi]" type="checkbox" id="ga_dash_userapi" value="1" <?php checked( $options['ga_dash_userapi'], 1 ); ?> onchange="this.form.submit()" /><?php echo " ".__("use your own API Project credentials", 'google-analytics-dashboard-for-wp' );?>
1155
- </td>
1156
- </tr>
1157
- <?php
1158
- }
1159
- if ( $options['ga_dash_userapi'] ) {
1160
- ?>
1161
- <tr>
1162
- <td class="gadwp-settings-title"><label for="options[ga_dash_clientid]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?></label></td>
1163
- <td><input type="text" name="options[ga_dash_clientid]" value="<?php echo esc_attr($options['ga_dash_clientid']); ?>" size="40" required="required"></td>
1164
- </tr>
1165
- <tr>
1166
- <td class="gadwp-settings-title"><label for="options[ga_dash_clientsecret]"><?php _e("Client Secret:", 'google-analytics-dashboard-for-wp'); ?></label></td>
1167
- <td><input type="text" name="options[ga_dash_clientsecret]" value="<?php echo esc_attr($options['ga_dash_clientsecret']); ?>" size="40" required="required"> <input type="hidden" name="options[ga_dash_hidden]" value="Y">
1168
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1169
- </td>
1170
- </tr>
1171
- <?php
1172
- }
1173
- if ( $options['ga_dash_token'] ) {
1174
- ?>
1175
- <tr>
1176
- <td colspan="2"><input type="submit" name="Reset" class="button button-secondary" value="<?php _e( "Clear Authorization", 'google-analytics-dashboard-for-wp' ); ?>" /> <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" /> <input type="submit" name="Refresh" class="button button-secondary" value="<?php _e( "Refresh Properties", 'google-analytics-dashboard-for-wp' ); ?>" /></td>
1177
- </tr>
1178
- <tr>
1179
- <td colspan="2"><hr></td>
1180
- </tr>
1181
- <tr>
1182
- <td colspan="2"><?php echo "<h2>" . __( "Properties/Views Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1183
- </tr>
1184
- <?php
1185
- if ( isset( $options['ga_dash_tableid_network'] ) ) {
1186
- $options['ga_dash_tableid_network'] = json_decode( json_encode( $options['ga_dash_tableid_network'] ), false );
1187
- }
1188
- foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
1189
- ?>
1190
- <tr>
1191
- <td class="gadwp-settings-title-s"><label for="ga_dash_tableid_network"><?php echo '<strong>'.$blog['domain'].$blog['path'].'</strong>: ';?></label></td>
1192
- <td><select id="ga_dash_tableid_network" <?php disabled(!empty($options['ga_dash_profile_list']),false);?> name="options[ga_dash_tableid_network][<?php echo $blog['blog_id'];?>]">
1193
- <?php
1194
- if ( ! empty( $options['ga_dash_profile_list'] ) ) {
1195
- foreach ( $options['ga_dash_profile_list'] as $items ) {
1196
- if ( $items[3] ) {
1197
- $temp_id = $blog['blog_id'];
1198
- echo '<option value="' . esc_attr( $items[1] ) . '" ' . selected( $items[1], isset( $options['ga_dash_tableid_network']->$temp_id ) ? $options['ga_dash_tableid_network']->$temp_id : '', false );
1199
- echo ' title="' . __( "View Name:", 'google-analytics-dashboard-for-wp' ) . ' ' . esc_attr( $items[0] ) . '">' . esc_html( GADWP_Tools::strip_protocol( $items[3] ) ) . ' &#8658; ' . esc_attr( $items[0] ) . '</option>';
1200
- }
1201
- }
1202
- } else {
1203
- echo '<option value="">' . __( "Property not found", 'google-analytics-dashboard-for-wp' ) . '</option>';
1204
- }
1205
- ?>
1206
- </select> <br /></td>
1207
- </tr>
1208
- <?php
1209
- }
1210
- ?>
1211
- <tr>
1212
- <td colspan="2"><?php echo "<h2>" . __( "Automatic Updates", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1213
- </tr>
1214
- <tr>
1215
- <td colspan="2" class="gadwp-settings-title">
1216
- <div class="button-primary gadwp-settings-switchoo">
1217
- <input type="checkbox" name="options[automatic_updates_minorversion]" value="1" class="gadwp-settings-switchoo-checkbox" id="automatic_updates_minorversion" <?php checked( $options['automatic_updates_minorversion'], 1 ); ?>> <label class="gadwp-settings-switchoo-label" for="automatic_updates_minorversion">
1218
- <div class="gadwp-settings-switchoo-inner"></div>
1219
- <div class="gadwp-settings-switchoo-switch"></div>
1220
- </label>
1221
- </div>
1222
- <div class="switch-desc"><?php echo " ".__( "automatic updates for minor versions (security and maintenance releases only)", 'google-analytics-dashboard-for-wp' );?></div>
1223
- </td>
1224
- </tr>
1225
- <tr>
1226
- <td colspan="2"><hr><?php echo "<h2>" . __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1227
- </tr>
1228
- <tr>
1229
- <td colspan="2" class="gadwp-settings-title">
1230
- <div class="button-primary gadwp-settings-switchoo">
1231
- <input type="checkbox" name="options[ga_dash_excludesa]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_excludesa"<?php checked( $options['ga_dash_excludesa'], 1); ?>"> <label class="gadwp-settings-switchoo-label" for="ga_dash_excludesa">
1232
- <div class="gadwp-settings-switchoo-inner"></div>
1233
- <div class="gadwp-settings-switchoo-switch"></div>
1234
- </label>
1235
- </div>
1236
- <div class="switch-desc"><?php echo " ".__("exclude Super Admin tracking for the entire network", 'google-analytics-dashboard-for-wp' );?></div>
1237
- </td>
1238
- </tr>
1239
- <tr>
1240
- <td colspan="2"><hr></td>
1241
- </tr>
1242
- <tr>
1243
- <td colspan="2" class="submit"><input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" /></td>
1244
- </tr>
1245
- <?php
1246
- } else {
1247
- ?>
1248
- <tr>
1249
- <td colspan="2"><hr></td>
1250
- </tr>
1251
- <tr>
1252
- <td colspan="2"><input type="submit" name="Authorize" class="button button-secondary" id="authorize" value="<?php _e( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ); ?>" /> <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" /></td>
1253
- </tr>
1254
- <?php } //Network Mode check?>
1255
- <tr>
1256
- <td colspan="2"><hr></td>
1257
- </tr>
1258
- </table>
1259
- </form>
1260
- <?php
1261
- self::output_sidebar();
1262
- return;
1263
- }
1264
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1265
  </table>
1266
- </form>
1267
- <?php
1268
- }
 
1269
  self::output_sidebar();
1270
  }
1271
 
@@ -1274,85 +1681,85 @@ final class GADWP_Settings {
1274
 
1275
  $gadwp = GADWP();
1276
  ?>
1277
- </div>
1278
- </div>
1279
- </div>
1280
- <div id="postbox-container-1" class="postbox-container">
1281
- <div class="meta-box-sortables">
1282
- <div class="postbox">
1283
- <h3>
1284
- <span><?php _e("Setup Tutorial & Demo",'google-analytics-dashboard-for-wp') ?></span>
1285
- </h3>
1286
- <div class="inside">
1287
- <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=video&utm_campaign=gadwp" target="_blank"><img src="<?php echo plugins_url( 'images/google-analytics-dashboard.png' , __FILE__ );?>" width="100%" alt="" /></a>
1288
- </div>
1289
- </div>
1290
- <div class="postbox">
1291
- <h3>
1292
- <span><?php _e("Follow & Review",'google-analytics-dashboard-for-wp')?></span>
1293
- </h3>
1294
- <div class="inside">
1295
- <div class="gadash-desc">
1296
- <div style="margin-left: -10px;">
1297
- <div class="g-page" data-width="273" data-href="//plus.google.com/+Deconfcom" data-layout="landscape" data-showtagline="false" data-showcoverphoto="false" data-rel="publisher"></div>
1298
- </div>
1299
- <script type="text/javascript">
1300
  (function() {
1301
- var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
1302
- po.src = 'https://apis.google.com/js/platform.js';
1303
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
1304
  })();
1305
  </script>
1306
- </div>
1307
- <br />
1308
- <div class="gadash-desc">
1309
- <a href="https://twitter.com/deconfcom" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @deconfcom</a>
1310
- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
1311
- </div>
1312
- <br />
1313
- <div class="gadash-title">
1314
- <a href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info"><img src="<?php echo plugins_url( 'images/star.png' , __FILE__ ); ?>" /></a>
1315
- </div>
1316
- <div class="gadash-desc">
1317
- <?php printf(__('Your feedback and review are both important, %s!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info">%s</a>', __('rate this plugin', 'google-analytics-dashboard-for-wp')));?>
1318
- </div>
1319
- </div>
1320
- </div>
1321
- <div class="postbox">
1322
- <h3>
1323
- <span><?php _e("Further Reading",'google-analytics-dashboard-for-wp')?></span>
1324
- </h3>
1325
- <div class="inside">
1326
- <div class="gadash-title">
1327
- <a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/clicky.png' , __FILE__ ); ?>" /></a>
1328
- </div>
1329
- <div class="gadash-desc">
1330
- <?php printf(__('%s service with users tracking at IP level.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp">%s</a>', __('Web Analytics', 'google-analytics-dashboard-for-wp')));?>
1331
- </div>
1332
- <br />
1333
- <div class="gadash-title">
1334
- <a href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/ssl.png' , __FILE__ ); ?>" /></a>
1335
- </div>
1336
- <div class="gadash-desc">
1337
- <?php printf(__('%s by moving your website to HTTPS/SSL.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp">%s</a>', __('Improve search rankings', 'google-analytics-dashboard-for-wp')));?>
1338
- </div>
1339
- <br />
1340
- <div class="gadash-title">
1341
- <a href="https://deconf.com/wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=plugins&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/wp.png' , __FILE__ ); ?>" /></a>
1342
- </div>
1343
- <div class="gadash-desc">
1344
- <?php printf(__('Other %s written by the same author', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=plugins&utm_campaign=gadwp">%s</a>', __('WordPress Plugins', 'google-analytics-dashboard-for-wp')));?>
1345
- </div>
1346
- </div>
1347
- </div>
1348
- </div>
1349
- </div>
1350
- </div>
1351
- </div>
1352
  <?php
1353
- //Dismiss the admin update notice
1354
- if ( version_compare( $wp_version, '4.2', '<' ) && current_user_can('manage_options') ) {
1355
- delete_option('gadwp_got_updated');
1356
  }
1357
  }
1358
  }
8
  */
9
 
10
  // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
  exit();
13
+ }
14
 
15
  final class GADWP_Settings {
16
 
18
  $gadwp = GADWP();
19
  $network_settings = false;
20
  $options = $gadwp->config->options; // Get current options
21
+ if ( isset( $_POST['options']['ga_dash_hidden'] ) && isset( $_POST['options'] ) && ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) && 'Reset' != $who ) {
22
  $new_options = $_POST['options'];
23
+ if ( 'tracking' == $who ) {
24
  $options['ga_dash_anonim'] = 0;
25
  $options['ga_event_tracking'] = 0;
26
  $options['ga_enhanced_links'] = 0;
27
  $options['ga_dash_remarketing'] = 0;
 
28
  $options['ga_event_bouncerate'] = 0;
29
  $options['ga_crossdomain_tracking'] = 0;
30
  $options['ga_aff_tracking'] = 0;
31
  $options['ga_hash_tracking'] = 0;
32
+ $options['ga_formsubmit_tracking'] = 0;
33
+ $options['ga_pagescrolldepth_tracking'] = 0;
34
+ $options['tm_pagescrolldepth_tracking'] = 0;
35
+ $options['amp_tracking_analytics'] = 0;
36
+ $options['amp_tracking_tagmanager'] = 0;
37
+ $options['optimize_pagehiding'] = 0;
38
+ $options['optimize_tracking'] = 0;
39
+ $options['trackingcode_infooter'] = 0;
40
+ $options['trackingevents_infooter'] = 0;
41
  if ( isset( $_POST['options']['ga_tracking_code'] ) ) {
42
  $new_options['ga_tracking_code'] = trim( $new_options['ga_tracking_code'], "\t" );
43
  }
44
  if ( empty( $new_options['ga_track_exclude'] ) ) {
45
  $new_options['ga_track_exclude'] = array();
46
  }
47
+ } elseif ( 'backend' == $who ) {
48
  $options['switch_profile'] = 0;
49
  $options['backend_item_reports'] = 0;
50
  $options['dashboard_widget'] = 0;
51
  if ( empty( $new_options['ga_dash_access_back'] ) ) {
52
  $new_options['ga_dash_access_back'][] = 'administrator';
53
  }
54
+ } elseif ( 'frontend' == $who ) {
55
  $options['frontend_item_reports'] = 0;
56
  if ( empty( $new_options['ga_dash_access_front'] ) ) {
57
  $new_options['ga_dash_access_front'][] = 'administrator';
58
  }
59
+ } elseif ( 'general' == $who ) {
60
  $options['ga_dash_userapi'] = 0;
61
  if ( ! is_multisite() ) {
62
  $options['automatic_updates_minorversion'] = 0;
63
  }
64
+ } elseif ( 'network' == $who ) {
65
  $options['ga_dash_userapi'] = 0;
66
  $options['ga_dash_network'] = 0;
67
  $options['ga_dash_excludesa'] = 0;
90
  }
91
  $options = self::update_options( 'frontend' );
92
  if ( isset( $_POST['options']['ga_dash_hidden'] ) ) {
93
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
94
  if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
95
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
96
  }
97
  }
98
  if ( ! $gadwp->config->options['ga_dash_tableid_jail'] || ! $gadwp->config->options['ga_dash_token'] ) {
100
  }
101
  ?>
102
  <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
103
+ <div class="wrap">
104
  <?php echo "<h2>" . __( "Google Analytics Frontend Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?><hr>
105
+ </div>
106
+ <div id="poststuff" class="gadwp">
107
+ <div id="post-body" class="metabox-holder columns-2">
108
+ <div id="post-body-content">
109
+ <div class="settings-wrapper">
110
+ <div class="inside">
111
  <?php if (isset($message)) echo $message; ?>
112
  <table class="gadwp-settings-options">
113
+ <tr>
114
+ <td colspan="2"><?php echo "<h2>" . __( "Permissions", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
115
+ </tr>
116
+ <tr>
117
+ <td class="roles gadwp-settings-title">
118
+ <label for="ga_dash_access_front"><?php _e("Show stats to:", 'google-analytics-dashboard-for-wp' ); ?>
119
+ </label>
120
+ </td>
121
+ <td class="gadwp-settings-roles">
122
+ <table>
123
+ <tr>
124
+ <?php if ( ! isset( $wp_roles ) ) : ?>
125
+ <?php $wp_roles = new WP_Roles(); ?>
126
+ <?php endif; ?>
127
+ <?php $i = 0; ?>
128
+ <?php foreach ( $wp_roles->role_names as $role => $name ) : ?>
129
+ <?php if ( 'subscriber' != $role ) : ?>
130
+ <?php $i++; ?>
131
+ <td>
132
+ <label>
133
+ <input type="checkbox" name="options[ga_dash_access_front][]" value="<?php echo $role; ?>" <?php if ( in_array($role,$options['ga_dash_access_front']) || 'administrator' == $role ) echo 'checked="checked"'; if ( 'administrator' == $role ) echo 'disabled="disabled"';?> /><?php echo $name; ?>
134
+ </label>
135
+ </td>
136
+ <?php endif; ?>
137
+ <?php if ( 0 == $i % 4 ) : ?>
138
+ </tr>
139
+ <tr>
140
+ <?php endif; ?>
141
+ <?php endforeach; ?>
142
+ </table>
143
+ </td>
144
+ </tr>
145
+ <tr>
146
+ <td colspan="2" class="gadwp-settings-title">
147
+ <div class="button-primary gadwp-settings-switchoo">
148
+ <input type="checkbox" name="options[frontend_item_reports]" value="1" class="gadwp-settings-switchoo-checkbox" id="frontend_item_reports" <?php checked( $options['frontend_item_reports'], 1 ); ?>>
149
+ <label class="gadwp-settings-switchoo-label" for="frontend_item_reports">
150
+ <div class="gadwp-settings-switchoo-inner"></div>
151
+ <div class="gadwp-settings-switchoo-switch"></div>
152
+ </label>
153
+ </div>
154
+ <div class="switch-desc"><?php echo " ".__("enable web page reports on frontend", 'google-analytics-dashboard-for-wp' );?></div>
155
+ </td>
156
+ </tr>
157
+ <tr>
158
+ <td colspan="2">
159
+ <hr>
160
+ </td>
161
+ </tr>
162
+ <tr>
163
+ <td colspan="2" class="submit">
164
+ <input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" />
165
+ </td>
166
+ </tr>
167
+ </table>
168
+ <input type="hidden" name="options[ga_dash_hidden]" value="Y">
169
  <?php wp_nonce_field('gadash_form','gadash_security');?>
170
  </form>
171
  <?php
179
  }
180
  $options = self::update_options( 'backend' );
181
  if ( isset( $_POST['options']['ga_dash_hidden'] ) ) {
182
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
183
  if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
184
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
185
  }
186
  }
187
  if ( ! $gadwp->config->options['ga_dash_tableid_jail'] || ! $gadwp->config->options['ga_dash_token'] ) {
189
  }
190
  ?>
191
  <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
192
+ <div class="wrap">
193
  <?php echo "<h2>" . __( "Google Analytics Backend Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?><hr>
194
+ </div>
195
+ <div id="poststuff" class="gadwp">
196
+ <div id="post-body" class="metabox-holder columns-2">
197
+ <div id="post-body-content">
198
+ <div class="settings-wrapper">
199
+ <div class="inside">
200
  <?php if (isset($message)) echo $message; ?>
201
  <table class="gadwp-settings-options">
202
+ <tr>
203
+ <td colspan="2"><?php echo "<h2>" . __( "Permissions", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
204
+ </tr>
205
+ <tr>
206
+ <td class="roles gadwp-settings-title">
207
+ <label for="ga_dash_access_back"><?php _e("Show stats to:", 'google-analytics-dashboard-for-wp' ); ?>
208
+ </label>
209
+ </td>
210
+ <td class="gadwp-settings-roles">
 
 
 
211
  <table>
212
+ <tr>
213
+ <?php if ( ! isset( $wp_roles ) ) : ?>
214
+ <?php $wp_roles = new WP_Roles(); ?>
215
+ <?php endif; ?>
216
+ <?php $i = 0; ?>
217
+ <?php foreach ( $wp_roles->role_names as $role => $name ) : ?>
218
+ <?php if ( 'subscriber' != $role ) : ?>
219
+ <?php $i++; ?>
220
+ <td>
221
+ <label>
222
+ <input type="checkbox" name="options[ga_dash_access_back][]" value="<?php echo $role; ?>" <?php if ( in_array($role,$options['ga_dash_access_back']) || 'administrator' == $role ) echo 'checked="checked"'; if ( 'administrator' == $role ) echo 'disabled="disabled"';?> /> <?php echo $name; ?>
223
+ </label>
224
+ </td>
225
+ <?php endif; ?>
226
+ <?php if ( 0 == $i % 4 ) : ?>
227
+ </tr>
228
+ <tr>
229
+ <?php endif; ?>
230
+ <?php endforeach; ?>
231
+ </table>
232
+ </td>
233
+ </tr>
234
+ <tr>
235
+ <td colspan="2" class="gadwp-settings-title">
236
+ <div class="button-primary gadwp-settings-switchoo">
237
+ <input type="checkbox" name="options[switch_profile]" value="1" class="gadwp-settings-switchoo-checkbox" id="switch_profile" <?php checked( $options['switch_profile'], 1 ); ?>>
238
+ <label class="gadwp-settings-switchoo-label" for="switch_profile">
239
+ <div class="gadwp-settings-switchoo-inner"></div>
240
+ <div class="gadwp-settings-switchoo-switch"></div>
241
+ </label>
242
+ </div>
243
+ <div class="switch-desc"><?php _e ( "enable Switch View functionality", 'google-analytics-dashboard-for-wp' );?></div>
244
+ </td>
245
+ </tr>
246
+ <tr>
247
+ <td colspan="2" class="gadwp-settings-title">
248
+ <div class="button-primary gadwp-settings-switchoo">
249
+ <input type="checkbox" name="options[backend_item_reports]" value="1" class="gadwp-settings-switchoo-checkbox" id="backend_item_reports" <?php checked( $options['backend_item_reports'], 1 ); ?>>
250
+ <label class="gadwp-settings-switchoo-label" for="backend_item_reports">
251
+ <div class="gadwp-settings-switchoo-inner"></div>
252
+ <div class="gadwp-settings-switchoo-switch"></div>
253
+ </label>
254
+ </div>
255
+ <div class="switch-desc"><?php _e ( "enable reports on Posts List and Pages List", 'google-analytics-dashboard-for-wp' );?></div>
256
+ </td>
257
+ </tr>
258
+ <tr>
259
+ <td colspan="2" class="gadwp-settings-title">
260
+ <div class="button-primary gadwp-settings-switchoo">
261
+ <input type="checkbox" name="options[dashboard_widget]" value="1" class="gadwp-settings-switchoo-checkbox" id="dashboard_widget" <?php checked( $options['dashboard_widget'], 1 ); ?>>
262
+ <label class="gadwp-settings-switchoo-label" for="dashboard_widget">
263
+ <div class="gadwp-settings-switchoo-inner"></div>
264
+ <div class="gadwp-settings-switchoo-switch"></div>
265
+ </label>
266
+ </div>
267
+ <div class="switch-desc"><?php _e ( "enable the main Dashboard Widget", 'google-analytics-dashboard-for-wp' );?></div>
268
+ </td>
269
+ </tr>
270
+ <tr>
271
+ <td colspan="2">
272
+ <hr><?php echo "<h2>" . __( "Real-Time Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
273
+ </tr>
274
+ <tr>
275
+ <td colspan="2" class="gadwp-settings-title"> <?php _e("Maximum number of pages to display on real-time tab:", 'google-analytics-dashboard-for-wp'); ?>
276
+ <input type="number" name="options[ga_realtime_pages]" id="ga_realtime_pages" value="<?php echo (int)$options['ga_realtime_pages']; ?>" size="3">
277
+ </td>
278
+ </tr>
279
+ <tr>
280
+ <td colspan="2">
281
+ <hr><?php echo "<h2>" . __( "Location Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
282
+ </tr>
283
+ <tr>
284
+ <td colspan="2" class="gadwp-settings-title">
285
  <?php echo __("Target Geo Map to country:", 'google-analytics-dashboard-for-wp'); ?>
286
  <input type="text" style="text-align: center;" name="options[ga_target_geomap]" value="<?php echo esc_attr($options['ga_target_geomap']); ?>" size="3">
287
+ </td>
288
+ </tr>
289
+ <tr>
290
+ <td colspan="2" class="gadwp-settings-title">
291
  <?php echo __("Maps API Key:", 'google-analytics-dashboard-for-wp'); ?>
292
  <input type="text" style="text-align: center;" name="options[maps_api_key]" value="<?php echo esc_attr($options['maps_api_key']); ?>" size="50">
293
+ </td>
294
+ </tr>
295
+ <tr>
296
+ <td colspan="2">
297
+ <hr><?php echo "<h2>" . __( "404 Errors Report", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
298
+ </tr>
299
+ <tr>
300
+ <td colspan="2" class="gadwp-settings-title">
301
  <?php echo __("404 Page Title contains:", 'google-analytics-dashboard-for-wp'); ?>
302
  <input type="text" style="text-align: center;" name="options[pagetitle_404]" value="<?php echo esc_attr($options['pagetitle_404']); ?>" size="20">
303
+ </td>
304
+ </tr>
305
+ <tr>
306
+ <td colspan="2">
307
+ <hr>
308
+ </td>
309
+ </tr>
310
+ <tr>
311
+ <td colspan="2" class="submit">
312
+ <input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" />
313
+ </td>
314
+ </tr>
315
+ </table>
316
+ <input type="hidden" name="options[ga_dash_hidden]" value="Y">
317
  <?php wp_nonce_field('gadash_form','gadash_security'); ?>
 
318
  </form>
319
  <?php
320
  self::output_sidebar();
328
  }
329
  $options = self::update_options( 'tracking' );
330
  if ( isset( $_POST['options']['ga_dash_hidden'] ) ) {
331
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
332
  if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
333
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
334
  }
335
  }
336
  if ( ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
337
  $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
338
  }
 
 
 
339
  ?>
340
  <form name="ga_dash_form" method="post" action="<?php esc_url($_SERVER['REQUEST_URI']); ?>">
341
+ <div class="wrap">
342
  <?php echo "<h2>" . __( "Google Analytics Tracking Code", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
343
  </div>
344
+ <div id="poststuff" class="gadwp">
345
+ <div id="post-body" class="metabox-holder columns-2">
346
+ <div id="post-body-content">
347
+ <div class="settings-wrapper">
348
+ <div class="inside">
349
+ <?php if ( 'universal' == $options['ga_dash_tracking_type'] ) :?>
350
+ <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ), 'events' => __( "Events Tracking", 'google-analytics-dashboard-for-wp' ), 'custom' => __( "Custom Definitions", 'google-analytics-dashboard-for-wp' ), 'exclude' => __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ), 'advanced' => __( "Advanced Settings", 'google-analytics-dashboard-for-wp' ), 'integration' => __( "Integration", 'google-analytics-dashboard-for-wp' ) );?>
351
+ <?php elseif ( 'tagmanager' == $options['ga_dash_tracking_type'] ) :?>
352
+ <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ), 'tmdatalayervars' => __( "DataLayer Variables", 'google-analytics-dashboard-for-wp' ), 'exclude' => __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ), 'tmintegration' => __( "Integration", 'google-analytics-dashboard-for-wp' ) );?>
353
+ <?php else :?>
354
+ <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ) );?>
355
+ <?php endif; ?>
356
+ <?php self::navigation_tabs( $tabs ); ?>
357
+ <?php if ( isset( $message ) ) : ?>
358
+ <?php echo $message; ?>
359
+ <?php endif; ?>
360
+ <div id="gadwp-basic">
361
+ <table class="gadwp-settings-options">
 
 
 
 
 
 
362
  <tr>
363
+ <td colspan="2"><?php echo "<h2>" . __( "Tracking Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
364
+ </tr>
 
 
 
 
 
365
  <tr>
366
+ <td class="gadwp-settings-title">
367
+ <label for="ga_dash_tracking_type"><?php _e("Tracking Type:", 'google-analytics-dashboard-for-wp' ); ?>
368
+ </label>
369
+ </td>
370
+ <td>
371
+ <select id="ga_dash_tracking_type" name="options[ga_dash_tracking_type]" onchange="this.form.submit()">
372
+ <option value="universal" <?php selected( $options['ga_dash_tracking_type'], 'universal' ); ?>><?php _e("Analytics", 'google-analytics-dashboard-for-wp');?></option>
373
+ <option value="tagmanager" <?php selected( $options['ga_dash_tracking_type'], 'tagmanager' ); ?>><?php _e("Tag Manager", 'google-analytics-dashboard-for-wp');?></option>
374
+ <option value="disabled" <?php selected( $options['ga_dash_tracking_type'], 'disabled' ); ?>><?php _e("Disabled", 'google-analytics-dashboard-for-wp');?></option>
375
+ </select>
376
+ </td>
377
+ </tr>
378
+ <?php if ( 'universal' == $options['ga_dash_tracking_type'] ) : ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
379
  <tr>
380
+ <td class="gadwp-settings-title"></td>
381
+ <td>
382
+ <?php $profile_info = GADWP_Tools::get_selected_profile($gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail']); ?>
383
+ <?php echo '<pre>' . __("View Name:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[0]) . "<br />" . __("Tracking ID:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[2]) . "<br />" . __("Default URL:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[3]) . "<br />" . __("Time Zone:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[5]) . '</pre>';?>
384
+ </td>
385
+ </tr>
386
+ <?php elseif ( 'tagmanager' == $options['ga_dash_tracking_type'] ) : ?>
387
+ <tr>
388
+ <td class="gadwp-settings-title">
389
+ <label for="ga_dash_tracking_type"><?php _e("Web Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
390
+ </label>
391
+ </td>
392
+ <td>
393
+ <input type="text" name="options[web_containerid]" value="<?php echo esc_attr($options['web_containerid']); ?>" size="15">
394
+ </td>
395
+ </tr>
396
+ <?php endif; ?>
397
+ <tr>
398
+ <td class="gadwp-settings-title">
399
+ <label for="trackingcode_infooter"><?php _e("Code Placement:", 'google-analytics-dashboard-for-wp' ); ?>
400
+ </label>
401
+ </td>
402
+ <td>
403
+ <select id="trackingcode_infooter" name="options[trackingcode_infooter]">
404
+ <option value="0" <?php selected( $options['trackingcode_infooter'], 0 ); ?>><?php _e("HTML Head", 'google-analytics-dashboard-for-wp');?></option>
405
+ <option value="1" <?php selected( $options['trackingcode_infooter'], 1 ); ?>><?php _e("HTML Body", 'google-analytics-dashboard-for-wp');?></option>
406
+ </select>
407
+ </td>
408
+ </tr>
409
+ </table>
410
+ </div>
411
+ <div id="gadwp-events">
412
+ <table class="gadwp-settings-options">
413
+ <tr>
414
+ <td colspan="2"><?php echo "<h2>" . __( "Events Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
415
+ </tr>
416
+ <tr>
417
+ <td colspan="2" class="gadwp-settings-title">
418
+ <div class="button-primary gadwp-settings-switchoo">
419
+ <input type="checkbox" name="options[ga_event_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_event_tracking" <?php checked( $options['ga_event_tracking'], 1 ); ?>>
420
+ <label class="gadwp-settings-switchoo-label" for="ga_event_tracking">
421
+ <div class="gadwp-settings-switchoo-inner"></div>
422
+ <div class="gadwp-settings-switchoo-switch"></div>
423
+ </label>
424
+ </div>
425
+ <div class="switch-desc"><?php echo " ".__("track downloads, mailto, telephone and outbound links", 'google-analytics-dashboard-for-wp' ); ?></div>
426
+ </td>
427
+ </tr>
428
+ <tr>
429
+ <td colspan="2" class="gadwp-settings-title">
430
+ <div class="button-primary gadwp-settings-switchoo">
431
+ <input type="checkbox" name="options[ga_aff_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_aff_tracking" <?php checked( $options['ga_aff_tracking'], 1 ); ?>>
432
+ <label class="gadwp-settings-switchoo-label" for="ga_aff_tracking">
433
+ <div class="gadwp-settings-switchoo-inner"></div>
434
+ <div class="gadwp-settings-switchoo-switch"></div>
435
+ </label>
436
+ </div>
437
+ <div class="switch-desc"><?php echo " ".__("track affiliate links", 'google-analytics-dashboard-for-wp' ); ?></div>
438
+ </td>
439
+ </tr>
440
+ <tr>
441
+ <td colspan="2" class="gadwp-settings-title">
442
+ <div class="button-primary gadwp-settings-switchoo">
443
+ <input type="checkbox" name="options[ga_hash_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_hash_tracking" <?php checked( $options['ga_hash_tracking'], 1 ); ?>>
444
+ <label class="gadwp-settings-switchoo-label" for="ga_hash_tracking">
445
+ <div class="gadwp-settings-switchoo-inner"></div>
446
+ <div class="gadwp-settings-switchoo-switch"></div>
447
+ </label>
448
+ </div>
449
+ <div class="switch-desc"><?php echo " ".__("track fragment identifiers, hashmarks (#) in URI links", 'google-analytics-dashboard-for-wp' ); ?></div>
450
+ </td>
451
+ </tr>
452
+ <tr>
453
+ <td colspan="2" class="gadwp-settings-title">
454
+ <div class="button-primary gadwp-settings-switchoo">
455
+ <input type="checkbox" name="options[ga_formsubmit_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_formsubmit_tracking" <?php checked( $options['ga_formsubmit_tracking'], 1 ); ?>>
456
+ <label class="gadwp-settings-switchoo-label" for="ga_formsubmit_tracking">
457
+ <div class="gadwp-settings-switchoo-inner"></div>
458
+ <div class="gadwp-settings-switchoo-switch"></div>
459
+ </label>
460
+ </div>
461
+ <div class="switch-desc"><?php echo " ".__("track form submit actions", 'google-analytics-dashboard-for-wp' ); ?></div>
462
+ </td>
463
+ </tr>
464
+ <tr>
465
+ <td colspan="2" class="gadwp-settings-title">
466
+ <div class="button-primary gadwp-settings-switchoo">
467
+ <input type="checkbox" name="options[ga_pagescrolldepth_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_pagescrolldepth_tracking" <?php checked( $options['ga_pagescrolldepth_tracking'], 1 ); ?>>
468
+ <label class="gadwp-settings-switchoo-label" for="ga_pagescrolldepth_tracking">
469
+ <div class="gadwp-settings-switchoo-inner"></div>
470
+ <div class="gadwp-settings-switchoo-switch"></div>
471
+ </label>
472
+ </div>
473
+ <div class="switch-desc"><?php echo " ".__("track page scrolling depth", 'google-analytics-dashboard-for-wp' ); ?></div>
474
+ </td>
475
+ </tr>
476
+ <tr>
477
+ <td class="gadwp-settings-title">
478
+ <label for="ga_event_downloads"><?php _e("Downloads Regex:", 'google-analytics-dashboard-for-wp'); ?>
479
+ </label>
480
+ </td>
481
+ <td>
482
+ <input type="text" id="ga_event_downloads" name="options[ga_event_downloads]" value="<?php echo esc_attr($options['ga_event_downloads']); ?>" size="50">
483
+ </td>
484
+ </tr>
485
+ <tr>
486
+ <td class="gadwp-settings-title">
487
+ <label for="ga_event_affiliates"><?php _e("Affiliates Regex:", 'google-analytics-dashboard-for-wp'); ?>
488
+ </label>
489
+ </td>
490
+ <td>
491
+ <input type="text" id="ga_event_affiliates" name="options[ga_event_affiliates]" value="<?php echo esc_attr($options['ga_event_affiliates']); ?>" size="50">
492
+ </td>
493
+ </tr>
494
+ <tr>
495
+ <td class="gadwp-settings-title">
496
+ <label for="trackingevents_infooter"><?php _e("Code Placement:", 'google-analytics-dashboard-for-wp' ); ?>
497
+ </label>
498
+ </td>
499
+ <td>
500
+ <select id="trackingevents_infooter" name="options[trackingevents_infooter]">
501
+ <option value="0" <?php selected( $options['trackingevents_infooter'], 0 ); ?>><?php _e("HTML Head", 'google-analytics-dashboard-for-wp');?></option>
502
+ <option value="1" <?php selected( $options['trackingevents_infooter'], 1 ); ?>><?php _e("HTML Body", 'google-analytics-dashboard-for-wp');?></option>
503
+ </select>
504
+ </td>
505
+ </tr>
506
+ </table>
507
+ </div>
508
+ <div id="gadwp-custom">
509
+ <table class="gadwp-settings-options">
510
+ <tr>
511
+ <td colspan="2"><?php echo "<h2>" . __( "Custom Dimensions", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
512
+ </tr>
513
+ <tr>
514
+ <td class="gadwp-settings-title">
515
+ <label for="ga_author_dimindex"><?php _e("Authors:", 'google-analytics-dashboard-for-wp' ); ?>
516
+ </label>
517
+ </td>
518
+ <td>
519
+ <select id="ga_author_dimindex" name="options[ga_author_dimindex]">
520
+ <?php for ($i=0;$i<21;$i++) : ?>
521
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_author_dimindex'], $i ); ?>><?php echo 0 == $i ?'Disabled':'dimension '.$i; ?></option>
522
+ <?php endfor; ?>
523
+ </select>
524
+ </td>
525
+ </tr>
526
+ <tr>
527
+ <td class="gadwp-settings-title">
528
+ <label for="ga_pubyear_dimindex"><?php _e("Publication Year:", 'google-analytics-dashboard-for-wp' ); ?>
529
+ </label>
530
+ </td>
531
+ <td>
532
+ <select id="ga_pubyear_dimindex" name="options[ga_pubyear_dimindex]">
533
+ <?php for ($i=0;$i<21;$i++) : ?>
534
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_pubyear_dimindex'], $i ); ?>><?php echo 0 == $i ?'Disabled':'dimension '.$i; ?></option>
535
+ <?php endfor; ?>
536
+ </select>
537
+ </td>
538
+ </tr>
539
+ <tr>
540
+ <td class="gadwp-settings-title">
541
+ <label for="ga_pubyearmonth_dimindex"><?php _e("Publication Month:", 'google-analytics-dashboard-for-wp' ); ?>
542
+ </label>
543
+ </td>
544
+ <td>
545
+ <select id="ga_pubyearmonth_dimindex" name="options[ga_pubyearmonth_dimindex]">
546
+ <?php for ($i=0;$i<21;$i++) : ?>
547
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_pubyearmonth_dimindex'], $i ); ?>><?php echo 0 == $i ?'Disabled':'dimension '.$i; ?></option>
548
+ <?php endfor; ?>
549
+ </select>
550
+ </td>
551
+ </tr>
552
+ <tr>
553
+ <td class="gadwp-settings-title">
554
+ <label for="ga_category_dimindex"><?php _e("Categories:", 'google-analytics-dashboard-for-wp' ); ?>
555
+ </label>
556
+ </td>
557
+ <td>
558
+ <select id="ga_category_dimindex" name="options[ga_category_dimindex]">
559
+ <?php for ($i=0;$i<21;$i++) : ?>
560
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_category_dimindex'], $i ); ?>><?php echo 0 == $i ? 'Disabled':'dimension '.$i; ?></option>
561
+ <?php endfor; ?>
562
+ </select>
563
+ </td>
564
+ </tr>
565
+ <tr>
566
+ <td class="gadwp-settings-title">
567
+ <label for="ga_user_dimindex"><?php _e("User Type:", 'google-analytics-dashboard-for-wp' ); ?>
568
+ </label>
569
+ </td>
570
+ <td>
571
+ <select id="ga_user_dimindex" name="options[ga_user_dimindex]">
572
+ <?php for ($i=0;$i<21;$i++) : ?>
573
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_user_dimindex'], $i ); ?>><?php echo 0 == $i ? 'Disabled':'dimension '.$i; ?></option>
574
+ <?php endfor; ?>
575
+ </select>
576
+ </td>
577
+ </tr>
578
+ <tr>
579
+ <td class="gadwp-settings-title">
580
+ <label for="ga_tag_dimindex"><?php _e("Tags:", 'google-analytics-dashboard-for-wp' ); ?>
581
+ </label>
582
+ </td>
583
+ <td>
584
+ <select id="ga_tag_dimindex" name="options[ga_tag_dimindex]">
585
+ <?php for ($i=0;$i<21;$i++) : ?>
586
+ <option value="<?php echo $i;?>" <?php selected( $options['ga_tag_dimindex'], $i ); ?>><?php echo 0 == $i ? 'Disabled':'dimension '.$i; ?></option>
587
+ <?php endfor; ?>
588
+ </select>
589
+ </td>
590
+ </tr>
591
+ </table>
592
+ </div>
593
+ <div id="gadwp-tmdatalayervars">
594
+ <table class="gadwp-settings-options">
595
+ <tr>
596
+ <td colspan="2"><?php echo "<h2>" . __( "Main Variables", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
597
+ </tr>
598
+ <tr>
599
+ <td class="gadwp-settings-title">
600
+ <label for="tm_author_var"><?php _e("Authors:", 'google-analytics-dashboard-for-wp' ); ?>
601
+ </label>
602
+ </td>
603
+ <td>
604
+ <select id="tm_author_var" name="options[tm_author_var]">
605
+ <option value="1" <?php selected( $options['tm_author_var'], 1 ); ?>>gadwpAuthor</option>
606
+ <option value="0" <?php selected( $options['tm_author_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
607
+ </select>
608
+ </td>
609
+ </tr>
610
+ <tr>
611
+ <td class="gadwp-settings-title">
612
+ <label for="tm_pubyear_var"><?php _e("Publication Year:", 'google-analytics-dashboard-for-wp' ); ?>
613
+ </label>
614
+ </td>
615
+ <td>
616
+ <select id="tm_pubyear_var" name="options[tm_pubyear_var]">
617
+ <option value="1" <?php selected( $options['tm_pubyear_var'], 1 ); ?>>gadwpPublicationYear</option>
618
+ <option value="0" <?php selected( $options['tm_pubyear_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
619
+ </select>
620
+ </td>
621
+ </tr>
622
+ <tr>
623
+ <td class="gadwp-settings-title">
624
+ <label for="tm_pubyearmonth_var"><?php _e("Publication Month:", 'google-analytics-dashboard-for-wp' ); ?>
625
+ </label>
626
+ </td>
627
+ <td>
628
+ <select id="tm_pubyearmonth_var" name="options[tm_pubyearmonth_var]">
629
+ <option value="1" <?php selected( $options['tm_pubyearmonth_var'], 1 ); ?>>gadwpPublicationYearMonth</option>
630
+ <option value="0" <?php selected( $options['tm_pubyearmonth_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
631
+ </select>
632
+ </td>
633
+ </tr>
634
+ <tr>
635
+ <td class="gadwp-settings-title">
636
+ <label for="tm_category_var"><?php _e("Categories:", 'google-analytics-dashboard-for-wp' ); ?>
637
+ </label>
638
+ </td>
639
+ <td>
640
+ <select id="tm_category_var" name="options[tm_category_var]">
641
+ <option value="1" <?php selected( $options['tm_category_var'], 1 ); ?>>gadwpCategory</option>
642
+ <option value="0" <?php selected( $options['tm_category_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
643
+ </select>
644
+ </td>
645
+ </tr>
646
+ <tr>
647
+ <td class="gadwp-settings-title">
648
+ <label for="tm_user_var"><?php _e("User Type:", 'google-analytics-dashboard-for-wp' ); ?>
649
+ </label>
650
+ </td>
651
+ <td>
652
+ <select id="tm_user_var" name="options[tm_user_var]">
653
+ <option value="1" <?php selected( $options['tm_user_var'], 1 ); ?>>gadwpUser</option>
654
+ <option value="0" <?php selected( $options['tm_user_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
655
+ </select>
656
+ </td>
657
+ </tr>
658
+ <tr>
659
+ <td class="gadwp-settings-title">
660
+ <label for="tm_tag_var"><?php _e("Tags:", 'google-analytics-dashboard-for-wp' ); ?>
661
+ </label>
662
+ </td>
663
+ <td>
664
+ <select id="tm_tag_var" name="options[tm_tag_var]">
665
+ <option value="1" <?php selected( $options['tm_tag_var'], 1 ); ?>>gadwpTag</option>
666
+ <option value="0" <?php selected( $options['tm_tag_var'], 0 ); ?>><?php _e( "Disabled", 'google-analytics-dashboard-for-wp' ); ?></option>
667
+ </select>
668
+ </td>
669
+ </tr>
670
+ <tr>
671
+ <td colspan="2"><?php echo "<h2>" . __( "Page Scrolling Depth Variables", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
672
+ </tr>
673
+ <tr>
674
+ <td colspan="2" class="gadwp-settings-title">
675
+ <div class="button-primary gadwp-settings-switchoo">
676
+ <input type="checkbox" name="options[tm_pagescrolldepth_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="tm_pagescrolldepth_tracking" <?php checked( $options['tm_pagescrolldepth_tracking'], 1 ); ?>>
677
+ <label class="gadwp-settings-switchoo-label" for="tm_pagescrolldepth_tracking">
678
+ <div class="gadwp-settings-switchoo-inner"></div>
679
+ <div class="gadwp-settings-switchoo-switch"></div>
680
+ </label>
681
+ </div>
682
+ <div class="switch-desc"><?php echo " ".__("enable page scrolling depth variables: ", 'google-analytics-dashboard-for-wp' ) . "<strong>{{event}} = ScrollDistance, {{eventCategory}}, {{eventAction}}, {{eventLabel}}, {{eventValue}}, {{eventNonInteraction}}</strong>"?></div>
683
+ </td>
684
+ </tr>
685
+ </table>
686
+ </div>
687
+ <div id="gadwp-advanced">
688
+ <table class="gadwp-settings-options">
689
+ <tr>
690
+ <td colspan="2"><?php echo "<h2>" . __( "Advanced Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
691
+ </tr>
692
+ <tr>
693
+ <td class="gadwp-settings-title">
694
+ <label for="ga_speed_samplerate"><?php _e("Page Speed SR:", 'google-analytics-dashboard-for-wp'); ?>
695
+ </label>
696
+ </td>
697
+ <td>
698
+ <input type="number" id="ga_speed_samplerate" name="options[ga_speed_samplerate]" value="<?php echo (int)($options['ga_speed_samplerate']); ?>" max="100" min="1">
699
+ %
700
+ </td>
701
+ </tr>
702
+ <tr>
703
+ <td colspan="2" class="gadwp-settings-title">
704
+ <div class="button-primary gadwp-settings-switchoo">
705
+ <input type="checkbox" name="options[ga_dash_anonim]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_anonim" <?php checked( $options['ga_dash_anonim'], 1 ); ?>>
706
+ <label class="gadwp-settings-switchoo-label" for="ga_dash_anonim">
707
+ <div class="gadwp-settings-switchoo-inner"></div>
708
+ <div class="gadwp-settings-switchoo-switch"></div>
709
+ </label>
710
+ </div>
711
+ <div class="switch-desc"><?php echo " ".__("anonymize IPs while tracking", 'google-analytics-dashboard-for-wp' );?></div>
712
+ </td>
713
+ </tr>
714
+ <tr>
715
+ <td colspan="2" class="gadwp-settings-title">
716
+ <div class="button-primary gadwp-settings-switchoo">
717
+ <input type="checkbox" name="options[ga_dash_remarketing]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_remarketing" <?php checked( $options['ga_dash_remarketing'], 1 ); ?>>
718
+ <label class="gadwp-settings-switchoo-label" for="ga_dash_remarketing">
719
+ <div class="gadwp-settings-switchoo-inner"></div>
720
+ <div class="gadwp-settings-switchoo-switch"></div>
721
+ </label>
722
+ </div>
723
+ <div class="switch-desc"><?php echo " ".__("enable remarketing, demographics and interests reports", 'google-analytics-dashboard-for-wp' );?></div>
724
+ </td>
725
+ </tr>
726
+ <tr>
727
+ <td colspan="2" class="gadwp-settings-title">
728
+ <div class="button-primary gadwp-settings-switchoo">
729
+ <input type="checkbox" name="options[ga_event_bouncerate]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_event_bouncerate" <?php checked( $options['ga_event_bouncerate'], 1 ); ?>>
730
+ <label class="gadwp-settings-switchoo-label" for="ga_event_bouncerate">
731
+ <div class="gadwp-settings-switchoo-inner"></div>
732
+ <div class="gadwp-settings-switchoo-switch"></div>
733
+ </label>
734
+ </div>
735
+ <div class="switch-desc"><?php echo " ".__("exclude events from bounce-rate calculation", 'google-analytics-dashboard-for-wp' );?></div>
736
+ </td>
737
+ </tr>
738
+ <tr>
739
+ <td colspan="2" class="gadwp-settings-title">
740
+ <div class="button-primary gadwp-settings-switchoo">
741
+ <input type="checkbox" name="options[ga_enhanced_links]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_enhanced_links" <?php checked( $options['ga_enhanced_links'], 1 ); ?>>
742
+ <label class="gadwp-settings-switchoo-label" for="ga_enhanced_links">
743
+ <div class="gadwp-settings-switchoo-inner"></div>
744
+ <div class="gadwp-settings-switchoo-switch"></div>
745
+ </label>
746
+ </div>
747
+ <div class="switch-desc"><?php echo " ".__("enable enhanced link attribution", 'google-analytics-dashboard-for-wp' );?></div>
748
+ </td>
749
+ </tr>
750
+ <tr>
751
+ <td colspan="2"><?php echo "<h2>" . __( "Cross-domain Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
752
+ </tr>
753
+ <tr>
754
+ <td colspan="2" class="gadwp-settings-title">
755
+ <div class="button-primary gadwp-settings-switchoo">
756
+ <input type="checkbox" name="options[ga_crossdomain_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_crossdomain_tracking" <?php checked( $options['ga_crossdomain_tracking'], 1 ); ?>>
757
+ <label class="gadwp-settings-switchoo-label" for="ga_crossdomain_tracking">
758
+ <div class="gadwp-settings-switchoo-inner"></div>
759
+ <div class="gadwp-settings-switchoo-switch"></div>
760
+ </label>
761
+ </div>
762
+ <div class="switch-desc"><?php echo " ".__("enable cross domain tracking", 'google-analytics-dashboard-for-wp' ); ?></div>
763
+ </td>
764
+ </tr>
765
+ <tr>
766
+ <td class="gadwp-settings-title">
767
+ <label for="ga_crossdomain_list"><?php _e("Cross Domains:", 'google-analytics-dashboard-for-wp'); ?>
768
+ </label>
769
+ </td>
770
+ <td>
771
+ <input type="text" id="ga_crossdomain_list" name="options[ga_crossdomain_list]" value="<?php echo esc_attr($options['ga_crossdomain_list']); ?>" size="50">
772
+ </td>
773
+ </tr>
774
+ <tr>
775
+ <td colspan="2"><?php echo "<h2>" . __( "Cookie Customization", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
776
+ </tr>
777
+ <tr>
778
+ <td class="gadwp-settings-title">
779
+ <label for="ga_cookiedomain"><?php _e("Cookie Domain:", 'google-analytics-dashboard-for-wp'); ?>
780
+ </label>
781
+ </td>
782
+ <td>
783
+ <input type="text" id="ga_cookiedomain" name="options[ga_cookiedomain]" value="<?php echo esc_attr($options['ga_cookiedomain']); ?>" size="50">
784
+ </td>
785
+ </tr>
786
+ <tr>
787
+ <td class="gadwp-settings-title">
788
+ <label for="ga_cookiename"><?php _e("Cookie Name:", 'google-analytics-dashboard-for-wp'); ?>
789
+ </label>
790
+ </td>
791
+ <td>
792
+ <input type="text" id="ga_cookiename" name="options[ga_cookiename]" value="<?php echo esc_attr($options['ga_cookiename']); ?>" size="50">
793
+ </td>
794
+ </tr>
795
+ <tr>
796
+ <td class="gadwp-settings-title">
797
+ <label for="ga_cookieexpires"><?php _e("Cookie Expires:", 'google-analytics-dashboard-for-wp'); ?>
798
+ </label>
799
+ </td>
800
+ <td>
801
+ <input type="text" id="ga_cookieexpires" name="options[ga_cookieexpires]" value="<?php echo esc_attr($options['ga_cookieexpires']); ?>" size="10">
802
+ <?php _e("seconds", 'google-analytics-dashboard-for-wp' ); ?>
803
+ </td>
804
+ </tr>
805
+ </table>
806
+ </div>
807
+ <div id="gadwp-integration">
808
+ <table class="gadwp-settings-options">
809
+ <tr>
810
+ <td colspan="2"><?php echo "<h2>" . __( "Accelerated Mobile Pages (AMP)", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
811
+ </tr>
812
+ <tr>
813
+ <td colspan="2" class="gadwp-settings-title">
814
+ <div class="button-primary gadwp-settings-switchoo">
815
+ <input type="checkbox" name="options[amp_tracking_analytics]" value="1" class="gadwp-settings-switchoo-checkbox" id="amp_tracking_analytics" <?php checked( $options['amp_tracking_analytics'], 1 ); ?>>
816
+ <label class="gadwp-settings-switchoo-label" for="amp_tracking_analytics">
817
+ <div class="gadwp-settings-switchoo-inner"></div>
818
+ <div class="gadwp-settings-switchoo-switch"></div>
819
+ </label>
820
+ </div>
821
+ <div class="switch-desc"><?php echo " ".__("enable tracking for Accelerated Mobile Pages (AMP)", 'google-analytics-dashboard-for-wp' );?></div>
822
+ </td>
823
+ </tr>
824
+ <tr>
825
+ <td colspan="2"><?php echo "<h2>" . __( "Ecommerce", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
826
+ </tr>
827
+ <tr>
828
+ <td class="gadwp-settings-title">
829
+ <label for="ga_dash_tracking_type"><?php _e("Ecommerce Tracking:", 'google-analytics-dashboard-for-wp' ); ?>
830
+ </label>
831
+ </td>
832
+ <td>
833
+ <select id="ecommerce_mode" name="options[ecommerce_mode]">
834
+ <option value="disabled" <?php selected( $options['ecommerce_mode'], 'disabled' ); ?>><?php _e("Disabled", 'google-analytics-dashboard-for-wp');?></option>
835
+ <option value="standard" <?php selected( $options['ecommerce_mode'], 'standard' ); ?>><?php _e("Ecommerce Plugin", 'google-analytics-dashboard-for-wp');?></option>
836
+ <option value="enhanced" <?php selected( $options['ecommerce_mode'], 'enhanced' ); ?>><?php _e("Enhanced Ecommerce Plugin", 'google-analytics-dashboard-for-wp');?></option>
837
+ </select>
838
+ </td>
839
+ </tr>
840
+ <tr>
841
+ <td colspan="2"><?php echo "<h2>" . __( "Optimize", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
842
+ </tr>
843
+ <tr>
844
+ <td colspan="2" class="gadwp-settings-title">
845
+ <div class="button-primary gadwp-settings-switchoo">
846
+ <input type="checkbox" name="options[optimize_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="optimize_tracking" <?php checked( $options['optimize_tracking'], 1 ); ?>>
847
+ <label class="gadwp-settings-switchoo-label" for="optimize_tracking">
848
+ <div class="gadwp-settings-switchoo-inner"></div>
849
+ <div class="gadwp-settings-switchoo-switch"></div>
850
+ </label>
851
+ </div>
852
+ <div class="switch-desc"><?php echo " ".__("enable Optimize tracking", 'google-analytics-dashboard-for-wp' );?></div>
853
+ </td>
854
+ </tr>
855
+ <tr>
856
+ <td colspan="2" class="gadwp-settings-title">
857
+ <div class="button-primary gadwp-settings-switchoo">
858
+ <input type="checkbox" name="options[optimize_pagehiding]" value="1" class="gadwp-settings-switchoo-checkbox" id="optimize_pagehiding" <?php checked( $options['optimize_pagehiding'], 1 ); ?>>
859
+ <label class="gadwp-settings-switchoo-label" for="optimize_pagehiding">
860
+ <div class="gadwp-settings-switchoo-inner"></div>
861
+ <div class="gadwp-settings-switchoo-switch"></div>
862
+ </label>
863
+ </div>
864
+ <div class="switch-desc"><?php echo " ".__("enable Page Hiding support", 'google-analytics-dashboard-for-wp' );?></div>
865
+ </td>
866
+ </tr>
867
+ <tr>
868
+ <td class="gadwp-settings-title">
869
+ <label for="ga_dash_tracking_type"><?php _e("Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
870
+ </label>
871
+ </td>
872
+ <td>
873
+ <input type="text" name="options[optimize_containerid]" value="<?php echo esc_attr($options['optimize_containerid']); ?>" size="15">
874
+ </td>
875
+ </tr>
876
+ </table>
877
+ </div>
878
+ <div id="gadwp-tmintegration">
879
+ <table class="gadwp-settings-options">
880
+ <tr>
881
+ <td colspan="2"><?php echo "<h2>" . __( "Accelerated Mobile Pages (AMP)", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
882
+ </tr>
883
+ <tr>
884
+ <td colspan="2" class="gadwp-settings-title">
885
+ <div class="button-primary gadwp-settings-switchoo">
886
+ <input type="checkbox" name="options[amp_tracking_tagmanager]" value="1" class="gadwp-settings-switchoo-checkbox" id="amp_tracking_tagmanager" <?php checked( $options['amp_tracking_tagmanager'], 1 ); ?>>
887
+ <label class="gadwp-settings-switchoo-label" for="amp_tracking_tagmanager">
888
+ <div class="gadwp-settings-switchoo-inner"></div>
889
+ <div class="gadwp-settings-switchoo-switch"></div>
890
+ </label>
891
+ </div>
892
+ <div class="switch-desc"><?php echo " ".__("enable tracking for Accelerated Mobile Pages (AMP)", 'google-analytics-dashboard-for-wp' );?></div>
893
+ </td>
894
+ </tr>
895
+ <tr>
896
+ <td class="gadwp-settings-title">
897
+ <label for="ga_dash_tracking_type"><?php _e("AMP Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
898
+ </label>
899
+ </td>
900
+ <td>
901
+ <input type="text" name="options[amp_containerid]" value="<?php echo esc_attr($options['amp_containerid']); ?>" size="15">
902
+ </td>
903
+ </tr>
904
+ </table>
905
+ </div>
906
+ <div id="gadwp-exclude">
907
+ <table class="gadwp-settings-options">
908
+ <tr>
909
+ <td colspan="2"><?php echo "<h2>" . __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
910
+ </tr>
911
+ <tr>
912
+ <td class="roles gadwp-settings-title">
913
+ <label for="ga_track_exclude"><?php _e("Exclude tracking for:", 'google-analytics-dashboard-for-wp' ); ?></label>
914
+ </td>
915
+ <td class="gadwp-settings-roles">
916
+ <table>
917
+ <tr>
918
+ <?php if ( ! isset( $wp_roles ) ) : ?>
919
+ <?php $wp_roles = new WP_Roles(); ?>
920
+ <?php endif; ?>
921
+ <?php $i = 0; ?>
922
+ <?php foreach ( $wp_roles->role_names as $role => $name ) : ?>
923
+ <?php if ( 'subscriber' != $role ) : ?>
924
+ <?php $i++; ?>
925
+ <td>
926
+ <label>
927
+ <input type="checkbox" name="options[ga_track_exclude][]" value="<?php echo $role; ?>" <?php if (in_array($role,$options['ga_track_exclude'])) echo 'checked="checked"'; ?> /> <?php echo $name; ?>
928
+ </label>
929
+ </td>
930
+ <?php endif; ?>
931
+ <?php if ( 0 == $i % 4 ) : ?>
932
+ </tr>
933
+ <tr>
934
+ <?php endif; ?>
935
+ <?php endforeach; ?>
936
+ </table>
937
+ </td>
938
+ </tr>
939
+ </table>
940
+ </div>
941
+ <table class="gadwp-settings-options">
942
+ <tr>
943
+ <td colspan="2">
944
+ <hr>
945
+ </td>
946
+ </tr>
947
+ <tr>
948
+ <td colspan="2" class="submit">
949
+ <input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" />
950
+ </td>
951
+ </tr>
952
+ </table>
953
+ <input type="hidden" name="options[ga_dash_hidden]" value="Y">
954
  <?php wp_nonce_field('gadash_form','gadash_security'); ?>
955
  </form>
956
  <?php
984
  }
985
  ?>
986
  <div class="wrap">
987
+ <?php echo "<h2>" . __( "Google Analytics Errors & Debugging", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
988
+ </div>
989
  <div id="poststuff" class="gadwp">
990
+ <div id="post-body" class="metabox-holder columns-2">
991
+ <div id="post-body-content">
992
+ <div class="settings-wrapper">
993
+ <div class="inside">
994
+ <?php if (isset($message)) echo $message; ?>
995
+ <?php $tabs = array( 'errors' => __( "Errors & Details", 'google-analytics-dashboard-for-wp' ), 'config' => __( "Plugin Settings", 'google-analytics-dashboard-for-wp' ) ); ?>
996
+ <?php self::navigation_tabs( $tabs ); ?>
 
 
997
  <div id="gadwp-errors">
998
+ <table class="gadwp-settings-options">
999
+ <tr>
1000
+ <td>
1001
+ <?php echo "<h2>" . __( "Last Error detected", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1002
+ </td>
1003
+ </tr>
1004
+ <tr>
1005
+ <td>
1006
+ <?php $errors = print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ? esc_html( print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) : __( "None", 'google-analytics-dashboard-for-wp' ); ?>
1007
+ <pre class="gadwp-settings-logdata"><?php echo __("Last Error: ", 'google-analytics-dashboard-for-wp') . $errors;?></pre>
1008
+ </td>
1009
+ </tr>
1010
+ <tr>
1011
+ <td colspan="2">
1012
+ <hr><?php echo "<h2>" . __( "Error Details", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1013
+ </tr>
1014
+ <tr>
1015
+ <td>
1016
+ <pre class="gadwp-settings-logdata"><?php _e("Error Details: ", 'google-analytics-dashboard-for-wp'); $error_details = print_r( GADWP_Tools::get_cache( 'gapi_errors' ), true ) ? "\n" . esc_html( print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) : __( "None", 'google-analytics-dashboard-for-wp' ); echo $error_details; ?></pre>
1017
+ <br />
1018
+ <hr>
1019
+ </td>
1020
+ </tr>
1021
+ <tr>
1022
+ <td>
1023
+ <?php echo "<h2>" . __( "Sampled Data", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1024
+ </td>
1025
+ </tr>
1026
+ <tr>
1027
+ <td>
1028
+ <?php $sampling = GADWP_TOOLS::get_cache( 'sampleddata' ); ?>
1029
+ <?php if ( $sampling ) :?>
1030
+ <?php printf( __( "Last Detected on %s.", 'google-analytics-dashboard-for-wp' ), '<strong>'. $sampling['date'] . '</strong>' );?>
1031
+ <br />
1032
+ <?php printf( __( "The report was based on %s of sessions.", 'google-analytics-dashboard-for-wp' ), '<strong>'. $sampling['percent'] . '</strong>' );?>
1033
+ <br />
1034
+ <?php printf( __( "Sessions ratio: %s.", 'google-analytics-dashboard-for-wp' ), '<strong>'. $sampling['sessions'] . '</strong>' ); ?>
1035
+ <?php else :?>
1036
+ <?php _e( "None", 'google-analytics-dashboard-for-wp' ); ?>
1037
+ <?php endif;?>
1038
+ </td>
1039
+ </tr>
1040
+ </table>
1041
+ </div>
1042
+ <div id="gadwp-config">
1043
+ <table class="gadwp-settings-options">
1044
+ <tr>
1045
+ <td><?php echo "<h2>" . __( "Plugin Configuration", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1046
+ </tr>
1047
+ <tr>
1048
+ <td>
1049
+ <pre class="gadwp-settings-logdata"><?php echo esc_html(print_r($anonim, true));?></pre>
1050
+ <br />
1051
+ <hr>
1052
+ </td>
1053
+ </tr>
1054
+ </table>
1055
+ </div>
1056
+ <?php
1057
  self::output_sidebar();
1058
  }
1059
 
1072
  }
1073
  echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
1074
  if ( isset( $_POST['ga_dash_code'] ) ) {
1075
+ if ( 1 == ! stripos( 'x' . $_POST['ga_dash_code'], 'UA-', 1 ) ) {
1076
  try {
1077
  $gadwp->gapi_controller->client->authenticate( $_POST['ga_dash_code'] );
1078
  $gadwp->config->options['ga_dash_token'] = $gadwp->gapi_controller->client->getAccessToken();
1079
  $gadwp->config->options['automatic_updates_minorversion'] = 1;
1080
  $gadwp->config->set_plugin_options();
1081
  $options = self::update_options( 'general' );
1082
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1083
  GADWP_Tools::delete_cache( 'gapi_errors' );
1084
  GADWP_Tools::delete_cache( 'last_error' );
1085
  if ( $gadwp->config->options['ga_dash_token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1111
  $gadwp->gapi_controller->reset_token( false );
1112
  }
1113
  } else {
1114
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
1115
  }
1116
  }
1117
  if ( isset( $_POST['Clear'] ) ) {
1118
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1119
  GADWP_Tools::clear_cache();
1120
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Cleared Cache.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1121
  } else {
1122
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1123
  }
1124
  }
1125
  if ( isset( $_POST['Reset'] ) ) {
1126
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1127
  $gadwp->gapi_controller->reset_token( true );
1128
  GADWP_Tools::clear_cache();
1129
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Token Reseted and Revoked.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1130
  $options = self::update_options( 'Reset' );
1131
  } else {
1132
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1133
  }
1134
  }
1135
  if ( isset( $_POST['Reset_Err'] ) ) {
1136
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1137
  GADWP_Tools::delete_cache( 'last_error' );
1138
  GADWP_Tools::delete_cache( 'gapi_errors' );
1139
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "All errors reseted.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1140
  } else {
1141
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1142
  }
1143
  }
1144
  if ( isset( $_POST['options']['ga_dash_hidden'] ) && ! isset( $_POST['Clear'] ) && ! isset( $_POST['Reset'] ) && ! isset( $_POST['Reset_Err'] ) ) {
1145
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1146
  if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
1147
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1148
  }
1149
  }
1150
  if ( isset( $_POST['Hide'] ) ) {
1151
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1152
+ $message = "<div class='updated' id='gadwp-action'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1153
  $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] );
1154
  $gadwp->config->options['ga_dash_profile_list'] = array( $lock_profile );
1155
  $options = self::update_options( 'general' );
1156
  } else {
1157
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1158
  }
1159
  }
1160
  ?>
1161
+ <div class="wrap">
1162
  <?php echo "<h2>" . __( "Google Analytics Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1163
+ <hr>
1164
+ </div>
1165
+ <div id="poststuff" class="gadwp">
1166
+ <div id="post-body" class="metabox-holder columns-2">
1167
+ <div id="post-body-content">
1168
+ <div class="settings-wrapper">
1169
+ <div class="inside">
1170
+ <?php if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) : ?>
1171
+ <?php $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );?>
1172
+ <?php endif;?>
1173
+ <?php if ( isset( $_POST['Authorize'] ) ) : ?>
1174
+ <?php GADWP_Tools::clear_cache(); ?>
1175
+ <?php $gadwp->gapi_controller->token_request(); ?>
1176
+ <div class="updated">
1177
+ <p><?php _e( "Use the red link (see below) to generate and get your access code!", 'google-analytics-dashboard-for-wp' )?></p>
1178
+ </div>
1179
+ <?php else : ?>
1180
+ <?php if ( isset( $message ) ) :?>
1181
+ <?php echo $message;?>
1182
+ <?php endif; ?>
1183
+ <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
1184
+ <input type="hidden" name="options[ga_dash_hidden]" value="Y">
1185
+ <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1186
+ <table class="gadwp-settings-options">
1187
+ <tr>
1188
+ <td colspan="2">
1189
+ <?php echo "<h2>" . __( "Plugin Authorization", 'google-analytics-dashboard-for-wp' ) . "</h2>";?>
1190
+ </td>
1191
+ </tr>
1192
+ <tr>
1193
+ <td colspan="2" class="gadwp-settings-info">
1194
+ <?php printf(__('You should watch the %1$s and read this %2$s before proceeding to authorization. This plugin requires a properly configured Google Analytics account!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_video&utm_campaign=gadwp', __("video", 'google-analytics-dashboard-for-wp')), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_tutorial&utm_campaign=gadwp', __("tutorial", 'google-analytics-dashboard-for-wp')));?>
1195
+ </td>
1196
+ </tr>
1197
+ <?php if (! $options['ga_dash_token'] || $options['ga_dash_userapi']) : ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1198
  <tr>
1199
+ <td colspan="2" class="gadwp-settings-info">
1200
+ <input name="options[ga_dash_userapi]" type="checkbox" id="ga_dash_userapi" value="1" <?php checked( $options['ga_dash_userapi'], 1 ); ?> onchange="this.form.submit()" <?php echo ($options['ga_dash_network'])?'disabled="disabled"':''; ?> /><?php echo " ".__("developer mode (requires advanced API knowledge)", 'google-analytics-dashboard-for-wp' );?>
1201
+ </td>
1202
+ </tr>
1203
+ <?php endif; ?>
1204
+ <?php if ($options['ga_dash_userapi']) : ?>
1205
+ <tr>
1206
+ <td class="gadwp-settings-title">
1207
+ <label for="options[ga_dash_clientid]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?></label>
1208
+ </td>
1209
+ <td>
1210
+ <input type="text" name="options[ga_dash_clientid]" value="<?php echo esc_attr($options['ga_dash_clientid']); ?>" size="40" required="required">
1211
+ </td>
1212
+ </tr>
1213
+ <tr>
1214
+ <td class="gadwp-settings-title">
1215
+ <label for="options[ga_dash_clientsecret]"><?php _e("Client Secret:", 'google-analytics-dashboard-for-wp'); ?></label>
1216
+ </td>
1217
+ <td>
1218
+ <input type="text" name="options[ga_dash_clientsecret]" value="<?php echo esc_attr($options['ga_dash_clientsecret']); ?>" size="40" required="required">
1219
+ <input type="hidden" name="options[ga_dash_hidden]" value="Y">
1220
+ <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1221
+ </td>
1222
+ </tr>
1223
+ <?php endif; ?>
1224
+ <?php if ( $options['ga_dash_token'] ) : ?>
1225
+ <tr>
1226
+ <td colspan="2">
1227
+ <input type="submit" name="Reset" class="button button-secondary" value="<?php _e( "Clear Authorization", 'google-analytics-dashboard-for-wp' ); ?>" <?php echo $options['ga_dash_network']?'disabled="disabled"':''; ?> />
1228
+ <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1229
+ <input type="submit" name="Reset_Err" class="button button-secondary" value="<?php _e( "Reset Errors", 'google-analytics-dashboard-for-wp' ); ?>" />
1230
+ </td>
1231
+ </tr>
1232
+ <tr>
1233
+ <td colspan="2">
1234
+ <hr>
1235
+ </td>
1236
+ </tr>
1237
+ <tr>
1238
+ <td colspan="2"><?php echo "<h2>" . __( "General Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1239
+ </tr>
1240
+ <tr>
1241
+ <td class="gadwp-settings-title">
1242
+ <label for="ga_dash_tableid_jail"><?php _e("Select View:", 'google-analytics-dashboard-for-wp' ); ?></label>
1243
+ </td>
1244
+ <td>
1245
+ <select id="ga_dash_tableid_jail" <?php disabled(empty($options['ga_dash_profile_list']) || 1 == count($options['ga_dash_profile_list']), true); ?> name="options[ga_dash_tableid_jail]">
1246
+ <?php if ( ! empty( $options['ga_dash_profile_list'] ) ) : ?>
1247
+ <?php foreach ( $options['ga_dash_profile_list'] as $items ) : ?>
1248
+ <?php if ( $items[3] ) : ?>
1249
+ <option value="<?php echo esc_attr( $items[1] ); ?>" <?php selected( $items[1], $options['ga_dash_tableid_jail'] ); ?> title="<?php _e( "View Name:", 'google-analytics-dashboard-for-wp' ); ?> <?php echo esc_attr( $items[0] ); ?>">
1250
+ <?php echo esc_html( GADWP_Tools::strip_protocol( $items[3] ) )?> &#8658; <?php echo esc_attr( $items[0] ); ?>
1251
+ </option>
1252
+ <?php endif; ?>
1253
+ <?php endforeach; ?>
1254
+ <?php else : ?>
1255
+ <option value=""><?php _e( "Property not found", 'google-analytics-dashboard-for-wp' ); ?></option>
1256
+ <?php endif; ?>
1257
+ </select>
1258
+ <?php if ( count( $options['ga_dash_profile_list'] ) > 1 ) : ?>
1259
+ &nbsp;<input type="submit" name="Hide" class="button button-secondary" value="<?php _e( "Lock Selection", 'google-analytics-dashboard-for-wp' ); ?>" />
1260
+ <?php endif; ?>
1261
+ </td>
1262
+ </tr>
1263
+ <?php if ( $options['ga_dash_tableid_jail'] ) : ?>
1264
+ <tr>
1265
+ <td class="gadwp-settings-title"></td>
1266
+ <td>
1267
+ <?php $profile_info = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] ); ?>
1268
+ <pre><?php echo __( "View Name:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[0] ) . "<br />" . __( "Tracking ID:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[2] ) . "<br />" . __( "Default URL:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[3] ) . "<br />" . __( "Time Zone:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[5] );?></pre>
1269
+ </td>
1270
+ </tr>
1271
+ <?php endif; ?>
1272
+ <tr>
1273
+ <td class="gadwp-settings-title">
1274
+ <label for="ga_dash_style"><?php _e("Theme Color:", 'google-analytics-dashboard-for-wp' ); ?></label>
1275
+ </td>
1276
+ <td>
1277
+ <input type="text" id="ga_dash_style" class="ga_dash_style" name="options[ga_dash_style]" value="<?php echo esc_attr($options['ga_dash_style']); ?>" size="10">
1278
+ </td>
1279
+ </tr>
1280
+ <tr>
1281
+ <td colspan="2">
1282
+ <hr>
1283
+ </td>
1284
+ </tr>
1285
+ <?php if ( !is_multisite()) :?>
1286
+ <tr>
1287
+ <td colspan="2"><?php echo "<h2>" . __( "Automatic Updates", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1288
+ </tr>
1289
+ <tr>
1290
+ <td colspan="2" class="gadwp-settings-title">
1291
+ <div class="button-primary gadwp-settings-switchoo">
1292
+ <input type="checkbox" name="options[automatic_updates_minorversion]" value="1" class="gadwp-settings-switchoo-checkbox" id="automatic_updates_minorversion" <?php checked( $options['automatic_updates_minorversion'], 1 ); ?>>
1293
+ <label class="gadwp-settings-switchoo-label" for="automatic_updates_minorversion">
1294
+ <div class="gadwp-settings-switchoo-inner"></div>
1295
+ <div class="gadwp-settings-switchoo-switch"></div>
1296
+ </label>
1297
+ </div>
1298
+ <div class="switch-desc"><?php echo " ".__( "automatic updates for minor versions (security and maintenance releases only)", 'google-analytics-dashboard-for-wp' );?></div>
1299
+ </td>
1300
+ </tr>
1301
+ <tr>
1302
+ <td colspan="2">
1303
+ <hr>
1304
+ </td>
1305
+ </tr>
1306
+ <?php endif; ?>
1307
+ <tr>
1308
+ <td colspan="2" class="submit">
1309
+ <input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" />
1310
+ </td>
1311
+ </tr>
1312
+ <?php else : ?>
1313
+ <tr>
1314
+ <td colspan="2">
1315
+ <hr>
1316
+ </td>
1317
+ </tr>
1318
+ <tr>
1319
+ <td colspan="2">
1320
+ <input type="submit" name="Authorize" class="button button-secondary" id="authorize" value="<?php _e( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ); ?>" <?php echo $options['ga_dash_network']?'disabled="disabled"':''; ?> />
1321
+ <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1322
+ </td>
1323
+ </tr>
1324
+ <tr>
1325
+ <td colspan="2">
1326
+ <hr>
1327
+ </td>
1328
+ </tr>
1329
+ </table>
1330
+ </form>
1331
+ <?php self::output_sidebar(); ?>
1332
+ <?php return; ?>
1333
+ <?php endif; ?>
1334
+ </table>
1335
+ </form>
1336
+ <?php endif; ?>
1337
  <?php
1338
+
 
 
 
 
 
 
 
1339
  self::output_sidebar();
1340
  }
1341
+
1342
  // Network Settings
1343
  public static function general_settings_network() {
1344
  $gadwp = GADWP();
1359
 
1360
  echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
1361
  if ( isset( $_POST['ga_dash_code'] ) ) {
1362
+ if ( 1 == ! stripos( 'x' . $_POST['ga_dash_code'], 'UA-', 1 ) ) {
1363
  try {
1364
  $gadwp->gapi_controller->client->authenticate( $_POST['ga_dash_code'] );
1365
  $gadwp->config->options['ga_dash_token'] = $gadwp->gapi_controller->client->getAccessToken();
1366
  $gadwp->config->options['automatic_updates_minorversion'] = 1;
1367
  $gadwp->config->set_plugin_options( true );
1368
  $options = self::update_options( 'network' );
1369
+ $message = "<div class='updated' id='gadwp-action'><p>" . __( "Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1370
  if ( is_multisite() ) { // Cleanup errors on the entire network
1371
  foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
1372
  switch_to_blog( $blog['blog_id'] );
1405
  $gadwp->gapi_controller->reset_token( false );
1406
  }
1407
  } else {
1408
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
1409
  }
1410
  }
1411
  if ( isset( $_POST['Refresh'] ) ) {
1412
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1413
  $gadwp->config->options['ga_dash_profile_list'] = array();
1414
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Properties refreshed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1415
  $options = self::update_options( 'network' );
1416
  if ( $gadwp->config->options['ga_dash_token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1417
  if ( ! empty( $gadwp->config->options['ga_dash_profile_list'] ) ) {
1431
  }
1432
  }
1433
  } else {
1434
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1435
  }
1436
  }
1437
  if ( isset( $_POST['Clear'] ) ) {
1438
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1439
  GADWP_Tools::clear_cache();
1440
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Cleared Cache.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1441
  } else {
1442
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1443
  }
1444
  }
1445
  if ( isset( $_POST['Reset'] ) ) {
1446
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1447
  $gadwp->gapi_controller->reset_token( true );
1448
  GADWP_Tools::clear_cache();
1449
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Token Reseted and Revoked.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1450
  $options = self::update_options( 'Reset' );
1451
  } else {
1452
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1453
  }
1454
  }
1455
  if ( isset( $_POST['options']['ga_dash_hidden'] ) && ! isset( $_POST['Clear'] ) && ! isset( $_POST['Reset'] ) && ! isset( $_POST['Refresh'] ) ) {
1456
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1457
  if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
1458
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1459
  }
1460
  }
1461
  if ( isset( $_POST['Hide'] ) ) {
1462
  if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1463
+ $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1464
  $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] );
1465
  $gadwp->config->options['ga_dash_profile_list'] = array( $lock_profile );
1466
  $options = self::update_options( 'network' );
1467
  } else {
1468
+ $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1469
  }
1470
  }
1471
  ?>
1472
+ <div class="wrap">
1473
+ <h2><?php _e( "Google Analytics Settings", 'google-analytics-dashboard-for-wp' );?></h2>
1474
+ <hr>
1475
+ </div>
1476
+ <div id="poststuff" class="gadwp">
1477
+ <div id="post-body" class="metabox-holder columns-2">
1478
+ <div id="post-body-content">
1479
+ <div class="settings-wrapper">
1480
+ <div class="inside">
1481
+ <?php if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) : ?>
1482
+ <?php $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );?>
1483
+ <?php endif; ?>
1484
+ <?php if ( isset( $_POST['Authorize'] ) ) : ?>
1485
+ <?php GADWP_Tools::clear_cache();?>
1486
+ <?php $gadwp->gapi_controller->token_request();?>
1487
+ <div class="updated">
1488
+ <p><?php _e( "Use the red link (see below) to generate and get your access code!", 'google-analytics-dashboard-for-wp' );?></p>
1489
+ </div>
1490
+ <?php else : ?>
1491
+ <?php if ( isset( $message ) ) : ?>
1492
+ <?php echo $message; ?>
1493
+ <?php endif; ?>
1494
+ <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
1495
+ <input type="hidden" name="options[ga_dash_hidden]" value="Y">
1496
+ <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1497
+ <table class="gadwp-settings-options">
1498
+ <tr>
1499
+ <td colspan="2">
1500
+ <?php echo "<h2>" . __( "Network Setup", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1501
+ </td>
1502
+ </tr>
1503
+ <tr>
1504
+ <td colspan="2" class="gadwp-settings-title">
1505
+ <div class="button-primary gadwp-settings-switchoo">
1506
+ <input type="checkbox" name="options[ga_dash_network]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_network" <?php checked( $options['ga_dash_network'], 1); ?> onchange="this.form.submit()">
1507
+ <label class="gadwp-settings-switchoo-label" for="ga_dash_network">
1508
+ <div class="gadwp-settings-switchoo-inner"></div>
1509
+ <div class="gadwp-settings-switchoo-switch"></div>
1510
+ </label>
1511
+ </div>
1512
+ <div class="switch-desc"><?php echo " ".__("use a single Google Analytics account for the entire network", 'google-analytics-dashboard-for-wp' );?></div>
1513
+ </td>
1514
+ </tr>
1515
+ <?php if ($options['ga_dash_network']) : ?>
1516
+ <tr>
1517
+ <td colspan="2">
1518
+ <hr>
1519
+ </td>
1520
+ </tr>
1521
+ <tr>
1522
+ <td colspan="2"><?php echo "<h2>" . __( "Plugin Authorization", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1523
+ </tr>
1524
+ <tr>
1525
+ <td colspan="2" class="gadwp-settings-info">
1526
+ <?php printf(__('You should watch the %1$s and read this %2$s before proceeding to authorization. This plugin requires a properly configured Google Analytics account!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_video&utm_campaign=gadwp', __("video", 'google-analytics-dashboard-for-wp')), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_tutorial&utm_campaign=gadwp', __("tutorial", 'google-analytics-dashboard-for-wp')));?>
1527
+ </td>
1528
+ </tr>
1529
+ <?php if ( ! $options['ga_dash_token'] || $options['ga_dash_userapi'] ) : ?>
1530
  <tr>
1531
+ <td colspan="2" class="gadwp-settings-info">
1532
+ <input name="options[ga_dash_userapi]" type="checkbox" id="ga_dash_userapi" value="1" <?php checked( $options['ga_dash_userapi'], 1 ); ?> onchange="this.form.submit()" /><?php echo " ".__("developer mode (requires advanced API knowledge)", 'google-analytics-dashboard-for-wp' );?>
1533
+ </td>
1534
+ </tr>
1535
+ <?php endif; ?>
1536
+ <?php if ( $options['ga_dash_userapi'] ) : ?>
1537
+ <tr>
1538
+ <td class="gadwp-settings-title">
1539
+ <label for="options[ga_dash_clientid]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?>
1540
+ </label>
1541
+ </td>
1542
+ <td>
1543
+ <input type="text" name="options[ga_dash_clientid]" value="<?php echo esc_attr($options['ga_dash_clientid']); ?>" size="40" required="required">
1544
+ </td>
1545
+ </tr>
1546
+ <tr>
1547
+ <td class="gadwp-settings-title">
1548
+ <label for="options[ga_dash_clientsecret]"><?php _e("Client Secret:", 'google-analytics-dashboard-for-wp'); ?>
1549
+ </label>
1550
+ </td>
1551
+ <td>
1552
+ <input type="text" name="options[ga_dash_clientsecret]" value="<?php echo esc_attr($options['ga_dash_clientsecret']); ?>" size="40" required="required">
1553
+ <input type="hidden" name="options[ga_dash_hidden]" value="Y">
1554
+ <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1555
+ </td>
1556
+ </tr>
1557
+ <?php endif; ?>
1558
+ <?php if ( $options['ga_dash_token'] ) : ?>
1559
+ <tr>
1560
+ <td colspan="2">
1561
+ <input type="submit" name="Reset" class="button button-secondary" value="<?php _e( "Clear Authorization", 'google-analytics-dashboard-for-wp' ); ?>" />
1562
+ <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1563
+ <input type="submit" name="Refresh" class="button button-secondary" value="<?php _e( "Refresh Properties", 'google-analytics-dashboard-for-wp' ); ?>" />
1564
+ </td>
1565
+ </tr>
1566
+ <tr>
1567
+ <td colspan="2">
1568
+ <hr>
1569
+ </td>
1570
+ </tr>
1571
+ <tr>
1572
+ <td colspan="2">
1573
+ <?php echo "<h2>" . __( "Properties/Views Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1574
+ </td>
1575
+ </tr>
1576
+ <?php if ( isset( $options['ga_dash_tableid_network'] ) ) : ?>
1577
+ <?php $options['ga_dash_tableid_network'] = json_decode( json_encode( $options['ga_dash_tableid_network'] ), false ); ?>
1578
+ <?php endif; ?>
1579
+ <?php foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) : ?>
1580
+ <tr>
1581
+ <td class="gadwp-settings-title-s">
1582
+ <label for="ga_dash_tableid_network"><?php echo '<strong>'.$blog['domain'].$blog['path'].'</strong>: ';?></label>
1583
+ </td>
1584
+ <td>
1585
+ <select id="ga_dash_tableid_network" <?php disabled(!empty($options['ga_dash_profile_list']),false);?> name="options[ga_dash_tableid_network][<?php echo $blog['blog_id'];?>]">
1586
+ <?php if ( ! empty( $options['ga_dash_profile_list'] ) ) : ?>
1587
+ <?php foreach ( $options['ga_dash_profile_list'] as $items ) : ?>
1588
+ <?php if ( $items[3] ) : ?>
1589
+ <?php $temp_id = $blog['blog_id']; ?>
1590
+ <option value="<?php echo esc_attr( $items[1] );?>" <?php selected( $items[1], isset( $options['ga_dash_tableid_network']->$temp_id ) ? $options['ga_dash_tableid_network']->$temp_id : '');?> title="<?php echo __( "View Name:", 'google-analytics-dashboard-for-wp' ) . ' ' . esc_attr( $items[0] );?>">
1591
+ <?php echo esc_html( GADWP_Tools::strip_protocol( $items[3] ) );?> &#8658; <?php echo esc_attr( $items[0] );?>
1592
+ </option>
1593
+ <?php endif; ?>
1594
+ <?php endforeach; ?>
1595
+ <?php else : ?>
1596
+ <option value="">
1597
+ <?php _e( "Property not found", 'google-analytics-dashboard-for-wp' );?>
1598
+ </option>
1599
+ <?php endif; ?>
1600
+ </select>
1601
+ <br />
1602
+ </td>
1603
+ </tr>
1604
+ <?php endforeach; ?>
1605
+ <tr>
1606
+ <td colspan="2">
1607
+ <h2><?php echo _e( "Automatic Updates", 'google-analytics-dashboard-for-wp' );?></h2>
1608
+ </td>
1609
+ </tr>
1610
+ <tr>
1611
+ <td colspan="2" class="gadwp-settings-title">
1612
+ <div class="button-primary gadwp-settings-switchoo">
1613
+ <input type="checkbox" name="options[automatic_updates_minorversion]" value="1" class="gadwp-settings-switchoo-checkbox" id="automatic_updates_minorversion" <?php checked( $options['automatic_updates_minorversion'], 1 ); ?>>
1614
+ <label class="gadwp-settings-switchoo-label" for="automatic_updates_minorversion">
1615
+ <div class="gadwp-settings-switchoo-inner"></div>
1616
+ <div class="gadwp-settings-switchoo-switch"></div>
1617
+ </label>
1618
+ </div>
1619
+ <div class="switch-desc"><?php echo " ".__( "automatic updates for minor versions (security and maintenance releases only)", 'google-analytics-dashboard-for-wp' );?></div>
1620
+ </td>
1621
+ </tr>
1622
+ <tr>
1623
+ <td colspan="2">
1624
+ <hr><?php echo "<h2>" . __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1625
+ </tr>
1626
+ <tr>
1627
+ <td colspan="2" class="gadwp-settings-title">
1628
+ <div class="button-primary gadwp-settings-switchoo">
1629
+ <input type="checkbox" name="options[ga_dash_excludesa]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_excludesa"<?php checked( $options['ga_dash_excludesa'], 1); ?>">
1630
+ <label class="gadwp-settings-switchoo-label" for="ga_dash_excludesa">
1631
+ <div class="gadwp-settings-switchoo-inner"></div>
1632
+ <div class="gadwp-settings-switchoo-switch"></div>
1633
+ </label>
1634
+ </div>
1635
+ <div class="switch-desc"><?php echo " ".__("exclude Super Admin tracking for the entire network", 'google-analytics-dashboard-for-wp' );?></div>
1636
+ </td>
1637
+ </tr>
1638
+ <tr>
1639
+ <td colspan="2">
1640
+ <hr>
1641
+ </td>
1642
+ </tr>
1643
+ <tr>
1644
+ <td colspan="2" class="submit">
1645
+ <input type="submit" name="Submit" class="button button-primary" value="<?php _e('Save Changes', 'google-analytics-dashboard-for-wp' ) ?>" />
1646
+ </td>
1647
+ </tr>
1648
+ <?php else : ?>
1649
+ <tr>
1650
+ <td colspan="2">
1651
+ <hr>
1652
+ </td>
1653
+ </tr>
1654
+ <tr>
1655
+ <td colspan="2">
1656
+ <input type="submit" name="Authorize" class="button button-secondary" id="authorize" value="<?php _e( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ); ?>" />
1657
+ <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1658
+ </td>
1659
+ </tr>
1660
+ <?php endif; ?>
1661
+ <tr>
1662
+ <td colspan="2">
1663
+ <hr>
1664
+ </td>
1665
+ </tr>
1666
+ </table>
1667
+ </form>
1668
+ <?php self::output_sidebar(); ?>
1669
+ <?php return; ?>
1670
+ <?php endif;?>
1671
  </table>
1672
+ </form>
1673
+ <?php endif; ?>
1674
+ <?php
1675
+
1676
  self::output_sidebar();
1677
  }
1678
 
1681
 
1682
  $gadwp = GADWP();
1683
  ?>
1684
+ </div>
1685
+ </div>
1686
+ </div>
1687
+ <div id="postbox-container-1" class="postbox-container">
1688
+ <div class="meta-box-sortables">
1689
+ <div class="postbox">
1690
+ <h3>
1691
+ <span><?php _e("Setup Tutorial & Demo",'google-analytics-dashboard-for-wp') ?></span>
1692
+ </h3>
1693
+ <div class="inside">
1694
+ <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=video&utm_campaign=gadwp" target="_blank"><img src="<?php echo plugins_url( 'images/google-analytics-dashboard.png' , __FILE__ );?>" width="100%" alt="" /></a>
1695
+ </div>
1696
+ </div>
1697
+ <div class="postbox">
1698
+ <h3>
1699
+ <span><?php _e("Follow & Review",'google-analytics-dashboard-for-wp')?></span>
1700
+ </h3>
1701
+ <div class="inside">
1702
+ <div class="gadash-desc">
1703
+ <div style="margin-left: -10px;">
1704
+ <div class="g-page" data-width="273" data-href="//plus.google.com/+Deconfcom" data-layout="landscape" data-showtagline="false" data-showcoverphoto="false" data-rel="publisher"></div>
1705
+ </div>
1706
+ <script type="text/javascript">
1707
  (function() {
1708
+ var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
1709
+ po.src = 'https://apis.google.com/js/platform.js';
1710
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
1711
  })();
1712
  </script>
1713
+ </div>
1714
+ <br />
1715
+ <div class="gadash-desc">
1716
+ <a href="https://twitter.com/deconfcom" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @deconfcom</a>
1717
+ <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
1718
+ </div>
1719
+ <br />
1720
+ <div class="gadash-title">
1721
+ <a href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info"><img src="<?php echo plugins_url( 'images/star.png' , __FILE__ ); ?>" /></a>
1722
+ </div>
1723
+ <div class="gadash-desc">
1724
+ <?php printf(__('Your feedback and review are both important, %s!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info">%s</a>', __('rate this plugin', 'google-analytics-dashboard-for-wp')));?>
1725
+ </div>
1726
+ </div>
1727
+ </div>
1728
+ <div class="postbox">
1729
+ <h3>
1730
+ <span><?php _e("Further Reading",'google-analytics-dashboard-for-wp')?></span>
1731
+ </h3>
1732
+ <div class="inside">
1733
+ <div class="gadash-title">
1734
+ <a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/clicky.png' , __FILE__ ); ?>" /></a>
1735
+ </div>
1736
+ <div class="gadash-desc">
1737
+ <?php printf(__('%s service with users tracking at IP level.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp">%s</a>', __('Web Analytics', 'google-analytics-dashboard-for-wp')));?>
1738
+ </div>
1739
+ <br />
1740
+ <div class="gadash-title">
1741
+ <a href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/ssl.png' , __FILE__ ); ?>" /></a>
1742
+ </div>
1743
+ <div class="gadash-desc">
1744
+ <?php printf(__('%s by moving your website to HTTPS/SSL.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp">%s</a>', __('Improve search rankings', 'google-analytics-dashboard-for-wp')));?>
1745
+ </div>
1746
+ <br />
1747
+ <div class="gadash-title">
1748
+ <a href="https://deconf.com/wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=plugins&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/wp.png' , __FILE__ ); ?>" /></a>
1749
+ </div>
1750
+ <div class="gadash-desc">
1751
+ <?php printf(__('Other %s written by the same author', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=plugins&utm_campaign=gadwp">%s</a>', __('WordPress Plugins', 'google-analytics-dashboard-for-wp')));?>
1752
+ </div>
1753
+ </div>
1754
+ </div>
1755
+ </div>
1756
+ </div>
1757
+ </div>
1758
+ </div>
1759
  <?php
1760
+ // Dismiss the admin update notice
1761
+ if ( version_compare( $wp_version, '4.2', '<' ) && current_user_can( 'manage_options' ) ) {
1762
+ delete_option( 'gadwp_got_updated' );
1763
  }
1764
  }
1765
  }
admin/setup.php CHANGED
@@ -146,7 +146,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
146
 
147
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
148
 
149
- wp_enqueue_script( 'gadwp-backend-dashboard-reports', GADWP_URL . 'common/js/reports.js', array( 'jquery', 'googlecharts', 'gadwp-nprogress', 'jquery-ui-tooltip', 'jquery-ui-core', 'jquery-ui-position', 'jquery-ui-tooltip-html' ), GADWP_CURRENT_VERSION, true );
150
 
151
  /* @formatter:off */
152
  wp_localize_script( 'gadwp-backend-dashboard-reports', 'gadwpItemData', array(
@@ -249,7 +249,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
249
 
250
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
251
 
252
- wp_enqueue_script( 'gadwp-backend-item-reports', GADWP_URL . 'common/js/reports.js', array( 'gadwp-nprogress', 'googlecharts', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION, true );
253
 
254
  /* @formatter:off */
255
  wp_localize_script( 'gadwp-backend-item-reports', 'gadwpItemData', array(
@@ -352,7 +352,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
352
  function admin_notice() {
353
  $currentScreen = get_current_screen();
354
 
355
- if ( ! current_user_can( 'manage_options' ) || $currentScreen->base != 'dashboard' ) {
356
  return;
357
  }
358
 
146
 
147
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
148
 
149
+ wp_enqueue_script( 'gadwp-backend-dashboard-reports', GADWP_URL . 'common/js/reports5.js', array( 'jquery', 'googlecharts', 'gadwp-nprogress', 'jquery-ui-tooltip', 'jquery-ui-core', 'jquery-ui-position', 'jquery-ui-tooltip-html' ), GADWP_CURRENT_VERSION, true );
150
 
151
  /* @formatter:off */
152
  wp_localize_script( 'gadwp-backend-dashboard-reports', 'gadwpItemData', array(
249
 
250
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
251
 
252
+ wp_enqueue_script( 'gadwp-backend-item-reports', GADWP_URL . 'common/js/reports5.js', array( 'gadwp-nprogress', 'googlecharts', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION, true );
253
 
254
  /* @formatter:off */
255
  wp_localize_script( 'gadwp-backend-item-reports', 'gadwpItemData', array(
352
  function admin_notice() {
353
  $currentScreen = get_current_screen();
354
 
355
+ if ( ! current_user_can( 'manage_options' ) || 'dashboard' != $currentScreen->base ) {
356
  return;
357
  }
358
 
common/js/reports.js DELETED
@@ -1,1118 +0,0 @@
1
- /*-
2
- * Author: Alin Marcu
3
- * Author URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- "use strict";
10
-
11
- if ( gadwpItemData.mapsApiKey ) {
12
- google.charts.load('current', {mapsApiKey: gadwpItemData.mapsApiKey, 'packages':['corechart', 'table', 'orgchart', 'geochart']});
13
- } else {
14
- google.charts.load('current', {'packages':['corechart', 'table', 'orgchart', 'geochart']});
15
- }
16
-
17
- google.charts.setOnLoadCallback( GADWPReportLoad );
18
-
19
- // Get the numeric ID
20
- gadwpItemData.getID = function ( item ) {
21
- if ( gadwpItemData.scope == 'admin-item' ) {
22
- if ( typeof item.id == "undefined" ) {
23
- return 0
24
- }
25
- if ( item.id.split( '-' )[ 1 ] == "undefined" ) {
26
- return 0;
27
- } else {
28
- return item.id.split( '-' )[ 1 ];
29
- }
30
- } else {
31
- if ( typeof item.id == "undefined" ) {
32
- return 1;
33
- }
34
- if ( item.id.split( '-' )[ 4 ] == "undefined" ) {
35
- return 1;
36
- } else {
37
- return item.id.split( '-' )[ 4 ];
38
- }
39
- }
40
- }
41
-
42
- // Get the selector
43
- gadwpItemData.getSelector = function ( scope ) {
44
- if ( scope == 'admin-item' ) {
45
- return 'a[id^="gadwp-"]';
46
- } else {
47
- return 'li[id^="wp-admin-bar-gadwp"]';
48
- }
49
- }
50
-
51
- gadwpItemData.responsiveDialog = function () {
52
- var dialog, wWidth, visible;
53
-
54
- visible = jQuery( ".ui-dialog:visible" );
55
-
56
- // on each visible dialog
57
- visible.each( function () {
58
- dialog = jQuery( this ).find( ".ui-dialog-content" ).data( "ui-dialog" );
59
- // on each fluid dialog
60
- if ( dialog.options.fluid ) {
61
- wWidth = jQuery( window ).width();
62
- // window width vs dialog width
63
- if ( wWidth < ( parseInt( dialog.options.maxWidth ) + 50 ) ) {
64
- // don't fill the entire screen
65
- jQuery( this ).css( "max-width", "90%" );
66
- } else {
67
- // maxWidth bug fix
68
- jQuery( this ).css( "max-width", dialog.options.maxWidth + "px" );
69
- }
70
- // change dialog position
71
- dialog.option( "position", dialog.options.position );
72
- }
73
- } );
74
- }
75
-
76
- jQuery.fn.extend( {
77
- gadwpItemReport : function ( itemId ) {
78
- var postData, tools, template, reports, refresh, init, slug = "-" + itemId;
79
-
80
- tools = {
81
- setCookie : function ( name, value ) {
82
- var expires, dateItem = new Date();
83
-
84
- if ( gadwpItemData.scope == 'admin-widgets' ) {
85
- name = "gadwp_wg_" + name;
86
- } else {
87
- name = "gadwp_ir_" + name;
88
- }
89
- dateItem.setTime( dateItem.getTime() + ( 24 * 60 * 60 * 1000 * 7 ) );
90
- expires = "expires=" + dateItem.toUTCString();
91
- document.cookie = name + "=" + value + "; " + expires + "; path=/";
92
- },
93
- getCookie : function ( name ) {
94
- var cookie, cookiesArray, div, i = 0;
95
-
96
- if ( gadwpItemData.scope == 'admin-widgets' ) {
97
- name = "gadwp_wg_" + name + "=";
98
- } else {
99
- name = "gadwp_ir_" + name + "=";
100
- }
101
- cookiesArray = document.cookie.split( ';' );
102
- for ( i = 0; i < cookiesArray.length; i++ ) {
103
- cookie = cookiesArray[ i ];
104
- while ( cookie.charAt( 0 ) == ' ' )
105
- cookie = cookie.substring( 1 );
106
- if ( cookie.indexOf( name ) == 0 )
107
- return cookie.substring( name.length, cookie.length );
108
- }
109
- return false;
110
- },
111
- escape : function ( str ) {
112
- div = document.createElement( 'div' );
113
- div.appendChild( document.createTextNode( str ) );
114
- return div.innerHTML;
115
- }
116
- }
117
-
118
- template = {
119
-
120
- addOptions : function ( id, list ) {
121
- var defaultMetric, defaultDimension, defaultView, output = [];
122
-
123
- if ( list == false ) {
124
- return;
125
- }
126
-
127
- if ( !tools.getCookie( 'default_metric' ) || !tools.getCookie( 'default_dimension' ) ) {
128
- defaultMetric = 'sessions';
129
- defaultDimension = '30daysAgo';
130
- } else {
131
- defaultMetric = tools.getCookie( 'default_metric' );
132
- defaultDimension = tools.getCookie( 'default_dimension' );
133
- defaultView = tools.getCookie( 'default_view' );
134
- }
135
-
136
- jQuery.each( list, function ( key, value ) {
137
- if ( key == defaultMetric || key == defaultDimension || key == defaultView ) {
138
- output.push( '<option value="' + key + '" selected="selected">' + value + '</option>' );
139
- } else {
140
- output.push( '<option value="' + key + '">' + value + '</option>' );
141
- }
142
- } );
143
- jQuery( id ).html( output.join( '' ) );
144
- },
145
-
146
- init : function () {
147
- var tpl;
148
-
149
- if ( !jQuery( '#gadwp-window' + slug ).length ) {
150
- return;
151
- }
152
-
153
- if ( jQuery( '#gadwp-window' + slug ).html().length ) { // add main template once
154
- return;
155
- }
156
-
157
- tpl = '<div id="gadwp-container' + slug + '">';
158
- if ( gadwpItemData.viewList != false ) {
159
- tpl += '<select id="gadwp-sel-view' + slug + '"></select>';
160
- }
161
- tpl += '<select id="gadwp-sel-period' + slug + '"></select> ';
162
- tpl += '<select id="gadwp-sel-report' + slug + '"></select>';
163
- tpl += '<div id="gadwp-progressbar' + slug + '"></div>';
164
- tpl += '<div id="gadwp-status' + slug + '"></div>';
165
- tpl += '<div id="gadwp-reports' + slug + '"></div>';
166
- tpl += '<div style="text-align:right;width:100%;font-size:0.8em;clear:both;margin-right:5px;margin-top:10px;">';
167
- tpl += gadwpItemData.i18n[ 14 ];
168
- tpl += ' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=back_report&utm_campaign=gadwp" rel="nofollow" style="text-decoration:none;font-size:1em;">GADWP</a>&nbsp;';
169
- tpl += '</div>';
170
- tpl += '</div>',
171
-
172
- jQuery( '#gadwp-window' + slug ).append( tpl );
173
-
174
- template.addOptions( '#gadwp-sel-view' + slug, gadwpItemData.viewList );
175
- template.addOptions( '#gadwp-sel-period' + slug, gadwpItemData.dateList );
176
- template.addOptions( '#gadwp-sel-report' + slug, gadwpItemData.reportList );
177
-
178
- }
179
- }
180
-
181
- reports = {
182
- oldViewPort: 0,
183
- orgChartTableChartData : '',
184
- tableChartData : '',
185
- orgChartPieChartsData : '',
186
- geoChartTableChartData : '',
187
- areaChartBottomStatsData : '',
188
- realtime : '',
189
- rtRuns : null,
190
- i18n : null,
191
-
192
- getTitle : function ( scope ) {
193
- if ( scope == 'admin-item' ) {
194
- return jQuery( '#gadwp' + slug ).attr( "title" );
195
- } else {
196
- return document.getElementsByTagName( "title" )[ 0 ].innerHTML;
197
- }
198
- },
199
-
200
- alertMessage : function ( msg ) {
201
- jQuery( "#gadwp-status" + slug ).css( {
202
- "margin-top" : "3px",
203
- "padding-left" : "5px",
204
- "height" : "auto",
205
- "color" : "#000",
206
- "border-left" : "5px solid red"
207
- } );
208
- jQuery( "#gadwp-status" + slug ).html( msg );
209
- },
210
-
211
- areaChartBottomStats : function ( response ) {
212
- reports.areaChartBottomStatsData = response;
213
- if ( jQuery.isArray( response ) ) {
214
- if ( !jQuery.isNumeric( response[ 0 ] ) ) {
215
- if ( jQuery.isArray( response[ 0 ] ) ) {
216
- jQuery( '#gadwp-reports' + slug ).show();
217
- if ( postData.query == 'visitBounceRate,bottomstats' ) {
218
- reports.drawAreaChart( response[ 0 ], true );
219
- } else {
220
- reports.drawAreaChart( response[ 0 ], false );
221
- }
222
- } else {
223
- reports.throwDebug( response[ 0 ] );
224
- }
225
- } else {
226
- jQuery( '#gadwp-reports' + slug ).show();
227
- reports.throwError( '#gadwp-areachart' + slug, response[ 0 ], "125px" );
228
- }
229
- if ( !jQuery.isNumeric( response[ 1 ] ) ) {
230
- if ( jQuery.isArray( response[ 1 ] ) ) {
231
- jQuery( '#gadwp-reports' + slug ).show();
232
- reports.drawBottomStats( response[ 1 ] );
233
- } else {
234
- reports.throwDebug( response[ 1 ] );
235
- }
236
- } else {
237
- jQuery( '#gadwp-reports' + slug ).show();
238
- reports.throwError( '#gadwp-bottomstats' + slug, response[ 1 ], "40px" );
239
- }
240
- } else {
241
- reports.throwDebug( response );
242
- }
243
- NProgress.done();
244
-
245
- },
246
-
247
- orgChartPieCharts : function ( response ) {
248
- var i = 0;
249
- reports.orgChartPieChartsData = response;
250
- if ( jQuery.isArray( response ) ) {
251
- if ( !jQuery.isNumeric( response[ 0 ] ) ) {
252
- if ( jQuery.isArray( response[ 0 ] ) ) {
253
- jQuery( '#gadwp-reports' + slug ).show();
254
- reports.drawOrgChart( response[ 0 ] );
255
- } else {
256
- reports.throwDebug( response[ 0 ] );
257
- }
258
- } else {
259
- jQuery( '#gadwp-reports' + slug ).show();
260
- reports.throwError( '#gadwp-orgchart' + slug, response[ 0 ], "125px" );
261
- }
262
-
263
- for ( i = 1; i < response.length; i++ ) {
264
- if ( !jQuery.isNumeric( response[ i ] ) ) {
265
- if ( jQuery.isArray( response[ i ] ) ) {
266
- jQuery( '#gadwp-reports' + slug ).show();
267
- reports.drawPieChart( 'piechart-' + i, response[ i ], reports.i18n[ i ] );
268
- } else {
269
- reports.throwDebug( response[ i ] );
270
- }
271
- } else {
272
- jQuery( '#gadwp-reports' + slug ).show();
273
- reports.throwError( '#gadwp-piechart-' + i + slug, response[ i ], "80px" );
274
- }
275
- }
276
- } else {
277
- reports.throwDebug( response );
278
- }
279
- NProgress.done();
280
- },
281
-
282
- geoChartTableChart : function ( response ) {
283
- reports.geoChartTableChartData = response;
284
- if ( jQuery.isArray( response ) ) {
285
- if ( !jQuery.isNumeric( response[ 0 ] ) ) {
286
- if ( jQuery.isArray( response[ 0 ] ) ) {
287
- jQuery( '#gadwp-reports' + slug ).show();
288
- reports.drawGeoChart( response[ 0 ] );
289
- reports.drawTableChart( response[ 0 ] );
290
- } else {
291
- reports.throwDebug( response[ 0 ] );
292
- }
293
- } else {
294
- jQuery( '#gadwp-reports' + slug ).show();
295
- reports.throwError( '#gadwp-geochart' + slug, response[ 0 ], "125px" );
296
- reports.throwError( '#gadwp-tablechart' + slug, response[ 0 ], "125px" );
297
- }
298
- } else {
299
- reports.throwDebug( response );
300
- }
301
- NProgress.done();
302
- },
303
-
304
- orgChartTableChart : function ( response ) {
305
- reports.orgChartTableChartData = response
306
- if ( jQuery.isArray( response ) ) {
307
- if ( !jQuery.isNumeric( response[ 0 ] ) ) {
308
- if ( jQuery.isArray( response[ 0 ] ) ) {
309
- jQuery( '#gadwp-reports' + slug ).show();
310
- reports.drawOrgChart( response[ 0 ] );
311
- } else {
312
- reports.throwDebug( response[ 0 ] );
313
- }
314
- } else {
315
- jQuery( '#gadwp-reports' + slug ).show();
316
- reports.throwError( '#gadwp-orgchart' + slug, response[ 0 ], "125px" );
317
- }
318
-
319
- if ( !jQuery.isNumeric( response[ 1 ] ) ) {
320
- if ( jQuery.isArray( response[ 1 ] ) ) {
321
- reports.drawTableChart( response[ 1 ] );
322
- } else {
323
- reports.throwDebug( response[ 1 ] );
324
- }
325
- } else {
326
- reports.throwError( '#gadwp-tablechart' + slug, response[ 1 ], "125px" );
327
- }
328
- } else {
329
- reports.throwDebug( response );
330
- }
331
- NProgress.done();
332
- },
333
-
334
- tableChart : function ( response ) {
335
- reports.tableChartData = response
336
- if ( jQuery.isArray( response ) ) {
337
- if ( !jQuery.isNumeric( response[ 0 ] ) ) {
338
- if ( jQuery.isArray( response[ 0 ] ) ) {
339
- jQuery( '#gadwp-reports' + slug ).show();
340
- reports.drawTableChart( response[ 0 ] );
341
- } else {
342
- reports.throwDebug( response[ 0 ] );
343
- }
344
- } else {
345
- jQuery( '#gadwp-reports' + slug ).show();
346
- reports.throwError( '#gadwp-tablechart' + slug, response[ 0 ], "125px" );
347
- }
348
- } else {
349
- reports.throwDebug( response );
350
- }
351
- NProgress.done();
352
- },
353
-
354
- drawTableChart : function ( data ) {
355
- var chartData, options, chart;
356
-
357
- chartData = google.visualization.arrayToDataTable( data );
358
- options = {
359
- page : 'enable',
360
- pageSize : 10,
361
- width : '100%',
362
- allowHtml : true
363
- };
364
- chart = new google.visualization.Table( document.getElementById( 'gadwp-tablechart' + slug ) );
365
-
366
- chart.draw( chartData, options );
367
- },
368
-
369
- drawOrgChart : function ( data ) {
370
- var chartData, options, chart;
371
-
372
- chartData = google.visualization.arrayToDataTable( data );
373
- options = {
374
- allowCollapse : true,
375
- allowHtml : true,
376
- height : '100%'
377
- };
378
- chart = new google.visualization.OrgChart( document.getElementById( 'gadwp-orgchart' + slug ) );
379
-
380
- chart.draw( chartData, options );
381
- },
382
-
383
- drawPieChart : function ( id, data, title ) {
384
- var chartData, options, chart;
385
-
386
- chartData = google.visualization.arrayToDataTable( data );
387
- options = {
388
- is3D : false,
389
- tooltipText : 'percentage',
390
- legend : 'none',
391
- chartArea : {
392
- width : '99%',
393
- height : '80%'
394
- },
395
- title : title,
396
- pieSliceText : 'value',
397
- colors : gadwpItemData.colorVariations
398
- };
399
- chart = new google.visualization.PieChart( document.getElementById( 'gadwp-' + id + slug ) );
400
-
401
- chart.draw( chartData, options );
402
- },
403
-
404
- drawGeoChart : function ( data ) {
405
- var chartData, options, chart;
406
-
407
- chartData = google.visualization.arrayToDataTable( data );
408
- options = {
409
- chartArea : {
410
- width : '99%',
411
- height : '90%'
412
- },
413
- colors : [ gadwpItemData.colorVariations[ 5 ], gadwpItemData.colorVariations[ 4 ] ]
414
- }
415
- if ( gadwpItemData.region ) {
416
- options.region = gadwpItemData.region;
417
- options.displayMode = 'markers';
418
- options.datalessRegionColor = 'EFEFEF';
419
- }
420
- chart = new google.visualization.GeoChart( document.getElementById( 'gadwp-geochart' + slug ) );
421
-
422
- chart.draw( chartData, options );
423
- },
424
-
425
- drawAreaChart : function ( data, format ) {
426
- var chartData, options, chart, formatter;
427
-
428
- chartData = google.visualization.arrayToDataTable( data );
429
-
430
- if ( format ) {
431
- formatter = new google.visualization.NumberFormat( {
432
- suffix : '%',
433
- fractionDigits : 2
434
- } );
435
-
436
- formatter.format( chartData, 1 );
437
- }
438
-
439
- options = {
440
- legend : {
441
- position : 'none'
442
- },
443
- pointSize : 3,
444
- colors : [ gadwpItemData.colorVariations[ 0 ], gadwpItemData.colorVariations[ 4 ] ],
445
- chartArea : {
446
- width : '99%',
447
- height : '90%'
448
- },
449
- vAxis : {
450
- textPosition : "in",
451
- minValue : 0
452
- },
453
- hAxis : {
454
- textPosition : 'none'
455
- }
456
- };
457
- chart = new google.visualization.AreaChart( document.getElementById( 'gadwp-areachart' + slug ) );
458
-
459
- chart.draw( chartData, options );
460
- },
461
-
462
- drawBottomStats : function ( data ) {
463
- jQuery( "#gdsessions" + slug ).html( data[ 0 ] );
464
- jQuery( "#gdusers" + slug ).html( data[ 1 ] );
465
- jQuery( "#gdpageviews" + slug ).html( data[ 2 ] );
466
- jQuery( "#gdbouncerate" + slug ).html( data[ 3 ] );
467
- jQuery( "#gdorganicsearch" + slug ).html( data[ 4 ] );
468
- jQuery( "#gdpagespervisit" + slug ).html( data[ 5 ] );
469
- jQuery( "#gdpagetime" + slug ).html( data[ 6 ] );
470
- jQuery( "#gdpageload" + slug ).html( data[ 7 ] );
471
- jQuery( "#gdsessionduration" + slug ).html( data[ 8 ] );
472
- },
473
-
474
- rtOnlyUniqueValues : function ( value, index, self ) {
475
- return self.indexOf( value ) === index;
476
- },
477
-
478
- rtCountSessions : function ( rtData, searchValue ) {
479
- var count = 0, i = 0;
480
-
481
- for ( i = 0; i < rtData[ "rows" ].length; i++ ) {
482
- if ( jQuery.inArray( searchValue, rtData[ "rows" ][ i ] ) > -1 ) {
483
- count += parseInt( rtData[ "rows" ][ i ][ 6 ] );
484
- }
485
- }
486
- return count;
487
- },
488
-
489
- rtGenerateTooltip : function ( rtData ) {
490
- var count = 0, table = "", i = 0;
491
-
492
- for ( i = 0; i < rtData.length; i++ ) {
493
- count += parseInt( rtData[ i ].count );
494
- table += "<tr><td class='gadwp-pgdetailsl'>" + rtData[ i ].value + "</td><td class='gadwp-pgdetailsr'>" + rtData[ i ].count + "</td></tr>";
495
- }
496
- ;
497
- if ( count ) {
498
- return ( "<table>" + table + "</table>" );
499
- } else {
500
- return ( "" );
501
- }
502
- },
503
-
504
- rtPageDetails : function ( rtData, searchValue ) {
505
- var sant, pageTitle, pgStatsTable, i = 0, j = 0, sum = 0, newsum = 0, countrfr = 0, countkwd = 0, countdrt = 0, countscl = 0, countcpg = 0, tablerfr = "", tablekwd = "", tablescl = "", tablecpg = "", tabledrt = "";
506
-
507
- rtData = rtData[ "rows" ];
508
-
509
- for ( i = 0; i < rtData.length; i++ ) {
510
-
511
- if ( rtData[ i ][ 0 ] == searchValue ) {
512
- pageTitle = rtData[ i ][ 5 ];
513
-
514
- switch ( rtData[ i ][ 3 ] ) {
515
-
516
- case "REFERRAL":
517
- countrfr += parseInt( rtData[ i ][ 6 ] );
518
- tablerfr += "<tr><td class='gadwp-pgdetailsl'>" + rtData[ i ][ 1 ] + "</td><td class='gadwp-pgdetailsr'>" + rtData[ i ][ 6 ] + "</td></tr>";
519
- break;
520
- case "ORGANIC":
521
- countkwd += parseInt( rtData[ i ][ 6 ] );
522
- tablekwd += "<tr><td class='gadwp-pgdetailsl'>" + rtData[ i ][ 2 ] + "</td><td class='gadwp-pgdetailsr'>" + rtData[ i ][ 6 ] + "</td></tr>";
523
- break;
524
- case "SOCIAL":
525
- countscl += parseInt( rtData[ i ][ 6 ] );
526
- tablescl += "<tr><td class='gadwp-pgdetailsl'>" + rtData[ i ][ 1 ] + "</td><td class='gadwp-pgdetailsr'>" + rtData[ i ][ 6 ] + "</td></tr>";
527
- break;
528
- case "CUSTOM":
529
- countcpg += parseInt( rtData[ i ][ 6 ] );
530
- tablecpg += "<tr><td class='gadwp-pgdetailsl'>" + rtData[ i ][ 1 ] + "</td><td class='gadwp-pgdetailsr'>" + rtData[ i ][ 6 ] + "</td></tr>";
531
- break;
532
- case "DIRECT":
533
- countdrt += parseInt( rtData[ i ][ 6 ] );
534
- break;
535
- }
536
- }
537
- }
538
-
539
- if ( countrfr ) {
540
- tablerfr = "<table><tr><td>" + reports.i18n[ 0 ] + "(" + countrfr + ")</td></tr>" + tablerfr + "</table><br />";
541
- }
542
- if ( countkwd ) {
543
- tablekwd = "<table><tr><td>" + reports.i18n[ 1 ] + "(" + countkwd + ")</td></tr>" + tablekwd + "</table><br />";
544
- }
545
- if ( countscl ) {
546
- tablescl = "<table><tr><td>" + reports.i18n[ 2 ] + "(" + countscl + ")</td></tr>" + tablescl + "</table><br />";
547
- }
548
- if ( countcpg ) {
549
- tablecpg = "<table><tr><td>" + reports.i18n[ 3 ] + "(" + countcpg + ")</td></tr>" + tablecpg + "</table><br />";
550
- }
551
- if ( countdrt ) {
552
- tabledrt = "<table><tr><td>" + reports.i18n[ 4 ] + "(" + countdrt + ")</td></tr></table><br />";
553
- }
554
- return ( "<p><center><strong>" + pageTitle + "</strong></center></p>" + tablerfr + tablekwd + tablescl + tablecpg + tabledrt );
555
- },
556
-
557
- rtRefresh : function () {
558
- if ( reports.render.focusFlag ) {
559
- postData.from = false;
560
- postData.to = false;
561
- postData.query = 'realtime';
562
- jQuery.post( gadwpItemData.ajaxurl, postData, function ( response ) {
563
- if ( jQuery.isArray( response ) ) {
564
- jQuery( '#gadwp-reports' + slug ).show();
565
- reports.realtime = response[ 0 ];
566
- reports.drawRealtime( reports.realtime );
567
- } else {
568
- reports.throwDebug( response );
569
- }
570
-
571
- NProgress.done();
572
-
573
- } );
574
- }
575
- },
576
-
577
- drawRealtime : function ( rtData ) {
578
- var rtInfoRight, uPagePath, uReferrals, uKeywords, uSocial, uCustom, i = 0, pagepath = [], referrals = [], keywords = [], social = [], visittype = [], custom = [], uPagePathStats = [], pgStatsTable = "", uReferrals = [], uKeywords = [], uSocial = [], uCustom = [], uVisitType = [ "REFERRAL", "ORGANIC", "SOCIAL", "CUSTOM" ], uVisitorType = [ "DIRECT", "NEW" ];
579
-
580
- jQuery( function () {
581
- jQuery( '#gadwp-widget *' ).tooltip( {
582
- tooltipClass : "gadwp"
583
- } );
584
- } );
585
-
586
- rtData = rtData[ 0 ];
587
-
588
- if ( jQuery.isNumeric( rtData ) || typeof rtData === "undefined" ) {
589
- rtData = [];
590
- rtData[ "totalsForAllResults" ] = []
591
- rtData[ "totalsForAllResults" ][ "rt:activeUsers" ] = "0";
592
- rtData[ "rows" ] = [];
593
- }
594
-
595
- if ( rtData[ "totalsForAllResults" ][ "rt:activeUsers" ] !== document.getElementById( "gadwp-online" ).innerHTML ) {
596
- jQuery( "#gadwp-online" ).fadeOut( "slow" );
597
- jQuery( "#gadwp-online" ).fadeOut( 500 );
598
- jQuery( "#gadwp-online" ).fadeOut( "slow", function () {
599
- if ( ( parseInt( rtData[ "totalsForAllResults" ][ "rt:activeUsers" ] ) ) < ( parseInt( document.getElementById( "gadwp-online" ).innerHTML ) ) ) {
600
- jQuery( "#gadwp-online" ).css( {
601
- 'background-color' : '#FFE8E8'
602
- } );
603
- } else {
604
- jQuery( "#gadwp-online" ).css( {
605
- 'background-color' : '#E0FFEC'
606
- } );
607
- }
608
- document.getElementById( "gadwp-online" ).innerHTML = rtData[ "totalsForAllResults" ][ "rt:activeUsers" ];
609
- } );
610
- jQuery( "#gadwp-online" ).fadeIn( "slow" );
611
- jQuery( "#gadwp-online" ).fadeIn( 500 );
612
- jQuery( "#gadwp-online" ).fadeIn( "slow", function () {
613
- jQuery( "#gadwp-online" ).css( {
614
- 'background-color' : '#FFFFFF'
615
- } );
616
- } );
617
- }
618
-
619
- if ( rtData[ "totalsForAllResults" ][ "rt:activeUsers" ] == 0 ) {
620
- rtData[ "rows" ] = [];
621
- }
622
-
623
- for ( i = 0; i < rtData[ "rows" ].length; i++ ) {
624
- pagepath.push( rtData[ "rows" ][ i ][ 0 ] );
625
- if ( rtData[ "rows" ][ i ][ 3 ] == "REFERRAL" ) {
626
- referrals.push( rtData[ "rows" ][ i ][ 1 ] );
627
- }
628
- if ( rtData[ "rows" ][ i ][ 3 ] == "ORGANIC" ) {
629
- keywords.push( rtData[ "rows" ][ i ][ 2 ] );
630
- }
631
- if ( rtData[ "rows" ][ i ][ 3 ] == "SOCIAL" ) {
632
- social.push( rtData[ "rows" ][ i ][ 1 ] );
633
- }
634
- if ( rtData[ "rows" ][ i ][ 3 ] == "CUSTOM" ) {
635
- custom.push( rtData[ "rows" ][ i ][ 1 ] );
636
- }
637
- visittype.push( rtData[ "rows" ][ i ][ 3 ] );
638
- }
639
-
640
- uPagePath = pagepath.filter( reports.rtOnlyUniqueValues );
641
- for ( i = 0; i < uPagePath.length; i++ ) {
642
- uPagePathStats[ i ] = {
643
- "pagepath" : uPagePath[ i ],
644
- "count" : reports.rtCountSessions( rtData, uPagePath[ i ] )
645
- }
646
- }
647
- uPagePathStats.sort( function ( a, b ) {
648
- return b.count - a.count
649
- } );
650
-
651
- pgStatsTable = "";
652
- for ( i = 0; i < uPagePathStats.length; i++ ) {
653
- if ( i < gadwpItemData.rtLimitPages ) {
654
- pgStatsTable += '<div class="gadwp-pline"><div class="gadwp-pleft"><a href="#" data-gadwp="' + reports.rtPageDetails( rtData, uPagePathStats[ i ].pagepath ) + '">' + uPagePathStats[ i ].pagepath.substring( 0, 70 ) + '</a></div><div class="gadwp-pright">' + uPagePathStats[ i ].count + '</div></div>';
655
- }
656
- }
657
- document.getElementById( "gadwp-pages" ).innerHTML = '<br /><div class="gadwp-pg">' + pgStatsTable + '</div>';
658
-
659
- uReferrals = referrals.filter( reports.rtOnlyUniqueValues );
660
- for ( i = 0; i < uReferrals.length; i++ ) {
661
- uReferrals[ i ] = {
662
- "value" : uReferrals[ i ],
663
- "count" : reports.rtCountSessions( rtData, uReferrals[ i ] )
664
- };
665
- }
666
- uReferrals.sort( function ( a, b ) {
667
- return b.count - a.count
668
- } );
669
-
670
- uKeywords = keywords.filter( reports.rtOnlyUniqueValues );
671
- for ( i = 0; i < uKeywords.length; i++ ) {
672
- uKeywords[ i ] = {
673
- "value" : uKeywords[ i ],
674
- "count" : reports.rtCountSessions( rtData, uKeywords[ i ] )
675
- };
676
- }
677
- uKeywords.sort( function ( a, b ) {
678
- return b.count - a.count
679
- } );
680
-
681
- uSocial = social.filter( reports.rtOnlyUniqueValues );
682
- for ( i = 0; i < uSocial.length; i++ ) {
683
- uSocial[ i ] = {
684
- "value" : uSocial[ i ],
685
- "count" : reports.rtCountSessions( rtData, uSocial[ i ] )
686
- };
687
- }
688
- uSocial.sort( function ( a, b ) {
689
- return b.count - a.count
690
- } );
691
-
692
- uCustom = custom.filter( reports.rtOnlyUniqueValues );
693
- for ( i = 0; i < uCustom.length; i++ ) {
694
- uCustom[ i ] = {
695
- "value" : uCustom[ i ],
696
- "count" : reports.rtCountSessions( rtData, uCustom[ i ] )
697
- };
698
- }
699
- uCustom.sort( function ( a, b ) {
700
- return b.count - a.count
701
- } );
702
-
703
- rtInfoRight = '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rtGenerateTooltip( uReferrals ) + '"><div class="gadwp-bleft">' + reports.i18n[ 0 ] + '</a></div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitType[ 0 ] ) + '</div></div>';
704
- rtInfoRight += '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rtGenerateTooltip( uKeywords ) + '"><div class="gadwp-bleft">' + reports.i18n[ 1 ] + '</a></div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitType[ 1 ] ) + '</div></div>';
705
- rtInfoRight += '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rtGenerateTooltip( uSocial ) + '"><div class="gadwp-bleft">' + reports.i18n[ 2 ] + '</a></div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitType[ 2 ] ) + '</div></div>';
706
- rtInfoRight += '<div class="gadwp-bigtext"><a href="#" data-gadwp="' + reports.rtGenerateTooltip( uCustom ) + '"><div class="gadwp-bleft">' + reports.i18n[ 3 ] + '</a></div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitType[ 3 ] ) + '</div></div>';
707
-
708
- rtInfoRight += '<div class="gadwp-bigtext"><div class="gadwp-bleft">' + reports.i18n[ 4 ] + '</div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitorType[ 0 ] ) + '</div></div>';
709
- rtInfoRight += '<div class="gadwp-bigtext"><div class="gadwp-bleft">' + reports.i18n[ 5 ] + '</div><div class="gadwp-bright">' + reports.rtCountSessions( rtData, uVisitorType[ 1 ] ) + '</div></div>';
710
-
711
- document.getElementById( "gadwp-tdo-right" ).innerHTML = rtInfoRight;
712
- },
713
-
714
- throwDebug : function ( response ) {
715
- jQuery( "#gadwp-status" + slug ).css( {
716
- "margin-top" : "3px",
717
- "padding-left" : "5px",
718
- "height" : "auto",
719
- "color" : "#000",
720
- "border-left" : "5px solid red"
721
- } );
722
- if ( response == '-24' ) {
723
- jQuery( "#gadwp-status" + slug ).html( gadwpItemData.i18n[ 15 ] );
724
- } else {
725
- jQuery( "#gadwp-reports" + slug ).css( {
726
- "background-color" : "#F7F7F7",
727
- "height" : "auto",
728
- "margin-top" : "10px",
729
- "padding-top" : "50px",
730
- "padding-bottom" : "50px",
731
- "color" : "#000",
732
- "text-align" : "center"
733
- } );
734
- jQuery( "#gadwp-reports" + slug ).html ( response );
735
- jQuery( "#gadwp-reports" + slug ).show();
736
- jQuery( "#gadwp-status" + slug ).html( gadwpItemData.i18n[ 11 ] );
737
- console.log( "\n********************* GADWP Log ********************* \n\n" + response );
738
- postData = {
739
- action : 'gadwp_set_error',
740
- response : response,
741
- gadwp_security_set_error : gadwpItemData.security,
742
- }
743
- jQuery.post( gadwpItemData.ajaxurl, postData );
744
- }
745
- },
746
-
747
- throwError : function ( target, response, p ) {
748
- jQuery( target ).css( {
749
- "background-color" : "#F7F7F7",
750
- "height" : "auto",
751
- "padding-top" : p,
752
- "padding-bottom" : p,
753
- "color" : "#000",
754
- "text-align" : "center"
755
- } );
756
- if ( response == -21 ) {
757
- jQuery( target ).html( gadwpItemData.i18n[ 12 ] + ' (' + response + ')' );
758
- } else {
759
- jQuery( target ).html( gadwpItemData.i18n[ 13 ] + ' (' + response + ')' );
760
- }
761
- },
762
-
763
- render : function ( view, period, query ) {
764
- var projectId, from, to, tpl, focusFlag;
765
-
766
- if ( period == 'realtime' ) {
767
- jQuery( '#gadwp-sel-report' + slug ).hide();
768
- } else {
769
- jQuery( '#gadwp-sel-report' + slug ).show();
770
- clearInterval( reports.rtRuns );
771
- }
772
-
773
- jQuery( '#gadwp-status' + slug ).html( '' );
774
- switch ( period ) {
775
- case 'today':
776
- from = 'today';
777
- to = 'today';
778
- break;
779
- case 'yesterday':
780
- from = 'yesterday';
781
- to = 'yesterday';
782
- break;
783
- case '7daysAgo':
784
- from = '7daysAgo';
785
- to = 'yesterday';
786
- break;
787
- case '14daysAgo':
788
- from = '14daysAgo';
789
- to = 'yesterday';
790
- break;
791
- case '90daysAgo':
792
- from = '90daysAgo';
793
- to = 'yesterday';
794
- break;
795
- case '365daysAgo':
796
- from = '365daysAgo';
797
- to = 'yesterday';
798
- break;
799
- case '1095daysAgo':
800
- from = '1095daysAgo';
801
- to = 'yesterday';
802
- break;
803
- default:
804
- from = '30daysAgo';
805
- to = 'yesterday';
806
- break;
807
- }
808
-
809
- tools.setCookie( 'default_metric', query );
810
- tools.setCookie( 'default_dimension', period );
811
-
812
- if ( typeof view !== 'undefined' ) {
813
- tools.setCookie( 'default_view', view );
814
- projectId = view;
815
- } else {
816
- projectId = false;
817
- }
818
-
819
- if ( gadwpItemData.scope == 'admin-item' ) {
820
- postData = {
821
- action : 'gadwp_backend_item_reports',
822
- gadwp_security_backend_item_reports : gadwpItemData.security,
823
- from : from,
824
- to : to,
825
- filter : itemId
826
- }
827
- } else if ( gadwpItemData.scope == 'front-item' ) {
828
- postData = {
829
- action : 'gadwp_frontend_item_reports',
830
- gadwp_security_frontend_item_reports : gadwpItemData.security,
831
- from : from,
832
- to : to,
833
- filter : gadwpItemData.filter
834
- }
835
- } else {
836
- postData = {
837
- action : 'gadwp_backend_item_reports',
838
- gadwp_security_backend_item_reports : gadwpItemData.security,
839
- projectId : projectId,
840
- from : from,
841
- to : to
842
- }
843
- }
844
- if ( period == 'realtime' ) {
845
-
846
- reports.i18n = gadwpItemData.i18n.slice( 20, 26 );
847
-
848
- reports.render.focusFlag = 1;
849
-
850
- jQuery( window ).bind( "focus", function ( event ) {
851
- reports.render.focusFlag = 1;
852
- } ).bind( "blur", function ( event ) {
853
- reports.render.focusFlag = 0;
854
- } );
855
-
856
- tpl = '<div id="gadwp-realtime' + slug + '">';
857
- tpl += '<div class="gadwp-rt-box">';
858
- tpl += '<div class="gadwp-tdo-left">';
859
- tpl += '<div class="gadwp-online" id="gadwp-online">0</div>';
860
- tpl += '</div>';
861
- tpl += '<div class="gadwp-tdo-right" id="gadwp-tdo-right">';
862
- tpl += '<div class="gadwp-bigtext">';
863
- tpl += '<div class="gadwp-bleft">' + reports.i18n[ 0 ] + '</div>';
864
- tpl += '<div class="gadwp-bright">0</div>';
865
- tpl += '</div>';
866
- tpl += '<div class="gadwp-bigtext">';
867
- tpl += '<div class="gadwp-bleft">' + reports.i18n[ 1 ] + '</div>';
868
- tpl += '<div class="gadwp-bright">0</div>';
869
- tpl += '</div>';
870
- tpl += '<div class="gadwp-bigtext">';
871
- tpl += '<div class="gadwp-bleft">' + reports.i18n[ 2 ] + '</div>';
872
- tpl += '<div class="gadwp-bright">0</div>';
873
- tpl += '</div>';
874
- tpl += '<div class="gadwp-bigtext">';
875
- tpl += '<div class="gadwp-bleft">' + reports.i18n[ 3 ] + '</div>';
876
- tpl += '<div class="gadwp-bright">0</div>';
877
- tpl += '</div>';
878
- tpl += '<div class="gadwp-bigtext">';
879
- tpl += '<div class="gadwp-bleft">' + reports.i18n[ 4 ] + '</div>';
880
- tpl += '<div class="gadwp-bright">0</div>';
881
- tpl += '</div>';
882
- tpl += '<div class="gadwp-bigtext">';
883
- tpl += '<div class="gadwp-bleft">' + reports.i18n[ 5 ] + '</div>';
884
- tpl += '<div class="gadwp-bright">0</div>';
885
- tpl += '</div>';
886
- tpl += '</div>';
887
- tpl += '</div>';
888
- tpl += '<div>';
889
- tpl += '<div id="gadwp-pages" class="gadwp-pages">&nbsp;</div>';
890
- tpl += '</div>';
891
- tpl += '</div>';
892
-
893
- jQuery( '#gadwp-reports' + slug ).html( tpl );
894
-
895
- reports.rtRefresh( reports.render.focusFlag );
896
-
897
- reports.rtRuns = setInterval( reports.rtRefresh, 55000 );
898
-
899
- } else {
900
- if ( jQuery.inArray( query, [ 'referrers', 'contentpages', 'searches' ] ) > -1 ) {
901
-
902
- tpl = '<div id="gadwp-orgcharttablechart' + slug + '">';
903
- tpl += '<div id="gadwp-orgchart' + slug + '"></div>';
904
- tpl += '<div id="gadwp-tablechart' + slug + '"></div>';
905
- tpl += '</div>';
906
-
907
- jQuery( '#gadwp-reports' + slug ).html( tpl );
908
- jQuery( '#gadwp-reports' + slug ).hide();
909
-
910
- postData.query = 'channelGrouping,' + query;
911
-
912
- jQuery.post( gadwpItemData.ajaxurl, postData, function ( response ) {
913
- reports.orgChartTableChart( response );
914
- } );
915
- } else if ( query == '404errors' ) {
916
- tpl = '<div id="gadwp-404tablechart' + slug + '">';
917
- tpl += '<div id="gadwp-tablechart' + slug + '"></div>';
918
- tpl += '</div>';
919
-
920
- jQuery( '#gadwp-reports' + slug ).html( tpl );
921
- jQuery( '#gadwp-reports' + slug ).hide();
922
-
923
- postData.query = query;
924
-
925
- jQuery.post( gadwpItemData.ajaxurl, postData, function ( response ) {
926
- reports.tableChart( response );
927
- } );
928
- } else if ( query == 'trafficdetails' || query == 'technologydetails' ) {
929
-
930
- tpl = '<div id="gadwp-orgchartpiecharts' + slug + '">';
931
- tpl += '<div id="gadwp-orgchart' + slug + '"></div>';
932
- tpl += '<div class="gadwp-floatwraper">';
933
- tpl += '<div id="gadwp-piechart-1' + slug + '" class="halfsize floatleft"></div>';
934
- tpl += '<div id="gadwp-piechart-2' + slug + '" class="halfsize floatright"></div>';
935
- tpl += '</div>';
936
- tpl += '<div class="gadwp-floatwraper">';
937
- tpl += '<div id="gadwp-piechart-3' + slug + '" class="halfsize floatleft"></div>';
938
- tpl += '<div id="gadwp-piechart-4' + slug + '" class="halfsize floatright"></div>';
939
- tpl += '</div>';
940
- tpl += '</div>';
941
-
942
- jQuery( '#gadwp-reports' + slug ).html( tpl );
943
- jQuery( '#gadwp-reports' + slug ).hide();
944
- if ( query == 'trafficdetails' ) {
945
- postData.query = 'channelGrouping,medium,visitorType,source,socialNetwork';
946
- reports.i18n = gadwpItemData.i18n.slice( 0, 5 );
947
- } else {
948
- reports.i18n = gadwpItemData.i18n.slice( 15, 20 );
949
- postData.query = 'deviceCategory,browser,operatingSystem,screenResolution,mobileDeviceBranding';
950
- }
951
-
952
- jQuery.post( gadwpItemData.ajaxurl, postData, function ( response ) {
953
- reports.orgChartPieCharts( response )
954
- } );
955
-
956
- } else if ( query == 'locations' ) {
957
-
958
- tpl = '<div id="gadwp-geocharttablechart' + slug + '">';
959
- tpl += '<div id="gadwp-geochart' + slug + '"></div>';
960
- tpl += '<div id="gadwp-tablechart' + slug + '"></div>';
961
- tpl += '</div>';
962
-
963
- jQuery( '#gadwp-reports' + slug ).html( tpl );
964
- jQuery( '#gadwp-reports' + slug ).hide();
965
-
966
- postData.query = query;
967
-
968
- jQuery.post( gadwpItemData.ajaxurl, postData, function ( response ) {
969
- reports.geoChartTableChart( response );
970
- } );
971
-
972
- } else {
973
-
974
- tpl = '<div id="gadwp-areachartbottomstats' + slug + '">';
975
- tpl += '<div id="gadwp-areachart' + slug + '"></div>';
976
- tpl += '<div id="gadwp-bottomstats' + slug + '">';
977
- tpl += '<div class="inside">';
978
- tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 5 ] + '</h3><p id="gdsessions' + slug + '">&nbsp;</p></div>';
979
- tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 6 ] + '</h3><p id="gdusers' + slug + '">&nbsp;</p></div>';
980
- tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 7 ] + '</h3><p id="gdpageviews' + slug + '">&nbsp;</p></div>';
981
- tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 8 ] + '</h3><p id="gdbouncerate' + slug + '">&nbsp;</p></div>';
982
- tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 9 ] + '</h3><p id="gdorganicsearch' + slug + '">&nbsp;</p></div>';
983
- tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 10 ] + '</h3><p id="gdpagespervisit' + slug + '">&nbsp;</p></div>';
984
- tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 26 ] + '</h3><p id="gdpagetime' + slug + '">&nbsp;</p></div>';
985
- tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 27 ] + '</h3><p id="gdpageload' + slug + '">&nbsp;</p></div>';
986
- tpl += '<div class="small-box"><h3>' + gadwpItemData.i18n[ 28 ] + '</h3><p id="gdsessionduration' + slug + '">&nbsp;</p></div>';
987
- tpl += '</div>';
988
- tpl += '</div>';
989
- tpl += '</div>';
990
-
991
- jQuery( '#gadwp-reports' + slug ).html( tpl );
992
- jQuery( '#gadwp-reports' + slug ).hide();
993
-
994
- postData.query = query + ',bottomstats';
995
-
996
- jQuery.post( gadwpItemData.ajaxurl, postData, function ( response ) {
997
- reports.areaChartBottomStats( response );
998
- } );
999
-
1000
- }
1001
-
1002
- }
1003
-
1004
- },
1005
-
1006
- refresh : function () {
1007
- if ( jQuery( '#gadwp-areachartbottomstats' + slug ).length > 0 && jQuery.isArray( reports.areaChartBottomStatsData ) ) {
1008
- reports.areaChartBottomStats( reports.areaChartBottomStatsData );
1009
- }
1010
- if ( jQuery( '#gadwp-orgchartpiecharts' + slug ).length > 0 && jQuery.isArray( reports.orgChartPieChartsData ) ) {
1011
- reports.orgChartPieCharts( reports.orgChartPieChartsData );
1012
- }
1013
- if ( jQuery( '#gadwp-geocharttablechart' + slug ).length > 0 && jQuery.isArray( reports.geoChartTableChartData ) ) {
1014
- reports.geoChartTableChart( reports.geoChartTableChartData );
1015
- }
1016
- if ( jQuery( '#gadwp-orgcharttablechart' + slug ).length > 0 && jQuery.isArray( reports.orgChartTableChartData ) ) {
1017
- reports.orgChartTableChart( reports.orgChartTableChartData );
1018
- }
1019
- if ( jQuery( '#gadwp-404tablechart' + slug ).length > 0 && jQuery.isArray( reports.tableChartData ) ) {
1020
- reports.tableChart( reports.tableChartData );
1021
- }
1022
- },
1023
-
1024
- init : function () {
1025
-
1026
- if ( !jQuery( "#gadwp-reports" + slug ).length ) {
1027
- return;
1028
- }
1029
-
1030
- if ( jQuery( "#gadwp-reports" + slug ).html().length ) { // only when report is empty
1031
- return;
1032
- }
1033
-
1034
- try {
1035
- NProgress.configure( {
1036
- parent : "#gadwp-progressbar" + slug,
1037
- showSpinner : false
1038
- } );
1039
- NProgress.start();
1040
- } catch ( e ) {
1041
- reports.alertMessage( gadwpItemData.i18n[ 0 ] );
1042
- }
1043
-
1044
- reports.render( jQuery( '#gadwp-sel-view' + slug ).val(), jQuery( '#gadwp-sel-period' + slug ).val(), jQuery( '#gadwp-sel-report' + slug ).val() );
1045
-
1046
- jQuery( window ).resize( function () {
1047
- var diff = jQuery(window).width() - reports.oldViewPort;
1048
- if ( ( diff < -5 ) || ( diff > 5 ) ) {
1049
- reports.oldViewPort = jQuery(window).width();
1050
- reports.refresh(); //refresh only on over 5px viewport width changes
1051
- }
1052
- } );
1053
- }
1054
- }
1055
-
1056
- template.init();
1057
-
1058
- reports.init();
1059
-
1060
- jQuery( '#gadwp-sel-view' + slug ).change( function () {
1061
- jQuery( '#gadwp-reports' + slug ).html( '' );
1062
- reports.init();
1063
- } );
1064
-
1065
- jQuery( '#gadwp-sel-period' + slug ).change( function () {
1066
- jQuery( '#gadwp-reports' + slug ).html( '' );
1067
- reports.init();
1068
- } );
1069
-
1070
- jQuery( '#gadwp-sel-report' + slug ).change( function () {
1071
- jQuery( '#gadwp-reports' + slug ).html( '' );
1072
- reports.init();
1073
- } );
1074
-
1075
- if ( gadwpItemData.scope == 'admin-widgets' ) {
1076
- return;
1077
- } else {
1078
- return this.dialog( {
1079
- width : 'auto',
1080
- maxWidth : 510,
1081
- height : 'auto',
1082
- modal : true,
1083
- fluid : true,
1084
- dialogClass : 'gadwp wp-dialog',
1085
- resizable : false,
1086
- title : reports.getTitle( gadwpItemData.scope ),
1087
- position : {
1088
- my : "top",
1089
- at : "top+100",
1090
- of : window
1091
- }
1092
- } );
1093
- }
1094
- }
1095
- } );
1096
-
1097
- function GADWPReportLoad () {
1098
- if ( gadwpItemData.scope == 'admin-widgets' ) {
1099
- jQuery( '#gadwp-window-1' ).gadwpItemReport( 1 );
1100
- } else {
1101
- jQuery( gadwpItemData.getSelector( gadwpItemData.scope ) ).click( function () {
1102
- if ( !jQuery( "#gadwp-window-" + gadwpItemData.getID( this ) ).length > 0 ) {
1103
- jQuery( "body" ).append( '<div id="gadwp-window-' + gadwpItemData.getID( this ) + '"></div>' );
1104
- }
1105
- jQuery( '#gadwp-window-' + gadwpItemData.getID( this ) ).gadwpItemReport( gadwpItemData.getID( this ) );
1106
- } );
1107
- }
1108
-
1109
- // on window resize
1110
- jQuery( window ).resize( function () {
1111
- gadwpItemData.responsiveDialog();
1112
- } );
1113
-
1114
- // dialog width larger than viewport
1115
- jQuery( document ).on( "dialogopen", ".ui-dialog", function ( event, ui ) {
1116
- gadwpItemData.responsiveDialog();
1117
- } );
1118
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
common/js/reports5.js ADDED
@@ -0,0 +1 @@
 
1
+ "use strict";if(gadwpItemData.mapsApiKey){google.charts.load("current",{mapsApiKey:gadwpItemData.mapsApiKey,packages:["corechart","table","orgchart","geochart"]})}else{google.charts.load("current",{packages:["corechart","table","orgchart","geochart"]})}google.charts.setOnLoadCallback(GADWPReportLoad);gadwpItemData.getID=function(a){if(gadwpItemData.scope=="admin-item"){if(typeof a.id=="undefined"){return 0}if(a.id.split("-")[1]=="undefined"){return 0}else{return a.id.split("-")[1]}}else{if(typeof a.id=="undefined"){return 1}if(a.id.split("-")[4]=="undefined"){return 1}else{return a.id.split("-")[4]}}};gadwpItemData.getSelector=function(a){if(a=="admin-item"){return'a[id^="gadwp-"]'}else{return'li[id^="wp-admin-bar-gadwp"] a'}};gadwpItemData.responsiveDialog=function(){var b,a,c;c=jQuery(".ui-dialog:visible");c.each(function(){b=jQuery(this).find(".ui-dialog-content").data("ui-dialog");if(b.options.fluid){a=jQuery(window).width();if(a<(parseInt(b.options.maxWidth)+50)){jQuery(this).css("max-width","90%")}else{jQuery(this).css("max-width",b.options.maxWidth+"px")}b.option("position",b.options.position)}})};jQuery.fn.extend({gadwpItemReport:function(g){var a,d,h,e,f,i,c,b="-"+g;d={setCookie:function(k,m){var j,l=new Date();if(gadwpItemData.scope=="admin-widgets"){k="gadwp_wg_"+k}else{k="gadwp_ir_"+k}l.setTime(l.getTime()+(24*60*60*1000*7));j="expires="+l.toUTCString();document.cookie=k+"="+m+"; "+j+"; path=/"},getCookie:function(j){var l,m,n,k=0;if(gadwpItemData.scope=="admin-widgets"){j="gadwp_wg_"+j+"="}else{j="gadwp_ir_"+j+"="}m=document.cookie.split(";");for(k=0;k<m.length;k++){l=m[k];while(l.charAt(0)==" "){l=l.substring(1)}if(l.indexOf(j)==0){return l.substring(j.length,l.length)}}return false},escape:function(j){div=document.createElement("div");div.appendChild(document.createTextNode(j));return div.innerHTML}};h={addOptions:function(o,n){var j,l,m,k=[];if(!d.getCookie("default_metric")||!d.getCookie("default_dimension")||!d.getCookie("default_swmetric")){j="sessions";l="30daysAgo";if(gadwpItemData.scope=="front-item"||gadwpItemData.scope=="admin-item"){c="pageviews"}else{c="sessions"}}else{j=d.getCookie("default_metric");l=d.getCookie("default_dimension");m=d.getCookie("default_view");c=d.getCookie("default_swmetric")}if(n==false){if(gadwpItemData.scope=="front-item"||gadwpItemData.scope=="admin-item"){k=""}else{k='<span id="gadwp-swmetric-sessions" title="'+gadwpItemData.i18n[5]+'" class="dashicons dashicons-clock" style="font-size:22px;padding:4px;"></span>'}k+='<span id="gadwp-swmetric-users" title="'+gadwpItemData.i18n[6]+'" class="dashicons dashicons-admin-users" style="font-size:22px;padding:4px;"></span>';k+='<span id="gadwp-swmetric-pageviews" title="'+gadwpItemData.i18n[7]+'" class="dashicons dashicons-admin-page" style="font-size:22px;padding:4px;"></span>';jQuery(o).html(k);jQuery("#gadwp-swmetric-"+c).css("color","#008ec2")}else{jQuery.each(n,function(p,q){if(p==j||p==l||p==m){k.push('<option value="'+p+'" selected="selected">'+q+"</option>")}else{k.push('<option value="'+p+'">'+q+"</option>")}});jQuery(o).html(k.join(""))}},init:function(){var j;if(!jQuery("#gadwp-window"+b).length){return}if(jQuery("#gadwp-window"+b).html().length){return}j='<div id="gadwp-container'+b+'">';if(gadwpItemData.viewList!=false){j+='<select id="gadwp-sel-view'+b+'"></select>'}j+='<select id="gadwp-sel-period'+b+'"></select> ';j+='<select id="gadwp-sel-report'+b+'"></select>';j+='<div id="gadwp-sel-metric'+b+'" style="float:right;display:none;">';j+="</div>";j+='<div id="gadwp-progressbar'+b+'"></div>';j+='<div id="gadwp-status'+b+'"></div>';j+='<div id="gadwp-reports'+b+'"></div>';j+='<div style="text-align:right;width:100%;font-size:0.8em;clear:both;margin-right:5px;margin-top:10px;">';j+=gadwpItemData.i18n[14];j+=' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=back_report&utm_campaign=gadwp" rel="nofollow" style="text-decoration:none;font-size:1em;">GADWP</a>&nbsp;';j+="</div>";j+="</div>",jQuery("#gadwp-window"+b).append(j);h.addOptions("#gadwp-sel-view"+b,gadwpItemData.viewList);h.addOptions("#gadwp-sel-period"+b,gadwpItemData.dateList);h.addOptions("#gadwp-sel-report"+b,gadwpItemData.reportList);h.addOptions("#gadwp-sel-metric"+b,false)}};e={oldViewPort:0,orgChartTableChartData:"",tableChartData:"",orgChartPieChartsData:"",geoChartTableChartData:"",areaChartBottomStatsData:"",realtime:"",rtRuns:null,i18n:null,getTitle:function(j){if(j=="admin-item"){return jQuery("#gadwp"+b).attr("title")}else{return document.getElementsByTagName("title")[0].innerHTML}},alertMessage:function(j){jQuery("#gadwp-status"+b).css({"margin-top":"3px","padding-left":"5px",height:"auto",color:"#000","border-left":"5px solid red"});jQuery("#gadwp-status"+b).html(j)},areaChartBottomStats:function(j){e.areaChartBottomStatsData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();if(a.query=="visitBounceRate,bottomstats"){e.drawAreaChart(j[0],true)}else{e.drawAreaChart(j[0],false)}}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-areachart"+b,j[0],"125px")}if(!jQuery.isNumeric(j[1])){if(jQuery.isArray(j[1])){jQuery("#gadwp-reports"+b).show();e.drawBottomStats(j[1])}else{e.throwDebug(j[1])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-bottomstats"+b,j[1],"40px")}}else{e.throwDebug(j)}NProgress.done()},orgChartPieCharts:function(j){var k=0;e.orgChartPieChartsData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawOrgChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-orgchart"+b,j[0],"125px")}for(k=1;k<j.length;k++){if(!jQuery.isNumeric(j[k])){if(jQuery.isArray(j[k])){jQuery("#gadwp-reports"+b).show();e.drawPieChart("piechart-"+k,j[k],e.i18n[k])}else{e.throwDebug(j[k])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-piechart-"+k+b,j[k],"80px")}}}else{e.throwDebug(j)}NProgress.done()},geoChartTableChart:function(j){e.geoChartTableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawGeoChart(j[0]);e.drawTableChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-geochart"+b,j[0],"125px");e.throwError("#gadwp-tablechart"+b,j[0],"125px")}}else{e.throwDebug(j)}NProgress.done()},orgChartTableChart:function(j){e.orgChartTableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawOrgChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-orgchart"+b,j[0],"125px")}if(!jQuery.isNumeric(j[1])){if(jQuery.isArray(j[1])){e.drawTableChart(j[1])}else{e.throwDebug(j[1])}}else{e.throwError("#gadwp-tablechart"+b,j[1],"125px")}}else{e.throwDebug(j)}NProgress.done()},tableChart:function(j){e.tableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawTableChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-tablechart"+b,j[0],"125px")}}else{e.throwDebug(j)}NProgress.done()},drawTableChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={page:"enable",pageSize:10,width:"100%",allowHtml:true};k=new google.visualization.Table(document.getElementById("gadwp-tablechart"+b));k.draw(l,j)},drawOrgChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={allowCollapse:true,allowHtml:true,height:"100%"};k=new google.visualization.OrgChart(document.getElementById("gadwp-orgchart"+b));k.draw(l,j)},drawPieChart:function(o,m,n){var l,j,k;l=google.visualization.arrayToDataTable(m);j={is3D:false,tooltipText:"percentage",legend:"none",chartArea:{width:"99%",height:"80%"},title:n,pieSliceText:"value",colors:gadwpItemData.colorVariations};k=new google.visualization.PieChart(document.getElementById("gadwp-"+o+b));k.draw(l,j)},drawGeoChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={chartArea:{width:"99%",height:"90%"},colors:[gadwpItemData.colorVariations[5],gadwpItemData.colorVariations[4]]};if(gadwpItemData.region){j.region=gadwpItemData.region;j.displayMode="markers";j.datalessRegionColor="EFEFEF"}k=new google.visualization.GeoChart(document.getElementById("gadwp-geochart"+b));k.draw(l,j)},drawAreaChart:function(n,o){var m,j,l,k;m=google.visualization.arrayToDataTable(n);if(o){k=new google.visualization.NumberFormat({suffix:"%",fractionDigits:2});k.format(m,1)}j={legend:{position:"none"},pointSize:3,colors:[gadwpItemData.colorVariations[0],gadwpItemData.colorVariations[4]],chartArea:{width:"99%",height:"90%"},vAxis:{textPosition:"in",minValue:0},hAxis:{textPosition:"none"}};l=new google.visualization.AreaChart(document.getElementById("gadwp-areachart"+b));l.draw(m,j)},drawBottomStats:function(j){jQuery("#gdsessions"+b).html(j[0]);jQuery("#gdusers"+b).html(j[1]);jQuery("#gdpageviews"+b).html(j[2]);jQuery("#gdbouncerate"+b).html(j[3]);jQuery("#gdorganicsearch"+b).html(j[4]);jQuery("#gdpagespervisit"+b).html(j[5]);jQuery("#gdpagetime"+b).html(j[6]);jQuery("#gdpageload"+b).html(j[7]);jQuery("#gdsessionduration"+b).html(j[8])},rtOnlyUniqueValues:function(l,k,j){return j.indexOf(l)===k},rtCountSessions:function(k,m){var l=0,j=0;for(j=0;j<k.rows.length;j++){if(jQuery.inArray(m,k.rows[j])>-1){l+=parseInt(k.rows[j][6])}}return l},rtGenerateTooltip:function(k){var m=0,l="",j=0;for(j=0;j<k.length;j++){m+=parseInt(k[j].count);l+="<tr><td class='gadwp-pgdetailsl'>"+k[j].value+"</td><td class='gadwp-pgdetailsr'>"+k[j].count+"</td></tr>"}if(m){return("<table>"+l+"</table>")}else{return("")}},rtPageDetails:function(y,n){var w,o,r,x=0,v=0,m=0,s=0,t=0,z=0,C=0,q=0,l=0,u="",A="",p="",k="",B="";y=y.rows;for(x=0;x<y.length;x++){if(y[x][0]==n){o=y[x][5];switch(y[x][3]){case"REFERRAL":t+=parseInt(y[x][6]);u+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"ORGANIC":z+=parseInt(y[x][6]);A+="<tr><td class='gadwp-pgdetailsl'>"+y[x][2]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"SOCIAL":q+=parseInt(y[x][6]);p+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"CUSTOM":l+=parseInt(y[x][6]);k+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"DIRECT":C+=parseInt(y[x][6]);break}}}if(t){u="<table><tr><td>"+e.i18n[0]+"("+t+")</td></tr>"+u+"</table><br />"}if(z){A="<table><tr><td>"+e.i18n[1]+"("+z+")</td></tr>"+A+"</table><br />"}if(q){p="<table><tr><td>"+e.i18n[2]+"("+q+")</td></tr>"+p+"</table><br />"}if(l){k="<table><tr><td>"+e.i18n[3]+"("+l+")</td></tr>"+k+"</table><br />"}if(C){B="<table><tr><td>"+e.i18n[4]+"("+C+")</td></tr></table><br />"}return("<p><center><strong>"+o+"</strong></center></p>"+u+A+p+k+B)},rtRefresh:function(){if(e.render.focusFlag){a.from=false;a.to=false;a.query="realtime";jQuery.post(gadwpItemData.ajaxurl,a,function(j){if(jQuery.isArray(j)){jQuery("#gadwp-reports"+b).show();e.realtime=j[0];e.drawRealtime(e.realtime)}else{e.throwDebug(j)}NProgress.done()})}},drawRealtime:function(y){var j,n,o,w,t,r,x=0,v=[],z=[],p=[],m=[],q=[],k=[],l=[],s="",o=[],w=[],t=[],r=[],u=["REFERRAL","ORGANIC","SOCIAL","CUSTOM"],A=["DIRECT","NEW"];jQuery(function(){jQuery("#gadwp-widget *").tooltip({tooltipClass:"gadwp"})});y=y[0];if(jQuery.isNumeric(y)||typeof y==="undefined"){y=[];y.totalsForAllResults=[];y.totalsForAllResults["rt:activeUsers"]="0";y.rows=[]}if(y.totalsForAllResults["rt:activeUsers"]!==document.getElementById("gadwp-online").innerHTML){jQuery("#gadwp-online").fadeOut("slow");jQuery("#gadwp-online").fadeOut(500);jQuery("#gadwp-online").fadeOut("slow",function(){if((parseInt(y.totalsForAllResults["rt:activeUsers"]))<(parseInt(document.getElementById("gadwp-online").innerHTML))){jQuery("#gadwp-online").css({"background-color":"#FFE8E8"})}else{jQuery("#gadwp-online").css({"background-color":"#E0FFEC"})}document.getElementById("gadwp-online").innerHTML=y.totalsForAllResults["rt:activeUsers"]});jQuery("#gadwp-online").fadeIn("slow");jQuery("#gadwp-online").fadeIn(500);jQuery("#gadwp-online").fadeIn("slow",function(){jQuery("#gadwp-online").css({"background-color":"#FFFFFF"})})}if(y.totalsForAllResults["rt:activeUsers"]==0){y.rows=[]}for(x=0;x<y.rows.length;x++){v.push(y.rows[x][0]);if(y.rows[x][3]=="REFERRAL"){z.push(y.rows[x][1])}if(y.rows[x][3]=="ORGANIC"){p.push(y.rows[x][2])}if(y.rows[x][3]=="SOCIAL"){m.push(y.rows[x][1])}if(y.rows[x][3]=="CUSTOM"){k.push(y.rows[x][1])}q.push(y.rows[x][3])}n=v.filter(e.rtOnlyUniqueValues);for(x=0;x<n.length;x++){l[x]={pagepath:n[x],count:e.rtCountSessions(y,n[x])}}l.sort(function(C,B){return B.count-C.count});s="";for(x=0;x<l.length;x++){if(x<gadwpItemData.rtLimitPages){s+='<div class="gadwp-pline"><div class="gadwp-pleft"><a href="#" data-gadwp="'+e.rtPageDetails(y,l[x].pagepath)+'">'+l[x].pagepath.substring(0,70)+'</a></div><div class="gadwp-pright">'+l[x].count+"</div></div>"}}document.getElementById("gadwp-pages").innerHTML='<br /><div class="gadwp-pg">'+s+"</div>";o=z.filter(e.rtOnlyUniqueValues);for(x=0;x<o.length;x++){o[x]={value:o[x],count:e.rtCountSessions(y,o[x])}}o.sort(function(C,B){return B.count-C.count});w=p.filter(e.rtOnlyUniqueValues);for(x=0;x<w.length;x++){w[x]={value:w[x],count:e.rtCountSessions(y,w[x])}}w.sort(function(C,B){return B.count-C.count});t=m.filter(e.rtOnlyUniqueValues);for(x=0;x<t.length;x++){t[x]={value:t[x],count:e.rtCountSessions(y,t[x])}}t.sort(function(C,B){return B.count-C.count});r=k.filter(e.rtOnlyUniqueValues);for(x=0;x<r.length;x++){r[x]={value:r[x],count:e.rtCountSessions(y,r[x])}}r.sort(function(C,B){return B.count-C.count});j='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(o)+'"><div class="gadwp-bleft">'+e.i18n[0]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[0])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(w)+'"><div class="gadwp-bleft">'+e.i18n[1]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[1])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(t)+'"><div class="gadwp-bleft">'+e.i18n[2]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[2])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(r)+'"><div class="gadwp-bleft">'+e.i18n[3]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[3])+"</div></div>";j+='<div class="gadwp-bigtext"><div class="gadwp-bleft">'+e.i18n[4]+'</div><div class="gadwp-bright">'+e.rtCountSessions(y,A[0])+"</div></div>";j+='<div class="gadwp-bigtext"><div class="gadwp-bleft">'+e.i18n[5]+'</div><div class="gadwp-bright">'+e.rtCountSessions(y,A[1])+"</div></div>";document.getElementById("gadwp-tdo-right").innerHTML=j},throwDebug:function(j){jQuery("#gadwp-status"+b).css({"margin-top":"3px","padding-left":"5px",height:"auto",color:"#000","border-left":"5px solid red"});if(j=="-24"){jQuery("#gadwp-status"+b).html(gadwpItemData.i18n[15])}else{jQuery("#gadwp-reports"+b).css({"background-color":"#F7F7F7",height:"auto","margin-top":"10px","padding-top":"50px","padding-bottom":"50px",color:"#000","text-align":"center"});jQuery("#gadwp-reports"+b).html(j);jQuery("#gadwp-reports"+b).show();jQuery("#gadwp-status"+b).html(gadwpItemData.i18n[11]);console.log("\n********************* GADWP Log ********************* \n\n"+j);a={action:"gadwp_set_error",response:j,gadwp_security_set_error:gadwpItemData.security};jQuery.post(gadwpItemData.ajaxurl,a)}},throwError:function(l,j,k){jQuery(l).css({"background-color":"#F7F7F7",height:"auto","padding-top":k,"padding-bottom":k,color:"#000","text-align":"center"});if(j==-21){jQuery(l).html(gadwpItemData.i18n[12]+" ("+j+")")}else{jQuery(l).html(gadwpItemData.i18n[13]+" ("+j+")")}},render:function(j,o,n){var k,q,p,l,m;if(o=="realtime"){jQuery("#gadwp-sel-report"+b).hide()}else{jQuery("#gadwp-sel-report"+b).show();clearInterval(e.rtRuns)}jQuery("#gadwp-status"+b).html("");switch(o){case"today":q="today";p="today";break;case"yesterday":q="yesterday";p="yesterday";break;case"7daysAgo":q="7daysAgo";p="yesterday";break;case"14daysAgo":q="14daysAgo";p="yesterday";break;case"90daysAgo":q="90daysAgo";p="yesterday";break;case"365daysAgo":q="365daysAgo";p="yesterday";break;case"1095daysAgo":q="1095daysAgo";p="yesterday";break;default:q="30daysAgo";p="yesterday";break}d.setCookie("default_metric",n);d.setCookie("default_dimension",o);if(typeof j!=="undefined"){d.setCookie("default_view",j);k=j}else{k=false}if(gadwpItemData.scope=="admin-item"){a={action:"gadwp_backend_item_reports",gadwp_security_backend_item_reports:gadwpItemData.security,from:q,to:p,filter:g}}else{if(gadwpItemData.scope=="front-item"){a={action:"gadwp_frontend_item_reports",gadwp_security_frontend_item_reports:gadwpItemData.security,from:q,to:p,filter:gadwpItemData.filter}}else{a={action:"gadwp_backend_item_reports",gadwp_security_backend_item_reports:gadwpItemData.security,projectId:k,from:q,to:p}}}if(o=="realtime"){e.i18n=gadwpItemData.i18n.slice(20,26);e.render.focusFlag=1;jQuery(window).bind("focus",function(r){e.render.focusFlag=1}).bind("blur",function(r){e.render.focusFlag=0});l='<div id="gadwp-realtime'+b+'">';l+='<div class="gadwp-rt-box">';l+='<div class="gadwp-tdo-left">';l+='<div class="gadwp-online" id="gadwp-online">0</div>';l+="</div>";l+='<div class="gadwp-tdo-right" id="gadwp-tdo-right">';l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[0]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[1]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[2]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[3]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[4]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[5]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+="</div>";l+="</div>";l+="<div>";l+='<div id="gadwp-pages" class="gadwp-pages">&nbsp;</div>';l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);e.rtRefresh(e.render.focusFlag);e.rtRuns=setInterval(e.rtRefresh,55000)}else{if(jQuery.inArray(n,["referrers","contentpages","searches"])>-1){l='<div id="gadwp-orgcharttablechart'+b+'">';l+='<div id="gadwp-orgchart'+b+'"></div>';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query="channelGrouping,"+n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.orgChartTableChart(r)})}else{if(n=="404errors"){l='<div id="gadwp-404tablechart'+b+'">';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query=n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.tableChart(r)})}else{if(n=="trafficdetails"||n=="technologydetails"){l='<div id="gadwp-orgchartpiecharts'+b+'">';l+='<div id="gadwp-orgchart'+b+'"></div>';l+='<div class="gadwp-floatwraper">';l+='<div id="gadwp-piechart-1'+b+'" class="halfsize floatleft"></div>';l+='<div id="gadwp-piechart-2'+b+'" class="halfsize floatright"></div>';l+="</div>";l+='<div class="gadwp-floatwraper">';l+='<div id="gadwp-piechart-3'+b+'" class="halfsize floatleft"></div>';l+='<div id="gadwp-piechart-4'+b+'" class="halfsize floatright"></div>';l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();if(n=="trafficdetails"){a.query="channelGrouping,medium,visitorType,source,socialNetwork";e.i18n=gadwpItemData.i18n.slice(0,5)}else{e.i18n=gadwpItemData.i18n.slice(15,20);a.query="deviceCategory,browser,operatingSystem,screenResolution,mobileDeviceBranding"}a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.orgChartPieCharts(r)})}else{if(n=="locations"){l='<div id="gadwp-geocharttablechart'+b+'">';l+='<div id="gadwp-geochart'+b+'"></div>';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query=n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.geoChartTableChart(r)})}else{l='<div id="gadwp-areachartbottomstats'+b+'">';l+='<div id="gadwp-areachart'+b+'"></div>';l+='<div id="gadwp-bottomstats'+b+'">';l+='<div class="inside">';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[5]+'</h3><p id="gdsessions'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[6]+'</h3><p id="gdusers'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[7]+'</h3><p id="gdpageviews'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[8]+'</h3><p id="gdbouncerate'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[9]+'</h3><p id="gdorganicsearch'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[10]+'</h3><p id="gdpagespervisit'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[26]+'</h3><p id="gdpagetime'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[27]+'</h3><p id="gdpageload'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[28]+'</h3><p id="gdsessionduration'+b+'">&nbsp;</p></div>';l+="</div>";l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();a.query=n+",bottomstats";jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.areaChartBottomStats(r)})}}}}}},refresh:function(){if(jQuery("#gadwp-areachartbottomstats"+b).length>0&&jQuery.isArray(e.areaChartBottomStatsData)){e.areaChartBottomStats(e.areaChartBottomStatsData)}if(jQuery("#gadwp-orgchartpiecharts"+b).length>0&&jQuery.isArray(e.orgChartPieChartsData)){e.orgChartPieCharts(e.orgChartPieChartsData)}if(jQuery("#gadwp-geocharttablechart"+b).length>0&&jQuery.isArray(e.geoChartTableChartData)){e.geoChartTableChart(e.geoChartTableChartData)}if(jQuery("#gadwp-orgcharttablechart"+b).length>0&&jQuery.isArray(e.orgChartTableChartData)){e.orgChartTableChart(e.orgChartTableChartData)}if(jQuery("#gadwp-404tablechart"+b).length>0&&jQuery.isArray(e.tableChartData)){e.tableChart(e.tableChartData)}},init:function(){if(!jQuery("#gadwp-reports"+b).length){return}if(jQuery("#gadwp-reports"+b).html().length){return}try{NProgress.configure({parent:"#gadwp-progressbar"+b,showSpinner:false});NProgress.start()}catch(j){e.alertMessage(gadwpItemData.i18n[0])}e.render(jQuery("#gadwp-sel-view"+b).val(),jQuery("#gadwp-sel-period"+b).val(),jQuery("#gadwp-sel-report"+b).val());jQuery(window).resize(function(){var k=jQuery(window).width()-e.oldViewPort;if((k<-5)||(k>5)){e.oldViewPort=jQuery(window).width();e.refresh()}})}};h.init();e.init();jQuery("#gadwp-sel-view"+b).change(function(){jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("#gadwp-sel-period"+b).change(function(){jQuery("#gadwp-sel-metric"+b).hide();jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("#gadwp-sel-report"+b).change(function(){jQuery("#gadwp-sel-metric"+b).hide();jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("[id^=gadwp-swmetric-]").click(function(){c=this.id.replace("gadwp-swmetric-","");d.setCookie("default_swmetric",c);jQuery("#gadwp-swmetric-sessions").css("color","#444");jQuery("#gadwp-swmetric-users").css("color","#444");jQuery("#gadwp-swmetric-pageviews").css("color","#444");jQuery("#"+this.id).css("color","#008ec2");jQuery("#gadwp-reports"+b).html("");e.init()});if(gadwpItemData.scope=="admin-widgets"){return}else{return this.dialog({width:"auto",maxWidth:510,height:"auto",modal:true,fluid:true,dialogClass:"gadwp wp-dialog",resizable:false,title:e.getTitle(gadwpItemData.scope),position:{my:"top",at:"top+100",of:window}})}}});function GADWPReportLoad(){if(gadwpItemData.scope=="admin-widgets"){jQuery("#gadwp-window-1").gadwpItemReport(1)}else{jQuery(gadwpItemData.getSelector(gadwpItemData.scope)).click(function(){if(!jQuery("#gadwp-window-"+gadwpItemData.getID(this)).length>0){jQuery("body").append('<div id="gadwp-window-'+gadwpItemData.getID(this)+'"></div>')}jQuery("#gadwp-window-"+gadwpItemData.getID(this)).gadwpItemReport(gadwpItemData.getID(this))})}jQuery(window).resize(function(){gadwpItemData.responsiveDialog()});jQuery(document).on("dialogopen",".ui-dialog",function(a,b){gadwpItemData.responsiveDialog()})};
common/nprogress/nprogress.css CHANGED
@@ -1,87 +1 @@
1
- #nprogress {
2
- pointer-events: none;
3
- }
4
-
5
- #nprogress .bar {
6
- background: #29d;
7
- position: fixed;
8
- z-index: 1031;
9
- top: 0;
10
- left: 0;
11
- width: 100%;
12
- height: 2px;
13
- }
14
-
15
- /* Fancy blur effect */
16
- #nprogress .peg {
17
- display: block;
18
- position: absolute;
19
- right: 0px;
20
- width: 100px;
21
- height: 100%;
22
- box-shadow: 0 0 10px #29d, 0 0 5px #29d;
23
- opacity: 1.0;
24
- -webkit-transform: rotate(3deg) translate(0px, -4px);
25
- -ms-transform: rotate(3deg) translate(0px, -4px);
26
- transform: rotate(3deg) translate(0px, -4px);
27
- }
28
-
29
- /* Remove these to get rid of the spinner */
30
- #nprogress .spinner {
31
- display: block;
32
- position: fixed;
33
- z-index: 1031;
34
- top: 15px;
35
- right: 15px;
36
- }
37
-
38
- #nprogress .spinner-icon {
39
- width: 18px;
40
- height: 18px;
41
- box-sizing: border-box;
42
- border: solid 2px transparent;
43
- border-top-color: #29d;
44
- border-left-color: #29d;
45
- border-radius: 50%;
46
- -webkit-animation: nprogress-spinner 400ms linear infinite;
47
- animation: nprogress-spinner 400ms linear infinite;
48
- }
49
-
50
- .nprogress-custom-parent {
51
- overflow: hidden;
52
- position: relative;
53
- }
54
-
55
- .nprogress-custom-parent #nprogress .spinner, .nprogress-custom-parent #nprogress .bar {
56
- position: absolute;
57
- }
58
-
59
- @
60
- -webkit-keyframes nprogress-spinner { 0% {
61
- -webkit-transform: rotate(0deg);
62
- }
63
-
64
- 100%
65
- {
66
- -webkit-transform
67
- :
68
-
69
- rotate
70
- (360deg);
71
-
72
- }
73
- }
74
- @
75
- keyframes nprogress-spinner { 0% {
76
- transform: rotate(0deg);
77
- }
78
- 100%
79
- {
80
- transform
81
- :
82
-
83
- rotate
84
- (360deg);
85
-
86
- }
87
- }
1
+ #nprogress{pointer-events:none}#nprogress .bar{background:#29d;position:fixed;z-index:1031;top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;box-shadow:0 0 10px #29d,0 0 5px #29d;opacity:1;-webkit-transform:rotate(3deg) translate(0,-4px);-ms-transform:rotate(3deg) translate(0,-4px);transform:rotate(3deg) translate(0,-4px)}#nprogress .spinner{display:block;position:fixed;z-index:1031;top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;box-sizing:border-box;border:solid 2px transparent;border-top-color:#29d;border-left-color:#29d;border-radius:50%;-webkit-animation:nprogress-spinner 400ms linear infinite;animation:nprogress-spinner 400ms linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .spinner,.nprogress-custom-parent #nprogress .bar{position:absolute}@ -webkit-keyframes nprogress-spinner{0{-webkit-transform:rotate(0)}100%{-webkit-transform:rotate(360deg)}}@ keyframes nprogress-spinner{0{transform:rotate(0)}100%{transform:rotate(360deg)}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
common/nprogress/nprogress.js CHANGED
@@ -1,477 +1 @@
1
- /**
2
- * NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress * @license MIT
3
- */
4
-
5
- ;(function(root, factory) {
6
-
7
- if (typeof define === 'function' && define.amd) {
8
- define(factory);
9
- } else if (typeof exports === 'object') {
10
- module.exports = factory();
11
- } else {
12
- root.NProgress = factory();
13
- }
14
-
15
- })(this, function() {
16
- var NProgress = {};
17
-
18
- NProgress.version = '0.1.6';
19
-
20
- var Settings = NProgress.settings = {
21
- minimum: 0.08,
22
- easing: 'ease',
23
- positionUsing: '',
24
- speed: 200,
25
- trickle: true,
26
- trickleRate: 0.02,
27
- trickleSpeed: 800,
28
- showSpinner: true,
29
- barSelector: '[role="bar"]',
30
- spinnerSelector: '[role="spinner"]',
31
- parent: 'body',
32
- template: '<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'
33
- };
34
-
35
- /**
36
- * Updates configuration.
37
- *
38
- * NProgress.configure({
39
- * minimum: 0.1
40
- * });
41
- */
42
- NProgress.configure = function(options) {
43
- var key, value;
44
- for (key in options) {
45
- value = options[key];
46
- if (value !== undefined && options.hasOwnProperty(key)) Settings[key] = value;
47
- }
48
-
49
- return this;
50
- };
51
-
52
- /**
53
- * Last number.
54
- */
55
-
56
- NProgress.status = null;
57
-
58
- /**
59
- * Sets the progress bar status, where `n` is a number from `0.0` to `1.0`.
60
- *
61
- * NProgress.set(0.4);
62
- * NProgress.set(1.0);
63
- */
64
-
65
- NProgress.set = function(n) {
66
- var started = NProgress.isStarted();
67
-
68
- n = clamp(n, Settings.minimum, 1);
69
- NProgress.status = (n === 1 ? null : n);
70
-
71
- var progress = NProgress.render(!started),
72
- bar = progress.querySelector(Settings.barSelector),
73
- speed = Settings.speed,
74
- ease = Settings.easing;
75
-
76
- progress.offsetWidth; /* Repaint */
77
-
78
- queue(function(next) {
79
- // Set positionUsing if it hasn't already been set
80
- if (Settings.positionUsing === '') Settings.positionUsing = NProgress.getPositioningCSS();
81
-
82
- // Add transition
83
- css(bar, barPositionCSS(n, speed, ease));
84
-
85
- if (n === 1) {
86
- // Fade out
87
- css(progress, {
88
- transition: 'none',
89
- opacity: 1
90
- });
91
- progress.offsetWidth; /* Repaint */
92
-
93
- setTimeout(function() {
94
- css(progress, {
95
- transition: 'all ' + speed + 'ms linear',
96
- opacity: 0
97
- });
98
- setTimeout(function() {
99
- NProgress.remove();
100
- next();
101
- }, speed);
102
- }, speed);
103
- } else {
104
- setTimeout(next, speed);
105
- }
106
- });
107
-
108
- return this;
109
- };
110
-
111
- NProgress.isStarted = function() {
112
- return typeof NProgress.status === 'number';
113
- };
114
-
115
- /**
116
- * Shows the progress bar.
117
- * This is the same as setting the status to 0%, except that it doesn't go backwards.
118
- *
119
- * NProgress.start();
120
- *
121
- */
122
- NProgress.start = function() {
123
- if (!NProgress.status) NProgress.set(0);
124
-
125
- var work = function() {
126
- setTimeout(function() {
127
- if (!NProgress.status) return;
128
- NProgress.trickle();
129
- work();
130
- }, Settings.trickleSpeed);
131
- };
132
-
133
- if (Settings.trickle) work();
134
-
135
- return this;
136
- };
137
-
138
- /**
139
- * Hides the progress bar.
140
- * This is the *sort of* the same as setting the status to 100%, with the
141
- * difference being `done()` makes some placebo effect of some realistic motion.
142
- *
143
- * NProgress.done();
144
- *
145
- * If `true` is passed, it will show the progress bar even if its hidden.
146
- *
147
- * NProgress.done(true);
148
- */
149
-
150
- NProgress.done = function(force) {
151
- if (!force && !NProgress.status) return this;
152
-
153
- return NProgress.inc(0.3 + 0.5 * Math.random()).set(1);
154
- };
155
-
156
- /**
157
- * Increments by a random amount.
158
- */
159
-
160
- NProgress.inc = function(amount) {
161
- var n = NProgress.status;
162
-
163
- if (!n) {
164
- return NProgress.start();
165
- } else {
166
- if (typeof amount !== 'number') {
167
- amount = (1 - n) * clamp(Math.random() * n, 0.1, 0.95);
168
- }
169
-
170
- n = clamp(n + amount, 0, 0.994);
171
- return NProgress.set(n);
172
- }
173
- };
174
-
175
- NProgress.trickle = function() {
176
- return NProgress.inc(Math.random() * Settings.trickleRate);
177
- };
178
-
179
- /**
180
- * Waits for all supplied jQuery promises and
181
- * increases the progress as the promises resolve.
182
- *
183
- * @param $promise jQUery Promise
184
- */
185
- (function() {
186
- var initial = 0, current = 0;
187
-
188
- NProgress.promise = function($promise) {
189
- if (!$promise || $promise.state() == "resolved") {
190
- return this;
191
- }
192
-
193
- if (current == 0) {
194
- NProgress.start();
195
- }
196
-
197
- initial++;
198
- current++;
199
-
200
- $promise.always(function() {
201
- current--;
202
- if (current == 0) {
203
- initial = 0;
204
- NProgress.done();
205
- } else {
206
- NProgress.set((initial - current) / initial);
207
- }
208
- });
209
-
210
- return this;
211
- };
212
-
213
- })();
214
-
215
- /**
216
- * (Internal) renders the progress bar markup based on the `template`
217
- * setting.
218
- */
219
-
220
- NProgress.render = function(fromStart) {
221
- if (NProgress.isRendered()) return document.getElementById('nprogress');
222
-
223
- addClass(document.documentElement, 'nprogress-busy');
224
-
225
- var progress = document.createElement('div');
226
- progress.id = 'nprogress';
227
- progress.innerHTML = Settings.template;
228
-
229
- var bar = progress.querySelector(Settings.barSelector),
230
- perc = fromStart ? '-100' : toBarPerc(NProgress.status || 0),
231
- parent = document.querySelector(Settings.parent),
232
- spinner;
233
-
234
- css(bar, {
235
- transition: 'all 0 linear',
236
- transform: 'translate3d(' + perc + '%,0,0)'
237
- });
238
-
239
- if (!Settings.showSpinner) {
240
- spinner = progress.querySelector(Settings.spinnerSelector);
241
- spinner && removeElement(spinner);
242
- }
243
-
244
- if (parent != document.body) {
245
- addClass(parent, 'nprogress-custom-parent');
246
- }
247
-
248
- parent.appendChild(progress);
249
- return progress;
250
- };
251
-
252
- /**
253
- * Removes the element. Opposite of render().
254
- */
255
-
256
- NProgress.remove = function() {
257
- removeClass(document.documentElement, 'nprogress-busy');
258
- removeClass(document.querySelector(Settings.parent), 'nprogress-custom-parent')
259
- var progress = document.getElementById('nprogress');
260
- progress && removeElement(progress);
261
- };
262
-
263
- /**
264
- * Checks if the progress bar is rendered.
265
- */
266
-
267
- NProgress.isRendered = function() {
268
- return !!document.getElementById('nprogress');
269
- };
270
-
271
- /**
272
- * Determine which positioning CSS rule to use.
273
- */
274
-
275
- NProgress.getPositioningCSS = function() {
276
- // Sniff on document.body.style
277
- var bodyStyle = document.body.style;
278
-
279
- // Sniff prefixes
280
- var vendorPrefix = ('WebkitTransform' in bodyStyle) ? 'Webkit' :
281
- ('MozTransform' in bodyStyle) ? 'Moz' :
282
- ('msTransform' in bodyStyle) ? 'ms' :
283
- ('OTransform' in bodyStyle) ? 'O' : '';
284
-
285
- if (vendorPrefix + 'Perspective' in bodyStyle) {
286
- // Modern browsers with 3D support, e.g. Webkit, IE10
287
- return 'translate3d';
288
- } else if (vendorPrefix + 'Transform' in bodyStyle) {
289
- // Browsers without 3D support, e.g. IE9
290
- return 'translate';
291
- } else {
292
- // Browsers without translate() support, e.g. IE7-8
293
- return 'margin';
294
- }
295
- };
296
-
297
- /**
298
- * Helpers
299
- */
300
-
301
- function clamp(n, min, max) {
302
- if (n < min) return min;
303
- if (n > max) return max;
304
- return n;
305
- }
306
-
307
- /**
308
- * (Internal) converts a percentage (`0..1`) to a bar translateX
309
- * percentage (`-100%..0%`).
310
- */
311
-
312
- function toBarPerc(n) {
313
- return (-1 + n) * 100;
314
- }
315
-
316
-
317
- /**
318
- * (Internal) returns the correct CSS for changing the bar's
319
- * position given an n percentage, and speed and ease from Settings
320
- */
321
-
322
- function barPositionCSS(n, speed, ease) {
323
- var barCSS;
324
-
325
- if (Settings.positionUsing === 'translate3d') {
326
- barCSS = { transform: 'translate3d('+toBarPerc(n)+'%,0,0)' };
327
- } else if (Settings.positionUsing === 'translate') {
328
- barCSS = { transform: 'translate('+toBarPerc(n)+'%,0)' };
329
- } else {
330
- barCSS = { 'margin-left': toBarPerc(n)+'%' };
331
- }
332
-
333
- barCSS.transition = 'all '+speed+'ms '+ease;
334
-
335
- return barCSS;
336
- }
337
-
338
- /**
339
- * (Internal) Queues a function to be executed.
340
- */
341
-
342
- var queue = (function() {
343
- var pending = [];
344
-
345
- function next() {
346
- var fn = pending.shift();
347
- if (fn) {
348
- fn(next);
349
- }
350
- }
351
-
352
- return function(fn) {
353
- pending.push(fn);
354
- if (pending.length == 1) next();
355
- };
356
- })();
357
-
358
- /**
359
- * (Internal) Applies css properties to an element, similar to the jQuery
360
- * css method.
361
- *
362
- * While this helper does assist with vendor prefixed property names, it
363
- * does not perform any manipulation of values prior to setting styles.
364
- */
365
-
366
- var css = (function() {
367
- var cssPrefixes = [ 'Webkit', 'O', 'Moz', 'ms' ],
368
- cssProps = {};
369
-
370
- function camelCase(string) {
371
- return string.replace(/^-ms-/, 'ms-').replace(/-([\da-z])/gi, function(match, letter) {
372
- return letter.toUpperCase();
373
- });
374
- }
375
-
376
- function getVendorProp(name) {
377
- var style = document.body.style;
378
- if (name in style) return name;
379
-
380
- var i = cssPrefixes.length,
381
- capName = name.charAt(0).toUpperCase() + name.slice(1),
382
- vendorName;
383
- while (i--) {
384
- vendorName = cssPrefixes[i] + capName;
385
- if (vendorName in style) return vendorName;
386
- }
387
-
388
- return name;
389
- }
390
-
391
- function getStyleProp(name) {
392
- name = camelCase(name);
393
- return cssProps[name] || (cssProps[name] = getVendorProp(name));
394
- }
395
-
396
- function applyCss(element, prop, value) {
397
- prop = getStyleProp(prop);
398
- element.style[prop] = value;
399
- }
400
-
401
- return function(element, properties) {
402
- var args = arguments,
403
- prop,
404
- value;
405
-
406
- if (args.length == 2) {
407
- for (prop in properties) {
408
- value = properties[prop];
409
- if (value !== undefined && properties.hasOwnProperty(prop)) applyCss(element, prop, value);
410
- }
411
- } else {
412
- applyCss(element, args[1], args[2]);
413
- }
414
- }
415
- })();
416
-
417
- /**
418
- * (Internal) Determines if an element or space separated list of class names contains a class name.
419
- */
420
-
421
- function hasClass(element, name) {
422
- var list = typeof element == 'string' ? element : classList(element);
423
- return list.indexOf(' ' + name + ' ') >= 0;
424
- }
425
-
426
- /**
427
- * (Internal) Adds a class to an element.
428
- */
429
-
430
- function addClass(element, name) {
431
- var oldList = classList(element),
432
- newList = oldList + name;
433
-
434
- if (hasClass(oldList, name)) return;
435
-
436
- // Trim the opening space.
437
- element.className = newList.substring(1);
438
- }
439
-
440
- /**
441
- * (Internal) Removes a class from an element.
442
- */
443
-
444
- function removeClass(element, name) {
445
- var oldList = classList(element),
446
- newList;
447
-
448
- if (!hasClass(element, name)) return;
449
-
450
- // Replace the class name.
451
- newList = oldList.replace(' ' + name + ' ', ' ');
452
-
453
- // Trim the opening and closing spaces.
454
- element.className = newList.substring(1, newList.length - 1);
455
- }
456
-
457
- /**
458
- * (Internal) Gets a space separated list of the class names on the element.
459
- * The list is wrapped with a single space on each end to facilitate finding
460
- * matches within the list.
461
- */
462
-
463
- function classList(element) {
464
- return (' ' + (element.className || '') + ' ').replace(/\s+/gi, ' ');
465
- }
466
-
467
- /**
468
- * (Internal) Removes an element from the DOM.
469
- */
470
-
471
- function removeElement(element) {
472
- element && element.parentNode && element.parentNode.removeChild(element);
473
- }
474
-
475
- return NProgress;
476
- });
477
-
1
+ (function(a,b){if(typeof define==="function"&&define.amd){define(b)}else{if(typeof exports==="object"){module.exports=b()}else{a.NProgress=b()}}})(this,function(){var e={};e.version="0.1.6";var b=e.settings={minimum:0.08,easing:"ease",positionUsing:"",speed:200,trickle:true,trickleRate:0.02,trickleSpeed:800,showSpinner:true,barSelector:'[role="bar"]',spinnerSelector:'[role="spinner"]',parent:"body",template:'<div class="bar" role="bar"><div class="peg"></div></div><div class="spinner" role="spinner"><div class="spinner-icon"></div></div>'};e.configure=function(m){var n,o;for(n in m){o=m[n];if(o!==undefined&&m.hasOwnProperty(n)){b[n]=o}}return this};e.status=null;e.set=function(s){var m=e.isStarted();s=g(s,b.minimum,1);e.status=(s===1?null:s);var o=e.render(!m),p=o.querySelector(b.barSelector),q=b.speed,r=b.easing;o.offsetWidth;i(function(n){if(b.positionUsing===""){b.positionUsing=e.getPositioningCSS()}h(p,a(s,q,r));if(s===1){h(o,{transition:"none",opacity:1});o.offsetWidth;setTimeout(function(){h(o,{transition:"all "+q+"ms linear",opacity:0});setTimeout(function(){e.remove();n()},q)},q)}else{setTimeout(n,q)}});return this};e.isStarted=function(){return typeof e.status==="number"};e.start=function(){if(!e.status){e.set(0)}var m=function(){setTimeout(function(){if(!e.status){return}e.trickle();m()},b.trickleSpeed)};if(b.trickle){m()}return this};e.done=function(m){if(!m&&!e.status){return this}return e.inc(0.3+0.5*Math.random()).set(1)};e.inc=function(m){var o=e.status;if(!o){return e.start()}else{if(typeof m!=="number"){m=(1-o)*g(Math.random()*o,0.1,0.95)}o=g(o+m,0,0.994);return e.set(o)}};e.trickle=function(){return e.inc(Math.random()*b.trickleRate)};(function(){var m=0,n=0;e.promise=function(o){if(!o||o.state()=="resolved"){return this}if(n==0){e.start()}m++;n++;o.always(function(){n--;if(n==0){m=0;e.done()}else{e.set((m-n)/m)}});return this}})();e.render=function(m){if(e.isRendered()){return document.getElementById("nprogress")}j(document.documentElement,"nprogress-busy");var n=document.createElement("div");n.id="nprogress";n.innerHTML=b.template;var q=n.querySelector(b.barSelector),o=m?"-100":c(e.status||0),p=document.querySelector(b.parent),r;h(q,{transition:"all 0 linear",transform:"translate3d("+o+"%,0,0)"});if(!b.showSpinner){r=n.querySelector(b.spinnerSelector);r&&k(r)}if(p!=document.body){j(p,"nprogress-custom-parent")}p.appendChild(n);return n};e.remove=function(){l(document.documentElement,"nprogress-busy");l(document.querySelector(b.parent),"nprogress-custom-parent");var m=document.getElementById("nprogress");m&&k(m)};e.isRendered=function(){return !!document.getElementById("nprogress")};e.getPositioningCSS=function(){var m=document.body.style;var n=("WebkitTransform" in m)?"Webkit":("MozTransform" in m)?"Moz":("msTransform" in m)?"ms":("OTransform" in m)?"O":"";if(n+"Perspective" in m){return"translate3d"}else{if(n+"Transform" in m){return"translate"}else{return"margin"}}};function g(p,o,m){if(p<o){return o}if(p>m){return m}return p}function c(m){return(-1+m)*100}function a(q,o,p){var m;if(b.positionUsing==="translate3d"){m={transform:"translate3d("+c(q)+"%,0,0)"}}else{if(b.positionUsing==="translate"){m={transform:"translate("+c(q)+"%,0)"}}else{m={"margin-left":c(q)+"%"}}}m.transition="all "+o+"ms "+p;return m}var i=(function(){var n=[];function m(){var o=n.shift();if(o){o(m)}}return function(o){n.push(o);if(n.length==1){m()}}})();var h=(function(){var m=["Webkit","O","Moz","ms"],r={};function o(s){return s.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,function(t,u){return u.toUpperCase()})}function q(s){var u=document.body.style;if(s in u){return s}var t=m.length,w=s.charAt(0).toUpperCase()+s.slice(1),v;while(t--){v=m[t]+w;if(v in u){return v}}return s}function p(s){s=o(s);return r[s]||(r[s]=q(s))}function n(s,u,t){u=p(u);s.style[u]=t}return function(u,t){var s=arguments,w,v;if(s.length==2){for(w in t){v=t[w];if(v!==undefined&&t.hasOwnProperty(w)){n(u,w,v)}}}else{n(u,s[1],s[2])}}})();function f(n,m){var o=typeof n=="string"?n:d(n);return o.indexOf(" "+m+" ")>=0}function j(n,m){var p=d(n),o=p+m;if(f(p,m)){return}n.className=o.substring(1)}function l(n,m){var p=d(n),o;if(!f(n,m)){return}o=p.replace(" "+m+" "," ");n.className=o.substring(1,o.length-1)}function d(m){return(" "+(m.className||"")+" ").replace(/\s+/gi," ")}function k(m){m&&m.parentNode&&m.parentNode.removeChild(m)}return e});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
common/realtime/jquery.ui.tooltip.html.css CHANGED
@@ -1,54 +1,3 @@
1
  /*! jQuery UI - v1.9.2 - 2013-09-22
2
  * http://jqueryui.com
3
- * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
4
- .ui-tooltip.gadwp {
5
- padding: 8px;
6
- position: absolute;
7
- z-index: 9999;
8
- max-width: 300px;
9
- -webkit-box-shadow: 0 0 5px #aaa;
10
- box-shadow: 0 0 5px #aaa
11
- }
12
-
13
- * html .ui-tooltip.gadwp {
14
- background-image: none
15
- }
16
-
17
- body .ui-tooltip.gadwp {
18
- border-width: 2px
19
- }
20
-
21
- .ui-widget.gadwp {
22
- font-family: Verdana, Arial, sans-serif;
23
- font-size: 1.1em;
24
- }
25
-
26
- .ui-widget.gadwp .ui-widget {
27
- font-size: 1em;
28
- }
29
-
30
- .ui-widget.gadwp input, .ui-widget.gadwp select, .ui-widget.gadwp textarea, .ui-widget.gadwp button {
31
- font-family: Verdana, Arial, sans-serif;
32
- font-size: 1em;
33
- }
34
-
35
- .ui-widget-content.gadwp {
36
- border: 1px solid #aaaaaa;
37
- background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x;
38
- color: #222222;
39
- }
40
-
41
- .ui-widget-content.gadwp a {
42
- color: #222222;
43
- }
44
-
45
- .gadwp .ui-widget-header {
46
- border: 1px solid #aaaaaa;
47
- background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x;
48
- color: #222222;
49
- font-weight: bold;
50
- }
51
-
52
- .gadwp .ui-widget-header a {
53
- color: #222222;
54
- }
1
  /*! jQuery UI - v1.9.2 - 2013-09-22
2
  * http://jqueryui.com
3
+ * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */.ui-tooltip.gadwp{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}* html .ui-tooltip.gadwp{background-image:none}body .ui-tooltip.gadwp{border-width:2px}.ui-widget.gadwp{font-family:Verdana,Arial,sans-serif;font-size:1.1em}.ui-widget.gadwp .ui-widget{font-size:1em}.ui-widget.gadwp input,.ui-widget.gadwp select,.ui-widget.gadwp textarea,.ui-widget.gadwp button{font-family:Verdana,Arial,sans-serif;font-size:1em}.ui-widget-content.gadwp{border:1px solid #aaa;background:#fff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x;color:#222}.ui-widget-content.gadwp a{color:#222}.gadwp .ui-widget-header{border:1px solid #aaa;background:#ccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x;color:#222;font-weight:bold}.gadwp .ui-widget-header a{color:#222}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
common/realtime/jquery.ui.tooltip.html.js CHANGED
@@ -1,16 +1 @@
1
- /*-
2
- * Author: Alin Marcu Author
3
- * URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- jQuery(function () {
10
- jQuery('#gadwp-widget *').tooltip({
11
- items: "[data-gadwp]",
12
- content: function () {
13
- return jQuery(this).attr("data-gadwp");
14
- }
15
- });
16
- });
1
+ jQuery(function(){jQuery("#gadwp-widget *").tooltip({items:"[data-gadwp]",content:function(){return jQuery(this).attr("data-gadwp")}})});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
config.php CHANGED
@@ -45,7 +45,7 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
45
  if ( ! isset( $item['new_version'] ) || ! isset( $item['plugin'] ) || ! $this->options['automatic_updates_minorversion'] ) {
46
  return $update;
47
  }
48
- if ( isset( $item['slug'] ) && $item['slug'] == 'google-analytics-dashboard-for-wp' ) {
49
  // Only when a minor update is available
50
  return ( $this->get_major_version( GADWP_CURRENT_VERSION ) == $this->get_major_version( $item['new_version'] ) );
51
  }
@@ -58,79 +58,84 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
58
  }
59
 
60
  // Validates data before storing
61
- private static function validate_data( $options ) {
62
- if ( isset( $options['ga_realtime_pages'] ) ) {
63
- $options['ga_realtime_pages'] = (int) $options['ga_realtime_pages'];
64
- }
65
- if ( isset( $options['ga_crossdomain_tracking'] ) ) {
66
- $options['ga_crossdomain_tracking'] = (int) $options['ga_crossdomain_tracking'];
67
- }
68
- if ( isset( $options['ga_crossdomain_list'] ) ) {
69
- $options['ga_crossdomain_list'] = sanitize_text_field( $options['ga_crossdomain_list'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
- if ( isset( $options['ga_dash_clientid'] ) ) {
72
- $options['ga_dash_clientid'] = sanitize_text_field( $options['ga_dash_clientid'] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  }
74
- if ( isset( $options['ga_dash_clientsecret'] ) ) {
75
- $options['ga_dash_clientsecret'] = sanitize_text_field( $options['ga_dash_clientsecret'] );
 
 
76
  }
77
- if ( isset( $options['ga_dash_style'] ) ) {
78
- $options['ga_dash_style'] = sanitize_text_field( $options['ga_dash_style'] );
 
79
  }
80
- if ( isset( $options['ga_event_downloads'] ) ) {
81
- if ( empty( $options['ga_event_downloads'] ) ) {
82
- $options['ga_event_downloads'] = 'zip|mp3*|mpe*g|pdf|docx*|pptx*|xlsx*|rar*';
83
- }
84
- $options['ga_event_downloads'] = sanitize_text_field( $options['ga_event_downloads'] );
85
  }
 
86
  if ( isset( $options['ga_speed_samplerate'] ) && ( $options['ga_speed_samplerate'] < 1 || $options['ga_speed_samplerate'] > 100 ) ) {
87
  $options['ga_speed_samplerate'] = 1;
88
  }
89
- if ( isset( $options['ga_target_geomap'] ) ) {
90
- $options['ga_target_geomap'] = sanitize_text_field( $options['ga_target_geomap'] );
91
- }
92
- if ( isset( $options['ga_author_dimindex'] ) ) {
93
- $options['ga_author_dimindex'] = (int) $options['ga_author_dimindex'];
94
- }
95
- if ( isset( $options['ga_category_dimindex'] ) ) {
96
- $options['ga_category_dimindex'] = (int) $options['ga_category_dimindex'];
97
- }
98
- if ( isset( $options['ga_tag_dimindex'] ) ) {
99
- $options['ga_tag_dimindex'] = (int) $options['ga_tag_dimindex'];
100
- }
101
- if ( isset( $options['ga_user_dimindex'] ) ) {
102
- $options['ga_user_dimindex'] = (int) $options['ga_user_dimindex'];
103
- }
104
- if ( isset( $options['ga_pubyear_dimindex'] ) ) {
105
- $options['ga_pubyear_dimindex'] = (int) $options['ga_pubyear_dimindex'];
106
- }
107
- if ( isset( $options['ga_pubyearmonth_dimindex'] ) ) {
108
- $options['ga_pubyearmonth_dimindex'] = (int) $options['ga_pubyearmonth_dimindex'];
109
- }
110
- if ( isset( $options['ga_aff_tracking'] ) ) {
111
- $options['ga_aff_tracking'] = (int) $options['ga_aff_tracking'];
112
- }
113
- if ( isset( $options['ga_cookiedomain'] ) ) { // v4.9
114
- $options['ga_cookiedomain'] = sanitize_text_field( $options['ga_cookiedomain'] );
115
- }
116
- if ( isset( $options['ga_cookiename'] ) ) { // v4.9
117
- $options['ga_cookiename'] = sanitize_text_field( $options['ga_cookiename'] );
118
- }
119
- if ( isset( $options['pagetitle_404'] ) ) { // v4.9.4
120
- $options['pagetitle_404'] = sanitize_text_field( $options['pagetitle_404'] );
121
- }
122
- if ( isset( $options['maps_api_key'] ) ) { // v4.9.4
123
- $options['maps_api_key'] = sanitize_text_field( $options['maps_api_key'] );
124
- }
125
  if ( isset( $options['ga_cookieexpires'] ) && $options['ga_cookieexpires'] ) { // v4.9
126
  $options['ga_cookieexpires'] = (int) $options['ga_cookieexpires'];
127
  }
128
- if ( isset( $options['ga_event_affiliates'] ) ) {
129
- if ( empty( $options['ga_event_affiliates'] ) ) {
130
- $options['ga_event_affiliates'] = '/out/';
131
- }
132
- $options['ga_event_affiliates'] = sanitize_text_field( $options['ga_event_affiliates'] );
133
- }
134
 
135
  $token = json_decode( $options['ga_dash_token'] ); // v4.8.2
136
  if ( isset( $token->token_type ) ) {
@@ -235,182 +240,143 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
235
  GADWP_Tools::unset_cookie( 'default_dimension' );
236
  GADWP_Tools::unset_cookie( 'default_view' );
237
  }
238
- if ( ! isset( $this->options['ga_enhanced_links'] ) ) {
239
- $this->options['ga_enhanced_links'] = 0;
240
- $flag = true;
241
- }
242
- if ( ! isset( $this->options['ga_dash_network'] ) ) {
243
- $this->options['ga_dash_network'] = 0;
244
- $flag = true;
245
- }
246
- if ( ! isset( $this->options['ga_enhanced_excludesa'] ) ) {
247
- $this->options['ga_dash_excludesa'] = 0;
248
- $flag = true;
249
- }
250
- if ( ! isset( $this->options['ga_dash_remarketing'] ) ) {
251
- $this->options['ga_dash_remarketing'] = 0;
252
- $flag = true;
253
- }
254
- if ( ! isset( $this->options['ga_dash_adsense'] ) ) {
255
- $this->options['ga_dash_adsense'] = 0;
256
- $flag = true;
257
- }
258
- if ( ! isset( $this->options['ga_speed_samplerate'] ) ) {
259
- $this->options['ga_speed_samplerate'] = 1;
260
- $flag = true;
261
- }
262
- if ( ! isset( $this->options['automatic_updates_minorversion'] ) ) {
263
- $this->options['automatic_updates_minorversion'] = 1;
264
- $flag = true;
265
- }
266
- if ( ! isset( $this->options['ga_event_bouncerate'] ) ) {
267
- $this->options['ga_event_bouncerate'] = 0;
268
- $flag = true;
269
- }
270
- if ( ! is_array( $this->options['ga_dash_access_front'] ) || empty( $this->options['ga_dash_access_front'] ) ) {
271
- $this->options['ga_dash_access_front'] = array();
272
- $this->options['ga_dash_access_front'][] = 'administrator';
273
- $flag = true;
274
- }
275
 
276
- if ( ! is_array( $this->options['ga_dash_profile_list'] ) ) {
277
- $this->options['ga_dash_profile_list'] = array();
278
- $flag = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
  }
280
 
281
- if ( ! is_array( $this->options['ga_dash_access_back'] ) || empty( $this->options['ga_dash_access_back'] ) ) {
282
- $this->options['ga_dash_access_back'] = array();
283
- $this->options['ga_dash_access_back'][] = 'administrator';
284
- $flag = true;
285
- }
286
- if ( ! is_array( $this->options['ga_track_exclude'] ) ) {
287
- $this->options['ga_track_exclude'] = array();
288
- $flag = true;
289
- }
290
- if ( ! isset( $this->options['ga_crossdomain_tracking'] ) ) {
291
- $this->options['ga_crossdomain_tracking'] = 0;
292
- $flag = true;
293
- }
294
- if ( ! isset( $this->options['ga_crossdomain_list'] ) ) {
295
- $this->options['ga_crossdomain_list'] = '';
296
- $flag = true;
297
- }
298
- if ( ! isset( $this->options['ga_author_dimindex'] ) ) {
299
- $this->options['ga_author_dimindex'] = 0;
300
- $flag = true;
301
- }
302
- if ( ! isset( $this->options['ga_tag_dimindex'] ) ) {
303
- $this->options['ga_tag_dimindex'] = 0;
304
- $flag = true;
305
- }
306
- if ( ! isset( $this->options['ga_category_dimindex'] ) ) {
307
- $this->options['ga_category_dimindex'] = 0;
308
- $flag = true;
309
- }
310
- $options['ga_tag_dimindex'] = 0;
311
- if ( ! isset( $this->options['ga_user_dimindex'] ) ) {
312
- $this->options['ga_user_dimindex'] = 0;
313
- $flag = true;
314
- }
315
- if ( ! isset( $this->options['ga_pubyear_dimindex'] ) ) {
316
- $this->options['ga_pubyear_dimindex'] = 0;
317
- $flag = true;
318
- }
319
- if ( ! isset( $this->options['ga_pubyearmonth_dimindex'] ) ) {
320
- $this->options['ga_pubyearmonth_dimindex'] = 0;
321
- $flag = true;
322
- }
323
- if ( ! isset( $this->options['ga_event_affiliates'] ) ) {
324
- $this->options['ga_event_affiliates'] = '/out/';
325
- $flag = true;
326
- }
327
- if ( ! isset( $this->options['ga_aff_tracking'] ) ) {
328
- $this->options['ga_aff_tracking'] = 0;
329
- $flag = true;
330
- }
331
- if ( ! isset( $this->options['ga_hash_tracking'] ) ) {
332
- $this->options['ga_hash_tracking'] = 0;
333
- $flag = true;
334
- }
335
- if ( ! isset( $this->options['backend_item_reports'] ) ) { // v4.8
336
- $this->options['backend_item_reports'] = 1;
337
- $flag = true;
338
- }
339
- if ( isset( $this->options['ga_dash_default_metric'] ) ) { // v4.8.1
340
- unset( $this->options['ga_dash_default_metric'] );
341
- $flag = true;
342
- }
343
- if ( isset( $this->options['ga_dash_default_dimension'] ) ) { // v4.8.1
344
- unset( $this->options['ga_dash_default_dimension'] );
345
- $flag = true;
346
- }
347
  if ( isset( $this->options['item_reports'] ) ) { // v4.8
348
  $this->options['backend_item_reports'] = $this->options['item_reports'];
349
- unset( $this->options['item_reports'] );
350
- $flag = true;
351
  }
352
  if ( isset( $this->options['ga_dash_frontend_stats'] ) ) { // v4.8
353
  $this->options['frontend_item_reports'] = $this->options['ga_dash_frontend_stats'];
354
- unset( $this->options['ga_dash_frontend_stats'] );
355
- $flag = true;
356
  }
357
- if ( ! isset( $this->options['dashboard_widget'] ) ) { // v4.7
358
- $this->options['dashboard_widget'] = 1;
359
- $flag = true;
360
- }
361
- if ( ! isset( $this->options['api_backoff'] ) ) { // v4.8.1.3
362
- $this->options['api_backoff'] = 0;
363
- $flag = true;
 
 
 
 
 
 
 
 
 
 
 
364
  }
365
- if ( ! isset( $this->options['pagetitle_404'] ) ) { // v4.9.4
366
- $this->options['pagetitle_404'] = 'Page Not Found';
367
- $flag = true;
 
 
 
 
 
 
 
 
 
 
 
 
368
  }
369
- if ( ! isset( $this->options['maps_api_key'] ) ) { // v4.9.4
370
- $this->options['maps_api_key'] = '';
371
- $flag = true;
 
 
 
 
 
 
 
 
372
  }
373
- if ( isset( $this->options['ga_tracking_code'] ) ) {
374
- unset( $this->options['ga_tracking_code'] );
375
- $flag = true;
 
 
 
 
 
 
 
 
376
  }
377
- if ( isset( $this->options['ga_dash_tableid'] ) ) { // v4.9
378
- unset( $this->options['ga_dash_tableid'] );
379
- $flag = true;
380
  }
381
- if ( isset( $this->options['ga_dash_frontend_keywords'] ) ) { // v4.8
382
- unset( $this->options['ga_dash_frontend_keywords'] );
383
- $flag = true;
384
  }
385
- if ( isset( $this->options['ga_dash_apikey'] ) ) { // v4.9.1.3
386
- unset( $this->options['ga_dash_apikey'] );
 
 
387
  $flag = true;
388
  }
389
- if ( isset( $this->options['ga_dash_jailadmins'] ) ) { // v4.7
390
- if ( isset( $this->options['ga_dash_jailadmins'] ) ) {
391
- $this->options['switch_profile'] = 0;
392
- unset( $this->options['ga_dash_jailadmins'] );
393
- $flag = true;
394
- } else {
395
- $this->options['switch_profile'] = 1;
396
- unset( $this->options['ga_dash_jailadmins'] );
397
- $flag = true;
398
- }
399
- }
400
- if ( ! isset( $this->options['ga_cookiedomain'] ) ) {
401
- $this->options['ga_cookiedomain'] = '';
402
  $flag = true;
403
  }
404
- if ( ! isset( $this->options['ga_cookiedomain'] ) ) { // v4.9
405
- $this->options['ga_cookiedomain'] = '';
 
406
  $flag = true;
407
  }
408
- if ( ! isset( $this->options['ga_cookiename'] ) ) { // v4.9
409
- $this->options['ga_cookiename'] = '';
 
410
  $flag = true;
411
  }
412
- if ( ! isset( $this->options['ga_cookieexpires'] ) ) { // v4.9
413
- $this->options['ga_cookieexpires'] = '';
 
414
  $flag = true;
415
  }
416
 
45
  if ( ! isset( $item['new_version'] ) || ! isset( $item['plugin'] ) || ! $this->options['automatic_updates_minorversion'] ) {
46
  return $update;
47
  }
48
+ if ( isset( $item['slug'] ) && 'google-analytics-dashboard-for-wp' == $item['slug'] ) {
49
  // Only when a minor update is available
50
  return ( $this->get_major_version( GADWP_CURRENT_VERSION ) == $this->get_major_version( $item['new_version'] ) );
51
  }
58
  }
59
 
60
  // Validates data before storing
61
+ private function validate_data( $options ) {
62
+ /* @formatter:off */
63
+ $numerics = array( 'ga_realtime_pages',
64
+ 'ga_enhanced_links',
65
+ 'ga_crossdomain_tracking',
66
+ 'ga_author_dimindex',
67
+ 'ga_category_dimindex',
68
+ 'ga_tag_dimindex',
69
+ 'ga_user_dimindex',
70
+ 'ga_pubyear_dimindex',
71
+ 'ga_pubyearmonth_dimindex',
72
+ 'tm_author_var',
73
+ 'tm_category_var',
74
+ 'tm_tag_var',
75
+ 'tm_user_var',
76
+ 'tm_pubyear_var',
77
+ 'tm_pubyearmonth_var',
78
+ 'ga_aff_tracking',
79
+ 'amp_tracking_analytics',
80
+ 'amp_tracking_tagmanager',
81
+ 'optimize_tracking',
82
+ 'optimize_pagehiding',
83
+ 'trackingcode_infooter',
84
+ 'trackingevents_infooter',
85
+ 'ga_formsubmit_tracking',
86
+ 'ga_dash_excludesa',
87
+ 'ga_pagescrolldepth_tracking',
88
+ 'tm_pagescrolldepth_tracking',
89
+ );
90
+ foreach ( $numerics as $key ) {
91
+ if ( isset( $options[$key] ) ) {
92
+ $options[$key] = (int) $options[$key];
93
+ }
94
  }
95
+
96
+ $texts = array( 'ga_crossdomain_list',
97
+ 'ga_dash_clientid',
98
+ 'ga_dash_clientsecret',
99
+ 'ga_dash_style',
100
+ 'ga_target_geomap',
101
+ 'ga_cookiedomain',
102
+ 'ga_cookiename',
103
+ 'pagetitle_404',
104
+ 'maps_api_key',
105
+ 'web_containerid',
106
+ 'amp_containerid',
107
+ 'optimize_containerid',
108
+ 'ga_event_downloads',
109
+ 'ga_event_affiliates',
110
+ 'ecommerce_mode',
111
+ 'ga_dash_tracking_type',
112
+ );
113
+ foreach ( $texts as $key ) {
114
+ if ( isset( $options[$key] ) ) {
115
+ $options[$key] = trim (sanitize_text_field( $options[$key] ));
116
+ }
117
  }
118
+ /* @formatter:on */
119
+
120
+ if ( isset( $options['ga_event_downloads'] ) && empty( $options['ga_event_downloads'] ) ) {
121
+ $options['ga_event_downloads'] = 'zip|mp3*|mpe*g|pdf|docx*|pptx*|xlsx*|rar*';
122
  }
123
+
124
+ if ( isset( $options['pagetitle_404'] ) && empty( $options['pagetitle_404'] ) ) {
125
+ $options['pagetitle_404'] = 'Page Not Found';
126
  }
127
+
128
+ if ( isset( $options['ga_event_affiliates'] ) && empty( $options['ga_event_affiliates'] ) ) {
129
+ $options['ga_event_affiliates'] = '/out/';
 
 
130
  }
131
+
132
  if ( isset( $options['ga_speed_samplerate'] ) && ( $options['ga_speed_samplerate'] < 1 || $options['ga_speed_samplerate'] > 100 ) ) {
133
  $options['ga_speed_samplerate'] = 1;
134
  }
135
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  if ( isset( $options['ga_cookieexpires'] ) && $options['ga_cookieexpires'] ) { // v4.9
137
  $options['ga_cookieexpires'] = (int) $options['ga_cookieexpires'];
138
  }
 
 
 
 
 
 
139
 
140
  $token = json_decode( $options['ga_dash_token'] ); // v4.8.2
141
  if ( isset( $token->token_type ) ) {
240
  GADWP_Tools::unset_cookie( 'default_dimension' );
241
  GADWP_Tools::unset_cookie( 'default_view' );
242
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
 
244
+ /* @formatter:off */
245
+ $zeros = array( 'ga_enhanced_links',
246
+ 'ga_dash_network',
247
+ 'ga_enhanced_excludesa',
248
+ 'ga_dash_remarketing',
249
+ 'ga_event_bouncerate',
250
+ 'ga_author_dimindex',
251
+ 'ga_tag_dimindex',
252
+ 'ga_category_dimindex',
253
+ 'ga_user_dimindex',
254
+ 'ga_pubyear_dimindex',
255
+ 'ga_pubyearmonth_dimindex',
256
+ 'tm_author_var', // v5.0
257
+ 'tm_category_var', // v5.0
258
+ 'tm_tag_var', // v5.0
259
+ 'tm_user_var', // v5.0
260
+ 'tm_pubyear_var', // v5.0
261
+ 'tm_pubyearmonth_var', // v5.0
262
+ 'ga_crossdomain_tracking',
263
+ 'api_backoff', // v4.8.1.3
264
+ 'ga_aff_tracking',
265
+ 'ga_hash_tracking',
266
+ 'switch_profile', // V4.7
267
+ 'amp_tracking_analytics', //v5.0
268
+ 'optimize_tracking', //v5.0
269
+ 'optimize_pagehiding', //v5.0
270
+ 'amp_tracking_tagmanager', //v5.0
271
+ 'trackingcode_infooter', //v5.0
272
+ 'trackingevents_infooter', //v5.0
273
+ 'ga_formsubmit_tracking', //v5.0
274
+ 'ga_dash_excludesa', //v5.0
275
+ 'ga_pagescrolldepth_tracking', //v5.0
276
+ 'tm_pagescrolldepth_tracking', //v5.0
277
+ );
278
+ foreach ( $zeros as $key ) {
279
+ if ( ! isset( $this->options[$key] ) ) {
280
+ $this->options[$key] = 0;
281
+ $flag = true;
282
+ }
283
  }
284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  if ( isset( $this->options['item_reports'] ) ) { // v4.8
286
  $this->options['backend_item_reports'] = $this->options['item_reports'];
 
 
287
  }
288
  if ( isset( $this->options['ga_dash_frontend_stats'] ) ) { // v4.8
289
  $this->options['frontend_item_reports'] = $this->options['ga_dash_frontend_stats'];
 
 
290
  }
291
+
292
+ $unsets = array( 'ga_dash_jailadmins', // v4.7
293
+ 'ga_tracking_code',
294
+ 'ga_dash_tableid', // v4.9
295
+ 'ga_dash_frontend_keywords', // v4.8
296
+ 'ga_dash_apikey', // v4.9.1.3
297
+ 'ga_dash_default_metric', // v4.8.1
298
+ 'ga_dash_default_dimension', // v4.8.1
299
+ 'ga_dash_adsense', // v5.0
300
+ 'ga_dash_frontend_stats', // v4.8
301
+ 'item_reports', // v4.8
302
+ 'ga_dash_tracking', // v5.0
303
+ );
304
+ foreach ( $unsets as $key ) {
305
+ if ( isset( $this->options[$key] ) ) {
306
+ unset( $this->options[$key] );
307
+ $flag = true;
308
+ }
309
  }
310
+
311
+ $empties = array( 'ga_crossdomain_list',
312
+ 'ga_cookiedomain', // v4.9.4
313
+ 'ga_cookiename', // v4.9.4
314
+ 'ga_cookieexpires', // v4.9.4
315
+ 'maps_api_key', // v4.9.4
316
+ 'web_containerid', // v5.0
317
+ 'amp_containerid', // v5.0
318
+ 'optimize_containerid', // v5.0
319
+ );
320
+ foreach ( $empties as $key ) {
321
+ if ( ! isset( $this->options[$key] ) ) {
322
+ $this->options[$key] = '';
323
+ $flag = true;
324
+ }
325
  }
326
+
327
+ $ones = array( 'ga_speed_samplerate',
328
+ 'automatic_updates_minorversion',
329
+ 'backend_item_reports', // v4.8
330
+ 'dashboard_widget', // v4.7
331
+ );
332
+ foreach ( $ones as $key ) {
333
+ if ( ! isset( $this->options[$key] ) ) {
334
+ $this->options[$key] = 1;
335
+ $flag = true;
336
+ }
337
  }
338
+
339
+ $arrays = array( 'ga_dash_access_front',
340
+ 'ga_dash_access_back',
341
+ 'ga_dash_profile_list',
342
+ 'ga_track_exclude',
343
+ );
344
+ foreach ( $arrays as $key ) {
345
+ if ( ! is_array( $this->options[$key] ) ) {
346
+ $this->options[$key] = array();
347
+ $flag = true;
348
+ }
349
  }
350
+ if ( empty( $this->options['ga_dash_access_front'] ) ) {
351
+ $this->options['ga_dash_access_front'][] = 'administrator';
 
352
  }
353
+ if ( empty( $this->options['ga_dash_access_back'] ) ) {
354
+ $this->options['ga_dash_access_back'][] = 'administrator';
 
355
  }
356
+ /* @formatter:on */
357
+
358
+ if ( ! isset( $this->options['ga_event_affiliates'] ) ) {
359
+ $this->options['ga_event_affiliates'] = '/out/';
360
  $flag = true;
361
  }
362
+
363
+ if ( ! isset( $this->options['ga_event_downloads'] ) ) {
364
+ $this->options['ga_event_downloads'] = 'zip|mp3*|mpe*g|pdf|docx*|pptx*|xlsx*|rar*';
 
 
 
 
 
 
 
 
 
 
365
  $flag = true;
366
  }
367
+
368
+ if ( ! isset( $this->options['pagetitle_404'] ) ) { // v4.9.4
369
+ $this->options['pagetitle_404'] = 'Page Not Found';
370
  $flag = true;
371
  }
372
+
373
+ if ( ! isset( $this->options['ecommerce_mode'] ) ) { // v5.0
374
+ $this->options['ecommerce_mode'] = 'disabled';
375
  $flag = true;
376
  }
377
+
378
+ if ( 'classic' == $this->options['ga_dash_tracking_type'] ) { // v5.0
379
+ $this->options['ga_dash_tracking_type'] = 'universal';
380
  $flag = true;
381
  }
382
 
front/ajax-actions.php CHANGED
@@ -44,6 +44,11 @@ if ( ! class_exists( 'GADWP_Frontend_Ajax' ) ) {
44
  $to = $_POST['to'];
45
  $query = $_POST['query'];
46
  $uri = $_POST['filter'];
 
 
 
 
 
47
 
48
  $query = $_POST['query'];
49
  if ( ob_get_length() ) {
@@ -83,7 +88,7 @@ if ( ! class_exists( 'GADWP_Frontend_Ajax' ) ) {
83
 
84
  $lastchar = substr( $filter, - 1 );
85
 
86
- if ( isset( $profile_info[6] ) && $profile_info[6] && $lastchar == '/' ) {
87
  $filter = $filter . $profile_info[6];
88
  }
89
 
@@ -95,7 +100,7 @@ if ( ! class_exists( 'GADWP_Frontend_Ajax' ) ) {
95
  $results = array();
96
 
97
  foreach ( $queries as $value ) {
98
- $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to, $filter );
99
  }
100
 
101
  wp_send_json( $results );
44
  $to = $_POST['to'];
45
  $query = $_POST['query'];
46
  $uri = $_POST['filter'];
47
+ if ( isset( $_POST['metric'] ) ) {
48
+ $metric = $_POST['metric'];
49
+ } else {
50
+ $metric = 'pageviews';
51
+ }
52
 
53
  $query = $_POST['query'];
54
  if ( ob_get_length() ) {
88
 
89
  $lastchar = substr( $filter, - 1 );
90
 
91
+ if ( isset( $profile_info[6] ) && $profile_info[6] && '/' == $lastchar ) {
92
  $filter = $filter . $profile_info[6];
93
  }
94
 
100
  $results = array();
101
 
102
  foreach ( $queries as $value ) {
103
+ $results[] = $this->gadwp->gapi_controller->get( $projectId, $value, $from, $to, $filter, $metric );
104
  }
105
 
106
  wp_send_json( $results );
front/css/item-reports.css CHANGED
@@ -1,185 +1 @@
1
- /**
2
- * Author: Alin Marcu
3
- * Author URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- /* Frontend Item Reports */
10
- .column-gadwp_stats {
11
- width: 70px;
12
- }
13
-
14
- .gadwp-icon {
15
- color: #555;
16
- }
17
-
18
- .gadwp-icon:hover {
19
- color: #2ea2cc;
20
- }
21
-
22
- .gadwp-icon-oldwp {
23
- padding-top: 5px;
24
- }
25
-
26
- [id^=gadwp-container-] {
27
- width: 480px;
28
- }
29
-
30
- [id^=gadwp-areachart-] {
31
- height: 280px;
32
- }
33
-
34
- [id^=gadwp-progressbar-] {
35
- width: 100%;
36
- height: 3px;
37
- margin: 5px 0 0px 0;
38
- }
39
-
40
- [id^=gadwp-bottomstats-] {
41
- width: 100%;
42
- }
43
-
44
- [id^=gadwp-bottomstats-] .inside {
45
- display: table;
46
- margin: 0 auto;
47
- padding: 0px;
48
- }
49
-
50
- [id^=gadwp-bottomstats-] .inside .small-box {
51
- width: 31.2%;
52
- float: left;
53
- margin: 10px 5px 10px 5px;
54
- background: #fff;
55
- text-align: center;
56
- -moz-box-shadow: 0px 0px 7px 0px #BBB;
57
- -webkit-box-shadow: 0px 0px 7px 0px #BBB;
58
- box-shadow: 0px 0px 7px 0px #BBB;
59
- }
60
-
61
- [id^=gadwp-bottomstats-] .inside .small-box h3 {
62
- font-family: 'Open Sans', sans-serif;
63
- font-size: 1em;
64
- color: #777;
65
- padding: 0px 5px 0px 5px;
66
- margin: 0px 0px 0px 0px;
67
- text-overflow: ellipsis;
68
- overflow: hidden;
69
- white-space: nowrap;
70
- }
71
-
72
- [id^=gadwp-bottomstats-] .inside .small-box p {
73
- font-size: 1.2em;
74
- margin: 0px 0px 2px 0px;
75
- }
76
-
77
- .gadwp-floatwraper {
78
- display: table;
79
- width: 100%;
80
- height: 100%;
81
- }
82
-
83
- [id^=gadwp-piechart-].halfsize {
84
- width: 47%;
85
- margin: 10px 0 0 0;
86
- height: 200px;
87
- float: left;
88
- }
89
-
90
- [id^=gadwp-piechart-].floatleft {
91
- float: left;
92
- }
93
-
94
- [id^=gadwp-piechart-].floatright {
95
- float: right;
96
- }
97
-
98
- [id^=gadwp-tablechart-], [id^=gadwp-tablechart-] {
99
- margin: 10px 0 0 0;
100
- }
101
-
102
- .ui-dialog.gadwp {
103
- font-family: 'Open Sans', sans-serif;
104
- font-size: 13px;
105
- -webkit-box-sizing: initial;
106
- -moz-box-sizing: initial;
107
- }
108
-
109
- .ui-dialog.gadwp select {
110
- font-family: 'Open Sans', sans-serif;
111
- border: 1px solid #ddd;
112
- font-size: 14px;
113
- background: #fff;
114
- padding: 2px;
115
- color: #333;
116
- width: auto;
117
- }
118
-
119
- .ui-dialog.gadwp table {
120
- margin: auto;
121
- width: auto;
122
- }
123
-
124
- .gadwp .ui-dialog-titlebar {
125
- font-size: 1.1em;
126
- text-overflow: ellipsis;
127
- overflow: hidden;
128
- }
129
-
130
- @media screen and (max-width: 500px) {
131
- [id^=gadwp-container-] {
132
- width: 410px;
133
- }
134
- [id^=gadwp-bottomstats-] .inside .small-box {
135
- width: 30.8%;
136
- }
137
- }
138
-
139
- @media screen and (max-width: 410px) {
140
- [id^=gadwp-container-] {
141
- width: 260px;
142
- }
143
- [id^=gadwp-bottomstats-] .inside .small-box {
144
- width: 46%;
145
- }
146
- }
147
-
148
- /* Toolbar Node (Analytics menu item) */
149
- #wpadminbar #wp-admin-bar-gadwp-1>.ab-item:before {
150
- content: '\f239';
151
- top: 2px;
152
- }
153
-
154
- .no-font-face #wpadminbar #wp-admin-bar-gadwp-1>.ab-item {
155
- text-indent: 0;
156
- }
157
-
158
- @media screen and ( max-width: 782px ) {
159
- #wpadminbar #wp-admin-bar-gadwp-1>.ab-item {
160
- text-indent: 100%;
161
- white-space: nowrap;
162
- overflow: hidden;
163
- width: 52px;
164
- padding: 0;
165
- color: #999;
166
- position: relative;
167
- }
168
- #wpadminbar #wp-admin-bar-gadwp-1>.ab-item:before {
169
- display: block;
170
- text-indent: 0;
171
- font: normal 32px/1 'dashicons';
172
- speak: none;
173
- top: 7px;
174
- width: 52px;
175
- text-align: center;
176
- -webkit-font-smoothing: antialiased;
177
- -moz-osx-font-smoothing: grayscale;
178
- }
179
- #wpadminbar li#wp-admin-bar-gadwp-1 {
180
- display: block;
181
- }
182
- #wpadminbar #wp-admin-bar-gadwp-1 {
183
- position: static;
184
- }
185
- }
1
+ .column-gadwp_stats{width:70px}.gadwp-icon{color:#555}.gadwp-icon:hover{color:#2ea2cc}.gadwp-icon-oldwp{padding-top:5px}[id^=gadwp-container-]{width:480px}[id^=gadwp-areachart-]{height:280px}[id^=gadwp-progressbar-]{width:100%;height:3px;margin:5px 0 0 0}[id^=gadwp-bottomstats-]{width:100%}[id^=gadwp-bottomstats-] .inside{display:table;margin:0 auto;padding:0}[id^=gadwp-bottomstats-] .inside .small-box{width:31.2%;float:left;margin:10px 5px 10px 5px;background:#fff;text-align:center;-moz-box-shadow:0 0 7px 0 #BBB;-webkit-box-shadow:0 0 7px 0 #BBB;box-shadow:0 0 7px 0 #BBB}[id^=gadwp-bottomstats-] .inside .small-box h3{font-family:'Open Sans',sans-serif;font-size:1em;color:#777;padding:0 5px 0 5px;margin:0;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}[id^=gadwp-bottomstats-] .inside .small-box p{font-size:1.2em;margin:0 0 2px 0}.gadwp-floatwraper{display:table;width:100%;height:100%}[id^=gadwp-piechart-].halfsize{width:47%;margin:10px 0 0 0;height:200px;float:left}[id^=gadwp-piechart-].floatleft{float:left}[id^=gadwp-piechart-].floatright{float:right}[id^=gadwp-tablechart-],[id^=gadwp-tablechart-]{margin:10px 0 0 0}.ui-dialog.gadwp{font-family:'Open Sans',sans-serif;font-size:13px;-webkit-box-sizing:initial;-moz-box-sizing:initial}.ui-dialog.gadwp select{font-family:'Open Sans',sans-serif;border:1px solid #ddd;font-size:14px;background:#fff;padding:2px;color:#333;width:auto}.ui-dialog.gadwp table{margin:auto;width:auto}.gadwp .ui-dialog-titlebar{font-size:1.1em;text-overflow:ellipsis;overflow:hidden}@media screen and (max-width:500px){[id^=gadwp-container-]{width:410px}[id^=gadwp-bottomstats-] .inside .small-box{width:30.8%}}@media screen and (max-width:410px){[id^=gadwp-container-]{width:260px}[id^=gadwp-bottomstats-] .inside .small-box{width:46%}}#wpadminbar #wp-admin-bar-gadwp-1>.ab-item:before{content:'\f239';top:2px}.no-font-face #wpadminbar #wp-admin-bar-gadwp-1>.ab-item{text-indent:0}@media screen and (max-width:782px){#wpadminbar #wp-admin-bar-gadwp-1>.ab-item{text-indent:100%;white-space:nowrap;overflow:hidden;width:52px;padding:0;color:#999;position:relative}#wpadminbar #wp-admin-bar-gadwp-1>.ab-item:before{display:block;text-indent:0;font:normal 32px/1 'dashicons';speak:none;top:7px;width:52px;text-align:center;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#wpadminbar li#wp-admin-bar-gadwp-1{display:block}#wpadminbar #wp-admin-bar-gadwp-1{position:static}}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
front/css/widgets.css CHANGED
@@ -1,75 +1 @@
1
- /**
2
- * Author: Alin Marcu
3
- * Author URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
- #gadwp {
9
- font-family: 'Open Sans', sans-serif;
10
- }
11
-
12
- #gadwp-searches td {
13
- line-height: 1.5em;
14
- padding: 2px;
15
- font-size: 1em;
16
- }
17
-
18
- #gadwp-searches {
19
- line-height: 10px;
20
- margin-top: 15px;
21
- }
22
-
23
- #gadwp-visits {
24
- height: 200px;
25
- margin-top: 15px;
26
- }
27
-
28
- #gadwp-content {
29
- width: 100%;
30
- }
31
-
32
- #gadwp-title {
33
- text-transform: uppercase;
34
- font-weight: 600;
35
- font-size: 14px;
36
- padding-bottom: 2px;
37
- }
38
-
39
- #gadwp-widget {
40
- padding: 0 5px;
41
- }
42
-
43
- #gadwp-widgetchart {
44
- width: 100%;
45
- }
46
-
47
- #gadwp-widgettotals {
48
- margin: 0 0 10px 0;
49
- width: 100%;
50
- display: table;
51
- clear: both;
52
- }
53
-
54
- #gadwp-widgettotals .gadwp-left {
55
- padding: 10px 0 0 0;
56
- width: 45%;
57
- float: left;
58
- font-weight: 600;
59
- }
60
-
61
- #gadwp-progressbar {
62
- width: 100%;
63
- height: 3px;
64
- margin: 3px 0;
65
- }
66
-
67
- #gadwp-widgettotals .gadwp-right {
68
- padding: 10px 0 0 0;
69
- float: left;
70
- font-style: italic;
71
- }
72
-
73
- .widget_gadwp-frontwidget-report h2.widget-title {
74
- margin-bottom: 0px;
75
- }
1
+ #gadwp{font-family:'Open Sans',sans-serif}#gadwp-searches td{line-height:1.5em;padding:2px;font-size:1em}#gadwp-searches{line-height:10px;margin-top:15px}#gadwp-visits{height:200px;margin-top:15px}#gadwp-content{width:100%}#gadwp-title{text-transform:uppercase;font-weight:600;font-size:14px;padding-bottom:2px}#gadwp-widget{padding:0 5px}#gadwp-widgetchart{width:100%}#gadwp-widgettotals{margin:0 0 10px 0;width:100%;display:table;clear:both}#gadwp-widgettotals .gadwp-left{padding:10px 0 0 0;width:45%;float:left;font-weight:600}#gadwp-progressbar{width:100%;height:3px;margin:3px 0}#gadwp-widgettotals .gadwp-right{padding:10px 0 0 0;float:left;font-style:italic}.widget_gadwp-frontwidget-report h2.widget-title{margin-bottom:0}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
front/js/tracking-analytics-events.js ADDED
@@ -0,0 +1 @@
 
1
+ var gadwpRedirectLink;var gadwpRedirectCalled=false;function gadwpRedirect(){if(gadwpRedirectCalled){return}gadwpRedirectCalled=true;document.location.href=gadwpRedirectLink}(function(a){a(window).load(function(){if(gadwpUAEventsData.options.event_tracking){a("a").filter(function(){var b=new RegExp(".*\\.("+gadwpUAEventsData.options.event_downloads+")(\\?.*)?$");return this.href.match(b)}).click(function(b){if(gadwpUAEventsData.options.event_bouncerate){ga("send","event","download","click",this.href,{nonInteraction:1})}else{ga("send","event","download","click",this.href)}});a('a[href^="mailto"]').click(function(b){if(gadwpUAEventsData.options.event_bouncerate){ga("send","event","email","send",this.href,{nonInteraction:1})}else{ga("send","event","email","send",this.href)}});a('a[href^="tel"]').click(function(b){if(gadwpUAEventsData.options.event_bouncerate){ga("send","event","telephone","call",this.href,{nonInteraction:1})}else{ga("send","event","telephone","call",this.href)}});if(gadwpUAEventsData.options.root_domain){a('a[href^="http"]').filter(function(){var b=new RegExp(".*\\.("+gadwpUAEventsData.options.event_downloads+")(\\?.*)?$");if(!this.href.match(b)){if(this.href.indexOf(gadwpUAEventsData.options.root_domain)==-1){return this.href}}}).click(function(b){gadwpRedirectCalled=false;gadwpRedirectLink=this.href;if(gadwpUAEventsData.options.event_bouncerate){ga("send","event","outbound","click",this.href,{nonInteraction:1,hitCallback:gadwpRedirect})}else{ga("send","event","outbound","click",this.href,{hitCallback:gadwpRedirect})}if(this.target!="_blank"){setTimeout(gadwpRedirect,gadwpUAEventsData.options.event_timeout);return false}else{gadwpRedirectCalled=true}})}}if(gadwpUAEventsData.options.event_affiliates&&gadwpUAEventsData.options.aff_tracking){a("a").filter(function(){if(gadwpUAEventsData.options.event_affiliates!=""){var b=new RegExp("("+gadwpUAEventsData.options.event_affiliates.replace(/\//g,"/")+")");return this.href.match(b)}}).click(function(b){gadwpRedirectCalled=false;gadwpRedirectLink=this.href;if(gadwpUAEventsData.options.event_bouncerate){ga("send","event","affiliates","click",this.href,{nonInteraction:1,hitCallback:gadwpRedirect})}else{ga("send","event","affiliates","click",this.href,{hitCallback:gadwpRedirect})}if(this.target!="_blank"){setTimeout(gadwpRedirect,gadwpUAEventsData.options.event_timeout);return false}else{gadwpRedirectCalled=true}})}if(gadwpUAEventsData.options.root_domain&&gadwpUAEventsData.options.hash_tracking){a("a").filter(function(){if(this.href.indexOf(gadwpUAEventsData.options.root_domain)!=-1||this.href.indexOf("://")==-1){return this.hash}}).click(function(b){if(gadwpUAEventsData.options.event_bouncerate){ga("send","event","hashmark","click",this.href,{nonInteraction:1})}else{ga("send","event","hashmark","click",this.href)}})}if(gadwpUAEventsData.options.event_formsubmit){a('input[type="submit"]').click(function(c){gadwpSubmitObject=this;var b=gadwpSubmitObject.value;if(gadwpUAEventsData.options.event_formsubmit){ga("send","event","form","submit",b,{nonInteraction:1})}else{ga("send","event","form","submit",b)}})}if(gadwpUAEventsData.options.ga_pagescrolldepth_tracking){a.scrollDepth({percentage:true,userTiming:false,pixelDepth:false,gtmOverride:true,nonInteraction:gadwpUAEventsData.options.event_bouncerate})}})})(jQuery);
front/js/tracking-scrolldepth.js ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ /*!
2
+ * @preserve
3
+ * jquery.scrolldepth.js | v1.0
4
+ * Copyright (c) 2016 Rob Flaherty (@robflaherty)
5
+ * Licensed under the MIT and GPL licenses.
6
+ */
7
+ (function(a){if(typeof define==="function"&&define.amd){define(["jquery"],a)}else{if(typeof module==="object"&&module.exports){module.exports=a(require("jquery"))}else{a(jQuery)}}}(function(g){var f={minHeight:0,elements:[],percentage:true,userTiming:true,pixelDepth:true,nonInteraction:true,gaGlobal:false,gtmOverride:false,trackerName:false,dataLayer:"dataLayer"};var b=g(window),a=[],h=false,d=0,c,j,e,i;g.scrollDepth=function(t){var l=+new Date;t=g.extend({},f,t);if(g(document).height()<t.minHeight){return}if(t.gaGlobal){c=true;e=t.gaGlobal}else{if(typeof ga==="function"){c=true;e="ga"}else{if(typeof __gaTracker==="function"){c=true;e="__gaTracker"}}}if(typeof _gaq!=="undefined"&&typeof _gaq.push==="function"){j=true}if(typeof t.eventHandler==="function"){i=t.eventHandler}else{if(typeof window[t.dataLayer]!=="undefined"&&typeof window[t.dataLayer].push==="function"&&!t.gtmOverride){i=function(u){window[t.dataLayer].push(u)}}}function r(x,v,u,w){var y=t.trackerName?(t.trackerName+".send"):"send";if(i){i({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:x,eventLabel:v,eventValue:1,eventNonInteraction:t.nonInteraction});if(t.pixelDepth&&arguments.length>2&&u>d){d=u;i({event:"ScrollDistance",eventCategory:"Scroll Depth",eventAction:"Pixel Depth",eventLabel:m(u),eventValue:1,eventNonInteraction:t.nonInteraction})}if(t.userTiming&&arguments.length>3){i({event:"ScrollTiming",eventCategory:"Scroll Depth",eventAction:x,eventLabel:v,eventTiming:w})}}else{if(c){window[e](y,"event","Scroll Depth",x,v,1,{nonInteraction:t.nonInteraction});if(t.pixelDepth&&arguments.length>2&&u>d){d=u;window[e](y,"event","Scroll Depth","Pixel Depth",m(u),1,{nonInteraction:t.nonInteraction})}if(t.userTiming&&arguments.length>3){window[e](y,"timing","Scroll Depth",x,w,v)}}if(j){_gaq.push(["_trackEvent","Scroll Depth",x,v,1,t.nonInteraction]);if(t.pixelDepth&&arguments.length>2&&u>d){d=u;_gaq.push(["_trackEvent","Scroll Depth","Pixel Depth",m(u),1,t.nonInteraction])}if(t.userTiming&&arguments.length>3){_gaq.push(["_trackTiming","Scroll Depth",x,w,v,100])}}}}function q(u){return{"25%":parseInt(u*0.25,10),"50%":parseInt(u*0.5,10),"75%":parseInt(u*0.75,10),"100%":u-5}}function o(v,u,w){g.each(v,function(x,y){if(g.inArray(x,a)===-1&&u>=y){r("Percentage",x,u,w);a.push(x)}})}function n(w,u,v){g.each(w,function(x,y){if(g.inArray(y,a)===-1&&g(y).length){if(u>=g(y).offset().top){r("Elements",y,u,v);a.push(y)}}})}function m(u){return(Math.floor(u/250)*250).toString()}function s(){k()}g.scrollDepth.reset=function(){a=[];d=0;b.off("scroll.scrollDepth");k()};g.scrollDepth.addElements=function(u){if(typeof u=="undefined"||!g.isArray(u)){return}g.merge(t.elements,u);if(!h){k()}};g.scrollDepth.removeElements=function(u){if(typeof u=="undefined"||!g.isArray(u)){return}g.each(u,function(w,y){var v=g.inArray(y,t.elements);var x=g.inArray(y,a);if(v!=-1){t.elements.splice(v,1)}if(x!=-1){a.splice(x,1)}})};function p(z,B){var x,w,u;var A=null;var y=0;var v=function(){y=new Date;A=null;u=z.apply(x,w)};return function(){var C=new Date;if(!y){y=C}var D=B-(C-y);x=this;w=arguments;if(D<=0){clearTimeout(A);A=null;y=C;u=z.apply(x,w)}else{if(!A){A=setTimeout(v,D)}}return u}}function k(){h=true;b.on("scroll.scrollDepth",p(function(){var w=g(document).height(),v=window.innerHeight?window.innerHeight:b.height(),u=b.scrollTop()+v,x=q(w),y=+new Date-l;if(a.length>=t.elements.length+(t.percentage?4:0)){b.off("scroll.scrollDepth");h=false;return}if(t.elements){n(t.elements,u,y)}if(t.percentage){o(x,u,y)}},500))}s()};return g.scrollDepth}));
front/js/tracking-tagmanager-events.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(a){a(window).load(function(){a.scrollDepth({percentage:true,userTiming:false,pixelDepth:false,gtmOverride:false})})})(jQuery);
front/js/widgets.js CHANGED
@@ -1,13 +1 @@
1
- /*-
2
- * Author: Alin Marcu
3
- * Author URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- jQuery( window ).resize( function () {
10
- if ( typeof gadwp_drawFrontWidgetChart == "function" && typeof gadwpFrontWidgetData !== 'undefined' && !jQuery.isNumeric( gadwpFrontWidgetData ) ) {
11
- gadwp_drawFrontWidgetChart( gadwpFrontWidgetData );
12
- }
13
- } );
1
+ jQuery(window).resize(function(){if(typeof gadwp_drawFrontWidgetChart=="function"&&typeof gadwpFrontWidgetData!=="undefined"&&!jQuery.isNumeric(gadwpFrontWidgetData)){gadwp_drawFrontWidgetChart(gadwpFrontWidgetData)}});
 
 
 
 
 
 
 
 
 
 
 
 
front/setup.php CHANGED
@@ -57,7 +57,7 @@ if ( ! class_exists( 'GADWP_Frontend_Setup' ) ) {
57
 
58
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
59
 
60
- wp_enqueue_script( 'gadwp-frontend-item-reports', GADWP_URL . 'common/js/reports.js', array( 'gadwp-nprogress', 'googlecharts', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION, true );
61
 
62
  /* @formatter:off */
63
  wp_localize_script( 'gadwp-frontend-item-reports', 'gadwpItemData', array(
@@ -115,6 +115,7 @@ if ( ! class_exists( 'GADWP_Frontend_Setup' ) ) {
115
  __( "Time on Page", 'google-analytics-dashboard-for-wp' ),
116
  __( "Page Load Time", 'google-analytics-dashboard-for-wp' ),
117
  __( "Exit Rate", 'google-analytics-dashboard-for-wp' ),
 
118
  ),
119
  'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
120
  'region' => $region,
57
 
58
  wp_enqueue_script( 'gadwp-nprogress', GADWP_URL . 'common/nprogress/nprogress.js', array( 'jquery' ), GADWP_CURRENT_VERSION );
59
 
60
+ wp_enqueue_script( 'gadwp-frontend-item-reports', GADWP_URL . 'common/js/reports5.js', array( 'gadwp-nprogress', 'googlecharts', 'jquery', 'jquery-ui-dialog' ), GADWP_CURRENT_VERSION, true );
61
 
62
  /* @formatter:off */
63
  wp_localize_script( 'gadwp-frontend-item-reports', 'gadwpItemData', array(
115
  __( "Time on Page", 'google-analytics-dashboard-for-wp' ),
116
  __( "Page Load Time", 'google-analytics-dashboard-for-wp' ),
117
  __( "Exit Rate", 'google-analytics-dashboard-for-wp' ),
118
+ __( "Precision: ", 'google-analytics-dashboard-for-wp' ), //29
119
  ),
120
  'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
121
  'region' => $region,
front/tracking-analytics.php ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2017 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Tracking_Analytics' ) ) {
15
+
16
+ class GADWP_Tracking_Analytics {
17
+
18
+ private $gadwp;
19
+
20
+ private $uaid;
21
+
22
+ private $commands;
23
+
24
+ public function __construct() {
25
+ $this->gadwp = GADWP();
26
+
27
+ $profile = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_dash_profile_list'], $this->gadwp->config->options['ga_dash_tableid_jail'] );
28
+
29
+ $this->uaid = esc_html( $profile[2] );
30
+
31
+ $this->load_scripts();
32
+
33
+ if ( $this->gadwp->config->options['optimize_tracking'] && $this->gadwp->config->options['optimize_pagehiding'] && $this->gadwp->config->options['optimize_containerid'] ) {
34
+ add_action( 'wp_head', array( $this, 'optimize_output' ), 99 );
35
+ }
36
+
37
+ if ( $this->gadwp->config->options['trackingcode_infooter'] ) {
38
+ add_action( 'wp_footer', array( $this, 'output' ), 99 );
39
+ } else {
40
+ add_action( 'wp_head', array( $this, 'output' ), 99 );
41
+ }
42
+
43
+ if ( $this->gadwp->config->options['amp_tracking_analytics'] ) {
44
+ add_action( 'amp_post_template_head', array( $this, 'amp_add_analytics_script' ) );
45
+ add_action( 'amp_post_template_footer', array( $this, 'amp_output' ) );
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Retrieves the commands
51
+ */
52
+ public function get() {
53
+ return $this->commands;
54
+ }
55
+
56
+ /**
57
+ * Stores the commands
58
+ * @param array $commands
59
+ */
60
+ public function set( $commands ) {
61
+ $this->commands = $commands;
62
+ }
63
+
64
+ /**
65
+ * Formats the command before being added to the commands
66
+ * @param string $command
67
+ * @param array $fields
68
+ * @param string $fieldsobject
69
+ * @return array
70
+ */
71
+ public function prepare( $command, $fields, $fieldsobject = null ) {
72
+ return array( 'command' => $command, 'fields' => $fields, 'fieldsobject' => $fieldsobject );
73
+ }
74
+
75
+ /**
76
+ * Styles & Scripts load
77
+ */
78
+ private function load_scripts() {
79
+ if ( $this->gadwp->config->options['ga_event_tracking'] || $this->gadwp->config->options['ga_aff_tracking'] || $this->gadwp->config->options['ga_hash_tracking'] || $this->gadwp->config->options['ga_pagescrolldepth_tracking'] ) {
80
+
81
+ $domaindata = GADWP_Tools::get_root_domain( esc_html( get_option( 'siteurl' ) ) );
82
+ $root_domain = $domaindata['domain'];
83
+
84
+ wp_enqueue_script( 'gadwp-tracking-analytics-events', GADWP_URL . 'front/js/tracking-analytics-events.js', array( 'jquery' ), GADWP_CURRENT_VERSION, $this->gadwp->config->options['trackingevents_infooter'] );
85
+
86
+ if ( $this->gadwp->config->options['ga_pagescrolldepth_tracking'] ) {
87
+ wp_enqueue_script( 'gadwp-pagescrolldepth-tracking', GADWP_URL . 'front/js/tracking-scrolldepth.js', array( 'jquery' ), GADWP_CURRENT_VERSION, $this->gadwp->config->options['trackingevents_infooter'] );
88
+ }
89
+
90
+ /* @formatter:off */
91
+ wp_localize_script( 'gadwp-tracking-analytics-events', 'gadwpUAEventsData', array(
92
+ 'options' => array(
93
+ 'event_tracking' => $this->gadwp->config->options['ga_event_tracking'],
94
+ 'event_downloads' => esc_js($this->gadwp->config->options['ga_event_downloads']),
95
+ 'event_bouncerate' => $this->gadwp->config->options['ga_event_bouncerate'],
96
+ 'aff_tracking' => $this->gadwp->config->options['ga_aff_tracking'],
97
+ 'event_affiliates' => esc_js($this->gadwp->config->options['ga_event_affiliates']),
98
+ 'hash_tracking' => $this->gadwp->config->options ['ga_hash_tracking'],
99
+ 'root_domain' => $root_domain,
100
+ 'event_timeout' => apply_filters( 'gadwp_analyticsevents_timeout', 100 ),
101
+ 'event_formsubmit' => $this->gadwp->config->options ['ga_formsubmit_tracking'],
102
+ 'ga_pagescrolldepth_tracking' => $this->gadwp->config->options['ga_pagescrolldepth_tracking'],
103
+ ),
104
+ )
105
+ );
106
+ /* @formatter:on */
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Adds a formatted command to commands
112
+ * @param string $command
113
+ * @param array $fields
114
+ * @param string $fieldsobject
115
+ */
116
+ private function add( $command, $fields, $fieldsobject = null ) {
117
+ $this->commands[] = $this->prepare( $command, $fields, $fieldsobject = null );
118
+ }
119
+
120
+ /**
121
+ * Sanitizes the output of commands in the tracking code
122
+ * @param string $value
123
+ * @return string
124
+ */
125
+ private function filter( $value ) {
126
+ if ( 'true' == $value || 'false' == $value ) {
127
+ return $value;
128
+ }
129
+
130
+ if ( substr( $value, 0, 1 ) == '[' && substr( $value, - 1 ) == ']' ) {
131
+ return $value;
132
+ }
133
+
134
+ return "'" . $value . "'";
135
+ }
136
+
137
+ /**
138
+ * Builds the commands based on user's options
139
+ */
140
+ private function build_commands() {
141
+ $fields = array();
142
+ $fieldsobject = array();
143
+ $fields['trackingId'] = $this->uaid;
144
+ if ( 1 != $this->gadwp->config->options['ga_speed_samplerate'] ) {
145
+ $fieldsobject['siteSpeedSampleRate'] = (int) $this->gadwp->config->options['ga_speed_samplerate'];
146
+ }
147
+ if ( $this->gadwp->config->options['ga_crossdomain_tracking'] && '' != $this->gadwp->config->options['ga_crossdomain_list'] ) {
148
+ $fieldsobject['allowLinker'] = 'true';
149
+ }
150
+ if ( ! empty( $this->gadwp->config->options['ga_cookiedomain'] ) ) {
151
+ $fieldsobject['cookieDomain'] = $this->gadwp->config->options['ga_cookiedomain'];
152
+ } else {
153
+ $fields['cookieDomain'] = 'auto';
154
+ }
155
+ if ( ! empty( $this->gadwp->config->options['ga_cookiename'] ) ) {
156
+ $fieldsobject['cookieName'] = $this->gadwp->config->options['ga_cookiename'];
157
+ }
158
+ if ( ! empty( $this->gadwp->config->options['ga_cookieexpires'] ) ) {
159
+ $fieldsobject['cookieExpires'] = (int) $this->gadwp->config->options['ga_cookieexpires'];
160
+ }
161
+ $this->add( 'create', $fields, $fieldsobject );
162
+
163
+ if ( $this->gadwp->config->options['ga_crossdomain_tracking'] && '' != $this->gadwp->config->options['ga_crossdomain_list'] ) {
164
+ $fields = array();
165
+ $fields['plugin'] = 'linker';
166
+ $this->add( 'require', $fields );
167
+
168
+ $fields = array();
169
+ $domains = '';
170
+ $domains = explode( ',', $this->gadwp->config->options['ga_crossdomain_list'] );
171
+ $domains = array_map( 'trim', $domains );
172
+ $domains = strip_tags( implode( "','", $domains ) );
173
+ $domains = "['" . $domains . "']";
174
+ $fields['domains'] = $domains;
175
+ $this->add( 'linker:autoLink', $fields );
176
+ }
177
+
178
+ if ( $this->gadwp->config->options['ga_dash_remarketing'] ) {
179
+ $fields = array();
180
+ $fields['plugin'] = 'displayfeatures';
181
+ $this->add( 'require', $fields );
182
+ }
183
+
184
+ if ( $this->gadwp->config->options['ga_enhanced_links'] ) {
185
+ $fields = array();
186
+ $fields['plugin'] = 'linkid';
187
+ $this->add( 'require', $fields );
188
+ }
189
+
190
+ if ( $this->gadwp->config->options['ga_author_dimindex'] && ( is_single() || is_page() ) ) {
191
+ $fields = array();
192
+ global $post;
193
+ $author_id = $post->post_author;
194
+ $author_name = get_the_author_meta( 'display_name', $author_id );
195
+ $fields['dimension'] = 'dimension' . (int) $this->gadwp->config->options['ga_author_dimindex'];
196
+ $fields['value'] = esc_attr( $author_name );
197
+ $this->add( 'set', $fields );
198
+ }
199
+
200
+ if ( $this->gadwp->config->options['ga_pubyear_dimindex'] && is_single() ) {
201
+ $fields = array();
202
+ global $post;
203
+ $date = get_the_date( 'Y', $post->ID );
204
+ $fields['dimension'] = 'dimension' . (int) $this->gadwp->config->options['ga_pubyear_dimindex'];
205
+ $fields['value'] = (int) $date;
206
+ $this->add( 'set', $fields );
207
+ }
208
+
209
+ if ( $this->gadwp->config->options['ga_pubyearmonth_dimindex'] && is_single() ) {
210
+ $fields = array();
211
+ global $post;
212
+ $date = get_the_date( 'Y-m', $post->ID );
213
+ $fields['dimension'] = 'dimension' . (int) $this->gadwp->config->options['ga_pubyearmonth_dimindex'];
214
+ $fields['value'] = esc_attr( $date );
215
+ $this->add( 'set', $fields );
216
+ }
217
+
218
+ if ( $this->gadwp->config->options['ga_category_dimindex'] && is_category() ) {
219
+ $fields = array();
220
+ $fields['dimension'] = 'dimension' . (int) $this->gadwp->config->options['ga_category_dimindex'];
221
+ $fields['value'] = esc_attr( single_tag_title( '', false ) );
222
+ $this->add( 'set', $fields );
223
+ }
224
+ if ( $this->gadwp->config->options['ga_category_dimindex'] && is_single() ) {
225
+ $fields = array();
226
+ global $post;
227
+ $categories = get_the_category( $post->ID );
228
+ foreach ( $categories as $category ) {
229
+ $fields['dimension'] = 'dimension' . (int) $this->gadwp->config->options['ga_category_dimindex'];
230
+ $fields['value'] = esc_attr( $category->name );
231
+ $this->add( 'set', $fields );
232
+ break;
233
+ }
234
+ }
235
+
236
+ if ( $this->gadwp->config->options['ga_tag_dimindex'] && is_single() ) {
237
+ global $post;
238
+ $fields = array();
239
+ $post_tags_list = '';
240
+ $post_tags_array = get_the_tags( $post->ID );
241
+ if ( $post_tags_array ) {
242
+ foreach ( $post_tags_array as $tag ) {
243
+ $post_tags_list .= $tag->name . ', ';
244
+ }
245
+ }
246
+ $post_tags_list = rtrim( $post_tags_list, ', ' );
247
+ if ( $post_tags_list ) {
248
+ $fields['dimension'] = 'dimension' . (int) $this->gadwp->config->options['ga_tag_dimindex'];
249
+ $fields['value'] = esc_attr( $post_tags_list );
250
+ $this->add( 'set', $fields );
251
+ }
252
+ }
253
+
254
+ if ( $this->gadwp->config->options['ga_user_dimindex'] ) {
255
+ $fields = array();
256
+ $fields['dimension'] = 'dimension' . (int) $this->gadwp->config->options['ga_user_dimindex'];
257
+ $fields['value'] = is_user_logged_in() ? 'registered' : 'guest';
258
+ $this->add( 'set', $fields );
259
+ }
260
+
261
+ if ( $this->gadwp->config->options['ga_dash_anonim'] ) {
262
+ $fields = array();
263
+ $fields['option'] = 'anonymizeIp';
264
+ $fields['value'] = 'true';
265
+ $this->add( 'set', $fields );
266
+ }
267
+
268
+ if ( 'enhanced' == $this->gadwp->config->options['ecommerce_mode'] ) {
269
+ $fields = array();
270
+ $fields['plugin'] = 'ec';
271
+ $this->add( 'require', $fields );
272
+ } else if ( 'standard' == $this->gadwp->config->options['ecommerce_mode'] ) {
273
+ $fields = array();
274
+ $fields['plugin'] = 'ecommerce';
275
+ $this->add( 'require', $fields );
276
+ }
277
+
278
+ if ( $this->gadwp->config->options['optimize_tracking'] && $this->gadwp->config->options['optimize_containerid'] ) {
279
+ $fields = array();
280
+ $fields['plugin'] = esc_attr( $this->gadwp->config->options['optimize_containerid'] );
281
+ $this->add( 'require', $fields );
282
+ }
283
+
284
+ $fields = array();
285
+ $fields['hitType'] = 'pageview';
286
+ $this->add( 'send', $fields );
287
+
288
+ do_action( 'gadwp_analytics_commands', $this );
289
+ }
290
+
291
+ /**
292
+ * Outputs the Google Optimize tracking code
293
+ */
294
+ public function optimize_output() {
295
+ GADWP_Tools::load_view( 'front/views/optimize-code.php', array( 'containerid' => $this->gadwp->config->options['optimize_containerid'] ) );
296
+ }
297
+
298
+ /**
299
+ * Outputs the Google Analytics tracking code
300
+ */
301
+ public function output() {
302
+ $this->commands = array();
303
+
304
+ $this->build_commands();
305
+
306
+ $trackingcode = '';
307
+
308
+ foreach ( $this->commands as $set ) {
309
+ $command = $set['command'];
310
+
311
+ $fields = '';
312
+ foreach ( $set['fields'] as $fieldkey => $fieldvalue ) {
313
+ $fieldvalue = $this->filter( $fieldvalue );
314
+ $fields .= ", " . $fieldvalue;
315
+ }
316
+
317
+ if ( $set['fieldsobject'] ) {
318
+ $fieldsobject = ", {";
319
+ foreach ( $set['fieldsobject'] as $fieldkey => $fieldvalue ) {
320
+ $fieldvalue = $this->filter( $fieldvalue );
321
+ $fieldkey = $this->filter( $fieldkey );
322
+ $fieldsobject .= $fieldkey . ": " . $fieldvalue . ", ";
323
+ }
324
+ $fieldsobject = rtrim( $fieldsobject, ", " );
325
+ $fieldsobject .= "}";
326
+ $trackingcode .= " ga('" . $command . "'" . $fields . $fieldsobject . ");\n";
327
+ } else {
328
+ $trackingcode .= " ga('" . $command . "'" . $fields . ");\n";
329
+ }
330
+ }
331
+
332
+ GADWP_Tools::load_view( 'front/views/analytics-code.php', array( 'trackingcode' => $trackingcode ) );
333
+ }
334
+
335
+ /**
336
+ * Inserts the Analytics AMP script in the head section
337
+ */
338
+ public function amp_add_analytics_script() {
339
+ ?><script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script><?php
340
+ }
341
+
342
+ /**
343
+ * Outputs the Google Analytics tracking code for AMP
344
+ */
345
+ public function amp_output() {
346
+ ?><amp-analytics type="googleanalytics" id="gadwp-googleanalytics"> <script type="application/json">{"vars": { "account" : "<?php echo $this->uaid; ?>"}, "triggers": { "trackPageview": { "on": "visible", "request": "pageview" }}}</script> </amp-analytics><?php
347
+ }
348
+ }
349
+ }
front/tracking-tagmanager.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * Copyright 2017 Alin Marcu
6
+ * License: GPLv2 or later
7
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
+ */
9
+
10
+ // Exit if accessed directly
11
+ if ( ! defined( 'ABSPATH' ) )
12
+ exit();
13
+
14
+ if ( ! class_exists( 'GADWP_Tracking_TagManager' ) ) {
15
+
16
+ class GADWP_Tracking_TagManager {
17
+
18
+ private $gadwp;
19
+
20
+ private $datalayer;
21
+
22
+ public function __construct() {
23
+ $this->gadwp = GADWP();
24
+
25
+ $this->load_scripts();
26
+
27
+ if ( $this->gadwp->config->options['trackingcode_infooter'] ) {
28
+ add_action( 'wp_footer', array( $this, 'output' ), 99 );
29
+ } else {
30
+ add_action( 'wp_head', array( $this, 'output' ), 99 );
31
+ }
32
+
33
+ if ( $this->gadwp->config->options['amp_tracking_tagmanager'] && $this->gadwp->config->options['amp_containerid'] ) {
34
+ add_action( 'amp_post_template_head', array( $this, 'amp_add_analytics_script' ) );
35
+ add_action( 'amp_post_template_footer', array( $this, 'amp_output' ) );
36
+ }
37
+ }
38
+
39
+ /**
40
+ * Styles & Scripts load
41
+ */
42
+ private function load_scripts() {
43
+ if ( $this->gadwp->config->options['tm_pagescrolldepth_tracking'] ) {
44
+ wp_enqueue_script( 'gadwp-pagescrolldepth-tracking', GADWP_URL . 'front/js/tracking-scrolldepth.js', array( 'jquery' ), GADWP_CURRENT_VERSION, $this->gadwp->config->options['trackingcode_infooter'] );
45
+ wp_enqueue_script( 'gadwp-tracking-tagmanager-events', GADWP_URL . 'front/js/tracking-tagmanager-events.js', array( 'jquery', 'gadwp-pagescrolldepth-tracking' ), GADWP_CURRENT_VERSION, $this->gadwp->config->options['trackingcode_infooter'] );
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Retrieves the datalayer variables
51
+ */
52
+ public function get() {
53
+ return $this->datalayer;
54
+ }
55
+
56
+ /**
57
+ * Stores the datalayer variables
58
+ * @param array $datalayer
59
+ */
60
+ public function set( $datalayer ) {
61
+ $this->datalayer = $datalayer;
62
+ }
63
+
64
+ /**
65
+ * Adds a variable to the datalayer
66
+ * @param string $name
67
+ * @param string $value
68
+ */
69
+ private function add_var( $name, $value ) {
70
+ $this->datalayer[$name] = $value;
71
+ }
72
+
73
+ /**
74
+ * Builds the datalayer based on user's options
75
+ */
76
+ private function build_datalayer() {
77
+ global $post;
78
+
79
+ if ( $this->gadwp->config->options['tm_author_var'] && ( is_single() || is_page() ) ) {
80
+ global $post;
81
+ $author_id = $post->post_author;
82
+ $author_name = get_the_author_meta( 'display_name', $author_id );
83
+ $this->add_var( 'gadwpAuthor', esc_attr( $author_name ) );
84
+ }
85
+
86
+ if ( $this->gadwp->config->options['tm_pubyear_var'] && is_single() ) {
87
+ global $post;
88
+ $date = get_the_date( 'Y', $post->ID );
89
+ $this->add_var( 'gadwpPublicationYear', (int) $date );
90
+ }
91
+
92
+ if ( $this->gadwp->config->options['tm_pubyearmonth_var'] && is_single() ) {
93
+ global $post;
94
+ $date = get_the_date( 'Y-m', $post->ID );
95
+ $this->add_var( 'gadwpPublicationYearMonth', esc_attr( $date ) );
96
+ }
97
+
98
+ if ( $this->gadwp->config->options['tm_category_var'] && is_category() ) {
99
+ $this->add_var( 'gadwpCategory', esc_attr( single_tag_title() ) );
100
+ }
101
+ if ( $this->gadwp->config->options['tm_category_var'] && is_single() ) {
102
+ global $post;
103
+ $categories = get_the_category( $post->ID );
104
+ foreach ( $categories as $category ) {
105
+ $this->add_var( 'gadwpCategory', esc_attr( $category->name ) );
106
+ break;
107
+ }
108
+ }
109
+
110
+ if ( $this->gadwp->config->options['tm_tag_var'] && is_single() ) {
111
+ global $post;
112
+ $post_tags_list = '';
113
+ $post_tags_array = get_the_tags( $post->ID );
114
+ if ( $post_tags_array ) {
115
+ foreach ( $post_tags_array as $tag ) {
116
+ $post_tags_list .= $tag->name . ', ';
117
+ }
118
+ }
119
+ $post_tags_list = rtrim( $post_tags_list, ', ' );
120
+ if ( $post_tags_list ) {
121
+ $this->add_var( 'gadwpTag', esc_attr( $post_tags_list ) );
122
+ }
123
+ }
124
+
125
+ if ( $this->gadwp->config->options['tm_user_var'] ) {
126
+ $usertype = is_user_logged_in() ? 'registered' : 'guest';
127
+ $this->add_var( 'gadwpUser', $usertype );
128
+ }
129
+
130
+ do_action( 'gadwp_tagmanager_datalayer', $this );
131
+ }
132
+
133
+ /**
134
+ * Outputs the Google Tag Manager tracking code
135
+ */
136
+ public function output() {
137
+ $this->build_datalayer();
138
+
139
+ if ( is_array( $this->datalayer ) ) {
140
+ $vars = "{";
141
+ foreach ( $this->datalayer as $var => $value ) {
142
+ $vars .= "'" . $var . "': '" . $value . "', ";
143
+ }
144
+ $vars = rtrim( $vars, ", " );
145
+ $vars .= "}";
146
+ } else {
147
+ $vars = "{}";
148
+ }
149
+
150
+ GADWP_Tools::load_view( 'front/views/tagmanager-code.php', array( 'containerid' => $this->gadwp->config->options['web_containerid'], 'vars' => $vars ) );
151
+ }
152
+
153
+ /**
154
+ * Inserts the Analytics AMP script in the head section
155
+ */
156
+ public function amp_add_analytics_script() {
157
+ ?><script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script><?php
158
+ }
159
+
160
+ /**
161
+ * Outputs the Tag Manager code for AMP
162
+ */
163
+ public function amp_output() {
164
+ ?><amp-analytics config="https://www.googletagmanager.com/amp.json?id=<?php echo $this->gadwp->config->options['amp_containerid']; ?>&gtm.url=SOURCE_URL" data-credentials="include"></amp-analytics><?php
165
+ }
166
+ }
167
+ }
front/tracking.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
- * Copyright 2013 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
@@ -17,47 +17,36 @@ if ( ! class_exists( 'GADWP_Tracking' ) ) {
17
 
18
  private $gadwp;
19
 
 
 
 
 
 
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
 
23
- add_action( 'wp_head', array( $this, 'tracking_code' ), 99 );
24
- add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
25
- }
26
-
27
- public function load_scripts() {
28
- if ( $this->gadwp->config->options['ga_event_tracking'] ) {
29
- if ( wp_script_is( 'jquery' ) ) {
30
- wp_dequeue_script( 'jquery' );
31
- }
32
- wp_enqueue_script( 'jquery' );
33
- }
34
  }
35
 
36
- public function tracking_code() {
 
37
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_track_exclude'], true ) || ( $this->gadwp->config->options['ga_dash_excludesa'] && current_user_can( 'manage_network' ) ) ) {
38
  return;
39
  }
40
- $traking_mode = $this->gadwp->config->options['ga_dash_tracking'];
41
- $traking_type = $this->gadwp->config->options['ga_dash_tracking_type'];
42
- if ( $traking_mode > 0 ) {
43
- if ( ! $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
44
- return;
45
- }
46
- if ( $traking_type == "classic" ) {
47
- echo "\n<!-- BEGIN GADWP v" . GADWP_CURRENT_VERSION . " Classic Tracking - https://deconf.com/google-analytics-dashboard-wordpress/ -->\n";
48
- if ( $this->gadwp->config->options['ga_event_tracking'] ) {
49
- require_once 'tracking/events-classic.php';
50
- }
51
- require_once 'tracking/code-classic.php';
52
- echo "\n<!-- END GADWP Classic Tracking -->\n\n";
53
- } else {
54
- echo "\n<!-- BEGIN GADWP v" . GADWP_CURRENT_VERSION . " Universal Tracking - https://deconf.com/google-analytics-dashboard-wordpress/ -->\n";
55
- if ( $this->gadwp->config->options['ga_event_tracking'] || $this->gadwp->config->options['ga_aff_tracking'] || $this->gadwp->config->options['ga_hash_tracking'] ) {
56
- require_once 'tracking/events-universal.php';
57
- }
58
- require_once 'tracking/code-universal.php';
59
- echo "\n<!-- END GADWP Universal Tracking -->\n\n";
60
- }
61
  }
62
  }
63
  }
2
  /**
3
  * Author: Alin Marcu
4
  * Author URI: https://deconf.com
5
+ * Copyright 2017 Alin Marcu
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
17
 
18
  private $gadwp;
19
 
20
+ public $analytics;
21
+
22
+ public $amp;
23
+
24
+ public $tagmanager;
25
+
26
  public function __construct() {
27
  $this->gadwp = GADWP();
28
 
29
+ $this->init();
 
 
 
 
 
 
 
 
 
 
30
  }
31
 
32
+ public function init() {
33
+ // excluded roles
34
  if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_track_exclude'], true ) || ( $this->gadwp->config->options['ga_dash_excludesa'] && current_user_can( 'manage_network' ) ) ) {
35
  return;
36
  }
37
+
38
+ if ( 'universal' == $this->gadwp->config->options['ga_dash_tracking_type'] && $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
39
+
40
+ // Analytics
41
+ require_once 'tracking-analytics.php';
42
+ $this->analytics = new GADWP_Tracking_Analytics();
43
+ }
44
+
45
+ if ( 'tagmanager' == $this->gadwp->config->options['ga_dash_tracking_type'] && $this->gadwp->config->options['web_containerid'] ) {
46
+
47
+ // Tag Manager
48
+ require_once 'tracking-tagmanager.php';
49
+ $this->tagmanager = new GADWP_Tracking_TagManager();
 
 
 
 
 
 
 
 
50
  }
51
  }
52
  }
front/tracking/code-classic.php DELETED
@@ -1,34 +0,0 @@
1
- <?php
2
- /**
3
- * Author: Alin Marcu
4
- * Author URI: https://deconf.com
5
- * Copyright 2013 Alin Marcu
6
- * License: GPLv2 or later
7
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
- */
9
-
10
- // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) )
12
- exit();
13
-
14
- $profile = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_dash_profile_list'], $this->gadwp->config->options['ga_dash_tableid_jail'] );
15
- ?>
16
- <script type="text/javascript">
17
- var _gaq = _gaq || [];
18
- <?php if ($this->gadwp->config->options ['ga_enhanced_links']) {?>
19
- var pluginUrl = '//www.google-analytics.com/plugins/ga/inpage_linkid.js';
20
- _gaq.push(['_require', 'inpage_linkid', pluginUrl]);
21
- <?php }?>
22
- _gaq.push(['_setAccount', '<?php echo esc_html($profile[2]); ?>']);
23
- _gaq.push(['_trackPageview']<?php if ($this->gadwp->config->options ['ga_dash_anonim']) {?>, ['_gat._anonymizeIp']<?php }?>);
24
-
25
- (function() {
26
- var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
27
- <?php if ($this->gadwp->config->options ['ga_dash_remarketing']) { ?>
28
- ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';
29
- <?php }else{?>
30
- ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
31
- <?php }?>
32
- var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
33
- })();
34
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
front/tracking/code-universal.php DELETED
@@ -1,142 +0,0 @@
1
- <?php
2
- /**
3
- * Author: Alin Marcu
4
- * Author URI: https://deconf.com
5
- * Copyright 2013 Alin Marcu
6
- * License: GPLv2 or later
7
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
- */
9
-
10
- // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) )
12
- exit();
13
-
14
- $profile = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_dash_profile_list'], $this->gadwp->config->options['ga_dash_tableid_jail'] );
15
- ?>
16
- <script>
17
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
18
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
19
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
20
- })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
21
- <?php
22
- $create_options = '{';
23
- if ( $this->gadwp->config->options['ga_speed_samplerate'] != 1 ) {
24
- $create_options .= "'siteSpeedSampleRate' : " . (int) $this->gadwp->config->options['ga_speed_samplerate'];
25
- }
26
- if ( $this->gadwp->config->options['ga_crossdomain_tracking'] && $this->gadwp->config->options['ga_crossdomain_list'] != '' ) {
27
- if ( $create_options != '{' ) {
28
- $create_options .= ', ';
29
- }
30
- $create_options .= "'allowLinker' : true";
31
- }
32
- $create_options .= '}';
33
-
34
- $options = "'auto'";
35
- $optionsArray = array();
36
- if ( ! empty( $this->gadwp->config->options['ga_cookiedomain'] ) ) {
37
- $optionsArray['cookieDomain'] = $this->gadwp->config->options['ga_cookiedomain'];
38
- }
39
- if ( ! empty( $this->gadwp->config->options['ga_cookiename'] ) ) {
40
- $optionsArray['cookieName'] = $this->gadwp->config->options['ga_cookiename'];
41
- }
42
- if ( ! empty( $this->gadwp->config->options['ga_cookieexpires'] ) ) {
43
- $optionsArray['cookieExpires'] = (int) $this->gadwp->config->options['ga_cookieexpires'];
44
- }
45
- if ( ! empty( $optionsArray ) ) {
46
- $options = json_encode( $optionsArray );
47
- }
48
- ?>
49
- ga('create', '<?php echo esc_html($profile[2]); ?>', <?php echo $options; ?><?php if ($create_options != '{}') {?>, <?php echo $create_options; }?>);
50
- <?php if ($this->gadwp->config->options ['ga_crossdomain_tracking'] && $this->gadwp->config->options ['ga_crossdomain_list']!='') {?>
51
- ga('require', 'linker');
52
- <?php
53
- $crossdomain_list = explode( ',', $this->gadwp->config->options['ga_crossdomain_list'] );
54
- $crossdomain_list = array_map( 'trim', $crossdomain_list );
55
- $crossdomain_list = strip_tags( implode( "','", $crossdomain_list ) );
56
- ?>
57
- ga('linker:autoLink', ['<?php echo ($crossdomain_list)?>'] );
58
- <?php
59
- }
60
- if ( $this->gadwp->config->options['ga_dash_remarketing'] ) {
61
- ?>
62
- ga('require', 'displayfeatures');
63
- <?php
64
- }
65
- if ( $this->gadwp->config->options['ga_enhanced_links'] ) {
66
- ?>
67
- ga('require', 'linkid', 'linkid.js');
68
- <?php
69
- }
70
- if ( $this->gadwp->config->options['ga_author_dimindex'] && ( is_single() || is_page() ) ) {
71
- global $post;
72
- $author_id = $post->post_author;
73
- $author_name = get_the_author_meta( 'display_name', $author_id );
74
- ?>
75
- ga('set', 'dimension<?php echo (int)$this->gadwp->config->options ['ga_author_dimindex']; ?>', '<?php echo esc_attr($author_name); ?>');
76
- <?php
77
- }
78
- if ( $this->gadwp->config->options['ga_pubyear_dimindex'] && is_single() ) {
79
- global $post;
80
- $date = get_the_date( 'Y', $post->ID );
81
- ?>
82
- ga('set', 'dimension<?php echo (int)$this->gadwp->config->options ['ga_pubyear_dimindex']; ?>', '<?php echo (int)$date; ?>');
83
- <?php
84
- }
85
- if ( $this->gadwp->config->options['ga_pubyearmonth_dimindex'] && is_single() ) {
86
- global $post;
87
- $date = get_the_date( 'Y-m', $post->ID );
88
- ?>
89
- ga('set', 'dimension<?php echo (int)$this->gadwp->config->options ['ga_pubyearmonth_dimindex']; ?>', '<?php echo $date; ?>');
90
- <?php
91
- }
92
- if ( $this->gadwp->config->options['ga_category_dimindex'] && is_category() ) {
93
- ?>
94
- ga('set', 'dimension<?php echo (int)$this->gadwp->config->options ['ga_category_dimindex']; ?>', '<?php echo esc_attr(single_tag_title()); ?>');
95
- <?php
96
- }
97
- if ( $this->gadwp->config->options['ga_tag_dimindex'] && is_single() ) {
98
- global $post;
99
- $post_tags_list = '';
100
- $post_tags_array = get_the_tags( $post->ID );
101
- if ( $post_tags_array ) {
102
- foreach ( $post_tags_array as $tag ) {
103
- $post_tags_list .= $tag->name . ', ';
104
- }
105
- }
106
- $post_tags_list = rtrim( $post_tags_list, ', ' );
107
- if ( $post_tags_list ) {
108
- ?>
109
- ga('set', 'dimension<?php echo (int)$this->gadwp->config->options ['ga_tag_dimindex']; ?>', '<?php echo esc_attr($post_tags_list); ?>');
110
- <?php
111
- }
112
- }
113
- if ( $this->gadwp->config->options['ga_category_dimindex'] && is_single() ) {
114
- global $post;
115
- $categories = get_the_category( $post->ID );
116
- foreach ( $categories as $category ) {
117
- ?>
118
- ga('set', 'dimension<?php echo (int)$this->gadwp->config->options ['ga_category_dimindex']; ?>', '<?php echo esc_attr($category->name); ?>');
119
- <?php
120
- break;
121
- }
122
- }
123
- if ( $this->gadwp->config->options['ga_user_dimindex'] ) {
124
- ?>
125
- ga('set', 'dimension<?php echo (int)$this->gadwp->config->options ['ga_user_dimindex']; ?>', '<?php echo is_user_logged_in()?'registered':'guest'; ?>');
126
- <?php
127
- }
128
- if ( $this->gadwp->config->options['ga_dash_anonim'] ) {
129
- ?>
130
- ga('set', 'anonymizeIp', true);
131
- <?php
132
- }
133
- do_action( 'ga_dash_addtrackingcode' );
134
- ?>
135
- ga('send', 'pageview');
136
- <?php
137
- if ( $this->gadwp->config->options['ga_dash_adsense'] ) {
138
- ?>
139
-
140
- window.google_analytics_uacct = "<?php echo esc_html($profile[2]); ?>";
141
- <?php }?>
142
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
front/tracking/events-classic.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
- /**
3
- * Author: Alin Marcu
4
- * Author URI: https://deconf.com
5
- * Copyright 2013 Alin Marcu
6
- * License: GPLv2 or later
7
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
- */
9
-
10
- // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) )
12
- exit();
13
- ?>
14
- <script type="text/javascript">
15
- (function($){
16
- $(window).load(function() {
17
- if (this._gat) {
18
- tks = this._gat._getTrackers();
19
- ga_track = function(p) {
20
- for (i=0; i < tks.length; i++) {
21
- var n = tks[i]._getName() !== "" ? tks[i]._getName()+"." : "";
22
- a = [];
23
- for (i2=0; i2 < p.length; i2++) {
24
- var b = i2===0 ? n+p[i2] : p[i2];
25
- a.push(b);
26
- }
27
- _gaq.push(a);
28
- }
29
- };
30
- $('a').filter(function() {
31
- return this.href.match(/.*\.(<?php echo esc_js($this->gadwp->config->options['ga_event_downloads']);?>)(\?.*)?$/);
32
- }).click(function(e) {
33
- ga_track(['_trackEvent', 'download', 'click', this.href]);
34
- });
35
- $('a[href^="mailto"]').click(function(e) {
36
- ga_track(['_trackSocial', 'email', 'send', this.href]);
37
- });
38
- var loc = location.host.split('.');
39
- while (loc.length > 2) { loc.shift(); }
40
- loc = loc.join('.');
41
- var localURLs = [
42
- loc,
43
- '<?php echo esc_html(get_option('siteurl'));?>'
44
- ];
45
- $('a[href^="http"]').filter(function() {
46
- for (var i = 0; i < localURLs.length; i++) {
47
- if (this.href.indexOf(localURLs[i]) == -1) return this.href;
48
- }
49
- }).click(function(e) {
50
- ga_track(['_trackEvent', 'outbound', 'click', this.href]);
51
- });
52
- }
53
- });
54
- })(jQuery);
55
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
front/tracking/events-universal.php DELETED
@@ -1,67 +0,0 @@
1
- <?php
2
- /**
3
- * Author: Alin Marcu
4
- * Author URI: https://deconf.com
5
- * Copyright 2013 Alin Marcu
6
- * License: GPLv2 or later
7
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
- */
9
-
10
- // Exit if accessed directly
11
- if ( ! defined( 'ABSPATH' ) )
12
- exit();
13
-
14
- $domaindata = GADWP_Tools::get_root_domain( esc_html( get_option( 'siteurl' ) ) );
15
- ?>
16
- <script type="text/javascript">
17
- (function($){
18
- $(window).load(function() {
19
- <?php if ($this->gadwp->config->options['ga_event_tracking']){ ?>
20
-
21
- //Track Downloads
22
- $('a').filter(function() {
23
- return this.href.match(/.*\.(<?php echo esc_js($this->gadwp->config->options['ga_event_downloads']);?>)(\?.*)?$/);
24
- }).click(function(e) {
25
- ga('send','event', 'download', 'click', this.href<?php if(isset($this->gadwp->config->options['ga_event_bouncerate']) && $this->gadwp->config->options['ga_event_bouncerate']){echo ", {'nonInteraction': 1}";}?>);
26
- });
27
-
28
- //Track Mailto
29
- $('a[href^="mailto"]').click(function(e) {
30
- ga('send','event', 'email', 'send', this.href<?php if(isset($this->gadwp->config->options['ga_event_bouncerate']) && $this->gadwp->config->options['ga_event_bouncerate']){echo ", {'nonInteraction': 1}";}?>);
31
- });
32
- <?php if (isset ( $domaindata ['domain'] ) && $domaindata ['domain']) { ?>
33
-
34
- //Track Outbound Links
35
- $('a[href^="http"]').filter(function() {
36
- if (!this.href.match(/.*\.(<?php echo esc_js($this->gadwp->config->options['ga_event_downloads']);?>)(\?.*)?$/)){
37
- if (this.href.indexOf('<?php echo $domaindata['domain']; ?>') == -1) return this.href;
38
- }
39
- }).click(function(e) {
40
- ga('send','event', 'outbound', 'click', this.href<?php if(isset($this->gadwp->config->options['ga_event_bouncerate']) && $this->gadwp->config->options['ga_event_bouncerate']){echo ", {'nonInteraction': 1}";}?>);
41
- });
42
- <?php } ?>
43
- <?php } ?>
44
- <?php if ($this->gadwp->config->options['ga_event_affiliates'] && $this->gadwp->config->options['ga_aff_tracking']){ ?>
45
-
46
- //Track Affiliates
47
- $('a').filter(function() {
48
- if ('<?php echo esc_js($this->gadwp->config->options['ga_event_affiliates']);?>'!=''){
49
- return this.href.match(/(<?php echo str_replace('/','\/',(esc_js($this->gadwp->config->options['ga_event_affiliates'])));?>)/);
50
- }
51
- }).click(function(event) {
52
- ga('send','event', 'affiliates', 'click', this.href<?php if(isset($this->gadwp->config->options['ga_event_bouncerate']) && $this->gadwp->config->options['ga_event_bouncerate']){echo ", {'nonInteraction': 1}";}?>);
53
- });
54
- <?php } ?>
55
- <?php if (isset ( $domaindata ['domain'] ) && $domaindata ['domain'] && $this->gadwp->config->options ['ga_hash_tracking']) { ?>
56
-
57
- //Track Hashmarks
58
- $('a').filter(function() {
59
- if (this.href.indexOf('<?php echo $domaindata['domain']; ?>') != -1 || this.href.indexOf('://') == -1) return this.hash;
60
- }).click(function(e) {
61
- ga('send','event', 'hashmark', 'click', this.href<?php if(isset($this->gadwp->config->options['ga_event_bouncerate']) && $this->gadwp->config->options['ga_event_bouncerate']){echo ", {'nonInteraction': 1}";}?>);
62
- });
63
-
64
- <?php } ?>
65
- });
66
- })(jQuery);
67
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
front/views/analytics-code.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <!-- BEGIN GADWP v<?php echo GADWP_CURRENT_VERSION; ?> Universal Analytics - https://deconf.com/google-analytics-dashboard-wordpress/ -->
3
+ <script>
4
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
5
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
6
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
7
+ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
8
+ <?php echo $data['trackingcode']?>
9
+ </script>
10
+ <!-- END GADWP Universal Analytics -->
front/views/optimize-code.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style>
2
+ .async-hide {
3
+ opacity: 0 !important
4
+ }
5
+ </style>
6
+ <script>
7
+ (function(a,s,y,n,c,h,i,d,e){s.className+=' '+y;h.start=1*new Date;
8
+ h.end=i=function(){s.className=s.className.replace(RegExp(' ?'+y),'')};
9
+ (a[n]=a[n]||[]).hide=h;setTimeout(function(){i();h.end=null},c);h.timeout=c;
10
+ })(window,document.documentElement,'async-hide','dataLayer',4000,
11
+ {'<?php echo $data['containerid']; ?>':true});
12
+ </script>
front/views/tagmanager-code.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <!-- BEGIN GADWP v<?php echo GADWP_CURRENT_VERSION; ?> Tag Manager - https://deconf.com/google-analytics-dashboard-wordpress/ -->
3
+ <script>
4
+ window.dataLayer = window.dataLayer || [];
5
+ window.dataLayer.push(<?php echo $data['vars']; ?>);
6
+ </script>
7
+
8
+ <script>
9
+ (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
10
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
11
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
12
+ 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
13
+ })(window,document,'script','dataLayer','<?php echo $data['containerid']; ?>');
14
+ </script>
15
+ <!-- END GADWP Tag Manager -->
16
+
front/widgets.php CHANGED
@@ -124,14 +124,14 @@ final class GADWP_Frontend_Widget extends WP_Widget {
124
  chart.draw(data, options);
125
  }
126
  function gadwp_drawFrontWidgetTotals(response) {
127
- if (response == null){
128
  response = 0;
129
  }
130
  jQuery("#gadwp-widgettotals").html('<div class="gadwp-left"><?php _e( "Period:", 'google-analytics-dashboard-for-wp' ); ?></div> <div class="gadwp-right"><?php echo $periodtext; ?> </div><div class="gadwp-left"><?php _e( "Sessions:", 'google-analytics-dashboard-for-wp' ); ?></div> <div class="gadwp-right">'+response+'</div>');
131
  }
132
  </script>
133
  <?php
134
- if ( $instance['give_credits'] == 1 ) :
135
  ?>
136
  <div style="text-align: right; width: 100%; font-size: 0.8em; clear: both; margin-right: 5px;"><?php _e( 'generated by', 'google-analytics-dashboard-for-wp' ); ?> <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=front_widget&utm_campaign=gadwp" rel="nofollow" style="text-decoration: none; font-size: 1em;">GADWP</a>&nbsp;
137
  </div>
124
  chart.draw(data, options);
125
  }
126
  function gadwp_drawFrontWidgetTotals(response) {
127
+ if ( null == response ){
128
  response = 0;
129
  }
130
  jQuery("#gadwp-widgettotals").html('<div class="gadwp-left"><?php _e( "Period:", 'google-analytics-dashboard-for-wp' ); ?></div> <div class="gadwp-right"><?php echo $periodtext; ?> </div><div class="gadwp-left"><?php _e( "Sessions:", 'google-analytics-dashboard-for-wp' ); ?></div> <div class="gadwp-right">'+response+'</div>');
131
  }
132
  </script>
133
  <?php
134
+ if ( 1 == $instance['give_credits'] ) :
135
  ?>
136
  <div style="text-align: right; width: 100%; font-size: 0.8em; clear: both; margin-right: 5px;"><?php _e( 'generated by', 'google-analytics-dashboard-for-wp' ); ?> <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=front_widget&utm_campaign=gadwp" rel="nofollow" style="text-decoration: none; font-size: 1em;">GADWP</a>&nbsp;
137
  </div>
gadwp.php CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  /**
3
- * Plugin Name: Google Analytics Dashboard for WP
4
  * Plugin URI: https://deconf.com
5
  * Description: Displays Google Analytics Reports and Real-Time Statistics in your Dashboard. Automatically inserts the tracking code in every page of your website.
6
  * Author: Alin Marcu
7
- * Version: 4.9.6.2
8
  * Author URI: https://deconf.com
9
  * Text Domain: google-analytics-dashboard-for-wp
10
  * Domain Path: /languages
@@ -16,7 +16,7 @@ if ( ! defined( 'ABSPATH' ) )
16
 
17
  // Plugin Version
18
  if ( ! defined( 'GADWP_CURRENT_VERSION' ) ) {
19
- define( 'GADWP_CURRENT_VERSION', '4.9.6.2' );
20
  }
21
 
22
  if ( ! class_exists( 'GADWP_Manager' ) ) {
@@ -233,7 +233,7 @@ if ( ! class_exists( 'GADWP_Manager' ) ) {
233
  }
234
  }
235
 
236
- if ( ! GADWP_Tools::check_roles( self::$instance->config->options['ga_track_exclude'], true ) && self::$instance->config->options['ga_dash_tracking'] ) {
237
  /*
238
  * Load tracking class
239
  */
1
  <?php
2
  /**
3
+ * Plugin Name: Google Analytics Dashboard for WP (GADWP)
4
  * Plugin URI: https://deconf.com
5
  * Description: Displays Google Analytics Reports and Real-Time Statistics in your Dashboard. Automatically inserts the tracking code in every page of your website.
6
  * Author: Alin Marcu
7
+ * Version: 5.0
8
  * Author URI: https://deconf.com
9
  * Text Domain: google-analytics-dashboard-for-wp
10
  * Domain Path: /languages
16
 
17
  // Plugin Version
18
  if ( ! defined( 'GADWP_CURRENT_VERSION' ) ) {
19
+ define( 'GADWP_CURRENT_VERSION', '5.0' );
20
  }
21
 
22
  if ( ! class_exists( 'GADWP_Manager' ) ) {
233
  }
234
  }
235
 
236
+ if ( ! GADWP_Tools::check_roles( self::$instance->config->options['ga_track_exclude'], true ) && 'disabled' != self::$instance->config->options['ga_dash_tracking_type'] ) {
237
  /*
238
  * Load tracking class
239
  */
install/install.php CHANGED
@@ -24,7 +24,6 @@ class GADWP_Install {
24
  $options['ga_dash_style'] = '#1e73be';
25
  $options['switch_profile'] = 0;
26
  $options['ga_dash_cachetime'] = 3600;
27
- $options['ga_dash_tracking'] = 1;
28
  $options['ga_dash_tracking_type'] = 'universal';
29
  $options['ga_dash_default_ua'] = '';
30
  $options['ga_dash_anonim'] = 0;
@@ -42,7 +41,6 @@ class GADWP_Install {
42
  $options['ga_dash_remarketing'] = 0;
43
  $options['ga_dash_frontend_stats'] = 0;
44
  $options['ga_dash_network'] = 0;
45
- $options['ga_dash_adsense'] = 0;
46
  $options['ga_speed_samplerate'] = 1;
47
  $options['ga_event_bouncerate'] = 0;
48
  $options['ga_crossdomain_tracking'] = 0;
@@ -63,9 +61,28 @@ class GADWP_Install {
63
  $options['ga_cookiedomain'] = '';
64
  $options['ga_cookiename'] = '';
65
  $options['ga_cookieexpires'] = '';
66
- $option['pagetitle_404'] = 'Page Not Found';
67
- $option['maps_api_key'] = '';
68
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  } else {
70
  $options = array();
71
  $options['ga_dash_clientid'] = get_option( 'ga_dash_clientid' );
@@ -78,11 +95,6 @@ class GADWP_Install {
78
  $options['ga_dash_style'] = '#1e73be';
79
  $options['switch_profile'] = get_option( 'ga_dash_jailadmins' );
80
  $options['ga_dash_cachetime'] = get_option( 'ga_dash_cachetime' );
81
- if ( get_option( 'ga_dash_tracking' ) == 4 ) {
82
- $options['ga_dash_tracking'] = 0;
83
- } else {
84
- $options['ga_dash_tracking'] = 1;
85
- }
86
  $options['ga_dash_tracking_type'] = get_option( 'ga_dash_tracking_type' );
87
  $options['ga_dash_default_ua'] = get_option( 'ga_dash_default_ua' );
88
  $options['ga_dash_anonim'] = get_option( 'ga_dash_anonim' );
@@ -117,8 +129,28 @@ class GADWP_Install {
117
  $options['ga_cookiedomain'] = '';
118
  $options['ga_cookiename'] = '';
119
  $options['ga_cookieexpires'] = '';
120
- $option['pagetitle_404'] = 'Page Not Found';
121
- $option['maps_api_key'] = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
  delete_option( 'ga_dash_clientid' );
124
  delete_option( 'ga_dash_clientsecret' );
24
  $options['ga_dash_style'] = '#1e73be';
25
  $options['switch_profile'] = 0;
26
  $options['ga_dash_cachetime'] = 3600;
 
27
  $options['ga_dash_tracking_type'] = 'universal';
28
  $options['ga_dash_default_ua'] = '';
29
  $options['ga_dash_anonim'] = 0;
41
  $options['ga_dash_remarketing'] = 0;
42
  $options['ga_dash_frontend_stats'] = 0;
43
  $options['ga_dash_network'] = 0;
 
44
  $options['ga_speed_samplerate'] = 1;
45
  $options['ga_event_bouncerate'] = 0;
46
  $options['ga_crossdomain_tracking'] = 0;
61
  $options['ga_cookiedomain'] = '';
62
  $options['ga_cookiename'] = '';
63
  $options['ga_cookieexpires'] = '';
64
+ $options['pagetitle_404'] = 'Page Not Found';
65
+ $options['maps_api_key'] = '';
66
+ $options['tm_author_var'] = 0;
67
+ $options['tm_category_var'] = 0;
68
+ $options['tm_tag_var'] = 0;
69
+ $options['tm_user_var'] = 0;
70
+ $options['tm_pubyear_var'] = 0;
71
+ $options['tm_pubyearmonth_var'] = 0;
72
+ $options['web_containerid'] = '';
73
+ $options['amp_containerid'] = '';
74
+ $options['amp_tracking_tagmanager'] = 0;
75
+ $options['amp_tracking_analytics'] = 0;
76
+ $options['trackingcode_infooter'] = 0;
77
+ $options['trackingevents_infooter'] = 0;
78
+ $options['ecommerce_mode'] = 'disabled';
79
+ $options['ga_formsubmit_tracking'] = 0;
80
+ $options['optimize_tracking'] = 0;
81
+ $options['optimize_containerid'] = '';
82
+ $options['optimize_pagehiding'] = '';
83
+ $options['ga_dash_excludesa'] = 0;
84
+ $options['ga_pagescrolldepth_tracking'] = 0;
85
+ $options['tm_pagescrolldepth_tracking'] = 0;
86
  } else {
87
  $options = array();
88
  $options['ga_dash_clientid'] = get_option( 'ga_dash_clientid' );
95
  $options['ga_dash_style'] = '#1e73be';
96
  $options['switch_profile'] = get_option( 'ga_dash_jailadmins' );
97
  $options['ga_dash_cachetime'] = get_option( 'ga_dash_cachetime' );
 
 
 
 
 
98
  $options['ga_dash_tracking_type'] = get_option( 'ga_dash_tracking_type' );
99
  $options['ga_dash_default_ua'] = get_option( 'ga_dash_default_ua' );
100
  $options['ga_dash_anonim'] = get_option( 'ga_dash_anonim' );
129
  $options['ga_cookiedomain'] = '';
130
  $options['ga_cookiename'] = '';
131
  $options['ga_cookieexpires'] = '';
132
+ $options['pagetitle_404'] = 'Page Not Found';
133
+ $options['maps_api_key'] = '';
134
+ $options['tm_author_var'] = 0;
135
+ $options['tm_category_var'] = 0;
136
+ $options['tm_tag_var'] = 0;
137
+ $options['tm_user_var'] = 0;
138
+ $options['tm_pubyear_var'] = 0;
139
+ $options['tm_pubyearmonth_var'] = 0;
140
+ $options['web_containerid'] = '';
141
+ $options['amp_containerid'] = '';
142
+ $options['amp_tracking_tagmanager'] = 0;
143
+ $options['amp_tracking_analytics'] = 0;
144
+ $options['trackingcode_infooter'] = 0;
145
+ $options['trackingevents_infooter'] = 0;
146
+ $options['ecommerce_mode'] = 'disabled';
147
+ $options['ga_formsubmit_tracking'] = 0;
148
+ $options['optimize_tracking'] = 0;
149
+ $options['optimize_containerid'] = '';
150
+ $options['optimize_pagehiding'] = '';
151
+ $options['ga_dash_excludesa'] = 0;
152
+ $options['ga_pagescrolldepth_tracking'] = 0;
153
+ $options['tm_pagescrolldepth_tracking'] = 0;
154
 
155
  delete_option( 'ga_dash_clientid' );
156
  delete_option( 'ga_dash_clientsecret' );
readme.txt CHANGED
@@ -1,23 +1,23 @@
1
- === Google Analytics Dashboard for WP ===
2
  Contributors: deconf
3
  Donate link: https://deconf.com/donate/
4
- Tags: stats,analytics,google analytics,google analytics dashboard,google analytics plugin,google analytics widget,dashboard,tracking,analytics dashboard,universal google analytics,realtime,multisite,gadwp
5
  Requires at least: 3.5
6
- Tested up to: 4.7.4
7
- Stable tag: 4.9.6.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- Displays Google Analytics stats in your WordPress Dashboard. Inserts the latest Google Analytics tracking code in your pages.
12
 
13
  == Description ==
14
  This Google Analytics for WordPress plugin enables you to track your site using the latest Google Analytics tracking code and allows you to view key Google Analytics stats in your WordPress install.
15
 
16
  In addition to a set of general Google Analytics stats, in-depth Page reports and in-depth Post reports allow further segmentation of your analytics data, providing performance details for each post or page from your website.
17
 
18
- The Google Analytics tracking code is fully customizable through options and hooks, allowing advanced data collection using custom dimensions and events.
19
 
20
- = Google Analytics Real-Time Stats=
21
 
22
  Google Analytics reports, in real-time, in your dashboard screen:
23
 
@@ -31,24 +31,24 @@ The Google Analytics reports you need, on your dashboard, in your All Posts and
31
 
32
  - Sessions, organic searches, page views, bounce rate analytics stats
33
  - Locations, pages, referrers, keywords, 404 errors analytics stats
34
- - Traffic channels, social networks, traffic mediums, search engines analytics reports
35
- - Device categories, browsers, operating systems, screen resolutions, mobile brands analytics reports
36
- - User access control over analytics reports
37
 
38
- = Google Analytics Basic Tracking =
 
 
39
 
40
  Installs the latest Google Analytics tracking code and allows full code customization:
41
 
42
- - Switch between Universal Google Analytics and Classic Google Analytics code
43
  - IP address anonymization
44
  - Enhanced link attribution
45
  - Remarketing, demographics and interests tracking
46
- - Google AdSense linking
47
  - Page Speed sampling rate control
48
  - Cross domain tracking
49
  - Exclude user roles from tracking
50
-
51
- = Google Analytics Event Tracking =
52
 
53
  Google Analytics Dashboard for WP enables you to easily track events like:
54
 
@@ -57,8 +57,8 @@ Google Analytics Dashboard for WP enables you to easily track events like:
57
  - Outbound links
58
  - Affiliate links
59
  - Fragment identifiers
60
-
61
- = Google Analytics Custom Dimensions =
62
 
63
  With Google Analytics Dashboard for WP you can use custom dimensions to track:
64
 
@@ -69,6 +69,18 @@ With Google Analytics Dashboard for WP you can use custom dimensions to track:
69
  - Tags
70
  - User engagement
71
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  = Google Analytics Dashboard for WP on Multisite =
73
 
74
  This plugin is fully compatible with multisite network installs, allowing three setup modes:
@@ -135,42 +147,29 @@ Google Analytics Dashboard for WP it's released under the GPLv2, you can use it
135
 
136
  == Upgrade Notice ==
137
 
 
 
138
  == Changelog ==
139
 
140
- = 4.9.6.2 =
141
- * Enhancements:
142
- * switching sampling level to higher precision to increase the accuracy of reports
143
-
144
- = 4.9.6.1 =
145
- * Enhancements:
146
- * enable anonymization for all hits instead of single hits to avoid false-positives from IP Anonymization checking tools
147
-
148
- = 4.9.6 =
149
- * Enhancements:
150
- * introducing average time on page, average page load time, average exit rate, and average session duration metrics
151
- * Bug Fixes:
152
- * use Google Maps API key only if available
153
- * fixes gadwp_sites_limit filter
154
-
155
- = 4.9.5 =
156
  * Enhancements:
157
- * introducing the <strong>gadwp_curl_options</strong> filter to allow changes on CURL options for the Google_IO_Curl class, props by [Alexandre Simard](https://github.com/brocheafoin)
158
- * Bug Fixes:
159
- * correction of some files with mixed endings, props by [Edward Dekker](http://www.github.com/edwarddekker)
160
- * only load the necessary resources for frontend widget
161
- * corrected a JavaScript error on frontend sidebar widget
162
-
163
- = 4.9.4 =
164
- * Enhancements:
165
- * always load analytics.js over SSL
166
- * gadwp_backenditem_uri filter passes post ID as an additional variable
167
- * option to use a Google Maps API key for the Locations report
168
  * New Features:
169
- * a new year-month dimension is now available, to allow further segmentation of the most successful publication years, by month; props by [Antoine Girard](https://github.com/thetoine)
170
- * a new 404 Errors report designed to analyze and easily identify the source of 404 errors
171
- * Bug Fixes:
172
- * switch to get_sites() while maintaining compatibility with older WP installs
173
- * fix for multisite installs, Properties/Views Settings list was not properly displayed on PHP7
174
- * prevent autoloading of reports' cache entries; props by [Alex Bradaric](https://github.com/bradaric)
 
 
 
175
 
176
  The full changelog is [available here](https://deconf.com/changelog-google-analytics-dashboard-for-wp/).
1
+ === Google Analytics Dashboard for WP (GADWP) ===
2
  Contributors: deconf
3
  Donate link: https://deconf.com/donate/
4
+ Tags: analytics,google analytics,google analytics dashboard,google analytics plugin,google analytics widget
5
  Requires at least: 3.5
6
+ Tested up to: 4.7.5
7
+ Stable tag: 5.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Connects Google Analytics with your WordPress site. Displays stats to help you understand your users and site content on a whole new level!
12
 
13
  == Description ==
14
  This Google Analytics for WordPress plugin enables you to track your site using the latest Google Analytics tracking code and allows you to view key Google Analytics stats in your WordPress install.
15
 
16
  In addition to a set of general Google Analytics stats, in-depth Page reports and in-depth Post reports allow further segmentation of your analytics data, providing performance details for each post or page from your website.
17
 
18
+ The Google Analytics tracking code is fully customizable through options and hooks, allowing advanced data collection like custom dimensions and events.
19
 
20
+ = Google Analytics Real-Time Stats =
21
 
22
  Google Analytics reports, in real-time, in your dashboard screen:
23
 
31
 
32
  - Sessions, organic searches, page views, bounce rate analytics stats
33
  - Locations, pages, referrers, keywords, 404 errors analytics stats
34
+ - Traffic channels, social networks, traffic mediums, search engines analytics stats
35
+ - Device categories, browsers, operating systems, screen resolutions, mobile brands analytics stats
 
36
 
37
+ In addition, you can control who can view specific Google Analytics reports by setting permissions based on user roles.
38
+
39
+ = Google Analytics Tracking =
40
 
41
  Installs the latest Google Analytics tracking code and allows full code customization:
42
 
43
+ - Universal Google Analytics tracking code
44
  - IP address anonymization
45
  - Enhanced link attribution
46
  - Remarketing, demographics and interests tracking
 
47
  - Page Speed sampling rate control
48
  - Cross domain tracking
49
  - Exclude user roles from tracking
50
+ - Accelerated Mobile Pages (AMP) support for Google Analytics
51
+ - Ecommerce support for Google Analytics
52
 
53
  Google Analytics Dashboard for WP enables you to easily track events like:
54
 
57
  - Outbound links
58
  - Affiliate links
59
  - Fragment identifiers
60
+ - Telephone
61
+ - Page Scrolling Depth
62
 
63
  With Google Analytics Dashboard for WP you can use custom dimensions to track:
64
 
69
  - Tags
70
  - User engagement
71
 
72
+ Actions and filters are available for further Google Analytics tracking code customization.
73
+
74
+ = Google Tag Manager Tracking =
75
+
76
+ As an alternative to Google Analytics tracking code, you can use Google Tag Manager for tracking:
77
+
78
+ - Google Tag Manager code
79
+ - Data Layer variables: authors, publication year, publication month, categories, tags, user type
80
+ - Additional Data Layer variables for page scrolling depth
81
+ - Exclude user roles from tracking
82
+ - Accelerated Mobile Pages (AMP) support for Google Tag Manager
83
+
84
  = Google Analytics Dashboard for WP on Multisite =
85
 
86
  This plugin is fully compatible with multisite network installs, allowing three setup modes:
147
 
148
  == Upgrade Notice ==
149
 
150
+ This is a major update, please read the [release notes](https://deconf.com/google-analytics-dashboard-for-wp-5-0-release-notes/) first.
151
+
152
  == Changelog ==
153
 
154
+ = 5.0 =
155
+ * Release notes: [GADWP 5.0](https://deconf.com/google-analytics-dashboard-for-wp-5-0-release-notes/)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  * Enhancements:
157
+ * complete redesign of the tracking component
158
+ * AdSense Linking feature was removed since the new linking procedure does not require a special code anymore
159
+ * dropping support for Classic Analytics (ga.js) since all properties were transferred to Universal Analytics
160
+ * events are now tracked using a JS file instead of in-line JavaScript
161
+ * multiple improvements for events tracking accuracy
162
+ * ability to switch between sessions, users and pageviews metrics on reports like Location, Traffic, Searches
163
+ * the GAPI PHP Client was updated to v1.1.8
 
 
 
 
164
  * New Features:
165
+ * ability to use Google Tag Manager instead of Google Analytics tracking
166
+ * added Accelerated Mobile Pages (AMP) support for Google Analytics and Google Tag Manager tracking
167
+ * users can now switch the position of the tracking codes from head to body through options
168
+ * option to load Ecommerce or Enhanced Ecommerce plug-ins for analytics.js
169
+ * option to select the placement of the tracking code (head or footer)
170
+ * events tracking for form submit actions
171
+ * events tracking for telephone calls
172
+ * events tracking for page scrolling depth
173
+ * full support for experiments with Optimize
174
 
175
  The full changelog is [available here](https://deconf.com/changelog-google-analytics-dashboard-for-wp/).
realtime/jquery/jquery.ui.tooltip.html.css CHANGED
@@ -1,57 +1,3 @@
1
  /*! jQuery UI - v1.9.2 - 2013-09-22
2
  * http://jqueryui.com
3
- * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
4
- .ui-tooltip {
5
- padding: 8px;
6
- position: absolute;
7
- z-index: 9999;
8
- max-width: 300px;
9
- -webkit-box-shadow: 0 0 5px #aaa;
10
- box-shadow: 0 0 5px #aaa
11
- }
12
-
13
- * html .ui-tooltip {
14
- background-image: none
15
- }
16
-
17
- body .ui-tooltip {
18
- border-width: 2px
19
- }
20
-
21
- .ui-widget {
22
- font-family: Verdana, Arial, sans-serif;
23
- font-size: 1.1em;
24
- }
25
-
26
- .ui-widget .ui-widget {
27
- font-size: 1em;
28
- }
29
-
30
- .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button
31
- {
32
- font-family: Verdana, Arial, sans-serif;
33
- font-size: 1em;
34
- }
35
-
36
- .ui-widget-content {
37
- border: 1px solid #aaaaaa;
38
- background: #ffffff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50%
39
- repeat-x;
40
- color: #222222;
41
- }
42
-
43
- .ui-widget-content a {
44
- color: #222222;
45
- }
46
-
47
- .ui-widget-header {
48
- border: 1px solid #aaaaaa;
49
- background: #cccccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png)
50
- 50% 50% repeat-x;
51
- color: #222222;
52
- font-weight: bold;
53
- }
54
-
55
- .ui-widget-header a {
56
- color: #222222;
57
- }
1
  /*! jQuery UI - v1.9.2 - 2013-09-22
2
  * http://jqueryui.com
3
+ * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */.ui-tooltip{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}* html .ui-tooltip{background-image:none}body .ui-tooltip{border-width:2px}.ui-widget{font-family:Verdana,Arial,sans-serif;font-size:1.1em}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Verdana,Arial,sans-serif;font-size:1em}.ui-widget-content{border:1px solid #aaa;background:#fff url(images/ui-bg_flat_75_ffffff_40x100.png) 50% 50% repeat-x;color:#222}.ui-widget-content a{color:#222}.ui-widget-header{border:1px solid #aaa;background:#ccc url(images/ui-bg_highlight-soft_75_cccccc_1x100.png) 50% 50% repeat-x;color:#222;font-weight:bold}.ui-widget-header a{color:#222}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
realtime/jquery/jquery.ui.tooltip.html.js CHANGED
@@ -1,16 +1 @@
1
- /*-
2
- * Author: Alin Marcu
3
- * Author URI: https://deconf.com
4
- * Copyright 2013 Alin Marcu
5
- * License: GPLv2 or later
6
- * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
- */
8
-
9
- jQuery(function () {
10
- jQuery('#gadash-widget *').tooltip({
11
- items: "[data-tooltip]",
12
- content: function () {
13
- return jQuery(this).attr("data-tooltip");
14
- }
15
- });
16
- });
1
+ jQuery(function(){jQuery("#gadash-widget *").tooltip({items:"[data-tooltip]",content:function(){return jQuery(this).attr("data-tooltip")}})});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
tools/gapi.php CHANGED
@@ -32,7 +32,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
32
  public function __construct() {
33
  $this->gadwp = GADWP();
34
 
35
- include_once ( GADWP_DIR . 'tools/autoload.php' );
36
  $config = new Google_Config();
37
  $config->setCacheClass( 'Google_Cache_Null' );
38
  if ( function_exists( 'curl_version' ) ) {
@@ -101,14 +101,14 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
101
  */
102
  public function gapi_errors_handler() {
103
  $errors = GADWP_Tools::get_cache( 'gapi_errors' );
104
- if ( $errors === false || ! isset( $errors[0] ) ) { // invalid error
105
  return false;
106
  }
107
- if ( isset( $errors[1][0]['reason'] ) && ( $errors[1][0]['reason'] == 'invalidCredentials' || $errors[1][0]['reason'] == 'authError' || $errors[1][0]['reason'] == 'insufficientPermissions' || $errors[1][0]['reason'] == 'required' || $errors[1][0]['reason'] == 'keyExpired' ) ) {
108
  $this->reset_token( false );
109
  return true;
110
  }
111
- if ( isset( $errors[1][0]['reason'] ) && ( $errors[1][0]['reason'] == 'userRateLimitExceeded' || $errors[1][0]['reason'] == 'quotaExceeded' ) ) {
112
  if ( $this->gadwp->config->options['api_backoff'] <= 5 ) {
113
  usleep( rand( 100000, 1500000 ) );
114
  $this->gadwp->config->options['api_backoff'] = $this->gadwp->config->options['api_backoff'] + 1;
@@ -118,7 +118,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
118
  return true;
119
  }
120
  }
121
- if ( $errors[0] == 400 || $errors[0] == 401 || $errors[0] == 403 ) {
122
  return true;
123
  }
124
  return false;
@@ -277,19 +277,27 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
277
  */
278
  private function handle_corereports( $projectId, $from, $to, $metrics, $options, $serial ) {
279
  try {
280
- if ( $from == "today" ) {
281
- $timeouts = 0;
282
  } else {
283
- $timeouts = 1;
284
  }
285
  $transient = GADWP_Tools::get_cache( $serial );
286
- if ( $transient === false ) {
287
  if ( $this->gapi_errors_handler() ) {
288
  return - 23;
289
  }
290
  $options['samplingLevel'] = 'HIGHER_PRECISION';
291
  $data = $this->service->data_ga->get( 'ga:' . $projectId, $from, $to, $metrics, $options );
292
- GADWP_Tools::set_cache( $serial, $data, $this->get_timeouts( $timeouts ) );
 
 
 
 
 
 
 
 
293
  $this->gadwp->config->options['api_backoff'] = 0;
294
  $this->gadwp->config->set_plugin_options();
295
  } else {
@@ -357,10 +365,10 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
357
  $title = __( "Sessions", 'google-analytics-dashboard-for-wp' );
358
  }
359
  $metrics = 'ga:' . $query;
360
- if ( $from == "today" || $from == "yesterday" ) {
361
  $dimensions = 'ga:hour';
362
  $dayorhour = __( "Hour", 'google-analytics-dashboard-for-wp' );
363
- } else if ( $from == "365daysAgo" || $from == "1095daysAgo" ) {
364
  $dimensions = 'ga:yearMonth, ga:month';
365
  $dayorhour = __( "Date", 'google-analytics-dashboard-for-wp' );
366
  } else {
@@ -377,11 +385,11 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
377
  return $data;
378
  }
379
  $gadwp_data = array( array( $dayorhour, $title ) );
380
- if ( $from == "today" || $from == "yesterday" ) {
381
  foreach ( $data->getRows() as $row ) {
382
  $gadwp_data[] = array( (int) $row[0] . ':00', round( $row[1], 2 ) );
383
  }
384
- } else if ( $from == "365daysAgo" || $from == "1095daysAgo" ) {
385
  foreach ( $data->getRows() as $row ) {
386
  /*
387
  * translators:
@@ -428,7 +436,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
428
  $serial = 'qr3_' . $this->get_serial( $projectId . $from . $filter );
429
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
430
  if ( is_numeric( $data ) ) {
431
- if ( $data == - 21 ) {
432
  return array_fill( 0, 9, 0 );
433
  } else {
434
  return $data;
@@ -470,19 +478,19 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
470
  * $filter
471
  * @return array|int
472
  */
473
- private function get_contentpages( $projectId, $from, $to, $filter = '' ) {
474
- $metrics = 'ga:sessions';
475
  $dimensions = 'ga:pageTitle';
476
- $options = array( 'dimensions' => $dimensions, 'sort' => '-ga:sessions', 'quotaUser' => $this->managequota . 'p' . $projectId );
477
  if ( $filter ) {
478
  $options['filters'] = 'ga:pagePath==' . $filter;
479
  }
480
- $serial = 'qr4_' . $this->get_serial( $projectId . $from . $filter );
481
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
482
  if ( is_numeric( $data ) ) {
483
  return $data;
484
  }
485
- $gadwp_data = array( array( __( "Pages", 'google-analytics-dashboard-for-wp' ), __( "Sessions", 'google-analytics-dashboard-for-wp' ) ) );
486
  foreach ( $data->getRows() as $row ) {
487
  $gadwp_data[] = array( esc_html( $row[0] ), (int) $row[1] );
488
  }
@@ -500,17 +508,17 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
500
  * $to
501
  * @return array|int
502
  */
503
- private function get_404errors( $projectId, $from, $to, $filter = "Page Not Found" ) {
504
- $metrics = 'ga:sessions';
505
  $dimensions = 'ga:pagePath,ga:fullReferrer';
506
- $options = array( 'dimensions' => $dimensions, 'sort' => '-ga:sessions', 'quotaUser' => $this->managequota . 'p' . $projectId );
507
  $options['filters'] = 'ga:pageTitle=@' . $filter;
508
- $serial = 'qr4_' . $this->get_serial( $projectId . $from . $filter );
509
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
510
  if ( is_numeric( $data ) ) {
511
  return $data;
512
  }
513
- $gadwp_data = array( array( __( "404 Errors", 'google-analytics-dashboard-for-wp' ), __( "Sessions", 'google-analytics-dashboard-for-wp' ) ) );
514
  foreach ( $data->getRows() as $row ) {
515
  $path = esc_html( $row[0] );
516
  $source = esc_html( $row[1] );
@@ -532,21 +540,21 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
532
  * $filter
533
  * @return array|int
534
  */
535
- private function get_referrers( $projectId, $from, $to, $filter = '' ) {
536
- $metrics = 'ga:sessions';
537
  $dimensions = 'ga:source';
538
- $options = array( 'dimensions' => $dimensions, 'sort' => '-ga:sessions', 'quotaUser' => $this->managequota . 'p' . $projectId );
539
  if ( $filter ) {
540
  $options['filters'] = 'ga:medium==referral;ga:pagePath==' . $filter;
541
  } else {
542
  $options['filters'] = 'ga:medium==referral';
543
  }
544
- $serial = 'qr5_' . $this->get_serial( $projectId . $from . $filter );
545
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
546
  if ( is_numeric( $data ) ) {
547
  return $data;
548
  }
549
- $gadwp_data = array( array( __( "Referrers", 'google-analytics-dashboard-for-wp' ), __( "Sessions", 'google-analytics-dashboard-for-wp' ) ) );
550
  foreach ( $data->getRows() as $row ) {
551
  $gadwp_data[] = array( esc_html( $row[0] ), (int) $row[1] );
552
  }
@@ -566,22 +574,22 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
566
  * $filter
567
  * @return array|int
568
  */
569
- private function get_searches( $projectId, $from, $to, $filter = '' ) {
570
- $metrics = 'ga:sessions';
571
  $dimensions = 'ga:keyword';
572
- $options = array( 'dimensions' => $dimensions, 'sort' => '-ga:sessions', 'quotaUser' => $this->managequota . 'p' . $projectId );
573
  if ( $filter ) {
574
  $options['filters'] = 'ga:keyword!=(not set);ga:pagePath==' . $filter;
575
  } else {
576
  $options['filters'] = 'ga:keyword!=(not set)';
577
  }
578
- $serial = 'qr6_' . $this->get_serial( $projectId . $from . $filter );
579
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
580
  if ( is_numeric( $data ) ) {
581
  return $data;
582
  }
583
 
584
- $gadwp_data = array( array( __( "Searches", 'google-analytics-dashboard-for-wp' ), __( "Sessions", 'google-analytics-dashboard-for-wp' ) ) );
585
  foreach ( $data->getRows() as $row ) {
586
  $gadwp_data[] = array( esc_html( $row[0] ), (int) $row[1] );
587
  }
@@ -601,8 +609,8 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
601
  * $filter
602
  * @return array|int
603
  */
604
- private function get_locations( $projectId, $from, $to, $filter = '' ) {
605
- $metrics = 'ga:sessions';
606
  $options = "";
607
  $title = __( "Countries", 'google-analytics-dashboard-for-wp' );
608
  $serial = 'qr7_' . $this->get_serial( $projectId . $from . $filter );
@@ -615,10 +623,10 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
615
  if ( isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
616
  $local_filter = 'ga:country==' . ( $country_codes[$this->gadwp->config->options['ga_target_geomap']] );
617
  $title = __( "Cities from", 'google-analytics-dashboard-for-wp' ) . ' ' . __( $country_codes[$this->gadwp->config->options['ga_target_geomap']] );
618
- $serial = 'qr7_' . $this->get_serial( $projectId . $from . $this->gadwp->config->options['ga_target_geomap'] . $filter );
619
  }
620
  }
621
- $options = array( 'dimensions' => $dimensions, 'sort' => '-ga:sessions', 'quotaUser' => $this->managequota . 'p' . $projectId );
622
  if ( $filter ) {
623
  $options['filters'] = 'ga:pagePath==' . $filter;
624
  if ( $local_filter ) {
@@ -633,7 +641,8 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
633
  if ( is_numeric( $data ) ) {
634
  return $data;
635
  }
636
- $gadwp_data = array( array( $title, __( "Sessions", 'google-analytics-dashboard-for-wp' ) ) );
 
637
  foreach ( $data->getRows() as $row ) {
638
  if ( isset( $row[2] ) ) {
639
  $gadwp_data[] = array( esc_html( $row[0] ) . ', ' . esc_html( $row[1] ), (int) $row[2] );
@@ -659,23 +668,23 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
659
  * $filter
660
  * @return array|int
661
  */
662
- private function get_orgchart_data( $projectId, $from, $to, $query, $filter = '' ) {
663
- $metrics = 'ga:sessions';
664
  $dimensions = 'ga:' . $query;
665
- $options = array( 'dimensions' => $dimensions, 'sort' => '-ga:sessions', 'quotaUser' => $this->managequota . 'p' . $projectId );
666
  if ( $filter ) {
667
  $options['filters'] = 'ga:pagePath==' . $filter;
668
  }
669
- $serial = 'qr8_' . $this->get_serial( $projectId . $from . $query . $filter );
670
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
671
  if ( is_numeric( $data ) ) {
672
  return $data;
673
  }
674
- $block = ( $query == 'channelGrouping' ) ? __( "Channels", 'google-analytics-dashboard-for-wp' ) : __( "Devices", 'google-analytics-dashboard-for-wp' );
675
- $gadwp_data = array( array( '<div style="color:black; font-size:1.1em">' . $block . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $data['totalsForAllResults']["ga:sessions"] . '</div>', "" ) );
676
  foreach ( $data->getRows() as $row ) {
677
  $shrink = explode( " ", $row[0] );
678
- $gadwp_data[] = array( '<div style="color:black; font-size:1.1em">' . esc_html( $shrink[0] ) . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $row[1] . '</div>', '<div style="color:black; font-size:1.1em">' . $block . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $data['totalsForAllResults']["ga:sessions"] . '</div>' );
679
  }
680
  return $gadwp_data;
681
  }
@@ -695,31 +704,31 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
695
  * $filter
696
  * @return array|int
697
  */
698
- private function get_piechart_data( $projectId, $from, $to, $query, $filter = '' ) {
699
- $metrics = 'ga:sessions';
700
  $dimensions = 'ga:' . $query;
701
 
702
- if ( $query == 'source' ) {
703
- $options = array( 'dimensions' => $dimensions, 'sort' => '-ga:sessions', 'quotaUser' => $this->managequota . 'p' . $projectId );
704
  if ( $filter ) {
705
  $options['filters'] = 'ga:medium==organic;ga:keyword!=(not set);ga:pagePath==' . $filter;
706
  } else {
707
  $options['filters'] = 'ga:medium==organic;ga:keyword!=(not set)';
708
  }
709
  } else {
710
- $options = array( 'dimensions' => $dimensions, 'sort' => '-ga:sessions', 'quotaUser' => $this->managequota . 'p' . $projectId );
711
  if ( $filter ) {
712
  $options['filters'] = 'ga:' . $query . '!=(not set);ga:pagePath==' . $filter;
713
  } else {
714
  $options['filters'] = 'ga:' . $query . '!=(not set)';
715
  }
716
  }
717
- $serial = 'qr10_' . $this->get_serial( $projectId . $from . $query . $filter );
718
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
719
  if ( is_numeric( $data ) ) {
720
  return $data;
721
  }
722
- $gadwp_data = array( array( __( "Type", 'google-analytics-dashboard-for-wp' ), __( "Sessions", 'google-analytics-dashboard-for-wp' ) ) );
723
  $i = 0;
724
  $included = 0;
725
  foreach ( $data->getRows() as $row ) {
@@ -732,7 +741,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
732
  }
733
  }
734
  $totals = $data->getTotalsForAllResults();
735
- $others = $totals['ga:sessions'] - $included;
736
  if ( $others > 0 ) {
737
  $gadwp_data[] = array( __( 'Other', 'google-analytics-dashboard-for-wp' ), $others );
738
  }
@@ -790,7 +799,7 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
790
  try {
791
  $serial = 'qr_realtimecache_' . $this->get_serial( $projectId );
792
  $transient = GADWP_Tools::get_cache( $serial );
793
- if ( $transient === false ) {
794
  if ( $this->gapi_errors_handler() ) {
795
  return - 23;
796
  }
@@ -845,40 +854,40 @@ if ( ! class_exists( 'GADWP_GAPI_Controller' ) ) {
845
  * $filter
846
  * @return number|Google_Service_Analytics_GaData
847
  */
848
- public function get( $projectId, $query, $from = false, $to = false, $filter = '' ) {
849
  if ( empty( $projectId ) || ! is_numeric( $projectId ) ) {
850
  wp_die( - 26 );
851
  }
852
  if ( in_array( $query, array( 'sessions', 'users', 'organicSearches', 'visitBounceRate', 'pageviews', 'uniquePageviews' ) ) ) {
853
  return $this->get_areachart_data( $projectId, $from, $to, $query, $filter );
854
  }
855
- if ( $query == 'bottomstats' ) {
856
  return $this->get_bottomstats( $projectId, $from, $to, $filter );
857
  }
858
- if ( $query == 'locations' ) {
859
- return $this->get_locations( $projectId, $from, $to, $filter );
860
  }
861
- if ( $query == 'referrers' ) {
862
- return $this->get_referrers( $projectId, $from, $to, $filter );
863
  }
864
- if ( $query == 'contentpages' ) {
865
- return $this->get_contentpages( $projectId, $from, $to, $filter );
866
  }
867
- if ( $query == '404errors' ) {
868
  $filter = $this->gadwp->config->options['pagetitle_404'];
869
- return $this->get_404errors( $projectId, $from, $to, $filter );
870
  }
871
- if ( $query == 'searches' ) {
872
- return $this->get_searches( $projectId, $from, $to, $filter );
873
  }
874
- if ( $query == 'realtime' ) {
875
  return $this->get_realtime( $projectId );
876
  }
877
- if ( $query == 'channelGrouping' || $query == 'deviceCategory' ) {
878
- return $this->get_orgchart_data( $projectId, $from, $to, $query, $filter );
879
  }
880
  if ( in_array( $query, array( 'medium', 'visitorType', 'socialNetwork', 'source', 'browser', 'operatingSystem', 'screenResolution', 'mobileDeviceBranding' ) ) ) {
881
- return $this->get_piechart_data( $projectId, $from, $to, $query, $filter );
882
  }
883
  wp_die( - 27 );
884
  }
32
  public function __construct() {
33
  $this->gadwp = GADWP();
34
 
35
+ include_once ( GADWP_DIR . 'tools/src/Google/autoload.php' );
36
  $config = new Google_Config();
37
  $config->setCacheClass( 'Google_Cache_Null' );
38
  if ( function_exists( 'curl_version' ) ) {
101
  */
102
  public function gapi_errors_handler() {
103
  $errors = GADWP_Tools::get_cache( 'gapi_errors' );
104
+ if ( false === $errors || ! isset( $errors[0] ) ) { // invalid error
105
  return false;
106
  }
107
+ if ( isset( $errors[1][0]['reason'] ) && ( 'invalidCredentials' == $errors[1][0]['reason'] || 'authError' == $errors[1][0]['reason'] || 'insufficientPermissions' == $errors[1][0]['reason'] || 'required' == $errors[1][0]['reason'] || 'keyExpired' == $errors[1][0]['reason'] ) ) {
108
  $this->reset_token( false );
109
  return true;
110
  }
111
+ if ( isset( $errors[1][0]['reason'] ) && ( 'userRateLimitExceeded' == $errors[1][0]['reason'] || 'quotaExceeded' == $errors[1][0]['reason'] ) ) {
112
  if ( $this->gadwp->config->options['api_backoff'] <= 5 ) {
113
  usleep( rand( 100000, 1500000 ) );
114
  $this->gadwp->config->options['api_backoff'] = $this->gadwp->config->options['api_backoff'] + 1;
118
  return true;
119
  }
120
  }
121
+ if ( 400 == $errors[0] || 401 == $errors[0] || 403 == $errors[0] ) {
122
  return true;
123
  }
124
  return false;
277
  */
278
  private function handle_corereports( $projectId, $from, $to, $metrics, $options, $serial ) {
279
  try {
280
+ if ( 'today' == $from ) {
281
+ $daily = 0;
282
  } else {
283
+ $daily = 1;
284
  }
285
  $transient = GADWP_Tools::get_cache( $serial );
286
+ if ( false === $transient ) {
287
  if ( $this->gapi_errors_handler() ) {
288
  return - 23;
289
  }
290
  $options['samplingLevel'] = 'HIGHER_PRECISION';
291
  $data = $this->service->data_ga->get( 'ga:' . $projectId, $from, $to, $metrics, $options );
292
+ if ( method_exists( $data, 'getContainsSampledData' ) && $data->getContainsSampledData() ) {
293
+ $sampling['date'] = date( 'Y-m-d H:i:s' );
294
+ $sampling['percent'] = number_format( ( $data->getSampleSize() / $data->getSampleSpace() ) * 100, 2 ) . '%';
295
+ $sampling['sessions'] = $data->getSampleSize() . ' / ' . $data->getSampleSpace();
296
+ GADWP_Tools::set_cache( 'sampleddata', $sampling, 30 * 24 * 3600 );
297
+ GADWP_Tools::set_cache( $serial, $data, $this->get_timeouts( 0 ) ); // refresh every hour if data is sampled
298
+ } else {
299
+ GADWP_Tools::set_cache( $serial, $data, $this->get_timeouts( $daily ) );
300
+ }
301
  $this->gadwp->config->options['api_backoff'] = 0;
302
  $this->gadwp->config->set_plugin_options();
303
  } else {
365
  $title = __( "Sessions", 'google-analytics-dashboard-for-wp' );
366
  }
367
  $metrics = 'ga:' . $query;
368
+ if ( 'today' == $from || 'yesterday' == $from ) {
369
  $dimensions = 'ga:hour';
370
  $dayorhour = __( "Hour", 'google-analytics-dashboard-for-wp' );
371
+ } else if ( '365daysAgo' == $from || '1095daysAgo' == $from ) {
372
  $dimensions = 'ga:yearMonth, ga:month';
373
  $dayorhour = __( "Date", 'google-analytics-dashboard-for-wp' );
374
  } else {
385
  return $data;
386
  }
387
  $gadwp_data = array( array( $dayorhour, $title ) );
388
+ if ( 'today' == $from || 'yesterday' == $from ) {
389
  foreach ( $data->getRows() as $row ) {
390
  $gadwp_data[] = array( (int) $row[0] . ':00', round( $row[1], 2 ) );
391
  }
392
+ } else if ( '365daysAgo' == $from || '1095daysAgo' == $from ) {
393
  foreach ( $data->getRows() as $row ) {
394
  /*
395
  * translators:
436
  $serial = 'qr3_' . $this->get_serial( $projectId . $from . $filter );
437
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
438
  if ( is_numeric( $data ) ) {
439
+ if ( - 21 == $data ) {
440
  return array_fill( 0, 9, 0 );
441
  } else {
442
  return $data;
478
  * $filter
479
  * @return array|int
480
  */
481
+ private function get_contentpages( $projectId, $from, $to, $filter = '', $metric ) {
482
+ $metrics = 'ga:' . $metric;
483
  $dimensions = 'ga:pageTitle';
484
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
485
  if ( $filter ) {
486
  $options['filters'] = 'ga:pagePath==' . $filter;
487
  }
488
+ $serial = 'qr4_' . $this->get_serial( $projectId . $from . $filter . $metric );
489
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
490
  if ( is_numeric( $data ) ) {
491
  return $data;
492
  }
493
+ $gadwp_data = array( array( __( "Pages", 'google-analytics-dashboard-for-wp' ), __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
494
  foreach ( $data->getRows() as $row ) {
495
  $gadwp_data[] = array( esc_html( $row[0] ), (int) $row[1] );
496
  }
508
  * $to
509
  * @return array|int
510
  */
511
+ private function get_404errors( $projectId, $from, $to, $filter = "Page Not Found", $metric ) {
512
+ $metrics = 'ga:' . $metric;
513
  $dimensions = 'ga:pagePath,ga:fullReferrer';
514
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
515
  $options['filters'] = 'ga:pageTitle=@' . $filter;
516
+ $serial = 'qr4_' . $this->get_serial( $projectId . $from . $filter . $metric );
517
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
518
  if ( is_numeric( $data ) ) {
519
  return $data;
520
  }
521
+ $gadwp_data = array( array( __( "404 Errors", 'google-analytics-dashboard-for-wp' ), __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
522
  foreach ( $data->getRows() as $row ) {
523
  $path = esc_html( $row[0] );
524
  $source = esc_html( $row[1] );
540
  * $filter
541
  * @return array|int
542
  */
543
+ private function get_referrers( $projectId, $from, $to, $filter = '', $metric ) {
544
+ $metrics = 'ga:' . $metric;
545
  $dimensions = 'ga:source';
546
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
547
  if ( $filter ) {
548
  $options['filters'] = 'ga:medium==referral;ga:pagePath==' . $filter;
549
  } else {
550
  $options['filters'] = 'ga:medium==referral';
551
  }
552
+ $serial = 'qr5_' . $this->get_serial( $projectId . $from . $filter . $metric );
553
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
554
  if ( is_numeric( $data ) ) {
555
  return $data;
556
  }
557
+ $gadwp_data = array( array( __( "Referrers", 'google-analytics-dashboard-for-wp' ), __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
558
  foreach ( $data->getRows() as $row ) {
559
  $gadwp_data[] = array( esc_html( $row[0] ), (int) $row[1] );
560
  }
574
  * $filter
575
  * @return array|int
576
  */
577
+ private function get_searches( $projectId, $from, $to, $filter = '', $metric ) {
578
+ $metrics = 'ga:' . $metric;
579
  $dimensions = 'ga:keyword';
580
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
581
  if ( $filter ) {
582
  $options['filters'] = 'ga:keyword!=(not set);ga:pagePath==' . $filter;
583
  } else {
584
  $options['filters'] = 'ga:keyword!=(not set)';
585
  }
586
+ $serial = 'qr6_' . $this->get_serial( $projectId . $from . $filter . $metric );
587
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
588
  if ( is_numeric( $data ) ) {
589
  return $data;
590
  }
591
 
592
+ $gadwp_data = array( array( __( "Searches", 'google-analytics-dashboard-for-wp' ), __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
593
  foreach ( $data->getRows() as $row ) {
594
  $gadwp_data[] = array( esc_html( $row[0] ), (int) $row[1] );
595
  }
609
  * $filter
610
  * @return array|int
611
  */
612
+ private function get_locations( $projectId, $from, $to, $filter = '', $metric ) {
613
+ $metrics = 'ga:' . $metric;
614
  $options = "";
615
  $title = __( "Countries", 'google-analytics-dashboard-for-wp' );
616
  $serial = 'qr7_' . $this->get_serial( $projectId . $from . $filter );
623
  if ( isset( $country_codes[$this->gadwp->config->options['ga_target_geomap']] ) ) {
624
  $local_filter = 'ga:country==' . ( $country_codes[$this->gadwp->config->options['ga_target_geomap']] );
625
  $title = __( "Cities from", 'google-analytics-dashboard-for-wp' ) . ' ' . __( $country_codes[$this->gadwp->config->options['ga_target_geomap']] );
626
+ $serial = 'qr7_' . $this->get_serial( $projectId . $from . $this->gadwp->config->options['ga_target_geomap'] . $filter . $metric );
627
  }
628
  }
629
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
630
  if ( $filter ) {
631
  $options['filters'] = 'ga:pagePath==' . $filter;
632
  if ( $local_filter ) {
641
  if ( is_numeric( $data ) ) {
642
  return $data;
643
  }
644
+
645
+ $gadwp_data = array( array( $title, __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
646
  foreach ( $data->getRows() as $row ) {
647
  if ( isset( $row[2] ) ) {
648
  $gadwp_data[] = array( esc_html( $row[0] ) . ', ' . esc_html( $row[1] ), (int) $row[2] );
668
  * $filter
669
  * @return array|int
670
  */
671
+ private function get_orgchart_data( $projectId, $from, $to, $query, $filter = '', $metric ) {
672
+ $metrics = 'ga:' . $metric;
673
  $dimensions = 'ga:' . $query;
674
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
675
  if ( $filter ) {
676
  $options['filters'] = 'ga:pagePath==' . $filter;
677
  }
678
+ $serial = 'qr8_' . $this->get_serial( $projectId . $from . $query . $filter . $metric );
679
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
680
  if ( is_numeric( $data ) ) {
681
  return $data;
682
  }
683
+ $block = ( 'channelGrouping' == $query ) ? __( "Channels", 'google-analytics-dashboard-for-wp' ) : __( "Devices", 'google-analytics-dashboard-for-wp' );
684
+ $gadwp_data = array( array( '<div style="color:black; font-size:1.1em">' . $block . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $data['totalsForAllResults'][$metrics] . '</div>', "" ) );
685
  foreach ( $data->getRows() as $row ) {
686
  $shrink = explode( " ", $row[0] );
687
+ $gadwp_data[] = array( '<div style="color:black; font-size:1.1em">' . esc_html( $shrink[0] ) . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $row[1] . '</div>', '<div style="color:black; font-size:1.1em">' . $block . '</div><div style="color:darkblue; font-size:1.2em">' . (int) $data['totalsForAllResults'][$metrics] . '</div>' );
688
  }
689
  return $gadwp_data;
690
  }
704
  * $filter
705
  * @return array|int
706
  */
707
+ private function get_piechart_data( $projectId, $from, $to, $query, $filter = '', $metric ) {
708
+ $metrics = 'ga:' . $metric;
709
  $dimensions = 'ga:' . $query;
710
 
711
+ if ( 'source' == $query ) {
712
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
713
  if ( $filter ) {
714
  $options['filters'] = 'ga:medium==organic;ga:keyword!=(not set);ga:pagePath==' . $filter;
715
  } else {
716
  $options['filters'] = 'ga:medium==organic;ga:keyword!=(not set)';
717
  }
718
  } else {
719
+ $options = array( 'dimensions' => $dimensions, 'sort' => '-' . $metrics, 'quotaUser' => $this->managequota . 'p' . $projectId );
720
  if ( $filter ) {
721
  $options['filters'] = 'ga:' . $query . '!=(not set);ga:pagePath==' . $filter;
722
  } else {
723
  $options['filters'] = 'ga:' . $query . '!=(not set)';
724
  }
725
  }
726
+ $serial = 'qr10_' . $this->get_serial( $projectId . $from . $query . $filter . $metric );
727
  $data = $this->handle_corereports( $projectId, $from, $to, $metrics, $options, $serial );
728
  if ( is_numeric( $data ) ) {
729
  return $data;
730
  }
731
+ $gadwp_data = array( array( __( "Type", 'google-analytics-dashboard-for-wp' ), __( ucfirst( $metric ), 'google-analytics-dashboard-for-wp' ) ) );
732
  $i = 0;
733
  $included = 0;
734
  foreach ( $data->getRows() as $row ) {
741
  }
742
  }
743
  $totals = $data->getTotalsForAllResults();
744
+ $others = $totals[$metrics] - $included;
745
  if ( $others > 0 ) {
746
  $gadwp_data[] = array( __( 'Other', 'google-analytics-dashboard-for-wp' ), $others );
747
  }
799
  try {
800
  $serial = 'qr_realtimecache_' . $this->get_serial( $projectId );
801
  $transient = GADWP_Tools::get_cache( $serial );
802
+ if ( false === $transient ) {
803
  if ( $this->gapi_errors_handler() ) {
804
  return - 23;
805
  }
854
  * $filter
855
  * @return number|Google_Service_Analytics_GaData
856
  */
857
+ public function get( $projectId, $query, $from = false, $to = false, $filter = '', $metric = 'sessions' ) {
858
  if ( empty( $projectId ) || ! is_numeric( $projectId ) ) {
859
  wp_die( - 26 );
860
  }
861
  if ( in_array( $query, array( 'sessions', 'users', 'organicSearches', 'visitBounceRate', 'pageviews', 'uniquePageviews' ) ) ) {
862
  return $this->get_areachart_data( $projectId, $from, $to, $query, $filter );
863
  }
864
+ if ( 'bottomstats' == $query ) {
865
  return $this->get_bottomstats( $projectId, $from, $to, $filter );
866
  }
867
+ if ( 'locations' == $query ) {
868
+ return $this->get_locations( $projectId, $from, $to, $filter, $metric );
869
  }
870
+ if ( 'referrers' == $query ) {
871
+ return $this->get_referrers( $projectId, $from, $to, $filter, $metric );
872
  }
873
+ if ( 'contentpages' == $query ) {
874
+ return $this->get_contentpages( $projectId, $from, $to, $filter, $metric );
875
  }
876
+ if ( '404errors' == $query ) {
877
  $filter = $this->gadwp->config->options['pagetitle_404'];
878
+ return $this->get_404errors( $projectId, $from, $to, $filter, $metric );
879
  }
880
+ if ( 'searches' == $query ) {
881
+ return $this->get_searches( $projectId, $from, $to, $filter, $metric );
882
  }
883
+ if ( 'realtime' == $query ) {
884
  return $this->get_realtime( $projectId );
885
  }
886
+ if ( 'channelGrouping' == $query || 'deviceCategory' == $query ) {
887
+ return $this->get_orgchart_data( $projectId, $from, $to, $query, $filter, $metric );
888
  }
889
  if ( in_array( $query, array( 'medium', 'visitorType', 'socialNetwork', 'source', 'browser', 'operatingSystem', 'screenResolution', 'mobileDeviceBranding' ) ) ) {
890
+ return $this->get_piechart_data( $projectId, $from, $to, $query, $filter, $metric );
891
  }
892
  wp_die( - 27 );
893
  }
tools/src/Google/Auth/Abstract.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,27 +14,25 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * Abstract class for the Authentication in the API client
21
- *
22
  * @author Chris Chabot <chabotc@google.com>
23
- *
24
  */
25
  abstract class Google_Auth_Abstract
26
  {
27
-
28
- /**
29
- * An utility function that first calls $this->auth->sign($request) and then
30
- * executes makeRequest() on that signed request.
31
- * Used for when a request
32
- * should be authenticated
33
- *
34
- * @param Google_Http_Request $request
35
- * @return Google_Http_Request $request
36
- */
37
- abstract public function authenticatedRequest(Google_Http_Request $request);
38
-
39
- abstract public function sign(Google_Http_Request $request);
40
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * Abstract class for the Authentication in the API client
 
24
  * @author Chris Chabot <chabotc@google.com>
25
+ *
26
  */
27
  abstract class Google_Auth_Abstract
28
  {
29
+ /**
30
+ * An utility function that first calls $this->auth->sign($request) and then
31
+ * executes makeRequest() on that signed request. Used for when a request
32
+ * should be authenticated
33
+ * @param Google_Http_Request $request
34
+ * @return Google_Http_Request $request
35
+ */
36
+ abstract public function authenticatedRequest(Google_Http_Request $request);
37
+ abstract public function sign(Google_Http_Request $request);
 
 
 
 
38
  }
tools/src/Google/Auth/AppIdentity.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,88 +14,107 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
 
17
  /*
18
  * WARNING - this class depends on the Google App Engine PHP library
19
  * which is 5.3 and above only, so if you include this in a PHP 5.2
20
  * setup or one without 5.3 things will blow up.
21
  */
22
  use google\appengine\api\app_identity\AppIdentityService;
23
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
24
 
25
  /**
26
  * Authentication via the Google App Engine App Identity service.
27
  */
28
  class Google_Auth_AppIdentity extends Google_Auth_Abstract
29
  {
 
 
 
 
30
 
31
- const CACHE_PREFIX = "Google_Auth_AppIdentity::";
 
 
 
32
 
33
- private $key = null;
 
 
 
 
 
 
 
34
 
35
- private $client;
 
 
 
 
 
36
 
37
- private $token = false;
 
 
 
 
 
 
38
 
39
- private $tokenScopes = false;
 
 
40
 
41
- public function __construct(Google_Client $client, $config = null)
42
- {
43
- $this->client = $client;
 
 
 
 
 
 
 
 
 
 
44
  }
 
45
 
46
- /**
47
- * Retrieve an access token for the scopes supplied.
48
- */
49
- public function authenticateForScope($scopes)
50
- {
51
- if ($this->token && $this->tokenScopes == $scopes) {
52
- return $this->token;
53
- }
54
- $cacheKey = self::CACHE_PREFIX;
55
- if (is_string($scopes)) {
56
- $cacheKey .= $scopes;
57
- } else
58
- if (is_array($scopes)) {
59
- $cacheKey .= implode(":", $scopes);
60
- }
61
- $this->token = $this->client->getCache()->get($cacheKey);
62
- if (! $this->token) {
63
- $this->token = AppIdentityService::getAccessToken($scopes);
64
- if ($this->token) {
65
- $this->client->getCache()->set($cacheKey, $this->token);
66
- }
67
- }
68
- $this->tokenScopes = $scopes;
69
- return $this->token;
70
- }
71
 
72
- /**
73
- * Perform an authenticated / signed apiHttpRequest.
74
- * This function takes the apiHttpRequest, calls apiAuth->sign on it
75
- * (which can modify the request in what ever way fits the auth mechanism)
76
- * and then calls apiCurlIO::makeRequest on the signed request
77
- *
78
- * @param Google_Http_Request $request
79
- * @return Google_Http_Request The resulting HTTP response including the
80
- * responseHttpCode, responseHeaders and responseBody.
81
- */
82
- public function authenticatedRequest(Google_Http_Request $request)
83
- {
84
- $request = $this->sign($request);
85
- return $this->client->getIo()->makeRequest($request);
86
  }
87
 
88
- public function sign(Google_Http_Request $request)
89
- {
90
- if (! $this->token) {
91
- // No token, so nothing to do.
92
- return $request;
93
- }
94
- $this->client->getLogger()->debug('App Identity authentication');
95
- // Add the OAuth2 header to the request
96
- $request->setRequestHeaders(array(
97
- 'Authorization' => 'Bearer ' . $this->token['access_token']
98
- ));
99
- return $request;
100
- }
101
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
  /*
19
  * WARNING - this class depends on the Google App Engine PHP library
20
  * which is 5.3 and above only, so if you include this in a PHP 5.2
21
  * setup or one without 5.3 things will blow up.
22
  */
23
  use google\appengine\api\app_identity\AppIdentityService;
24
+
25
+ if (!class_exists('Google_Client')) {
26
+ require_once dirname(__FILE__) . '/../autoload.php';
27
+ }
28
 
29
  /**
30
  * Authentication via the Google App Engine App Identity service.
31
  */
32
  class Google_Auth_AppIdentity extends Google_Auth_Abstract
33
  {
34
+ const CACHE_PREFIX = "Google_Auth_AppIdentity::";
35
+ private $client;
36
+ private $token = false;
37
+ private $tokenScopes = false;
38
 
39
+ public function __construct(Google_Client $client, $config = null)
40
+ {
41
+ $this->client = $client;
42
+ }
43
 
44
+ /**
45
+ * Retrieve an access token for the scopes supplied.
46
+ */
47
+ public function authenticateForScope($scopes)
48
+ {
49
+ if ($this->token && $this->tokenScopes == $scopes) {
50
+ return $this->token;
51
+ }
52
 
53
+ $cacheKey = self::CACHE_PREFIX;
54
+ if (is_string($scopes)) {
55
+ $cacheKey .= $scopes;
56
+ } else if (is_array($scopes)) {
57
+ $cacheKey .= implode(":", $scopes);
58
+ }
59
 
60
+ $this->token = $this->client->getCache()->get($cacheKey);
61
+ if (!$this->token) {
62
+ $this->retrieveToken($scopes, $cacheKey);
63
+ } else if ($this->token['expiration_time'] < time()) {
64
+ $this->client->getCache()->delete($cacheKey);
65
+ $this->retrieveToken($scopes, $cacheKey);
66
+ }
67
 
68
+ $this->tokenScopes = $scopes;
69
+ return $this->token;
70
+ }
71
 
72
+ /**
73
+ * Retrieve a new access token and store it in cache
74
+ * @param mixed $scopes
75
+ * @param string $cacheKey
76
+ */
77
+ private function retrieveToken($scopes, $cacheKey)
78
+ {
79
+ $this->token = AppIdentityService::getAccessToken($scopes);
80
+ if ($this->token) {
81
+ $this->client->getCache()->set(
82
+ $cacheKey,
83
+ $this->token
84
+ );
85
  }
86
+ }
87
 
88
+ /**
89
+ * Perform an authenticated / signed apiHttpRequest.
90
+ * This function takes the apiHttpRequest, calls apiAuth->sign on it
91
+ * (which can modify the request in what ever way fits the auth mechanism)
92
+ * and then calls apiCurlIO::makeRequest on the signed request
93
+ *
94
+ * @param Google_Http_Request $request
95
+ * @return Google_Http_Request The resulting HTTP response including the
96
+ * responseHttpCode, responseHeaders and responseBody.
97
+ */
98
+ public function authenticatedRequest(Google_Http_Request $request)
99
+ {
100
+ $request = $this->sign($request);
101
+ return $this->client->getIo()->makeRequest($request);
102
+ }
 
 
 
 
 
 
 
 
 
 
103
 
104
+ public function sign(Google_Http_Request $request)
105
+ {
106
+ if (!$this->token) {
107
+ // No token, so nothing to do.
108
+ return $request;
 
 
 
 
 
 
 
 
 
109
  }
110
 
111
+ $this->client->getLogger()->debug('App Identity authentication');
112
+
113
+ // Add the OAuth2 header to the request
114
+ $request->setRequestHeaders(
115
+ array('Authorization' => 'Bearer ' . $this->token['access_token'])
116
+ );
117
+
118
+ return $request;
119
+ }
 
 
 
 
120
  }
tools/src/Google/Auth/AssertionCredentials.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,130 +14,123 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * Credentials object used for OAuth 2.0 Signed JWT assertion grants.
21
- *
22
- * @author Chirag Shah <chirags@google.com>
23
  */
24
  class Google_Auth_AssertionCredentials
25
  {
 
26
 
27
- const MAX_TOKEN_LIFETIME_SECS = 3600;
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- public $serviceAccountName;
30
-
31
- public $scopes;
32
-
33
- public $privateKey;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- public $privateKeyPassword;
 
 
36
 
37
- public $assertionType;
 
 
 
 
 
 
38
 
39
- public $sub;
 
 
 
 
40
 
41
- /**
42
- *
43
- * @deprecated
44
- *
45
- * @link http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06
46
- */
47
- public $prn;
48
 
49
- private $useCache;
 
 
 
 
 
 
 
50
 
51
- /**
52
- *
53
- * @param
54
- * $serviceAccountName
55
- * @param $scopes array
56
- * List of scopes
57
- * @param
58
- * $privateKey
59
- * @param string $privateKeyPassword
60
- * @param string $assertionType
61
- * @param bool|string $sub
62
- * The email address of the user for which the
63
- * application is requesting delegated access.
64
- * @param
65
- * bool useCache Whether to generate a cache key and allow
66
- * automatic caching of the generated token.
67
- */
68
- public function __construct($serviceAccountName, $scopes, $privateKey, $privateKeyPassword = 'notasecret', $assertionType = 'http://oauth.net/grant_type/jwt/1.0/bearer', $sub = false, $useCache = true)
69
- {
70
- $this->serviceAccountName = $serviceAccountName;
71
- $this->scopes = is_string($scopes) ? $scopes : implode(' ', $scopes);
72
- $this->privateKey = $privateKey;
73
- $this->privateKeyPassword = $privateKeyPassword;
74
- $this->assertionType = $assertionType;
75
- $this->sub = $sub;
76
- $this->prn = $sub;
77
- $this->useCache = $useCache;
78
- }
79
 
80
- /**
81
- * Generate a unique key to represent this credential.
82
- *
83
- * @return string
84
- */
85
- public function getCacheKey()
86
- {
87
- if (! $this->useCache) {
88
- return false;
89
- }
90
- $h = $this->sub;
91
- $h .= $this->assertionType;
92
- $h .= $this->privateKey;
93
- $h .= $this->scopes;
94
- $h .= $this->serviceAccountName;
95
- return md5($h);
96
- }
97
 
98
- public function generateAssertion()
99
- {
100
- $now = time();
101
- $jwtParams = array(
102
- 'aud' => Google_Auth_OAuth2::OAUTH2_TOKEN_URI,
103
- 'scope' => $this->scopes,
104
- 'iat' => $now,
105
- 'exp' => $now + self::MAX_TOKEN_LIFETIME_SECS,
106
- 'iss' => $this->serviceAccountName
107
- );
108
- if ($this->sub !== false) {
109
- $jwtParams['sub'] = $this->sub;
110
- } else
111
- if ($this->prn !== false) {
112
- $jwtParams['prn'] = $this->prn;
113
- }
114
- return $this->makeSignedJwt($jwtParams);
115
- }
116
 
117
- /**
118
- * Creates a signed JWT.
119
- *
120
- * @param array $payload
121
- * @return string The signed JWT.
122
- */
123
- private function makeSignedJwt($payload)
124
- {
125
- $header = array(
126
- 'typ' => 'JWT',
127
- 'alg' => 'RS256'
128
- );
129
- $payload = json_encode($payload);
130
- // Handle some overzealous escaping in PHP json that seemed to cause some errors
131
- // with claimsets.
132
- $payload = str_replace('\/', '/', $payload);
133
- $segments = array(
134
- Google_Utils::urlSafeB64Encode(json_encode($header)),
135
- Google_Utils::urlSafeB64Encode($payload)
136
- );
137
- $signingInput = implode('.', $segments);
138
- $signer = new Google_Signer_P12($this->privateKey, $this->privateKeyPassword);
139
- $signature = $signer->sign($signingInput);
140
- $segments[] = Google_Utils::urlSafeB64Encode($signature);
141
- return implode(".", $segments);
142
- }
143
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * Credentials object used for OAuth 2.0 Signed JWT assertion grants.
 
 
24
  */
25
  class Google_Auth_AssertionCredentials
26
  {
27
+ const MAX_TOKEN_LIFETIME_SECS = 3600;
28
 
29
+ public $serviceAccountName;
30
+ public $scopes;
31
+ public $privateKey;
32
+ public $privateKeyPassword;
33
+ public $assertionType;
34
+ public $sub;
35
+ /**
36
+ * @deprecated
37
+ * @link http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06
38
+ */
39
+ public $prn;
40
+ private $useCache;
41
 
42
+ /**
43
+ * @param $serviceAccountName
44
+ * @param $scopes array List of scopes
45
+ * @param $privateKey
46
+ * @param string $privateKeyPassword
47
+ * @param string $assertionType
48
+ * @param bool|string $sub The email address of the user for which the
49
+ * application is requesting delegated access.
50
+ * @param bool useCache Whether to generate a cache key and allow
51
+ * automatic caching of the generated token.
52
+ */
53
+ public function __construct(
54
+ $serviceAccountName,
55
+ $scopes,
56
+ $privateKey,
57
+ $privateKeyPassword = 'notasecret',
58
+ $assertionType = 'http://oauth.net/grant_type/jwt/1.0/bearer',
59
+ $sub = false,
60
+ $useCache = true
61
+ ) {
62
+ $this->serviceAccountName = $serviceAccountName;
63
+ $this->scopes = is_string($scopes) ? $scopes : implode(' ', $scopes);
64
+ $this->privateKey = $privateKey;
65
+ $this->privateKeyPassword = $privateKeyPassword;
66
+ $this->assertionType = $assertionType;
67
+ $this->sub = $sub;
68
+ $this->prn = $sub;
69
+ $this->useCache = $useCache;
70
+ }
71
+
72
+ /**
73
+ * Generate a unique key to represent this credential.
74
+ * @return string
75
+ */
76
+ public function getCacheKey()
77
+ {
78
+ if (!$this->useCache) {
79
+ return false;
80
+ }
81
+ $h = $this->sub;
82
+ $h .= $this->assertionType;
83
+ $h .= $this->privateKey;
84
+ $h .= $this->scopes;
85
+ $h .= $this->serviceAccountName;
86
+ return md5($h);
87
+ }
88
 
89
+ public function generateAssertion()
90
+ {
91
+ $now = time();
92
 
93
+ $jwtParams = array(
94
+ 'aud' => Google_Auth_OAuth2::OAUTH2_TOKEN_URI,
95
+ 'scope' => $this->scopes,
96
+ 'iat' => $now,
97
+ 'exp' => $now + self::MAX_TOKEN_LIFETIME_SECS,
98
+ 'iss' => $this->serviceAccountName,
99
+ );
100
 
101
+ if ($this->sub !== false) {
102
+ $jwtParams['sub'] = $this->sub;
103
+ } else if ($this->prn !== false) {
104
+ $jwtParams['prn'] = $this->prn;
105
+ }
106
 
107
+ return $this->makeSignedJwt($jwtParams);
108
+ }
 
 
 
 
 
109
 
110
+ /**
111
+ * Creates a signed JWT.
112
+ * @param array $payload
113
+ * @return string The signed JWT.
114
+ */
115
+ private function makeSignedJwt($payload)
116
+ {
117
+ $header = array('typ' => 'JWT', 'alg' => 'RS256');
118
 
119
+ $payload = json_encode($payload);
120
+ // Handle some overzealous escaping in PHP json that seemed to cause some errors
121
+ // with claimsets.
122
+ $payload = str_replace('\/', '/', $payload);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
+ $segments = array(
125
+ Google_Utils::urlSafeB64Encode(json_encode($header)),
126
+ Google_Utils::urlSafeB64Encode($payload)
127
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
128
 
129
+ $signingInput = implode('.', $segments);
130
+ $signer = new Google_Signer_P12($this->privateKey, $this->privateKeyPassword);
131
+ $signature = $signer->sign($signingInput);
132
+ $segments[] = Google_Utils::urlSafeB64Encode($signature);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
+ return implode(".", $segments);
135
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  }
tools/src/Google/Auth/ComputeEngine.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright 2014 Google Inc.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
+
22
+ /**
23
+ * Authentication via built-in Compute Engine service accounts.
24
+ * The instance must be pre-configured with a service account
25
+ * and the appropriate scopes.
26
+ * @author Jonathan Parrott <jon.wayne.parrott@gmail.com>
27
+ */
28
+ class Google_Auth_ComputeEngine extends Google_Auth_Abstract
29
+ {
30
+ const METADATA_AUTH_URL =
31
+ 'http://metadata/computeMetadata/v1/instance/service-accounts/default/token';
32
+ private $client;
33
+ private $token;
34
+
35
+ public function __construct(Google_Client $client, $config = null)
36
+ {
37
+ $this->client = $client;
38
+ }
39
+
40
+ /**
41
+ * Perform an authenticated / signed apiHttpRequest.
42
+ * This function takes the apiHttpRequest, calls apiAuth->sign on it
43
+ * (which can modify the request in what ever way fits the auth mechanism)
44
+ * and then calls apiCurlIO::makeRequest on the signed request
45
+ *
46
+ * @param Google_Http_Request $request
47
+ * @return Google_Http_Request The resulting HTTP response including the
48
+ * responseHttpCode, responseHeaders and responseBody.
49
+ */
50
+ public function authenticatedRequest(Google_Http_Request $request)
51
+ {
52
+ $request = $this->sign($request);
53
+ return $this->client->getIo()->makeRequest($request);
54
+ }
55
+
56
+ /**
57
+ * @param string $token
58
+ * @throws Google_Auth_Exception
59
+ */
60
+ public function setAccessToken($token)
61
+ {
62
+ $token = json_decode($token, true);
63
+ if ($token == null) {
64
+ throw new Google_Auth_Exception('Could not json decode the token');
65
+ }
66
+ if (! isset($token['access_token'])) {
67
+ throw new Google_Auth_Exception("Invalid token format");
68
+ }
69
+ $token['created'] = time();
70
+ $this->token = $token;
71
+ }
72
+
73
+ public function getAccessToken()
74
+ {
75
+ return json_encode($this->token);
76
+ }
77
+
78
+ /**
79
+ * Acquires a new access token from the compute engine metadata server.
80
+ * @throws Google_Auth_Exception
81
+ */
82
+ public function acquireAccessToken()
83
+ {
84
+ $request = new Google_Http_Request(
85
+ self::METADATA_AUTH_URL,
86
+ 'GET',
87
+ array(
88
+ 'Metadata-Flavor' => 'Google'
89
+ )
90
+ );
91
+ $request->disableGzip();
92
+ $response = $this->client->getIo()->makeRequest($request);
93
+
94
+ if ($response->getResponseHttpCode() == 200) {
95
+ $this->setAccessToken($response->getResponseBody());
96
+ $this->token['created'] = time();
97
+ return $this->getAccessToken();
98
+ } else {
99
+ throw new Google_Auth_Exception(
100
+ sprintf(
101
+ "Error fetching service account access token, message: '%s'",
102
+ $response->getResponseBody()
103
+ ),
104
+ $response->getResponseHttpCode()
105
+ );
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Include an accessToken in a given apiHttpRequest.
111
+ * @param Google_Http_Request $request
112
+ * @return Google_Http_Request
113
+ * @throws Google_Auth_Exception
114
+ */
115
+ public function sign(Google_Http_Request $request)
116
+ {
117
+ if ($this->isAccessTokenExpired()) {
118
+ $this->acquireAccessToken();
119
+ }
120
+
121
+ $this->client->getLogger()->debug('Compute engine service account authentication');
122
+
123
+ $request->setRequestHeaders(
124
+ array('Authorization' => 'Bearer ' . $this->token['access_token'])
125
+ );
126
+
127
+ return $request;
128
+ }
129
+
130
+ /**
131
+ * Returns if the access_token is expired.
132
+ * @return bool Returns True if the access_token is expired.
133
+ */
134
+ public function isAccessTokenExpired()
135
+ {
136
+ if (!$this->token || !isset($this->token['created'])) {
137
+ return true;
138
+ }
139
+
140
+ // If the token is set to expire in the next 30 seconds.
141
+ $expired = ($this->token['created']
142
+ + ($this->token['expires_in'] - 30)) < time();
143
+
144
+ return $expired;
145
+ }
146
+ }
tools/src/Google/Auth/Exception.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  class Google_Auth_Exception extends Google_Exception
20
  {
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  class Google_Auth_Exception extends Google_Exception
23
  {
tools/src/Google/Auth/LoginTicket.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * Class to hold information about an authenticated login.
@@ -23,54 +26,46 @@ require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
23
  */
24
  class Google_Auth_LoginTicket
25
  {
 
26
 
27
- const USER_ATTR = "sub";
28
- // Information from id token envelope.
29
- private $envelope;
30
- // Information from id token payload.
31
- private $payload;
32
 
33
- /**
34
- * Creates a user based on the supplied token.
35
- *
36
- * @param string $envelope
37
- * Header from a verified authentication token.
38
- * @param string $payload
39
- * Information from a verified authentication token.
40
- */
41
- public function __construct($envelope, $payload)
42
- {
43
- $this->envelope = $envelope;
44
- $this->payload = $payload;
45
- }
46
 
47
- /**
48
- * Returns the numeric identifier for the user.
49
- *
50
- * @throws Google_Auth_Exception
51
- * @return
52
- *
53
- */
54
- public function getUserId()
55
- {
56
- if (array_key_exists(self::USER_ATTR, $this->payload)) {
57
- return $this->payload[self::USER_ATTR];
58
- }
59
- throw new Google_Auth_Exception("No user_id in token");
60
- }
61
 
62
- /**
63
- * Returns attributes from the login ticket.
64
- * This can contain
65
- * various information about the user session.
66
- *
67
- * @return array
68
- */
69
- public function getAttributes()
70
- {
71
- return array(
72
- "envelope" => $this->envelope,
73
- "payload" => $this->payload
74
- );
75
  }
 
 
 
 
 
 
 
 
 
 
 
 
76
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * Class to hold information about an authenticated login.
26
  */
27
  class Google_Auth_LoginTicket
28
  {
29
+ const USER_ATTR = "sub";
30
 
31
+ // Information from id token envelope.
32
+ private $envelope;
 
 
 
33
 
34
+ // Information from id token payload.
35
+ private $payload;
 
 
 
 
 
 
 
 
 
 
 
36
 
37
+ /**
38
+ * Creates a user based on the supplied token.
39
+ *
40
+ * @param string $envelope Header from a verified authentication token.
41
+ * @param string $payload Information from a verified authentication token.
42
+ */
43
+ public function __construct($envelope, $payload)
44
+ {
45
+ $this->envelope = $envelope;
46
+ $this->payload = $payload;
47
+ }
 
 
 
48
 
49
+ /**
50
+ * Returns the numeric identifier for the user.
51
+ * @throws Google_Auth_Exception
52
+ * @return
53
+ */
54
+ public function getUserId()
55
+ {
56
+ if (array_key_exists(self::USER_ATTR, $this->payload)) {
57
+ return $this->payload[self::USER_ATTR];
 
 
 
 
58
  }
59
+ throw new Google_Auth_Exception("No user_id in token");
60
+ }
61
+
62
+ /**
63
+ * Returns attributes from the login ticket. This can contain
64
+ * various information about the user session.
65
+ * @return array
66
+ */
67
+ public function getAttributes()
68
+ {
69
+ return array("envelope" => $this->envelope, "payload" => $this->payload);
70
+ }
71
  }
tools/src/Google/Auth/OAuth2.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,534 +14,633 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * Authentication class that deals with the OAuth 2 web-server authentication flow
21
  *
22
- * @author Chris Chabot <chabotc@google.com>
23
- * @author Chirag Shah <chirags@google.com>
24
- *
25
  */
26
  class Google_Auth_OAuth2 extends Google_Auth_Abstract
27
  {
 
 
 
 
 
 
 
 
28
 
29
- const OAUTH2_REVOKE_URI = 'https://accounts.google.com/o/oauth2/revoke';
30
-
31
- const OAUTH2_TOKEN_URI = 'https://accounts.google.com/o/oauth2/token';
32
-
33
- const OAUTH2_AUTH_URL = 'https://accounts.google.com/o/oauth2/auth';
34
-
35
- const CLOCK_SKEW_SECS = 300;
36
- // five minutes in seconds
37
- const AUTH_TOKEN_LIFETIME_SECS = 300;
38
- // five minutes in seconds
39
- const MAX_TOKEN_LIFETIME_SECS = 86400;
40
- // one day in seconds
41
- const OAUTH2_ISSUER = 'accounts.google.com';
42
-
43
- /**
44
- *
45
- * @var Google_Auth_AssertionCredentials $assertionCredentials
46
- */
47
- private $assertionCredentials;
48
-
49
- /**
50
- *
51
- * @var string The state parameters for CSRF and other forgery protection.
52
- */
53
- private $state;
54
-
55
- /**
56
- *
57
- * @var array The token bundle.
58
- */
59
- private $token = array();
60
-
61
- /**
62
- *
63
- * @var Google_Client the base client
64
- */
65
- private $client;
66
-
67
- /**
68
- * Instantiates the class, but does not initiate the login flow, leaving it
69
- * to the discretion of the caller.
70
- */
71
- public function __construct(Google_Client $client)
72
- {
73
- $this->client = $client;
74
- }
75
-
76
- /**
77
- * Perform an authenticated / signed apiHttpRequest.
78
- * This function takes the apiHttpRequest, calls apiAuth->sign on it
79
- * (which can modify the request in what ever way fits the auth mechanism)
80
- * and then calls apiCurlIO::makeRequest on the signed request
81
- *
82
- * @param Google_Http_Request $request
83
- * @return Google_Http_Request The resulting HTTP response including the
84
- * responseHttpCode, responseHeaders and responseBody.
85
- */
86
- public function authenticatedRequest(Google_Http_Request $request)
87
- {
88
- $request = $this->sign($request);
89
- return $this->client->getIo()->makeRequest($request);
90
- }
91
-
92
- /**
93
- *
94
- * @param string $code
95
- * @throws Google_Auth_Exception
96
- * @return string
97
- */
98
- public function authenticate($code)
99
- {
100
- if (strlen($code) == 0) {
101
- throw new Google_Auth_Exception("Invalid code");
102
- }
103
- // We got here from the redirect from a successful authorization grant,
104
- // fetch the access token
105
- $request = new Google_Http_Request(self::OAUTH2_TOKEN_URI, 'POST', array(), array(
106
- 'code' => $code,
107
- 'grant_type' => 'authorization_code',
108
- 'redirect_uri' => $this->client->getClassConfig($this, 'redirect_uri'),
109
- 'client_id' => $this->client->getClassConfig($this, 'client_id'),
110
- 'client_secret' => $this->client->getClassConfig($this, 'client_secret')
111
- ));
112
- $request->disableGzip();
113
- $response = $this->client->getIo()->makeRequest($request);
114
- if ($response->getResponseHttpCode() == 200) {
115
- $this->setAccessToken($response->getResponseBody());
116
- $this->token['created'] = time();
117
- return $this->getAccessToken();
118
- } else {
119
- $decodedResponse = json_decode($response->getResponseBody(), true);
120
- if ($decodedResponse != null && $decodedResponse['error']) {
121
- $errorText = $decodedResponse['error'];
122
- if (isset($decodedResponse['error_description'])) {
123
- $errorText .= ": " . $decodedResponse['error_description'];
124
- }
125
- }
126
- throw new Google_Auth_Exception(sprintf("Error fetching OAuth2 access token, message: '%s'", $errorText), $response->getResponseHttpCode());
127
- }
128
  }
129
 
130
- /**
131
- * Create a URL to obtain user authorization.
132
- * The authorization endpoint allows the user to first
133
- * authenticate, and then grant/deny the access request.
134
- *
135
- * @param string $scope
136
- * The scope is expressed as a list of space-delimited strings.
137
- * @return string
138
- */
139
- public function createAuthUrl($scope)
140
- {
141
- $params = array(
142
- 'response_type' => 'code',
143
- 'redirect_uri' => $this->client->getClassConfig($this, 'redirect_uri'),
144
- 'client_id' => $this->client->getClassConfig($this, 'client_id'),
145
- 'scope' => $scope,
146
- 'access_type' => $this->client->getClassConfig($this, 'access_type')
147
- );
148
- // Prefer prompt to approval prompt.
149
- if ($this->client->getClassConfig($this, 'prompt')) {
150
- $params = $this->maybeAddParam($params, 'prompt');
151
- } else {
152
- $params = $this->maybeAddParam($params, 'approval_prompt');
153
- }
154
- $params = $this->maybeAddParam($params, 'login_hint');
155
- $params = $this->maybeAddParam($params, 'hd');
156
- $params = $this->maybeAddParam($params, 'openid.realm');
157
- $params = $this->maybeAddParam($params, 'include_granted_scopes');
158
- // If the list of scopes contains plus.login, add request_visible_actions
159
- // to auth URL.
160
- $rva = $this->client->getClassConfig($this, 'request_visible_actions');
161
- if (strpos($scope, 'plus.login') && strlen($rva) > 0) {
162
- $params['request_visible_actions'] = $rva;
163
- }
164
- if (isset($this->state)) {
165
- $params['state'] = $this->state;
166
- }
167
- return self::OAUTH2_AUTH_URL . "?" . http_build_query($params, '', '&');
168
- }
169
-
170
- /**
171
- *
172
- * @param string $token
173
- * @throws Google_Auth_Exception
174
- */
175
- public function setAccessToken($token)
176
- {
177
- $token = json_decode($token, true);
178
- if ($token == null) {
179
- throw new Google_Auth_Exception('Could not json decode the token');
180
- }
181
- if (! isset($token['access_token'])) {
182
- throw new Google_Auth_Exception("Invalid token format");
183
- }
184
- $this->token = $token;
185
  }
186
 
187
- public function getAccessToken()
188
- {
189
- return json_encode($this->token);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  }
 
191
 
192
- public function getRefreshToken()
193
- {
194
- if (array_key_exists('refresh_token', $this->token)) {
195
- return $this->token['refresh_token'];
196
- } else {
197
- return null;
198
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  }
 
 
 
 
200
 
201
- public function setState($state)
202
- {
203
- $this->state = $state;
 
 
204
  }
205
 
206
- public function setAssertionCredentials(Google_Auth_AssertionCredentials $creds)
207
- {
208
- $this->assertionCredentials = $creds;
209
  }
210
 
211
- /**
212
- * Include an accessToken in a given apiHttpRequest.
213
- *
214
- * @param Google_Http_Request $request
215
- * @return Google_Http_Request
216
- * @throws Google_Auth_Exception
217
- */
218
- public function sign(Google_Http_Request $request)
219
- {
220
- // add the developer key to the request before signing it
221
- if ($this->client->getClassConfig($this, 'developer_key')) {
222
- $request->setQueryParam('key', $this->client->getClassConfig($this, 'developer_key'));
223
- }
224
- // Cannot sign the request without an OAuth access token.
225
- if (null == $this->token && null == $this->assertionCredentials) {
226
- return $request;
227
- }
228
- // Check if the token is set to expire in the next 30 seconds
229
- // (or has already expired).
230
- if ($this->isAccessTokenExpired()) {
231
- if ($this->assertionCredentials) {
232
- $this->refreshTokenWithAssertion();
233
- } else {
234
- $this->client->getLogger()->debug('OAuth2 access token expired');
235
- if (! array_key_exists('refresh_token', $this->token)) {
236
- $error = "The OAuth 2.0 access token has expired," . " and a refresh token is not available. Refresh tokens" . " are not returned for responses that were auto-approved.";
237
- $this->client->getLogger()->error($error);
238
- throw new Google_Auth_Exception($error);
239
- }
240
- $this->refreshToken($this->token['refresh_token']);
241
- }
242
- }
243
- $this->client->getLogger()->debug('OAuth2 authentication');
244
- // Add the OAuth2 header to the request
245
- $request->setRequestHeaders(array(
246
- 'Authorization' => 'Bearer ' . $this->token['access_token']
247
- ));
248
- return $request;
249
- }
250
-
251
- /**
252
- * Fetches a fresh access token with the given refresh token.
253
- *
254
- * @param string $refreshToken
255
- * @return void
256
- */
257
- public function refreshToken($refreshToken)
258
- {
259
- $this->refreshTokenRequest(array(
260
- 'client_id' => $this->client->getClassConfig($this, 'client_id'),
261
- 'client_secret' => $this->client->getClassConfig($this, 'client_secret'),
262
- 'refresh_token' => $refreshToken,
263
- 'grant_type' => 'refresh_token'
264
- ));
265
- }
266
-
267
- /**
268
- * Fetches a fresh access token with a given assertion token.
269
- *
270
- * @param Google_Auth_AssertionCredentials $assertionCredentials
271
- * optional.
272
- * @return void
273
- */
274
- public function refreshTokenWithAssertion($assertionCredentials = null)
275
- {
276
- if (! $assertionCredentials) {
277
- $assertionCredentials = $this->assertionCredentials;
278
- }
279
- $cacheKey = $assertionCredentials->getCacheKey();
280
- if ($cacheKey) {
281
- // We can check whether we have a token available in the
282
- // cache. If it is expired, we can retrieve a new one from
283
- // the assertion.
284
- $token = $this->client->getCache()->get($cacheKey);
285
- if ($token) {
286
- $this->setAccessToken($token);
287
- }
288
- if (! $this->isAccessTokenExpired()) {
289
- return;
290
- }
291
- }
292
  $this->client->getLogger()->debug('OAuth2 access token expired');
293
- $this->refreshTokenRequest(array(
294
- 'grant_type' => 'assertion',
295
- 'assertion_type' => $assertionCredentials->assertionType,
296
- 'assertion' => $assertionCredentials->generateAssertion()
297
- ));
298
- if ($cacheKey) {
299
- // Attempt to cache the token.
300
- $this->client->getCache()->set($cacheKey, $this->getAccessToken());
301
  }
 
 
302
  }
303
 
304
- private function refreshTokenRequest($params)
305
- {
306
- if (isset($params['assertion'])) {
307
- $this->client->getLogger()->info('OAuth2 access token refresh with Signed JWT assertion grants.');
308
- } else {
309
- $this->client->getLogger()->info('OAuth2 access token refresh');
310
- }
311
- $http = new Google_Http_Request(self::OAUTH2_TOKEN_URI, 'POST', array(), $params);
312
- $http->disableGzip();
313
- $request = $this->client->getIo()->makeRequest($http);
314
- $code = $request->getResponseHttpCode();
315
- $body = $request->getResponseBody();
316
- if (200 == $code) {
317
- $token = json_decode($body, true);
318
- if ($token == null) {
319
- throw new Google_Auth_Exception("Could not json decode the access token");
320
- }
321
- if (! isset($token['access_token']) || ! isset($token['expires_in'])) {
322
- throw new Google_Auth_Exception("Invalid token format");
323
- }
324
- if (isset($token['id_token'])) {
325
- $this->token['id_token'] = $token['id_token'];
326
- }
327
- $this->token['access_token'] = $token['access_token'];
328
- $this->token['expires_in'] = $token['expires_in'];
329
- $this->token['created'] = time();
330
- } else {
331
- throw new Google_Auth_Exception("Error refreshing the OAuth2 token, message: '$body'", $code);
332
- }
 
 
 
 
 
 
 
333
  }
334
 
335
- /**
336
- * Revoke an OAuth2 access token or refresh token.
337
- * This method will revoke the current access
338
- * token, if a token isn't provided.
339
- *
340
- * @throws Google_Auth_Exception
341
- * @param string|null $token
342
- * The token (access token or a refresh token) that should be revoked.
343
- * @return boolean Returns True if the revocation was successful, otherwise False.
344
- */
345
- public function revokeToken($token = null)
346
- {
347
- if (! $token) {
348
- if (! $this->token) {
349
- // Not initialized, no token to actually revoke
350
- return false;
351
- } elseif (array_key_exists('refresh_token', $this->token)) {
352
- $token = $this->token['refresh_token'];
353
- } else {
354
- $token = $this->token['access_token'];
355
- }
356
- }
357
- $request = new Google_Http_Request(self::OAUTH2_REVOKE_URI, 'POST', array(), "token=$token");
358
- $request->disableGzip();
359
- $response = $this->client->getIo()->makeRequest($request);
360
- $code = $response->getResponseHttpCode();
361
- if ($code == 200) {
362
- $this->token = null;
363
- return true;
364
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  }
367
 
368
- /**
369
- * Returns if the access_token is expired.
370
- *
371
- * @return bool Returns True if the access_token is expired.
372
- */
373
- public function isAccessTokenExpired()
374
- {
375
- if (! $this->token || ! isset($this->token['created'])) {
376
- return true;
377
- }
378
- // If the token is set to expire in the next 30 seconds.
379
- $expired = ($this->token['created'] + ($this->token['expires_in'] - 30)) < time();
380
- return $expired;
381
- }
382
- // Gets federated sign-on certificates to use for verifying identity tokens.
383
- // Returns certs as array structure, where keys are key ids, and values
384
- // are PEM encoded certificates.
385
- private function getFederatedSignOnCerts()
386
- {
387
- return $this->retrieveCertsFromLocation($this->client->getClassConfig($this, 'federated_signon_certs_url'));
388
- }
389
-
390
- /**
391
- * Retrieve and cache a certificates file.
392
- *
393
- * @param $url string
394
- * location
395
- * @throws Google_Auth_Exception
396
- * @return array certificates
397
- */
398
- public function retrieveCertsFromLocation($url)
399
- {
400
- // If we're retrieving a local file, just grab it.
401
- if ("http" != substr($url, 0, 4)) {
402
- $file = file_get_contents($url);
403
- if ($file) {
404
- return json_decode($file, true);
405
- } else {
406
- throw new Google_Auth_Exception("Failed to retrieve verification certificates: '" . $url . "'.");
407
- }
408
- }
409
- // This relies on makeRequest caching certificate responses.
410
- $request = $this->client->getIo()->makeRequest(new Google_Http_Request($url));
411
- if ($request->getResponseHttpCode() == 200) {
412
- $certs = json_decode($request->getResponseBody(), true);
413
- if ($certs) {
414
- return $certs;
415
- }
416
- }
417
- throw new Google_Auth_Exception("Failed to retrieve verification certificates: '" . $request->getResponseBody() . "'.", $request->getResponseHttpCode());
418
- }
419
-
420
- /**
421
- * Verifies an id token and returns the authenticated apiLoginTicket.
422
- * Throws an exception if the id token is not valid.
423
- * The audience parameter can be used to control which id tokens are
424
- * accepted. By default, the id token must have been issued to this OAuth2 client.
425
- *
426
- * @param
427
- * $id_token
428
- * @param
429
- * $audience
430
- * @return Google_Auth_LoginTicket
431
- */
432
- public function verifyIdToken($id_token = null, $audience = null)
433
- {
434
- if (! $id_token) {
435
- $id_token = $this->token['id_token'];
436
- }
437
- $certs = $this->getFederatedSignonCerts();
438
- if (! $audience) {
439
- $audience = $this->client->getClassConfig($this, 'client_id');
440
- }
441
- return $this->verifySignedJwtWithCerts($id_token, $certs, $audience, self::OAUTH2_ISSUER);
442
- }
443
-
444
- /**
445
- * Verifies the id token, returns the verified token contents.
446
- *
447
- * @param $jwt string
448
- * the token
449
- * @param $certs array
450
- * of certificates
451
- * @param $required_audience string
452
- * the expected consumer of the token
453
- * @param
454
- * [$issuer] the expected issues, defaults to Google
455
- * @param
456
- * [$max_expiry] the max lifetime of a token, defaults to MAX_TOKEN_LIFETIME_SECS
457
- * @throws Google_Auth_Exception
458
- * @return mixed token information if valid, false if not
459
- */
460
- public function verifySignedJwtWithCerts($jwt, $certs, $required_audience, $issuer = null, $max_expiry = null)
461
- {
462
- if (! $max_expiry) {
463
- // Set the maximum time we will accept a token for.
464
- $max_expiry = self::MAX_TOKEN_LIFETIME_SECS;
465
- }
466
- $segments = explode(".", $jwt);
467
- if (count($segments) != 3) {
468
- throw new Google_Auth_Exception("Wrong number of segments in token: $jwt");
469
- }
470
- $signed = $segments[0] . "." . $segments[1];
471
- $signature = Google_Utils::urlSafeB64Decode($segments[2]);
472
- // Parse envelope.
473
- $envelope = json_decode(Google_Utils::urlSafeB64Decode($segments[0]), true);
474
- if (! $envelope) {
475
- throw new Google_Auth_Exception("Can't parse token envelope: " . $segments[0]);
476
- }
477
- // Parse token
478
- $json_body = Google_Utils::urlSafeB64Decode($segments[1]);
479
- $payload = json_decode($json_body, true);
480
- if (! $payload) {
481
- throw new Google_Auth_Exception("Can't parse token payload: " . $segments[1]);
482
- }
483
- // Check signature
484
- $verified = false;
485
- foreach ($certs as $keyName => $pem) {
486
- $public_key = new Google_Verifier_Pem($pem);
487
- if ($public_key->verify($signed, $signature)) {
488
- $verified = true;
489
- break;
490
- }
491
- }
492
- if (! $verified) {
493
- throw new Google_Auth_Exception("Invalid token signature: $jwt");
494
- }
495
- // Check issued-at timestamp
496
- $iat = 0;
497
- if (array_key_exists("iat", $payload)) {
498
- $iat = $payload["iat"];
499
- }
500
- if (! $iat) {
501
- throw new Google_Auth_Exception("No issue time in token: $json_body");
502
- }
503
- $earliest = $iat - self::CLOCK_SKEW_SECS;
504
- // Check expiration timestamp
505
- $now = time();
506
- $exp = 0;
507
- if (array_key_exists("exp", $payload)) {
508
- $exp = $payload["exp"];
509
- }
510
- if (! $exp) {
511
- throw new Google_Auth_Exception("No expiration time in token: $json_body");
512
- }
513
- if ($exp >= $now + $max_expiry) {
514
- throw new Google_Auth_Exception(sprintf("Expiration time too far in future: %s", $json_body));
515
- }
516
- $latest = $exp + self::CLOCK_SKEW_SECS;
517
- if ($now < $earliest) {
518
- throw new Google_Auth_Exception(sprintf("Token used too early, %s < %s: %s", $now, $earliest, $json_body));
519
- }
520
- if ($now > $latest) {
521
- throw new Google_Auth_Exception(sprintf("Token used too late, %s > %s: %s", $now, $latest, $json_body));
522
- }
523
- $iss = $payload['iss'];
524
- if ($issuer && $iss != $issuer) {
525
- throw new Google_Auth_Exception(sprintf("Invalid issuer, %s != %s: %s", $iss, $issuer, $json_body));
526
- }
527
- // Check audience
528
- $aud = $payload["aud"];
529
- if ($aud != $required_audience) {
530
- throw new Google_Auth_Exception(sprintf("Wrong recipient, %s != %s:", $aud, $required_audience, $json_body));
531
- }
532
- // All good.
533
- return new Google_Auth_LoginTicket($envelope, $payload);
534
- }
535
-
536
- /**
537
- * Add a parameter to the auth params if not empty string.
538
- */
539
- private function maybeAddParam($params, $name)
540
- {
541
- $param = $this->client->getClassConfig($this, $name);
542
- if ($param != '') {
543
- $params[$name] = $param;
544
- }
545
- return $params;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  }
 
 
547
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * Authentication class that deals with the OAuth 2 web-server authentication flow
24
  *
 
 
 
25
  */
26
  class Google_Auth_OAuth2 extends Google_Auth_Abstract
27
  {
28
+ const OAUTH2_REVOKE_URI = 'https://accounts.google.com/o/oauth2/revoke';
29
+ const OAUTH2_TOKEN_URI = 'https://accounts.google.com/o/oauth2/token';
30
+ const OAUTH2_AUTH_URL = 'https://accounts.google.com/o/oauth2/auth';
31
+ const CLOCK_SKEW_SECS = 300; // five minutes in seconds
32
+ const AUTH_TOKEN_LIFETIME_SECS = 300; // five minutes in seconds
33
+ const MAX_TOKEN_LIFETIME_SECS = 86400; // one day in seconds
34
+ const OAUTH2_ISSUER = 'accounts.google.com';
35
+ const OAUTH2_ISSUER_HTTPS = 'https://accounts.google.com';
36
 
37
+ /** @var Google_Auth_AssertionCredentials $assertionCredentials */
38
+ private $assertionCredentials;
39
+
40
+ /**
41
+ * @var string The state parameters for CSRF and other forgery protection.
42
+ */
43
+ private $state;
44
+
45
+ /**
46
+ * @var array The token bundle.
47
+ */
48
+ private $token = array();
49
+
50
+ /**
51
+ * @var Google_Client the base client
52
+ */
53
+ private $client;
54
+
55
+ /**
56
+ * Instantiates the class, but does not initiate the login flow, leaving it
57
+ * to the discretion of the caller.
58
+ */
59
+ public function __construct(Google_Client $client)
60
+ {
61
+ $this->client = $client;
62
+ }
63
+
64
+ /**
65
+ * Perform an authenticated / signed apiHttpRequest.
66
+ * This function takes the apiHttpRequest, calls apiAuth->sign on it
67
+ * (which can modify the request in what ever way fits the auth mechanism)
68
+ * and then calls apiCurlIO::makeRequest on the signed request
69
+ *
70
+ * @param Google_Http_Request $request
71
+ * @return Google_Http_Request The resulting HTTP response including the
72
+ * responseHttpCode, responseHeaders and responseBody.
73
+ */
74
+ public function authenticatedRequest(Google_Http_Request $request)
75
+ {
76
+ $request = $this->sign($request);
77
+ return $this->client->getIo()->makeRequest($request);
78
+ }
79
+
80
+ /**
81
+ * @param string $code
82
+ * @param boolean $crossClient
83
+ * @throws Google_Auth_Exception
84
+ * @return string
85
+ */
86
+ public function authenticate($code, $crossClient = false)
87
+ {
88
+ if (strlen($code) == 0) {
89
+ throw new Google_Auth_Exception("Invalid code");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  }
91
 
92
+ $arguments = array(
93
+ 'code' => $code,
94
+ 'grant_type' => 'authorization_code',
95
+ 'client_id' => $this->client->getClassConfig($this, 'client_id'),
96
+ 'client_secret' => $this->client->getClassConfig($this, 'client_secret')
97
+ );
98
+
99
+ if ($crossClient !== true) {
100
+ $arguments['redirect_uri'] = $this->client->getClassConfig($this, 'redirect_uri');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
 
103
+ // We got here from the redirect from a successful authorization grant,
104
+ // fetch the access token
105
+ $request = new Google_Http_Request(
106
+ self::OAUTH2_TOKEN_URI,
107
+ 'POST',
108
+ array(),
109
+ $arguments
110
+ );
111
+ $request->disableGzip();
112
+ $response = $this->client->getIo()->makeRequest($request);
113
+
114
+ if ($response->getResponseHttpCode() == 200) {
115
+ $this->setAccessToken($response->getResponseBody());
116
+ $this->token['created'] = time();
117
+ return $this->getAccessToken();
118
+ } else {
119
+ $decodedResponse = json_decode($response->getResponseBody(), true);
120
+ if ($decodedResponse != null && $decodedResponse['error']) {
121
+ $errorText = $decodedResponse['error'];
122
+ if (isset($decodedResponse['error_description'])) {
123
+ $errorText .= ": " . $decodedResponse['error_description'];
124
+ }
125
+ }
126
+ throw new Google_Auth_Exception(
127
+ sprintf(
128
+ "Error fetching OAuth2 access token, message: '%s'",
129
+ $errorText
130
+ ),
131
+ $response->getResponseHttpCode()
132
+ );
133
  }
134
+ }
135
 
136
+ /**
137
+ * Create a URL to obtain user authorization.
138
+ * The authorization endpoint allows the user to first
139
+ * authenticate, and then grant/deny the access request.
140
+ * @param string $scope The scope is expressed as a list of space-delimited strings.
141
+ * @return string
142
+ */
143
+ public function createAuthUrl($scope)
144
+ {
145
+ $params = array(
146
+ 'response_type' => 'code',
147
+ 'redirect_uri' => $this->client->getClassConfig($this, 'redirect_uri'),
148
+ 'client_id' => $this->client->getClassConfig($this, 'client_id'),
149
+ 'scope' => $scope,
150
+ 'access_type' => $this->client->getClassConfig($this, 'access_type'),
151
+ );
152
+
153
+ // Prefer prompt to approval prompt.
154
+ if ($this->client->getClassConfig($this, 'prompt')) {
155
+ $params = $this->maybeAddParam($params, 'prompt');
156
+ } else {
157
+ $params = $this->maybeAddParam($params, 'approval_prompt');
158
  }
159
+ $params = $this->maybeAddParam($params, 'login_hint');
160
+ $params = $this->maybeAddParam($params, 'hd');
161
+ $params = $this->maybeAddParam($params, 'openid.realm');
162
+ $params = $this->maybeAddParam($params, 'include_granted_scopes');
163
 
164
+ // If the list of scopes contains plus.login, add request_visible_actions
165
+ // to auth URL.
166
+ $rva = $this->client->getClassConfig($this, 'request_visible_actions');
167
+ if (strpos($scope, 'plus.login') && strlen($rva) > 0) {
168
+ $params['request_visible_actions'] = $rva;
169
  }
170
 
171
+ if (isset($this->state)) {
172
+ $params['state'] = $this->state;
 
173
  }
174
 
175
+ return self::OAUTH2_AUTH_URL . "?" . http_build_query($params, '', '&');
176
+ }
177
+
178
+ /**
179
+ * @param string $token
180
+ * @throws Google_Auth_Exception
181
+ */
182
+ public function setAccessToken($token)
183
+ {
184
+ $token = json_decode($token, true);
185
+ if ($token == null) {
186
+ throw new Google_Auth_Exception('Could not json decode the token');
187
+ }
188
+ if (! isset($token['access_token'])) {
189
+ throw new Google_Auth_Exception("Invalid token format");
190
+ }
191
+ $this->token = $token;
192
+ }
193
+
194
+ public function getAccessToken()
195
+ {
196
+ return json_encode($this->token);
197
+ }
198
+
199
+ public function getRefreshToken()
200
+ {
201
+ if (array_key_exists('refresh_token', $this->token)) {
202
+ return $this->token['refresh_token'];
203
+ } else {
204
+ return null;
205
+ }
206
+ }
207
+
208
+ public function setState($state)
209
+ {
210
+ $this->state = $state;
211
+ }
212
+
213
+ public function setAssertionCredentials(Google_Auth_AssertionCredentials $creds)
214
+ {
215
+ $this->assertionCredentials = $creds;
216
+ }
217
+
218
+ /**
219
+ * Include an accessToken in a given apiHttpRequest.
220
+ * @param Google_Http_Request $request
221
+ * @return Google_Http_Request
222
+ * @throws Google_Auth_Exception
223
+ */
224
+ public function sign(Google_Http_Request $request)
225
+ {
226
+ // add the developer key to the request before signing it
227
+ if ($this->client->getClassConfig($this, 'developer_key')) {
228
+ $request->setQueryParam('key', $this->client->getClassConfig($this, 'developer_key'));
229
+ }
230
+
231
+ // Cannot sign the request without an OAuth access token.
232
+ if (null == $this->token && null == $this->assertionCredentials) {
233
+ return $request;
234
+ }
235
+
236
+ // Check if the token is set to expire in the next 30 seconds
237
+ // (or has already expired).
238
+ if ($this->isAccessTokenExpired()) {
239
+ if ($this->assertionCredentials) {
240
+ $this->refreshTokenWithAssertion();
241
+ } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  $this->client->getLogger()->debug('OAuth2 access token expired');
243
+ if (! array_key_exists('refresh_token', $this->token)) {
244
+ $error = "The OAuth 2.0 access token has expired,"
245
+ ." and a refresh token is not available. Refresh tokens"
246
+ ." are not returned for responses that were auto-approved.";
247
+
248
+ $this->client->getLogger()->error($error);
249
+ throw new Google_Auth_Exception($error);
 
250
  }
251
+ $this->refreshToken($this->token['refresh_token']);
252
+ }
253
  }
254
 
255
+ $this->client->getLogger()->debug('OAuth2 authentication');
256
+
257
+ // Add the OAuth2 header to the request
258
+ $request->setRequestHeaders(
259
+ array('Authorization' => 'Bearer ' . $this->token['access_token'])
260
+ );
261
+
262
+ return $request;
263
+ }
264
+
265
+ /**
266
+ * Fetches a fresh access token with the given refresh token.
267
+ * @param string $refreshToken
268
+ * @return void
269
+ */
270
+ public function refreshToken($refreshToken)
271
+ {
272
+ $this->refreshTokenRequest(
273
+ array(
274
+ 'client_id' => $this->client->getClassConfig($this, 'client_id'),
275
+ 'client_secret' => $this->client->getClassConfig($this, 'client_secret'),
276
+ 'refresh_token' => $refreshToken,
277
+ 'grant_type' => 'refresh_token'
278
+ )
279
+ );
280
+ }
281
+
282
+ /**
283
+ * Fetches a fresh access token with a given assertion token.
284
+ * @param Google_Auth_AssertionCredentials $assertionCredentials optional.
285
+ * @return void
286
+ */
287
+ public function refreshTokenWithAssertion($assertionCredentials = null)
288
+ {
289
+ if (!$assertionCredentials) {
290
+ $assertionCredentials = $this->assertionCredentials;
291
  }
292
 
293
+ $cacheKey = $assertionCredentials->getCacheKey();
294
+
295
+ if ($cacheKey) {
296
+ // We can check whether we have a token available in the
297
+ // cache. If it is expired, we can retrieve a new one from
298
+ // the assertion.
299
+ $token = $this->client->getCache()->get($cacheKey);
300
+ if ($token) {
301
+ $this->setAccessToken($token);
302
+ }
303
+ if (!$this->isAccessTokenExpired()) {
304
+ return;
305
+ }
306
+ }
307
+
308
+ $this->client->getLogger()->debug('OAuth2 access token expired');
309
+ $this->refreshTokenRequest(
310
+ array(
311
+ 'grant_type' => 'assertion',
312
+ 'assertion_type' => $assertionCredentials->assertionType,
313
+ 'assertion' => $assertionCredentials->generateAssertion(),
314
+ )
315
+ );
316
+
317
+ if ($cacheKey) {
318
+ // Attempt to cache the token.
319
+ $this->client->getCache()->set(
320
+ $cacheKey,
321
+ $this->getAccessToken()
322
+ );
323
+ }
324
+ }
325
+
326
+ private function refreshTokenRequest($params)
327
+ {
328
+ if (isset($params['assertion'])) {
329
+ $this->client->getLogger()->info(
330
+ 'OAuth2 access token refresh with Signed JWT assertion grants.'
331
+ );
332
+ } else {
333
+ $this->client->getLogger()->info('OAuth2 access token refresh');
334
+ }
335
+
336
+ $http = new Google_Http_Request(
337
+ self::OAUTH2_TOKEN_URI,
338
+ 'POST',
339
+ array(),
340
+ $params
341
+ );
342
+ $http->disableGzip();
343
+ $request = $this->client->getIo()->makeRequest($http);
344
+
345
+ $code = $request->getResponseHttpCode();
346
+ $body = $request->getResponseBody();
347
+ if (200 == $code) {
348
+ $token = json_decode($body, true);
349
+ if ($token == null) {
350
+ throw new Google_Auth_Exception("Could not json decode the access token");
351
+ }
352
+
353
+ if (! isset($token['access_token']) || ! isset($token['expires_in'])) {
354
+ throw new Google_Auth_Exception("Invalid token format");
355
+ }
356
+
357
+ if (isset($token['id_token'])) {
358
+ $this->token['id_token'] = $token['id_token'];
359
+ }
360
+ $this->token['access_token'] = $token['access_token'];
361
+ $this->token['expires_in'] = $token['expires_in'];
362
+ $this->token['created'] = time();
363
+ } else {
364
+ throw new Google_Auth_Exception("Error refreshing the OAuth2 token, message: '$body'", $code);
365
+ }
366
+ }
367
+
368
+ /**
369
+ * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
370
+ * token, if a token isn't provided.
371
+ * @throws Google_Auth_Exception
372
+ * @param string|null $token The token (access token or a refresh token) that should be revoked.
373
+ * @return boolean Returns True if the revocation was successful, otherwise False.
374
+ */
375
+ public function revokeToken($token = null)
376
+ {
377
+ if (!$token) {
378
+ if (!$this->token) {
379
+ // Not initialized, no token to actually revoke
380
  return false;
381
+ } elseif (array_key_exists('refresh_token', $this->token)) {
382
+ $token = $this->token['refresh_token'];
383
+ } else {
384
+ $token = $this->token['access_token'];
385
+ }
386
+ }
387
+ $request = new Google_Http_Request(
388
+ self::OAUTH2_REVOKE_URI,
389
+ 'POST',
390
+ array(),
391
+ "token=$token"
392
+ );
393
+ $request->disableGzip();
394
+ $response = $this->client->getIo()->makeRequest($request);
395
+ $code = $response->getResponseHttpCode();
396
+ if ($code == 200) {
397
+ $this->token = null;
398
+ return true;
399
  }
400
 
401
+ return false;
402
+ }
403
+
404
+ /**
405
+ * Returns if the access_token is expired.
406
+ * @return bool Returns True if the access_token is expired.
407
+ */
408
+ public function isAccessTokenExpired()
409
+ {
410
+ if (!$this->token || !isset($this->token['created'])) {
411
+ return true;
412
+ }
413
+
414
+ // If the token is set to expire in the next 30 seconds.
415
+ $expired = ($this->token['created']
416
+ + ($this->token['expires_in'] - 30)) < time();
417
+
418
+ return $expired;
419
+ }
420
+
421
+ // Gets federated sign-on certificates to use for verifying identity tokens.
422
+ // Returns certs as array structure, where keys are key ids, and values
423
+ // are PEM encoded certificates.
424
+ private function getFederatedSignOnCerts()
425
+ {
426
+ return $this->retrieveCertsFromLocation(
427
+ $this->client->getClassConfig($this, 'federated_signon_certs_url')
428
+ );
429
+ }
430
+
431
+ /**
432
+ * Retrieve and cache a certificates file.
433
+ *
434
+ * @param $url string location
435
+ * @throws Google_Auth_Exception
436
+ * @return array certificates
437
+ */
438
+ public function retrieveCertsFromLocation($url)
439
+ {
440
+ // If we're retrieving a local file, just grab it.
441
+ if ("http" != substr($url, 0, 4)) {
442
+ $file = file_get_contents($url);
443
+ if ($file) {
444
+ return json_decode($file, true);
445
+ } else {
446
+ throw new Google_Auth_Exception(
447
+ "Failed to retrieve verification certificates: '" .
448
+ $url . "'."
449
+ );
450
+ }
451
+ }
452
+
453
+ // This relies on makeRequest caching certificate responses.
454
+ $request = $this->client->getIo()->makeRequest(
455
+ new Google_Http_Request(
456
+ $url
457
+ )
458
+ );
459
+ if ($request->getResponseHttpCode() == 200) {
460
+ $certs = json_decode($request->getResponseBody(), true);
461
+ if ($certs) {
462
+ return $certs;
463
+ }
464
+ }
465
+ throw new Google_Auth_Exception(
466
+ "Failed to retrieve verification certificates: '" .
467
+ $request->getResponseBody() . "'.",
468
+ $request->getResponseHttpCode()
469
+ );
470
+ }
471
+
472
+ /**
473
+ * Verifies an id token and returns the authenticated apiLoginTicket.
474
+ * Throws an exception if the id token is not valid.
475
+ * The audience parameter can be used to control which id tokens are
476
+ * accepted. By default, the id token must have been issued to this OAuth2 client.
477
+ *
478
+ * @param $id_token
479
+ * @param $audience
480
+ * @return Google_Auth_LoginTicket
481
+ */
482
+ public function verifyIdToken($id_token = null, $audience = null)
483
+ {
484
+ if (!$id_token) {
485
+ $id_token = $this->token['id_token'];
486
+ }
487
+ $certs = $this->getFederatedSignonCerts();
488
+ if (!$audience) {
489
+ $audience = $this->client->getClassConfig($this, 'client_id');
490
+ }
491
+
492
+ return $this->verifySignedJwtWithCerts(
493
+ $id_token,
494
+ $certs,
495
+ $audience,
496
+ array(self::OAUTH2_ISSUER, self::OAUTH2_ISSUER_HTTPS)
497
+ );
498
+ }
499
+
500
+ /**
501
+ * Verifies the id token, returns the verified token contents.
502
+ *
503
+ * @param $jwt string the token
504
+ * @param $certs array of certificates
505
+ * @param $required_audience string the expected consumer of the token
506
+ * @param [$issuer] the expected issues, defaults to Google
507
+ * @param [$max_expiry] the max lifetime of a token, defaults to MAX_TOKEN_LIFETIME_SECS
508
+ * @throws Google_Auth_Exception
509
+ * @return mixed token information if valid, false if not
510
+ */
511
+ public function verifySignedJwtWithCerts(
512
+ $jwt,
513
+ $certs,
514
+ $required_audience,
515
+ $issuer = null,
516
+ $max_expiry = null
517
+ ) {
518
+ if (!$max_expiry) {
519
+ // Set the maximum time we will accept a token for.
520
+ $max_expiry = self::MAX_TOKEN_LIFETIME_SECS;
521
+ }
522
+
523
+ $segments = explode(".", $jwt);
524
+ if (count($segments) != 3) {
525
+ throw new Google_Auth_Exception("Wrong number of segments in token: $jwt");
526
+ }
527
+ $signed = $segments[0] . "." . $segments[1];
528
+ $signature = Google_Utils::urlSafeB64Decode($segments[2]);
529
+
530
+ // Parse envelope.
531
+ $envelope = json_decode(Google_Utils::urlSafeB64Decode($segments[0]), true);
532
+ if (!$envelope) {
533
+ throw new Google_Auth_Exception("Can't parse token envelope: " . $segments[0]);
534
+ }
535
+
536
+ // Parse token
537
+ $json_body = Google_Utils::urlSafeB64Decode($segments[1]);
538
+ $payload = json_decode($json_body, true);
539
+ if (!$payload) {
540
+ throw new Google_Auth_Exception("Can't parse token payload: " . $segments[1]);
541
+ }
542
+
543
+ // Check signature
544
+ $verified = false;
545
+ foreach ($certs as $keyName => $pem) {
546
+ $public_key = new Google_Verifier_Pem($pem);
547
+ if ($public_key->verify($signed, $signature)) {
548
+ $verified = true;
549
+ break;
550
+ }
551
+ }
552
+
553
+ if (!$verified) {
554
+ throw new Google_Auth_Exception("Invalid token signature: $jwt");
555
+ }
556
+
557
+ // Check issued-at timestamp
558
+ $iat = 0;
559
+ if (array_key_exists("iat", $payload)) {
560
+ $iat = $payload["iat"];
561
+ }
562
+ if (!$iat) {
563
+ throw new Google_Auth_Exception("No issue time in token: $json_body");
564
+ }
565
+ $earliest = $iat - self::CLOCK_SKEW_SECS;
566
+
567
+ // Check expiration timestamp
568
+ $now = time();
569
+ $exp = 0;
570
+ if (array_key_exists("exp", $payload)) {
571
+ $exp = $payload["exp"];
572
+ }
573
+ if (!$exp) {
574
+ throw new Google_Auth_Exception("No expiration time in token: $json_body");
575
+ }
576
+ if ($exp >= $now + $max_expiry) {
577
+ throw new Google_Auth_Exception(
578
+ sprintf("Expiration time too far in future: %s", $json_body)
579
+ );
580
+ }
581
+
582
+ $latest = $exp + self::CLOCK_SKEW_SECS;
583
+ if ($now < $earliest) {
584
+ throw new Google_Auth_Exception(
585
+ sprintf(
586
+ "Token used too early, %s < %s: %s",
587
+ $now,
588
+ $earliest,
589
+ $json_body
590
+ )
591
+ );
592
+ }
593
+ if ($now > $latest) {
594
+ throw new Google_Auth_Exception(
595
+ sprintf(
596
+ "Token used too late, %s > %s: %s",
597
+ $now,
598
+ $latest,
599
+ $json_body
600
+ )
601
+ );
602
+ }
603
+
604
+ // support HTTP and HTTPS issuers
605
+ // @see https://developers.google.com/identity/sign-in/web/backend-auth
606
+ $iss = $payload['iss'];
607
+ if ($issuer && !in_array($iss, (array) $issuer)) {
608
+ throw new Google_Auth_Exception(
609
+ sprintf(
610
+ "Invalid issuer, %s not in %s: %s",
611
+ $iss,
612
+ "[".implode(",", (array) $issuer)."]",
613
+ $json_body
614
+ )
615
+ );
616
+ }
617
+
618
+ // Check audience
619
+ $aud = $payload["aud"];
620
+ if ($aud != $required_audience) {
621
+ throw new Google_Auth_Exception(
622
+ sprintf(
623
+ "Wrong recipient, %s != %s:",
624
+ $aud,
625
+ $required_audience,
626
+ $json_body
627
+ )
628
+ );
629
+ }
630
+
631
+ // All good.
632
+ return new Google_Auth_LoginTicket($envelope, $payload);
633
+ }
634
+
635
+ /**
636
+ * Add a parameter to the auth params if not empty string.
637
+ */
638
+ private function maybeAddParam($params, $name)
639
+ {
640
+ $param = $this->client->getClassConfig($this, $name);
641
+ if ($param != '') {
642
+ $params[$name] = $param;
643
  }
644
+ return $params;
645
+ }
646
  }
tools/src/Google/Auth/Simple.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,52 +14,50 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
- * Simple API access implementation.
21
- * Can either be used to make requests
22
  * completely unauthenticated, or by using a Simple API Access developer
23
  * key.
24
- *
25
- * @author Chris Chabot <chabotc@google.com>
26
- * @author Chirag Shah <chirags@google.com>
27
  */
28
  class Google_Auth_Simple extends Google_Auth_Abstract
29
  {
 
30
 
31
- private $key = null;
32
-
33
- private $client;
 
34
 
35
- public function __construct(Google_Client $client, $config = null)
36
- {
37
- $this->client = $client;
38
- }
39
-
40
- /**
41
- * Perform an authenticated / signed apiHttpRequest.
42
- * This function takes the apiHttpRequest, calls apiAuth->sign on it
43
- * (which can modify the request in what ever way fits the auth mechanism)
44
- * and then calls apiCurlIO::makeRequest on the signed request
45
- *
46
- * @param Google_Http_Request $request
47
- * @return Google_Http_Request The resulting HTTP response including the
48
- * responseHttpCode, responseHeaders and responseBody.
49
- */
50
- public function authenticatedRequest(Google_Http_Request $request)
51
- {
52
- $request = $this->sign($request);
53
- return $this->io->makeRequest($request);
54
- }
55
 
56
- public function sign(Google_Http_Request $request)
57
- {
58
- $key = $this->client->getClassConfig($this, 'developer_key');
59
- if ($key) {
60
- $this->client->getLogger()->debug('Simple API Access developer key authentication');
61
- $request->setQueryParam('key', $key);
62
- }
63
- return $request;
64
  }
 
 
65
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
+ * Simple API access implementation. Can either be used to make requests
 
24
  * completely unauthenticated, or by using a Simple API Access developer
25
  * key.
 
 
 
26
  */
27
  class Google_Auth_Simple extends Google_Auth_Abstract
28
  {
29
+ private $client;
30
 
31
+ public function __construct(Google_Client $client, $config = null)
32
+ {
33
+ $this->client = $client;
34
+ }
35
 
36
+ /**
37
+ * Perform an authenticated / signed apiHttpRequest.
38
+ * This function takes the apiHttpRequest, calls apiAuth->sign on it
39
+ * (which can modify the request in what ever way fits the auth mechanism)
40
+ * and then calls apiCurlIO::makeRequest on the signed request
41
+ *
42
+ * @param Google_Http_Request $request
43
+ * @return Google_Http_Request The resulting HTTP response including the
44
+ * responseHttpCode, responseHeaders and responseBody.
45
+ */
46
+ public function authenticatedRequest(Google_Http_Request $request)
47
+ {
48
+ $request = $this->sign($request);
49
+ return $this->io->makeRequest($request);
50
+ }
 
 
 
 
 
51
 
52
+ public function sign(Google_Http_Request $request)
53
+ {
54
+ $key = $this->client->getClassConfig($this, 'developer_key');
55
+ if ($key) {
56
+ $this->client->getLogger()->debug(
57
+ 'Simple API Access developer key authentication'
58
+ );
59
+ $request->setQueryParam('key', $key);
60
  }
61
+ return $request;
62
+ }
63
  }
tools/src/Google/Cache/Abstract.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /*
4
  * Copyright 2008 Google Inc.
5
  *
@@ -7,7 +6,7 @@
7
  * you may not use this file except in compliance with the License.
8
  * You may obtain a copy of the License at
9
  *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
  *
12
  * Unless required by applicable law or agreed to in writing, software
13
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,6 +14,7 @@
15
  * See the License for the specific language governing permissions and
16
  * limitations under the License.
17
  */
 
18
  /**
19
  * Abstract storage class
20
  *
@@ -22,37 +22,32 @@
22
  */
23
  abstract class Google_Cache_Abstract
24
  {
 
 
25
 
26
- abstract public function __construct(Google_Client $client);
27
-
28
- /**
29
- * Retrieves the data for the given key, or false if they
30
- * key is unknown or expired
31
- *
32
- * @param String $key
33
- * The key who's data to retrieve
34
- * @param boolean|int $expiration
35
- * Expiration time in seconds
36
- *
37
- */
38
- abstract public function get($key, $expiration = false);
39
 
40
- /**
41
- * Store the key => $value set.
42
- * The $value is serialized
43
- * by this function so can be of any type
44
- *
45
- * @param string $key
46
- * Key of the data
47
- * @param string $value
48
- * data
49
- */
50
- abstract public function set($key, $value);
51
 
52
- /**
53
- * Removes the key/data pair for the given $key
54
- *
55
- * @param String $key
56
- */
57
- abstract public function delete($key);
58
  }
1
  <?php
 
2
  /*
3
  * Copyright 2008 Google Inc.
4
  *
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
  /**
19
  * Abstract storage class
20
  *
22
  */
23
  abstract class Google_Cache_Abstract
24
  {
25
+
26
+ abstract public function __construct(Google_Client $client);
27
 
28
+ /**
29
+ * Retrieves the data for the given key, or false if they
30
+ * key is unknown or expired
31
+ *
32
+ * @param String $key The key who's data to retrieve
33
+ * @param boolean|int $expiration Expiration time in seconds
34
+ *
35
+ */
36
+ abstract public function get($key, $expiration = false);
 
 
 
 
37
 
38
+ /**
39
+ * Store the key => $value set. The $value is serialized
40
+ * by this function so can be of any type
41
+ *
42
+ * @param string $key Key of the data
43
+ * @param string $value data
44
+ */
45
+ abstract public function set($key, $value);
 
 
 
46
 
47
+ /**
48
+ * Removes the key/data pair for the given $key
49
+ *
50
+ * @param String $key
51
+ */
52
+ abstract public function delete($key);
53
  }
tools/src/Google/Cache/Apc.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * A persistent storage class based on the APC cache, which is not
@@ -26,83 +29,85 @@ require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
26
  */
27
  class Google_Cache_Apc extends Google_Cache_Abstract
28
  {
 
 
 
 
29
 
30
- /**
31
- *
32
- * @var Google_Client the current client
33
- */
34
- private $client;
35
 
36
- public function __construct(Google_Client $client)
37
- {
38
- if (! function_exists('apc_add')) {
39
- $error = "Apc functions not available";
40
- $client->getLogger()->error($error);
41
- throw new Google_Cache_Exception($error);
42
- }
43
- $this->client = $client;
44
  }
45
 
46
- /**
47
- * @inheritDoc
48
- */
49
- public function get($key, $expiration = false)
50
- {
51
- $ret = apc_fetch($key);
52
- if ($ret === false) {
53
- $this->client->getLogger()->debug('APC cache miss', array(
54
- 'key' => $key
55
- ));
56
- return false;
57
- }
58
- if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) {
59
- $this->client->getLogger()->debug('APC cache miss (expired)', array(
60
- 'key' => $key,
61
- 'var' => $ret
62
- ));
63
- $this->delete($key);
64
- return false;
65
- }
66
- $this->client->getLogger()->debug('APC cache hit', array(
67
- 'key' => $key,
68
- 'var' => $ret
69
- ));
70
- return $ret['data'];
71
- }
72
 
73
- /**
74
- * @inheritDoc
75
- */
76
- public function set($key, $value)
77
- {
78
- $var = array(
79
- 'time' => time(),
80
- 'data' => $value
81
- );
82
- $rc = apc_store($key, $var);
83
- if ($rc == false) {
84
- $this->client->getLogger()->error('APC cache set failed', array(
85
- 'key' => $key,
86
- 'var' => $var
87
- ));
88
- throw new Google_Cache_Exception("Couldn't store data");
89
- }
90
- $this->client->getLogger()->debug('APC cache set', array(
91
- 'key' => $key,
92
- 'var' => $var
93
- ));
94
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
- /**
97
- * @inheritDoc
98
- *
99
- * @param String $key
100
- */
101
- public function delete($key)
102
- {
103
- $this->client->getLogger()->debug('APC cache delete', array(
104
- 'key' => $key
105
- ));
106
- apc_delete($key);
 
 
 
 
 
 
107
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * A persistent storage class based on the APC cache, which is not
29
  */
30
  class Google_Cache_Apc extends Google_Cache_Abstract
31
  {
32
+ /**
33
+ * @var Google_Client the current client
34
+ */
35
+ private $client;
36
 
37
+ public function __construct(Google_Client $client)
38
+ {
39
+ if (! function_exists('apc_add') ) {
40
+ $error = "Apc functions not available";
 
41
 
42
+ $client->getLogger()->error($error);
43
+ throw new Google_Cache_Exception($error);
 
 
 
 
 
 
44
  }
45
 
46
+ $this->client = $client;
47
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
+ /**
50
+ * @inheritDoc
51
+ */
52
+ public function get($key, $expiration = false)
53
+ {
54
+ $ret = apc_fetch($key);
55
+ if ($ret === false) {
56
+ $this->client->getLogger()->debug(
57
+ 'APC cache miss',
58
+ array('key' => $key)
59
+ );
60
+ return false;
 
 
 
 
 
 
 
 
 
61
  }
62
+ if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) {
63
+ $this->client->getLogger()->debug(
64
+ 'APC cache miss (expired)',
65
+ array('key' => $key, 'var' => $ret)
66
+ );
67
+ $this->delete($key);
68
+ return false;
69
+ }
70
+
71
+ $this->client->getLogger()->debug(
72
+ 'APC cache hit',
73
+ array('key' => $key, 'var' => $ret)
74
+ );
75
 
76
+ return $ret['data'];
77
+ }
78
+
79
+ /**
80
+ * @inheritDoc
81
+ */
82
+ public function set($key, $value)
83
+ {
84
+ $var = array('time' => time(), 'data' => $value);
85
+ $rc = apc_store($key, $var);
86
+
87
+ if ($rc == false) {
88
+ $this->client->getLogger()->error(
89
+ 'APC cache set failed',
90
+ array('key' => $key, 'var' => $var)
91
+ );
92
+ throw new Google_Cache_Exception("Couldn't store data");
93
  }
94
+
95
+ $this->client->getLogger()->debug(
96
+ 'APC cache set',
97
+ array('key' => $key, 'var' => $var)
98
+ );
99
+ }
100
+
101
+ /**
102
+ * @inheritDoc
103
+ * @param String $key
104
+ */
105
+ public function delete($key)
106
+ {
107
+ $this->client->getLogger()->debug(
108
+ 'APC cache delete',
109
+ array('key' => $key)
110
+ );
111
+ apc_delete($key);
112
+ }
113
  }
tools/src/Google/Cache/Exception.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  class Google_Cache_Exception extends Google_Exception
20
  {
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  class Google_Cache_Exception extends Google_Exception
23
  {
tools/src/Google/Cache/File.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /*
20
  * This class implements a basic on disk storage. While that does
@@ -26,161 +29,181 @@ require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
26
  */
27
  class Google_Cache_File extends Google_Cache_Abstract
28
  {
29
-
30
- const MAX_LOCK_RETRIES = 10;
31
-
32
- private $path;
33
-
34
- private $fh;
35
-
36
- /**
37
- *
38
- * @var Google_Client the current client
39
- */
40
- private $client;
41
-
42
- public function __construct(Google_Client $client)
43
- {
44
- $this->client = $client;
45
- $this->path = $this->client->getClassConfig($this, 'directory');
 
 
 
 
 
 
 
 
 
46
  }
47
 
48
- public function get($key, $expiration = false)
49
- {
50
- $storageFile = $this->getCacheFile($key);
51
- $data = false;
52
- if (! file_exists($storageFile)) {
53
- $this->client->getLogger()->debug('File cache miss', array(
54
- 'key' => $key,
55
- 'file' => $storageFile
56
- ));
57
- return false;
58
- }
59
- if ($expiration) {
60
- $mtime = filemtime($storageFile);
61
- if ((time() - $mtime) >= $expiration) {
62
- $this->client->getLogger()->debug('File cache miss (expired)', array(
63
- 'key' => $key,
64
- 'file' => $storageFile
65
- ));
66
- $this->delete($key);
67
- return false;
68
- }
69
- }
70
- if ($this->acquireReadLock($storageFile)) {
71
- $data = fread($this->fh, filesize($storageFile));
72
- $data = unserialize($data);
73
- $this->unlock($storageFile);
74
- }
75
- $this->client->getLogger()->debug('File cache hit', array(
76
- 'key' => $key,
77
- 'file' => $storageFile,
78
- 'var' => $data
79
- ));
80
- return $data;
81
  }
82
 
83
- public function set($key, $value)
84
- {
85
- $storageFile = $this->getWriteableCacheFile($key);
86
- if ($this->acquireWriteLock($storageFile)) {
87
- // We serialize the whole request object, since we don't only want the
88
- // responseContent but also the postBody used, headers, size, etc.
89
- $data = serialize($value);
90
- $result = fwrite($this->fh, $data);
91
- $this->unlock($storageFile);
92
- $this->client->getLogger()->debug('File cache set', array(
93
- 'key' => $key,
94
- 'file' => $storageFile,
95
- 'var' => $value
96
- ));
97
- } else {
98
- $this->client->getLogger()->notice('File cache set failed', array(
99
- 'key' => $key,
100
- 'file' => $storageFile
101
- ));
102
- }
103
  }
104
 
105
- public function delete($key)
106
- {
107
- $file = $this->getCacheFile($key);
108
- if (file_exists($file) && ! unlink($file)) {
109
- $this->client->getLogger()->error('File cache delete failed', array(
110
- 'key' => $key,
111
- 'file' => $file
112
- ));
113
- throw new Google_Cache_Exception("Cache file could not be deleted");
114
- }
115
- $this->client->getLogger()->debug('File cache delete', array(
116
- 'key' => $key,
117
- 'file' => $file
118
- ));
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
120
-
121
- private function getWriteableCacheFile($file)
122
- {
123
- return $this->getCacheFile($file, true);
 
 
 
 
 
 
 
124
  }
125
 
126
- private function getCacheFile($file, $forWrite = false)
127
- {
128
- return $this->getCacheDir($file, $forWrite) . '/' . md5($file);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  }
130
-
131
- private function getCacheDir($file, $forWrite)
132
- {
133
- // use the first 2 characters of the hash as a directory prefix
134
- // this should prevent slowdowns due to huge directory listings
135
- // and thus give some basic amount of scalability
136
- $storageDir = $this->path . '/' . substr(md5($file), 0, 2);
137
- if ($forWrite && ! is_dir($storageDir)) {
138
- if (! mkdir($storageDir, 0755, true)) {
139
- $this->client->getLogger()->error('File cache creation failed', array(
140
- 'dir' => $storageDir
141
- ));
142
- throw new Google_Cache_Exception("Could not create storage directory: $storageDir");
143
- }
144
- }
145
- return $storageDir;
 
146
  }
147
-
148
- private function acquireReadLock($storageFile)
149
- {
150
- return $this->acquireLock(LOCK_SH, $storageFile);
 
 
 
 
 
 
 
 
 
151
  }
152
-
153
- private function acquireWriteLock($storageFile)
154
- {
155
- $rc = $this->acquireLock(LOCK_EX, $storageFile);
156
- if (! $rc) {
157
- $this->client->getLogger()->notice('File cache write lock failed', array(
158
- 'file' => $storageFile
159
- ));
160
- $this->delete($storageFile);
161
- }
162
- return $rc;
163
  }
164
-
165
- private function acquireLock($type, $storageFile)
166
- {
167
- $mode = $type == LOCK_EX ? "w" : "r";
168
- $this->fh = fopen($storageFile, $mode);
169
- $count = 0;
170
- while (! flock($this->fh, $type | LOCK_NB)) {
171
- // Sleep for 10ms.
172
- usleep(10000);
173
- if (++ $count < self::MAX_LOCK_RETRIES) {
174
- return false;
175
- }
176
- }
177
- return true;
178
  }
 
 
179
 
180
- public function unlock($storageFile)
181
- {
182
- if ($this->fh) {
183
- flock($this->fh, LOCK_UN);
184
- }
185
  }
 
186
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /*
23
  * This class implements a basic on disk storage. While that does
29
  */
30
  class Google_Cache_File extends Google_Cache_Abstract
31
  {
32
+ const MAX_LOCK_RETRIES = 10;
33
+ private $path;
34
+ private $fh;
35
+
36
+ /**
37
+ * @var Google_Client the current client
38
+ */
39
+ private $client;
40
+
41
+ public function __construct(Google_Client $client)
42
+ {
43
+ $this->client = $client;
44
+ $this->path = $this->client->getClassConfig($this, 'directory');
45
+ }
46
+
47
+ public function get($key, $expiration = false)
48
+ {
49
+ $storageFile = $this->getCacheFile($key);
50
+ $data = false;
51
+
52
+ if (!file_exists($storageFile)) {
53
+ $this->client->getLogger()->debug(
54
+ 'File cache miss',
55
+ array('key' => $key, 'file' => $storageFile)
56
+ );
57
+ return false;
58
  }
59
 
60
+ if ($expiration) {
61
+ $mtime = filemtime($storageFile);
62
+ if ((time() - $mtime) >= $expiration) {
63
+ $this->client->getLogger()->debug(
64
+ 'File cache miss (expired)',
65
+ array('key' => $key, 'file' => $storageFile)
66
+ );
67
+ $this->delete($key);
68
+ return false;
69
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
+ if ($this->acquireReadLock($storageFile)) {
73
+ if (filesize($storageFile) > 0) {
74
+ $data = fread($this->fh, filesize($storageFile));
75
+ $data = unserialize($data);
76
+ } else {
77
+ $this->client->getLogger()->debug(
78
+ 'Cache file was empty',
79
+ array('file' => $storageFile)
80
+ );
81
+ }
82
+ $this->unlock($storageFile);
 
 
 
 
 
 
 
 
 
83
  }
84
 
85
+ $this->client->getLogger()->debug(
86
+ 'File cache hit',
87
+ array('key' => $key, 'file' => $storageFile, 'var' => $data)
88
+ );
89
+
90
+ return $data;
91
+ }
92
+
93
+ public function set($key, $value)
94
+ {
95
+ $storageFile = $this->getWriteableCacheFile($key);
96
+ if ($this->acquireWriteLock($storageFile)) {
97
+ // We serialize the whole request object, since we don't only want the
98
+ // responseContent but also the postBody used, headers, size, etc.
99
+ $data = serialize($value);
100
+ $result = fwrite($this->fh, $data);
101
+ $this->unlock($storageFile);
102
+
103
+ $this->client->getLogger()->debug(
104
+ 'File cache set',
105
+ array('key' => $key, 'file' => $storageFile, 'var' => $value)
106
+ );
107
+ } else {
108
+ $this->client->getLogger()->notice(
109
+ 'File cache set failed',
110
+ array('key' => $key, 'file' => $storageFile)
111
+ );
112
  }
113
+ }
114
+
115
+ public function delete($key)
116
+ {
117
+ $file = $this->getCacheFile($key);
118
+ if (file_exists($file) && !unlink($file)) {
119
+ $this->client->getLogger()->error(
120
+ 'File cache delete failed',
121
+ array('key' => $key, 'file' => $file)
122
+ );
123
+ throw new Google_Cache_Exception("Cache file could not be deleted");
124
  }
125
 
126
+ $this->client->getLogger()->debug(
127
+ 'File cache delete',
128
+ array('key' => $key, 'file' => $file)
129
+ );
130
+ }
131
+
132
+ private function getWriteableCacheFile($file)
133
+ {
134
+ return $this->getCacheFile($file, true);
135
+ }
136
+
137
+ private function getCacheFile($file, $forWrite = false)
138
+ {
139
+ return $this->getCacheDir($file, $forWrite) . '/' . md5($file);
140
+ }
141
+
142
+ private function getCacheDir($file, $forWrite)
143
+ {
144
+ // use the first 2 characters of the hash as a directory prefix
145
+ // this should prevent slowdowns due to huge directory listings
146
+ // and thus give some basic amount of scalability
147
+ $storageDir = $this->path . '/' . substr(md5($file), 0, 2);
148
+ if ($forWrite && ! is_dir($storageDir)) {
149
+ if (! mkdir($storageDir, 0700, true)) {
150
+ $this->client->getLogger()->error(
151
+ 'File cache creation failed',
152
+ array('dir' => $storageDir)
153
+ );
154
+ throw new Google_Cache_Exception("Could not create storage directory: $storageDir");
155
+ }
156
  }
157
+ return $storageDir;
158
+ }
159
+
160
+ private function acquireReadLock($storageFile)
161
+ {
162
+ return $this->acquireLock(LOCK_SH, $storageFile);
163
+ }
164
+
165
+ private function acquireWriteLock($storageFile)
166
+ {
167
+ $rc = $this->acquireLock(LOCK_EX, $storageFile);
168
+ if (!$rc) {
169
+ $this->client->getLogger()->notice(
170
+ 'File cache write lock failed',
171
+ array('file' => $storageFile)
172
+ );
173
+ $this->delete($storageFile);
174
  }
175
+ return $rc;
176
+ }
177
+
178
+ private function acquireLock($type, $storageFile)
179
+ {
180
+ $mode = $type == LOCK_EX ? "w" : "r";
181
+ $this->fh = fopen($storageFile, $mode);
182
+ if (!$this->fh) {
183
+ $this->client->getLogger()->error(
184
+ 'Failed to open file during lock acquisition',
185
+ array('file' => $storageFile)
186
+ );
187
+ return false;
188
  }
189
+ if ($type == LOCK_EX) {
190
+ chmod($storageFile, 0600);
 
 
 
 
 
 
 
 
 
191
  }
192
+ $count = 0;
193
+ while (!flock($this->fh, $type | LOCK_NB)) {
194
+ // Sleep for 10ms.
195
+ usleep(10000);
196
+ if (++$count < self::MAX_LOCK_RETRIES) {
197
+ return false;
198
+ }
 
 
 
 
 
 
 
199
  }
200
+ return true;
201
+ }
202
 
203
+ public function unlock($storageFile)
204
+ {
205
+ if ($this->fh) {
206
+ flock($this->fh, LOCK_UN);
 
207
  }
208
+ }
209
  }
tools/src/Google/Cache/Memcache.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * A persistent storage class based on the memcache, which is not
@@ -28,151 +31,154 @@ require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
28
  */
29
  class Google_Cache_Memcache extends Google_Cache_Abstract
30
  {
 
 
 
 
 
 
 
 
 
31
 
32
- private $connection = false;
33
-
34
- private $mc = false;
35
-
36
- private $host;
37
-
38
- private $port;
39
-
40
- /**
41
- *
42
- * @var Google_Client the current client
43
- */
44
- private $client;
45
-
46
- public function __construct(Google_Client $client)
47
- {
48
- if (! function_exists('memcache_connect') && ! class_exists("Memcached")) {
49
- $error = "Memcache functions not available";
50
- $client->getLogger()->error($error);
51
- throw new Google_Cache_Exception($error);
52
- }
53
- $this->client = $client;
54
- if ($client->isAppEngine()) {
55
- // No credentials needed for GAE.
56
- $this->mc = new Memcached();
57
- $this->connection = true;
58
- } else {
59
- $this->host = $client->getClassConfig($this, 'host');
60
- $this->port = $client->getClassConfig($this, 'port');
61
- if (empty($this->host) || (empty($this->port) && (string) $this->port != "0")) {
62
- $error = "You need to supply a valid memcache host and port";
63
- $client->getLogger()->error($error);
64
- throw new Google_Cache_Exception($error);
65
- }
66
- }
67
  }
68
 
69
- /**
70
- * @inheritDoc
71
- */
72
- public function get($key, $expiration = false)
73
- {
74
- $this->connect();
75
- $ret = false;
76
- if ($this->mc) {
77
- $ret = $this->mc->get($key);
78
- } else {
79
- $ret = memcache_get($this->connection, $key);
80
- }
81
- if ($ret === false) {
82
- $this->client->getLogger()->debug('Memcache cache miss', array(
83
- 'key' => $key
84
- ));
85
- return false;
86
- }
87
- if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) {
88
- $this->client->getLogger()->debug('Memcache cache miss (expired)', array(
89
- 'key' => $key,
90
- 'var' => $ret
91
- ));
92
- $this->delete($key);
93
- return false;
94
- }
95
- $this->client->getLogger()->debug('Memcache cache hit', array(
96
- 'key' => $key,
97
- 'var' => $ret
98
- ));
99
- return $ret['data'];
100
  }
 
101
 
102
- /**
103
- * @inheritDoc
104
- *
105
- * @param string $key
106
- * @param string $value
107
- * @throws Google_Cache_Exception
108
- */
109
- public function set($key, $value)
110
- {
111
- $this->connect();
112
- // we store it with the cache_time default expiration so objects will at
113
- // least get cleaned eventually.
114
- $data = array(
115
- 'time' => time(),
116
- 'data' => $value
117
- );
118
- $rc = false;
119
- if ($this->mc) {
120
- $rc = $this->mc->set($key, $data);
121
- } else {
122
- $rc = memcache_set($this->connection, $key, $data, false);
123
- }
124
- if ($rc == false) {
125
- $this->client->getLogger()->error('Memcache cache set failed', array(
126
- 'key' => $key,
127
- 'var' => $data
128
- ));
129
- throw new Google_Cache_Exception("Couldn't store data in cache");
130
- }
131
- $this->client->getLogger()->debug('Memcache cache set', array(
132
- 'key' => $key,
133
- 'var' => $data
134
- ));
135
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
- /**
138
- * @inheritDoc
139
- *
140
- * @param String $key
141
- */
142
- public function delete($key)
143
- {
144
- $this->connect();
145
- if ($this->mc) {
146
- $this->mc->delete($key, 0);
147
- } else {
148
- memcache_delete($this->connection, $key, 0);
149
- }
150
- $this->client->getLogger()->debug('Memcache cache delete', array(
151
- 'key' => $key
152
- ));
 
 
 
 
153
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
- /**
156
- * Lazy initialiser for memcache connection.
157
- * Uses pconnect for to take
158
- * advantage of the persistence pool where possible.
159
- */
160
- private function connect()
161
- {
162
- if ($this->connection) {
163
- return;
164
- }
165
- if (class_exists("Memcached")) {
166
- $this->mc = new Memcached();
167
- $this->mc->addServer($this->host, $this->port);
168
- $this->connection = true;
169
- } else {
170
- $this->connection = memcache_pconnect($this->host, $this->port);
171
- }
172
- if (! $this->connection) {
173
- $error = "Couldn't connect to memcache server";
174
- $this->client->getLogger()->error($error);
175
- throw new Google_Cache_Exception($error);
176
- }
177
  }
 
178
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * A persistent storage class based on the memcache, which is not
31
  */
32
  class Google_Cache_Memcache extends Google_Cache_Abstract
33
  {
34
+ private $connection = false;
35
+ private $mc = false;
36
+ private $host;
37
+ private $port;
38
+
39
+ /**
40
+ * @var Google_Client the current client
41
+ */
42
+ private $client;
43
 
44
+ public function __construct(Google_Client $client)
45
+ {
46
+ if (!function_exists('memcache_connect') && !class_exists("Memcached")) {
47
+ $error = "Memcache functions not available";
48
+
49
+ $client->getLogger()->error($error);
50
+ throw new Google_Cache_Exception($error);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  }
52
 
53
+ $this->client = $client;
54
+
55
+ if ($client->isAppEngine()) {
56
+ // No credentials needed for GAE.
57
+ $this->mc = new Memcached();
58
+ $this->connection = true;
59
+ } else {
60
+ $this->host = $client->getClassConfig($this, 'host');
61
+ $this->port = $client->getClassConfig($this, 'port');
62
+ if (empty($this->host) || (empty($this->port) && (string) $this->port != "0")) {
63
+ $error = "You need to supply a valid memcache host and port";
64
+
65
+ $client->getLogger()->error($error);
66
+ throw new Google_Cache_Exception($error);
67
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  }
69
+ }
70
 
71
+ /**
72
+ * @inheritDoc
73
+ */
74
+ public function get($key, $expiration = false)
75
+ {
76
+ $this->connect();
77
+ $ret = false;
78
+ if ($this->mc) {
79
+ $ret = $this->mc->get($key);
80
+ } else {
81
+ $ret = memcache_get($this->connection, $key);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
83
+ if ($ret === false) {
84
+ $this->client->getLogger()->debug(
85
+ 'Memcache cache miss',
86
+ array('key' => $key)
87
+ );
88
+ return false;
89
+ }
90
+ if (is_numeric($expiration) && (time() - $ret['time'] > $expiration)) {
91
+ $this->client->getLogger()->debug(
92
+ 'Memcache cache miss (expired)',
93
+ array('key' => $key, 'var' => $ret)
94
+ );
95
+ $this->delete($key);
96
+ return false;
97
+ }
98
+
99
+ $this->client->getLogger()->debug(
100
+ 'Memcache cache hit',
101
+ array('key' => $key, 'var' => $ret)
102
+ );
103
 
104
+ return $ret['data'];
105
+ }
106
+
107
+ /**
108
+ * @inheritDoc
109
+ * @param string $key
110
+ * @param string $value
111
+ * @throws Google_Cache_Exception
112
+ */
113
+ public function set($key, $value)
114
+ {
115
+ $this->connect();
116
+ // we store it with the cache_time default expiration so objects will at
117
+ // least get cleaned eventually.
118
+ $data = array('time' => time(), 'data' => $value);
119
+ $rc = false;
120
+ if ($this->mc) {
121
+ $rc = $this->mc->set($key, $data);
122
+ } else {
123
+ $rc = memcache_set($this->connection, $key, $data, false);
124
  }
125
+ if ($rc == false) {
126
+ $this->client->getLogger()->error(
127
+ 'Memcache cache set failed',
128
+ array('key' => $key, 'var' => $data)
129
+ );
130
+
131
+ throw new Google_Cache_Exception("Couldn't store data in cache");
132
+ }
133
+
134
+ $this->client->getLogger()->debug(
135
+ 'Memcache cache set',
136
+ array('key' => $key, 'var' => $data)
137
+ );
138
+ }
139
+
140
+ /**
141
+ * @inheritDoc
142
+ * @param String $key
143
+ */
144
+ public function delete($key)
145
+ {
146
+ $this->connect();
147
+ if ($this->mc) {
148
+ $this->mc->delete($key, 0);
149
+ } else {
150
+ memcache_delete($this->connection, $key, 0);
151
+ }
152
+
153
+ $this->client->getLogger()->debug(
154
+ 'Memcache cache delete',
155
+ array('key' => $key)
156
+ );
157
+ }
158
+
159
+ /**
160
+ * Lazy initialiser for memcache connection. Uses pconnect for to take
161
+ * advantage of the persistence pool where possible.
162
+ */
163
+ private function connect()
164
+ {
165
+ if ($this->connection) {
166
+ return;
167
+ }
168
+
169
+ if (class_exists("Memcached")) {
170
+ $this->mc = new Memcached();
171
+ $this->mc->addServer($this->host, $this->port);
172
+ $this->connection = true;
173
+ } else {
174
+ $this->connection = memcache_pconnect($this->host, $this->port);
175
+ }
176
+
177
+ if (! $this->connection) {
178
+ $error = "Couldn't connect to memcache server";
179
 
180
+ $this->client->getLogger()->error($error);
181
+ throw new Google_Cache_Exception($error);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  }
183
+ }
184
  }
tools/src/Google/Cache/Null.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * A blank storage class, for cases where caching is not
@@ -22,33 +25,33 @@ require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
22
  */
23
  class Google_Cache_Null extends Google_Cache_Abstract
24
  {
 
 
25
 
26
- public function __construct(Google_Client $client)
27
- {}
28
 
29
- /**
30
- * @inheritDoc
31
- */
32
- public function get($key, $expiration = false)
33
- {
34
- return false;
35
- }
36
 
37
- /**
38
- * @inheritDoc
39
- */
40
- public function set($key, $value)
41
- {
42
- // Nop.
43
- }
44
 
45
- /**
46
- * @inheritDoc
47
- *
48
- * @param String $key
49
- */
50
- public function delete($key)
51
- {
52
- // Nop.
53
- }
54
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * A blank storage class, for cases where caching is not
25
  */
26
  class Google_Cache_Null extends Google_Cache_Abstract
27
  {
28
+ public function __construct(Google_Client $client)
29
+ {
30
 
31
+ }
 
32
 
33
+ /**
34
+ * @inheritDoc
35
+ */
36
+ public function get($key, $expiration = false)
37
+ {
38
+ return false;
39
+ }
40
 
41
+ /**
42
+ * @inheritDoc
43
+ */
44
+ public function set($key, $value)
45
+ {
46
+ // Nop.
47
+ }
48
 
49
+ /**
50
+ * @inheritDoc
51
+ * @param String $key
52
+ */
53
+ public function delete($key)
54
+ {
55
+ // Nop.
56
+ }
 
57
  }
tools/src/Google/Client.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,748 +14,702 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../autoload.php');
 
 
 
18
 
19
  /**
20
  * The Google API Client
21
- * http://code.google.com/p/google-api-php-client/
22
- *
23
- * @author Chris Chabot <chabotc@google.com>
24
- * @author Chirag Shah <chirags@google.com>
25
  */
26
  class Google_Client
27
  {
28
-
29
- const LIBVER = "1.1.2";
30
-
31
- const USER_AGENT_SUFFIX = "google-api-php-client/";
32
-
33
- /**
34
- *
35
- * @var Google_Auth_Abstract $auth
36
- */
37
- private $auth;
38
-
39
- /**
40
- *
41
- * @var Google_IO_Abstract $io
42
- */
43
- private $io;
44
-
45
- /**
46
- *
47
- * @var Google_Cache_Abstract $cache
48
- */
49
- private $cache;
50
-
51
- /**
52
- *
53
- * @var Google_Config $config
54
- */
55
- private $config;
56
-
57
- /**
58
- *
59
- * @var Google_Logger_Abstract $logger
60
- */
61
- private $logger;
62
-
63
- /**
64
- *
65
- * @var boolean $deferExecution
66
- */
67
- private $deferExecution = false;
68
-
69
- /**
70
- *
71
- * @var array $scopes
72
- */
73
- // Scopes requested by the client
74
- protected $requestedScopes = array();
75
- // definitions of services that are discovered.
76
- protected $services = array();
77
- // Used to track authenticated state, can't discover services after doing authenticate()
78
- private $authenticated = false;
79
-
80
- /**
81
- * Construct the Google Client.
82
- *
83
- * @param $config Google_Config
84
- * or string for the ini file to load
85
- */
86
- public function __construct($config = null)
87
- {
88
- if (is_string($config) && strlen($config)) {
89
- $config = new Google_Config($config);
90
- } else
91
- if (! ($config instanceof Google_Config)) {
92
- $config = new Google_Config();
93
- if ($this->isAppEngine()) {
94
- // Automatically use Memcache if we're in AppEngine.
95
- $config->setCacheClass('Google_Cache_Memcache');
96
- }
97
- if (version_compare(phpversion(), "5.3.4", "<=") || $this->isAppEngine()) {
98
- // Automatically disable compress.zlib, as currently unsupported.
99
- $config->setClassConfig('Google_Http_Request', 'disable_gzip', true);
100
- }
101
- }
102
- if ($config->getIoClass() == Google_Config::USE_AUTO_IO_SELECTION) {
103
- if (function_exists('curl_version') && function_exists('curl_exec') && ! $this->isAppEngine()) {
104
- $config->setIoClass("Google_IO_Curl");
105
- } else {
106
- $config->setIoClass("Google_IO_Stream");
107
- }
108
- }
109
- $this->config = $config;
110
- }
111
-
112
- /**
113
- * Get a string containing the version of the library.
114
- *
115
- * @return string
116
- */
117
- public function getLibraryVersion()
118
- {
119
- return self::LIBVER;
120
- }
121
-
122
- /**
123
- * Attempt to exchange a code for an valid authentication token.
124
- * Helper wrapped around the OAuth 2.0 implementation.
125
- *
126
- * @param $code string
127
- * code from accounts.google.com
128
- * @return string token
129
- */
130
- public function authenticate($code)
131
- {
132
- $this->authenticated = true;
133
- return $this->getAuth()->authenticate($code);
134
- }
135
-
136
- /**
137
- * Set the auth config from the JSON string provided.
138
- * This structure should match the file downloaded from
139
- * the "Download JSON" button on in the Google Developer
140
- * Console.
141
- *
142
- * @param string $json
143
- * the configuration json
144
- * @throws Google_Exception
145
- */
146
- public function setAuthConfig($json)
147
- {
148
- $data = json_decode($json);
149
- $key = isset($data->installed) ? 'installed' : 'web';
150
- if (! isset($data->$key)) {
151
- throw new Google_Exception("Invalid client secret JSON file.");
152
- }
153
- $this->setClientId($data->$key->client_id);
154
- $this->setClientSecret($data->$key->client_secret);
155
- if (isset($data->$key->redirect_uris)) {
156
- $this->setRedirectUri($data->$key->redirect_uris[0]);
157
- }
158
- }
159
-
160
- /**
161
- * Set the auth config from the JSON file in the path
162
- * provided.
163
- * This should match the file downloaded from
164
- * the "Download JSON" button on in the Google Developer
165
- * Console.
166
- *
167
- * @param string $file
168
- * the file location of the client json
169
- */
170
- public function setAuthConfigFile($file)
171
- {
172
- $this->setAuthConfig(file_get_contents($file));
173
- }
174
-
175
- /**
176
- *
177
- * @throws Google_Auth_Exception
178
- * @return array @visible For Testing
179
- */
180
- public function prepareScopes()
181
- {
182
- if (empty($this->requestedScopes)) {
183
- throw new Google_Auth_Exception("No scopes specified");
184
- }
185
- $scopes = implode(' ', $this->requestedScopes);
186
- return $scopes;
187
- }
188
-
189
- /**
190
- * Set the OAuth 2.0 access token using the string that resulted from calling createAuthUrl()
191
- * or Google_Client#getAccessToken().
192
- *
193
- * @param string $accessToken
194
- * JSON encoded string containing in the following format:
195
- * {"access_token":"TOKEN", "refresh_token":"TOKEN", "token_type":"Bearer",
196
- * "expires_in":3600, "id_token":"TOKEN", "created":1320790426}
197
- */
198
- public function setAccessToken($accessToken)
199
- {
200
- if ($accessToken == 'null') {
201
- $accessToken = null;
202
- }
203
- $this->getAuth()->setAccessToken($accessToken);
204
- }
205
-
206
- /**
207
- * Set the authenticator object
208
- *
209
- * @param Google_Auth_Abstract $auth
210
- */
211
- public function setAuth(Google_Auth_Abstract $auth)
212
- {
213
- $this->config->setAuthClass(get_class($auth));
214
- $this->auth = $auth;
215
- }
216
-
217
- /**
218
- * Set the IO object
219
- *
220
- * @param Google_IO_Abstract $io
221
- */
222
- public function setIo(Google_IO_Abstract $io)
223
- {
224
- $this->config->setIoClass(get_class($io));
225
- $this->io = $io;
226
- }
227
-
228
- /**
229
- * Set the Cache object
230
- *
231
- * @param Google_Cache_Abstract $cache
232
- */
233
- public function setCache(Google_Cache_Abstract $cache)
234
- {
235
- $this->config->setCacheClass(get_class($cache));
236
- $this->cache = $cache;
237
- }
238
-
239
- /**
240
- * Set the Logger object
241
- *
242
- * @param Google_Logger_Abstract $logger
243
- */
244
- public function setLogger(Google_Logger_Abstract $logger)
245
- {
246
- $this->config->setLoggerClass(get_class($logger));
247
- $this->logger = $logger;
248
- }
249
-
250
- /**
251
- * Construct the OAuth 2.0 authorization request URI.
252
- *
253
- * @return string
254
- */
255
- public function createAuthUrl()
256
- {
257
- $scopes = $this->prepareScopes();
258
- return $this->getAuth()->createAuthUrl($scopes);
259
- }
260
-
261
- /**
262
- * Get the OAuth 2.0 access token.
263
- *
264
- * @return string $accessToken JSON encoded string in the following format:
265
- * {"access_token":"TOKEN", "refresh_token":"TOKEN", "token_type":"Bearer",
266
- * "expires_in":3600,"id_token":"TOKEN", "created":1320790426}
267
- */
268
- public function getAccessToken()
269
- {
270
- $token = $this->getAuth()->getAccessToken();
271
- // The response is json encoded, so could be the string null.
272
- // It is arguable whether this check should be here or lower
273
- // in the library.
274
- return (null == $token || 'null' == $token || '[]' == $token) ? null : $token;
275
- }
276
-
277
- /**
278
- * Get the OAuth 2.0 refresh token.
279
- *
280
- * @return string $refreshToken refresh token or null if not available
281
- */
282
- public function getRefreshToken()
283
- {
284
- return $this->getAuth()->getRefreshToken();
285
- }
286
-
287
- /**
288
- * Returns if the access_token is expired.
289
- *
290
- * @return bool Returns True if the access_token is expired.
291
- */
292
- public function isAccessTokenExpired()
293
- {
294
- return $this->getAuth()->isAccessTokenExpired();
295
- }
296
-
297
- /**
298
- * Set OAuth 2.0 "state" parameter to achieve per-request customization.
299
- *
300
- * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-3.1.2.2
301
- * @param string $state
302
- */
303
- public function setState($state)
304
- {
305
- $this->getAuth()->setState($state);
306
- }
307
-
308
- /**
309
- *
310
- * @param string $accessType
311
- * Possible values for access_type include:
312
- * {@code "offline"} to request offline access from the user.
313
- * {@code "online"} to request online access from the user.
314
- */
315
- public function setAccessType($accessType)
316
- {
317
- $this->config->setAccessType($accessType);
318
- }
319
-
320
- /**
321
- *
322
- * @param string $approvalPrompt
323
- * Possible values for approval_prompt include:
324
- * {@code "force"} to force the approval UI to appear. (This is the default value)
325
- * {@code "auto"} to request auto-approval when possible.
326
- */
327
- public function setApprovalPrompt($approvalPrompt)
328
- {
329
- $this->config->setApprovalPrompt($approvalPrompt);
330
- }
331
-
332
- /**
333
- * Set the login hint, email address or sub id.
334
- *
335
- * @param string $loginHint
336
- */
337
- public function setLoginHint($loginHint)
338
- {
339
- $this->config->setLoginHint($loginHint);
340
- }
341
-
342
- /**
343
- * Set the application name, this is included in the User-Agent HTTP header.
344
- *
345
- * @param string $applicationName
346
- */
347
- public function setApplicationName($applicationName)
348
- {
349
- $this->config->setApplicationName($applicationName);
350
- }
351
-
352
- /**
353
- * Set the OAuth 2.0 Client ID.
354
- *
355
- * @param string $clientId
356
- */
357
- public function setClientId($clientId)
358
- {
359
- $this->config->setClientId($clientId);
360
- }
361
-
362
- /**
363
- * Set the OAuth 2.0 Client Secret.
364
- *
365
- * @param string $clientSecret
366
- */
367
- public function setClientSecret($clientSecret)
368
- {
369
- $this->config->setClientSecret($clientSecret);
370
- }
371
-
372
- /**
373
- * Set the OAuth 2.0 Redirect URI.
374
- *
375
- * @param string $redirectUri
376
- */
377
- public function setRedirectUri($redirectUri)
378
- {
379
- $this->config->setRedirectUri($redirectUri);
380
- }
381
-
382
- /**
383
- * If 'plus.login' is included in the list of requested scopes, you can use
384
- * this method to define types of app activities that your app will write.
385
- * You can find a list of available types here:
386
- *
387
- * @link https://developers.google.com/+/api/moment-types
388
- *
389
- * @param array $requestVisibleActions
390
- * Array of app activity types
391
- */
392
- public function setRequestVisibleActions($requestVisibleActions)
393
- {
394
- if (is_array($requestVisibleActions)) {
395
- $requestVisibleActions = join(" ", $requestVisibleActions);
396
- }
397
- $this->config->setRequestVisibleActions($requestVisibleActions);
398
- }
399
-
400
- /**
401
- * Set the developer key to use, these are obtained through the API Console.
402
- *
403
- * @see http://code.google.com/apis/console-help/#generatingdevkeys
404
- * @param string $developerKey
405
- */
406
- public function setDeveloperKey($developerKey)
407
- {
408
- $this->config->setDeveloperKey($developerKey);
409
- }
410
-
411
- /**
412
- * Set the hd (hosted domain) parameter streamlines the login process for
413
- * Google Apps hosted accounts.
414
- * By including the domain of the user, you
415
- * restrict sign-in to accounts at that domain.
416
- *
417
- * @param $hd string
418
- * - the domain to use.
419
- */
420
- public function setHostedDomain($hd)
421
- {
422
- $this->config->setHostedDomain($hd);
423
- }
424
-
425
- /**
426
- * Set the prompt hint.
427
- * Valid values are none, consent and select_account.
428
- * If no value is specified and the user has not previously authorized
429
- * access, then the user is shown a consent screen.
430
- *
431
- * @param $prompt string
432
- */
433
- public function setPrompt($prompt)
434
- {
435
- $this->config->setPrompt($prompt);
436
- }
437
-
438
- /**
439
- * openid.realm is a parameter from the OpenID 2.0 protocol, not from OAuth
440
- * 2.0.
441
- * It is used in OpenID 2.0 requests to signify the URL-space for which
442
- * an authentication request is valid.
443
- *
444
- * @param $realm string
445
- * - the URL-space to use.
446
- */
447
- public function setOpenidRealm($realm)
448
- {
449
- $this->config->setOpenidRealm($realm);
450
- }
451
-
452
- /**
453
- * If this is provided with the value true, and the authorization request is
454
- * granted, the authorization will include any previous authorizations
455
- * granted to this user/application combination for other scopes.
456
- *
457
- * @param $include boolean
458
- * - the URL-space to use.
459
- */
460
- public function setIncludeGrantedScopes($include)
461
- {
462
- $this->config->setIncludeGrantedScopes($include);
463
- }
464
-
465
- /**
466
- * Fetches a fresh OAuth 2.0 access token with the given refresh token.
467
- *
468
- * @param string $refreshToken
469
- */
470
- public function refreshToken($refreshToken)
471
- {
472
- $this->getAuth()->refreshToken($refreshToken);
473
- }
474
-
475
- /**
476
- * Revoke an OAuth2 access token or refresh token.
477
- * This method will revoke the current access
478
- * token, if a token isn't provided.
479
- *
480
- * @throws Google_Auth_Exception
481
- * @param string|null $token
482
- * The token (access token or a refresh token) that should be revoked.
483
- * @return boolean Returns True if the revocation was successful, otherwise False.
484
- */
485
- public function revokeToken($token = null)
486
- {
487
- return $this->getAuth()->revokeToken($token);
488
- }
489
-
490
- /**
491
- * Verify an id_token.
492
- * This method will verify the current id_token, if one
493
- * isn't provided.
494
- *
495
- * @throws Google_Auth_Exception
496
- * @param string|null $token
497
- * The token (id_token) that should be verified.
498
- * @return Google_Auth_LoginTicket Returns an apiLoginTicket if the verification was
499
- * successful.
500
- */
501
- public function verifyIdToken($token = null)
502
- {
503
- return $this->getAuth()->verifyIdToken($token);
504
- }
505
-
506
- /**
507
- * Verify a JWT that was signed with your own certificates.
508
- *
509
- * @param $id_token string
510
- * The JWT token
511
- * @param $cert_location array
512
- * of certificates
513
- * @param $audience string
514
- * the expected consumer of the token
515
- * @param $issuer string
516
- * the expected issuer, defaults to Google
517
- * @param
518
- * [$max_expiry] the max lifetime of a token, defaults to MAX_TOKEN_LIFETIME_SECS
519
- * @return mixed token information if valid, false if not
520
- */
521
- public function verifySignedJwt($id_token, $cert_location, $audience, $issuer, $max_expiry = null)
522
- {
523
- $auth = new Google_Auth_OAuth2($this);
524
- $certs = $auth->retrieveCertsFromLocation($cert_location);
525
- return $auth->verifySignedJwtWithCerts($id_token, $certs, $audience, $issuer, $max_expiry);
526
- }
527
-
528
- /**
529
- *
530
- * @param $creds Google_Auth_AssertionCredentials
531
- */
532
- public function setAssertionCredentials(Google_Auth_AssertionCredentials $creds)
533
- {
534
- $this->getAuth()->setAssertionCredentials($creds);
535
- }
536
-
537
- /**
538
- * Set the scopes to be requested.
539
- * Must be called before createAuthUrl().
540
- * Will remove any previously configured scopes.
541
- *
542
- * @param array $scopes,
543
- * ie: array('https://www.googleapis.com/auth/plus.login',
544
- * 'https://www.googleapis.com/auth/moderator')
545
- */
546
- public function setScopes($scopes)
547
- {
548
- $this->requestedScopes = array();
549
- $this->addScope($scopes);
550
- }
551
-
552
- /**
553
- * This functions adds a scope to be requested as part of the OAuth2.0 flow.
554
- * Will append any scopes not previously requested to the scope parameter.
555
- * A single string will be treated as a scope to request. An array of strings
556
- * will each be appended.
557
- *
558
- * @param $scope_or_scopes string|array
559
- * e.g. "profile"
560
- */
561
- public function addScope($scope_or_scopes)
562
- {
563
- if (is_string($scope_or_scopes) && ! in_array($scope_or_scopes, $this->requestedScopes)) {
564
- $this->requestedScopes[] = $scope_or_scopes;
565
- } else
566
- if (is_array($scope_or_scopes)) {
567
- foreach ($scope_or_scopes as $scope) {
568
- $this->addScope($scope);
569
- }
570
- }
571
- }
572
-
573
- /**
574
- * Returns the list of scopes requested by the client
575
- *
576
- * @return array the list of scopes
577
- *
578
- */
579
- public function getScopes()
580
- {
581
- return $this->requestedScopes;
582
- }
583
-
584
- /**
585
- * Declare whether batch calls should be used.
586
- * This may increase throughput
587
- * by making multiple requests in one connection.
588
- *
589
- * @param boolean $useBatch
590
- * True if the batch support should
591
- * be enabled. Defaults to False.
592
- */
593
- public function setUseBatch($useBatch)
594
- {
595
- // This is actually an alias for setDefer.
596
- $this->setDefer($useBatch);
597
- }
598
-
599
- /**
600
- * Declare whether making API calls should make the call immediately, or
601
- * return a request which can be called with ->execute();
602
- *
603
- * @param boolean $defer
604
- * True if calls should not be executed right away.
605
- */
606
- public function setDefer($defer)
607
- {
608
- $this->deferExecution = $defer;
609
- }
610
-
611
- /**
612
- * Helper method to execute deferred HTTP requests.
613
- *
614
- * @param $request Google_Http_Request|Google_Http_Batch
615
- * @throws Google_Exception
616
- * @return object of the type of the expected class or array.
617
- */
618
- public function execute($request)
619
- {
620
- if ($request instanceof Google_Http_Request) {
621
- $request->setUserAgent($this->getApplicationName() . " " . self::USER_AGENT_SUFFIX . $this->getLibraryVersion());
622
- if (! $this->getClassConfig("Google_Http_Request", "disable_gzip")) {
623
- $request->enableGzip();
624
- }
625
- $request->maybeMoveParametersToBody();
626
- return Google_Http_REST::execute($this, $request);
627
- } else
628
- if ($request instanceof Google_Http_Batch) {
629
- return $request->execute();
630
- } else {
631
- throw new Google_Exception("Do not know how to execute this type of object.");
632
- }
633
- }
634
-
635
- /**
636
- * Whether or not to return raw requests
637
- *
638
- * @return boolean
639
- */
640
- public function shouldDefer()
641
- {
642
- return $this->deferExecution;
643
- }
644
-
645
- /**
646
- *
647
- * @return Google_Auth_Abstract Authentication implementation
648
- */
649
- public function getAuth()
650
- {
651
- if (! isset($this->auth)) {
652
- $class = $this->config->getAuthClass();
653
- $this->auth = new $class($this);
654
- }
655
- return $this->auth;
656
- }
657
-
658
- /**
659
- *
660
- * @return Google_IO_Abstract IO implementation
661
- */
662
- public function getIo()
663
- {
664
- if (! isset($this->io)) {
665
- $class = $this->config->getIoClass();
666
- $this->io = new $class($this);
667
- }
668
- return $this->io;
669
- }
670
-
671
- /**
672
- *
673
- * @return Google_Cache_Abstract Cache implementation
674
- */
675
- public function getCache()
676
- {
677
- if (! isset($this->cache)) {
678
- $class = $this->config->getCacheClass();
679
- $this->cache = new $class($this);
680
- }
681
- return $this->cache;
682
- }
683
-
684
- /**
685
- *
686
- * @return Google_Logger_Abstract Logger implementation
687
- */
688
- public function getLogger()
689
- {
690
- if (! isset($this->logger)) {
691
- $class = $this->config->getLoggerClass();
692
- $this->logger = new $class($this);
693
- }
694
- return $this->logger;
695
- }
696
-
697
- /**
698
- * Retrieve custom configuration for a specific class.
699
- *
700
- * @param $class string|object
701
- * - class or instance of class to retrieve
702
- * @param $key string
703
- * optional - key to retrieve
704
- * @return array
705
- */
706
- public function getClassConfig($class, $key = null)
707
- {
708
- if (! is_string($class)) {
709
- $class = get_class($class);
710
- }
711
- return $this->config->getClassConfig($class, $key);
712
- }
713
-
714
- /**
715
- * Set configuration specific to a given class.
716
- * $config->setClassConfig('Google_Cache_File',
717
- * array('directory' => '/tmp/cache'));
718
- *
719
- * @param $class string|object
720
- * - The class name for the configuration
721
- * @param $config string
722
- * key or an array of configuration values
723
- * @param $value string
724
- * optional - if $config is a key, the value
725
- *
726
- */
727
- public function setClassConfig($class, $config, $value = null)
728
- {
729
- if (! is_string($class)) {
730
- $class = get_class($class);
731
- }
732
- $this->config->setClassConfig($class, $config, $value);
733
- }
734
-
735
- /**
736
- *
737
- * @return string the base URL to use for calls to the APIs
738
- */
739
- public function getBasePath()
740
- {
741
- return $this->config->getBasePath();
742
- }
743
-
744
- /**
745
- *
746
- * @return string the name of the application
747
- */
748
- public function getApplicationName()
749
- {
750
- return $this->config->getApplicationName();
751
- }
752
-
753
- /**
754
- * Are we running in Google AppEngine?
755
- * return bool
756
- */
757
- public function isAppEngine()
758
- {
759
- return (isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false);
760
- }
761
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/autoload.php';
20
+ }
21
 
22
  /**
23
  * The Google API Client
24
+ * https://github.com/google/google-api-php-client
 
 
 
25
  */
26
  class Google_Client
27
  {
28
+ const LIBVER = "1.1.5";
29
+ const USER_AGENT_SUFFIX = "google-api-php-client/";
30
+ /**
31
+ * @var Google_Auth_Abstract $auth
32
+ */
33
+ private $auth;
34
+
35
+ /**
36
+ * @var Google_IO_Abstract $io
37
+ */
38
+ private $io;
39
+
40
+ /**
41
+ * @var Google_Cache_Abstract $cache
42
+ */
43
+ private $cache;
44
+
45
+ /**
46
+ * @var Google_Config $config
47
+ */
48
+ private $config;
49
+
50
+ /**
51
+ * @var Google_Logger_Abstract $logger
52
+ */
53
+ private $logger;
54
+
55
+ /**
56
+ * @var boolean $deferExecution
57
+ */
58
+ private $deferExecution = false;
59
+
60
+ /** @var array $scopes */
61
+ // Scopes requested by the client
62
+ protected $requestedScopes = array();
63
+
64
+ // definitions of services that are discovered.
65
+ protected $services = array();
66
+
67
+ // Used to track authenticated state, can't discover services after doing authenticate()
68
+ private $authenticated = false;
69
+
70
+ /**
71
+ * Construct the Google Client.
72
+ *
73
+ * @param $config Google_Config or string for the ini file to load
74
+ */
75
+ public function __construct($config = null)
76
+ {
77
+ if (is_string($config) && strlen($config)) {
78
+ $config = new Google_Config($config);
79
+ } else if ( !($config instanceof Google_Config)) {
80
+ $config = new Google_Config();
81
+
82
+ if ($this->isAppEngine()) {
83
+ // Automatically use Memcache if we're in AppEngine.
84
+ $config->setCacheClass('Google_Cache_Memcache');
85
+ }
86
+
87
+ if (version_compare(phpversion(), "5.3.4", "<=") || $this->isAppEngine()) {
88
+ // Automatically disable compress.zlib, as currently unsupported.
89
+ $config->setClassConfig('Google_Http_Request', 'disable_gzip', true);
90
+ }
91
+ }
92
+
93
+ if ($config->getIoClass() == Google_Config::USE_AUTO_IO_SELECTION) {
94
+ if (function_exists('curl_version') && function_exists('curl_exec')
95
+ && !$this->isAppEngine()) {
96
+ $config->setIoClass("Google_IO_Curl");
97
+ } else {
98
+ $config->setIoClass("Google_IO_Stream");
99
+ }
100
+ }
101
+
102
+ $this->config = $config;
103
+ }
104
+
105
+ /**
106
+ * Get a string containing the version of the library.
107
+ *
108
+ * @return string
109
+ */
110
+ public function getLibraryVersion()
111
+ {
112
+ return self::LIBVER;
113
+ }
114
+
115
+ /**
116
+ * Attempt to exchange a code for an valid authentication token.
117
+ * If $crossClient is set to true, the request body will not include
118
+ * the request_uri argument
119
+ * Helper wrapped around the OAuth 2.0 implementation.
120
+ *
121
+ * @param $code string code from accounts.google.com
122
+ * @param $crossClient boolean, whether this is a cross-client authentication
123
+ * @return string token
124
+ */
125
+ public function authenticate($code, $crossClient = false)
126
+ {
127
+ $this->authenticated = true;
128
+ return $this->getAuth()->authenticate($code, $crossClient);
129
+ }
130
+
131
+ /**
132
+ * Loads a service account key and parameters from a JSON
133
+ * file from the Google Developer Console. Uses that and the
134
+ * given array of scopes to return an assertion credential for
135
+ * use with refreshTokenWithAssertionCredential.
136
+ *
137
+ * @param string $jsonLocation File location of the project-key.json.
138
+ * @param array $scopes The scopes to assert.
139
+ * @return Google_Auth_AssertionCredentials.
140
+ * @
141
+ */
142
+ public function loadServiceAccountJson($jsonLocation, $scopes)
143
+ {
144
+ $data = json_decode(file_get_contents($jsonLocation));
145
+ if (isset($data->type) && $data->type == 'service_account') {
146
+ // Service Account format.
147
+ $cred = new Google_Auth_AssertionCredentials(
148
+ $data->client_email,
149
+ $scopes,
150
+ $data->private_key
151
+ );
152
+ return $cred;
153
+ } else {
154
+ throw new Google_Exception("Invalid service account JSON file.");
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Set the auth config from the JSON string provided.
160
+ * This structure should match the file downloaded from
161
+ * the "Download JSON" button on in the Google Developer
162
+ * Console.
163
+ * @param string $json the configuration json
164
+ * @throws Google_Exception
165
+ */
166
+ public function setAuthConfig($json)
167
+ {
168
+ $data = json_decode($json);
169
+ $key = isset($data->installed) ? 'installed' : 'web';
170
+ if (!isset($data->$key)) {
171
+ throw new Google_Exception("Invalid client secret JSON file.");
172
+ }
173
+ $this->setClientId($data->$key->client_id);
174
+ $this->setClientSecret($data->$key->client_secret);
175
+ if (isset($data->$key->redirect_uris)) {
176
+ $this->setRedirectUri($data->$key->redirect_uris[0]);
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Set the auth config from the JSON file in the path
182
+ * provided. This should match the file downloaded from
183
+ * the "Download JSON" button on in the Google Developer
184
+ * Console.
185
+ * @param string $file the file location of the client json
186
+ */
187
+ public function setAuthConfigFile($file)
188
+ {
189
+ $this->setAuthConfig(file_get_contents($file));
190
+ }
191
+
192
+ /**
193
+ * @throws Google_Auth_Exception
194
+ * @return array
195
+ * @visible For Testing
196
+ */
197
+ public function prepareScopes()
198
+ {
199
+ if (empty($this->requestedScopes)) {
200
+ throw new Google_Auth_Exception("No scopes specified");
201
+ }
202
+ $scopes = implode(' ', $this->requestedScopes);
203
+ return $scopes;
204
+ }
205
+
206
+ /**
207
+ * Set the OAuth 2.0 access token using the string that resulted from calling createAuthUrl()
208
+ * or Google_Client#getAccessToken().
209
+ * @param string $accessToken JSON encoded string containing in the following format:
210
+ * {"access_token":"TOKEN", "refresh_token":"TOKEN", "token_type":"Bearer",
211
+ * "expires_in":3600, "id_token":"TOKEN", "created":1320790426}
212
+ */
213
+ public function setAccessToken($accessToken)
214
+ {
215
+ if ($accessToken == 'null') {
216
+ $accessToken = null;
217
+ }
218
+ $this->getAuth()->setAccessToken($accessToken);
219
+ }
220
+
221
+
222
+
223
+ /**
224
+ * Set the authenticator object
225
+ * @param Google_Auth_Abstract $auth
226
+ */
227
+ public function setAuth(Google_Auth_Abstract $auth)
228
+ {
229
+ $this->config->setAuthClass(get_class($auth));
230
+ $this->auth = $auth;
231
+ }
232
+
233
+ /**
234
+ * Set the IO object
235
+ * @param Google_IO_Abstract $io
236
+ */
237
+ public function setIo(Google_IO_Abstract $io)
238
+ {
239
+ $this->config->setIoClass(get_class($io));
240
+ $this->io = $io;
241
+ }
242
+
243
+ /**
244
+ * Set the Cache object
245
+ * @param Google_Cache_Abstract $cache
246
+ */
247
+ public function setCache(Google_Cache_Abstract $cache)
248
+ {
249
+ $this->config->setCacheClass(get_class($cache));
250
+ $this->cache = $cache;
251
+ }
252
+
253
+ /**
254
+ * Set the Logger object
255
+ * @param Google_Logger_Abstract $logger
256
+ */
257
+ public function setLogger(Google_Logger_Abstract $logger)
258
+ {
259
+ $this->config->setLoggerClass(get_class($logger));
260
+ $this->logger = $logger;
261
+ }
262
+
263
+ /**
264
+ * Construct the OAuth 2.0 authorization request URI.
265
+ * @return string
266
+ */
267
+ public function createAuthUrl()
268
+ {
269
+ $scopes = $this->prepareScopes();
270
+ return $this->getAuth()->createAuthUrl($scopes);
271
+ }
272
+
273
+ /**
274
+ * Get the OAuth 2.0 access token.
275
+ * @return string $accessToken JSON encoded string in the following format:
276
+ * {"access_token":"TOKEN", "refresh_token":"TOKEN", "token_type":"Bearer",
277
+ * "expires_in":3600,"id_token":"TOKEN", "created":1320790426}
278
+ */
279
+ public function getAccessToken()
280
+ {
281
+ $token = $this->getAuth()->getAccessToken();
282
+ // The response is json encoded, so could be the string null.
283
+ // It is arguable whether this check should be here or lower
284
+ // in the library.
285
+ return (null == $token || 'null' == $token || '[]' == $token) ? null : $token;
286
+ }
287
+
288
+ /**
289
+ * Get the OAuth 2.0 refresh token.
290
+ * @return string $refreshToken refresh token or null if not available
291
+ */
292
+ public function getRefreshToken()
293
+ {
294
+ return $this->getAuth()->getRefreshToken();
295
+ }
296
+
297
+ /**
298
+ * Returns if the access_token is expired.
299
+ * @return bool Returns True if the access_token is expired.
300
+ */
301
+ public function isAccessTokenExpired()
302
+ {
303
+ return $this->getAuth()->isAccessTokenExpired();
304
+ }
305
+
306
+ /**
307
+ * Set OAuth 2.0 "state" parameter to achieve per-request customization.
308
+ * @see http://tools.ietf.org/html/draft-ietf-oauth-v2-22#section-3.1.2.2
309
+ * @param string $state
310
+ */
311
+ public function setState($state)
312
+ {
313
+ $this->getAuth()->setState($state);
314
+ }
315
+
316
+ /**
317
+ * @param string $accessType Possible values for access_type include:
318
+ * {@code "offline"} to request offline access from the user.
319
+ * {@code "online"} to request online access from the user.
320
+ */
321
+ public function setAccessType($accessType)
322
+ {
323
+ $this->config->setAccessType($accessType);
324
+ }
325
+
326
+ /**
327
+ * @param string $approvalPrompt Possible values for approval_prompt include:
328
+ * {@code "force"} to force the approval UI to appear. (This is the default value)
329
+ * {@code "auto"} to request auto-approval when possible.
330
+ */
331
+ public function setApprovalPrompt($approvalPrompt)
332
+ {
333
+ $this->config->setApprovalPrompt($approvalPrompt);
334
+ }
335
+
336
+ /**
337
+ * Set the login hint, email address or sub id.
338
+ * @param string $loginHint
339
+ */
340
+ public function setLoginHint($loginHint)
341
+ {
342
+ $this->config->setLoginHint($loginHint);
343
+ }
344
+
345
+ /**
346
+ * Set the application name, this is included in the User-Agent HTTP header.
347
+ * @param string $applicationName
348
+ */
349
+ public function setApplicationName($applicationName)
350
+ {
351
+ $this->config->setApplicationName($applicationName);
352
+ }
353
+
354
+ /**
355
+ * Set the OAuth 2.0 Client ID.
356
+ * @param string $clientId
357
+ */
358
+ public function setClientId($clientId)
359
+ {
360
+ $this->config->setClientId($clientId);
361
+ }
362
+
363
+ /**
364
+ * Set the OAuth 2.0 Client Secret.
365
+ * @param string $clientSecret
366
+ */
367
+ public function setClientSecret($clientSecret)
368
+ {
369
+ $this->config->setClientSecret($clientSecret);
370
+ }
371
+
372
+ /**
373
+ * Set the OAuth 2.0 Redirect URI.
374
+ * @param string $redirectUri
375
+ */
376
+ public function setRedirectUri($redirectUri)
377
+ {
378
+ $this->config->setRedirectUri($redirectUri);
379
+ }
380
+
381
+ /**
382
+ * If 'plus.login' is included in the list of requested scopes, you can use
383
+ * this method to define types of app activities that your app will write.
384
+ * You can find a list of available types here:
385
+ * @link https://developers.google.com/+/api/moment-types
386
+ *
387
+ * @param array $requestVisibleActions Array of app activity types
388
+ */
389
+ public function setRequestVisibleActions($requestVisibleActions)
390
+ {
391
+ if (is_array($requestVisibleActions)) {
392
+ $requestVisibleActions = join(" ", $requestVisibleActions);
393
+ }
394
+ $this->config->setRequestVisibleActions($requestVisibleActions);
395
+ }
396
+
397
+ /**
398
+ * Set the developer key to use, these are obtained through the API Console.
399
+ * @see http://code.google.com/apis/console-help/#generatingdevkeys
400
+ * @param string $developerKey
401
+ */
402
+ public function setDeveloperKey($developerKey)
403
+ {
404
+ $this->config->setDeveloperKey($developerKey);
405
+ }
406
+
407
+ /**
408
+ * Set the hd (hosted domain) parameter streamlines the login process for
409
+ * Google Apps hosted accounts. By including the domain of the user, you
410
+ * restrict sign-in to accounts at that domain.
411
+ * @param $hd string - the domain to use.
412
+ */
413
+ public function setHostedDomain($hd)
414
+ {
415
+ $this->config->setHostedDomain($hd);
416
+ }
417
+
418
+ /**
419
+ * Set the prompt hint. Valid values are none, consent and select_account.
420
+ * If no value is specified and the user has not previously authorized
421
+ * access, then the user is shown a consent screen.
422
+ * @param $prompt string
423
+ */
424
+ public function setPrompt($prompt)
425
+ {
426
+ $this->config->setPrompt($prompt);
427
+ }
428
+
429
+ /**
430
+ * openid.realm is a parameter from the OpenID 2.0 protocol, not from OAuth
431
+ * 2.0. It is used in OpenID 2.0 requests to signify the URL-space for which
432
+ * an authentication request is valid.
433
+ * @param $realm string - the URL-space to use.
434
+ */
435
+ public function setOpenidRealm($realm)
436
+ {
437
+ $this->config->setOpenidRealm($realm);
438
+ }
439
+
440
+ /**
441
+ * If this is provided with the value true, and the authorization request is
442
+ * granted, the authorization will include any previous authorizations
443
+ * granted to this user/application combination for other scopes.
444
+ * @param $include boolean - the URL-space to use.
445
+ */
446
+ public function setIncludeGrantedScopes($include)
447
+ {
448
+ $this->config->setIncludeGrantedScopes($include);
449
+ }
450
+
451
+ /**
452
+ * Fetches a fresh OAuth 2.0 access token with the given refresh token.
453
+ * @param string $refreshToken
454
+ */
455
+ public function refreshToken($refreshToken)
456
+ {
457
+ $this->getAuth()->refreshToken($refreshToken);
458
+ }
459
+
460
+ /**
461
+ * Revoke an OAuth2 access token or refresh token. This method will revoke the current access
462
+ * token, if a token isn't provided.
463
+ * @throws Google_Auth_Exception
464
+ * @param string|null $token The token (access token or a refresh token) that should be revoked.
465
+ * @return boolean Returns True if the revocation was successful, otherwise False.
466
+ */
467
+ public function revokeToken($token = null)
468
+ {
469
+ return $this->getAuth()->revokeToken($token);
470
+ }
471
+
472
+ /**
473
+ * Verify an id_token. This method will verify the current id_token, if one
474
+ * isn't provided.
475
+ * @throws Google_Auth_Exception
476
+ * @param string|null $token The token (id_token) that should be verified.
477
+ * @return Google_Auth_LoginTicket Returns an apiLoginTicket if the verification was
478
+ * successful.
479
+ */
480
+ public function verifyIdToken($token = null)
481
+ {
482
+ return $this->getAuth()->verifyIdToken($token);
483
+ }
484
+
485
+ /**
486
+ * Verify a JWT that was signed with your own certificates.
487
+ *
488
+ * @param $id_token string The JWT token
489
+ * @param $cert_location array of certificates
490
+ * @param $audience string the expected consumer of the token
491
+ * @param $issuer string the expected issuer, defaults to Google
492
+ * @param [$max_expiry] the max lifetime of a token, defaults to MAX_TOKEN_LIFETIME_SECS
493
+ * @return mixed token information if valid, false if not
494
+ */
495
+ public function verifySignedJwt($id_token, $cert_location, $audience, $issuer, $max_expiry = null)
496
+ {
497
+ $auth = new Google_Auth_OAuth2($this);
498
+ $certs = $auth->retrieveCertsFromLocation($cert_location);
499
+ return $auth->verifySignedJwtWithCerts($id_token, $certs, $audience, $issuer, $max_expiry);
500
+ }
501
+
502
+ /**
503
+ * @param $creds Google_Auth_AssertionCredentials
504
+ */
505
+ public function setAssertionCredentials(Google_Auth_AssertionCredentials $creds)
506
+ {
507
+ $this->getAuth()->setAssertionCredentials($creds);
508
+ }
509
+
510
+ /**
511
+ * Set the scopes to be requested. Must be called before createAuthUrl().
512
+ * Will remove any previously configured scopes.
513
+ * @param array $scopes, ie: array('https://www.googleapis.com/auth/plus.login',
514
+ * 'https://www.googleapis.com/auth/moderator')
515
+ */
516
+ public function setScopes($scopes)
517
+ {
518
+ $this->requestedScopes = array();
519
+ $this->addScope($scopes);
520
+ }
521
+
522
+ /**
523
+ * This functions adds a scope to be requested as part of the OAuth2.0 flow.
524
+ * Will append any scopes not previously requested to the scope parameter.
525
+ * A single string will be treated as a scope to request. An array of strings
526
+ * will each be appended.
527
+ * @param $scope_or_scopes string|array e.g. "profile"
528
+ */
529
+ public function addScope($scope_or_scopes)
530
+ {
531
+ if (is_string($scope_or_scopes) && !in_array($scope_or_scopes, $this->requestedScopes)) {
532
+ $this->requestedScopes[] = $scope_or_scopes;
533
+ } else if (is_array($scope_or_scopes)) {
534
+ foreach ($scope_or_scopes as $scope) {
535
+ $this->addScope($scope);
536
+ }
537
+ }
538
+ }
539
+
540
+ /**
541
+ * Returns the list of scopes requested by the client
542
+ * @return array the list of scopes
543
+ *
544
+ */
545
+ public function getScopes()
546
+ {
547
+ return $this->requestedScopes;
548
+ }
549
+
550
+ /**
551
+ * Declare whether batch calls should be used. This may increase throughput
552
+ * by making multiple requests in one connection.
553
+ *
554
+ * @param boolean $useBatch True if the batch support should
555
+ * be enabled. Defaults to False.
556
+ */
557
+ public function setUseBatch($useBatch)
558
+ {
559
+ // This is actually an alias for setDefer.
560
+ $this->setDefer($useBatch);
561
+ }
562
+
563
+ /**
564
+ * Declare whether making API calls should make the call immediately, or
565
+ * return a request which can be called with ->execute();
566
+ *
567
+ * @param boolean $defer True if calls should not be executed right away.
568
+ */
569
+ public function setDefer($defer)
570
+ {
571
+ $this->deferExecution = $defer;
572
+ }
573
+
574
+ /**
575
+ * Helper method to execute deferred HTTP requests.
576
+ *
577
+ * @param $request Google_Http_Request|Google_Http_Batch
578
+ * @throws Google_Exception
579
+ * @return object of the type of the expected class or array.
580
+ */
581
+ public function execute($request)
582
+ {
583
+ if ($request instanceof Google_Http_Request) {
584
+ $request->setUserAgent(
585
+ $this->getApplicationName()
586
+ . " " . self::USER_AGENT_SUFFIX
587
+ . $this->getLibraryVersion()
588
+ );
589
+ if (!$this->getClassConfig("Google_Http_Request", "disable_gzip")) {
590
+ $request->enableGzip();
591
+ }
592
+ $request->maybeMoveParametersToBody();
593
+ return Google_Http_REST::execute($this, $request);
594
+ } else if ($request instanceof Google_Http_Batch) {
595
+ return $request->execute();
596
+ } else {
597
+ throw new Google_Exception("Do not know how to execute this type of object.");
598
+ }
599
+ }
600
+
601
+ /**
602
+ * Whether or not to return raw requests
603
+ * @return boolean
604
+ */
605
+ public function shouldDefer()
606
+ {
607
+ return $this->deferExecution;
608
+ }
609
+
610
+ /**
611
+ * @return Google_Auth_Abstract Authentication implementation
612
+ */
613
+ public function getAuth()
614
+ {
615
+ if (!isset($this->auth)) {
616
+ $class = $this->config->getAuthClass();
617
+ $this->auth = new $class($this);
618
+ }
619
+ return $this->auth;
620
+ }
621
+
622
+ /**
623
+ * @return Google_IO_Abstract IO implementation
624
+ */
625
+ public function getIo()
626
+ {
627
+ if (!isset($this->io)) {
628
+ $class = $this->config->getIoClass();
629
+ $this->io = new $class($this);
630
+ }
631
+ return $this->io;
632
+ }
633
+
634
+ /**
635
+ * @return Google_Cache_Abstract Cache implementation
636
+ */
637
+ public function getCache()
638
+ {
639
+ if (!isset($this->cache)) {
640
+ $class = $this->config->getCacheClass();
641
+ $this->cache = new $class($this);
642
+ }
643
+ return $this->cache;
644
+ }
645
+
646
+ /**
647
+ * @return Google_Logger_Abstract Logger implementation
648
+ */
649
+ public function getLogger()
650
+ {
651
+ if (!isset($this->logger)) {
652
+ $class = $this->config->getLoggerClass();
653
+ $this->logger = new $class($this);
654
+ }
655
+ return $this->logger;
656
+ }
657
+
658
+ /**
659
+ * Retrieve custom configuration for a specific class.
660
+ * @param $class string|object - class or instance of class to retrieve
661
+ * @param $key string optional - key to retrieve
662
+ * @return array
663
+ */
664
+ public function getClassConfig($class, $key = null)
665
+ {
666
+ if (!is_string($class)) {
667
+ $class = get_class($class);
668
+ }
669
+ return $this->config->getClassConfig($class, $key);
670
+ }
671
+
672
+ /**
673
+ * Set configuration specific to a given class.
674
+ * $config->setClassConfig('Google_Cache_File',
675
+ * array('directory' => '/tmp/cache'));
676
+ * @param $class string|object - The class name for the configuration
677
+ * @param $config string key or an array of configuration values
678
+ * @param $value string optional - if $config is a key, the value
679
+ *
680
+ */
681
+ public function setClassConfig($class, $config, $value = null)
682
+ {
683
+ if (!is_string($class)) {
684
+ $class = get_class($class);
685
+ }
686
+ $this->config->setClassConfig($class, $config, $value);
687
+
688
+ }
689
+
690
+ /**
691
+ * @return string the base URL to use for calls to the APIs
692
+ */
693
+ public function getBasePath()
694
+ {
695
+ return $this->config->getBasePath();
696
+ }
697
+
698
+ /**
699
+ * @return string the name of the application
700
+ */
701
+ public function getApplicationName()
702
+ {
703
+ return $this->config->getApplicationName();
704
+ }
705
+
706
+ /**
707
+ * Are we running in Google AppEngine?
708
+ * return bool
709
+ */
710
+ public function isAppEngine()
711
+ {
712
+ return (isset($_SERVER['SERVER_SOFTWARE']) &&
713
+ strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine') !== false);
714
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
715
  }
tools/src/Google/Collection.php CHANGED
@@ -1,5 +1,8 @@
1
  <?php
2
- require_once realpath(dirname(__FILE__) . '/../../autoload.php');
 
 
 
3
 
4
  /**
5
  * Extension to the regular Google_Model that automatically
@@ -8,86 +11,91 @@ require_once realpath(dirname(__FILE__) . '/../../autoload.php');
8
  */
9
  class Google_Collection extends Google_Model implements Iterator, Countable
10
  {
 
11
 
12
- protected $collection_key = 'items';
13
-
14
- public function rewind()
15
- {
16
- if (isset($this->modelData[$this->collection_key]) && is_array($this->modelData[$this->collection_key])) {
17
- reset($this->modelData[$this->collection_key]);
18
- }
19
  }
 
20
 
21
- public function current()
22
- {
23
- $this->coerceType($this->key());
24
- if (is_array($this->modelData[$this->collection_key])) {
25
- return current($this->modelData[$this->collection_key]);
26
- }
27
  }
 
28
 
29
- public function key()
30
- {
31
- if (isset($this->modelData[$this->collection_key]) && is_array($this->modelData[$this->collection_key])) {
32
- return key($this->modelData[$this->collection_key]);
33
- }
34
  }
 
35
 
36
- public function next()
37
- {
38
- return next($this->modelData[$this->collection_key]);
39
- }
40
 
41
- public function valid()
42
- {
43
- $key = $this->key();
44
- return $key !== null && $key !== false;
45
- }
46
 
47
- public function count()
48
- {
49
- return count($this->modelData[$this->collection_key]);
 
50
  }
 
 
51
 
52
- public function offsetExists($offset)
53
- {
54
- if (! is_numeric($offset)) {
55
- return parent::offsetExists($offset);
56
- }
57
- return isset($this->modelData[$this->collection_key][$offset]);
58
  }
 
 
59
 
60
- public function offsetGet($offset)
61
- {
62
- if (! is_numeric($offset)) {
63
- return parent::offsetGet($offset);
64
- }
65
- $this->coerceType($offset);
66
- return $this->modelData[$this->collection_key][$offset];
67
  }
 
 
 
68
 
69
- public function offsetSet($offset, $value)
70
- {
71
- if (! is_numeric($offset)) {
72
- return parent::offsetSet($offset, $value);
73
- }
74
- $this->modelData[$this->collection_key][$offset] = $value;
75
  }
 
 
76
 
77
- public function offsetUnset($offset)
78
- {
79
- if (! is_numeric($offset)) {
80
- return parent::offsetUnset($offset);
81
- }
82
- unset($this->modelData[$this->collection_key][$offset]);
83
  }
 
 
84
 
85
- private function coerceType($offset)
86
- {
87
- $typeKey = $this->keyType($this->collection_key);
88
- if (isset($this->$typeKey) && ! is_object($this->modelData[$this->collection_key][$offset])) {
89
- $type = $this->$typeKey;
90
- $this->modelData[$this->collection_key][$offset] = new $type($this->modelData[$this->collection_key][$offset]);
91
- }
92
  }
 
93
  }
1
  <?php
2
+
3
+ if (!class_exists('Google_Client')) {
4
+ require_once dirname(__FILE__) . '/autoload.php';
5
+ }
6
 
7
  /**
8
  * Extension to the regular Google_Model that automatically
11
  */
12
  class Google_Collection extends Google_Model implements Iterator, Countable
13
  {
14
+ protected $collection_key = 'items';
15
 
16
+ public function rewind()
17
+ {
18
+ if (isset($this->modelData[$this->collection_key])
19
+ && is_array($this->modelData[$this->collection_key])) {
20
+ reset($this->modelData[$this->collection_key]);
 
 
21
  }
22
+ }
23
 
24
+ public function current()
25
+ {
26
+ $this->coerceType($this->key());
27
+ if (is_array($this->modelData[$this->collection_key])) {
28
+ return current($this->modelData[$this->collection_key]);
 
29
  }
30
+ }
31
 
32
+ public function key()
33
+ {
34
+ if (isset($this->modelData[$this->collection_key])
35
+ && is_array($this->modelData[$this->collection_key])) {
36
+ return key($this->modelData[$this->collection_key]);
37
  }
38
+ }
39
 
40
+ public function next()
41
+ {
42
+ return next($this->modelData[$this->collection_key]);
43
+ }
44
 
45
+ public function valid()
46
+ {
47
+ $key = $this->key();
48
+ return $key !== null && $key !== false;
49
+ }
50
 
51
+ public function count()
52
+ {
53
+ if (!isset($this->modelData[$this->collection_key])) {
54
+ return 0;
55
  }
56
+ return count($this->modelData[$this->collection_key]);
57
+ }
58
 
59
+ public function offsetExists($offset)
60
+ {
61
+ if (!is_numeric($offset)) {
62
+ return parent::offsetExists($offset);
 
 
63
  }
64
+ return isset($this->modelData[$this->collection_key][$offset]);
65
+ }
66
 
67
+ public function offsetGet($offset)
68
+ {
69
+ if (!is_numeric($offset)) {
70
+ return parent::offsetGet($offset);
 
 
 
71
  }
72
+ $this->coerceType($offset);
73
+ return $this->modelData[$this->collection_key][$offset];
74
+ }
75
 
76
+ public function offsetSet($offset, $value)
77
+ {
78
+ if (!is_numeric($offset)) {
79
+ return parent::offsetSet($offset, $value);
 
 
80
  }
81
+ $this->modelData[$this->collection_key][$offset] = $value;
82
+ }
83
 
84
+ public function offsetUnset($offset)
85
+ {
86
+ if (!is_numeric($offset)) {
87
+ return parent::offsetUnset($offset);
 
 
88
  }
89
+ unset($this->modelData[$this->collection_key][$offset]);
90
+ }
91
 
92
+ private function coerceType($offset)
93
+ {
94
+ $typeKey = $this->keyType($this->collection_key);
95
+ if (isset($this->$typeKey) && !is_object($this->modelData[$this->collection_key][$offset])) {
96
+ $type = $this->$typeKey;
97
+ $this->modelData[$this->collection_key][$offset] =
98
+ new $type($this->modelData[$this->collection_key][$offset]);
99
  }
100
+ }
101
  }
tools/src/Google/Config.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /*
4
  * Copyright 2010 Google Inc.
5
  *
@@ -7,7 +6,7 @@
7
  * you may not use this file except in compliance with the License.
8
  * You may obtain a copy of the License at
9
  *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
  *
12
  * Unless required by applicable law or agreed to in writing, software
13
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,433 +14,443 @@
15
  * See the License for the specific language governing permissions and
16
  * limitations under the License.
17
  */
 
18
  /**
19
  * A class to contain the library configuration for the Google API client.
20
  */
21
  class Google_Config
22
  {
23
-
24
- const GZIP_DISABLED = true;
25
-
26
- const GZIP_ENABLED = false;
27
-
28
- const GZIP_UPLOADS_ENABLED = true;
29
-
30
- const GZIP_UPLOADS_DISABLED = false;
31
-
32
- const USE_AUTO_IO_SELECTION = "auto";
33
-
34
- protected $configuration;
35
-
36
- /**
37
- * Create a new Google_Config.
38
- * Can accept an ini file location with the
39
- * local configuration. For example:
40
- * application_name="My App"
41
- *
42
- * @param
43
- * [$ini_file_location] - optional - The location of the ini file to load
44
- */
45
- public function __construct($ini_file_location = null)
46
- {
47
- $this->configuration = array(
48
- // The application_name is included in the User-Agent HTTP header.
49
- 'application_name' => '',
50
- // Which Authentication, Storage and HTTP IO classes to use.
51
- 'auth_class' => 'Google_Auth_OAuth2',
52
- 'io_class' => self::USE_AUTO_IO_SELECTION,
53
- 'cache_class' => 'Google_Cache_File',
54
- 'logger_class' => 'Google_Logger_Null',
55
- // Don't change these unless you're working against a special development
56
- // or testing environment.
57
- 'base_path' => 'https://www.googleapis.com',
58
- // Definition of class specific values, like file paths and so on.
59
- 'classes' => array(
60
- 'Google_IO_Abstract' => array(
61
- 'request_timeout_seconds' => 100
62
- ),
63
- 'Google_Logger_Abstract' => array(
64
- 'level' => 'debug',
65
- 'log_format' => "[%datetime%] %level%: %message% %context%\n",
66
- 'date_format' => 'd/M/Y:H:i:s O',
67
- 'allow_newlines' => true
68
- ),
69
- 'Google_Logger_File' => array(
70
- 'file' => 'php://stdout',
71
- 'mode' => 0640,
72
- 'lock' => false
73
- ),
74
- 'Google_Http_Request' => array(
75
- // Disable the use of gzip on calls if set to true. Defaults to false.
76
- 'disable_gzip' => self::GZIP_ENABLED,
77
- // We default gzip to disabled on uploads even if gzip is otherwise
78
- // enabled, due to some issues seen with small packet sizes for uploads.
79
- // Please test with this option before enabling gzip for uploads in
80
- // a production environment.
81
- 'enable_gzip_for_uploads' => self::GZIP_UPLOADS_DISABLED
82
- ),
83
- // If you want to pass in OAuth 2.0 settings, they will need to be
84
- // structured like this.
85
- 'Google_Auth_OAuth2' => array(
86
- // Keys for OAuth 2.0 access, see the API console at
87
- // https://developers.google.com/console
88
- 'client_id' => '',
89
- 'client_secret' => '',
90
- 'redirect_uri' => '',
91
- // Simple API access key, also from the API console. Ensure you get
92
- // a Server key, and not a Browser key.
93
- 'developer_key' => '',
94
- // Other parameters.
95
- 'hd' => '',
96
- 'prompt' => '',
97
- 'openid.realm' => '',
98
- 'include_granted_scopes' => '',
99
- 'login_hint' => '',
100
- 'request_visible_actions' => '',
101
- 'access_type' => 'online',
102
- 'approval_prompt' => 'auto',
103
- 'federated_signon_certs_url' => 'https://www.googleapis.com/oauth2/v1/certs'
104
- ),
105
- // Set a default directory for the file cache.
106
- 'Google_Cache_File' => array(
107
- 'directory' => sys_get_temp_dir() . '/Google_Client'
108
- )
109
- )
110
- );
111
- if ($ini_file_location) {
112
- $ini = parse_ini_file($ini_file_location, true);
113
- if (is_array($ini) && count($ini)) {
114
- $merged_configuration = $ini + $this->configuration;
115
- if (isset($ini['classes']) && isset($this->configuration['classes'])) {
116
- $merged_configuration['classes'] = $ini['classes'] + $this->configuration['classes'];
117
- }
118
- $this->configuration = $merged_configuration;
119
- }
120
- }
121
- }
122
-
123
- /**
124
- * Set configuration specific to a given class.
125
- * $config->setClassConfig('Google_Cache_File',
126
- * array('directory' => '/tmp/cache'));
127
- *
128
- * @param $class string
129
- * The class name for the configuration
130
- * @param $config string
131
- * key or an array of configuration values
132
- * @param $value string
133
- * optional - if $config is a key, the value
134
- */
135
- public function setClassConfig($class, $config, $value = null)
136
- {
137
- if (! is_array($config)) {
138
- if (! isset($this->configuration['classes'][$class])) {
139
- $this->configuration['classes'][$class] = array();
140
- }
141
- $this->configuration['classes'][$class][$config] = $value;
142
- } else {
143
- $this->configuration['classes'][$class] = $config;
144
- }
145
- }
146
-
147
- public function getClassConfig($class, $key = null)
148
- {
149
- if (! isset($this->configuration['classes'][$class])) {
150
- return null;
151
- }
152
- if ($key === null) {
153
- return $this->configuration['classes'][$class];
154
- } else {
155
- return $this->configuration['classes'][$class][$key];
156
- }
157
- }
158
-
159
- /**
160
- * Return the configured cache class.
161
- *
162
- * @return string
163
- */
164
- public function getCacheClass()
165
- {
166
- return $this->configuration['cache_class'];
167
- }
168
-
169
- /**
170
- * Return the configured logger class.
171
- *
172
- * @return string
173
- */
174
- public function getLoggerClass()
175
- {
176
- return $this->configuration['logger_class'];
177
- }
178
-
179
- /**
180
- * Return the configured Auth class.
181
- *
182
- * @return string
183
- */
184
- public function getAuthClass()
185
- {
186
- return $this->configuration['auth_class'];
187
- }
188
-
189
- /**
190
- * Set the auth class.
191
- *
192
- * @param $class string
193
- * the class name to set
194
- */
195
- public function setAuthClass($class)
196
- {
197
- $prev = $this->configuration['auth_class'];
198
- if (! isset($this->configuration['classes'][$class]) && isset($this->configuration['classes'][$prev])) {
199
- $this->configuration['classes'][$class] = $this->configuration['classes'][$prev];
200
- }
201
- $this->configuration['auth_class'] = $class;
202
- }
203
-
204
- /**
205
- * Set the IO class.
206
- *
207
- * @param $class string
208
- * the class name to set
209
- */
210
- public function setIoClass($class)
211
- {
212
- $prev = $this->configuration['io_class'];
213
- if (! isset($this->configuration['classes'][$class]) && isset($this->configuration['classes'][$prev])) {
214
- $this->configuration['classes'][$class] = $this->configuration['classes'][$prev];
215
- }
216
- $this->configuration['io_class'] = $class;
217
- }
218
-
219
- /**
220
- * Set the cache class.
221
- *
222
- * @param $class string
223
- * the class name to set
224
- */
225
- public function setCacheClass($class)
226
- {
227
- $prev = $this->configuration['cache_class'];
228
- if (! isset($this->configuration['classes'][$class]) && isset($this->configuration['classes'][$prev])) {
229
- $this->configuration['classes'][$class] = $this->configuration['classes'][$prev];
230
- }
231
- $this->configuration['cache_class'] = $class;
232
- }
233
-
234
- /**
235
- * Set the logger class.
236
- *
237
- * @param $class string
238
- * the class name to set
239
- */
240
- public function setLoggerClass($class)
241
- {
242
- $prev = $this->configuration['logger_class'];
243
- if (! isset($this->configuration['classes'][$class]) && isset($this->configuration['classes'][$prev])) {
244
- $this->configuration['classes'][$class] = $this->configuration['classes'][$prev];
245
  }
246
- $this->configuration['logger_class'] = $class;
247
- }
248
-
249
- /**
250
- * Return the configured IO class.
251
- *
252
- * @return string
253
- */
254
- public function getIoClass()
255
- {
256
- return $this->configuration['io_class'];
257
- }
258
-
259
- /**
260
- * Set the application name, this is included in the User-Agent HTTP header.
261
- *
262
- * @param string $name
263
- */
264
- public function setApplicationName($name)
265
- {
266
- $this->configuration['application_name'] = $name;
267
- }
268
-
269
- /**
270
- *
271
- * @return string the name of the application
272
- */
273
- public function getApplicationName()
274
- {
275
- return $this->configuration['application_name'];
276
  }
277
-
278
- /**
279
- * Set the client ID for the auth class.
280
- *
281
- * @param $clientId string
282
- * - the API console client ID
283
- */
284
- public function setClientId($clientId)
285
- {
286
- $this->setAuthConfig('client_id', $clientId);
 
 
 
 
 
 
 
 
 
287
  }
 
288
 
289
- /**
290
- * Set the client secret for the auth class.
291
- *
292
- * @param $secret string
293
- * - the API console client secret
294
- */
295
- public function setClientSecret($secret)
296
- {
297
- $this->setAuthConfig('client_secret', $secret);
298
  }
299
-
300
- /**
301
- * Set the redirect uri for the auth class.
302
- * Note that if using the
303
- * Javascript based sign in flow, this should be the string 'postmessage'.
304
- *
305
- * @param $uri string
306
- * - the URI that users should be redirected to
307
- */
308
- public function setRedirectUri($uri)
309
- {
310
- $this->setAuthConfig('redirect_uri', $uri);
311
  }
312
-
313
- /**
314
- * Set the app activities for the auth class.
315
- *
316
- * @param $rva string
317
- * a space separated list of app activity types
318
- */
319
- public function setRequestVisibleActions($rva)
320
- {
321
- $this->setAuthConfig('request_visible_actions', $rva);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  }
323
-
324
- /**
325
- * Set the the access type requested (offline or online.)
326
- *
327
- * @param $access string
328
- * - the access type
329
- */
330
- public function setAccessType($access)
331
- {
332
- $this->setAuthConfig('access_type', $access);
 
 
 
 
 
333
  }
334
-
335
- /**
336
- * Set when to show the approval prompt (auto or force)
337
- *
338
- * @param $approval string
339
- * - the approval request
340
- */
341
- public function setApprovalPrompt($approval)
342
- {
343
- $this->setAuthConfig('approval_prompt', $approval);
 
 
 
 
 
344
  }
345
-
346
- /**
347
- * Set the login hint (email address or sub identifier)
348
- *
349
- * @param $hint string
350
- */
351
- public function setLoginHint($hint)
352
- {
353
- $this->setAuthConfig('login_hint', $hint);
 
 
 
 
 
 
354
  }
355
-
356
- /**
357
- * Set the developer key for the auth class.
358
- * Note that this is separate value
359
- * from the client ID - if it looks like a URL, its a client ID!
360
- *
361
- * @param $key string
362
- * - the API console developer key
363
- */
364
- public function setDeveloperKey($key)
365
- {
366
- $this->setAuthConfig('developer_key', $key);
367
- }
368
-
369
- /**
370
- * Set the hd (hosted domain) parameter streamlines the login process for
371
- * Google Apps hosted accounts.
372
- * By including the domain of the user, you
373
- * restrict sign-in to accounts at that domain.
374
- *
375
- * @param $hd string
376
- * - the domain to use.
377
- */
378
- public function setHostedDomain($hd)
379
- {
380
- $this->setAuthConfig('hd', $hd);
381
- }
382
-
383
- /**
384
- * Set the prompt hint.
385
- * Valid values are none, consent and select_account.
386
- * If no value is specified and the user has not previously authorized
387
- * access, then the user is shown a consent screen.
388
- *
389
- * @param $prompt string
390
- */
391
- public function setPrompt($prompt)
392
- {
393
- $this->setAuthConfig('prompt', $prompt);
394
- }
395
-
396
- /**
397
- * openid.realm is a parameter from the OpenID 2.0 protocol, not from OAuth
398
- * 2.0.
399
- * It is used in OpenID 2.0 requests to signify the URL-space for which
400
- * an authentication request is valid.
401
- *
402
- * @param $realm string
403
- * - the URL-space to use.
404
- */
405
- public function setOpenidRealm($realm)
406
- {
407
- $this->setAuthConfig('openid.realm', $realm);
408
- }
409
-
410
- /**
411
- * If this is provided with the value true, and the authorization request is
412
- * granted, the authorization will include any previous authorizations
413
- * granted to this user/application combination for other scopes.
414
- *
415
- * @param $include boolean
416
- * - the URL-space to use.
417
- */
418
- public function setIncludeGrantedScopes($include)
419
- {
420
- $this->setAuthConfig('include_granted_scopes', $include ? "true" : "false");
421
- }
422
-
423
- /**
424
- *
425
- * @return string the base URL to use for API calls
426
- */
427
- public function getBasePath()
428
- {
429
- return $this->configuration['base_path'];
430
- }
431
-
432
- /**
433
- * Set the auth configuration for the current auth class.
434
- *
435
- * @param $key -
436
- * the key to set
437
- * @param $value -
438
- * the parameter value
439
- */
440
- private function setAuthConfig($key, $value)
441
- {
442
- if (! isset($this->configuration['classes'][$this->getAuthClass()])) {
443
- $this->configuration['classes'][$this->getAuthClass()] = array();
444
- }
445
- $this->configuration['classes'][$this->getAuthClass()][$key] = $value;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  }
 
 
447
  }
1
  <?php
 
2
  /*
3
  * Copyright 2010 Google Inc.
4
  *
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
  /**
19
  * A class to contain the library configuration for the Google API client.
20
  */
21
  class Google_Config
22
  {
23
+ const GZIP_DISABLED = true;
24
+ const GZIP_ENABLED = false;
25
+ const GZIP_UPLOADS_ENABLED = true;
26
+ const GZIP_UPLOADS_DISABLED = false;
27
+ const USE_AUTO_IO_SELECTION = "auto";
28
+ const TASK_RETRY_NEVER = 0;
29
+ const TASK_RETRY_ONCE = 1;
30
+ const TASK_RETRY_ALWAYS = -1;
31
+ protected $configuration;
32
+
33
+ /**
34
+ * Create a new Google_Config. Can accept an ini file location with the
35
+ * local configuration. For example:
36
+ * application_name="My App"
37
+ *
38
+ * @param [$ini_file_location] - optional - The location of the ini file to load
39
+ */
40
+ public function __construct($ini_file_location = null)
41
+ {
42
+ $this->configuration = array(
43
+ // The application_name is included in the User-Agent HTTP header.
44
+ 'application_name' => '',
45
+
46
+ // Which Authentication, Storage and HTTP IO classes to use.
47
+ 'auth_class' => 'Google_Auth_OAuth2',
48
+ 'io_class' => self::USE_AUTO_IO_SELECTION,
49
+ 'cache_class' => 'Google_Cache_File',
50
+ 'logger_class' => 'Google_Logger_Null',
51
+
52
+ // Don't change these unless you're working against a special development
53
+ // or testing environment.
54
+ 'base_path' => 'https://www.googleapis.com',
55
+
56
+ // Definition of class specific values, like file paths and so on.
57
+ 'classes' => array(
58
+ 'Google_IO_Abstract' => array(
59
+ 'request_timeout_seconds' => 100,
60
+ ),
61
+ 'Google_IO_Curl' => array(
62
+ 'disable_proxy_workaround' => false,
63
+ 'options' => null,
64
+ ),
65
+ 'Google_Logger_Abstract' => array(
66
+ 'level' => 'debug',
67
+ 'log_format' => "[%datetime%] %level%: %message% %context%\n",
68
+ 'date_format' => 'd/M/Y:H:i:s O',
69
+ 'allow_newlines' => true
70
+ ),
71
+ 'Google_Logger_File' => array(
72
+ 'file' => 'php://stdout',
73
+ 'mode' => 0640,
74
+ 'lock' => false,
75
+ ),
76
+ 'Google_Http_Request' => array(
77
+ // Disable the use of gzip on calls if set to true. Defaults to false.
78
+ 'disable_gzip' => self::GZIP_ENABLED,
79
+
80
+ // We default gzip to disabled on uploads even if gzip is otherwise
81
+ // enabled, due to some issues seen with small packet sizes for uploads.
82
+ // Please test with this option before enabling gzip for uploads in
83
+ // a production environment.
84
+ 'enable_gzip_for_uploads' => self::GZIP_UPLOADS_DISABLED,
85
+ ),
86
+ // If you want to pass in OAuth 2.0 settings, they will need to be
87
+ // structured like this.
88
+ 'Google_Auth_OAuth2' => array(
89
+ // Keys for OAuth 2.0 access, see the API console at
90
+ // https://developers.google.com/console
91
+ 'client_id' => '',
92
+ 'client_secret' => '',
93
+ 'redirect_uri' => '',
94
+
95
+ // Simple API access key, also from the API console. Ensure you get
96
+ // a Server key, and not a Browser key.
97
+ 'developer_key' => '',
98
+
99
+ // Other parameters.
100
+ 'hd' => '',
101
+ 'prompt' => '',
102
+ 'openid.realm' => '',
103
+ 'include_granted_scopes' => '',
104
+ 'login_hint' => '',
105
+ 'request_visible_actions' => '',
106
+ 'access_type' => 'online',
107
+ 'approval_prompt' => 'auto',
108
+ 'federated_signon_certs_url' =>
109
+ 'https://www.googleapis.com/oauth2/v1/certs',
110
+ ),
111
+ 'Google_Task_Runner' => array(
112
+ // Delays are specified in seconds
113
+ 'initial_delay' => 1,
114
+ 'max_delay' => 60,
115
+ // Base number for exponential backoff
116
+ 'factor' => 2,
117
+ // A random number between -jitter and jitter will be added to the
118
+ // factor on each iteration to allow for better distribution of
119
+ // retries.
120
+ 'jitter' => .5,
121
+ // Maximum number of retries allowed
122
+ 'retries' => 0
123
+ ),
124
+ 'Google_Service_Exception' => array(
125
+ 'retry_map' => array(
126
+ '500' => self::TASK_RETRY_ALWAYS,
127
+ '503' => self::TASK_RETRY_ALWAYS,
128
+ 'rateLimitExceeded' => self::TASK_RETRY_ALWAYS,
129
+ 'userRateLimitExceeded' => self::TASK_RETRY_ALWAYS
130
+ )
131
+ ),
132
+ 'Google_IO_Exception' => array(
133
+ 'retry_map' => !extension_loaded('curl') ? array() : array(
134
+ CURLE_COULDNT_RESOLVE_HOST => self::TASK_RETRY_ALWAYS,
135
+ CURLE_COULDNT_CONNECT => self::TASK_RETRY_ALWAYS,
136
+ CURLE_OPERATION_TIMEOUTED => self::TASK_RETRY_ALWAYS,
137
+ CURLE_SSL_CONNECT_ERROR => self::TASK_RETRY_ALWAYS,
138
+ CURLE_GOT_NOTHING => self::TASK_RETRY_ALWAYS
139
+ )
140
+ ),
141
+ // Set a default directory for the file cache.
142
+ 'Google_Cache_File' => array(
143
+ 'directory' => sys_get_temp_dir() . '/Google_Client'
144
+ )
145
+ ),
146
+ );
147
+ if ($ini_file_location) {
148
+ $ini = parse_ini_file($ini_file_location, true);
149
+ if (is_array($ini) && count($ini)) {
150
+ $merged_configuration = $ini + $this->configuration;
151
+ if (isset($ini['classes']) && isset($this->configuration['classes'])) {
152
+ $merged_configuration['classes'] = $ini['classes'] + $this->configuration['classes'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  }
154
+ $this->configuration = $merged_configuration;
155
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
  }
157
+ }
158
+
159
+ /**
160
+ * Set configuration specific to a given class.
161
+ * $config->setClassConfig('Google_Cache_File',
162
+ * array('directory' => '/tmp/cache'));
163
+ * @param $class string The class name for the configuration
164
+ * @param $config string key or an array of configuration values
165
+ * @param $value string optional - if $config is a key, the value
166
+ */
167
+ public function setClassConfig($class, $config, $value = null)
168
+ {
169
+ if (!is_array($config)) {
170
+ if (!isset($this->configuration['classes'][$class])) {
171
+ $this->configuration['classes'][$class] = array();
172
+ }
173
+ $this->configuration['classes'][$class][$config] = $value;
174
+ } else {
175
+ $this->configuration['classes'][$class] = $config;
176
  }
177
+ }
178
 
179
+ public function getClassConfig($class, $key = null)
180
+ {
181
+ if (!isset($this->configuration['classes'][$class])) {
182
+ return null;
 
 
 
 
 
183
  }
184
+ if ($key === null) {
185
+ return $this->configuration['classes'][$class];
186
+ } else {
187
+ return $this->configuration['classes'][$class][$key];
 
 
 
 
 
 
 
 
188
  }
189
+ }
190
+
191
+ /**
192
+ * Return the configured cache class.
193
+ * @return string
194
+ */
195
+ public function getCacheClass()
196
+ {
197
+ return $this->configuration['cache_class'];
198
+ }
199
+
200
+ /**
201
+ * Return the configured logger class.
202
+ * @return string
203
+ */
204
+ public function getLoggerClass()
205
+ {
206
+ return $this->configuration['logger_class'];
207
+ }
208
+
209
+ /**
210
+ * Return the configured Auth class.
211
+ * @return string
212
+ */
213
+ public function getAuthClass()
214
+ {
215
+ return $this->configuration['auth_class'];
216
+ }
217
+
218
+ /**
219
+ * Set the auth class.
220
+ *
221
+ * @param $class string the class name to set
222
+ */
223
+ public function setAuthClass($class)
224
+ {
225
+ $prev = $this->configuration['auth_class'];
226
+ if (!isset($this->configuration['classes'][$class]) &&
227
+ isset($this->configuration['classes'][$prev])) {
228
+ $this->configuration['classes'][$class] =
229
+ $this->configuration['classes'][$prev];
230
  }
231
+ $this->configuration['auth_class'] = $class;
232
+ }
233
+
234
+ /**
235
+ * Set the IO class.
236
+ *
237
+ * @param $class string the class name to set
238
+ */
239
+ public function setIoClass($class)
240
+ {
241
+ $prev = $this->configuration['io_class'];
242
+ if (!isset($this->configuration['classes'][$class]) &&
243
+ isset($this->configuration['classes'][$prev])) {
244
+ $this->configuration['classes'][$class] =
245
+ $this->configuration['classes'][$prev];
246
  }
247
+ $this->configuration['io_class'] = $class;
248
+ }
249
+
250
+ /**
251
+ * Set the cache class.
252
+ *
253
+ * @param $class string the class name to set
254
+ */
255
+ public function setCacheClass($class)
256
+ {
257
+ $prev = $this->configuration['cache_class'];
258
+ if (!isset($this->configuration['classes'][$class]) &&
259
+ isset($this->configuration['classes'][$prev])) {
260
+ $this->configuration['classes'][$class] =
261
+ $this->configuration['classes'][$prev];
262
  }
263
+ $this->configuration['cache_class'] = $class;
264
+ }
265
+
266
+ /**
267
+ * Set the logger class.
268
+ *
269
+ * @param $class string the class name to set
270
+ */
271
+ public function setLoggerClass($class)
272
+ {
273
+ $prev = $this->configuration['logger_class'];
274
+ if (!isset($this->configuration['classes'][$class]) &&
275
+ isset($this->configuration['classes'][$prev])) {
276
+ $this->configuration['classes'][$class] =
277
+ $this->configuration['classes'][$prev];
278
  }
279
+ $this->configuration['logger_class'] = $class;
280
+ }
281
+
282
+ /**
283
+ * Return the configured IO class.
284
+ *
285
+ * @return string
286
+ */
287
+ public function getIoClass()
288
+ {
289
+ return $this->configuration['io_class'];
290
+ }
291
+
292
+ /**
293
+ * Set the application name, this is included in the User-Agent HTTP header.
294
+ * @param string $name
295
+ */
296
+ public function setApplicationName($name)
297
+ {
298
+ $this->configuration['application_name'] = $name;
299
+ }
300
+
301
+ /**
302
+ * @return string the name of the application
303
+ */
304
+ public function getApplicationName()
305
+ {
306
+ return $this->configuration['application_name'];
307
+ }
308
+
309
+ /**
310
+ * Set the client ID for the auth class.
311
+ * @param $clientId string - the API console client ID
312
+ */
313
+ public function setClientId($clientId)
314
+ {
315
+ $this->setAuthConfig('client_id', $clientId);
316
+ }
317
+
318
+ /**
319
+ * Set the client secret for the auth class.
320
+ * @param $secret string - the API console client secret
321
+ */
322
+ public function setClientSecret($secret)
323
+ {
324
+ $this->setAuthConfig('client_secret', $secret);
325
+ }
326
+
327
+ /**
328
+ * Set the redirect uri for the auth class. Note that if using the
329
+ * Javascript based sign in flow, this should be the string 'postmessage'.
330
+ *
331
+ * @param $uri string - the URI that users should be redirected to
332
+ */
333
+ public function setRedirectUri($uri)
334
+ {
335
+ $this->setAuthConfig('redirect_uri', $uri);
336
+ }
337
+
338
+ /**
339
+ * Set the app activities for the auth class.
340
+ * @param $rva string a space separated list of app activity types
341
+ */
342
+ public function setRequestVisibleActions($rva)
343
+ {
344
+ $this->setAuthConfig('request_visible_actions', $rva);
345
+ }
346
+
347
+ /**
348
+ * Set the the access type requested (offline or online.)
349
+ * @param $access string - the access type
350
+ */
351
+ public function setAccessType($access)
352
+ {
353
+ $this->setAuthConfig('access_type', $access);
354
+ }
355
+
356
+ /**
357
+ * Set when to show the approval prompt (auto or force)
358
+ * @param $approval string - the approval request
359
+ */
360
+ public function setApprovalPrompt($approval)
361
+ {
362
+ $this->setAuthConfig('approval_prompt', $approval);
363
+ }
364
+
365
+ /**
366
+ * Set the login hint (email address or sub identifier)
367
+ * @param $hint string
368
+ */
369
+ public function setLoginHint($hint)
370
+ {
371
+ $this->setAuthConfig('login_hint', $hint);
372
+ }
373
+
374
+ /**
375
+ * Set the developer key for the auth class. Note that this is separate value
376
+ * from the client ID - if it looks like a URL, its a client ID!
377
+ * @param $key string - the API console developer key
378
+ */
379
+ public function setDeveloperKey($key)
380
+ {
381
+ $this->setAuthConfig('developer_key', $key);
382
+ }
383
+
384
+ /**
385
+ * Set the hd (hosted domain) parameter streamlines the login process for
386
+ * Google Apps hosted accounts. By including the domain of the user, you
387
+ * restrict sign-in to accounts at that domain.
388
+ *
389
+ * This should not be used to ensure security on your application - check
390
+ * the hd values within an id token (@see Google_Auth_LoginTicket) after sign
391
+ * in to ensure that the user is from the domain you were expecting.
392
+ *
393
+ * @param $hd string - the domain to use.
394
+ */
395
+ public function setHostedDomain($hd)
396
+ {
397
+ $this->setAuthConfig('hd', $hd);
398
+ }
399
+
400
+ /**
401
+ * Set the prompt hint. Valid values are none, consent and select_account.
402
+ * If no value is specified and the user has not previously authorized
403
+ * access, then the user is shown a consent screen.
404
+ * @param $prompt string
405
+ */
406
+ public function setPrompt($prompt)
407
+ {
408
+ $this->setAuthConfig('prompt', $prompt);
409
+ }
410
+
411
+ /**
412
+ * openid.realm is a parameter from the OpenID 2.0 protocol, not from OAuth
413
+ * 2.0. It is used in OpenID 2.0 requests to signify the URL-space for which
414
+ * an authentication request is valid.
415
+ * @param $realm string - the URL-space to use.
416
+ */
417
+ public function setOpenidRealm($realm)
418
+ {
419
+ $this->setAuthConfig('openid.realm', $realm);
420
+ }
421
+
422
+ /**
423
+ * If this is provided with the value true, and the authorization request is
424
+ * granted, the authorization will include any previous authorizations
425
+ * granted to this user/application combination for other scopes.
426
+ * @param $include boolean - the URL-space to use.
427
+ */
428
+ public function setIncludeGrantedScopes($include)
429
+ {
430
+ $this->setAuthConfig(
431
+ 'include_granted_scopes',
432
+ $include ? "true" : "false"
433
+ );
434
+ }
435
+
436
+ /**
437
+ * @return string the base URL to use for API calls
438
+ */
439
+ public function getBasePath()
440
+ {
441
+ return $this->configuration['base_path'];
442
+ }
443
+
444
+ /**
445
+ * Set the auth configuration for the current auth class.
446
+ * @param $key - the key to set
447
+ * @param $value - the parameter value
448
+ */
449
+ private function setAuthConfig($key, $value)
450
+ {
451
+ if (!isset($this->configuration['classes'][$this->getAuthClass()])) {
452
+ $this->configuration['classes'][$this->getAuthClass()] = array();
453
  }
454
+ $this->configuration['classes'][$this->getAuthClass()][$key] = $value;
455
+ }
456
  }
tools/src/Google/Exception.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /*
4
  * Copyright 2013 Google Inc.
5
  *
@@ -7,7 +6,7 @@
7
  * you may not use this file except in compliance with the License.
8
  * You may obtain a copy of the License at
9
  *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
  *
12
  * Unless required by applicable law or agreed to in writing, software
13
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,6 +14,7 @@
15
  * See the License for the specific language governing permissions and
16
  * limitations under the License.
17
  */
 
18
  class Google_Exception extends Exception
19
  {
20
  }
1
  <?php
 
2
  /*
3
  * Copyright 2013 Google Inc.
4
  *
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
  class Google_Exception extends Exception
19
  {
20
  }
tools/src/Google/Http/Batch.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,125 +14,132 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
- *
21
- * @author Chirag Shah <chirags@google.com>
22
  */
23
  class Google_Http_Batch
24
  {
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
- /**
27
- *
28
- * @var string Multipart Boundary.
29
- */
30
- private $boundary;
31
-
32
- /**
33
- *
34
- * @var array service requests to be executed.
35
- */
36
- private $requests = array();
37
-
38
- /**
39
- *
40
- * @var Google_Client
41
- */
42
- private $client;
43
-
44
- private $expected_classes = array();
45
-
46
- private $base_path;
47
-
48
- public function __construct(Google_Client $client, $boundary = false)
49
- {
50
- $this->client = $client;
51
- $this->base_path = $this->client->getBasePath();
52
- $this->expected_classes = array();
53
- $boundary = (false == $boundary) ? mt_rand() : $boundary;
54
- $this->boundary = str_replace('"', '', $boundary);
55
  }
56
 
57
- public function add(Google_Http_Request $request, $key = false)
58
- {
59
- if (false == $key) {
60
- $key = mt_rand();
61
- }
62
- $this->requests[$key] = $request;
 
 
 
 
 
 
63
  }
64
 
65
- public function execute()
66
- {
67
- $body = '';
68
- /**
69
- *
70
- * @var Google_Http_Request $req
71
- */
72
- foreach ($this->requests as $key => $req) {
73
- $body .= "--{$this->boundary}\n";
74
- $body .= $req->toBatchString($key) . "\n";
75
- $this->expected_classes["response-" . $key] = $req->getExpectedClass();
76
- }
77
- $body = rtrim($body);
78
- $body .= "\n--{$this->boundary}--";
79
- $url = $this->base_path . '/batch';
80
- $httpRequest = new Google_Http_Request($url, 'POST');
81
- $httpRequest->setRequestHeaders(array(
82
- 'Content-Type' => 'multipart/mixed; boundary=' . $this->boundary
83
- ));
84
- $httpRequest->setPostBody($body);
85
- $response = $this->client->getIo()->makeRequest($httpRequest);
86
- return $this->parseResponse($response);
 
 
87
  }
88
 
89
- public function parseResponse(Google_Http_Request $response)
90
- {
91
- $contentType = $response->getResponseHeader('content-type');
92
- $contentType = explode(';', $contentType);
93
- $boundary = false;
94
- foreach ($contentType as $part) {
95
- $part = (explode('=', $part, 2));
96
- if (isset($part[0]) && 'boundary' == trim($part[0])) {
97
- $boundary = $part[1];
98
- }
99
- }
100
- $body = $response->getResponseBody();
101
- if ($body) {
102
- $body = str_replace("--$boundary--", "--$boundary", $body);
103
- $parts = explode("--$boundary", $body);
104
- $responses = array();
105
- foreach ($parts as $part) {
106
- $part = trim($part);
107
- if (! empty($part)) {
108
- list ($metaHeaders, $part) = explode("\r\n\r\n", $part, 2);
109
- $metaHeaders = $this->client->getIo()->getHttpResponseHeaders($metaHeaders);
110
- $status = substr($part, 0, strpos($part, "\n"));
111
- $status = explode(" ", $status);
112
- $status = $status[1];
113
- list ($partHeaders, $partBody) = $this->client->getIo()->ParseHttpResponse($part, false);
114
- $response = new Google_Http_Request("");
115
- $response->setResponseHttpCode($status);
116
- $response->setResponseHeaders($partHeaders);
117
- $response->setResponseBody($partBody);
118
- // Need content id.
119
- $key = $metaHeaders['content-id'];
120
- if (isset($this->expected_classes[$key]) && strlen($this->expected_classes[$key]) > 0) {
121
- $class = $this->expected_classes[$key];
122
- $response->setExpectedClass($class);
123
- }
124
- try {
125
- $response = Google_Http_REST::decodeHttpResponse($response, $this->client);
126
- $responses[$key] = $response;
127
- } catch (Google_Service_Exception $e) {
128
- // Store the exception as the response, so successful responses
129
- // can be processed.
130
- $responses[$key] = $e;
131
- }
132
- }
133
- }
134
- return $responses;
135
  }
136
- return null;
 
 
137
  }
 
 
 
138
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
+ * Class to handle batched requests to the Google API service.
 
24
  */
25
  class Google_Http_Batch
26
  {
27
+ /** @var string Multipart Boundary. */
28
+ private $boundary;
29
+
30
+ /** @var array service requests to be executed. */
31
+ private $requests = array();
32
+
33
+ /** @var Google_Client */
34
+ private $client;
35
+
36
+ private $expected_classes = array();
37
+
38
+ private $root_url;
39
 
40
+ private $batch_path;
41
+
42
+ public function __construct(Google_Client $client, $boundary = false, $rootUrl = '', $batchPath = '')
43
+ {
44
+ $this->client = $client;
45
+ $this->root_url = rtrim($rootUrl ? $rootUrl : $this->client->getBasePath(), '/');
46
+ $this->batch_path = $batchPath ? $batchPath : 'batch';
47
+ $this->expected_classes = array();
48
+ $boundary = (false == $boundary) ? mt_rand() : $boundary;
49
+ $this->boundary = str_replace('"', '', $boundary);
50
+ }
51
+
52
+ public function add(Google_Http_Request $request, $key = false)
53
+ {
54
+ if (false == $key) {
55
+ $key = mt_rand();
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
57
 
58
+ $this->requests[$key] = $request;
59
+ }
60
+
61
+ public function execute()
62
+ {
63
+ $body = '';
64
+
65
+ /** @var Google_Http_Request $req */
66
+ foreach ($this->requests as $key => $req) {
67
+ $body .= "--{$this->boundary}\n";
68
+ $body .= $req->toBatchString($key) . "\n\n";
69
+ $this->expected_classes["response-" . $key] = $req->getExpectedClass();
70
  }
71
 
72
+ $body .= "--{$this->boundary}--";
73
+
74
+ $url = $this->root_url . '/' . $this->batch_path;
75
+ $httpRequest = new Google_Http_Request($url, 'POST');
76
+ $httpRequest->setRequestHeaders(
77
+ array('Content-Type' => 'multipart/mixed; boundary=' . $this->boundary)
78
+ );
79
+
80
+ $httpRequest->setPostBody($body);
81
+ $response = $this->client->getIo()->makeRequest($httpRequest);
82
+
83
+ return $this->parseResponse($response);
84
+ }
85
+
86
+ public function parseResponse(Google_Http_Request $response)
87
+ {
88
+ $contentType = $response->getResponseHeader('content-type');
89
+ $contentType = explode(';', $contentType);
90
+ $boundary = false;
91
+ foreach ($contentType as $part) {
92
+ $part = (explode('=', $part, 2));
93
+ if (isset($part[0]) && 'boundary' == trim($part[0])) {
94
+ $boundary = $part[1];
95
+ }
96
  }
97
 
98
+ $body = $response->getResponseBody();
99
+ if ($body) {
100
+ $body = str_replace("--$boundary--", "--$boundary", $body);
101
+ $parts = explode("--$boundary", $body);
102
+ $responses = array();
103
+
104
+ foreach ($parts as $part) {
105
+ $part = trim($part);
106
+ if (!empty($part)) {
107
+ list($metaHeaders, $part) = explode("\r\n\r\n", $part, 2);
108
+ $metaHeaders = $this->client->getIo()->getHttpResponseHeaders($metaHeaders);
109
+
110
+ $status = substr($part, 0, strpos($part, "\n"));
111
+ $status = explode(" ", $status);
112
+ $status = $status[1];
113
+
114
+ list($partHeaders, $partBody) = $this->client->getIo()->ParseHttpResponse($part, false);
115
+ $response = new Google_Http_Request("");
116
+ $response->setResponseHttpCode($status);
117
+ $response->setResponseHeaders($partHeaders);
118
+ $response->setResponseBody($partBody);
119
+
120
+ // Need content id.
121
+ $key = $metaHeaders['content-id'];
122
+
123
+ if (isset($this->expected_classes[$key]) &&
124
+ strlen($this->expected_classes[$key]) > 0) {
125
+ $class = $this->expected_classes[$key];
126
+ $response->setExpectedClass($class);
127
+ }
128
+
129
+ try {
130
+ $response = Google_Http_REST::decodeHttpResponse($response, $this->client);
131
+ $responses[$key] = $response;
132
+ } catch (Google_Service_Exception $e) {
133
+ // Store the exception as the response, so successful responses
134
+ // can be processed.
135
+ $responses[$key] = $e;
136
+ }
 
 
 
 
 
 
 
137
  }
138
+ }
139
+
140
+ return $responses;
141
  }
142
+
143
+ return null;
144
+ }
145
  }
tools/src/Google/Http/CacheParser.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,169 +14,172 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
- * Implement the caching directives specified in rfc2616.
21
- * This
22
  * implementation is guided by the guidance offered in rfc2616-sec13.
23
- *
24
- * @author Chirag Shah <chirags@google.com>
25
  */
26
  class Google_Http_CacheParser
27
  {
 
 
28
 
29
- public static $CACHEABLE_HTTP_METHODS = array(
30
- 'GET',
31
- 'HEAD'
32
- );
33
-
34
- public static $CACHEABLE_STATUS_CODES = array(
35
- '200',
36
- '203',
37
- '300',
38
- '301'
39
- );
40
-
41
- /**
42
- * Check if an HTTP request can be cached by a private local cache.
43
- *
44
- * @static
45
- *
46
- * @param Google_Http_Request $resp
47
- * @return bool True if the request is cacheable.
48
- * False if the request is uncacheable.
49
- */
50
- public static function isRequestCacheable(Google_Http_Request $resp)
51
- {
52
- $method = $resp->getRequestMethod();
53
- if (! in_array($method, self::$CACHEABLE_HTTP_METHODS)) {
54
- return false;
55
- }
56
- // Don't cache authorized requests/responses.
57
- // [rfc2616-14.8] When a shared cache receives a request containing an
58
- // Authorization field, it MUST NOT return the corresponding response
59
- // as a reply to any other request...
60
- if ($resp->getRequestHeader("authorization")) {
61
- return false;
62
- }
63
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  }
65
 
66
- /**
67
- * Check if an HTTP response can be cached by a private local cache.
68
- *
69
- * @static
70
- *
71
- * @param Google_Http_Request $resp
72
- * @return bool True if the response is cacheable.
73
- * False if the response is un-cacheable.
74
- */
75
- public static function isResponseCacheable(Google_Http_Request $resp)
76
- {
77
- // First, check if the HTTP request was cacheable before inspecting the
78
- // HTTP response.
79
- if (false == self::isRequestCacheable($resp)) {
80
- return false;
81
- }
82
- $code = $resp->getResponseHttpCode();
83
- if (! in_array($code, self::$CACHEABLE_STATUS_CODES)) {
84
- return false;
85
- }
86
- // The resource is uncacheable if the resource is already expired and
87
- // the resource doesn't have an ETag for revalidation.
88
- $etag = $resp->getResponseHeader("etag");
89
- if (self::isExpired($resp) && $etag == false) {
90
- return false;
91
- }
92
- // [rfc2616-14.9.2] If [no-store is] sent in a response, a cache MUST NOT
93
- // store any part of either this response or the request that elicited it.
94
- $cacheControl = $resp->getParsedCacheControl();
95
- if (isset($cacheControl['no-store'])) {
96
- return false;
97
- }
98
- // Pragma: no-cache is an http request directive, but is occasionally
99
- // used as a response header incorrectly.
100
- $pragma = $resp->getResponseHeader('pragma');
101
- if ($pragma == 'no-cache' || strpos($pragma, 'no-cache') !== false) {
102
- return false;
103
- }
104
- // [rfc2616-14.44] Vary: * is extremely difficult to cache. "It implies that
105
- // a cache cannot determine from the request headers of a subsequent request
106
- // whether this response is the appropriate representation."
107
- // Given this, we deem responses with the Vary header as uncacheable.
108
- $vary = $resp->getResponseHeader('vary');
109
- if ($vary) {
110
- return false;
111
- }
112
  return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
 
115
- /**
116
- *
117
- * @static
118
- *
119
- * @param Google_Http_Request $resp
120
- * @return bool True if the HTTP response is considered to be expired.
121
- * False if it is considered to be fresh.
122
- */
123
- public static function isExpired(Google_Http_Request $resp)
124
- {
125
- // HTTP/1.1 clients and caches MUST treat other invalid date formats,
126
- // especially including the value “0”, as in the past.
127
- $parsedExpires = false;
128
- $responseHeaders = $resp->getResponseHeaders();
129
- if (isset($responseHeaders['expires'])) {
130
- $rawExpires = $responseHeaders['expires'];
131
- // Check for a malformed expires header first.
132
- if (empty($rawExpires) || (is_numeric($rawExpires) && $rawExpires <= 0)) {
133
- return true;
134
- }
135
- // See if we can parse the expires header.
136
- $parsedExpires = strtotime($rawExpires);
137
- if (false == $parsedExpires || $parsedExpires <= 0) {
138
- return true;
139
- }
140
- }
141
- // Calculate the freshness of an http response.
142
- $freshnessLifetime = false;
143
- $cacheControl = $resp->getParsedCacheControl();
144
- if (isset($cacheControl['max-age'])) {
145
- $freshnessLifetime = $cacheControl['max-age'];
146
- }
147
- $rawDate = $resp->getResponseHeader('date');
148
- $parsedDate = strtotime($rawDate);
149
- if (empty($rawDate) || false == $parsedDate) {
150
- // We can't default this to now, as that means future cache reads
151
- // will always pass with the logic below, so we will require a
152
- // date be injected if not supplied.
153
- throw new Google_Exception("All cacheable requests must have creation dates.");
154
- }
155
- if (false == $freshnessLifetime && isset($responseHeaders['expires'])) {
156
- $freshnessLifetime = $parsedExpires - $parsedDate;
157
- }
158
- if (false == $freshnessLifetime) {
159
- return true;
160
- }
161
- // Calculate the age of an http response.
162
- $age = max(0, time() - $parsedDate);
163
- if (isset($responseHeaders['age'])) {
164
- $age = max($age, strtotime($responseHeaders['age']));
165
- }
166
- return $freshnessLifetime <= $age;
167
  }
168
 
169
- /**
170
- * Determine if a cache entry should be revalidated with by the origin.
171
- *
172
- * @param Google_Http_Request $response
173
- * @return bool True if the entry is expired, else return false.
174
- */
175
- public static function mustRevalidate(Google_Http_Request $response)
176
- {
177
- // [13.3] When a cache has a stale entry that it would like to use as a
178
- // response to a client's request, it first has to check with the origin
179
- // server to see if its cached entry is still usable.
180
- return self::isExpired($response);
181
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
182
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
+ * Implement the caching directives specified in rfc2616. This
 
24
  * implementation is guided by the guidance offered in rfc2616-sec13.
 
 
25
  */
26
  class Google_Http_CacheParser
27
  {
28
+ public static $CACHEABLE_HTTP_METHODS = array('GET', 'HEAD');
29
+ public static $CACHEABLE_STATUS_CODES = array('200', '203', '300', '301');
30
 
31
+ /**
32
+ * Check if an HTTP request can be cached by a private local cache.
33
+ *
34
+ * @static
35
+ * @param Google_Http_Request $resp
36
+ * @return bool True if the request is cacheable.
37
+ * False if the request is uncacheable.
38
+ */
39
+ public static function isRequestCacheable(Google_Http_Request $resp)
40
+ {
41
+ $method = $resp->getRequestMethod();
42
+ if (! in_array($method, self::$CACHEABLE_HTTP_METHODS)) {
43
+ return false;
44
+ }
45
+
46
+ // Don't cache authorized requests/responses.
47
+ // [rfc2616-14.8] When a shared cache receives a request containing an
48
+ // Authorization field, it MUST NOT return the corresponding response
49
+ // as a reply to any other request...
50
+ if ($resp->getRequestHeader("authorization")) {
51
+ return false;
52
+ }
53
+
54
+ return true;
55
+ }
56
+
57
+ /**
58
+ * Check if an HTTP response can be cached by a private local cache.
59
+ *
60
+ * @static
61
+ * @param Google_Http_Request $resp
62
+ * @return bool True if the response is cacheable.
63
+ * False if the response is un-cacheable.
64
+ */
65
+ public static function isResponseCacheable(Google_Http_Request $resp)
66
+ {
67
+ // First, check if the HTTP request was cacheable before inspecting the
68
+ // HTTP response.
69
+ if (false == self::isRequestCacheable($resp)) {
70
+ return false;
71
+ }
72
+
73
+ $code = $resp->getResponseHttpCode();
74
+ if (! in_array($code, self::$CACHEABLE_STATUS_CODES)) {
75
+ return false;
76
+ }
77
+
78
+ // The resource is uncacheable if the resource is already expired and
79
+ // the resource doesn't have an ETag for revalidation.
80
+ $etag = $resp->getResponseHeader("etag");
81
+ if (self::isExpired($resp) && $etag == false) {
82
+ return false;
83
+ }
84
+
85
+ // [rfc2616-14.9.2] If [no-store is] sent in a response, a cache MUST NOT
86
+ // store any part of either this response or the request that elicited it.
87
+ $cacheControl = $resp->getParsedCacheControl();
88
+ if (isset($cacheControl['no-store'])) {
89
+ return false;
90
+ }
91
+
92
+ // Pragma: no-cache is an http request directive, but is occasionally
93
+ // used as a response header incorrectly.
94
+ $pragma = $resp->getResponseHeader('pragma');
95
+ if ($pragma == 'no-cache' || strpos($pragma, 'no-cache') !== false) {
96
+ return false;
97
+ }
98
+
99
+ // [rfc2616-14.44] Vary: * is extremely difficult to cache. "It implies that
100
+ // a cache cannot determine from the request headers of a subsequent request
101
+ // whether this response is the appropriate representation."
102
+ // Given this, we deem responses with the Vary header as uncacheable.
103
+ $vary = $resp->getResponseHeader('vary');
104
+ if ($vary) {
105
+ return false;
106
  }
107
 
108
+ return true;
109
+ }
110
+
111
+ /**
112
+ * @static
113
+ * @param Google_Http_Request $resp
114
+ * @return bool True if the HTTP response is considered to be expired.
115
+ * False if it is considered to be fresh.
116
+ */
117
+ public static function isExpired(Google_Http_Request $resp)
118
+ {
119
+ // HTTP/1.1 clients and caches MUST treat other invalid date formats,
120
+ // especially including the value “0”, as in the past.
121
+ $parsedExpires = false;
122
+ $responseHeaders = $resp->getResponseHeaders();
123
+
124
+ if (isset($responseHeaders['expires'])) {
125
+ $rawExpires = $responseHeaders['expires'];
126
+ // Check for a malformed expires header first.
127
+ if (empty($rawExpires) || (is_numeric($rawExpires) && $rawExpires <= 0)) {
128
+ return true;
129
+ }
130
+
131
+ // See if we can parse the expires header.
132
+ $parsedExpires = strtotime($rawExpires);
133
+ if (false == $parsedExpires || $parsedExpires <= 0) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  return true;
135
+ }
136
+ }
137
+
138
+ // Calculate the freshness of an http response.
139
+ $freshnessLifetime = false;
140
+ $cacheControl = $resp->getParsedCacheControl();
141
+ if (isset($cacheControl['max-age'])) {
142
+ $freshnessLifetime = $cacheControl['max-age'];
143
+ }
144
+
145
+ $rawDate = $resp->getResponseHeader('date');
146
+ $parsedDate = strtotime($rawDate);
147
+
148
+ if (empty($rawDate) || false == $parsedDate) {
149
+ // We can't default this to now, as that means future cache reads
150
+ // will always pass with the logic below, so we will require a
151
+ // date be injected if not supplied.
152
+ throw new Google_Exception("All cacheable requests must have creation dates.");
153
  }
154
 
155
+ if (false == $freshnessLifetime && isset($responseHeaders['expires'])) {
156
+ $freshnessLifetime = $parsedExpires - $parsedDate;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  }
158
 
159
+ if (false == $freshnessLifetime) {
160
+ return true;
 
 
 
 
 
 
 
 
 
 
161
  }
162
+
163
+ // Calculate the age of an http response.
164
+ $age = max(0, time() - $parsedDate);
165
+ if (isset($responseHeaders['age'])) {
166
+ $age = max($age, strtotime($responseHeaders['age']));
167
+ }
168
+
169
+ return $freshnessLifetime <= $age;
170
+ }
171
+
172
+ /**
173
+ * Determine if a cache entry should be revalidated with by the origin.
174
+ *
175
+ * @param Google_Http_Request $response
176
+ * @return bool True if the entry is expired, else return false.
177
+ */
178
+ public static function mustRevalidate(Google_Http_Request $response)
179
+ {
180
+ // [13.3] When a cache has a stale entry that it would like to use as a
181
+ // response to a client's request, it first has to check with the origin
182
+ // server to see if its cached entry is still usable.
183
+ return self::isExpired($response);
184
+ }
185
  }
tools/src/Google/Http/MediaFileUpload.php CHANGED
@@ -14,302 +14,328 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
- *
21
- * @author Chirag Shah <chirags@google.com>
22
- *
23
  */
24
  class Google_Http_MediaFileUpload
25
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- const UPLOAD_MEDIA_TYPE = 'media';
28
-
29
- const UPLOAD_MULTIPART_TYPE = 'multipart';
30
-
31
- const UPLOAD_RESUMABLE_TYPE = 'resumable';
32
-
33
- /**
34
- *
35
- * @var string $mimeType
36
- */
37
- private $mimeType;
38
-
39
- /**
40
- *
41
- * @var string $data
42
- */
43
- private $data;
44
-
45
- /**
46
- *
47
- * @var bool $resumable
48
- */
49
- private $resumable;
50
-
51
- /**
52
- *
53
- * @var int $chunkSize
54
- */
55
- private $chunkSize;
56
-
57
- /**
58
- *
59
- * @var int $size
60
- */
61
- private $size;
62
-
63
- /**
64
- *
65
- * @var string $resumeUri
66
- */
67
- private $resumeUri;
68
-
69
- /**
70
- *
71
- * @var int $progress
72
- */
73
- private $progress;
74
-
75
- /**
76
- *
77
- * @var Google_Client
78
- */
79
- private $client;
80
-
81
- /**
82
- *
83
- * @var Google_Http_Request
84
- */
85
- private $request;
86
-
87
- /**
88
- *
89
- * @var string
90
- */
91
- private $boundary;
92
-
93
- /**
94
- * Result code from last HTTP call
95
- *
96
- * @var int
97
- */
98
- private $httpResultCode;
99
-
100
- /**
101
- *
102
- * @param $mimeType string
103
- * @param $data string
104
- * The bytes you want to upload.
105
- * @param $resumable bool
106
- * @param bool $chunkSize
107
- * File will be uploaded in chunks of this many bytes.
108
- * only used if resumable=True
109
- */
110
- public function __construct(Google_Client $client, Google_Http_Request $request, $mimeType, $data, $resumable = false, $chunkSize = false, $boundary = false)
111
- {
112
- $this->client = $client;
113
- $this->request = $request;
114
- $this->mimeType = $mimeType;
115
- $this->data = $data;
116
- $this->size = strlen($this->data);
117
- $this->resumable = $resumable;
118
- if (! $chunkSize) {
119
- $chunkSize = 256 * 1024;
120
- }
121
- $this->chunkSize = $chunkSize;
122
- $this->progress = 0;
123
- $this->boundary = $boundary;
124
- // Process Media Request
125
- $this->process();
126
  }
127
 
128
- /**
129
- * Set the size of the file that is being uploaded.
130
- *
131
- * @param $size -
132
- * int file size in bytes
133
- */
134
- public function setFileSize($size)
135
- {
136
- $this->size = $size;
 
 
 
 
 
 
 
 
 
 
 
137
  }
 
138
 
139
- /**
140
- * Return the progress on the upload
141
- *
142
- * @return int progress in bytes uploaded.
143
- */
144
- public function getProgress()
145
- {
146
- return $this->progress;
 
147
  }
148
 
149
- /**
150
- * Return the HTTP result code from the last call made.
151
- *
152
- * @return int code
153
- */
154
- public function getHttpResultCode()
155
- {
156
- return $this->httpResultCode;
157
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
 
159
- /**
160
- * Send the next part of the file to upload.
161
- *
162
- * @param
163
- * [$chunk] the next set of bytes to send. If false will used $data passed
164
- * at construct time.
165
- */
166
- public function nextChunk($chunk = false)
167
- {
168
- if (false == $this->resumeUri) {
169
- $this->resumeUri = $this->getResumeUri();
170
- }
171
- if (false == $chunk) {
172
- $chunk = substr($this->data, $this->progress, $this->chunkSize);
173
- }
174
- $lastBytePos = $this->progress + strlen($chunk) - 1;
175
- $headers = array(
176
- 'content-range' => "bytes $this->progress-$lastBytePos/$this->size",
177
- 'content-type' => $this->request->getRequestHeader('content-type'),
178
- 'content-length' => $this->chunkSize,
179
- 'expect' => ''
180
- );
181
- $httpRequest = new Google_Http_Request($this->resumeUri, 'PUT', $headers, $chunk);
182
- if ($this->client->getClassConfig("Google_Http_Request", "enable_gzip_for_uploads")) {
183
- $httpRequest->enableGzip();
184
- } else {
185
- $httpRequest->disableGzip();
186
- }
187
- $response = $this->client->getIo()->makeRequest($httpRequest);
188
- $response->setExpectedClass($this->request->getExpectedClass());
189
- $code = $response->getResponseHttpCode();
190
- $this->httpResultCode = $code;
191
- if (308 == $code) {
192
- // Track the amount uploaded.
193
- $range = explode('-', $response->getResponseHeader('range'));
194
- $this->progress = $range[1] + 1;
195
- // Allow for changing upload URLs.
196
- $location = $response->getResponseHeader('location');
197
- if ($location) {
198
- $this->resumeUri = $location;
199
- }
200
- // No problems, but upload not complete.
201
- return false;
202
- } else {
203
- return Google_Http_REST::decodeHttpResponse($response, $this->client);
204
- }
 
 
 
 
 
 
 
 
 
 
 
 
205
  }
206
 
207
- /**
208
- *
209
- * @param
210
- * $meta
211
- * @param
212
- * $params
213
- * @return array|bool @visible for testing
214
- */
215
- private function process()
216
- {
217
- $postBody = false;
218
- $contentType = false;
219
- $meta = $this->request->getPostBody();
220
- $meta = is_string($meta) ? json_decode($meta, true) : $meta;
221
- $uploadType = $this->getUploadType($meta);
222
- $this->request->setQueryParam('uploadType', $uploadType);
223
- $this->transformToUploadUrl();
224
- $mimeType = $this->mimeType ? $this->mimeType : $this->request->getRequestHeader('content-type');
225
- if (self::UPLOAD_RESUMABLE_TYPE == $uploadType) {
226
- $contentType = $mimeType;
227
- $postBody = is_string($meta) ? $meta : json_encode($meta);
228
- } else
229
- if (self::UPLOAD_MEDIA_TYPE == $uploadType) {
230
- $contentType = $mimeType;
231
- $postBody = $this->data;
232
- } else
233
- if (self::UPLOAD_MULTIPART_TYPE == $uploadType) {
234
- // This is a multipart/related upload.
235
- $boundary = $this->boundary ? $this->boundary : mt_rand();
236
- $boundary = str_replace('"', '', $boundary);
237
- $contentType = 'multipart/related; boundary=' . $boundary;
238
- $related = "--$boundary\r\n";
239
- $related .= "Content-Type: application/json; charset=UTF-8\r\n";
240
- $related .= "\r\n" . json_encode($meta) . "\r\n";
241
- $related .= "--$boundary\r\n";
242
- $related .= "Content-Type: $mimeType\r\n";
243
- $related .= "Content-Transfer-Encoding: base64\r\n";
244
- $related .= "\r\n" . base64_encode($this->data) . "\r\n";
245
- $related .= "--$boundary--";
246
- $postBody = $related;
247
- }
248
- $this->request->setPostBody($postBody);
249
- if (isset($contentType) && $contentType) {
250
- $contentTypeHeader['content-type'] = $contentType;
251
- $this->request->setRequestHeaders($contentTypeHeader);
252
- }
253
  }
 
254
 
255
- private function transformToUploadUrl()
256
- {
257
- $base = $this->request->getBaseComponent();
258
- $this->request->setBaseComponent($base . '/upload');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
259
  }
260
 
261
- /**
262
- * Valid upload types:
263
- * - resumable (UPLOAD_RESUMABLE_TYPE)
264
- * - media (UPLOAD_MEDIA_TYPE)
265
- * - multipart (UPLOAD_MULTIPART_TYPE)
266
- *
267
- * @param
268
- * $meta
269
- * @return string @visible for testing
270
- */
271
- public function getUploadType($meta)
272
- {
273
- if ($this->resumable) {
274
- return self::UPLOAD_RESUMABLE_TYPE;
275
- }
276
- if (false == $meta && $this->data) {
277
- return self::UPLOAD_MEDIA_TYPE;
278
- }
279
- return self::UPLOAD_MULTIPART_TYPE;
280
  }
281
 
282
- private function getResumeUri()
283
- {
284
- $result = null;
285
- $body = $this->request->getPostBody();
286
- if ($body) {
287
- $headers = array(
288
- 'content-type' => 'application/json; charset=UTF-8',
289
- 'content-length' => Google_Utils::getStrLen($body),
290
- 'x-upload-content-type' => $this->mimeType,
291
- 'x-upload-content-length' => $this->size,
292
- 'expect' => ''
293
- );
294
- $this->request->setRequestHeaders($headers);
295
- }
296
- $response = $this->client->getIo()->makeRequest($this->request);
297
- $location = $response->getResponseHeader('location');
298
- $code = $response->getResponseHttpCode();
299
- if (200 == $code && true == $location) {
300
- return $location;
301
- }
302
- $message = $code;
303
- $body = @json_decode($response->getResponseBody());
304
- if (! empty($body->error->errors)) {
305
- $message .= ': ';
306
- foreach ($body->error->errors as $error) {
307
- $message .= "{$error->domain}, {$error->message};";
308
- }
309
- $message = rtrim($message, ';');
310
- }
311
- $error = "Failed to start the resumable upload (HTTP {$message})";
312
- $this->client->getLogger()->error($error);
313
- throw new Google_Exception($error);
314
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  }
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
+ * Manage large file uploads, which may be media but can be any type
24
+ * of sizable data.
 
25
  */
26
  class Google_Http_MediaFileUpload
27
  {
28
+ const UPLOAD_MEDIA_TYPE = 'media';
29
+ const UPLOAD_MULTIPART_TYPE = 'multipart';
30
+ const UPLOAD_RESUMABLE_TYPE = 'resumable';
31
+
32
+ /** @var string $mimeType */
33
+ private $mimeType;
34
+
35
+ /** @var string $data */
36
+ private $data;
37
+
38
+ /** @var bool $resumable */
39
+ private $resumable;
40
+
41
+ /** @var int $chunkSize */
42
+ private $chunkSize;
43
+
44
+ /** @var int $size */
45
+ private $size;
46
+
47
+ /** @var string $resumeUri */
48
+ private $resumeUri;
49
+
50
+ /** @var int $progress */
51
+ private $progress;
52
+
53
+ /** @var Google_Client */
54
+ private $client;
55
+
56
+ /** @var Google_Http_Request */
57
+ private $request;
58
+
59
+ /** @var string */
60
+ private $boundary;
61
+
62
+ /**
63
+ * Result code from last HTTP call
64
+ * @var int
65
+ */
66
+ private $httpResultCode;
67
+
68
+ /**
69
+ * @param $mimeType string
70
+ * @param $data string The bytes you want to upload.
71
+ * @param $resumable bool
72
+ * @param bool $chunkSize File will be uploaded in chunks of this many bytes.
73
+ * only used if resumable=True
74
+ */
75
+ public function __construct(
76
+ Google_Client $client,
77
+ Google_Http_Request $request,
78
+ $mimeType,
79
+ $data,
80
+ $resumable = false,
81
+ $chunkSize = false,
82
+ $boundary = false
83
+ ) {
84
+ $this->client = $client;
85
+ $this->request = $request;
86
+ $this->mimeType = $mimeType;
87
+ $this->data = $data;
88
+ $this->size = strlen($this->data);
89
+ $this->resumable = $resumable;
90
+ if (!$chunkSize) {
91
+ $chunkSize = 256 * 1024;
92
+ }
93
+ $this->chunkSize = $chunkSize;
94
+ $this->progress = 0;
95
+ $this->boundary = $boundary;
96
+
97
+ // Process Media Request
98
+ $this->process();
99
+ }
100
+
101
+ /**
102
+ * Set the size of the file that is being uploaded.
103
+ * @param $size - int file size in bytes
104
+ */
105
+ public function setFileSize($size)
106
+ {
107
+ $this->size = $size;
108
+ }
109
+
110
+ /**
111
+ * Return the progress on the upload
112
+ * @return int progress in bytes uploaded.
113
+ */
114
+ public function getProgress()
115
+ {
116
+ return $this->progress;
117
+ }
118
 
119
+ /**
120
+ * Return the HTTP result code from the last call made.
121
+ * @return int code
122
+ */
123
+ public function getHttpResultCode()
124
+ {
125
+ return $this->httpResultCode;
126
+ }
127
+
128
+ /**
129
+ * Sends a PUT-Request to google drive and parses the response,
130
+ * setting the appropiate variables from the response()
131
+ *
132
+ * @param Google_Http_Request $httpRequest the Reuqest which will be send
133
+ *
134
+ * @return false|mixed false when the upload is unfinished or the decoded http response
135
+ *
136
+ */
137
+ private function makePutRequest(Google_Http_Request $httpRequest)
138
+ {
139
+ if ($this->client->getClassConfig("Google_Http_Request", "enable_gzip_for_uploads")) {
140
+ $httpRequest->enableGzip();
141
+ } else {
142
+ $httpRequest->disableGzip();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
144
 
145
+ $response = $this->client->getIo()->makeRequest($httpRequest);
146
+ $response->setExpectedClass($this->request->getExpectedClass());
147
+ $code = $response->getResponseHttpCode();
148
+ $this->httpResultCode = $code;
149
+
150
+ if (308 == $code) {
151
+ // Track the amount uploaded.
152
+ $range = explode('-', $response->getResponseHeader('range'));
153
+ $this->progress = $range[1] + 1;
154
+
155
+ // Allow for changing upload URLs.
156
+ $location = $response->getResponseHeader('location');
157
+ if ($location) {
158
+ $this->resumeUri = $location;
159
+ }
160
+
161
+ // No problems, but upload not complete.
162
+ return false;
163
+ } else {
164
+ return Google_Http_REST::decodeHttpResponse($response, $this->client);
165
  }
166
+ }
167
 
168
+ /**
169
+ * Send the next part of the file to upload.
170
+ * @param [$chunk] the next set of bytes to send. If false will used $data passed
171
+ * at construct time.
172
+ */
173
+ public function nextChunk($chunk = false)
174
+ {
175
+ if (false == $this->resumeUri) {
176
+ $this->resumeUri = $this->fetchResumeUri();
177
  }
178
 
179
+ if (false == $chunk) {
180
+ $chunk = substr($this->data, $this->progress, $this->chunkSize);
 
 
 
 
 
 
181
  }
182
+ $lastBytePos = $this->progress + strlen($chunk) - 1;
183
+ $headers = array(
184
+ 'content-range' => "bytes $this->progress-$lastBytePos/$this->size",
185
+ 'content-type' => $this->request->getRequestHeader('content-type'),
186
+ 'content-length' => $this->chunkSize,
187
+ 'expect' => '',
188
+ );
189
+
190
+ $httpRequest = new Google_Http_Request(
191
+ $this->resumeUri,
192
+ 'PUT',
193
+ $headers,
194
+ $chunk
195
+ );
196
+ return $this->makePutRequest($httpRequest);
197
+ }
198
 
199
+ /**
200
+ * Resume a previously unfinished upload
201
+ * @param $resumeUri the resume-URI of the unfinished, resumable upload.
202
+ */
203
+ public function resume($resumeUri)
204
+ {
205
+ $this->resumeUri = $resumeUri;
206
+ $headers = array(
207
+ 'content-range' => "bytes */$this->size",
208
+ 'content-length' => 0,
209
+ );
210
+ $httpRequest = new Google_Http_Request(
211
+ $this->resumeUri,
212
+ 'PUT',
213
+ $headers
214
+ );
215
+ return $this->makePutRequest($httpRequest);
216
+ }
217
+
218
+ /**
219
+ * @return array|bool
220
+ * @visible for testing
221
+ */
222
+ private function process()
223
+ {
224
+ $postBody = false;
225
+ $contentType = false;
226
+
227
+ $meta = $this->request->getPostBody();
228
+ $meta = is_string($meta) ? json_decode($meta, true) : $meta;
229
+
230
+ $uploadType = $this->getUploadType($meta);
231
+ $this->request->setQueryParam('uploadType', $uploadType);
232
+ $this->transformToUploadUrl();
233
+ $mimeType = $this->mimeType ?
234
+ $this->mimeType :
235
+ $this->request->getRequestHeader('content-type');
236
+
237
+ if (self::UPLOAD_RESUMABLE_TYPE == $uploadType) {
238
+ $contentType = $mimeType;
239
+ $postBody = is_string($meta) ? $meta : json_encode($meta);
240
+ } else if (self::UPLOAD_MEDIA_TYPE == $uploadType) {
241
+ $contentType = $mimeType;
242
+ $postBody = $this->data;
243
+ } else if (self::UPLOAD_MULTIPART_TYPE == $uploadType) {
244
+ // This is a multipart/related upload.
245
+ $boundary = $this->boundary ? $this->boundary : mt_rand();
246
+ $boundary = str_replace('"', '', $boundary);
247
+ $contentType = 'multipart/related; boundary=' . $boundary;
248
+ $related = "--$boundary\r\n";
249
+ $related .= "Content-Type: application/json; charset=UTF-8\r\n";
250
+ $related .= "\r\n" . json_encode($meta) . "\r\n";
251
+ $related .= "--$boundary\r\n";
252
+ $related .= "Content-Type: $mimeType\r\n";
253
+ $related .= "Content-Transfer-Encoding: base64\r\n";
254
+ $related .= "\r\n" . base64_encode($this->data) . "\r\n";
255
+ $related .= "--$boundary--";
256
+ $postBody = $related;
257
  }
258
 
259
+ $this->request->setPostBody($postBody);
260
+
261
+ if (isset($contentType) && $contentType) {
262
+ $contentTypeHeader['content-type'] = $contentType;
263
+ $this->request->setRequestHeaders($contentTypeHeader);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
  }
265
+ }
266
 
267
+ private function transformToUploadUrl()
268
+ {
269
+ $base = $this->request->getBaseComponent();
270
+ $this->request->setBaseComponent($base . '/upload');
271
+ }
272
+
273
+ /**
274
+ * Valid upload types:
275
+ * - resumable (UPLOAD_RESUMABLE_TYPE)
276
+ * - media (UPLOAD_MEDIA_TYPE)
277
+ * - multipart (UPLOAD_MULTIPART_TYPE)
278
+ * @param $meta
279
+ * @return string
280
+ * @visible for testing
281
+ */
282
+ public function getUploadType($meta)
283
+ {
284
+ if ($this->resumable) {
285
+ return self::UPLOAD_RESUMABLE_TYPE;
286
  }
287
 
288
+ if (false == $meta && $this->data) {
289
+ return self::UPLOAD_MEDIA_TYPE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  }
291
 
292
+ return self::UPLOAD_MULTIPART_TYPE;
293
+ }
294
+
295
+ public function getResumeUri()
296
+ {
297
+ return ( $this->resumeUri !== null ? $this->resumeUri : $this->fetchResumeUri() );
298
+ }
299
+
300
+ private function fetchResumeUri()
301
+ {
302
+ $result = null;
303
+ $body = $this->request->getPostBody();
304
+ if ($body) {
305
+ $headers = array(
306
+ 'content-type' => 'application/json; charset=UTF-8',
307
+ 'content-length' => Google_Utils::getStrLen($body),
308
+ 'x-upload-content-type' => $this->mimeType,
309
+ 'x-upload-content-length' => $this->size,
310
+ 'expect' => '',
311
+ );
312
+ $this->request->setRequestHeaders($headers);
 
 
 
 
 
 
 
 
 
 
 
313
  }
314
+
315
+ $response = $this->client->getIo()->makeRequest($this->request);
316
+ $location = $response->getResponseHeader('location');
317
+ $code = $response->getResponseHttpCode();
318
+
319
+ if (200 == $code && true == $location) {
320
+ return $location;
321
+ }
322
+ $message = $code;
323
+ $body = @json_decode($response->getResponseBody());
324
+ if (!empty($body->error->errors) ) {
325
+ $message .= ': ';
326
+ foreach ($body->error->errors as $error) {
327
+ $message .= "{$error->domain}, {$error->message};";
328
+ }
329
+ $message = rtrim($message, ';');
330
+ }
331
+
332
+ $error = "Failed to start the resumable upload (HTTP {$message})";
333
+ $this->client->getLogger()->error($error);
334
+ throw new Google_Exception($error);
335
+ }
336
+
337
+ public function setChunkSize($chunkSize)
338
+ {
339
+ $this->chunkSize = $chunkSize;
340
+ }
341
  }
tools/src/Google/Http/REST.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,130 +14,165 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * This class implements the RESTful transport of apiServiceRequest()'s
21
- *
22
- * @author Chris Chabot <chabotc@google.com>
23
- * @author Chirag Shah <chirags@google.com>
24
  */
25
  class Google_Http_REST
26
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
- /**
29
- * Executes a Google_Http_Request
30
- *
31
- * @param Google_Client $client
32
- * @param Google_Http_Request $req
33
- * @return array decoded result
34
- * @throws Google_Service_Exception on server side error (ie: not authenticated,
35
- * invalid or malformed post body, invalid url)
36
- */
37
- public static function execute(Google_Client $client, Google_Http_Request $req)
38
- {
39
- $httpRequest = $client->getIo()->makeRequest($req);
40
- $httpRequest->setExpectedClass($req->getExpectedClass());
41
- return self::decodeHttpResponse($httpRequest, $client);
42
  }
43
 
44
- /**
45
- * Decode an HTTP Response.
46
- *
47
- * @static
48
- *
49
- * @throws Google_Service_Exception
50
- * @param Google_Http_Request $response
51
- * The http response to be decoded.
52
- * @param Google_Client $client
53
- * @return mixed|null
54
- */
55
- public static function decodeHttpResponse($response, Google_Client $client = null)
56
- {
57
- $code = $response->getResponseHttpCode();
58
- $body = $response->getResponseBody();
59
- $decoded = null;
60
- if ((intVal($code)) >= 300) {
61
- $decoded = json_decode($body, true);
62
- $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl();
63
- if (isset($decoded['error']) && isset($decoded['error']['message']) && isset($decoded['error']['code'])) {
64
- // if we're getting a json encoded error definition, use that instead of the raw response
65
- // body for improved readability
66
- $err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}";
67
- } else {
68
- $err .= ": ($code) $body";
69
- }
70
- $errors = null;
71
- // Specific check for APIs which don't return error details, such as Blogger.
72
- if (isset($decoded['error']) && isset($decoded['error']['errors'])) {
73
- $errors = $decoded['error']['errors'];
74
- }
75
- if ($client) {
76
- $client->getLogger()->error($err, array(
77
- 'code' => $code,
78
- 'errors' => $errors
79
- ));
80
- }
81
- throw new Google_Service_Exception($err, $code, null, $errors);
82
  }
83
- // Only attempt to decode the response, if the response code wasn't (204) 'no content'
84
- if ($code != '204') {
85
- $decoded = json_decode($body, true);
86
- if ($decoded === null || $decoded === "") {
87
- $error = "Invalid json in service response: $body";
88
- if ($client) {
89
- $client->getLogger()->error($error);
90
- }
91
- throw new Google_Service_Exception($error);
92
- }
93
- if ($response->getExpectedClass()) {
94
- $class = $response->getExpectedClass();
95
- $decoded = new $class($decoded);
96
- }
97
- }
98
- return $decoded;
99
  }
 
 
100
 
101
- /**
102
- * Parse/expand request parameters and create a fully qualified
103
- * request uri.
104
- *
105
- * @static
106
- *
107
- * @param string $servicePath
108
- * @param string $restPath
109
- * @param array $params
110
- * @return string $requestUrl
111
- */
112
- public static function createRequestUri($servicePath, $restPath, $params)
113
- {
114
- $requestUrl = $servicePath . $restPath;
115
- $uriTemplateVars = array();
116
- $queryVars = array();
117
- foreach ($params as $paramName => $paramSpec) {
118
- if ($paramSpec['type'] == 'boolean') {
119
- $paramSpec['value'] = ($paramSpec['value']) ? 'true' : 'false';
120
- }
121
- if ($paramSpec['location'] == 'path') {
122
- $uriTemplateVars[$paramName] = $paramSpec['value'];
123
- } else
124
- if ($paramSpec['location'] == 'query') {
125
- if (isset($paramSpec['repeated']) && is_array($paramSpec['value'])) {
126
- foreach ($paramSpec['value'] as $value) {
127
- $queryVars[] = $paramName . '=' . rawurlencode(rawurldecode($value));
128
- }
129
- } else {
130
- $queryVars[] = $paramName . '=' . rawurlencode(rawurldecode($paramSpec['value']));
131
- }
132
- }
133
- }
134
- if (count($uriTemplateVars)) {
135
- $uriTemplateParser = new Google_Utils_URITemplate();
136
- $requestUrl = $uriTemplateParser->parse($requestUrl, $uriTemplateVars);
137
  }
138
- if (count($queryVars)) {
139
- $requestUrl .= '?' . implode($queryVars, '&');
140
- }
141
- return $requestUrl;
142
  }
 
 
 
 
 
 
 
 
 
 
 
 
143
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * This class implements the RESTful transport of apiServiceRequest()'s
 
 
 
24
  */
25
  class Google_Http_REST
26
  {
27
+ /**
28
+ * Executes a Google_Http_Request and (if applicable) automatically retries
29
+ * when errors occur.
30
+ *
31
+ * @param Google_Client $client
32
+ * @param Google_Http_Request $req
33
+ * @return array decoded result
34
+ * @throws Google_Service_Exception on server side error (ie: not authenticated,
35
+ * invalid or malformed post body, invalid url)
36
+ */
37
+ public static function execute(Google_Client $client, Google_Http_Request $req)
38
+ {
39
+ $runner = new Google_Task_Runner(
40
+ $client,
41
+ sprintf('%s %s', $req->getRequestMethod(), $req->getUrl()),
42
+ array(get_class(), 'doExecute'),
43
+ array($client, $req)
44
+ );
45
+
46
+ return $runner->run();
47
+ }
48
+
49
+ /**
50
+ * Executes a Google_Http_Request
51
+ *
52
+ * @param Google_Client $client
53
+ * @param Google_Http_Request $req
54
+ * @return array decoded result
55
+ * @throws Google_Service_Exception on server side error (ie: not authenticated,
56
+ * invalid or malformed post body, invalid url)
57
+ */
58
+ public static function doExecute(Google_Client $client, Google_Http_Request $req)
59
+ {
60
+ $httpRequest = $client->getIo()->makeRequest($req);
61
+ $httpRequest->setExpectedClass($req->getExpectedClass());
62
+ return self::decodeHttpResponse($httpRequest, $client);
63
+ }
64
+
65
+ /**
66
+ * Decode an HTTP Response.
67
+ * @static
68
+ * @throws Google_Service_Exception
69
+ * @param Google_Http_Request $response The http response to be decoded.
70
+ * @param Google_Client $client
71
+ * @return mixed|null
72
+ */
73
+ public static function decodeHttpResponse($response, Google_Client $client = null)
74
+ {
75
+ $code = $response->getResponseHttpCode();
76
+ $body = $response->getResponseBody();
77
+ $decoded = null;
78
+
79
+ if ((intVal($code)) >= 300) {
80
+ $decoded = json_decode($body, true);
81
+ $err = 'Error calling ' . $response->getRequestMethod() . ' ' . $response->getUrl();
82
+ if (isset($decoded['error']) &&
83
+ isset($decoded['error']['message']) &&
84
+ isset($decoded['error']['code'])) {
85
+ // if we're getting a json encoded error definition, use that instead of the raw response
86
+ // body for improved readability
87
+ $err .= ": ({$decoded['error']['code']}) {$decoded['error']['message']}";
88
+ } else {
89
+ $err .= ": ($code) $body";
90
+ }
91
+
92
+ $errors = null;
93
+ // Specific check for APIs which don't return error details, such as Blogger.
94
+ if (isset($decoded['error']) && isset($decoded['error']['errors'])) {
95
+ $errors = $decoded['error']['errors'];
96
+ }
97
+
98
+ $map = null;
99
+ if ($client) {
100
+ $client->getLogger()->error(
101
+ $err,
102
+ array('code' => $code, 'errors' => $errors)
103
+ );
104
 
105
+ $map = $client->getClassConfig(
106
+ 'Google_Service_Exception',
107
+ 'retry_map'
108
+ );
109
+ }
110
+ throw new Google_Service_Exception($err, $code, null, $errors, $map);
 
 
 
 
 
 
 
 
111
  }
112
 
113
+ // Only attempt to decode the response, if the response code wasn't (204) 'no content'
114
+ if ($code != '204') {
115
+ if ($response->getExpectedRaw()) {
116
+ return $body;
117
+ }
118
+
119
+ $decoded = json_decode($body, true);
120
+ if ($decoded === null || $decoded === "") {
121
+ $error = "Invalid json in service response: $body";
122
+ if ($client) {
123
+ $client->getLogger()->error($error);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  }
125
+ throw new Google_Service_Exception($error);
126
+ }
127
+
128
+ if ($response->getExpectedClass()) {
129
+ $class = $response->getExpectedClass();
130
+ $decoded = new $class($decoded);
131
+ }
 
 
 
 
 
 
 
 
 
132
  }
133
+ return $decoded;
134
+ }
135
 
136
+ /**
137
+ * Parse/expand request parameters and create a fully qualified
138
+ * request uri.
139
+ * @static
140
+ * @param string $servicePath
141
+ * @param string $restPath
142
+ * @param array $params
143
+ * @return string $requestUrl
144
+ */
145
+ public static function createRequestUri($servicePath, $restPath, $params)
146
+ {
147
+ $requestUrl = $servicePath . $restPath;
148
+ $uriTemplateVars = array();
149
+ $queryVars = array();
150
+ foreach ($params as $paramName => $paramSpec) {
151
+ if ($paramSpec['type'] == 'boolean') {
152
+ $paramSpec['value'] = ($paramSpec['value']) ? 'true' : 'false';
153
+ }
154
+ if ($paramSpec['location'] == 'path') {
155
+ $uriTemplateVars[$paramName] = $paramSpec['value'];
156
+ } else if ($paramSpec['location'] == 'query') {
157
+ if (isset($paramSpec['repeated']) && is_array($paramSpec['value'])) {
158
+ foreach ($paramSpec['value'] as $value) {
159
+ $queryVars[] = $paramName . '=' . rawurlencode(rawurldecode($value));
160
+ }
161
+ } else {
162
+ $queryVars[] = $paramName . '=' . rawurlencode(rawurldecode($paramSpec['value']));
 
 
 
 
 
 
 
 
 
163
  }
164
+ }
 
 
 
165
  }
166
+
167
+ if (count($uriTemplateVars)) {
168
+ $uriTemplateParser = new Google_Utils_URITemplate();
169
+ $requestUrl = $uriTemplateParser->parse($requestUrl, $uriTemplateVars);
170
+ }
171
+
172
+ if (count($queryVars)) {
173
+ $requestUrl .= '?' . implode($queryVars, '&');
174
+ }
175
+
176
+ return $requestUrl;
177
+ }
178
  }
tools/src/Google/Http/Request.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,485 +14,491 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
- * HTTP Request to be executed by IO classes.
21
- * Upon execution, the
22
  * responseHttpCode, responseHeaders and responseBody will be filled in.
23
  *
24
  * @author Chris Chabot <chabotc@google.com>
25
  * @author Chirag Shah <chirags@google.com>
26
- *
27
  */
28
  class Google_Http_Request
29
  {
30
-
31
- const GZIP_UA = " (gzip)";
32
-
33
- private $batchHeaders = array(
34
- 'Content-Type' => 'application/http',
35
- 'Content-Transfer-Encoding' => 'binary',
36
- 'MIME-Version' => '1.0'
37
- );
38
-
39
- protected $queryParams;
40
-
41
- protected $requestMethod;
42
-
43
- protected $requestHeaders;
44
-
45
- protected $baseComponent = null;
46
-
47
- protected $path;
48
-
49
- protected $postBody;
50
-
51
- protected $userAgent;
52
-
53
- protected $canGzip = null;
54
-
55
- protected $responseHttpCode;
56
-
57
- protected $responseHeaders;
58
-
59
- protected $responseBody;
60
-
61
- protected $expectedClass;
62
-
63
- public $accessKey;
64
-
65
- public function __construct($url, $method = 'GET', $headers = array(), $postBody = null)
66
- {
67
- $this->setUrl($url);
68
- $this->setRequestMethod($method);
69
- $this->setRequestHeaders($headers);
70
- $this->setPostBody($postBody);
71
- }
72
-
73
- /**
74
- * Misc function that returns the base url component of the $url
75
- * used by the OAuth signing class to calculate the base string
76
- *
77
- * @return string The base url component of the $url.
78
- */
79
- public function getBaseComponent()
80
- {
81
- return $this->baseComponent;
82
- }
83
-
84
- /**
85
- * Set the base URL that path and query parameters will be added to.
86
- *
87
- * @param $baseComponent string
88
- */
89
- public function setBaseComponent($baseComponent)
90
- {
91
- $this->baseComponent = $baseComponent;
92
- }
93
-
94
- /**
95
- * Enable support for gzipped responses with this request.
96
- */
97
- public function enableGzip()
98
- {
99
- $this->setRequestHeaders(array(
100
- "Accept-Encoding" => "gzip"
101
- ));
102
- $this->canGzip = true;
103
- $this->setUserAgent($this->userAgent);
104
- }
105
-
106
- /**
107
- * Disable support for gzip responses with this request.
108
- */
109
- public function disableGzip()
110
- {
111
- if (isset($this->requestHeaders['accept-encoding']) && $this->requestHeaders['accept-encoding'] == "gzip") {
112
- unset($this->requestHeaders['accept-encoding']);
113
- }
114
- $this->canGzip = false;
115
- $this->userAgent = str_replace(self::GZIP_UA, "", $this->userAgent);
116
- }
117
-
118
- /**
119
- * Can this request accept a gzip response?
120
- *
121
- * @return bool
122
- */
123
- public function canGzip()
124
- {
125
- return $this->canGzip;
126
- }
127
-
128
- /**
129
- * Misc function that returns an array of the query parameters of the current
130
- * url used by the OAuth signing class to calculate the signature
131
- *
132
- * @return array Query parameters in the query string.
133
- */
134
- public function getQueryParams()
135
- {
136
- return $this->queryParams;
137
- }
138
-
139
- /**
140
- * Set a new query parameter.
141
- *
142
- * @param $key -
143
- * string to set, does not need to be URL encoded
144
- * @param $value -
145
- * string to set, does not need to be URL encoded
146
- */
147
- public function setQueryParam($key, $value)
148
- {
149
- $this->queryParams[$key] = $value;
150
- }
151
-
152
- /**
153
- *
154
- * @return string HTTP Response Code.
155
- */
156
- public function getResponseHttpCode()
157
- {
158
- return (int) $this->responseHttpCode;
159
- }
160
-
161
- /**
162
- *
163
- * @param int $responseHttpCode
164
- * HTTP Response Code.
165
- */
166
- public function setResponseHttpCode($responseHttpCode)
167
- {
168
- $this->responseHttpCode = $responseHttpCode;
169
- }
170
-
171
- /**
172
- *
173
- * @return $responseHeaders (array) HTTP Response Headers.
174
- */
175
- public function getResponseHeaders()
176
- {
177
- return $this->responseHeaders;
178
- }
179
-
180
- /**
181
- *
182
- * @return string HTTP Response Body
183
- */
184
- public function getResponseBody()
185
- {
186
- return $this->responseBody;
187
- }
188
-
189
- /**
190
- * Set the class the response to this request should expect.
191
- *
192
- * @param $class string
193
- * the class name
194
- */
195
- public function setExpectedClass($class)
196
- {
197
- $this->expectedClass = $class;
198
- }
199
-
200
- /**
201
- * Retrieve the expected class the response should expect.
202
- *
203
- * @return string class name
204
- */
205
- public function getExpectedClass()
206
- {
207
- return $this->expectedClass;
208
- }
209
-
210
- /**
211
- *
212
- * @param array $headers
213
- * The HTTP response headers
214
- * to be normalized.
215
- */
216
- public function setResponseHeaders($headers)
217
- {
218
- $headers = Google_Utils::normalize($headers);
219
- if ($this->responseHeaders) {
220
- $headers = array_merge($this->responseHeaders, $headers);
221
- }
222
- $this->responseHeaders = $headers;
223
- }
224
-
225
- /**
226
- *
227
- * @param string $key
228
- * @return array|boolean Returns the requested HTTP header or
229
- * false if unavailable.
230
- */
231
- public function getResponseHeader($key)
232
- {
233
- return isset($this->responseHeaders[$key]) ? $this->responseHeaders[$key] : false;
234
- }
235
-
236
- /**
237
- *
238
- * @param string $responseBody
239
- * The HTTP response body.
240
- */
241
- public function setResponseBody($responseBody)
242
- {
243
- $this->responseBody = $responseBody;
244
- }
245
-
246
- /**
247
- *
248
- * @return string $url The request URL.
249
- */
250
- public function getUrl()
251
- {
252
- return $this->baseComponent . $this->path . (count($this->queryParams) ? "?" . $this->buildQuery($this->queryParams) : '');
253
- }
254
-
255
- /**
256
- *
257
- * @return string $method HTTP Request Method.
258
- */
259
- public function getRequestMethod()
260
- {
261
- return $this->requestMethod;
262
- }
263
-
264
- /**
265
- *
266
- * @return array $headers HTTP Request Headers.
267
- */
268
- public function getRequestHeaders()
269
- {
270
- return $this->requestHeaders;
271
- }
272
-
273
- /**
274
- *
275
- * @param string $key
276
- * @return array|boolean Returns the requested HTTP header or
277
- * false if unavailable.
278
- */
279
- public function getRequestHeader($key)
280
- {
281
- return isset($this->requestHeaders[$key]) ? $this->requestHeaders[$key] : false;
282
- }
283
-
284
- /**
285
- *
286
- * @return string $postBody HTTP Request Body.
287
- */
288
- public function getPostBody()
289
- {
290
- return $this->postBody;
291
- }
292
-
293
- /**
294
- *
295
- * @param string $url
296
- * the url to set
297
- */
298
- public function setUrl($url)
299
- {
300
- if (substr($url, 0, 4) != 'http') {
301
- // Force the path become relative.
302
- if (substr($url, 0, 1) !== '/') {
303
- $url = '/' . $url;
304
- }
305
- }
306
- $parts = parse_url($url);
307
- if (isset($parts['host'])) {
308
- $this->baseComponent = sprintf("%s%s%s", isset($parts['scheme']) ? $parts['scheme'] . "://" : '', isset($parts['host']) ? $parts['host'] : '', isset($parts['port']) ? ":" . $parts['port'] : '');
309
- }
310
- $this->path = isset($parts['path']) ? $parts['path'] : '';
311
- $this->queryParams = array();
312
- if (isset($parts['query'])) {
313
- $this->queryParams = $this->parseQuery($parts['query']);
314
- }
315
- }
316
-
317
- /**
318
- *
319
- * @param string $method
320
- * Set he HTTP Method and normalize
321
- * it to upper-case, as required by HTTP.
322
- *
323
- */
324
- public function setRequestMethod($method)
325
- {
326
- $this->requestMethod = strtoupper($method);
327
- }
328
-
329
- /**
330
- *
331
- * @param array $headers
332
- * The HTTP request headers
333
- * to be set and normalized.
334
- */
335
- public function setRequestHeaders($headers)
336
- {
337
- $headers = Google_Utils::normalize($headers);
338
- if ($this->requestHeaders) {
339
- $headers = array_merge($this->requestHeaders, $headers);
340
- }
341
- $this->requestHeaders = $headers;
342
- }
343
-
344
- /**
345
- *
346
- * @param string $postBody
347
- * the postBody to set
348
- */
349
- public function setPostBody($postBody)
350
- {
351
- $this->postBody = $postBody;
352
- }
353
-
354
- /**
355
- * Set the User-Agent Header.
356
- *
357
- * @param string $userAgent
358
- * The User-Agent.
359
- */
360
- public function setUserAgent($userAgent)
361
- {
362
- $this->userAgent = $userAgent;
363
- if ($this->canGzip) {
364
- $this->userAgent = $userAgent . self::GZIP_UA;
365
- }
366
- }
367
-
368
- /**
369
- *
370
- * @return string The User-Agent.
371
- */
372
- public function getUserAgent()
373
- {
374
- return $this->userAgent;
375
- }
376
-
377
- /**
378
- * Returns a cache key depending on if this was an OAuth signed request
379
- * in which case it will use the non-signed url and access key to make this
380
- * cache key unique per authenticated user, else use the plain request url
381
- *
382
- * @return string The md5 hash of the request cache key.
383
- */
384
- public function getCacheKey()
385
- {
386
- $key = $this->getUrl();
387
- if (isset($this->accessKey)) {
388
- $key .= $this->accessKey;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
389
  }
390
- if (isset($this->requestHeaders['authorization'])) {
391
- $key .= $this->requestHeaders['authorization'];
392
- }
393
- return md5($key);
394
- }
395
-
396
- public function getParsedCacheControl()
397
- {
398
- $parsed = array();
399
- $rawCacheControl = $this->getResponseHeader('cache-control');
400
- if ($rawCacheControl) {
401
- $rawCacheControl = str_replace(', ', '&', $rawCacheControl);
402
- parse_str($rawCacheControl, $parsed);
403
- }
404
- return $parsed;
405
- }
406
-
407
- /**
408
- *
409
- * @param string $id
410
- * @return string A string representation of the HTTP Request.
411
- */
412
- public function toBatchString($id)
413
- {
414
- $str = '';
415
- $path = parse_url($this->getUrl(), PHP_URL_PATH) . "?" . http_build_query($this->queryParams);
416
- $str .= $this->getRequestMethod() . ' ' . $path . " HTTP/1.1\n";
417
- foreach ($this->getRequestHeaders() as $key => $val) {
418
- $str .= $key . ': ' . $val . "\n";
419
  }
420
- if ($this->getPostBody()) {
421
- $str .= "\n";
422
- $str .= $this->getPostBody();
423
- }
424
- $headers = '';
425
- foreach ($this->batchHeaders as $key => $val) {
426
- $headers .= $key . ': ' . $val . "\n";
427
- }
428
- $headers .= "Content-ID: $id\n";
429
- $str = $headers . "\n" . $str;
430
- return $str;
431
- }
432
-
433
- /**
434
- * Our own version of parse_str that allows for multiple variables
435
- * with the same name.
436
- *
437
- * @param $string -
438
- * the query string to parse
439
- */
440
- private function parseQuery($string)
441
- {
442
- $return = array();
443
- $parts = explode("&", $string);
444
- foreach ($parts as $part) {
445
- list ($key, $value) = explode('=', $part, 2);
446
- $value = urldecode($value);
447
- if (isset($return[$key])) {
448
- if (! is_array($return[$key])) {
449
- $return[$key] = array(
450
- $return[$key]
451
- );
452
- }
453
- $return[$key][] = $value;
454
- } else {
455
- $return[$key] = $value;
456
- }
457
- }
458
- return $return;
459
- }
460
-
461
- /**
462
- * A version of build query that allows for multiple
463
- * duplicate keys.
464
- *
465
- * @param $parts array
466
- * of key value pairs
467
- */
468
- private function buildQuery($parts)
469
- {
470
- $return = array();
471
- foreach ($parts as $key => $value) {
472
- if (is_array($value)) {
473
- foreach ($value as $v) {
474
- $return[] = urlencode($key) . "=" . urlencode($v);
475
- }
476
- } else {
477
- $return[] = urlencode($key) . "=" . urlencode($value);
478
- }
479
- }
480
- return implode('&', $return);
481
- }
482
-
483
- /**
484
- * If we're POSTing and have no body to send, we can send the query
485
- * parameters in there, which avoids length issues with longer query
486
- * params.
487
- */
488
- public function maybeMoveParametersToBody()
489
- {
490
- if ($this->getRequestMethod() == "POST" && empty($this->postBody)) {
491
- $this->setRequestHeaders(array(
492
- "content-type" => "application/x-www-form-urlencoded; charset=UTF-8"
493
- ));
494
- $this->setPostBody($this->buildQuery($this->queryParams));
495
- $this->queryParams = array();
496
- }
497
- }
498
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
+ * HTTP Request to be executed by IO classes. Upon execution, the
 
24
  * responseHttpCode, responseHeaders and responseBody will be filled in.
25
  *
26
  * @author Chris Chabot <chabotc@google.com>
27
  * @author Chirag Shah <chirags@google.com>
28
+ *
29
  */
30
  class Google_Http_Request
31
  {
32
+ const GZIP_UA = " (gzip)";
33
+
34
+ private $batchHeaders = array(
35
+ 'Content-Type' => 'application/http',
36
+ 'Content-Transfer-Encoding' => 'binary',
37
+ 'MIME-Version' => '1.0',
38
+ );
39
+
40
+ protected $queryParams;
41
+ protected $requestMethod;
42
+ protected $requestHeaders;
43
+ protected $baseComponent = null;
44
+ protected $path;
45
+ protected $postBody;
46
+ protected $userAgent;
47
+ protected $canGzip = null;
48
+
49
+ protected $responseHttpCode;
50
+ protected $responseHeaders;
51
+ protected $responseBody;
52
+
53
+ protected $expectedClass;
54
+ protected $expectedRaw = false;
55
+
56
+ public $accessKey;
57
+
58
+ public function __construct(
59
+ $url,
60
+ $method = 'GET',
61
+ $headers = array(),
62
+ $postBody = null
63
+ ) {
64
+ $this->setUrl($url);
65
+ $this->setRequestMethod($method);
66
+ $this->setRequestHeaders($headers);
67
+ $this->setPostBody($postBody);
68
+ }
69
+
70
+ /**
71
+ * Misc function that returns the base url component of the $url
72
+ * used by the OAuth signing class to calculate the base string
73
+ * @return string The base url component of the $url.
74
+ */
75
+ public function getBaseComponent()
76
+ {
77
+ return $this->baseComponent;
78
+ }
79
+
80
+ /**
81
+ * Set the base URL that path and query parameters will be added to.
82
+ * @param $baseComponent string
83
+ */
84
+ public function setBaseComponent($baseComponent)
85
+ {
86
+ $this->baseComponent = rtrim($baseComponent, '/');
87
+ }
88
+
89
+ /**
90
+ * Enable support for gzipped responses with this request.
91
+ */
92
+ public function enableGzip()
93
+ {
94
+ $this->setRequestHeaders(array("Accept-Encoding" => "gzip"));
95
+ $this->canGzip = true;
96
+ $this->setUserAgent($this->userAgent);
97
+ }
98
+
99
+ /**
100
+ * Disable support for gzip responses with this request.
101
+ */
102
+ public function disableGzip()
103
+ {
104
+ if (
105
+ isset($this->requestHeaders['accept-encoding']) &&
106
+ $this->requestHeaders['accept-encoding'] == "gzip"
107
+ ) {
108
+ unset($this->requestHeaders['accept-encoding']);
109
+ }
110
+ $this->canGzip = false;
111
+ $this->userAgent = str_replace(self::GZIP_UA, "", $this->userAgent);
112
+ }
113
+
114
+ /**
115
+ * Can this request accept a gzip response?
116
+ * @return bool
117
+ */
118
+ public function canGzip()
119
+ {
120
+ return $this->canGzip;
121
+ }
122
+
123
+ /**
124
+ * Misc function that returns an array of the query parameters of the current
125
+ * url used by the OAuth signing class to calculate the signature
126
+ * @return array Query parameters in the query string.
127
+ */
128
+ public function getQueryParams()
129
+ {
130
+ return $this->queryParams;
131
+ }
132
+
133
+ /**
134
+ * Set a new query parameter.
135
+ * @param $key - string to set, does not need to be URL encoded
136
+ * @param $value - string to set, does not need to be URL encoded
137
+ */
138
+ public function setQueryParam($key, $value)
139
+ {
140
+ $this->queryParams[$key] = $value;
141
+ }
142
+
143
+ /**
144
+ * @return string HTTP Response Code.
145
+ */
146
+ public function getResponseHttpCode()
147
+ {
148
+ return (int) $this->responseHttpCode;
149
+ }
150
+
151
+ /**
152
+ * @param int $responseHttpCode HTTP Response Code.
153
+ */
154
+ public function setResponseHttpCode($responseHttpCode)
155
+ {
156
+ $this->responseHttpCode = $responseHttpCode;
157
+ }
158
+
159
+ /**
160
+ * @return $responseHeaders (array) HTTP Response Headers.
161
+ */
162
+ public function getResponseHeaders()
163
+ {
164
+ return $this->responseHeaders;
165
+ }
166
+
167
+ /**
168
+ * @return string HTTP Response Body
169
+ */
170
+ public function getResponseBody()
171
+ {
172
+ return $this->responseBody;
173
+ }
174
+
175
+ /**
176
+ * Set the class the response to this request should expect.
177
+ *
178
+ * @param $class string the class name
179
+ */
180
+ public function setExpectedClass($class)
181
+ {
182
+ $this->expectedClass = $class;
183
+ }
184
+
185
+ /**
186
+ * Retrieve the expected class the response should expect.
187
+ * @return string class name
188
+ */
189
+ public function getExpectedClass()
190
+ {
191
+ return $this->expectedClass;
192
+ }
193
+
194
+ /**
195
+ * Enable expected raw response
196
+ */
197
+ public function enableExpectedRaw()
198
+ {
199
+ $this->expectedRaw = true;
200
+ }
201
+
202
+ /**
203
+ * Disable expected raw response
204
+ */
205
+ public function disableExpectedRaw()
206
+ {
207
+ $this->expectedRaw = false;
208
+ }
209
+
210
+ /**
211
+ * Expected raw response or not.
212
+ * @return boolean expected raw response
213
+ */
214
+ public function getExpectedRaw()
215
+ {
216
+ return $this->expectedRaw;
217
+ }
218
+
219
+ /**
220
+ * @param array $headers The HTTP response headers
221
+ * to be normalized.
222
+ */
223
+ public function setResponseHeaders($headers)
224
+ {
225
+ $headers = Google_Utils::normalize($headers);
226
+ if ($this->responseHeaders) {
227
+ $headers = array_merge($this->responseHeaders, $headers);
228
+ }
229
+
230
+ $this->responseHeaders = $headers;
231
+ }
232
+
233
+ /**
234
+ * @param string $key
235
+ * @return array|boolean Returns the requested HTTP header or
236
+ * false if unavailable.
237
+ */
238
+ public function getResponseHeader($key)
239
+ {
240
+ return isset($this->responseHeaders[$key])
241
+ ? $this->responseHeaders[$key]
242
+ : false;
243
+ }
244
+
245
+ /**
246
+ * @param string $responseBody The HTTP response body.
247
+ */
248
+ public function setResponseBody($responseBody)
249
+ {
250
+ $this->responseBody = $responseBody;
251
+ }
252
+
253
+ /**
254
+ * @return string $url The request URL.
255
+ */
256
+ public function getUrl()
257
+ {
258
+ return $this->baseComponent . $this->path .
259
+ (count($this->queryParams) ?
260
+ "?" . $this->buildQuery($this->queryParams) :
261
+ '');
262
+ }
263
+
264
+ /**
265
+ * @return string $method HTTP Request Method.
266
+ */
267
+ public function getRequestMethod()
268
+ {
269
+ return $this->requestMethod;
270
+ }
271
+
272
+ /**
273
+ * @return array $headers HTTP Request Headers.
274
+ */
275
+ public function getRequestHeaders()
276
+ {
277
+ return $this->requestHeaders;
278
+ }
279
+
280
+ /**
281
+ * @param string $key
282
+ * @return array|boolean Returns the requested HTTP header or
283
+ * false if unavailable.
284
+ */
285
+ public function getRequestHeader($key)
286
+ {
287
+ return isset($this->requestHeaders[$key])
288
+ ? $this->requestHeaders[$key]
289
+ : false;
290
+ }
291
+
292
+ /**
293
+ * @return string $postBody HTTP Request Body.
294
+ */
295
+ public function getPostBody()
296
+ {
297
+ return $this->postBody;
298
+ }
299
+
300
+ /**
301
+ * @param string $url the url to set
302
+ */
303
+ public function setUrl($url)
304
+ {
305
+ if (substr($url, 0, 4) != 'http') {
306
+ // Force the path become relative.
307
+ if (substr($url, 0, 1) !== '/') {
308
+ $url = '/' . $url;
309
+ }
310
+ }
311
+ $parts = parse_url($url);
312
+ if (isset($parts['host'])) {
313
+ $this->baseComponent = sprintf(
314
+ "%s%s%s",
315
+ isset($parts['scheme']) ? $parts['scheme'] . "://" : '',
316
+ isset($parts['host']) ? $parts['host'] : '',
317
+ isset($parts['port']) ? ":" . $parts['port'] : ''
318
+ );
319
+ }
320
+ $this->path = isset($parts['path']) ? $parts['path'] : '';
321
+ $this->queryParams = array();
322
+ if (isset($parts['query'])) {
323
+ $this->queryParams = $this->parseQuery($parts['query']);
324
+ }
325
+ }
326
+
327
+ /**
328
+ * @param string $method Set he HTTP Method and normalize
329
+ * it to upper-case, as required by HTTP.
330
+ *
331
+ */
332
+ public function setRequestMethod($method)
333
+ {
334
+ $this->requestMethod = strtoupper($method);
335
+ }
336
+
337
+ /**
338
+ * @param array $headers The HTTP request headers
339
+ * to be set and normalized.
340
+ */
341
+ public function setRequestHeaders($headers)
342
+ {
343
+ $headers = Google_Utils::normalize($headers);
344
+ if ($this->requestHeaders) {
345
+ $headers = array_merge($this->requestHeaders, $headers);
346
+ }
347
+ $this->requestHeaders = $headers;
348
+ }
349
+
350
+ /**
351
+ * @param string $postBody the postBody to set
352
+ */
353
+ public function setPostBody($postBody)
354
+ {
355
+ $this->postBody = $postBody;
356
+ }
357
+
358
+ /**
359
+ * Set the User-Agent Header.
360
+ * @param string $userAgent The User-Agent.
361
+ */
362
+ public function setUserAgent($userAgent)
363
+ {
364
+ $this->userAgent = $userAgent;
365
+ if ($this->canGzip) {
366
+ $this->userAgent = $userAgent . self::GZIP_UA;
367
+ }
368
+ }
369
+
370
+ /**
371
+ * @return string The User-Agent.
372
+ */
373
+ public function getUserAgent()
374
+ {
375
+ return $this->userAgent;
376
+ }
377
+
378
+ /**
379
+ * Returns a cache key depending on if this was an OAuth signed request
380
+ * in which case it will use the non-signed url and access key to make this
381
+ * cache key unique per authenticated user, else use the plain request url
382
+ * @return string The md5 hash of the request cache key.
383
+ */
384
+ public function getCacheKey()
385
+ {
386
+ $key = $this->getUrl();
387
+
388
+ if (isset($this->accessKey)) {
389
+ $key .= $this->accessKey;
390
+ }
391
+
392
+ if (isset($this->requestHeaders['authorization'])) {
393
+ $key .= $this->requestHeaders['authorization'];
394
+ }
395
+
396
+ return md5($key);
397
+ }
398
+
399
+ public function getParsedCacheControl()
400
+ {
401
+ $parsed = array();
402
+ $rawCacheControl = $this->getResponseHeader('cache-control');
403
+ if ($rawCacheControl) {
404
+ $rawCacheControl = str_replace(', ', '&', $rawCacheControl);
405
+ parse_str($rawCacheControl, $parsed);
406
+ }
407
+
408
+ return $parsed;
409
+ }
410
+
411
+ /**
412
+ * @param string $id
413
+ * @return string A string representation of the HTTP Request.
414
+ */
415
+ public function toBatchString($id)
416
+ {
417
+ $str = '';
418
+ $path = parse_url($this->getUrl(), PHP_URL_PATH) . "?" .
419
+ http_build_query($this->queryParams, '', '&');
420
+ $str .= $this->getRequestMethod() . ' ' . $path . " HTTP/1.1\n";
421
+
422
+ foreach ($this->getRequestHeaders() as $key => $val) {
423
+ $str .= $key . ': ' . $val . "\n";
424
+ }
425
+
426
+ if ($this->getPostBody()) {
427
+ $str .= "\n";
428
+ $str .= $this->getPostBody();
429
+ }
430
+
431
+ $headers = '';
432
+ foreach ($this->batchHeaders as $key => $val) {
433
+ $headers .= $key . ': ' . $val . "\n";
434
+ }
435
+
436
+ $headers .= "Content-ID: $id\n";
437
+ $str = $headers . "\n" . $str;
438
+
439
+ return $str;
440
+ }
441
+
442
+ /**
443
+ * Our own version of parse_str that allows for multiple variables
444
+ * with the same name.
445
+ * @param $string - the query string to parse
446
+ */
447
+ private function parseQuery($string)
448
+ {
449
+ $return = array();
450
+ $parts = explode("&", $string);
451
+ foreach ($parts as $part) {
452
+ list($key, $value) = explode('=', $part, 2);
453
+ $value = urldecode($value);
454
+ if (isset($return[$key])) {
455
+ if (!is_array($return[$key])) {
456
+ $return[$key] = array($return[$key]);
457
  }
458
+ $return[$key][] = $value;
459
+ } else {
460
+ $return[$key] = $value;
461
+ }
462
+ }
463
+ return $return;
464
+ }
465
+
466
+ /**
467
+ * A version of build query that allows for multiple
468
+ * duplicate keys.
469
+ * @param $parts array of key value pairs
470
+ */
471
+ private function buildQuery($parts)
472
+ {
473
+ $return = array();
474
+ foreach ($parts as $key => $value) {
475
+ if (is_array($value)) {
476
+ foreach ($value as $v) {
477
+ $return[] = urlencode($key) . "=" . urlencode($v);
 
 
 
 
 
 
 
 
 
478
  }
479
+ } else {
480
+ $return[] = urlencode($key) . "=" . urlencode($value);
481
+ }
482
+ }
483
+ return implode('&', $return);
484
+ }
485
+
486
+ /**
487
+ * If we're POSTing and have no body to send, we can send the query
488
+ * parameters in there, which avoids length issues with longer query
489
+ * params.
490
+ */
491
+ public function maybeMoveParametersToBody()
492
+ {
493
+ if ($this->getRequestMethod() == "POST" && empty($this->postBody)) {
494
+ $this->setRequestHeaders(
495
+ array(
496
+ "content-type" =>
497
+ "application/x-www-form-urlencoded; charset=UTF-8"
498
+ )
499
+ );
500
+ $this->setPostBody($this->buildQuery($this->queryParams));
501
+ $this->queryParams = array();
502
+ }
503
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  }
tools/src/Google/IO/Abstract.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,327 +14,326 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
 
17
  /**
18
  * Abstract IO base class
19
  */
20
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
21
 
22
  abstract class Google_IO_Abstract
23
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- const UNKNOWN_CODE = 0;
26
 
27
- const FORM_URLENCODED = 'application/x-www-form-urlencoded';
 
28
 
29
- private static $CONNECTION_ESTABLISHED_HEADERS = array(
30
- "HTTP/1.0 200 Connection established\r\n\r\n",
31
- "HTTP/1.1 200 Connection established\r\n\r\n"
32
- );
 
 
 
 
33
 
34
- private static $ENTITY_HTTP_METHODS = array(
35
- "POST" => null,
36
- "PUT" => null
37
- );
 
 
 
38
 
39
- /**
40
- *
41
- * @var Google_Client
42
- */
43
- protected $client;
44
 
45
- public function __construct(Google_Client $client)
46
- {
47
- $this->client = $client;
48
- $timeout = $client->getClassConfig('Google_IO_Abstract', 'request_timeout_seconds');
49
- if ($timeout > 0) {
50
- $this->setTimeout($timeout);
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
 
54
- /**
55
- * Executes a Google_Http_Request and returns the resulting populated Google_Http_Request
56
- *
57
- * @param Google_Http_Request $request
58
- * @return Google_Http_Request $request
59
- */
60
- abstract public function executeRequest(Google_Http_Request $request);
61
-
62
- /**
63
- * Set options that update the transport implementation's behavior.
64
- *
65
- * @param
66
- * $options
67
- */
68
- abstract public function setOptions($options);
69
-
70
- /**
71
- * Set the maximum request time in seconds.
72
- *
73
- * @param $timeout in
74
- * seconds
75
- */
76
- abstract public function setTimeout($timeout);
77
-
78
- /**
79
- * Get the maximum request time in seconds.
80
- *
81
- * @return timeout in seconds
82
- */
83
- abstract public function getTimeout();
84
-
85
- /**
86
- * Test for the presence of a cURL header processing bug
87
- *
88
- * The cURL bug was present in versions prior to 7.30.0 and caused the header
89
- * length to be miscalculated when a "Connection established" header added by
90
- * some proxies was present.
91
- *
92
- * @return boolean
93
- */
94
- abstract protected function needsQuirk();
95
-
96
- /**
97
- * @visible for testing.
98
- * Cache the response to an HTTP request if it is cacheable.
99
- *
100
- * @param Google_Http_Request $request
101
- * @return bool Returns true if the insertion was successful.
102
- * Otherwise, return false.
103
- */
104
- public function setCachedRequest(Google_Http_Request $request)
105
- {
106
- // Determine if the request is cacheable.
107
- if (Google_Http_CacheParser::isResponseCacheable($request)) {
108
- $this->client->getCache()->set($request->getCacheKey(), $request);
109
- return true;
110
- }
111
- return false;
112
  }
113
 
114
- /**
115
- * Execute an HTTP Request
116
- *
117
- * @param Google_HttpRequest $request
118
- * the http request to be executed
119
- * @return Google_HttpRequest http request with the response http code,
120
- * response headers and response body filled in
121
- * @throws Google_IO_Exception on curl or IO error
122
- */
123
- public function makeRequest(Google_Http_Request $request)
124
- {
125
- // First, check to see if we have a valid cached version.
126
- $cached = $this->getCachedRequest($request);
127
- if ($cached !== false && $cached instanceof Google_Http_Request) {
128
- if (! $this->checkMustRevalidateCachedRequest($cached, $request)) {
129
- return $cached;
130
- }
131
- }
132
- if (array_key_exists($request->getRequestMethod(), self::$ENTITY_HTTP_METHODS)) {
133
- $request = $this->processEntityRequest($request);
134
- }
135
- list ($responseData, $responseHeaders, $respHttpCode) = $this->executeRequest($request);
136
- if ($respHttpCode == 304 && $cached) {
137
- // If the server responded NOT_MODIFIED, return the cached request.
138
- $this->updateCachedRequest($cached, $responseHeaders);
139
- return $cached;
140
- }
141
- if (! isset($responseHeaders['Date']) && ! isset($responseHeaders['date'])) {
142
- $responseHeaders['Date'] = date("r");
143
- }
144
- $request->setResponseHttpCode($respHttpCode);
145
- $request->setResponseHeaders($responseHeaders);
146
- $request->setResponseBody($responseData);
147
- // Store the request in cache (the function checks to see if the request
148
- // can actually be cached)
149
- $this->setCachedRequest($request);
150
- return $request;
151
  }
152
 
153
- /**
154
- * @visible for testing.
155
- *
156
- * @param Google_Http_Request $request
157
- * @return Google_Http_Request|bool Returns the cached object or
158
- * false if the operation was unsuccessful.
159
- */
160
- public function getCachedRequest(Google_Http_Request $request)
161
- {
162
- if (false === Google_Http_CacheParser::isRequestCacheable($request)) {
163
- return false;
164
- }
165
- return $this->client->getCache()->get($request->getCacheKey());
166
  }
167
 
168
- /**
169
- * @visible for testing
170
- * Process an http request that contains an enclosed entity.
171
- *
172
- * @param Google_Http_Request $request
173
- * @return Google_Http_Request Processed request with the enclosed entity.
174
- */
175
- public function processEntityRequest(Google_Http_Request $request)
176
- {
177
- $postBody = $request->getPostBody();
178
- $contentType = $request->getRequestHeader("content-type");
179
- // Set the default content-type as application/x-www-form-urlencoded.
180
- if (false == $contentType) {
181
- $contentType = self::FORM_URLENCODED;
182
- $request->setRequestHeaders(array(
183
- 'content-type' => $contentType
184
- ));
185
- }
186
- // Force the payload to match the content-type asserted in the header.
187
- if ($contentType == self::FORM_URLENCODED && is_array($postBody)) {
188
- $postBody = http_build_query($postBody, '', '&');
189
- $request->setPostBody($postBody);
190
- }
191
- // Make sure the content-length header is set.
192
- if (! $postBody || is_string($postBody)) {
193
- $postsLength = strlen($postBody);
194
- $request->setRequestHeaders(array(
195
- 'content-length' => $postsLength
196
- ));
197
- }
198
- return $request;
199
  }
200
 
201
- /**
202
- * Check if an already cached request must be revalidated, and if so update
203
- * the request with the correct ETag headers.
204
- *
205
- * @param Google_Http_Request $cached
206
- * A previously cached response.
207
- * @param Google_Http_Request $request
208
- * The outbound request.
209
- * return bool If the cached object needs to be revalidated, false if it is
210
- * still current and can be re-used.
211
- */
212
- protected function checkMustRevalidateCachedRequest($cached, $request)
213
- {
214
- if (Google_Http_CacheParser::mustRevalidate($cached)) {
215
- $addHeaders = array();
216
- if ($cached->getResponseHeader('etag')) {
217
- // [13.3.4] If an entity tag has been provided by the origin server,
218
- // we must use that entity tag in any cache-conditional request.
219
- $addHeaders['If-None-Match'] = $cached->getResponseHeader('etag');
220
- } elseif ($cached->getResponseHeader('date')) {
221
- $addHeaders['If-Modified-Since'] = $cached->getResponseHeader('date');
222
- }
223
- $request->setRequestHeaders($addHeaders);
224
- return true;
225
- } else {
226
- return false;
227
- }
228
  }
229
 
230
- /**
231
- * Update a cached request, using the headers from the last response.
232
- *
233
- * @param Google_HttpRequest $cached
234
- * A previously cached response.
235
- * @param
236
- * mixed Associative array of response headers from the last request.
237
- */
238
- protected function updateCachedRequest($cached, $responseHeaders)
239
- {
240
- if (isset($responseHeaders['connection'])) {
241
- $hopByHop = array_merge(self::$HOP_BY_HOP, explode(',', $responseHeaders['connection']));
242
- $endToEnd = array();
243
- foreach ($hopByHop as $key) {
244
- if (isset($responseHeaders[$key])) {
245
- $endToEnd[$key] = $responseHeaders[$key];
246
- }
247
- }
248
- $cached->setResponseHeaders($endToEnd);
249
- }
250
  }
251
 
252
- /**
253
- * Used by the IO lib and also the batch processing.
254
- *
255
- * @param
256
- * $respData
257
- * @param
258
- * $headerSize
259
- * @return array
260
- */
261
- public function parseHttpResponse($respData, $headerSize)
262
- {
263
- // check proxy header
264
- foreach (self::$CONNECTION_ESTABLISHED_HEADERS as $established_header) {
265
- if (stripos($respData, $established_header) !== false) {
266
- // existed, remove it
267
- $respData = str_ireplace($established_header, '', $respData);
268
- // Subtract the proxy header size unless the cURL bug prior to 7.30.0
269
- // is present which prevented the proxy header size from being taken into
270
- // account.
271
- if (! $this->needsQuirk()) {
272
- $headerSize -= strlen($established_header);
273
- }
274
- break;
275
- }
276
- }
277
- if ($headerSize) {
278
- $responseBody = substr($respData, $headerSize);
279
- $responseHeaders = substr($respData, 0, $headerSize);
280
- } else {
281
- $responseSegments = explode("\r\n\r\n", $respData, 2);
282
- $responseHeaders = $responseSegments[0];
283
- $responseBody = isset($responseSegments[1]) ? $responseSegments[1] : null;
284
- }
285
- $responseHeaders = $this->getHttpResponseHeaders($responseHeaders);
286
- return array(
287
- $responseHeaders,
288
- $responseBody
289
- );
290
  }
291
 
292
- /**
293
- * Parse out headers from raw headers
294
- *
295
- * @param
296
- * rawHeaders array or string
297
- * @return array
298
- */
299
- public function getHttpResponseHeaders($rawHeaders)
300
- {
301
- if (is_array($rawHeaders)) {
302
- return $this->parseArrayHeaders($rawHeaders);
303
- } else {
304
- return $this->parseStringHeaders($rawHeaders);
305
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  }
307
 
308
- private function parseStringHeaders($rawHeaders)
309
- {
310
- $headers = array();
311
- $responseHeaderLines = explode("\r\n", $rawHeaders);
312
- foreach ($responseHeaderLines as $headerLine) {
313
- if ($headerLine && strpos($headerLine, ':') !== false) {
314
- list ($header, $value) = explode(': ', $headerLine, 2);
315
- $header = strtolower($header);
316
- if (isset($headers[$header])) {
317
- $headers[$header] .= "\n" . $value;
318
- } else {
319
- $headers[$header] = $value;
320
- }
321
- }
 
 
 
 
 
 
 
 
 
322
  }
323
- return $headers;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  }
 
325
 
326
- private function parseArrayHeaders($rawHeaders)
327
- {
328
- $header_count = count($rawHeaders);
329
- $headers = array();
330
- for ($i = 0; $i < $header_count; $i ++) {
331
- $header = $rawHeaders[$i];
332
- // Times will have colons in - so we just want the first match.
333
- $header_parts = explode(': ', $header, 2);
334
- if (count($header_parts) == 2) {
335
- $headers[$header_parts[0]] = $header_parts[1];
336
- }
 
337
  }
338
- return $headers;
339
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
  /**
19
  * Abstract IO base class
20
  */
21
+
22
+ if (!class_exists('Google_Client')) {
23
+ require_once dirname(__FILE__) . '/../autoload.php';
24
+ }
25
 
26
  abstract class Google_IO_Abstract
27
  {
28
+ const UNKNOWN_CODE = 0;
29
+ const FORM_URLENCODED = 'application/x-www-form-urlencoded';
30
+ private static $CONNECTION_ESTABLISHED_HEADERS = array(
31
+ "HTTP/1.0 200 Connection established\r\n\r\n",
32
+ "HTTP/1.1 200 Connection established\r\n\r\n",
33
+ );
34
+ private static $ENTITY_HTTP_METHODS = array("POST" => null, "PUT" => null);
35
+ private static $HOP_BY_HOP = array(
36
+ 'connection' => true,
37
+ 'keep-alive' => true,
38
+ 'proxy-authenticate' => true,
39
+ 'proxy-authorization' => true,
40
+ 'te' => true,
41
+ 'trailers' => true,
42
+ 'transfer-encoding' => true,
43
+ 'upgrade' => true
44
+ );
45
 
 
46
 
47
+ /** @var Google_Client */
48
+ protected $client;
49
 
50
+ public function __construct(Google_Client $client)
51
+ {
52
+ $this->client = $client;
53
+ $timeout = $client->getClassConfig('Google_IO_Abstract', 'request_timeout_seconds');
54
+ if ($timeout > 0) {
55
+ $this->setTimeout($timeout);
56
+ }
57
+ }
58
 
59
+ /**
60
+ * Executes a Google_Http_Request
61
+ * @param Google_Http_Request $request the http request to be executed
62
+ * @return array containing response headers, body, and http code
63
+ * @throws Google_IO_Exception on curl or IO error
64
+ */
65
+ abstract public function executeRequest(Google_Http_Request $request);
66
 
67
+ /**
68
+ * Set options that update the transport implementation's behavior.
69
+ * @param $options
70
+ */
71
+ abstract public function setOptions($options);
72
 
73
+ /**
74
+ * Set the maximum request time in seconds.
75
+ * @param $timeout in seconds
76
+ */
77
+ abstract public function setTimeout($timeout);
78
+
79
+ /**
80
+ * Get the maximum request time in seconds.
81
+ * @return timeout in seconds
82
+ */
83
+ abstract public function getTimeout();
84
+
85
+ /**
86
+ * Test for the presence of a cURL header processing bug
87
+ *
88
+ * The cURL bug was present in versions prior to 7.30.0 and caused the header
89
+ * length to be miscalculated when a "Connection established" header added by
90
+ * some proxies was present.
91
+ *
92
+ * @return boolean
93
+ */
94
+ abstract protected function needsQuirk();
95
+
96
+ /**
97
+ * @visible for testing.
98
+ * Cache the response to an HTTP request if it is cacheable.
99
+ * @param Google_Http_Request $request
100
+ * @return bool Returns true if the insertion was successful.
101
+ * Otherwise, return false.
102
+ */
103
+ public function setCachedRequest(Google_Http_Request $request)
104
+ {
105
+ // Determine if the request is cacheable.
106
+ if (Google_Http_CacheParser::isResponseCacheable($request)) {
107
+ $this->client->getCache()->set($request->getCacheKey(), $request);
108
+ return true;
109
  }
110
 
111
+ return false;
112
+ }
113
+
114
+ /**
115
+ * Execute an HTTP Request
116
+ *
117
+ * @param Google_Http_Request $request the http request to be executed
118
+ * @return Google_Http_Request http request with the response http code,
119
+ * response headers and response body filled in
120
+ * @throws Google_IO_Exception on curl or IO error
121
+ */
122
+ public function makeRequest(Google_Http_Request $request)
123
+ {
124
+ // First, check to see if we have a valid cached version.
125
+ $cached = $this->getCachedRequest($request);
126
+ if ($cached !== false && $cached instanceof Google_Http_Request) {
127
+ if (!$this->checkMustRevalidateCachedRequest($cached, $request)) {
128
+ return $cached;
129
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  }
131
 
132
+ if (array_key_exists($request->getRequestMethod(), self::$ENTITY_HTTP_METHODS)) {
133
+ $request = $this->processEntityRequest($request);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
135
 
136
+ list($responseData, $responseHeaders, $respHttpCode) = $this->executeRequest($request);
137
+
138
+ if ($respHttpCode == 304 && $cached) {
139
+ // If the server responded NOT_MODIFIED, return the cached request.
140
+ $this->updateCachedRequest($cached, $responseHeaders);
141
+ return $cached;
 
 
 
 
 
 
 
142
  }
143
 
144
+ if (!isset($responseHeaders['Date']) && !isset($responseHeaders['date'])) {
145
+ $responseHeaders['date'] = date("r");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
  }
147
 
148
+ $request->setResponseHttpCode($respHttpCode);
149
+ $request->setResponseHeaders($responseHeaders);
150
+ $request->setResponseBody($responseData);
151
+ // Store the request in cache (the function checks to see if the request
152
+ // can actually be cached)
153
+ $this->setCachedRequest($request);
154
+ return $request;
155
+ }
156
+
157
+ /**
158
+ * @visible for testing.
159
+ * @param Google_Http_Request $request
160
+ * @return Google_Http_Request|bool Returns the cached object or
161
+ * false if the operation was unsuccessful.
162
+ */
163
+ public function getCachedRequest(Google_Http_Request $request)
164
+ {
165
+ if (false === Google_Http_CacheParser::isRequestCacheable($request)) {
166
+ return false;
 
 
 
 
 
 
 
 
167
  }
168
 
169
+ return $this->client->getCache()->get($request->getCacheKey());
170
+ }
171
+
172
+ /**
173
+ * @visible for testing
174
+ * Process an http request that contains an enclosed entity.
175
+ * @param Google_Http_Request $request
176
+ * @return Google_Http_Request Processed request with the enclosed entity.
177
+ */
178
+ public function processEntityRequest(Google_Http_Request $request)
179
+ {
180
+ $postBody = $request->getPostBody();
181
+ $contentType = $request->getRequestHeader("content-type");
182
+
183
+ // Set the default content-type as application/x-www-form-urlencoded.
184
+ if (false == $contentType) {
185
+ $contentType = self::FORM_URLENCODED;
186
+ $request->setRequestHeaders(array('content-type' => $contentType));
 
 
187
  }
188
 
189
+ // Force the payload to match the content-type asserted in the header.
190
+ if ($contentType == self::FORM_URLENCODED && is_array($postBody)) {
191
+ $postBody = http_build_query($postBody, '', '&');
192
+ $request->setPostBody($postBody);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  }
194
 
195
+ // Make sure the content-length header is set.
196
+ if (!$postBody || is_string($postBody)) {
197
+ $postsLength = strlen($postBody);
198
+ $request->setRequestHeaders(array('content-length' => $postsLength));
199
+ }
200
+
201
+ return $request;
202
+ }
203
+
204
+ /**
205
+ * Check if an already cached request must be revalidated, and if so update
206
+ * the request with the correct ETag headers.
207
+ * @param Google_Http_Request $cached A previously cached response.
208
+ * @param Google_Http_Request $request The outbound request.
209
+ * return bool If the cached object needs to be revalidated, false if it is
210
+ * still current and can be re-used.
211
+ */
212
+ protected function checkMustRevalidateCachedRequest($cached, $request)
213
+ {
214
+ if (Google_Http_CacheParser::mustRevalidate($cached)) {
215
+ $addHeaders = array();
216
+ if ($cached->getResponseHeader('etag')) {
217
+ // [13.3.4] If an entity tag has been provided by the origin server,
218
+ // we must use that entity tag in any cache-conditional request.
219
+ $addHeaders['If-None-Match'] = $cached->getResponseHeader('etag');
220
+ } elseif ($cached->getResponseHeader('date')) {
221
+ $addHeaders['If-Modified-Since'] = $cached->getResponseHeader('date');
222
+ }
223
+
224
+ $request->setRequestHeaders($addHeaders);
225
+ return true;
226
+ } else {
227
+ return false;
228
+ }
229
+ }
230
+
231
+ /**
232
+ * Update a cached request, using the headers from the last response.
233
+ * @param Google_Http_Request $cached A previously cached response.
234
+ * @param mixed Associative array of response headers from the last request.
235
+ */
236
+ protected function updateCachedRequest($cached, $responseHeaders)
237
+ {
238
+ $hopByHop = self::$HOP_BY_HOP;
239
+ if (!empty($responseHeaders['connection'])) {
240
+ $connectionHeaders = array_map(
241
+ 'strtolower',
242
+ array_filter(
243
+ array_map('trim', explode(',', $responseHeaders['connection']))
244
+ )
245
+ );
246
+ $hopByHop += array_fill_keys($connectionHeaders, true);
247
  }
248
 
249
+ $endToEnd = array_diff_key($responseHeaders, $hopByHop);
250
+ $cached->setResponseHeaders($endToEnd);
251
+ }
252
+
253
+ /**
254
+ * Used by the IO lib and also the batch processing.
255
+ *
256
+ * @param $respData
257
+ * @param $headerSize
258
+ * @return array
259
+ */
260
+ public function parseHttpResponse($respData, $headerSize)
261
+ {
262
+ // check proxy header
263
+ foreach (self::$CONNECTION_ESTABLISHED_HEADERS as $established_header) {
264
+ if (stripos($respData, $established_header) !== false) {
265
+ // existed, remove it
266
+ $respData = str_ireplace($established_header, '', $respData);
267
+ // Subtract the proxy header size unless the cURL bug prior to 7.30.0
268
+ // is present which prevented the proxy header size from being taken into
269
+ // account.
270
+ if (!$this->needsQuirk()) {
271
+ $headerSize -= strlen($established_header);
272
  }
273
+ break;
274
+ }
275
+ }
276
+
277
+ if ($headerSize) {
278
+ $responseBody = substr($respData, $headerSize);
279
+ $responseHeaders = substr($respData, 0, $headerSize);
280
+ } else {
281
+ $responseSegments = explode("\r\n\r\n", $respData, 2);
282
+ $responseHeaders = $responseSegments[0];
283
+ $responseBody = isset($responseSegments[1]) ? $responseSegments[1] :
284
+ null;
285
+ }
286
+
287
+ $responseHeaders = $this->getHttpResponseHeaders($responseHeaders);
288
+ return array($responseHeaders, $responseBody);
289
+ }
290
+
291
+ /**
292
+ * Parse out headers from raw headers
293
+ * @param rawHeaders array or string
294
+ * @return array
295
+ */
296
+ public function getHttpResponseHeaders($rawHeaders)
297
+ {
298
+ if (is_array($rawHeaders)) {
299
+ return $this->parseArrayHeaders($rawHeaders);
300
+ } else {
301
+ return $this->parseStringHeaders($rawHeaders);
302
  }
303
+ }
304
 
305
+ private function parseStringHeaders($rawHeaders)
306
+ {
307
+ $headers = array();
308
+ $responseHeaderLines = explode("\r\n", $rawHeaders);
309
+ foreach ($responseHeaderLines as $headerLine) {
310
+ if ($headerLine && strpos($headerLine, ':') !== false) {
311
+ list($header, $value) = explode(': ', $headerLine, 2);
312
+ $header = strtolower($header);
313
+ if (isset($headers[$header])) {
314
+ $headers[$header] .= "\n" . $value;
315
+ } else {
316
+ $headers[$header] = $value;
317
  }
318
+ }
319
  }
320
+ return $headers;
321
+ }
322
+
323
+ private function parseArrayHeaders($rawHeaders)
324
+ {
325
+ $header_count = count($rawHeaders);
326
+ $headers = array();
327
+
328
+ for ($i = 0; $i < $header_count; $i++) {
329
+ $header = $rawHeaders[$i];
330
+ // Times will have colons in - so we just want the first match.
331
+ $header_parts = explode(': ', $header, 2);
332
+ if (count($header_parts) == 2) {
333
+ $headers[strtolower($header_parts[0])] = $header_parts[1];
334
+ }
335
+ }
336
+
337
+ return $headers;
338
+ }
339
  }
tools/src/Google/IO/Curl.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,140 +14,181 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
 
17
  /**
18
  * Curl based implementation of Google_IO.
19
  *
20
  * @author Stuart Langley <slangley@google.com>
21
  */
22
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
23
 
24
  class Google_IO_Curl extends Google_IO_Abstract
25
  {
26
- // cURL hex representation of version 7.30.0
27
- const NO_QUIRK_VERSION = 0x071E00;
28
-
29
- private $options = array();
30
-
31
- /**
32
- * Execute an HTTP Request
33
- *
34
- * @param Google_HttpRequest $request
35
- * the http request to be executed
36
- * @return Google_HttpRequest http request with the response http code,
37
- * response headers and response body filled in
38
- * @throws Google_IO_Exception on curl or IO error
39
- */
40
- public function executeRequest(Google_Http_Request $request)
41
- {
42
- $curl = curl_init();
43
- if ($request->getPostBody()) {
44
- curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getPostBody());
45
- }
46
- $requestHeaders = $request->getRequestHeaders();
47
- if ($requestHeaders && is_array($requestHeaders)) {
48
- $curlHeaders = array();
49
- foreach ($requestHeaders as $k => $v) {
50
- $curlHeaders[] = "$k: $v";
51
- }
52
- curl_setopt($curl, CURLOPT_HTTPHEADER, $curlHeaders);
53
- }
54
- curl_setopt($curl, CURLOPT_URL, $request->getUrl());
55
- curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getRequestMethod());
56
- curl_setopt($curl, CURLOPT_USERAGENT, $request->getUserAgent());
57
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
58
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
59
- // 1 is CURL_SSLVERSION_TLSv1, which is not always defined in PHP.
60
- curl_setopt($curl, CURLOPT_SSLVERSION, 1);
61
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
62
- curl_setopt($curl, CURLOPT_HEADER, true);
63
- if ($request->canGzip()) {
64
- curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
65
- }
66
- $options = $this->client->getClassConfig('Google_IO_Curl', 'options');
67
- if (is_array($options)) {
68
- $this->setOptions($options);
69
- }
70
- foreach ($this->options as $key => $var) {
71
- curl_setopt($curl, $key, $var);
72
- }
73
- if (! isset($this->options[CURLOPT_CAINFO])) {
74
- curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . '/cacerts.pem');
75
- }
76
- $this->client->getLogger()->debug('cURL request', array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  'url' => $request->getUrl(),
78
  'method' => $request->getRequestMethod(),
79
  'headers' => $requestHeaders,
80
  'body' => $request->getPostBody()
81
- ));
82
- $response = curl_exec($curl);
83
- if ($response === false) {
84
- $error = curl_error($curl);
85
- $this->client->getLogger()->error('cURL ' . $error);
86
- throw new Google_IO_Exception($error);
87
- }
88
- $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
89
- list ($responseHeaders, $responseBody) = $this->parseHttpResponse($response, $headerSize);
90
- $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
91
- $this->client->getLogger()->debug('cURL response', array(
 
 
 
 
 
 
 
 
 
92
  'code' => $responseCode,
93
  'headers' => $responseHeaders,
94
- 'body' => $responseBody
95
- ));
96
- return array(
97
- $responseBody,
98
- $responseHeaders,
99
- $responseCode
100
- );
101
- }
102
 
103
- /**
104
- * Set options that update the transport implementation's behavior.
105
- *
106
- * @param
107
- * $options
108
- */
109
- public function setOptions($options)
110
- {
111
- $this->options = $options + $this->options;
112
- }
113
 
114
- /**
115
- * Set the maximum request time in seconds.
116
- *
117
- * @param $timeout in
118
- * seconds
119
- */
120
- public function setTimeout($timeout)
121
- {
122
- // Since this timeout is really for putting a bound on the time
123
- // we'll set them both to the same. If you need to specify a longer
124
- // CURLOPT_TIMEOUT, or a tigher CONNECTTIMEOUT, the best thing to
125
- // do is use the setOptions method for the values individually.
126
- $this->options[CURLOPT_CONNECTTIMEOUT] = $timeout;
127
- $this->options[CURLOPT_TIMEOUT] = $timeout;
128
- }
129
 
130
- /**
131
- * Get the maximum request time in seconds.
132
- *
133
- * @return timeout in seconds
134
- */
135
- public function getTimeout()
136
- {
137
- return $this->options[CURLOPT_TIMEOUT];
138
- }
 
 
 
 
139
 
140
- /**
141
- * Test for the presence of a cURL header processing bug
142
- *
143
- * {@inheritDoc}
144
- *
145
- * @return boolean
146
- */
147
- protected function needsQuirk()
148
- {
149
- $ver = curl_version();
150
- $versionNum = $ver['version_number'];
151
- return $versionNum < Google_IO_Curl::NO_QUIRK_VERSION;
 
 
 
 
 
 
 
 
152
  }
 
 
 
 
 
153
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
  /**
19
  * Curl based implementation of Google_IO.
20
  *
21
  * @author Stuart Langley <slangley@google.com>
22
  */
23
+
24
+ if (!class_exists('Google_Client')) {
25
+ require_once dirname(__FILE__) . '/../autoload.php';
26
+ }
27
 
28
  class Google_IO_Curl extends Google_IO_Abstract
29
  {
30
+ // cURL hex representation of version 7.30.0
31
+ const NO_QUIRK_VERSION = 0x071E00;
32
+
33
+ private $options = array();
34
+
35
+ /** @var bool $disableProxyWorkaround */
36
+ private $disableProxyWorkaround;
37
+
38
+ public function __construct(Google_Client $client)
39
+ {
40
+ if (!extension_loaded('curl')) {
41
+ $error = 'The cURL IO handler requires the cURL extension to be enabled';
42
+ $client->getLogger()->critical($error);
43
+ throw new Google_IO_Exception($error);
44
+ }
45
+
46
+ parent::__construct($client);
47
+
48
+ $this->disableProxyWorkaround = $this->client->getClassConfig(
49
+ 'Google_IO_Curl',
50
+ 'disable_proxy_workaround'
51
+ );
52
+ }
53
+
54
+ /**
55
+ * Execute an HTTP Request
56
+ *
57
+ * @param Google_Http_Request $request the http request to be executed
58
+ * @return array containing response headers, body, and http code
59
+ * @throws Google_IO_Exception on curl or IO error
60
+ */
61
+ public function executeRequest(Google_Http_Request $request)
62
+ {
63
+ $curl = curl_init();
64
+
65
+ if ($request->getPostBody()) {
66
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getPostBody());
67
+ }
68
+
69
+ $requestHeaders = $request->getRequestHeaders();
70
+ if ($requestHeaders && is_array($requestHeaders)) {
71
+ $curlHeaders = array();
72
+ foreach ($requestHeaders as $k => $v) {
73
+ $curlHeaders[] = "$k: $v";
74
+ }
75
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $curlHeaders);
76
+ }
77
+ curl_setopt($curl, CURLOPT_URL, $request->getUrl());
78
+
79
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getRequestMethod());
80
+ curl_setopt($curl, CURLOPT_USERAGENT, $request->getUserAgent());
81
+
82
+ curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
83
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
84
+
85
+ // The SSL version will be determined by the underlying library
86
+ // @see https://github.com/google/google-api-php-client/pull/644
87
+ //curl_setopt($curl, CURLOPT_SSLVERSION, 1);
88
+
89
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
90
+ curl_setopt($curl, CURLOPT_HEADER, true);
91
+
92
+ if ($request->canGzip()) {
93
+ curl_setopt($curl, CURLOPT_ENCODING, 'gzip,deflate');
94
+ }
95
+
96
+ $options = $this->client->getClassConfig('Google_IO_Curl', 'options');
97
+ if (is_array($options)) {
98
+ $this->setOptions($options);
99
+ }
100
+
101
+ foreach ($this->options as $key => $var) {
102
+ curl_setopt($curl, $key, $var);
103
+ }
104
+
105
+ if (!isset($this->options[CURLOPT_CAINFO])) {
106
+ curl_setopt($curl, CURLOPT_CAINFO, dirname(__FILE__) . '/cacerts.pem');
107
+ }
108
+
109
+ $this->client->getLogger()->debug(
110
+ 'cURL request',
111
+ array(
112
  'url' => $request->getUrl(),
113
  'method' => $request->getRequestMethod(),
114
  'headers' => $requestHeaders,
115
  'body' => $request->getPostBody()
116
+ )
117
+ );
118
+
119
+ $response = curl_exec($curl);
120
+ if ($response === false) {
121
+ $error = curl_error($curl);
122
+ $code = curl_errno($curl);
123
+ $map = $this->client->getClassConfig('Google_IO_Exception', 'retry_map');
124
+
125
+ $this->client->getLogger()->error('cURL ' . $error);
126
+ throw new Google_IO_Exception($error, $code, null, $map);
127
+ }
128
+ $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
129
+
130
+ list($responseHeaders, $responseBody) = $this->parseHttpResponse($response, $headerSize);
131
+ $responseCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
132
+
133
+ $this->client->getLogger()->debug(
134
+ 'cURL response',
135
+ array(
136
  'code' => $responseCode,
137
  'headers' => $responseHeaders,
138
+ 'body' => $responseBody,
139
+ )
140
+ );
 
 
 
 
 
141
 
142
+ return array($responseBody, $responseHeaders, $responseCode);
143
+ }
 
 
 
 
 
 
 
 
144
 
145
+ /**
146
+ * Set options that update the transport implementation's behavior.
147
+ * @param $options
148
+ */
149
+ public function setOptions($options)
150
+ {
151
+ $this->options = $options + $this->options;
152
+ }
 
 
 
 
 
 
 
153
 
154
+ /**
155
+ * Set the maximum request time in seconds.
156
+ * @param $timeout in seconds
157
+ */
158
+ public function setTimeout($timeout)
159
+ {
160
+ // Since this timeout is really for putting a bound on the time
161
+ // we'll set them both to the same. If you need to specify a longer
162
+ // CURLOPT_TIMEOUT, or a higher CONNECTTIMEOUT, the best thing to
163
+ // do is use the setOptions method for the values individually.
164
+ $this->options[CURLOPT_CONNECTTIMEOUT] = $timeout;
165
+ $this->options[CURLOPT_TIMEOUT] = $timeout;
166
+ }
167
 
168
+ /**
169
+ * Get the maximum request time in seconds.
170
+ * @return timeout in seconds
171
+ */
172
+ public function getTimeout()
173
+ {
174
+ return $this->options[CURLOPT_TIMEOUT];
175
+ }
176
+
177
+ /**
178
+ * Test for the presence of a cURL header processing bug
179
+ *
180
+ * {@inheritDoc}
181
+ *
182
+ * @return boolean
183
+ */
184
+ protected function needsQuirk()
185
+ {
186
+ if ($this->disableProxyWorkaround) {
187
+ return false;
188
  }
189
+
190
+ $ver = curl_version();
191
+ $versionNum = $ver['version_number'];
192
+ return $versionNum < Google_IO_Curl::NO_QUIRK_VERSION;
193
+ }
194
  }
tools/src/Google/IO/Exception.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,8 +14,56 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
18
 
19
- class Google_IO_Exception extends Google_Exception
 
 
 
 
20
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
 
17
 
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
+
22
+ class Google_IO_Exception extends Google_Exception implements Google_Task_Retryable
23
  {
24
+ /**
25
+ * @var array $retryMap Map of errors with retry counts.
26
+ */
27
+ private $retryMap = array();
28
+
29
+ /**
30
+ * Creates a new IO exception with an optional retry map.
31
+ *
32
+ * @param string $message
33
+ * @param int $code
34
+ * @param Exception|null $previous
35
+ * @param array|null $retryMap Map of errors with retry counts.
36
+ */
37
+ public function __construct(
38
+ $message,
39
+ $code = 0,
40
+ Exception $previous = null,
41
+ array $retryMap = null
42
+ ) {
43
+ if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
44
+ parent::__construct($message, $code, $previous);
45
+ } else {
46
+ parent::__construct($message, $code);
47
+ }
48
+
49
+ if (is_array($retryMap)) {
50
+ $this->retryMap = $retryMap;
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Gets the number of times the associated task can be retried.
56
+ *
57
+ * NOTE: -1 is returned if the task can be retried indefinitely
58
+ *
59
+ * @return integer
60
+ */
61
+ public function allowedRetries()
62
+ {
63
+ if (isset($this->retryMap[$this->code])) {
64
+ return $this->retryMap[$this->code];
65
+ }
66
+
67
+ return 0;
68
+ }
69
  }
tools/src/Google/IO/Stream.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,189 +14,230 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
 
17
  /**
18
  * Http Streams based implementation of Google_IO.
19
  *
20
  * @author Stuart Langley <slangley@google.com>
21
  */
22
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
23
 
24
  class Google_IO_Stream extends Google_IO_Abstract
25
  {
 
 
 
 
 
26
 
27
- const TIMEOUT = "timeout";
 
 
 
28
 
29
- const ZLIB = "compress.zlib://";
 
 
30
 
31
- private $options = array();
 
 
 
 
 
 
 
32
 
33
- private $trappedErrorNumber;
 
34
 
35
- private $trappedErrorString;
 
 
 
 
 
 
 
 
 
36
 
37
- private static $DEFAULT_HTTP_CONTEXT = array(
38
- "follow_location" => 0,
39
- "ignore_errors" => 1
40
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
- private static $DEFAULT_SSL_CONTEXT = array(
43
- "verify_peer" => true
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  );
45
 
46
- /**
47
- * Execute an HTTP Request
48
- *
49
- * @param Google_HttpRequest $request
50
- * the http request to be executed
51
- * @return Google_HttpRequest http request with the response http code,
52
- * response headers and response body filled in
53
- * @throws Google_IO_Exception on curl or IO error
54
- */
55
- public function executeRequest(Google_Http_Request $request)
56
- {
57
- $default_options = stream_context_get_options(stream_context_get_default());
58
- $requestHttpContext = array_key_exists('http', $default_options) ? $default_options['http'] : array();
59
- if ($request->getPostBody()) {
60
- $requestHttpContext["content"] = $request->getPostBody();
61
- }
62
- $requestHeaders = $request->getRequestHeaders();
63
- if ($requestHeaders && is_array($requestHeaders)) {
64
- $headers = "";
65
- foreach ($requestHeaders as $k => $v) {
66
- $headers .= "$k: $v\r\n";
67
- }
68
- $requestHttpContext["header"] = $headers;
69
- }
70
- $requestHttpContext["method"] = $request->getRequestMethod();
71
- $requestHttpContext["user_agent"] = $request->getUserAgent();
72
- $requestSslContext = array_key_exists('ssl', $default_options) ? $default_options['ssl'] : array();
73
- if (! array_key_exists("cafile", $requestSslContext)) {
74
- $requestSslContext["cafile"] = dirname(__FILE__) . '/cacerts.pem';
75
- }
76
- $options = array(
77
- "http" => array_merge(self::$DEFAULT_HTTP_CONTEXT, $requestHttpContext),
78
- "ssl" => array_merge(self::$DEFAULT_SSL_CONTEXT, $requestSslContext)
79
- );
80
- $context = stream_context_create($options);
81
- $url = $request->getUrl();
82
- if ($request->canGzip()) {
83
- $url = self::ZLIB . $url;
84
- }
85
- $this->client->getLogger()->debug('Stream request', array(
86
  'url' => $url,
87
  'method' => $request->getRequestMethod(),
88
  'headers' => $requestHeaders,
89
  'body' => $request->getPostBody()
90
- ));
91
- // We are trapping any thrown errors in this method only and
92
- // throwing an exception.
93
- $this->trappedErrorNumber = null;
94
- $this->trappedErrorString = null;
95
- // START - error trap.
96
- set_error_handler(array(
97
- $this,
98
- 'trapError'
99
- ));
100
- $fh = fopen($url, 'r', false, $context);
101
- restore_error_handler();
102
- // END - error trap.
103
- if ($this->trappedErrorNumber) {
104
- $error = sprintf("HTTP Error: Unable to connect: '%s'", $this->trappedErrorString);
105
- $this->client->getLogger()->error('Stream ' . $error);
106
- throw new Google_IO_Exception($error, $this->trappedErrorNumber);
107
- }
108
- $response_data = false;
109
- $respHttpCode = self::UNKNOWN_CODE;
110
- if ($fh) {
111
- if (isset($this->options[self::TIMEOUT])) {
112
- stream_set_timeout($fh, $this->options[self::TIMEOUT]);
113
- }
114
- $response_data = stream_get_contents($fh);
115
- fclose($fh);
116
- $respHttpCode = $this->getHttpResponseCode($http_response_header);
117
- }
118
- if (false === $response_data) {
119
- $error = sprintf("HTTP Error: Unable to connect: '%s'", $respHttpCode);
120
- $this->client->getLogger()->error('Stream ' . $error);
121
- throw new Google_IO_Exception($error, $respHttpCode);
122
- }
123
- $responseHeaders = $this->getHttpResponseHeaders($http_response_header);
124
- $this->client->getLogger()->debug('Stream response', array(
125
- 'code' => $respHttpCode,
126
- 'headers' => $responseHeaders,
127
- 'body' => $response_data
128
- ));
129
- return array(
130
- $response_data,
131
- $responseHeaders,
132
- $respHttpCode
133
- );
134
- }
135
 
136
- /**
137
- * Set options that update the transport implementation's behavior.
138
- *
139
- * @param
140
- * $options
141
- */
142
- public function setOptions($options)
143
- {
144
- $this->options = $options + $this->options;
145
- }
146
 
147
- /**
148
- * Method to handle errors, used for error handling around
149
- * stream connection methods.
150
- */
151
- public function trapError($errno, $errstr)
152
- {
153
- $this->trappedErrorNumber = $errno;
154
- $this->trappedErrorString = $errstr;
155
- }
156
 
157
- /**
158
- * Set the maximum request time in seconds.
159
- *
160
- * @param $timeout in
161
- * seconds
162
- */
163
- public function setTimeout($timeout)
164
- {
165
- $this->options[self::TIMEOUT] = $timeout;
166
  }
167
 
168
- /**
169
- * Get the maximum request time in seconds.
170
- *
171
- * @return timeout in seconds
172
- */
173
- public function getTimeout()
174
- {
175
- return $this->options[self::TIMEOUT];
 
 
 
176
  }
177
 
178
- /**
179
- * Test for the presence of a cURL header processing bug
180
- *
181
- * {@inheritDoc}
182
- *
183
- * @return boolean
184
- */
185
- protected function needsQuirk()
186
- {
187
- return false;
188
  }
189
 
190
- protected function getHttpResponseCode($response_headers)
191
- {
192
- $header_count = count($response_headers);
193
- for ($i = 0; $i < $header_count; $i ++) {
194
- $header = $response_headers[$i];
195
- if (strncasecmp("HTTP", $header, strlen("HTTP")) == 0) {
196
- $response = explode(' ', $header);
197
- return $response[1];
198
- }
199
- }
200
- return self::UNKNOWN_CODE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
  }
 
 
202
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
  /**
19
  * Http Streams based implementation of Google_IO.
20
  *
21
  * @author Stuart Langley <slangley@google.com>
22
  */
23
+
24
+ if (!class_exists('Google_Client')) {
25
+ require_once dirname(__FILE__) . '/../autoload.php';
26
+ }
27
 
28
  class Google_IO_Stream extends Google_IO_Abstract
29
  {
30
+ const TIMEOUT = "timeout";
31
+ const ZLIB = "compress.zlib://";
32
+ private $options = array();
33
+ private $trappedErrorNumber;
34
+ private $trappedErrorString;
35
 
36
+ private static $DEFAULT_HTTP_CONTEXT = array(
37
+ "follow_location" => 0,
38
+ "ignore_errors" => 1,
39
+ );
40
 
41
+ private static $DEFAULT_SSL_CONTEXT = array(
42
+ "verify_peer" => true,
43
+ );
44
 
45
+ public function __construct(Google_Client $client)
46
+ {
47
+ if (!ini_get('allow_url_fopen')) {
48
+ $error = 'The stream IO handler requires the allow_url_fopen runtime ' .
49
+ 'configuration to be enabled';
50
+ $client->getLogger()->critical($error);
51
+ throw new Google_IO_Exception($error);
52
+ }
53
 
54
+ parent::__construct($client);
55
+ }
56
 
57
+ /**
58
+ * Execute an HTTP Request
59
+ *
60
+ * @param Google_Http_Request $request the http request to be executed
61
+ * @return array containing response headers, body, and http code
62
+ * @throws Google_IO_Exception on curl or IO error
63
+ */
64
+ public function executeRequest(Google_Http_Request $request)
65
+ {
66
+ $default_options = stream_context_get_options(stream_context_get_default());
67
 
68
+ $requestHttpContext = array_key_exists('http', $default_options) ?
69
+ $default_options['http'] : array();
70
+
71
+ if ($request->getPostBody()) {
72
+ $requestHttpContext["content"] = $request->getPostBody();
73
+ }
74
+
75
+ $requestHeaders = $request->getRequestHeaders();
76
+ if ($requestHeaders && is_array($requestHeaders)) {
77
+ $headers = "";
78
+ foreach ($requestHeaders as $k => $v) {
79
+ $headers .= "$k: $v\r\n";
80
+ }
81
+ $requestHttpContext["header"] = $headers;
82
+ }
83
+
84
+ $requestHttpContext["method"] = $request->getRequestMethod();
85
+ $requestHttpContext["user_agent"] = $request->getUserAgent();
86
 
87
+ $requestSslContext = array_key_exists('ssl', $default_options) ?
88
+ $default_options['ssl'] : array();
89
+
90
+ if (!$this->client->isAppEngine() && !array_key_exists("cafile", $requestSslContext)) {
91
+ $requestSslContext["cafile"] = dirname(__FILE__) . '/cacerts.pem';
92
+ }
93
+
94
+ $options = array(
95
+ "http" => array_merge(
96
+ self::$DEFAULT_HTTP_CONTEXT,
97
+ $requestHttpContext
98
+ ),
99
+ "ssl" => array_merge(
100
+ self::$DEFAULT_SSL_CONTEXT,
101
+ $requestSslContext
102
+ )
103
  );
104
 
105
+ $context = stream_context_create($options);
106
+
107
+ $url = $request->getUrl();
108
+
109
+ if ($request->canGzip()) {
110
+ $url = self::ZLIB . $url;
111
+ }
112
+
113
+ $this->client->getLogger()->debug(
114
+ 'Stream request',
115
+ array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116
  'url' => $url,
117
  'method' => $request->getRequestMethod(),
118
  'headers' => $requestHeaders,
119
  'body' => $request->getPostBody()
120
+ )
121
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
 
123
+ // We are trapping any thrown errors in this method only and
124
+ // throwing an exception.
125
+ $this->trappedErrorNumber = null;
126
+ $this->trappedErrorString = null;
 
 
 
 
 
 
127
 
128
+ // START - error trap.
129
+ set_error_handler(array($this, 'trapError'));
130
+ $fh = fopen($url, 'r', false, $context);
131
+ restore_error_handler();
132
+ // END - error trap.
 
 
 
 
133
 
134
+ if ($this->trappedErrorNumber) {
135
+ $error = sprintf(
136
+ "HTTP Error: Unable to connect: '%s'",
137
+ $this->trappedErrorString
138
+ );
139
+
140
+ $this->client->getLogger()->error('Stream ' . $error);
141
+ throw new Google_IO_Exception($error, $this->trappedErrorNumber);
 
142
  }
143
 
144
+ $response_data = false;
145
+ $respHttpCode = self::UNKNOWN_CODE;
146
+ if ($fh) {
147
+ if (isset($this->options[self::TIMEOUT])) {
148
+ stream_set_timeout($fh, $this->options[self::TIMEOUT]);
149
+ }
150
+
151
+ $response_data = stream_get_contents($fh);
152
+ fclose($fh);
153
+
154
+ $respHttpCode = $this->getHttpResponseCode($http_response_header);
155
  }
156
 
157
+ if (false === $response_data) {
158
+ $error = sprintf(
159
+ "HTTP Error: Unable to connect: '%s'",
160
+ $respHttpCode
161
+ );
162
+
163
+ $this->client->getLogger()->error('Stream ' . $error);
164
+ throw new Google_IO_Exception($error, $respHttpCode);
 
 
165
  }
166
 
167
+ $responseHeaders = $this->getHttpResponseHeaders($http_response_header);
168
+
169
+ $this->client->getLogger()->debug(
170
+ 'Stream response',
171
+ array(
172
+ 'code' => $respHttpCode,
173
+ 'headers' => $responseHeaders,
174
+ 'body' => $response_data,
175
+ )
176
+ );
177
+
178
+ return array($response_data, $responseHeaders, $respHttpCode);
179
+ }
180
+
181
+ /**
182
+ * Set options that update the transport implementation's behavior.
183
+ * @param $options
184
+ */
185
+ public function setOptions($options)
186
+ {
187
+ $this->options = $options + $this->options;
188
+ }
189
+
190
+ /**
191
+ * Method to handle errors, used for error handling around
192
+ * stream connection methods.
193
+ */
194
+ public function trapError($errno, $errstr)
195
+ {
196
+ $this->trappedErrorNumber = $errno;
197
+ $this->trappedErrorString = $errstr;
198
+ }
199
+
200
+ /**
201
+ * Set the maximum request time in seconds.
202
+ * @param $timeout in seconds
203
+ */
204
+ public function setTimeout($timeout)
205
+ {
206
+ $this->options[self::TIMEOUT] = $timeout;
207
+ }
208
+
209
+ /**
210
+ * Get the maximum request time in seconds.
211
+ * @return timeout in seconds
212
+ */
213
+ public function getTimeout()
214
+ {
215
+ return $this->options[self::TIMEOUT];
216
+ }
217
+
218
+ /**
219
+ * Test for the presence of a cURL header processing bug
220
+ *
221
+ * {@inheritDoc}
222
+ *
223
+ * @return boolean
224
+ */
225
+ protected function needsQuirk()
226
+ {
227
+ return false;
228
+ }
229
+
230
+ protected function getHttpResponseCode($response_headers)
231
+ {
232
+ $header_count = count($response_headers);
233
+
234
+ for ($i = 0; $i < $header_count; $i++) {
235
+ $header = $response_headers[$i];
236
+ if (strncasecmp("HTTP", $header, strlen("HTTP")) == 0) {
237
+ $response = explode(' ', $header);
238
+ return $response[1];
239
+ }
240
  }
241
+ return self::UNKNOWN_CODE;
242
+ }
243
  }
tools/src/Google/Logger/Abstract.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * Abstract logging class based on the PSR-3 standard.
@@ -26,385 +29,380 @@ require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
26
  */
27
  abstract class Google_Logger_Abstract
28
  {
29
-
30
- /**
31
- * Default log format
32
- */
33
- const DEFAULT_LOG_FORMAT = "[%datetime%] %level%: %message% %context%\n";
34
-
35
- /**
36
- * Default date format
37
- *
38
- * Example: 16/Nov/2014:03:26:16 -0500
39
- */
40
- const DEFAULT_DATE_FORMAT = 'd/M/Y:H:i:s O';
41
-
42
- /**
43
- * System is unusable
44
- */
45
- const EMERGENCY = 'emergency';
46
-
47
- /**
48
- * Action must be taken immediately
49
- *
50
- * Example: Entire website down, database unavailable, etc. This should
51
- * trigger the SMS alerts and wake you up.
52
- */
53
- const ALERT = 'alert';
54
-
55
- /**
56
- * Critical conditions
57
- *
58
- * Example: Application component unavailable, unexpected exception.
59
- */
60
- const CRITICAL = 'critical';
61
-
62
- /**
63
- * Runtime errors that do not require immediate action but should typically
64
- * be logged and monitored.
65
- */
66
- const ERROR = 'error';
67
-
68
- /**
69
- * Exceptional occurrences that are not errors.
70
- *
71
- * Example: Use of deprecated APIs, poor use of an API, undesirable things
72
- * that are not necessarily wrong.
73
- */
74
- const WARNING = 'warning';
75
-
76
- /**
77
- * Normal but significant events.
78
- */
79
- const NOTICE = 'notice';
80
-
81
- /**
82
- * Interesting events.
83
- *
84
- * Example: User logs in, SQL logs.
85
- */
86
- const INFO = 'info';
87
-
88
- /**
89
- * Detailed debug information.
90
- */
91
- const DEBUG = 'debug';
92
-
93
- /**
94
- *
95
- * @var array $levels Logging levels
96
- */
97
- protected static $levels = array(
98
- self::EMERGENCY => 600,
99
- self::ALERT => 550,
100
- self::CRITICAL => 500,
101
- self::ERROR => 400,
102
- self::WARNING => 300,
103
- self::NOTICE => 250,
104
- self::INFO => 200,
105
- self::DEBUG => 100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  );
107
 
108
- /**
109
- *
110
- * @var integer $level The minimum logging level
111
- */
112
- protected $level = self::DEBUG;
113
-
114
- /**
115
- *
116
- * @var string $logFormat The current log format
117
- */
118
- protected $logFormat = self::DEFAULT_LOG_FORMAT;
119
-
120
- /**
121
- *
122
- * @var string $dateFormat The current date format
123
- */
124
- protected $dateFormat = self::DEFAULT_DATE_FORMAT;
125
-
126
- /**
127
- *
128
- * @var boolean $allowNewLines If newlines are allowed
129
- */
130
- protected $allowNewLines = false;
131
-
132
- /**
133
- *
134
- * @param Google_Client $client
135
- * The current Google client
136
- */
137
- public function __construct(Google_Client $client)
138
- {
139
- $this->setLevel($client->getClassConfig('Google_Logger_Abstract', 'level'));
140
- $format = $client->getClassConfig('Google_Logger_Abstract', 'log_format');
141
- $this->logFormat = $format ? $format : self::DEFAULT_LOG_FORMAT;
142
- $format = $client->getClassConfig('Google_Logger_Abstract', 'date_format');
143
- $this->dateFormat = $format ? $format : self::DEFAULT_DATE_FORMAT;
144
- $this->allowNewLines = (bool) $client->getClassConfig('Google_Logger_Abstract', 'allow_newlines');
145
- }
146
 
147
- /**
148
- * Sets the minimum logging level that this logger handles.
149
- *
150
- * @param integer $level
151
- */
152
- public function setLevel($level)
153
- {
154
- $this->level = $this->normalizeLevel($level);
155
- }
156
 
157
- /**
158
- * Checks if the logger should handle messages at the provided level.
159
- *
160
- * @param integer $level
161
- * @return boolean
162
- */
163
- public function shouldHandle($level)
164
- {
165
- return $this->normalizeLevel($level) >= $this->level;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  }
167
 
168
- /**
169
- * System is unusable.
170
- *
171
- * @param string $message
172
- * The log message
173
- * @param array $context
174
- * The log context
175
- */
176
- public function emergency($message, array $context = array())
177
- {
178
- $this->log(self::EMERGENCY, $message, $context);
179
- }
180
 
181
- /**
182
- * Action must be taken immediately.
183
- *
184
- * Example: Entire website down, database unavailable, etc. This should
185
- * trigger the SMS alerts and wake you up.
186
- *
187
- * @param string $message
188
- * The log message
189
- * @param array $context
190
- * The log context
191
- */
192
- public function alert($message, array $context = array())
193
- {
194
- $this->log(self::ALERT, $message, $context);
 
 
 
 
195
  }
196
 
197
- /**
198
- * Critical conditions.
199
- *
200
- * Example: Application component unavailable, unexpected exception.
201
- *
202
- * @param string $message
203
- * The log message
204
- * @param array $context
205
- * The log context
206
- */
207
- public function critical($message, array $context = array())
208
- {
209
- $this->log(self::CRITICAL, $message, $context);
210
  }
211
 
212
- /**
213
- * Runtime errors that do not require immediate action but should typically
214
- * be logged and monitored.
215
- *
216
- * @param string $message
217
- * The log message
218
- * @param array $context
219
- * The log context
220
- */
221
- public function error($message, array $context = array())
222
- {
223
- $this->log(self::ERROR, $message, $context);
224
  }
225
 
226
- /**
227
- * Exceptional occurrences that are not errors.
228
- *
229
- * Example: Use of deprecated APIs, poor use of an API, undesirable things
230
- * that are not necessarily wrong.
231
- *
232
- * @param string $message
233
- * The log message
234
- * @param array $context
235
- * The log context
236
- */
237
- public function warning($message, array $context = array())
238
- {
239
- $this->log(self::WARNING, $message, $context);
240
- }
241
 
242
- /**
243
- * Normal but significant events.
244
- *
245
- * @param string $message
246
- * The log message
247
- * @param array $context
248
- * The log context
249
- */
250
- public function notice($message, array $context = array())
251
- {
252
- $this->log(self::NOTICE, $message, $context);
253
  }
254
-
255
- /**
256
- * Interesting events.
257
- *
258
- * Example: User logs in, SQL logs.
259
- *
260
- * @param string $message
261
- * The log message
262
- * @param array $context
263
- * The log context
264
- */
265
- public function info($message, array $context = array())
266
- {
267
- $this->log(self::INFO, $message, $context);
 
268
  }
269
 
270
- /**
271
- * Detailed debug information.
272
- *
273
- * @param string $message
274
- * The log message
275
- * @param array $context
276
- * The log context
277
- */
278
- public function debug($message, array $context = array())
279
- {
280
- $this->log(self::DEBUG, $message, $context);
281
  }
282
 
283
- /**
284
- * Logs with an arbitrary level.
285
- *
286
- * @param mixed $level
287
- * The log level
288
- * @param string $message
289
- * The log message
290
- * @param array $context
291
- * The log context
292
- */
293
- public function log($level, $message, array $context = array())
294
- {
295
- if (! $this->shouldHandle($level)) {
296
- return false;
297
- }
298
- $levelName = is_int($level) ? array_search($level, self::$levels) : $level;
299
- $message = $this->interpolate(array(
300
- 'message' => $message,
301
- 'context' => $context,
302
- 'level' => strtoupper($levelName),
303
- 'datetime' => new DateTime()
304
- ));
305
- $this->write($message);
306
  }
307
 
308
- /**
309
- * Interpolates log variables into the defined log format.
310
- *
311
- * @param array $variables
312
- * The log variables.
313
- * @return string
314
- */
315
- protected function interpolate(array $variables = array())
316
- {
317
- $template = $this->logFormat;
318
- if (! $variables['context']) {
319
- $template = str_replace('%context%', '', $template);
320
- unset($variables['context']);
321
- } else {
322
- $this->reverseJsonInContext($variables['context']);
323
- }
324
- foreach ($variables as $key => $value) {
325
- if (strpos($template, '%' . $key . '%') !== false) {
326
- $template = str_replace('%' . $key . '%', $this->export($value), $template);
327
- }
328
- }
329
- return $template;
330
- }
331
 
332
- /**
333
- * Reverses JSON encoded PHP arrays and objects so that they log better.
334
- *
335
- * @param array $context
336
- * The log context
337
- */
338
- protected function reverseJsonInContext(array &$context)
339
- {
340
- if (! $context) {
341
- return;
342
- }
343
- foreach ($context as $key => $val) {
344
- if (! $val || ! is_string($val) || ! ($val[0] == '{' || $val[0] == '[')) {
345
- continue;
346
- }
347
- $json = @json_decode($val);
348
- if (is_object($json) || is_array($json)) {
349
- $context[$key] = $json;
350
- }
351
- }
352
  }
353
 
354
- /**
355
- * Exports a PHP value for logging to a string.
356
- *
357
- * @param mixed $value
358
- * The value to
359
- */
360
- protected function export($value)
361
- {
362
- if (is_string($value)) {
363
- if ($this->allowNewLines) {
364
- return $value;
365
- }
366
- return preg_replace('/[\r\n]+/', ' ', $value);
367
- }
368
- if (is_resource($value)) {
369
- return sprintf('resource(%d) of type (%s)', $value, get_resource_type($value));
370
- }
371
- if ($value instanceof DateTime) {
372
- return $value->format($this->dateFormat);
373
- }
374
- if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
375
- $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
376
- if ($this->allowNewLines) {
377
- $options |= JSON_PRETTY_PRINT;
378
- }
379
- return @json_encode($value, $options);
380
- }
381
- return str_replace('\\/', '/', @json_encode($value));
382
  }
383
 
384
- /**
385
- * Converts a given log level to the integer form.
386
- *
387
- * @param mixed $level
388
- * The logging level
389
- * @return integer $level The normalized level
390
- * @throws Google_Logger_Exception If $level is invalid
391
- */
392
- protected function normalizeLevel($level)
393
- {
394
- if (is_int($level) && array_search($level, self::$levels) !== false) {
395
- return $level;
396
- }
397
- if (is_string($level) && isset(self::$levels[$level])) {
398
- return self::$levels[$level];
399
- }
400
- throw new Google_Logger_Exception(sprintf("Unknown LogLevel: '%s'", $level));
401
  }
402
 
403
- /**
404
- * Writes a message to the current log implementation.
405
- *
406
- * @param string $message
407
- * The message
408
- */
409
- abstract protected function write($message);
 
 
 
 
410
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * Abstract logging class based on the PSR-3 standard.
29
  */
30
  abstract class Google_Logger_Abstract
31
  {
32
+ /**
33
+ * Default log format
34
+ */
35
+ const DEFAULT_LOG_FORMAT = "[%datetime%] %level%: %message% %context%\n";
36
+ /**
37
+ * Default date format
38
+ *
39
+ * Example: 16/Nov/2014:03:26:16 -0500
40
+ */
41
+ const DEFAULT_DATE_FORMAT = 'd/M/Y:H:i:s O';
42
+
43
+ /**
44
+ * System is unusable
45
+ */
46
+ const EMERGENCY = 'emergency';
47
+ /**
48
+ * Action must be taken immediately
49
+ *
50
+ * Example: Entire website down, database unavailable, etc. This should
51
+ * trigger the SMS alerts and wake you up.
52
+ */
53
+ const ALERT = 'alert';
54
+ /**
55
+ * Critical conditions
56
+ *
57
+ * Example: Application component unavailable, unexpected exception.
58
+ */
59
+ const CRITICAL = 'critical';
60
+ /**
61
+ * Runtime errors that do not require immediate action but should typically
62
+ * be logged and monitored.
63
+ */
64
+ const ERROR = 'error';
65
+ /**
66
+ * Exceptional occurrences that are not errors.
67
+ *
68
+ * Example: Use of deprecated APIs, poor use of an API, undesirable things
69
+ * that are not necessarily wrong.
70
+ */
71
+ const WARNING = 'warning';
72
+ /**
73
+ * Normal but significant events.
74
+ */
75
+ const NOTICE = 'notice';
76
+ /**
77
+ * Interesting events.
78
+ *
79
+ * Example: User logs in, SQL logs.
80
+ */
81
+ const INFO = 'info';
82
+ /**
83
+ * Detailed debug information.
84
+ */
85
+ const DEBUG = 'debug';
86
+
87
+ /**
88
+ * @var array $levels Logging levels
89
+ */
90
+ protected static $levels = array(
91
+ self::EMERGENCY => 600,
92
+ self::ALERT => 550,
93
+ self::CRITICAL => 500,
94
+ self::ERROR => 400,
95
+ self::WARNING => 300,
96
+ self::NOTICE => 250,
97
+ self::INFO => 200,
98
+ self::DEBUG => 100,
99
+ );
100
+
101
+ /**
102
+ * @var integer $level The minimum logging level
103
+ */
104
+ protected $level = self::DEBUG;
105
+
106
+ /**
107
+ * @var string $logFormat The current log format
108
+ */
109
+ protected $logFormat = self::DEFAULT_LOG_FORMAT;
110
+ /**
111
+ * @var string $dateFormat The current date format
112
+ */
113
+ protected $dateFormat = self::DEFAULT_DATE_FORMAT;
114
+
115
+ /**
116
+ * @var boolean $allowNewLines If newlines are allowed
117
+ */
118
+ protected $allowNewLines = false;
119
+
120
+ /**
121
+ * @param Google_Client $client The current Google client
122
+ */
123
+ public function __construct(Google_Client $client)
124
+ {
125
+ $this->setLevel(
126
+ $client->getClassConfig('Google_Logger_Abstract', 'level')
127
  );
128
 
129
+ $format = $client->getClassConfig('Google_Logger_Abstract', 'log_format');
130
+ $this->logFormat = $format ? $format : self::DEFAULT_LOG_FORMAT;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
 
132
+ $format = $client->getClassConfig('Google_Logger_Abstract', 'date_format');
133
+ $this->dateFormat = $format ? $format : self::DEFAULT_DATE_FORMAT;
 
 
 
 
 
 
 
134
 
135
+ $this->allowNewLines = (bool) $client->getClassConfig(
136
+ 'Google_Logger_Abstract',
137
+ 'allow_newlines'
138
+ );
139
+ }
140
+
141
+ /**
142
+ * Sets the minimum logging level that this logger handles.
143
+ *
144
+ * @param integer $level
145
+ */
146
+ public function setLevel($level)
147
+ {
148
+ $this->level = $this->normalizeLevel($level);
149
+ }
150
+
151
+ /**
152
+ * Checks if the logger should handle messages at the provided level.
153
+ *
154
+ * @param integer $level
155
+ * @return boolean
156
+ */
157
+ public function shouldHandle($level)
158
+ {
159
+ return $this->normalizeLevel($level) >= $this->level;
160
+ }
161
+
162
+ /**
163
+ * System is unusable.
164
+ *
165
+ * @param string $message The log message
166
+ * @param array $context The log context
167
+ */
168
+ public function emergency($message, array $context = array())
169
+ {
170
+ $this->log(self::EMERGENCY, $message, $context);
171
+ }
172
+
173
+ /**
174
+ * Action must be taken immediately.
175
+ *
176
+ * Example: Entire website down, database unavailable, etc. This should
177
+ * trigger the SMS alerts and wake you up.
178
+ *
179
+ * @param string $message The log message
180
+ * @param array $context The log context
181
+ */
182
+ public function alert($message, array $context = array())
183
+ {
184
+ $this->log(self::ALERT, $message, $context);
185
+ }
186
+
187
+ /**
188
+ * Critical conditions.
189
+ *
190
+ * Example: Application component unavailable, unexpected exception.
191
+ *
192
+ * @param string $message The log message
193
+ * @param array $context The log context
194
+ */
195
+ public function critical($message, array $context = array())
196
+ {
197
+ $this->log(self::CRITICAL, $message, $context);
198
+ }
199
+
200
+ /**
201
+ * Runtime errors that do not require immediate action but should typically
202
+ * be logged and monitored.
203
+ *
204
+ * @param string $message The log message
205
+ * @param array $context The log context
206
+ */
207
+ public function error($message, array $context = array())
208
+ {
209
+ $this->log(self::ERROR, $message, $context);
210
+ }
211
+
212
+ /**
213
+ * Exceptional occurrences that are not errors.
214
+ *
215
+ * Example: Use of deprecated APIs, poor use of an API, undesirable things
216
+ * that are not necessarily wrong.
217
+ *
218
+ * @param string $message The log message
219
+ * @param array $context The log context
220
+ */
221
+ public function warning($message, array $context = array())
222
+ {
223
+ $this->log(self::WARNING, $message, $context);
224
+ }
225
+
226
+ /**
227
+ * Normal but significant events.
228
+ *
229
+ * @param string $message The log message
230
+ * @param array $context The log context
231
+ */
232
+ public function notice($message, array $context = array())
233
+ {
234
+ $this->log(self::NOTICE, $message, $context);
235
+ }
236
+
237
+ /**
238
+ * Interesting events.
239
+ *
240
+ * Example: User logs in, SQL logs.
241
+ *
242
+ * @param string $message The log message
243
+ * @param array $context The log context
244
+ */
245
+ public function info($message, array $context = array())
246
+ {
247
+ $this->log(self::INFO, $message, $context);
248
+ }
249
+
250
+ /**
251
+ * Detailed debug information.
252
+ *
253
+ * @param string $message The log message
254
+ * @param array $context The log context
255
+ */
256
+ public function debug($message, array $context = array())
257
+ {
258
+ $this->log(self::DEBUG, $message, $context);
259
+ }
260
+
261
+ /**
262
+ * Logs with an arbitrary level.
263
+ *
264
+ * @param mixed $level The log level
265
+ * @param string $message The log message
266
+ * @param array $context The log context
267
+ */
268
+ public function log($level, $message, array $context = array())
269
+ {
270
+ if (!$this->shouldHandle($level)) {
271
+ return false;
272
  }
273
 
274
+ $levelName = is_int($level) ? array_search($level, self::$levels) : $level;
275
+ $message = $this->interpolate(
276
+ array(
277
+ 'message' => $message,
278
+ 'context' => $context,
279
+ 'level' => strtoupper($levelName),
280
+ 'datetime' => new DateTime(),
281
+ )
282
+ );
 
 
 
283
 
284
+ $this->write($message);
285
+ }
286
+
287
+ /**
288
+ * Interpolates log variables into the defined log format.
289
+ *
290
+ * @param array $variables The log variables.
291
+ * @return string
292
+ */
293
+ protected function interpolate(array $variables = array())
294
+ {
295
+ $template = $this->logFormat;
296
+
297
+ if (!$variables['context']) {
298
+ $template = str_replace('%context%', '', $template);
299
+ unset($variables['context']);
300
+ } else {
301
+ $this->reverseJsonInContext($variables['context']);
302
  }
303
 
304
+ foreach ($variables as $key => $value) {
305
+ if (strpos($template, '%'. $key .'%') !== false) {
306
+ $template = str_replace(
307
+ '%' . $key . '%',
308
+ $this->export($value),
309
+ $template
310
+ );
311
+ }
 
 
 
 
 
312
  }
313
 
314
+ return $template;
315
+ }
316
+
317
+ /**
318
+ * Reverses JSON encoded PHP arrays and objects so that they log better.
319
+ *
320
+ * @param array $context The log context
321
+ */
322
+ protected function reverseJsonInContext(array &$context)
323
+ {
324
+ if (!$context) {
325
+ return;
326
  }
327
 
328
+ foreach ($context as $key => $val) {
329
+ if (!$val || !is_string($val) || !($val[0] == '{' || $val[0] == '[')) {
330
+ continue;
331
+ }
 
 
 
 
 
 
 
 
 
 
 
332
 
333
+ $json = @json_decode($val);
334
+ if (is_object($json) || is_array($json)) {
335
+ $context[$key] = $json;
336
+ }
 
 
 
 
 
 
 
337
  }
338
+ }
339
+
340
+ /**
341
+ * Exports a PHP value for logging to a string.
342
+ *
343
+ * @param mixed $value The value to
344
+ */
345
+ protected function export($value)
346
+ {
347
+ if (is_string($value)) {
348
+ if ($this->allowNewLines) {
349
+ return $value;
350
+ }
351
+
352
+ return preg_replace('/[\r\n]+/', ' ', $value);
353
  }
354
 
355
+ if (is_resource($value)) {
356
+ return sprintf(
357
+ 'resource(%d) of type (%s)',
358
+ $value,
359
+ get_resource_type($value)
360
+ );
 
 
 
 
 
361
  }
362
 
363
+ if ($value instanceof DateTime) {
364
+ return $value->format($this->dateFormat);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  }
366
 
367
+ if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
368
+ $options = JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
369
 
370
+ if ($this->allowNewLines) {
371
+ $options |= JSON_PRETTY_PRINT;
372
+ }
373
+
374
+ return @json_encode($value, $options);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375
  }
376
 
377
+ return str_replace('\\/', '/', @json_encode($value));
378
+ }
379
+
380
+ /**
381
+ * Converts a given log level to the integer form.
382
+ *
383
+ * @param mixed $level The logging level
384
+ * @return integer $level The normalized level
385
+ * @throws Google_Logger_Exception If $level is invalid
386
+ */
387
+ protected function normalizeLevel($level)
388
+ {
389
+ if (is_int($level) && array_search($level, self::$levels) !== false) {
390
+ return $level;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
391
  }
392
 
393
+ if (is_string($level) && isset(self::$levels[$level])) {
394
+ return self::$levels[$level];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
  }
396
 
397
+ throw new Google_Logger_Exception(
398
+ sprintf("Unknown LogLevel: '%s'", $level)
399
+ );
400
+ }
401
+
402
+ /**
403
+ * Writes a message to the current log implementation.
404
+ *
405
+ * @param string $message The message
406
+ */
407
+ abstract protected function write($message);
408
  }
tools/src/Google/Logger/Exception.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  class Google_Logger_Exception extends Google_Exception
20
  {
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  class Google_Logger_Exception extends Google_Exception
23
  {
tools/src/Google/Logger/File.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * File logging class based on the PSR-3 standard.
@@ -23,127 +26,133 @@ require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
23
  */
24
  class Google_Logger_File extends Google_Logger_Abstract
25
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- /**
28
- *
29
- * @var string|resource $file Where logs are written
30
- */
31
- private $file;
32
-
33
- /**
34
- *
35
- * @var integer $mode The mode to use if the log file needs to be created
36
- */
37
- private $mode = 0640;
38
-
39
- /**
40
- *
41
- * @var boolean $lock If a lock should be attempted before writing to the log
42
- */
43
- private $lock = false;
44
-
45
- /**
46
- *
47
- * @var integer $trappedErrorNumber Trapped error number
48
- */
49
- private $trappedErrorNumber;
50
-
51
- /**
52
- *
53
- * @var string $trappedErrorString Trapped error string
54
- */
55
- private $trappedErrorString;
56
-
57
- /**
58
- * @ERROR!!!
59
- */
60
- public function __construct(Google_Client $client)
61
- {
62
- parent::__construct($client);
63
- $file = $client->getClassConfig('Google_Logger_File', 'file');
64
- if (! is_string($file) && ! is_resource($file)) {
65
- throw new Google_Logger_Exception('File logger requires a filename or a valid file pointer');
66
- }
67
- $mode = $client->getClassConfig('Google_Logger_File', 'mode');
68
- if (! $mode) {
69
- $this->mode = $mode;
70
- }
71
- $this->lock = (bool) $client->getClassConfig('Google_Logger_File', 'lock');
72
- $this->file = $file;
73
  }
74
 
75
- /**
76
- * @ERROR!!!
77
- */
78
- protected function write($message)
79
- {
80
- if (is_string($this->file)) {
81
- $this->open();
82
- } elseif (! is_resource($this->file)) {
83
- throw new Google_Logger_Exception('File pointer is no longer available');
84
- }
85
- if ($this->lock) {
86
- flock($this->file, LOCK_EX);
87
- }
88
- fwrite($this->file, (string) $message);
89
- if ($this->lock) {
90
- flock($this->file, LOCK_UN);
91
- }
92
  }
93
 
94
- /**
95
- * Opens the log for writing.
96
- *
97
- * @return resource
98
- */
99
- private function open()
100
- {
101
- // Used for trapping `fopen()` errors.
102
- $this->trappedErrorNumber = null;
103
- $this->trappedErrorString = null;
104
- $old = set_error_handler(array(
105
- $this,
106
- 'trapError'
107
- ));
108
- $needsChmod = ! file_exists($this->file);
109
- $fh = fopen($this->file, 'a');
110
- restore_error_handler();
111
- // Handles trapped `fopen()` errors.
112
- if ($this->trappedErrorNumber) {
113
- throw new Google_Logger_Exception(sprintf("Logger Error: '%s'", $this->trappedErrorString), $this->trappedErrorNumber);
114
- }
115
- if ($needsChmod) {
116
- @chmod($this->file, $this->mode & ~ umask());
117
- }
118
- return $this->file = $fh;
119
  }
120
 
121
- /**
122
- * Closes the log stream resource.
123
- */
124
- private function close()
125
- {
126
- if (is_resource($this->file)) {
127
- fclose($this->file);
128
- }
129
  }
130
 
131
- /**
132
- * Traps `fopen()` errors.
133
- *
134
- * @param integer $errno
135
- * The error number
136
- * @param string $errstr
137
- * The error string
138
- */
139
- private function trapError($errno, $errstr)
140
- {
141
- $this->trappedErrorNumber = $errno;
142
- $this->trappedErrorString = $errstr;
143
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
 
145
- public function __destruct()
146
- {
147
- $this->close();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * File logging class based on the PSR-3 standard.
26
  */
27
  class Google_Logger_File extends Google_Logger_Abstract
28
  {
29
+ /**
30
+ * @var string|resource $file Where logs are written
31
+ */
32
+ private $file;
33
+ /**
34
+ * @var integer $mode The mode to use if the log file needs to be created
35
+ */
36
+ private $mode = 0640;
37
+ /**
38
+ * @var boolean $lock If a lock should be attempted before writing to the log
39
+ */
40
+ private $lock = false;
41
+
42
+ /**
43
+ * @var integer $trappedErrorNumber Trapped error number
44
+ */
45
+ private $trappedErrorNumber;
46
+ /**
47
+ * @var string $trappedErrorString Trapped error string
48
+ */
49
+ private $trappedErrorString;
50
 
51
+ /**
52
+ * {@inheritdoc}
53
+ */
54
+ public function __construct(Google_Client $client)
55
+ {
56
+ parent::__construct($client);
57
+
58
+ $file = $client->getClassConfig('Google_Logger_File', 'file');
59
+ if (!is_string($file) && !is_resource($file)) {
60
+ throw new Google_Logger_Exception(
61
+ 'File logger requires a filename or a valid file pointer'
62
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  }
64
 
65
+ $mode = $client->getClassConfig('Google_Logger_File', 'mode');
66
+ if (!$mode) {
67
+ $this->mode = $mode;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  }
69
 
70
+ $this->lock = (bool) $client->getClassConfig('Google_Logger_File', 'lock');
71
+ $this->file = $file;
72
+ }
73
+
74
+ /**
75
+ * {@inheritdoc}
76
+ */
77
+ protected function write($message)
78
+ {
79
+ if (is_string($this->file)) {
80
+ $this->open();
81
+ } elseif (!is_resource($this->file)) {
82
+ throw new Google_Logger_Exception('File pointer is no longer available');
 
 
 
 
 
 
 
 
 
 
 
 
83
  }
84
 
85
+ if ($this->lock) {
86
+ flock($this->file, LOCK_EX);
 
 
 
 
 
 
87
  }
88
 
89
+ fwrite($this->file, (string) $message);
90
+
91
+ if ($this->lock) {
92
+ flock($this->file, LOCK_UN);
 
 
 
 
 
 
 
 
93
  }
94
+ }
95
+
96
+ /**
97
+ * Opens the log for writing.
98
+ *
99
+ * @return resource
100
+ */
101
+ private function open()
102
+ {
103
+ // Used for trapping `fopen()` errors.
104
+ $this->trappedErrorNumber = null;
105
+ $this->trappedErrorString = null;
106
+
107
+ $old = set_error_handler(array($this, 'trapError'));
108
+
109
+ $needsChmod = !file_exists($this->file);
110
+ $fh = fopen($this->file, 'a');
111
 
112
+ restore_error_handler();
113
+
114
+ // Handles trapped `fopen()` errors.
115
+ if ($this->trappedErrorNumber) {
116
+ throw new Google_Logger_Exception(
117
+ sprintf(
118
+ "Logger Error: '%s'",
119
+ $this->trappedErrorString
120
+ ),
121
+ $this->trappedErrorNumber
122
+ );
123
+ }
124
+
125
+ if ($needsChmod) {
126
+ @chmod($this->file, $this->mode & ~umask());
127
+ }
128
+
129
+ return $this->file = $fh;
130
+ }
131
+
132
+ /**
133
+ * Closes the log stream resource.
134
+ */
135
+ private function close()
136
+ {
137
+ if (is_resource($this->file)) {
138
+ fclose($this->file);
139
  }
140
+ }
141
+
142
+ /**
143
+ * Traps `fopen()` errors.
144
+ *
145
+ * @param integer $errno The error number
146
+ * @param string $errstr The error string
147
+ */
148
+ private function trapError($errno, $errstr)
149
+ {
150
+ $this->trappedErrorNumber = $errno;
151
+ $this->trappedErrorString = $errstr;
152
+ }
153
+
154
+ public function __destruct()
155
+ {
156
+ $this->close();
157
+ }
158
  }
tools/src/Google/Logger/Null.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * Null logger based on the PSR-3 standard.
@@ -23,18 +26,18 @@ require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
23
  */
24
  class Google_Logger_Null extends Google_Logger_Abstract
25
  {
 
 
 
 
 
 
 
26
 
27
- /**
28
- * @ERROR!!!
29
- */
30
- public function shouldHandle($level)
31
- {
32
- return false;
33
- }
34
-
35
- /**
36
- * @ERROR!!!
37
- */
38
- protected function write($message, array $context = array())
39
- {}
40
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * Null logger based on the PSR-3 standard.
26
  */
27
  class Google_Logger_Null extends Google_Logger_Abstract
28
  {
29
+ /**
30
+ * {@inheritdoc}
31
+ */
32
+ public function shouldHandle($level)
33
+ {
34
+ return false;
35
+ }
36
 
37
+ /**
38
+ * {@inheritdoc}
39
+ */
40
+ protected function write($message, array $context = array())
41
+ {
42
+ }
 
 
 
 
 
 
 
43
  }
tools/src/Google/Logger/Psr.php CHANGED
@@ -6,7 +6,7 @@
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -14,7 +14,10 @@
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
- require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
 
 
 
18
 
19
  /**
20
  * Psr logging class based on the PSR-3 standard.
@@ -24,70 +27,67 @@ require_once realpath(dirname(__FILE__) . '/../../../autoload.php');
24
  */
25
  class Google_Logger_Psr extends Google_Logger_Abstract
26
  {
 
 
 
 
27
 
28
- /**
29
- *
30
- * @param Psr\Log\LoggerInterface $logger
31
- * The PSR-3 logger
32
- */
33
- private $logger;
 
34
 
35
- /**
36
- *
37
- * @param Google_Client $client
38
- * The current Google client
39
- * @param Psr\Log\LoggerInterface $logger
40
- * PSR-3 logger where logging will be delegated.
41
- */
42
- public function __construct(Google_Client $client, /*Psr\Log\LoggerInterface*/ $logger = null)
43
- {
44
- parent::__construct($client);
45
- if ($logger) {
46
- $this->setLogger($logger);
47
- }
48
  }
 
49
 
50
- /**
51
- * Sets the PSR-3 logger where logging will be delegated.
52
- *
53
- * NOTE: The `$logger` should technically implement
54
- * `Psr\Log\LoggerInterface`, but we don't explicitly require this so that
55
- * we can be compatible with PHP 5.2.
56
- *
57
- * @param Psr\Log\LoggerInterface $logger
58
- * The PSR-3 logger
59
- */
60
- public function setLogger(/*Psr\Log\LoggerInterface*/ $logger)
61
- {
62
- $this->logger = $logger;
63
- }
64
 
65
- /**
66
- * @ERROR!!!
67
- */
68
- public function shouldHandle($level)
69
- {
70
- return isset($this->logger) && parent::shouldHandle($level);
 
 
 
 
 
 
 
 
 
71
  }
72
 
73
- /**
74
- * @ERROR!!!
75
- */
76
- public function log($level, $message, array $context = array())
77
- {
78
- if (! $this->shouldHandle($level)) {
79
- return false;
80
- }
81
- if ($context) {
82
- $this->reverseJsonInContext($context);
83
- }
84
- $levelName = is_int($level) ? array_search($level, self::$levels) : $level;
85
- $this->logger->log($levelName, $message, $context);
86
  }
87
 
88
- /**
89
- * @ERROR!!!
90
- */
91
- protected function write($message, array $context = array())
92
- {}
 
 
 
 
 
93
  }
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
+ if (!class_exists('Google_Client')) {
19
+ require_once dirname(__FILE__) . '/../autoload.php';
20
+ }
21
 
22
  /**
23
  * Psr logging class based on the PSR-3 standard.
27
  */
28
  class Google_Logger_Psr extends Google_Logger_Abstract
29
  {
30
+ /**
31
+ * @param Psr\Log\LoggerInterface $logger The PSR-3 logger
32
+ */
33
+ private $logger;
34
 
35
+ /**
36
+ * @param Google_Client $client The current Google client
37
+ * @param Psr\Log\LoggerInterface $logger PSR-3 logger where logging will be delegated.
38
+ */
39
+ public function __construct(Google_Client $client, /*Psr\Log\LoggerInterface*/ $logger = null)
40
+ {
41
+ parent::__construct($client);
42
 
43
+ if ($logger) {
44
+ $this->setLogger($logger);
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
+ }
47
 
48
+ /**
49
+ * Sets the PSR-3 logger where logging will be delegated.
50
+ *
51
+ * NOTE: The `$logger` should technically implement
52
+ * `Psr\Log\LoggerInterface`, but we don't explicitly require this so that
53
+ * we can be compatible with PHP 5.2.
54
+ *
55
+ * @param Psr\Log\LoggerInterface $logger The PSR-3 logger
56
+ */
57
+ public function setLogger(/*Psr\Log\LoggerInterface*/ $logger)
58
+ {
59
+ $this->logger = $logger;
60
+ }
 
61
 
62
+ /**
63
+ * {@inheritdoc}
64
+ */
65
+ public function shouldHandle($level)
66
+ {
67
+ return isset($this->logger) && parent::shouldHandle($level);
68
+ }
69
+
70
+ /**
71
+ * {@inheritdoc}
72
+ */
73
+ public function log($level, $message, array $context = array())
74
+ {
75
+ if (!$this->shouldHandle($level)) {
76
+ return false;
77
  }
78
 
79
+ if ($context) {
80
+ $this->reverseJsonInContext($context);
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
 
83
+ $levelName = is_int($level) ? array_search($level, self::$levels) : $level;
84
+ $this->logger->log($levelName, $message, $context);
85
+ }
86
+
87
+ /**
88
+ * {@inheritdoc}
89
+ */
90
+ protected function write($message, array $context = array())
91
+ {
92
+ }
93
  }
tools/src/Google/Model.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /*
4
  * Copyright 2011 Google Inc.
5
  *
@@ -7,7 +6,7 @@
7
  * you may not use this file except in compliance with the License.
8
  * You may obtain a copy of the License at
9
  *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
  *
12
  * Unless required by applicable law or agreed to in writing, software
13
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,269 +14,282 @@
15
  * See the License for the specific language governing permissions and
16
  * limitations under the License.
17
  */
 
18
  /**
19
  * This class defines attributes, valid values, and usage which is generated
20
  * from a given json schema.
21
  * http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5
22
  *
23
- * @author Chirag Shah <chirags@google.com>
24
- *
25
  */
26
  class Google_Model implements ArrayAccess
27
  {
 
 
 
 
 
 
 
 
28
 
29
- protected $internal_gapi_mappings = array();
30
-
31
- protected $modelData = array();
 
 
 
 
 
 
 
 
 
 
32
 
33
- protected $processed = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- /**
36
- * Polymorphic - accepts a variable number of arguments dependent
37
- * on the type of the model subclass.
38
- */
39
- final public function __construct()
40
- {
41
- if (func_num_args() == 1 && is_array(func_get_arg(0))) {
42
- // Initialize the model with the array's contents.
43
- $array = func_get_arg(0);
44
- $this->mapTypes($array);
45
  }
46
- $this->gapiInit();
47
- }
48
-
49
- /**
50
- * Getter that handles passthrough access to the data array, and lazy object creation.
51
- *
52
- * @param string $key
53
- * Property name.
54
- * @return mixed The value if any, or null.
55
- */
56
- public function __get($key)
57
- {
58
- $keyTypeName = $this->keyType($key);
59
- $keyDataType = $this->dataType($key);
60
- if (isset($this->$keyTypeName) && ! isset($this->processed[$key])) {
61
- if (isset($this->modelData[$key])) {
62
- $val = $this->modelData[$key];
63
- } else
64
- if (isset($this->$keyDataType) && ($this->$keyDataType == 'array' || $this->$keyDataType == 'map')) {
65
- $val = array();
66
- } else {
67
- $val = null;
68
- }
69
- if ($this->isAssociativeArray($val)) {
70
- if (isset($this->$keyDataType) && 'map' == $this->$keyDataType) {
71
- foreach ($val as $arrayKey => $arrayItem) {
72
- $this->modelData[$key][$arrayKey] = $this->createObjectFromName($keyTypeName, $arrayItem);
73
- }
74
- } else {
75
- $this->modelData[$key] = $this->createObjectFromName($keyTypeName, $val);
76
- }
77
- } else
78
- if (is_array($val)) {
79
- $arrayObject = array();
80
- foreach ($val as $arrayIndex => $arrayItem) {
81
- $arrayObject[$arrayIndex] = $this->createObjectFromName($keyTypeName, $arrayItem);
82
- }
83
- $this->modelData[$key] = $arrayObject;
84
- }
85
- $this->processed[$key] = true;
86
  }
87
- return isset($this->modelData[$key]) ? $this->modelData[$key] : null;
 
 
88
  }
89
 
90
- /**
91
- * Initialize this object's properties from an array.
92
- *
93
- * @param array $array
94
- * Used to seed this object's properties.
95
- * @return void
96
- */
97
- protected function mapTypes($array)
98
- {
99
- // Hard initilise simple types, lazy load more complex ones.
100
- foreach ($array as $key => $val) {
101
- if (! property_exists($this, $this->keyType($key)) && property_exists($this, $key)) {
102
- $this->$key = $val;
103
- unset($array[$key]);
104
- } elseif (property_exists($this, $camelKey = Google_Utils::camelCase($key))) {
105
- // This checks if property exists as camelCase, leaving it in array as snake_case
106
- // in case of backwards compatibility issues.
107
- $this->$camelKey = $val;
108
- }
109
- }
110
- $this->modelData = $array;
111
- }
112
 
113
- /**
114
- * Blank initialiser to be used in subclasses to do post-construction initialisation - this
115
- * avoids the need for subclasses to have to implement the variadics handling in their
116
- * constructors.
117
- */
118
- protected function gapiInit()
119
- {
120
- return;
 
 
 
 
 
 
 
 
 
 
 
121
  }
 
 
122
 
123
- /**
124
- * Create a simplified object suitable for straightforward
125
- * conversion to JSON.
126
- * This is relatively expensive
127
- * due to the usage of reflection, but shouldn't be called
128
- * a whole lot, and is the most straightforward way to filter.
129
- */
130
- public function toSimpleObject()
131
- {
132
- $object = new stdClass();
133
- // Process all other data.
134
- foreach ($this->modelData as $key => $val) {
135
- $result = $this->getSimpleValue($val);
136
- if ($result !== null) {
137
- $object->$key = $result;
138
- }
139
- }
140
- // Process all public properties.
141
- $reflect = new ReflectionObject($this);
142
- $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
143
- foreach ($props as $member) {
144
- $name = $member->getName();
145
- $result = $this->getSimpleValue($this->$name);
146
- if ($result !== null) {
147
- $name = $this->getMappedName($name);
148
- $object->$name = $result;
149
- }
150
- }
151
- return $object;
152
- }
153
 
154
- /**
155
- * Handle different types of values, primarily
156
- * other objects and map and array data types.
157
- */
158
- private function getSimpleValue($value)
159
- {
160
- if ($value instanceof Google_Model) {
161
- return $value->toSimpleObject();
162
- } else
163
- if (is_array($value)) {
164
- $return = array();
165
- foreach ($value as $key => $a_value) {
166
- $a_value = $this->getSimpleValue($a_value);
167
- if ($a_value !== null) {
168
- $key = $this->getMappedName($key);
169
- $return[$key] = $a_value;
170
- }
171
- }
172
- return $return;
173
- }
174
- return $value;
175
- }
176
 
177
- /**
178
- * If there is an internal name mapping, use that.
179
- */
180
- private function getMappedName($key)
181
- {
182
- if (isset($this->internal_gapi_mappings) && isset($this->internal_gapi_mappings[$key])) {
183
- $key = $this->internal_gapi_mappings[$key];
184
- }
185
- return $key;
186
  }
187
 
188
- /**
189
- * Returns true only if the array is associative.
190
- *
191
- * @param array $array
192
- * @return bool True if the array is associative.
193
- */
194
- protected function isAssociativeArray($array)
195
- {
196
- if (! is_array($array)) {
197
- return false;
198
- }
199
- $keys = array_keys($array);
200
- foreach ($keys as $key) {
201
- if (is_string($key)) {
202
- return true;
203
- }
204
- }
205
- return false;
206
  }
207
 
208
- /**
209
- * Given a variable name, discover its type.
210
- *
211
- * @param
212
- * $name
213
- * @param
214
- * $item
215
- * @return object The object from the item.
216
- */
217
- private function createObjectFromName($name, $item)
218
- {
219
- $type = $this->$name;
220
- return new $type($item);
221
- }
222
 
223
- /**
224
- * Verify if $obj is an array.
225
- *
226
- * @throws Google_Exception Thrown if $obj isn't an array.
227
- * @param array $obj
228
- * Items that should be validated.
229
- * @param string $method
230
- * Method expecting an array as an argument.
231
- */
232
- public function assertIsArray($obj, $method)
233
- {
234
- if ($obj && ! is_array($obj)) {
235
- throw new Google_Exception("Incorrect parameter type passed to $method(). Expected an array.");
 
 
236
  }
 
 
237
  }
238
-
239
- public function offsetExists($offset)
240
- {
241
- return isset($this->$offset) || isset($this->modelData[$offset]);
 
 
 
 
 
 
242
  }
 
 
243
 
244
- public function offsetGet($offset)
245
- {
246
- return isset($this->$offset) ? $this->$offset : $this->__get($offset);
 
 
 
 
 
247
  }
 
 
248
 
249
- public function offsetSet($offset, $value)
250
- {
251
- if (property_exists($this, $offset)) {
252
- $this->$offset = $value;
253
- } else {
254
- $this->modelData[$offset] = $value;
255
- $this->processed[$offset] = true;
256
- }
 
257
  }
258
-
259
- public function offsetUnset($offset)
260
- {
261
- unset($this->modelData[$offset]);
 
262
  }
 
 
263
 
264
- protected function keyType($key)
265
- {
266
- return $key . "Type";
267
- }
 
 
 
 
 
 
 
 
268
 
269
- protected function dataType($key)
270
- {
271
- return $key . "DataType";
 
 
 
 
 
 
 
 
 
272
  }
 
273
 
274
- public function __isset($key)
275
- {
276
- return isset($this->modelData[$key]);
277
- }
 
 
 
 
 
 
 
278
 
279
- public function __unset($key)
280
- {
281
- unset($this->modelData[$key]);
 
 
 
 
282
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  }
1
  <?php
 
2
  /*
3
  * Copyright 2011 Google Inc.
4
  *
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
  /**
19
  * This class defines attributes, valid values, and usage which is generated
20
  * from a given json schema.
21
  * http://tools.ietf.org/html/draft-zyp-json-schema-03#section-5
22
  *
 
 
23
  */
24
  class Google_Model implements ArrayAccess
25
  {
26
+ /**
27
+ * If you need to specify a NULL JSON value, use Google_Model::NULL_VALUE
28
+ * instead - it will be replaced when converting to JSON with a real null.
29
+ */
30
+ const NULL_VALUE = "{}gapi-php-null";
31
+ protected $internal_gapi_mappings = array();
32
+ protected $modelData = array();
33
+ protected $processed = array();
34
 
35
+ /**
36
+ * Polymorphic - accepts a variable number of arguments dependent
37
+ * on the type of the model subclass.
38
+ */
39
+ final public function __construct()
40
+ {
41
+ if (func_num_args() == 1 && is_array(func_get_arg(0))) {
42
+ // Initialize the model with the array's contents.
43
+ $array = func_get_arg(0);
44
+ $this->mapTypes($array);
45
+ }
46
+ $this->gapiInit();
47
+ }
48
 
49
+ /**
50
+ * Getter that handles passthrough access to the data array, and lazy object creation.
51
+ * @param string $key Property name.
52
+ * @return mixed The value if any, or null.
53
+ */
54
+ public function __get($key)
55
+ {
56
+ $keyTypeName = $this->keyType($key);
57
+ $keyDataType = $this->dataType($key);
58
+ if (isset($this->$keyTypeName) && !isset($this->processed[$key])) {
59
+ if (isset($this->modelData[$key])) {
60
+ $val = $this->modelData[$key];
61
+ } else if (isset($this->$keyDataType) &&
62
+ ($this->$keyDataType == 'array' || $this->$keyDataType == 'map')) {
63
+ $val = array();
64
+ } else {
65
+ $val = null;
66
+ }
67
 
68
+ if ($this->isAssociativeArray($val)) {
69
+ if (isset($this->$keyDataType) && 'map' == $this->$keyDataType) {
70
+ foreach ($val as $arrayKey => $arrayItem) {
71
+ $this->modelData[$key][$arrayKey] =
72
+ $this->createObjectFromName($keyTypeName, $arrayItem);
73
+ }
74
+ } else {
75
+ $this->modelData[$key] = $this->createObjectFromName($keyTypeName, $val);
 
 
76
  }
77
+ } else if (is_array($val)) {
78
+ $arrayObject = array();
79
+ foreach ($val as $arrayIndex => $arrayItem) {
80
+ $arrayObject[$arrayIndex] =
81
+ $this->createObjectFromName($keyTypeName, $arrayItem);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
83
+ $this->modelData[$key] = $arrayObject;
84
+ }
85
+ $this->processed[$key] = true;
86
  }
87
 
88
+ return isset($this->modelData[$key]) ? $this->modelData[$key] : null;
89
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
+ /**
92
+ * Initialize this object's properties from an array.
93
+ *
94
+ * @param array $array Used to seed this object's properties.
95
+ * @return void
96
+ */
97
+ protected function mapTypes($array)
98
+ {
99
+ // Hard initialise simple types, lazy load more complex ones.
100
+ foreach ($array as $key => $val) {
101
+ if ( !property_exists($this, $this->keyType($key)) &&
102
+ property_exists($this, $key)) {
103
+ $this->$key = $val;
104
+ unset($array[$key]);
105
+ } elseif (property_exists($this, $camelKey = Google_Utils::camelCase($key))) {
106
+ // This checks if property exists as camelCase, leaving it in array as snake_case
107
+ // in case of backwards compatibility issues.
108
+ $this->$camelKey = $val;
109
+ }
110
  }
111
+ $this->modelData = $array;
112
+ }
113
 
114
+ /**
115
+ * Blank initialiser to be used in subclasses to do post-construction initialisation - this
116
+ * avoids the need for subclasses to have to implement the variadics handling in their
117
+ * constructors.
118
+ */
119
+ protected function gapiInit()
120
+ {
121
+ return;
122
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
 
124
+ /**
125
+ * Create a simplified object suitable for straightforward
126
+ * conversion to JSON. This is relatively expensive
127
+ * due to the usage of reflection, but shouldn't be called
128
+ * a whole lot, and is the most straightforward way to filter.
129
+ */
130
+ public function toSimpleObject()
131
+ {
132
+ $object = new stdClass();
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
134
+ // Process all other data.
135
+ foreach ($this->modelData as $key => $val) {
136
+ $result = $this->getSimpleValue($val);
137
+ if ($result !== null) {
138
+ $object->$key = $this->nullPlaceholderCheck($result);
139
+ }
 
 
 
140
  }
141
 
142
+ // Process all public properties.
143
+ $reflect = new ReflectionObject($this);
144
+ $props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
145
+ foreach ($props as $member) {
146
+ $name = $member->getName();
147
+ $result = $this->getSimpleValue($this->$name);
148
+ if ($result !== null) {
149
+ $name = $this->getMappedName($name);
150
+ $object->$name = $this->nullPlaceholderCheck($result);
151
+ }
 
 
 
 
 
 
 
 
152
  }
153
 
154
+ return $object;
155
+ }
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
+ /**
158
+ * Handle different types of values, primarily
159
+ * other objects and map and array data types.
160
+ */
161
+ private function getSimpleValue($value)
162
+ {
163
+ if ($value instanceof Google_Model) {
164
+ return $value->toSimpleObject();
165
+ } else if (is_array($value)) {
166
+ $return = array();
167
+ foreach ($value as $key => $a_value) {
168
+ $a_value = $this->getSimpleValue($a_value);
169
+ if ($a_value !== null) {
170
+ $key = $this->getMappedName($key);
171
+ $return[$key] = $this->nullPlaceholderCheck($a_value);
172
  }
173
+ }
174
+ return $return;
175
  }
176
+ return $value;
177
+ }
178
+
179
+ /**
180
+ * Check whether the value is the null placeholder and return true null.
181
+ */
182
+ private function nullPlaceholderCheck($value)
183
+ {
184
+ if ($value === self::NULL_VALUE) {
185
+ return null;
186
  }
187
+ return $value;
188
+ }
189
 
190
+ /**
191
+ * If there is an internal name mapping, use that.
192
+ */
193
+ private function getMappedName($key)
194
+ {
195
+ if (isset($this->internal_gapi_mappings) &&
196
+ isset($this->internal_gapi_mappings[$key])) {
197
+ $key = $this->internal_gapi_mappings[$key];
198
  }
199
+ return $key;
200
+ }
201
 
202
+ /**
203
+ * Returns true only if the array is associative.
204
+ * @param array $array
205
+ * @return bool True if the array is associative.
206
+ */
207
+ protected function isAssociativeArray($array)
208
+ {
209
+ if (!is_array($array)) {
210
+ return false;
211
  }
212
+ $keys = array_keys($array);
213
+ foreach ($keys as $key) {
214
+ if (is_string($key)) {
215
+ return true;
216
+ }
217
  }
218
+ return false;
219
+ }
220
 
221
+ /**
222
+ * Given a variable name, discover its type.
223
+ *
224
+ * @param $name
225
+ * @param $item
226
+ * @return object The object from the item.
227
+ */
228
+ private function createObjectFromName($name, $item)
229
+ {
230
+ $type = $this->$name;
231
+ return new $type($item);
232
+ }
233
 
234
+ /**
235
+ * Verify if $obj is an array.
236
+ * @throws Google_Exception Thrown if $obj isn't an array.
237
+ * @param array $obj Items that should be validated.
238
+ * @param string $method Method expecting an array as an argument.
239
+ */
240
+ public function assertIsArray($obj, $method)
241
+ {
242
+ if ($obj && !is_array($obj)) {
243
+ throw new Google_Exception(
244
+ "Incorrect parameter type passed to $method(). Expected an array."
245
+ );
246
  }
247
+ }
248
 
249
+ public function offsetExists($offset)
250
+ {
251
+ return isset($this->$offset) || isset($this->modelData[$offset]);
252
+ }
253
+
254
+ public function offsetGet($offset)
255
+ {
256
+ return isset($this->$offset) ?
257
+ $this->$offset :
258
+ $this->__get($offset);
259
+ }
260
 
261
+ public function offsetSet($offset, $value)
262
+ {
263
+ if (property_exists($this, $offset)) {
264
+ $this->$offset = $value;
265
+ } else {
266
+ $this->modelData[$offset] = $value;
267
+ $this->processed[$offset] = true;
268
  }
269
+ }
270
+
271
+ public function offsetUnset($offset)
272
+ {
273
+ unset($this->modelData[$offset]);
274
+ }
275
+
276
+ protected function keyType($key)
277
+ {
278
+ return $key . "Type";
279
+ }
280
+
281
+ protected function dataType($key)
282
+ {
283
+ return $key . "DataType";
284
+ }
285
+
286
+ public function __isset($key)
287
+ {
288
+ return isset($this->modelData[$key]);
289
+ }
290
+
291
+ public function __unset($key)
292
+ {
293
+ unset($this->modelData[$key]);
294
+ }
295
  }
tools/src/Google/Service.php CHANGED
@@ -1,5 +1,4 @@
1
  <?php
2
-
3
  /*
4
  * Copyright 2010 Google Inc.
5
  *
@@ -7,7 +6,7 @@
7
  * you may not use this file except in compliance with the License.
8
  * You may obtain a copy of the License at
9
  *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
  *
12
  * Unless required by applicable law or agreed to in writing, software
13
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -15,31 +14,43 @@
15
  * See the License for the specific language governing permissions and
16
  * limitations under the License.
17
  */
 
18
  class Google_Service
19
  {
20
-
21
- public $version;
22
-
23
- public $servicePath;
24
-
25
- public $availableScopes;
26
-
27
- public $resource;
28
-
29
- private $client;
30
-
31
- public function __construct(Google_Client $client)
32
- {
33
- $this->client = $client;
34
- }
35
-
36
- /**
37
- * Return the associated Google_Client class.
38
- *
39
- * @return Google_Client
40
- */
41
- public function getClient()
42
- {
43
- return $this->client;
44
- }
 
 
 
 
 
 
 
 
 
 
 
45
  }
1
  <?php
 
2
  /*
3
  * Copyright 2010 Google Inc.
4
  *
6
  * you may not use this file except in compliance with the License.
7
  * You may obtain a copy of the License at
8
  *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
  *
11
  * Unless required by applicable law or agreed to in writing, software
12
  * distributed under the License is distributed on an "AS IS" BASIS,
14
  * See the License for the specific language governing permissions and
15
  * limitations under the License.
16
  */
17
+
18
  class Google_Service
19
  {
20
+ public $batchPath;
21
+ public $rootUrl;
22
+ public $version;
23
+ public $servicePath;
24
+ public $availableScopes;
25
+ public $resource;
26
+ private $client;
27
+
28
+ public function __construct(Google_Client $client)
29
+ {
30
+ $this->client = $client;
31
+ }
32
+
33
+ /**
34
+ * Return the associated Google_Client class.
35
+ * @return Google_Client
36
+ */
37
+ public function getClient()
38
+ {
39
+ return $this->client;
40
+ }
41
+
42
+ /**
43
+ * Create a new HTTP Batch handler for this service
44
+ *
45
+ * @return Google_Http_Batch
46
+ */
47
+ public function createBatch()
48
+ {
49
+ return new Google_Http_Batch(
50
+ $this->client,
51
+ false,
52
+ $this->rootUrl,
53
+ $this->batchPath
54
+ );
55
+ }
56
  }
tools/src/Google/Service/Analytics.php CHANGED
@@ -1,8 +1,5 @@
1
  <?php
2
-
3
  /*
4
- * Copyright 2010 Google Inc.
5
- *
6
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
7
  * use this file except in compliance with the License. You may obtain a copy of
8
  * the License at
@@ -15,6 +12,7 @@
15
  * License for the specific language governing permissions and limitations under
16
  * the License.
17
  */
 
18
  /**
19
  * Service definition for Analytics (v3).
20
  *
@@ -30,11767 +28,9912 @@
30
  */
31
  class Google_Service_Analytics extends Google_Service
32
  {
33
-
34
- /**
35
- * View and manage your Google Analytics data.
36
- */
37
- const ANALYTICS = "https://www.googleapis.com/auth/analytics";
38
-
39
- /**
40
- * Edit Google Analytics management entities.
41
- */
42
- const ANALYTICS_EDIT = "https://www.googleapis.com/auth/analytics.edit";
43
-
44
- /**
45
- * Manage Google Analytics Account users by email address.
46
- */
47
- const ANALYTICS_MANAGE_USERS = "https://www.googleapis.com/auth/analytics.manage.users";
48
-
49
- /**
50
- * View Google Analytics user permissions.
51
- */
52
- const ANALYTICS_MANAGE_USERS_READONLY = "https://www.googleapis.com/auth/analytics.manage.users.readonly";
53
-
54
- /**
55
- * Create a new Google Analytics account along with its default property and view.
56
- */
57
- const ANALYTICS_PROVISION = "https://www.googleapis.com/auth/analytics.provision";
58
-
59
- /**
60
- * View your Google Analytics data.
61
- */
62
- const ANALYTICS_READONLY = "https://www.googleapis.com/auth/analytics.readonly";
63
-
64
- public $data_ga;
65
-
66
- public $data_mcf;
67
-
68
- public $data_realtime;
69
-
70
- public $management_accountSummaries;
71
-
72
- public $management_accountUserLinks;
73
-
74
- public $management_accounts;
75
-
76
- public $management_customDataSources;
77
-
78
- public $management_dailyUploads;
79
-
80
- public $management_experiments;
81
-
82
- public $management_filters;
83
-
84
- public $management_goals;
85
-
86
- public $management_profileFilterLinks;
87
-
88
- public $management_profileUserLinks;
89
-
90
- public $management_profiles;
91
-
92
- public $management_segments;
93
-
94
- public $management_unsampledReports;
95
-
96
- public $management_uploads;
97
-
98
- public $management_webPropertyAdWordsLinks;
99
-
100
- public $management_webproperties;
101
-
102
- public $management_webpropertyUserLinks;
103
-
104
- public $metadata_columns;
105
-
106
- public $provisioning;
107
-
108
- /**
109
- * Constructs the internal representation of the Analytics service.
110
- *
111
- * @param Google_Client $client
112
- */
113
- public function __construct(Google_Client $client)
114
- {
115
- parent::__construct($client);
116
- $this->servicePath = 'analytics/v3/';
117
- $this->version = 'v3';
118
- $this->serviceName = 'analytics';
119
- $this->data_ga = new Google_Service_Analytics_DataGa_Resource($this, $this->serviceName, 'ga', array(
120
- 'methods' => array(
121
- 'get' => array(
122
- 'path' => 'data/ga',
123
- 'httpMethod' => 'GET',
124
- 'parameters' => array(
125
- 'ids' => array(
126
- 'location' => 'query',
127
- 'type' => 'string',
128
- 'required' => true
129
- ),
130
- 'start-date' => array(
131
- 'location' => 'query',
132
- 'type' => 'string',
133
- 'required' => true
134
- ),
135
- 'end-date' => array(
136
- 'location' => 'query',
137
- 'type' => 'string',
138
- 'required' => true
139
- ),
140
- 'metrics' => array(
141
- 'location' => 'query',
142
- 'type' => 'string',
143
- 'required' => true
144
- ),
145
- 'max-results' => array(
146
- 'location' => 'query',
147
- 'type' => 'integer'
148
- ),
149
- 'sort' => array(
150
- 'location' => 'query',
151
- 'type' => 'string'
152
- ),
153
- 'dimensions' => array(
154
- 'location' => 'query',
155
- 'type' => 'string'
156
- ),
157
- 'start-index' => array(
158
- 'location' => 'query',
159
- 'type' => 'integer'
160
- ),
161
- 'segment' => array(
162
- 'location' => 'query',
163
- 'type' => 'string'
164
- ),
165
- 'samplingLevel' => array(
166
- 'location' => 'query',
167
- 'type' => 'string'
168
- ),
169
- 'filters' => array(
170
- 'location' => 'query',
171
- 'type' => 'string'
172
- ),
173
- 'output' => array(
174
- 'location' => 'query',
175
- 'type' => 'string'
176
- )
177
- )
178
- )
179
- )
180
- ));
181
- $this->data_mcf = new Google_Service_Analytics_DataMcf_Resource($this, $this->serviceName, 'mcf', array(
182
- 'methods' => array(
183
- 'get' => array(
184
- 'path' => 'data/mcf',
185
- 'httpMethod' => 'GET',
186
- 'parameters' => array(
187
- 'ids' => array(
188
- 'location' => 'query',
189
- 'type' => 'string',
190
- 'required' => true
191
- ),
192
- 'start-date' => array(
193
- 'location' => 'query',
194
- 'type' => 'string',
195
- 'required' => true
196
- ),
197
- 'end-date' => array(
198
- 'location' => 'query',
199
- 'type' => 'string',
200
- 'required' => true
201
- ),
202
- 'metrics' => array(
203
- 'location' => 'query',
204
- 'type' => 'string',
205
- 'required' => true
206
- ),
207
- 'max-results' => array(
208
- 'location' => 'query',
209
- 'type' => 'integer'
210
- ),
211
- 'sort' => array(
212
- 'location' => 'query',
213
- 'type' => 'string'
214
- ),
215
- 'dimensions' => array(
216
- 'location' => 'query',
217
- 'type' => 'string'
218
- ),
219
- 'start-index' => array(
220
- 'location' => 'query',
221
- 'type' => 'integer'
222
- ),
223
- 'samplingLevel' => array(
224
- 'location' => 'query',
225
- 'type' => 'string'
226
- ),
227
- 'filters' => array(
228
- 'location' => 'query',
229
- 'type' => 'string'
230
- )
231
- )
232
- )
233
- )
234
- ));
235
- $this->data_realtime = new Google_Service_Analytics_DataRealtime_Resource($this, $this->serviceName, 'realtime', array(
236
- 'methods' => array(
237
- 'get' => array(
238
- 'path' => 'data/realtime',
239
- 'httpMethod' => 'GET',
240
- 'parameters' => array(
241
- 'ids' => array(
242
- 'location' => 'query',
243
- 'type' => 'string',
244
- 'required' => true
245
- ),
246
- 'metrics' => array(
247
- 'location' => 'query',
248
- 'type' => 'string',
249
- 'required' => true
250
- ),
251
- 'max-results' => array(
252
- 'location' => 'query',
253
- 'type' => 'integer'
254
- ),
255
- 'sort' => array(
256
- 'location' => 'query',
257
- 'type' => 'string'
258
- ),
259
- 'dimensions' => array(
260
- 'location' => 'query',
261
- 'type' => 'string'
262
- ),
263
- 'filters' => array(
264
- 'location' => 'query',
265
- 'type' => 'string'
266
- )
267
- )
268
- )
269
- )
270
- ));
271
- $this->management_accountSummaries = new Google_Service_Analytics_ManagementAccountSummaries_Resource($this, $this->serviceName, 'accountSummaries', array(
272
- 'methods' => array(
273
- 'list' => array(
274
- 'path' => 'management/accountSummaries',
275
- 'httpMethod' => 'GET',
276
- 'parameters' => array(
277
- 'max-results' => array(
278
- 'location' => 'query',
279
- 'type' => 'integer'
280
- ),
281
- 'start-index' => array(
282
- 'location' => 'query',
283
- 'type' => 'integer'
284
- )
285
- )
286
- )
287
- )
288
- ));
289
- $this->management_accountUserLinks = new Google_Service_Analytics_ManagementAccountUserLinks_Resource($this, $this->serviceName, 'accountUserLinks', array(
290
- 'methods' => array(
291
- 'delete' => array(
292
- 'path' => 'management/accounts/{accountId}/entityUserLinks/{linkId}',
293
- 'httpMethod' => 'DELETE',
294
- 'parameters' => array(
295
- 'accountId' => array(
296
- 'location' => 'path',
297
- 'type' => 'string',
298
- 'required' => true
299
- ),
300
- 'linkId' => array(
301
- 'location' => 'path',
302
- 'type' => 'string',
303
- 'required' => true
304
- )
305
- )
306
- ),
307
- 'insert' => array(
308
- 'path' => 'management/accounts/{accountId}/entityUserLinks',
309
- 'httpMethod' => 'POST',
310
- 'parameters' => array(
311
- 'accountId' => array(
312
- 'location' => 'path',
313
- 'type' => 'string',
314
- 'required' => true
315
- )
316
- )
317
- ),
318
- 'list' => array(
319
- 'path' => 'management/accounts/{accountId}/entityUserLinks',
320
- 'httpMethod' => 'GET',
321
- 'parameters' => array(
322
- 'accountId' => array(
323
- 'location' => 'path',
324
- 'type' => 'string',
325
- 'required' => true
326
- ),
327
- 'max-results' => array(
328
- 'location' => 'query',
329
- 'type' => 'integer'
330
- ),
331
- 'start-index' => array(
332
- 'location' => 'query',
333
- 'type' => 'integer'
334
- )
335
- )
336
- ),
337
- 'update' => array(
338
- 'path' => 'management/accounts/{accountId}/entityUserLinks/{linkId}',
339
- 'httpMethod' => 'PUT',
340
- 'parameters' => array(
341
- 'accountId' => array(
342
- 'location' => 'path',
343
- 'type' => 'string',
344
- 'required' => true
345
- ),
346
- 'linkId' => array(
347
- 'location' => 'path',
348
- 'type' => 'string',
349
- 'required' => true
350
- )
351
- )
352
- )
353
- )
354
- ));
355
- $this->management_accounts = new Google_Service_Analytics_ManagementAccounts_Resource($this, $this->serviceName, 'accounts', array(
356
- 'methods' => array(
357
- 'list' => array(
358
- 'path' => 'management/accounts',
359
- 'httpMethod' => 'GET',
360
- 'parameters' => array(
361
- 'max-results' => array(
362
- 'location' => 'query',
363
- 'type' => 'integer'
364
- ),
365
- 'start-index' => array(
366
- 'location' => 'query',
367
- 'type' => 'integer'
368
- )
369
- )
370
- )
371
- )
372
- ));
373
- $this->management_customDataSources = new Google_Service_Analytics_ManagementCustomDataSources_Resource($this, $this->serviceName, 'customDataSources', array(
374
- 'methods' => array(
375
- 'list' => array(
376
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources',
377
- 'httpMethod' => 'GET',
378
- 'parameters' => array(
379
- 'accountId' => array(
380
- 'location' => 'path',
381
- 'type' => 'string',
382
- 'required' => true
383
- ),
384
- 'webPropertyId' => array(
385
- 'location' => 'path',
386
- 'type' => 'string',
387
- 'required' => true
388
- ),
389
- 'max-results' => array(
390
- 'location' => 'query',
391
- 'type' => 'integer'
392
- ),
393
- 'start-index' => array(
394
- 'location' => 'query',
395
- 'type' => 'integer'
396
- )
397
- )
398
- )
399
- )
400
- ));
401
- $this->management_dailyUploads = new Google_Service_Analytics_ManagementDailyUploads_Resource($this, $this->serviceName, 'dailyUploads', array(
402
- 'methods' => array(
403
- 'delete' => array(
404
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/dailyUploads/{date}',
405
- 'httpMethod' => 'DELETE',
406
- 'parameters' => array(
407
- 'accountId' => array(
408
- 'location' => 'path',
409
- 'type' => 'string',
410
- 'required' => true
411
- ),
412
- 'webPropertyId' => array(
413
- 'location' => 'path',
414
- 'type' => 'string',
415
- 'required' => true
416
- ),
417
- 'customDataSourceId' => array(
418
- 'location' => 'path',
419
- 'type' => 'string',
420
- 'required' => true
421
- ),
422
- 'date' => array(
423
- 'location' => 'path',
424
- 'type' => 'string',
425
- 'required' => true
426
- ),
427
- 'type' => array(
428
- 'location' => 'query',
429
- 'type' => 'string',
430
- 'required' => true
431
- )
432
- )
433
- ),
434
- 'list' => array(
435
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/dailyUploads',
436
- 'httpMethod' => 'GET',
437
- 'parameters' => array(
438
- 'accountId' => array(
439
- 'location' => 'path',
440
- 'type' => 'string',
441
- 'required' => true
442
- ),
443
- 'webPropertyId' => array(
444
- 'location' => 'path',
445
- 'type' => 'string',
446
- 'required' => true
447
- ),
448
- 'customDataSourceId' => array(
449
- 'location' => 'path',
450
- 'type' => 'string',
451
- 'required' => true
452
- ),
453
- 'start-date' => array(
454
- 'location' => 'query',
455
- 'type' => 'string',
456
- 'required' => true
457
- ),
458
- 'end-date' => array(
459
- 'location' => 'query',
460
- 'type' => 'string',
461
- 'required' => true
462
- ),
463
- 'max-results' => array(
464
- 'location' => 'query',
465
- 'type' => 'integer'
466
- ),
467
- 'start-index' => array(
468
- 'location' => 'query',
469
- 'type' => 'integer'
470
- )
471
- )
472
- ),
473
- 'upload' => array(
474
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/dailyUploads/{date}/uploads',
475
- 'httpMethod' => 'POST',
476
- 'parameters' => array(
477
- 'accountId' => array(
478
- 'location' => 'path',
479
- 'type' => 'string',
480
- 'required' => true
481
- ),
482
- 'webPropertyId' => array(
483
- 'location' => 'path',
484
- 'type' => 'string',
485
- 'required' => true
486
- ),
487
- 'customDataSourceId' => array(
488
- 'location' => 'path',
489
- 'type' => 'string',
490
- 'required' => true
491
- ),
492
- 'date' => array(
493
- 'location' => 'path',
494
- 'type' => 'string',
495
- 'required' => true
496
- ),
497
- 'appendNumber' => array(
498
- 'location' => 'query',
499
- 'type' => 'integer',
500
- 'required' => true
501
- ),
502
- 'type' => array(
503
- 'location' => 'query',
504
- 'type' => 'string',
505
- 'required' => true
506
- ),
507
- 'reset' => array(
508
- 'location' => 'query',
509
- 'type' => 'boolean'
510
- )
511
- )
512
- )
513
- )
514
- ));
515
- $this->management_experiments = new Google_Service_Analytics_ManagementExperiments_Resource($this, $this->serviceName, 'experiments', array(
516
- 'methods' => array(
517
- 'delete' => array(
518
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}',
519
- 'httpMethod' => 'DELETE',
520
- 'parameters' => array(
521
- 'accountId' => array(
522
- 'location' => 'path',
523
- 'type' => 'string',
524
- 'required' => true
525
- ),
526
- 'webPropertyId' => array(
527
- 'location' => 'path',
528
- 'type' => 'string',
529
- 'required' => true
530
- ),
531
- 'profileId' => array(
532
- 'location' => 'path',
533
- 'type' => 'string',
534
- 'required' => true
535
- ),
536
- 'experimentId' => array(
537
- 'location' => 'path',
538
- 'type' => 'string',
539
- 'required' => true
540
- )
541
- )
542
- ),
543
- 'get' => array(
544
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}',
545
- 'httpMethod' => 'GET',
546
- 'parameters' => array(
547
- 'accountId' => array(
548
- 'location' => 'path',
549
- 'type' => 'string',
550
- 'required' => true
551
- ),
552
- 'webPropertyId' => array(
553
- 'location' => 'path',
554
- 'type' => 'string',
555
- 'required' => true
556
- ),
557
- 'profileId' => array(
558
- 'location' => 'path',
559
- 'type' => 'string',
560
- 'required' => true
561
- ),
562
- 'experimentId' => array(
563
- 'location' => 'path',
564
- 'type' => 'string',
565
- 'required' => true
566
- )
567
- )
568
- ),
569
- 'insert' => array(
570
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments',
571
- 'httpMethod' => 'POST',
572
- 'parameters' => array(
573
- 'accountId' => array(
574
- 'location' => 'path',
575
- 'type' => 'string',
576
- 'required' => true
577
- ),
578
- 'webPropertyId' => array(
579
- 'location' => 'path',
580
- 'type' => 'string',
581
- 'required' => true
582
- ),
583
- 'profileId' => array(
584
- 'location' => 'path',
585
- 'type' => 'string',
586
- 'required' => true
587
- )
588
- )
589
- ),
590
- 'list' => array(
591
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments',
592
- 'httpMethod' => 'GET',
593
- 'parameters' => array(
594
- 'accountId' => array(
595
- 'location' => 'path',
596
- 'type' => 'string',
597
- 'required' => true
598
- ),
599
- 'webPropertyId' => array(
600
- 'location' => 'path',
601
- 'type' => 'string',
602
- 'required' => true
603
- ),
604
- 'profileId' => array(
605
- 'location' => 'path',
606
- 'type' => 'string',
607
- 'required' => true
608
- ),
609
- 'max-results' => array(
610
- 'location' => 'query',
611
- 'type' => 'integer'
612
- ),
613
- 'start-index' => array(
614
- 'location' => 'query',
615
- 'type' => 'integer'
616
- )
617
- )
618
- ),
619
- 'patch' => array(
620
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}',
621
- 'httpMethod' => 'PATCH',
622
- 'parameters' => array(
623
- 'accountId' => array(
624
- 'location' => 'path',
625
- 'type' => 'string',
626
- 'required' => true
627
- ),
628
- 'webPropertyId' => array(
629
- 'location' => 'path',
630
- 'type' => 'string',
631
- 'required' => true
632
- ),
633
- 'profileId' => array(
634
- 'location' => 'path',
635
- 'type' => 'string',
636
- 'required' => true
637
- ),
638
- 'experimentId' => array(
639
- 'location' => 'path',
640
- 'type' => 'string',
641
- 'required' => true
642
- )
643
- )
644
- ),
645
- 'update' => array(
646
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/experiments/{experimentId}',
647
- 'httpMethod' => 'PUT',
648
- 'parameters' => array(
649
- 'accountId' => array(
650
- 'location' => 'path',
651
- 'type' => 'string',
652
- 'required' => true
653
- ),
654
- 'webPropertyId' => array(
655
- 'location' => 'path',
656
- 'type' => 'string',
657
- 'required' => true
658
- ),
659
- 'profileId' => array(
660
- 'location' => 'path',
661
- 'type' => 'string',
662
- 'required' => true
663
- ),
664
- 'experimentId' => array(
665
- 'location' => 'path',
666
- 'type' => 'string',
667
- 'required' => true
668
- )
669
- )
670
- )
671
- )
672
- ));
673
- $this->management_filters = new Google_Service_Analytics_ManagementFilters_Resource($this, $this->serviceName, 'filters', array(
674
- 'methods' => array(
675
- 'delete' => array(
676
- 'path' => 'management/accounts/{accountId}/filters/{filterId}',
677
- 'httpMethod' => 'DELETE',
678
- 'parameters' => array(
679
- 'accountId' => array(
680
- 'location' => 'path',
681
- 'type' => 'string',
682
- 'required' => true
683
- ),
684
- 'filterId' => array(
685
- 'location' => 'path',
686
- 'type' => 'string',
687
- 'required' => true
688
- )
689
- )
690
- ),
691
- 'get' => array(
692
- 'path' => 'management/accounts/{accountId}/filters/{filterId}',
693
- 'httpMethod' => 'GET',
694
- 'parameters' => array(
695
- 'accountId' => array(
696
- 'location' => 'path',
697
- 'type' => 'string',
698
- 'required' => true
699
- ),
700
- 'filterId' => array(
701
- 'location' => 'path',
702
- 'type' => 'string',
703
- 'required' => true
704
- )
705
- )
706
- ),
707
- 'insert' => array(
708
- 'path' => 'management/accounts/{accountId}/filters',
709
- 'httpMethod' => 'POST',
710
- 'parameters' => array(
711
- 'accountId' => array(
712
- 'location' => 'path',
713
- 'type' => 'string',
714
- 'required' => true
715
- )
716
- )
717
- ),
718
- 'list' => array(
719
- 'path' => 'management/accounts/{accountId}/filters',
720
- 'httpMethod' => 'GET',
721
- 'parameters' => array(
722
- 'accountId' => array(
723
- 'location' => 'path',
724
- 'type' => 'string',
725
- 'required' => true
726
- ),
727
- 'max-results' => array(
728
- 'location' => 'query',
729
- 'type' => 'integer'
730
- ),
731
- 'start-index' => array(
732
- 'location' => 'query',
733
- 'type' => 'integer'
734
- )
735
- )
736
- ),
737
- 'patch' => array(
738
- 'path' => 'management/accounts/{accountId}/filters/{filterId}',
739
- 'httpMethod' => 'PATCH',
740
- 'parameters' => array(
741
- 'accountId' => array(
742
- 'location' => 'path',
743
- 'type' => 'string',
744
- 'required' => true
745
- ),
746
- 'filterId' => array(
747
- 'location' => 'path',
748
- 'type' => 'string',
749
- 'required' => true
750
- )
751
- )
752
- ),
753
- 'update' => array(
754
- 'path' => 'management/accounts/{accountId}/filters/{filterId}',
755
- 'httpMethod' => 'PUT',
756
- 'parameters' => array(
757
- 'accountId' => array(
758
- 'location' => 'path',
759
- 'type' => 'string',
760
- 'required' => true
761
- ),
762
- 'filterId' => array(
763
- 'location' => 'path',
764
- 'type' => 'string',
765
- 'required' => true
766
- )
767
- )
768
- )
769
- )
770
- ));
771
- $this->management_goals = new Google_Service_Analytics_ManagementGoals_Resource($this, $this->serviceName, 'goals', array(
772
- 'methods' => array(
773
- 'get' => array(
774
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals/{goalId}',
775
- 'httpMethod' => 'GET',
776
- 'parameters' => array(
777
- 'accountId' => array(
778
- 'location' => 'path',
779
- 'type' => 'string',
780
- 'required' => true
781
- ),
782
- 'webPropertyId' => array(
783
- 'location' => 'path',
784
- 'type' => 'string',
785
- 'required' => true
786
- ),
787
- 'profileId' => array(
788
- 'location' => 'path',
789
- 'type' => 'string',
790
- 'required' => true
791
- ),
792
- 'goalId' => array(
793
- 'location' => 'path',
794
- 'type' => 'string',
795
- 'required' => true
796
- )
797
- )
798
- ),
799
- 'insert' => array(
800
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals',
801
- 'httpMethod' => 'POST',
802
- 'parameters' => array(
803
- 'accountId' => array(
804
- 'location' => 'path',
805
- 'type' => 'string',
806
- 'required' => true
807
- ),
808
- 'webPropertyId' => array(
809
- 'location' => 'path',
810
- 'type' => 'string',
811
- 'required' => true
812
- ),
813
- 'profileId' => array(
814
- 'location' => 'path',
815
- 'type' => 'string',
816
- 'required' => true
817
- )
818
- )
819
- ),
820
- 'list' => array(
821
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals',
822
- 'httpMethod' => 'GET',
823
- 'parameters' => array(
824
- 'accountId' => array(
825
- 'location' => 'path',
826
- 'type' => 'string',
827
- 'required' => true
828
- ),
829
- 'webPropertyId' => array(
830
- 'location' => 'path',
831
- 'type' => 'string',
832
- 'required' => true
833
- ),
834
- 'profileId' => array(
835
- 'location' => 'path',
836
- 'type' => 'string',
837
- 'required' => true
838
- ),
839
- 'max-results' => array(
840
- 'location' => 'query',
841
- 'type' => 'integer'
842
- ),
843
- 'start-index' => array(
844
- 'location' => 'query',
845
- 'type' => 'integer'
846
- )
847
- )
848
- ),
849
- 'patch' => array(
850
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals/{goalId}',
851
- 'httpMethod' => 'PATCH',
852
- 'parameters' => array(
853
- 'accountId' => array(
854
- 'location' => 'path',
855
- 'type' => 'string',
856
- 'required' => true
857
- ),
858
- 'webPropertyId' => array(
859
- 'location' => 'path',
860
- 'type' => 'string',
861
- 'required' => true
862
- ),
863
- 'profileId' => array(
864
- 'location' => 'path',
865
- 'type' => 'string',
866
- 'required' => true
867
- ),
868
- 'goalId' => array(
869
- 'location' => 'path',
870
- 'type' => 'string',
871
- 'required' => true
872
- )
873
- )
874
- ),
875
- 'update' => array(
876
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals/{goalId}',
877
- 'httpMethod' => 'PUT',
878
- 'parameters' => array(
879
- 'accountId' => array(
880
- 'location' => 'path',
881
- 'type' => 'string',
882
- 'required' => true
883
- ),
884
- 'webPropertyId' => array(
885
- 'location' => 'path',
886
- 'type' => 'string',
887
- 'required' => true
888
- ),
889
- 'profileId' => array(
890
- 'location' => 'path',
891
- 'type' => 'string',
892
- 'required' => true
893
- ),
894
- 'goalId' => array(
895
- 'location' => 'path',
896
- 'type' => 'string',
897
- 'required' => true
898
- )
899
- )
900
- )
901
- )
902
- ));
903
- $this->management_profileFilterLinks = new Google_Service_Analytics_ManagementProfileFilterLinks_Resource($this, $this->serviceName, 'profileFilterLinks', array(
904
- 'methods' => array(
905
- 'delete' => array(
906
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}',
907
- 'httpMethod' => 'DELETE',
908
- 'parameters' => array(
909
- 'accountId' => array(
910
- 'location' => 'path',
911
- 'type' => 'string',
912
- 'required' => true
913
- ),
914
- 'webPropertyId' => array(
915
- 'location' => 'path',
916
- 'type' => 'string',
917
- 'required' => true
918
- ),
919
- 'profileId' => array(
920
- 'location' => 'path',
921
- 'type' => 'string',
922
- 'required' => true
923
- ),
924
- 'linkId' => array(
925
- 'location' => 'path',
926
- 'type' => 'string',
927
- 'required' => true
928
- )
929
- )
930
- ),
931
- 'get' => array(
932
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}',
933
- 'httpMethod' => 'GET',
934
- 'parameters' => array(
935
- 'accountId' => array(
936
- 'location' => 'path',
937
- 'type' => 'string',
938
- 'required' => true
939
- ),
940
- 'webPropertyId' => array(
941
- 'location' => 'path',
942
- 'type' => 'string',
943
- 'required' => true
944
- ),
945
- 'profileId' => array(
946
- 'location' => 'path',
947
- 'type' => 'string',
948
- 'required' => true
949
- ),
950
- 'linkId' => array(
951
- 'location' => 'path',
952
- 'type' => 'string',
953
- 'required' => true
954
- )
955
- )
956
- ),
957
- 'insert' => array(
958
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks',
959
- 'httpMethod' => 'POST',
960
- 'parameters' => array(
961
- 'accountId' => array(
962
- 'location' => 'path',
963
- 'type' => 'string',
964
- 'required' => true
965
- ),
966
- 'webPropertyId' => array(
967
- 'location' => 'path',
968
- 'type' => 'string',
969
- 'required' => true
970
- ),
971
- 'profileId' => array(
972
- 'location' => 'path',
973
- 'type' => 'string',
974
- 'required' => true
975
- )
976
- )
977
- ),
978
- 'list' => array(
979
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks',
980
- 'httpMethod' => 'GET',
981
- 'parameters' => array(
982
- 'accountId' => array(
983
- 'location' => 'path',
984
- 'type' => 'string',
985
- 'required' => true
986
- ),
987
- 'webPropertyId' => array(
988
- 'location' => 'path',
989
- 'type' => 'string',
990
- 'required' => true
991
- ),
992
- 'profileId' => array(
993
- 'location' => 'path',
994
- 'type' => 'string',
995
- 'required' => true
996
- ),
997
- 'max-results' => array(
998
- 'location' => 'query',
999
- 'type' => 'integer'
1000
- ),
1001
- 'start-index' => array(
1002
- 'location' => 'query',
1003
- 'type' => 'integer'
1004
- )
1005
- )
1006
- ),
1007
- 'patch' => array(
1008
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}',
1009
- 'httpMethod' => 'PATCH',
1010
- 'parameters' => array(
1011
- 'accountId' => array(
1012
- 'location' => 'path',
1013
- 'type' => 'string',
1014
- 'required' => true
1015
- ),
1016
- 'webPropertyId' => array(
1017
- 'location' => 'path',
1018
- 'type' => 'string',
1019
- 'required' => true
1020
- ),
1021
- 'profileId' => array(
1022
- 'location' => 'path',
1023
- 'type' => 'string',
1024
- 'required' => true
1025
- ),
1026
- 'linkId' => array(
1027
- 'location' => 'path',
1028
- 'type' => 'string',
1029
- 'required' => true
1030
- )
1031
- )
1032
- ),
1033
- 'update' => array(
1034
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/profileFilterLinks/{linkId}',
1035
- 'httpMethod' => 'PUT',
1036
- 'parameters' => array(
1037
- 'accountId' => array(
1038
- 'location' => 'path',
1039
- 'type' => 'string',
1040
- 'required' => true
1041
- ),
1042
- 'webPropertyId' => array(
1043
- 'location' => 'path',
1044
- 'type' => 'string',
1045
- 'required' => true
1046
- ),
1047
- 'profileId' => array(
1048
- 'location' => 'path',
1049
- 'type' => 'string',
1050
- 'required' => true
1051
- ),
1052
- 'linkId' => array(
1053
- 'location' => 'path',
1054
- 'type' => 'string',
1055
- 'required' => true
1056
- )
1057
- )
1058
- )
1059
- )
1060
- ));
1061
- $this->management_profileUserLinks = new Google_Service_Analytics_ManagementProfileUserLinks_Resource($this, $this->serviceName, 'profileUserLinks', array(
1062
- 'methods' => array(
1063
- 'delete' => array(
1064
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks/{linkId}',
1065
- 'httpMethod' => 'DELETE',
1066
- 'parameters' => array(
1067
- 'accountId' => array(
1068
- 'location' => 'path',
1069
- 'type' => 'string',
1070
- 'required' => true
1071
- ),
1072
- 'webPropertyId' => array(
1073
- 'location' => 'path',
1074
- 'type' => 'string',
1075
- 'required' => true
1076
- ),
1077
- 'profileId' => array(
1078
- 'location' => 'path',
1079
- 'type' => 'string',
1080
- 'required' => true
1081
- ),
1082
- 'linkId' => array(
1083
- 'location' => 'path',
1084
- 'type' => 'string',
1085
- 'required' => true
1086
- )
1087
- )
1088
- ),
1089
- 'insert' => array(
1090
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks',
1091
- 'httpMethod' => 'POST',
1092
- 'parameters' => array(
1093
- 'accountId' => array(
1094
- 'location' => 'path',
1095
- 'type' => 'string',
1096
- 'required' => true
1097
- ),
1098
- 'webPropertyId' => array(
1099
- 'location' => 'path',
1100
- 'type' => 'string',
1101
- 'required' => true
1102
- ),
1103
- 'profileId' => array(
1104
- 'location' => 'path',
1105
- 'type' => 'string',
1106
- 'required' => true
1107
- )
1108
- )
1109
- ),
1110
- 'list' => array(
1111
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks',
1112
- 'httpMethod' => 'GET',
1113
- 'parameters' => array(
1114
- 'accountId' => array(
1115
- 'location' => 'path',
1116
- 'type' => 'string',
1117
- 'required' => true
1118
- ),
1119
- 'webPropertyId' => array(
1120
- 'location' => 'path',
1121
- 'type' => 'string',
1122
- 'required' => true
1123
- ),
1124
- 'profileId' => array(
1125
- 'location' => 'path',
1126
- 'type' => 'string',
1127
- 'required' => true
1128
- ),
1129
- 'max-results' => array(
1130
- 'location' => 'query',
1131
- 'type' => 'integer'
1132
- ),
1133
- 'start-index' => array(
1134
- 'location' => 'query',
1135
- 'type' => 'integer'
1136
- )
1137
- )
1138
- ),
1139
- 'update' => array(
1140
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/entityUserLinks/{linkId}',
1141
- 'httpMethod' => 'PUT',
1142
- 'parameters' => array(
1143
- 'accountId' => array(
1144
- 'location' => 'path',
1145
- 'type' => 'string',
1146
- 'required' => true
1147
- ),
1148
- 'webPropertyId' => array(
1149
- 'location' => 'path',
1150
- 'type' => 'string',
1151
- 'required' => true
1152
- ),
1153
- 'profileId' => array(
1154
- 'location' => 'path',
1155
- 'type' => 'string',
1156
- 'required' => true
1157
- ),
1158
- 'linkId' => array(
1159
- 'location' => 'path',
1160
- 'type' => 'string',
1161
- 'required' => true
1162
- )
1163
- )
1164
- )
1165
- )
1166
- ));
1167
- $this->management_profiles = new Google_Service_Analytics_ManagementProfiles_Resource($this, $this->serviceName, 'profiles', array(
1168
- 'methods' => array(
1169
- 'delete' => array(
1170
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}',
1171
- 'httpMethod' => 'DELETE',
1172
- 'parameters' => array(
1173
- 'accountId' => array(
1174
- 'location' => 'path',
1175
- 'type' => 'string',
1176
- 'required' => true
1177
- ),
1178
- 'webPropertyId' => array(
1179
- 'location' => 'path',
1180
- 'type' => 'string',
1181
- 'required' => true
1182
- ),
1183
- 'profileId' => array(
1184
- 'location' => 'path',
1185
- 'type' => 'string',
1186
- 'required' => true
1187
- )
1188
- )
1189
- ),
1190
- 'get' => array(
1191
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}',
1192
- 'httpMethod' => 'GET',
1193
- 'parameters' => array(
1194
- 'accountId' => array(
1195
- 'location' => 'path',
1196
- 'type' => 'string',
1197
- 'required' => true
1198
- ),
1199
- 'webPropertyId' => array(
1200
- 'location' => 'path',
1201
- 'type' => 'string',
1202
- 'required' => true
1203
- ),
1204
- 'profileId' => array(
1205
- 'location' => 'path',
1206
- 'type' => 'string',
1207
- 'required' => true
1208
- )
1209
- )
1210
- ),
1211
- 'insert' => array(
1212
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles',
1213
- 'httpMethod' => 'POST',
1214
- 'parameters' => array(
1215
- 'accountId' => array(
1216
- 'location' => 'path',
1217
- 'type' => 'string',
1218
- 'required' => true
1219
- ),
1220
- 'webPropertyId' => array(
1221
- 'location' => 'path',
1222
- 'type' => 'string',
1223
- 'required' => true
1224
- )
1225
- )
1226
- ),
1227
- 'list' => array(
1228
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles',
1229
- 'httpMethod' => 'GET',
1230
- 'parameters' => array(
1231
- 'accountId' => array(
1232
- 'location' => 'path',
1233
- 'type' => 'string',
1234
- 'required' => true
1235
- ),
1236
- 'webPropertyId' => array(
1237
- 'location' => 'path',
1238
- 'type' => 'string',
1239
- 'required' => true
1240
- ),
1241
- 'max-results' => array(
1242
- 'location' => 'query',
1243
- 'type' => 'integer'
1244
- ),
1245
- 'start-index' => array(
1246
- 'location' => 'query',
1247
- 'type' => 'integer'
1248
- )
1249
- )
1250
- ),
1251
- 'patch' => array(
1252
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}',
1253
- 'httpMethod' => 'PATCH',
1254
- 'parameters' => array(
1255
- 'accountId' => array(
1256
- 'location' => 'path',
1257
- 'type' => 'string',
1258
- 'required' => true
1259
- ),
1260
- 'webPropertyId' => array(
1261
- 'location' => 'path',
1262
- 'type' => 'string',
1263
- 'required' => true
1264
- ),
1265
- 'profileId' => array(
1266
- 'location' => 'path',
1267
- 'type' => 'string',
1268
- 'required' => true
1269
- )
1270
- )
1271
- ),
1272
- 'update' => array(
1273
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}',
1274
- 'httpMethod' => 'PUT',
1275
- 'parameters' => array(
1276
- 'accountId' => array(
1277
- 'location' => 'path',
1278
- 'type' => 'string',
1279
- 'required' => true
1280
- ),
1281
- 'webPropertyId' => array(
1282
- 'location' => 'path',
1283
- 'type' => 'string',
1284
- 'required' => true
1285
- ),
1286
- 'profileId' => array(
1287
- 'location' => 'path',
1288
- 'type' => 'string',
1289
- 'required' => true
1290
- )
1291
- )
1292
- )
1293
- )
1294
- ));
1295
- $this->management_segments = new Google_Service_Analytics_ManagementSegments_Resource($this, $this->serviceName, 'segments', array(
1296
- 'methods' => array(
1297
- 'list' => array(
1298
- 'path' => 'management/segments',
1299
- 'httpMethod' => 'GET',
1300
- 'parameters' => array(
1301
- 'max-results' => array(
1302
- 'location' => 'query',
1303
- 'type' => 'integer'
1304
- ),
1305
- 'start-index' => array(
1306
- 'location' => 'query',
1307
- 'type' => 'integer'
1308
- )
1309
- )
1310
- )
1311
- )
1312
- ));
1313
- $this->management_unsampledReports = new Google_Service_Analytics_ManagementUnsampledReports_Resource($this, $this->serviceName, 'unsampledReports', array(
1314
- 'methods' => array(
1315
- 'get' => array(
1316
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/unsampledReports/{unsampledReportId}',
1317
- 'httpMethod' => 'GET',
1318
- 'parameters' => array(
1319
- 'accountId' => array(
1320
- 'location' => 'path',
1321
- 'type' => 'string',
1322
- 'required' => true
1323
- ),
1324
- 'webPropertyId' => array(
1325
- 'location' => 'path',
1326
- 'type' => 'string',
1327
- 'required' => true
1328
- ),
1329
- 'profileId' => array(
1330
- 'location' => 'path',
1331
- 'type' => 'string',
1332
- 'required' => true
1333
- ),
1334
- 'unsampledReportId' => array(
1335
- 'location' => 'path',
1336
- 'type' => 'string',
1337
- 'required' => true
1338
- )
1339
- )
1340
- ),
1341
- 'insert' => array(
1342
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/unsampledReports',
1343
- 'httpMethod' => 'POST',
1344
- 'parameters' => array(
1345
- 'accountId' => array(
1346
- 'location' => 'path',
1347
- 'type' => 'string',
1348
- 'required' => true
1349
- ),
1350
- 'webPropertyId' => array(
1351
- 'location' => 'path',
1352
- 'type' => 'string',
1353
- 'required' => true
1354
- ),
1355
- 'profileId' => array(
1356
- 'location' => 'path',
1357
- 'type' => 'string',
1358
- 'required' => true
1359
- )
1360
- )
1361
- ),
1362
- 'list' => array(
1363
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/unsampledReports',
1364
- 'httpMethod' => 'GET',
1365
- 'parameters' => array(
1366
- 'accountId' => array(
1367
- 'location' => 'path',
1368
- 'type' => 'string',
1369
- 'required' => true
1370
- ),
1371
- 'webPropertyId' => array(
1372
- 'location' => 'path',
1373
- 'type' => 'string',
1374
- 'required' => true
1375
- ),
1376
- 'profileId' => array(
1377
- 'location' => 'path',
1378
- 'type' => 'string',
1379
- 'required' => true
1380
- ),
1381
- 'max-results' => array(
1382
- 'location' => 'query',
1383
- 'type' => 'integer'
1384
- ),
1385
- 'start-index' => array(
1386
- 'location' => 'query',
1387
- 'type' => 'integer'
1388
- )
1389
- )
1390
- )
1391
- )
1392
- ));
1393
- $this->management_uploads = new Google_Service_Analytics_ManagementUploads_Resource($this, $this->serviceName, 'uploads', array(
1394
- 'methods' => array(
1395
- 'deleteUploadData' => array(
1396
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/deleteUploadData',
1397
- 'httpMethod' => 'POST',
1398
- 'parameters' => array(
1399
- 'accountId' => array(
1400
- 'location' => 'path',
1401
- 'type' => 'string',
1402
- 'required' => true
1403
- ),
1404
- 'webPropertyId' => array(
1405
- 'location' => 'path',
1406
- 'type' => 'string',
1407
- 'required' => true
1408
- ),
1409
- 'customDataSourceId' => array(
1410
- 'location' => 'path',
1411
- 'type' => 'string',
1412
- 'required' => true
1413
- )
1414
- )
1415
- ),
1416
- 'get' => array(
1417
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads/{uploadId}',
1418
- 'httpMethod' => 'GET',
1419
- 'parameters' => array(
1420
- 'accountId' => array(
1421
- 'location' => 'path',
1422
- 'type' => 'string',
1423
- 'required' => true
1424
- ),
1425
- 'webPropertyId' => array(
1426
- 'location' => 'path',
1427
- 'type' => 'string',
1428
- 'required' => true
1429
- ),
1430
- 'customDataSourceId' => array(
1431
- 'location' => 'path',
1432
- 'type' => 'string',
1433
- 'required' => true
1434
- ),
1435
- 'uploadId' => array(
1436
- 'location' => 'path',
1437
- 'type' => 'string',
1438
- 'required' => true
1439
- )
1440
- )
1441
- ),
1442
- 'list' => array(
1443
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads',
1444
- 'httpMethod' => 'GET',
1445
- 'parameters' => array(
1446
- 'accountId' => array(
1447
- 'location' => 'path',
1448
- 'type' => 'string',
1449
- 'required' => true
1450
- ),
1451
- 'webPropertyId' => array(
1452
- 'location' => 'path',
1453
- 'type' => 'string',
1454
- 'required' => true
1455
- ),
1456
- 'customDataSourceId' => array(
1457
- 'location' => 'path',
1458
- 'type' => 'string',
1459
- 'required' => true
1460
- ),
1461
- 'max-results' => array(
1462
- 'location' => 'query',
1463
- 'type' => 'integer'
1464
- ),
1465
- 'start-index' => array(
1466
- 'location' => 'query',
1467
- 'type' => 'integer'
1468
- )
1469
- )
1470
- ),
1471
- 'migrateDataImport' => array(
1472
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/migrateDataImport',
1473
- 'httpMethod' => 'POST',
1474
- 'parameters' => array(
1475
- 'accountId' => array(
1476
- 'location' => 'path',
1477
- 'type' => 'string',
1478
- 'required' => true
1479
- ),
1480
- 'webPropertyId' => array(
1481
- 'location' => 'path',
1482
- 'type' => 'string',
1483
- 'required' => true
1484
- ),
1485
- 'customDataSourceId' => array(
1486
- 'location' => 'path',
1487
- 'type' => 'string',
1488
- 'required' => true
1489
- )
1490
- )
1491
- ),
1492
- 'uploadData' => array(
1493
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/customDataSources/{customDataSourceId}/uploads',
1494
- 'httpMethod' => 'POST',
1495
- 'parameters' => array(
1496
- 'accountId' => array(
1497
- 'location' => 'path',
1498
- 'type' => 'string',
1499
- 'required' => true
1500
- ),
1501
- 'webPropertyId' => array(
1502
- 'location' => 'path',
1503
- 'type' => 'string',
1504
- 'required' => true
1505
- ),
1506
- 'customDataSourceId' => array(
1507
- 'location' => 'path',
1508
- 'type' => 'string',
1509
- 'required' => true
1510
- )
1511
- )
1512
- )
1513
- )
1514
- ));
1515
- $this->management_webPropertyAdWordsLinks = new Google_Service_Analytics_ManagementWebPropertyAdWordsLinks_Resource($this, $this->serviceName, 'webPropertyAdWordsLinks', array(
1516
- 'methods' => array(
1517
- 'delete' => array(
1518
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}',
1519
- 'httpMethod' => 'DELETE',
1520
- 'parameters' => array(
1521
- 'accountId' => array(
1522
- 'location' => 'path',
1523
- 'type' => 'string',
1524
- 'required' => true
1525
- ),
1526
- 'webPropertyId' => array(
1527
- 'location' => 'path',
1528
- 'type' => 'string',
1529
- 'required' => true
1530
- ),
1531
- 'webPropertyAdWordsLinkId' => array(
1532
- 'location' => 'path',
1533
- 'type' => 'string',
1534
- 'required' => true
1535
- )
1536
- )
1537
- ),
1538
- 'get' => array(
1539
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}',
1540
- 'httpMethod' => 'GET',
1541
- 'parameters' => array(
1542
- 'accountId' => array(
1543
- 'location' => 'path',
1544
- 'type' => 'string',
1545
- 'required' => true
1546
- ),
1547
- 'webPropertyId' => array(
1548
- 'location' => 'path',
1549
- 'type' => 'string',
1550
- 'required' => true
1551
- ),
1552
- 'webPropertyAdWordsLinkId' => array(
1553
- 'location' => 'path',
1554
- 'type' => 'string',
1555
- 'required' => true
1556
- )
1557
- )
1558
- ),
1559
- 'insert' => array(
1560
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks',
1561
- 'httpMethod' => 'POST',
1562
- 'parameters' => array(
1563
- 'accountId' => array(
1564
- 'location' => 'path',
1565
- 'type' => 'string',
1566
- 'required' => true
1567
- ),
1568
- 'webPropertyId' => array(
1569
- 'location' => 'path',
1570
- 'type' => 'string',
1571
- 'required' => true
1572
- )
1573
- )
1574
- ),
1575
- 'list' => array(
1576
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks',
1577
- 'httpMethod' => 'GET',
1578
- 'parameters' => array(
1579
- 'accountId' => array(
1580
- 'location' => 'path',
1581
- 'type' => 'string',
1582
- 'required' => true
1583
- ),
1584
- 'webPropertyId' => array(
1585
- 'location' => 'path',
1586
- 'type' => 'string',
1587
- 'required' => true
1588
- ),
1589
- 'max-results' => array(
1590
- 'location' => 'query',
1591
- 'type' => 'integer'
1592
- ),
1593
- 'start-index' => array(
1594
- 'location' => 'query',
1595
- 'type' => 'integer'
1596
- )
1597
- )
1598
- ),
1599
- 'patch' => array(
1600
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}',
1601
- 'httpMethod' => 'PATCH',
1602
- 'parameters' => array(
1603
- 'accountId' => array(
1604
- 'location' => 'path',
1605
- 'type' => 'string',
1606
- 'required' => true
1607
- ),
1608
- 'webPropertyId' => array(
1609
- 'location' => 'path',
1610
- 'type' => 'string',
1611
- 'required' => true
1612
- ),
1613
- 'webPropertyAdWordsLinkId' => array(
1614
- 'location' => 'path',
1615
- 'type' => 'string',
1616
- 'required' => true
1617
- )
1618
- )
1619
- ),
1620
- 'update' => array(
1621
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/entityAdWordsLinks/{webPropertyAdWordsLinkId}',
1622
- 'httpMethod' => 'PUT',
1623
- 'parameters' => array(
1624
- 'accountId' => array(
1625
- 'location' => 'path',
1626
- 'type' => 'string',
1627
- 'required' => true
1628
- ),
1629
- 'webPropertyId' => array(
1630
- 'location' => 'path',
1631
- 'type' => 'string',
1632
- 'required' => true
1633
- ),
1634
- 'webPropertyAdWordsLinkId' => array(
1635
- 'location' => 'path',
1636
- 'type' => 'string',
1637
- 'required' => true
1638
- )
1639
- )
1640
- )
1641
- )
1642
- ));
1643
- $this->management_webproperties = new Google_Service_Analytics_ManagementWebproperties_Resource($this, $this->serviceName, 'webproperties', array(
1644
- 'methods' => array(
1645
- 'get' => array(
1646
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}',
1647
- 'httpMethod' => 'GET',
1648
- 'parameters' => array(
1649
- 'accountId' => array(
1650
- 'location' => 'path',
1651
- 'type' => 'string',
1652
- 'required' => true
1653
- ),
1654
- 'webPropertyId' => array(
1655
- 'location' => 'path',
1656
- 'type' => 'string',
1657
- 'required' => true
1658
- )
1659
- )
1660
- ),
1661
- 'insert' => array(
1662
- 'path' => 'management/accounts/{accountId}/webproperties',
1663
- 'httpMethod' => 'POST',
1664
- 'parameters' => array(
1665
- 'accountId' => array(
1666
- 'location' => 'path',
1667
- 'type' => 'string',
1668
- 'required' => true
1669
- )
1670
- )
1671
- ),
1672
- 'list' => array(
1673
- 'path' => 'management/accounts/{accountId}/webproperties',
1674
- 'httpMethod' => 'GET',
1675
- 'parameters' => array(
1676
- 'accountId' => array(
1677
- 'location' => 'path',
1678
- 'type' => 'string',
1679
- 'required' => true
1680
- ),
1681
- 'max-results' => array(
1682
- 'location' => 'query',
1683
- 'type' => 'integer'
1684
- ),
1685
- 'start-index' => array(
1686
- 'location' => 'query',
1687
- 'type' => 'integer'
1688
- )
1689
- )
1690
- ),
1691
- 'patch' => array(
1692
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}',
1693
- 'httpMethod' => 'PATCH',
1694
- 'parameters' => array(
1695
- 'accountId' => array(
1696
- 'location' => 'path',
1697
- 'type' => 'string',
1698
- 'required' => true
1699
- ),
1700
- 'webPropertyId' => array(
1701
- 'location' => 'path',
1702
- 'type' => 'string',
1703
- 'required' => true
1704
- )
1705
- )
1706
- ),
1707
- 'update' => array(
1708
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}',
1709
- 'httpMethod' => 'PUT',
1710
- 'parameters' => array(
1711
- 'accountId' => array(
1712
- 'location' => 'path',
1713
- 'type' => 'string',
1714
- 'required' => true
1715
- ),
1716
- 'webPropertyId' => array(
1717
- 'location' => 'path',
1718
- 'type' => 'string',
1719
- 'required' => true
1720
- )
1721
- )
1722
- )
1723
- )
1724
- ));
1725
- $this->management_webpropertyUserLinks = new Google_Service_Analytics_ManagementWebpropertyUserLinks_Resource($this, $this->serviceName, 'webpropertyUserLinks', array(
1726
- 'methods' => array(
1727
- 'delete' => array(
1728
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks/{linkId}',
1729
- 'httpMethod' => 'DELETE',
1730
- 'parameters' => array(
1731
- 'accountId' => array(
1732
- 'location' => 'path',
1733
- 'type' => 'string',
1734
- 'required' => true
1735
- ),
1736
- 'webPropertyId' => array(
1737
- 'location' => 'path',
1738
- 'type' => 'string',
1739
- 'required' => true
1740
- ),
1741
- 'linkId' => array(
1742
- 'location' => 'path',
1743
- 'type' => 'string',
1744
- 'required' => true
1745
- )
1746
- )
1747
- ),
1748
- 'insert' => array(
1749
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks',
1750
- 'httpMethod' => 'POST',
1751
- 'parameters' => array(
1752
- 'accountId' => array(
1753
- 'location' => 'path',
1754
- 'type' => 'string',
1755
- 'required' => true
1756
- ),
1757
- 'webPropertyId' => array(
1758
- 'location' => 'path',
1759
- 'type' => 'string',
1760
- 'required' => true
1761
- )
1762
- )
1763
- ),
1764
- 'list' => array(
1765
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks',
1766
- 'httpMethod' => 'GET',
1767
- 'parameters' => array(
1768
- 'accountId' => array(
1769
- 'location' => 'path',
1770
- 'type' => 'string',
1771
- 'required' => true
1772
- ),
1773
- 'webPropertyId' => array(
1774
- 'location' => 'path',
1775
- 'type' => 'string',
1776
- 'required' => true
1777
- ),
1778
- 'max-results' => array(
1779
- 'location' => 'query',
1780
- 'type' => 'integer'
1781
- ),
1782
- 'start-index' => array(
1783
- 'location' => 'query',
1784
- 'type' => 'integer'
1785
- )
1786
- )
1787
- ),
1788
- 'update' => array(
1789
- 'path' => 'management/accounts/{accountId}/webproperties/{webPropertyId}/entityUserLinks/{linkId}',
1790
- 'httpMethod' => 'PUT',
1791
- 'parameters' => array(
1792
- 'accountId' => array(
1793
- 'location' => 'path',
1794
- 'type' => 'string',
1795
- 'required' => true
1796
- ),
1797
- 'webPropertyId' => array(
1798
- 'location' => 'path',
1799
- 'type' => 'string',
1800
- 'required' => true
1801
- ),
1802
- 'linkId' => array(
1803
- 'location' => 'path',
1804
- 'type' => 'string',
1805
- 'required' => true
1806
- )
1807
- )
1808
- )
1809
- )
1810
- ));
1811
- $this->metadata_columns = new Google_Service_Analytics_MetadataColumns_Resource($this, $this->serviceName, 'columns', array(
1812
- 'methods' => array(
1813
- 'list' => array(
1814
- 'path' => 'metadata/{reportType}/columns',
1815
- 'httpMethod' => 'GET',
1816
- 'parameters' => array(
1817
- 'reportType' => array(
1818
- 'location' => 'path',
1819
- 'type' => 'string',
1820
- 'required' => true
1821
- )
1822
- )
1823
- )
1824
- )
1825
- ));
1826
- $this->provisioning = new Google_Service_Analytics_Provisioning_Resource($this, $this->serviceName, 'provisioning', array(
1827
- 'methods' => array(
1828
- 'createAccountTicket' => array(
1829
- 'path' => 'provisioning/createAccountTicket',
1830
- 'httpMethod' => 'POST',
1831
- 'parameters' => array()
1832
- )
1833
- )
1834
- ));
1835
- }
1836
- }
1837
-
1838
- /**
1839
- * The "data" collection of methods.
1840
- * Typical usage is:
1841
- * <code>
1842
- * $analyticsService = new Google_Service_Analytics(...);
1843
- * $data = $analyticsService->data;
1844
- * </code>
1845
- */
1846
- class Google_Service_Analytics_Data_Resource extends Google_Service_Resource
1847
- {
1848
- }
1849
-
1850
- /**
1851
- * The "ga" collection of methods.
1852
- * Typical usage is:
1853
- * <code>
1854
- * $analyticsService = new Google_Service_Analytics(...);
1855
- * $ga = $analyticsService->ga;
1856
- * </code>
1857
- */
1858
- class Google_Service_Analytics_DataGa_Resource extends Google_Service_Resource
1859
- {
1860
-
1861
- /**
1862
- * Returns Analytics data for a view (profile).
1863
- * (ga.get)
1864
- *
1865
- * @param string $ids
1866
- * Unique table ID for retrieving Analytics data. Table ID is
1867
- * of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
1868
- * @param string $startDate
1869
- * Start date for fetching Analytics data. Requests can
1870
- * specify a start date formatted as YYYY-MM-DD, or as a relative date (e.g.,
1871
- * today, yesterday, or 7daysAgo). The default value is 7daysAgo.
1872
- * @param string $endDate
1873
- * End date for fetching Analytics data. Request can
1874
- * should specify an end date formatted as YYYY-MM-DD, or as a relative date
1875
- * (e.g., today, yesterday, or 7daysAgo). The default value is yesterday.
1876
- * @param string $metrics
1877
- * A comma-separated list of Analytics metrics. E.g.,
1878
- * 'ga:sessions,ga:pageviews'. At least one metric must be specified.
1879
- * @param array $optParams
1880
- * Optional parameters.
1881
- *
1882
- * @opt_param int max-results The maximum number of entries to include in this
1883
- * feed.
1884
- * @opt_param string sort A comma-separated list of dimensions or metrics that
1885
- * determine the sort order for Analytics data.
1886
- * @opt_param string dimensions A comma-separated list of Analytics dimensions.
1887
- * E.g., 'ga:browser,ga:city'.
1888
- * @opt_param int start-index An index of the first entity to retrieve. Use this
1889
- * parameter as a pagination mechanism along with the max-results parameter.
1890
- * @opt_param string segment An Analytics segment to be applied to data.
1891
- * @opt_param string samplingLevel The desired sampling level.
1892
- * @opt_param string filters A comma-separated list of dimension or metric
1893
- * filters to be applied to Analytics data.
1894
- * @opt_param string output The selected format for the response. Default format
1895
- * is JSON.
1896
- * @return Google_Service_Analytics_GaData
1897
- */
1898
- public function get($ids, $startDate, $endDate, $metrics, $optParams = array())
1899
- {
1900
- $params = array(
1901
- 'ids' => $ids,
1902
- 'start-date' => $startDate,
1903
- 'end-date' => $endDate,
1904
- 'metrics' => $metrics
1905
- );
1906
- $params = array_merge($params, $optParams);
1907
- return $this->call('get', array(
1908
- $params
1909
- ), "Google_Service_Analytics_GaData");
1910
- }
1911
- }
1912
-
1913
- /**
1914
- * The "mcf" collection of methods.
1915
- * Typical usage is:
1916
- * <code>
1917
- * $analyticsService = new Google_Service_Analytics(...);
1918
- * $mcf = $analyticsService->mcf;
1919
- * </code>
1920
- */
1921
- class Google_Service_Analytics_DataMcf_Resource extends Google_Service_Resource
1922
- {
1923
-
1924
- /**
1925
- * Returns Analytics Multi-Channel Funnels data for a view (profile).
1926
- * (mcf.get)
1927
- *
1928
- * @param string $ids
1929
- * Unique table ID for retrieving Analytics data. Table ID is
1930
- * of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
1931
- * @param string $startDate
1932
- * Start date for fetching Analytics data. Requests can
1933
- * specify a start date formatted as YYYY-MM-DD, or as a relative date (e.g.,
1934
- * today, yesterday, or 7daysAgo). The default value is 7daysAgo.
1935
- * @param string $endDate
1936
- * End date for fetching Analytics data. Requests can
1937
- * specify a start date formatted as YYYY-MM-DD, or as a relative date (e.g.,
1938
- * today, yesterday, or 7daysAgo). The default value is 7daysAgo.
1939
- * @param string $metrics
1940
- * A comma-separated list of Multi-Channel Funnels
1941
- * metrics. E.g., 'mcf:totalConversions,mcf:totalConversionValue'. At least one
1942
- * metric must be specified.
1943
- * @param array $optParams
1944
- * Optional parameters.
1945
- *
1946
- * @opt_param int max-results The maximum number of entries to include in this
1947
- * feed.
1948
- * @opt_param string sort A comma-separated list of dimensions or metrics that
1949
- * determine the sort order for the Analytics data.
1950
- * @opt_param string dimensions A comma-separated list of Multi-Channel Funnels
1951
- * dimensions. E.g., 'mcf:source,mcf:medium'.
1952
- * @opt_param int start-index An index of the first entity to retrieve. Use this
1953
- * parameter as a pagination mechanism along with the max-results parameter.
1954
- * @opt_param string samplingLevel The desired sampling level.
1955
- * @opt_param string filters A comma-separated list of dimension or metric
1956
- * filters to be applied to the Analytics data.
1957
- * @return Google_Service_Analytics_McfData
1958
- */
1959
- public function get($ids, $startDate, $endDate, $metrics, $optParams = array())
1960
- {
1961
- $params = array(
1962
- 'ids' => $ids,
1963
- 'start-date' => $startDate,
1964
- 'end-date' => $endDate,
1965
- 'metrics' => $metrics
1966
- );
1967
- $params = array_merge($params, $optParams);
1968
- return $this->call('get', array(
1969
- $params
1970
- ), "Google_Service_Analytics_McfData");
1971
- }
1972
- }
1973
-
1974
- /**
1975
- * The "realtime" collection of methods.
1976
- * Typical usage is:
1977
- * <code>
1978
- * $analyticsService = new Google_Service_Analytics(...);
1979
- * $realtime = $analyticsService->realtime;
1980
- * </code>
1981
- */
1982
- class Google_Service_Analytics_DataRealtime_Resource extends Google_Service_Resource
1983
- {
1984
-
1985
- /**
1986
- * Returns real time data for a view (profile).
1987
- * (realtime.get)
1988
- *
1989
- * @param string $ids
1990
- * Unique table ID for retrieving real time data. Table ID is
1991
- * of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
1992
- * @param string $metrics
1993
- * A comma-separated list of real time metrics. E.g.,
1994
- * 'rt:activeUsers'. At least one metric must be specified.
1995
- * @param array $optParams
1996
- * Optional parameters.
1997
- *
1998
- * @opt_param int max-results The maximum number of entries to include in this
1999
- * feed.
2000
- * @opt_param string sort A comma-separated list of dimensions or metrics that
2001
- * determine the sort order for real time data.
2002
- * @opt_param string dimensions A comma-separated list of real time dimensions.
2003
- * E.g., 'rt:medium,rt:city'.
2004
- * @opt_param string filters A comma-separated list of dimension or metric
2005
- * filters to be applied to real time data.
2006
- * @return Google_Service_Analytics_RealtimeData
2007
- */
2008
- public function get($ids, $metrics, $optParams = array())
2009
- {
2010
- $params = array(
2011
- 'ids' => $ids,
2012
- 'metrics' => $metrics
2013
- );
2014
- $params = array_merge($params, $optParams);
2015
- return $this->call('get', array(
2016
- $params
2017
- ), "Google_Service_Analytics_RealtimeData");
2018
- }
2019
- }
2020
-
2021
- /**
2022
- * The "management" collection of methods.
2023
- * Typical usage is:
2024
- * <code>
2025
- * $analyticsService = new Google_Service_Analytics(...);
2026
- * $management = $analyticsService->management;
2027
- * </code>
2028
- */
2029
- class Google_Service_Analytics_Management_Resource extends Google_Service_Resource
2030
- {
2031
- }
2032
-
2033
- /**
2034
- * The "accountSummaries" collection of methods.
2035
- * Typical usage is:
2036
- * <code>
2037
- * $analyticsService = new Google_Service_Analytics(...);
2038
- * $accountSummaries = $analyticsService->accountSummaries;
2039
- * </code>
2040
- */
2041
- class Google_Service_Analytics_ManagementAccountSummaries_Resource extends Google_Service_Resource
2042
- {
2043
-
2044
- /**
2045
- * Lists account summaries (lightweight tree comprised of
2046
- * accounts/properties/profiles) to which the user has access.
2047
- * (accountSummaries.listManagementAccountSummaries)
2048
- *
2049
- * @param array $optParams
2050
- * Optional parameters.
2051
- *
2052
- * @opt_param int max-results The maximum number of account summaries to include
2053
- * in this response, where the largest acceptable value is 1000.
2054
- * @opt_param int start-index An index of the first entity to retrieve. Use this
2055
- * parameter as a pagination mechanism along with the max-results parameter.
2056
- * @return Google_Service_Analytics_AccountSummaries
2057
- */
2058
- public function listManagementAccountSummaries($optParams = array())
2059
- {
2060
- $params = array();
2061
- $params = array_merge($params, $optParams);
2062
- return $this->call('list', array(
2063
- $params
2064
- ), "Google_Service_Analytics_AccountSummaries");
2065
- }
2066
- }
2067
-
2068
- /**
2069
- * The "accountUserLinks" collection of methods.
2070
- * Typical usage is:
2071
- * <code>
2072
- * $analyticsService = new Google_Service_Analytics(...);
2073
- * $accountUserLinks = $analyticsService->accountUserLinks;
2074
- * </code>
2075
- */
2076
- class Google_Service_Analytics_ManagementAccountUserLinks_Resource extends Google_Service_Resource
2077
- {
2078
-
2079
- /**
2080
- * Removes a user from the given account.
2081
- * (accountUserLinks.delete)
2082
- *
2083
- * @param string $accountId
2084
- * Account ID to delete the user link for.
2085
- * @param string $linkId
2086
- * Link ID to delete the user link for.
2087
- * @param array $optParams
2088
- * Optional parameters.
2089
- */
2090
- public function delete($accountId, $linkId, $optParams = array())
2091
- {
2092
- $params = array(
2093
- 'accountId' => $accountId,
2094
- 'linkId' => $linkId
2095
- );
2096
- $params = array_merge($params, $optParams);
2097
- return $this->call('delete', array(
2098
- $params
2099
- ));
2100
- }
2101
-
2102
- /**
2103
- * Adds a new user to the given account.
2104
- * (accountUserLinks.insert)
2105
- *
2106
- * @param string $accountId
2107
- * Account ID to create the user link for.
2108
- * @param Google_EntityUserLink $postBody
2109
- * @param array $optParams
2110
- * Optional parameters.
2111
- * @return Google_Service_Analytics_EntityUserLink
2112
- */
2113
- public function insert($accountId, Google_Service_Analytics_EntityUserLink $postBody, $optParams = array())
2114
- {
2115
- $params = array(
2116
- 'accountId' => $accountId,
2117
- 'postBody' => $postBody
2118
- );
2119
- $params = array_merge($params, $optParams);
2120
- return $this->call('insert', array(
2121
- $params
2122
- ), "Google_Service_Analytics_EntityUserLink");
2123
- }
2124
-
2125
- /**
2126
- * Lists account-user links for a given account.
2127
- * (accountUserLinks.listManagementAccountUserLinks)
2128
- *
2129
- * @param string $accountId
2130
- * Account ID to retrieve the user links for.
2131
- * @param array $optParams
2132
- * Optional parameters.
2133
- *
2134
- * @opt_param int max-results The maximum number of account-user links to
2135
- * include in this response.
2136
- * @opt_param int start-index An index of the first account-user link to
2137
- * retrieve. Use this parameter as a pagination mechanism along with the max-
2138
- * results parameter.
2139
- * @return Google_Service_Analytics_EntityUserLinks
2140
- */
2141
- public function listManagementAccountUserLinks($accountId, $optParams = array())
2142
- {
2143
- $params = array(
2144
- 'accountId' => $accountId
2145
- );
2146
- $params = array_merge($params, $optParams);
2147
- return $this->call('list', array(
2148
- $params
2149
- ), "Google_Service_Analytics_EntityUserLinks");
2150
- }
2151
-
2152
- /**
2153
- * Updates permissions for an existing user on the given account.
2154
- * (accountUserLinks.update)
2155
- *
2156
- * @param string $accountId
2157
- * Account ID to update the account-user link for.
2158
- * @param string $linkId
2159
- * Link ID to update the account-user link for.
2160
- * @param Google_EntityUserLink $postBody
2161
- * @param array $optParams
2162
- * Optional parameters.
2163
- * @return Google_Service_Analytics_EntityUserLink
2164
- */
2165
- public function update($accountId, $linkId, Google_Service_Analytics_EntityUserLink $postBody, $optParams = array())
2166
- {
2167
- $params = array(
2168
- 'accountId' => $accountId,
2169
- 'linkId' => $linkId,
2170
- 'postBody' => $postBody
2171
- );
2172
- $params = array_merge($params, $optParams);
2173
- return $this->call('update', array(
2174
- $params
2175
- ), "Google_Service_Analytics_EntityUserLink");
2176
- }
2177
- }
2178
-
2179
- /**
2180
- * The "accounts" collection of methods.
2181
- * Typical usage is:
2182
- * <code>
2183
- * $analyticsService = new Google_Service_Analytics(...);
2184
- * $accounts = $analyticsService->accounts;
2185
- * </code>
2186
- */
2187
- class Google_Service_Analytics_ManagementAccounts_Resource extends Google_Service_Resource
2188
- {
2189
-
2190
- /**
2191
- * Lists all accounts to which the user has access.
2192
- * (accounts.listManagementAccounts)
2193
- *
2194
- * @param array $optParams
2195
- * Optional parameters.
2196
- *
2197
- * @opt_param int max-results The maximum number of accounts to include in this
2198
- * response.
2199
- * @opt_param int start-index An index of the first account to retrieve. Use
2200
- * this parameter as a pagination mechanism along with the max-results
2201
- * parameter.
2202
- * @return Google_Service_Analytics_Accounts
2203
- */
2204
- public function listManagementAccounts($optParams = array())
2205
- {
2206
- $params = array();
2207
- $params = array_merge($params, $optParams);
2208
- return $this->call('list', array(
2209
- $params
2210
- ), "Google_Service_Analytics_Accounts");
2211
- }
2212
- }
2213
-
2214
- /**
2215
- * The "customDataSources" collection of methods.
2216
- * Typical usage is:
2217
- * <code>
2218
- * $analyticsService = new Google_Service_Analytics(...);
2219
- * $customDataSources = $analyticsService->customDataSources;
2220
- * </code>
2221
- */
2222
- class Google_Service_Analytics_ManagementCustomDataSources_Resource extends Google_Service_Resource
2223
- {
2224
-
2225
- /**
2226
- * List custom data sources to which the user has access.
2227
- * (customDataSources.listManagementCustomDataSources)
2228
- *
2229
- * @param string $accountId
2230
- * Account Id for the custom data sources to retrieve.
2231
- * @param string $webPropertyId
2232
- * Web property Id for the custom data sources to
2233
- * retrieve.
2234
- * @param array $optParams
2235
- * Optional parameters.
2236
- *
2237
- * @opt_param int max-results The maximum number of custom data sources to
2238
- * include in this response.
2239
- * @opt_param int start-index A 1-based index of the first custom data source to
2240
- * retrieve. Use this parameter as a pagination mechanism along with the max-
2241
- * results parameter.
2242
- * @return Google_Service_Analytics_CustomDataSources
2243
- */
2244
- public function listManagementCustomDataSources($accountId, $webPropertyId, $optParams = array())
2245
- {
2246
- $params = array(
2247
- 'accountId' => $accountId,
2248
- 'webPropertyId' => $webPropertyId
2249
- );
2250
- $params = array_merge($params, $optParams);
2251
- return $this->call('list', array(
2252
- $params
2253
- ), "Google_Service_Analytics_CustomDataSources");
2254
- }
2255
- }
2256
-
2257
- /**
2258
- * The "dailyUploads" collection of methods.
2259
- * Typical usage is:
2260
- * <code>
2261
- * $analyticsService = new Google_Service_Analytics(...);
2262
- * $dailyUploads = $analyticsService->dailyUploads;
2263
- * </code>
2264
- */
2265
- class Google_Service_Analytics_ManagementDailyUploads_Resource extends Google_Service_Resource
2266
- {
2267
-
2268
- /**
2269
- * Delete uploaded data for the given date.
2270
- * (dailyUploads.delete)
2271
- *
2272
- * @param string $accountId
2273
- * Account Id associated with daily upload delete.
2274
- * @param string $webPropertyId
2275
- * Web property Id associated with daily upload
2276
- * delete.
2277
- * @param string $customDataSourceId
2278
- * Custom data source Id associated with daily
2279
- * upload delete.
2280
- * @param string $date
2281
- * Date for which data is to be deleted. Date should be
2282
- * formatted as YYYY-MM-DD.
2283
- * @param string $type
2284
- * Type of data for this delete.
2285
- * @param array $optParams
2286
- * Optional parameters.
2287
- */
2288
- public function delete($accountId, $webPropertyId, $customDataSourceId, $date, $type, $optParams = array())
2289
- {
2290
- $params = array(
2291
- 'accountId' => $accountId,
2292
- 'webPropertyId' => $webPropertyId,
2293
- 'customDataSourceId' => $customDataSourceId,
2294
- 'date' => $date,
2295
- 'type' => $type
2296
- );
2297
- $params = array_merge($params, $optParams);
2298
- return $this->call('delete', array(
2299
- $params
2300
- ));
2301
- }
2302
-
2303
- /**
2304
- * List daily uploads to which the user has access.
2305
- * (dailyUploads.listManagementDailyUploads)
2306
- *
2307
- * @param string $accountId
2308
- * Account Id for the daily uploads to retrieve.
2309
- * @param string $webPropertyId
2310
- * Web property Id for the daily uploads to
2311
- * retrieve.
2312
- * @param string $customDataSourceId
2313
- * Custom data source Id for daily uploads to
2314
- * retrieve.
2315
- * @param string $startDate
2316
- * Start date of the form YYYY-MM-DD.
2317
- * @param string $endDate
2318
- * End date of the form YYYY-MM-DD.
2319
- * @param array $optParams
2320
- * Optional parameters.
2321
- *
2322
- * @opt_param int max-results The maximum number of custom data sources to
2323
- * include in this response.
2324
- * @opt_param int start-index A 1-based index of the first daily upload to
2325
- * retrieve. Use this parameter as a pagination mechanism along with the max-
2326
- * results parameter.
2327
- * @return Google_Service_Analytics_DailyUploads
2328
- */
2329
- public function listManagementDailyUploads($accountId, $webPropertyId, $customDataSourceId, $startDate, $endDate, $optParams = array())
2330
- {
2331
- $params = array(
2332
- 'accountId' => $accountId,
2333
- 'webPropertyId' => $webPropertyId,
2334
- 'customDataSourceId' => $customDataSourceId,
2335
- 'start-date' => $startDate,
2336
- 'end-date' => $endDate
2337
- );
2338
- $params = array_merge($params, $optParams);
2339
- return $this->call('list', array(
2340
- $params
2341
- ), "Google_Service_Analytics_DailyUploads");
2342
- }
2343
-
2344
- /**
2345
- * Update/Overwrite data for a custom data source.
2346
- * (dailyUploads.upload)
2347
- *
2348
- * @param string $accountId
2349
- * Account Id associated with daily upload.
2350
- * @param string $webPropertyId
2351
- * Web property Id associated with daily upload.
2352
- * @param string $customDataSourceId
2353
- * Custom data source Id to which the data
2354
- * being uploaded belongs.
2355
- * @param string $date
2356
- * Date for which data is uploaded. Date should be formatted
2357
- * as YYYY-MM-DD.
2358
- * @param int $appendNumber
2359
- * Append number for this upload indexed from 1.
2360
- * @param string $type
2361
- * Type of data for this upload.
2362
- * @param array $optParams
2363
- * Optional parameters.
2364
- *
2365
- * @opt_param bool reset Reset/Overwrite all previous appends for this date and
2366
- * start over with this file as the first upload.
2367
- * @return Google_Service_Analytics_DailyUploadAppend
2368
- */
2369
- public function upload($accountId, $webPropertyId, $customDataSourceId, $date, $appendNumber, $type, $optParams = array())
2370
- {
2371
- $params = array(
2372
- 'accountId' => $accountId,
2373
- 'webPropertyId' => $webPropertyId,
2374
- 'customDataSourceId' => $customDataSourceId,
2375
- 'date' => $date,
2376
- 'appendNumber' => $appendNumber,
2377
- 'type' => $type
2378
- );
2379
- $params = array_merge($params, $optParams);
2380
- return $this->call('upload', array(
2381
- $params
2382
- ), "Google_Service_Analytics_DailyUploadAppend");
2383
- }
2384
- }
2385
-
2386
- /**
2387
- * The "experiments" collection of methods.
2388
- * Typical usage is:
2389
- * <code>
2390
- * $analyticsService = new Google_Service_Analytics(...);
2391
- * $experiments = $analyticsService->experiments;
2392
- * </code>
2393
- */
2394
- class Google_Service_Analytics_ManagementExperiments_Resource extends Google_Service_Resource
2395
- {
2396
-
2397
- /**
2398
- * Delete an experiment.
2399
- * (experiments.delete)
2400
- *
2401
- * @param string $accountId
2402
- * Account ID to which the experiment belongs
2403
- * @param string $webPropertyId
2404
- * Web property ID to which the experiment belongs
2405
- * @param string $profileId
2406
- * View (Profile) ID to which the experiment belongs
2407
- * @param string $experimentId
2408
- * ID of the experiment to delete
2409
- * @param array $optParams
2410
- * Optional parameters.
2411
- */
2412
- public function delete($accountId, $webPropertyId, $profileId, $experimentId, $optParams = array())
2413
- {
2414
- $params = array(
2415
- 'accountId' => $accountId,
2416
- 'webPropertyId' => $webPropertyId,
2417
- 'profileId' => $profileId,
2418
- 'experimentId' => $experimentId
2419
- );
2420
- $params = array_merge($params, $optParams);
2421
- return $this->call('delete', array(
2422
- $params
2423
- ));
2424
- }
2425
-
2426
- /**
2427
- * Returns an experiment to which the user has access.
2428
- * (experiments.get)
2429
- *
2430
- * @param string $accountId
2431
- * Account ID to retrieve the experiment for.
2432
- * @param string $webPropertyId
2433
- * Web property ID to retrieve the experiment for.
2434
- * @param string $profileId
2435
- * View (Profile) ID to retrieve the experiment for.
2436
- * @param string $experimentId
2437
- * Experiment ID to retrieve the experiment for.
2438
- * @param array $optParams
2439
- * Optional parameters.
2440
- * @return Google_Service_Analytics_Experiment
2441
- */
2442
- public function get($accountId, $webPropertyId, $profileId, $experimentId, $optParams = array())
2443
- {
2444
- $params = array(
2445
- 'accountId' => $accountId,
2446
- 'webPropertyId' => $webPropertyId,
2447
- 'profileId' => $profileId,
2448
- 'experimentId' => $experimentId
2449
- );
2450
- $params = array_merge($params, $optParams);
2451
- return $this->call('get', array(
2452
- $params
2453
- ), "Google_Service_Analytics_Experiment");
2454
- }
2455
-
2456
- /**
2457
- * Create a new experiment.
2458
- * (experiments.insert)
2459
- *
2460
- * @param string $accountId
2461
- * Account ID to create the experiment for.
2462
- * @param string $webPropertyId
2463
- * Web property ID to create the experiment for.
2464
- * @param string $profileId
2465
- * View (Profile) ID to create the experiment for.
2466
- * @param Google_Experiment $postBody
2467
- * @param array $optParams
2468
- * Optional parameters.
2469
- * @return Google_Service_Analytics_Experiment
2470
- */
2471
- public function insert($accountId, $webPropertyId, $profileId, Google_Service_Analytics_Experiment $postBody, $optParams = array())
2472
- {
2473
- $params = array(
2474
- 'accountId' => $accountId,
2475
- 'webPropertyId' => $webPropertyId,
2476
- 'profileId' => $profileId,
2477
- 'postBody' => $postBody
2478
- );
2479
- $params = array_merge($params, $optParams);
2480
- return $this->call('insert', array(
2481
- $params
2482
- ), "Google_Service_Analytics_Experiment");
2483
- }
2484
-
2485
- /**
2486
- * Lists experiments to which the user has access.
2487
- * (experiments.listManagementExperiments)
2488
- *
2489
- * @param string $accountId
2490
- * Account ID to retrieve experiments for.
2491
- * @param string $webPropertyId
2492
- * Web property ID to retrieve experiments for.
2493
- * @param string $profileId
2494
- * View (Profile) ID to retrieve experiments for.
2495
- * @param array $optParams
2496
- * Optional parameters.
2497
- *
2498
- * @opt_param int max-results The maximum number of experiments to include in
2499
- * this response.
2500
- * @opt_param int start-index An index of the first experiment to retrieve. Use
2501
- * this parameter as a pagination mechanism along with the max-results
2502
- * parameter.
2503
- * @return Google_Service_Analytics_Experiments
2504
- */
2505
- public function listManagementExperiments($accountId, $webPropertyId, $profileId, $optParams = array())
2506
- {
2507
- $params = array(
2508
- 'accountId' => $accountId,
2509
- 'webPropertyId' => $webPropertyId,
2510
- 'profileId' => $profileId
2511
- );
2512
- $params = array_merge($params, $optParams);
2513
- return $this->call('list', array(
2514
- $params
2515
- ), "Google_Service_Analytics_Experiments");
2516
- }
2517
-
2518
- /**
2519
- * Update an existing experiment.
2520
- * This method supports patch semantics.
2521
- * (experiments.patch)
2522
- *
2523
- * @param string $accountId
2524
- * Account ID of the experiment to update.
2525
- * @param string $webPropertyId
2526
- * Web property ID of the experiment to update.
2527
- * @param string $profileId
2528
- * View (Profile) ID of the experiment to update.
2529
- * @param string $experimentId
2530
- * Experiment ID of the experiment to update.
2531
- * @param Google_Experiment $postBody
2532
- * @param array $optParams
2533
- * Optional parameters.
2534
- * @return Google_Service_Analytics_Experiment
2535
- */
2536
- public function patch($accountId, $webPropertyId, $profileId, $experimentId, Google_Service_Analytics_Experiment $postBody, $optParams = array())
2537
- {
2538
- $params = array(
2539
- 'accountId' => $accountId,
2540
- 'webPropertyId' => $webPropertyId,
2541
- 'profileId' => $profileId,
2542
- 'experimentId' => $experimentId,
2543
- 'postBody' => $postBody
2544
- );
2545
- $params = array_merge($params, $optParams);
2546
- return $this->call('patch', array(
2547
- $params
2548
- ), "Google_Service_Analytics_Experiment");
2549
- }
2550
-
2551
- /**
2552
- * Update an existing experiment.
2553
- * (experiments.update)
2554
- *
2555
- * @param string $accountId
2556
- * Account ID of the experiment to update.
2557
- * @param string $webPropertyId
2558
- * Web property ID of the experiment to update.
2559
- * @param string $profileId
2560
- * View (Profile) ID of the experiment to update.
2561
- * @param string $experimentId
2562
- * Experiment ID of the experiment to update.
2563
- * @param Google_Experiment $postBody
2564
- * @param array $optParams
2565
- * Optional parameters.
2566
- * @return Google_Service_Analytics_Experiment
2567
- */
2568
- public function update($accountId, $webPropertyId, $profileId, $experimentId, Google_Service_Analytics_Experiment $postBody, $optParams = array())
2569
- {
2570
- $params = array(
2571
- 'accountId' => $accountId,
2572
- 'webPropertyId' => $webPropertyId,
2573
- 'profileId' => $profileId,
2574
- 'experimentId' => $experimentId,
2575
- 'postBody' => $postBody
2576
- );
2577
- $params = array_merge($params, $optParams);
2578
- return $this->call('update', array(
2579
- $params
2580
- ), "Google_Service_Analytics_Experiment");
2581
- }
2582
- }
2583
-
2584
- /**
2585
- * The "filters" collection of methods.
2586
- * Typical usage is:
2587
- * <code>
2588
- * $analyticsService = new Google_Service_Analytics(...);
2589
- * $filters = $analyticsService->filters;
2590
- * </code>
2591
- */
2592
- class Google_Service_Analytics_ManagementFilters_Resource extends Google_Service_Resource
2593
- {
2594
-
2595
- /**
2596
- * Delete a filter.
2597
- * (filters.delete)
2598
- *
2599
- * @param string $accountId
2600
- * Account ID to delete the filter for.
2601
- * @param string $filterId
2602
- * ID of the filter to be deleted.
2603
- * @param array $optParams
2604
- * Optional parameters.
2605
- * @return Google_Service_Analytics_Filter
2606
- */
2607
- public function delete($accountId, $filterId, $optParams = array())
2608
- {
2609
- $params = array(
2610
- 'accountId' => $accountId,
2611
- 'filterId' => $filterId
2612
- );
2613
- $params = array_merge($params, $optParams);
2614
- return $this->call('delete', array(
2615
- $params
2616
- ), "Google_Service_Analytics_Filter");
2617
- }
2618
-
2619
- /**
2620
- * Returns a filters to which the user has access.
2621
- * (filters.get)
2622
- *
2623
- * @param string $accountId
2624
- * Account ID to retrieve filters for.
2625
- * @param string $filterId
2626
- * Filter ID to retrieve filters for.
2627
- * @param array $optParams
2628
- * Optional parameters.
2629
- * @return Google_Service_Analytics_Filter
2630
- */
2631
- public function get($accountId, $filterId, $optParams = array())
2632
- {
2633
- $params = array(
2634
- 'accountId' => $accountId,
2635
- 'filterId' => $filterId
2636
- );
2637
- $params = array_merge($params, $optParams);
2638
- return $this->call('get', array(
2639
- $params
2640
- ), "Google_Service_Analytics_Filter");
2641
- }
2642
-
2643
- /**
2644
- * Create a new filter.
2645
- * (filters.insert)
2646
- *
2647
- * @param string $accountId
2648
- * Account ID to create filter for.
2649
- * @param Google_Filter $postBody
2650
- * @param array $optParams
2651
- * Optional parameters.
2652
- * @return Google_Service_Analytics_Filter
2653
- */
2654
- public function insert($accountId, Google_Service_Analytics_Filter $postBody, $optParams = array())
2655
- {
2656
- $params = array(
2657
- 'accountId' => $accountId,
2658
- 'postBody' => $postBody
2659
- );
2660
- $params = array_merge($params, $optParams);
2661
- return $this->call('insert', array(
2662
- $params
2663
- ), "Google_Service_Analytics_Filter");
2664
- }
2665
-
2666
- /**
2667
- * Lists all filters for an account (filters.listManagementFilters)
2668
- *
2669
- * @param string $accountId
2670
- * Account ID to retrieve filters for.
2671
- * @param array $optParams
2672
- * Optional parameters.
2673
- *
2674
- * @opt_param int max-results The maximum number of filters to include in this
2675
- * response.
2676
- * @opt_param int start-index An index of the first entity to retrieve. Use this
2677
- * parameter as a pagination mechanism along with the max-results parameter.
2678
- * @return Google_Service_Analytics_Filters
2679
- */
2680
- public function listManagementFilters($accountId, $optParams = array())
2681
- {
2682
- $params = array(
2683
- 'accountId' => $accountId
2684
- );
2685
- $params = array_merge($params, $optParams);
2686
- return $this->call('list', array(
2687
- $params
2688
- ), "Google_Service_Analytics_Filters");
2689
- }
2690
-
2691
- /**
2692
- * Updates an existing filter.
2693
- * This method supports patch semantics.
2694
- * (filters.patch)
2695
- *
2696
- * @param string $accountId
2697
- * Account ID to which the filter belongs.
2698
- * @param string $filterId
2699
- * ID of the filter to be updated.
2700
- * @param Google_Filter $postBody
2701
- * @param array $optParams
2702
- * Optional parameters.
2703
- * @return Google_Service_Analytics_Filter
2704
- */
2705
- public function patch($accountId, $filterId, Google_Service_Analytics_Filter $postBody, $optParams = array())
2706
- {
2707
- $params = array(
2708
- 'accountId' => $accountId,
2709
- 'filterId' => $filterId,
2710
- 'postBody' => $postBody
2711
- );
2712
- $params = array_merge($params, $optParams);
2713
- return $this->call('patch', array(
2714
- $params
2715
- ), "Google_Service_Analytics_Filter");
2716
- }
2717
-
2718
- /**
2719
- * Updates an existing filter.
2720
- * (filters.update)
2721
- *
2722
- * @param string $accountId
2723
- * Account ID to which the filter belongs.
2724
- * @param string $filterId
2725
- * ID of the filter to be updated.
2726
- * @param Google_Filter $postBody
2727
- * @param array $optParams
2728
- * Optional parameters.
2729
- * @return Google_Service_Analytics_Filter
2730
- */
2731
- public function update($accountId, $filterId, Google_Service_Analytics_Filter $postBody, $optParams = array())
2732
- {
2733
- $params = array(
2734
- 'accountId' => $accountId,
2735
- 'filterId' => $filterId,
2736
- 'postBody' => $postBody
2737
- );
2738
- $params = array_merge($params, $optParams);
2739
- return $this->call('update', array(
2740
- $params
2741
- ), "Google_Service_Analytics_Filter");
2742
- }
2743
- }
2744
-
2745
- /**
2746
- * The "goals" collection of methods.
2747
- * Typical usage is:
2748
- * <code>
2749
- * $analyticsService = new Google_Service_Analytics(...);
2750
- * $goals = $analyticsService->goals;
2751
- * </code>
2752
- */
2753
- class Google_Service_Analytics_ManagementGoals_Resource extends Google_Service_Resource
2754
- {
2755
-
2756
- /**
2757
- * Gets a goal to which the user has access.
2758
- * (goals.get)
2759
- *
2760
- * @param string $accountId
2761
- * Account ID to retrieve the goal for.
2762
- * @param string $webPropertyId
2763
- * Web property ID to retrieve the goal for.
2764
- * @param string $profileId
2765
- * View (Profile) ID to retrieve the goal for.
2766
- * @param string $goalId
2767
- * Goal ID to retrieve the goal for.
2768
- * @param array $optParams
2769
- * Optional parameters.
2770
- * @return Google_Service_Analytics_Goal
2771
- */
2772
- public function get($accountId, $webPropertyId, $profileId, $goalId, $optParams = array())
2773
- {
2774
- $params = array(
2775
- 'accountId' => $accountId,
2776
- 'webPropertyId' => $webPropertyId,
2777
- 'profileId' => $profileId,
2778
- 'goalId' => $goalId
2779
- );
2780
- $params = array_merge($params, $optParams);
2781
- return $this->call('get', array(
2782
- $params
2783
- ), "Google_Service_Analytics_Goal");
2784
- }
2785
-
2786
- /**
2787
- * Create a new goal.
2788
- * (goals.insert)
2789
- *
2790
- * @param string $accountId
2791
- * Account ID to create the goal for.
2792
- * @param string $webPropertyId
2793
- * Web property ID to create the goal for.
2794
- * @param string $profileId
2795
- * View (Profile) ID to create the goal for.
2796
- * @param Google_Goal $postBody
2797
- * @param array $optParams
2798
- * Optional parameters.
2799
- * @return Google_Service_Analytics_Goal
2800
- */
2801
- public function insert($accountId, $webPropertyId, $profileId, Google_Service_Analytics_Goal $postBody, $optParams = array())
2802
- {
2803
- $params = array(
2804
- 'accountId' => $accountId,
2805
- 'webPropertyId' => $webPropertyId,
2806
- 'profileId' => $profileId,
2807
- 'postBody' => $postBody
2808
- );
2809
- $params = array_merge($params, $optParams);
2810
- return $this->call('insert', array(
2811
- $params
2812
- ), "Google_Service_Analytics_Goal");
2813
- }
2814
-
2815
- /**
2816
- * Lists goals to which the user has access.
2817
- * (goals.listManagementGoals)
2818
- *
2819
- * @param string $accountId
2820
- * Account ID to retrieve goals for. Can either be a
2821
- * specific account ID or '~all', which refers to all the accounts that user has
2822
- * access to.
2823
- * @param string $webPropertyId
2824
- * Web property ID to retrieve goals for. Can
2825
- * either be a specific web property ID or '~all', which refers to all the web
2826
- * properties that user has access to.
2827
- * @param string $profileId
2828
- * View (Profile) ID to retrieve goals for. Can either
2829
- * be a specific view (profile) ID or '~all', which refers to all the views
2830
- * (profiles) that user has access to.
2831
- * @param array $optParams
2832
- * Optional parameters.
2833
- *
2834
- * @opt_param int max-results The maximum number of goals to include in this
2835
- * response.
2836
- * @opt_param int start-index An index of the first goal to retrieve. Use this
2837
- * parameter as a pagination mechanism along with the max-results parameter.
2838
- * @return Google_Service_Analytics_Goals
2839
- */
2840
- public function listManagementGoals($accountId, $webPropertyId, $profileId, $optParams = array())
2841
- {
2842
- $params = array(
2843
- 'accountId' => $accountId,
2844
- 'webPropertyId' => $webPropertyId,
2845
- 'profileId' => $profileId
2846
- );
2847
- $params = array_merge($params, $optParams);
2848
- return $this->call('list', array(
2849
- $params
2850
- ), "Google_Service_Analytics_Goals");
2851
- }
2852
-
2853
- /**
2854
- * Updates an existing view (profile).
2855
- * This method supports patch semantics.
2856
- * (goals.patch)
2857
- *
2858
- * @param string $accountId
2859
- * Account ID to update the goal.
2860
- * @param string $webPropertyId
2861
- * Web property ID to update the goal.
2862
- * @param string $profileId
2863
- * View (Profile) ID to update the goal.
2864
- * @param string $goalId
2865
- * Index of the goal to be updated.
2866
- * @param Google_Goal $postBody
2867
- * @param array $optParams
2868
- * Optional parameters.
2869
- * @return Google_Service_Analytics_Goal
2870
- */
2871
- public function patch($accountId, $webPropertyId, $profileId, $goalId, Google_Service_Analytics_Goal $postBody, $optParams = array())
2872
- {
2873
- $params = array(
2874
- 'accountId' => $accountId,
2875
- 'webPropertyId' => $webPropertyId,
2876
- 'profileId' => $profileId,
2877
- 'goalId' => $goalId,
2878
- 'postBody' => $postBody
2879
- );
2880
- $params = array_merge($params, $optParams);
2881
- return $this->call('patch', array(
2882
- $params
2883
- ), "Google_Service_Analytics_Goal");
2884
- }
2885
-
2886
- /**
2887
- * Updates an existing view (profile).
2888
- * (goals.update)
2889
- *
2890
- * @param string $accountId
2891
- * Account ID to update the goal.
2892
- * @param string $webPropertyId
2893
- * Web property ID to update the goal.
2894
- * @param string $profileId
2895
- * View (Profile) ID to update the goal.
2896
- * @param string $goalId
2897
- * Index of the goal to be updated.
2898
- * @param Google_Goal $postBody
2899
- * @param array $optParams
2900
- * Optional parameters.
2901
- * @return Google_Service_Analytics_Goal
2902
- */
2903
- public function update($accountId, $webPropertyId, $profileId, $goalId, Google_Service_Analytics_Goal $postBody, $optParams = array())
2904
- {
2905
- $params = array(
2906
- 'accountId' => $accountId,
2907
- 'webPropertyId' => $webPropertyId,
2908
- 'profileId' => $profileId,
2909
- 'goalId' => $goalId,
2910
- 'postBody' => $postBody
2911
- );
2912
- $params = array_merge($params, $optParams);
2913
- return $this->call('update', array(
2914
- $params
2915
- ), "Google_Service_Analytics_Goal");
2916
- }
2917
- }
2918
-
2919
- /**
2920
- * The "profileFilterLinks" collection of methods.
2921
- * Typical usage is:
2922
- * <code>
2923
- * $analyticsService = new Google_Service_Analytics(...);
2924
- * $profileFilterLinks = $analyticsService->profileFilterLinks;
2925
- * </code>
2926
- */
2927
- class Google_Service_Analytics_ManagementProfileFilterLinks_Resource extends Google_Service_Resource
2928
- {
2929
-
2930
- /**
2931
- * Delete a profile filter link.
2932
- * (profileFilterLinks.delete)
2933
- *
2934
- * @param string $accountId
2935
- * Account ID to which the profile filter link belongs.
2936
- * @param string $webPropertyId
2937
- * Web property Id to which the profile filter link
2938
- * belongs.
2939
- * @param string $profileId
2940
- * Profile ID to which the filter link belongs.
2941
- * @param string $linkId
2942
- * ID of the profile filter link to delete.
2943
- * @param array $optParams
2944
- * Optional parameters.
2945
- */
2946
- public function delete($accountId, $webPropertyId, $profileId, $linkId, $optParams = array())
2947
- {
2948
- $params = array(
2949
- 'accountId' => $accountId,
2950
- 'webPropertyId' => $webPropertyId,
2951
- 'profileId' => $profileId,
2952
- 'linkId' => $linkId
2953
- );
2954
- $params = array_merge($params, $optParams);
2955
- return $this->call('delete', array(
2956
- $params
2957
- ));
2958
- }
2959
-
2960
- /**
2961
- * Returns a single profile filter link.
2962
- * (profileFilterLinks.get)
2963
- *
2964
- * @param string $accountId
2965
- * Account ID to retrieve profile filter link for.
2966
- * @param string $webPropertyId
2967
- * Web property Id to retrieve profile filter link
2968
- * for.
2969
- * @param string $profileId
2970
- * Profile ID to retrieve filter link for.
2971
- * @param string $linkId
2972
- * ID of the profile filter link.
2973
- * @param array $optParams
2974
- * Optional parameters.
2975
- * @return Google_Service_Analytics_ProfileFilterLink
2976
- */
2977
- public function get($accountId, $webPropertyId, $profileId, $linkId, $optParams = array())
2978
- {
2979
- $params = array(
2980
- 'accountId' => $accountId,
2981
- 'webPropertyId' => $webPropertyId,
2982
- 'profileId' => $profileId,
2983
- 'linkId' => $linkId
2984
- );
2985
- $params = array_merge($params, $optParams);
2986
- return $this->call('get', array(
2987
- $params
2988
- ), "Google_Service_Analytics_ProfileFilterLink");
2989
- }
2990
-
2991
- /**
2992
- * Create a new profile filter link.
2993
- * (profileFilterLinks.insert)
2994
- *
2995
- * @param string $accountId
2996
- * Account ID to create profile filter link for.
2997
- * @param string $webPropertyId
2998
- * Web property Id to create profile filter link
2999
- * for.
3000
- * @param string $profileId
3001
- * Profile ID to create filter link for.
3002
- * @param Google_ProfileFilterLink $postBody
3003
- * @param array $optParams
3004
- * Optional parameters.
3005
- * @return Google_Service_Analytics_ProfileFilterLink
3006
- */
3007
- public function insert($accountId, $webPropertyId, $profileId, Google_Service_Analytics_ProfileFilterLink $postBody, $optParams = array())
3008
- {
3009
- $params = array(
3010
- 'accountId' => $accountId,
3011
- 'webPropertyId' => $webPropertyId,
3012
- 'profileId' => $profileId,
3013
- 'postBody' => $postBody
3014
- );
3015
- $params = array_merge($params, $optParams);
3016
- return $this->call('insert', array(
3017
- $params
3018
- ), "Google_Service_Analytics_ProfileFilterLink");
3019
- }
3020
-
3021
- /**
3022
- * Lists all profile filter links for a profile.
3023
- * (profileFilterLinks.listManagementProfileFilterLinks)
3024
- *
3025
- * @param string $accountId
3026
- * Account ID to retrieve profile filter links for.
3027
- * @param string $webPropertyId
3028
- * Web property Id for profile filter links for.
3029
- * Can either be a specific web property ID or '~all', which refers to all the
3030
- * web properties that user has access to.
3031
- * @param string $profileId
3032
- * Profile ID to retrieve filter links for. Can either
3033
- * be a specific profile ID or '~all', which refers to all the profiles that
3034
- * user has access to.
3035
- * @param array $optParams
3036
- * Optional parameters.
3037
- *
3038
- * @opt_param int max-results The maximum number of profile filter links to
3039
- * include in this response.
3040
- * @opt_param int start-index An index of the first entity to retrieve. Use this
3041
- * parameter as a pagination mechanism along with the max-results parameter.
3042
- * @return Google_Service_Analytics_ProfileFilterLinks
3043
- */
3044
- public function listManagementProfileFilterLinks($accountId, $webPropertyId, $profileId, $optParams = array())
3045
- {
3046
- $params = array(
3047
- 'accountId' => $accountId,
3048
- 'webPropertyId' => $webPropertyId,
3049
- 'profileId' => $profileId
3050
- );
3051
- $params = array_merge($params, $optParams);
3052
- return $this->call('list', array(
3053
- $params
3054
- ), "Google_Service_Analytics_ProfileFilterLinks");
3055
- }
3056
-
3057
- /**
3058
- * Update an existing profile filter link.
3059
- * This method supports patch semantics.
3060
- * (profileFilterLinks.patch)
3061
- *
3062
- * @param string $accountId
3063
- * Account ID to which profile filter link belongs.
3064
- * @param string $webPropertyId
3065
- * Web property Id to which profile filter link
3066
- * belongs
3067
- * @param string $profileId
3068
- * Profile ID to which filter link belongs
3069
- * @param string $linkId
3070
- * ID of the profile filter link to be updated.
3071
- * @param Google_ProfileFilterLink $postBody
3072
- * @param array $optParams
3073
- * Optional parameters.
3074
- * @return Google_Service_Analytics_ProfileFilterLink
3075
- */
3076
- public function patch($accountId, $webPropertyId, $profileId, $linkId, Google_Service_Analytics_ProfileFilterLink $postBody, $optParams = array())
3077
- {
3078
- $params = array(
3079
- 'accountId' => $accountId,
3080
- 'webPropertyId' => $webPropertyId,
3081
- 'profileId' => $profileId,
3082
- 'linkId' => $linkId,
3083
- 'postBody' => $postBody
3084
- );
3085
- $params = array_merge($params, $optParams);
3086
- return $this->call('patch', array(
3087
- $params
3088
- ), "Google_Service_Analytics_ProfileFilterLink");
3089
- }
3090
-
3091
- /**
3092
- * Update an existing profile filter link.
3093
- * (profileFilterLinks.update)
3094
- *
3095
- * @param string $accountId
3096
- * Account ID to which profile filter link belongs.
3097
- * @param string $webPropertyId
3098
- * Web property Id to which profile filter link
3099
- * belongs
3100
- * @param string $profileId
3101
- * Profile ID to which filter link belongs
3102
- * @param string $linkId
3103
- * ID of the profile filter link to be updated.
3104
- * @param Google_ProfileFilterLink $postBody
3105
- * @param array $optParams
3106
- * Optional parameters.
3107
- * @return Google_Service_Analytics_ProfileFilterLink
3108
- */
3109
- public function update($accountId, $webPropertyId, $profileId, $linkId, Google_Service_Analytics_ProfileFilterLink $postBody, $optParams = array())
3110
- {
3111
- $params = array(
3112
- 'accountId' => $accountId,
3113
- 'webPropertyId' => $webPropertyId,
3114
- 'profileId' => $profileId,
3115
- 'linkId' => $linkId,
3116
- 'postBody' => $postBody
3117
- );
3118
- $params = array_merge($params, $optParams);
3119
- return $this->call('update', array(
3120
- $params
3121
- ), "Google_Service_Analytics_ProfileFilterLink");
3122
- }
3123
- }
3124
-
3125
- /**
3126
- * The "profileUserLinks" collection of methods.
3127
- * Typical usage is:
3128
- * <code>
3129
- * $analyticsService = new Google_Service_Analytics(...);
3130
- * $profileUserLinks = $analyticsService->profileUserLinks;
3131
- * </code>
3132
- */
3133
- class Google_Service_Analytics_ManagementProfileUserLinks_Resource extends Google_Service_Resource
3134
- {
3135
-
3136
- /**
3137
- * Removes a user from the given view (profile).
3138
- * (profileUserLinks.delete)
3139
- *
3140
- * @param string $accountId
3141
- * Account ID to delete the user link for.
3142
- * @param string $webPropertyId
3143
- * Web Property ID to delete the user link for.
3144
- * @param string $profileId
3145
- * View (Profile) ID to delete the user link for.
3146
- * @param string $linkId
3147
- * Link ID to delete the user link for.
3148
- * @param array $optParams
3149
- * Optional parameters.
3150
- */
3151
- public function delete($accountId, $webPropertyId, $profileId, $linkId, $optParams = array())
3152
- {
3153
- $params = array(
3154
- 'accountId' => $accountId,
3155
- 'webPropertyId' => $webPropertyId,
3156
- 'profileId' => $profileId,
3157
- 'linkId' => $linkId
3158
- );
3159
- $params = array_merge($params, $optParams);
3160
- return $this->call('delete', array(
3161
- $params
3162
- ));
3163
- }
3164
-
3165
- /**
3166
- * Adds a new user to the given view (profile).
3167
- * (profileUserLinks.insert)
3168
- *
3169
- * @param string $accountId
3170
- * Account ID to create the user link for.
3171
- * @param string $webPropertyId
3172
- * Web Property ID to create the user link for.
3173
- * @param string $profileId
3174
- * View (Profile) ID to create the user link for.
3175
- * @param Google_EntityUserLink $postBody
3176
- * @param array $optParams
3177
- * Optional parameters.
3178
- * @return Google_Service_Analytics_EntityUserLink
3179
- */
3180
- public function insert($accountId, $webPropertyId, $profileId, Google_Service_Analytics_EntityUserLink $postBody, $optParams = array())
3181
- {
3182
- $params = array(
3183
- 'accountId' => $accountId,
3184
- 'webPropertyId' => $webPropertyId,
3185
- 'profileId' => $profileId,
3186
- 'postBody' => $postBody
3187
- );
3188
- $params = array_merge($params, $optParams);
3189
- return $this->call('insert', array(
3190
- $params
3191
- ), "Google_Service_Analytics_EntityUserLink");
3192
- }
3193
-
3194
- /**
3195
- * Lists profile-user links for a given view (profile).
3196
- * (profileUserLinks.listManagementProfileUserLinks)
3197
- *
3198
- * @param string $accountId
3199
- * Account ID which the given view (profile) belongs
3200
- * to.
3201
- * @param string $webPropertyId
3202
- * Web Property ID which the given view (profile)
3203
- * belongs to. Can either be a specific web property ID or '~all', which refers
3204
- * to all the web properties that user has access to.
3205
- * @param string $profileId
3206
- * View (Profile) ID to retrieve the profile-user links
3207
- * for. Can either be a specific profile ID or '~all', which refers to all the
3208
- * profiles that user has access to.
3209
- * @param array $optParams
3210
- * Optional parameters.
3211
- *
3212
- * @opt_param int max-results The maximum number of profile-user links to
3213
- * include in this response.
3214
- * @opt_param int start-index An index of the first profile-user link to
3215
- * retrieve. Use this parameter as a pagination mechanism along with the max-
3216
- * results parameter.
3217
- * @return Google_Service_Analytics_EntityUserLinks
3218
- */
3219
- public function listManagementProfileUserLinks($accountId, $webPropertyId, $profileId, $optParams = array())
3220
- {
3221
- $params = array(
3222
- 'accountId' => $accountId,
3223
- 'webPropertyId' => $webPropertyId,
3224
- 'profileId' => $profileId
3225
- );
3226
- $params = array_merge($params, $optParams);
3227
- return $this->call('list', array(
3228
- $params
3229
- ), "Google_Service_Analytics_EntityUserLinks");
3230
- }
3231
-
3232
- /**
3233
- * Updates permissions for an existing user on the given view (profile).
3234
- * (profileUserLinks.update)
3235
- *
3236
- * @param string $accountId
3237
- * Account ID to update the user link for.
3238
- * @param string $webPropertyId
3239
- * Web Property ID to update the user link for.
3240
- * @param string $profileId
3241
- * View (Profile ID) to update the user link for.
3242
- * @param string $linkId
3243
- * Link ID to update the user link for.
3244
- * @param Google_EntityUserLink $postBody
3245
- * @param array $optParams
3246
- * Optional parameters.
3247
- * @return Google_Service_Analytics_EntityUserLink
3248
- */
3249
- public function update($accountId, $webPropertyId, $profileId, $linkId, Google_Service_Analytics_EntityUserLink $postBody, $optParams = array())
3250
- {
3251
- $params = array(
3252
- 'accountId' => $accountId,
3253
- 'webPropertyId' => $webPropertyId,
3254
- 'profileId' => $profileId,
3255
- 'linkId' => $linkId,
3256
- 'postBody' => $postBody
3257
- );
3258
- $params = array_merge($params, $optParams);
3259
- return $this->call('update', array(
3260
- $params
3261
- ), "Google_Service_Analytics_EntityUserLink");
3262
- }
3263
- }
3264
-
3265
- /**
3266
- * The "profiles" collection of methods.
3267
- * Typical usage is:
3268
- * <code>
3269
- * $analyticsService = new Google_Service_Analytics(...);
3270
- * $profiles = $analyticsService->profiles;
3271
- * </code>
3272
- */
3273
- class Google_Service_Analytics_ManagementProfiles_Resource extends Google_Service_Resource
3274
- {
3275
-
3276
- /**
3277
- * Deletes a view (profile).
3278
- * (profiles.delete)
3279
- *
3280
- * @param string $accountId
3281
- * Account ID to delete the view (profile) for.
3282
- * @param string $webPropertyId
3283
- * Web property ID to delete the view (profile)
3284
- * for.
3285
- * @param string $profileId
3286
- * ID of the view (profile) to be deleted.
3287
- * @param array $optParams
3288
- * Optional parameters.
3289
- */
3290
- public function delete($accountId, $webPropertyId, $profileId, $optParams = array())
3291
- {
3292
- $params = array(
3293
- 'accountId' => $accountId,
3294
- 'webPropertyId' => $webPropertyId,
3295
- 'profileId' => $profileId
3296
- );
3297
- $params = array_merge($params, $optParams);
3298
- return $this->call('delete', array(
3299
- $params
3300
- ));
3301
- }
3302
-
3303
- /**
3304
- * Gets a view (profile) to which the user has access.
3305
- * (profiles.get)
3306
- *
3307
- * @param string $accountId
3308
- * Account ID to retrieve the goal for.
3309
- * @param string $webPropertyId
3310
- * Web property ID to retrieve the goal for.
3311
- * @param string $profileId
3312
- * View (Profile) ID to retrieve the goal for.
3313
- * @param array $optParams
3314
- * Optional parameters.
3315
- * @return Google_Service_Analytics_Profile
3316
- */
3317
- public function get($accountId, $webPropertyId, $profileId, $optParams = array())
3318
- {
3319
- $params = array(
3320
- 'accountId' => $accountId,
3321
- 'webPropertyId' => $webPropertyId,
3322
- 'profileId' => $profileId
3323
- );
3324
- $params = array_merge($params, $optParams);
3325
- return $this->call('get', array(
3326
- $params
3327
- ), "Google_Service_Analytics_Profile");
3328
- }
3329
-
3330
- /**
3331
- * Create a new view (profile).
3332
- * (profiles.insert)
3333
- *
3334
- * @param string $accountId
3335
- * Account ID to create the view (profile) for.
3336
- * @param string $webPropertyId
3337
- * Web property ID to create the view (profile)
3338
- * for.
3339
- * @param Google_Profile $postBody
3340
- * @param array $optParams
3341
- * Optional parameters.
3342
- * @return Google_Service_Analytics_Profile
3343
- */
3344
- public function insert($accountId, $webPropertyId, Google_Service_Analytics_Profile $postBody, $optParams = array())
3345
- {
3346
- $params = array(
3347
- 'accountId' => $accountId,
3348
- 'webPropertyId' => $webPropertyId,
3349
- 'postBody' => $postBody
3350
- );
3351
- $params = array_merge($params, $optParams);
3352
- return $this->call('insert', array(
3353
- $params
3354
- ), "Google_Service_Analytics_Profile");
3355
- }
3356
-
3357
- /**
3358
- * Lists views (profiles) to which the user has access.
3359
- * (profiles.listManagementProfiles)
3360
- *
3361
- * @param string $accountId
3362
- * Account ID for the view (profiles) to retrieve. Can
3363
- * either be a specific account ID or '~all', which refers to all the accounts
3364
- * to which the user has access.
3365
- * @param string $webPropertyId
3366
- * Web property ID for the views (profiles) to
3367
- * retrieve. Can either be a specific web property ID or '~all', which refers to
3368
- * all the web properties to which the user has access.
3369
- * @param array $optParams
3370
- * Optional parameters.
3371
- *
3372
- * @opt_param int max-results The maximum number of views (profiles) to include
3373
- * in this response.
3374
- * @opt_param int start-index An index of the first entity to retrieve. Use this
3375
- * parameter as a pagination mechanism along with the max-results parameter.
3376
- * @return Google_Service_Analytics_Profiles
3377
- */
3378
- public function listManagementProfiles($accountId, $webPropertyId, $optParams = array())
3379
- {
3380
- $params = array(
3381
- 'accountId' => $accountId,
3382
- 'webPropertyId' => $webPropertyId
3383
- );
3384
- $params = array_merge($params, $optParams);
3385
- return $this->call('list', array(
3386
- $params
3387
- ), "Google_Service_Analytics_Profiles");
3388
- }
3389
-
3390
- /**
3391
- * Updates an existing view (profile).
3392
- * This method supports patch semantics.
3393
- * (profiles.patch)
3394
- *
3395
- * @param string $accountId
3396
- * Account ID to which the view (profile) belongs
3397
- * @param string $webPropertyId
3398
- * Web property ID to which the view (profile)
3399
- * belongs
3400
- * @param string $profileId
3401
- * ID of the view (profile) to be updated.
3402
- * @param Google_Profile $postBody
3403
- * @param array $optParams
3404
- * Optional parameters.
3405
- * @return Google_Service_Analytics_Profile
3406
- */
3407
- public function patch($accountId, $webPropertyId, $profileId, Google_Service_Analytics_Profile $postBody, $optParams = array())
3408
- {
3409
- $params = array(
3410
- 'accountId' => $accountId,
3411
- 'webPropertyId' => $webPropertyId,
3412
- 'profileId' => $profileId,
3413
- 'postBody' => $postBody
3414
- );
3415
- $params = array_merge($params, $optParams);
3416
- return $this->call('patch', array(
3417
- $params
3418
- ), "Google_Service_Analytics_Profile");
3419
- }
3420
-
3421
- /**
3422
- * Updates an existing view (profile).
3423
- * (profiles.update)
3424
- *
3425
- * @param string $accountId
3426
- * Account ID to which the view (profile) belongs
3427
- * @param string $webPropertyId
3428
- * Web property ID to which the view (profile)
3429
- * belongs
3430
- * @param string $profileId
3431
- * ID of the view (profile) to be updated.
3432
- * @param Google_Profile $postBody
3433
- * @param array $optParams
3434
- * Optional parameters.
3435
- * @return Google_Service_Analytics_Profile
3436
- */
3437
- public function update($accountId, $webPropertyId, $profileId, Google_Service_Analytics_Profile $postBody, $optParams = array())
3438
- {
3439
- $params = array(
3440
- 'accountId' => $accountId,
3441
- 'webPropertyId' => $webPropertyId,
3442
- 'profileId' => $profileId,
3443
- 'postBody' => $postBody
3444
- );
3445
- $params = array_merge($params, $optParams);
3446
- return $this->call('update', array(
3447
- $params
3448
- ), "Google_Service_Analytics_Profile");
3449
- }
3450
- }
3451
-
3452
- /**
3453
- * The "segments" collection of methods.
3454
- * Typical usage is:
3455
- * <code>
3456
- * $analyticsService = new Google_Service_Analytics(...);
3457
- * $segments = $analyticsService->segments;
3458
- * </code>
3459
- */
3460
- class Google_Service_Analytics_ManagementSegments_Resource extends Google_Service_Resource
3461
- {
3462
-
3463
- /**
3464
- * Lists segments to which the user has access.
3465
- * (segments.listManagementSegments)
3466
- *
3467
- * @param array $optParams
3468
- * Optional parameters.
3469
- *
3470
- * @opt_param int max-results The maximum number of segments to include in this
3471
- * response.
3472
- * @opt_param int start-index An index of the first segment to retrieve. Use
3473
- * this parameter as a pagination mechanism along with the max-results
3474
- * parameter.
3475
- * @return Google_Service_Analytics_Segments
3476
- */
3477
- public function listManagementSegments($optParams = array())
3478
- {
3479
- $params = array();
3480
- $params = array_merge($params, $optParams);
3481
- return $this->call('list', array(
3482
- $params
3483
- ), "Google_Service_Analytics_Segments");
3484
- }
3485
- }
3486
-
3487
- /**
3488
- * The "unsampledReports" collection of methods.
3489
- * Typical usage is:
3490
- * <code>
3491
- * $analyticsService = new Google_Service_Analytics(...);
3492
- * $unsampledReports = $analyticsService->unsampledReports;
3493
- * </code>
3494
- */
3495
- class Google_Service_Analytics_ManagementUnsampledReports_Resource extends Google_Service_Resource
3496
- {
3497
-
3498
- /**
3499
- * Returns a single unsampled report.
3500
- * (unsampledReports.get)
3501
- *
3502
- * @param string $accountId
3503
- * Account ID to retrieve unsampled report for.
3504
- * @param string $webPropertyId
3505
- * Web property ID to retrieve unsampled reports
3506
- * for.
3507
- * @param string $profileId
3508
- * View (Profile) ID to retrieve unsampled report for.
3509
- * @param string $unsampledReportId
3510
- * ID of the unsampled report to retrieve.
3511
- * @param array $optParams
3512
- * Optional parameters.
3513
- * @return Google_Service_Analytics_UnsampledReport
3514
- */
3515
- public function get($accountId, $webPropertyId, $profileId, $unsampledReportId, $optParams = array())
3516
- {
3517
- $params = array(
3518
- 'accountId' => $accountId,
3519
- 'webPropertyId' => $webPropertyId,
3520
- 'profileId' => $profileId,
3521
- 'unsampledReportId' => $unsampledReportId
3522
- );
3523
- $params = array_merge($params, $optParams);
3524
- return $this->call('get', array(
3525
- $params
3526
- ), "Google_Service_Analytics_UnsampledReport");
3527
- }
3528
-
3529
- /**
3530
- * Create a new unsampled report.
3531
- * (unsampledReports.insert)
3532
- *
3533
- * @param string $accountId
3534
- * Account ID to create the unsampled report for.
3535
- * @param string $webPropertyId
3536
- * Web property ID to create the unsampled report
3537
- * for.
3538
- * @param string $profileId
3539
- * View (Profile) ID to create the unsampled report
3540
- * for.
3541
- * @param Google_UnsampledReport $postBody
3542
- * @param array $optParams
3543
- * Optional parameters.
3544
- * @return Google_Service_Analytics_UnsampledReport
3545
- */
3546
- public function insert($accountId, $webPropertyId, $profileId, Google_Service_Analytics_UnsampledReport $postBody, $optParams = array())
3547
- {
3548
- $params = array(
3549
- 'accountId' => $accountId,
3550
- 'webPropertyId' => $webPropertyId,
3551
- 'profileId' => $profileId,
3552
- 'postBody' => $postBody
3553
- );
3554
- $params = array_merge($params, $optParams);
3555
- return $this->call('insert', array(
3556
- $params
3557
- ), "Google_Service_Analytics_UnsampledReport");
3558
- }
3559
-
3560
- /**
3561
- * Lists unsampled reports to which the user has access.
3562
- * (unsampledReports.listManagementUnsampledReports)
3563
- *
3564
- * @param string $accountId
3565
- * Account ID to retrieve unsampled reports for. Must
3566
- * be a specific account ID, ~all is not supported.
3567
- * @param string $webPropertyId
3568
- * Web property ID to retrieve unsampled reports
3569
- * for. Must be a specific web property ID, ~all is not supported.
3570
- * @param string $profileId
3571
- * View (Profile) ID to retrieve unsampled reports for.
3572
- * Must be a specific view (profile) ID, ~all is not supported.
3573
- * @param array $optParams
3574
- * Optional parameters.
3575
- *
3576
- * @opt_param int max-results The maximum number of unsampled reports to include
3577
- * in this response.
3578
- * @opt_param int start-index An index of the first unsampled report to
3579
- * retrieve. Use this parameter as a pagination mechanism along with the max-
3580
- * results parameter.
3581
- * @return Google_Service_Analytics_UnsampledReports
3582
- */
3583
- public function listManagementUnsampledReports($accountId, $webPropertyId, $profileId, $optParams = array())
3584
- {
3585
- $params = array(
3586
- 'accountId' => $accountId,
3587
- 'webPropertyId' => $webPropertyId,
3588
- 'profileId' => $profileId
3589
- );
3590
- $params = array_merge($params, $optParams);
3591
- return $this->call('list', array(
3592
- $params
3593
- ), "Google_Service_Analytics_UnsampledReports");
3594
- }
3595
- }
3596
-
3597
- /**
3598
- * The "uploads" collection of methods.
3599
- * Typical usage is:
3600
- * <code>
3601
- * $analyticsService = new Google_Service_Analytics(...);
3602
- * $uploads = $analyticsService->uploads;
3603
- * </code>
3604
- */
3605
- class Google_Service_Analytics_ManagementUploads_Resource extends Google_Service_Resource
3606
- {
3607
-
3608
- /**
3609
- * Delete data associated with a previous upload.
3610
- * (uploads.deleteUploadData)
3611
- *
3612
- * @param string $accountId
3613
- * Account Id for the uploads to be deleted.
3614
- * @param string $webPropertyId
3615
- * Web property Id for the uploads to be deleted.
3616
- * @param string $customDataSourceId
3617
- * Custom data source Id for the uploads to be
3618
- * deleted.
3619
- * @param Google_AnalyticsDataimportDeleteUploadDataRequest $postBody
3620
- * @param array $optParams
3621
- * Optional parameters.
3622
- */
3623
- public function deleteUploadData($accountId, $webPropertyId, $customDataSourceId, Google_Service_Analytics_AnalyticsDataimportDeleteUploadDataRequest $postBody, $optParams = array())
3624
- {
3625
- $params = array(
3626
- 'accountId' => $accountId,
3627
- 'webPropertyId' => $webPropertyId,
3628
- 'customDataSourceId' => $customDataSourceId,
3629
- 'postBody' => $postBody
3630
- );
3631
- $params = array_merge($params, $optParams);
3632
- return $this->call('deleteUploadData', array(
3633
- $params
3634
- ));
3635
- }
3636
-
3637
- /**
3638
- * List uploads to which the user has access.
3639
- * (uploads.get)
3640
- *
3641
- * @param string $accountId
3642
- * Account Id for the upload to retrieve.
3643
- * @param string $webPropertyId
3644
- * Web property Id for the upload to retrieve.
3645
- * @param string $customDataSourceId
3646
- * Custom data source Id for upload to
3647
- * retrieve.
3648
- * @param string $uploadId
3649
- * Upload Id to retrieve.
3650
- * @param array $optParams
3651
- * Optional parameters.
3652
- * @return Google_Service_Analytics_Upload
3653
- */
3654
- public function get($accountId, $webPropertyId, $customDataSourceId, $uploadId, $optParams = array())
3655
- {
3656
- $params = array(
3657
- 'accountId' => $accountId,
3658
- 'webPropertyId' => $webPropertyId,
3659
- 'customDataSourceId' => $customDataSourceId,
3660
- 'uploadId' => $uploadId
3661
- );
3662
- $params = array_merge($params, $optParams);
3663
- return $this->call('get', array(
3664
- $params
3665
- ), "Google_Service_Analytics_Upload");
3666
- }
3667
-
3668
- /**
3669
- * List uploads to which the user has access.
3670
- * (uploads.listManagementUploads)
3671
- *
3672
- * @param string $accountId
3673
- * Account Id for the uploads to retrieve.
3674
- * @param string $webPropertyId
3675
- * Web property Id for the uploads to retrieve.
3676
- * @param string $customDataSourceId
3677
- * Custom data source Id for uploads to
3678
- * retrieve.
3679
- * @param array $optParams
3680
- * Optional parameters.
3681
- *
3682
- * @opt_param int max-results The maximum number of uploads to include in this
3683
- * response.
3684
- * @opt_param int start-index A 1-based index of the first upload to retrieve.
3685
- * Use this parameter as a pagination mechanism along with the max-results
3686
- * parameter.
3687
- * @return Google_Service_Analytics_Uploads
3688
- */
3689
- public function listManagementUploads($accountId, $webPropertyId, $customDataSourceId, $optParams = array())
3690
- {
3691
- $params = array(
3692
- 'accountId' => $accountId,
3693
- 'webPropertyId' => $webPropertyId,
3694
- 'customDataSourceId' => $customDataSourceId
3695
- );
3696
- $params = array_merge($params, $optParams);
3697
- return $this->call('list', array(
3698
- $params
3699
- ), "Google_Service_Analytics_Uploads");
3700
- }
3701
-
3702
- /**
3703
- * Migrate custom data source and data imports to latest version.
3704
- * (uploads.migrateDataImport)
3705
- *
3706
- * @param string $accountId
3707
- * Account Id for migration.
3708
- * @param string $webPropertyId
3709
- * Web property Id for migration.
3710
- * @param string $customDataSourceId
3711
- * Custom data source Id for migration.
3712
- * @param array $optParams
3713
- * Optional parameters.
3714
- */
3715
- public function migrateDataImport($accountId, $webPropertyId, $customDataSourceId, $optParams = array())
3716
- {
3717
- $params = array(
3718
- 'accountId' => $accountId,
3719
- 'webPropertyId' => $webPropertyId,
3720
- 'customDataSourceId' => $customDataSourceId
3721
- );
3722
- $params = array_merge($params, $optParams);
3723
- return $this->call('migrateDataImport', array(
3724
- $params
3725
- ));
3726
- }
3727
-
3728
- /**
3729
- * Upload data for a custom data source.
3730
- * (uploads.uploadData)
3731
- *
3732
- * @param string $accountId
3733
- * Account Id associated with the upload.
3734
- * @param string $webPropertyId
3735
- * Web property UA-string associated with the
3736
- * upload.
3737
- * @param string $customDataSourceId
3738
- * Custom data source Id to which the data
3739
- * being uploaded belongs.
3740
- * @param array $optParams
3741
- * Optional parameters.
3742
- * @return Google_Service_Analytics_Upload
3743
- */
3744
- public function uploadData($accountId, $webPropertyId, $customDataSourceId, $optParams = array())
3745
- {
3746
- $params = array(
3747
- 'accountId' => $accountId,
3748
- 'webPropertyId' => $webPropertyId,
3749
- 'customDataSourceId' => $customDataSourceId
3750
- );
3751
- $params = array_merge($params, $optParams);
3752
- return $this->call('uploadData', array(
3753
- $params
3754
- ), "Google_Service_Analytics_Upload");
3755
- }
3756
- }
3757
-
3758
- /**
3759
- * The "webPropertyAdWordsLinks" collection of methods.
3760
- * Typical usage is:
3761
- * <code>
3762
- * $analyticsService = new Google_Service_Analytics(...);
3763
- * $webPropertyAdWordsLinks = $analyticsService->webPropertyAdWordsLinks;
3764
- * </code>
3765
- */
3766
- class Google_Service_Analytics_ManagementWebPropertyAdWordsLinks_Resource extends Google_Service_Resource
3767
- {
3768
-
3769
- /**
3770
- * Deletes a web property-AdWords link.
3771
- * (webPropertyAdWordsLinks.delete)
3772
- *
3773
- * @param string $accountId
3774
- * ID of the account which the given web property
3775
- * belongs to.
3776
- * @param string $webPropertyId
3777
- * Web property ID to delete the AdWords link for.
3778
- * @param string $webPropertyAdWordsLinkId
3779
- * Web property AdWords link ID.
3780
- * @param array $optParams
3781
- * Optional parameters.
3782
- */
3783
- public function delete($accountId, $webPropertyId, $webPropertyAdWordsLinkId, $optParams = array())
3784
- {
3785
- $params = array(
3786
- 'accountId' => $accountId,
3787
- 'webPropertyId' => $webPropertyId,
3788
- 'webPropertyAdWordsLinkId' => $webPropertyAdWordsLinkId
3789
- );
3790
- $params = array_merge($params, $optParams);
3791
- return $this->call('delete', array(
3792
- $params
3793
- ));
3794
- }
3795
-
3796
- /**
3797
- * Returns a web property-AdWords link to which the user has access.
3798
- * (webPropertyAdWordsLinks.get)
3799
- *
3800
- * @param string $accountId
3801
- * ID of the account which the given web property
3802
- * belongs to.
3803
- * @param string $webPropertyId
3804
- * Web property ID to retrieve the AdWords link
3805
- * for.
3806
- * @param string $webPropertyAdWordsLinkId
3807
- * Web property-AdWords link ID.
3808
- * @param array $optParams
3809
- * Optional parameters.
3810
- * @return Google_Service_Analytics_EntityAdWordsLink
3811
- */
3812
- public function get($accountId, $webPropertyId, $webPropertyAdWordsLinkId, $optParams = array())
3813
- {
3814
- $params = array(
3815
- 'accountId' => $accountId,
3816
- 'webPropertyId' => $webPropertyId,
3817
- 'webPropertyAdWordsLinkId' => $webPropertyAdWordsLinkId
3818
- );
3819
- $params = array_merge($params, $optParams);
3820
- return $this->call('get', array(
3821
- $params
3822
- ), "Google_Service_Analytics_EntityAdWordsLink");
3823
- }
3824
-
3825
- /**
3826
- * Creates a webProperty-AdWords link.
3827
- * (webPropertyAdWordsLinks.insert)
3828
- *
3829
- * @param string $accountId
3830
- * ID of the Google Analytics account to create the
3831
- * link for.
3832
- * @param string $webPropertyId
3833
- * Web property ID to create the link for.
3834
- * @param Google_EntityAdWordsLink $postBody
3835
- * @param array $optParams
3836
- * Optional parameters.
3837
- * @return Google_Service_Analytics_EntityAdWordsLink
3838
- */
3839
- public function insert($accountId, $webPropertyId, Google_Service_Analytics_EntityAdWordsLink $postBody, $optParams = array())
3840
- {
3841
- $params = array(
3842
- 'accountId' => $accountId,
3843
- 'webPropertyId' => $webPropertyId,
3844
- 'postBody' => $postBody
3845
- );
3846
- $params = array_merge($params, $optParams);
3847
- return $this->call('insert', array(
3848
- $params
3849
- ), "Google_Service_Analytics_EntityAdWordsLink");
3850
- }
3851
-
3852
- /**
3853
- * Lists webProperty-AdWords links for a given web property.
3854
- * (webPropertyAdWordsLinks.listManagementWebPropertyAdWordsLinks)
3855
- *
3856
- * @param string $accountId
3857
- * ID of the account which the given web property
3858
- * belongs to.
3859
- * @param string $webPropertyId
3860
- * Web property ID to retrieve the AdWords links
3861
- * for.
3862
- * @param array $optParams
3863
- * Optional parameters.
3864
- *
3865
- * @opt_param int max-results The maximum number of webProperty-AdWords links to
3866
- * include in this response.
3867
- * @opt_param int start-index An index of the first webProperty-AdWords link to
3868
- * retrieve. Use this parameter as a pagination mechanism along with the max-
3869
- * results parameter.
3870
- * @return Google_Service_Analytics_EntityAdWordsLinks
3871
- */
3872
- public function listManagementWebPropertyAdWordsLinks($accountId, $webPropertyId, $optParams = array())
3873
- {
3874
- $params = array(
3875
- 'accountId' => $accountId,
3876
- 'webPropertyId' => $webPropertyId
3877
- );
3878
- $params = array_merge($params, $optParams);
3879
- return $this->call('list', array(
3880
- $params
3881
- ), "Google_Service_Analytics_EntityAdWordsLinks");
3882
- }
3883
-
3884
- /**
3885
- * Updates an existing webProperty-AdWords link.
3886
- * This method supports patch
3887
- * semantics. (webPropertyAdWordsLinks.patch)
3888
- *
3889
- * @param string $accountId
3890
- * ID of the account which the given web property
3891
- * belongs to.
3892
- * @param string $webPropertyId
3893
- * Web property ID to retrieve the AdWords link
3894
- * for.
3895
- * @param string $webPropertyAdWordsLinkId
3896
- * Web property-AdWords link ID.
3897
- * @param Google_EntityAdWordsLink $postBody
3898
- * @param array $optParams
3899
- * Optional parameters.
3900
- * @return Google_Service_Analytics_EntityAdWordsLink
3901
- */
3902
- public function patch($accountId, $webPropertyId, $webPropertyAdWordsLinkId, Google_Service_Analytics_EntityAdWordsLink $postBody, $optParams = array())
3903
- {
3904
- $params = array(
3905
- 'accountId' => $accountId,
3906
- 'webPropertyId' => $webPropertyId,
3907
- 'webPropertyAdWordsLinkId' => $webPropertyAdWordsLinkId,
3908
- 'postBody' => $postBody
3909
- );
3910
- $params = array_merge($params, $optParams);
3911
- return $this->call('patch', array(
3912
- $params
3913
- ), "Google_Service_Analytics_EntityAdWordsLink");
3914
- }
3915
-
3916
- /**
3917
- * Updates an existing webProperty-AdWords link.
3918
- * (webPropertyAdWordsLinks.update)
3919
- *
3920
- * @param string $accountId
3921
- * ID of the account which the given web property
3922
- * belongs to.
3923
- * @param string $webPropertyId
3924
- * Web property ID to retrieve the AdWords link
3925
- * for.
3926
- * @param string $webPropertyAdWordsLinkId
3927
- * Web property-AdWords link ID.
3928
- * @param Google_EntityAdWordsLink $postBody
3929
- * @param array $optParams
3930
- * Optional parameters.
3931
- * @return Google_Service_Analytics_EntityAdWordsLink
3932
- */
3933
- public function update($accountId, $webPropertyId, $webPropertyAdWordsLinkId, Google_Service_Analytics_EntityAdWordsLink $postBody, $optParams = array())
3934
- {
3935
- $params = array(
3936
- 'accountId' => $accountId,
3937
- 'webPropertyId' => $webPropertyId,
3938
- 'webPropertyAdWordsLinkId' => $webPropertyAdWordsLinkId,
3939
- 'postBody' => $postBody
3940
- );
3941
- $params = array_merge($params, $optParams);
3942
- return $this->call('update', array(
3943
- $params
3944
- ), "Google_Service_Analytics_EntityAdWordsLink");
3945
- }
3946
- }
3947
-
3948
- /**
3949
- * The "webproperties" collection of methods.
3950
- * Typical usage is:
3951
- * <code>
3952
- * $analyticsService = new Google_Service_Analytics(...);
3953
- * $webproperties = $analyticsService->webproperties;
3954
- * </code>
3955
- */
3956
- class Google_Service_Analytics_ManagementWebproperties_Resource extends Google_Service_Resource
3957
- {
3958
-
3959
- /**
3960
- * Gets a web property to which the user has access.
3961
- * (webproperties.get)
3962
- *
3963
- * @param string $accountId
3964
- * Account ID to retrieve the web property for.
3965
- * @param string $webPropertyId
3966
- * ID to retrieve the web property for.
3967
- * @param array $optParams
3968
- * Optional parameters.
3969
- * @return Google_Service_Analytics_Webproperty
3970
- */
3971
- public function get($accountId, $webPropertyId, $optParams = array())
3972
- {
3973
- $params = array(
3974
- 'accountId' => $accountId,
3975
- 'webPropertyId' => $webPropertyId
3976
- );
3977
- $params = array_merge($params, $optParams);
3978
- return $this->call('get', array(
3979
- $params
3980
- ), "Google_Service_Analytics_Webproperty");
3981
- }
3982
-
3983
- /**
3984
- * Create a new property if the account has fewer than 20 properties.
3985
- * Web
3986
- * properties are visible in the Google Analytics interface only if they have at
3987
- * least one profile. (webproperties.insert)
3988
- *
3989
- * @param string $accountId
3990
- * Account ID to create the web property for.
3991
- * @param Google_Webproperty $postBody
3992
- * @param array $optParams
3993
- * Optional parameters.
3994
- * @return Google_Service_Analytics_Webproperty
3995
- */
3996
- public function insert($accountId, Google_Service_Analytics_Webproperty $postBody, $optParams = array())
3997
- {
3998
- $params = array(
3999
- 'accountId' => $accountId,
4000
- 'postBody' => $postBody
4001
- );
4002
- $params = array_merge($params, $optParams);
4003
- return $this->call('insert', array(
4004
- $params
4005
- ), "Google_Service_Analytics_Webproperty");
4006
- }
4007
-
4008
- /**
4009
- * Lists web properties to which the user has access.
4010
- * (webproperties.listManagementWebproperties)
4011
- *
4012
- * @param string $accountId
4013
- * Account ID to retrieve web properties for. Can
4014
- * either be a specific account ID or '~all', which refers to all the accounts
4015
- * that user has access to.
4016
- * @param array $optParams
4017
- * Optional parameters.
4018
- *
4019
- * @opt_param int max-results The maximum number of web properties to include in
4020
- * this response.
4021
- * @opt_param int start-index An index of the first entity to retrieve. Use this
4022
- * parameter as a pagination mechanism along with the max-results parameter.
4023
- * @return Google_Service_Analytics_Webproperties
4024
- */
4025
- public function listManagementWebproperties($accountId, $optParams = array())
4026
- {
4027
- $params = array(
4028
- 'accountId' => $accountId
4029
- );
4030
- $params = array_merge($params, $optParams);
4031
- return $this->call('list', array(
4032
- $params
4033
- ), "Google_Service_Analytics_Webproperties");
4034
- }
4035
-
4036
- /**
4037
- * Updates an existing web property.
4038
- * This method supports patch semantics.
4039
- * (webproperties.patch)
4040
- *
4041
- * @param string $accountId
4042
- * Account ID to which the web property belongs
4043
- * @param string $webPropertyId
4044
- * Web property ID
4045
- * @param Google_Webproperty $postBody
4046
- * @param array $optParams
4047
- * Optional parameters.
4048
- * @return Google_Service_Analytics_Webproperty
4049
- */
4050
- public function patch($accountId, $webPropertyId, Google_Service_Analytics_Webproperty $postBody, $optParams = array())
4051
- {
4052
- $params = array(
4053
- 'accountId' => $accountId,
4054
- 'webPropertyId' => $webPropertyId,
4055
- 'postBody' => $postBody
4056
- );
4057
- $params = array_merge($params, $optParams);
4058
- return $this->call('patch', array(
4059
- $params
4060
- ), "Google_Service_Analytics_Webproperty");
4061
- }
4062
-
4063
- /**
4064
- * Updates an existing web property.
4065
- * (webproperties.update)
4066
- *
4067
- * @param string $accountId
4068
- * Account ID to which the web property belongs
4069
- * @param string $webPropertyId
4070
- * Web property ID
4071
- * @param Google_Webproperty $postBody
4072
- * @param array $optParams
4073
- * Optional parameters.
4074
- * @return Google_Service_Analytics_Webproperty
4075
- */
4076
- public function update($accountId, $webPropertyId, Google_Service_Analytics_Webproperty $postBody, $optParams = array())
4077
- {
4078
- $params = array(
4079
- 'accountId' => $accountId,
4080
- 'webPropertyId' => $webPropertyId,
4081
- 'postBody' => $postBody
4082
- );
4083
- $params = array_merge($params, $optParams);
4084
- return $this->call('update', array(
4085
- $params
4086
- ), "Google_Service_Analytics_Webproperty");
4087
- }
4088
- }
4089
-
4090
- /**
4091
- * The "webpropertyUserLinks" collection of methods.
4092
- * Typical usage is:
4093
- * <code>
4094
- * $analyticsService = new Google_Service_Analytics(...);
4095
- * $webpropertyUserLinks = $analyticsService->webpropertyUserLinks;
4096
- * </code>
4097
- */
4098
- class Google_Service_Analytics_ManagementWebpropertyUserLinks_Resource extends Google_Service_Resource
4099
- {
4100
-
4101
- /**
4102
- * Removes a user from the given web property.
4103
- * (webpropertyUserLinks.delete)
4104
- *
4105
- * @param string $accountId
4106
- * Account ID to delete the user link for.
4107
- * @param string $webPropertyId
4108
- * Web Property ID to delete the user link for.
4109
- * @param string $linkId
4110
- * Link ID to delete the user link for.
4111
- * @param array $optParams
4112
- * Optional parameters.
4113
- */
4114
- public function delete($accountId, $webPropertyId, $linkId, $optParams = array())
4115
- {
4116
- $params = array(
4117
- 'accountId' => $accountId,
4118
- 'webPropertyId' => $webPropertyId,
4119
- 'linkId' => $linkId
4120
- );
4121
- $params = array_merge($params, $optParams);
4122
- return $this->call('delete', array(
4123
- $params
4124
- ));
4125
- }
4126
-
4127
- /**
4128
- * Adds a new user to the given web property.
4129
- * (webpropertyUserLinks.insert)
4130
- *
4131
- * @param string $accountId
4132
- * Account ID to create the user link for.
4133
- * @param string $webPropertyId
4134
- * Web Property ID to create the user link for.
4135
- * @param Google_EntityUserLink $postBody
4136
- * @param array $optParams
4137
- * Optional parameters.
4138
- * @return Google_Service_Analytics_EntityUserLink
4139
- */
4140
- public function insert($accountId, $webPropertyId, Google_Service_Analytics_EntityUserLink $postBody, $optParams = array())
4141
- {
4142
- $params = array(
4143
- 'accountId' => $accountId,
4144
- 'webPropertyId' => $webPropertyId,
4145
- 'postBody' => $postBody
4146
- );
4147
- $params = array_merge($params, $optParams);
4148
- return $this->call('insert', array(
4149
- $params
4150
- ), "Google_Service_Analytics_EntityUserLink");
4151
- }
4152
-
4153
- /**
4154
- * Lists webProperty-user links for a given web property.
4155
- * (webpropertyUserLinks.listManagementWebpropertyUserLinks)
4156
- *
4157
- * @param string $accountId
4158
- * Account ID which the given web property belongs to.
4159
- * @param string $webPropertyId
4160
- * Web Property ID for the webProperty-user links
4161
- * to retrieve. Can either be a specific web property ID or '~all', which refers
4162
- * to all the web properties that user has access to.
4163
- * @param array $optParams
4164
- * Optional parameters.
4165
- *
4166
- * @opt_param int max-results The maximum number of webProperty-user Links to
4167
- * include in this response.
4168
- * @opt_param int start-index An index of the first webProperty-user link to
4169
- * retrieve. Use this parameter as a pagination mechanism along with the max-
4170
- * results parameter.
4171
- * @return Google_Service_Analytics_EntityUserLinks
4172
- */
4173
- public function listManagementWebpropertyUserLinks($accountId, $webPropertyId, $optParams = array())
4174
- {
4175
- $params = array(
4176
- 'accountId' => $accountId,
4177
- 'webPropertyId' => $webPropertyId
4178
- );
4179
- $params = array_merge($params, $optParams);
4180
- return $this->call('list', array(
4181
- $params
4182
- ), "Google_Service_Analytics_EntityUserLinks");
4183
- }
4184
-
4185
- /**
4186
- * Updates permissions for an existing user on the given web property.
4187
- * (webpropertyUserLinks.update)
4188
- *
4189
- * @param string $accountId
4190
- * Account ID to update the account-user link for.
4191
- * @param string $webPropertyId
4192
- * Web property ID to update the account-user link
4193
- * for.
4194
- * @param string $linkId
4195
- * Link ID to update the account-user link for.
4196
- * @param Google_EntityUserLink $postBody
4197
- * @param array $optParams
4198
- * Optional parameters.
4199
- * @return Google_Service_Analytics_EntityUserLink
4200
- */
4201
- public function update($accountId, $webPropertyId, $linkId, Google_Service_Analytics_EntityUserLink $postBody, $optParams = array())
4202
- {
4203
- $params = array(
4204
- 'accountId' => $accountId,
4205
- 'webPropertyId' => $webPropertyId,
4206
- 'linkId' => $linkId,
4207
- 'postBody' => $postBody
4208
- );
4209
- $params = array_merge($params, $optParams);
4210
- return $this->call('update', array(
4211
- $params
4212
- ), "Google_Service_Analytics_EntityUserLink");
4213
- }
4214
- }
4215
-
4216
- /**
4217
- * The "metadata" collection of methods.
4218
- * Typical usage is:
4219
- * <code>
4220
- * $analyticsService = new Google_Service_Analytics(...);
4221
- * $metadata = $analyticsService->metadata;
4222
- * </code>
4223
- */
4224
- class Google_Service_Analytics_Metadata_Resource extends Google_Service_Resource
4225
- {
4226
- }
4227
-
4228
- /**
4229
- * The "columns" collection of methods.
4230
- * Typical usage is:
4231
- * <code>
4232
- * $analyticsService = new Google_Service_Analytics(...);
4233
- * $columns = $analyticsService->columns;
4234
- * </code>
4235
- */
4236
- class Google_Service_Analytics_MetadataColumns_Resource extends Google_Service_Resource
4237
- {
4238
-
4239
- /**
4240
- * Lists all columns for a report type (columns.listMetadataColumns)
4241
- *
4242
- * @param string $reportType
4243
- * Report type. Allowed Values: 'ga'. Where 'ga'
4244
- * corresponds to the Core Reporting API
4245
- * @param array $optParams
4246
- * Optional parameters.
4247
- * @return Google_Service_Analytics_Columns
4248
- */
4249
- public function listMetadataColumns($reportType, $optParams = array())
4250
- {
4251
- $params = array(
4252
- 'reportType' => $reportType
4253
- );
4254
- $params = array_merge($params, $optParams);
4255
- return $this->call('list', array(
4256
- $params
4257
- ), "Google_Service_Analytics_Columns");
4258
- }
4259
- }
4260
-
4261
- /**
4262
- * The "provisioning" collection of methods.
4263
- * Typical usage is:
4264
- * <code>
4265
- * $analyticsService = new Google_Service_Analytics(...);
4266
- * $provisioning = $analyticsService->provisioning;
4267
- * </code>
4268
- */
4269
- class Google_Service_Analytics_Provisioning_Resource extends Google_Service_Resource
4270
- {
4271
-
4272
- /**
4273
- * Creates an account ticket.
4274
- * (provisioning.createAccountTicket)
4275
- *
4276
- * @param Google_AccountTicket $postBody
4277
- * @param array $optParams
4278
- * Optional parameters.
4279
- * @return Google_Service_Analytics_AccountTicket
4280
- */
4281
- public function createAccountTicket(Google_Service_Analytics_AccountTicket $postBody, $optParams = array())
4282
- {
4283
- $params = array(
4284
- 'postBody' => $postBody
4285
- );
4286
- $params = array_merge($params, $optParams);
4287
- return $this->call('createAccountTicket', array(
4288
- $params
4289
- ), "Google_Service_Analytics_AccountTicket");
4290
- }
4291
- }
4292
-
4293
- class Google_Service_Analytics_Account extends Google_Model
4294
- {
4295
-
4296
- protected $internal_gapi_mappings = array();
4297
-
4298
- protected $childLinkType = 'Google_Service_Analytics_AccountChildLink';
4299
-
4300
- protected $childLinkDataType = '';
4301
-
4302
- public $created;
4303
-
4304
- public $id;
4305
-
4306
- public $kind;
4307
-
4308
- public $name;
4309
-
4310
- protected $permissionsType = 'Google_Service_Analytics_AccountPermissions';
4311
-
4312
- protected $permissionsDataType = '';
4313
-
4314
- public $selfLink;
4315
-
4316
- public $updated;
4317
-
4318
- public function setChildLink(Google_Service_Analytics_AccountChildLink $childLink)
4319
- {
4320
- $this->childLink = $childLink;
4321
- }
4322
-
4323
- public function getChildLink()
4324
- {
4325
- return $this->childLink;
4326
- }
4327
-
4328
- public function setCreated($created)
4329
- {
4330
- $this->created = $created;
4331
- }
4332
-
4333
- public function getCreated()
4334
- {
4335
- return $this->created;
4336
- }
4337
-
4338
- public function setId($id)
4339
- {
4340
- $this->id = $id;
4341
- }
4342
-
4343
- public function getId()
4344
- {
4345
- return $this->id;
4346
- }
4347
-
4348
- public function setKind($kind)
4349
- {
4350
- $this->kind = $kind;
4351
- }
4352
-
4353
- public function getKind()
4354
- {
4355
- return $this->kind;
4356
- }
4357
-
4358
- public function setName($name)
4359
- {
4360
- $this->name = $name;
4361
- }
4362
-
4363
- public function getName()
4364
- {
4365
- return $this->name;
4366
- }
4367
-
4368
- public function setPermissions(Google_Service_Analytics_AccountPermissions $permissions)
4369
- {
4370
- $this->permissions = $permissions;
4371
- }
4372
-
4373
- public function getPermissions()
4374
- {
4375
- return $this->permissions;
4376
- }
4377
-
4378
- public function setSelfLink($selfLink)
4379
- {
4380
- $this->selfLink = $selfLink;
4381
- }
4382
-
4383
- public function getSelfLink()
4384
- {
4385
- return $this->selfLink;
4386
- }
4387
-
4388
- public function setUpdated($updated)
4389
- {
4390
- $this->updated = $updated;
4391
- }
4392
-
4393
- public function getUpdated()
4394
- {
4395
- return $this->updated;
4396
- }
4397
- }
4398
-
4399
- class Google_Service_Analytics_AccountChildLink extends Google_Model
4400
- {
4401
-
4402
- protected $internal_gapi_mappings = array();
4403
-
4404
- public $href;
4405
-
4406
- public $type;
4407
-
4408
- public function setHref($href)
4409
- {
4410
- $this->href = $href;
4411
- }
4412
-
4413
- public function getHref()
4414
- {
4415
- return $this->href;
4416
- }
4417
-
4418
- public function setType($type)
4419
- {
4420
- $this->type = $type;
4421
- }
4422
-
4423
- public function getType()
4424
- {
4425
- return $this->type;
4426
- }
4427
- }
4428
-
4429
- class Google_Service_Analytics_AccountPermissions extends Google_Collection
4430
- {
4431
-
4432
- protected $collection_key = 'effective';
4433
-
4434
- protected $internal_gapi_mappings = array();
4435
-
4436
- public $effective;
4437
-
4438
- public function setEffective($effective)
4439
- {
4440
- $this->effective = $effective;
4441
- }
4442
-
4443
- public function getEffective()
4444
- {
4445
- return $this->effective;
4446
- }
4447
- }
4448
-
4449
- class Google_Service_Analytics_AccountRef extends Google_Model
4450
- {
4451
-
4452
- protected $internal_gapi_mappings = array();
4453
-
4454
- public $href;
4455
-
4456
- public $id;
4457
-
4458
- public $kind;
4459
-
4460
- public $name;
4461
-
4462
- public function setHref($href)
4463
- {
4464
- $this->href = $href;
4465
- }
4466
-
4467
- public function getHref()
4468
- {
4469
- return $this->href;
4470
- }
4471
-
4472
- public function setId($id)
4473
- {
4474
- $this->id = $id;
4475
- }
4476
-
4477
- public function getId()
4478
- {
4479
- return $this->id;
4480
- }
4481
-
4482
- public function setKind($kind)
4483
- {
4484
- $this->kind = $kind;
4485
- }
4486
-
4487
- public function getKind()
4488
- {
4489
- return $this->kind;
4490
- }
4491
-
4492
- public function setName($name)
4493
- {
4494
- $this->name = $name;
4495
- }
4496
-
4497
- public function getName()
4498
- {
4499
- return $this->name;
4500
- }
4501
- }
4502
-
4503
- class Google_Service_Analytics_AccountSummaries extends Google_Collection
4504
- {
4505
-
4506
- protected $collection_key = 'items';
4507
-
4508
- protected $internal_gapi_mappings = array();
4509
-
4510
- protected $itemsType = 'Google_Service_Analytics_AccountSummary';
4511
-
4512
- protected $itemsDataType = 'array';
4513
-
4514
- public $itemsPerPage;
4515
-
4516
- public $kind;
4517
-
4518
- public $nextLink;
4519
-
4520
- public $previousLink;
4521
-
4522
- public $startIndex;
4523
-
4524
- public $totalResults;
4525
-
4526
- public $username;
4527
-
4528
- public function setItems($items)
4529
- {
4530
- $this->items = $items;
4531
- }
4532
-
4533
- public function getItems()
4534
- {
4535
- return $this->items;
4536
- }
4537
-
4538
- public function setItemsPerPage($itemsPerPage)
4539
- {
4540
- $this->itemsPerPage = $itemsPerPage;
4541
- }
4542
-
4543
- public function getItemsPerPage()
4544
- {
4545
- return $this->itemsPerPage;
4546
- }
4547
-
4548
- public function setKind($kind)
4549
- {
4550
- $this->kind = $kind;
4551
- }
4552
-
4553
- public function getKind()
4554
- {
4555
- return $this->kind;
4556
- }
4557
-
4558
- public function setNextLink($nextLink)
4559
- {
4560
- $this->nextLink = $nextLink;
4561
- }
4562
-
4563
- public function getNextLink()
4564
- {
4565
- return $this->nextLink;
4566
- }
4567
-
4568
- public function setPreviousLink($previousLink)
4569
- {
4570
- $this->previousLink = $previousLink;
4571
- }
4572
-
4573
- public function getPreviousLink()
4574
- {
4575
- return $this->previousLink;
4576
- }
4577
-
4578
- public function setStartIndex($startIndex)
4579
- {
4580
- $this->startIndex = $startIndex;
4581
- }
4582
-
4583
- public function getStartIndex()
4584
- {
4585
- return $this->startIndex;
4586
- }
4587
-
4588
- public function setTotalResults($totalResults)
4589
- {
4590
- $this->totalResults = $totalResults;
4591
- }
4592
-
4593
- public function getTotalResults()
4594
- {
4595
- return $this->totalResults;
4596
- }
4597
-
4598
- public function setUsername($username)
4599
- {
4600
- $this->username = $username;
4601
- }
4602
-
4603
- public function getUsername()
4604
- {
4605
- return $this->username;
4606
- }
4607
- }
4608
-
4609
- class Google_Service_Analytics_AccountSummary extends Google_Collection
4610
- {
4611
-
4612
- protected $collection_key = 'webProperties';
4613
-
4614
- protected $internal_gapi_mappings = array();
4615
-
4616
- public $id;
4617
-
4618
- public $kind;
4619
-
4620
- public $name;
4621
-
4622
- protected $webPropertiesType = 'Google_Service_Analytics_WebPropertySummary';
4623
-
4624
- protected $webPropertiesDataType = 'array';
4625
-
4626
- public function setId($id)
4627
- {
4628
- $this->id = $id;
4629
- }
4630
-
4631
- public function getId()
4632
- {
4633
- return $this->id;
4634
- }
4635
-
4636
- public function setKind($kind)
4637
- {
4638
- $this->kind = $kind;
4639
- }
4640
-
4641
- public function getKind()
4642
- {
4643
- return $this->kind;
4644
- }
4645
-
4646
- public function setName($name)
4647
- {
4648
- $this->name = $name;
4649
- }
4650
-
4651
- public function getName()
4652
- {
4653
- return $this->name;
4654
- }
4655
-
4656
- public function setWebProperties($webProperties)
4657
- {
4658
- $this->webProperties = $webProperties;
4659
- }
4660
-
4661
- public function getWebProperties()
4662
- {
4663
- return $this->webProperties;
4664
- }
4665
- }
4666
-
4667
- class Google_Service_Analytics_AccountTicket extends Google_Model
4668
- {
4669
-
4670
- protected $internal_gapi_mappings = array();
4671
-
4672
- protected $accountType = 'Google_Service_Analytics_Account';
4673
-
4674
- protected $accountDataType = '';
4675
-
4676
- public $id;
4677
-
4678
- public $kind;
4679
-
4680
- protected $profileType = 'Google_Service_Analytics_Profile';
4681
-
4682
- protected $profileDataType = '';
4683
-
4684
- public $redirectUri;
4685
-
4686
- protected $webpropertyType = 'Google_Service_Analytics_Webproperty';
4687
-
4688
- protected $webpropertyDataType = '';
4689
-
4690
- public function setAccount(Google_Service_Analytics_Account $account)
4691
- {
4692
- $this->account = $account;
4693
- }
4694
-
4695
- public function getAccount()
4696
- {
4697
- return $this->account;
4698
- }
4699
-
4700
- public function setId($id)
4701
- {
4702
- $this->id = $id;
4703
- }
4704
-
4705
- public function getId()
4706
- {
4707
- return $this->id;
4708
- }
4709
-
4710
- public function setKind($kind)
4711
- {
4712
- $this->kind = $kind;
4713
- }
4714
-
4715
- public function getKind()
4716
- {
4717
- return $this->kind;
4718
- }
4719
-
4720
- public function setProfile(Google_Service_Analytics_Profile $profile)
4721
- {
4722
- $this->profile = $profile;
4723
- }
4724
-
4725
- public function getProfile()
4726
- {
4727
- return $this->profile;
4728
- }
4729
-
4730
- public function setRedirectUri($redirectUri)
4731
- {
4732
- $this->redirectUri = $redirectUri;
4733
- }
4734
-
4735
- public function getRedirectUri()
4736
- {
4737
- return $this->redirectUri;
4738
- }
4739
-
4740
- public function setWebproperty(Google_Service_Analytics_Webproperty $webproperty)
4741
- {
4742
- $this->webproperty = $webproperty;
4743
- }
4744
-
4745
- public function getWebproperty()
4746
- {
4747
- return $this->webproperty;
4748
- }
4749
- }
4750
-
4751
- class Google_Service_Analytics_Accounts extends Google_Collection
4752
- {
4753
-
4754
- protected $collection_key = 'items';
4755
-
4756
- protected $internal_gapi_mappings = array();
4757
-
4758
- protected $itemsType = 'Google_Service_Analytics_Account';
4759
-
4760
- protected $itemsDataType = 'array';
4761
-
4762
- public $itemsPerPage;
4763
-
4764
- public $kind;
4765
-
4766
- public $nextLink;
4767
-
4768
- public $previousLink;
4769
-
4770
- public $startIndex;
4771
-
4772
- public $totalResults;
4773
-
4774
- public $username;
4775
-
4776
- public function setItems($items)
4777
- {
4778
- $this->items = $items;
4779
- }
4780
-
4781
- public function getItems()
4782
- {
4783
- return $this->items;
4784
- }
4785
-
4786
- public function setItemsPerPage($itemsPerPage)
4787
- {
4788
- $this->itemsPerPage = $itemsPerPage;
4789
- }
4790
-
4791
- public function getItemsPerPage()
4792
- {
4793
- return $this->itemsPerPage;
4794
- }
4795
-
4796
- public function setKind($kind)
4797
- {
4798
- $this->kind = $kind;
4799
- }
4800
-
4801
- public function getKind()
4802
- {
4803
- return $this->kind;
4804
- }
4805
-
4806
- public function setNextLink($nextLink)
4807
- {
4808
- $this->nextLink = $nextLink;
4809
- }
4810
-
4811
- public function getNextLink()
4812
- {
4813
- return $this->nextLink;
4814
- }
4815
-
4816
- public function setPreviousLink($previousLink)
4817
- {
4818
- $this->previousLink = $previousLink;
4819
- }
4820
-
4821
- public function getPreviousLink()
4822
- {
4823
- return $this->previousLink;
4824
- }
4825
-
4826
- public function setStartIndex($startIndex)
4827
- {
4828
- $this->startIndex = $startIndex;
4829
- }
4830
-
4831
- public function getStartIndex()
4832
- {
4833
- return $this->startIndex;
4834
- }
4835
-
4836
- public function setTotalResults($totalResults)
4837
- {
4838
- $this->totalResults = $totalResults;
4839
- }
4840
-
4841
- public function getTotalResults()
4842
- {
4843
- return $this->totalResults;
4844
- }
4845
-
4846
- public function setUsername($username)
4847
- {
4848
- $this->username = $username;
4849
- }
4850
-
4851
- public function getUsername()
4852
- {
4853
- return $this->username;
4854
- }
4855
- }
4856
-
4857
- class Google_Service_Analytics_AdWordsAccount extends Google_Model
4858
- {
4859
-
4860
- protected $internal_gapi_mappings = array();
4861
-
4862
- public $autoTaggingEnabled;
4863
-
4864
- public $customerId;
4865
-
4866
- public $kind;
4867
-
4868
- public function setAutoTaggingEnabled($autoTaggingEnabled)
4869
- {
4870
- $this->autoTaggingEnabled = $autoTaggingEnabled;
4871
- }
4872
-
4873
- public function getAutoTaggingEnabled()
4874
- {
4875
- return $this->autoTaggingEnabled;
4876
- }
4877
-
4878
- public function setCustomerId($customerId)
4879
- {
4880
- $this->customerId = $customerId;
4881
- }
4882
-
4883
- public function getCustomerId()
4884
- {
4885
- return $this->customerId;
4886
- }
4887
-
4888
- public function setKind($kind)
4889
- {
4890
- $this->kind = $kind;
4891
- }
4892
-
4893
- public function getKind()
4894
- {
4895
- return $this->kind;
4896
- }
4897
- }
4898
-
4899
- class Google_Service_Analytics_AnalyticsDataimportDeleteUploadDataRequest extends Google_Collection
4900
- {
4901
-
4902
- protected $collection_key = 'customDataImportUids';
4903
-
4904
- protected $internal_gapi_mappings = array();
4905
-
4906
- public $customDataImportUids;
4907
-
4908
- public function setCustomDataImportUids($customDataImportUids)
4909
- {
4910
- $this->customDataImportUids = $customDataImportUids;
4911
- }
4912
-
4913
- public function getCustomDataImportUids()
4914
- {
4915
- return $this->customDataImportUids;
4916
- }
4917
- }
4918
-
4919
- class Google_Service_Analytics_Column extends Google_Model
4920
- {
4921
-
4922
- protected $internal_gapi_mappings = array();
4923
-
4924
- public $attributes;
4925
-
4926
- public $id;
4927
-
4928
- public $kind;
4929
-
4930
- public function setAttributes($attributes)
4931
- {
4932
- $this->attributes = $attributes;
4933
- }
4934
-
4935
- public function getAttributes()
4936
- {
4937
- return $this->attributes;
4938
- }
4939
-
4940
- public function setId($id)
4941
- {
4942
- $this->id = $id;
4943
- }
4944
-
4945
- public function getId()
4946
- {
4947
- return $this->id;
4948
- }
4949
-
4950
- public function setKind($kind)
4951
- {
4952
- $this->kind = $kind;
4953
- }
4954
-
4955
- public function getKind()
4956
- {
4957
- return $this->kind;
4958
- }
4959
- }
4960
-
4961
- class Google_Service_Analytics_ColumnAttributes extends Google_Model
4962
- {
4963
- }
4964
-
4965
- class Google_Service_Analytics_Columns extends Google_Collection
4966
- {
4967
-
4968
- protected $collection_key = 'items';
4969
-
4970
- protected $internal_gapi_mappings = array();
4971
-
4972
- public $attributeNames;
4973
-
4974
- public $etag;
4975
-
4976
- protected $itemsType = 'Google_Service_Analytics_Column';
4977
-
4978
- protected $itemsDataType = 'array';
4979
-
4980
- public $kind;
4981
-
4982
- public $totalResults;
4983
-
4984
- public function setAttributeNames($attributeNames)
4985
- {
4986
- $this->attributeNames = $attributeNames;
4987
- }
4988
-
4989
- public function getAttributeNames()
4990
- {
4991
- return $this->attributeNames;
4992
- }
4993
-
4994
- public function setEtag($etag)
4995
- {
4996
- $this->etag = $etag;
4997
- }
4998
-
4999
- public function getEtag()
5000
- {
5001
- return $this->etag;
5002
- }
5003
-
5004
- public function setItems($items)
5005
- {
5006
- $this->items = $items;
5007
- }
5008
-
5009
- public function getItems()
5010
- {
5011
- return $this->items;
5012
- }
5013
-
5014
- public function setKind($kind)
5015
- {
5016
- $this->kind = $kind;
5017
- }
5018
-
5019
- public function getKind()
5020
- {
5021
- return $this->kind;
5022
- }
5023
-
5024
- public function setTotalResults($totalResults)
5025
- {
5026
- $this->totalResults = $totalResults;
5027
- }
5028
-
5029
- public function getTotalResults()
5030
- {
5031
- return $this->totalResults;
5032
- }
5033
- }
5034
-
5035
- class Google_Service_Analytics_CustomDataSource extends Google_Collection
5036
- {
5037
-
5038
- protected $collection_key = 'profilesLinked';
5039
-
5040
- protected $internal_gapi_mappings = array();
5041
-
5042
- public $accountId;
5043
-
5044
- protected $childLinkType = 'Google_Service_Analytics_CustomDataSourceChildLink';
5045
-
5046
- protected $childLinkDataType = '';
5047
-
5048
- public $created;
5049
-
5050
- public $description;
5051
-
5052
- public $id;
5053
-
5054
- public $importBehavior;
5055
-
5056
- public $kind;
5057
-
5058
- public $name;
5059
-
5060
- protected $parentLinkType = 'Google_Service_Analytics_CustomDataSourceParentLink';
5061
-
5062
- protected $parentLinkDataType = '';
5063
-
5064
- public $profilesLinked;
5065
-
5066
- public $selfLink;
5067
-
5068
- public $type;
5069
-
5070
- public $updated;
5071
-
5072
- public $uploadType;
5073
-
5074
- public $webPropertyId;
5075
-
5076
- public function setAccountId($accountId)
5077
- {
5078
- $this->accountId = $accountId;
5079
- }
5080
-
5081
- public function getAccountId()
5082
- {
5083
- return $this->accountId;
5084
- }
5085
-
5086
- public function setChildLink(Google_Service_Analytics_CustomDataSourceChildLink $childLink)
5087
- {
5088
- $this->childLink = $childLink;
5089
- }
5090
-
5091
- public function getChildLink()
5092
- {
5093
- return $this->childLink;
5094
- }
5095
-
5096
- public function setCreated($created)
5097
- {
5098
- $this->created = $created;
5099
- }
5100
-
5101
- public function getCreated()
5102
- {
5103
- return $this->created;
5104
- }
5105
-
5106
- public function setDescription($description)
5107
- {
5108
- $this->description = $description;
5109
- }
5110
-
5111
- public function getDescription()
5112
- {
5113
- return $this->description;
5114
- }
5115
-
5116
- public function setId($id)
5117
- {
5118
- $this->id = $id;
5119
- }
5120
-
5121
- public function getId()
5122
- {
5123
- return $this->id;
5124
- }
5125
-
5126
- public function setImportBehavior($importBehavior)
5127
- {
5128
- $this->importBehavior = $importBehavior;
5129
- }
5130
-
5131
- public function getImportBehavior()
5132
- {
5133
- return $this->importBehavior;
5134
- }
5135
-
5136
- public function setKind($kind)
5137
- {
5138
- $this->kind = $kind;
5139
- }
5140
-
5141
- public function getKind()
5142
- {
5143
- return $this->kind;
5144
- }
5145
-
5146
- public function setName($name)
5147
- {
5148
- $this->name = $name;
5149
- }
5150
-
5151
- public function getName()
5152
- {
5153
- return $this->name;
5154
- }
5155
-
5156
- public function setParentLink(Google_Service_Analytics_CustomDataSourceParentLink $parentLink)
5157
- {
5158
- $this->parentLink = $parentLink;
5159
- }
5160
-
5161
- public function getParentLink()
5162
- {
5163
- return $this->parentLink;
5164
- }
5165
-
5166
- public function setProfilesLinked($profilesLinked)
5167
- {
5168
- $this->profilesLinked = $profilesLinked;
5169
- }
5170
-
5171
- public function getProfilesLinked()
5172
- {
5173
- return $this->profilesLinked;
5174
- }
5175
-
5176
- public function setSelfLink($selfLink)
5177
- {
5178
- $this->selfLink = $selfLink;
5179
- }
5180
-
5181
- public function getSelfLink()
5182
- {
5183
- return $this->selfLink;
5184
- }
5185
-
5186
- public function setType($type)
5187
- {
5188
- $this->type = $type;
5189
- }
5190
-
5191
- public function getType()
5192
- {
5193
- return $this->type;
5194
- }
5195
-
5196
- public function setUpdated($updated)
5197
- {
5198
- $this->updated = $updated;
5199
- }
5200
-
5201
- public function getUpdated()
5202
- {
5203
- return $this->updated;
5204
- }
5205
-
5206
- public function setUploadType($uploadType)
5207
- {
5208
- $this->uploadType = $uploadType;
5209
- }
5210
-
5211
- public function getUploadType()
5212
- {
5213
- return $this->uploadType;
5214
- }
5215
-
5216
- public function setWebPropertyId($webPropertyId)
5217
- {
5218
- $this->webPropertyId = $webPropertyId;
5219
- }
5220
-
5221
- public function getWebPropertyId()
5222
- {
5223
- return $this->webPropertyId;
5224
- }
5225
- }
5226
-
5227
- class Google_Service_Analytics_CustomDataSourceChildLink extends Google_Model
5228
- {
5229
-
5230
- protected $internal_gapi_mappings = array();
5231
-
5232
- public $href;
5233
-
5234
- public $type;
5235
-
5236
- public function setHref($href)
5237
- {
5238
- $this->href = $href;
5239
- }
5240
-
5241
- public function getHref()
5242
- {
5243
- return $this->href;
5244
- }
5245
-
5246
- public function setType($type)
5247
- {
5248
- $this->type = $type;
5249
- }
5250
-
5251
- public function getType()
5252
- {
5253
- return $this->type;
5254
- }
5255
- }
5256
-
5257
- class Google_Service_Analytics_CustomDataSourceParentLink extends Google_Model
5258
- {
5259
-
5260
- protected $internal_gapi_mappings = array();
5261
-
5262
- public $href;
5263
-
5264
- public $type;
5265
-
5266
- public function setHref($href)
5267
- {
5268
- $this->href = $href;
5269
- }
5270
-
5271
- public function getHref()
5272
- {
5273
- return $this->href;
5274
- }
5275
-
5276
- public function setType($type)
5277
- {
5278
- $this->type = $type;
5279
- }
5280
-
5281
- public function getType()
5282
- {
5283
- return $this->type;
5284
- }
5285
- }
5286
-
5287
- class Google_Service_Analytics_CustomDataSources extends Google_Collection
5288
- {
5289
-
5290
- protected $collection_key = 'items';
5291
-
5292
- protected $internal_gapi_mappings = array();
5293
-
5294
- protected $itemsType = 'Google_Service_Analytics_CustomDataSource';
5295
-
5296
- protected $itemsDataType = 'array';
5297
-
5298
- public $itemsPerPage;
5299
-
5300
- public $kind;
5301
-
5302
- public $nextLink;
5303
-
5304
- public $previousLink;
5305
-
5306
- public $startIndex;
5307
-
5308
- public $totalResults;
5309
-
5310
- public $username;
5311
-
5312
- public function setItems($items)
5313
- {
5314
- $this->items = $items;
5315
- }
5316
-
5317
- public function getItems()
5318
- {
5319
- return $this->items;
5320
- }
5321
-
5322
- public function setItemsPerPage($itemsPerPage)
5323
- {
5324
- $this->itemsPerPage = $itemsPerPage;
5325
- }
5326
-
5327
- public function getItemsPerPage()
5328
- {
5329
- return $this->itemsPerPage;
5330
- }
5331
-
5332
- public function setKind($kind)
5333
- {
5334
- $this->kind = $kind;
5335
- }
5336
-
5337
- public function getKind()
5338
- {
5339
- return $this->kind;
5340
- }
5341
-
5342
- public function setNextLink($nextLink)
5343
- {
5344
- $this->nextLink = $nextLink;
5345
- }
5346
-
5347
- public function getNextLink()
5348
- {
5349
- return $this->nextLink;
5350
- }
5351
-
5352
- public function setPreviousLink($previousLink)
5353
- {
5354
- $this->previousLink = $previousLink;
5355
- }
5356
-
5357
- public function getPreviousLink()
5358
- {
5359
- return $this->previousLink;
5360
- }
5361
-
5362
- public function setStartIndex($startIndex)
5363
- {
5364
- $this->startIndex = $startIndex;
5365
- }
5366
-
5367
- public function getStartIndex()
5368
- {
5369
- return $this->startIndex;
5370
- }
5371
-
5372
- public function setTotalResults($totalResults)
5373
- {
5374
- $this->totalResults = $totalResults;
5375
- }
5376
-
5377
- public function getTotalResults()
5378
- {
5379
- return $this->totalResults;
5380
- }
5381
-
5382
- public function setUsername($username)
5383
- {
5384
- $this->username = $username;
5385
- }
5386
-
5387
- public function getUsername()
5388
- {
5389
- return $this->username;
5390
- }
5391
- }
5392
-
5393
- class Google_Service_Analytics_DailyUpload extends Google_Collection
5394
- {
5395
-
5396
- protected $collection_key = 'recentChanges';
5397
-
5398
- protected $internal_gapi_mappings = array();
5399
-
5400
- public $accountId;
5401
-
5402
- public $appendCount;
5403
-
5404
- public $createdTime;
5405
-
5406
- public $customDataSourceId;
5407
-
5408
- public $date;
5409
-
5410
- public $kind;
5411
-
5412
- public $modifiedTime;
5413
-
5414
- protected $parentLinkType = 'Google_Service_Analytics_DailyUploadParentLink';
5415
-
5416
- protected $parentLinkDataType = '';
5417
-
5418
- protected $recentChangesType = 'Google_Service_Analytics_DailyUploadRecentChanges';
5419
-
5420
- protected $recentChangesDataType = 'array';
5421
-
5422
- public $selfLink;
5423
-
5424
- public $webPropertyId;
5425
-
5426
- public function setAccountId($accountId)
5427
- {
5428
- $this->accountId = $accountId;
5429
- }
5430
-
5431
- public function getAccountId()
5432
- {
5433
- return $this->accountId;
5434
- }
5435
-
5436
- public function setAppendCount($appendCount)
5437
- {
5438
- $this->appendCount = $appendCount;
5439
- }
5440
-
5441
- public function getAppendCount()
5442
- {
5443
- return $this->appendCount;
5444
- }
5445
-
5446
- public function setCreatedTime($createdTime)
5447
- {
5448
- $this->createdTime = $createdTime;
5449
- }
5450
-
5451
- public function getCreatedTime()
5452
- {
5453
- return $this->createdTime;
5454
- }
5455
-
5456
- public function setCustomDataSourceId($customDataSourceId)
5457
- {
5458
- $this->customDataSourceId = $customDataSourceId;
5459
- }
5460
-
5461
- public function getCustomDataSourceId()
5462
- {
5463
- return $this->customDataSourceId;
5464
- }
5465
-
5466
- public function setDate($date)
5467
- {
5468
- $this->date = $date;
5469
- }
5470
-
5471
- public function getDate()
5472
- {
5473
- return $this->date;
5474
- }
5475
-
5476
- public function setKind($kind)
5477
- {
5478
- $this->kind = $kind;
5479
- }
5480
-
5481
- public function getKind()
5482
- {
5483
- return $this->kind;
5484
- }
5485
-
5486
- public function setModifiedTime($modifiedTime)
5487
- {
5488
- $this->modifiedTime = $modifiedTime;
5489
- }
5490
-
5491
- public function getModifiedTime()
5492
- {
5493
- return $this->modifiedTime;
5494
- }
5495
-
5496
- public function setParentLink(Google_Service_Analytics_DailyUploadParentLink $parentLink)
5497
- {
5498
- $this->parentLink = $parentLink;
5499
- }
5500
-
5501
- public function getParentLink()
5502
- {
5503
- return $this->parentLink;
5504
- }
5505
-
5506
- public function setRecentChanges($recentChanges)
5507
- {
5508
- $this->recentChanges = $recentChanges;
5509
- }
5510
-
5511
- public function getRecentChanges()
5512
- {
5513
- return $this->recentChanges;
5514
- }
5515
-
5516
- public function setSelfLink($selfLink)
5517
- {
5518
- $this->selfLink = $selfLink;
5519
- }
5520
-
5521
- public function getSelfLink()
5522
- {
5523
- return $this->selfLink;
5524
- }
5525
-
5526
- public function setWebPropertyId($webPropertyId)
5527
- {
5528
- $this->webPropertyId = $webPropertyId;
5529
- }
5530
-
5531
- public function getWebPropertyId()
5532
- {
5533
- return $this->webPropertyId;
5534
- }
5535
- }
5536
-
5537
- class Google_Service_Analytics_DailyUploadAppend extends Google_Model
5538
- {
5539
-
5540
- protected $internal_gapi_mappings = array();
5541
-
5542
- public $accountId;
5543
-
5544
- public $appendNumber;
5545
-
5546
- public $customDataSourceId;
5547
-
5548
- public $date;
5549
-
5550
- public $kind;
5551
-
5552
- public $nextAppendLink;
5553
-
5554
- public $webPropertyId;
5555
-
5556
- public function setAccountId($accountId)
5557
- {
5558
- $this->accountId = $accountId;
5559
- }
5560
-
5561
- public function getAccountId()
5562
- {
5563
- return $this->accountId;
5564
- }
5565
-
5566
- public function setAppendNumber($appendNumber)
5567
- {
5568
- $this->appendNumber = $appendNumber;
5569
- }
5570
-
5571
- public function getAppendNumber()
5572
- {
5573
- return $this->appendNumber;
5574
- }
5575
-
5576
- public function setCustomDataSourceId($customDataSourceId)
5577
- {
5578
- $this->customDataSourceId = $customDataSourceId;
5579
- }
5580
-
5581
- public function getCustomDataSourceId()
5582
- {
5583
- return $this->customDataSourceId;
5584
- }
5585
-
5586
- public function setDate($date)
5587
- {
5588
- $this->date = $date;
5589
- }
5590
-
5591
- public function getDate()
5592
- {
5593
- return $this->date;
5594
- }
5595
-
5596
- public function setKind($kind)
5597
- {
5598
- $this->kind = $kind;
5599
- }
5600
-
5601
- public function getKind()
5602
- {
5603
- return $this->kind;
5604
- }
5605
-
5606
- public function setNextAppendLink($nextAppendLink)
5607
- {
5608
- $this->nextAppendLink = $nextAppendLink;
5609
- }
5610
-
5611
- public function getNextAppendLink()
5612
- {
5613
- return $this->nextAppendLink;
5614
- }
5615
-
5616
- public function setWebPropertyId($webPropertyId)
5617
- {
5618
- $this->webPropertyId = $webPropertyId;
5619
- }
5620
-
5621
- public function getWebPropertyId()
5622
- {
5623
- return $this->webPropertyId;
5624
- }
5625
- }
5626
-
5627
- class Google_Service_Analytics_DailyUploadParentLink extends Google_Model
5628
- {
5629
-
5630
- protected $internal_gapi_mappings = array();
5631
-
5632
- public $href;
5633
-
5634
- public $type;
5635
-
5636
- public function setHref($href)
5637
- {
5638
- $this->href = $href;
5639
- }
5640
-
5641
- public function getHref()
5642
- {
5643
- return $this->href;
5644
- }
5645
-
5646
- public function setType($type)
5647
- {
5648
- $this->type = $type;
5649
- }
5650
-
5651
- public function getType()
5652
- {
5653
- return $this->type;
5654
- }
5655
- }
5656
-
5657
- class Google_Service_Analytics_DailyUploadRecentChanges extends Google_Model
5658
- {
5659
-
5660
- protected $internal_gapi_mappings = array();
5661
-
5662
- public $change;
5663
-
5664
- public $time;
5665
-
5666
- public function setChange($change)
5667
- {
5668
- $this->change = $change;
5669
- }
5670
-
5671
- public function getChange()
5672
- {
5673
- return $this->change;
5674
- }
5675
-
5676
- public function setTime($time)
5677
- {
5678
- $this->time = $time;
5679
- }
5680
-
5681
- public function getTime()
5682
- {
5683
- return $this->time;
5684
- }
5685
- }
5686
-
5687
- class Google_Service_Analytics_DailyUploads extends Google_Collection
5688
- {
5689
-
5690
- protected $collection_key = 'items';
5691
-
5692
- protected $internal_gapi_mappings = array();
5693
-
5694
- protected $itemsType = 'Google_Service_Analytics_DailyUpload';
5695
-
5696
- protected $itemsDataType = 'array';
5697
-
5698
- public $itemsPerPage;
5699
-
5700
- public $kind;
5701
-
5702
- public $nextLink;
5703
-
5704
- public $previousLink;
5705
-
5706
- public $startIndex;
5707
-
5708
- public $totalResults;
5709
-
5710
- public $username;
5711
-
5712
- public function setItems($items)
5713
- {
5714
- $this->items = $items;
5715
- }
5716
-
5717
- public function getItems()
5718
- {
5719
- return $this->items;
5720
- }
5721
-
5722
- public function setItemsPerPage($itemsPerPage)
5723
- {
5724
- $this->itemsPerPage = $itemsPerPage;
5725
- }
5726
-
5727
- public function getItemsPerPage()
5728
- {
5729
- return $this->itemsPerPage;
5730
- }
5731
-
5732
- public function setKind($kind)
5733
- {
5734
- $this->kind = $kind;
5735
- }
5736
-
5737
- public function getKind()
5738
- {
5739
- return $this->kind;
5740
- }
5741
-
5742
- public function setNextLink($nextLink)
5743
- {
5744
- $this->nextLink = $nextLink;
5745
- }
5746
-
5747
- public function getNextLink()
5748
- {
5749
- return $this->nextLink;
5750
- }
5751
-
5752
- public function setPreviousLink($previousLink)
5753
- {
5754
- $this->previousLink = $previousLink;
5755
- }
5756
-
5757
- public function getPreviousLink()
5758
- {
5759
- return $this->previousLink;
5760
- }
5761
-
5762
- public function setStartIndex($startIndex)
5763
- {
5764
- $this->startIndex = $startIndex;
5765
- }
5766
-
5767
- public function getStartIndex()
5768
- {
5769
- return $this->startIndex;
5770
- }
5771
-
5772
- public function setTotalResults($totalResults)
5773
- {
5774
- $this->totalResults = $totalResults;
5775
- }
5776
-
5777
- public function getTotalResults()
5778
- {
5779
- return $this->totalResults;
5780
- }
5781
-
5782
- public function setUsername($username)
5783
- {
5784
- $this->username = $username;
5785
- }
5786
-
5787
- public function getUsername()
5788
- {
5789
- return $this->username;
5790
- }
5791
- }
5792
-
5793
- class Google_Service_Analytics_EntityAdWordsLink extends Google_Collection
5794
- {
5795
-
5796
- protected $collection_key = 'profileIds';
5797
-
5798
- protected $internal_gapi_mappings = array();
5799
-
5800
- protected $adWordsAccountsType = 'Google_Service_Analytics_AdWordsAccount';
5801
-
5802
- protected $adWordsAccountsDataType = 'array';
5803
-
5804
- protected $entityType = 'Google_Service_Analytics_EntityAdWordsLinkEntity';
5805
-
5806
- protected $entityDataType = '';
5807
-
5808
- public $id;
5809
-
5810
- public $kind;
5811
-
5812
- public $name;
5813
-
5814
- public $profileIds;
5815
-
5816
- public $selfLink;
5817
-
5818
- public function setAdWordsAccounts($adWordsAccounts)
5819
- {
5820
- $this->adWordsAccounts = $adWordsAccounts;
5821
- }
5822
-
5823
- public function getAdWordsAccounts()
5824
- {
5825
- return $this->adWordsAccounts;
5826
- }
5827
-
5828
- public function setEntity(Google_Service_Analytics_EntityAdWordsLinkEntity $entity)
5829
- {
5830
- $this->entity = $entity;
5831
- }
5832
-
5833
- public function getEntity()
5834
- {
5835
- return $this->entity;
5836
- }
5837
-
5838
- public function setId($id)
5839
- {
5840
- $this->id = $id;
5841
- }
5842
-
5843
- public function getId()
5844
- {
5845
- return $this->id;
5846
- }
5847
-
5848
- public function setKind($kind)
5849
- {
5850
- $this->kind = $kind;
5851
- }
5852
-
5853
- public function getKind()
5854
- {
5855
- return $this->kind;
5856
- }
5857
-
5858
- public function setName($name)
5859
- {
5860
- $this->name = $name;
5861
- }
5862
-
5863
- public function getName()
5864
- {
5865
- return $this->name;
5866
- }
5867
-
5868
- public function setProfileIds($profileIds)
5869
- {
5870
- $this->profileIds = $profileIds;
5871
- }
5872
-
5873
- public function getProfileIds()
5874
- {
5875
- return $this->profileIds;
5876
- }
5877
-
5878
- public function setSelfLink($selfLink)
5879
- {
5880
- $this->selfLink = $selfLink;
5881
- }
5882
-
5883
- public function getSelfLink()
5884
- {
5885
- return $this->selfLink;
5886
- }
5887
- }
5888
-
5889
- class Google_Service_Analytics_EntityAdWordsLinkEntity extends Google_Model
5890
- {
5891
-
5892
- protected $internal_gapi_mappings = array();
5893
-
5894
- protected $webPropertyRefType = 'Google_Service_Analytics_WebPropertyRef';
5895
-
5896
- protected $webPropertyRefDataType = '';
5897
-
5898
- public function setWebPropertyRef(Google_Service_Analytics_WebPropertyRef $webPropertyRef)
5899
- {
5900
- $this->webPropertyRef = $webPropertyRef;
5901
- }
5902
-
5903
- public function getWebPropertyRef()
5904
- {
5905
- return $this->webPropertyRef;
5906
- }
5907
- }
5908
-
5909
- class Google_Service_Analytics_EntityAdWordsLinks extends Google_Collection
5910
- {
5911
-
5912
- protected $collection_key = 'items';
5913
-
5914
- protected $internal_gapi_mappings = array();
5915
-
5916
- protected $itemsType = 'Google_Service_Analytics_EntityAdWordsLink';
5917
-
5918
- protected $itemsDataType = 'array';
5919
-
5920
- public $itemsPerPage;
5921
-
5922
- public $kind;
5923
-
5924
- public $nextLink;
5925
-
5926
- public $previousLink;
5927
-
5928
- public $startIndex;
5929
-
5930
- public $totalResults;
5931
-
5932
- public function setItems($items)
5933
- {
5934
- $this->items = $items;
5935
- }
5936
-
5937
- public function getItems()
5938
- {
5939
- return $this->items;
5940
- }
5941
-
5942
- public function setItemsPerPage($itemsPerPage)
5943
- {
5944
- $this->itemsPerPage = $itemsPerPage;
5945
- }
5946
-
5947
- public function getItemsPerPage()
5948
- {
5949
- return $this->itemsPerPage;
5950
- }
5951
-
5952
- public function setKind($kind)
5953
- {
5954
- $this->kind = $kind;
5955
- }
5956
-
5957
- public function getKind()
5958
- {
5959
- return $this->kind;
5960
- }
5961
-
5962
- public function setNextLink($nextLink)
5963
- {
5964
- $this->nextLink = $nextLink;
5965
- }
5966
-
5967
- public function getNextLink()
5968
- {
5969
- return $this->nextLink;
5970
- }
5971
-
5972
- public function setPreviousLink($previousLink)
5973
- {
5974
- $this->previousLink = $previousLink;
5975
- }
5976
-
5977
- public function getPreviousLink()
5978
- {
5979
- return $this->previousLink;
5980
- }
5981
-
5982
- public function setStartIndex($startIndex)
5983
- {
5984
- $this->startIndex = $startIndex;
5985
- }
5986
-
5987
- public function getStartIndex()
5988
- {
5989
- return $this->startIndex;
5990
- }
5991
-
5992
- public function setTotalResults($totalResults)
5993
- {
5994
- $this->totalResults = $totalResults;
5995
- }
5996
-
5997
- public function getTotalResults()
5998
- {
5999
- return $this->totalResults;
6000
- }
6001
- }
6002
-
6003
- class Google_Service_Analytics_EntityUserLink extends Google_Model
6004
- {
6005
-
6006
- protected $internal_gapi_mappings = array();
6007
-
6008
- protected $entityType = 'Google_Service_Analytics_EntityUserLinkEntity';
6009
-
6010
- protected $entityDataType = '';
6011
-
6012
- public $id;
6013
-
6014
- public $kind;
6015
-
6016
- protected $permissionsType = 'Google_Service_Analytics_EntityUserLinkPermissions';
6017
-
6018
- protected $permissionsDataType = '';
6019
-
6020
- public $selfLink;
6021
-
6022
- protected $userRefType = 'Google_Service_Analytics_UserRef';
6023
-
6024
- protected $userRefDataType = '';
6025
-
6026
- public function setEntity(Google_Service_Analytics_EntityUserLinkEntity $entity)
6027
- {
6028
- $this->entity = $entity;
6029
- }
6030
-
6031
- public function getEntity()
6032
- {
6033
- return $this->entity;
6034
- }
6035
-
6036
- public function setId($id)
6037
- {
6038
- $this->id = $id;
6039
- }
6040
-
6041
- public function getId()
6042
- {
6043
- return $this->id;
6044
- }
6045
-
6046
- public function setKind($kind)
6047
- {
6048
- $this->kind = $kind;
6049
- }
6050
-
6051
- public function getKind()
6052
- {
6053
- return $this->kind;
6054
- }
6055
-
6056
- public function setPermissions(Google_Service_Analytics_EntityUserLinkPermissions $permissions)
6057
- {
6058
- $this->permissions = $permissions;
6059
- }
6060
-
6061
- public function getPermissions()
6062
- {
6063
- return $this->permissions;
6064
- }
6065
-
6066
- public function setSelfLink($selfLink)
6067
- {
6068
- $this->selfLink = $selfLink;
6069
- }
6070
-
6071
- public function getSelfLink()
6072
- {
6073
- return $this->selfLink;
6074
- }
6075
-
6076
- public function setUserRef(Google_Service_Analytics_UserRef $userRef)
6077
- {
6078
- $this->userRef = $userRef;
6079
- }
6080
-
6081
- public function getUserRef()
6082
- {
6083
- return $this->userRef;
6084
- }
6085
- }
6086
-
6087
- class Google_Service_Analytics_EntityUserLinkEntity extends Google_Model
6088
- {
6089
-
6090
- protected $internal_gapi_mappings = array();
6091
-
6092
- protected $accountRefType = 'Google_Service_Analytics_AccountRef';
6093
-
6094
- protected $accountRefDataType = '';
6095
-
6096
- protected $profileRefType = 'Google_Service_Analytics_ProfileRef';
6097
-
6098
- protected $profileRefDataType = '';
6099
-
6100
- protected $webPropertyRefType = 'Google_Service_Analytics_WebPropertyRef';
6101
-
6102
- protected $webPropertyRefDataType = '';
6103
-
6104
- public function setAccountRef(Google_Service_Analytics_AccountRef $accountRef)
6105
- {
6106
- $this->accountRef = $accountRef;
6107
- }
6108
-
6109
- public function getAccountRef()
6110
- {
6111
- return $this->accountRef;
6112
- }
6113
-
6114
- public function setProfileRef(Google_Service_Analytics_ProfileRef $profileRef)
6115
- {
6116
- $this->profileRef = $profileRef;
6117
- }
6118
-
6119
- public function getProfileRef()
6120
- {
6121
- return $this->profileRef;
6122
- }
6123
-
6124
- public function setWebPropertyRef(Google_Service_Analytics_WebPropertyRef $webPropertyRef)
6125
- {
6126
- $this->webPropertyRef = $webPropertyRef;
6127
- }
6128
-
6129
- public function getWebPropertyRef()
6130
- {
6131
- return $this->webPropertyRef;
6132
- }
6133
- }
6134
-
6135
- class Google_Service_Analytics_EntityUserLinkPermissions extends Google_Collection
6136
- {
6137
-
6138
- protected $collection_key = 'local';
6139
-
6140
- protected $internal_gapi_mappings = array();
6141
-
6142
- public $effective;
6143
-
6144
- public $local;
6145
-
6146
- public function setEffective($effective)
6147
- {
6148
- $this->effective = $effective;
6149
- }
6150
-
6151
- public function getEffective()
6152
- {
6153
- return $this->effective;
6154
- }
6155
-
6156
- public function setLocal($local)
6157
- {
6158
- $this->local = $local;
6159
- }
6160
-
6161
- public function getLocal()
6162
- {
6163
- return $this->local;
6164
- }
6165
- }
6166
-
6167
- class Google_Service_Analytics_EntityUserLinks extends Google_Collection
6168
- {
6169
-
6170
- protected $collection_key = 'items';
6171
-
6172
- protected $internal_gapi_mappings = array();
6173
-
6174
- protected $itemsType = 'Google_Service_Analytics_EntityUserLink';
6175
-
6176
- protected $itemsDataType = 'array';
6177
-
6178
- public $itemsPerPage;
6179
-
6180
- public $kind;
6181
-
6182
- public $nextLink;
6183
-
6184
- public $previousLink;
6185
-
6186
- public $startIndex;
6187
-
6188
- public $totalResults;
6189
-
6190
- public function setItems($items)
6191
- {
6192
- $this->items = $items;
6193
- }
6194
-
6195
- public function getItems()
6196
- {
6197
- return $this->items;
6198
- }
6199
-
6200
- public function setItemsPerPage($itemsPerPage)
6201
- {
6202
- $this->itemsPerPage = $itemsPerPage;
6203
- }
6204
-
6205
- public function getItemsPerPage()
6206
- {
6207
- return $this->itemsPerPage;
6208
- }
6209
-
6210
- public function setKind($kind)
6211
- {
6212
- $this->kind = $kind;
6213
- }
6214
-
6215
- public function getKind()
6216
- {
6217
- return $this->kind;
6218
- }
6219
-
6220
- public function setNextLink($nextLink)
6221
- {
6222
- $this->nextLink = $nextLink;
6223
- }
6224
-
6225
- public function getNextLink()
6226
- {
6227
- return $this->nextLink;
6228
- }
6229
-
6230
- public function setPreviousLink($previousLink)
6231
- {
6232
- $this->previousLink = $previousLink;
6233
- }
6234
-
6235
- public function getPreviousLink()
6236
- {
6237
- return $this->previousLink;
6238
- }
6239
-
6240
- public function setStartIndex($startIndex)
6241
- {
6242
- $this->startIndex = $startIndex;
6243
- }
6244
-
6245
- public function getStartIndex()
6246
- {
6247
- return $this->startIndex;
6248
- }
6249
-
6250
- public function setTotalResults($totalResults)
6251
- {
6252
- $this->totalResults = $totalResults;
6253
- }
6254
-
6255
- public function getTotalResults()
6256
- {
6257
- return $this->totalResults;
6258
- }
6259
- }
6260
-
6261
- class Google_Service_Analytics_Experiment extends Google_Collection
6262
- {
6263
-
6264
- protected $collection_key = 'variations';
6265
-
6266
- protected $internal_gapi_mappings = array();
6267
-
6268
- public $accountId;
6269
-
6270
- public $created;
6271
-
6272
- public $description;
6273
-
6274
- public $editableInGaUi;
6275
-
6276
- public $endTime;
6277
-
6278
- public $equalWeighting;
6279
-
6280
- public $id;
6281
-
6282
- public $internalWebPropertyId;
6283
-
6284
- public $kind;
6285
-
6286
- public $minimumExperimentLengthInDays;
6287
-
6288
- public $name;
6289
-
6290
- public $objectiveMetric;
6291
-
6292
- public $optimizationType;
6293
-
6294
- protected $parentLinkType = 'Google_Service_Analytics_ExperimentParentLink';
6295
-
6296
- protected $parentLinkDataType = '';
6297
-
6298
- public $profileId;
6299
-
6300
- public $reasonExperimentEnded;
6301
-
6302
- public $rewriteVariationUrlsAsOriginal;
6303
-
6304
- public $selfLink;
6305
-
6306
- public $servingFramework;
6307
-
6308
- public $snippet;
6309
-
6310
- public $startTime;
6311
-
6312
- public $status;
6313
-
6314
- public $trafficCoverage;
6315
-
6316
- public $updated;
6317
-
6318
- protected $variationsType = 'Google_Service_Analytics_ExperimentVariations';
6319
-
6320
- protected $variationsDataType = 'array';
6321
-
6322
- public $webPropertyId;
6323
-
6324
- public $winnerConfidenceLevel;
6325
-
6326
- public $winnerFound;
6327
-
6328
- public function setAccountId($accountId)
6329
- {
6330
- $this->accountId = $accountId;
6331
- }
6332
-
6333
- public function getAccountId()
6334
- {
6335
- return $this->accountId;
6336
- }
6337
-
6338
- public function setCreated($created)
6339
- {
6340
- $this->created = $created;
6341
- }
6342
-
6343
- public function getCreated()
6344
- {
6345
- return $this->created;
6346
- }
6347
-
6348
- public function setDescription($description)
6349
- {
6350
- $this->description = $description;
6351
- }
6352
-
6353
- public function getDescription()
6354
- {
6355
- return $this->description;
6356
- }
6357
-
6358
- public function setEditableInGaUi($editableInGaUi)
6359
- {
6360
- $this->editableInGaUi = $editableInGaUi;
6361
- }
6362
-
6363
- public function getEditableInGaUi()
6364
- {
6365
- return $this->editableInGaUi;
6366
- }
6367
-
6368
- public function setEndTime($endTime)
6369
- {
6370
- $this->endTime = $endTime;
6371
- }
6372
-
6373
- public function getEndTime()
6374
- {
6375
- return $this->endTime;
6376
- }
6377
-
6378
- public function setEqualWeighting($equalWeighting)
6379
- {
6380
- $this->equalWeighting = $equalWeighting;
6381
- }
6382
-
6383
- public function getEqualWeighting()
6384
- {
6385
- return $this->equalWeighting;
6386
- }
6387
-
6388
- public function setId($id)
6389
- {
6390
- $this->id = $id;
6391
- }
6392
-
6393
- public function getId()
6394
- {
6395
- return $this->id;
6396
- }
6397
-
6398
- public function setInternalWebPropertyId($internalWebPropertyId)
6399
- {
6400
- $this->internalWebPropertyId = $internalWebPropertyId;
6401
- }
6402
-
6403
- public function getInternalWebPropertyId()
6404
- {
6405
- return $this->internalWebPropertyId;
6406
- }
6407
-
6408
- public function setKind($kind)
6409
- {
6410
- $this->kind = $kind;
6411
- }
6412
-
6413
- public function getKind()
6414
- {
6415
- return $this->kind;
6416
- }
6417
-
6418
- public function setMinimumExperimentLengthInDays($minimumExperimentLengthInDays)
6419
- {
6420
- $this->minimumExperimentLengthInDays = $minimumExperimentLengthInDays;
6421
- }
6422
-
6423
- public function getMinimumExperimentLengthInDays()
6424
- {
6425
- return $this->minimumExperimentLengthInDays;
6426
- }
6427
-
6428
- public function setName($name)
6429
- {
6430
- $this->name = $name;
6431
- }
6432
-
6433
- public function getName()
6434
- {
6435
- return $this->name;
6436
- }
6437
-
6438
- public function setObjectiveMetric($objectiveMetric)
6439
- {
6440
- $this->objectiveMetric = $objectiveMetric;
6441
- }
6442
-
6443
- public function getObjectiveMetric()
6444
- {
6445
- return $this->objectiveMetric;
6446
- }
6447
-
6448
- public function setOptimizationType($optimizationType)
6449
- {
6450
- $this->optimizationType = $optimizationType;
6451
- }
6452
-
6453
- public function getOptimizationType()
6454
- {
6455
- return $this->optimizationType;
6456
- }
6457
-
6458
- public function setParentLink(Google_Service_Analytics_ExperimentParentLink $parentLink)
6459
- {
6460
- $this->parentLink = $parentLink;
6461
- }
6462
-
6463
- public function getParentLink()
6464
- {
6465
- return $this->parentLink;
6466
- }
6467
-
6468
- public function setProfileId($profileId)
6469
- {
6470
- $this->profileId = $profileId;
6471
- }
6472
-
6473
- public function getProfileId()
6474
- {
6475
- return $this->profileId;
6476
- }
6477
-
6478
- public function setReasonExperimentEnded($reasonExperimentEnded)
6479
- {
6480
- $this->reasonExperimentEnded = $reasonExperimentEnded;
6481
- }
6482
-
6483
- public function getReasonExperimentEnded()
6484
- {
6485
- return $this->reasonExperimentEnded;
6486
- }
6487
-
6488
- public function setRewriteVariationUrlsAsOriginal($rewriteVariationUrlsAsOriginal)
6489
- {
6490
- $this->rewriteVariationUrlsAsOriginal = $rewriteVariationUrlsAsOriginal;
6491
- }
6492
-
6493
- public function getRewriteVariationUrlsAsOriginal()
6494
- {
6495
- return $this->rewriteVariationUrlsAsOriginal;
6496
- }
6497
-
6498
- public function setSelfLink($selfLink)
6499
- {
6500
- $this->selfLink = $selfLink;
6501
- }
6502
-
6503
- public function getSelfLink()
6504
- {
6505
- return $this->selfLink;
6506
- }
6507
-
6508
- public function setServingFramework($servingFramework)
6509
- {
6510
- $this->servingFramework = $servingFramework;
6511
- }
6512
-
6513
- public function getServingFramework()
6514
- {
6515
- return $this->servingFramework;
6516
- }
6517
-
6518
- public function setSnippet($snippet)
6519
- {
6520
- $this->snippet = $snippet;
6521
- }
6522
-
6523
- public function getSnippet()
6524
- {
6525
- return $this->snippet;
6526
- }
6527
-
6528
- public function setStartTime($startTime)
6529
- {
6530
- $this->startTime = $startTime;
6531
- }
6532
-
6533
- public function getStartTime()
6534
- {
6535
- return $this->startTime;
6536
- }
6537
-
6538
- public function setStatus($status)
6539
- {
6540
- $this->status = $status;
6541
- }
6542
-
6543
- public function getStatus()
6544
- {
6545
- return $this->status;
6546
- }
6547
-
6548
- public function setTrafficCoverage($trafficCoverage)
6549
- {
6550
- $this->trafficCoverage = $trafficCoverage;
6551
- }
6552
-
6553
- public function getTrafficCoverage()
6554
- {
6555
- return $this->trafficCoverage;
6556
- }
6557
-
6558
- public function setUpdated($updated)
6559
- {
6560
- $this->updated = $updated;
6561
- }
6562
-
6563
- public function getUpdated()
6564
- {
6565
- return $this->updated;
6566
- }
6567
-
6568
- public function setVariations($variations)
6569
- {
6570
- $this->variations = $variations;
6571
- }
6572
-
6573
- public function getVariations()
6574
- {
6575
- return $this->variations;
6576
- }
6577
-
6578
- public function setWebPropertyId($webPropertyId)
6579
- {
6580
- $this->webPropertyId = $webPropertyId;
6581
- }
6582
-
6583
- public function getWebPropertyId()
6584
- {
6585
- return $this->webPropertyId;
6586
- }
6587
-
6588
- public function setWinnerConfidenceLevel($winnerConfidenceLevel)
6589
- {
6590
- $this->winnerConfidenceLevel = $winnerConfidenceLevel;
6591
- }
6592
-
6593
- public function getWinnerConfidenceLevel()
6594
- {
6595
- return $this->winnerConfidenceLevel;
6596
- }
6597
-
6598
- public function setWinnerFound($winnerFound)
6599
- {
6600
- $this->winnerFound = $winnerFound;
6601
- }
6602
-
6603
- public function getWinnerFound()
6604
- {
6605
- return $this->winnerFound;
6606
- }
6607
- }
6608
-
6609
- class Google_Service_Analytics_ExperimentParentLink extends Google_Model
6610
- {
6611
-
6612
- protected $internal_gapi_mappings = array();
6613
-
6614
- public $href;
6615
-
6616
- public $type;
6617
-
6618
- public function setHref($href)
6619
- {
6620
- $this->href = $href;
6621
- }
6622
-
6623
- public function getHref()
6624
- {
6625
- return $this->href;
6626
- }
6627
-
6628
- public function setType($type)
6629
- {
6630
- $this->type = $type;
6631
- }
6632
-
6633
- public function getType()
6634
- {
6635
- return $this->type;
6636
- }
6637
- }
6638
-
6639
- class Google_Service_Analytics_ExperimentVariations extends Google_Model
6640
- {
6641
-
6642
- protected $internal_gapi_mappings = array();
6643
-
6644
- public $name;
6645
-
6646
- public $status;
6647
-
6648
- public $url;
6649
-
6650
- public $weight;
6651
-
6652
- public $won;
6653
-
6654
- public function setName($name)
6655
- {
6656
- $this->name = $name;
6657
- }
6658
-
6659
- public function getName()
6660
- {
6661
- return $this->name;
6662
- }
6663
-
6664
- public function setStatus($status)
6665
- {
6666
- $this->status = $status;
6667
- }
6668
-
6669
- public function getStatus()
6670
- {
6671
- return $this->status;
6672
- }
6673
-
6674
- public function setUrl($url)
6675
- {
6676
- $this->url = $url;
6677
- }
6678
-
6679
- public function getUrl()
6680
- {
6681
- return $this->url;
6682
- }
6683
-
6684
- public function setWeight($weight)
6685
- {
6686
- $this->weight = $weight;
6687
- }
6688
-
6689
- public function getWeight()
6690
- {
6691
- return $this->weight;
6692
- }
6693
-
6694
- public function setWon($won)
6695
- {
6696
- $this->won = $won;
6697
- }
6698
-
6699
- public function getWon()
6700
- {
6701
- return $this->won;
6702
- }
6703
- }
6704
-
6705
- class Google_Service_Analytics_Experiments extends Google_Collection
6706
- {
6707
-
6708
- protected $collection_key = 'items';
6709
-
6710
- protected $internal_gapi_mappings = array();
6711
-
6712
- protected $itemsType = 'Google_Service_Analytics_Experiment';
6713
-
6714
- protected $itemsDataType = 'array';
6715
-
6716
- public $itemsPerPage;
6717
-
6718
- public $kind;
6719
-
6720
- public $nextLink;
6721
-
6722
- public $previousLink;
6723
-
6724
- public $startIndex;
6725
-
6726
- public $totalResults;
6727
-
6728
- public $username;
6729
-
6730
- public function setItems($items)
6731
- {
6732
- $this->items = $items;
6733
- }
6734
-
6735
- public function getItems()
6736
- {
6737
- return $this->items;
6738
- }
6739
-
6740
- public function setItemsPerPage($itemsPerPage)
6741
- {
6742
- $this->itemsPerPage = $itemsPerPage;
6743
- }
6744
-
6745
- public function getItemsPerPage()
6746
- {
6747
- return $this->itemsPerPage;
6748
- }
6749
-
6750
- public function setKind($kind)
6751
- {
6752
- $this->kind = $kind;
6753
- }
6754
-
6755
- public function getKind()
6756
- {
6757
- return $this->kind;
6758
- }
6759
-
6760
- public function setNextLink($nextLink)
6761
- {
6762
- $this->nextLink = $nextLink;
6763
- }
6764
-
6765
- public function getNextLink()
6766
- {
6767
- return $this->nextLink;
6768
- }
6769
-
6770
- public function setPreviousLink($previousLink)
6771
- {
6772
- $this->previousLink = $previousLink;
6773
- }
6774
-
6775
- public function getPreviousLink()
6776
- {
6777
- return $this->previousLink;
6778
- }
6779
-
6780
- public function setStartIndex($startIndex)
6781
- {
6782
- $this->startIndex = $startIndex;
6783
- }
6784
-
6785
- public function getStartIndex()
6786
- {
6787
- return $this->startIndex;
6788
- }
6789
-
6790
- public function setTotalResults($totalResults)
6791
- {
6792
- $this->totalResults = $totalResults;
6793
- }
6794
-
6795
- public function getTotalResults()
6796
- {
6797
- return $this->totalResults;
6798
- }
6799
-
6800
- public function setUsername($username)
6801
- {
6802
- $this->username = $username;
6803
- }
6804
-
6805
- public function getUsername()
6806
- {
6807
- return $this->username;
6808
- }
6809
- }
6810
-
6811
- class Google_Service_Analytics_Filter extends Google_Model
6812
- {
6813
-
6814
- protected $internal_gapi_mappings = array();
6815
-
6816
- public $accountId;
6817
-
6818
- protected $advancedDetailsType = 'Google_Service_Analytics_FilterAdvancedDetails';
6819
-
6820
- protected $advancedDetailsDataType = '';
6821
-
6822
- public $created;
6823
-
6824
- protected $excludeDetailsType = 'Google_Service_Analytics_FilterExpression';
6825
-
6826
- protected $excludeDetailsDataType = '';
6827
-
6828
- public $id;
6829
-
6830
- protected $includeDetailsType = 'Google_Service_Analytics_FilterExpression';
6831
-
6832
- protected $includeDetailsDataType = '';
6833
-
6834
- public $kind;
6835
-
6836
- protected $lowercaseDetailsType = 'Google_Service_Analytics_FilterLowercaseDetails';
6837
-
6838
- protected $lowercaseDetailsDataType = '';
6839
-
6840
- public $name;
6841
-
6842
- protected $parentLinkType = 'Google_Service_Analytics_FilterParentLink';
6843
-
6844
- protected $parentLinkDataType = '';
6845
-
6846
- protected $searchAndReplaceDetailsType = 'Google_Service_Analytics_FilterSearchAndReplaceDetails';
6847
-
6848
- protected $searchAndReplaceDetailsDataType = '';
6849
-
6850
- public $selfLink;
6851
-
6852
- public $type;
6853
-
6854
- public $updated;
6855
-
6856
- protected $uppercaseDetailsType = 'Google_Service_Analytics_FilterUppercaseDetails';
6857
-
6858
- protected $uppercaseDetailsDataType = '';
6859
-
6860
- public function setAccountId($accountId)
6861
- {
6862
- $this->accountId = $accountId;
6863
- }
6864
-
6865
- public function getAccountId()
6866
- {
6867
- return $this->accountId;
6868
- }
6869
-
6870
- public function setAdvancedDetails(Google_Service_Analytics_FilterAdvancedDetails $advancedDetails)
6871
- {
6872
- $this->advancedDetails = $advancedDetails;
6873
- }
6874
-
6875
- public function getAdvancedDetails()
6876
- {
6877
- return $this->advancedDetails;
6878
- }
6879
-
6880
- public function setCreated($created)
6881
- {
6882
- $this->created = $created;
6883
- }
6884
-
6885
- public function getCreated()
6886
- {
6887
- return $this->created;
6888
- }
6889
-
6890
- public function setExcludeDetails(Google_Service_Analytics_FilterExpression $excludeDetails)
6891
- {
6892
- $this->excludeDetails = $excludeDetails;
6893
- }
6894
-
6895
- public function getExcludeDetails()
6896
- {
6897
- return $this->excludeDetails;
6898
- }
6899
-
6900
- public function setId($id)
6901
- {
6902
- $this->id = $id;
6903
- }
6904
-
6905
- public function getId()
6906
- {
6907
- return $this->id;
6908
- }
6909
-
6910
- public function setIncludeDetails(Google_Service_Analytics_FilterExpression $includeDetails)
6911
- {
6912
- $this->includeDetails = $includeDetails;
6913
- }
6914
-
6915
- public function getIncludeDetails()
6916
- {
6917
- return $this->includeDetails;
6918
- }
6919
-
6920
- public function setKind($kind)
6921
- {
6922
- $this->kind = $kind;
6923
- }
6924
-
6925
- public function getKind()
6926
- {
6927
- return $this->kind;
6928
- }
6929
-
6930
- public function setLowercaseDetails(Google_Service_Analytics_FilterLowercaseDetails $lowercaseDetails)
6931
- {
6932
- $this->lowercaseDetails = $lowercaseDetails;
6933
- }
6934
-
6935
- public function getLowercaseDetails()
6936
- {
6937
- return $this->lowercaseDetails;
6938
- }
6939
-
6940
- public function setName($name)
6941
- {
6942
- $this->name = $name;
6943
- }
6944
-
6945
- public function getName()
6946
- {
6947
- return $this->name;
6948
- }
6949
-
6950
- public function setParentLink(Google_Service_Analytics_FilterParentLink $parentLink)
6951
- {
6952
- $this->parentLink = $parentLink;
6953
- }
6954
-
6955
- public function getParentLink()
6956
- {
6957
- return $this->parentLink;
6958
- }
6959
-
6960
- public function setSearchAndReplaceDetails(Google_Service_Analytics_FilterSearchAndReplaceDetails $searchAndReplaceDetails)
6961
- {
6962
- $this->searchAndReplaceDetails = $searchAndReplaceDetails;
6963
- }
6964
-
6965
- public function getSearchAndReplaceDetails()
6966
- {
6967
- return $this->searchAndReplaceDetails;
6968
- }
6969
-
6970
- public function setSelfLink($selfLink)
6971
- {
6972
- $this->selfLink = $selfLink;
6973
- }
6974
-
6975
- public function getSelfLink()
6976
- {
6977
- return $this->selfLink;
6978
- }
6979
-
6980
- public function setType($type)
6981
- {
6982
- $this->type = $type;
6983
- }
6984
-
6985
- public function getType()
6986
- {
6987
- return $this->type;
6988
- }
6989
-
6990
- public function setUpdated($updated)
6991
- {
6992
- $this->updated = $updated;
6993
- }
6994
-
6995
- public function getUpdated()
6996
- {
6997
- return $this->updated;
6998
- }
6999
-
7000
- public function setUppercaseDetails(Google_Service_Analytics_FilterUppercaseDetails $uppercaseDetails)
7001
- {
7002
- $this->uppercaseDetails = $uppercaseDetails;
7003
- }
7004
-
7005
- public function getUppercaseDetails()
7006
- {
7007
- return $this->uppercaseDetails;
7008
- }
7009
- }
7010
-
7011
- class Google_Service_Analytics_FilterAdvancedDetails extends Google_Model
7012
- {
7013
-
7014
- protected $internal_gapi_mappings = array();
7015
-
7016
- public $caseSensitive;
7017
-
7018
- public $extractA;
7019
-
7020
- public $extractB;
7021
-
7022
- public $fieldA;
7023
-
7024
- public $fieldARequired;
7025
-
7026
- public $fieldB;
7027
-
7028
- public $fieldBRequired;
7029
-
7030
- public $outputConstructor;
7031
-
7032
- public $outputToField;
7033
-
7034
- public $overrideOutputField;
7035
-
7036
- public function setCaseSensitive($caseSensitive)
7037
- {
7038
- $this->caseSensitive = $caseSensitive;
7039
- }
7040
-
7041
- public function getCaseSensitive()
7042
- {
7043
- return $this->caseSensitive;
7044
- }
7045
-
7046
- public function setExtractA($extractA)
7047
- {
7048
- $this->extractA = $extractA;
7049
- }
7050
-
7051
- public function getExtractA()
7052
- {
7053
- return $this->extractA;
7054
- }
7055
-
7056
- public function setExtractB($extractB)
7057
- {
7058
- $this->extractB = $extractB;
7059
- }
7060
-
7061
- public function getExtractB()
7062
- {
7063
- return $this->extractB;
7064
- }
7065
-
7066
- public function setFieldA($fieldA)
7067
- {
7068
- $this->fieldA = $fieldA;
7069
- }
7070
-
7071
- public function getFieldA()
7072
- {
7073
- return $this->fieldA;
7074
- }
7075
-
7076
- public function setFieldARequired($fieldARequired)
7077
- {
7078
- $this->fieldARequired = $fieldARequired;
7079
- }
7080
-
7081
- public function getFieldARequired()
7082
- {
7083
- return $this->fieldARequired;
7084
- }
7085
-
7086
- public function setFieldB($fieldB)
7087
- {
7088
- $this->fieldB = $fieldB;
7089
- }
7090
-
7091
- public function getFieldB()
7092
- {
7093
- return $this->fieldB;
7094
- }
7095
-
7096
- public function setFieldBRequired($fieldBRequired)
7097
- {
7098
- $this->fieldBRequired = $fieldBRequired;
7099
- }
7100
-
7101
- public function getFieldBRequired()
7102
- {
7103
- return $this->fieldBRequired;
7104
- }
7105
-
7106
- public function setOutputConstructor($outputConstructor)
7107
- {
7108
- $this->outputConstructor = $outputConstructor;
7109
- }
7110
-
7111
- public function getOutputConstructor()
7112
- {
7113
- return $this->outputConstructor;
7114
- }
7115
-
7116
- public function setOutputToField($outputToField)
7117
- {
7118
- $this->outputToField = $outputToField;
7119
- }
7120
-
7121
- public function getOutputToField()
7122
- {
7123
- return $this->outputToField;
7124
- }
7125
-
7126
- public function setOverrideOutputField($overrideOutputField)
7127
- {
7128
- $this->overrideOutputField = $overrideOutputField;
7129
- }
7130
-
7131
- public function getOverrideOutputField()
7132
- {
7133
- return $this->overrideOutputField;
7134
- }
7135
- }
7136
-
7137
- class Google_Service_Analytics_FilterExpression extends Google_Model
7138
- {
7139
-
7140
- protected $internal_gapi_mappings = array();
7141
-
7142
- public $caseSensitive;
7143
-
7144
- public $expressionValue;
7145
-
7146
- public $field;
7147
-
7148
- public $kind;
7149
-
7150
- public $matchType;
7151
-
7152
- public function setCaseSensitive($caseSensitive)
7153
- {
7154
- $this->caseSensitive = $caseSensitive;
7155
- }
7156
-
7157
- public function getCaseSensitive()
7158
- {
7159
- return $this->caseSensitive;
7160
- }
7161
-
7162
- public function setExpressionValue($expressionValue)
7163
- {
7164
- $this->expressionValue = $expressionValue;
7165
- }
7166
-
7167
- public function getExpressionValue()
7168
- {
7169
- return $this->expressionValue;
7170
- }
7171
-
7172
- public function setField($field)
7173
- {
7174
- $this->field = $field;
7175
- }
7176
-
7177
- public function getField()
7178
- {
7179
- return $this->field;
7180
- }
7181
-
7182
- public function setKind($kind)
7183
- {
7184
- $this->kind = $kind;
7185
- }
7186
-
7187
- public function getKind()
7188
- {
7189
- return $this->kind;
7190
- }
7191
-
7192
- public function setMatchType($matchType)
7193
- {
7194
- $this->matchType = $matchType;
7195
- }
7196
-
7197
- public function getMatchType()
7198
- {
7199
- return $this->matchType;
7200
- }
7201
- }
7202
-
7203
- class Google_Service_Analytics_FilterLowercaseDetails extends Google_Model
7204
- {
7205
-
7206
- protected $internal_gapi_mappings = array();
7207
-
7208
- public $field;
7209
-
7210
- public function setField($field)
7211
- {
7212
- $this->field = $field;
7213
- }
7214
-
7215
- public function getField()
7216
- {
7217
- return $this->field;
7218
- }
7219
- }
7220
-
7221
- class Google_Service_Analytics_FilterParentLink extends Google_Model
7222
- {
7223
-
7224
- protected $internal_gapi_mappings = array();
7225
-
7226
- public $href;
7227
-
7228
- public $type;
7229
-
7230
- public function setHref($href)
7231
- {
7232
- $this->href = $href;
7233
- }
7234
-
7235
- public function getHref()
7236
- {
7237
- return $this->href;
7238
- }
7239
-
7240
- public function setType($type)
7241
- {
7242
- $this->type = $type;
7243
- }
7244
-
7245
- public function getType()
7246
- {
7247
- return $this->type;
7248
- }
7249
- }
7250
-
7251
- class Google_Service_Analytics_FilterRef extends Google_Model
7252
- {
7253
-
7254
- protected $internal_gapi_mappings = array();
7255
-
7256
- public $accountId;
7257
-
7258
- public $href;
7259
-
7260
- public $id;
7261
-
7262
- public $kind;
7263
-
7264
- public $name;
7265
-
7266
- public function setAccountId($accountId)
7267
- {
7268
- $this->accountId = $accountId;
7269
- }
7270
-
7271
- public function getAccountId()
7272
- {
7273
- return $this->accountId;
7274
- }
7275
-
7276
- public function setHref($href)
7277
- {
7278
- $this->href = $href;
7279
- }
7280
-
7281
- public function getHref()
7282
- {
7283
- return $this->href;
7284
- }
7285
-
7286
- public function setId($id)
7287
- {
7288
- $this->id = $id;
7289
- }
7290
-
7291
- public function getId()
7292
- {
7293
- return $this->id;
7294
- }
7295
-
7296
- public function setKind($kind)
7297
- {
7298
- $this->kind = $kind;
7299
- }
7300
-
7301
- public function getKind()
7302
- {
7303
- return $this->kind;
7304
- }
7305
-
7306
- public function setName($name)
7307
- {
7308
- $this->name = $name;
7309
- }
7310
-
7311
- public function getName()
7312
- {
7313
- return $this->name;
7314
- }
7315
- }
7316
-
7317
- class Google_Service_Analytics_FilterSearchAndReplaceDetails extends Google_Model
7318
- {
7319
-
7320
- protected $internal_gapi_mappings = array();
7321
-
7322
- public $caseSensitive;
7323
-
7324
- public $field;
7325
-
7326
- public $replaceString;
7327
-
7328
- public $searchString;
7329
-
7330
- public function setCaseSensitive($caseSensitive)
7331
- {
7332
- $this->caseSensitive = $caseSensitive;
7333
- }
7334
-
7335
- public function getCaseSensitive()
7336
- {
7337
- return $this->caseSensitive;
7338
- }
7339
-
7340
- public function setField($field)
7341
- {
7342
- $this->field = $field;
7343
- }
7344
-
7345
- public function getField()
7346
- {
7347
- return $this->field;
7348
- }
7349
-
7350
- public function setReplaceString($replaceString)
7351
- {
7352
- $this->replaceString = $replaceString;
7353
- }
7354
-
7355
- public function getReplaceString()
7356
- {
7357
- return $this->replaceString;
7358
- }
7359
-
7360
- public function setSearchString($searchString)
7361
- {
7362
- $this->searchString = $searchString;
7363
- }
7364
-
7365
- public function getSearchString()
7366
- {
7367
- return $this->searchString;
7368
- }
7369
- }
7370
-
7371
- class Google_Service_Analytics_FilterUppercaseDetails extends Google_Model
7372
- {
7373
-
7374
- protected $internal_gapi_mappings = array();
7375
-
7376
- public $field;
7377
-
7378
- public function setField($field)
7379
- {
7380
- $this->field = $field;
7381
- }
7382
-
7383
- public function getField()
7384
- {
7385
- return $this->field;
7386
- }
7387
- }
7388
-
7389
- class Google_Service_Analytics_Filters extends Google_Collection
7390
- {
7391
-
7392
- protected $collection_key = 'items';
7393
-
7394
- protected $internal_gapi_mappings = array();
7395
-
7396
- protected $itemsType = 'Google_Service_Analytics_Filter';
7397
-
7398
- protected $itemsDataType = 'array';
7399
-
7400
- public $itemsPerPage;
7401
-
7402
- public $kind;
7403
-
7404
- public $nextLink;
7405
-
7406
- public $previousLink;
7407
-
7408
- public $startIndex;
7409
-
7410
- public $totalResults;
7411
-
7412
- public $username;
7413
-
7414
- public function setItems($items)
7415
- {
7416
- $this->items = $items;
7417
- }
7418
-
7419
- public function getItems()
7420
- {
7421
- return $this->items;
7422
- }
7423
-
7424
- public function setItemsPerPage($itemsPerPage)
7425
- {
7426
- $this->itemsPerPage = $itemsPerPage;
7427
- }
7428
-
7429
- public function getItemsPerPage()
7430
- {
7431
- return $this->itemsPerPage;
7432
- }
7433
-
7434
- public function setKind($kind)
7435
- {
7436
- $this->kind = $kind;
7437
- }
7438
-
7439
- public function getKind()
7440
- {
7441
- return $this->kind;
7442
- }
7443
-
7444
- public function setNextLink($nextLink)
7445
- {
7446
- $this->nextLink = $nextLink;
7447
- }
7448
-
7449
- public function getNextLink()
7450
- {
7451
- return $this->nextLink;
7452
- }
7453
-
7454
- public function setPreviousLink($previousLink)
7455
- {
7456
- $this->previousLink = $previousLink;
7457
- }
7458
-
7459
- public function getPreviousLink()
7460
- {
7461
- return $this->previousLink;
7462
- }
7463
-
7464
- public function setStartIndex($startIndex)
7465
- {
7466
- $this->startIndex = $startIndex;
7467
- }
7468
-
7469
- public function getStartIndex()
7470
- {
7471
- return $this->startIndex;
7472
- }
7473
-
7474
- public function setTotalResults($totalResults)
7475
- {
7476
- $this->totalResults = $totalResults;
7477
- }
7478
-
7479
- public function getTotalResults()
7480
- {
7481
- return $this->totalResults;
7482
- }
7483
-
7484
- public function setUsername($username)
7485
- {
7486
- $this->username = $username;
7487
- }
7488
-
7489
- public function getUsername()
7490
- {
7491
- return $this->username;
7492
- }
7493
- }
7494
-
7495
- class Google_Service_Analytics_GaData extends Google_Collection
7496
- {
7497
-
7498
- protected $collection_key = 'rows';
7499
-
7500
- protected $internal_gapi_mappings = array();
7501
-
7502
- protected $columnHeadersType = 'Google_Service_Analytics_GaDataColumnHeaders';
7503
-
7504
- protected $columnHeadersDataType = 'array';
7505
-
7506
- public $containsSampledData;
7507
-
7508
- protected $dataTableType = 'Google_Service_Analytics_GaDataDataTable';
7509
-
7510
- protected $dataTableDataType = '';
7511
-
7512
- public $id;
7513
-
7514
- public $itemsPerPage;
7515
-
7516
- public $kind;
7517
-
7518
- public $nextLink;
7519
-
7520
- public $previousLink;
7521
-
7522
- protected $profileInfoType = 'Google_Service_Analytics_GaDataProfileInfo';
7523
-
7524
- protected $profileInfoDataType = '';
7525
-
7526
- protected $queryType = 'Google_Service_Analytics_GaDataQuery';
7527
-
7528
- protected $queryDataType = '';
7529
-
7530
- public $rows;
7531
-
7532
- public $sampleSize;
7533
-
7534
- public $sampleSpace;
7535
-
7536
- public $selfLink;
7537
-
7538
- public $totalResults;
7539
-
7540
- public $totalsForAllResults;
7541
-
7542
- public function setColumnHeaders($columnHeaders)
7543
- {
7544
- $this->columnHeaders = $columnHeaders;
7545
- }
7546
-
7547
- public function getColumnHeaders()
7548
- {
7549
- return $this->columnHeaders;
7550
- }
7551
-
7552
- public function setContainsSampledData($containsSampledData)
7553
- {
7554
- $this->containsSampledData = $containsSampledData;
7555
- }
7556
-
7557
- public function getContainsSampledData()
7558
- {
7559
- return $this->containsSampledData;
7560
- }
7561
-
7562
- public function setDataTable(Google_Service_Analytics_GaDataDataTable $dataTable)
7563
- {
7564
- $this->dataTable = $dataTable;
7565
- }
7566
-
7567
- public function getDataTable()
7568
- {
7569
- return $this->dataTable;
7570
- }
7571
-
7572
- public function setId($id)
7573
- {
7574
- $this->id = $id;
7575
- }
7576
-
7577
- public function getId()
7578
- {
7579
- return $this->id;
7580
- }
7581
-
7582
- public function setItemsPerPage($itemsPerPage)
7583
- {
7584
- $this->itemsPerPage = $itemsPerPage;
7585
- }
7586
-
7587
- public function getItemsPerPage()
7588
- {
7589
- return $this->itemsPerPage;
7590
- }
7591
-
7592
- public function setKind($kind)
7593
- {
7594
- $this->kind = $kind;
7595
- }
7596
-
7597
- public function getKind()
7598
- {
7599
- return $this->kind;
7600
- }
7601
-
7602
- public function setNextLink($nextLink)
7603
- {
7604
- $this->nextLink = $nextLink;
7605
- }
7606
-
7607
- public function getNextLink()
7608
- {
7609
- return $this->nextLink;
7610
- }
7611
-
7612
- public function setPreviousLink($previousLink)
7613
- {
7614
- $this->previousLink = $previousLink;
7615
- }
7616
-
7617
- public function getPreviousLink()
7618
- {
7619
- return $this->previousLink;
7620
- }
7621
-
7622
- public function setProfileInfo(Google_Service_Analytics_GaDataProfileInfo $profileInfo)
7623
- {
7624
- $this->profileInfo = $profileInfo;
7625
- }
7626
-
7627
- public function getProfileInfo()
7628
- {
7629
- return $this->profileInfo;
7630
- }
7631
-
7632
- public function setQuery(Google_Service_Analytics_GaDataQuery $query)
7633
- {
7634
- $this->query = $query;
7635
- }
7636
-
7637
- public function getQuery()
7638
- {
7639
- return $this->query;
7640
- }
7641
-
7642
- public function setRows($rows)
7643
- {
7644
- $this->rows = $rows;
7645
- }
7646
-
7647
- public function getRows()
7648
- {
7649
- return $this->rows;
7650
- }
7651
-
7652
- public function setSampleSize($sampleSize)
7653
- {
7654
- $this->sampleSize = $sampleSize;
7655
- }
7656
-
7657
- public function getSampleSize()
7658
- {
7659
- return $this->sampleSize;
7660
- }
7661
-
7662
- public function setSampleSpace($sampleSpace)
7663
- {
7664
- $this->sampleSpace = $sampleSpace;
7665
- }
7666
-
7667
- public function getSampleSpace()
7668
- {
7669
- return $this->sampleSpace;
7670
- }
7671
-
7672
- public function setSelfLink($selfLink)
7673
- {
7674
- $this->selfLink = $selfLink;
7675
- }
7676
-
7677
- public function getSelfLink()
7678
- {
7679
- return $this->selfLink;
7680
- }
7681
-
7682
- public function setTotalResults($totalResults)
7683
- {
7684
- $this->totalResults = $totalResults;
7685
- }
7686
-
7687
- public function getTotalResults()
7688
- {
7689
- return $this->totalResults;
7690
- }
7691
-
7692
- public function setTotalsForAllResults($totalsForAllResults)
7693
- {
7694
- $this->totalsForAllResults = $totalsForAllResults;
7695
- }
7696
-
7697
- public function getTotalsForAllResults()
7698
- {
7699
- return $this->totalsForAllResults;
7700
- }
7701
- }
7702
-
7703
- class Google_Service_Analytics_GaDataColumnHeaders extends Google_Model
7704
- {
7705
-
7706
- protected $internal_gapi_mappings = array();
7707
-
7708
- public $columnType;
7709
-
7710
- public $dataType;
7711
-
7712
- public $name;
7713
-
7714
- public function setColumnType($columnType)
7715
- {
7716
- $this->columnType = $columnType;
7717
- }
7718
-
7719
- public function getColumnType()
7720
- {
7721
- return $this->columnType;
7722
- }
7723
-
7724
- public function setDataType($dataType)
7725
- {
7726
- $this->dataType = $dataType;
7727
- }
7728
-
7729
- public function getDataType()
7730
- {
7731
- return $this->dataType;
7732
- }
7733
-
7734
- public function setName($name)
7735
- {
7736
- $this->name = $name;
7737
- }
7738
-
7739
- public function getName()
7740
- {
7741
- return $this->name;
7742
- }
7743
- }
7744
-
7745
- class Google_Service_Analytics_GaDataDataTable extends Google_Collection
7746
- {
7747
-
7748
- protected $collection_key = 'rows';
7749
-
7750
- protected $internal_gapi_mappings = array();
7751
-
7752
- protected $colsType = 'Google_Service_Analytics_GaDataDataTableCols';
7753
-
7754
- protected $colsDataType = 'array';
7755
-
7756
- protected $rowsType = 'Google_Service_Analytics_GaDataDataTableRows';
7757
-
7758
- protected $rowsDataType = 'array';
7759
-
7760
- public function setCols($cols)
7761
- {
7762
- $this->cols = $cols;
7763
- }
7764
-
7765
- public function getCols()
7766
- {
7767
- return $this->cols;
7768
- }
7769
-
7770
- public function setRows($rows)
7771
- {
7772
- $this->rows = $rows;
7773
- }
7774
-
7775
- public function getRows()
7776
- {
7777
- return $this->rows;
7778
- }
7779
- }
7780
-
7781
- class Google_Service_Analytics_GaDataDataTableCols extends Google_Model
7782
- {
7783
-
7784
- protected $internal_gapi_mappings = array();
7785
-
7786
- public $id;
7787
-
7788
- public $label;
7789
-
7790
- public $type;
7791
-
7792
- public function setId($id)
7793
- {
7794
- $this->id = $id;
7795
- }
7796
-
7797
- public function getId()
7798
- {
7799
- return $this->id;
7800
- }
7801
-
7802
- public function setLabel($label)
7803
- {
7804
- $this->label = $label;
7805
- }
7806
-
7807
- public function getLabel()
7808
- {
7809
- return $this->label;
7810
- }
7811
-
7812
- public function setType($type)
7813
- {
7814
- $this->type = $type;
7815
- }
7816
-
7817
- public function getType()
7818
- {
7819
- return $this->type;
7820
- }
7821
- }
7822
-
7823
- class Google_Service_Analytics_GaDataDataTableRows extends Google_Collection
7824
- {
7825
-
7826
- protected $collection_key = 'c';
7827
-
7828
- protected $internal_gapi_mappings = array();
7829
-
7830
- protected $cType = 'Google_Service_Analytics_GaDataDataTableRowsC';
7831
-
7832
- protected $cDataType = 'array';
7833
-
7834
- public function setC($c)
7835
- {
7836
- $this->c = $c;
7837
- }
7838
-
7839
- public function getC()
7840
- {
7841
- return $this->c;
7842
- }
7843
- }
7844
-
7845
- class Google_Service_Analytics_GaDataDataTableRowsC extends Google_Model
7846
- {
7847
-
7848
- protected $internal_gapi_mappings = array();
7849
-
7850
- public $v;
7851
-
7852
- public function setV($v)
7853
- {
7854
- $this->v = $v;
7855
- }
7856
-
7857
- public function getV()
7858
- {
7859
- return $this->v;
7860
- }
7861
- }
7862
-
7863
- class Google_Service_Analytics_GaDataProfileInfo extends Google_Model
7864
- {
7865
-
7866
- protected $internal_gapi_mappings = array();
7867
-
7868
- public $accountId;
7869
-
7870
- public $internalWebPropertyId;
7871
-
7872
- public $profileId;
7873
-
7874
- public $profileName;
7875
-
7876
- public $tableId;
7877
-
7878
- public $webPropertyId;
7879
-
7880
- public function setAccountId($accountId)
7881
- {
7882
- $this->accountId = $accountId;
7883
- }
7884
-
7885
- public function getAccountId()
7886
- {
7887
- return $this->accountId;
7888
- }
7889
-
7890
- public function setInternalWebPropertyId($internalWebPropertyId)
7891
- {
7892
- $this->internalWebPropertyId = $internalWebPropertyId;
7893
- }
7894
-
7895
- public function getInternalWebPropertyId()
7896
- {
7897
- return $this->internalWebPropertyId;
7898
- }
7899
-
7900
- public function setProfileId($profileId)
7901
- {
7902
- $this->profileId = $profileId;
7903
- }
7904
-
7905
- public function getProfileId()
7906
- {
7907
- return $this->profileId;
7908
- }
7909
-
7910
- public function setProfileName($profileName)
7911
- {
7912
- $this->profileName = $profileName;
7913
- }
7914
-
7915
- public function getProfileName()
7916
- {
7917
- return $this->profileName;
7918
- }
7919
-
7920
- public function setTableId($tableId)
7921
- {
7922
- $this->tableId = $tableId;
7923
- }
7924
-
7925
- public function getTableId()
7926
- {
7927
- return $this->tableId;
7928
- }
7929
-
7930
- public function setWebPropertyId($webPropertyId)
7931
- {
7932
- $this->webPropertyId = $webPropertyId;
7933
- }
7934
-
7935
- public function getWebPropertyId()
7936
- {
7937
- return $this->webPropertyId;
7938
- }
7939
- }
7940
-
7941
- class Google_Service_Analytics_GaDataQuery extends Google_Collection
7942
- {
7943
-
7944
- protected $collection_key = 'sort';
7945
-
7946
- protected $internal_gapi_mappings = array(
7947
- "endDate" => "end-date",
7948
- "maxResults" => "max-results",
7949
- "startDate" => "start-date",
7950
- "startIndex" => "start-index"
7951
- );
7952
-
7953
- public $dimensions;
7954
-
7955
- public $endDate;
7956
-
7957
- public $filters;
7958
-
7959
- public $ids;
7960
-
7961
- public $maxResults;
7962
-
7963
- public $metrics;
7964
-
7965
- public $samplingLevel;
7966
-
7967
- public $segment;
7968
-
7969
- public $sort;
7970
-
7971
- public $startDate;
7972
-
7973
- public $startIndex;
7974
-
7975
- public function setDimensions($dimensions)
7976
- {
7977
- $this->dimensions = $dimensions;
7978
- }
7979
-
7980
- public function getDimensions()
7981
- {
7982
- return $this->dimensions;
7983
- }
7984
-
7985
- public function setEndDate($endDate)
7986
- {
7987
- $this->endDate = $endDate;
7988
- }
7989
-
7990
- public function getEndDate()
7991
- {
7992
- return $this->endDate;
7993
- }
7994
-
7995
- public function setFilters($filters)
7996
- {
7997
- $this->filters = $filters;
7998
- }
7999
-
8000
- public function getFilters()
8001
- {
8002
- return $this->filters;
8003
- }
8004
-
8005
- public function setIds($ids)
8006
- {
8007
- $this->ids = $ids;
8008
- }
8009
-
8010
- public function getIds()
8011
- {
8012
- return $this->ids;
8013
- }
8014
-
8015
- public function setMaxResults($maxResults)
8016
- {
8017
- $this->maxResults = $maxResults;
8018
- }
8019
-
8020
- public function getMaxResults()
8021
- {
8022
- return $this->maxResults;
8023
- }
8024
-
8025
- public function setMetrics($metrics)
8026
- {
8027
- $this->metrics = $metrics;
8028
- }
8029
-
8030
- public function getMetrics()
8031
- {
8032
- return $this->metrics;
8033
- }
8034
-
8035
- public function setSamplingLevel($samplingLevel)
8036
- {
8037
- $this->samplingLevel = $samplingLevel;
8038
- }
8039
-
8040
- public function getSamplingLevel()
8041
- {
8042
- return $this->samplingLevel;
8043
- }
8044
-
8045
- public function setSegment($segment)
8046
- {
8047
- $this->segment = $segment;
8048
- }
8049
-
8050
- public function getSegment()
8051
- {
8052
- return $this->segment;
8053
- }
8054
-
8055
- public function setSort($sort)
8056
- {
8057
- $this->sort = $sort;
8058
- }
8059
-
8060
- public function getSort()
8061
- {
8062
- return $this->sort;
8063
- }
8064
-
8065
- public function setStartDate($startDate)
8066
- {
8067
- $this->startDate = $startDate;
8068
- }
8069
-
8070
- public function getStartDate()
8071
- {
8072
- return $this->startDate;
8073
- }
8074
-
8075
- public function setStartIndex($startIndex)
8076
- {
8077
- $this->startIndex = $startIndex;
8078
- }
8079
-
8080
- public function getStartIndex()
8081
- {
8082
- return $this->startIndex;
8083
- }
8084
- }
8085
-
8086
- class Google_Service_Analytics_GaDataTotalsForAllResults extends Google_Model
8087
- {
8088
- }
8089
-
8090
- class Google_Service_Analytics_Goal extends Google_Model
8091
- {
8092
-
8093
- protected $internal_gapi_mappings = array();
8094
-
8095
- public $accountId;
8096
-
8097
- public $active;
8098
-
8099
- public $created;
8100
-
8101
- protected $eventDetailsType = 'Google_Service_Analytics_GoalEventDetails';
8102
-
8103
- protected $eventDetailsDataType = '';
8104
-
8105
- public $id;
8106
-
8107
- public $internalWebPropertyId;
8108
-
8109
- public $kind;
8110
-
8111
- public $name;
8112
-
8113
- protected $parentLinkType = 'Google_Service_Analytics_GoalParentLink';
8114
-
8115
- protected $parentLinkDataType = '';
8116
-
8117
- public $profileId;
8118
-
8119
- public $selfLink;
8120
-
8121
- public $type;
8122
-
8123
- public $updated;
8124
-
8125
- protected $urlDestinationDetailsType = 'Google_Service_Analytics_GoalUrlDestinationDetails';
8126
-
8127
- protected $urlDestinationDetailsDataType = '';
8128
-
8129
- public $value;
8130
-
8131
- protected $visitNumPagesDetailsType = 'Google_Service_Analytics_GoalVisitNumPagesDetails';
8132
-
8133
- protected $visitNumPagesDetailsDataType = '';
8134
-
8135
- protected $visitTimeOnSiteDetailsType = 'Google_Service_Analytics_GoalVisitTimeOnSiteDetails';
8136
-
8137
- protected $visitTimeOnSiteDetailsDataType = '';
8138
-
8139
- public $webPropertyId;
8140
-
8141
- public function setAccountId($accountId)
8142
- {
8143
- $this->accountId = $accountId;
8144
- }
8145
-
8146
- public function getAccountId()
8147
- {
8148
- return $this->accountId;
8149
- }
8150
-
8151
- public function setActive($active)
8152
- {
8153
- $this->active = $active;
8154
- }
8155
-
8156
- public function getActive()
8157
- {
8158
- return $this->active;
8159
- }
8160
-
8161
- public function setCreated($created)
8162
- {
8163
- $this->created = $created;
8164
- }
8165
-
8166
- public function getCreated()
8167
- {
8168
- return $this->created;
8169
- }
8170
-
8171
- public function setEventDetails(Google_Service_Analytics_GoalEventDetails $eventDetails)
8172
- {
8173
- $this->eventDetails = $eventDetails;
8174
- }
8175
-
8176
- public function getEventDetails()
8177
- {
8178
- return $this->eventDetails;
8179
- }
8180
-
8181
- public function setId($id)
8182
- {
8183
- $this->id = $id;
8184
- }
8185
-
8186
- public function getId()
8187
- {
8188
- return $this->id;
8189
- }
8190
-
8191
- public function setInternalWebPropertyId($internalWebPropertyId)
8192
- {
8193
- $this->internalWebPropertyId = $internalWebPropertyId;
8194
- }
8195
-
8196
- public function getInternalWebPropertyId()
8197
- {
8198
- return $this->internalWebPropertyId;
8199
- }
8200
-
8201
- public function setKind($kind)
8202
- {
8203
- $this->kind = $kind;
8204
- }
8205
-
8206
- public function getKind()
8207
- {
8208
- return $this->kind;
8209
- }
8210
-
8211
- public function setName($name)
8212
- {
8213
- $this->name = $name;
8214
- }
8215
-
8216
- public function getName()
8217
- {
8218
- return $this->name;
8219
- }
8220
-
8221
- public function setParentLink(Google_Service_Analytics_GoalParentLink $parentLink)
8222
- {
8223
- $this->parentLink = $parentLink;
8224
- }
8225
-
8226
- public function getParentLink()
8227
- {
8228
- return $this->parentLink;
8229
- }
8230
-
8231
- public function setProfileId($profileId)
8232
- {
8233
- $this->profileId = $profileId;
8234
- }
8235
-
8236
- public function getProfileId()
8237
- {
8238
- return $this->profileId;
8239
- }
8240
-
8241
- public function setSelfLink($selfLink)
8242
- {
8243
- $this->selfLink = $selfLink;
8244
- }
8245
-
8246
- public function getSelfLink()
8247
- {
8248
- return $this->selfLink;
8249
- }
8250
-
8251
- public function setType($type)
8252
- {
8253
- $this->type = $type;
8254
- }
8255
-
8256
- public function getType()
8257
- {
8258
- return $this->type;
8259
- }
8260
-
8261
- public function setUpdated($updated)
8262
- {
8263
- $this->updated = $updated;
8264
- }
8265
-
8266
- public function getUpdated()
8267
- {
8268
- return $this->updated;
8269
- }
8270
-
8271
- public function setUrlDestinationDetails(Google_Service_Analytics_GoalUrlDestinationDetails $urlDestinationDetails)
8272
- {
8273
- $this->urlDestinationDetails = $urlDestinationDetails;
8274
- }
8275
-
8276
- public function getUrlDestinationDetails()
8277
- {
8278
- return $this->urlDestinationDetails;
8279
- }
8280
-
8281
- public function setValue($value)
8282
- {
8283
- $this->value = $value;
8284
- }
8285
-
8286
- public function getValue()
8287
- {
8288
- return $this->value;
8289
- }
8290
-
8291
- public function setVisitNumPagesDetails(Google_Service_Analytics_GoalVisitNumPagesDetails $visitNumPagesDetails)
8292
- {
8293
- $this->visitNumPagesDetails = $visitNumPagesDetails;
8294
- }
8295
-
8296
- public function getVisitNumPagesDetails()
8297
- {
8298
- return $this->visitNumPagesDetails;
8299
- }
8300
-
8301
- public function setVisitTimeOnSiteDetails(Google_Service_Analytics_GoalVisitTimeOnSiteDetails $visitTimeOnSiteDetails)
8302
- {
8303
- $this->visitTimeOnSiteDetails = $visitTimeOnSiteDetails;
8304
- }
8305
-
8306
- public function getVisitTimeOnSiteDetails()
8307
- {
8308
- return $this->visitTimeOnSiteDetails;
8309
- }
8310
-
8311
- public function setWebPropertyId($webPropertyId)
8312
- {
8313
- $this->webPropertyId = $webPropertyId;
8314
- }
8315
-
8316
- public function getWebPropertyId()
8317
- {
8318
- return $this->webPropertyId;
8319
- }
8320
- }
8321
-
8322
- class Google_Service_Analytics_GoalEventDetails extends Google_Collection
8323
- {
8324
-
8325
- protected $collection_key = 'eventConditions';
8326
-
8327
- protected $internal_gapi_mappings = array();
8328
-
8329
- protected $eventConditionsType = 'Google_Service_Analytics_GoalEventDetailsEventConditions';
8330
-
8331
- protected $eventConditionsDataType = 'array';
8332
-
8333
- public $useEventValue;
8334
-
8335
- public function setEventConditions($eventConditions)
8336
- {
8337
- $this->eventConditions = $eventConditions;
8338
- }
8339
-
8340
- public function getEventConditions()
8341
- {
8342
- return $this->eventConditions;
8343
- }
8344
-
8345
- public function setUseEventValue($useEventValue)
8346
- {
8347
- $this->useEventValue = $useEventValue;
8348
- }
8349
-
8350
- public function getUseEventValue()
8351
- {
8352
- return $this->useEventValue;
8353
- }
8354
- }
8355
-
8356
- class Google_Service_Analytics_GoalEventDetailsEventConditions extends Google_Model
8357
- {
8358
-
8359
- protected $internal_gapi_mappings = array();
8360
-
8361
- public $comparisonType;
8362
-
8363
- public $comparisonValue;
8364
-
8365
- public $expression;
8366
-
8367
- public $matchType;
8368
-
8369
- public $type;
8370
-
8371
- public function setComparisonType($comparisonType)
8372
- {
8373
- $this->comparisonType = $comparisonType;
8374
- }
8375
-
8376
- public function getComparisonType()
8377
- {
8378
- return $this->comparisonType;
8379
- }
8380
-
8381
- public function setComparisonValue($comparisonValue)
8382
- {
8383
- $this->comparisonValue = $comparisonValue;
8384
- }
8385
-
8386
- public function getComparisonValue()
8387
- {
8388
- return $this->comparisonValue;
8389
- }
8390
-
8391
- public function setExpression($expression)
8392
- {
8393
- $this->expression = $expression;
8394
- }
8395
-
8396
- public function getExpression()
8397
- {
8398
- return $this->expression;
8399
- }
8400
-
8401
- public function setMatchType($matchType)
8402
- {
8403
- $this->matchType = $matchType;
8404
- }
8405
-
8406
- public function getMatchType()
8407
- {
8408
- return $this->matchType;
8409
- }
8410
-
8411
- public function setType($type)
8412
- {
8413
- $this->type = $type;
8414
- }
8415
-
8416
- public function getType()
8417
- {
8418
- return $this->type;
8419
- }
8420
- }
8421
-
8422
- class Google_Service_Analytics_GoalParentLink extends Google_Model
8423
- {
8424
-
8425
- protected $internal_gapi_mappings = array();
8426
-
8427
- public $href;
8428
-
8429
- public $type;
8430
-
8431
- public function setHref($href)
8432
- {
8433
- $this->href = $href;
8434
- }
8435
-
8436
- public function getHref()
8437
- {
8438
- return $this->href;
8439
- }
8440
-
8441
- public function setType($type)
8442
- {
8443
- $this->type = $type;
8444
- }
8445
-
8446
- public function getType()
8447
- {
8448
- return $this->type;
8449
- }
8450
- }
8451
-
8452
- class Google_Service_Analytics_GoalUrlDestinationDetails extends Google_Collection
8453
- {
8454
-
8455
- protected $collection_key = 'steps';
8456
-
8457
- protected $internal_gapi_mappings = array();
8458
-
8459
- public $caseSensitive;
8460
-
8461
- public $firstStepRequired;
8462
-
8463
- public $matchType;
8464
-
8465
- protected $stepsType = 'Google_Service_Analytics_GoalUrlDestinationDetailsSteps';
8466
-
8467
- protected $stepsDataType = 'array';
8468
-
8469
- public $url;
8470
-
8471
- public function setCaseSensitive($caseSensitive)
8472
- {
8473
- $this->caseSensitive = $caseSensitive;
8474
- }
8475
-
8476
- public function getCaseSensitive()
8477
- {
8478
- return $this->caseSensitive;
8479
- }
8480
-
8481
- public function setFirstStepRequired($firstStepRequired)
8482
- {
8483
- $this->firstStepRequired = $firstStepRequired;
8484
- }
8485
-
8486
- public function getFirstStepRequired()
8487
- {
8488
- return $this->firstStepRequired;
8489
- }
8490
-
8491
- public function setMatchType($matchType)
8492
- {
8493
- $this->matchType = $matchType;
8494
- }
8495
-
8496
- public function getMatchType()
8497
- {
8498
- return $this->matchType;
8499
- }
8500
-
8501
- public function setSteps($steps)
8502
- {
8503
- $this->steps = $steps;
8504
- }
8505
-
8506
- public function getSteps()
8507
- {
8508
- return $this->steps;
8509
- }
8510
-
8511
- public function setUrl($url)
8512
- {
8513
- $this->url = $url;
8514
- }
8515
-
8516
- public function getUrl()
8517
- {
8518
- return $this->url;
8519
- }
8520
- }
8521
-
8522
- class Google_Service_Analytics_GoalUrlDestinationDetailsSteps extends Google_Model
8523
- {
8524
-
8525
- protected $internal_gapi_mappings = array();
8526
-
8527
- public $name;
8528
-
8529
- public $number;
8530
-
8531
- public $url;
8532
-
8533
- public function setName($name)
8534
- {
8535
- $this->name = $name;
8536
- }
8537
-
8538
- public function getName()
8539
- {
8540
- return $this->name;
8541
- }
8542
-
8543
- public function setNumber($number)
8544
- {
8545
- $this->number = $number;
8546
- }
8547
-
8548
- public function getNumber()
8549
- {
8550
- return $this->number;
8551
- }
8552
-
8553
- public function setUrl($url)
8554
- {
8555
- $this->url = $url;
8556
- }
8557
-
8558
- public function getUrl()
8559
- {
8560
- return $this->url;
8561
- }
8562
- }
8563
-
8564
- class Google_Service_Analytics_GoalVisitNumPagesDetails extends Google_Model
8565
- {
8566
-
8567
- protected $internal_gapi_mappings = array();
8568
-
8569
- public $comparisonType;
8570
-
8571
- public $comparisonValue;
8572
-
8573
- public function setComparisonType($comparisonType)
8574
- {
8575
- $this->comparisonType = $comparisonType;
8576
- }
8577
-
8578
- public function getComparisonType()
8579
- {
8580
- return $this->comparisonType;
8581
- }
8582
-
8583
- public function setComparisonValue($comparisonValue)
8584
- {
8585
- $this->comparisonValue = $comparisonValue;
8586
- }
8587
-
8588
- public function getComparisonValue()
8589
- {
8590
- return $this->comparisonValue;
8591
- }
8592
- }
8593
-
8594
- class Google_Service_Analytics_GoalVisitTimeOnSiteDetails extends Google_Model
8595
- {
8596
-
8597
- protected $internal_gapi_mappings = array();
8598
-
8599
- public $comparisonType;
8600
-
8601
- public $comparisonValue;
8602
-
8603
- public function setComparisonType($comparisonType)
8604
- {
8605
- $this->comparisonType = $comparisonType;
8606
- }
8607
-
8608
- public function getComparisonType()
8609
- {
8610
- return $this->comparisonType;
8611
- }
8612
-
8613
- public function setComparisonValue($comparisonValue)
8614
- {
8615
- $this->comparisonValue = $comparisonValue;
8616
- }
8617
-
8618
- public function getComparisonValue()
8619
- {
8620
- return $this->comparisonValue;
8621
- }
8622
- }
8623
-
8624
- class Google_Service_Analytics_Goals extends Google_Collection
8625
- {
8626
-
8627
- protected $collection_key = 'items';
8628
-
8629
- protected $internal_gapi_mappings = array();
8630
-
8631
- protected $itemsType = 'Google_Service_Analytics_Goal';
8632
-
8633
- protected $itemsDataType = 'array';
8634
-
8635
- public $itemsPerPage;
8636
-
8637
- public $kind;
8638
-
8639
- public $nextLink;
8640
-
8641
- public $previousLink;
8642
-
8643
- public $startIndex;
8644
-
8645
- public $totalResults;
8646
-
8647
- public $username;
8648
-
8649
- public function setItems($items)
8650
- {
8651
- $this->items = $items;
8652
- }
8653
-
8654
- public function getItems()
8655
- {
8656
- return $this->items;
8657
- }
8658
-
8659
- public function setItemsPerPage($itemsPerPage)
8660
- {
8661
- $this->itemsPerPage = $itemsPerPage;
8662
- }
8663
-
8664
- public function getItemsPerPage()
8665
- {
8666
- return $this->itemsPerPage;
8667
- }
8668
-
8669
- public function setKind($kind)
8670
- {
8671
- $this->kind = $kind;
8672
- }
8673
-
8674
- public function getKind()
8675
- {
8676
- return $this->kind;
8677
- }
8678
-
8679
- public function setNextLink($nextLink)
8680
- {
8681
- $this->nextLink = $nextLink;
8682
- }
8683
-
8684
- public function getNextLink()
8685
- {
8686
- return $this->nextLink;
8687
- }
8688
-
8689
- public function setPreviousLink($previousLink)
8690
- {
8691
- $this->previousLink = $previousLink;
8692
- }
8693
-
8694
- public function getPreviousLink()
8695
- {
8696
- return $this->previousLink;
8697
- }
8698
-
8699
- public function setStartIndex($startIndex)
8700
- {
8701
- $this->startIndex = $startIndex;
8702
- }
8703
-
8704
- public function getStartIndex()
8705
- {
8706
- return $this->startIndex;
8707
- }
8708
-
8709
- public function setTotalResults($totalResults)
8710
- {
8711
- $this->totalResults = $totalResults;
8712
- }
8713
-
8714
- public function getTotalResults()
8715
- {
8716
- return $this->totalResults;
8717
- }
8718
-
8719
- public function setUsername($username)
8720
- {
8721
- $this->username = $username;
8722
- }
8723
-
8724
- public function getUsername()
8725
- {
8726
- return $this->username;
8727
- }
8728
- }
8729
-
8730
- class Google_Service_Analytics_McfData extends Google_Collection
8731
- {
8732
-
8733
- protected $collection_key = 'rows';
8734
-
8735
- protected $internal_gapi_mappings = array();
8736
-
8737
- protected $columnHeadersType = 'Google_Service_Analytics_McfDataColumnHeaders';
8738
-
8739
- protected $columnHeadersDataType = 'array';
8740
-
8741
- public $containsSampledData;
8742
-
8743
- public $id;
8744
-
8745
- public $itemsPerPage;
8746
-
8747
- public $kind;
8748
-
8749
- public $nextLink;
8750
-
8751
- public $previousLink;
8752
-
8753
- protected $profileInfoType = 'Google_Service_Analytics_McfDataProfileInfo';
8754
-
8755
- protected $profileInfoDataType = '';
8756
-
8757
- protected $queryType = 'Google_Service_Analytics_McfDataQuery';
8758
-
8759
- protected $queryDataType = '';
8760
-
8761
- protected $rowsType = 'Google_Service_Analytics_McfDataRows';
8762
-
8763
- protected $rowsDataType = 'array';
8764
-
8765
- public $sampleSize;
8766
-
8767
- public $sampleSpace;
8768
-
8769
- public $selfLink;
8770
-
8771
- public $totalResults;
8772
-
8773
- public $totalsForAllResults;
8774
-
8775
- public function setColumnHeaders($columnHeaders)
8776
- {
8777
- $this->columnHeaders = $columnHeaders;
8778
- }
8779
-
8780
- public function getColumnHeaders()
8781
- {
8782
- return $this->columnHeaders;
8783
- }
8784
-
8785
- public function setContainsSampledData($containsSampledData)
8786
- {
8787
- $this->containsSampledData = $containsSampledData;
8788
- }
8789
-
8790
- public function getContainsSampledData()
8791
- {
8792
- return $this->containsSampledData;
8793
- }
8794
-
8795
- public function setId($id)
8796
- {
8797
- $this->id = $id;
8798
- }
8799
-
8800
- public function getId()
8801
- {
8802
- return $this->id;
8803
- }
8804
-
8805
- public function setItemsPerPage($itemsPerPage)
8806
- {
8807
- $this->itemsPerPage = $itemsPerPage;
8808
- }
8809
-
8810
- public function getItemsPerPage()
8811
- {
8812
- return $this->itemsPerPage;
8813
- }
8814
-
8815
- public function setKind($kind)
8816
- {
8817
- $this->kind = $kind;
8818
- }
8819
-
8820
- public function getKind()
8821
- {
8822
- return $this->kind;
8823
- }
8824
-
8825
- public function setNextLink($nextLink)
8826
- {
8827
- $this->nextLink = $nextLink;
8828
- }
8829
-
8830
- public function getNextLink()
8831
- {
8832
- return $this->nextLink;
8833
- }
8834
-
8835
- public function setPreviousLink($previousLink)
8836
- {
8837
- $this->previousLink = $previousLink;
8838
- }
8839
-
8840
- public function getPreviousLink()
8841
- {
8842
- return $this->previousLink;
8843
- }
8844
-
8845
- public function setProfileInfo(Google_Service_Analytics_McfDataProfileInfo $profileInfo)
8846
- {
8847
- $this->profileInfo = $profileInfo;
8848
- }
8849
-
8850
- public function getProfileInfo()
8851
- {
8852
- return $this->profileInfo;
8853
- }
8854
-
8855
- public function setQuery(Google_Service_Analytics_McfDataQuery $query)
8856
- {
8857
- $this->query = $query;
8858
- }
8859
-
8860
- public function getQuery()
8861
- {
8862
- return $this->query;
8863
- }
8864
-
8865
- public function setRows($rows)
8866
- {
8867
- $this->rows = $rows;
8868
- }
8869
-
8870
- public function getRows()
8871
- {
8872
- return $this->rows;
8873
- }
8874
-
8875
- public function setSampleSize($sampleSize)
8876
- {
8877
- $this->sampleSize = $sampleSize;
8878
- }
8879
-
8880
- public function getSampleSize()
8881
- {
8882
- return $this->sampleSize;
8883
- }
8884
-
8885
- public function setSampleSpace($sampleSpace)
8886
- {
8887
- $this->sampleSpace = $sampleSpace;
8888
- }
8889
-
8890
- public function getSampleSpace()
8891
- {
8892
- return $this->sampleSpace;
8893
- }
8894
-
8895
- public function setSelfLink($selfLink)
8896
- {
8897
- $this->selfLink = $selfLink;
8898
- }
8899
-
8900
- public function getSelfLink()
8901
- {
8902
- return $this->selfLink;
8903
- }
8904
-
8905
- public function setTotalResults($totalResults)
8906
- {
8907
- $this->totalResults = $totalResults;
8908
- }
8909
-
8910
- public function getTotalResults()
8911
- {
8912
- return $this->totalResults;
8913
- }
8914
-
8915
- public function setTotalsForAllResults($totalsForAllResults)
8916
- {
8917
- $this->totalsForAllResults = $totalsForAllResults;
8918
- }
8919
-
8920
- public function getTotalsForAllResults()
8921
- {
8922
- return $this->totalsForAllResults;
8923
- }
8924
- }
8925
-
8926
- class Google_Service_Analytics_McfDataColumnHeaders extends Google_Model
8927
- {
8928
-
8929
- protected $internal_gapi_mappings = array();
8930
-
8931
- public $columnType;
8932
-
8933
- public $dataType;
8934
-
8935
- public $name;
8936
-
8937
- public function setColumnType($columnType)
8938
- {
8939
- $this->columnType = $columnType;
8940
- }
8941
-
8942
- public function getColumnType()
8943
- {
8944
- return $this->columnType;
8945
- }
8946
-
8947
- public function setDataType($dataType)
8948
- {
8949
- $this->dataType = $dataType;
8950
- }
8951
-
8952
- public function getDataType()
8953
- {
8954
- return $this->dataType;
8955
- }
8956
-
8957
- public function setName($name)
8958
- {
8959
- $this->name = $name;
8960
- }
8961
-
8962
- public function getName()
8963
- {
8964
- return $this->name;
8965
- }
8966
- }
8967
-
8968
- class Google_Service_Analytics_McfDataProfileInfo extends Google_Model
8969
- {
8970
-
8971
- protected $internal_gapi_mappings = array();
8972
-
8973
- public $accountId;
8974
-
8975
- public $internalWebPropertyId;
8976
-
8977
- public $profileId;
8978
-
8979
- public $profileName;
8980
-
8981
- public $tableId;
8982
-
8983
- public $webPropertyId;
8984
-
8985
- public function setAccountId($accountId)
8986
- {
8987
- $this->accountId = $accountId;
8988
- }
8989
-
8990
- public function getAccountId()
8991
- {
8992
- return $this->accountId;
8993
- }
8994
-
8995
- public function setInternalWebPropertyId($internalWebPropertyId)
8996
- {
8997
- $this->internalWebPropertyId = $internalWebPropertyId;
8998
- }
8999
-
9000
- public function getInternalWebPropertyId()
9001
- {
9002
- return $this->internalWebPropertyId;
9003
- }
9004
-
9005
- public function setProfileId($profileId)
9006
- {
9007
- $this->profileId = $profileId;
9008
- }
9009
-
9010
- public function getProfileId()
9011
- {
9012
- return $this->profileId;
9013
- }
9014
-
9015
- public function setProfileName($profileName)
9016
- {
9017
- $this->profileName = $profileName;
9018
- }
9019
-
9020
- public function getProfileName()
9021
- {
9022
- return $this->profileName;
9023
- }
9024
-
9025
- public function setTableId($tableId)
9026
- {
9027
- $this->tableId = $tableId;
9028
- }
9029
-
9030
- public function getTableId()
9031
- {
9032
- return $this->tableId;
9033
- }
9034
-
9035
- public function setWebPropertyId($webPropertyId)
9036
- {
9037
- $this->webPropertyId = $webPropertyId;
9038
- }
9039
-
9040
- public function getWebPropertyId()
9041
- {
9042
- return $this->webPropertyId;
9043
- }
9044
- }
9045
-
9046
- class Google_Service_Analytics_McfDataQuery extends Google_Collection
9047
- {
9048
-
9049
- protected $collection_key = 'sort';
9050
-
9051
- protected $internal_gapi_mappings = array(
9052
- "endDate" => "end-date",
9053
- "maxResults" => "max-results",
9054
- "startDate" => "start-date",
9055
- "startIndex" => "start-index"
9056
- );
9057
-
9058
- public $dimensions;
9059
-
9060
- public $endDate;
9061
-
9062
- public $filters;
9063
-
9064
- public $ids;
9065
-
9066
- public $maxResults;
9067
-
9068
- public $metrics;
9069
-
9070
- public $samplingLevel;
9071
-
9072
- public $segment;
9073
-
9074
- public $sort;
9075
-
9076
- public $startDate;
9077
-
9078
- public $startIndex;
9079
-
9080
- public function setDimensions($dimensions)
9081
- {
9082
- $this->dimensions = $dimensions;
9083
- }
9084
-
9085
- public function getDimensions()
9086
- {
9087
- return $this->dimensions;
9088
- }
9089
-
9090
- public function setEndDate($endDate)
9091
- {
9092
- $this->endDate = $endDate;
9093
- }
9094
-
9095
- public function getEndDate()
9096
- {
9097
- return $this->endDate;
9098
- }
9099
-
9100
- public function setFilters($filters)
9101
- {
9102
- $this->filters = $filters;
9103
- }
9104
-
9105
- public function getFilters()
9106
- {
9107
- return $this->filters;
9108
- }
9109
-
9110
- public function setIds($ids)
9111
- {
9112
- $this->ids = $ids;
9113
- }
9114
-
9115
- public function getIds()
9116
- {
9117
- return $this->ids;
9118
- }
9119
-
9120
- public function setMaxResults($maxResults)
9121
- {
9122
- $this->maxResults = $maxResults;
9123
- }
9124
-
9125
- public function getMaxResults()
9126
- {
9127
- return $this->maxResults;
9128
- }
9129
-
9130
- public function setMetrics($metrics)
9131
- {
9132
- $this->metrics = $metrics;
9133
- }
9134
-
9135
- public function getMetrics()
9136
- {
9137
- return $this->metrics;
9138
- }
9139
-
9140
- public function setSamplingLevel($samplingLevel)
9141
- {
9142
- $this->samplingLevel = $samplingLevel;
9143
- }
9144
-
9145
- public function getSamplingLevel()
9146
- {
9147
- return $this->samplingLevel;
9148
- }
9149
-
9150
- public function setSegment($segment)
9151
- {
9152
- $this->segment = $segment;
9153
- }
9154
-
9155
- public function getSegment()
9156
- {
9157
- return $this->segment;
9158
- }
9159
-
9160
- public function setSort($sort)
9161
- {
9162
- $this->sort = $sort;
9163
- }
9164
-
9165
- public function getSort()
9166
- {
9167
- return $this->sort;
9168
- }
9169
-
9170
- public function setStartDate($startDate)
9171
- {
9172
- $this->startDate = $startDate;
9173
- }
9174
-
9175
- public function getStartDate()
9176
- {
9177
- return $this->startDate;
9178
- }
9179
-
9180
- public function setStartIndex($startIndex)
9181
- {
9182
- $this->startIndex = $startIndex;
9183
- }
9184
-
9185
- public function getStartIndex()
9186
- {
9187
- return $this->startIndex;
9188
- }
9189
- }
9190
-
9191
- class Google_Service_Analytics_McfDataRows extends Google_Collection
9192
- {
9193
-
9194
- protected $collection_key = 'conversionPathValue';
9195
-
9196
- protected $internal_gapi_mappings = array();
9197
-
9198
- protected $conversionPathValueType = 'Google_Service_Analytics_McfDataRowsConversionPathValue';
9199
-
9200
- protected $conversionPathValueDataType = 'array';
9201
-
9202
- public $primitiveValue;
9203
-
9204
- public function setConversionPathValue($conversionPathValue)
9205
- {
9206
- $this->conversionPathValue = $conversionPathValue;
9207
- }
9208
-
9209
- public function getConversionPathValue()
9210
- {
9211
- return $this->conversionPathValue;
9212
- }
9213
-
9214
- public function setPrimitiveValue($primitiveValue)
9215
- {
9216
- $this->primitiveValue = $primitiveValue;
9217
- }
9218
-
9219
- public function getPrimitiveValue()
9220
- {
9221
- return $this->primitiveValue;
9222
- }
9223
- }
9224
-
9225
- class Google_Service_Analytics_McfDataRowsConversionPathValue extends Google_Model
9226
- {
9227
-
9228
- protected $internal_gapi_mappings = array();
9229
-
9230
- public $interactionType;
9231
-
9232
- public $nodeValue;
9233
-
9234
- public function setInteractionType($interactionType)
9235
- {
9236
- $this->interactionType = $interactionType;
9237
- }
9238
-
9239
- public function getInteractionType()
9240
- {
9241
- return $this->interactionType;
9242
- }
9243
-
9244
- public function setNodeValue($nodeValue)
9245
- {
9246
- $this->nodeValue = $nodeValue;
9247
- }
9248
-
9249
- public function getNodeValue()
9250
- {
9251
- return $this->nodeValue;
9252
- }
9253
- }
9254
-
9255
- class Google_Service_Analytics_McfDataTotalsForAllResults extends Google_Model
9256
- {
9257
- }
9258
-
9259
- class Google_Service_Analytics_Profile extends Google_Model
9260
- {
9261
-
9262
- protected $internal_gapi_mappings = array();
9263
-
9264
- public $accountId;
9265
-
9266
- protected $childLinkType = 'Google_Service_Analytics_ProfileChildLink';
9267
-
9268
- protected $childLinkDataType = '';
9269
-
9270
- public $created;
9271
-
9272
- public $currency;
9273
-
9274
- public $defaultPage;
9275
-
9276
- public $eCommerceTracking;
9277
-
9278
- public $enhancedECommerceTracking;
9279
-
9280
- public $excludeQueryParameters;
9281
-
9282
- public $id;
9283
-
9284
- public $internalWebPropertyId;
9285
-
9286
- public $kind;
9287
-
9288
- public $name;
9289
-
9290
- protected $parentLinkType = 'Google_Service_Analytics_ProfileParentLink';
9291
-
9292
- protected $parentLinkDataType = '';
9293
-
9294
- protected $permissionsType = 'Google_Service_Analytics_ProfilePermissions';
9295
-
9296
- protected $permissionsDataType = '';
9297
-
9298
- public $selfLink;
9299
-
9300
- public $siteSearchCategoryParameters;
9301
-
9302
- public $siteSearchQueryParameters;
9303
-
9304
- public $stripSiteSearchCategoryParameters;
9305
-
9306
- public $stripSiteSearchQueryParameters;
9307
-
9308
- public $timezone;
9309
-
9310
- public $type;
9311
-
9312
- public $updated;
9313
-
9314
- public $webPropertyId;
9315
-
9316
- public $websiteUrl;
9317
-
9318
- public function setAccountId($accountId)
9319
- {
9320
- $this->accountId = $accountId;
9321
- }
9322
-
9323
- public function getAccountId()
9324
- {
9325
- return $this->accountId;
9326
- }
9327
-
9328
- public function setChildLink(Google_Service_Analytics_ProfileChildLink $childLink)
9329
- {
9330
- $this->childLink = $childLink;
9331
- }
9332
-
9333
- public function getChildLink()
9334
- {
9335
- return $this->childLink;
9336
- }
9337
-
9338
- public function setCreated($created)
9339
- {
9340
- $this->created = $created;
9341
- }
9342
-
9343
- public function getCreated()
9344
- {
9345
- return $this->created;
9346
- }
9347
-
9348
- public function setCurrency($currency)
9349
- {
9350
- $this->currency = $currency;
9351
- }
9352
-
9353
- public function getCurrency()
9354
- {
9355
- return $this->currency;
9356
- }
9357
-
9358
- public function setDefaultPage($defaultPage)
9359
- {
9360
- $this->defaultPage = $defaultPage;
9361
- }
9362
-
9363
- public function getDefaultPage()
9364
- {
9365
- return $this->defaultPage;
9366
- }
9367
-
9368
- public function setECommerceTracking($eCommerceTracking)
9369
- {
9370
- $this->eCommerceTracking = $eCommerceTracking;
9371
- }
9372
-
9373
- public function getECommerceTracking()
9374
- {
9375
- return $this->eCommerceTracking;
9376
- }
9377
-
9378
- public function setEnhancedECommerceTracking($enhancedECommerceTracking)
9379
- {
9380
- $this->enhancedECommerceTracking = $enhancedECommerceTracking;
9381
- }
9382
-
9383
- public function getEnhancedECommerceTracking()
9384
- {
9385
- return $this->enhancedECommerceTracking;
9386
- }
9387
-
9388
- public function setExcludeQueryParameters($excludeQueryParameters)
9389
- {
9390
- $this->excludeQueryParameters = $excludeQueryParameters;
9391
- }
9392
-
9393
- public function getExcludeQueryParameters()
9394
- {
9395
- return $this->excludeQueryParameters;
9396
- }
9397
-
9398
- public function setId($id)
9399
- {
9400
- $this->id = $id;
9401
- }
9402
-
9403
- public function getId()
9404
- {
9405
- return $this->id;
9406
- }
9407
-
9408
- public function setInternalWebPropertyId($internalWebPropertyId)
9409
- {
9410
- $this->internalWebPropertyId = $internalWebPropertyId;
9411
- }
9412
-
9413
- public function getInternalWebPropertyId()
9414
- {
9415
- return $this->internalWebPropertyId;
9416
- }
9417
-
9418
- public function setKind($kind)
9419
- {
9420
- $this->kind = $kind;
9421
- }
9422
-
9423
- public function getKind()
9424
- {
9425
- return $this->kind;
9426
- }
9427
-
9428
- public function setName($name)
9429
- {
9430
- $this->name = $name;
9431
- }
9432
-
9433
- public function getName()
9434
- {
9435
- return $this->name;
9436
- }
9437
-
9438
- public function setParentLink(Google_Service_Analytics_ProfileParentLink $parentLink)
9439
- {
9440
- $this->parentLink = $parentLink;
9441
- }
9442
-
9443
- public function getParentLink()
9444
- {
9445
- return $this->parentLink;
9446
- }
9447
-
9448
- public function setPermissions(Google_Service_Analytics_ProfilePermissions $permissions)
9449
- {
9450
- $this->permissions = $permissions;
9451
- }
9452
-
9453
- public function getPermissions()
9454
- {
9455
- return $this->permissions;
9456
- }
9457
-
9458
- public function setSelfLink($selfLink)
9459
- {
9460
- $this->selfLink = $selfLink;
9461
- }
9462
-
9463
- public function getSelfLink()
9464
- {
9465
- return $this->selfLink;
9466
- }
9467
-
9468
- public function setSiteSearchCategoryParameters($siteSearchCategoryParameters)
9469
- {
9470
- $this->siteSearchCategoryParameters = $siteSearchCategoryParameters;
9471
- }
9472
-
9473
- public function getSiteSearchCategoryParameters()
9474
- {
9475
- return $this->siteSearchCategoryParameters;
9476
- }
9477
-
9478
- public function setSiteSearchQueryParameters($siteSearchQueryParameters)
9479
- {
9480
- $this->siteSearchQueryParameters = $siteSearchQueryParameters;
9481
- }
9482
-
9483
- public function getSiteSearchQueryParameters()
9484
- {
9485
- return $this->siteSearchQueryParameters;
9486
- }
9487
-
9488
- public function setStripSiteSearchCategoryParameters($stripSiteSearchCategoryParameters)
9489
- {
9490
- $this->stripSiteSearchCategoryParameters = $stripSiteSearchCategoryParameters;
9491
- }
9492
-
9493
- public function getStripSiteSearchCategoryParameters()
9494
- {
9495
- return $this->stripSiteSearchCategoryParameters;
9496
- }
9497
-
9498
- public function setStripSiteSearchQueryParameters($stripSiteSearchQueryParameters)
9499
- {
9500
- $this->stripSiteSearchQueryParameters = $stripSiteSearchQueryParameters;
9501
- }
9502
-
9503
- public function getStripSiteSearchQueryParameters()
9504
- {
9505
- return $this->stripSiteSearchQueryParameters;
9506
- }
9507
-
9508
- public function setTimezone($timezone)
9509
- {
9510
- $this->timezone = $timezone;
9511
- }
9512
-
9513
- public function getTimezone()
9514
- {
9515
- return $this->timezone;
9516
- }
9517
-
9518
- public function setType($type)
9519
- {
9520
- $this->type = $type;
9521
- }
9522
-
9523
- public function getType()
9524
- {
9525
- return $this->type;
9526
- }
9527
-
9528
- public function setUpdated($updated)
9529
- {
9530
- $this->updated = $updated;
9531
- }
9532
-
9533
- public function getUpdated()
9534
- {
9535
- return $this->updated;
9536
- }
9537
-
9538
- public function setWebPropertyId($webPropertyId)
9539
- {
9540
- $this->webPropertyId = $webPropertyId;
9541
- }
9542
-
9543
- public function getWebPropertyId()
9544
- {
9545
- return $this->webPropertyId;
9546
- }
9547
-
9548
- public function setWebsiteUrl($websiteUrl)
9549
- {
9550
- $this->websiteUrl = $websiteUrl;
9551
- }
9552
-
9553
- public function getWebsiteUrl()
9554
- {
9555
- return $this->websiteUrl;
9556
- }
9557
- }
9558
-
9559
- class Google_Service_Analytics_ProfileChildLink extends Google_Model
9560
- {
9561
-
9562
- protected $internal_gapi_mappings = array();
9563
-
9564
- public $href;
9565
-
9566
- public $type;
9567
-
9568
- public function setHref($href)
9569
- {
9570
- $this->href = $href;
9571
- }
9572
-
9573
- public function getHref()
9574
- {
9575
- return $this->href;
9576
- }
9577
-
9578
- public function setType($type)
9579
- {
9580
- $this->type = $type;
9581
- }
9582
-
9583
- public function getType()
9584
- {
9585
- return $this->type;
9586
- }
9587
- }
9588
-
9589
- class Google_Service_Analytics_ProfileFilterLink extends Google_Model
9590
- {
9591
-
9592
- protected $internal_gapi_mappings = array();
9593
-
9594
- protected $filterRefType = 'Google_Service_Analytics_FilterRef';
9595
-
9596
- protected $filterRefDataType = '';
9597
-
9598
- public $id;
9599
-
9600
- public $kind;
9601
-
9602
- protected $profileRefType = 'Google_Service_Analytics_ProfileRef';
9603
-
9604
- protected $profileRefDataType = '';
9605
-
9606
- public $rank;
9607
-
9608
- public $selfLink;
9609
-
9610
- public function setFilterRef(Google_Service_Analytics_FilterRef $filterRef)
9611
- {
9612
- $this->filterRef = $filterRef;
9613
- }
9614
-
9615
- public function getFilterRef()
9616
- {
9617
- return $this->filterRef;
9618
- }
9619
-
9620
- public function setId($id)
9621
- {
9622
- $this->id = $id;
9623
- }
9624
-
9625
- public function getId()
9626
- {
9627
- return $this->id;
9628
- }
9629
-
9630
- public function setKind($kind)
9631
- {
9632
- $this->kind = $kind;
9633
- }
9634
-
9635
- public function getKind()
9636
- {
9637
- return $this->kind;
9638
- }
9639
-
9640
- public function setProfileRef(Google_Service_Analytics_ProfileRef $profileRef)
9641
- {
9642
- $this->profileRef = $profileRef;
9643
- }
9644
-
9645
- public function getProfileRef()
9646
- {
9647
- return $this->profileRef;
9648
- }
9649
-
9650
- public function setRank($rank)
9651
- {
9652
- $this->rank = $rank;
9653
- }
9654
-
9655
- public function getRank()
9656
- {
9657
- return $this->rank;
9658
- }
9659
-
9660
- public function setSelfLink($selfLink)
9661
- {
9662
- $this->selfLink = $selfLink;
9663
- }
9664
-
9665
- public function getSelfLink()
9666
- {
9667
- return $this->selfLink;
9668
- }
9669
- }
9670
-
9671
- class Google_Service_Analytics_ProfileFilterLinks extends Google_Collection
9672
- {
9673
-
9674
- protected $collection_key = 'items';
9675
-
9676
- protected $internal_gapi_mappings = array();
9677
-
9678
- protected $itemsType = 'Google_Service_Analytics_ProfileFilterLink';
9679
-
9680
- protected $itemsDataType = 'array';
9681
-
9682
- public $itemsPerPage;
9683
-
9684
- public $kind;
9685
-
9686
- public $nextLink;
9687
-
9688
- public $previousLink;
9689
-
9690
- public $startIndex;
9691
-
9692
- public $totalResults;
9693
-
9694
- public $username;
9695
-
9696
- public function setItems($items)
9697
- {
9698
- $this->items = $items;
9699
- }
9700
-
9701
- public function getItems()
9702
- {
9703
- return $this->items;
9704
- }
9705
-
9706
- public function setItemsPerPage($itemsPerPage)
9707
- {
9708
- $this->itemsPerPage = $itemsPerPage;
9709
- }
9710
-
9711
- public function getItemsPerPage()
9712
- {
9713
- return $this->itemsPerPage;
9714
- }
9715
-
9716
- public function setKind($kind)
9717
- {
9718
- $this->kind = $kind;
9719
- }
9720
-
9721
- public function getKind()
9722
- {
9723
- return $this->kind;
9724
- }
9725
-
9726
- public function setNextLink($nextLink)
9727
- {
9728
- $this->nextLink = $nextLink;
9729
- }
9730
-
9731
- public function getNextLink()
9732
- {
9733
- return $this->nextLink;
9734
- }
9735
-
9736
- public function setPreviousLink($previousLink)
9737
- {
9738
- $this->previousLink = $previousLink;
9739
- }
9740
-
9741
- public function getPreviousLink()
9742
- {
9743
- return $this->previousLink;
9744
- }
9745
-
9746
- public function setStartIndex($startIndex)
9747
- {
9748
- $this->startIndex = $startIndex;
9749
- }
9750
-
9751
- public function getStartIndex()
9752
- {
9753
- return $this->startIndex;
9754
- }
9755
-
9756
- public function setTotalResults($totalResults)
9757
- {
9758
- $this->totalResults = $totalResults;
9759
- }
9760
-
9761
- public function getTotalResults()
9762
- {
9763
- return $this->totalResults;
9764
- }
9765
-
9766
- public function setUsername($username)
9767
- {
9768
- $this->username = $username;
9769
- }
9770
-
9771
- public function getUsername()
9772
- {
9773
- return $this->username;
9774
- }
9775
- }
9776
-
9777
- class Google_Service_Analytics_ProfileParentLink extends Google_Model
9778
- {
9779
-
9780
- protected $internal_gapi_mappings = array();
9781
-
9782
- public $href;
9783
-
9784
- public $type;
9785
-
9786
- public function setHref($href)
9787
- {
9788
- $this->href = $href;
9789
- }
9790
-
9791
- public function getHref()
9792
- {
9793
- return $this->href;
9794
- }
9795
-
9796
- public function setType($type)
9797
- {
9798
- $this->type = $type;
9799
- }
9800
-
9801
- public function getType()
9802
- {
9803
- return $this->type;
9804
- }
9805
- }
9806
-
9807
- class Google_Service_Analytics_ProfilePermissions extends Google_Collection
9808
- {
9809
-
9810
- protected $collection_key = 'effective';
9811
-
9812
- protected $internal_gapi_mappings = array();
9813
-
9814
- public $effective;
9815
-
9816
- public function setEffective($effective)
9817
- {
9818
- $this->effective = $effective;
9819
- }
9820
-
9821
- public function getEffective()
9822
- {
9823
- return $this->effective;
9824
- }
9825
- }
9826
-
9827
- class Google_Service_Analytics_ProfileRef extends Google_Model
9828
- {
9829
-
9830
- protected $internal_gapi_mappings = array();
9831
-
9832
- public $accountId;
9833
-
9834
- public $href;
9835
-
9836
- public $id;
9837
-
9838
- public $internalWebPropertyId;
9839
-
9840
- public $kind;
9841
-
9842
- public $name;
9843
-
9844
- public $webPropertyId;
9845
-
9846
- public function setAccountId($accountId)
9847
- {
9848
- $this->accountId = $accountId;
9849
- }
9850
-
9851
- public function getAccountId()
9852
- {
9853
- return $this->accountId;
9854
- }
9855
-
9856
- public function setHref($href)
9857
- {
9858
- $this->href = $href;
9859
- }
9860
-
9861
- public function getHref()
9862
- {
9863
- return $this->href;
9864
- }
9865
-
9866
- public function setId($id)
9867
- {
9868
- $this->id = $id;
9869
- }
9870
-
9871
- public function getId()
9872
- {
9873
- return $this->id;
9874
- }
9875
-
9876
- public function setInternalWebPropertyId($internalWebPropertyId)
9877
- {
9878
- $this->internalWebPropertyId = $internalWebPropertyId;
9879
- }
9880
-
9881
- public function getInternalWebPropertyId()
9882
- {
9883
- return $this->internalWebPropertyId;
9884
- }
9885
-
9886
- public function setKind($kind)
9887
- {
9888
- $this->kind = $kind;
9889
- }
9890
-
9891
- public function getKind()
9892
- {
9893
- return $this->kind;
9894
- }
9895
-
9896
- public function setName($name)
9897
- {
9898
- $this->name = $name;
9899
- }
9900
-
9901
- public function getName()
9902
- {
9903
- return $this->name;
9904
- }
9905
-
9906
- public function setWebPropertyId($webPropertyId)
9907
- {
9908
- $this->webPropertyId = $webPropertyId;
9909
- }
9910
-
9911
- public function getWebPropertyId()
9912
- {
9913
- return $this->webPropertyId;
9914
- }
9915
- }
9916
-
9917
- class Google_Service_Analytics_ProfileSummary extends Google_Model
9918
- {
9919
-
9920
- protected $internal_gapi_mappings = array();
9921
-
9922
- public $id;
9923
-
9924
- public $kind;
9925
-
9926
- public $name;
9927
-
9928
- public $type;
9929
-
9930
- public function setId($id)
9931
- {
9932
- $this->id = $id;
9933
- }
9934
-
9935
- public function getId()
9936
- {
9937
- return $this->id;
9938
- }
9939
-
9940
- public function setKind($kind)
9941
- {
9942
- $this->kind = $kind;
9943
- }
9944
-
9945
- public function getKind()
9946
- {
9947
- return $this->kind;
9948
- }
9949
-
9950
- public function setName($name)
9951
- {
9952
- $this->name = $name;
9953
- }
9954
-
9955
- public function getName()
9956
- {
9957
- return $this->name;
9958
- }
9959
-
9960
- public function setType($type)
9961
- {
9962
- $this->type = $type;
9963
- }
9964
-
9965
- public function getType()
9966
- {
9967
- return $this->type;
9968
- }
9969
- }
9970
-
9971
- class Google_Service_Analytics_Profiles extends Google_Collection
9972
- {
9973
-
9974
- protected $collection_key = 'items';
9975
-
9976
- protected $internal_gapi_mappings = array();
9977
-
9978
- protected $itemsType = 'Google_Service_Analytics_Profile';
9979
-
9980
- protected $itemsDataType = 'array';
9981
-
9982
- public $itemsPerPage;
9983
-
9984
- public $kind;
9985
-
9986
- public $nextLink;
9987
-
9988
- public $previousLink;
9989
-
9990
- public $startIndex;
9991
-
9992
- public $totalResults;
9993
-
9994
- public $username;
9995
-
9996
- public function setItems($items)
9997
- {
9998
- $this->items = $items;
9999
- }
10000
-
10001
- public function getItems()
10002
- {
10003
- return $this->items;
10004
- }
10005
-
10006
- public function setItemsPerPage($itemsPerPage)
10007
- {
10008
- $this->itemsPerPage = $itemsPerPage;
10009
- }
10010
-
10011
- public function getItemsPerPage()
10012
- {
10013
- return $this->itemsPerPage;
10014
- }
10015
-
10016
- public function setKind($kind)
10017
- {
10018
- $this->kind = $kind;
10019
- }
10020
-
10021
- public function getKind()
10022
- {
10023
- return $this->kind;
10024
- }
10025
-
10026
- public function setNextLink($nextLink)
10027
- {
10028
- $this->nextLink = $nextLink;
10029
- }
10030
-
10031
- public function getNextLink()
10032
- {
10033
- return $this->nextLink;
10034
- }
10035
-
10036
- public function setPreviousLink($previousLink)
10037
- {
10038
- $this->previousLink = $previousLink;
10039
- }
10040
-
10041
- public function getPreviousLink()
10042
- {
10043
- return $this->previousLink;
10044
- }
10045
-
10046
- public function setStartIndex($startIndex)
10047
- {
10048
- $this->startIndex = $startIndex;
10049
- }
10050
-
10051
- public function getStartIndex()
10052
- {
10053
- return $this->startIndex;
10054
- }
10055
-
10056
- public function setTotalResults($totalResults)
10057
- {
10058
- $this->totalResults = $totalResults;
10059
- }
10060
-
10061
- public function getTotalResults()
10062
- {
10063
- return $this->totalResults;
10064
- }
10065
-
10066
- public function setUsername($username)
10067
- {
10068
- $this->username = $username;
10069
- }
10070
-
10071
- public function getUsername()
10072
- {
10073
- return $this->username;
10074
- }
10075
- }
10076
-
10077
- class Google_Service_Analytics_RealtimeData extends Google_Collection
10078
- {
10079
-
10080
- protected $collection_key = 'rows';
10081
-
10082
- protected $internal_gapi_mappings = array();
10083
-
10084
- protected $columnHeadersType = 'Google_Service_Analytics_RealtimeDataColumnHeaders';
10085
-
10086
- protected $columnHeadersDataType = 'array';
10087
-
10088
- public $id;
10089
-
10090
- public $kind;
10091
-
10092
- protected $profileInfoType = 'Google_Service_Analytics_RealtimeDataProfileInfo';
10093
-
10094
- protected $profileInfoDataType = '';
10095
-
10096
- protected $queryType = 'Google_Service_Analytics_RealtimeDataQuery';
10097
-
10098
- protected $queryDataType = '';
10099
-
10100
- public $rows;
10101
-
10102
- public $selfLink;
10103
-
10104
- public $totalResults;
10105
-
10106
- public $totalsForAllResults;
10107
-
10108
- public function setColumnHeaders($columnHeaders)
10109
- {
10110
- $this->columnHeaders = $columnHeaders;
10111
- }
10112
-
10113
- public function getColumnHeaders()
10114
- {
10115
- return $this->columnHeaders;
10116
- }
10117
-
10118
- public function setId($id)
10119
- {
10120
- $this->id = $id;
10121
- }
10122
-
10123
- public function getId()
10124
- {
10125
- return $this->id;
10126
- }
10127
-
10128
- public function setKind($kind)
10129
- {
10130
- $this->kind = $kind;
10131
- }
10132
-
10133
- public function getKind()
10134
- {
10135
- return $this->kind;
10136
- }
10137
-
10138
- public function setProfileInfo(Google_Service_Analytics_RealtimeDataProfileInfo $profileInfo)
10139
- {
10140
- $this->profileInfo = $profileInfo;
10141
- }
10142
-
10143
- public function getProfileInfo()
10144
- {
10145
- return $this->profileInfo;
10146
- }
10147
-
10148
- public function setQuery(Google_Service_Analytics_RealtimeDataQuery $query)
10149
- {
10150
- $this->query = $query;
10151
- }
10152
-
10153
- public function getQuery()
10154
- {
10155
- return $this->query;
10156
- }
10157
-
10158
- public function setRows($rows)
10159
- {
10160
- $this->rows = $rows;
10161
- }
10162
-
10163
- public function getRows()
10164
- {
10165
- return $this->rows;
10166
- }
10167
-
10168
- public function setSelfLink($selfLink)
10169
- {
10170
- $this->selfLink = $selfLink;
10171
- }
10172
-
10173
- public function getSelfLink()
10174
- {
10175
- return $this->selfLink;
10176
- }
10177
-
10178
- public function setTotalResults($totalResults)
10179
- {
10180
- $this->totalResults = $totalResults;
10181
- }
10182
-
10183
- public function getTotalResults()
10184
- {
10185
- return $this->totalResults;
10186
- }
10187
-
10188
- public function setTotalsForAllResults($totalsForAllResults)
10189
- {
10190
- $this->totalsForAllResults = $totalsForAllResults;
10191
- }
10192
-
10193
- public function getTotalsForAllResults()
10194
- {
10195
- return $this->totalsForAllResults;
10196
- }
10197
- }
10198
-
10199
- class Google_Service_Analytics_RealtimeDataColumnHeaders extends Google_Model
10200
- {
10201
-
10202
- protected $internal_gapi_mappings = array();
10203
-
10204
- public $columnType;
10205
-
10206
- public $dataType;
10207
-
10208
- public $name;
10209
-
10210
- public function setColumnType($columnType)
10211
- {
10212
- $this->columnType = $columnType;
10213
- }
10214
-
10215
- public function getColumnType()
10216
- {
10217
- return $this->columnType;
10218
- }
10219
-
10220
- public function setDataType($dataType)
10221
- {
10222
- $this->dataType = $dataType;
10223
- }
10224
-
10225
- public function getDataType()
10226
- {
10227
- return $this->dataType;
10228
- }
10229
-
10230
- public function setName($name)
10231
- {
10232
- $this->name = $name;
10233
- }
10234
-
10235
- public function getName()
10236
- {
10237
- return $this->name;
10238
- }
10239
- }
10240
-
10241
- class Google_Service_Analytics_RealtimeDataProfileInfo extends Google_Model
10242
- {
10243
-
10244
- protected $internal_gapi_mappings = array();
10245
-
10246
- public $accountId;
10247
-
10248
- public $internalWebPropertyId;
10249
-
10250
- public $profileId;
10251
-
10252
- public $profileName;
10253
-
10254
- public $tableId;
10255
-
10256
- public $webPropertyId;
10257
-
10258
- public function setAccountId($accountId)
10259
- {
10260
- $this->accountId = $accountId;
10261
- }
10262
-
10263
- public function getAccountId()
10264
- {
10265
- return $this->accountId;
10266
- }
10267
-
10268
- public function setInternalWebPropertyId($internalWebPropertyId)
10269
- {
10270
- $this->internalWebPropertyId = $internalWebPropertyId;
10271
- }
10272
-
10273
- public function getInternalWebPropertyId()
10274
- {
10275
- return $this->internalWebPropertyId;
10276
- }
10277
-
10278
- public function setProfileId($profileId)
10279
- {
10280
- $this->profileId = $profileId;
10281
- }
10282
-
10283
- public function getProfileId()
10284
- {
10285
- return $this->profileId;
10286
- }
10287
-
10288
- public function setProfileName($profileName)
10289
- {
10290
- $this->profileName = $profileName;
10291
- }
10292
-
10293
- public function getProfileName()
10294
- {
10295
- return $this->profileName;
10296
- }
10297
-
10298
- public function setTableId($tableId)
10299
- {
10300
- $this->tableId = $tableId;
10301
- }
10302
-
10303
- public function getTableId()
10304
- {
10305
- return $this->tableId;
10306
- }
10307
-
10308
- public function setWebPropertyId($webPropertyId)
10309
- {
10310
- $this->webPropertyId = $webPropertyId;
10311
- }
10312
-
10313
- public function getWebPropertyId()
10314
- {
10315
- return $this->webPropertyId;
10316
- }
10317
- }
10318
-
10319
- class Google_Service_Analytics_RealtimeDataQuery extends Google_Collection
10320
- {
10321
-
10322
- protected $collection_key = 'sort';
10323
-
10324
- protected $internal_gapi_mappings = array(
10325
- "maxResults" => "max-results"
1
  <?php
 
2
  /*
 
 
3
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
4
  * use this file except in compliance with the License. You may obtain a copy of
5
  * the License at
12
  * License for the specific language governing permissions and limitations under
13
  * the License.
14
  */
15
+
16
  /**
17
  * Service definition for Analytics (v3).
18
  *
28
  */
29
  class Google_Service_Analytics extends Google_Service
30
  {
31
+ /** View and manage your Google Analytics data. */
32
+ const ANALYTICS =
33
+ "https://www.googleapis.com/auth/analytics";
34
+ /** Edit Google Analytics management entities. */
35
+ const ANALYTICS_EDIT =
36
+ "https://www.googleapis.com/auth/analytics.edit";
37
+ /** Manage Google Analytics Account users by email address. */
38
+ const ANALYTICS_MANAGE_USERS =
39
+ "https://www.googleapis.com/auth/analytics.manage.users";
40
+ /** View Google Analytics user permissions. */
41
+ const ANALYTICS_MANAGE_USERS_READONLY =
42
+ "https://www.googleapis.com/auth/analytics.manage.users.readonly";
43
+ /** Create a new Google Analytics account along with its default property and view. */
44
+ const ANALYTICS_PROVISION =
45
+ "https://www.googleapis.com/auth/analytics.provision";
46
+ /** View your Google Analytics data. */
47
+ const ANALYTICS_READONLY =
48
+ "https://www.googleapis.com/auth/analytics.readonly";
49
+
50
+ public $data_ga;
51
+ public $data_mcf;
52
+ public $data_realtime;
53
+ public $management_accountSummaries;
54
+ public $management_accountUserLinks;
55
+ public $management_accounts;
56
+ public $management_customDataSources;
57
+ public $management_customDimensions;
58
+ public $management_customMetrics;
59
+ public $management_experiments;
60
+ public $management_filters;
61
+ public $management_goals;
62
+ public $management_profileFilterLinks;
63
+ public $management_profileUserLinks;
64
+ public $management_profiles;
65
+ public $management_segments;
66
+ public $management_unsampledReports;
67
+ public $management_uploads;
68
+ public $management_webPropertyAdWordsLinks;
69
+ public $management_webproperties;
70
+ public $management_webpropertyUserLinks;
71
+ public $metadata_columns;
72
+ public $provisioning;
73
+
74
+
75
+ /**
76
+ * Constructs the internal representation of the Analytics service.
77
+ *
78
+ * @param Google_Client $client
79
+ */
80
+ public function __construct(Google_Client $client)
81
+ {
82
+ parent::__construct($client);
83
+ $this->rootUrl = 'https://www.googleapis.com/';
84
+ $this->servicePath = 'analytics/v3/';
85
+ $this->version = 'v3';
86
+ $this->serviceName = 'analytics';
87
+
88
+ $this->data_ga = new Google_Service_Analytics_DataGa_Resource(
89
+ $this,
90
+ $this->serviceName,
91
+ 'ga',
92
+ array(
93
+ 'methods' => array(
94
+ 'get' => array(
95
+ 'path' => 'data/ga',
96
+ 'httpMethod' => 'GET',
97
+ 'parameters' => array(
98
+ 'ids' => array(
99
+ 'location' => 'query',
100
+ 'type' => 'string',
101
+ 'required' => true,
102
+ ),
103
+ 'start-date' => array(
104
+ 'location' => 'query',
105
+ 'type' => 'string',
106
+ 'required' => true,
107
+ ),
108
+ 'end-date' => array(
109
+ 'location' => 'query',
110
+ 'type' => 'string',
111
+ 'required' => true,
112
+ ),
113
+ 'metrics' => array(
114
+ 'location' => 'query',
115
+ 'type' => 'string',
116
+ 'required' => true,
117
+ ),
118
+ 'dimensions' => array(
119
+ 'location' => 'query',
120
+ 'type' => 'string',
121
+ ),
122
+ 'filters' => array(
123
+ 'location' => 'query',
124
+ 'type' => 'string',
125
+ ),
126
+ 'include-empty-rows' => array(
127
+ 'location' => 'query',
128
+ 'type' => 'boolean',
129
+ ),
130
+ 'max-results' => array(
131
+ 'location' => 'query',
132
+ 'type' => 'integer',
133
+ ),
134
+ 'output' => array(
135
+ 'location' => 'query',
136
+ 'type' => 'string',
137
+ ),
138
+ 'samplingLevel' => array(
139
+ 'location' => 'query',
140
+ 'type' => 'string',
141
+ ),
142
+ 'segment' => array(
143
+ 'location' => 'query',
144
+ 'type' => 'string',
145
+ ),
146
+ 'sort' => array(
147
+ 'location' => 'query',
148
+ 'type' => 'string',
149
+ ),
150
+ 'start-index' => array(
151
+ 'location' => 'query',
152
+ 'type' => 'integer',
153
+ ),
154
+ ),
155
+ ),
156
+ )
157
+ )
158
+ );
159
+ $this->data_mcf = new Google_Service_Analytics_DataMcf_Resource(
160
+ $this,
161
+ $this->serviceName,
162
+ 'mcf',
163
+ array(
164
+ 'methods' => array(
165
+ 'get' => array(
166
+ 'path' => 'data/mcf',
167
+ 'httpMethod' => 'GET',
168
+ 'parameters' => array(
169
+ 'ids' => array(
170
+ 'location' => 'query',
171
+ 'type' => 'string',
172
+ 'required' => true,
173
+ ),
174
+ 'start-date' => array(
175
+ 'location' => 'query',
176
+ 'type' => 'string',
177
+ 'required' => true,
178
+ ),
179
+ 'end-date' => array(
180
+ 'location' => 'query',
181
+ 'type' => 'string',
182
+ 'required' => true,
183
+ ),
184
+ 'metrics' => array(
185
+ 'location' => 'query',
186
+ 'type' => 'string',
187
+ 'required' => true,
188
+ ),
189
+ 'dimensions' => array(
190
+ 'location' => 'query',
191
+ 'type' => 'string',
192
+ ),
193
+ 'filters' => array(
194
+ 'location' => 'query',
195
+ 'type' => 'string',
196
+ ),
197
+ 'max-results' => array(
198
+ 'location' => 'query',
199
+ 'type' => 'integer',
200
+ ),
201
+ 'samplingLevel' => array(
202
+ 'location' => 'query',
203
+ 'type' => 'string',
204
+ ),
205
+ 'sort' => array(
206
+ 'location' => 'query',
207
+ 'type' => 'string',
208
+ ),
209
+ 'start-index' => array(
210
+ 'location' => 'query',
211
+ 'type' => 'integer',
212
+ ),
213
+ ),
214
+ ),
215
+ )
216
+ )
217
+ );
218
+ $this->data_realtime = new Google_Service_Analytics_DataRealtime_Resource(
219
+ $this,
220
+ $this->serviceName,
221
+ 'realtime',
222
+ array(
223
+ 'methods' => array(
224
+ 'get' => array(
225
+ 'path' => 'data/realtime',
226
+ 'httpMethod' => 'GET',
227
+ 'parameters' => array(
228
+ 'ids' => array(
229
+ 'location' => 'query',
230
+ 'type' => 'string',
231
+ 'required' => true,
232
+ ),
233
+ 'metrics' => array(
234
+ 'location' => 'query',
235
+ 'type' => 'string',
236
+ 'required' => true,
237
+ ),
238
+ 'dimensions' => array(
239
+ 'location' => 'query',
240
+ 'type' => 'string',
241
+ ),
242
+ 'filters' => array(
243
+ 'location' => 'query',
244
+ 'type' => 'string',
245
+ ),
246
+ 'max-results' => array(
247
+ 'location' => 'query',
248
+ 'type' => 'integer',
249
+ ),
250
+ 'sort' => array(
251
+ 'location' => 'query',
252
+ 'type' => 'string',
253
+ ),
254
+ ),
255
+ ),
256
+ )
257
+ )
258
+ );
259
+ $this->management_accountSummaries = new Google_Service_Analytics_ManagementAccountSummaries_Resource(
260
+ $this,
261
+ $this->serviceName,
262
+ 'accountSummaries',
263
+ array(
264
+ 'methods' => array(
265
+ 'list' => array(
266
+ 'path' => 'management/accountSummaries',
267
+ 'httpMethod' => 'GET',
268
+ 'parameters' => array(
269
+ 'max-results' => array(
270
+ 'location' => 'query',
271
+ 'type' => 'integer',
272
+ ),
273
+ 'start-index' => array(
274
+ 'location' => 'query',
275
+ 'type' => 'integer',
276
+ ),
277
+ ),
278
+ ),
279
+ )
280
+ )
281
+ );
282
+ $this->management_accountUserLinks = new Google_Service_Analytics_ManagementAccountUserLinks_Resource(
283
+ $this,
284
+ $this->serviceName,
285
+ 'accountUserLinks',
286
+ array(
287
+ 'methods' => array(
288
+ 'delete' => array(
289
+ 'path' => 'management/accounts/{accountId}/entityUserLinks/{linkId}',
290
+ 'httpMethod' => 'DELETE',
291
+ 'parameters' => array(
292
+ 'accountId' => array(
293
+ 'location' => 'path',
294
+ 'type' => 'string',
295
+ 'required' => true,
296
+ ),
297
+ 'linkId' => array(
298
+ 'location' => 'path',
299
+ 'type' => 'string',
300
+ 'required' => true,
301
+ ),
302
+ ),
303
+ ),'insert' => array(
304
+ 'path' => 'management/accounts/{accountId}/entityUserLinks',
305
+ 'httpMethod' => 'POST',
306
+ 'parameters' => array(
307
+ 'accountId' => array(
308
+ 'location' => 'path',
309
+ 'type' => 'string',
310
+ 'required' => true,
311
+ ),
312
+ ),
313
+ ),'list' => array(
314
+ 'path' => 'management/accounts/{accountId}/entityUserLinks',
315
+ 'httpMethod' => 'GET',
316
+ 'parameters' => array(
317
+ 'accountId' => array(
318
+ 'location' => 'path',
319
+ 'type' => 'string',
320
+ 'required' => true,
321
+ ),
322
+ 'max-results' => array(
323
+ 'location'