diff --git a/admin/admin.php b/admin/admin.php
index 009e854..268734f 100755
--- a/admin/admin.php
+++ b/admin/admin.php
@@ -280,6 +280,7 @@ className: 'select-checkbox',
{data: 'select'},
{data: 'id'},
{data: 'PID'},
+ {data: 'redirect'},
//{data: 'LOCAL_ID'},
{data: 'ark_url'},
{data: 'metadata'},
@@ -313,21 +314,21 @@ className: 'select-checkbox',
orderable: false,
targets: 4
},
- /*{
+ {
"targets": 3,
- "data": "LOCAL_ID",
+ "data": "redirect",
"render": function (data, type, row) {
if (data) {
return data;
} else {
- return " ";
+ return "0";
}
}
- },*/
+ },
{
- "targets": 4,
+ "targets": 5,
"data": "metadata",
"render": function (data, type, row) {
if (data !== undefined && data.indexOf("|") != -1) {
@@ -348,7 +349,7 @@ className: 'select-checkbox',
}
},
{
- "targets": 3,
+ "targets": 4,
"data": "ark_url",
"render": function (data, type, row) {
data.sort();
@@ -1337,6 +1338,7 @@ function processPostSuccess(index, csvResult, data) {
|
Ark ID |
PID |
+ Number of Redirects |
Ark URL |
Metadata |
diff --git a/admin/rest.php b/admin/rest.php
index 0ba106c..d01b342 100644
--- a/admin/rest.php
+++ b/admin/rest.php
@@ -313,6 +313,8 @@ function selectBound()
$r['PID'] = (!empty($column['_value'])) ? $column['_value'] : ' ';
if ($key_data[1] == "LOCAL_ID")
$r['LOCAL_ID'] = (!empty($column['_value'])) ? $column['_value'] : ' ';
+ if ($key_data[1] == "REDIRECT")
+ $r['redirect'] = (!empty($column['_value'])) ? $column['_value'] : ' ';
$r['metadata'] = (!empty($r['metadata']) ? $r['metadata'] . "|" : "") . $key_data[1] .':' .$column['_value'];
// check if server have https://, if not, go with http://
diff --git a/resolver.php b/resolver.php
index c89a9c2..bbad8bb 100644
--- a/resolver.php
+++ b/resolver.php
@@ -70,6 +70,9 @@
if (!empty($result)) {
// found URL field bound associated with the ark id
$url = $result;
+
+ // TODO: add a counter here
+ increase_reidrection($db, $arkid);
break;
}
}
@@ -84,6 +87,9 @@
// found URL field bound associated with the ark id
$dns = getNAA($db);
$url = "https://$dns/islandora/object/" . $pid;
+
+ // TODO: add a counter here
+ increase_reidrection($db, $arkid);
break;
}
}
@@ -95,6 +101,45 @@
print "invalid argument";
}
+/**
+ * Counting redirection
+ */
+function increase_reidrection($db, $ark_id) {
+
+// TODO UPDATE REDIRECTION COUNT HERE
+ $link = mysqli_connect(MysqlArkConf::$mysql_host, MysqlArkConf::$mysql_user, MysqlArkConf::$mysql_passwd, MysqlArkConf::$mysql_dbname);
+
+ if (!$link) {
+ echo "Error: Unable to connect to MySQL." . PHP_EOL;
+ echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
+ echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
+ exit;
+ }
+
+ // get existed redirection count.
+ $count = lookup($db, $ark_id, "REDIRECT");
+ if ($count == false) {
+ $count = 1;
+ // do insert
+ $query = "INSERT INTO `$db` (_key, _value) VALUES('$ark_id REDIRECT', $count)";
+ }
+ else {
+ $where = 'WHERE _key regexp "(^|[[:space:]])'.$ark_id.'([[:space:]])REDIRECT$"';
+ $count++;
+ // do update
+ $query = "UPDATE `$db` SET _value = $count ". $where;
+ }
+
+ $count++;
+ if (mysqli_query($link, $query)) {
+ echo "New record created successfully";
+ }
+ else {
+ echo "New record created failed";
+ }
+ mysqli_close($link);
+}
+
/**
* Get Org registered info
*/