Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

301
 
331
 
331
 
recently_visited.php
_> 11 <?php
  22 /*
<> 3 -
   3+  $Id: $
44   osCommerce, Open Source E-Commerce Solutions
  55   http://www.oscommerce.com
  66 
     
 !
99   Released under the GNU General Public License
  1010 */
  1111 
<> 12 -  class osC_RecentlyVisited {
   12+  class osC_Content_recently_visited extends osC_Boxes {
   13+    var $_title = 'Recently Visited',
   14+        $_code = 'recently_visited',
   15+        $_author_name = 'osCommerce',
   16+        $_author_www = 'http://www.oscommerce.com';
1317 
<> 14 -    var $visits = array();
  15 -
1618 /* Class constructor */
  1719 
<> 18 -    function osC_RecentlyVisited() {
  19 -      if (isset($_SESSION['osC_RecentlyVisited_data']) === false) {
  20 -        $_SESSION['osC_RecentlyVisited_data'] = array();
  21 -      }
  22 -
  23 -      $this->visits =& $_SESSION['osC_RecentlyVisited_data'];
   20+    function osC_Content_recently_visited() {
2421     }
  2522 
<> 26 -    function contentModuleInitialize() {
  27 -      global $osC_Product, $osC_Category, $osC_Search;
  28 -
  29 -      if (SERVICE_RECENTLY_VISITED_SHOW_PRODUCTS == 'True') {
  30 -        if (isset($osC_Product) && is_a($osC_Product, 'osC_Product')) {
  31 -          $this->setProduct($osC_Product->getID());
  32 -        }
  33 -      }
  34 -
  35 -      if (SERVICE_RECENTLY_VISITED_SHOW_CATEGORIES == 'True') {
  36 -        if (isset($osC_Category) && is_a($osC_Category, 'osC_Category')) {
  37 -          $this->setCategory($osC_Category->getID());
  38 -        }
  39 -      }
  40 -
  41 -      if (SERVICE_RECENTLY_VISITED_SHOW_SEARCHES == 'True') {
  42 -        if (isset($osC_Search) && is_a($osC_Search, 'osC_Search')) {
  43 -          if ($osC_Search->hasKeywords()) {
  44 -            $this->setSearchQuery($osC_Search->getKeywords());
  45 -          }
  46 -        }
  47 -      }
   23+    function initialize() {
   24+      $this->_content = 'dummy text';
4825     }
  4926 
<> 50 -    function getContentModule() {
  51 -      return 'recently_visited.php';
  52 -    }
   27+    function install() {
   28+      global $osC_Database;
5329 
<> 54 -    function setProduct($id) {
  55 -      if (isset($this->visits['products'])) {
  56 -        foreach ($this->visits['products'] as $key => $value) {
  57 -          if ($value['id'] == $id) {
  58 -            unset($this->visits['products'][$key]);
  59 -            break;
  60 -          }
  61 -        }
  62 -
  63 -        if (sizeof($this->visits['products']) > (SERVICE_RECENTLY_VISITED_MAX_PRODUCTS * 2)) {
  64 -          array_pop($this->visits['products']);
  65 -        }
  66 -      } else {
  67 -        $this->visits['products'] = array();
  68 -      }
  69 -
  70 -      array_unshift($this->visits['products'], array('id' => $id));
   30+      $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)');
   31+      $Qinstall->bindTable(':table_templates_boxes', TABLE_TEMPLATES_BOXES);
   32+      $Qinstall->bindValue(':title', $this->_title);
   33+      $Qinstall->bindValue(':code', $this->_code);
   34+      $Qinstall->bindValue(':author_name', $this->_author_name);
   35+      $Qinstall->bindValue(':author_www', $this->_author_www);
   36+      $Qinstall->bindValue(':modules_group', 'content');
   37+      $Qinstall->execute();
7138     }
<> 72 -
  73 -    function setCategory($id) {
  74 -      if (isset($this->visits['categories'])) {
  75 -        foreach ($this->visits['categories'] as $key => $value) {
  76 -          if ($value['id'] == $id) {
  77 -            unset($this->visits['categories'][$key]);
  78 -            break;
  79 -          }
  80 -        }
  81 -
  82 -        if (sizeof($this->visits['categories']) > (SERVICE_RECENTLY_VISITED_MAX_CATEGORIES * 2)) {
  83 -          array_pop($this->visits['categories']);
  84 -        }
  85 -      } else {
  86 -        $this->visits['categories'] = array();
  87 -      }
  88 -
  89 -      array_unshift($this->visits['categories'], array('id' => $id));
  90 -    }
  91 -
  92 -    function setSearchQuery($keywords) {
  93 -      global $osC_Search;
  94 -
  95 -      if (isset($this->visits['searches'])) {
  96 -        foreach ($this->visits['searches'] as $key => $value) {
  97 -          if ($value['keywords'] == $keywords) {
  98 -            unset($this->visits['searches'][$key]);
  99 -            break;
  100 -          }
  101 -        }
  102 -
  103 -        if (sizeof($this->visits['searches']) > (SERVICE_RECENTLY_VISITED_MAX_SEARCHES * 2)) {
  104 -          array_pop($this->visits['searches']);
  105 -        }
  106 -      } else {
  107 -        $this->visits['searches'] = array();
  108 -      }
  109 -
  110 -      array_unshift($this->visits['searches'], array('keywords' => $keywords,
  111 -                                                     'results' => $osC_Search->getNumberOfResults()
  112 -                                                    ));
  113 -    }
  114 -
  115 -    function hasHistory() {
  116 -      if ($this->hasProducts() || $this->hasCategories() || $this->hasSearches()) {
  117 -        return true;
  118 -      }
  119 -
  120 -      return false;
  121 -    }
  122 -
  123 -    function hasProducts() {
  124 -      if (isset($this->visits['products']) && (empty($this->visits['products']) === false)) {
  125 -        return true;
  126 -      }
  127 -
  128 -      return false;
  129 -    }
  130 -
  131 -    function getProducts() {
  132 -      $history = array();
  133 -
  134 -      if (isset($this->visits['products']) && (empty($this->visits['products']) === false)) {
  135 -        $counter = 0;
  136 -
  137 -        foreach ($this->visits['products'] as $k => $v) {
  138 -          $counter++;
  139 -
  140 -          $osC_Product = new osC_Product($v['id']);
  141 -          $osC_Category = new osC_Category($osC_Product->getCategoryID());
  142 -
  143 -          $history[] = array('name' => $osC_Product->getTitle(),
  144 -                             'id' => $osC_Product->getID(),
  145 -                             'keyword' => $osC_Product->getKeyword(),
  146 -                             'price' => (SERVICE_RECENTLY_VISITED_SHOW_PRODUCT_PRICES == 'True') ? $osC_Product->getPriceFormated(true) : '',
  147 -                             'image' => $osC_Product->getImage(),
  148 -                             'category_name' =>  $osC_Category->getTitle(),
  149 -                             'category_path' => $osC_Category->getPath()
  150 -                            );
  151 -
  152 -          if ($counter == SERVICE_RECENTLY_VISITED_MAX_PRODUCTS) {
  153 -            break;
  154 -          }
  155 -        }
  156 -      }
  157 -
  158 -      return $history;
  159 -    }
  160 -
  161 -    function hasCategories() {
  162 -      if (isset($this->visits['categories']) && (empty($this->visits['categories']) === false)) {
  163 -        return true;
  164 -      }
  165 -
  166 -      return false;
  167 -    }
  168 -
  169 -    function getCategories() {
  170 -      $history = array();
  171 -
  172 -      if (isset($this->visits['categories']) && (empty($this->visits['categories']) === false)) {
  173 -        $counter = 0;
  174 -
  175 -        foreach ($this->visits['categories'] as $k => $v) {
  176 -          $counter++;
  177 -
  178 -          $osC_Category = new osC_Category($v['id']);
  179 -
  180 -          if ($osC_Category->hasParent()) {
  181 -            $osC_CategoryParent = new osC_Category($osC_Category->getParent());
  182 -          }
  183 -
  184 -          $history[]  = array('id' => $osC_Category->getID(),
  185 -                              'name' => $osC_Category->getTitle(),
  186 -                              'path' => $osC_Category->getPath(),
  187 -                              'image' => $osC_Category->getImage(),
  188 -                              'parent_name' => ($osC_Category->hasParent()) ? $osC_CategoryParent->getTitle() : '',
  189 -                              'parent_id' => ($osC_Category->hasParent()) ? $osC_CategoryParent->getID() : ''
  190 -                             );
  191 -
  192 -          if ($counter == SERVICE_RECENTLY_VISITED_MAX_CATEGORIES) {
  193 -            break;
  194 -          }
  195 -        }
  196 -      }
  197 -
  198 -      return $history;
  199 -    }
  200 -
  201 -    function hasSearches() {
  202 -      if (isset($this->visits['searches']) && (empty($this->visits['searches']) === false)) {
  203 -        return true;
  204 -      }
  205 -
  206 -      return false;
  207 -    }
  208 -
  209 -    function getSearches() {
  210 -      $history = array();
  211 -
  212 -      if (isset($this->visits['searches']) && (empty($this->visits['searches']) === false)) {
  213 -        $counter = 0;
  214 -
  215 -        foreach ($this->visits['searches'] as $k => $v) {
  216 -          $counter++;
  217 -
  218 -          $history[]  = array('keywords' => $this->visits['searches'][$k]['keywords'],
  219 -                              'results' => $this->visits['searches'][$k]['results']
  220 -                             );
  221 -
  222 -          if ($counter == SERVICE_RECENTLY_VISITED_MAX_SEARCHES) {
  223 -            break;
  224 -          }
  225 -        }
  226 -      }
  227 -
  228 -      return $history;
  229 -    }
<_ 23039   }
  23140 ?>