<?php
namespace Manage\Src;

use Dever;
use Dever\Template\View;
use Manage\Src\Lib\Visual;

class Template
{
	/**
     * project
     *
     * @var string
     */
	private $project;

	/**
     * dir
     *
     * @var string
     */
	protected $type;
	
	/**
     * config
     *
     * @var array
     */
	protected $config;

	/**
     * __construct
     * 
     * @return mixed
     */
	public function __construct()
	{
		$this->project 	= Dever::input('key');
		$this->type 	= Dever::input('type', 'config');
		
		$config = Dever::load('manage/project.get');

		if(isset($config[$this->project]))
		{
			$this->config 		= $config[$this->project];
		}
	}
	
	/**
     * index
     * 
     * @return mixed
     */
	public function index()
	{
		# 读取当前的service
		$view = View::getInstance('home', $this->config['path'], $this->project);
		$content = $view->runing();
		
		$config = $view->result();
		
		if(strpos($content, '</body>') >= 0)
		{
			$content = str_replace('</body>', Visual::tool() . '</body>', $content);
		}
		else
		{
			$content = $content . Visual::tool();
		}
		
		return $content;
	}
}
