forked from typecho-fans/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
panel.php
142 lines (137 loc) · 6.35 KB
/
panel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
include 'header.php';
include 'menu.php';
?>
<div class="main">
<div class="body container">
<?php include 'page-title.php'; ?>
<div class="container typecho-page-main">
<div class="col-mb-12 typecho-list">
<div class="typecho-option-tabs">
<ul class="typecho-option-tabs clearfix">
<li class="current">
<form action="<?php $options->index('/action/golinks?add'); ?>" method="post" >
KEY:<input name="key" id="key" type="text" value="" />
目标:<input name="target" id="target" type="text" value="http://" />
<input type="submit" class="btn-s primary" value="添加" />
</form>
</li>
<li class="right current">
<?php $ro = Typecho_Router::get('go'); ?>
自定义链接:<input id="links" name="links" value="<?php echo $ro['url'] ?>" type="text">
<button id="qlinks" type="button">修改</button>
</li>
</ul>
</div>
<div class="typecho-table-wrap">
<table class="typecho-list-table">
<colgroup>
<col width="8%"/>
<col width="32%"/>
<col width="47%"/>
<col width="5%"/>
<col width="8%"/>
</colgroup>
<thead>
<tr>
<th><?php _e('KEY'); ?></th>
<th><?php _e('站内链接'); ?></th>
<th><?php _e('目标链接'); ?> </th>
<th><?php _e('统计'); ?> </th>
<th><?php _e('操作'); ?></th>
</tr>
</thead>
<tbody>
<?php $page = isset($request->page) ? $request->page : 1 ; ?>
<?php $links = $db->fetchAll($db->select()->from('table.golinks')->page($page, 15)->order('table.golinks.id', Typecho_Db::SORT_DESC)); ?>
<?php foreach($links as $link): ?>
<tr class="even" id="<?php _e($link['id']); ?>" >
<td>
<?php _e($link['key']); ?>
</td>
<td>
<?php $rourl = str_replace('[key]', $link['key'], $ro['url']); ?>
<?php $options->index($rourl);?>
</td>
<td id="e-<?php _e($link['id']); ?>"><?php _e($link['target']); ?></td>
<td><?php _e($link['count']); ?></td>
<td>
<a href="#<?php _e($link['id']); ?>" class="operate-edit">修改</a>
<a lang="<?php _e('你确认要删除该链接吗?'); ?>" href="<?php $options->index('/action/golinks?del=' . $link['id']); ?>" class="operate-delete"><?php _e('删除'); ?></a>
</td>
</tr>
<?php endforeach;?>
</tbody>
</table>
</div>
<div class="typecho-pager">
<div class="typecho-pager-content">
<ul>
<?php $total = $db->fetchObject($db->select(array('COUNT(id)' => 'num'))->from('table.golinks'))->num; ?>
<?php for($i=1;$i<=ceil($total/15);$i++): ?>
<li class='current'><a href="<?php $options->adminUrl('extending.php?panel=GoLinks%2Fpanel.php&page='.$i); ?>" style= 'cursor:pointer;' title='第 <?php _e($i); ?> 页'> <?php _e($i); ?> </a></li>
<?php endfor; ?>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
include 'copyright.php';
include 'common-js.php';
include 'footer.php';
?>
<script type="text/javascript">
$(document).ready(function () {
$('.operate-delete').click(function () {
var t = $(this), href = t.attr('href'), tr = t.parents('tr');
if (confirm(t.attr('lang'))) {
tr.fadeOut(function () {
window.location.href = href;
});
}
return false;
});
$('.operate-edit').click(function () {
var tr = $(this).parents('tr'), t = $(this), id = tr.attr('id');
var value = $('#e-'+id).html();
$('#e-'+id).html('<input type="text" id="t-'+id +'" size="55" value="'+ value + '" /> <button type="submit" id="u-'+ id +'" class="btn-s primary"><?php _e('确认'); ?></button> <button type="button" id="c-'+ id +'" class="btn-s cancel"><?php _e('取消'); ?></button>');
$("[href='#"+id+"']").hide();
//确认
$('#u-'+id).click(function(){
$.ajax({
url: '<?php $options->index('/action/golinks?edit'); ?>',
data:'id='+id+'&url='+$('#t-'+id).val(),
dataType:"json",
success:function(data){
if(data==='success'){
$('#e-'+id).html($('#t-'+id).val());
$("[href='#"+id+"']").show();
}else{
alert('请输入有效链接');
}
}
});
});
//取消
$('#c-'+id).click(function(){
$('#e-'+id).html(value);
$("[href='#"+id+"']").show();
});
});
$('#qlinks').click(function(){
$.ajax({
url:'<?php $options->index('/action/golinks?resetLink'); ?>',
data:'link='+$('#links').val(),
dataType:'json',
success:function(data){
if('success' === data){
location.reload();
}
}
});
});
});
</script>