Source for file hvmenu-defs.php

Documentation is available at hvmenu-defs.php

  1. <?php
  2. /* ******************************************************************** */
  3. /* CATALYST PHP Source Code */
  4. /* -------------------------------------------------------------------- */
  5. /* This program is free software; you can redistribute it and/or modify */
  6. /* it under the terms of the GNU General Public License as published by */
  7. /* the Free Software Foundation; either version 2 of the License, or */
  8. /* (at your option) any later version. */
  9. /* */
  10. /* This program is distributed in the hope that it will be useful, */
  11. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  12. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  13. /* GNU General Public License for more details. */
  14. /* */
  15. /* You should have received a copy of the GNU General Public License */
  16. /* along with this program; if not, write to: */
  17. /* The Free Software Foundation, Inc., 59 Temple Place, Suite 330, */
  18. /* Boston, MA 02111-1307 USA */
  19. /* -------------------------------------------------------------------- */
  20. /* */
  21. /* Filename: hvmenu-defs.php */
  22. /* Author: Paul Waite */
  23. /* Description: Definitions for a Javascript-based multi-level menu. */
  24. /* The system creates a semi-static config file in a */
  25. /* dynamic manner and the javascript content is generated */
  26. /* from that. The semi-static file (menu-vars.js) is only */
  27. /* rebuilt when either the stylesheet or the menu data in */
  28. /* the database is changed. The stylesheet should contain */
  29. /* .menu and .submenu classes as per the default Axyl */
  30. /* installation. */
  31. /* */
  32. /* DEPRECATED. Use xmenu-defs instead. This module needs */
  33. /* non-free menuing javascript package 'menu_com.js' */
  34. /* which is not distributed with Axyl. */
  35. /* */
  36. /* ******************************************************************** */
  37. /** @package menu */
  38. include_once("menu-defs.php");
  39.  
  40. // ----------------------------------------------------------------------
  41. /**
  42. * The HV Menu Javascript variables file. This file is
  43. * dynamically generated by this class.
  44. * @access private
  45. */
  46. define("MENU_VARS_FILE", "menu_vars.js");
  47. /**
  48. * HVMenu class
  49. * This module is being retained for legacy applications which still use
  50. * the core javascript system (version 5.41) which was written by
  51. * Ger Versluis 24 December 2001.
  52. * @deprecated HVmenu javascript no longer packaged with Axyl. Use Xmenu instead.
  53. * @package menu
  54. */
  55. class HVmenu extends RenderableObject {
  56. // Public
  57. /** Menu name eg: 'main' */
  58.  
  59. var $menu_name = "";
  60. /** Menu language */
  61.  
  62. var $language = 0;
  63. /** Name of stylesheet file to get menu styles from */
  64.  
  65. var $stylesheet = "";
  66.  
  67. // Private
  68. /** Unique database menu ID
  69. @access private */
  70. var $menu_id = 0;
  71. /** Path to menu variables file - theme aware
  72. @access private */
  73. var $menuvarsfile = "";
  74. /** WWW menu URL - theme aware
  75. @access private */
  76. var $menuhref = "";
  77. /** Positioned relatively, or not
  78. @access private */
  79. var $relative_positioned = false;
  80. /** Level of menu to render
  81. @access private */
  82. var $menu_level = 0;
  83. /** Width of all menu items in pixels
  84. @access private */
  85. var $item_width = 150;
  86. /** Height of menu items in pixels
  87. @access private */
  88. var $item_height = 18;
  89. // ....................................................................
  90. /**
  91. * Constructor
  92. * Create the HV menu object.
  93. * @param string $menu_name Menu name
  94. * @param object $webpage Webpage object that this menu is being created for
  95. * @param string $stylsheet Name of stylesheet file to reference for menu styles
  96. * @param integer $lang Optional language variant of this menu (zero = default)
  97. */
  98. function HVmenu($menu_name="main", $webpage=false, $stylesheet="", $lang=-1) {
  99. global $RESPONSE;
  100. $this->menu_name = $menu_name;
  101. // Set the menu language..
  102. if ($lang != -1) {
  103. $this->language = $lang;
  104. }
  105. elseif ($webpage !== false && $webpage->multilang && isset($webpage->languages[0])) {
  106. $this->language = $webpage->languages[0];
  107. }
  108. elseif (isset($RESPONSE) && $RESPONSE->multilang && isset($RESPONSE->languages[0])) {
  109. $this->language = $RESPONSE->languages[0];
  110. }
  111. // Get menu, fall back to default if not found..
  112. $tryagain = true;
  113. do {
  114. $tryagain = ($this->language != 0);
  115. $q = "SELECT menu_id";
  116. $q .= " FROM ax_menu";
  117. $q .= " WHERE menu_name='" . escape_string($this->menu_name) . "'";
  118. $q .= " AND lang_id=$this->language";
  119. $mID = dbrecordset($q);
  120. if ($mID->hasdata) {
  121. $tryagain = false;
  122. }
  123. else {
  124. debugbr("menu language not found ($this->language): falling back to default", DBG_DEBUG);
  125. $this->language = 0;
  126. }
  127. } while ($tryagain);
  128.  
  129. if ($mID->hasdata) {
  130. $this->menu_id = $mID->field("menu_id");
  131. }
  132. if ($webpage) {
  133. $this->stylesheet = $webpage->site_docroot . $webpage->head->stylesheet;
  134. global $CMDIR;
  135. $this->menuvarsfile = $webpage->site_docroot . "$CMDIR/" . $webpage->theme . "_" . MENU_VARS_FILE;
  136. $this->menuhref = "$CMDIR/" . $webpage->theme . "_" . MENU_VARS_FILE;
  137. $this->display_in_webpage($webpage);
  138. }
  139. // Over-ridden stylesheet to use..
  140. if ($stylesheet != "") {
  141. $this->stylesheet = $webpage->site_docroot . "/" . $stylesheet;
  142. }
  143. } // HVmenu
  144. // ....................................................................
  145. /**
  146. * Requires build
  147. * Check if the database records containing the menu
  148. * have been modified since the last modification time
  149. * of the menu vars file. Returns true if so.
  150. * @return bool True if menu requires build (config has been changed)
  151. * @access private
  152. */
  153. function requires_build() {
  154. // First check existence and file timestamp of the
  155. // menu setup file that is used by the system..
  156. if (!file_exists($this->menuvarsfile)) {
  157. debugbr("rebuilding: vars file absent", DBG_DEBUG);
  158. return true;
  159. }
  160. clearstatcache();
  161. $mvarmod_ts = filemtime($this->menuvarsfile);
  162. $mvarmod_dt = timestamp_to_datetime($mvarmod_ts);
  163.  
  164. // Now check file mod time vs database mod times..
  165. $q = "SELECT COUNT(*) AS tot FROM ax_menu";
  166. $q .= " WHERE menu_id='$this->menu_id'";
  167. $q .= " AND last_modified > '$mvarmod_dt'";
  168. $modQ = dbrecordset($q);
  169. if ($modQ->field("tot") > 0) {
  170. return true;
  171. }
  172. $q = "SELECT COUNT(*) AS tot FROM ax_menuoption";
  173. $q .= " WHERE menu_id='$this->menu_id'";
  174. $q .= " AND last_modified > '$mvarmod_dt'";
  175. $modQ = dbrecordset($q);
  176. if ($modQ->field("tot") > 0) {
  177. return true;
  178. }
  179. // If stylesheet file is provided, then check against
  180. // that also, since this influences things like fonts
  181. // and colours etc..
  182. if ($this->stylesheet != "") {
  183. $stylemod_ts = filemtime($this->stylesheet);
  184. if ($stylemod_ts > $mvarmod_ts) {
  185. return true;
  186. }
  187. }
  188. // If we got here, no need to build..
  189. return false;
  190. } // requires build
  191. // ....................................................................
  192. /**
  193. * Display in webpage
  194. * Inserts the javascript necessary to embed the menu into a given webpage.
  195. * NB: Normally the webpage passed in here is $RESPONSE.
  196. * NOTE: The 'menu_com.js' module is not distributed with the Axyl library
  197. * due to being non-free. It must be placed into the '$LIBDIR' of your
  198. * website (see below) to enable this to work. There are various versions
  199. * of this javascript menuing module available on the 'net.
  200. * @param object $webpage Webpage object that this menu is being created for
  201. */
  202. function display_in_webpage($webpage) {
  203. global $LIBDIR;
  204. $webpage->head->add_scriptsrc($this->menuhref);
  205. $webpage->head->add_script("var TargetLoc='menu_$this->menu_id';\n");
  206. $webpage->head->add_script($this->menu_structure());
  207. $webpage->body->add_script("function Go(){return;}\n");
  208. $webpage->body->add_scriptsrc("$LIBDIR/menu_com.js");
  209. } // display_in_webpage
  210. // ....................................................................
  211. /**
  212. * This renders the field as HTML.
  213. * Inserts the HTML DIV tag which the HVmenu will use to position
  214. * itself to. The name of the DIV is taken from the unique menu ID,
  215. * and corresponds to the TargetLoc variable defined above..
  216. * @return string The menu anchor point (DIV) as HTML.
  217. */
  218. function html() {
  219. // Always build menu variables file if required..
  220. if ($this->requires_build()) {
  221. $this->build();
  222. }
  223. if ($this->relative_positioned) {
  224. return "<div id=\"menu_$this->menu_id\" style=\"position:relative;\"></div>";
  225. }
  226. else {
  227. return "<div id=\"menu_$this->menu_id\"></div>";
  228. }
  229. } // html
  230. // ....................................................................
  231. /**
  232. * Build menu config
  233. * Build the static menu_vars.js file which is used to set menu
  234. * look and feel, driven by the given stylesheet. This is a physical
  235. * file which gets (re-)built and saved to disk.
  236. * @access private
  237. */
  238. function build() {
  239. global $RESPONSE;
  240. global $LIBDIR;
  241. // Get fonts and colours etc. If this stylesheet is undefined or
  242. // doesn't exist on disk, then we should still be able to generate
  243. // the vars below, but will get the defaults in each case..
  244. $ss = new stylesheet($this->stylesheet);
  245. // Read in all the style settings..
  246. $FontLowColor = defaulted($ss->style("menu", "color"), "#efefef");
  247. $LowBgColor = defaulted($ss->style("menu", "background-color"), "black");
  248. $FontHighColor = defaulted($ss->style("menu_highlight", "color"), "white");
  249. $HighBgColor = defaulted($ss->style("menu_highlight", "background-color"), "grey");
  250. $BorderColor = defaulted($ss->style("menu", "border-color"), "black");
  251. $MenuTextCentered = defaulted($ss->style("menu", "text-align"), "left");
  252. $MenuCentered = defaulted($ss->style("menu", "menu-align"), "left");
  253. $MenuVerticalCentered = defaulted($ss->style("menu", "menu-vertical-align"), "top");
  254. $FontFamily = defaulted($ss->style("menu", "font-family"), "arial");
  255. $FontSubLowColor = defaulted($ss->style("submenu", "color"), "#efefef");
  256. $LowSubBgColor = defaulted($ss->style("submenu", "background-color"), "black");
  257. $FontSubHighColor = defaulted($ss->style("submenu_highlight", "color"), "white");
  258. $HighSubBgColor = defaulted($ss->style("submenu_highlight", "background-color"), "grey");
  259. $BorderSubColor = defaulted($ss->style("submenu", "border-color"), "black");
  260.  
  261. // Elements with superfluous bits to be removed..
  262. $val = defaulted($ss->style("menu", "menu-frame"), "self");
  263. $FirstLineFrame = str_replace("'", "", $val);
  264. $val = defaulted($ss->style("menu", "submenu-frame"), "self");
  265. $SecLineFrame = str_replace("'", "", $val);
  266. $val = defaulted($ss->style("menu", "content-frame"), "self");
  267. $DocTargetFrame = str_replace("'", "", $val);
  268. $val = defaulted($ss->style("menu", "margin-top"), "0");
  269. $StartTop = str_replace("px", "", $val);
  270. $val = defaulted($ss->style("menu", "margin-left"), "0");
  271. $StartLeft = str_replace("px", "", $val);
  272. $val = defaulted($ss->style("menu", "vertical-correction"), "0");
  273. $VerCorrect = str_replace("px", "", $val);
  274. $val = defaulted($ss->style("menu", "horizontal-correction"), "0");
  275. $HorCorrect = str_replace("px", "", $val);
  276. $val = defaulted($ss->style("menu", "padding-left"), "0");
  277. $LeftPaddng = str_replace("px", "", $val);
  278. $val = defaulted($ss->style("menu", "padding-top"), "0");
  279. $TopPaddng = str_replace("px", "", $val);
  280. $val = defaulted($ss->style("menu", "font-size"), "8");
  281. $FontSize = str_replace("pt", "", $val);
  282. $val = defaulted($ss->style("menu", "disappear-delay"), "100");
  283. $DisappearDelay = str_replace("ms", "", $val);
  284. $val = defaulted($ss->style("menu", "border-width"), "1");
  285. $BorderWidth = str_replace("px", "", $val);
  286. $val = defaulted($ss->style("menu", "item-spacing"), "0");
  287. $BorderBtwnElmnts = str_replace("px", "", $val);
  288.  
  289. // Real Numbers..
  290. $ChildOverlap = defaulted($ss->style("menu", "child-overlap"), "0.2");
  291. if ($ChildOverlap > 1.0) $ChildOverlap = 1.0;
  292. if ($ChildOverlap < 0.0) $ChildOverlap = 0.0;
  293.  
  294. $ChildVerticalOverlap = defaulted($ss->style("menu", "child-vertical-overlap"), "0.2");
  295. if ($ChildVerticalOverlap > 1.0) $ChildVerticalOverlap = 1.0;
  296. if ($ChildVerticalOverlap < 0.0) $ChildVerticalOverlap = 0.0;
  297. $ChildVerticalOverlap = (1.0 - $ChildVerticalOverlap);
  298.  
  299. // Integers, Logicals, et al..
  300. $val = defaulted($ss->style("menu", "font-weight"), "normal");
  301. if ($val == "bold") $FontBold = "1";
  302. else $FontBold = "0";
  303.  
  304. $val = defaulted($ss->style("menu", "font-style"), "normal");
  305. if ($val == "italic") $FontItalic = "1";
  306. else $FontItalic = "0";
  307.  
  308. $val = defaulted($ss->style("menu", "orientation"), "horizontal");
  309. if ($val == "horizontal") $FirstLineHorizontal = "1";
  310. else $FirstLineHorizontal = "0";
  311.  
  312. $val = defaulted($ss->style("menu", "frames-columns"), "no");
  313. if ($val == "yes") $MenuFramesVertical = "1";
  314. else $MenuFramesVertical = "0";
  315.  
  316. $val = defaulted($ss->style("menu", "takeover-background-color"), "no");
  317. if ($val == "yes") $TakeOverBgColor = "1";
  318. else $TakeOverBgColor = "0";
  319.  
  320. $val = defaulted($ss->style("menu", "hide-top"), "no");
  321. if ($val == "yes") $HideTop = "1";
  322. else $HideTop = "0";
  323.  
  324. $val = defaulted($ss->style("menu", "wrap"), "no");
  325. if ($val == "yes") $MenuWrap = "1";
  326. else $MenuWrap = "0";
  327.  
  328. $val = defaulted($ss->style("menu", "wrap"), "no");
  329. if ($val == "yes") $MenuWrap = "1";
  330. else $MenuWrap = "0";
  331.  
  332. $val = defaulted($ss->style("menu", "right-to-left"), "yes");
  333. if ($val == "yes") $RightToLeft = "1";
  334. else $RightToLeft = "0";
  335.  
  336. $val = defaulted($ss->style("menu", "unfold-on-click"), "no");
  337. if ($val == "yes") $UnfoldsOnClick = "1";
  338. else $UnfoldsOnClick = "0";
  339.  
  340. $val = defaulted($ss->style("menu", "debug"), "no");
  341. if ($val == "yes") $WebMasterCheck = "1";
  342. else $WebMasterCheck = "0";
  343.  
  344. $val = defaulted($ss->style("menu", "show-arrows"), "no");
  345. if ($val == "yes") $ShowArrow = "1";
  346. else $ShowArrow = "0";
  347.  
  348. $val = defaulted($ss->style("menu", "show-status"), "no");
  349. if ($val == "yes") $ShowStatus = "1";
  350. else $ShowStatus = "0";
  351.  
  352. // This can take values: 'url' or 'description'. It determines
  353. // what is shown in the browser status bar..
  354. $StatusContent = defaulted($ss->style("menu", "status-content"), "url");
  355.  
  356. $val = defaulted($ss->style("menu", "keep-highlight"), "no");
  357. if ($val == "yes") $KeepHilite = "1";
  358. else $KeepHilite = "0";
  359.  
  360. $val = defaulted($ss->style("menu", "relative-positioned"), "no");
  361. if ($val == "yes") $this->relative_positioned = true;
  362. else $this->relative_positioned = false;
  363.  
  364. // Write the variables file out..
  365. $newMV = new outputfile($this->menuvarsfile);
  366. if ($newMV->opened) {
  367. $newMV->writeln("//HVMENU (c)2001 Ger Versluis");
  368. $newMV->writeln("var LowBgColor='$LowBgColor';");
  369. $newMV->writeln("var LowSubBgColor='$LowSubBgColor';");
  370. $newMV->writeln("var HighBgColor='$HighBgColor';");
  371. $newMV->writeln("var HighSubBgColor='$HighSubBgColor';");
  372. $newMV->writeln("var FontLowColor='$FontLowColor';");
  373. $newMV->writeln("var FontSubLowColor='$FontSubLowColor';");
  374. $newMV->writeln("var FontHighColor='$FontHighColor';");
  375. $newMV->writeln("var FontSubHighColor='$FontSubHighColor';");
  376. $newMV->writeln("var BorderColor='$BorderColor';");
  377. $newMV->writeln("var BorderSubColor='$BorderSubColor';");
  378. $newMV->writeln("var BorderWidth=$BorderWidth;");
  379. $newMV->writeln("var BorderBtwnElmnts=$BorderBtwnElmnts;");
  380. $newMV->writeln("var FontFamily='$FontFamily';");
  381. $newMV->writeln("var FontSize='$FontSize';");
  382. $newMV->writeln("var FontBold=$FontBold;");
  383. $newMV->writeln("var FontItalic=$FontItalic;");
  384. $newMV->writeln("var MenuTextCentered='$MenuTextCentered';");
  385. $newMV->writeln("var MenuCentered='$MenuCentered';");
  386. $newMV->writeln("var MenuVerticalCentered='$MenuVerticalCentered';");
  387. $newMV->writeln("var ChildOverlap=$ChildOverlap;");
  388. $newMV->writeln("var ChildVerticalOverlap=$ChildVerticalOverlap;");
  389. $newMV->writeln("var StartTop=$StartTop;");
  390. $newMV->writeln("var StartLeft=$StartLeft;");
  391. $newMV->writeln("var VerCorrect=$VerCorrect;");
  392. $newMV->writeln("var HorCorrect=$HorCorrect;");
  393. $newMV->writeln("var LeftPaddng=$LeftPaddng;");
  394. $newMV->writeln("var TopPaddng=$TopPaddng;");
  395. $newMV->writeln("var FirstLineHorizontal=$FirstLineHorizontal;");
  396. $newMV->writeln("var MenuFramesVertical=$MenuFramesVertical;");
  397. $newMV->writeln("var DisappearDelay=$DisappearDelay;");
  398. $newMV->writeln("var TakeOverBgColor=$TakeOverBgColor;");
  399. $newMV->writeln("var FirstLineFrame='$FirstLineFrame';");
  400. $newMV->writeln("var SecLineFrame='$SecLineFrame';");
  401. $newMV->writeln("var DocTargetFrame='$DocTargetFrame';");
  402. $newMV->writeln("var HideTop=$HideTop;");
  403. $newMV->writeln("var MenuWrap=$MenuWrap;");
  404. $newMV->writeln("var RightToLeft=$RightToLeft;");
  405. $newMV->writeln("var UnfoldsOnClick=$UnfoldsOnClick;");
  406. $newMV->writeln("var WebMasterCheck=$WebMasterCheck;");
  407. $newMV->writeln("var ShowArrow=$ShowArrow;");
  408. $newMV->writeln("var ShowStatus=$ShowStatus;");
  409. $newMV->writeln("var StatusContent='$StatusContent';");
  410. $newMV->writeln("var KeepHilite=$KeepHilite;");
  411. $newMV->writeln("var Arrws=['$LIBDIR/img/_tri.gif',5,10,'$LIBDIR/img/_tridown.gif',10,5,'$LIBDIR/img/_trileft.gif',5,10];");
  412. $newMV->writeln("function BeforeStart(){return}");
  413. $newMV->writeln("function AfterBuild(){return}");
  414. $newMV->writeln("function BeforeFirstOpen(){return}");
  415. $newMV->writeln("function AfterCloseAll(){return}");
  416. // Finish up..
  417. $newMV->closefile();
  418. } // newMV file opened
  419. } // build
  420. // ....................................................................
  421. /**
  422. * Menu structure
  423. * This function returns a set of Javascript array definitions which
  424. * should be put into the page which will be hosting the menu. Note
  425. * that this will be built for each user, since each user has a
  426. * unique auth_code which might be a part of the menu..
  427. * @return string Javascript var definitions for menu structure
  428. * @access private
  429. */
  430. function menu_structure() {
  431. global $RESPONSE;
  432. // Menu Tree
  433. // MenuX=new Array(
  434. // Text to show,
  435. // Link,
  436. // background image (optional),
  437. // number of sub elements,
  438. // height,
  439. // width
  440. // );
  441. // For rollover images set "Text to show" to:
  442. // "rollover:Image1.jpg:Image2.jpg"
  443. $js = "";
  444. $q = "SELECT *";
  445. $q .= " FROM ax_menu m, ax_menuoption mo";
  446. $q .= " WHERE m.menu_id=$this->menu_id";
  447. $q .= " AND mo.menu_id=m.menu_id";
  448. $q .= " AND m.active=TRUE";
  449. $q .= " AND mo.active=TRUE";
  450. $q .= " ORDER BY mo.menu_level,mo.display_order,mo.parent_id";
  451. $item = dbrecordset($q);
  452. if ($item->hasdata) {
  453. $topcount = 0;
  454. do {
  455. $mopid = $item->field("menuoption_id");
  456. $mnu_ugroups = $item->field("user_groups");
  457. $mnu_usertype = $item->field("user_type");
  458. if ($mnu_ugroups == "" || $RESPONSE->ismemberof_group_in($mnu_ugroups)) {
  459. if ($mnu_usertype == "" || ($RESPONSE->user_type == $mnu_usertype)) {
  460. $parent_id = $item->field("parent_id");
  461. $menu_level = $item->field("menu_level");
  462. $label = $item->field("label");
  463. $description = $item->field("description");
  464. $action = $item->field("action");
  465. $target = $item->field("target");
  466. $authcode = $item->istrue("auth_code");
  467. $width = $item->field("width");
  468. $height = $item->field("height");
  469. $is_parent = $item->istrue("is_parent");
  470. if ($menu_level == 0) {
  471. $topcount += 1;
  472. $mno_top[$topcount] = $mopid;
  473. }
  474. $mno_details[$mopid] = "$label|$description|$action|$target|" . ($authcode ? "t" : "f") . "|$width|$height";
  475. $mno_level[$mopid] = $menu_level;
  476. $mno_parent[$mopid] = $parent_id;
  477. if ($parent_id != "") {
  478. if (isset($mno_children[$parent_id])) {
  479. $mno_children[$parent_id] .= "|";
  480. }
  481. $mno_children[$parent_id] .= $mopid;
  482. }
  483. } // user type check
  484. } // memberof
  485. } while ($item->get_next());
  486.  
  487. // Number of top-level items..
  488. $js .= "var NoOffFirstLineMenus=$topcount;\n";
  489.  
  490. if (is_array( $mno_top )) {
  491. while (list($item_no, $mopid) = each($mno_top)) {
  492. $prefix = "$item_no";
  493. $js .= HVmenu_entry($prefix, $mopid, $mno_children, $mno_details);
  494. }
  495. }
  496. } // hasdata
  497. return $js;
  498. } // menu_structure
  499.  
  500. } // HVmenu class
  501. // ----------------------------------------------------------------------
  502.  
  503. /**
  504. * Recursively produce HVmenu definition entries. These array
  505. * definitions define the menu structure in terms of the actual
  506. * menus and their sub-menus. This routine produces a single
  507. * menu-option definition, but will recursively call all child
  508. * (sub-menu) definitions.
  509. @param string $prefix The existing menu level prefix
  510. @param string $mopid Menu option ID
  511. @param string $mno_children List of children IDs of a menu option
  512. @param string $mno_details Menu option details
  513. @access private
  514. */
  515. function HVmenu_entry($prefix, $mopid, $mno_children, $mno_details) {
  516. global $RESPONSE;
  517. $childcount = 0;
  518. $js = "";
  519. if (isset($mno_children[$mopid]) && $mno_children[$mopid] != "") {
  520. $childoptions = explode("|", $mno_children[$mopid]);
  521. $childcount = count($childoptions);
  522. $pfxcount = 1;
  523. foreach ($childoptions as $childmopid) {
  524. $childprefix = $prefix . "_" . $pfxcount;
  525. $js .= HVmenu_entry($childprefix, $childmopid, $mno_children, $mno_details);
  526. $pfxcount += 1;
  527. }
  528. }
  529. // Now finally write this current menu option to file..
  530. $details = explode("|", $mno_details[$mopid]);
  531. $label = $details[0];
  532. if ($label == MENU_ITEM_SPACER) {
  533. $label = "";
  534. }
  535. $description = $details[1];
  536. $action = $details[2];
  537. $target = $details[3];
  538. $authcode = $details[4];
  539. $width = $details[5];
  540. $height = $details[6];
  541. if ($authcode == "t") {
  542. if (strstr($action, "?")) $action .= "&";
  543. else $action .= "?";
  544. $action .= "auth_code=" . $RESPONSE->get_auth_code();
  545. }
  546. // Make menu entry..
  547. $js .= "Menu" . $prefix . "=new Array(\"$label\",\"$action\",\"$description\",\"\",$childcount,$height,$width);\n";
  548. // Return the javascript..
  549. return $js;
  550. }
  551.  
  552. // ----------------------------------------------------------------------
  553. ?>

Documentation generated by phpDocumentor 1.3.0RC3