<%
/* ---------------------------------------------------------------------------------------- */
/* Copyright [2009] [System & Method Technologies]                                          */
/*                                                                                          */
/* Licensed under the Apache License, Version 2.0 (the "License");                          */
/* you may not use this file except in compliance with the License.                         */
/* You may obtain a copy of the License at                                                  */
/*                                                                                          */
/*     http://www.apache.org/licenses/LICENSE-2.0                                           */
/*                                                                                          */
/* Unless required by applicable law or agreed to in writing, software                      */
/* distributed under the License is distributed on an "AS IS" BASIS,                        */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.                 */
/* See the License for the specific language governing permissions and                      */
/* limitations under the License.                                                           */
/* ---------------------------------------------------------------------------------------- */
/*                                                                                          */
/* This program can be used as a basic template for loading application specific menus      */
/*                                                                                          */
/*                                                                                          */
/* Project . . . : IceBreak                                                                 */
/* Design  . . . : Niels Liisberg                                                           */
/* Function  . . : simple demo menu driver                                                  */
/*                                                                                          */
/* By       Date       Task    Description                                                  */
/* -------- ---------- ------- ------------------------------------------------------------ */
/* NLI      05.09.2009 0000000 New program - Subproject IceCap                              */
/* ---------------------------------------------------------------------------------------- */
H TEXT('iceCap: Simple menu driver')
H BNDDIR('ICEUTILITY')
H BNDDIR('EXTUTILITY')

fmenudemo  if   e           k disk
   
/include qasphdr,iceUtility
/include qasphdr,extUtility

d path            s             32    varying
d menu            s             10    
d search          s             32    varying   
                                                            
// ----------------------------------------------------------------------------------------
// Take a peek with:  select * from icemnudevd/menudemo
// Call it from the url with hive and name: menuDemo3.aspx?menu=ROOT
// example: http://dkexp05:60421/menu/samples/menuDemo3.aspx?menu=ROOT
// ----------------------------------------------------------------------------------------
 /free                                                      
            
	SetContentType('text/plain; charset=windows-1252');
	
	search = qryStr('search' : form('search'));
	path   = qryStr('path'   : form('path'));

  if  search > '';
    exsr searchMenu;
  else;
    exsr normalMenu;
  endIf;
  
  return;
  
// ----------------------------------------------------------------------------------------
// Normal menu: List bothe menu items and sub-menus  
// ----------------------------------------------------------------------------------------
begsr normalMenu;

  // take the menu node name as the list of menu items to show
	menu   = qrystr('node'   : form('node'));
  if menu = 'root' or menu = '';
    menu = qrystr('menu');
  endif;

	extMenuBegin(path);
	
	setll menu menuDemoR;
	reade menu menuDemoR;
	dow not %eof(menuDemo);
	  if subMenu > '';
			extSubMenu ( menuText : subMenu);
		else;
		  extMenuItem( menuText : menuLink);
		endif;
  	reade menu menuDemoR;
	endDo;
	
  extMenuEnd();
  
endsr;
// ----------------------------------------------------------------------------------------
// Search Menu : List all menu items that is contained in the search argument   
// ----------------------------------------------------------------------------------------
begsr searchMenu;

  search = uppercase(search);
	
	extMenuBegin(path);
	
	setll *LOVAL  menuDemoR;
	read  menuDemoR;
	dow not %eof(menuDemo);
  
    if subMenu = ''; // Skip sub menus 
      if %scan(search:uppercase(menuText)) > 0;
        extMenuItem( menuText : menuLink);
      endif;
    endIf;
    
  	read menuDemoR;
	endDo;
	
  extMenuEnd();

endSr;