Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
fdl_card.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * View Document
8  *
9  * @author Anakeen
10  * @version $Id: fdl_card.php,v 1.42 2008/12/02 15:20:52 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Dir.php");
18 /**
19  * View a document
20  * @param Action &$action current action
21  * @global string $id Http var : document identifier to see
22  * @global string $latest Http var : (Y|N|L|P) if Y force view latest revision, L : latest fixed revision, P : previous revision
23  * @global string $state Http var : to view document in latest fixed state (only if revision > 0)
24  * @global string $abstract Http var : (Y|N) if Y view only abstract attribute
25  * @global string $props Http var : (Y|N) if Y view properties also
26  * @global string $zonebodycard Http var : if set, view other specific representation
27  * @global string $vid Http var : if set, view represention describe in view control (can be use only if doc has controlled view)
28  * @global string $ulink Http var : (Y|N)if N hyperlink are disabled
29  * @global string $target Http var : is set target of hyperlink can change (default _self)
30  * @global string $inline Http var : (Y|N) set to Y for binary template. View in navigator
31  * @global string $reload Http var : (Y|N) if Y update freedom folders in client navigator
32  * @global string $dochead Http var : (Y|N) if N don't see head of document (not title and icon)
33  * @global string $unlock Http var : (Y|N) set to Y to unlock the document before viewing (default N)
34  */
35 function fdl_card(&$action)
36 {
37  // -----------------------------------
38  $docid = GetHttpVars("id");
39  $latest = GetHttpVars("latest");
40  $zone = GetHttpVars("zone");
41  $ulink = (GetHttpVars("ulink", '2')); // add url link
42  $target = GetHttpVars("target"); // may be mail
43  $vid = GetHttpVars("vid"); // special controlled view
44  $state = GetHttpVars("state"); // search doc in this state
45  $inline = (getHttpVars("inline") == "Y"); // view file inline
46  $unlock = (getHttpVars("unlock", "N") == "Y");
47 
48  $dbaccess = $action->dbaccess;
49 
50  if ($docid == "") $action->exitError(_("no document reference"));
51  if (!is_numeric($docid)) $docid = getIdFromName($dbaccess, $docid);
52  if (intval($docid) == 0) $action->exitError(sprintf(_("unknow logical reference '%s'") , htmlspecialchars(GetHttpVars("id") , ENT_QUOTES)));
54  if (!$doc->isAffected()) {
55  $err = simpleQuery($dbaccess, sprintf("select id from dochisto where id=%d limit 1", $docid) , $hashisto, true, true);
56  if ($hashisto) {
57  $action->exitError(sprintf(_("Document %s has been destroyed.") , htmlspecialchars($docid, ENT_QUOTES)) . sprintf(" <a href='?app=FDL&action=VIEWDESTROYDOC&id=%s'>%s</a>", urlencode($docid) , htmlspecialchars(_("See latest information about it.") , ENT_QUOTES)) , true);
58  } else {
59  $action->exitError(htmlspecialchars(sprintf(_("cannot see unknow reference %s") , $docid)) , ENT_QUOTES);
60  }
61  }
62 
63  if ($unlock) {
64  $err = $doc->UnLock(true);
65  if ($err != "") $action->ExitError($err);
66  }
67 
69  if ($state != "") {
70  $docid = $doc->getRevisionState($state, true);
71  if ($docid == 0) {
72  $action->exitError(sprintf(_("Document %s in %s state not found") , htmlspecialchars($doc->title, ENT_QUOTES) , htmlspecialchars(_($state) , ENT_QUOTES)));
73  }
74  SetHttpVar("id", $docid);
75  } else {
76  if (($latest == "Y") && ($doc->locked == - 1)) {
77  // get latest revision
78  $docid = $doc->getLatestId();
79  if ($docid == "") $action->exitError(_("no alive document reference"));
80  SetHttpVar("id", $docid);
81  } else if (($latest == "L") && ($doc->lmodify != 'L')) {
82  // get latest fixed revision
83  $docid = $doc->getLatestId(true);
84  SetHttpVar("id", $docid);
85  } else if (($latest == "P") && ($doc->revision > 0)) {
86  // get previous fixed revision
87  $pdoc = getRevTDoc($dbaccess, $doc->initid, $doc->revision - 1);
88  $docid = $pdoc["id"];
89  SetHttpVar("id", $docid);
90  }
91  }
92 
93  if ($docid != $doc->id) $doc = new_doc($dbaccess, $docid);
94 
95  SetHttpVar("viewbarmenu", 1);
96 
97  $action->parent->addCssRef("css/dcp/main.css");
98  $action->parent->addCssRef("css/dcp/document-view.css");
99  $mgeo = $action->getParam("MVIEW_GEO");
100  $action->lay->set("mviewgeo", $mgeo);
101 
102  $action->lay->set("RSS", ($doc->getRawValue("gui_isrss") === "yes"));
103  if ($action->lay->get("RSS")) {
104  $action->lay->set("rsslink", $doc->getRssLink());
105  }
106  $action->lay->Set("TITLE", $doc->getHtmlTitle());
107  $action->lay->Set("id", $doc->id);
108  $action->lay->Set("initid", $doc->initid);
109  if ($action->read("navigator") == "EXPLORER") $action->lay->Set("shorticon", getParam("DYNACASE_FAVICO"));
110  else $action->lay->Set("shorticon", $doc->getIcon());
111  $action->lay->Set("docicon", $doc->getIcon('', 16));
112  $action->lay->Set("pds", $doc->urlWhatEncodeSpec(""));
113 
114  $tview = array();
115  if (($zone == "") && ($vid != "")) {
116  /*
117  * @var CVDoc $cvdoc
118  */
119  $cvdoc = new_Doc($dbaccess, $doc->cvid);
120  if ($cvdoc->fromid == 28) {
121  $cvdoc->set($doc);
122 
123  $err = $cvdoc->control(trim($vid)); // control special view
124  if ($err != "") $action->exitError("CV:" . htmlspecialchars($cvdoc->title, ENT_QUOTES) . "\n" . $err);
125  $tview = $cvdoc->getView($vid);
126  $zone = $tview["CV_ZVIEW"];
127  }
128  }
129  if ($zone == "") $zone = $doc->defaultview;
130  $zo = $doc->getZoneOption($zone);
131  if ($zo === "S") { // waiting for special zone contradiction
132  $action->lay->template = $doc->viewdoc($zone, $target, $ulink);
133  } else {
134  $engine = $doc->getZoneTransform($zone);
135  if ($engine) {
136  $sgets = fdl_getGetVars();
137  redirect($action, "FDL", "GETFILETRANSFORMATION&idv=$vid&zone=$zone$sgets&id=" . $doc->id, $action->GetParam("CORE_STANDURL"));
138  exit;
139  }
140  if ($zo == "B") {
141  // binary layout file
142  if (!empty($tview["CV_MSKID"])) {
143  $err = $doc->setMask($tview["CV_MSKID"]);
144  if ($err) addWarningMsg($err);
145  }
146  $file = $doc->viewdoc($zone, $target, $ulink);
147  if ((!file_exists($file))) { // error in file generation
148  $action->lay->template = $file;
149  return;
150  }
151 
153  if ($ext == '') $ext = "html";
154  $mime = getSysMimeFile($file, basename($file));
155  // print "$file,".$doc->title.".$ext $mime"; exit;
156  Http_DownloadFile($file, $doc->title . ".$ext", $mime, $inline, false);
157  @unlink($file);
158  exit;
159  } else {
160  $action->lay->set("nocss", ($zo == "U"));
161  $taction = array();
162  if ($doc->doctype != 'C' && $doc->doctype != 'Z') {
163  $listattr = $doc->GetActionAttributes();
164  $mwidth = $action->getParam("FDL_HD2SIZE", 300);
165  $mheight = $action->getParam("FDL_VD2SIZE", 400);
166  foreach ($listattr as $k => $v) {
167  if (($v->mvisibility != "H") && ($v->mvisibility != "O")) {
168  if ($v->getOption("onlymenu") != "yes") {
169  $mvis = MENU_ACTIVE;
170  if ($v->precond != "") $mvis = $doc->ApplyMethod($v->precond, MENU_ACTIVE);
171  if ($mvis == MENU_ACTIVE) {
172  $taction[$k] = array(
173  "wadesc" => $v->getOption("llabel") ,
174  "walabel" => ucfirst($v->getLabel()) ,
175  "wwidth" => $v->getOption("mwidth", $mwidth) ,
176  "wheight" => $v->getOption("mheight", $mheight) ,
177  "wtarget" => ($v->getOption("ltarget") == "") ? (($v->getOption("mtarget") == "") ? $v->id . "_" . $doc->id : $v->getOption("mtarget")) : $v->getOption("ltarget") ,
178  "wlink" => $doc->urlWhatEncode($v->getLink($doc->getLatestId()))
179  );
180  }
181  }
182  }
183  }
184  }
185  $action->lay->setBlockData("WACTION", $taction);
186  $action->lay->set("VALTERN", ($action->GetParam("FDL_VIEWALTERN", "yes") == "yes"));
187  }
188  }
189 }
190 
191 function fdl_getGetVars()
192 {
193  global $_GET;
194 
195  $exclude = array(
196  "app",
197  "action",
198  "sole",
199  "id",
200  "zone"
201  );
202  $s = '';
203  foreach ($_GET as $k => $v) {
204  if (!in_array($k, $exclude)) $s.= "&$k=$v";
205  }
206 
207  return $s;
208 }
global $action
fixMultipleAliveDocument(Doc &$doc)
SetHttpVar($name, $def)
Definition: Lib.Http.php:150
fdl_card(&$action)
Definition: fdl_card.php:35
addWarningMsg($msg)
Definition: Lib.Common.php:95
getSysMimeFile($f, $fn="")
$file
if($famId) $s
const MENU_ACTIVE
Definition: Class.Doc.php:36
$docid
Definition: cleanFamily.php:13
getFileExtension($filename)
fdl_getGetVars()
Definition: fdl_card.php:191
global $_GET
Definition: wsh.php:37
getParam($name, $def="")
must be in core or global type
Definition: Lib.Common.php:193
getHttpVars($name, $def="", $scope="all")
Definition: Lib.Http.php:124
switch($command) exit
Definition: checkVault.php:46
new_Doc($dbaccess, $id= '', $latest=false)
Http_DownloadFile($filename, $name, $mime_type= '', $inline=false, $cache=true, $deleteafter=false)
Definition: Lib.Http.php:225
getRevTDoc($dbaccess, $initid, $rev)
$dbaccess
Definition: checkVault.php:17
getIdFromName($dbaccess, $name)
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
Definition: Lib.Common.php:484
if($file) if($subject==""&&$file) if($subject=="") $err
$latest
← centre documentaire © anakeen