Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace:

Diff

297
 
298
 
298
 
recently_visited.php
_> 2424     }
  2525 
  2626     function contentModuleInitialize() {
<> 27 -      global $osC_Product;
   27+      global $osC_Product, $osC_Category, $osC_Search;
2828 
  2929       if (isset($osC_Product) && is_a($osC_Product, 'osC_Product')) {
  3030         $this->setProduct($osC_Product->getID());
  3131       }
  3232 
  3333       if (SERVICE_RECENTLY_VISITED_SHOW_CATEGORIES == 'True') {
<> 34 -        $this->setCategory();
   34+        if (isset($osC_Category) && is_a($osC_Category, 'osC_Category')) {
   35+          $this->setCategory($osC_Category->getID());
   36+        }
3537       }
  3638 
  3739       if (SERVICE_RECENTLY_VISITED_SHOW_SEARCHES == 'True') {
<> 38 -        $this->setSearchQuery();
   40+        if (isset($osC_Search) && is_a($osC_Search, 'osC_Search')) {
   41+          if ($osC_Search->hasKeywords()) {
   42+            $this->setSearchQuery($osC_Search->getKeywords());
   43+          }
   44+        }
3945       }
  4046     }
  4147 
  4248     function getContentModule() {
  4349       return 'recently_visited.php';
  4450     }
  4551 
