Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
viewhisto.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * View Document History
9  *
10  * @author Anakeen 2000
11  * @version $Id: viewhisto.php,v 1.27 2009/01/04 18:36:37 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 
19 include_once ("FDL/Class.Doc.php");
20 function viewhisto(&$action)
21 {
22  $dbaccess = $action->GetParam("FREEDOM_DB");
23  $docid = GetHttpVars("id", 0);
24  $viewapp = GetHttpVars("viewapp", "FDL");
25  $viewact = GetHttpVars("viewact", "FDL_CARD");
26  $target = GetHttpVars("target", "");
27  $viewrev = (GetHttpVars("viewrev", "Y") == "Y");
28  $comment = GetHttpVars("comment", _("no comment"));
29  $notice = (GetHttpVars("notice", "N") == "Y"); // view notice
30  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/subwindow.js");
31  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL") . "/FDL/Layout/common.js");
32 
34  $action->lay->Set("title", $doc->title);
35  $action->lay->Set("target", $target);
36  $action->lay->Set("VIEWAPP", $viewapp);
37  $action->lay->Set("VIEWACT", $viewact);
38  $action->lay->Set("VIEWREV", $viewrev);
39  $action->lay->Set("notice", $notice);
40  $hastate = false;
41  $ldoc = $doc->GetRevisions("TABLE");
42 
43  $hasnotice = false;
44  $trdoc = array();
45  $tversion = array();
46  $iversion = 0;
47  foreach ($ldoc as $k => $zdoc) {
48  $rdoc = getDocObject($dbaccess, $zdoc);
49  $owner = new User("", $rdoc->owner);
50  $trdoc[$k]["owner"] = $owner->firstname . " " . $owner->lastname;
51  if ($k == 0) $trdoc[$k]["owner"] = _("Modification date");
52 
53  $trdoc[$k]["revision"] = $rdoc->revision;
54  $trdoc[$k]["version"] = $rdoc->version;
55  $trdoc[$k]["target"] = ($target == "") ? "doc_" . $rdoc->id : $target;
56 
57  $state = $rdoc->getState();
58  $color = $rdoc->getStateColor();
59  $sact = $rdoc->getStateActivity(_("Current_state"));
60  $trdoc[$k]["state"] = ($state == "") ? "" : (($rdoc->locked == - 1) ? _($state) : sprintf("%s (%s)", $sact, _($state)));
61  $hastate = $hastate | ($state != "");
62  $trdoc[$k]["color"] = ($color == "") ? "transparent" : $color;
63  if ($action->GetParam("CORE_LANG") == "fr_FR") { // date format depend of locale
64  $trdoc[$k]["date"] = strftime("%a %d %b %Y %H:%M", $rdoc->revdate);
65  } else {
66  $trdoc[$k]["date"] = strftime("%x<BR>%T", $rdoc->revdate);
67  }
68  // special table for versions
69  if (!in_array($rdoc->version, array_keys($tversion))) {
70  $tversion[$rdoc->version] = "vtr" . $iversion++;
71  $trdoc[$k]["cversion"] = true;
72  } else {
73  $trdoc[$k]["cversion"] = false;
74  }
75  $trdoc[$k]["vername"] = $tversion[$rdoc->version];
76 
77  $trdoc[$k]["COMMENT"] = "COMMENT$k";
78 
79  $tc = $rdoc->getHisto();
80  $tlc = array();
81  $kc = 0; // index comment
82  foreach ($tc as $vc) {
83  if ((!$notice) && ($vc["level"] < HISTO_INFO)) {
84  $hasnotice = true;
85  continue;
86  }
87  $stime = $vc["date"];
88  /* if (ereg("([0-9]{1,2})/([0-9]{1,2})/([0-9]{1,4}) ([0-2]{0,1}[0-9]):([0-5]{0,1}[0-9])",
89  $reg[1], $regt)) {
90  $stime=strftime ("%a %d %b %Y %H:%M",mktime($regt[4],$regt[5],$regt[6],$regt[2],$regt[1],$regt[3]));
91  } else $stime=$reg[1];
92  */
93  $tlc[] = array(
94  "cdate" => $stime,
95  "cauthor" => $vc["uname"],
96  "clevel" => $vc["level"],
97  "ccomment" => nl2br(htmlentities($vc["comment"], ENT_COMPAT, "UTF-8"))
98  );
99  }
100  $action->lay->SetBlockData("COMMENT$k", $tlc);
101 
102  $trdoc[$k]["id"] = $rdoc->id;
103  $trdoc[$k]["divid"] = $k;
104  }
105  if (!$hasnotice) $action->lay->Set("notice", true);
106  // not display detail display
107  $action->lay->Set("STATE", $hastate);
108  $action->lay->Set("viewdiff", (count($ldoc) > 1));
109  $action->lay->Set("nodetail", ($iversion > 1));
110  $action->lay->SetBlockData("TABLEBODY", $trdoc);
111 }
112 ?>
← centre documentaire © anakeen - published under CC License - Dynacase