Location: PHPKode > projects > Basic Announce > Basic Announce Version 4.0/system/menu_manager.php
<?php
################################################################################
##              -= YOU MAY NOT REMOVE OR CHANGE THIS NOTICE =-                 #
## --------------------------------------------------------------------------- #
##  ApPHP AdminPanel Pro                                                       #
##  Developed by:  ApPHP <hide@address.com>                                      #
##  License:       GNU LGPL v.3                                                #
##  Site:          http://www.apphp.com/php-adminpanel/                        #
##  Copyright:     ApPHP AdminPanel (c) 2006-2011. All rights reserved.        #
##                                                                             #
################################################################################

    header("content-type: text/html; charset=utf-8");
    
    // Initialize the session.
    session_start();
    
    require_once("../inc/classes/session.class.php");	
    require_once("../inc/checkAdminPagePermissions.php");

    require_once("../inc/config.inc.php");
    require_once("../inc/settings.inc.php");
	require_once("../inc/functions.inc.php");
	require_once("../inc/languages/".$SETTINGS['site_language'].".php");
	
    if(!page_access_allowed($_SERVER['SCRIPT_NAME'])) redirect_to("access_denied.php");

	$mode		= isset($_REQUEST['meng_mode']) ? $_REQUEST['meng_mode'] : "";
    $rid 		= isset($_REQUEST['meng_rid']) ? $_REQUEST['meng_rid'] : "";
    $msg 		= isset($_GET['msg']) ? $_GET['msg'] : "";
    $mgid 		= isset($_GET['mgid']) ? $_GET['mgid'] : "";
	$oid 		= isset($_GET['oid']) ? $_GET['oid'] : "0";
    $act 		= isset($_GET['act']) ? $_GET['act'] : "";
	$file_path  = "../pages/";
	$icon_path  = "../images/icons/";
	$css_class  = isset($SETTINGS['datagrid_css_style']) ? $SETTINGS['datagrid_css_style'] : "default";
	$max_index 	= "0";
	$refresh_panel = false;
  
    // Check for deleting non-removable menu groups
    if($mode == "delete"){
        $db->Query("SELECT * FROM ".TABLE_MENU." WHERE id=".(int)$rid);
        if($r__ = $db->FetchAssoc()){
            if(intval($r__['is_removable']) == intval("0")){
				redirect_to("menu_manager.php?msg=1");
                exit;
            }
        }
    }
    
    // Hide/Unhide Menu group
    if($act != ""){
		if(strtolower(_SITE_MODE) == "demo"){
			$msg = "2";			
		}else if(($act == "up") || ($act == "down")){
			// Up/Down menu item order
			$db->Query("SELECT id, order_index FROM ".TABLE_MENU." WHERE id=".(int)$oid);
			if($row_ = $db->FetchArray()){
				$first_id = $row_['id'];
				$first_order = $row_['order_index'];
				if($act == "up"){
					$sql = "SELECT id, order_index FROM ".TABLE_MENU." WHERE order_index <= ".$first_order." AND id != ".(int)$oid." AND parent_id = 0 ORDER BY ABS(order_index) DESC LIMIT 0, 1";
					$db->Query($sql);					
				}else{
					$sql = "SELECT id, order_index FROM ".TABLE_MENU." WHERE order_index >= ".$first_order." AND id != ".(int)$oid." AND parent_id = 0 ORDER BY ABS(order_index) ASC LIMIT 0, 1";
					$db->Query($sql);					
				}
				if($row_ = $db->FetchArray()){
					$second_id = $row_['id'];
					$second_order = $row_['order_index'];
					$sql = "UPDATE ".TABLE_MENU." SET order_index = ".$second_order." WHERE id = ".(int)$first_id;
					$db->Exec($sql);
					$sql = "UPDATE ".TABLE_MENU." SET order_index = ".$first_order." WHERE id = ".(int)$second_id;
					$db->Exec($sql);
					if($db->Error() == "") $msg = "4";			
				}
			}
			if($db->Error() != ""){
				$msg = "3";			
			}
		}else{
			if($act == "Hide"){
				$hide_value = "1";
			}else{
				$hide_value = "0";
			}
			$db->Exec("UPDATE ".TABLE_MENU." SET is_hidden =".(int)$hide_value." WHERE id=".(int)$mgid);
			if($db->Error() == "") $msg = "5";			
		}
    }
    
	// Get Maximum order index
	if($mode == "add"){
		$sql = "SELECT MAX(order_index) as max_index FROM ".TABLE_MENU." WHERE parent_id = 0";
		$db->Query($sql);
		if($row = $db->FetchAssoc()){
			$max_index = $row['max_index'];
		}		
	}

    $file_type = "1"; // default - static
    if($mode == "edit"){
        $db->Query("SELECT * FROM ".TABLE_MENU." WHERE id=".(int)$rid);
        if($r__ = $db->FetchAssoc()){
            $file_type = $r__['file_type_id'];        
        }        
    }

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
    <title><?php echo $SETTINGS['site_name']; ?> :: <?php echo lang('admin_panel'); ?> :: <?php echo lang('menu_manager'); ?></title>
    <meta http-equiv=Content-Type content="text/html; charset=utf-8">
    <link href="../styles/<?php echo $SETTINGS['css_style'];?>/style.css" type="text/css" rel="stylesheet">
