Platform  3.1
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  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * View Document
9  *
10  * @author Anakeen 2000
11  * @version $Id: fdl_card.php,v 1.42 2008/12/02 15:20:52 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.Dir.php");
20 /**
21  * View a document
22  * @param Action &$action current action
23  * @global id Http var : document identificator to see
24  * @global latest Http var : (Y|N|L|P) if Y force view latest revision, L : latest fixed revision, P : previous revision
25  * @global state Http var : to view document in latest fixed state (only if revision > 0)
26  * @global abstract Http var : (Y|N) if Y view only abstract attribute
27  * @global props Http var : (Y|N) if Y view properties also
28  * @global zonebodycard Http var : if set, view other specific representation
29  * @global vid Http var : if set, view represention describe in view control (can be use only if doc has controlled view)
30  * @global ulink Http var : (Y|N)if N hyperlink are disabled
31  * @global target Http var : is set target of hyperlink can change (default _self)
32  * @global inline Http var : (Y|N) set to Y for binary template. View in navigator
33  * @global reload Http var : (Y|N) if Y update freedom folders in client navigator
34  * @global dochead Http var : (Y|N) if N don't see head of document (not title and icon)
35  * @global unlock Http var : (Y|N) set to Y to unlock the document before viewing (default N)
36  */
37 function fdl_card(&$action)
38 {
39  // -----------------------------------
40  $docid = GetHttpVars("id");
41  $latest = GetHttpVars("latest");
42  $zone = GetHttpVars("zone");
43  $ulink = (GetHttpVars("ulink", '2')); // add url link
44  $target = GetHttpVars("target"); // may be mail
45  $vid = GetHttpVars("vid"); // special controlled view
46  $state = GetHttpVars("state"); // search doc in this state
47  $inline = getHttpVars("inline" == "Y"); // view file inline
48  $unlock = (getHttpVars("unlock", "N") == "Y");
49 
50  $dbaccess = $action->GetParam("FREEDOM_DB");
51 
52  if ($docid == "") $action->exitError(_("no document reference"));
53  if (!is_numeric($docid)) $docid = getIdFromName($dbaccess, $docid);
54  if (intval($docid) == 0) $action->exitError(sprintf(_("unknow logical reference '%s'") , GetHttpVars("id")));
56  if (!$doc->isAffected()) {
57  $err = simpleQuery($dbaccess, sprintf("select id from dochisto where id=%d limit 1", $docid) , $hashisto, true, true);
58  if ($hashisto) $action->exitError(sprintf(_("Document %s has been destroyed.") , $docid) . sprintf(" <a href='?app=FDL&action=VIEWDESTROYDOC&id=%s>%s</a>", $docid, _("See latest information about it.")));
59  else $action->exitError(sprintf(_("cannot see unknow reference %s") , $docid));
60  }
61 
62  if ($unlock) {
63  $err = $doc->UnLock(true);
64  if ($err != "") $action->ExitError($err);
65  }
66 
67  if ($state != "") {
68  $docid = $doc->getRevisionState($state, true);
69  if ($docid == 0) {
70  $action->exitError(sprintf(_("Document %s in %s state not found") , $doc->title, _($state)));
71  }
72  SetHttpVar("id", $docid);
73  } else {
74  if (($latest == "Y") && ($doc->locked == - 1)) {
75  // get latest revision
76  $docid = $doc->latestId();
77  if ($docid == "") $action->exitError(_("no alive document reference"));
78  SetHttpVar("id", $docid);
79  } else if (($latest == "L") && ($doc->lmodify != 'L')) {
80  // get latest fixed revision
81  $docid = $doc->latestId(true);
82  SetHttpVar("id", $docid);
83  } else if (($latest == "P") && ($doc->revision > 0)) {
84  // get previous fixed revision
85  $pdoc = getRevTDoc($dbaccess, $doc->initid, $doc->revision - 1);
86  $docid = $pdoc["id"];
87  SetHttpVar("id", $docid);
88  }
89  }
90 
91  if ($docid != $doc->id) $doc = new_doc($dbaccess, $docid);
92 
93  SetHttpVar("viewbarmenu", 1);
94 
95  $action->lay->set("RSS", ($doc->getValue("gui_isrss")));
96  $action->lay->set("rsslink", $doc->getRssLink());
97  $action->lay->Set("TITLE", $doc->getHtmlTitle());
98  $action->lay->Set("id", $doc->id);
99  $action->lay->Set("initid", $doc->initid);
100  if ($action->read("navigator") == "EXPLORER") $action->lay->Set("shorticon", getParam("DYNACASE_FAVICO"));
101  else $action->lay->Set("shorticon", $doc->getIcon());
102  $action->lay->Set("docicon", $doc->getIcon('', 16));
103  $action->lay->Set("pds", $doc->urlWhatEncodeSpec(""));
104 
105  $action->lay->Set("forum", false);
106  if (($doc->doctype == 'F' || $doc->doctype == 'D') && abs(intval($doc->forumid)) > 0) {
107  $action->lay->Set("forumid", abs($doc->forumid));
108  $action->lay->Set("forum", ($doc->forumid != "" ? true : false));
109  }
110 
111  if (($zone == "") && ($vid != "")) {
112  $cvdoc = new_Doc($dbaccess, $doc->cvid);
113  if ($cvdoc->fromid == 28) {
114  $cvdoc->set($doc);
115 
116  $err = $cvdoc->control(trim($vid)); // control special view
117  if ($err != "") $action->exitError("CV:" . $cvdoc->title . "\n" . $err);
118  $tview = $cvdoc->getView($vid);
119  $zone = $tview["CV_ZVIEW"];
120  }
121  }
122  if ($zone == "") $zone = $doc->defaultview;
123  $zo = $doc->getZoneOption($zone);
124  if ($zo == "Sxxxxxxxxx") { // waiting for special zone contradiction
125  $action->lay = new Layout(getLayoutFile("FDL", "viewscard.xml") , $action);
126  $action->lay->set("ZONESCARD", $doc->viewdoc($zone, $target, $ulink));
127  } else {
128  $engine = $doc->getZoneTransform($zone);
129  if ($engine) {
130  $sgets = fdl_getGetVars();
131  redirect($action, "FDL", "GETFILETRANSFORMATION&idv=$vid&zone=$zone$sgets&id=" . $doc->id, $action->GetParam("CORE_STANDURL"));
132  exit;
133  }
134  if ($zo == "B") {
135  // binary layout file
136  if ($tview["CV_MSKID"]) $doc->setMask($tview["CV_MSKID"]);
137  $file = $doc->viewdoc($zone, $target, $ulink);
138  if ((!file_exists($file))) { // error in file generation
139  $action->lay->template = $file;
140  return;
141  }
142 
143  $ext = getFileExtension($file);
144  if ($ext == '') $ext = "html";
145  $mime = getSysMimeFile($file, basename($file));
146  // print "$file,".$doc->title.".$ext $mime"; exit;
147  Http_DownloadFile($file, $doc->title . ".$ext", $mime, $inline, false);
148  @unlink($file);
149  exit;
150  } else {
151  $action->lay->set("nocss", ($zo == "U"));
152  $taction = array();
153  if ($doc->doctype != 'C' && $doc->doctype != 'Z') {
154  $listattr = $doc->GetActionAttributes();
155  $mwidth = $action->getParam("FDL_HD2SIZE", 300);
156  $mheight = $action->getParam("FDL_VD2SIZE", 400);
157  foreach ($listattr as $k => $v) {
158  if (($v->mvisibility != "H") && ($v->mvisibility != "O")) {
159  if ($v->getOption("onlymenu") != "yes") {
160  $mvis = MENU_ACTIVE;
161  if ($v->precond != "") $mvis = $doc->ApplyMethod($v->precond, MENU_ACTIVE);
162  if ($mvis == MENU_ACTIVE) {
163  $taction[$k] = array(
164  "wadesc" => $v->getOption("llabel") ,
165  "walabel" => ucfirst($v->getLabel()) ,
166  "wwidth" => $v->getOption("mwidth", $mwidth) ,
167  "wheight" => $v->getOption("mheight", $mheight) ,
168  "wtarget" => ($v->getOption("ltarget") == "") ? $v->id . "_" . $doc->id : $v->getOption("ltarget") ,
169  "wlink" => $doc->urlWhatEncode($v->getLink($doc->latestId()))
170  );
171  }
172  }
173  }
174  }
175  }
176  $action->lay->setBlockData("WACTION", $taction);
177  $action->lay->set("VALTERN", ($action->GetParam("FDL_VIEWALTERN", "yes") == "yes"));
178  }
179  }
180 }
181 
182 function fdl_getGetVars()
183 {
184  global $_GET;
185 
186  $exclude = array(
187  "app",
188  "action",
189  "sole",
190  "id",
191  "zone"
192  );
193  $s = '';
194  foreach ($_GET as $k => $v) {
195  if (!in_array($k, $exclude)) $s.= "&$k=$v";
196  }
197 
198  return $s;
199 }
200 ?>
← centre documentaire © anakeen - published under CC License - Dynacase