Location: PHPKode > projects > Basic Announce > Basic Announce Version 4.0/system/create_page.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");

    $unique_prefix = "cp_";    /* prevent overlays - must be started with a letter */
                                 
    $mode           = isset($_REQUEST[$unique_prefix.'mode']) ? $_REQUEST[$unique_prefix.'mode'] : "";
    $rid            = isset($_REQUEST[$unique_prefix.'rid']) ? (int)$_REQUEST[$unique_prefix.'rid'] : "";
    $msg            = isset($_REQUEST['msg']) ? $_REQUEST['msg'] : "";
	$page_type      = isset($_REQUEST['page_type']) ? $_REQUEST['page_type'] : "";
    #$mgid           = isset($_REQUEST['mgid']) ? $_REQUEST['mgid'] : "";
    #$moid           = isset($_REQUEST['moid']) ? $_REQUEST['moid'] : "";
    #$act            = isset($_REQUEST['act']) ? $_REQUEST['act'] : "";
    $page_name      = isset($_POST['rtypage_name']) ? $_POST['rtypage_name'] : "";
    $file_type_id   = isset($_POST['riyfile_type_id']) ? $_POST['riyfile_type_id'] : "";
    $file_type      = "1"; // default - static
    $file_path      = "../pages/";
    $css_class      = isset($SETTINGS['datagrid_css_style']) ? $SETTINGS['datagrid_css_style'] : "default";
	$styis_create_file = isset($_POST['styis_create_file']) ? $_POST['styis_create_file'] : "";
	
     
    //--------------------------------------------------------------------------
    // Menu item was deleted   
    //--------------------------------------------------------------------------
    if($mode == "cancel"){
		if($page_type == "static"){
			redirect_to("static_pages_manager.php");
			exit;
		}		
    }
 
  
################################################################################
## +---------------------------------------------------------------------------+
## | 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
        ".TABLE_MENU.".id,
        ".TABLE_MENU.".name,
        ".TABLE_MENU.".page_name,
        ".TABLE_MENU.".is_menu_group,
        ".TABLE_MENU.".is_removable,
        ".TABLE_MENU.".is_hidden,
        ".TABLE_MENU.".icon,
        ".TABLE_MENU.".parent_id,
        ".TABLE_MENU.".order_index,
        CASE
            WHEN ".TABLE_MENU.".is_menu_item = 1 THEN 'Show'
            ELSE \"Don't Show\"
        END as my_is_menu_item,        
        CASE
            WHEN ".TABLE_MENU.".is_dashboard_icon = 1 THEN 'Show'
            ELSE \"Don't Show\"
        END as my_is_dashboard_icon,        
        CASE
            WHEN ".TABLE_MENU.".is_removable = 1 THEN 'Yes'
            ELSE 'No'
        END as my_removable,        
        CASE
            WHEN ".TABLE_MENU.".is_hidden = 1 THEN 'Unhide'
            ELSE 'Hide'
        END as hidden_link,
        CASE
            WHEN ".TABLE_MENU.".is_menu_group = 1 THEN ''
            ELSE page_name
        END as my_page_name,
        'Menu Options' as menu_options_link,
        CASE
            WHEN ".TABLE_MENU.".file_type_id = 1 THEN CONCAT('<a class=\"".$css_class."_dg_a\" href=\"static_pages_manager.php?sp_mode=edit&sp_rid=', ".TABLE_STATIC_PAGES.".id, '\">[Edit Content]</a>')
            WHEN ".TABLE_MENU.".file_type_id = 2 THEN CONCAT('<a class=\"".$css_class."_dg_a\" href=\"dynamic_pages_editor.php?dpid=', ".TABLE_DYNAMIC_PAGES.".id, '\">', '[Edit Content]</a>')
            WHEN ".TABLE_MENU.".file_type_id = 3 THEN CONCAT('<a class=\"".$css_class."_dg_a\" href=\"datagrid_pages_editor.php?dpid=', ".TABLE_DATAGRID_PAGES.".id, '\">', '[Edit Content]</a>')
            ELSE 'Not Editable'
        END page_edit_link,
        ".TABLE_MENU.".file_type_id,
        ".TABLE_FILE_TYPES.".name as file_type_name
    FROM ".TABLE_MENU."
        LEFT OUTER JOIN ".TABLE_FILE_TYPES." ON ".TABLE_MENU.".file_type_id = ".TABLE_FILE_TYPES.".id
        LEFT OUTER JOIN ".TABLE_STATIC_PAGES." ON ".TABLE_MENU.".id = ".TABLE_STATIC_PAGES.".menu_id
        LEFT OUTER JOIN ".TABLE_DYNAMIC_PAGES." ON ".TABLE_MENU.".id = ".TABLE_DYNAMIC_PAGES.".menu_id
        LEFT OUTER JOIN ".TABLE_DATAGRID_PAGES." ON ".TABLE_MENU.".id = ".TABLE_DATAGRID_PAGES.".menu_id
    WHERE
        ".TABLE_MENU.".is_menu_group = 0 ";
	
	if($page_type == "static"){
		$sql .= " AND ".TABLE_MENU.".file_type_id = 1 ";
	}
	//".TABLE_MENU.".parent_id = ".(int)$mgid."	
    
