Skip to content
Browse files

Merge branch 'bd789ffebd46e719aedb'

  • Loading branch information...
2 parents 170c689 + bd789ff commit f3c56fee3184dfff0c5c7d96ace58dd7fcc940ef @dannyhenderson dannyhenderson committed Apr 6, 2011
View
14 osCommerce/OM/Core/ErrorHandler.php
@@ -8,6 +8,7 @@
namespace osCommerce\OM\Core;
+ use osCommerce\OM\Core\DateTime;
use osCommerce\OM\Core\OSCOM;
use osCommerce\OM\Core\PDO;
@@ -66,9 +67,18 @@ public static function execute($errno, $errstr, $errfile, $errline) {
}
public static function connect() {
- self::$_dbh = PDO::initialize(OSCOM::BASE_DIRECTORY . 'Work/Database/errors.sqlite3', null, null, null, null, 'SQLite3');
+ $result = false;
- return self::$_dbh->exec('create table if not exists error_log ( timestamp int, message text );');
+ try {
+ self::$_dbh = PDO::initialize(OSCOM::BASE_DIRECTORY . 'Work/Database/errors.sqlite3', null, null, null, null, 'SQLite3');
+ self::$_dbh->exec('create table if not exists error_log ( timestamp int, message text );');
+
+ $result = true;
+ } catch ( \Exception $e ) {
+ trigger_error($e->getMessage());
+ }
+
+ return $result;
}
public static function getAll($limit = null, $pageset = null) {
View
200 osCommerce/OM/Core/Site/Shop/NavigationHistory.php
@@ -11,149 +11,235 @@
use osCommerce\OM\Core\OSCOM;
use osCommerce\OM\Core\Registry;
+/**
+ * @since v3.0.0
+ */
+
class NavigationHistory {
+
+/**
+ * @since v3.0.0
+ */
+
protected $_data = array();
+
+/**
+ * @since v3.0.0
+ */
+
protected $_snapshot = array();
+/**
+ * @since v3.0.0
+ */
+
public function __construct($add_current_page = false) {
- if ( isset($_SESSION['osC_NavigationHistory_data']) && is_array($_SESSION['osC_NavigationHistory_data']) && !empty($_SESSION['osC_NavigationHistory_data']) ) {
- $this->_data =& $_SESSION['osC_NavigationHistory_data'];
+ if ( isset($_SESSION[OSCOM::getSite()]['NavigationHistory']['data']) && is_array($_SESSION[OSCOM::getSite()]['NavigationHistory']['data']) && !empty($_SESSION[OSCOM::getSite()]['NavigationHistory']['data']) ) {
+ $this->_data =& $_SESSION[OSCOM::getSite()]['NavigationHistory']['data'];
}
- if ( isset($_SESSION['osC_NavigationHistory_snapshot']) && is_array($_SESSION['osC_NavigationHistory_snapshot']) && !empty($_SESSION['osC_NavigationHistory_snapshot']) ) {
- $this->_snapshot =& $_SESSION['osC_NavigationHistory_snapshot'];
+ if ( isset($_SESSION[OSCOM::getSite()]['NavigationHistory']['snapshot']) && is_array($_SESSION[OSCOM::getSite()]['NavigationHistory']['snapshot']) && !empty($_SESSION[OSCOM::getSite()]['NavigationHistory']['snapshot']) ) {
+ $this->_snapshot =& $_SESSION[OSCOM::getSite()]['NavigationHistory']['snapshot'];
}
if ( $add_current_page === true ) {
$this->addCurrentPage();
}
}
+/**
+ * @since v3.0.0
+ */
+
public function addCurrentPage() {
- $set = 'true';
+ $action_counter = 0;
+ $application_key = null;
+ $action = array();
+
+ foreach ( $_GET as $key => $value ) {
+ if ( !isset($application_key) && ($key == OSCOM::getSiteApplication()) ) {
+ $application_key = $action_counter;
+
+ $action_counter++;
+
+ continue;
+ }
+
+ $action[] = array($key => $value);
+
+ if ( $this->siteApplicationActionExists(implode('\\', array_keys($action))) === false ) {
+ array_pop($action);
+
+ break;
+ }
+
+ $action_counter++;
+ }
+
+ $action_get = http_build_query($action);
for ( $i=0, $n=sizeof($this->_data); $i<$n; $i++ ) {
- if ( $this->_data[$i]['page'] == basename($_SERVER['SCRIPT_FILENAME']) ) {
+ if ( ($this->_data[$i]['application'] == OSCOM::getSiteApplication()) && ($this->_data[$i]['action'] == $action_get) ) {
array_splice($this->_data, $i);
- $set = 'true';
break;
}
}
- if ( $set == 'true' ) {
- $this->_data[] = array('page' => basename($_SERVER['SCRIPT_FILENAME']),
- 'mode' => OSCOM::getRequestType(),
- 'get' => $_GET,
- 'post' => $_POST);
+ $this->_data[] = array('application' => OSCOM::getSiteApplication(),
+ 'action' => $action_get,
+ 'mode' => OSCOM::getRequestType(),
+ 'get' => array_slice($_GET, $action_counter),
+ 'post' => $_POST);
- if ( !isset($_SESSION['osC_NavigationHistory_data']) ) {
- $_SESSION['osC_NavigationHistory_data'] = $this->_data;
- }
+ if ( !isset($_SESSION[OSCOM::getSite()]['NavigationHistory']['data']) ) {
+ $_SESSION[OSCOM::getSite()]['NavigationHistory']['data'] = $this->_data;
}
}
- function removeCurrentPage() {
- $last_entry_position = sizeof($this->_data) - 1;
+/**
+ * @since v3.0.0
+ */
- if ( $this->_data[$last_entry_position]['page'] == basename($_SERVER['SCRIPT_FILENAME']) ) {
- unset($this->_data[$last_entry_position]);
+ public function removeCurrentPage() {
+ array_pop($this->_data);
- if ( sizeof($this->_data) > 0 ) {
- if ( !isset($_SESSION['osC_NavigationHistory_data']) ) {
- $_SESSION['osC_NavigationHistory_data'] = $this->_data;
- }
- } else {
- $this->resetPath();
- }
+ if ( empty($this->_data) ) {
+ $this->resetPath();
}
}
- function hasPath($back = 1) {
+/**
+ * @since v3.0.0
+ */
+
+ public function hasPath($back = 1) {
if ( (is_numeric($back) === false) || (is_numeric($back) && ($back < 1)) ) {
$back = 1;
}
- return isset($this->_data[sizeof($this->_data) - $back]);
+ return isset($this->_data[count($this->_data) - $back]);
}
- function getPathURL($back = 1, $exclude = array()) {
+/**
+ * @since v3.0.0
+ */
+
+ public function getPathURL($back = 1, $exclude = array()) {
if ( (is_numeric($back) === false) || (is_numeric($back) && ($back < 1)) ) {
$back = 1;
}
- $back = sizeof($this->_data) - $back;
+ $back = count($this->_data) - $back;
- return OSCOM::getLink(null, null, $this->_parseParameters($this->_data[$back]['get'], $exclude), $this->_data[$back]['mode']);
+ return OSCOM::getLink(null, $this->_data[$back]['application'], $this->_data[$back]['action'] . '&' . $this->parseParameters($this->_data[$back]['get'], $exclude), $this->_data[$back]['mode']);
}
- function setSnapshot($page = '') {
- if ( is_array($page) ) {
- $this->_snapshot = array('page' => $page['page'],
+/**
+ * @since v3.0.0
+ */
+
+ public function setSnapshot($page = null) {
+ if ( isset($page) && is_array($page) ) {
+ $this->_snapshot = array('application' => $page['application'],
+ 'action' => $page['action'],
'mode' => $page['mode'],
'get' => $page['get'],
'post' => $page['post']);
} else {
- $this->_snapshot = array('page' => basename($_SERVER['SCRIPT_FILENAME']),
- 'mode' => OSCOM::getRequestType(),
- 'get' => $_GET,
- 'post' => $_POST);
+ $this->_snapshot = $this->_data[count($this->_data) - 1];
}
- if ( !isset($_SESSION['osC_NavigationHistory_snapshot']) ) {
- $_SESSION['osC_NavigationHistory_snapshot'] = $this->_snapshot;
+ if ( !isset($_SESSION[OSCOM::getSite()]['NavigationHistory']['snapshot']) ) {
+ $_SESSION[OSCOM::getSite()]['NavigationHistory']['snapshot'] = $this->_snapshot;
}
}
- function hasSnapshot() {
+/**
+ * @since v3.0.0
+ */
+
+ public function hasSnapshot() {
return !empty($this->_snapshot);
}
- function getSnapshot($key) {
+/**
+ * @since v3.0.0
+ */
+
+ public function getSnapshot($key) {
if ( isset($this->_snapshot[$key]) ) {
return $this->_snapshot[$key];
}
}
- function getSnapshotURL($auto_mode = false) {
+/**
+ * @since v3.0.0
+ */
+
+ public function getSnapshotURL($auto_mode = false) {
if ( $this->hasSnapshot() ) {
- $target = OSCOM::getLink(null, null, $this->_parseParameters($this->_snapshot['get']), ($auto_mode === true) ? 'AUTO' : $this->_snapshot['mode']);
+ $target = OSCOM::getLink(null, $this->_snapshot['application'], $this->_snapshot['action'] . '&' . $this->parseParameters($this->_snapshot['get']), ($auto_mode === true) ? 'AUTO' : $this->_snapshot['mode']);
} else {
$target = OSCOM::getLink(null, null, null, ($auto_mode === true) ? 'AUTO' : $this->_snapshot['mode']);
}
return $target;
}
- function redirectToSnapshot() {
+/**
+ * @since v3.0.0
+ */
+
+ public function redirectToSnapshot() {
$target = $this->getSnapshotURL(true);
$this->resetSnapshot();
OSCOM::redirect($target);
}
- function resetPath() {
+/**
+ * @since v3.0.0
+ */
+
+ public function resetPath() {
$this->_data = array();
- if ( isset($_SESSION['osC_NavigationHistory_data']) ) {
- unset($_SESSION['osC_NavigationHistory_data']);
+ if ( isset($_SESSION[OSCOM::getSite()]['NavigationHistory']['data']) ) {
+ unset($_SESSION[OSCOM::getSite()]['NavigationHistory']['data']);
}
}
- function resetSnapshot() {
+/**
+ * @since v3.0.0
+ */
+
+ public function resetSnapshot() {
$this->_snapshot = array();
- if ( isset($_SESSION['osC_NavigationHistory_snapshot']) ) {
- unset($_SESSION['osC_NavigationHistory_snapshot']);
+ if ( isset($_SESSION[OSCOM::getSite()]['NavigationHistory']['snapshot']) ) {
+ unset($_SESSION[OSCOM::getSite()]['NavigationHistory']['snapshot']);
}
}
- function reset() {
+/**
+ * @since v3.0.0
+ */
+
+ public function reset() {
$this->resetPath();
$this->resetSnapshot();
+
+ if ( isset($_SESSION[OSCOM::getSite()]['NavigationHistory']) ) {
+ unset($_SESSION[OSCOM::getSite()]['NavigationHistory']);
+ }
}
- function _parseParameters($array, $additional_exclude = array()) {
+/**
+ * @since v3.0.1
+ */
+
+ protected function parseParameters($array, $additional_exclude = array()) {
$exclude = array('x', 'y', Registry::get('Session')->getName());
if ( is_array($additional_exclude) && !empty($additional_exclude) ) {
@@ -174,5 +260,13 @@ function _parseParameters($array, $additional_exclude = array()) {
return $string;
}
+
+/**
+ * @since v3.0.1
+ */
+
+ protected function siteApplicationActionExists($action) {
+ return class_exists('osCommerce\\OM\\Core\\Site\\Shop\\Application\\' . OSCOM::getSiteApplication() . '\\Action\\' . $action);
+ }
}
?>
View
33 osCommerce/OM/Core/Site/Shop/Product.php
@@ -26,24 +26,19 @@ public function __construct($id) {
$Qproduct->bindInt(':products_status', 1);
$Qproduct->execute();
- $result = $Qproduct->fetch();
+ if ( $Qproduct->fetch() !== false ) {
+ $this->_data = $Qproduct->toArray();
- if ( !empty($result) ) {
- $this->_data = $result;
+ $this->_data['master_id'] = $Qproduct->valueInt('id');
- $this->_data['master_id'] = $result['id'];
-
- if ( $result['parent_id'] > 0 ) {
+ if ( $Qproduct->valueInt('parent_id') > 0 ) {
$Qmaster = $OSCOM_PDO->prepare('select products_id, has_children from :table_products where products_id = :products_id and products_status = :products_status');
- $Qmaster->bindInt(':products_id', $result['parent_id']);
+ $Qmaster->bindInt(':products_id', $Qproduct->valueInt('parent_id'));
$Qmaster->bindInt(':products_status', 1);
$Qmaster->execute();
- $result = $Qmaster->fetch();
-
- if ( !empty($result) ) {
- $this->_data['master_id'] = $result['products_id'];
- $this->_data['has_children'] = $result['has_children'];
+ if ( $Qmaster->fetch() !== false ) {
+ $this->_data['master_id'] = $Qmaster->valueInt('products_id');
} else { // master product is disabled so invalidate the product variant
$this->_data = array();
}
@@ -65,12 +60,10 @@ public function __construct($id) {
$Qproduct->bindInt(':products_status', 1);
$Qproduct->execute();
- $result = $Qproduct->fetch();
-
- if ( !empty($result) ) {
- $this->_data = $result;
+ if ( $Qproduct->fetch() !== false ) {
+ $this->_data = $Qproduct->toArray();
- $this->_data['master_id'] = $result['id'];
+ $this->_data['master_id'] = $Qproduct->valueInt('id');
}
}
@@ -116,10 +109,10 @@ public function __construct($id) {
'weight_class_id' => $Qsubproducts->valueInt('products_weight_class'),
'availability_shipping' => 1);
- $Qvariants = $OSCOM_PDO->prepare('select pv.default_combo, pvg.id as group_id, pvg.title as group_title, pvg.module, pvv.id as value_id, pvv.title as value_title, pvv.sort_order as value_sort_order from :table_products_variants pv, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.products_variants_values_id = pvv.id and pvv.languages_id = :languages_id and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id order by pvg.sort_order, pvg.title');
+ $Qvariants = $OSCOM_PDO->prepare('select pv.default_combo, pvg.id as group_id, pvg.title as group_title, pvg.module, pvv.id as value_id, pvv.title as value_title, pvv.sort_order as value_sort_order from :table_products_variants pv, :table_products_variants_groups pvg, :table_products_variants_values pvv where pv.products_id = :products_id and pv.products_variants_values_id = pvv.id and pvv.languages_id = :languages_id_pvv and pvv.products_variants_groups_id = pvg.id and pvg.languages_id = :languages_id_pvg order by pvg.sort_order, pvg.title');
$Qvariants->bindInt(':products_id', $Qsubproducts->valueInt('products_id'));
- $Qvariants->bindInt(':languages_id', $OSCOM_Language->getID());
- $Qvariants->bindInt(':languages_id', $OSCOM_Language->getID());
+ $Qvariants->bindInt(':languages_id_pvv', $OSCOM_Language->getID());
+ $Qvariants->bindInt(':languages_id_pvg', $OSCOM_Language->getID());
$Qvariants->execute();
while ( $Qvariants->fetch() ) {
View
2 osCommerce/OM/Core/Site/Shop/ShoppingCart.php
@@ -416,7 +416,7 @@ public function getQuantity($item_id) {
public function exists($product_id) {
foreach ( $this->_contents as $product ) {
- if ( $product['id'] === $product_id ) {
+ if ( $product['id'] == $product_id ) {
if ( isset($product['variants']) ) {
foreach ( $product['variants'] as $variant ) {
if ( $variant['has_custom_value'] === true ) {

0 comments on commit f3c56fe

Please sign in to comment.
Something went wrong with that request. Please try again.