2008-01-09 16:51:35 +01:00
|
|
|
<?php
|
|
|
|
$tag2tagservice =& ServiceFactory::getServiceInstance('Tag2TagService');
|
|
|
|
$userservice =& ServiceFactory::getServiceInstance('UserService');
|
|
|
|
|
|
|
|
function displayLinkedTags($tag, $linkType, $uId, $cat_url, $user, $editingMode =false, $precedentTag =null, $level=0, $stopList=array()) {
|
2008-01-28 15:55:07 +01:00
|
|
|
|
|
|
|
if(in_array($tag, $stopList)) {
|
|
|
|
return array('output' => '', 'stoplist' => $stopList);
|
|
|
|
}
|
|
|
|
|
2008-01-09 16:51:35 +01:00
|
|
|
$tag2tagservice =& ServiceFactory::getServiceInstance('Tag2TagService');
|
2008-01-22 17:16:06 +01:00
|
|
|
$tagstatservice =& ServiceFactory::getServiceInstance('TagStatService');
|
2008-01-09 16:51:35 +01:00
|
|
|
|
2008-03-12 17:53:00 +01:00
|
|
|
// link '>'
|
|
|
|
if($level>1) {
|
|
|
|
$link = '<small><a href="'.createURL('tag2tagedit', $precedentTag.'/'.$tag).'" title="'._('Edit link').'">></a> </small>';
|
|
|
|
}
|
|
|
|
|
2008-01-09 16:51:35 +01:00
|
|
|
$output = '';
|
|
|
|
$output.= '<tr>';
|
|
|
|
$output.= '<td></td>';
|
2008-01-28 15:55:07 +01:00
|
|
|
$output.= '<td>';
|
2008-01-28 16:02:58 +01:00
|
|
|
$output.= $level == 1?'<b>':'';
|
2008-03-12 17:53:00 +01:00
|
|
|
$output.= str_repeat(' ', $level*2) .$link.'<a href="'. sprintf($cat_url, filter($user, 'url'), filter($tag, 'url')) .'" rel="tag">'. filter($tag) .'</a>';
|
2008-01-28 15:55:07 +01:00
|
|
|
$output.= $level == 1?'</b>':'';
|
2008-01-22 17:16:06 +01:00
|
|
|
//$output.= ' - '. $tagstatservice->getMaxDepth($tag, $linkType, $uId);
|
|
|
|
|
2008-01-28 15:55:07 +01:00
|
|
|
$synonymTags = $tag2tagservice->getAllLinkedTags($tag, '=', $uId);
|
|
|
|
$synonymTags = is_array($synonymTags)?$synonymTags:array($synonymTags);
|
|
|
|
sort($synonymTags);
|
2008-02-05 14:30:33 +01:00
|
|
|
$synonymList = '';
|
2008-01-28 15:55:07 +01:00
|
|
|
foreach($synonymTags as $synonymTag) {
|
2008-02-05 14:30:33 +01:00
|
|
|
//$output.= ", ".$synonymTag;
|
|
|
|
$synonymList.= $synonymTag.' ';
|
|
|
|
}
|
|
|
|
if(count($synonymTags)>0) {
|
|
|
|
$output.= ', '.$synonymTags[0];
|
|
|
|
}
|
|
|
|
if(count($synonymTags)>1) {
|
|
|
|
$output.= '<span title="'.T_('Synonyms:').' '.$synonymList.'">, etc</span>';
|
2008-01-28 15:55:07 +01:00
|
|
|
}
|
|
|
|
|
2008-03-12 17:53:00 +01:00
|
|
|
/*if($editingMode) {
|
2008-01-09 16:51:35 +01:00
|
|
|
$output.= ' (';
|
2008-03-12 17:53:00 +01:00
|
|
|
$output.= '<a href="'.createURL('tag2tagadd', $tag).'" title="'._('Add a subtag').'">+</a>';
|
|
|
|
if(1) {
|
2008-01-09 16:51:35 +01:00
|
|
|
$output.= ' - ';
|
2008-03-12 17:53:00 +01:00
|
|
|
$output.= '<a href="'.createURL('tag2tagdelete', $tag).'">-</a>';
|
2008-01-09 16:51:35 +01:00
|
|
|
}
|
|
|
|
$output.= ')';
|
2008-03-12 17:53:00 +01:00
|
|
|
}*/
|
2008-01-09 16:51:35 +01:00
|
|
|
$output.= '</td>';
|
|
|
|
$output.= '</tr>';
|
|
|
|
|
2008-01-28 15:55:07 +01:00
|
|
|
$tags = array($tag);
|
|
|
|
$tags = array_merge($tags, $synonymTags);
|
|
|
|
foreach($tags as $tag) {
|
|
|
|
|
|
|
|
if(!in_array($tag, $stopList)) {
|
|
|
|
$linkedTags = $tag2tagservice->getLinkedTags($tag, '>', $uId);
|
|
|
|
$precedentTag = $tag;
|
|
|
|
$stopList[] = $tag;
|
|
|
|
foreach($linkedTags as $linkedTag) {
|
|
|
|
$displayLinkedTags = displayLinkedTags($linkedTag, $linkType, $uId, $cat_url, $user, $editingMode, $precedentTag, $level + 1, $stopList);
|
|
|
|
$output.= $displayLinkedTags['output'];
|
|
|
|
}
|
|
|
|
if(is_array($displayLinkedTags['stopList'])) {
|
|
|
|
$stopList = array_merge($stopList, $displayLinkedTags['stopList']);
|
|
|
|
$stopList = array_unique($stopList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return array('output' => $output, 'stopList' => $stopList);
|
2008-01-09 16:51:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$logged_on_userid = $userservice->getCurrentUserId();
|
|
|
|
if ($logged_on_userid === false) {
|
|
|
|
$logged_on_userid = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
$explodedTags = array();
|
|
|
|
if ($currenttag) {
|
|
|
|
$explodedTags = explode('+', $currenttag);
|
|
|
|
} else {
|
2008-01-23 15:47:35 +01:00
|
|
|
if($summarizeLinkedTags == true) {
|
2008-01-22 17:16:06 +01:00
|
|
|
$orphewTags = $tag2tagservice->getOrphewTags('>', $userid, 4, "nb");
|
2008-01-23 15:47:35 +01:00
|
|
|
} else {
|
|
|
|
$orphewTags = $tag2tagservice->getOrphewTags('>', $userid);
|
2008-01-22 17:16:06 +01:00
|
|
|
}
|
|
|
|
|
2008-01-09 16:51:35 +01:00
|
|
|
foreach($orphewTags as $orphewTag) {
|
|
|
|
$explodedTags[] = $orphewTag['tag'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
2008-01-22 17:16:06 +01:00
|
|
|
<h2>
|
|
|
|
<?php
|
|
|
|
echo T_('Linked Tags').' ';
|
|
|
|
//if($userid != null) {
|
|
|
|
$cUser = $userservice->getUser($userid);
|
|
|
|
echo '<a href="'.createURL('alltags', $cUser['username']).'">('.T_('plus').')</a>';
|
|
|
|
//}
|
|
|
|
?>
|
|
|
|
</h2>
|
|
|
|
|
2008-02-20 14:47:33 +01:00
|
|
|
<?php if(count($explodedTags)>0):?>
|
2008-01-22 17:16:06 +01:00
|
|
|
|
2008-01-09 16:51:35 +01:00
|
|
|
<div id="linked">
|
|
|
|
<table>
|
|
|
|
<?php
|
2008-01-11 10:34:32 +01:00
|
|
|
if(($logged_on_userid != null) && ($userid === $logged_on_userid)) {
|
|
|
|
$editingMode = true;
|
|
|
|
} else {
|
|
|
|
$editingMode = false;
|
|
|
|
}
|
2008-02-05 14:30:33 +01:00
|
|
|
|
|
|
|
if($editingMode) {
|
|
|
|
echo '<tr><td></td><td>';
|
|
|
|
echo ' (<a href="'. createURL('tag2tagadd','') .'" rel="tag">'.T_('Add new link').'</a>) ';
|
|
|
|
echo ' (<a href="'. createURL('tag2tagdelete','') .'" rel="tag">'.T_('Delete link').'</a>)';
|
|
|
|
echo '</td></tr>';
|
|
|
|
}
|
|
|
|
|
2008-02-20 14:43:06 +01:00
|
|
|
if(strlen($user)==0) {
|
|
|
|
$cat_url = createURL('tags', '%2$s');
|
|
|
|
}
|
|
|
|
|
2008-01-28 15:55:07 +01:00
|
|
|
$stopList = array();
|
2008-01-09 16:51:35 +01:00
|
|
|
foreach($explodedTags as $explodedTag) {
|
2008-01-28 15:55:07 +01:00
|
|
|
if(!in_array($explodedTag, $stopList)) {
|
|
|
|
// fathers tag
|
|
|
|
$fatherTags = $tag2tagservice->getLinkedTags($explodedTag, '>', $userid, true);
|
|
|
|
if(count($fatherTags)>0) {
|
|
|
|
foreach($fatherTags as $fatherTag) {
|
2008-01-28 16:02:58 +01:00
|
|
|
echo '<tr><td></td><td>';
|
2008-01-28 15:55:07 +01:00
|
|
|
echo '<a href="'. sprintf($cat_url, filter($user, 'url'), filter($fatherTag, 'url')) .'" rel="tag">('. filter($fatherTag) .')</a>';
|
|
|
|
echo '</td></tr>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-28 16:02:58 +01:00
|
|
|
$displayLinkedTags = displayLinkedTags($explodedTag, '>', $userid, $cat_url, $user, $editingMode, null, 1);
|
2008-01-28 15:55:07 +01:00
|
|
|
echo $displayLinkedTags['output'];
|
|
|
|
if(is_array($displayLinkedTags['stopList'])) {
|
|
|
|
$stopList = array_merge($stopList, $displayLinkedTags['stopList']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-09 16:51:35 +01:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
</table>
|
|
|
|
</div>
|
2008-02-20 14:47:33 +01:00
|
|
|
|
|
|
|
<?php endif?>
|