##  *** 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 */ 
  $dgrid = new DataGrid($debug_mode, $messaging, $unique_prefix, DATAGRID_DIR);
  if(strtolower(_SITE_MODE) == "demo") $dgrid->isDemo = true;
  //$dgrid->navigationBar = "<a class='".$css_class."_dg_a' href='menu_manager.php'>&laquo; Back to Menu Manager</a></center>";  

##  *** 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"=>false, "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 = false;
  $dgrid->allowMultirowOperations($multirow_option);
  $multirow_operations = array(
     "delete"  => array("view"=>true),
     "details" => array("view"=>false),
//     "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("page_type");
 $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 = "Create ".$page_type." page";
 $dgrid->setCaption($dg_caption);
##
##
## +---------------------------------------------------------------------------+
## | 3. Printing & Exporting Settings:                                         | 
## +---------------------------------------------------------------------------+
##  *** set printing option: true(default) or false 
 $printing_option = true;
 $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"=>"85%");
 $dgrid->setViewModeTableProperties($vm_table_properties);  
##  *** set columns in view mode
##  *** Ex.: "on_js_event"=>"onclick='alert(\"Yes!!!\");'"
##  ***      "barchart" : number format in SELECT SQL must be equal with number format in max_value
 $vm_colimns = array(
    "icon"              =>array("header"=>"Icon", "type"=>"image",      "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>"false", "tooltip_type"=>"floating|simple", "case"=>"normal|upper|lower|camel", "summarize"=>"false", "sort_type"=>"string|numeric", "sort_by"=>"", "visible"=>"true", "on_js_event"=>"", "target_path"=>"../images/icons/", "default"=>"", "image_width"=>"25px", "image_height"=>"25px", "magnify"=>"true", "magnify_type"=>"magnifier"),
    "name"              =>array("header"=>"Menu Option 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"=>""),
    "file_type_name"    =>array("header"=>"File Type", "type"=>"label",      "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>false, "tooltip_type"=>"floating|simple", "case"=>"normal", "summarize"=>"true|false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),    
    "my_is_menu_item"   =>array("header"=>" Menu ", "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"=>""),
    "my_is_dashboard_icon" =>array("header"=>lang("dashboard"), "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"=>""),    
    "order_index"       =>array("header"=>lang("order"), "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"=>""),
    "my_removable"      =>array("header"=>"Is 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"=>""),
    "page_edit_link"    =>array("header"=>" ", "type"=>"label",      "align"=>"center", "width"=>"", "wrap"=>"nowrap", "text_length"=>"-1", "tooltip"=>false, "tooltip_type"=>"floating|simple", "case"=>"normal", "summarize"=>"true|false", "sort_by"=>"", "visible"=>"true", "on_js_event"=>""),     
    //"hidden_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"=>"hidden_link", "field_key_1"=>"id", "field_data"=>"hidden_link", "rel"=>"", "title"=>"Hide/Unhide menu option", "target"=>"", "href"=>"menu_options_manager.php?act={0}&mgid=".$mgid."&moid={1}"),
 );
 $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"=>"No", "1"=>"Yes"); /* as "value"=>"option" */
 $fill_from_array_removable = array("0"=>"No", "1"=>"Yes"); 
 $fill_from_array_dashboard = array("0"=>"No", "1"=>"Yes"); 
 $fill_from_array_menu      = array("0"=>"No", "1"=>"Yes");
 
 $em_columns = array(
 
    "parent_id"      =>array("header"=>"Menu Group", "type"=>"foreign_key", "req_type"=>"ri", "width"=>"210px", "title"=>"", "readonly"=>(($mode == "edit") ? "true" : "false"), "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true"),
    "name"           =>array("header"=>"Menu Option 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"=>""),
    "page_name"      =>array("header"=>"Page Name", "type"=>"textbox",   "req_type"=>"rt", "width"=>"210px", "title"=>"Page Name", "readonly"=>(($file_type > "0") ? (($mode == "edit") ? "true" : "false") : "true"), "maxlength"=>"-1", "default"=>"", "unique"=>true, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "post_addition"=>(($file_type > "0" && ($file_type == "2" || $file_type == "3")) ? "<br />PHP pages will be placed in directory <b>pages/</b>" : "<br />Use .php exention for PHP Dynamic and PHP Datagrid pages")),
    "order_index"    =>array("header"=>"Order Index", "type"=>"textbox",   "req_type"=>"ri", "width"=>"50px", "title"=>"Order Index", "readonly"=>false, "maxlength"=>"3", "default"=>"0", "unique"=>false, "unique_condition"=>"", "visible"=>"true", "on_js_event"=>""),
    "is_removable"   => array("header"=>"Is Removable?",  "type"=>"enum",      "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"0", "unique"=>false, "unique_condition"=>"", "visible"=>(($file_type > "0") ? "true" : "false"), "on_js_event"=>"", "source"=>$fill_from_array_removable, "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "multiple"=>false, "multiple_size"=>"4"),
    "is_hidden"      =>array("header"=>"Is 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_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"),
    "icon"           =>array("header"=>"Icon", "type"=>"image",     "req_type"=>"st", "width"=>"220px", "title"=>"", "readonly"=>"false", "maxlength"=>"-1", "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true", "on_js_event"=>"", "target_path"=>"../images/icons/", "max_file_size"=>"100K", "image_width"=>"96px", "image_height"=>"96px", "magnify"=>"false", "file_name"=>"img_".((isset($_REQUEST[$mode.'mode']) && ($_REQUEST[$mode.'mode'] == "add")) ? $dgrid->GetRandomString("10") : $dgrid->GetCurrentId()), "host"=>"local", "magnify_type"=>"lightbox"),

    "is_menu_group"  =>array("header"=>"",       "type"=>"hidden",    "req_type"=>"st", "default"=>"0", "unique"=>false),
    "file_type_id"   =>array("header"=>"",       "type"=>"hidden",    "req_type"=>"st", "default"=>"1", "unique"=>false),
    "is_create_file" =>array("header"=>"",       "type"=>"hidden",    "req_type"=>"st", "default"=>"0", "unique"=>false),
    
    //"is_create_file" =>array("header"=>"Create File?", "type"=>"checkbox",  "req_type"=>"st", "width"=>"210px", "title"=>"", "readonly"=>false, "maxlength"=>"-1", "default"=>"1", "unique"=>false, "unique_condition"=>"", "visible"=>(($mode == "add") ? "true" : "false"), "on_js_event"=>"", "true_value"=>1, "false_value"=>0, "post_addition"=>"(for PHP Dynamic and PHP DataGrid pages)"),
    //"file_type_id"   => array("header"=>"Page Type", "type"=>"foreign_key", "req_type"=>"ri", "default"=>"1", "width"=>"210px", "title"=>"", "readonly"=>(($mode == "edit") ? "true" : "false"), "default"=>"", "unique"=>"false", "unique_condition"=>"", "visible"=>"true"),
 );
 
 $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(
    "parent_id"    => array("table"=>TABLE_MENU, "field_key"=>"id", "field_name"=>"name", "view_type"=>"dropdownlist", "radiobuttons_alignment"=>"horizontal|vertical", "condition"=>"is_menu_group = 1", "order_by_field"=>"", "order_type"=>"ASC", "on_js_event"=>""),
 ); 
 $dgrid->setForeignKeysEdit($foreign_keys);
##
################################################################################   


?>

<!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'); ?></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("static_pages_manager.php"); ?>
<br />
<?php

	## +---------------------------------------------------------------------------+
	## | 8. Bind the DataGrid:                                                     | 
	## +---------------------------------------------------------------------------+
	##  *** bind the DataGrid and draw it on the screen
	ob_start();    
	if($msg == "1"){
		draw_message("error", "This menu option can not be removed, only hidden! <br>To remove it, please turn removable flag 'ON' before.", true, "85%", "../");
		echo "<br/>";
	}else if($msg == "2"){
		draw_message("error", "This operation is blocked in demo version.", true, "85%", "../");
		echo "<br />";	
	}
	
	$add_msg = draw_message("success", "The adding operation was successfully completed! <br>To be sure that new changes will take effect, please <a href='javascript:parent.location.reload();'>refresh the site</a> or wait few seconds.", false, "85%", "../");
	$update_msg = draw_message("success", "The updating operation was successfully completed! <br>To be sure that new changes will take effect, please <a href='javascript:parent.location.reload();'>refresh the site</a> or wait few seconds.", false, "85%", "../");
	$delete_msg = draw_message("success", "The deleting operation was successfully completed! <br>To be sure that new changes will take effect, please <a href='javascript:parent.location.reload();'>refresh the site</a> or wait few seconds.", false, "85%", "../");
	
	$dgrid->SetDgMessages($add_msg, $update_msg, $delete_msg); 
    if($mode == "update" && $dgrid->IsOperationCompleted())
	{
		$dgrid->bind(false);
	}else{
		$dgrid->bind();
	}
	ob_end_flush();
  

    //--------------------------------------------------------------------------
    // Menu item was deleted   
    //--------------------------------------------------------------------------
	
    if($mode == "delete" && $dgrid->IsOperationCompleted() && $rid != "")
	{
		// if static page    
        if($file_type == "1"){
			// do nothing
        }
    }

    //--------------------------------------------------------------------------
    // Menu item was created
    //--------------------------------------------------------------------------
    if($mode == "update" && $rid == "-1" && $dgrid->IsOperationCompleted())
	{
        // create static page
        if($page_type == "static"){
            $page_text = "This is HTML static page <br/>";
            $page_text .= "This page was created on: ".date("M d, Y g:i A")." <br/>";
            
            $sql = "INSERT INTO ".TABLE_STATIC_PAGES." (id, menu_id, page_header, page_text, created_at, updated_at)
                    VALUES (NULL, ".(int)$dgrid->GetCurrentId().", 'Page Header', '".$page_text."', '".date("Y-m-d H:i:s")."', '0000-00-00 00:00:00')";
            $db->Exec($sql);
        }

		if(strtolower(_SITE_MODE) != "demo"){		
			if($SETTINGS['menu_style'] == "side"){
				echo "<script type='text/javascript'>
					setTimeout('parent.location.reload()', 500);";
				if($page_type == "static"){
					echo " setTimeout('document.location.href=\"static_pages_manager.php\"', 800); ";
				}					
				echo "</script>";
			}
		}
    } 

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