/** * Public function that creates a single instance */ public static function getInstance($parent) { if (!isset(self::$_instance)) { self::$_instance = new self($parent); } return self::$_instance; }
/** * Transfers control to module functions * * @param array $params * @param array $children */ public function transferControl($params, $children) { // global control actions if (isset($params['action'])) { switch ($params['action']) { case 'show_item': $handler = ShopItemHandler::getInstance($this); $handler->tag_Item($params, $children); break; case 'show_item_list': $handler = ShopItemHandler::getInstance($this); $handler->tag_ItemList($params, $children); break; case 'show_category': $handler = ShopCategoryHandler::getInstance($this); $handler->tag_Category($params, $children); break; case 'show_category_list': $handler = ShopCategoryHandler::getInstance($this); $handler->tag_CategoryList($params, $children); break; case 'show_completed_message': $this->tag_CompletedMessage($params, $children); break; case 'show_canceled_message': $this->tag_CanceledMessage($params, $children); break; case 'show_checkout_form': $this->tag_CheckoutForm($params, $children); break; case 'show_payment_methods': $this->tag_PaymentMethodsList($params, $children); break; case 'show_recurring_plan': $this->tag_RecurringPlan($params, $children); break; case 'configure_search': $this->configureSearch($params, $children); break; case 'checkout': $this->showCheckout(); break; case 'checkout_completed': $this->showCheckoutCompleted(); break; case 'checkout_canceled': $this->showCheckoutCanceled(); break; case 'show_checkout_items': $this->tag_CheckoutItems($params, $children); break; case 'set_item_as_cart': $this->setItemAsCart($params, $children); break; case 'set_cart_from_template': $this->setCartFromTemplate($params, $children); break; case 'set_recurring_plan': $this->setRecurringPlan($params, $children); break; case 'cancel_recurring_plan': $this->cancelRecurringPlan($params, $children); break; case 'include_scripts': $this->includeScripts($params, $children); break; case 'json_get_item': $handler = ShopItemHandler::getInstance($this); $handler->json_GetItem(); break; case 'json_get_currency': $this->json_GetCurrency(); break; case 'json_get_account_info': $this->json_GetAccountInfo(); break; case 'json_get_account_exists': $this->json_GetAccountExists(); break; case 'json_get_payment_methods': $this->json_GetPaymentMethods(); break; case 'json_add_item_to_shopping_cart': $this->json_AddItemToCart(); break; case 'json_remove_item_from_shopping_cart': $this->json_RemoveItemFromCart(); break; case 'json_change_item_quantity': $this->json_ChangeItemQuantity(); break; case 'json_clear_shopping_cart': $this->json_ClearCart(); break; case 'json_get_shopping_cart': $this->json_ShowCart(); break; case 'json_update_transaction_status': $handler = ShopTransactionsHandler::getInstance($this); $handler->json_UpdateTransactionStatus(); break; case 'json_get_shopping_cart_summary': $this->json_GetShoppingCartSummary(); break; case 'json_save_remark': $this->json_SaveRemark(); break; default: break; } } // global control actions if (isset($params['backend_action'])) { $action = $params['backend_action']; switch ($action) { case 'items': $handler = ShopItemHandler::getInstance($this); $handler->transferControl($params, $children); break; case 'currencies': $handler = ShopCurrenciesHandler::getInstance($this); $handler->transferControl($params, $children); break; case 'categories': $handler = ShopCategoryHandler::getInstance($this); $handler->transferControl($params, $children); break; case 'sizes': $handler = ShopItemSizesHandler::getInstance($this); $handler->transferControl($params, $children); break; case 'transactions': $handler = ShopTransactionsHandler::getInstance($this); $handler->transferControl($params, $children); break; case 'manufacturers': $handler = ShopManufacturerHandler::getInstance($this); $handler->transferControl($params, $children); break; case 'special_offers': break; case 'warehouses': $handler = ShopWarehouseHandler::getInstance($this); $handler->transferControl($params, $children); break; case 'stocks': break; case 'settings': $this->showSettings(); break; case 'settings_save': $this->saveSettings(); break; default: break; } } }