evaluate MVC architecture w/ template system
templates for rss, xml
clean urls
-filter by tags
preview media when embedding videos from youtube, images, etc
private saving
import/export
pagination
+allow commas or space delimited
+
pages
help - explain bookmarklet
about
return false;
}
+
+
+function filter_tags($tagstr) {
+
+ $tags = array();
+
+ # split on commas if using commas
+ if (strstr($tagstr, ',')) {
+ $tags = explode(",", $tagstr);
+ # replace spaces with pluses
+ $tags = array_map(function ($tag) {
+ $tag = trim($tag);
+ return strpos($tag, " ") ? str_replace(" ", "+", $tag) : $tag;
+ }, $tags);
+ }
+
+ # else, split on spaces
+ else {
+ $tags = explode(" ", $tagstr);
+ $tags = array_map(function ($tag) {
+ return trim($tag);
+ }, $tags);
+ }
+
+ #filter tag dupes
+ return array_unique($tags);
+}
</p>
<p>
- <label>tags (SPACEBAR delimited)</label>
+ <label>tags <span style="font-weight:normal">(space " " or comma "," delimited)</span></label>
<input type="text" name="tags" value="">
</p>
$dbh->beginTransaction();
# process tags
- $tags = explode(" ", $params['tags']);
- $tags = array_unique($tags);
+ $tags = filter_tags($params['tags']);
+ print_r($tags);
+ echo '<br />TODO: figure out delimiter for spaces for database';
+ exit;
+
+ #insert tags
if (count($tags) > 0) {
foreach($tags as $key => $tag) {
- $sql = "INSERT INTO `clmpr`.`tags` ( `tag`, `count` )
- VALUES ( ?, 1 )
- ON DUPLICATE KEY UPDATE
- `count` = `count` + 1";
- $q = $dbh->prepare($sql);
+ $q = $dbh->prepare("INSERT INTO `clmpr`.`tags` (`tag`, `count`)
+ VALUES ( ?, 1 )
+ ON DUPLICATE KEY
+ UPDATE `count` = `count` + 1");
$q->execute( array( $tag ));
}
}
# insert clump
- $sql = "INSERT INTO `clmpr`.`clumps` ( `user_id`, `title` , `url` , `tags`, `description`, `date` )
- VALUES ( ?, ?, ?, ?, ?, NOW() ) ";
- $q = $dbh->prepare($sql);
- $insert = $q->execute( array( $user['id'], $params['title'], $params['url'], implode(" ", $tags), htmlentities($params['description']) ));
+ $q = $dbh->prepare("INSERT INTO `clmpr`.`clumps`
+ ( `user_id`,
+ `title`,
+ `url`,
+ `tags`,
+ `description`,
+ `date` )
+ VALUES ( ?, ?, ?, ?, ?, NOW() ) ");
+ $insert = $q->execute( array(
+ $user['id'],
+ $params['title'],
+ $params['url'],
+ implode(" ", $tags),
+ htmlentities($params['description'])));
echo "clumped.<br/><br/>";
echo '<a href="javascript:window.close();">ok</a>';
$clump['tags'] = explode(" ", $clump['tags']);
# process tags
- $tags = explode(" ", $params['tags']);
- $tags = array_unique($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 = filter_tags($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) {