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['start'] = $start;
$tplVars['popCount'] = 30;
$tplVars['sidebar_blocks'] = array('recent');
$tplVars['sidebar_blocks'] = array('linked', 'recent');
$tplVars['range'] = 'all';
$tplVars['pagetitle'] = T_('Store, share and tag your favourite links');
$tplVars['subtitle'] = T_('Recent Bookmarks');
@ -84,4 +84,4 @@ if ($usecache) {
// Cache output if existing copy has expired
$cacheservice->End($hash);
}
?>
?>

View file

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

View file

@ -24,13 +24,22 @@ $tag2tagservice = & ServiceFactory :: getServiceInstance('Tag2TagService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$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']);
if ($_POST['confirm']) {
$newTag = $_POST['newTag'];
if ($tag2tagservice->addLinkedTags($tag, $newTag, '>', $userservice->getCurrentUserId())) {
$tplVars['msg'] = T_('Tag link created');
$logged_on_user = $userservice->getCurrentUser();
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
} else {
$tplVars['error'] = T_('Failed to create the link');
@ -38,7 +47,6 @@ if ($_POST['confirm']) {
exit();
}
} elseif ($_POST['cancel']) {
$logged_on_user = $userservice->getCurrentUser();
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');
$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']);
if ($_POST['confirm']) {
if ($tag2tagservice->removeLinkedTags($_POST['tag1'], $_POST['tag2'], '>', $userservice->getCurrentUserId())) {
$tplVars['msg'] = T_('Tag link deleted');
$logged_on_user = $userservice->getCurrentUser();
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
} else {
$tplVars['error'] = T_('Failed to delete the link');
@ -37,7 +45,6 @@ if ($_POST['confirm']) {
exit();
}
} elseif ($_POST['cancel']) {
$logged_on_user = $userservice->getCurrentUser();
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')] .'/'. $tags));
}

View file

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

View file

@ -64,7 +64,11 @@ if(count($explodedTags) > 0) {
<div id="linked">
<table>
<?php
$editingMode = ($userid === $logged_on_userid);
if(($logged_on_userid != null) && ($userid === $logged_on_userid)) {
$editingMode = true;
} else {
$editingMode = false;
}
foreach($explodedTags as $explodedTag) {
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->assertSame('a', $orphewTags[0]['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);
$this->assertSame(array('b', 'c'), $linkedTags);
@ -66,6 +69,8 @@ class Tag2TagTest extends PHPUnit_Framework_TestCase
$tts->removeLinkedTags('a', 'c', '>', 1);
$linkedTags = $tts->getLinkedTags('a', '>', 1);
$this->assertEquals(0, sizeof($linkedTags));
$linkedTags = $tts->getLinkedTags('a', '>');
$this->assertSame(array('b', 'c', 'd'), $linkedTags);
}
public function testAddLinkedTagsThroughBookmarking()