From d582054c77b22daeb08d2bff17794b9a69a20dd4 Mon Sep 17 00:00:00 2001 From: mensonge Date: Wed, 12 Dec 2007 16:29:16 +0000 Subject: import of scuttle 0.7.2 git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@1 b3834d28-1941-0410-a4f8-b48e95affb8f --- api/.htaccess | 10 +++++++ api/httpauth.inc.php | 22 ++++++++++++++ api/posts_add.php | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++ api/posts_all.php | 50 +++++++++++++++++++++++++++++++ api/posts_dates.php | 42 ++++++++++++++++++++++++++ api/posts_delete.php | 33 +++++++++++++++++++++ api/posts_get.php | 62 +++++++++++++++++++++++++++++++++++++++ api/posts_recent.php | 63 +++++++++++++++++++++++++++++++++++++++ api/posts_update.php | 26 ++++++++++++++++ api/tags_get.php | 25 ++++++++++++++++ api/tags_rename.php | 37 +++++++++++++++++++++++ 11 files changed, 453 insertions(+) create mode 100644 api/.htaccess create mode 100644 api/httpauth.inc.php create mode 100644 api/posts_add.php create mode 100644 api/posts_all.php create mode 100644 api/posts_dates.php create mode 100644 api/posts_delete.php create mode 100644 api/posts_get.php create mode 100644 api/posts_recent.php create mode 100644 api/posts_update.php create mode 100644 api/tags_get.php create mode 100644 api/tags_rename.php (limited to 'api') diff --git a/api/.htaccess b/api/.htaccess new file mode 100644 index 0000000..8c48221 --- /dev/null +++ b/api/.htaccess @@ -0,0 +1,10 @@ +RewriteEngine On +RewriteRule ^tags/get tags_get.php +RewriteRule ^posts/dates posts_dates.php +RewriteRule ^posts/get posts_get.php +RewriteRule ^posts/recent posts_recent.php +RewriteRule ^posts/all posts_all.php +RewriteRule ^posts/update posts_update.php +RewriteRule ^posts/add posts_add.php +RewriteRule ^posts/delete posts_delete.php +RewriteRule ^tags/rename tags_rename.php \ No newline at end of file diff --git a/api/httpauth.inc.php b/api/httpauth.inc.php new file mode 100644 index 0000000..bc26582 --- /dev/null +++ b/api/httpauth.inc.php @@ -0,0 +1,22 @@ +login($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); + if (!$login) { + authenticate(); + } +} +?> \ No newline at end of file diff --git a/api/posts_add.php b/api/posts_add.php new file mode 100644 index 0000000..77c3288 --- /dev/null +++ b/api/posts_add.php @@ -0,0 +1,83 @@ + 2) { + $status = 0; + } + } else { + switch ($status_str) { + case 'private': + $status = 2; + break; + case 'shared': + $status = 1; + break; + default: + $status = 0; + break; + } + } +} + +// Error out if there's no address or description +if (is_null($url) || is_null($description)) { + $added = false; +} else { +// We're good with info; now insert it! + if ($bookmarkservice->bookmarkExists($url, $userservice->getCurrentUserId())) + $added = false; + else + $added = $bookmarkservice->addBookmark($url, $description, $extended, $status, $tags, $dt, true); +} + +// Set up the XML file and output the result. +header('Content-Type: text/xml'); +echo '\r\n"; +echo ''; +?> \ No newline at end of file diff --git a/api/posts_all.php b/api/posts_all.php new file mode 100644 index 0000000..03026c4 --- /dev/null +++ b/api/posts_all.php @@ -0,0 +1,50 @@ +getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag); + +$currentuser = $userservice->getCurrentUser(); +$currentusername = $currentuser[$userservice->getFieldName('username')]; + +// Set up the XML file and output all the posts. +header('Content-Type: text/xml'); +echo '\r\n"; +echo '\r\n"; + +foreach($bookmarks['bookmarks'] as $row) { + if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) + $description = ''; + else + $description = 'extended="'. filter($row['bDescription'], 'xml') .'" '; + + $taglist = ''; + if (count($row['tags']) > 0) { + foreach($row['tags'] as $tag) + $taglist .= convertTag($tag) .' '; + $taglist = substr($taglist, 0, -1); + } else { + $taglist = 'system:unfiled'; + } + + echo "\t\r\n"; +} + +echo ''; +?> \ No newline at end of file diff --git a/api/posts_dates.php b/api/posts_dates.php new file mode 100644 index 0000000..7098756 --- /dev/null +++ b/api/posts_dates.php @@ -0,0 +1,42 @@ +getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag); + +$currentuser = $userservice->getCurrentUser(); +$currentusername = $currentuser[$userservice->getFieldName('username')]; + +// Set up the XML file and output all the tags. +header('Content-Type: text/xml'); +echo '\r\n"; +echo '\r\n"; + +$lastdate = NULL; +foreach($bookmarks['bookmarks'] as $row) { + $thisdate = gmdate('Y-m-d', strtotime($row['bDatetime'])); + if ($thisdate != $lastdate && $lastdate != NULL) { + echo "\t\r\n"; + $count = 1; + } else { + $count = $count + 1; + } + $lastdate = $thisdate; +} + +echo ""; +?> \ No newline at end of file diff --git a/api/posts_delete.php b/api/posts_delete.php new file mode 100644 index 0000000..737a4fb --- /dev/null +++ b/api/posts_delete.php @@ -0,0 +1,33 @@ +getBookmarkByAddress($_REQUEST['url']); + $bid = $bookmark['bId']; + $delete = $bookmarkservice->deleteBookmark($bid); + $deleted = true; +} + +// Set up the XML file and output the result. +header('Content-Type: text/xml'); +echo '\r\n"; +echo ''; +?> \ No newline at end of file diff --git a/api/posts_get.php b/api/posts_get.php new file mode 100644 index 0000000..8be067b --- /dev/null +++ b/api/posts_get.php @@ -0,0 +1,62 @@ +getBookmarks(0, NULL, $userservice->getCurrentUserId(), $tag, NULL, NULL, NULL, $dtstart, $dtend); + +$currentuser = $userservice->getCurrentUser(); +$currentusername = $currentuser[$userservice->getFieldName('username')]; + +// Set up the XML file and output all the tags. +header('Content-Type: text/xml'); +echo '\r\n"; +echo '\r\n"; + +foreach($bookmarks['bookmarks'] as $row) { + if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) + $description = ''; + else + $description = 'extended="'. filter($row['bDescription'], 'xml') .'" '; + + $taglist = ''; + if (count($row['tags']) > 0) { + foreach($row['tags'] as $tag) + $taglist .= convertTag($tag) .' '; + $taglist = substr($taglist, 0, -1); + } else { + $taglist = 'system:unfiled'; + } + + echo "\t\r\n"; +} + +echo ''; +?> \ No newline at end of file diff --git a/api/posts_recent.php b/api/posts_recent.php new file mode 100644 index 0000000..22fc2bd --- /dev/null +++ b/api/posts_recent.php @@ -0,0 +1,63 @@ + $countMax) + $count = $countMax; + elseif ($count < 0) + $count = 0; +} else { + $count = $countDefault; +} + +// Get the posts relevant to the passed-in variables. +$bookmarks =& $bookmarkservice->getBookmarks(0, $count, $userservice->getCurrentUserId(), $tag); + +$currentuser = $userservice->getCurrentUser(); +$currentusername = $currentuser[$userservice->getFieldName('username')]; + +// Set up the XML file and output all the tags. +header('Content-Type: text/xml'); +echo '\r\n"; +echo '\r\n"; + +foreach($bookmarks['bookmarks'] as $row) { + if (is_null($row['bDescription']) || (trim($row['bDescription']) == '')) + $description = ''; + else + $description = 'extended="'. filter($row['bDescription'], 'xml') .'" '; + + $taglist = ''; + if (count($row['tags']) > 0) { + foreach($row['tags'] as $tag) + $taglist .= convertTag($tag) .' '; + $taglist = substr($taglist, 0, -1); + } else { + $taglist = 'system:unfiled'; + } + + echo "\t\r\n"; +} + +echo ''; +?> \ No newline at end of file diff --git a/api/posts_update.php b/api/posts_update.php new file mode 100644 index 0000000..de379d2 --- /dev/null +++ b/api/posts_update.php @@ -0,0 +1,26 @@ +getBookmarks(0, 1, $userservice->getCurrentUserId()); + +$currentuser = $userservice->getCurrentUser(); +$currentusername = $currentuser[$userservice->getFieldName('username')]; + +// Set up the XML file and output all the tags. +header('Content-Type: text/xml'); +echo '\r\n"; +foreach($bookmarks['bookmarks'] as $row) { + echo ''; +} +?> \ No newline at end of file diff --git a/api/tags_get.php b/api/tags_get.php new file mode 100644 index 0000000..2584566 --- /dev/null +++ b/api/tags_get.php @@ -0,0 +1,25 @@ +getTags($userservice->getCurrentUserId()); + +// Set up the XML file and output all the tags. +header('Content-Type: text/xml'); +echo '\r\n"; +echo "\r\n"; +foreach($tags as $row) { + echo "\t\r\n"; +} +echo ""; +?> \ No newline at end of file diff --git a/api/tags_rename.php b/api/tags_rename.php new file mode 100644 index 0000000..20831e7 --- /dev/null +++ b/api/tags_rename.php @@ -0,0 +1,37 @@ +) than the other API calls. + +// Force HTTP authentication first! +require_once('httpauth.inc.php'); +require_once('../header.inc.php'); + +$tagservice =& ServiceFactory::getServiceInstance('TagService'); +$userservice =& ServiceFactory::getServiceInstance('UserService'); + +// Get the tag info. +if (isset($_REQUEST['old']) && (trim($_REQUEST['old']) != '')) + $old = trim($_REQUEST['old']); +else + $old = NULL; + +if (isset($_REQUEST['new']) && (trim($_REQUEST['new']) != '')) + $new = trim($_REQUEST['new']); +else + $new = NULL; + +if (is_null($old) || is_null($new)) { + $renamed = false; +} else { + // Rename the tag. + $result = $tagservice->renameTag($userservice->getCurrentUserId(), $old, $new, true); + $renamed = $result; +} + +// Set up the XML file and output the result. +header('Content-Type: text/xml'); +echo '\r\n"; +echo ''. ($renamed ? 'done' : 'something went wrong') .''; +?> -- cgit v1.2.3-54-g00ecf