Core  3.2
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  * @package FDL
5 */
6 /**
7  * View document only - without any menu
8  *
9  * @author Anakeen
10  * @version $Id: impcard.php,v 1.11 2008/02/08 09:50:26 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 
19 function impcard(Action & $action)
20 {
21  // GetAllParameters
22  $usage = new ActionUsage($action);
23  $usage->setDefinitionText("view document in HTML page");
24  $docid = $usage->addRequiredParameter("id", "document identifier");
25  $mime = $usage->addOptionalParameter("mime", "other mime type header to send");
26  $ext = $usage->addOptionalParameter("ext", "file extension if inline is no", null, "html");
27  $inline = $usage->addOptionalParameter("inline", "inline (yes|no) - if set to 'no', mime must be set also");
28  $inline = (strtolower(substr($inline, 0, 1)) == "y"); // view file inline
29  $zonebodycard = $usage->addOptionalParameter("zone", "special document view zone");
30  $vid = $usage->addOptionalParameter("vid", "special controlled view");
31  $state = $usage->addOptionalParameter("state", "search doc in this state");
32  $latest = $usage->addOptionalParameter("latest", "get document in latest version if Y", array(
33  "Y",
34  "N",
35  "L",
36  "P"
37  ));
38  $view = $usage->addOptionalParameter("view", "add view css print", array(
39  "print"
40  ));
41 
42  $usage->setStrictMode(false);
43  $usage->verify();
44  $szone = false;
45 
46  $dbaccess = $action->dbaccess;
47  $action->lay->rSet("viewprint", ($view == "print"));
48 
50 
51  $action->parent->addCssRef("css/dcp/main.css");
52  if ($state != "") {
53  $docid = $doc->getRevisionState($state, true);
54  if ($docid == 0) {
55  $action->exitError(sprintf(_("Document %s in %s state not found") , $doc->title, _($state)));
56  }
57  SetHttpVar("id", $docid);
58  } else {
59  if (($latest == "Y") && ($doc->locked == - 1)) {
60  // get latest revision
61  $docid = $doc->getLatestId();
62  SetHttpVar("id", $docid);
63  } else if (($latest == "L") && ($doc->lmodify != 'L')) {
64  // get latest fixed revision
65  $docid = $doc->getLatestId(true);
66  SetHttpVar("id", $docid);
67  } else if (($latest == "P") && ($doc->revision > 0)) {
68  // get previous fixed revision
69  $pdoc = getRevTDoc($dbaccess, $doc->initid, $doc->revision - 1);
70  $docid = $pdoc["id"];
71  SetHttpVar("id", $docid);
72  }
73  }
74  $action->lay->eset("TITLE", $doc->getTitle());
75  if (($zonebodycard == "") && ($vid != "")) {
76  /**
77  * @var \Dcp\Family\CVDOC $cvdoc
78  */
79  $cvdoc = new_Doc($dbaccess, $doc->cvid);
80  $tview = $cvdoc->getView($vid);
81  $zonebodycard = $tview["CV_ZVIEW"];
82  }
83  if ($zonebodycard == "") $zonebodycard = $doc->defaultview;
84  if ($zonebodycard == "") $zonebodycard = "FDL:VIEWCARD";
85 
86  $zo = $doc->getZoneOption($zonebodycard);
87  if ($zo == "B") {
88  // binary layout file
89  $ulink = false;
90  $target = "ooo";
91  $file = $doc->viewdoc($zonebodycard, $target, $ulink);
92  Http_DownloadFile($file, $doc->title . ".odt", 'application/vnd.oasis.opendocument.text', false, false);
93  @unlink($file);
94  exit;
95  }
96 
97  if ($zo == 'S') $szone = true; // the zonebodycard is a standalone zone ?
98  $action->lay->rSet("nocss", ($zo == "U"));
99  if ($szone) {
100  // change layout
101  include_once ("FDL/viewscard.php");
102  $action->lay = new Layout(getLayoutFile("FDL", "viewscard.xml") , $action);
103  viewscard($action);
104  }
105 
106  if ($mime != "") {
107  $export_file = uniqid(getTmpDir() . "/export") . ".$ext";
108 
109  $of = fopen($export_file, "w+");
110  fwrite($of, $action->lay->gen());
111  fclose($of);
112  http_DownloadFile($export_file, chop($doc->title) . ".$ext", "$mime", $inline, false);
113 
114  unlink($export_file);
115  exit;
116  }
117 }
Layout is a template generator.
viewscard(&$action)
Definition: viewscard.php:32
global $action
SetHttpVar($name, $def)
Definition: Lib.Http.php:150
$file
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
getLayoutFile($app, $layfile)
Definition: Lib.Common.php:258
Verify arguments for action function.
getTmpDir($def= '/tmp')
Definition: Lib.Common.php:150
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
$usage
$latest
← centre documentaire © anakeen