-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathap-edit-tags.php
executable file
·184 lines (170 loc) · 6.29 KB
/
ap-edit-tags.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
echo 'started'."\n";
$tag_file = './ap-tagignore.js';
$tags_start = 'var autoProducerTagList = [';
$tags_end = '];';
$tags_list = file_get_contents($tag_file);
$tags = array_map('stripslashes', explode(',',str_replace(array($tags_start,$tags_end,'"'),'',$tags_list)));
$tagsets_file = './ap-tagsets.js';
$tagsets_start = 'var autoProducerTagSets = ';
$tagsets_end = ';';
$tagsets_list = file_get_contents($tagsets_file);
var_dump($tagsets_list);
$tagsets_list = trim(str_replace(array($tagsets_start,$tagsets_end),'',$tagsets_list));
var_dump($tagsets_list);
$tagsets = json_decode($tagsets_list,true);
var_dump($tagsets);
?>
<!DOCTYPE html>
<head>
<title>AUTO-PRODUCER Tag Suggestion Manager</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="//cdn.foundation5.zurb.com/foundation.css" />
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
</style>
<link rel="icon" href="http://extras.mnginteractive.com/live/media/favIcon/dpo/favicon.ico" type="image/x-icon" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
</head>
<body>
<div id="snow"></div>
<section id="header">
<!-- NAVIGATION BAR -->
<div id="top-bar-margin" class="sticky fixed">
<nav class="top-bar" data-topbar="" role="navigation">
<ul class="title-area">
<li class="name">
<a href="http://denverpost.com"><img src="http://extras.denverpost.com/candidate-qa/denver-2015/images/dp-logo-white.png" alt="The Denver Post logo" class="nav-logo"></a>
</li>
</ul>
<section class="top-bar-section">
<ul class="right">
<li class="divider"></li>
<li class="top-top"><a href="ap-edit-types.php"><strong>EDIT STORY TYPES</strong></a></li>
<li class="divider"></li>
</ul>
</section>
</nav>
</div> <!-- Closes top-bar-margin -->
</section>
<div id="wrapper">
<div class="headerstyle">
<div class="row">
<div class="large-12 columns">
<h1>AUTO-PRODUCER Tag Suggestion Editor</h1>
<p>Tag suggestions rely on two things: an ignore list for bad tags that return too many false positives, and tag sets which determine a tag to suggest based on words and phrases that are not the same as the tag itself. This interface allows you to add or remove each type.</p>
<p>PROTIP: Hit CTRL+ENTER (CMD+ENTER for Macs) anywhere on this page to submit. Be careful!</p>
</div>
</div>
</div>
<div id="admin" class="row">
<form id="listtags" name="listtags" method="post" action="ap-submit.php">
<div class="large-5 columns">
<h2>Ignore list</h2>
<p>Manage tags to be ignored when by AUTO-PRODUCER offers suggestions. Click or use checkboxes to select items for deletion.</p>
<p>If you're adding a duplicate, it simply won't add anything.</p>
<fieldset>
<legend> Add tags to ignore </legend>
<label for="addnewtag">Separate tags with commas:</label>
<input type="text" name="addnewtag" />
<input type="submit" value="SAVE CHANGES" class="button" />
</fieldset>
<fieldset>
<legend> <?php echo count($tags); ?> tags </legend>
<?php if (!count($tags)>0) { ?>
<div class="row">
<div class="large-12 columns text-center">
<h3>No ignored tags to display!</h3>
</div>
</div>
<?php } else { ?>
<div class="row tablehead">
<div class="large-2 columns">
<strong>Select</strong>
</div>
<div class="large-10 columns">
<strong>Tag text</strong>
</div>
</div>
<?php foreach ($tags as $key => $value) { ?>
<div class="row">
<div class="large-2 columns">
<input class="smallmargin" type="checkbox" name="tagdelete-<?php echo $key; ?>" id="tagdelete-<?php echo $key; ?>" value="1" />
</div>
<div class="large-10 columns">
<label for="tag-<?php echo $key; ?>"><?php echo $value; ?></label>
</div>
</div>
<?php } ?>
<?php } ?>
<input type="hidden" name="tags_save" value="true" />
</fieldset>
</div>
<div class="large-7 columns">
<fieldset>
<legend> Add a tag set </legend>
<label for="addnewtag">Input the tag to suggest here:</label>
<input type="text" name="addnewtagset" />
<input type="submit" value="SAVE CHANGES" class="button" />
</fieldset>
<fieldset>
<legend> <?php echo count($tags); ?> tags </legend>
<?php if (!count($tags)>0) { ?>
<div class="row">
<div class="large-12 columns text-center">
<h3>No tag sets to display!</h3>
</div>
</div>
<?php } else { ?>
<div class="row tablehead">
<div class="large-2 columns">
<strong>Select</strong>
</div>
<div class="large-4 columns">
<strong>Tag to suggest</strong>
</div>
<div class="large-6 columns">
<strong>Trigger terms</strong>
</div>
</div>
<?php foreach ($tags as $key => $value) { ?>
<div class="row">
<div class="large-2 columns">
<input class="smallmargin" type="checkbox" name="tagdelete-<?php echo $key; ?>" id="tagsetdelete-<?php echo $key; ?>" value="1" />
</div>
<div class="large-4 columns">
<div class="large-3 columns">
<label for="tagset-<?php echo $key; ?>"><?php echo $value; ?></label>
</div>
</div>
<div class="large-6 columns">
<label for="tagset-<?php echo $key; ?>"><?php echo $value; ?></label>
</div>
</div>
<?php } ?>
<?php } ?>
<input type="hidden" name="tags_save" value="true" />
</fieldset>
</div>
</form>
</div>
<footer>
<div class="row">
<div class="large-12 medium-12 small-12 columns">
<p style="text-align: right">Copyright © 2017, The Denver Post</p>
</div>
</div>
</footer>
<script src="http://extras.denverpost.com/foundation/js/foundation.min.js"></script>
<script>
$(document).foundation();
</script>
<script>
document.body.addEventListener('keydown', function(e) {
if ((e.ctrlKey || e.metaKey) && (e.keyCode == 13 || e.keyCode == 10)) {
document.forms["listtags"].submit();
}
});
</script>
</body>
</html>