Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
rnavigate.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  * Relation Navigation
9  *
10  * @author Anakeen 2005
11  * @version $Id: rnavigate.php,v 1.7 2008/06/03 16:31:53 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage GED
15  */
16 /**
17  */
18 
19 include_once ("FDL/Class.Doc.php");
20 include_once ("FDL/Lib.Dir.php");
21 include_once ("FDL/Class.DocRel.php");
22 
23 function rnavigate(&$action)
24 {
25  $dbaccess = $action->GetParam("FREEDOM_DB");
26  $docid = GetHttpVars("id");
27  $action->parent->AddJsRef($action->GetParam("CORE_PUBURL") . "/FDL/Layout/common.js");
28  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/subwindow.js");
29  $limit = 100;
30 
32  if ($doc->locked == - 1) $doc = new_Doc($dbaccess, $doc->LatestId());
33  $idocid = $doc->initid;
34 
35  $rdoc = new DocRel($dbaccess, $idocid);
36  $rdoc->sinitid = $idocid;
37 
38  $action->lay->set("Title", $doc->title);
39  $tlay = array();
40 
41  $trel = $rdoc->getIRelations("", "", $limit);
42  if (count($trel) == 0) {
43  $tlay['_F'] = array(
44  "iconsrc" => "",
45  "initid" => 0,
46  "title" => "",
47  "aid" => "",
48  "alabel" => "",
49  "type" => _("Referenced from")
50  );
51  }
52  foreach ($trel as $k => $v) {
53  $tlay[$v["sinitid"] . '_F'] = array(
54  "iconsrc" => $doc->getIcon($v["sicon"]) ,
55  "initid" => $v["sinitid"],
56  "title" => $v["stitle"],
57  "aid" => $v["type"],
58  "alabel" => $v["type"] ? _($v["type"]) : "",
59  "type" => _("Referenced from")
60  );
61  }
62 
63  $trel = $rdoc->getRelations("", "", $limit);
64  if (count($trel) == 0) {
65  $tlay['_T'] = array(
66  "iconsrc" => "",
67  "initid" => 0,
68  "title" => "",
69  "aid" => "",
70  "alabel" => "",
71  "type" => _("Reference")
72  );
73  }
74  foreach ($trel as $k => $v) {
75  $tlay[$v["cinitid"] . '_T'] = array(
76  "iconsrc" => $doc->getIcon($v["cicon"]) ,
77  "initid" => $v["cinitid"],
78  "title" => $v["ctitle"],
79  "aid" => $v["type"],
80  "alabel" => $v["type"] ? _($v["type"]) : "",
81  "type" => _("Reference")
82  );
83  }
84 
85  if (count($tlay) > 0) {
86  foreach ($tlay as $k => $v) {
87  $taid[$v["aid"]] = $v["aid"];
88  }
89  $q = new QueryDb($dbaccess, "DocAttr");
90  $q->AddQuery(GetSqlCond($taid, "id"));
91  $l = $q->Query(0, 0, "TABLE");
92  if ($l) {
93  $la = array();
94  foreach ($l as $k => $v) {
95  $la[$v["id"]] = $v["labeltext"];
96  }
97  foreach ($tlay as $k => $v) {
98  if ($la[$v["aid"]]) $tlay[$k]["alabel"] = $la[$v["aid"]];
99  else if ($tlay[$k]["aid"] == 'folder') $tlay[$k]["alabel"] = _("folder");
100  }
101  }
102  }
103  // Verify visibility for current user
104  $tids = array();
105  foreach ($tlay as $k => $v) {
106  $tids[] = $v["initid"];
107  }
108  $vdoc = getVisibleDocsFromIds($dbaccess, $tids, $action->user->id);
109 
110  $tids = array();
111  if (is_array($vdoc)) foreach ($vdoc as $k => $v) $tids[] = $v["initid"];
112 
113  foreach ($tlay as $k => $v) {
114  if ((!in_array($v["initid"], $tids)) && ($v["initid"] != 0)) unset($tlay[$k]);
115  }
116 
117  $action->lay->setBlockData("RELS", $tlay);
118  $action->lay->set("docid", $docid);
119 }
120 
121 function rnavigate2(&$action)
122 {
123  header('Content-type: text/xml; charset=utf-8');
125 }
126 ?>
← centre documentaire © anakeen - published under CC License - Dynacase