[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/admin/ -> record_artists.php (source)

   1  <?php
   2  //

   3  // +----------------------------------------------------------------------+

   4  // |zen-cart Open Source E-commerce                                       |

   5  // +----------------------------------------------------------------------+

   6  // | Copyright (c) 2004 The zen-cart developers                           |

   7  // |                                                                      |

   8  // | http://www.zen-cart.com/index.php                                    |

   9  // |                                                                      |

  10  // | Portions Copyright (c) 2003 osCommerce                               |

  11  // +----------------------------------------------------------------------+

  12  // | This source file is subject to version 2.0 of the GPL license,       |

  13  // | that is bundled with this package in the file LICENSE, and is        |

  14  // | available through the world-wide-web at the following url:           |

  15  // | http://www.zen-cart.com/license/2_0.txt.                             |

  16  // | If you did not receive a copy of the zen-cart license and are unable |

  17  // | to obtain it through the world-wide-web, please send a note to       |

  18  // | license@zen-cart.com so we can mail you a copy immediately.          |

  19  // +----------------------------------------------------------------------+

  20  //  $Id: record_artists.php 4810 2006-10-22 19:02:19Z ajeh $

  21  //

  22  
  23    require ('includes/application_top.php');
  24  
  25    $action = (isset($_GET['action']) ? $_GET['action'] : '');
  26  
  27    if (zen_not_null($action)) {
  28      switch ($action) {
  29        case 'insert':
  30        case 'save':
  31          if (isset($_GET['mID'])) $artists_id = zen_db_prepare_input($_GET['mID']);
  32          $artists_name = zen_db_prepare_input($_POST['artists_name']);
  33  
  34          $sql_data_array = array('artists_name' => $artists_name);
  35  
  36          if ($action == 'insert') {
  37            $insert_sql_data = array('date_added' => 'now()');
  38  
  39            $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
  40  
  41            zen_db_perform(TABLE_RECORD_ARTISTS, $sql_data_array);
  42            $artists_id = zen_db_insert_id();
  43          } elseif ($action == 'save') {
  44            $update_sql_data = array('last_modified' => 'now()');
  45  
  46            $sql_data_array = array_merge($sql_data_array, $update_sql_data);
  47  
  48            zen_db_perform(TABLE_RECORD_ARTISTS, $sql_data_array, 'update', "artists_id = '" . (int)$artists_id . "'");
  49          }
  50  
  51        if ($_POST['artists_image_manual'] != '') {
  52          // add image manually

  53          $artists_image_name = $_POST['img_dir'] . $_POST['artists_image_manual'];
  54          $db->Execute("update " . TABLE_RECORD_ARTISTS . "
  55                        set artists_image = '" .  $artists_image_name . "'
  56                        where artists_id = '" . (int)$artists_id . "'");
  57        } else {
  58          $artists_image = new upload('artists_image');
  59          $artists_image->set_destination(DIR_FS_CATALOG_IMAGES . $_POST['img_dir']);
  60          if ( $artists_image->parse() &&  $artists_image->save()) {
  61            // remove image from database if none

  62            if ($artists_image->filename != 'none') {
  63              $db->Execute("update " . TABLE_RECORD_ARTISTS . "
  64                            set artists_image = '" .  $_POST['img_dir'] . $artists_image->filename . "'
  65                            where artists_id = '" . (int)$artists_id . "'");
  66            } else {
  67              $db->Execute("update " . TABLE_RECORD_ARTISTS . "
  68                            set artists_image = ''
  69                            where artists_id = '" . (int)$artists_id . "'");
  70            }
  71          }
  72        }
  73  
  74          $languages = zen_get_languages();
  75          for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
  76            $artists_url_array = $_POST['artists_url'];
  77            $language_id = $languages[$i]['id'];
  78  
  79            $sql_data_array = array('artists_url' => zen_db_prepare_input($artists_url_array[$language_id]));
  80  
  81            if ($action == 'insert') {
  82              $insert_sql_data = array('artists_id' => $artists_id,
  83                                       'languages_id' => $language_id);
  84  
  85              $sql_data_array = array_merge($sql_data_array, $insert_sql_data);
  86  
  87              zen_db_perform(TABLE_RECORD_ARTISTS_INFO, $sql_data_array);
  88            } elseif ($action == 'save') {
  89              zen_db_perform(TABLE_RECORD_ARTISTS_INFO, $sql_data_array, 'update', "artists_id = '" . (int)$artists_id . "' and languages_id = '" . (int)$language_id . "'");
  90            }
  91          }
  92  
  93          zen_redirect(zen_href_link(FILENAME_RECORD_ARTISTS, (isset($_GET['page']) ? 'page=' . $_GET['page'] . '&' : '') . 'mID=' . $artists_id));
  94          break;
  95        case 'deleteconfirm':
  96          // demo active test

  97          if (zen_admin_demo()) {
  98            $_GET['action']= '';
  99            $messageStack->add_session(ERROR_ADMIN_DEMO, 'caution');
 100            zen_redirect(zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page']));
 101          }
 102          $artists_id = zen_db_prepare_input($_GET['mID']);
 103  
 104          if (isset($_POST['delete_image']) && ($_POST['delete_image'] == 'on')) {
 105  
 106            $manufacturer = $db->Execute("select artists_image
 107                                          from " . TABLE_RECORD_ARTISTS . "
 108                                          where artists_id = '" . (int)$artists_id . "'");
 109            $image_location = DIR_FS_CATALOG_IMAGES . $manufacturer->fields['artists_image'];
 110  
 111            if (file_exists($image_location)) @unlink($image_location);
 112          }
 113  
 114          $db->Execute("delete from " . TABLE_RECORD_ARTISTS . "
 115                        where artists_id = '" . (int)$artists_id . "'");
 116          $db->Execute("delete from " . TABLE_RECORD_ARTISTS_INFO . "
 117                        where artists_id = '" . (int)$artists_id . "'");
 118  
 119          if (isset($_POST['delete_products']) && ($_POST['delete_products'] == 'on')) {
 120            $products = $db->Execute("select products_id
 121                                      from " . TABLE_PRODUCT_MUSIC_EXTRA . "
 122                                      where artists_id = '" . (int)$artists_id . "'");
 123  
 124            while (!$products->EOF) {
 125              zen_remove_product($products->fields['products_id']);
 126              $products->MoveNext();
 127            }
 128          } else {
 129            $db->Execute("update " . TABLE_PRODUCT_MUSIC_EXTRA . "
 130                          set artists_id = ''
 131                          where artists_id = '" . (int)$artists_id . "'");
 132          }
 133  
 134          zen_redirect(zen_href_link(FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page']));
 135          break;
 136      }
 137    }
 138  ?>
 139  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
 140  <html <?php echo HTML_PARAMS; ?>>
 141  <head>
 142  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 143  <title><?php echo TITLE; ?></title>
 144  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 145  <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
 146  <script language="javascript" src="includes/menu.js"></script>
 147  <script language="javascript" src="includes/general.js"></script>
 148  <script type="text/javascript">
 149    <!--
 150    function init()
 151    {
 152      cssjsmenu('navbar');
 153      if (document.getElementById)
 154      {
 155        var kill = document.getElementById('hoverJS');
 156        kill.disabled = true;
 157      }
 158    }
 159    // -->

 160  </script>
 161  </head>
 162  <body onload="init()">
 163  <!-- header //-->
 164  <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
 165  <!-- header_eof //-->
 166  
 167  <!-- body //-->
 168  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 169    <tr>
 170  <!-- body_text //-->
 171      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 172        <tr>
 173          <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 174            <tr>
 175              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 176              <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 177            </tr>
 178          </table></td>
 179        </tr>
 180        <tr>
 181          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 182            <tr>
 183              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 184                <tr class="dataTableHeadingRow">
 185                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_RECORD_ARTISTS; ?></td>
 186                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
 187                </tr>
 188  <?php
 189    $artists_query_raw = "select * from " . TABLE_RECORD_ARTISTS . " order by artists_name";
 190    $artists_split = new splitPageResults($_GET['page'], MAX_DISPLAY_SEARCH_RESULTS, $artists_query_raw, $artists_query_numrows);
 191    $artists = $db->Execute($artists_query_raw);
 192  
 193    while (!$artists->EOF) {
 194  
 195      if ((!isset($_GET['mID']) || (isset($_GET['mID']) && ($_GET['mID'] == $artists->fields['artists_id']))) && !isset($aInfo) && (substr($action, 0, 3) != 'new')) {
 196        $artists_products = $db->Execute("select count(*) as products_count
 197                                               from " . TABLE_PRODUCT_MUSIC_EXTRA . "
 198                                               where artists_id = '" . (int)$artists->fields['artists_id'] . "'");
 199  
 200        $aInfo_array = array_merge($artists->fields, $artists_products->fields);
 201        $aInfo = new objectInfo($aInfo_array);
 202      }
 203  
 204      if (isset($aInfo) && is_object($aInfo) && ($artists->fields['artists_id'] == $aInfo->artists_id)) {
 205        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";
 206      } else {
 207        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";
 208      }
 209  ?>
 210                  <td class="dataTableContent"><?php echo $artists->fields['artists_name']; ?></td>
 211                  <td class="dataTableContent" align="right">
 212                    <?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>'; ?>
 213                    <?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>'; ?>
 214                    <?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>'; } ?>
 215                  </td>
 216                </tr>
 217  <?php
 218      $artists->MoveNext();
 219    }
 220  ?>
 221                <tr>
 222                  <td colspan="2"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 223                    <tr>
 224                      <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>
 225                      <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>
 226                    </tr>
 227                  </table></td>
 228                </tr>
 229  <?php
 230    if (empty($action)) {
 231  ?>
 232                <tr>
 233                  <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>
 234                </tr>
 235  <?php
 236    }
 237  ?>
 238              </table></td>
 239  <?php
 240    $heading = array();
 241    $contents = array();
 242  
 243    switch ($action) {
 244      case 'new':
 245        $heading[] = array('text' => '<b>' . TEXT_HEADING_NEW_RECORD_ARTIST . '</b>');
 246  
 247        $contents = array('form' => zen_draw_form('artists', FILENAME_RECORD_ARTISTS, 'action=insert', 'post', 'enctype="multipart/form-data"'));
 248        $contents[] = array('text' => TEXT_NEW_INTRO);
 249        $contents[] = array('text' => '<br>' . TEXT_RECORD_ARTIST_NAME . '<br>' . zen_draw_input_field('artists_name', '', zen_set_field_length(TABLE_RECORD_ARTISTS, 'artists_name')));
 250        $contents[] = array('text' => '<br>' . TEXT_RECORD_ARTIST_IMAGE . '<br>' . zen_draw_file_field('artists_image'));
 251        $dir = @dir(DIR_FS_CATALOG_IMAGES);
 252        $dir_info[] = array('id' => '', 'text' => "Main Directory");
 253        while ($file = $dir->read()) {
 254          if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") {
 255            $dir_info[] = array('id' => $file . '/', 'text' => $file);
 256          }
 257        }
 258  
 259        $default_directory = 'artists/';
 260  
 261        $contents[] = array('text' => '<BR />' . TEXT_ARTISTS_IMAGE_DIR . zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory));
 262        $contents[] = array('text' => '<br />' . TEXT_ARTISTS_IMAGE_MANUAL . '&nbsp;' . zen_draw_input_field('artists_image_manual'));
 263  
 264        $manufacturer_inputs_string = '';
 265        $languages = zen_get_languages();
 266        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 267          $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') );
 268        }
 269  
 270        $contents[] = array('text' => '<br>' . TEXT_RECORD_ARTIST_URL . $manufacturer_inputs_string);
 271        $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>');
 272        break;
 273      case 'edit':
 274        $heading[] = array('text' => '<b>' . TEXT_HEADING_EDIT_RECORD_ARTIST . '</b>');
 275  
 276        $contents = array('form' => zen_draw_form('artists', FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $aInfo->artists_id . '&action=save', 'post', 'enctype="multipart/form-data"'));
 277        $contents[] = array('text' => TEXT_EDIT_INTRO);
 278        $contents[] = array('text' => '<br />' . TEXT_RECORD_ARTIST_NAME . '<br>' . zen_draw_input_field('artists_name', $aInfo->artists_name, zen_set_field_length(TABLE_RECORD_ARTISTS, 'artists_name')));
 279        $contents[] = array('text' => '<br />' . TEXT_RECORD_ARTIST_IMAGE . '<br>' . zen_draw_file_field('artists_image') . '<br />' . $aInfo->artists_image);
 280        $dir = @dir(DIR_FS_CATALOG_IMAGES);
 281        $dir_info[] = array('id' => '', 'text' => "Main Directory");
 282        while ($file = $dir->read()) {
 283          if (is_dir(DIR_FS_CATALOG_IMAGES . $file) && strtoupper($file) != 'CVS' && $file != "." && $file != "..") {
 284            $dir_info[] = array('id' => $file . '/', 'text' => $file);
 285          }
 286        }
 287        $default_directory = substr( $aInfo->artists_image, 0,strpos( $aInfo->artists_image, '/')+1);
 288        $contents[] = array('text' => '<BR />' . TEXT_ARTISTS_IMAGE_DIR . zen_draw_pull_down_menu('img_dir', $dir_info, $default_directory));
 289        $contents[] = array('text' => '<br />' . TEXT_ARTISTS_IMAGE_MANUAL . '&nbsp;' . zen_draw_input_field('artists_image_manual'));
 290        $contents[] = array('text' => '<br />' . zen_info_image($aInfo->artists_image, $aInfo->artists_name));
 291        $manufacturer_inputs_string = '';
 292        $languages = zen_get_languages();
 293        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
 294          $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'));
 295        }
 296  
 297        $contents[] = array('text' => '<br>' . TEXT_RECORD_ARTIST_URL . $manufacturer_inputs_string);
 298        $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>');
 299        break;
 300      case 'delete':
 301        $heading[] = array('text' => '<b>' . TEXT_HEADING_DELETE_RECORD_ARTIST . '</b>');
 302  
 303        $contents = array('form' => zen_draw_form('artists', FILENAME_RECORD_ARTISTS, 'page=' . $_GET['page'] . '&mID=' . $aInfo->artists_id . '&action=deleteconfirm'));
 304        $contents[] = array('text' => TEXT_DELETE_INTRO);
 305        $contents[] = array('text' => '<br><b>' . $aInfo->artists_name . '</b>');
 306        $contents[] = array('text' => '<br>' . zen_draw_checkbox_field('delete_image', '', true) . ' ' . TEXT_DELETE_IMAGE);
 307  
 308        if ($aInfo->products_count > 0) {
 309          $contents[] = array('text' => '<br>' . zen_draw_checkbox_field('delete_products') . ' ' . TEXT_DELETE_PRODUCTS);
 310          $contents[] = array('text' => '<br>' . sprintf(TEXT_DELETE_WARNING_PRODUCTS, $aInfo->products_count));
 311        }
 312  
 313        $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>');
 314        break;
 315      default:
 316        if (isset($aInfo) && is_object($aInfo)) {
 317          $heading[] = array('text' => '<b>' . $aInfo->artists_name . '</b>');
 318  
 319          $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>');
 320          $contents[] = array('text' => '<br>' . TEXT_DATE_ADDED . ' ' . zen_date_short($aInfo->date_added));
 321          if (zen_not_null($aInfo->last_modified)) $contents[] = array('text' => TEXT_LAST_MODIFIED . ' ' . zen_date_short($aInfo->last_modified));
 322          $contents[] = array('text' => '<br>' . zen_info_image($aInfo->artists_image, $aInfo->artists_name));
 323          $contents[] = array('text' => '<br>' . TEXT_PRODUCTS . ' ' . $aInfo->products_count);
 324        }
 325        break;
 326    }
 327  
 328    if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
 329      echo '            <td width="25%" valign="top">' . "\n";
 330  
 331      $box = new box;
 332      echo $box->infoBox($heading, $contents);
 333  
 334      echo '            </td>' . "\n";
 335    }
 336  ?>
 337            </tr>
 338          </table></td>
 339        </tr>
 340      </table></td>
 341  <!-- body_text_eof //-->
 342    </tr>
 343  </table>
 344  <!-- body_eof //-->
 345  
 346  <!-- footer //-->
 347  <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
 348  <!-- footer_eof //-->
 349  <br>
 350  </body>
 351  </html>
 352  <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics