ZenCart_Documentation  1.5.0
http://www.collinsharper.com
C:/xampp/htdocs/zen-cart/admin/record_artists.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'])) $artists_id = zen_db_prepare_input($_GET['mID']);
00019         $artists_name = zen_db_prepare_input($_POST['artists_name']);
00020 
00021         $sql_data_array = array('artists_name' => $artists_name);
00022 
00023         if ($action == 'insert') {
00024           $insert_sql_data = array('date_added' => 'now()');
00025 
00026           $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
00027 
00028           zen_db_perform(TABLE_RECORD_ARTISTS, $sql_data_array);
00029           $artists_id = zen_db_insert_id();
00030         } elseif ($action == 'save') {
00031           $update_sql_data = array('last_modified' => 'now()');
00032 
00033           $sql_data_array = array_merge($sql_data_array, $update_sql_data);
00034 
00035           zen_db_perform(TABLE_RECORD_ARTISTS, $sql_data_array, 'update', "artists_id = '" . (int)$artists_id . "'");
00036         }
00037 
00038       if ($_POST['artists_image_manual'] != '') {
00039         // add image manually
00040         $artists_image_name = zen_db_input($_POST['img_dir'] . $_POST['artists_image_manual']);
00041         $db->Execute("update " . TABLE_RECORD_ARTISTS . "
00042                       set artists_image = '" .  $artists_image_name . "'
00043                       where artists_id = '" . (int)$artists_id . "'");
00044       } else {
00045         $artists_image = new upload('artists_image');
00046         $artists_image->set_destination(DIR_FS_CATALOG_IMAGES . $_POST['img_dir']);
00047         if ( $artists_image->parse() &&  $artists_image->save()) {
00048           // remove image from database if none
00049           if ($artists_image->filename != 'none') {
00050             $db->Execute("update " . TABLE_RECORD_ARTISTS . "
00051                           set artists_image = '" .  zen_db_input($_POST['img_dir'] . $artists_image->filename) . "'
00052                           where artists_id = '" . (int)$artists_id . "'");
00053           } else {
00054             $db->Execute("update " . TABLE_RECORD_ARTISTS . "
00055                           set artists_image = ''
00056                           where artists_id = '" . (int)$artists_id . "'");
00057           }
00058         }
00059       }
00060 
00061         $languages = zen_get_languages();
00062         for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
00063           $artists_url_array = $_POST['artists_url'];
00064           $language_id = $languages[$i]['id'];
00065 
00066           $sql_data_array = array('artists_url' => zen_db_prepare_input($artists_url_array[$language_id]));
00067 
00068           if ($action == 'insert') {
00069             $insert_sql_data = array('artists_id' => $artists_id,
00070                                      'languages_id' => $language_id);
00071 
00072             $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
00073 
00074             zen_db_perform(TABLE_RECORD_ARTISTS_INFO, $sql_data_array);
00075           } elseif ($action == 'save') {
00076             zen_db_perform(TABLE_RECORD_ARTISTS_INFO, $sql_data_array, 'update', "artists_id = '" . (int)$artists_id . "' and languages_id = '" . (int)$language_id . "'");
00077           }
00078         }
00079 
00080         zen_redirect(zen_href_link(FILENAME_RECORD_ARTISTS, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'mID=' . $artists_id));
00081         break;
00082       case 'deleteconfirm':
00083         // demo active test
00084         if (zen_admin_demo()) {
00085           $_GET['action']= '';
00086           $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
00087           zen_redirect(zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page']));
00088         }
00089         $artists_id = zen_db_prepare_input($_POST['mID']);
00090 
00091         if (isset($_POST['delete_image']) && ($_POST['delete_image'] == 'on')) {
00092 
00093           $manufacturer = $db->Execute("select artists_image
00094                                         from " . TABLE_RECORD_ARTISTS . "
00095                                         where artists_id = '" . (int)$artists_id . "'");
00096           $image_location = DIR_FS_CATALOG_IMAGES . $manufacturer->fields['artists_image'];
00097 
00098           if (file_exists($image_location)) @unlink($image_location);
00099         }
00100 
00101         $db->Execute("delete from " . TABLE_RECORD_ARTISTS . "
00102                       where artists_id = '" . (int)$artists_id . "'");
00103         $db->Execute("delete from " . TABLE_RECORD_ARTISTS_INFO . "
00104                       where artists_id = '" . (int)$artists_id . "'");
00105 
00106         if (isset($_POST['delete_products']) && ($_POST['delete_products'] == 'on')) {
00107           $products = $db->Execute("select products_id
00108                                     from " . TABLE_PRODUCT_MUSIC_EXTRA . "
00109                                     where artists_id = '" . (int)$artists_id . "'");
00110 
00111           while (!$products->EOF) {
00112             zen_remove_product($products->fields['products_id']);
00113             $products->MoveNext();
00114           }
00115         } else {
00116           $db->Execute("update " . TABLE_PRODUCT_MUSIC_EXTRA . "
00117                         set artists_id = ''
00118                         where artists_id = '" . (int)$artists_id . "'");
00119         }
00120 
00121         zen_redirect(zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page']));
00122         break;
00123     }
00124   }
00125 ?>
00126 <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
00127 <html <?php echo HTML_PARAMS; ?>>
00128 <head>
00129 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
00130 <title><?php echo TITLE; ?></title>
00131 <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
00132 <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
00133 <script language="javascript" src="includes/menu.js"></script>
00134 <script language="javascript" src="includes/general.js"></script>
00135 <script type="text/javascript">
00136   <!--
00137   function init()
00138   {
00139     cssjsmenu('navbar');
00140     if (document.getElementById)
00141     {
00142       var kill = document.getElementById('hoverJS');
00143       kill.disabled = true;
00144     }
00145   }
00146   // -->
00147 </script>
00148 </head>
00149 <body onload="init()">
00150 <!-- header //-->
00151 <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
00152 <!-- header_eof //-->
00153 
00154 <!-- body //-->
00155 <table border="0" width="100%" cellspacing="2" cellpadding="2">
00156   <tr>
00157 <!-- body_text //-->
00158     <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00159       <tr>
00160         <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
00161           <tr>
00162             <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
00163             <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
00164           </tr>
00165         </table></td>
00166       </tr>
00167       <tr>
00168         <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
00169           <tr>
00170             <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00171               <tr class="dataTableHeadingRow">
00172                 <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_RECORD_ARTISTS; ?></td>
00173                 <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
00174               </tr>
00175 <?php
00176   $artists_query_raw = "select * from " . TABLE_RECORD_ARTISTS . " order by artists_name";
00177   $artists_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $artists_query_raw, $artists_query_numrows);
00178   $artists = $db->Execute($artists_query_raw);
00179 
00180   while (!$artists->EOF) {
00181 
00182     if ((!isset($_GET['mID']) || (isset($_GET['mID']) && ($_GET['mID'] == $artists->fields['artists_id']))) && !isset($aInfo) && (substr($action, 0, 3) != 'new')) {
00183       $artists_products = $db->Execute("select count(*) as products_count
00184                                              from " . TABLE_PRODUCT_MUSIC_EXTRA . "
00185                                              where artists_id = '" . (int)$artists->fields['artists_id'] . "'");
00186 
00187       $aInfo_array = array_merge($artists->fields, $artists_products->fields);
00188       $aInfo = new objectInfo($aInfo_array);
00189     }
00190 
00191     if (isset($aInfo) && is_object($aInfo) && ($artists->fields['artists_id'] == $aInfo->artists_id)) {
00192       echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $artists->fields['artists_id'] . '&action=edit') . '\'">' . "\n";
00193     } else {
00194       echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $artists->fields['artists_id'] . '&action=edit') . '\'">' . "\n";
00195     }
00196 ?>
00197                 <td class="dataTableContent"><?php echo $artists->fields['artists_name']; ?></td>
00198                 <td class="dataTableContent" align="right">
00199                   <?php echo '<a href="' . zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $artists->fields['artists_id'] . '&action=edit') . '">' . zen_image(DIR_WS_IMAGES . 'icon_edit.gif', ICON_EDIT) . '</a>'; ?>
00200                   <?php echo '<a href="' . zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $artists->fields['artists_id'] . '&action=delete') . '">' . zen_image(DIR_WS_IMAGES . 'icon_delete.gif', ICON_DELETE) . '</a>'; ?>
00201                   <?php if (isset($aInfo) && is_object($aInfo) && ($artists->fields['artists_id'] == $aInfo->artists_id)) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . zen_href_link(FILENAME_RECORD_ARTISTS, zen_get_all_get_params(array('mID')) . 'mID=' . $artists->fields['artists_id']) . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>
00202                 </td>
00203               </tr>
00204 <?php
00205     $artists->MoveNext();
00206   }
00207 ?>
00208               <tr>
00209                 <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
00210                   <tr>
00211                     <td class="smallText" valign="top"><?php echo $artists_split->display_count($artists_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $_GET['page'], TEXT_DISPLAY_NUMBER_OF_ARTISTS); ?></td>
00212                     <td class="smallText" align="right"><?php echo $artists_split->display_links($artists_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $_GET['page']); ?></td>
00213                   </tr>
00214                 </table></td>
00215               </tr>
00216 <?php
00217   if (empty($action)) {
00218 ?>
00219               <tr>
00220                 <td align="right" colspan="2" class="smallText"><?php echo '<a href="' . zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $aInfo->artists_id . '&action=new') . '">' . zen_image_button('button_insert.gif', IMAGE_INSERT) . '</a>'; ?></td>
00221               </tr>
00222 <?php
00223   }
00224 ?>
00225             </table></td>
00226 <?php
00227   $heading = array();
00228   $contents = array();
00229 
00230   switch ($action) {
00231     case 'new':
00232       $heading[] = array('text' => '<b>' . TEXT_HEADING_NEW_RECORD_ARTIST . '</b>');
00233 
00234       $contents = array('form' => zen_draw_form('artists', FILENAME_RECORD_ARTISTS, 'action=insert', 'post', 'enctype="multipart/form-data"'));
00235       $contents[] = array('text' => TEXT_NEW_INTRO);
00236       $contents[] = array('text' => '<br>' . TEXT_RECORD_ARTIST_NAME . '<br>' . zen_draw_input_field('artists_name', '', zen_set_field_length(TABLE_RECORD_ARTISTS, 'artists_name')));
00237       $contents[] = array('text' => '<br>' . TEXT_RECORD_ARTIST_IMAGE . '<br>' . zen_draw_file_field('artists_image'));
00238       $dir = @dir(DIR_FS_CATALOG_IMAGES);
00239       $dir_info[] = array('id' => '', 'text' => "Main Directory");
00240       while ($file = $dir->read()) {
00241         if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") {
00242           $dir_info[] = array('id' => $file . '/', 'text' => $file);
00243         }
00244       }
00245       $dir->close();
00246 
00247       $default_directory = 'artists/';
00248 
00249       $contents[] = array('text' => '<BR />' . TEXT_ARTISTS_IMAGE_DIR . zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory));
00250       $contents[] = array('text' => '<br />' . TEXT_ARTISTS_IMAGE_MANUAL . '&nbsp;' . zen_draw_input_field('artists_image_manual'));
00251 
00252       $manufacturer_inputs_string = '';
00253       $languages = zen_get_languages();
00254       for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
00255         $manufacturer_inputs_string .= '<br>' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . zen_draw_input_field('artists_url[' . $languages[$i]['id'] . ']', '', zen_set_field_length(TABLE_RECORD_ARTISTS_INFO, 'artists_url') );
00256       }
00257 
00258       $contents[] = array('text' => '<br>' . TEXT_RECORD_ARTIST_URL . $manufacturer_inputs_string);
00259       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $_GET['mID']) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
00260       break;
00261     case 'edit':
00262       $heading[] = array('text' => '<b>' . TEXT_HEADING_EDIT_RECORD_ARTIST . '</b>');
00263 
00264       $contents = array('form' => zen_draw_form('artists', FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $aInfo->artists_id . '&action=save', 'post', 'enctype="multipart/form-data"'));
00265       $contents[] = array('text' => TEXT_EDIT_INTRO);
00266       $contents[] = array('text' => '<br />' . TEXT_RECORD_ARTIST_NAME . '<br>' . zen_draw_input_field('artists_name', htmlspecialchars($aInfo->artists_name, ENT_COMPAT, CHARSET, TRUE), zen_set_field_length(TABLE_RECORD_ARTISTS, 'artists_name')));
00267       $contents[] = array('text' => '<br />' . TEXT_RECORD_ARTIST_IMAGE . '<br>' . zen_draw_file_field('artists_image') . '<br />' . $aInfo->artists_image);
00268       $dir = @dir(DIR_FS_CATALOG_IMAGES);
00269       $dir_info[] = array('id' => '', 'text' => "Main Directory");
00270       while ($file = $dir->read()) {
00271         if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") {
00272           $dir_info[] = array('id' => $file . '/', 'text' => $file);
00273         }
00274       }
00275       $dir->close();
00276       $default_directory = substr( $aInfo->artists_image, 0,strpos( $aInfo->artists_image, '/')+1);
00277       $contents[] = array('text' => '<BR />' . TEXT_ARTISTS_IMAGE_DIR . zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory));
00278       $contents[] = array('text' => '<br />' . TEXT_ARTISTS_IMAGE_MANUAL . '&nbsp;' . zen_draw_input_field('artists_image_manual'));
00279       $contents[] = array('text' => '<br />' . zen_info_image($aInfo->artists_image, $aInfo->artists_name));
00280       $manufacturer_inputs_string = '';
00281       $languages = zen_get_languages();
00282       for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
00283         $manufacturer_inputs_string .= '<br>' . zen_image(DIR_WS_CATALOG_LANGUAGES . $languages[$i]['directory'] . '/images/' . $languages[$i]['image'], $languages[$i]['name']) . '&nbsp;' . zen_draw_input_field('artists_url[' . $languages[$i]['id'] . ']', zen_get_artists_url($aInfo->artists_id, $languages[$i]['id']), zen_set_field_length(TABLE_RECORD_ARTISTS_INFO, 'artists_url'));
00284       }
00285 
00286       $contents[] = array('text' => '<br>' . TEXT_RECORD_ARTIST_URL . $manufacturer_inputs_string);
00287       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_save.gif', IMAGE_SAVE) . ' <a href="' . zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $aInfo->artists_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
00288       break;
00289     case 'delete':
00290       $heading[] = array('text' => '<b>' . TEXT_HEADING_DELETE_RECORD_ARTIST . '</b>');
00291 
00292       $contents = array('form' => zen_draw_form('artists', FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&action=deleteconfirm') . zen_draw_hidden_field('mID', $aInfo->artists_id));
00293       $contents[] = array('text' => TEXT_DELETE_INTRO);
00294       $contents[] = array('text' => '<br><b>' . $aInfo->artists_name . '</b>');
00295       $contents[] = array('text' => '<br>' . zen_draw_checkbox_field('delete_image', '', true) . ' ' . TEXT_DELETE_IMAGE);
00296 
00297       if ($aInfo->products_count > 0) {
00298         $contents[] = array('text' => '<br>' . zen_draw_checkbox_field('delete_products') . ' ' . TEXT_DELETE_PRODUCTS);
00299         $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $aInfo->products_count));
00300       }
00301 
00302       $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_delete.gif', IMAGE_DELETE) . ' <a href="' . zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $aInfo->artists_id) . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
00303       break;
00304     default:
00305       if (isset($aInfo) && is_object($aInfo)) {
00306         $heading[] = array('text' => '<b>' . $aInfo->artists_name . '</b>');
00307 
00308         $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $aInfo->artists_id . '&action=edit') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $aInfo->artists_id . '&action=delete') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
00309         $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . zen_date_short($aInfo->date_added));
00310         if (zen_not_null($aInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . zen_date_short($aInfo->last_modified));
00311         $contents[] = array('text' => '<br>' . zen_info_image($aInfo->artists_image, $aInfo->artists_name));
00312         $contents[] = array('text' => '<br>' . TEXT_PRODUCTS . ' ' . $aInfo->products_count);
00313       }
00314       break;
00315   }
00316 
00317   if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
00318     echo '            <td width="25%" valign="top">' . "\n";
00319 
00320     $box = new box;
00321     echo $box->infoBox($heading, $contents);
00322 
00323     echo '            </td>' . "\n";
00324   }
00325 ?>
00326           </tr>
00327         </table></td>
00328       </tr>
00329     </table></td>
00330 <!-- body_text_eof //-->
00331   </tr>
00332 </table>
00333 <!-- body_eof //-->
00334 
00335 <!-- footer //-->
00336 <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
00337 <!-- footer_eof //-->
00338 <br>
00339 </body>
00340 </html>
00341 <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
 All Data Structures Namespaces Files Functions Variables Enumerations