• User

    extra field multilinguaggio

    Ciao a tutti.
    sto modificando una mod per Zen cart.
    la mod EXTRA PRODUCT FIELDS MOD zen-cart.com/forum/showthread.php?t=127600 scritta da Delia Wilson Lunsford
    da la posssibilità, di carica un video e 4 file per ogno prodotto.
    partendo da questa base ho iniziato a modicarla perchè mi serve multilingua,
    cioè, per esempio gli inglesi possano accedere ai pdf nella loro lingua,
    gli italiani nella loro, e così via...
    mi sono un pò bloccato sulle modifiche per l'invio sul database dei dati
    allego il file con le ultime modifiche ai file.

    ringrazio chi voglia darmi una mano o anche due...

    collect_info

    
    //TABLE_PRODUCT_EXTRA_FIELDS line above is added for that mod (line 86))
          $pInfo->objectInfo($product->fields);
        } elseif (zen_not_null($_POST)) {
          $pInfo->objectInfo($_POST);
          $products_name = $_POST['products_name'];
          $products_description = $_POST['products_description'];
          $products_url = $_POST['products_url'];
       $products_extra_field = $_POST['extra_field'];
       $products_extra_field_file_1 = $_POST['file_1'];
       $products_extra_field_file_2 = $_POST['file_2'];
       $products_extra_field_file_3 = $_POST['file_3'];
       $products_extra_field_file_4 = $_POST['file_4'];
       $products_extra_field_file_1_title = $_POST['file_1_title'];
       $products_extra_field_file_2_title = $_POST['file_2_title'];
       $products_extra_field_file_3_title = $_POST['file_3_title'];
       $products_extra_field_file_4_title = $_POST['file_4_title'];
     
     
    // extra fields mod 
    ?>
    <?php
        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
    ?>          
    <tr>
                <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?>
                <br/>
                <br/></td>
              </tr>
                     <tr>
                <td class="main" valign="top" ><?php  echo TEXT_PRODUCTS_EXTRA_TEXT_FIELD . '&nbsp;'; ?></td>
                <td colspan="2"><table border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td class="main" width="25" valign="top"><?php echo zen_image(DIR_WS_CATALOG_LANGUAGES . $languages*['directory'] . '/images/' . $languages*['image'], $languages*['name']); ?>&nbsp;</td>
                    <td class="main" width="100%"><?php 
       echo zen_draw_textarea_field('extra_field[' . $languages*['id'] . ']', 'soft', '100%', '30', (isset($products_extra_field[$languages*['id']])) ? stripslashes($products_extra_field[$languages*['id']]) : zen_get_products_extra_fields($pInfo->products_id, $languages*['id'])) ?>
            </td>
                  </tr>
                </table></td>
              </tr>    
     <tr>
                <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
              </tr>
              <tr>
         <td><?php  echo TEXT_PRODUCTS_VIDEO; ?></td>
               <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_file_field('video') .  '&nbsp;'.  TEXT_VIDEO_FILE_DESCRIPTION . ' ' . zen_draw_input_field('video_title', $pInfo->video_title) .  zen_draw_hidden_field('previous_video', $pInfo->video). ' '.$pInfo->video; ?>
         </td>
         </tr>
         <tr>
         <td></td>
         <td class="main" ><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . TEXT_VIDEO_FILE_WIDTH .' '. zen_draw_input_field('width', $pInfo->width), $pInfo->width .TEXT_VIDEO_FILE_HEIGHT. ' '.  zen_draw_input_field('height', $pInfo->height); ?>
         </td>
      </tr>
              <tr>
                <td colspan="2"><?php echo zen_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
              </tr>
              <tr>
                <td class="main"><?php  echo TEXT_PRODUCTS_DESCRIPTION_FILE; ?></td>
                <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_file_field('file_1[' . $languages*['id'] . ']') .  '&nbsp;'. TEXT_PRODUCTS_FILE_DESCRIPTION . ' ' . zen_draw_input_field('file_1_title[' . $languages*['id'] . ']', (isset($products_extra_field_file_1_title[$languages*['id']]) ? $products_extra_field_file_1_title[$languages*['id']] : zen_get_products_extra_file_1_title($pInfo->products_id, $languages*['id']))). zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_get_products_extra_file_1($pInfo->products_id, $languages*['id']) ; ?></td>
              </tr>
              <tr>
                <td class="main"><?php  echo TEXT_PRODUCTS_DESCRIPTION_FILE; ?></td>
                <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_file_field('file_2[' . $languages*['id'] . ']') .  '&nbsp;'. TEXT_PRODUCTS_FILE_DESCRIPTION . ' ' . zen_draw_input_field('file_2_title[' . $languages*['id'] . ']', (isset($products_extra_field_file_2_title[$languages*['id']]) ? $products_extra_field_file_2_title[$languages*['id']] : zen_get_products_extra_file_2_title($pInfo->products_id, $languages*['id'])).' '.$pInfo->file_2). zen_draw_hidden_field('previous_file_2[' . $languages*['id'] . ']', $pInfo->file_2).' '.$pInfo->file_2 ; ?></td>
              </tr>
              <tr>
                <td class="main"><?php  echo TEXT_PRODUCTS_DESCRIPTION_FILE; ?></td>
                <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_file_field('file_3[' . $languages*['id'] . ']') .  '&nbsp;'. TEXT_PRODUCTS_FILE_DESCRIPTION . ' ' . zen_draw_input_field('file_3_title[' . $languages*['id'] . ']', (isset($products_extra_field_file_3_title[$languages*['id']]) ? $products_extra_field_file_3_title[$languages*['id']] : zen_get_products_extra_file_3_title($pInfo->products_id, $languages*['id'])).' '.$pInfo->file_3). zen_draw_hidden_field('previous_file_3', $pInfo->file_3).' '.$pInfo->file_3 ; ?></td>
              </tr>
              <tr>
                <td class="main"><?php  echo TEXT_PRODUCTS_DESCRIPTION_FILE; ?></td>
                <td class="main"><?php echo zen_draw_separator('pixel_trans.gif', '24', '15') . '&nbsp;' . zen_draw_file_field('file_4[' . $languages*['id'] . ']') .  '&nbsp;'. TEXT_PRODUCTS_FILE_DESCRIPTION . ' ' . zen_draw_input_field('file_4_title[' . $languages*['id'] . ']', (isset($products_extra_field_file_4_title[$languages*['id']]) ? $products_extra_field_file_4_title[$languages*['id']] : zen_get_products_extra_file_4_title($pInfo->products_id, $languages*['id'])).' '.$pInfo->file_4). zen_draw_hidden_field('previous_file_4', $pInfo->file_4).' '.$pInfo->file_4 ; ?></td>
              </tr>
     
    <?php
        }
    ?>
    <?php // eof extra fields mod // ?> 
    
    

    preview_info.php

    
    if (!defined('IS_ADMIN_FLAG')) {
      die('Illegal Access');
    }
        if (zen_not_null($_POST)) {
          $pInfo = new objectInfo($_POST);
          $products_name = $_POST['products_name'];
          $products_description = $_POST['products_description'];
          $products_url = $_POST['products_url'];
       $products_extra_field = $_POST['extra_field'];
       $products_extra_field_file_1 = $_POST['file_1'];
       $products_extra_field_file_2 = $_POST['file_2'];
       $products_extra_field_file_3 = $_POST['file_3'];
       $products_extra_field_file_4 = $_POST['file_4'];
       $products_extra_field_file_1_title = $_POST['file_1_title'];
       $products_extra_field_file_2_title = $_POST['file_2_title'];
       $products_extra_field_file_3_title = $_POST['file_3_title'];
       $products_extra_field_file_4_title = $_POST['file_4_title'];
        } else {
          $product = $db->Execute("select p.products_id, pd.language_id, pd.products_name,
                                          pd.products_description, pd.products_url, p.products_quantity,
                                          p.products_model, p.products_image, p.products_price, p.products_virtual,
                                          p.products_weight, p.products_date_added, p.products_last_modified,
                                          p.products_date_available, p.products_status, p.manufacturers_id,
                                          pe.extra_field, pe.file_1, pe.file_2, pe.file_3, pe.file_4, pe.file_1_title, pe.file_2_title, pe.file_3_title, pe.file_4_title, pe.video, pe.video_title,
                                          p.products_quantity_order_min, p.products_quantity_order_units, p.products_priced_by_attribute,
                                          p.product_is_free, p.product_is_call, p.products_quantity_mixed,
                                          p.product_is_always_free_shipping, p.products_qty_box_status, p.products_quantity_order_max,
                        p.products_sort_order
                                   from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd,
                                        " . TABLE_PRODUCT_EXTRA_FIELDS . " pe
                                   where p.products_id = pd.products_id and p.products_id = pe.products_id
                                   and p.products_id = '" . (int)$_GET['pID'] . "'");
    //TABLE_PRODUCT_EXTRA_FIELDS added for that mod (line 38)
          $pInfo = new objectInfo($product->fields);
          $products_image_name = $pInfo->products_image;
        }
        $form_action = (isset($_GET['pID'])) ? 'update_product' : 'insert_product';
        $languages = zen_get_languages();
        for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
          if (isset($_GET['read']) && ($_GET['read'] == 'only')) {
            $pInfo->products_name = zen_get_products_name($pInfo->products_id, $languages*['id']);
            $pInfo->products_description = zen_get_products_description($pInfo->products_id, $languages*['id']);
            $pInfo->products_url = zen_get_products_url($pInfo->products_id, $languages*['id']);
      $pInfo->extra_field = zen_get_products_extra_fields($pInfo->products_id, $languages*['id']);
      $pInfo->file_1 = zen_get_products_extra_file_1($pInfo->products_id, $languages*['id']);
      $pInfo->file_2 = zen_get_products_extra_file_2($pInfo->products_id, $languages*['id']);
      $pInfo->file_3 = zen_get_products_extra_file_3($pInfo->products_id, $languages*['id']);
      $pInfo->file_4 = zen_get_products_extra_file_4($pInfo->products_id, $languages*['id']);
      $pInfo->file_1_title = zen_get_products_extra_file_1_title($pInfo->products_id, $languages*['id']);
      $pInfo->file_2_title = zen_get_products_extra_file_2_title($pInfo->products_id, $languages*['id']);
      $pInfo->file_3_title = zen_get_products_extra_file_3_title($pInfo->products_id, $languages*['id']);
      $pInfo->file_4_title = zen_get_products_extra_file_4_title($pInfo->products_id, $languages*['id']);
          } else {
            $pInfo->products_name = zen_db_prepare_input($products_name[$languages*['id']]);
            $pInfo->products_description = zen_db_prepare_input($products_description[$languages*['id']]);
            $pInfo->products_url = zen_db_prepare_input($products_url[$languages*['id']]);
      $pInfo->extra_field = zen_db_prepare_input($products_extra_field[$languages*['id']]);
      $pInfo->file_1 = zen_db_prepare_input($products_extra_field_file_1[$languages*['id']]);
      $pInfo->file_2 = zen_db_prepare_input($products_extra_field_file_2[$languages*['id']]);
      $pInfo->file_3 = zen_db_prepare_input($products_extra_field_file_3[$languages*['id']]);
      $pInfo->file_4 = zen_db_prepare_input($products_extra_field_file_4[$languages*['id']]);
      $pInfo->file_1_title = zen_db_prepare_input($products_extra_field_file_1_title[$languages*['id']]);
      $pInfo->file_2_title = zen_db_prepare_input($products_extra_field_file_2_title[$languages*['id']]);
      $pInfo->file_3_title = zen_db_prepare_input($products_extra_field_file_3_title[$languages*['id']]);
      $pInfo->file_4_title = zen_db_prepare_input($products_extra_field_file_4_title[$languages*['id']]);
          }
     
    // extra fields mod multilang
      echo zen_draw_hidden_field('extra_field[' . $languages*['id'] . ']', htmlspecialchars(stripslashes($products_extra_field[$languages*['id']])));
      echo zen_draw_hidden_field('file_1[' . $languages*['id'] . ']', stripslashes($products_file_1_name[$languages*['id']]));
           echo zen_draw_hidden_field('file_2[' . $languages*['id'] . ']', stripslashes($products_file_2_name[$languages*['id']]));
           echo zen_draw_hidden_field('file_3[' . $languages*['id'] . ']', stripslashes($products_file_3_name[$languages*['id']]));
           echo zen_draw_hidden_field('file_4[' . $languages*['id'] . ']', stripslashes($products_file_4_name[$languages*['id']]));
    //eof extra field mod multilang