</head>

<!-- BEGIN MAIN CONTENT ARE -->
<body dir="<?php echo $SETTINGS['language_dir'];?>">
<?php echo page_breadcrumbs(); ?>
<br />

<?php

if($msg == "1"){
    draw_message("error", "This menu group can not be removed, only hidden! To remove it, please turn removable flag 'ON' before.", true, "80%", "../");
}else if($msg == "2"){
    draw_message("error", "This operation is blocked in demo version.", true, "80%", "../");
}else if($msg == "3"){
	draw_message("error", "An error occurred while changing order! Please tray again latter.", true, "80%", "../");
}else if($msg == "4"){
	draw_message("success", "Menu order was successfully changed.", true, "80%", "../");
	$refresh_panel = true;
}else if($msg == "5"){
	draw_message("success", "Menu group visibility was successfully changed.", true, "80%", "../");
	$refresh_panel = true;	
}
if($msg != "") echo "<br />";	

################################################################################
## +---------------------------------------------------------------------------+
## | 1. Creating & Calling:                                                    | 
## +---------------------------------------------------------------------------+
##  *** define a relative (virtual) path to datagrid.class.php file and "pear" 
##  *** directory (relatively to the current file)
##  *** RELATIVE PATH ONLY ***
	define ("DATAGRID_DIR", "../modules/datagrid/");  /* Ex.: "datagrid/" */ 
	define ("PEAR_DIR", "../modules/datagrid/pear/"); /* Ex.: "datagrid/pear/" */
  
	require_once(DATAGRID_DIR.'datagrid.class.php');
	require_once(PEAR_DIR.'PEAR.php');
	require_once(PEAR_DIR.'DB.php');

  ob_start();
  
##  *** creating variables that we need for database connection
  $config = new Config();
  $DB_USER = $config->getUser();
  $DB_PASS = $config->getPassword();
  $DB_HOST = $config->getHost();
  $DB_NAME = $config->getDatabase();
  $DB_TYPE = $config->getDatabaseType();
  
  $db_conn = DB::factory($DB_TYPE);  /* don't forget to change on appropriate db type */
  $result_conn = $db_conn->connect(DB::parseDSN($DB_TYPE.'://'.$DB_USER.':'.$DB_PASS.'@'.$DB_HOST.'/'.$DB_NAME));
  if(DB::isError($result_conn)){ die($result_conn->getDebugInfo()); }  
