Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
diffdoc.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Difference between 2 documents
8  *
9  * @author Anakeen
10  * @version $Id: diffdoc.php,v 1.5 2008/08/14 09:59:14 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Dir.php");
18 /**
19  * Compare 2 documents
20  * @param Action &$action current action
21  * @global id1 int Http var : first document identifier to compare
22  * @global id2 int Http var : second document identifier to compare
23  */
24 function diffdoc(&$action)
25 {
26  $docid1 = GetHttpVars("id1");
27  $docid2 = GetHttpVars("id2");
28  if (intval($docid1) > intval($docid2)) {
29  $docid2 = GetHttpVars("id1");
30  $docid1 = GetHttpVars("id2");
31  }
32  $dbaccess = $action->dbaccess;
33  $d1 = new_doc($dbaccess, $docid1);
34  if (!$d1->isAffected()) {
35  $action->exitError(sprintf(_("Document %s not found") , $docid1));
36  }
37  $err = $d1->control("view");
38  if ($err != "") $action->exitError($err);
39  $d2 = new_doc($dbaccess, $docid2);
40  if (!$d2->isAffected()) {
41  $action->exitError(sprintf(_("Document %s not found") , $docid2));
42  }
43  $err = $d2->control("view");
44  if ($err != "") $action->exitError($err);
45 
46  if ($d1->fromid != $d2->fromid) $action->exitError(sprintf(_("cannot compare two document which comes from two different family")));
47 
48  $la = $d1->GetNormalAttributes();
49 
50  $tattr = array();
51  foreach ($la as $k => $a) {
52 
53  if ($a->type == "array") {
54  $v1 = $d1->getArrayRawValues($a->id);
55  $v2 = $d2->getArrayRawValues($a->id);
56  if ($v1 == $v2) $cdiff = "eq";
57  else $cdiff = "ne";
58  } else {
59  $v1 = $d1->getRawValue($a->id);
60  $v2 = $d2->getRawValue($a->id);
61  if ($v1 == $v2) $cdiff = "eq";
62  else $cdiff = "ne";
63  }
64 
65  if ($a->visibility == "H") $vdiff = "hi";
66  else $vdiff = $cdiff;
67 
68  if (!$a->inArray()) {
69 
70  switch ($a->type) {
71  case "image":
72  $tattr[$a->id] = array(
73  "attname" => htmlspecialchars($a->getLabel() , ENT_QUOTES) ,
74  "v1" => sprintf("<img src=\"%s\">", $d1->getHtmlValue($a, $v1)) ,
75  "v2" => sprintf("<img src=\"%s\">", $d2->getHtmlValue($a, $v2)) ,
76  "cdiff" => htmlspecialchars($cdiff, ENT_QUOTES) ,
77  "vdiff" => htmlspecialchars($vdiff, ENT_QUOTES) ,
78  "EQ" => ($cdiff == "eq")
79  );
80  break;
81 
82  default:
83  $tattr[$a->id] = array(
84  "attname" => htmlspecialchars($a->getLabel() , ENT_QUOTES) ,
85  "v1" => $d1->getHtmlValue($a, $v1) ,
86  "v2" => $d2->getHtmlValue($a, $v2) ,
87  "cdiff" => htmlspecialchars($cdiff, ENT_QUOTES) ,
88  "vdiff" => htmlspecialchars($vdiff, ENT_QUOTES) ,
89  "EQ" => ($cdiff == "eq")
90  );
91  }
92  }
93  }
94 
95  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/subwindow.js");
96  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL") . "/FDL/Layout/common.js");
97  $action->lay->eset("document1", $d1->title);
98  $action->lay->rSet("id1", $d1->id);
99  $action->lay->eSet("date1", strftime("%a %d %b %Y %H:%M", $d1->revdate));
100  $action->lay->eSet("version1", $d1->version);
101  $action->lay->eSet("revision1", $d1->revision);
102 
103  $action->lay->eSet("document2", $d2->title);
104  $action->lay->rSet("id2", $d2->id);
105  $action->lay->eSet("date2", strftime("%a %d %b %Y %H:%M", $d2->revdate));
106  $action->lay->eSet("version2", $d2->version);
107  $action->lay->eSet("revision2", $d2->revision);
108 
109  $action->lay->rSet("title", sprintf(_("comparison between<br>%s (rev %d) and %s (rev %d)") , $d1->getHTMLTitle() , htmlspecialchars($d1->revision, ENT_QUOTES) , $d2->getHTMLTitle() , htmlspecialchars($d2->revision, ENT_QUOTES)));
110 
111  $action->lay->setBlockData("ATTRS", $tattr);
112 }
global $action
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
Definition: checklist.php:45
diffdoc(&$action)
Definition: diffdoc.php:24
$d1
Definition: dav.php:11
$d2
Definition: dav.php:67
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen