Core  3.2
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  * @package FDL
5 */
6 /**
7  * View Document History
8  *
9  * @author Anakeen
10  * @version $Id: viewhisto.php,v 1.27 2009/01/04 18:36:37 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
19 {
20  $dbaccess = $action->dbaccess;
21  $docid = GetHttpVars("id", 0);
22  $viewapp = GetHttpVars("viewapp", "FDL");
23  $viewact = GetHttpVars("viewact", "FDL_CARD");
24  $target = GetHttpVars("target", "");
25  $viewrev = (GetHttpVars("viewrev", "Y") == "Y");
26  $comment = GetHttpVars("comment", _("no comment"));
27  $notice = (GetHttpVars("notice", "Y") == "Y"); // view notice
28  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/subwindow.js");
29  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL") . "/FDL/Layout/common.js");
30  $action->parent->addJsRef("lib/jquery/jquery.js");
31  $action->parent->addJsRef("lib/jquery-ui/js/jquery-ui.js");
32  $action->parent->addCssRef("css/dcp/jquery-ui.css");
33  $action->parent->addJsRef("lib/jquery-dataTables/js/jquery.dataTables.min.js");
34  $action->parent->addCssRef("lib/jquery-dataTables/css/jquery.dataTables_themeroller.css");
35  $action->parent->addJsRef("FDL/Layout/viewhisto.js");
36 
37  $localeconfig = getLocaleConfig();
38  if ($localeconfig !== false) {
39  $formatDate = $localeconfig['dateFormat'] . " %H:%M:%S";
40  } else {
41  $formatDate = '';
42  }
43  $doc = new_Doc($dbaccess, $docid, true);
44 
45  if ($doc->wid) {
46  $action->lay->Set("lastState", $doc->getStateActivity(_("Current_state")));
47  } else {
48  $action->lay->Set("lastState", $doc->getHtmlTitle());
49  }
50  $action->lay->Set("lastRevision", $doc->revision);
51  $action->lay->eSet("lastOwner", Account::getDisplayName($doc->owner));
52 
53  $action->lay->Set("lastColor", $doc->getStateColor('transparent'));
54  $action->lay->Set("docid", $doc->id);
55  $action->lay->Set("lastDate", stringDateToLocaleDate(strftime("%Y-%m-%d %T", $doc->revdate) , $formatDate));
56  $action->lay->Set("pastRevision", ($doc->revision > 0));
57  $tc = $doc->getHisto();
58  $tlc = array();
59  foreach ($tc as $vc) {
60  if ((!$notice) && ($vc["level"] < HISTO_INFO)) {
61  $hasnotice = true;
62  continue;
63  }
64  $stime = $vc["date"];
65  /* 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])",
66  $reg[1], $regt)) {
67  $stime=strftime ("%a %d %b %Y %H:%M",mktime($regt[4],$regt[5],$regt[6],$regt[2],$regt[1],$regt[3]));
68  } else $stime=$reg[1];
69  */
70  $tlc[] = array(
71  "cdate" => stringDateToLocaleDate($stime, $formatDate) ,
72  "cauthor" => htmlspecialchars($vc["uname"]),
73  "clevel" => $vc["level"],
74  "ccomment" => nl2br(htmlentities($vc["comment"], ENT_COMPAT, "UTF-8"))
75  );
76  }
77  $action->lay->SetBlockData("LASTCOMMENT", $tlc);
78 
79  $action->lay->Set("title", $doc->getHTMLTitle());
80  $action->lay->eSet("target", $target);
81  $action->lay->eSet("VIEWAPP", $viewapp);
82  $action->lay->eSet("VIEWACT", $viewact);
83  $action->lay->eSet("VIEWREV", $viewrev);
84  $action->lay->eSet("notice", $notice);
85  $hastate = false;
86 
87  $s = new SearchDoc($action->dbaccess);
88  $s->addFilter("initid = %d", $doc->initid);
89  $s->setOrder("revision desc");
90  $s->latest = false;
91  $s->setObjectReturn();
92  $dl = $s->search()->getDocumentList();
93 
94  $hasnotice = false;
95  $trdoc = array();
96  $tversion = array();
97  $iversion = 0;
98  $hasVersion = false;
99  /*
100  * @var Doc $rdoc
101  */
102  foreach ($dl as $k => $rdoc) {
103  if ($rdoc->locked != - 1) continue;
104  if ($rdoc->control('view')) continue;
105  $trdoc[$k]["owner"] = htmlspecialchars(Account::getDisplayName($rdoc->owner));
106  if ($k == 0) $trdoc[$k]["owner"] = _("Modification date");
107 
108  $trdoc[$k]["revision"] = $rdoc->revision;
109  $trdoc[$k]["version"] = htmlspecialchars($rdoc->version);
110  $trdoc[$k]["target"] = ($target == "") ? "doc_" . $rdoc->id : $target;
111 
112  $state = $rdoc->getState();
113  $color = $rdoc->getStateColor();
114  $sact = $rdoc->getStateActivity(_("Current_state"));
115  $trdoc[$k]["state"] = ($state == "") ? $rdoc->getHTMLTitle() : _($state);
116  $hastate = $hastate | ($state != "");
117  $trdoc[$k]["color"] = ($color == "") ? "transparent" : $color;
118 
119  $trdoc[$k]["date"] = stringDateToLocaleDate(strftime("%Y-%m-%d %T", $rdoc->revdate) , $formatDate);
120  // special table for versions
121  if (!in_array($rdoc->version, array_keys($tversion))) {
122  $tversion[$rdoc->version] = "vtr" . $iversion++;
123  $trdoc[$k]["cversion"] = true;
124  } else {
125  $trdoc[$k]["cversion"] = false;
126  }
127  $trdoc[$k]["vername"] = $tversion[$rdoc->version];
128  if ($rdoc->version) $hasVersion = true;
129  $trdoc[$k]["COMMENT"] = "COMMENT$k";
130 
131  $tc = $rdoc->getHisto();
132  $tlc = array();
133  $kc = 0; // index comment
134  foreach ($tc as $vc) {
135  if ((!$notice) && ($vc["level"] < HISTO_INFO)) {
136  $hasnotice = true;
137  continue;
138  }
139  $stime = $vc["date"];
140  /* 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])",
141  $reg[1], $regt)) {
142  $stime=strftime ("%a %d %b %Y %H:%M",mktime($regt[4],$regt[5],$regt[6],$regt[2],$regt[1],$regt[3]));
143  } else $stime=$reg[1];
144  */
145  $tlc[] = array(
146  "cdate" => stringDateToLocaleDate($stime, $formatDate) ,
147  "cauthor" => htmlspecialchars($vc["uname"]),
148  "clevel" => $vc["level"],
149  "ccomment" => nl2br(htmlentities($vc["comment"], ENT_COMPAT, "UTF-8"))
150  );
151  }
152  $action->lay->SetBlockData("COMMENT$k", $tlc);
153 
154  $trdoc[$k]["id"] = $rdoc->id;
155  $trdoc[$k]["divid"] = $k;
156  }
157  if (!$hasnotice) $action->lay->Set("notice", true);
158  // not display detail display
159  $action->lay->Set("STATE", $hastate);
160  $action->lay->Set("viewdiff", ($s->count() > 1));
161  $action->lay->Set("nodetail", ($iversion > 1));
162 
163  $action->lay->Set("hasversion", $hasVersion);
164  $action->lay->eSet("latestVersion", $doc->version);
165  $action->lay->SetBlockData("TABLEBODY", $trdoc);
166 }
$comment
Definition: fdl_execute.php:35
global $action
const HISTO_INFO
stringDateToLocaleDate($fdate, $format= '')
Definition: Lib.Util.php:98
if($famId) $s
getLocaleConfig($core_lang= '')
Definition: Lib.Common.php:853
Set($name, &$parent)
$docid
Definition: cleanFamily.php:13
static getDisplayName($uid)
viewhisto(Action &$action)
Definition: viewhisto.php:18
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
← centre documentaire © anakeen