##  *** put a primary key on the first place 
  $sql = "SELECT
        id,
        name,
        page_name,
        is_menu_group,
        is_removable,
        is_hidden,
        parent_id,
        order_index,
        CONCAT(".TABLE_MENU.".order_index, '&nbsp;&nbsp;[<a class=\"".$css_class."_dg_a\" title=\"Up\" href=\"menu_manager.php?act=up&oid=', ".TABLE_MENU.".id, '&mgid=".$mgid."\">&uarr;</a><a class=\"".$css_class."_dg_a\" title=\"Down\" href=\"menu_manager.php?act=down&oid=', ".TABLE_MENU.".id, '&mgid=".$mgid."\">&darr;</a>]') as link_order_index,
        CASE
            WHEN is_menu_item = 1 THEN '".lang('show')."'
            ELSE \"Don't Show\"
        END as my_is_menu_item,        
        CASE
            WHEN is_dashboard_icon = 1 THEN '".lang('show')."'
            ELSE \"Don't Show\"
        END as my_is_dashboard_icon,        
        CASE
            WHEN is_removable = 1 THEN '".lang('yes')."'
            ELSE '".lang('no')."'
        END as my_removable,        
        CASE
            WHEN is_hidden = 1 THEN '".lang('unhide')."'
            ELSE '".lang('Hide')."'
        END as hidden_link,
        CASE
            WHEN is_hidden = 1 THEN '<b>".lang('yes')."</b> [".lang('unhide')."]'
            ELSE '<b>".lang('no')."</b> [".lang('hide')."]'
        END as hidden_link_view,
        CASE
            WHEN is_menu_group = 1 THEN ''
            ELSE page_name
        END as my_page_name,
        '[Menu Options]' as menu_options_link
    FROM ".TABLE_MENU." WHERE is_menu_group = 1";         
##  *** set needed options and create a new class instance 
  $debug_mode = false;        /* display SQL statements while processing */    
  $messaging = true;          /* display system messages on a screen */ 
  $unique_prefix = "meng_";    /* prevent overlays - must be started with a letter */
  $dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
  if(strtolower(_SITE_MODE) == "demo") $dgrid->isDemo = true;

##  *** set data source with needed options
  $default_order_field = "order_index";
  $default_order_type = "ASC";
  $dgrid->DataSource($db_conn, $sql, $default_order_field, $default_order_type);

## +---------------------------------------------------------------------------+
## | 2. General Settings:                                                      | 
## +---------------------------------------------------------------------------+
##  *** set encoding and collation (default: utf8/utf8_unicode_ci)
/// $dg_encoding = "utf8";
/// $dg_collation = "utf8_unicode_ci";
/// $dgrid->SetEncoding($dg_encoding, $dg_collation);
##  *** set interface language (default - English)
 $dg_language = $SETTINGS['site_language'];  
 $dgrid->SetInterfaceLang($dg_language);
##  *** set direction: "ltr" or "rtr" (default - "ltr")
 $direction = $SETTINGS['language_dir'];  
 $dgrid->SetDirection($direction);
##  *** set layouts: "0" - tabular(horizontal) - default, "1" - columnar(vertical), "2" - customized 
/// $layouts = array("view"=>"0", "edit"=>"1", "details"=>"1", "filter"=>"1"); 
/// $dgrid->setLayouts($layouts);
/// $details_template = "<table><tr><td>{field_name_1}</td><td>{field_name_2}</td></tr>...</table>";
/// $dgrid->setTemplates("","",$details_template);
##  *** set modes for operations ("type" => "link|button|image") 
##  *** "byFieldValue"=>"fieldName" - make the field to be a link to edit mode page
 $modes = array(
     "add"	   =>array("view"=>true, "edit"=>false, "type"=>"link"),
     "edit"	   =>array("view"=>true, "edit"=>true,  "type"=>"link", "byFieldValue"=>""),
     "cancel"  =>array("view"=>true, "edit"=>true,  "type"=>"link"),
     "details" =>array("view"=>false, "edit"=>false, "type"=>"link"),
     "delete"  =>array("view"=>true, "edit"=>false,  "type"=>"image")
 );
 $dgrid->setModes($modes);
