[ 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/ -> modules.php (source)

   1  <?php
   2  /**

   3   * @package admin

   4   * @copyright Copyright 2003-2006 Zen Cart Development Team

   5   * @copyright Portions Copyright 2003 osCommerce

   6   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

   7   * @version $Id: modules.php 4366 2006-09-03 19:27:34Z ajeh $

   8   */
   9  
  10    require ('includes/application_top.php');
  11  
  12    $set = (isset($_GET['set']) ? $_GET['set'] : '');
  13  
  14    if (zen_not_null($set)) {
  15      switch ($set) {
  16        case 'shipping':
  17          $module_type = 'shipping';
  18          $module_directory = DIR_FS_CATALOG_MODULES . 'shipping/';
  19          $module_key = 'MODULE_SHIPPING_INSTALLED';
  20          define('HEADING_TITLE', HEADING_TITLE_MODULES_SHIPPING);
  21          $shipping_errors = '';
  22          if (zen_get_configuration_key_value('SHIPPING_ORIGIN_ZIP') == 'NONE' or zen_get_configuration_key_value('SHIPPING_ORIGIN_ZIP') == '') {
  23            $shipping_errors .= '<br />' . ERROR_SHIPPING_ORIGIN_ZIP;
  24          }
  25          if (zen_get_configuration_key_value('ORDER_WEIGHT_ZERO_STATUS') == '1' and !defined('MODULE_SHIPPING_FREESHIPPER_STATUS')) {
  26            $shipping_errors .= '<br />' . ERROR_ORDER_WEIGHT_ZERO_STATUS;
  27          }
  28          if (defined('MODULE_SHIPPING_USPS_STATUS') and (MODULE_SHIPPING_USPS_USERID=='NONE' or MODULE_SHIPPING_USPS_SERVER == 'test')) {
  29            $shipping_errors .= '<br />' . ERROR_USPS_STATUS;
  30          }
  31          if ($shipping_errors != '') {
  32            $messageStack->add(ERROR_SHIPPING_CONFIGURATION . $shipping_errors, 'caution');
  33          }
  34          break;
  35        case 'ordertotal':
  36          $module_type = 'order_total';
  37          $module_directory = DIR_FS_CATALOG_MODULES . 'order_total/';
  38          $module_key = 'MODULE_ORDER_TOTAL_INSTALLED';
  39          define('HEADING_TITLE', HEADING_TITLE_MODULES_ORDER_TOTAL);
  40          break;
  41        case 'payment':
  42        default:
  43          $module_type = 'payment';
  44          $module_directory = DIR_FS_CATALOG_MODULES . 'payment/';
  45          $module_key = 'MODULE_PAYMENT_INSTALLED';
  46          define('HEADING_TITLE', HEADING_TITLE_MODULES_PAYMENT);
  47          break;
  48      }
  49    }
  50  
  51    $action = (isset($_GET['action']) ? $_GET['action'] : '');
  52  
  53    if (zen_not_null($action)) {
  54      switch ($action) {
  55        case 'save':
  56          while (list($key, $value) = each($_POST['configuration'])) {
  57  // BOF: UPS USPS

  58            if( is_array( $value ) ){
  59              $value = implode( ", ", $value);
  60              $value = ereg_replace (", --none--", "", $value);
  61            }
  62  // EOF: UPS USPS

  63            $db->Execute("update " . TABLE_CONFIGURATION . "
  64                          set configuration_value = '" . $value . "'
  65                          where configuration_key = '" . $key . "'");
  66          }
  67          $configuration_query = 'select configuration_key as cfgkey, configuration_value as cfgvalue
  68                                  from ' . TABLE_CONFIGURATION;
  69          $configuration = $db->Execute($configuration_query);
  70  
  71          zen_redirect(zen_href_link(FILENAME_MODULES, 'set=' . $set . ($_GET['module'] != '' ? '&module=' . $_GET['module'] : ''), 'NONSSL'));
  72          break;
  73        case 'install':
  74        case 'remove':
  75          $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
  76          $class = basename($_GET['module']);
  77          if (file_exists($module_directory . $class . $file_extension)) {
  78            $configuration_query = 'select configuration_key as cfgkey, configuration_value as cfgvalue
  79                                    from ' . TABLE_CONFIGURATION;
  80            $configuration = $db->Execute($configuration_query);
  81            include($module_directory . $class . $file_extension);
  82            $module = new $class;
  83            if ($action == 'install') {
  84              $module->install();
  85            } elseif ($action == 'remove') {
  86              $module->remove();
  87            }
  88          }
  89  
  90          if ($action == 'install') {
  91  //          zen_href_link(FILENAME_MODULES, 'set=' . $set . (isset($_GET['module']) ? '&module=' . $_GET['module'] : '') . '&action=edit');

  92            zen_redirect(zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class . '&action=edit', 'NONSSL'));
  93          } else {
  94            zen_redirect(zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class, 'NONSSL'));
  95          }
  96          break;
  97      }
  98    }
  99  ?>
 100  <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
 101  <html <?php echo HTML_PARAMS; ?>>
 102  <head>
 103  <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
 104  <title><?php echo TITLE; ?></title>
 105  <link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
 106  <link rel="stylesheet" type="text/css" href="includes/cssjsmenuhover.css" media="all" id="hoverJS">
 107  <script language="javascript" src="includes/menu.js"></script>
 108  <script language="javascript" src="includes/general.js"></script>
 109  <script type="text/javascript">
 110    <!--
 111    function init()
 112    {
 113      cssjsmenu('navbar');
 114      if (document.getElementById)
 115      {
 116        var kill = document.getElementById('hoverJS');
 117        kill.disabled = true;
 118      }
 119    }
 120    // -->

 121  </script>
 122  </head>
 123  <body onLoad="init()">
 124  <!-- header //-->
 125  <?php require(DIR_WS_INCLUDES . 'header.php'); ?>
 126  <!-- header_eof //-->
 127  
 128  <!-- body //-->
 129  <table border="0" width="100%" cellspacing="2" cellpadding="2">
 130    <tr>
 131  <!-- body_text //-->
 132      <td width="100%" valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 133        <tr>
 134          <td width="100%"><table border="0" width="100%" cellspacing="0" cellpadding="0">
 135            <tr>
 136              <td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
 137              <td class="pageHeading" align="right"><?php echo zen_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
 138            </tr>
 139          </table></td>
 140        </tr>
 141        <tr>
 142          <td><table border="0" width="100%" cellspacing="0" cellpadding="0">
 143            <tr>
 144              <td valign="top"><table border="0" width="100%" cellspacing="0" cellpadding="2">
 145                <tr class="dataTableHeadingRow">
 146                  <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_MODULES; ?></td>
 147                  <td class="dataTableHeadingContent">&nbsp;</td>
 148                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_SORT_ORDER; ?></td>
 149  <?php
 150    if ($set == 'payment') {
 151  ?>
 152                  <td class="dataTableHeadingContent" align="center" width="100"><?php echo TABLE_HEADING_ORDERS_STATUS; ?></td>
 153  <?php } ?>
 154                  <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_ACTION; ?>&nbsp;</td>
 155                </tr>
 156  <?php
 157    $file_extension = substr($PHP_SELF, strrpos($PHP_SELF, '.'));
 158    $directory_array = array();
 159    if ($dir = @dir($module_directory)) {
 160      while ($file = $dir->read()) {
 161        if (!is_dir($module_directory . $file)) {
 162          if (substr($file, strrpos($file, '.')) == $file_extension) {
 163            $directory_array[] = $file;
 164          }
 165        }
 166      }
 167      sort($directory_array);
 168      $dir->close();
 169    }
 170  
 171    $installed_modules = array();
 172    for ($i=0, $n=sizeof($directory_array); $i<$n; $i++) {
 173      $file = $directory_array[$i];
 174      include(DIR_FS_CATALOG_LANGUAGES . $_SESSION['language'] . '/modules/' . $module_type . '/' . $file);
 175      include($module_directory . $file);
 176      $class = substr($file, 0, strrpos($file, '.'));
 177      if (zen_class_exists($class)) {
 178        $module = new $class;
 179        if ($module->check() > 0) {
 180          if ($module->sort_order > 0) {
 181            if ($installed_modules[$module->sort_order] != '') {
 182              $zc_valid = false;
 183            }
 184            $installed_modules[$module->sort_order] = $file;
 185          } else {
 186            $installed_modules[] = $file;
 187          }
 188        }
 189        if ((!isset($_GET['module']) || (isset($_GET['module']) && ($_GET['module'] == $class))) && !isset($mInfo)) {
 190          $module_info = array('code' => $module->code,
 191                               'title' => $module->title,
 192                               'description' => $module->description,
 193                               'status' => $module->check());
 194          $module_keys = $module->keys();
 195          $keys_extra = array();
 196          for ($j=0, $k=sizeof($module_keys); $j<$k; $j++) {
 197            $key_value = $db->Execute("select configuration_title, configuration_value, configuration_key,
 198                                          configuration_description, use_function, set_function
 199                                          from " . TABLE_CONFIGURATION . "
 200                                          where configuration_key = '" . $module_keys[$j] . "'");
 201  
 202            $keys_extra[$module_keys[$j]]['title'] = $key_value->fields['configuration_title'];
 203            $keys_extra[$module_keys[$j]]['value'] = $key_value->fields['configuration_value'];
 204            $keys_extra[$module_keys[$j]]['description'] = $key_value->fields['configuration_description'];
 205            $keys_extra[$module_keys[$j]]['use_function'] = $key_value->fields['use_function'];
 206            $keys_extra[$module_keys[$j]]['set_function'] = $key_value->fields['set_function'];
 207          }
 208          $module_info['keys'] = $keys_extra;
 209          $mInfo = new objectInfo($module_info);
 210        }
 211        if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) {
 212          if ($module->check() > 0) {
 213            echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class . '&action=edit', 'NONSSL') . '\'">' . "\n";
 214          } else {
 215            echo '              <tr id="defaultSelected" class="dataTableRowSelected" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)">' . "\n";
 216          }
 217        } else {
 218          echo '              <tr class="dataTableRow" onmouseover="rowOverEffect(this)" onmouseout="rowOutEffect(this)" onclick="document.location.href=\'' . zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class, 'NONSSL') . '\'">' . "\n";
 219        }
 220  //print_r($module) . '<br><BR>';

 221  //echo (!empty($module->enabled) ? 'ENABLED' : 'NOT ENABLED') . ' vs ' . (is_numeric($module->sort_order) ? 'ON' : 'OFF') . '<BR><BR>' ;

 222  ?>
 223                  <td class="dataTableContent"><?php echo $module->title; ?></td>
 224                  <td class="dataTableContent"><?php echo $module->code; ?></td>
 225                  <td class="dataTableContent" align="right">
 226                    <?php if (is_numeric($module->sort_order)) echo $module->sort_order; ?>
 227                    <?php
 228                      // show current status

 229                      if ($set == 'payment' || $set == 'shipping') {
 230                        echo '&nbsp;' . ((!empty($module->enabled) && is_numeric($module->sort_order)) ? zen_image(DIR_WS_IMAGES . 'icon_status_green.gif') : ((empty($module->enabled) && is_numeric($module->sort_order)) ? zen_image(DIR_WS_IMAGES . 'icon_status_yellow.gif') : zen_image(DIR_WS_IMAGES . 'icon_status_red.gif')));
 231                      } else {
 232                        echo '&nbsp;' . (is_numeric($module->sort_order) ? zen_image(DIR_WS_IMAGES . 'icon_status_green.gif') : zen_image(DIR_WS_IMAGES . 'icon_status_red.gif'));
 233                      }
 234                    ?>
 235                  </td>
 236  <?php
 237    if ($set == 'payment') {
 238      $orders_status_name = $db->Execute("select orders_status_id, orders_status_name from " . TABLE_ORDERS_STATUS . " where orders_status_id='" . $module->order_status . "' and language_id='" . $_SESSION['languages_id'] . "'");
 239  ?>
 240                  <td class="dataTableContent" align="left">&nbsp;&nbsp;&nbsp;<?php echo (is_numeric($module->sort_order) ? (($orders_status_name->fields['orders_status_id'] < 1) ? TEXT_DEFAULT : $orders_status_name->fields['orders_status_name']) : ''); ?>&nbsp;&nbsp;&nbsp;</td>
 241  <?php } ?>
 242                  <td class="dataTableContent" align="right"><?php if (isset($mInfo) && is_object($mInfo) && ($class == $mInfo->code) ) { echo zen_image(DIR_WS_IMAGES . 'icon_arrow_right.gif'); } else { echo '<a href="' . zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $class, 'NONSSL') . '">' . zen_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?>&nbsp;</td>
 243                </tr>
 244  <?php
 245      }
 246    }
 247    ksort($installed_modules);
 248    $check = $db->Execute("select configuration_value
 249                           from " . TABLE_CONFIGURATION . "
 250                           where configuration_key = '" . $module_key . "'");
 251  
 252    if ($check->RecordCount() > 0) {
 253      if ($check->fields['configuration_value'] != implode(';', $installed_modules)) {
 254        $db->Execute("update " . TABLE_CONFIGURATION . "
 255                      set configuration_value = '" . implode(';', $installed_modules) . "', last_modified = now()
 256                      where configuration_key = '" . $module_key . "'");
 257      }
 258    } else {
 259      $db->Execute("insert into " . TABLE_CONFIGURATION . "
 260                  (configuration_title, configuration_key, configuration_value,
 261                   configuration_description, configuration_group_id, sort_order, date_added)
 262                   values ('Installed Modules', '" . $module_key . "', '" . implode(';', $installed_modules) . "',
 263                           'This is automatically updated. No need to edit.', '6', '0', now())");
 264    }
 265    if (isset($zc_valid) && $zc_valid == false) {
 266      echo '<span class="alert">' . WARNING_MODULES_SORT_ORDER . '</span>';
 267    }
 268  ?>
 269                <tr>
 270                  <td colspan="3" class="smallText"><?php echo TEXT_MODULE_DIRECTORY . ' ' . $module_directory; ?></td>
 271                </tr>
 272              </table></td>
 273  <?php
 274    $heading = array();
 275    $contents = array();
 276    switch ($action) {
 277      case 'edit':
 278        $keys = '';
 279        reset($mInfo->keys);
 280        while (list($key, $value) = each($mInfo->keys)) {
 281          $keys .= '<b>' . $value['title'] . '</b><br>' . $value['description'] . '<br>';
 282          if ($value['set_function']) {
 283            eval('$keys .= ' . $value['set_function'] . "'" . $value['value'] . "', '" . $key . "');");
 284          } else {
 285            $keys .= zen_draw_input_field('configuration[' . $key . ']', $value['value']);
 286          }
 287          $keys .= '<br><br>';
 288        }
 289        $keys = substr($keys, 0, strrpos($keys, '<br><br>'));
 290        $heading[] = array('text' => '<b>' . $mInfo->title . '</b>');
 291        $contents = array('form' => zen_draw_form('modules', FILENAME_MODULES, 'set=' . $set . ($_GET['module'] != '' ? '&module=' . $_GET['module'] : '') . '&action=save', 'post', '', true));
 292        if (ADMIN_CONFIGURATION_KEY_ON == 1) {
 293          $contents[] = array('text' => '<strong>Key: ' . $mInfo->code . '</strong><br />');
 294        }
 295        $contents[] = array('text' => $keys);
 296        $contents[] = array('align' => 'center', 'text' => '<br>' . zen_image_submit('button_update.gif', IMAGE_UPDATE) . ' <a href="' . zen_href_link(FILENAME_MODULES, 'set=' . $set . ($_GET['module'] != '' ? '&module=' . $_GET['module'] : ''), 'NONSSL') . '">' . zen_image_button('button_cancel.gif', IMAGE_CANCEL) . '</a>');
 297        break;
 298      default:
 299        $heading[] = array('text' => '<b>' . $mInfo->title . '</b>');
 300  
 301        if ($mInfo->status == '1') {
 302          $keys = '';
 303          reset($mInfo->keys);
 304          while (list(, $value) = each($mInfo->keys)) {
 305            $keys .= '<b>' . $value['title'] . '</b><br>';
 306            if ($value['use_function']) {
 307              $use_function = $value['use_function'];
 308              if (ereg('->', $use_function)) {
 309                $class_method = explode('->', $use_function);
 310                if (!is_object(${$class_method[0]})) {
 311                  include(DIR_WS_CLASSES . $class_method[0] . '.php');
 312                  ${$class_method[0]} = new $class_method[0]();
 313                }
 314                $keys .= zen_call_function($class_method[1], $value['value'], ${$class_method[0]});
 315              } else {
 316                $keys .= zen_call_function($use_function, $value['value']);
 317              }
 318            } else {
 319              $keys .= $value['value'];
 320            }
 321            $keys .= '<br><br>';
 322          }
 323  
 324          if (ADMIN_CONFIGURATION_KEY_ON == 1) {
 325            $contents[] = array('text' => '<strong>Key: ' . $mInfo->code . '</strong><br />');
 326          }
 327          $keys = substr($keys, 0, strrpos($keys, '<br><br>'));
 328          $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $mInfo->code . '&action=remove', 'NONSSL') . '">' . zen_image_button('button_module_remove.gif', IMAGE_MODULE_REMOVE) . '</a> <a href="' . zen_href_link(FILENAME_MODULES, 'set=' . $set . (isset($_GET['module']) ? '&module=' . $_GET['module'] : '') . '&action=edit', 'NONSSL') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a>');
 329          $contents[] = array('text' => '<br>' . $mInfo->description);
 330          $contents[] = array('text' => '<br>' . $keys);
 331        } else {
 332          $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_MODULES, 'set=' . $set . '&module=' . $mInfo->code . '&action=install', 'NONSSL') . '">' . zen_image_button('button_module_install.gif', IMAGE_MODULE_INSTALL) . '</a>');
 333          $contents[] = array('text' => '<br>' . $mInfo->description);
 334        }
 335        break;
 336    }
 337    if ( (zen_not_null($heading)) && (zen_not_null($contents)) ) {
 338      echo '            <td width="25%" valign="top">' . "\n";
 339      $box = new box;
 340      echo $box->infoBox($heading, $contents);
 341      echo '            </td>' . "\n";
 342    }
 343  ?>
 344            </tr>
 345          </table></td>
 346        </tr>
 347      </table></td>
 348  <!-- body_text_eof //-->
 349    </tr>
 350  </table>
 351  <!-- body_eof //-->
 352  <!-- footer //-->
 353  <?php require(DIR_WS_INCLUDES . 'footer.php'); ?>
 354  <!-- footer_eof //-->
 355  <br>
 356  </body>
 357  </html>
 358  <?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