Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
impcard.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 only - without any menu
9  *
10  * @author Anakeen 2000
11  * @version $Id: impcard.php,v 1.11 2008/02/08 09:50:26 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 
21 function impcard(&$action)
22 {
23  // GetAllParameters
24  $mime = GetHttpVars("mime"); // send to be view by word editor
25  $ext = GetHttpVars("ext", "html"); // extension
26  $docid = GetHttpVars("id");
27  $zonebodycard = GetHttpVars("zone"); // define view action
28  $valopt = GetHttpVars("opt"); // value of options
29  $vid = GetHttpVars("vid"); // special controlled view
30  $state = GetHttpVars("state"); // search doc in this state
31  $inline = (strtolower(substr(getHttpVars("inline") , 0, 1)) == "y"); // view file inline
32  $latest = GetHttpVars("latest");
33  $view = GetHttpVars("view"); // if print view css print
34  $szone = false;
35 
36  $dbaccess = $action->GetParam("FREEDOM_DB");
37  $action->lay->set("viewprint", ($view == "print"));
38  if ($valopt != "") {
39  include_once ("FDL/editoption.php");
41  $docid = $doc->id;
42  } else {
44  }
45 
46  if ($state != "") {
47  $docid = $doc->getRevisionState($state, true);
48  if ($docid == 0) {
49  $action->exitError(sprintf(_("Document %s in %s state not found") , $doc->title, _($state)));
50  }
51  SetHttpVar("id", $docid);
52  } else {
53  if (($latest == "Y") && ($doc->locked == - 1)) {
54  // get latest revision
55  $docid = $doc->latestId();
56  SetHttpVar("id", $docid);
57  } else if (($latest == "L") && ($doc->lmodify != 'L')) {
58  // get latest fixed revision
59  $docid = $doc->latestId(true);
60  SetHttpVar("id", $docid);
61  } else if (($latest == "P") && ($doc->revision > 0)) {
62  // get previous fixed revision
63  $pdoc = getRevTDoc($dbaccess, $doc->initid, $doc->revision - 1);
64  $docid = $pdoc["id"];
65  SetHttpVar("id", $docid);
66  }
67  }
68  $action->lay->set("TITLE", $doc->getTitle());
69  if (($zonebodycard == "") && ($vid != "")) {
70  $cvdoc = new_Doc($dbaccess, $doc->cvid);
71  $tview = $cvdoc->getView($vid);
72  $zonebodycard = $tview["CV_ZVIEW"];
73  }
74  if ($zonebodycard == "") $zonebodycard = $doc->defaultview;
75  if ($zonebodycard == "") $zonebodycard = "FDL:VIEWCARD";
76 
77  $zo = $doc->getZoneOption($zonebodycard);
78  if ($zo == "B") {
79  // binary layout file
80  $ulink = false;
81  $target = "ooo";
82  $file = $doc->viewdoc($zonebodycard, $target, $ulink);
83  Http_DownloadFile($file, $doc->title . ".odt", 'application/vnd.oasis.opendocument.text', false, false);
84  @unlink($file);
85  exit;
86  }
87 
88  if ($zo == 'S') $szone = true; // the zonebodycard is a standalone zone ?
89  $action->lay->set("nocss", ($zo == "U"));
90  if ($szone) {
91  // change layout
92  include_once ("FDL/viewscard.php");
93  $action->lay = new Layout(getLayoutFile("FDL", "viewscard.xml") , $action);
95  }
96 
97  if ($mime != "") {
98  $export_file = uniqid(getTmpDir() . "/export") . ".$ext";
99 
100  $of = fopen($export_file, "w+");
101  fwrite($of, $action->lay->gen());
102  fclose($of);
103  http_DownloadFile($export_file, chop($doc->title) . ".$ext", "$mime", $inline, false);
104 
105  unlink($export_file);
106  exit;
107  }
108 }
109 ?>
← centre documentaire © anakeen - published under CC License - Dynacase