##  *** allow scrolling on datagrid
/// $scrolling_option = false;
/// $dgrid->allowScrollingSettings($scrolling_option);  
##  *** set scrolling settings (optional)
/// $scrolling_width = "90%";
/// $scrolling_height = "100%";
/// $dgrid->setScrollingSettings($scrolling_width, $scrolling_height);
##  *** allow mulirow operations
//  $multirow_option = true;
//  $dgrid->allowMultirowOperations($multirow_option);
/// $multirow_operations = array(
///     "delete"  => array("view"=>true),
///     "details" => array("view"=>true),
///     "my_operation_name" => array("view"=>true, "flag_name"=>"my_flag_name", "flag_value"=>"my_flag_value", "tooltip"=>"Do something with selected", "image"=>"image.gif")
/// );
/// $dgrid->setMultirowOperations($multirow_operations);  
##  *** set CSS class for datagrid
##  *** "default" or "blue" or "gray" or "green" or "pink" or your own css file 
 $dgrid->setCssClass($css_class);
##  *** set variables that used to get access to the page (like: my_page.php?act=34&id=56 etc.) 
/// $http_get_vars = array("act", "id");
/// $dgrid->setHttpGetVars($http_get_vars);
##  *** set other datagrid/s unique prefixes (if you use few datagrids on one page)
##  *** format (in which mode to allow processing of another datagrids)
##  *** array("unique_prefix"=>array("view"=>true|false, "edit"=>true|false, "details"=>true|false));
/// $anotherDatagrids = array("abcd_"=>array("view"=>true, "edit"=>true, "details"=>true));
/// $dgrid->setAnotherDatagrids($anotherDatagrids);  
##  *** set DataGrid caption
 $dg_caption = lang('menu_manager');
 $dgrid->setCaption($dg_caption);

## +---------------------------------------------------------------------------+
## | 3. Printing & Exporting Settings:                                         | 
## +---------------------------------------------------------------------------+
##  *** set printing option: true(default) or false 
 $printing_option = false;
 $dgrid->allowPrinting($printing_option);
##  *** set exporting option: true(default) or false and relative (virtual) path
##  *** to export directory (relatively to datagrid.class.php file).
##  *** Ex.: "" - if we use current datagrid folder
 $exporting_option = false;
 $exporting_directory = "../tmp/export/";               
 $dgrid->allowExporting($exporting_option, $exporting_directory);

## +---------------------------------------------------------------------------+
## | 4. Sorting & Paging Settings:                                             | 
## +---------------------------------------------------------------------------+
##  *** set sorting option: true(default) or false 
/// $sorting_option = true;
/// $dgrid->allowSorting($sorting_option);               
##  *** set paging option: true(default) or false 
/// $paging_option = true;
/// $rows_numeration = false;
/// $numeration_sign = "N #";
/// $dgrid->allowPaging($paging_option, $rows_numeration, $numeration_sign);
##  *** set paging settings
 #$bottom_paging = array("results"=>true, "results_align"=>"left", "pages"=>true, "pages_align"=>"center", "page_size"=>true, "page_size_align"=>"right");
 #$top_paging = array();
 #$pages_array = array("10"=>"10", "25"=>"25", "50"=>"50", "100"=>"100", "250"=>"250", "500"=>"500", "1000"=>"1000");
 #$default_page_size = 10;
 #$paging_arrows = array("first"=>"|&lt;&lt;", "previous"=>"&lt;&lt;", "next"=>"&gt;&gt;", "last"=>"&gt;&gt;|");
 #$dgrid->setPagingSettings($bottom_paging, $top_paging, $pages_array, $default_page_size, $paging_arrows);

## +---------------------------------------------------------------------------+
## | 5. Filter Settings:                                                       | 
## +---------------------------------------------------------------------------+
##  *** set filtering option: true or false(default)
# $filtering_option = true;
# $show_search_type = true;
# $dgrid->allowFiltering($filtering_option, $show_search_type);
###  *** set aditional filtering settings
# //$fill_from_array = array("0"=>"No", "1"=>"Yes");  /* as "value"=>"option" */
# $filtering_fields = array(
# );
# $dgrid->setFieldsFiltering($filtering_fields);

## +---------------------------------------------------------------------------+
## | 6. View Mode Settings:                                                    | 
## +---------------------------------------------------------------------------+
##  *** set view mode table properties
 $vm_table_properties = array("width"=>"80%");
 $dgrid->setViewModeTableProperties($vm_table_properties);  
