summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SemanticScuttle/Service/Tag2Tag.php45
-rw-r--r--src/SemanticScuttle/Service/User.php20
-rw-r--r--src/SemanticScuttle/constants.php77
-rw-r--r--src/SemanticScuttle/header.php10
4 files changed, 109 insertions, 43 deletions
diff --git a/src/SemanticScuttle/Service/Tag2Tag.php b/src/SemanticScuttle/Service/Tag2Tag.php
index 8666209..33d211b 100644
--- a/src/SemanticScuttle/Service/Tag2Tag.php
+++ b/src/SemanticScuttle/Service/Tag2Tag.php
@@ -14,7 +14,7 @@
*/
/**
- * SemanticScuttle tag-to-tag service.
+ * SemanticScuttle tag-to-tag service which works with tag relations.
*
* @category Bookmarking
* @package SemanticScuttle
@@ -102,18 +102,49 @@ class SemanticScuttle_Service_Tag2Tag extends SemanticScuttle_DbService
return true;
}
- // Return linked tags just for admin users
- function getAdminLinkedTags($tag, $relationType, $inverseRelation = false, $stopList = array()) {
+
+
+ /**
+ * Same as getLinkedTags(), but only tags that have been created
+ * by admin users are returned.
+ *
+ * @param string $tag Tag to get related tags for
+ * @param string $relationType Type of tag-to-tag relation: >, < or =
+ * @param boolean $inverseRelation Reverse relation (parent -> child)
+ * @param array $stopList Array of tags that shall not be returned
+ *
+ * @return array Array of tag names
+ *
+ * @see getLinkedTags()
+ */
+ public function getAdminLinkedTags(
+ $tag, $relationType, $inverseRelation = false, $stopList = array()
+ ) {
// look for admin ids
$userservice = SemanticScuttle_Service_Factory :: get('User');
- $adminIds = $userservice->getAdminIds();
+ $adminIds = $userservice->getAdminIds();
//ask for their linked tags
- return $this->getLinkedTags($tag, $relationType, $adminIds, $inverseRelation, $stopList);
+ return $this->getLinkedTags(
+ $tag, $relationType, $adminIds, $inverseRelation, $stopList
+ );
}
- // Return the target linked tags. If inverseRelation is true, return the source linked tags.
- function getLinkedTags($tag, $relationType, $uId = null, $inverseRelation = false, $stopList = array()) {
+
+
+ /**
+ * Returns an array of tags that are in relation to the given $tag.
+ *
+ * @param string $tag Tag to get related tags for
+ * @param string $relationType Type of tag-to-tag relation: >, < or =
+ * @param boolean $inverseRelation Reverse relation (parent -> child)
+ * @param array $stopList Array of tags that shall not be returned
+ *
+ * @return array Array of tag names
+ */
+ public function getLinkedTags(
+ $tag, $relationType, $uId = null, $inverseRelation = false, $stopList = array()
+ ) {
// Set up the SQL query.
if($inverseRelation) {
$queriedTag = "tag1";
diff --git a/src/SemanticScuttle/Service/User.php b/src/SemanticScuttle/Service/User.php
index 091ea4d..9ef8430 100644
--- a/src/SemanticScuttle/Service/User.php
+++ b/src/SemanticScuttle/Service/User.php
@@ -203,18 +203,26 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
}
}
- /* Takes an numerical "id" or a string "username"
- and returns the numerical "id" if the user exists else returns NULL */
- function getIdFromUser($user) {
+ /**
+ * Obtains the ID of the given user name.
+ * If a user ID is passed, it is returned.
+ * In case the user does not exist, NULL is returned.
+ *
+ * @param string|integer $user User name or user ID
+ *
+ * @return integer NULL if not found or the user ID
+ */
+ public function getIdFromUser($user)
+ {
if (is_int($user)) {
return intval($user);
} else {
$objectUser = $this->getObjectUserByUsername($user);
- if($objectUser != NULL) {
+ if ($objectUser != null) {
return $objectUser->getId();
}
}
- return NULL;
+ return null;
}
/**
@@ -359,7 +367,7 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
return (int)$_SESSION[$this->getSessionKey()];
} else if (isset($_COOKIE[$this->getCookieKey()])) {
- $cook = split(':', $_COOKIE[$this->getCookieKey()]);
+ $cook = explode(':', $_COOKIE[$this->getCookieKey()]);
//cookie looks like this: 'id:md5(username+password)'
$query = 'SELECT * FROM '. $this->getTableName() .
' WHERE MD5(CONCAT('.$this->getFieldName('username') .
diff --git a/src/SemanticScuttle/constants.php b/src/SemanticScuttle/constants.php
index 95c4384..b023840 100644
--- a/src/SemanticScuttle/constants.php
+++ b/src/SemanticScuttle/constants.php
@@ -1,34 +1,51 @@
<?php
-/*
+/**
* Define constants used in all the application.
* Some constants are based on variables from configuration file.
+ *
+ * SemanticScuttle - your social bookmark manager.
+ *
+ * PHP version 5.
+ *
+ * @category Bookmarking
+ * @package SemanticScuttle
+ * @subcategory Base
+ * @author Benjamin Huynh-Kim-Bang <mensonge@users.sourceforge.net>
+ * @author Christian Weiske <cweiske@cweiske.de>
+ * @author Eric Dane <ericdane@users.sourceforge.net>
+ * @license GPL http://www.gnu.org/licenses/gpl.html
+ * @link http://sourceforge.net/projects/semanticscuttle
*/
// Debug managament
-if(isset($GLOBALS['debugMode'])) {
- define('DEBUG_MODE', $GLOBALS['debugMode']);
- define('DEBUG_EXTRA', $GLOBALS['debugMode']); // Constant used exclusively into db/ directory
+if (isset($GLOBALS['debugMode'])) {
+ define('DEBUG_MODE', $GLOBALS['debugMode']);
+ // Constant used exclusively into db/ directory
+ define('DEBUG_EXTRA', $GLOBALS['debugMode']);
}
// Determine the base URL as ROOT
if (!isset($GLOBALS['root'])) {
- $pieces = explode('/', $_SERVER['SCRIPT_NAME']);
-
- $rootTmp = '/';
- foreach ($pieces as $piece) {
- //we eliminate possible sscuttle subfolders (like gsearch for example)
- if ($piece != '' && !strstr($piece, '.php') && $piece != 'gsearch') {
- $rootTmp .= $piece .'/';
- }
- }
- if (($rootTmp != '/') && (substr($rootTmp, -1, 1) != '/')) {
- $rootTmp .= '/';
- }
-
- define('ROOT', 'http://'. $_SERVER['HTTP_HOST'] . $rootTmp);
+ $pieces = explode('/', $_SERVER['SCRIPT_NAME']);
+
+ $rootTmp = '/';
+ foreach ($pieces as $piece) {
+ //we eliminate possible sscuttle subfolders (like gsearch for example)
+ if ($piece != '' && !strstr($piece, '.php')
+ && $piece != 'gsearch' && $piece != 'ajax'
+ ) {
+ $rootTmp .= $piece .'/';
+ }
+ }
+ if (($rootTmp != '/') && (substr($rootTmp, -1, 1) != '/')) {
+ $rootTmp .= '/';
+ }
+
+ define('ROOT', 'http://'. $_SERVER['HTTP_HOST'] . $rootTmp);
} else {
- define('ROOT', $GLOBALS['root']);
+ define('ROOT', $GLOBALS['root']);
}
+define('ROOT_JS', ROOT . 'js/jstree-1.0-rc2/');
// Error codes
define('GENERAL_MESSAGE', 200);
@@ -44,19 +61,21 @@ define('PAGE_WATCHLIST', "watchlist");
// Miscellanous
-// INSTALLATION_ID is based on directory DB and used as prefix (in session and cookie) to prevent mutual login for different installations on the same host server
+// INSTALLATION_ID is based on directory DB and used as prefix
+// (in session and cookie) to prevent mutual login for different
+// installations on the same host server
define('INSTALLATION_ID', md5($GLOBALS['dbname'].$GLOBALS['tableprefix']));
// Correct bugs with PATH_INFO (maybe for Apache 1 or CGI) -- for 1&1 host...
if (isset($_SERVER['PATH_INFO']) && isset($_SERVER['ORIG_PATH_INFO'])) {
- if(strlen($_SERVER["PATH_INFO"])<strlen($_SERVER["ORIG_PATH_INFO"])) {
- $_SERVER["PATH_INFO"] = $_SERVER["ORIG_PATH_INFO"];
- }
- if(strcasecmp($_SERVER["PATH_INFO"], $_SERVER["SCRIPT_NAME "]) == 0) {
- unset($_SERVER["PATH_INFO"]);
- }
- if(strpos($_SERVER["PATH_INFO"], '.php') !== false) {
- unset($_SERVER["PATH_INFO"]);
- }
+ if (strlen($_SERVER["PATH_INFO"])<strlen($_SERVER["ORIG_PATH_INFO"])) {
+ $_SERVER["PATH_INFO"] = $_SERVER["ORIG_PATH_INFO"];
+ }
+ if (strcasecmp($_SERVER["PATH_INFO"], $_SERVER["SCRIPT_NAME "]) == 0) {
+ unset($_SERVER["PATH_INFO"]);
+ }
+ if (strpos($_SERVER["PATH_INFO"], '.php') !== false) {
+ unset($_SERVER["PATH_INFO"]);
+ }
}
?>
diff --git a/src/SemanticScuttle/header.php b/src/SemanticScuttle/header.php
index 4fecb8f..9c5f7da 100644
--- a/src/SemanticScuttle/header.php
+++ b/src/SemanticScuttle/header.php
@@ -121,7 +121,15 @@ $tplVars['userservice'] = $userservice;
if (!defined('UNIT_TEST_MODE')) {
//API files define that, so we need a way to support both of them
if (!isset($httpContentType)) {
- $httpContentType = 'text/html';
+ if (DEBUG_MODE) {
+ //using that mime type makes all javascript nice in Chromium
+ // it also serves as test base if the pages really validate
+ $httpContentType = 'application/xhtml+xml';
+ } else {
+ //until we are sure that all pages validate, we
+ // keep the non-strict mode on for normal installations
+ $httpContentType = 'text/html';
+ }
}
if ($httpContentType !== false) {
header('Content-Type: ' . $httpContentType . '; charset=utf-8');