-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
edit_csv.php
207 lines (187 loc) · 8.11 KB
/
edit_csv.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<?php
/**
* CSV Venues Editor
*
* Edição de venues a partir dos dados recebidos do load_csv.php
*
* @category Foursquare
* @package Foursquare-Mass-Editor-Tools
* @author Elio Gavlinski <[email protected]>
* @copyright Copyleft (c) 2011-2014
* @version 1.4
* @link https://github.com/gavlinski/Foursquare-Mass-Editor-Tools/blob/master/edit_csv.php
* @since File available since Release 0.3
* @license GPLv3 <http://www.gnu.org/licenses/gpl.txt>
*/
if (!isset($_SESSION))
session_start();
if (isset($_SESSION["oauth_token"])) {
$oauth_token = $_SESSION["oauth_token"];
$file = $_SESSION["file"];
} else {
header('Location: index.php'); /* Redirect browser */
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Elio Tools</title>
<meta http-equiv="Content-type" content="text/html; charset=ISO-8859-1"/>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="js/dijit/themes/claro/claro.css"/>
<link rel="stylesheet" type="text/css" href="estilo.css"/>
<script src="js/dojo/dojo.js" djConfig="parseOnLoad: true"></script>
<script type="text/javascript" src="js/4sq_csv.js"></script>
</head>
<body class="claro">
<h2>Editar venues</h2>
<p>Antes de salvar suas alterações, não deixe de ler nosso <a href="javascript:showDialogGuia();">guia de estilo</a> e as <a href="https://pt.foursquare.com/info/houserules" target="_blank">regras da casa</a>.</p>
<div id="listContainer">
<?php
if (array_key_exists("name", $file[0])) {
$hasName = true;
} else {
$hasName = false;
}
if (array_key_exists("address", $file[0])) {
$hasAddress = true;
} else {
$hasAddress = false;
}
if (array_key_exists("crossStreet", $file[0])) {
$hasCross = true;
} else {
$hasCross = false;
}
if (array_key_exists("city", $file[0])) {
$hasCity = true;
} else {
$hasCity = false;
}
if (array_key_exists("state", $file[0])) {
$hasState = true;
} else {
$hasState = false;
}
if (array_key_exists("zip", $file[0])) {
$hasZip = true;
} else {
$hasZip = false;
}
if (array_key_exists("twitter", $file[0])) {
$hasTwitter = true;
} else {
$hasTwitter = false;
}
if (array_key_exists("phone", $file[0])) {
$hasPhone = true;
} else {
$hasPhone = false;
}
if (array_key_exists("url", $file[0])) {
$hasUrl = true;
} else {
$hasUrl = false;
}
if (array_key_exists("description", $file[0])) {
$hasDesc = true;
} else {
$hasDesc = false;
}
if (array_key_exists("ll", $file[0])) {
$hasLl = true;
} else {
$hasLl = false;
}
if (array_key_exists("categoryId", $file[0])) {
$hasCategoryId = true;
} else {
$hasCategoryId = false;
}
$i = 0;
foreach ($file as $f) {
$i++;
echo '<div class="row">', chr(10), '<form name="form', $i, '" accept-charset="utf-8" encType="multipart/form-data" method="post">', chr(10);
$venue = $f['venue'];
echo '<input type="hidden" name="venue" value="', $venue, '"><a href="https://foursquare.com/v/', $venue, '" target="_blank"';
if ($hasCategoryId) {
echo ' style="margin-right: 5px;"';
}
echo '>';
if (count($file) < 10)
echo $i;
else if (count($file) < 100)
echo str_pad($i, 2, "0", STR_PAD_LEFT);
else
echo str_pad($i, 3, "0", STR_PAD_LEFT);
echo '</a>', chr(10);
if ($hasCategoryId) {
echo '<span id="icone', $i - 1, '"><img id=catImg', $i, ' src="https://foursquare.com/img/categories_v2/none_bg_32.png" style="height: 22px; width: 22px; margin-left: 0px"></span>', chr(10);
}
if ($hasName) {
$name = htmlentities($f['name'], ENT_QUOTES, 'ISO-8859-1');
echo '<input type="text" dojoType="dijit.form.TextBox" name="name" maxlength="256" value="', $name, '" placeHolder="Nome" style="width: 11em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
}
if ($hasAddress) {
$address = htmlentities($f['address'], ENT_QUOTES, 'ISO-8859-1');
echo '<input type="text" dojoType="dijit.form.TextBox" name="address" maxlength="128" value="', $address, '" placeHolder="Endereço" style="width: 11em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
}
if ($hasCross) {
$crossStreet = htmlentities($f['crossStreet'], ENT_QUOTES, 'ISO-8859-1');
echo '<input type="text" dojoType="dijit.form.TextBox" name="crossStreet" maxlength="51" value="', $crossStreet, '" placeHolder="Rua Cross" style="width: 9em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
}
if ($hasCity) {
$city = htmlentities($f['city'], ENT_QUOTES, 'ISO-8859-1');
echo '<input type="text" dojoType="dijit.form.TextBox" name="city" maxlength="31" value="', $city, '" placeHolder="Cidade" style="width: 7em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
}
if ($hasState) {
$state = htmlentities($f['state'], ENT_QUOTES, 'ISO-8859-1');
echo '<input type="text" dojoType="dijit.form.TextBox" name="state" maxlength="30" value="', $state, '" placeHolder="UF" style="width: 2.5em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
}
if ($hasZip) {
$zip = $f['zip'];
echo '<input type="text" dojoType="dijit.form.TextBox" name="zip" maxlength="13" value="', $zip, '" placeHolder="CEP" style="width: 6em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
}
if ($hasTwitter) {
$twitter = $f['twitter'];
echo '<input type="text" dojoType="dijit.form.TextBox" name="twitter" maxlength="51" value="', $twitter, '" placeHolder="Twitter" style="width: 7em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
}
if ($hasPhone) {
$phone = $f['phone'];
echo '<input type="text" dojoType="dijit.form.TextBox" name="phone" maxlength="21" value="', $phone, '" placeHolder="Telefone" style="width: 7em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
}
if ($hasUrl) {
$url = $f['url'];
echo '<input type="text" dojoType="dijit.form.TextBox" name="url" maxlength="256" value="', $url, '" placeHolder="Website" style="width: 8em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
}
if ($hasDesc) {
$description = htmlentities($f['description'], ENT_QUOTES, 'ISO-8859-1');
echo '<input type="text" dojoType="dijit.form.TextBox" name="description" maxlength="300" value="', $description, '" placeHolder="Descrição" style="width: 8em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
}
if ($hasLl) {
$ll = $f['ll'];
//if (($ll != '') && ($ll != ' ')) {
echo '<input type="text" dojoType="dijit.form.TextBox" name="ll" maxlength="402" value="', $ll, '" placeHolder="Lat/Long" style="width: 7em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
//} else {
//echo '<input type="text" dojoType="dijit.form.TextBox" name="ll" placeHolder="Lat/Long" style="width: 9em; margin-left: 5px;" disabled>', chr(10);
//}
}
if ($hasCategoryId) {
$categoryId = $f['categoryId'];
//if (($categoryId != '') && ($categoryId != ' ')) {
echo '<input type="text" dojoType="dijit.form.TextBox" name="categoryId" maxlength="75" value="', $categoryId, '" placeHolder="Categorias" style="width: 9em; margin-left: 5px;" onchange="verificarAlteracao(this, ', $i - 1, ')">', chr(10);
//} else {
//echo '<input type="text" dojoType="dijit.form.TextBox" name="categoryId" placeHolder="Categorias" style="width: 9em; margin-left: 5px;" disabled>', chr(10);
//}
}
echo '<span id="result', $i - 1, '"></span>', chr(10), '</form>', chr(10), '</div>', chr(10);
}
?>
</div>
<div>
<button id="saveButton" dojoType="dijit.form.Button" type="submit" name="saveButton" onclick="salvarVenues()" style="float: left; padding-right: 3px; margin-left: 0px; margin-bottom: 15px">Salvar</button>
<button id="cancelButton" dojoType="dijit.form.Button" type="button" onclick="history.go(-1)" name="cancelButton" style="float: left">Cancelar</button>
<div id="dropdownButtonContainer2" style="float: left"></div>
</div>
</body>
</html>