/**
  * Public function that creates a single instance
  */
 public static function getInstance($parent)
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self($parent);
     }
     return self::$_instance;
 }
Exemplo n.º 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();
     }
 }