ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/admin_page_registration.php
Go to the documentation of this file.
00001 <?php
00010 require('includes/application_top.php');
00011 
00012 // initialise form values
00013 $page_key = $language_key = $main_page = $page_params = $menu_key = $checked = '';
00014 $sort_order = 0;
00015 
00016 // check if we are receiving form content and if so validate and process it
00017 if (isset($_POST) && !empty($_POST))
00018 {
00019   $error = FALSE;
00020 
00021   if (isset($_POST['page_key'])) $page_key = zen_db_prepare_input($_POST['page_key']);
00022   if (empty($page_key))
00023   {
00024     $error = TRUE;
00025     $messageStack->add(ERROR_PAGE_KEY_NOT_ENTERED, 'error');
00026   } elseif (zen_page_key_exists($page_key))
00027   {
00028     $error = TRUE;
00029     $messageStack->add(ERROR_PAGE_KEY_ALREADY_EXISTS, 'error');
00030   }
00031 
00032   if (isset($_POST['language_key'])) $language_key = zen_db_prepare_input($_POST['language_key']);
00033   if (empty($page_key))
00034   {
00035     $error = TRUE;
00036     $messageStack->add(ERROR_LANGUAGE_KEY_NOT_ENTERED, 'error');
00037   } elseif (!defined($language_key))
00038   {
00039     $error = TRUE;
00040     $messageStack->add(ERROR_LANGUAGE_KEY_HAS_NOT_BEEN_DEFINED, 'error');
00041   }
00042 
00043   if (isset($_POST['main_page'])) $main_page = zen_db_prepare_input($_POST['main_page']);
00044   if (empty($main_page))
00045   {
00046     $error = TRUE;
00047     $messageStack->add(ERROR_MAIN_PAGE_NOT_ENTERED, 'error');
00048   } elseif (!defined($main_page))
00049   {
00050     $error = TRUE;
00051     $messageStack->add(ERROR_FILENAME_HAS_NOT_BEEN_DEFINED, 'error');
00052   }
00053 
00054   if (isset($_POST['page_params']))
00055   {
00056     $page_params = zen_db_prepare_input($_POST['page_params']);
00057   }
00058 
00059   if (isset($_POST['menu_key'])) $menu_key = zen_db_prepare_input($_POST['menu_key']);
00060   if (empty($menu_key))
00061   {
00062     $error = TRUE;
00063     $messageStack->add(ERROR_MENU_NOT_CHOSEN, 'error');
00064   }
00065 
00066   if (isset($_POST['display_on_menu']))
00067   {
00068     $checked = 'checked="true"';
00069     $display_on_menu = 'Y';
00070   } else
00071   {
00072     $display_on_menu = 'N';
00073   }
00074 
00075   if (isset($_POST['sort_order']))
00076   {
00077     $sort_order = (int)$_POST['sort_order'];
00078   }
00079 
00080   if (!$error)
00081   {
00082     // register page
00083     zen_register_admin_page($page_key, $language_key, $main_page, $page_params, $menu_key, $display_on_menu, $sort_order);
00084 
00085     // prepare success message
00086     $messageStack->add(SUCCESS_ADMIN_PAGE_REGISTERED, 'success');
00087 
00088     // reset form values
00089     $page_key = $language_key = $main_page = $page_params = $menu_key = $checked = '';
00090     $sort_order = 0;
00091   }
00092 
00093 }
00094 
00095 // prepare options for menu pulldown
00096 $menu_titles = zen_get_menu_titles();
00097 $menu_options = array();
00098 $menu_options[0] = array('id' => NULL, 'text' => TEXT_SELECT_MENU);
00099 foreach ($menu_titles as $id => $title) {
00100   $menu_options[] = array('id' => $id, 'text' => $title);
00101 }
00102 
00103 
00104 ?>
00105 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
00106 <html <?php echo HTML_PARAMS; ?>>
00107 <head>
00108 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
00109 <title><?php echo TITLE; ?></title>
00110 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
00111 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
00112 <link rel="stylesheet" type="text/css" href="includes/admin_access.css" />
00113 <script language="javascript" src="includes/menu.js"></script>
00114 <script language="javascript" src="includes/general.js"></script>
00115 <script type="text/javascript">
00116   <!--
00117   function init() {
00118     cssjsmenu('navbar');
00119   }
00120   // -->
00121 </script>
00122 </head>
00123 <body onload="init()">
00124 <!-- header //-->
00125 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
00126 <!-- header_eof //-->
00127 
00128 <!-- body //-->
00129 <div id="pageWrapper">
00130   <h1><?php echo HEADING_TITLE ?></h1>
00131   <?php echo zen_draw_form('admin_page_registration_form', FILENAME_ADMIN_PAGE_REGISTRATION, 'action=insert', 'post', 'id="adminPageRegistrationForm"'); ?>
00132     <div>
00133       <label for="pageKey"><?php echo TEXT_PAGE_KEY ?></label>
00134       <input type="text" name="page_key" id="pageKey" value="<?php echo $page_key ?>" />
00135       <span><?php echo TEXT_EXAMPLE_PAGE_KEY ?></span>
00136     </div>
00137     <div>
00138       <label for="languageKey"><?php echo TEXT_LANGUAGE_KEY ?></label>
00139       <input type="text" name="language_key" id="languageKey" value="<?php echo $language_key ?>" />
00140       <span><?php echo TEXT_EXAMPLE_LANGUAGE_KEY ?></span>
00141     </div>
00142     <div>
00143       <label for="mainPage"><?php echo TEXT_MAIN_PAGE ?></label>
00144       <input type="text" name="main_page" id="mainPage" value="<?php echo $main_page ?>" />
00145       <span><?php echo TEXT_EXAMPLE_MAIN_PAGE ?></span>
00146     </div>
00147     <div>
00148       <label for="pageParams"><?php echo TEXT_PAGE_PARAMS ?></label>
00149       <input type="text" name="page_params" id="pageParams" value="<?php echo $page_params ?>" />
00150       <span><?php echo TEXT_EXAMPLE_PAGE_PARAMS ?></span>
00151     </div>
00152     <div>
00153       <label for="menuKey"><?php echo TEXT_MENU_KEY ?></label>
00154       <?php echo zen_draw_pull_down_menu('menu_key', $menu_options, $menu_key) ?>
00155     </div>
00156     <div>
00157       <label for="displayOnMenu"><?php echo TEXT_DISPLAY_ON_MENU ?></label>
00158       <input type="checkbox" name="display_on_menu" id="displayOnMenu" <?php echo $checked ?> />
00159     </div>
00160     <div>
00161       <label for="sortOrder"><?php echo TEXT_SORT_ORDER ?></label>
00162       <input type="text" name="sort_order" id="sortOrder" value="<?php echo $sort_order ?>" />
00163     </div>
00164     <div>
00165       <?php echo zen_image_submit('button_insert.gif', IMAGE_INSERT, 'id="button"') ?>
00166     </div>
00167   <?php echo '</form>' ?>
00168 </div>
00169 <!-- body_eof //-->
00170 
00171 <!-- footer //-->
00172 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
00173 <!-- footer_eof //-->
00174 <br>
00175 </body>
00176 </html>
00177 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
 All Data Structures Namespaces Files Functions Variables Enumerations