Beginnings of visual conflict resolution
Beginnings of visual conflict resolution


Former-commit-id: f8dfd63919aab30a6b99f6861e80a36b55f5af04

--- a/.gitmodules
+++ b/.gitmodules
@@ -7,4 +7,7 @@
 [submodule "lib/springy"]
 	path = lib/springy
 	url = https://github.com/dhotson/springy.git
+[submodule "lib/php-diff"]
+	path = lib/php-diff
+	url = https://github.com/chrisboulton/php-diff.git
 

--- a/admin/import.php
+++ b/admin/import.php
@@ -1,6 +1,6 @@
 <?php
 
-require_once 'include/common.inc.php';
+require_once '../include/common.inc.php';
 try {
     $server->create_db('disclosr-agencies');
 } catch (SetteeRestClientException $e) {

--- /dev/null
+++ b/admin/resolveConflicts.php
@@ -1,1 +1,43 @@
+<?php
 
+include_once('../include/common.inc.php');
+include_header();
+// Include the diff class
+echo '<STYLE TYPE="text/css">
+<!--
+  @import url(../lib/php-diff/example/styles.css);
+-->
+</STYLE>
+    ';
+require_once dirname(__FILE__) . '/../lib/php-diff/lib/Diff.php';
+// Generate a side by side diff
+require_once dirname(__FILE__) . '/../lib/php-diff/lib/Diff/Renderer/Html/SideBySide.php';
+$renderer = new Diff_Renderer_Html_SideBySide;
+
+
+
+$db = $server->get_db('disclosr-agencies');
+$docs = Array();
+try {
+    $rows = $db->get_view("app", "getConflicts")->rows;
+    //print_r($rows);
+    foreach ($rows as $row) {
+        echo '<h2>' . $row->id . '</h2>';
+        echo "Comparing " . $row->value[0] . " and " . $row->value[1];
+        $docA = explode(",", json_encode($db->get($row->id . "?rev=" . $row->value[0])));
+        $docB = explode(",", json_encode($db->get($row->id . "?rev=" . $row->value[1])));
+        // Options for generating the diff
+        $options = array(
+                //'ignoreWhitespace' => true,
+                //'ignoreCase' => true,
+        );
+
+        // Initialize the diff class
+        $diff = new Diff($docA, $docB, $options);
+        echo $diff->Render($renderer);
+    }
+} catch (SetteeRestClientException $e) {
+    setteErrorHandler($e);
+}
+include_footer();
+?>

--- a/admin/verify.php
+++ b/admin/verify.php
@@ -1,6 +1,6 @@
 <?php
 
-include_once('include/common.inc.php');
+include_once('../include/common.inc.php');
 include_header();
 
 $db = $server->get_db('disclosr-agencies');

--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -4,11 +4,9 @@
 
 $basePath = "";
 if (strstr($_SERVER['PHP_SELF'], "alaveteli/")
-        || strstr($_SERVER['PHP_SELF'], "myway/")
+        || strstr($_SERVER['PHP_SELF'], "admin/")
         || strstr($_SERVER['PHP_SELF'], "lib/")
-        || strstr($_SERVER['PHP_SELF'], "geo/")
-        || strstr($_SERVER['PHP_SELF'], "include/")
-        || strstr($_SERVER['PHP_SELF'], "servicealerts/"))
+        || strstr($_SERVER['PHP_SELF'], "include/"))
     $basePath = "../";
 
 include_once ('couchdb.inc.php');

--- a/include/template.inc.php
+++ b/include/template.inc.php
@@ -1,6 +1,7 @@
 <?php
 
 function include_header() {
+    global $basePath;
     ?>
     <!DOCTYPE html>
 
@@ -18,11 +19,11 @@
             <title>Disclosr</title>
 
             <!-- Included CSS Files -->
-            <link rel="stylesheet" href="stylesheets/foundation.css">
-            <link rel="stylesheet" href="stylesheets/app.css">
+            <link rel="stylesheet" href="<?php echo $basePath?>stylesheets/foundation.css">
+            <link rel="stylesheet" href="<?php echo $basePath?>stylesheets/app.css">
 
             <!--[if lt IE 9]>
-                    <link rel="stylesheet" href="stylesheets/ie.css">
+                    <link rel="stylesheet" href="<?php echo $basePath?>stylesheets/ie.css">
             <![endif]-->
 
 
@@ -62,8 +63,8 @@
 
 
             <!-- Included JS Files -->
-            <script src="javascripts/foundation.js"></script>
-            <script src="javascripts/app.js"></script>
+            <script src="<?php echo $basePath?>javascripts/foundation.js"></script>
+            <script src="<?php echo $basePath?>javascripts/app.js"></script>
             <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
 
         </body>

directory:b/lib/php-diff (new)
--- /dev/null
+++ b/lib/php-diff