<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>YUNYECMS <?php echo YUNYECMS_VERSION; ?></title>
	<!-- Tell the browser to be responsive to screen width -->
	<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
	<!-- Bootstrap 3.3.6 -->
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>bootstrap/css/bootstrap.min.css">
	<!-- Font Awesome -->
	<link href="<?php echo YUNYECMS_PUBLIC; ?>plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>plugins/fontawesome-free/css/all.min.css">
	<!-- Theme style -->
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>plugins/iCheck/all.css">
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>dist/css/AdminLTE.min.css">
	<!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>dist/css/skins/_all-skins.min.css">
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>dist/css/admin.css">
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>validator/dist/css/bootstrapValidator.css" />

	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>plugins/daterangepicker/daterangepicker.css">
	<!-- bootstrap datepicker -->
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>plugins/datepicker/datepicker3.css">
	<!-- Bootstrap time Picker -->
	<link rel="stylesheet" href="<?php echo YUNYECMS_UI; ?>plugins/timepicker/bootstrap-timepicker.min.css">
	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>

<body class="hold-transition rightbgcolor" onload="changefrmHeight()">
	<!-- Content Wrapper. Contains page content -->
	<div class="container-fluid" id="mainwrap">
		<!-- Main content -->
		<section class="content">
			<div class="row">
				<!-- left column -->
				<div class="col-xs-12">
					<div class="card card-primary card-outline">
						<div class="card-header">
							<div class="col-xs-12 col-sm-12 col-md-8 pb10">
								<h3 class="card-title">应用市场</h3> &nbsp;
								<a href="<?php echo url_admin("init", "addons"); ?>" class="btn btn-info btn-sm btn-flat"><i class="fa fa-th-large" aria-hidden="true"> </i> 全部应用</a> &nbsp;
								<a href="<?php echo url_admin("addons_list", "addons"); ?>" class="btn bg-blue btn-sm btn-flat"><i class="fa  fa-th-list " aria-hidden="true"> </i> 已安装的应用</a> &nbsp;
							</div>
						</div>
						<div class="box-body" style="padding-bottom: 50px;">
							<div class="table-responsive" style="padding-left: 20px;line-height: 2;">
								<div id="addonsinfo" style="line-height: 2;">
									<h4>要安装的应用：<br /></h4>
									<table class="table table-hover">
										<tbody>
											<tr>
												<th width="150">名称</th>
												<th><?php echo $addonsdetail["title"]; ?></th>
											</tr>
											<tr>
												<td>图标</td>
												<td><img src="<?php echo $addonsdetail["pic"]; ?>" width="100" alt="<?php echo $addonsdetail["title"]; ?>"></td>
											</tr>
											<tr>
												<td>类型：</td>
												<td class="text-red"><?php echo $addonsdetail["pricetype"]; ?></td>
											</tr>
											<tr>
												<td>版本：</td>
												<td><span id="addons_ver"></span></td>
											</tr>
											<tr>
												<td>环境：</td>
												<td>php版本：<span id="addons_phpver"></span>&nbsp;&nbsp;&nbsp;&nbsp;mysql版本：<span id="addons_dbver"></span></td>
											</tr>
											<tr>
												<td>适用：</td>
												<td>yunyecms <?php echo formatver($addonsdetail["version_num"]); ?>以上版本</td>
											</tr>
										</tbody>
									</table>
								</div>
								<div id="updateinfo" style="line-height: 2;">
									<?php echo $installinfo; ?>
								</div>
								<div id="upgrade"> </div>
							</div>
						</div>

						<!-- /.box-header -->

					</div>
					<!-- /.box -->
				</div>
				<!--/.col (left) -->
			</div>
			<!-- /.row -->
		</section>
		<!-- /.content -->
	</div>
	<!-- /.content-wrapper -->
	<?php require tpl_adm('foot'); ?>
	<!-- jQuery 2.2.3 -->
	<script src="<?php echo YUNYECMS_UI; ?>plugins/jQuery/jquery-3.6.1.min.js"></script>
	<!-- Bootstrap 3.3.6 -->
	<script src="<?php echo YUNYECMS_UI; ?>bootstrap/js/bootstrap.min.js"></script>
	<!-- FastClick -->
	<script src="<?php echo YUNYECMS_UI; ?>plugins/fastclick/fastclick.js"></script>
	<!-- AdminLTE for demo purposes -->
	<script src="<?php echo YUNYECMS_UI; ?>dist/js/admin.js"></script>
	<script src="<?php echo YUNYECMS_UI; ?>dist/js/modal.js"></script>

	<script language="javascript" type="text/javascript">
		$(function() {
			var navudinfo = "<?php echo $parnav; ?>";
			$('.breadcrumb', window.parent.document).children('#homeitem').nextAll().remove();
			$('.breadcrumb', window.parent.document).children('#homeitem').after(navudinfo);
		});
	</script>

	<script language="javascript" type="text/javascript">
		$(function() {
			$.ajax({
				type: "post",
				dataType: "text",
				data: {
					id: <?php echo $addonsdetail['id']; ?>,
					catid: <?php echo $addonsdetail['catid']; ?>,
					phpver: <?php echo $addonsdetail['phpver']; ?>,
					dbver: <?php echo $addonsdetail['dbver']; ?>,
					fitver: <?php echo $addonsdetail['fitver']; ?>,
					<?php echo $this->PostHash['ehashvar'] . ":'" . $this->PostHash['ehash'] . "'"; ?>,
					<?php echo $this->PostHash['rhashvar'] . ":'" . $this->PostHash['rhash'] . "'"; ?>
				},
				async: true,
				url: "<?php echo url_admin('getaddons_attrib', 'addons'); ?>",
				success: function(data) {
					console.log(data);
					var addons_attribdata = JSON.parse(data);
					$("#addons_ver").html(addons_attribdata.addons_ver);
					$("#addons_phpver").html(addons_attribdata.phpver + "以上");
					$("#addons_dbver").html(addons_attribdata.dbver + "以上");
					//$("#addons_fitver").html(addons_attribdata.fitver+"以上版本");
				},
				error: function() {
					return false;
				}
			})
		});


		function install_addons(step, para) {
			var parameter = arguments[1] ? arguments[1] : "";
			$("#updateinfo").html("<button class='btn bg-purple margin btn-flat' style='margin-left:150px;' disabled onclick='javascript:;'> <i class='icon-puzzle'></i> 正在安装... </button>");
			$.ajax({
				type: "post",
				dataType: "text",
				data: {
					step: step,
					para: parameter,
					addonsid: <?php echo $addonsdetail['id']; ?>,
					addons_dir: '<?php echo $addonsdetail['addons_dir']; ?>',
					<?php echo $this->PostHash['ehashvar'] . ":'" . $this->PostHash['ehash'] . "'"; ?>,
					<?php echo $this->PostHash['rhashvar'] . ":'" . $this->PostHash['rhash'] . "'"; ?>
				},
				async: true,
				url: "<?php echo url_admin('install_process', 'addons'); ?>",
				success: function(data) {
					console.log(step);
					var msg = JSON.parse(data);
					if (step == "getpackage") {
						$("#upgrade").html("");
						$("#upgrade").append(msg.loaded);
					}
					$("#upgrade").append("<br\>" + msg.desc);
					if (!empty(msg.step) && msg.code != '999') {
						if (msg.para) {
							install_addons(msg.step, msg.para);
						} else {
							install_addons(msg.step);
						}
					}
					if (msg.code == '999') {
						$("#upgrade_loading").hide();
						$("#updateinfo").hide();
						$("#upgrade").append("<br/><span class='text-red'>安装完成！</span>");
						upversion();
					}
				},
				error: function() {
					return false;
				}
			})
		}

		function upversion() {
			$.ajax({
				type: "get",
				dataType: "text",
				async: true,
				url: "<?php echo url_admin('getver', 'autoupdate'); ?>",
				success: function(data) {
					//console.log(data);
					var versiondata = JSON.parse(data);
					$("#versioninfo").html("当前版本：" + versiondata.cur_ver);
				},
				error: function() {
					return false;
				}
			})
		}
	</script>

</body>

</html>