/** * Public function that creates a single instance */ public static function getInstance() { if (!isset(self::$_instance)) { self::$_instance = new self(); } return self::$_instance; }
/** * Handle drawing list of delivery method prices * * @param array $tag_params * @param array $children */ public function tag_DeliveryPricesList($tag_params, $children) { $manager = ShopDeliveryMethodPricesManager::getInstance(); $conditions = array(); $relations = array(); // prepare filtering conditions if (isset($tag_params['method'])) { $conditions['method'] = fix_id($tag_params['method']); } if (isset($_REQUEST['method'])) { $conditions['method'] = fix_id($_REQUEST['method']); } // get relations with shop item if (isset($tag_params['item'])) { $relations_manager = ShopDeliveryItemRelationsManager::getInstance(); $item_id = fix_id($tag_params['item']); $raw_relations = $relations_manager->getItems(array('price'), array('item' => $item_id)); if (count($raw_relations) > 0) { foreach ($raw_relations as $relation) { $relations[] = $relation->price; } } } // get template $template = $this->_parent->loadTemplate($tag_params, 'delivery_method_prices_list_item.xml'); // get items from database $items = $manager->getItems($manager->getFieldNames(), $conditions); if (count($items) > 0) { foreach ($items as $item) { $params = array('id' => $item->id, 'value' => $item->value, 'method' => isset($conditions['method']) ? $conditions['method'] : 0, 'selected' => in_array($item->id, $relations) ? 1 : 0, 'item_change' => url_MakeHyperlink($this->_parent->getLanguageConstant('change'), window_Open('shop_delivery_price_change', 370, $this->_parent->getLanguageConstant('title_delivery_method_price_change'), true, true, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'delivery_methods'), array('sub_action', 'change_price'), array('id', $item->id)))), 'item_delete' => url_MakeHyperlink($this->_parent->getLanguageConstant('delete'), window_Open('shop_delivery_price_delete', 400, $this->_parent->getLanguageConstant('title_delivery_method_price_delete'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'delivery_methods'), array('sub_action', 'delete_price'), array('id', $item->id))))); $template->setLocalParams($params); $template->restoreXML(); $template->parse(); } } }