<> 46 -   function setProduct($id) {
  47 -     foreach ($this->visits['products'] as $key => $value) {
  48 -      if ($this->visits['products'][$key]['products_id'] == $id) {
  49 -       unset($this->visits['products'][$key]);
  50 -       break;
   52+    function setProduct($id) {
   53+      if (isset($this->visits['products'])) {
   54+        foreach ($this->visits['products'] as $key => $value) {
   55+          if ($value['id'] == $id) {
   56+            unset($this->visits['products'][$key]);
   57+            break;
   58+          }
   59+        }
   60+
   61+        if (sizeof($this->visits['products']) > (MAX_RECENTLY_VISITED_PRODUCTS * 2)) {
   62+          array_pop($this->visits['products']);
   63+        }
   64+      } else {
   65+        $this->visits['products'] = array();
5166       }
<> 52 -     }
5367 
<> 54 -     if (sizeof($this->visits['products']) >= MAX_RECENTLY_VISITED_PRODUCTS+3) {
  55 -      $keys = array_keys($this->visits['products']);
  56 -      unset($this->visits['products'][$keys[0]]);
  57 -      $this->debug[] = 'unsetted ' . $keys[0];
  58 -     }
   68+      array_unshift($this->visits['products'], array('id' => $id));
   69+    }
5970 
<> 60 -     if (SERVICE_RECENTLY_VISITED_ORIGINAL_PAGE == 'True') {
  61 -      $this->visits['products'][] = array('products_id' => $id,
  62 -                                          'page_name' => basename($_SERVER['PHP_SELF']),
  63 -                                          'get_params' => tep_array_to_string($_GET, array($osC_Session->name, 'action', 'products_id'))
  64 -                                         );
  65 -     } else {
  66 -      $this->visits['products'][] = array('products_id' => $id);
  67 -     }
  68 -   }
   71+    function setCategory($id) {
   72+      if (isset($this->visits['categories'])) {
   73+        foreach ($this->visits['categories'] as $key => $value) {
   74+          if ($value['id'] == $id) {
   75+            unset($this->visits['categories'][$key]);
   76+            break;
   77+          }
   78+        }
6979 
<> 70 -   function setCategory() {
  71 -    if (!empty($_GET['cPath'])) {
   80+        if (sizeof($this->visits['categories']) > (MAX_RECENTLY_VISITED_CATEGORIES * 2)) {
   81+          array_pop($this->visits['categories']);
   82+        }
   83+      } else {
   84+        $this->visits['categories'] = array();
   85+      }
7286 
<> 73 -     $cpath = $_GET['cPath'];
   87+      array_unshift($this->visits['categories'], array('id' => $id));
   88+    }
7489 
<> 75 -     foreach ($this->visits['categories'] as $key => $value) {
  76 -      if ($this->visits['categories'][$key]['cpath'] == $cpath) {
  77 -       unset($this->visits['categories'][$key]);
  78 -       break;
  79 -      }
  80 -     }
   90+    function setSearchQuery($keywords) {
   91+      global $osC_Search;
8192 
<> 82 -     if (sizeof($this->visits['categories']) >= MAX_RECENTLY_VISITED_CATEGORIES+3) {
  83 -      $keys = array_keys($this->visits['categories']);
  84 -      unset($this->visits['categories'][$keys[0]]);
  85 -     }
   93+      if (isset($this->visits['searches'])) {
   94+        foreach ($this->visits['searches'] as $key => $value) {
   95+          if ($value['keywords'] == $keywords) {
   96+            unset($this->visits['searches'][$key]);
   97+            break;
   98+          }
   99+        }
86100 
<> 87 -      $this->visits['categories'][] = array('cpath' => $cpath);
   101+        if (sizeof($this->visits['searches']) > (MAX_RECENTLY_VISITED_SEARCHES * 2)) {
   102+          array_pop($this->visits['searches']);
   103+        }
   104+      } else {
   105+        $this->visits['searches'] = array();
   106+      }
88107 
<>  108+      array_unshift($this->visits['searches'], array('keywords' => $keywords,
   109+                                                     'results' => $osC_Search->getNumberOfResults()
   110+                                                    ));
89111     }
<> 90 -   }
91112 
<> 92 -   function setSearchQuery() {
  93 -    if (!empty($_GET['keywords'])) {
   113+    function hasHistory() {
   114+      if ($this->hasProducts() || $this->hasCategories() || $this->hasSearches()) {
   115+        return true;
   116+      }
94117 
<> 95 -     $keywords = $_GET['keywords'];
   118+      return false;
   119+    }
96120 
<> 97 -     foreach ($this->visits['searches'] as $key => $value) {
  98 -      if ($this->visits['searches'][$key]['keywords'] == $keywords) {
  99 -       unset($this->visits['searches'][$key]);
  100 -       break;
   121+    function hasProducts() {
   122+      if (isset($this->visits['products']) && (empty($this->visits['products']) === false)) {
   123+        return true;
101124       }
<> 102 -     }
103125 
<> 104 -     if (sizeof($this->visits['searches']) >= MAX_RECENTLY_VISITED_SEARCHES+3) {
  105 -      $keys = array_keys($this->visits['searches']);
  106 -      unset($this->visits['searches'][$keys[0]]);
  107 -     }
  108 -     $this->visits['searches'][] = array('keywords' => $keywords,
  109 -                                         'get_params' => tep_array_to_string($_GET, array($osC_Session->name, 'keywords')));
   126+      return false;
110127     }
<> 111 -   }
112128 
<> 113 -   function hasCategories() {
  114 -     if (isset($this->visits['categories']) && (empty($this->visits['categories']) === false)) {
  115 -       return true;
  116 -     }
   129+    function getProducts() {
   130+      global $osC_Database, $osC_Services, $osC_Currencies, $osC_Specials;
117131 
<> 118 -     return false;
  119 -   }
   132+      $history = array();
120133 
<> 121 -   function getCategories() {
  122 -     global $osC_Database;
   134+      if (isset($this->visits['products']) && (empty($this->visits['products']) === false)) {
   135+        $counter = 0;
123136 
<> 124 -     $history = array();
   137+        foreach ($this->visits['products'] as $k => $v) {
   138+          $counter++;
125139 
<> 126 -     if (isset($this->visits['categories']) && (empty($this->visits['categories']) === false)) {
  127 -       foreach ($this->visits['categories'] as $k => $v) {
  128 -         $parts = explode("_", $this->visits['categories'][$k]['cpath']);
   140+          $cpath = tep_get_product_path($this->visits['products'][$k]['id']);
   141+          $parts = explode("_", $cpath);
   142+          $cat_id =  $parts[sizeof($parts)-1];
129143 
<> 130 -         if (sizeof($parts) > 1) {
  131 -           $Qpcategory = $osC_Database->query('select categories_name, categories_id from :table_categories_description where categories_id = :categories_id and  language_id = :language_id');
  132 -           $Qpcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
  133 -           $Qpcategory->bindInt(':categories_id', $parts[0]);
  134 -           $Qpcategory->bindInt(':language_id', $_SESSION['languages_id']);
  135 -           $Qpcategory->execute();
   144+          $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and  language_id = :language_id');
   145+          $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
   146+          $Qcategory->bindInt(':categories_id', $cat_id);
   147+          $Qcategory->bindInt(':language_id', $_SESSION['languages_id']);
   148+          $Qcategory->execute();
136149 
<> 137 -           $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and  language_id = :language_id');
  138 -           $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
  139 -           $Qcategory->bindInt(':categories_id', $parts[sizeof($parts)-1]);
  140 -           $Qcategory->bindInt(':language_id', $_SESSION['languages_id']);
  141 -           $Qcategory->execute();
  142 -         } else {
  143 -           $Qpcategory = false;
   150+          $products_name = tep_get_products_name($this->visits['products'][$k]['id']);
144151 
<> 145 -           $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and  language_id = :language_id');
  146 -           $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
  147 -           $Qcategory->bindInt(':categories_id', $parts[0]);
  148 -           $Qcategory->bindInt(':language_id', $_SESSION['languages_id']);
  149 -           $Qcategory->execute();
  150 -         }
   152+          if ( (SERVICE_RECENTLY_VISITED_SHOW_IMAGE == 'True') or (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') ) {
   153+            $Qproduct = $osC_Database->query('select products_price, products_tax_class_id, products_image from :table_products where products_status = 1 and products_id = :products_id');
   154+            $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
   155+            $Qproduct->bindInt(':products_id', $this->visits['products'][$k]['id']);
   156+            $Qproduct->execute();
151157 
<> 152 -         $history[]  = array('parents_name' => ($Qpcategory) ? $Qpcategory->value('categories_name') : '',
  153 -                             'parents_id' => ($Qpcategory) ? $Qpcategory->value('categories_id') : '',
  154 -                             'category_name' => $Qcategory->value('categories_name'),
  155 -                             'category_id' => $this->visits['categories'][$k]['cpath']
   158+            if (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') {
   159+              if ( ($osC_Services->isStarted('specials')) && ($new_price = $osC_Specials->getPrice($this->visits['products'][$k]['id'])) ) {
   160+                $products_price = '<s>' . $osC_Currencies->displayPrice($Qproduct->value('products_price'), $Qproduct->valueInt('products_tax_class_id')) . '</s> <span class="productSpecialPrice">' . $osC_Currencies->displayPrice($new_price, $Qproduct->valueInt('products_tax_class_id')) . '</span>';
   161+              } else {
   162+                $products_price = $osC_Currencies->displayPrice($Qproduct->value('products_price'), $Qproduct->valueInt('products_tax_class_id'));
   163+              }
   164+            }
   165+          }
   166+
   167+          $history[] = array('name' => $products_name,
   168+                             'page' => ($this->visits['products'][$k]['page_name']) ? $this->visits['products'][$k]['page_name'] : FILENAME_DEFAULT,
   169+                             'id' => $this->visits['products'][$k]['id'],
   170+                             'get_params' => $this->visits['products'][$k]['get_params'],
   171+                             'price' => (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') ? $products_price : '',
   172+                             'image' => (SERVICE_RECENTLY_VISITED_SHOW_IMAGE == 'True') ? $Qproduct->value('products_image') : '',
   173+                             'category_name' =>  $Qcategory->value('categories_name'),
   174+                             'category_path' => $cpath
156175                             );
<> 157 -       }
158176 
<> 159 -       if (empty($history) === false) {
  160 -         krsort($history);
  161 -         $history = array_slice($history, 0, MAX_RECENTLY_VISITED_CATEGORIES);
  162 -       }
  163 -     }
   177+          if ($counter == MAX_RECENTLY_VISITED_PRODUCTS) {
   178+            break;
   179+          }
   180+        }
   181+      }
164182 
<> 165 -     return $history;
  166 -   }
   183+      return $history;
   184+    }
167185 
<> 168 -   function hasProducts() {
  169 -     if (isset($this->visits['products']) && (empty($this->visits['products']) === false)) {
  170 -       return true;
  171 -     }
   186+    function hasCategories() {
   187+      if (isset($this->visits['categories']) && (empty($this->visits['categories']) === false)) {
   188+        return true;
   189+      }
172190 
<> 173 -     return false;
  174 -   }
   191+      return false;
   192+    }
175193 
<> 176 -   function getProducts() {
  177 -     global $osC_Database, $osC_Services, $osC_Currencies, $osC_Specials;
   194+    function getCategories() {
   195+      global $osC_Database;
178196 
<> 179 -     $history = array();
   197+      $history = array();
180198 
<> 181 -     if (isset($this->visits['products']) && (empty($this->visits['products']) === false)) {
  182 -       foreach ($this->visits['products'] as $k => $v) {
  183 -         $cpath = tep_get_product_path($this->visits['products'][$k]['products_id']);
  184 -         $parts = explode("_", $cpath);
  185 -         $cat_id =  $parts[sizeof($parts)-1];
   199+      if (isset($this->visits['categories']) && (empty($this->visits['categories']) === false)) {
   200+        $osC_CategoryTree = new osC_CategoryTree();
186201 
<> 187 -         $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and  language_id = :language_id');
  188 -         $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
  189 -         $Qcategory->bindInt(':categories_id', $cat_id);
  190 -         $Qcategory->bindInt(':language_id', $_SESSION['languages_id']);
  191 -         $Qcategory->execute();
   202+        $counter = 0;
192203 
<> 193 -         $products_name = tep_get_products_name($this->visits['products'][$k]['products_id']);
   204+        foreach ($this->visits['categories'] as $k => $v) {
   205+          $counter++;
194206 
<> 195 -         if ( (SERVICE_RECENTLY_VISITED_SHOW_IMAGE == 'True') or (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') ) {
  196 -           $Qproduct = $osC_Database->query('select products_price, products_tax_class_id, products_image from :table_products where products_status = 1 and products_id = :products_id');
  197 -           $Qproduct->bindTable(':table_products', TABLE_PRODUCTS);
  198 -           $Qproduct->bindInt(':products_id', $this->visits['products'][$k]['products_id']);
  199 -           $Qproduct->execute();
   207+          $cpath = $osC_CategoryTree->buildBreadcrumb($this->visits['categories'][$k]['id']);
   208+          $parts = explode("_", $cpath);
200209 
<> 201 -           if (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') {
  202 -             if ( ($osC_Services->isStarted('specials')) && ($new_price = $osC_Specials->getPrice($this->visits['products'][$k]['products_id'])) ) {
  203 -               $products_price = '<s>' . $osC_Currencies->displayPrice($Qproduct->value('products_price'), $Qproduct->valueInt('products_tax_class_id')) . '</s> <span class="productSpecialPrice">' . $osC_Currencies->displayPrice($new_price, $Qproduct->valueInt('products_tax_class_id')) . '</span>';
  204 -             } else {
  205 -               $products_price = $osC_Currencies->displayPrice($Qproduct->value('products_price'), $Qproduct->valueInt('products_tax_class_id'));
  206 -             }
  207 -           }
  208 -         }
   210+          if (sizeof($parts) > 1) {
   211+            $Qpcategory = $osC_Database->query('select categories_name, categories_id from :table_categories_description where categories_id = :categories_id and  language_id = :language_id');
   212+            $Qpcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
   213+            $Qpcategory->bindInt(':categories_id', $parts[0]);
   214+            $Qpcategory->bindInt(':language_id', $_SESSION['languages_id']);
   215+            $Qpcategory->execute();
209216 
<> 210 -         $history[] = array('name' => $products_name,
  211 -                            'page' => ($this->visits['products'][$k]['page_name']) ? $this->visits['products'][$k]['page_name'] : FILENAME_DEFAULT,
  212 -                            'id' => $this->visits['products'][$k]['products_id'],
  213 -                            'get_params' => $this->visits['products'][$k]['get_params'],
  214 -                            'price' => (SERVICE_RECENTLY_VISITED_SHOW_PRICE == 'True') ? $products_price : '',
  215 -                            'image' => (SERVICE_RECENTLY_VISITED_SHOW_IMAGE == 'True') ? $Qproduct->value('products_image') : '',
  216 -                            'category_name' =>  $Qcategory->value('categories_name'),
  217 -                            'category_path' => $cpath
  218 -                           );
  219 -       }
   217+            $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and  language_id = :language_id');
   218+            $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
   219+            $Qcategory->bindInt(':categories_id', $parts[sizeof($parts)-1]);
   220+            $Qcategory->bindInt(':language_id', $_SESSION['languages_id']);
   221+            $Qcategory->execute();
   222+          } else {
   223+            $Qpcategory = false;
220224 
<> 221 -       if (empty($history) === false) {
  222 -         krsort($history);
  223 -         $history = array_slice($history, 0, MAX_RECENTLY_VISITED_PRODUCTS);
  224 -       }
  225 -     }
   225+            $Qcategory = $osC_Database->query('select categories_name from :table_categories_description where categories_id = :categories_id and  language_id = :language_id');
   226+            $Qcategory->bindTable(':table_categories_description', TABLE_CATEGORIES_DESCRIPTION);
   227+            $Qcategory->bindInt(':categories_id', $parts[0]);
   228+            $Qcategory->bindInt(':language_id', $_SESSION['languages_id']);
   229+            $Qcategory->execute();
   230+          }
226231 
<> 227 -     return $history;
  228 -   }
   232+          $history[]  = array('parents_name' => ($Qpcategory) ? $Qpcategory->value('categories_name') : '',
   233+                              'parents_id' => ($Qpcategory) ? $Qpcategory->value('categories_id') : '',
   234+                              'category_name' => $Qcategory->value('categories_name'),
   235+                              'category_id' => $cpath
   236+                             );
229237 
<> 230 -   function hasSearches() {
  231 -     if (isset($this->visits['searches']) && (empty($this->visits['searches']) === false)) {
  232 -       return true;
  233 -     }
   238+          if ($counter == MAX_RECENTLY_VISITED_CATEGORIES) {
   239+            break;
   240+          }
   241+        }
   242+      }
234243 
<> 235 -     return false;
  236 -   }
   244+      return $history;
   245+    }
237246 
<> 238 -   function getSearches() {
  239 -     $history = array();
   247+    function hasSearches() {
   248+      if (isset($this->visits['searches']) && (empty($this->visits['searches']) === false)) {
   249+        return true;
   250+      }
240251 
<> 241 -     if (isset($this->visits['searches']) && (empty($this->visits['searches']) === false)) {
  242 -       foreach ($this->visits['searches'] as $k => $v) {
  243 -         $history[]  = array('keywords' => $this->visits['searches'][$k]['keywords'],                                             'parents_id' => ($Qpcategory) ? $Qpcategory->value('categories_id') : '',
  244 -                             'get_params' => $this->visits['searches'][$k]['get_params']
  245 -                            );
  246 -       }
   252+      return false;
   253+    }
247254 
<> 248 -       if (empty($history) === false) {
  249 -         krsort($history);
  250 -         $history = array_slice($history, 0, MAX_RECENTLY_VISITED_SEARCHES);
  251 -       }
  252 -     }
   255+    function getSearches() {
   256+      $history = array();
253257 
<> 254 -     return $history;
  255 -   }
  256 - }
   258+      if (isset($this->visits['searches']) && (empty($this->visits['searches']) === false)) {
   259+        $counter = 0;
   260+
   261+        foreach ($this->visits['searches'] as $k => $v) {
   262+          $counter++;
   263+
   264+          $history[]  = array('keywords' => $this->visits['searches'][$k]['keywords'],
   265+                              'results' => $this->visits['searches'][$k]['results']
   266+                             );
   267+
   268+          if ($counter == MAX_RECENTLY_VISITED_SEARCHES) {
   269+            break;
   270+          }
   271+        }
   272+      }
   273+
   274+      return $history;
   275+    }
   276+  }
<_ 257277 ?>