Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

404
 
428
 
428
 
order_total.php
_> 11 <?php
  22 /*
<> 3 -  $Id: order_total.php 404 2006-01-25 22:55:27Z hpdl $
   3+  $Id: order_total.php 428 2006-02-14 16:47:41Z hpdl $
44 
  55   osCommerce, Open Source E-Commerce Solutions
  66   http://www.oscommerce.com
     
 !
1010   Released under the GNU General Public License
  1111 */
  1212 
<> 13 -  class order_total {
   13+  class osC_OrderTotal {
1414     var $modules;
  1515 
  1616 // class constructor
<> 17 -    function order_total() {
  18 -      global $osC_Language;
   17+    function osC_OrderTotal() {
   18+      global $osC_Database, $osC_Language;
1919 
<> 20 -      if (defined('MODULE_ORDER_TOTAL_INSTALLED') && tep_not_null(MODULE_ORDER_TOTAL_INSTALLED)) {
  21 -        $this->modules = explode(';', MODULE_ORDER_TOTAL_INSTALLED);
   20+      $Qmodules = $osC_Database->query('select code from :table_templates_boxes where modules_group = "order_total"');
   21+      $Qmodules->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
   22+      $Qmodules->setCache('modules-order_total');
   23+      $Qmodules->execute();
2224 
<> 23 -        $osC_Language->load('modules-order_total');
   25+      while ($Qmodules->next()) {
   26+        $this->modules[] = $Qmodules->value('code');
   27+      }
2428 
<> 25 -        reset($this->modules);
  26 -        while (list(, $value) = each($this->modules)) {
  27 -          include('includes/modules/order_total/' . $value);
   29+      $Qmodules->freeResult();
2830 
<> 29 -          $class = substr($value, 0, strrpos($value, '.'));
  30 -          $GLOBALS[$class] = new $class;
  31 -        }
   31+      $osC_Language->load('modules-order_total');
   32+
   33+      foreach ($this->modules as $module) {
   34+        include('includes/modules/order_total/' . $module . '.' . substr(basename(__FILE__), (strrpos(basename(__FILE__), '.')+1)));
   35+
   36+        $module_class = 'osC_OrderTotal_' . $module;
   37+
   38+        $GLOBALS[$module_class] = new $module_class();
3239       }
  3340     }
  3441 
  3542     function process() {
  3643       $order_total_array = array();
<> 37 -      if (is_array($this->modules)) {
  38 -        reset($this->modules);
  39 -        while (list(, $value) = each($this->modules)) {
  40 -          $class = substr($value, 0, strrpos($value, '.'));
  41 -          if ($GLOBALS[$class]->enabled) {
  42 -            $GLOBALS[$class]->process();
4344 
<> 44 -            for ($i=0, $n=sizeof($GLOBALS[$class]->output); $i<$n; $i++) {
  45 -              if (tep_not_null($GLOBALS[$class]->output[$i]['title']) && tep_not_null($GLOBALS[$class]->output[$i]['text'])) {
  46 -                $order_total_array[] = array('code' => $GLOBALS[$class]->code,
  47 -                                             'title' => $GLOBALS[$class]->output[$i]['title'],
  48 -                                             'text' => $GLOBALS[$class]->output[$i]['text'],
  49 -                                             'value' => $GLOBALS[$class]->output[$i]['value'],
  50 -                                             'sort_order' => $GLOBALS[$class]->sort_order);
  51 -              }
   45+      foreach ($this->modules as $module) {
   46+        $module = 'osC_OrderTotal_' . $module;
   47+
   48+        if ($GLOBALS[$module]->enabled) {
   49+          $GLOBALS[$module]->process();
   50+
   51+          foreach ($GLOBALS[$module]->output as $output) {
   52+            if (tep_not_null($output['title']) && tep_not_null($output['text'])) {
   53+              $order_total_array[] = array('code' => $GLOBALS[$module]->code,
   54+                                           'title' => $output['title'],
   55+                                           'text' => $output['text'],
   56+                                           'value' => $output['value'],
   57+                                           'sort_order' => $GLOBALS[$module]->sort_order);
5258             }
  5359           }
  5460         }
     
 !
5965 
  6066     function output() {
  6167       $output_string = '';
<> 62 -      if (is_array($this->modules)) {
  63 -        reset($this->modules);
  64 -        while (list(, $value) = each($this->modules)) {
  65 -          $class = substr($value, 0, strrpos($value, '.'));
  66 -          if ($GLOBALS[$class]->enabled) {
  67 -            $size = sizeof($GLOBALS[$class]->output);
  68 -            for ($i=0; $i<$size; $i++) {
  69 -              $output_string .= '              <tr>' . "\n" .
  70 -                                '                <td align="right" class="main">' . $GLOBALS[$class]->output[$i]['title'] . '</td>' . "\n" .
  71 -                                '                <td align="right" class="main">' . $GLOBALS[$class]->output[$i]['text'] . '</td>' . "\n" .
  72 -                                '              </tr>';
  73 -            }
   68+
   69+      foreach ($this->modules as $module) {
   70+        $module = 'osC_OrderTotal_' . $module;
   71+
   72+        if ($GLOBALS[$module]->enabled) {
   73+          foreach ($GLOBALS[$module]->output as $output) {
   74+            $output_string .= '              <tr>' . "\n" .
   75+                              '                <td align="right" class="main">' . $output['title'] . '</td>' . "\n" .
   76+                              '                <td align="right" class="main">' . $output['text'] . '</td>' . "\n" .
   77+                              '              </tr>';
7478           }
  7579         }
  7680       }
  7781 
  7882       return $output_string;
  7983     }
<>  84+
   85+    function hasKeys() {
   86+      static $has_keys;
   87+
   88+      if (isset($has_keys) === false) {
   89+        $has_keys = (sizeof($this->getKeys()) > 0) ? true : false;
   90+      }
   91+
   92+      return $has_keys;
   93+    }
   94+
   95+    function install() {
   96+      global $osC_Database, $osC_Language;
   97+
   98+      $Qinstall = $osC_Database->query('insert into :table_templates_boxes (title, code, author_name, author_www, modules_group) values (:title, :code, :author_name, :author_www, :modules_group)');
   99+      $Qinstall->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
   100+      $Qinstall->bindValue(':title', $this->_title);
   101+      $Qinstall->bindValue(':code', $this->_code);
   102+      $Qinstall->bindValue(':author_name', $this->_author_name);
   103+      $Qinstall->bindValue(':author_www', $this->_author_www);
   104+      $Qinstall->bindValue(':modules_group', $this->_group);
   105+      $Qinstall->execute();
   106+
   107+      foreach ($osC_Language->getAll() as $key => $value) {
   108+        if (file_exists(dirname(__FILE__) . '/../languages/' . $key . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) {
   109+          foreach ($osC_Language->extractDefinitions($key . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) {
   110+            $Qcheck = $osC_Database->query('select id from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group and languages_id = :languages_id limit 1');
   111+            $Qcheck->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
   112+            $Qcheck->bindValue(':definition_key', $def['key']);
   113+            $Qcheck->bindValue(':content_group', $def['group']);
   114+            $Qcheck->bindInt(':languages_id', $value['id']);
   115+            $Qcheck->execute();
   116+
   117+            if ($Qcheck->numberOfRows() === 1) {
   118+              $Qdef = $osC_Database->query('update :table_languages_definitions set definition_value = :definition_value where definition_key = :definition_key and content_group = :content_group and languages_id = :languages_id');
   119+            } else {
   120+              $Qdef = $osC_Database->query('insert into :table_languages_definitions (languages_id, content_group, definition_key, definition_value) values (:languages_id, :content_group, :definition_key, :definition_value)');
   121+            }
   122+            $Qdef->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
   123+            $Qdef->bindInt(':languages_id', $value['id']);
   124+            $Qdef->bindValue(':content_group', $def['group']);
   125+            $Qdef->bindValue(':definition_key', $def['key']);
   126+            $Qdef->bindValue(':definition_value', $def['value']);
   127+            $Qdef->execute();
   128+          }
   129+        }
   130+      }
   131+
   132+      osC_Cache::clear('languages');
   133+    }
   134+
   135+    function remove() {
   136+      global $osC_Database, $osC_Language;
   137+
   138+      $Qdel = $osC_Database->query('delete from :table_templates_boxes where code = :code and modules_group = :modules_group');
   139+      $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
   140+      $Qdel->bindValue(':code', $this->_code);
   141+      $Qdel->bindValue(':modules_group', $this->_group);
   142+      $Qdel->execute();
   143+
   144+      if ($this->hasKeys()) {
   145+        $Qdel = $osC_Database->query('delete from :table_configuration where configuration_key in (":configuration_key")');
   146+        $Qdel->bindTable(':table_configuration', TABLE_CONFIGURATION);
   147+        $Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys()));
   148+        $Qdel->execute();
   149+      }
   150+
   151+      if (file_exists(dirname(__FILE__) . '/../languages/' . $osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml')) {
   152+        foreach ($osC_Language->extractDefinitions($osC_Language->getCode() . '/modules/' . $this->_group . '/' . $this->_code . '.xml') as $def) {
   153+          $Qdel = $osC_Database->query('delete from :table_languages_definitions where definition_key = :definition_key and content_group = :content_group');
   154+          $Qdel->bindTable(':table_languages_definitions', TABLE_LANGUAGES_DEFINITIONS);
   155+          $Qdel->bindValue(':definition_key', $def['key']);
   156+          $Qdel->bindValue(':content_group', $def['group']);
   157+          $Qdel->execute();
   158+        }
   159+
   160+        osC_Cache::clear('languages');
   161+      }
   162+    }
   163+
   164+    function _usortModules($a, $b) {
   165+      if ($GLOBALS['osC_Shipping_' . $a]->sort_order == $GLOBALS['osC_Shipping_' . $b]->sort_order) {
   166+        return strnatcasecmp($GLOBALS['osC_Shipping_' . $a]->title, $GLOBALS['osC_Shipping_' . $a]->title);
   167+      }
   168+
   169+      return ($GLOBALS['osC_Shipping_' . $a]->sort_order < $GLOBALS['osC_Shipping_' . $b]->sort_order) ? -1 : 1;
   170+    }
80171   }
<_ 81 -?>
   172+?>