forked from webworka/Tagedit
/
formtarget.php
89 lines (78 loc) · 3.35 KB
/
formtarget.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
<?php
/**
* Script for evaluationg the form that is send from jQuery Plugin tagedit.
*
* @author Oliver Albrecht <info@webwork-albrecht.de>
* @version 1.0.0
* @copyright Copyright (c) 2010, Oliver Albrecht
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
//echo '<pre>' . print_r($_POST['tag'], true) . '</pre>';exit;
if(array_key_exists('save', $_POST) && array_key_exists('tag', $_POST)) {
// Include the autocompleteScript to know what was in the database
include ('autocomplete.php');
$result = array('new' => array(), 'deleted' => array(), 'changed' => array(), 'not changed' => array());
foreach($_POST['tag'] as $key => $value) {
if(preg_match('/([0-9]*)-?(a|d)?$/', $key, $keyparts) === 1) {
if(isset($keyparts[2])) {
switch($keyparts[2]) {
case 'a':
if($autocompletiondata[$keyparts[1]] != $value) {
// Items has changed
$result['changed'][] = $keyparts[1] . ' (new value: "' . $value . '")';
}
else {
$result['not changed'][] = $keyparts[1] . ' ("' . $value . '")';
}
break;
case 'd':
$result['deleted'][] = $keyparts[1] . ' ("' . $value . '")';
break;
}
}
else {
$result['new'][] = $key . ' ("' . $value . '")';
}
}
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
<title>jQuery Plugin tagedit - Tageditor</title>
<meta name="generator" content="Komodo IDE" />
<meta name="author" content="Oliver Albrecht" />
<meta name="description" content="Example Page for the jQuery Plugin tagedit. It offers an inputfield for adding, editing und deleting keywords, tags and other lists. There is also autocompletion" />
<meta name="robots" content="index, follow" />
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="de"/>
<meta name="language" content="de"/>
<link rel="shortcut icon" href="../favicon.ico"/>
<link rel="StyleSheet" href="../css/jquery.tagedit-1.0.0.css" type="text/css" media="all"/>
</head>
<body>
<h1>Tagedit result</h1>
<a href="../index.html" title="Back">Back to inputpage</a>
<?php if(array_key_exists('save', $_POST) && array_key_exists('tag', $_POST) && count($_POST['tag']) > 0) :?>
<p>The following inputs where received:</p>
<?php foreach($result as $key => $results) : ?>
<h2>Tags that are <?php echo $key; ?></h2>
<?php if(count($results) > 0) :?>
<ul>
<?php foreach($results as $tag): ?>
<li>Id: <?php echo $tag; ?></li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p>nothing</p>
<?php endif; //count(dleted) > 0?>
<?php endforeach; ?>
<?php else: ?>
<p>You did not enter any data</p>
<?php endif; // $_POST['tag'] ?>
</body>
</html>