|
@@ -78,12 +78,11 @@ class IndexController extends Controller
|
|
|
'productCheckouts'=>"ga:productCheckouts",
|
|
|
];
|
|
|
$i=1;
|
|
|
- $datas=array_chunk($metrics,3,true);
|
|
|
- echo "<pre>";
|
|
|
- print_r($datas);exit;
|
|
|
+ $datas=array_chunk($metrics,2,true);
|
|
|
foreach($datas as $data){
|
|
|
$response = $this->getReport($analytics,$data);
|
|
|
- $this->printResults($response);
|
|
|
+ // $this->printResults($response);
|
|
|
+ $res=$this->getResults($response);
|
|
|
}
|
|
|
exit;
|
|
|
return $this->render('index');
|
|
@@ -184,6 +183,47 @@ function printResults($reports) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+function getResults($reports) {
|
|
|
+ $data=[];
|
|
|
+ for ( $reportIndex = 0; $reportIndex < count( $reports ); $reportIndex++ ) {
|
|
|
+ $item=[];
|
|
|
+ $report = $reports[ $reportIndex ];
|
|
|
+
|
|
|
+ $header = $report->getColumnHeader();
|
|
|
+ $dimensionHeaders = $header->getDimensions();
|
|
|
+ $metricHeaders = $header->getMetricHeader()->getMetricHeaderEntries();
|
|
|
+ $rows = $report->getData()->getRows();
|
|
|
+
|
|
|
+
|
|
|
+ for ( $rowIndex = 0; $rowIndex < count($rows); $rowIndex++) {
|
|
|
+ $row = $rows[ $rowIndex ];
|
|
|
+ $dimensions = $row->getDimensions();
|
|
|
+
|
|
|
+ $metrics = $row->getMetrics();
|
|
|
+ echo "<pre>";
|
|
|
+ print_r($dimensionHeaders);exit;
|
|
|
+ if($dimensionHeaders&&$dimensions){
|
|
|
+ for ($i = 0; $i < count($dimensionHeaders) && $i < count($dimensions); $i++) {
|
|
|
+ $list[$dimensionHeaders[$i]]=
|
|
|
+ print($dimensionHeaders[$i] . ": " . $dimensions[$i] . "\n\r");
|
|
|
+ echo"<br/>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($metricHeaders&&$metrics){
|
|
|
+ for ($j = 0; $j < count($metrics); $j++) {
|
|
|
+ $values = $metrics[$j]->getValues();
|
|
|
+ for ($k = 0; $k < count($values); $k++) {
|
|
|
+ $entry = $metricHeaders[$k];
|
|
|
+ print($entry->getName() . ": " . $values[$k] . "\n\r");
|
|
|
+ echo"<br/>";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
@@ -198,65 +238,5 @@ function printResults($reports) {
|
|
|
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * Login action.
|
|
|
- *
|
|
|
- * @return Response|string
|
|
|
- */
|
|
|
- public function actionLogin()
|
|
|
- {
|
|
|
- if (!Yii::$app->user->isGuest) {
|
|
|
- return $this->goHome();
|
|
|
- }
|
|
|
|
|
|
- $model = new LoginForm();
|
|
|
- if ($model->load(Yii::$app->request->post()) && $model->login()) {
|
|
|
- return $this->goBack();
|
|
|
- }
|
|
|
-
|
|
|
- $model->password = '';
|
|
|
- return $this->render('login', [
|
|
|
- 'model' => $model,
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Logout action.
|
|
|
- *
|
|
|
- * @return Response
|
|
|
- */
|
|
|
- public function actionLogout()
|
|
|
- {
|
|
|
- Yii::$app->user->logout();
|
|
|
-
|
|
|
- return $this->goHome();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Displays contact page.
|
|
|
- *
|
|
|
- * @return Response|string
|
|
|
- */
|
|
|
- public function actionContact()
|
|
|
- {
|
|
|
- $model = new ContactForm();
|
|
|
- if ($model->load(Yii::$app->request->post()) && $model->contact(Yii::$app->params['adminEmail'])) {
|
|
|
- Yii::$app->session->setFlash('contactFormSubmitted');
|
|
|
-
|
|
|
- return $this->refresh();
|
|
|
- }
|
|
|
- return $this->render('contact', [
|
|
|
- 'model' => $model,
|
|
|
- ]);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Displays about page.
|
|
|
- *
|
|
|
- * @return string
|
|
|
- */
|
|
|
- public function actionAbout()
|
|
|
- {
|
|
|
- return $this->render('about');
|
|
|
- }
|
|
|
}
|