<?php
/**
* @package      Easyway Shop
* @copyright    Copyright (C) 2005 - 2011 TA-EDV
* @license      proprietary
* @author       Darius Zylka <dz@ta-edv.de>
* 
* Easyway Shop is a web e-commerce system
*/

include_once './core/manufacturer.class.php';
include_once './core/structure.class.php';
include_once './core/item.class.php';

class website_manufacturers_structure_details {
	private $base_object;
	private $layout_object;
	private $manufacturer_object;
	
	public function __construct($base_object, $layout_object) {
		$this->base_object = $base_object;
		$this->layout_object = $layout_object;
		$this->manufacturer_object = new Manufacturer($base_object);
	}
	
	public function run($manufacturerSuri, $structureSuri) {
		$manufacturer = $this->manufacturer_object->get_by_suri($manufacturerSuri);
		$this->layout_object->assign('manufacturer', $manufacturer);

		$structureId = URI::fetch_structure($structureSuri);

		$structure = new Structure($this->base_object);
		$structureItem = $structure->get_by_id($structureId);
		$this->layout_object->assign('structure', $structureItem);

		$item = new Item($this->base_object);
		$itemList = $item->get_item_list_manufacturer($structureId, $manufacturer->id);
		$this->layout_object->assign('items', $itemList);
		
		foreach ($itemList as $item) {
			$metaparts[] = $item->name;
		}
		$this->layout_object->metaTagObject->get_by_group('HERSTELLERWARENGRUPPENDETAILS');
		$this->layout_object->metaTagObject->overwriteVar('Warengruppe', $structureItem->name);
		$this->layout_object->metaTagObject->overwriteVar('Hersteller', $manufacturer->name);
		$this->layout_object->metaTagObject->overwriteMeta('keywords', implode(', ', $metaparts));
		$this->layout_object->metaTagObject->overwriteMeta('description', trim($structureItem->seo_description));
		
		return $this->layout_object->_fetch('website_manufacturers_structure_details.tpl');
	}
}