ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/media_types.php
Go to the documentation of this file.
00001 <?php
00010   require('includes/application_top.php');
00011 
00012   $action = (isset($_GET['action']) ? $_GET['action'] : '');
00013 
00014   if (zen_not_null($action)) {
00015     switch ($action) {
00016       case 'insert':
00017       case 'save':
00018         if (isset($_GET['mID'])) $type_id = zen_db_prepare_input($_GET['mID']);
00019         if (isset($_POST['type_ext'])) $type_ext = zen_db_prepare_input($_POST['type_ext']);
00020         if (isset($_POST['type_name'])) $type_name = zen_db_prepare_input($_POST['type_name']);
00021         $sql_data_array = array('type_ext' => $type_ext);
00022 
00023         if ($action == 'insert') {
00024           $insert_data_array = array('type_name' => $type_name);
00025 
00026           $sql_data_array = array_merge($sql_data_array, $insert_data_array);
00027 
00028           zen_db_perform(TABLE_MEDIA_TYPES, $sql_data_array);
00029           $type_id = zen_db_insert_id();
00030 
00031         } elseif ($action == 'save') {
00032           $insert_data_array = array('type_name' => $type_name);
00033           $sql_data_array = array_merge($sql_data_array, $insert_data_array);
00034 
00035           zen_db_perform(TABLE_MEDIA_TYPES, $sql_data_array, 'update', "type_id = '" . (int)$type_id . "'");
00036         }
00037 
00038         zen_redirect(zen_href_link(FILENAME_MEDIA_TYPES, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'mID=' . $type_id));
00039         break;
00040       case 'deleteconfirm':
00041         // demo active test
00042         if (zen_admin_demo()) {
00043           $_GET['action']= '';
00044           $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
00045           zen_redirect(zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page']));
00046         }
00047         $type_id = zen_db_prepare_input($_POST['mID']);
00048 
00049         $db->Execute("delete from " . TABLE_MEDIA_TYPES . "
00050                       where type_id = '" . (int)$type_id . "'");
00051 
00052 
00053         zen_redirect(zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page']));
00054         break;
00055     }
00056   }
00057 ?>
00058 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
00059 <html <?php echo HTML_PARAMS; ?>>
00060 <head>
00061 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
00062 <title><?php echo TITLE; ?></title>
00063 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
00064 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
00065 <script language="javascript" src="includes/menu.js"></script>
00066 <script language="javascript" src="includes/general.js"></script>
00067 <script type="text/javascript">
00068   <!--
00069   function init()
00070   {
00071     cssjsmenu('navbar');
00072     if (document.getElementById)
00073     {
00074       var kill = document.getElementById('hoverJS');
00075       kill.disabled = true;
00076     }
00077   }
00078   // -->
00079 </script>
00080 </head>
00081 <body onload="init()">
00082 <!-- header //-->
00083 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
00084 <!-- header_eof //-->
00085 
00086 <!-- body //-->
00087 <table border="0" width="100%" cellspacing="2" cellpadding="2">
00088   <tr>
00089 <!-- body_text //-->
00090     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00091       <tr>
00092         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
00093           <tr>
00094             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
00095             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
00096           </tr>
00097         </table></td>
00098       </tr>
00099       <tr>
00100         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
00101           <tr>
00102             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00103               <tr class="dataTableHeadingRow">
00104                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_MEDIA_TYPE; ?></td>
00105                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_MEDIA_TYPE_EXT; ?></td>
00106                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
00107               </tr>
00108 <?php
00109   $media_type_query_raw = "select * from " . TABLE_MEDIA_TYPES . " order by type_name";
00110   $media_type_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $media_type_query_raw, $media_type_query_numrows);
00111   $media_type = $db->Execute($media_type_query_raw);
00112   while (!$media_type->EOF) {
00113     if ((!isset($_GET['mID']) || (isset($_GET['mID']) && ($_GET['mID'] == $media_type->fields['type_id']))) && !isset($mInfo) && (substr($action, 0, 3) != 'new')) {
00114       $mInfo = new objectInfo($media_type->fields);
00115     }
00116 
00117     if (isset($mInfo) && is_object($mInfo) && ($media_type->fields['type_id'] == $mInfo->type_id)) {
00118       echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&mID=' . $media_type->fields['type_id'] . '&action=edit') . '\'">' . "\n";
00119     } else {
00120       echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&mID=' . $media_type->fields['type_id'] . '&action=edit') . '\'">' . "\n";
00121     }
00122 ?>
00123                 <td class="dataTableContent"><?php echo $media_type->fields['type_name']; ?></td>
00124                 <td class="dataTableContent"><?php echo $media_type->fields['type_ext']; ?></td>
00125                 <td class="dataTableContent" align="right">
00126                   <?php echo '<a href="' . zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&mID=' . $media_type->fields['type_id'] . '&action=edit') . '">' . zen_image(DIR_WS_IMAGES . 'icon_edit.gif', ICON_EDIT) . '</a>'; ?>
00127                   <?php echo '<a href="' . zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&mID=' . $media_type->fields['type_id'] . '&action=delete') . '">' . zen_image(DIR_WS_IMAGES . 'icon_delete.gif', ICON_DELETE) . '</a>'; ?>
00128                   <?php if (isset($mInfo) && is_object($mInfo) && ($media_type->fields['type_id'] == $mInfo->type_id)) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . zen_href_link(FILENAME_MEDIA_TYPES, zen_get_all_get_params(array('mID')) . 'mID=' . $media_type->fields['type_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>
00129                 </td>
00130               </tr>
00131 <?php
00132     $media_type->MoveNext();
00133   }
00134 ?>
00135               <tr>
00136                 <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00137                   <tr>
00138                     <td class="smallText" valign="top"><?php echo $media_type_split->display_count($media_type_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_MEDIA_TYPES); ?></td>
00139                     <td class="smallText" align="right"><?php echo $media_type_split->display_links($media_type_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
00140                   </tr>
00141                 </table></td>
00142               </tr>
00143 <?php
00144   if (empty($action)) {
00145 ?>
00146               <tr>
00147                 <td align="right" colspan="3" class="smallText"><?php echo '<a href="' . zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&mID=' . $mInfo->type_id . '&action=new') . '">' . zen_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?></td>
00148               </tr>
00149 <?php
00150   }
00151 ?>
00152             </table></td>
00153 <?php
00154   $heading = array();
00155   $contents = array();
00156 
00157   switch ($action) {
00158     case 'new':
00159       $heading[] = array('text' => '<b>' . TEXT_HEADING_NEW_MEDIA_TYPE . '</b>');
00160 
00161       $contents = array('form' => zen_draw_form('media_type', FILENAME_MEDIA_TYPES, 'action=insert', 'post', 'enctype="multipart/form-data"'));
00162       $contents[] = array('text' => TEXT_NEW_INTRO);
00163       $contents[] = array('text' => '<br>' . TEXT_MEDIA_TYPE_NAME . '<br>' . zen_draw_input_field('type_name', '', zen_set_field_length(TABLE_MEDIA_TYPES, 'type_name')));
00164       $contents[] = array('text' => '<br>' . TEXT_MEDIA_TYPE_EXT . '<br>' . zen_draw_input_field('type_ext', '', zen_set_field_length(TABLE_MEDIA_TYPES, 'type_ext')));
00165 
00166       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&mID=' . $_GET['mID']) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
00167       break;
00168     case 'edit':
00169       $heading[] = array('text' => '<b>' . TEXT_HEADING_EDIT_MEDIA_TYPE . '</b>');
00170 
00171       $contents = array('form' => zen_draw_form('media_type', FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&mID=' . $mInfo->type_id . '&action=save', 'post', 'enctype="multipart/form-data"'));
00172       $contents[] = array('text' => TEXT_EDIT_INTRO);
00173 
00174       $contents[] = array('text' => '<br>' . TEXT_MEDIA_TYPE_NAME . '<br>' . zen_draw_input_field('type_name', $mInfo->type_name, zen_set_field_length(TABLE_MEDIA_TYPES, 'type_name')));
00175 
00176       $contents[] = array('text' => '<br />' . TEXT_MEDIA_TYPE_EXT . '<br>' . zen_draw_input_field('type_ext', $mInfo->type_ext, zen_set_field_length(TABLE_MEDIA_TYPES, 'type_ext')));
00177       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&mID=' . $mInfo->type_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
00178       break;
00179     case 'delete':
00180       $heading[] = array('text' => '<b>' . TEXT_HEADING_DELETE_MEDIA_TYPES . '</b>');
00181 
00182       $contents = array('form' => zen_draw_form('media_type', FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&action=deleteconfirm') . zen_draw_hidden_field('mID', $mInfo->type_id));
00183       $contents[] = array('text' => TEXT_DELETE_INTRO);
00184       $contents[] = array('text' => '<br><b>' . $mInfo->type_name . '</b>');
00185 
00186       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&mID=' . $mInfo->type_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
00187       break;
00188     default:
00189       if (isset($mInfo) && is_object($mInfo)) {
00190         $heading[] = array('text' => '<b>' . $mInfo->type_name . '</b>');
00191 
00192         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&mID=' . $mInfo->type_id . '&action=edit') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_MEDIA_TYPES, 'page=' . $_GET['page'] . '&mID=' . $mInfo->type_id . '&action=delete') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
00193         $contents[] = array('text' => '<br>' . TEXT_EXTENSION . ' ' . $mInfo->type_ext);
00194       }
00195       break;
00196   }
00197 
00198   if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
00199     echo '            <td width="25%" valign="top">' . "\n";
00200 
00201     $box = new box;
00202     echo $box->infoBox($heading, $contents);
00203 
00204     echo '            </td>' . "\n";
00205   }
00206 ?>
00207           </tr>
00208         </table></td>
00209       </tr>
00210     </table></td>
00211 <!-- body_text_eof //-->
00212   </tr>
00213 </table>
00214 <!-- body_eof //-->
00215 
00216 <!-- footer //-->
00217 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
00218 <!-- footer_eof //-->
00219 <br>
00220 </body>
00221 </html>
00222 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
 All Data Structures Namespaces Files Functions Variables Enumerations