From 50e315fe670bc09809c24e0a8fd1b5ad70c4755e Mon Sep 17 00:00:00 2001
From: PromInc
Date: Wed, 2 Sep 2015 08:41:34 -0500
Subject: [PATCH] Improved settings
- The sites list in the settings page is no longer manually created,
rather it is pulled from Google Search Console.
- A quick links file is added to the reporting page.
- Fixed broken link on home page
---
inc/code/dataCapture.php | 31 +++++++++++++++++-
inc/html/reportQuickLinks.php | 0
index.php | 9 +++---
js/script.js | 4 +--
report.php | 2 ++
settings.php | 59 ++++++++++++++++-------------------
6 files changed, 65 insertions(+), 40 deletions(-)
create mode 100644 inc/html/reportQuickLinks.php
diff --git a/inc/code/dataCapture.php b/inc/code/dataCapture.php
index c5fbd04..9cfd978 100644
--- a/inc/code/dataCapture.php
+++ b/inc/code/dataCapture.php
@@ -14,7 +14,36 @@ class DataCapture
const GOOGLE_SEARCH_ANALYTICS_MAX_DATE_OFFSET = 4;
const GOOGLE_SEARCH_ANALYTICS_MAX_DAYS = 90;
-
+
+
+ /**
+ * Get authorized sites from Google Search Console
+ *
+ * @returns Array Site URL and permission level
+ */
+ public function getSitesGoogleSearchConsole() {
+ /* Authorize Google via oAuth 2.0 */
+ $gapiOauth = new GAPIoAuth();
+ $client = $gapiOauth->LogIn();
+
+ /* Load Google Webmasters API */
+ $webmasters = new Google_Service_Webmasters($client);
+
+ /* Load sites functions */
+ $siteServices = $webmasters->sites;
+
+ /* Get list of sites */
+ $gSites = $siteServices ->listSites();
+
+ $return = array();
+ foreach( $gSites->getSiteEntry() as $site ) {
+ $return[] = array( 'url' => $site['siteUrl'], 'permission' => $site['permissionLevel'] );
+ }
+
+ return $return;
+ }
+
+
/**
* Query database. Retrun all values from a table
*
diff --git a/inc/html/reportQuickLinks.php b/inc/html/reportQuickLinks.php
new file mode 100644
index 0000000..e69de29
diff --git a/index.php b/index.php
index 316b568..33887e7 100644
--- a/index.php
+++ b/index.php
@@ -9,21 +9,20 @@
Data Capture and Import
Capture and import data from Organic Search Analytics resources.
Note: At this time only Google Search Analytics data is configured to work with this tool. In the future additional data from Google and Bing will be added, as well as reporting features.
-
+
-
+
Settings
Configure various settings for the Organic Search Analytics capture and import tool
-
\ No newline at end of file
diff --git a/js/script.js b/js/script.js
index bc8242f..269a6b5 100644
--- a/js/script.js
+++ b/js/script.js
@@ -52,10 +52,10 @@ function importAllRun(catId) {
$(".importAllButtons[category='"+catId+"'] .buttonImportAllStop").show();
/* Trigger the first import button */
- if( $("#"+catId+" .buttonImport").eq(0) ) {
+ if( $("#"+catId+" .buttonImport").length > 0 ) {
$("#"+catId+" .buttonImport").eq(0).trigger("click");
} else {
- console.log("No more data to import");
+ importAllStop();
window.importAllProcessing = false;
}
}
diff --git a/report.php b/report.php
index c138b6f..250acf4 100644
--- a/report.php
+++ b/report.php
@@ -72,4 +72,6 @@
+
+
\ No newline at end of file
diff --git a/settings.php b/settings.php
index bb66904..421ecf0 100644
--- a/settings.php
+++ b/settings.php
@@ -11,47 +11,46 @@
if( !$isConfigured ) {
echo 'Configuration file is missing
';
} else {
- echo 'Configuration is set. No further action is needed at this time.
';
+ echo 'The configuration file is set.
';
}
?>
- Google
- Sites
- The sites listed here directly correlate to the URL for the site you have configured in Google Search Console. Ensure they match what is entered in Google Search Console.
- Use the checkbox to enable/disable this site from being available to the Data Capture tool.
+ Site Setup
+ Google Search Analytics
+ Choose which sites you wish to capture data from Google Search Console.
+ Not seeing the sites you expect?
Ensure that you have enabled the Google Search Console API and added your Google API Service Account email address as a user to each of your sites in Google Search Console.
Instruction on how to configure Google Search Analytics for API Access