Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
viewscard.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * View standalone document (without popup menu)
8  *
9  * @author Anakeen
10  * @version $Id: viewscard.php,v 1.8 2005/11/04 15:38:29 marc Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 // ---------------------------------------------------------------
17 // $Id: viewscard.php,v 1.8 2005/11/04 15:38:29 marc Exp $
18 // $Source: /home/cvsroot/anakeen/freedom/freedom/Action/Fdl/viewscard.php,v $
19 // ---------------------------------------------------------------
20 include_once ("FDL/Class.Doc.php");
21 /**
22  * View a document without standard header and footer. It is display in raw format
23  * @param Action &$action current action
24  * @global id int Http var : document identifier to see
25  * @global latest string Http var : (Y|N) if Y force view latest revision
26  * @global abstract string Http var : (Y|N) if Y view only abstract attribute
27  * @global zonebodycard string Http var : if set, view other specific representation
28  * @global vid int Http var : if set, view represention describe in view control (can be use only if doc has controlled view)
29  * @global ulink string Http var : (Y|N)if N hyperlink are disabled
30  * @global target string Http var : is set target of hyperlink can change (default _self)
31  */
32 function viewscard(&$action)
33 {
34  // GetAllParameters
35  $usage = new ActionUsage($action);
36  $usage->setStrictMode(false);
37  $docid = $usage->addRequiredParameter("id", "id of the document");
38  $abstract = ($usage->addOptionalParameter("abstract", "view only abstract's attributes", array(
39  "Y",
40  "N"
41  ) , "N") == "Y");
42  $zonebodycard = $usage->addOptionalParameter("zone", "view with another specific representation", null, "");
43  $ulink = ($usage->addOptionalParameter("ulink", "enable or disable hyperlink", array(
44  "Y",
45  "N",
46  ""
47  ) , "Y") !== "N");
48  $target = $usage->addOptionalParameter("target", "target for hyperlinks ('mail', '_self', etc.)", null, "");
49  $wedit = ($usage->addOptionalParameter("wedit", "view by word editor", array(
50  "Y",
51  "N"
52  ) , "N") == "Y");
53  $fromedit = ($usage->addOptionalParameter("fromedit", "compose temporary document", array(
54  "Y",
55  "N"
56  ) , "N") == "Y");
57  $latest = $usage->addOptionalParameter("latest", "view latest revision of document", null, "");
58  $tmime = $usage->addOptionalParameter("tmime", "MIME type", null, "");
59  $charset = $usage->addOptionalParameter("chset", "charset", null, "UTF-8");
60  $usage->verify();
61  // Set the globals elements
62  $dbaccess = $action->dbaccess;
63 
65  if (($latest == "Y") && ($doc->locked == - 1)) {
66  // get latest revision
67  $docid = $doc->getLatestId();
69  SetHttpVar("id", $docid);
70  }
71  $err = $doc->control("view");
72  if ($err != "") $action->exitError($err);
73  if ($fromedit) {
74  include_once ("FDL/modcard.php");
75 
76  $doc = $doc->duplicate(true, false, true);
78  $doc->modify();
79  setHttpVar("id", $doc->id);
80  }
81  if ($zonebodycard == "") $zonebodycard = $doc->defaultview;
82  if ($zonebodycard == "") $action->exitError(_("no zone specified"));
83 
84  $err = $doc->refresh();
85  $action->lay->Set("ZONESCARD", $doc->viewDoc($zonebodycard, $target, $ulink, $abstract));
86 
87  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/geometry.js");
88  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/subwindow.js");
89 
90  if ($wedit) {
91  $export_file = uniqid(getTmpDir() . "/export") . ".doc";
92 
93  $of = fopen($export_file, "w+");
94  fwrite($of, $action->lay->gen());
95  fclose($of);
96 
97  http_DownloadFile($export_file, chop($doc->title) . ".html", "application/msword");
98 
99  unlink($export_file);
100  exit;
101  }
102 
103  if ($tmime != "") {
104  header("Content-Type: $tmime; charset=$charset");
105  print $action->lay->gen();
106  exit;
107  }
108 }
viewscard(&$action)
Definition: viewscard.php:32
global $action
SetHttpVar($name, $def)
Definition: Lib.Http.php:150
setPostVars(Doc &$doc, &$info=array())
Definition: modcard.php:259
$docid
Definition: cleanFamily.php:13
Verify arguments for action function.
print
Definition: checklist.php:49
getTmpDir($def= '/tmp')
Definition: Lib.Common.php:150
switch($command) exit
Definition: checkVault.php:46
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
$usage
$latest
← centre documentaire © anakeen