<?php
/**
* @package      Easyshop
* @copyright    Copyright (C) 2005 - 2011 TA-EDV
* @license      proprietary
* @author       John T. Daly <jd@ta-edv.de>
*/

include_once './core/memory.class.php';
include_once './core/item.class.php';

class website_item_memory {
	
	private $base_object;
	private $layout_object;
	
	public function __construct($base_object, $layout_object) {
		$this->base_object = $base_object;
		$this->layout_object = $layout_object;
	}
		
	function run($search) {
		$memory_object = new Memory();
		
		// delete item
		if (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['item_id']) { 
			$memory_object->delete($_GET['item_id']);
		}
	
		// get all items
		$memory_items = $memory_object->get_all();
		$item_list = array();
		if ($memory_items) {
			$item_object = new Item($this->base_object);
			$item_list = $item_object->get_item_list_by_ids($memory_items, 'all');
		}
		
                $this->layout_object->assign('show_memory_items', 1);
		$this->layout_object->assign('shopArticles', $item_list);
		$this->layout_object->assign('hide_pagination', true);
		$this->layout_object->assign('hide_listoptions', true);
		
		// generate block element since there is none in old, non dynamic modules 
		$block = new stdClass();
		$block->style = 'h2';
		$this->layout_object->assign('block', $block);
		
		
//		return $this->layout_object->_fetch('content_item_memory.tpl');
		return $this->layout_object->_fetch('content_box_item_list.tpl');
	}
}