<?php
/*
 * @version			$Id: index.php 10381 2008-06-01 03:35:53Z $
 * @package			Carteasy
 * @copyright		Copyright (C) 2005 - 2011 Wlanium
 * @license			proprietary
 * @author			Thomas Bartelt
 * Carteasy is a web shop system
 */

include_once './core/main.class.php';

class Domain extends Main {
	protected $base_object;
	protected $db;

	public $list_table_config = array (
		'title' => 'Domain',
		'db_table' => 'domains',
		'list_fields' => array(
			array(
				'db_field' => 'name',
				'name' => 'Domain',
				'sortable' => 1
			),
			array(
				'db_field' => 'google_site_verification',
				'name' => 'Google-Site-Verification',
				'sortable' => 1
			),
			array(
				'db_field' => 'google_analytics_code',
				'name' => 'Google-Analytics-Code',
				'sortable' => 1
			),
			array(
				'db_field' => 'standard_theme_id',
				'name' => 'Standard-Theme',
				'rewrite_function' => 'theme_values',
				'sortable' => 1
			),
			array(
				'db_field' => 'standard_language_id',
				'name' => 'Standardsprache',
				'rewrite_function' => 'language_values',
				'sortable' => 1
			)
		),
		'search_fields' => array('name', 'google_site_verification'),
		'db_id_field' => 'id',
		'db_selectable_field' => 'name',
		'edit_link' => 'index.php?admin_modul=admin_object_edit&object=Domain&object_id=',
		'toolbar' => array(
			'delete' => '1',
			'new' => 'index.php?admin_modul=admin_object_edit&object=Domain',
			'copy' => 0,
			'select_all' => 1,
			'edit' => 0,
			'actions' => 0,
			'filter' => 0,
			'search' => 1
		),
		'edit_title' => 'Domain',
		'edit_fields' => array (
			array(
				'name' => 'Allgemein',
				'type' => 'form_title'
			),
			array(
				'db_field' => 'name',
				'name' => 'Domain',
				'type' => 'text'
			),
			array(
				'db_field' => 'google_site_verification',
				'name' => 'Google-Site-Verification',
				'type' => 'text'
			),
			array(
				'db_field' => 'google_analytics_code',
				'name' => 'Google-Analytics-Code',
				'type' => 'text'
			),
			array(
				'db_field' => 'standard_theme_id',
				'name' => 'Standard-Theme',
				'values' => 'theme_values',
				'type' => 'int'
			),
			array(
				'db_field' => 'standard_language_id',
				'name' => 'Standardsprache',
				'values' => 'language_values',
				'type' => 'int'
			)
		),
		'edit_mandatory_fields' => array('name', 'iso'),
		'edit_toolbar' => array(
			'close' => 'index.php?admin_modul=admin_object_list&object=Domain',
			'copy' => 0,
			'undo' => 0,
			'redo' => 0,
			'save' => 1,
			'send' => 0,
			'delete' => 1
		),
	);

	function __construct($base_object) {
		$this->db = $base_object->db;
		$this->base_object = $base_object;
	}

	public function theme_values() {
		include_once './core/shop_theme.class.php';
		$theme_object = new Shop_theme($this->base_object);
		$data = $theme_object->get_all_selectable();
		return $data;
	}

	public function language_values() {
		include_once './core/language.class.php';
		$language_object = new Language($this->base_object);
		$data = $language_object->get_all_selectable();
		return $data;
	}

	public function get_domain_config($domain_name) {
		$sql = "SELECT * FROM domains WHERE name='".$this->db->real_escape_string($domain_name)."'";
		$result = $this->db->query($sql);
		if ($result && $obj = $result->fetch_object()) {
			return $obj;
		}
		return false;
	}

}

?>