+// TODO
evaluate MVC architecture w/ template system
templates for rss, xml
clean urls
import/export
pagination
tag autocomplete from user tags
+check for quotes (for "multiple words")
+
-allow commas or space delimited
pages
help - explain bookmarklet
about
+
ref
+ pinterest.in
http://www.pui.ch/phred/archives/2005/05/tags-with-mysql-fulltext.html
http://code.google.com/p/mysqlicious/
--- /dev/null
+<?php
+
+include '../init.php';
+
+$dbh = get_db_connection();
+$dbh->beginTransaction();
+
+$q = $dbh->prepare("SELECT *, clumps.id as clump_id
+ FROM clumps
+ JOIN users
+ ON users.id = clumps.user_id
+ ORDER BY date DESC");
+$q->execute();
+
+$clumps = array();
+for($i = 0; $row = $q->fetch(); $i++ ):
+ $clumps[] = $row;
+endfor;
+
+foreach($clumps as $clump) :
+ #update tags
+ $tags = str_replace(" ", ',', $clump['tags']);
+ # update clump
+ $update = $dbh->prepare("UPDATE `clumps` SET `tags` = '".$tags."' WHERE `id` = '".$clump['clump_id']."'");
+ $update->execute();
+endforeach;
+
+exit;
+
+$dbh = null;
+$q = null;
return false;
}
+
+
+function tag_string_to_array($tagstr) {
+ # if has commas, split on commas
+ # else split on spaces
+ // TODO
+ # check for quotes (for "multiple words")
+ return strpos($tagstr, ',') ? explode(',', $tagstr) : explode(' ', $tagstr);
+}
?><!DOCTYPE html><head>
<?php include 'head.html'; ?>
-
<title>clmpr - <?=$clump['title']?></title>
-
-<link rel="stylesheet" type="text/css" href="/lib/tag-it/css/jquery-ui.css" />
-<link rel="stylesheet" type="text/css" href="/lib/tag-it/css/jquery.tagit.css" />
-<link rel="stylesheet" type="text/css" href="/lib/tag-it/css/clmpr.tagit.css" />
-
-<script src="/lib/tag-it/js/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
-<script src="/lib/tag-it/js/tag-it.js" type="text/javascript" charset="utf-8"></script>
-
<script type="text/javascript">
-$(document).ready(function() {
- // user tags array
- var userTags = [];
- $("#tag-input").tagit({
- availableTags : userTags,
- animate : false,
- spaceChar : '-',
- tabIndex : 3
- });
-});
function deleteClump( id ) {
if (confirm("confirm delete")) {
$.post('delete.php', { clump_id : id }, function(result) {
}
}
</script>
-
</head><body>
<?php include 'header.html'; ?>
</p>
<p>
- <label>tags <span class="ui">(combine "multiple words" with quotes)</span></label>
- <input type="text" tabindex="3" id="tag-input" name="tags" value="<?php echo $clump['tags']; ?>">
+ <label>tags</label>
+ <input type="text" tabindex="3" name="tags" value="<?php echo $clump['tags']; ?>">
<p>
<p>
<label>description</label>
- <input type="text" tabindex="4" name="description" value="<?php echo htmlentities($clump['description']); ?>">
+ <input type="text" tabindex="4" name="description" value="<?php echo $clump['description']; ?>">
</p>
<p>
?>
<!DOCTYPE html><head>
<?php include 'head.html'; ?>
-
- <link rel="stylesheet" type="text/css" href="/lib/tag-it/css/jquery-ui.css" />
- <link rel="stylesheet" type="text/css" href="/lib/tag-it/css/jquery.tagit.css" />
- <link rel="stylesheet" type="text/css" href="/lib/tag-it/css/clmpr.tagit.css" />
-
- <script src="/lib/tag-it/js/jquery-ui.min.js" type="text/javascript" charset="utf-8"></script>
- <script src="/lib/tag-it/js/tag-it.js" type="text/javascript" charset="utf-8"></script>
-
- <script>
- $(document).ready(function() {
-
- // user tags array
- var userTags = [];
-
- $("#tag-input").tagit({
- availableTags : userTags,
- animate : false,
- tabIndex : 3
- });
- $('.tagit input')[0].focus();
-
- });
- </script>
-
</head><body>
<?php
<?php
} else {
-
include 'signin.php';
-
}
-
-
}
catch(PDOException $e)
{
$dbh->beginTransaction();
# process tags
- $tags = explode(',', $params['tags']);
+ $tags = tag_string_to_array( $params['tags'] );
if (count($tags) > 0) {
foreach($tags as $key => $tag) {
$q = $dbh->prepare("INSERT INTO `tags` (`tag`, `count`)
VALUES ( ?, ?, ?, ?, ?, NOW() ) ");
$insert = $q->execute( array(
$user['id'], $params['title'], $params['url'],
- $params['tags'], $params['description']));
+ implode(',', $params['tags']), $params['description']));
echo "clumped.<br/><br/>";
echo '<a href="javascript:window.close();">ok</a>';
$params = array();
$params['id'] = isset($_POST['id']) ? $_POST['id'] : null;
$params['title'] = isset($_POST['title']) ? $_POST['title'] : null;
-$params['url'] = isset($_POST['url']) ? $_POST['url'] : null;
-$params['tags'] = isset($_POST['tags']) ? $_POST['tags'] : null;
+$params['url'] = isset($_POST['url']) ? $_POST['url'] : null;
+$params['tags'] = isset($_POST['tags']) ? $_POST['tags'] : null;
$params['description'] = isset($_POST['description']) ? $_POST['description'] : null;
//print_r($_POST);
$clump['tags'] = explode(",", $clump['tags']);
# process tags
- $tags = explode(',', $params['tags']);
- $tags_to_keep = array_intersect ($tags, $clump['tags']);
- $tags_to_delete = array_diff ($clump['tags'], $tags_to_keep);
- $tags_to_add = array_diff ($tags, $tags_to_keep);
+ $tags = tag_string_to_array( $params['tags'] );
+ $tags_to_keep = array_intersect ($tags, $clump['tags']);
+ $tags_to_delete = array_diff ($clump['tags'], $tags_to_keep);
+ $tags_to_add = array_diff ($tags, $tags_to_keep);
# add/increment new tags
if (count($tags_to_add) > 0) {