<?php
/*
 +----------------------------------------------------------------------
 | TEMMOKUMVC [ NO BEST , ONLY BETTER ]
 +----------------------------------------------------------------------
 | Copyright (c) 2018~2019 https://www.temmoku.cn All rights reserved.
 +----------------------------------------------------------------------
 | Author: 张宗强 Email:webmaster@temmoku.cn QQ:158726877 516669373 TEL:17895221001 微信:temmokumvc
 +---------------------------------------------------------------------- 
*/
namespace admin\controller;
use \temmoku\db;
use \temmoku\admin;

use \temmoku\lib\cloud as api;
class cloud extends admin
{
	public function modular(){
		//获取所有已安装的模块
		$_modular=db::select('initial_name')->from(jab.'modular')->where("1")->query();
		foreach($_modular as $row){
			$modular[]=$row[initial_name];
		}
		//获取所有已安装的插件
		$_plugin=db::select('initial_name')->from(jab.'plugin')->where("1")->query();
		foreach($_plugin as $row){
			$plugin[]=$row[initial_name];
		}
		$array=['modular'=>$modular,plugin=>$plugin];
		$this->assign('data',json_encode($array));
		$this->assign('method','modular');
		$this->display(tpl('cloud/index'));
	}
	
	public function plugin(){
		//获取所有已安装的插件
		$_plugin=db::select('initial_name')->from(jab.'plugin')->where("1")->query();
		foreach($_plugin as $row){
			$plugin[]=$row[initial_name];
		}
		$array=[plugin=>$plugin];
		$this->assign('data',json_encode($array));
		$this->assign('method','plugin');
		$this->display(tpl('cloud/index'));
	}
	
	public function hook(){
		$_hook=db::select('cloud_id')->from(jab.'hook_list')->where("cloud_id != 0")->groupBy(['cloud_id'])->query();
		foreach($_hook as $row){
			$hook[]=$row[cloud_id];
		}
		$array=['hook'=>$hook];
		$this->assign('data',json_encode($array));
		$this->assign('method','hook');
		$this->display(tpl('cloud/index'));
	}
	
	public function tpl(){
		//获取所有已安装的模块
		$_modular=db::select('initial_name,dir,name')->from(jab.'modular')->where("1")->query();
		foreach($_modular as $row){
			$modular[]=$row['initial_name'];
			$modular_tpl[$row['initial_name']][]=$row;
		}
		//获取所有已安装的插件
		$_plugin=db::select('initial_name,dir,name')->from(jab.'plugin')->where("1")->query();
		foreach($_plugin as $row){
			$plugin[]=$row['initial_name'];
			$plugin_tpl[$row['initial_name']][]=$row;
		}
		
		//获取所有已安装的模板
		$_install_cloud_tpl=(new \temmoku\model)->select('cloud_id')->from(jab.'cloud')->where("1")->query();
		foreach($_install_cloud_tpl as $row){
			$install_cloud_tpl[]=$row['cloud_id'];
		}
		$array=['modular'=>$modular,'modular_tpl'=>$modular_tpl,plugin=>$plugin,'plugin_tpl'=>$plugin_tpl,'install_cloud_tpl'=>$install_cloud_tpl];
		$this->assign('data',json_encode($array));
		$this->assign('method','tpl');
		$this->display(tpl('cloud/index'));
	}
	
	public function get_cloud_data(){
		echo (new api)->exec();
	}
}
?>