Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
popupdoc.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: popupdoc.php,v 1.23 2008/10/09 08:00:55 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 // -----------------------------------
19 function popupdoc(Action & $action, $tlink, $tsubmenu = array())
20 {
21 
22  if ($action->getParam("getmenulink")) { // to be use in viewbarmenu function
23  $action->parent->setVolatileParam("menulink", $tlink);
24  return;
25  }
26 
27  header('Content-type: text/xml; charset=utf-8');
28  $onlyctrl = (GetHttpVars("onlyctrl") == "yes"); // view only ctrl
29  $onlysub = GetHttpVars("submenu"); // view only sub menu
30  $action->lay = new Layout(getLayoutFile("FDL", "popupdoc.xml") , $action);
31 
32  if ($onlysub && (!seems_utf8($onlysub))) $onlysub = utf8_encode($onlysub);
33 
34  $mb = microtime();
35 
36  $action->lay->set("CODE", "OK");
37  $action->lay->set("warning", "");
38  // define accessibility
39  $action->lay->Set("SEP", false);
40  $noctrlkey = ($action->getParam("FDL_CTRLKEY", "yes") == "no");
41 
42  $useicon = false;
43  $rlink = array();
44  $rlinkbottom = array();
45  $menuKeys = array(
46  "title",
47  "submenu",
48  "tconfirm",
49  "visibility",
50  "url",
51  "jsfunction",
52  "isjs",
53  "icon"
54  );
55  foreach ($tlink as $k => $v) {
56  if ($onlyctrl) {
57  if (($v["visibility"] != POPUP_CTRLACTIVE) && ($v["visibility"] != POPUP_CTRLINACTIVE)) $v["visibility"] = POPUP_INVISIBLE;
58  if ($v["visibility"] == POPUP_CTRLACTIVE) $v["visibility"] = POPUP_ACTIVE;
59  else if ($v["visibility"] == POPUP_CTRLINACTIVE) $v["visibility"] = POPUP_INACTIVE;
60  }
61  foreach ($menuKeys as $mKey) if (!isset($v[$mKey])) $v[$mKey] = '';
62  if ($onlysub) {
63  if ($v["submenu"] != $onlysub) $v["visibility"] = POPUP_INVISIBLE;
64  else $v["submenu"] = "";
65  }
66  if ($v["visibility"] == POPUP_INACTIVE) {
67  if ($v["title"]) {
68  $v["url"] = '';
69  $v["jsfunction"] = htmlLayoutEncode(sprintf("displayWarningMsg(%s)", json_encode($v['title'])));
70  $v["isjs"] = true;
71  } else {
72  $v["url"] = '#';
73  $v["jsfunction"] = '';
74  $v["isjs"] = false;
75  }
76  $v["confirm"] = 'false';
77  }
78  if ($v["visibility"] != POPUP_INVISIBLE) {
79  if ($v["submenu"] == "") {
80  if (!empty($v["icon"])) $useicon = true;
81  $v["ICONS"] = "mainicon";
82  } else {
83  $smid = base64_encode($v["submenu"]);
84  if (!isset($tsubmenu[$smid])) $action->lay->set("icon" . $smid, false);
85  $v["ICONS"] = "icon" . $smid;
86  if ($v["icon"]) $action->lay->set("icon" . $smid, true);
87  }
88 
89  if ((!isset($v["icon"])) || ($v["icon"] == "")) {
90  $v["icon"] = "Images/none.gif";
91  }
92 
93  $v["issubmenu"] = false;
94  $v["title"] = htmlLayoutEncode(mb_ucfirst($v["title"]));
95  $v["tconfirm"] = htmlLayoutEncode(json_encode($v["tconfirm"]));
96  $v["descr"] = htmlLayoutEncode($v["descr"]);
97  if (!isset($v["visibility"])) $v["visibility"] = "";
98  if (!isset($v["confirm"])) $v["confirm"] = "";
99  if (!isset($v["color"])) $v["color"] = false;
100  if (!isset($v["title"])) $v["title"] = false;
101 
102  if (!isset($v["jsfunction"])) {
103  $v["jsfunction"] = "";
104  $v["isjs"] = false;
105  } else {
106  $v["isjs"] = true;
107  }
108  if (!isset($v["barmenu"])) $v["barmenu"] = "";
109  if (!isset($v["url"])) $v["url"] = "";
110  else $v["url"] = ($v["url"]);
111  if (!isset($v["separator"])) $v["separator"] = false;
112  if ((!isset($v["idlink"])) || ($v["idlink"] == "")) $v["idlink"] = $k;
113  if ((!isset($v["target"])) || ($v["target"] == "")) $v["target"] = $k;
114  if ((!isset($v["mwidth"])) || ($v["mwidth"] == "")) $v["mwidth"] = $action->getParam("FDL_HD2SIZE", 300);
115  if ((!isset($v["mheight"])) || ($v["mheight"] == "")) $v["mheight"] = $action->getParam("FDL_VD2SIZE", 400);
116  if ((isset($v["url"])) && ($v["url"] != "")) $v["URL"] = true;
117  else $v["URL"] = false;
118 
119  if ($noctrlkey) {
120  if ($v["visibility"] == POPUP_CTRLACTIVE) {
121  $v["submenu"] = N_("menuctrlkey");
122  $v["visibility"] = POPUP_ACTIVE;
123  }
124  }
125 
126  if ((isset($v["jsfunction"])) && ($v["jsfunction"] != "")) {
127  $v["isjs"] = true;
128  $v["JSFT"] = true;
129  } else {
130  $v["isjs"] = false;
131  $v["JSFT"] = false;
132  }
133  $v["smid"] = "";
134  if ((isset($v["submenu"])) && ($v["submenu"] != "")) {
135  $smid = base64_encode($v["submenu"]);
136  $v["smid"] = $smid;
137 
138  if (!isset($tsubmenu[$smid])) {
139  if ((!isset($v["icon"])) || ($v["icon"] == "")) {
140  $icon = "Images/none.gif";
141  } else {
142  $icon = $v["icon"];
143  }
144  $tsubmenu[$smid] = array(
145  "idlink" => $smid,
146  "descr" => htmlLayoutEncode(_($v['submenu'])) ,
147  "icon" => $v["icon"],
148  "visibility" => false,
149  "ICONS" => "mainicon",
150  "confirm" => false,
151  "color" => false,
152  "title" => false,
153  "jsfunction" => false,
154  "isjs" => false,
155  "barmenu" => false,
156  "url" => false,
157  "target" => false,
158  "mwidth" => false,
159  "mheight" => false,
160  "smid" => false,
161  "tconfirm" => false,
162  "issubmenu" => false
163  );
164  }
165 
166  if (!isset($tsubmenu[$smid]["displayed"])) {
167  $tsubmenu[$smid]["displayed"] = true;
168  $tsubmenu[$smid]["issubmenu"] = true;
169  $tsubmenu[$smid]["URL"] = false;
170  $tsubmenu[$smid]["JSFT"] = false;
171  $tsubmenu[$smid]["separator"] = false;
172  if ($noctrlkey && ($v["submenu"] == "menuctrlkey")) {
173  $rlinkbottom[] = $tsubmenu[$smid];
174  } else {
175  $rlink[] = $tsubmenu[$smid];
176  }
177  }
178  }
179 
180  $rlink[] = $v;
181  }
182  }
183 
184  if ($noctrlkey) {
185  // ctrlkey submenu at bottom
186  $rlink = array_merge($rlink, $rlinkbottom);
187  }
188  $action->lay->Set("mainicon", $useicon);
189  $action->lay->SetBlockData("ADDLINK", $rlink);
190  $action->lay->SetBlockData("SUBMENU", $tsubmenu);
191  $action->lay->SetBlockData("SUBDIVMENU", $tsubmenu);
192  $action->lay->Set("count", count($tlink));
193  $action->lay->Set("SEP", (count($tsubmenu) > 0)); // to see separator
194  $action->lay->set("delay", microtime_diff(microtime() , $mb));
195 }
196 
197 function htmlLayoutEncode($v)
198 {
199  return str_replace("[", "&#091;", htmlspecialchars($v, ENT_QUOTES));
200 }
Layout is a template generator.
seems_utf8($Str)
Definition: Lib.Common.php:759
global $action
const POPUP_CTRLINACTIVE
Definition: Class.Doc.php:43
const POPUP_INVISIBLE
Definition: Class.Doc.php:44
const POPUP_CTRLACTIVE
Definition: Class.Doc.php:42
popupdoc(Action &$action, $tlink, $tsubmenu=array())
Definition: popupdoc.php:19
Set($name, &$parent)
const POPUP_INACTIVE
Definition: Class.Doc.php:40
getLayoutFile($app, $layfile)
Definition: Lib.Common.php:258
microtime_diff($a, $b)
Definition: Lib.Common.php:302
mb_ucfirst($s)
Definition: Lib.Common.php:105
const POPUP_ACTIVE
Definition: Class.Doc.php:41
getParam($name, $def="")
N_($s)
Definition: Lib.Common.php:18
htmlLayoutEncode($v)
Definition: popupdoc.php:197
← centre documentaire © anakeen