##  *** set columns in view mode
 $vm_colimns = array(
    "name"              =>array("header"=>"Menu Group Name", "type"=>"label",    "align"=>"left", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>false, "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower", "summarize"=>"true|false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
    "my_is_menu_item"      =>array("header"=>lang("menu"), "type"=>"label",      "align"=>"center", "width"=>"80px", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>false, "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower", "summarize"=>"true|false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
    "my_is_dashboard_icon" =>array("header"=>lang("dashboard"), "type"=>"label", "align"=>"center", "width"=>"80px", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>false, "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower", "summarize"=>"true|false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),    
    "link_order_index"  =>array("header"=>lang("order"), "type"=>"label",      "align"=>"right", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>false, "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower", "summarize"=>"true|false", "sort_type"=>"numeric", "sort_by"=>"order_index", "visible"=>"true", "on_js_event"=>"", "post_addition"=>"&nbsp;"),
    "my_removable"      =>array("header"=>"Removable", "type"=>"label",      "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>false, "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower", "summarize"=>"true|false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),
    "hidden_link"       =>array("header"=>"Hidden", "type"=>"link",       "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>false, "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower", "summarize"=>"true|false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"hidden_link", "field_key_1"=>"id", "field_data"=>"hidden_link_view", "rel"=>"", "title"=>lang('hide')."/".lang('unhide')." menu group", "target"=>"", "href"=>"menu_manager.php?act={0}&mgid={1}"),
    "menu_options_link" =>array("header"=>" ", "type"=>"link",       "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>false, "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower", "summarize"=>"true|false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "field_key"=>"id", "field_data"=>"menu_options_link", "rel"=>"", "title"=>"Open menu options list", "target"=>"", "href"=>"menu_options_manager.php?mgid={0}"),
 );
 $dgrid->setColumnsInViewMode($vm_colimns);
##  *** set auto-genereted columns in view mode
//  $auto_column_in_view_mode = false;
//  $dgrid->setAutoColumnsInViewMode($auto_column_in_view_mode);
##
##
## +---------------------------------------------------------------------------+
## | 7. Add/Edit/Details Mode Settings:                                        | 
## +---------------------------------------------------------------------------+
##  *** set add/edit mode table properties
 $em_table_properties = array("width"=>"60%");
 $dgrid->setEditModeTableProperties($em_table_properties);
##  *** set details mode table properties
/// $dm_table_properties = array("width"=>"70%");
/// $dgrid->setDetailsModeTableProperties($dm_table_properties);
##  ***  set settings for add/edit/details modes
  $table_name  = TABLE_MENU;
  $primary_key = "id";
  $condition   = "";//"table_name.field = ".$_REQUEST['abc_rid'];
  $dgrid->setTableEdit($table_name, $primary_key, $condition);
##  *** set columns in edit mode
 $fill_from_array_hidden = array("0"=>lang('no'), "1"=>lang('yes')); /* as "value"=>"option" */
 $fill_from_array_removable = array("0"=>lang('no'), "1"=>lang('yes')); 
 $fill_from_array_dashboard = array("0"=>lang('no'), "1"=>lang('yes'));
 $fill_from_array_menu      = array("0"=>lang('no'), "1"=>lang('yes'));
 
 $em_columns = array( 
    "name"              =>array("header"=>"Menu Group Name", "type"=>"textbox",   "req_type"=>"ry", "width"=>"210px", "title"=>"Menu Group Name", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
    //"my_page_name"    =>array("header"=>"Page Name", "type"=>"textbox",   "req_type"=>"rt", "width"=>"210px", "title"=>"Page Name", "readonly"=>false, "maxlength"=>"-1", "default"=>"", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
    "order_index"       =>array("header"=>lang("order"), "type"=>"textbox",   "req_type"=>"ri", "width"=>"50px", "title"=>"Order Index", "readonly"=>false, "maxlength"=>"3", "default"=>(($max_index < 999) ? $max_index + 1 : $max_index), "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
    "is_hidden"         =>array("header"=>"Hidden",  "type"=>"enum",      "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"0", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array_hidden, "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>false, "multiple_size"=>"4"),
    "is_removable"      =>array("header"=>"Removable",  "type"=>"enum",      "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>(($file_type > "0") ? "false" : "true"), "maxlength"=>"-1", "default"=>"0", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array_removable, "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>false, "multiple_size"=>"4"),
    "is_menu_group"     =>array("header"=>"",       	"type"=>"hidden",    "req_type"=>"st", "default"=>"1", "visible"=>"true", "unique"=>false),
    "is_menu_item"      =>array("header"=>"Show In Menu?",  "type"=>"enum",      "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"1", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array_menu, "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>false, "multiple_size"=>"4"),
    "is_dashboard_icon" =>array("header"=>"Show In Dashboard?",  "type"=>"enum",      "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"1", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "source"=>$fill_from_array_dashboard, "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>false, "multiple_size"=>"4"),
 );
 $dgrid->setColumnsInEditMode($em_columns);
##  *** set auto-genereted columns in edit mode
//  $auto_column_in_edit_mode = false;
//  $dgrid->setAutoColumnsInEditMode($auto_column_in_edit_mode);
##  *** set foreign keys for add/edit/details modes (if there are linked tables)
##  *** Ex.: "condition"=>"TableName_1.FieldName > 'a' AND TableName_1.FieldName < 'c'"
##  *** Ex.: "on_js_event"=>"onclick='alert(\"Yes!!!\");'"
/// $foreign_keys = array(
///     "ForeignKey_1"=>array("table"=>"TableName_1", "field_key"=>"FieldKey_1", "field_name"=>"FieldName_1", "view_type"=>"dropdownlist(default)|radiobutton|textbox", "radiobuttons_alignment"=>"horizontal|vertical", "condition"=>"", "order_by_field"=>"My_Field_Name", "order_type"=>"ASC|DESC", "on_js_event"=>""),
///     "ForeignKey_2"=>array("table"=>"TableName_2", "field_key"=>"FieldKey_2", "field_name"=>"FieldName_2", "view_type"=>"dropdownlist(default)|radiobutton|textbox", "radiobuttons_alignment"=>"horizontal|vertical", "condition"=>"", "order_by_field"=>"My_Field_Name", "order_type"=>"ASC|DESC", "on_js_event"=>"")
/// ); 
/// $dgrid->setForeignKeysEdit($foreign_keys);
##
##
## +---------------------------------------------------------------------------+
## | 8. Bind the DataGrid:                                                     | 
## +---------------------------------------------------------------------------+
##  *** bind the DataGrid and draw it on the screen

  $add_msg = draw_message("success", lang("msg_mm_adding_successful"), false, "80%", "../");
  $update_msg = draw_message("success", lang("msg_mm_update_successful"), false, "80%", "../");
  $delete_msg = draw_message("success", lang("msg_mm_delete_successful"), false, "80%", "../");
 
  $dgrid->SetDgMessages($add_msg, $update_msg, $delete_msg); 
  $dgrid->bind();  
  ob_end_flush();
  
  if(($mode == "delete") && $dgrid->IsOperationCompleted()){
		$sql = "SELECT id, page_name, icon FROM ".TABLE_MENU." WHERE parent_id='".$dgrid->getCurrentID()."'";
		$db->Query($sql);
		while($row = $db->FetchArray()){
            // delete file
			@chdir($file_path);
            @unlink($row['page_name']);
			
            // delete icon
			@chdir($icon_path);
            @unlink($row['icon']);

            $sql = "DELETE FROM ".TABLE_DYNAMIC_PAGES." WHERE menu_id = ".(int)$row['id'];
            $db->Exec($sql); 
            $sql = "DELETE FROM ".TABLE_DATAGRID_PAGES." WHERE menu_id = ".(int)$row['id'];
            $db->Exec($sql);
			
			chdir("../../system");
		}        
		$db->Exec("DELETE FROM ".TABLE_MENU." WHERE parent_id='".$dgrid->getCurrentID()."'");        
   }
  
	if(strtolower(_SITE_MODE) != "demo")
	{
		if($dgrid->IsOperationCompleted() || $refresh_panel){
		  echo "<script type='text/javascript'>
			  setTimeout('parent.location.reload()', 1000);
		  </script>";  
		}
	}

##
################################################################################   

?>
<br />
</body>
</html>
Return current item: Basic Announce