/**
  * Public function that creates a single instance
  */
 public static function getInstance($parent)
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self($parent);
     }
     return self::$_instance;
 }
Example #2
0
 /**
  * Show form for editing existing shop item
  */
 private function changeItem()
 {
     $id = fix_id($_REQUEST['id']);
     $manager = ShopItemManager::getInstance();
     $item = $manager->getSingleItem($manager->getFieldNames(), array('id' => $id));
     if (is_object($item)) {
         // create template
         $template = new TemplateHandler('item_change.xml', $this->path . 'templates/');
         $template->setMappedModule($this->name);
         // register tag handlers
         $category_handler = ShopCategoryHandler::getInstance($this->_parent);
         $template->registerTagHandler('_category_list', $category_handler, 'tag_CategoryList');
         $size_handler = ShopItemSizesHandler::getInstance($this->_parent);
         $template->registerTagHandler('_size_list', $size_handler, 'tag_SizeList');
         $manufacturer_handler = ShopManufacturerHandler::getInstance($this->_parent);
         $template->registerTagHandler('_manufacturer_list', $manufacturer_handler, 'tag_ManufacturerList');
         $delivery_handler = ShopDeliveryMethodsHandler::getInstance($this->_parent);
         $template->registerTagHandler('_delivery_methods', $delivery_handler, 'tag_DeliveryMethodsList');
         $template->registerTagHandler('_item_list', $this, 'tag_ItemList');
         // prepare parameters
         $params = array('id' => $item->id, 'uid' => $item->uid, 'name' => $item->name, 'description' => $item->description, 'gallery' => $item->gallery, 'manufacturer' => $item->manufacturer, 'size_definition' => $item->size_definition, 'author' => $item->author, 'views' => $item->views, 'price' => $item->price, 'colors' => $item->colors, 'tax' => $item->tax, 'weight' => $item->weight, 'votes_up' => $item->votes_up, 'votes_down' => $item->votes_down, 'priority' => $item->priority, 'timestamp' => $item->timestamp, 'visible' => $item->visible, 'deleted' => $item->deleted, 'form_action' => backend_UrlMake($this->name, 'items', 'save'), 'cancel_action' => window_Close('shop_item_change'));
         // parse template
         $template->restoreXML();
         $template->setLocalParams($params);
         $template->parse();
     }
 }
Example #3
0
 /**
  * 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;
         }
     }
 }