Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
popupfam.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Specific menu for family
8  *
9  * @author Anakeen
10  * @version $Id: popupfam.php,v 1.22 2008/08/14 09:59:14 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 // -----------------------------------
19 function popupfam(Action & $action, &$tsubmenu)
20 {
21  // -----------------------------------
22  // ------------------------------
23  // define accessibility
24  $docid = GetHttpVars("id");
25  $abstract = (GetHttpVars("abstract", 'N') == "Y");
26 
27  $action->lay->Set("SEP", false);
28  $dbaccess = $action->dbaccess;
30  // if ($doc->doctype=="C") return; // not for familly
31  $kdiv = 1; // only one division
32  $action->lay->Set("id", $doc->id);
33 
34  include_once ("FDL/popup_util.php");
35  // -------------------- Menu menu ------------------
36  $lmenu = $doc->GetMenuAttributes();
37  $tmenu = array();
38  $km = 0;
39 
40  $tlink = array();
41  foreach ($lmenu as $k => $v) {
42 
43  $confirm = false;
44  $control = false;
45  if (($v->getOption("onlyglobal") == "yes") && ($doc->doctype != "C")) continue;
46  if (($v->getOption("global") != "yes") && ($doc->doctype == "C")) continue;
47  if ($v->link[0] == '?') {
48  $v->link = substr($v->link, 1);
49  $confirm = true;
50  }
51  if ($v->getOption("lconfirm") == "yes") $confirm = true;
52  if ($v->link[0] == 'C') {
53  $v->link = substr($v->link, 1);
54  $control = true;
55  }
56  if ($v->getOption("lcontrol") == "yes") $control = true;
57  if (preg_match('/\[(.*)\](.*)/', $v->link, $reg)) {
58  $v->link = $reg[2];
59  $tlink[$k]["target"] = $reg[1];
60  } else {
61  $tlink[$k]["target"] = $v->id;
62  }
63  if ($v->getOption("ltarget") != "") $tlink[$k]["target"] = $v->getOption("ltarget");
64  $tlink[$k]["idlink"] = $v->id;
65  $tlink[$k]["descr"] = $v->getLabel();
66  $tlink[$k]["url"] = addslashes($doc->urlWhatEncode($v->link));
67  $tlink[$k]["confirm"] = $confirm ? "true" : "false";
68  $tlink[$k]["control"] = $control;
69  $tlink[$k]["tconfirm"] = sprintf(_("Sure %s ?") , addslashes($v->getLabel()));
70  $tlink[$k]["visibility"] = MENU_ACTIVE;
71  $tlink[$k]["barmenu"] = ($v->getOption("barmenu") == "yes") ? "true" : "false";
72  if ($v->precond != "") $tlink[$k]["visibility"] = $doc->ApplyMethod($v->precond, MENU_ACTIVE);
73 
74  $tmenu[$km++] = $v->id;
75  popupAddItem('popupcard', $v->id);
76  }
77  // -------------------- Menu action ------------------
78  $lactions = $doc->GetActionAttributes();
79  foreach ($lactions as $k => $v) {
80  if ($v->getOption("submenu") != "") {
81  $confirm = false;
82  $control = false;
83  $v->link = $v->getLink($doc->id);
84  if ($v->getOption("lconfirm") == "yes") $confirm = true;
85  if ($v->getOption("lcontrol") == "yes") $control = true;
86 
87  if (preg_match('/\[(.*)\](.*)/', $v->link, $reg)) {
88  $v->link = $reg[2];
89  $tlink[$k]["target"] = $reg[1];
90  } else {
91  $tlink[$k]["target"] = $v->id;
92  }
93  $tlink[$k]["barmenu"] = ($v->getOption("barmenu") == "yes") ? "true" : "false";
94  $tlink[$k]["idlink"] = $v->id;
95  $tlink[$k]["descr"] = $v->getLabel();
96  $tlink[$k]["url"] = addslashes($doc->urlWhatEncode($v->link));
97  $tlink[$k]["confirm"] = $confirm ? "true" : "false";
98  $tlink[$k]["control"] = $control;
99  $tlink[$k]["tconfirm"] = sprintf(_("Sure %s ?") , addslashes($v->getLabel()));
100  $tlink[$k]["visibility"] = MENU_ACTIVE;
101  if ($v->precond != "") $tlink[$k]["visibility"] = $doc->ApplyMethod($v->precond, MENU_ACTIVE);
102 
103  $tmenu[$km++] = $v->id;
104  popupAddItem('popupcard', $v->id);
105  }
106  }
107 
108  if (count($tmenu) == 0) return;
109  // ---------------------------
110  // definition of popup menu
111  // ---------------------------
112  // definition of sub popup menu);
113  $lmenu = array_merge($lmenu, $lactions);
114 
115  foreach ($lmenu as $k => $v) {
116  $sm = $v->getOption("submenu");
117  if ($sm != "") {
118  $smid = base64_encode($sm);
119  $tsubmenu[$smid] = array(
120  "idmenu" => $smid,
121  "labelmenu" => $sm
122  );
123  popupSubMenu('popupcard', $v->id, $smid);
124  }
125  }
126 
127  foreach ($tmenu as $k => $v) {
128  if ($tlink[$v]["visibility"] == MENU_INVISIBLE) {
129  Popupinvisible('popupcard', $kdiv, $v);
130  } else {
131  if ($tlink[$v]["url"] != "") {
132  if ($tlink[$v]["visibility"] == MENU_INACTIVE) {
133  if ($tlink[$v]["control"]) PopupCtrlInactive('popupcard', $kdiv, $v);
134  else PopupInactive('popupcard', $kdiv, $v);
135  } else {
136  if ($tlink[$v]["control"]) PopupCtrlActive('popupcard', $kdiv, $v);
137  else Popupactive('popupcard', $kdiv, $v);
138  }
139  } else PopupInactive('popupcard', $kdiv, $v);
140  }
141  }
142 
143  $noctrlkey = ($action->getParam("FDL_CTRLKEY", "yes") == "no");
144  if ($noctrlkey) popupNoCtrlKey();
145 
146  $action->lay->SetBlockData("ADDLINK", $tlink);
147  $action->lay->Set("SEP", true); // to see separator
148 
149 }
global $action
const MENU_INVISIBLE
Definition: Class.Doc.php:37
const MENU_INACTIVE
Definition: Class.Doc.php:38
$sm
Definition: setStyle.php:373
Set($name, &$parent)
const MENU_ACTIVE
Definition: Class.Doc.php:36
$docid
Definition: cleanFamily.php:13
new_Doc($dbaccess, $id= '', $latest=false)
getParam($name, $def="")
$dbaccess
Definition: checkVault.php:17
popupfam(Action &$action, &$tsubmenu)
Definition: popupfam.php:19
← centre documentaire © anakeen