Interface fix: menu2 just displays linked tags from admins
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@292 b3834d28-1941-0410-a4f8-b48e95affb8f
This commit is contained in:
parent
6bd34af288
commit
0c81abaa3e
5 changed files with 97 additions and 10 deletions
64
ajax/getadminlinkedtags.php
Normal file
64
ajax/getadminlinkedtags.php
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
<?php
|
||||||
|
/***************************************************************************
|
||||||
|
Copyright (C) 2004 - 2006 Scuttle project
|
||||||
|
http://sourceforge.net/projects/scuttle/
|
||||||
|
http://scuttle.org/
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
/* Return a json file with list of linked tags */
|
||||||
|
|
||||||
|
require_once('../header.inc.php');
|
||||||
|
|
||||||
|
/* Service creation: only useful services are created */
|
||||||
|
$b2tservice =& ServiceFactory::getServiceInstance('Bookmark2TagService');
|
||||||
|
$bookmarkservice =& ServiceFactory::getServiceInstance('TagService');
|
||||||
|
$tagstatservice =& ServiceFactory::getServiceInstance('TagStatService');
|
||||||
|
|
||||||
|
/* Managing all possible inputs */
|
||||||
|
isset($_GET['tag']) ? define('GET_TAG', $_GET['tag']): define('GET_TAG', '');
|
||||||
|
isset($_GET['uId']) ? define('GET_UID', $_GET['uId']): define('GET_UID', '');
|
||||||
|
|
||||||
|
|
||||||
|
function displayTag($tag, $uId) {
|
||||||
|
$uId = ($uId==0)?NULL:$uId; // if user is nobody, NULL allows to look for every public tags
|
||||||
|
|
||||||
|
$tag2tagservice =& ServiceFactory::getServiceInstance('Tag2TagService');
|
||||||
|
$output = '{ id:'.rand().', name:\''.$tag.'\'';
|
||||||
|
|
||||||
|
$linkedTags = $tag2tagservice->getAdminLinkedTags($tag, '>');
|
||||||
|
if(count($linkedTags) > 0) {
|
||||||
|
$output.= ', children: [';
|
||||||
|
foreach($linkedTags as $linkedTag) {
|
||||||
|
$output.= displayTag($linkedTag, $uId);
|
||||||
|
}
|
||||||
|
$output = substr($output, 0, -1); // remove final comma avoiding IE6 Dojo bug
|
||||||
|
$output.= "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
$output.= '},';
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
{ label: 'name', identifier: 'id', items: [
|
||||||
|
<?php
|
||||||
|
$json = displayTag(GET_TAG, GET_UID);
|
||||||
|
$json = substr($json, 0, -1); // remove final comma avoiding IE6 Dojo bug
|
||||||
|
echo $json;
|
||||||
|
?>
|
||||||
|
] }
|
|
@ -330,13 +330,10 @@ class Bookmark2TagService {
|
||||||
function &getAdminTags($limit = 30, $logged_on_user = NULL, $days = NULL) {
|
function &getAdminTags($limit = 30, $logged_on_user = NULL, $days = NULL) {
|
||||||
// look for admin ids
|
// look for admin ids
|
||||||
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
$admins = array();
|
$adminIds = $userservice->getAdminIds();
|
||||||
foreach($GLOBALS['admin_users'] as $adminName) {
|
|
||||||
$admins[] = $userservice->getIdFromUser($adminName);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ask for their tags
|
// ask for their tags
|
||||||
return $this->getPopularTags($admins, $limit, $logged_on_user, $days);
|
return $this->getPopularTags($adminIds, $limit, $logged_on_user, $days);
|
||||||
}
|
}
|
||||||
|
|
||||||
function &getContactTags($user, $limit = 30, $logged_on_user = NULL, $days = NULL) {
|
function &getContactTags($user, $limit = 30, $logged_on_user = NULL, $days = NULL) {
|
||||||
|
|
|
@ -43,6 +43,16 @@ class Tag2TagService {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Return linked tags just for admin users
|
||||||
|
function getAdminLinkedTags($tag, $relationType, $inverseRelation = false, $stopList = array()) {
|
||||||
|
// look for admin ids
|
||||||
|
$userservice = & ServiceFactory :: getServiceInstance('UserService');
|
||||||
|
$adminIds = $userservice->getAdminIds();
|
||||||
|
|
||||||
|
//ask for their linked tags
|
||||||
|
return $this->getLinkedTags($tag, $relationType, $adminIds, $inverseRelation, $stopList);
|
||||||
|
}
|
||||||
|
|
||||||
// Return the target linked tags. If inverseRelation is true, return the source linked tags.
|
// Return the target linked tags. If inverseRelation is true, return the source linked tags.
|
||||||
function getLinkedTags($tag, $relationType, $uId = null, $inverseRelation = false, $stopList = array()) {
|
function getLinkedTags($tag, $relationType, $uId = null, $inverseRelation = false, $stopList = array()) {
|
||||||
// Set up the SQL query.
|
// Set up the SQL query.
|
||||||
|
@ -63,7 +73,13 @@ class Tag2TagService {
|
||||||
if($relationType) {
|
if($relationType) {
|
||||||
$query.= " AND relationType = '". $relationType ."'";
|
$query.= " AND relationType = '". $relationType ."'";
|
||||||
}
|
}
|
||||||
if($uId != null) {
|
if(is_array($uId)) {
|
||||||
|
$query.= " AND ( 1=0 "; //tricks always false
|
||||||
|
foreach($uId as $u) {
|
||||||
|
$query.= " OR uId = '".$u."'";
|
||||||
|
}
|
||||||
|
$query.= " ) ";
|
||||||
|
} elseif($uId != null) {
|
||||||
$query.= " AND uId = '".$uId."'";
|
$query.= " AND uId = '".$uId."'";
|
||||||
}
|
}
|
||||||
//die($query);
|
//die($query);
|
||||||
|
|
|
@ -431,6 +431,16 @@ class UserService {
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns an array with admin uIds
|
||||||
|
function getAdminIds() {
|
||||||
|
$admins = array();
|
||||||
|
foreach($GLOBALS['admin_users'] as $adminName) {
|
||||||
|
if($this->getIdFromUser($adminName) != NULL)
|
||||||
|
$admins[] = $this->getIdFromUser($adminName);
|
||||||
|
}
|
||||||
|
return $admins;
|
||||||
|
}
|
||||||
|
|
||||||
function deleteUser($uId) {
|
function deleteUser($uId) {
|
||||||
$query = 'DELETE FROM '. $this->getTableName() .' WHERE uId = '. intval($uId);
|
$query = 'DELETE FROM '. $this->getTableName() .' WHERE uId = '. intval($uId);
|
||||||
|
|
||||||
|
|
|
@ -29,15 +29,15 @@ if (sizeOf($menu2Tags) > 0) {
|
||||||
<div id="related"><?php
|
<div id="related"><?php
|
||||||
foreach($menu2Tags as $menu2Tag) {
|
foreach($menu2Tags as $menu2Tag) {
|
||||||
|
|
||||||
echo '<div dojoType="dojo.data.ItemFileReadStore" url="ajax/getlinkedtags.php?tag='.filter($menu2Tag, 'url').'" jsid="linkedTagStore" ></div>';
|
echo '<div dojoType="dojo.data.ItemFileReadStore" url="ajax/getadminlinkedtags.php?tag='.filter($menu2Tag, 'url').'" jsid="linkedTagStore" ></div>';
|
||||||
echo '<div dojoType="dijit.Tree" store="linkedTagStore" labelAttr="name" >';
|
echo '<div dojoType="dijit.Tree" store="linkedTagStore" labelAttr="name" >';
|
||||||
echo '<script type="dojo/method" event="onClick" args="item">';
|
echo '<script type="dojo/method" event="onClick" args="item">';
|
||||||
$returnUrl = sprintf($cat_url, filter($user, 'url'), filter('', 'url'));
|
$returnUrl = sprintf($cat_url, filter($user, 'url'), filter('', 'url'));
|
||||||
echo 'window.location = "'.$returnUrl.'"+item.name';
|
echo 'window.location = "'.$returnUrl.'"+item.name';
|
||||||
echo '</script>';
|
echo '</script>';
|
||||||
echo '<script type="dojo/method" event="getLabelClass" args="item">';
|
//echo '<script type="dojo/method" event="getLabelClass" args="item">';
|
||||||
echo 'return \'treeTag\';';
|
//echo 'return \'treeTag\';';
|
||||||
echo '</script>';
|
//echo '</script>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue