Interface design: structured tags on frontpage and tag pages + permission control added to add and delete tag links

git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@10 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
mensonge 2008-01-11 09:34:32 +00:00
parent cfbf95ebe5
commit 0bfd4e4d3f
7 changed files with 39 additions and 11 deletions

View File

@ -67,7 +67,7 @@ $dtstart = date('Y-m-d H:i:s', strtotime($dtend .' -'. $defaultRecentDays .' day
$tplVars['page'] = $page; $tplVars['page'] = $page;
$tplVars['start'] = $start; $tplVars['start'] = $start;
$tplVars['popCount'] = 30; $tplVars['popCount'] = 30;
$tplVars['sidebar_blocks'] = array('recent'); $tplVars['sidebar_blocks'] = array('linked', 'recent');
$tplVars['range'] = 'all'; $tplVars['range'] = 'all';
$tplVars['pagetitle'] = T_('Store, share and tag your favourite links'); $tplVars['pagetitle'] = T_('Store, share and tag your favourite links');
$tplVars['subtitle'] = T_('Recent Bookmarks'); $tplVars['subtitle'] = T_('Recent Bookmarks');
@ -84,4 +84,4 @@ if ($usecache) {
// Cache output if existing copy has expired // Cache output if existing copy has expired
$cacheservice->End($hash); $cacheservice->End($hash);
} }
?> ?>

View File

@ -88,14 +88,18 @@ class Tag2TagService {
return $output; return $output;
} }
function getOrphewTags($relationType, $uId) { function getOrphewTags($relationType, $uId = 0) {
$query = "SELECT DISTINCT tag1 as tag FROM `". $this->getTableName() ."`"; $query = "SELECT DISTINCT tag1 as tag FROM `". $this->getTableName() ."`";
$query.= " WHERE tag1 <> ALL"; $query.= " WHERE tag1 <> ALL";
$query.= " (SELECT DISTINCT tag2 FROM `". $this->getTableName() ."`"; $query.= " (SELECT DISTINCT tag2 FROM `". $this->getTableName() ."`";
$query.= " WHERE relationType = '".$relationType."'"; $query.= " WHERE relationType = '".$relationType."'";
$query.= " AND uId = '".$uId."'"; if($uId > 0) {
$query.= " AND uId = '".$uId."'";
}
$query.= ")"; $query.= ")";
$query.= " AND uId = '".$uId."'"; if($uId > 0) {
$query.= " AND uId = '".$uId."'";
}
//die($query); //die($query);

View File

@ -24,13 +24,22 @@ $tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService'); $templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$userservice = & ServiceFactory :: getServiceInstance('UserService'); $userservice = & ServiceFactory :: getServiceInstance('UserService');
$logged_on_user = $userservice->getCurrentUser();
//permissions
if($logged_on_user == null) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']); list ($url, $tag) = explode('/', $_SERVER['PATH_INFO']);
if ($_POST['confirm']) { if ($_POST['confirm']) {
$newTag = $_POST['newTag']; $newTag = $_POST['newTag'];
if ($tag2tagservice->addLinkedTags($tag, $newTag, '>', $userservice->getCurrentUserId())) { if ($tag2tagservice->addLinkedTags($tag, $newTag, '>', $userservice->getCurrentUserId())) {
$tplVars['msg'] = T_('Tag link created'); $tplVars['msg'] = T_('Tag link created');
$logged_on_user = $userservice->getCurrentUser();
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')])); header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
} else { } else {
$tplVars['error'] = T_('Failed to create the link'); $tplVars['error'] = T_('Failed to create the link');
@ -38,7 +47,6 @@ if ($_POST['confirm']) {
exit(); exit();
} }
} elseif ($_POST['cancel']) { } elseif ($_POST['cancel']) {
$logged_on_user = $userservice->getCurrentUser();
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags)); header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
} }

View File

@ -24,12 +24,20 @@ $tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService'); $templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$userservice = & ServiceFactory :: getServiceInstance('UserService'); $userservice = & ServiceFactory :: getServiceInstance('UserService');
$logged_on_user = $userservice->getCurrentUser();
//permissions
if($logged_on_user == null) {
$tplVars['error'] = T_('Permission denied.');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
list ($url, $tag1, $tag2) = explode('/', $_SERVER['PATH_INFO']); list ($url, $tag1, $tag2) = explode('/', $_SERVER['PATH_INFO']);
if ($_POST['confirm']) { if ($_POST['confirm']) {
if ($tag2tagservice->removeLinkedTags($_POST['tag1'], $_POST['tag2'], '>', $userservice->getCurrentUserId())) { if ($tag2tagservice->removeLinkedTags($_POST['tag1'], $_POST['tag2'], '>', $userservice->getCurrentUserId())) {
$tplVars['msg'] = T_('Tag link deleted'); $tplVars['msg'] = T_('Tag link deleted');
$logged_on_user = $userservice->getCurrentUser();
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')])); header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
} else { } else {
$tplVars['error'] = T_('Failed to delete the link'); $tplVars['error'] = T_('Failed to delete the link');
@ -37,7 +45,6 @@ if ($_POST['confirm']) {
exit(); exit();
} }
} elseif ($_POST['cancel']) { } elseif ($_POST['cancel']) {
$logged_on_user = $userservice->getCurrentUser();
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags)); header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
} }

View File

@ -70,7 +70,7 @@ $tplVars['page'] = $page;
$tplVars['start'] = $start; $tplVars['start'] = $start;
$tplVars['popCount'] = 25; $tplVars['popCount'] = 25;
$tplVars['currenttag'] = $cat; $tplVars['currenttag'] = $cat;
$tplVars['sidebar_blocks'] = array('related', 'popular'); $tplVars['sidebar_blocks'] = array('linked', 'related', 'popular');
$tplVars['subtitle'] = filter($pagetitle); $tplVars['subtitle'] = filter($pagetitle);
$tplVars['bookmarkCount'] = $start + 1; $tplVars['bookmarkCount'] = $start + 1;
$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, NULL, $cat, NULL, getSortOrder()); $bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, NULL, $cat, NULL, getSortOrder());

View File

@ -64,7 +64,11 @@ if(count($explodedTags) > 0) {
<div id="linked"> <div id="linked">
<table> <table>
<?php <?php
$editingMode = ($userid === $logged_on_userid); if(($logged_on_userid != null) && ($userid === $logged_on_userid)) {
$editingMode = true;
} else {
$editingMode = false;
}
foreach($explodedTags as $explodedTag) { foreach($explodedTags as $explodedTag) {
echo displayLinkedTags($explodedTag, '>', $userid, $cat_url, $user, $editingMode); echo displayLinkedTags($explodedTag, '>', $userid, $cat_url, $user, $editingMode);
} }

View File

@ -57,6 +57,9 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
$this->assertEquals(2, sizeof($orphewTags)); $this->assertEquals(2, sizeof($orphewTags));
$this->assertSame('a', $orphewTags[0]['tag']); $this->assertSame('a', $orphewTags[0]['tag']);
$this->assertSame('f', $orphewTags[1]['tag']); $this->assertSame('f', $orphewTags[1]['tag']);
$orphewTags = $tts->getOrphewTags('>');
$this->assertEquals(2, sizeof($orphewTags));
$this->assertSame('f', $orphewTags[0]['tag']);
$linkedTags = $tts->getLinkedTags('a', '>', 1); $linkedTags = $tts->getLinkedTags('a', '>', 1);
$this->assertSame(array('b', 'c'), $linkedTags); $this->assertSame(array('b', 'c'), $linkedTags);
@ -66,6 +69,8 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
$tts->removeLinkedTags('a', 'c', '>', 1); $tts->removeLinkedTags('a', 'c', '>', 1);
$linkedTags = $tts->getLinkedTags('a', '>', 1); $linkedTags = $tts->getLinkedTags('a', '>', 1);
$this->assertEquals(0, sizeof($linkedTags)); $this->assertEquals(0, sizeof($linkedTags));
$linkedTags = $tts->getLinkedTags('a', '>');
$this->assertSame(array('b', 'c', 'd'), $linkedTags);
} }
public function testAddLinkedTagsThroughBookmarking() public function testAddLinkedTagsThroughBookmarking()