[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/ -> languages.php (source)

   1  <?php
   2  /*

   3  $Id: languages.php 3 2006-05-27 04:59:07Z user $

   4  

   5    osCMax Power E-Commerce

   6    http://oscdox.com

   7  

   8    Copyright 2006 osCMax

   9  

  10    Released under the GNU General Public License

  11  */
  12  
  13    require ('includes/application_top.php');
  14  
  15    $action = (isset($HTTP_GET_VARS['action']) ? $HTTP_GET_VARS['action'] : '');
  16  
  17    if (tep_not_null($action)) {
  18      switch ($action) {
  19        case 'insert':
  20          $name = tep_db_prepare_input($HTTP_POST_VARS['name']);
  21          $code = tep_db_prepare_input(substr($HTTP_POST_VARS['code'], 0, 2));
  22          $image = tep_db_prepare_input($HTTP_POST_VARS['image']);
  23          $directory = tep_db_prepare_input($HTTP_POST_VARS['directory']);
  24          $sort_order = (int)tep_db_prepare_input($HTTP_POST_VARS['sort_order']);
  25  
  26          tep_db_query("insert into " . TABLE_LANGUAGES . " (name, code, image, directory, sort_order) values ('" . tep_db_input($name) . "', '" . tep_db_input($code) . "', '" . tep_db_input($image) . "', '" . tep_db_input($directory) . "', '" . tep_db_input($sort_order) . "')");
  27          $insert_id = tep_db_insert_id();
  28  
  29  // create additional categories_description records

  30          $categories_query = tep_db_query("select c.categories_id, cd.categories_name from " . TABLE_CATEGORIES . " c left join " . TABLE_CATEGORIES_DESCRIPTION . " cd on c.categories_id = cd.categories_id where cd.language_id = '" . (int)$languages_id . "'");
  31          while ($categories = tep_db_fetch_array($categories_query)) {
  32            tep_db_query("insert into " . TABLE_CATEGORIES_DESCRIPTION . " (categories_id, language_id, categories_name) values ('" . (int)$categories['categories_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($categories['categories_name']) . "')");
  33          }
  34  
  35  // create additional products_description records

  36          $products_query = tep_db_query("select p.products_id, pd.products_name, pd.products_description, pd.products_url from " . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_DESCRIPTION . " pd on p.products_id = pd.products_id where pd.language_id = '" . (int)$languages_id . "'");
  37          while ($products = tep_db_fetch_array($products_query)) {
  38            tep_db_query("insert into " . TABLE_PRODUCTS_DESCRIPTION . " (products_id, language_id, products_name, products_description, products_url) values ('" . (int)$products['products_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($products['products_name']) . "', '" . tep_db_input($products['products_description']) . "', '" . tep_db_input($products['products_url']) . "')");
  39          }
  40  
  41  // create additional products_options records

  42          $products_options_query = tep_db_query("select products_options_id, products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$languages_id . "'");
  43          while ($products_options = tep_db_fetch_array($products_options_query)) {
  44            tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, language_id, products_options_name) values ('" . (int)$products_options['products_options_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($products_options['products_options_name']) . "')");
  45          }
  46  
  47  // create additional products_options_values records

  48          $products_options_values_query = tep_db_query("select products_options_values_id, products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where language_id = '" . (int)$languages_id . "'");
  49          while ($products_options_values = tep_db_fetch_array($products_options_values_query)) {
  50            tep_db_query("insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$products_options_values['products_options_values_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($products_options_values['products_options_values_name']) . "')");
  51          }
  52  
  53  // create additional manufacturers_info records

  54          $manufacturers_query = tep_db_query("select m.manufacturers_id, mi.manufacturers_url from " . TABLE_MANUFACTURERS . " m left join " . TABLE_MANUFACTURERS_INFO . " mi on m.manufacturers_id = mi.manufacturers_id where mi.languages_id = '" . (int)$languages_id . "'");
  55          while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
  56            tep_db_query("insert into " . TABLE_MANUFACTURERS_INFO . " (manufacturers_id, languages_id, manufacturers_url) values ('" . $manufacturers['manufacturers_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($manufacturers['manufacturers_url']) . "')");
  57          }
  58  
  59  // create additional orders_status records

  60          $orders_status_query = tep_db_query("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$languages_id . "'");
  61          while ($orders_status = tep_db_fetch_array($orders_status_query)) {
  62            tep_db_query("insert into " . TABLE_ORDERS_STATUS . " (orders_status_id, language_id, orders_status_name) values ('" . (int)$orders_status['orders_status_id'] . "', '" . (int)$insert_id . "', '" . tep_db_input($orders_status['orders_status_name']) . "')");
  63          }
  64  
  65          if (isset($HTTP_POST_VARS['default']) && ($HTTP_POST_VARS['default'] == 'on')) {
  66            tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . tep_db_input($code) . "' where configuration_key = 'DEFAULT_LANGUAGE'");
  67          }
  68  
  69          tep_redirect(tep_href_link(FILENAME_LANGUAGES, (isset($HTTP_GET_VARS['page']) ? 'page=' . $HTTP_GET_VARS['page'] . '&' : '') . 'lID=' . $insert_id));
  70          break;
  71        case 'save':
  72          $lID = tep_db_prepare_input($HTTP_GET_VARS['lID']);
  73          $name = tep_db_prepare_input($HTTP_POST_VARS['name']);
  74          $code = tep_db_prepare_input(substr($HTTP_POST_VARS['code'], 0, 2));
  75          $image = tep_db_prepare_input($HTTP_POST_VARS['image']);
  76          $directory = tep_db_prepare_input($HTTP_POST_VARS['directory']);
  77          $sort_order = (int)tep_db_prepare_input($HTTP_POST_VARS['sort_order']);
  78  
  79          tep_db_query("update " . TABLE_LANGUAGES . " set name = '" . tep_db_input($name) . "', code = '" . tep_db_input($code) . "', image = '" . tep_db_input($image) . "', directory = '" . tep_db_input($directory) . "', sort_order = '" . tep_db_input($sort_order) . "' where languages_id = '" . (int)$lID . "'");
  80  
  81          if ($HTTP_POST_VARS['default'] == 'on') {
  82            tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '" . tep_db_input($code) . "' where configuration_key = 'DEFAULT_LANGUAGE'");
  83          }
  84  
  85          tep_redirect(tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $HTTP_GET_VARS['lID']));
  86          break;
  87        case 'deleteconfirm':
  88          $lID = tep_db_prepare_input($HTTP_GET_VARS['lID']);
  89  
  90          $lng_query = tep_db_query("select languages_id from " . TABLE_LANGUAGES . " where code = '" . DEFAULT_CURRENCY . "'");
  91          $lng = tep_db_fetch_array($lng_query);
  92          if ($lng['languages_id'] == $lID) {
  93            tep_db_query("update " . TABLE_CONFIGURATION . " set configuration_value = '' where configuration_key = 'DEFAULT_CURRENCY'");
  94          }
  95  
  96          tep_db_query("delete from " . TABLE_CATEGORIES_DESCRIPTION . " where language_id = '" . (int)$lID . "'");
  97          tep_db_query("delete from " . TABLE_PRODUCTS_DESCRIPTION . " where language_id = '" . (int)$lID . "'");
  98          tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS . " where language_id = '" . (int)$lID . "'");
  99          tep_db_query("delete from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where language_id = '" . (int)$lID . "'");
 100          tep_db_query("delete from " . TABLE_MANUFACTURERS_INFO . " where languages_id = '" . (int)$lID . "'");
 101          tep_db_query("delete from " . TABLE_ORDERS_STATUS . " where language_id = '" . (int)$lID . "'");
 102          tep_db_query("delete from " . TABLE_LANGUAGES . " where languages_id = '" . (int)$lID . "'");
 103  
 104          tep_redirect(tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page']));
 105          break;
 106        case 'delete':
 107          $lID = tep_db_prepare_input($HTTP_GET_VARS['lID']);
 108  
 109          $lng_query = tep_db_query("select code from " . TABLE_LANGUAGES . " where languages_id = '" . (int)$lID . "'");
 110          $lng = tep_db_fetch_array($lng_query);
 111  
 112          $remove_language = true;
 113          if ($lng['code'] == DEFAULT_LANGUAGE) {
 114            $remove_language = false;
 115            $messageStack->add(ERROR_REMOVE_DEFAULT_LANGUAGE, 'error');
 116          }
 117          break;
 118      }
 119    }
 120  ?>
 121  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
 122  <html <?php echo HTML_PARAMS; ?>>
 123  <head>
 124  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 125  <title><?php echo TITLE; ?></title>
 126  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 127  <script language="javascript" src="includes/general.js"></script>
 128  </head>
 129  <body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF" onload="SetFocus();">
 130  <!-- header //-->
 131  <?php require (DIR_WS_INCLUDES . 'header.php'); ?>
 132  <!-- header_eof //-->
 133  
 134  <!-- body //-->
 135  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 136    <tr>
 137      <td width="<?php echo BOX_WIDTH; ?>" valign="top"><table border="0" width="<?php echo BOX_WIDTH; ?>" cellspacing="1" cellpadding="1" class="columnLeft">
 138  <!-- left_navigation //-->
 139  <?php require (DIR_WS_INCLUDES . 'column_left.php'); ?>
 140  <!-- left_navigation_eof //-->
 141      </table></td>
 142  <!-- body_text //-->
 143      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 144        <tr>
 145          <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 146            <tr>
 147              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 148              <td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 149            </tr>
 150          </table></td>
 151        </tr>
 152        <tr>
 153          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 154            <tr>
 155              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 156                <tr class="dataTableHeadingRow">
 157                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LANGUAGE_NAME; ?></td>
 158                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_LANGUAGE_CODE; ?></td>
 159                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
 160                </tr>
 161  <?php
 162    $languages_query_raw = "select languages_id, name, code, image, directory, sort_order from " . TABLE_LANGUAGES . " order by sort_order";
 163    $languages_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $languages_query_raw, $languages_query_numrows);
 164    $languages_query = tep_db_query($languages_query_raw);
 165  
 166    while ($languages = tep_db_fetch_array($languages_query)) {
 167      if ((!isset($HTTP_GET_VARS['lID']) || (isset($HTTP_GET_VARS['lID']) && ($HTTP_GET_VARS['lID'] == $languages['languages_id']))) && !isset($lInfo) && (substr($action, 0, 3) != 'new')) {
 168        $lInfo = new objectInfo($languages);
 169      }
 170  
 171      if (isset($lInfo) && is_object($lInfo) && ($languages['languages_id'] == $lInfo->languages_id) ) {
 172        echo '                  <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $lInfo->languages_id . '&action=edit') . '\'">' . "\n";
 173      } else {
 174        echo '                  <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $languages['languages_id']) . '\'">' . "\n";
 175      }
 176  
 177      if (DEFAULT_LANGUAGE == $languages['code']) {
 178        echo '                <td class="dataTableContent"><b>' . $languages['name'] . ' (' . TEXT_DEFAULT . ')</b></td>' . "\n";
 179      } else {
 180        echo '                <td class="dataTableContent">' . $languages['name'] . '</td>' . "\n";
 181      }
 182  ?>
 183                  <td class="dataTableContent"><?php echo $languages['code']; ?></td>
 184                  <td class="dataTableContent" align="right"><?php if (isset($lInfo) && is_object($lInfo) && ($languages['languages_id'] == $lInfo->languages_id)) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $languages['languages_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
 185                </tr>
 186  <?php
 187    }
 188  ?>
 189                <tr>
 190                  <td colspan="3"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 191                    <tr>
 192                      <td class="smallText" valign="top"><?php echo $languages_split->display_count($languages_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, $HTTP_GET_VARS['page'], TEXT_DISPLAY_NUMBER_OF_LANGUAGES); ?></td>
 193                      <td class="smallText" align="right"><?php echo $languages_split->display_links($languages_query_numrows, MAX_DISPLAY_SEARCH_RESULTS, MAX_DISPLAY_PAGE_LINKS, $HTTP_GET_VARS['page']); ?></td>
 194                    </tr>
 195  <?php
 196    if (empty($action)) {
 197  ?>
 198                    <tr>
 199                      <td align="right" colspan="2"><?php echo '<a href="' . tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $lInfo->languages_id . '&action=new') . '">' . tep_image_button('button_new_language.gif', IMAGE_NEW_LANGUAGE) . '</a>'; ?></td>
 200                    </tr>
 201  <?php
 202    }
 203  ?>
 204                  </table></td>
 205                </tr>
 206              </table></td>
 207  <?php
 208    $heading = array();
 209    $contents = array();
 210  
 211    switch ($action) {
 212      case 'new':
 213        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_NEW_LANGUAGE . '</b>');
 214  
 215        $contents = array('form' => tep_draw_form('languages', FILENAME_LANGUAGES, 'action=insert'));
 216        $contents[] = array('text' => TEXT_INFO_INSERT_INTRO);
 217        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_NAME . '<br>' . tep_draw_input_field('name'));
 218        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_CODE . '<br>' . tep_draw_input_field('code'));
 219        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_IMAGE . '<br>' . tep_draw_input_field('image', 'icon.gif'));
 220        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_DIRECTORY . '<br>' . tep_draw_input_field('directory'));
 221        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order'));
 222        $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT);
 223        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_insert.gif', IMAGE_INSERT) . ' <a href="' . tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $HTTP_GET_VARS['lID']) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 224        break;
 225      case 'edit':
 226        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_EDIT_LANGUAGE . '</b>');
 227  
 228        $contents = array('form' => tep_draw_form('languages', FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $lInfo->languages_id . '&action=save'));
 229        $contents[] = array('text' => TEXT_INFO_EDIT_INTRO);
 230        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_NAME . '<br>' . tep_draw_input_field('name', $lInfo->name));
 231        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_CODE . '<br>' . tep_draw_input_field('code', $lInfo->code));
 232        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_IMAGE . '<br>' . tep_draw_input_field('image', $lInfo->image));
 233        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_DIRECTORY . '<br>' . tep_draw_input_field('directory', $lInfo->directory));
 234        $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_SORT_ORDER . '<br>' . tep_draw_input_field('sort_order', $lInfo->sort_order));
 235        if (DEFAULT_LANGUAGE != $lInfo->code) $contents[] = array('text' => '<br>' . tep_draw_checkbox_field('default') . ' ' . TEXT_SET_DEFAULT);
 236        $contents[] = array('align' => 'center', 'text' => '<br>' . tep_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $lInfo->languages_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 237        break;
 238      case 'delete':
 239        $heading[] = array('text' => '<b>' . TEXT_INFO_HEADING_DELETE_LANGUAGE . '</b>');
 240  
 241        $contents[] = array('text' => TEXT_INFO_DELETE_INTRO);
 242        $contents[] = array('text' => '<br><b>' . $lInfo->name . '</b>');
 243        $contents[] = array('align' => 'center', 'text' => '<br>' . (($remove_language) ? '<a href="' . tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $lInfo->languages_id . '&action=deleteconfirm') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a>' : '') . ' <a href="' . tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $lInfo->languages_id) . '">' . tep_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 244        break;
 245      default:
 246        if (is_object($lInfo)) {
 247          $heading[] = array('text' => '<b>' . $lInfo->name . '</b>');
 248  
 249          $contents[] = array('align' => 'center', 'text' => '<a href="' . tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $lInfo->languages_id . '&action=edit') . '">' . tep_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . tep_href_link(FILENAME_LANGUAGES, 'page=' . $HTTP_GET_VARS['page'] . '&lID=' . $lInfo->languages_id . '&action=delete') . '">' . tep_image_button('button_delete.gif', IMAGE_DELETE) . '</a> <a href="' . tep_href_link(FILENAME_DEFINE_LANGUAGE, 'lngdir=' . $lInfo->directory) . '">' . tep_image_button('button_details.gif', IMAGE_DETAILS) . '</a>');
 250          $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_NAME . ' ' . $lInfo->name);
 251          $contents[] = array('text' => TEXT_INFO_LANGUAGE_CODE . ' ' . $lInfo->code);
 252          $contents[] = array('text' => '<br>' . tep_image(DIR_WS_CATALOG_LANGUAGES . $lInfo->directory . '/images/' . $lInfo->image, $lInfo->name));
 253          $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_DIRECTORY . '<br>' . DIR_WS_CATALOG_LANGUAGES . '<b>' . $lInfo->directory . '</b>');
 254          $contents[] = array('text' => '<br>' . TEXT_INFO_LANGUAGE_SORT_ORDER . ' ' . $lInfo->sort_order);
 255        }
 256        break;
 257    }
 258  
 259    if ( (tep_not_null($heading)) && (tep_not_null($contents)) ) {
 260      echo '            <td width="25%" valign="top">' . "\n";
 261  
 262      $box = new box;
 263      echo $box->infoBox($heading, $contents);
 264  
 265      echo '            </td>' . "\n";
 266    }
 267  ?>
 268            </tr>
 269          </table></td>
 270        </tr>
 271      </table></td>
 272  <!-- body_text_eof //-->
 273    </tr>
 274  </table>
 275  <!-- body_eof //-->
 276  
 277  <!-- footer //-->
 278  <?php require (DIR_WS_INCLUDES . 'footer.php'); ?>
 279  <!-- footer_eof //-->
 280  <br>
 281  </body>
 282  </html>
 283  <?php require (DIR_WS_INCLUDES . 'application_bottom.php'); ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7