Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

331
 
332
 
332
 
boxes.php
_><_ 1 -<?php
  2 -/*
  3 -  $Id: $
  4 -
  5 -  osCommerce, Open Source E-Commerce Solutions
  6 -  http://www.oscommerce.com
  7 -
  8 -  Copyright (c) 2005 osCommerce
  9 -
  10 -  Released under the GNU General Public License
  11 -*/
  12 -
  13 -  class osC_Boxes {
  14 -    var $_boxes,
  15 -        $_code,
  16 -        $_title,
  17 -        $_title_link,
  18 -        $_content,
  19 -        $_author_name,
  20 -        $_author_www,
  21 -        $_keys,
  22 -        $_module_group;
  23 -
  24 -    function osC_Boxes($module_group) {
  25 -      $this->_module_group = $module_group;
  26 -
  27 -      global $osC_Database, $osC_Template, $osC_Cache;
  28 -
  29 -      if ($osC_Cache->read('templates_' . $this->_module_group . '_layout-' . $osC_Template->getTemplate() . '-' . $osC_Template->getGroup() . '-' . $osC_Template->getPageContentsFilename())) {
  30 -        $data = $osC_Cache->getCache();
  31 -      } else {
  32 -        $data = array();
  33 -
  34 -        $Qspecific = $osC_Database->query('select b2p.boxes_group, b.code from :table_templates_boxes_to_pages b2p, :table_templates_boxes b, :table_templates t where b2p.templates_id = :templates_id and b2p.page_specific = 1 and b2p.content_page in (:content_page) and b2p.templates_boxes_id = b.id and b.modules_group = :modules_group and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order');
  35 -        $Qspecific->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES);
  36 -        $Qspecific->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
  37 -        $Qspecific->bindTable(':table_templates', TABLE_TEMPLATES);
  38 -        $Qspecific->bindInt(':templates_id', 1);
  39 -        $Qspecific->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . substr($osC_Template->getPageContentsFilename(), 0, strrpos($osC_Template->getPageContentsFilename(), '.')) . '"');
  40 -        $Qspecific->bindValue(':modules_group', $this->_module_group);
  41 -        $Qspecific->execute();
  42 -
  43 -        if ($Qspecific->numberOfRows()) {
  44 -          while ($Qspecific->next()) {
  45 -            $data[$Qspecific->value('boxes_group')][] = $Qspecific->value('code');
  46 -          }
  47 -        } else {
  48 -          $Qboxes = $osC_Database->query('select b2p.boxes_group, b2p.content_page, b.code from :table_templates_boxes_to_pages b2p, :table_templates_boxes b, :table_templates t where b2p.templates_id = :templates_id and b2p.content_page in (:content_page) and b2p.templates_boxes_id = b.id and b.modules_group = :modules_group and b2p.templates_id = t.id order by b2p.boxes_group, b2p.sort_order');
  49 -          $Qboxes->bindTable(':table_templates_boxes_to_pages', TABLE_TEMPLATES_BOXES_TO_PAGES);
  50 -          $Qboxes->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
  51 -          $Qboxes->bindTable(':table_templates', TABLE_TEMPLATES);
  52 -          $Qboxes->bindInt(':templates_id', 1);
  53 -          $Qboxes->bindRaw(':content_page', '"*", "' . $osC_Template->getGroup() . '/*", "' . $osC_Template->getGroup() . '/' . substr($osC_Template->getPageContentsFilename(), 0, strrpos($osC_Template->getPageContentsFilename(), '.')) . '"');
  54 -          $Qboxes->bindValue(':modules_group', $this->_module_group);
  55 -          $Qboxes->execute();
  56 -
  57 -          while ($Qboxes->next()) {
  58 -            $_data[$Qboxes->value('boxes_group')][] = array('code' => $Qboxes->value('code'),
  59 -                                                            'page' => $Qboxes->value('content_page'));
  60 -          }
  61 -
  62 -          foreach ($_data as $groups => $boxes) {
  63 -            $clean = array();
  64 -
  65 -            foreach ($boxes as $box) {
  66 -              if (isset($clean[$box['code']])) {
  67 -                if (substr_count($box['page'], '/') > substr_count($clean[$box['code']]['page'], '/')) {
  68 -                  unset($clean[$box['code']]);
  69 -                }
  70 -              }
  71 -
  72 -              $clean[$box['code']] = $box;
  73 -            }
  74 -
  75 -            $_data[$groups] = $clean;
  76 -          }
  77 -
  78 -          foreach ($_data as $groups => $boxes) {
  79 -            foreach ($boxes as $box) {
  80 -              $data[$groups][] = $box['code'];
  81 -            }
  82 -          }
  83 -        }
  84 -
  85 -        $osC_Cache->writeBuffer($data);
  86 -      }
  87 -
  88 -      $this->_boxes = $data;
  89 -    }
  90 -
  91 -    function getCode() {
  92 -      return $this->_code;
  93 -    }
  94 -
  95 -    function getTitle() {
  96 -      return $this->_title;
  97 -    }
  98 -
  99 -    function getTitleLink() {
  100 -      return $this->_title_link;
  101 -    }
  102 -
  103 -    function hasTitleLink() {
  104 -      return !empty($this->_title_link);
  105 -    }
  106 -
  107 -    function getContent() {
  108 -      return $this->_content;
  109 -    }
  110 -
  111 -    function hasContent() {
  112 -      return !empty($this->_content);
  113 -    }
  114 -
  115 -    function getGroup($group) {
  116 -      $boxes = array();
  117 -
  118 -      if (isset($this->_boxes[$group])) {
  119 -        foreach ($this->_boxes[$group] as $box) {
  120 -          if (file_exists('includes/modules/' . $this->_module_group . '/' . $box . '.php')) {
  121 -            $box_class = 'osC_' . ucfirst($this->_module_group) . '_' . $box;
  122 -
  123 -            if (class_exists($box_class) === false) {
  124 -              include('includes/modules/' . $this->_module_group . '/' . $box . '.php');
  125 -            }
  126 -
  127 -            $boxes[] = $box_class;
  128 -          }
  129 -        }
  130 -      }
  131 -
  132 -      return $boxes;
  133 -    }
  134 -
  135 -    function isInstalled() {
  136 -      global $osC_Database;
  137 -
  138 -      static $is_installed;
  139 -
  140 -      if (isset($is_installed) === false) {
  141 -        $Qcheck = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group');
  142 -        $Qcheck->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
  143 -        $Qcheck->bindValue(':code', $this->_code);
  144 -        $Qcheck->bindValue(':modules_group', $this->_module_group);
  145 -        $Qcheck->execute();
  146 -
  147 -        $is_installed = ($Qcheck->numberOfRows()) ? true : false;
  148 -      }
  149 -
  150 -      return $is_installed;
  151 -    }
  152 -
  153 -    function hasKeys() {
  154 -      static $has_keys;
  155 -
  156 -      if (isset($has_keys) === false) {
  157 -        $has_keys = (sizeof($this->getKeys()) > 0) ? true : false;
  158 -      }
  159 -
  160 -      return $has_keys;
  161 -    }
  162 -
  163 -    function getKeys() {
  164 -      if (!isset($this->_keys)) {
  165 -        $this->_keys = array();
  166 -      }
  167 -
  168 -      return $this->_keys;
  169 -    }
  170 -
  171 -    function isActive() {
  172 -      return true;
  173 -    }
  174 -
  175 -    function remove() {
  176 -      global $osC_Database;
  177 -
  178 -      $Qbox = $osC_Database->query('select id from :table_templates_boxes where code = :code and modules_group = :modules_group');
  179 -      $Qbox->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
  180 -      $Qbox->bindValue(':code', $this->_code);
  181 -      $Qbox->bindValue(':modules_group', $this->_module_group);
  182 -      $Qbox->execute();
  183 -
  184 -      $Qdel = $osC_Database->query('delete from :table_templates_boxes_to_pages where templates_boxes_id = :templates_boxes_id');
  185 -      $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
  186 -      $Qdel->bindValue(':templates_boxes_id', $Qbox->valueInt('id'));
  187 -      $Qdel->execute();
  188 -
  189 -      $Qdel = $osC_Database->query('delete from :table_templates_boxes where code = :code and modules_group = :modules_group');
  190 -      $Qdel->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
  191 -      $Qdel->bindValue(':code', $this->_code);
  192 -      $Qdel->bindValue(':modules_group', $this->_module_group);
  193 -      $Qdel->execute();
  194 -
  195 -      if ($this->hasKeys()) {
  196 -        $Qdel = $osC_Database->query('delete from :table_configuration where configuration_key in (":configuration_key")');
  197 -        $Qdel->bindTable(':table_configuration', TABLE_CONFIGURATION);
  198 -        $Qdel->bindRaw(':configuration_key', implode('", "', $this->getKeys()));
  199 -        $Qdel->execute();
  200 -      }
  201 -    }
  202 -
  203 -    function getAuthorName() {
  204 -      return $this->_author_name;
  205 -    }
  206 -
  207 -    function getAuthorAddress() {
  208 -      return $this->_author_www;
  209 -    }
  210 -  }
  211 -?>