]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
New feature: add Google Custom Search into gsearch folder
authormensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sun, 1 Jun 2008 13:17:54 +0000 (13:17 +0000)
committermensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f>
Sun, 1 Jun 2008 13:17:54 +0000 (13:17 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@133 b3834d28-1941-0410-a4f8-b48e95affb8f

api/export_gcs.php
config.inc.php.example
constants.inc.php
gsearch/context.php [new file with mode: 0644]
gsearch/index.php [new file with mode: 0644]
upgrade.txt

index c8bf59d59a53c2dcc42807d949dd1c7b8b6ff9a4..48d51c18513538cac19f9041509f35df8c0a52d4 100644 (file)
@@ -1,13 +1,13 @@
 <?php
 /*
 Export for Google Custom Search
-*/\r
-\r
+*/
+
 // Force HTTP authentication first!
-//require_once('httpauth.inc.php');\r
-require_once('../header.inc.php');\r
-\r
-$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');\r
+//require_once('httpauth.inc.php');
+require_once('../header.inc.php');
+
+$bookmarkservice =& ServiceFactory::getServiceInstance('BookmarkService');
 $userservice =& ServiceFactory::getServiceInstance('UserService');
 
 /*
@@ -16,25 +16,44 @@ if(!$userservice->isAdmin($userservice->getCurrentUserId())) {
     die(T_('You are not allowed to do this action (admin access)'));
 }*/
 
-\r
-\r
-// Check to see if a tag was specified.\r
-if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))\r
-    $tag = trim($_REQUEST['tag']);\r
-else\r
-    $tag = NULL;\r
-\r
-// Get the posts relevant to the passed-in variables.\r
-$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, $tag, NULL, getSortOrder());\r
-\r
-$currentuser = $userservice->getCurrentUser();\r
-$currentusername = $currentuser[$userservice->getFieldName('username')];\r
-\r
-// Set up the plain file and output all the posts.\r
-header('Content-Type: text/plain');\r\r
-foreach($bookmarks['bookmarks'] as $row) {\r
-    echo $row['bAddress']."\n";\r
-}\r
-\r
-\r\r
-?>\r
+// Check if queried format is xml
+if (isset($_REQUEST['xml']) && (trim($_REQUEST['xml']) == 1))
+    $xml = true;
+else
+    $xml = false;
+
+// Check to see if a tag was specified.
+if (isset($_REQUEST['tag']) && (trim($_REQUEST['tag']) != ''))
+    $tag = trim($_REQUEST['tag']);
+else
+    $tag = NULL;
+
+// Get the posts relevant to the passed-in variables.
+$bookmarks =& $bookmarkservice->getBookmarks(0, NULL, NULL, $tag, NULL, getSortOrder());
+
+$currentuser = $userservice->getCurrentUser();
+$currentusername = $currentuser[$userservice->getFieldName('username')];
+
+// Set up the plain file and output all the posts.
+header('Content-Type: text/plain');
+if(!$xml) {
+    header('Content-Type: text/plain');
+    foreach($bookmarks['bookmarks'] as $row) {
+       echo $row['bAddress']."\n";
+    }
+} else {
+    header('Content-Type: application/xml');
+    echo '<GoogleCustomizations>'."\n";
+    echo '  <Annotations>'."\n";
+    foreach($bookmarks['bookmarks'] as $row) {
+       if(substr($row['bAddress'], 0, 7) == "http://") {
+           echo '    <Annotation about="'.filter($row['bAddress']).'">'."\n";
+           echo '      <Label name="include"/>'."\n";
+           echo '    </Annotation>'."\n";
+       }
+    }
+    echo '  </Annotations>'."\n";
+    echo '</GoogleCustomizations>'."\n";
+}
+
+?>
index cf0fed0e90f0e0a8fda8112dae005822502a4f09..7b9eff9a7393cf40e53914e45318448976a12307 100644 (file)
@@ -9,7 +9,7 @@
 #### System ####
 $sitename           = 'SemanticScuttle'; #The name of this site.
 $welcomeMessage     = 'Welcome to SemanticScuttle! More than a social bookmarking tool.'; # The welcome message of this site
-$root               = NULL; # Set to NULL to autodetect the root url of the website
+$root               = NULL; # Set to NULL to autodetect the root url of the website. If your installation is into a subdirectory like "www.example.com/semanticscuttle/" then replace NULL by your address (between "" and with final '/');
 $locale             = 'en_GB'; #locale used in /locales/ {de_DE  en_GB  fr_FR  ...}
 $usecache           = false; # use cache ? {true,false}
 $dir_cache          = dirname(__FILE__) .'/cache/'; # directory where cache files will be stored
@@ -77,6 +77,7 @@ $maxSizeMenuBlock = 7; # maximum number of items (tags) appearing into menu box
 
 ### Other ###
 $sizeSearchHistory = 10; # number of users' searches that are saved {1..10[Default]..-1[Unlimited]}
+$enableGoogleCustomSearch = true; #Enable Google Search Engine into "gsearch/" folder
 
 include_once('debug.inc.php');
 ?>
index 256ea2acbf5eaf1104b8585a91684fc66f279608..cadaffa4299e55432ad587f7452696f3d50af573 100644 (file)
@@ -13,8 +13,7 @@ define('PAGE_BOOKMARKS', "bookmarks");
 
 // Miscellanous
 
-// INSTALLATION_ID is based on directory  path and used as prefix (in session and cookie) to prevent mutual login for different installations on the same host server
-//define('INSTALLATION_ID', md5(dirname(realpath('.'))));
+// 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']));
 
 ?>
diff --git a/gsearch/context.php b/gsearch/context.php
new file mode 100644 (file)
index 0000000..a48179f
--- /dev/null
@@ -0,0 +1,20 @@
+<?php require_once('../header.inc.php');?>
+
+<!--?xml version="1.0" encoding="UTF-8" ?-->
+<GoogleCustomizations>
+    <CustomSearchEngine>
+        <Title><?php echo $GLOBALS['sitename'] ?></Title>
+        <Description><?php echo $GLOBALS['welcomeMessage'] ?></Description>
+        <Context>
+           <BackgroundLabels>
+             <Label name="include" mode="FILTER" />
+          </BackgroundLabels>
+        </Context>
+        <LookAndFeel nonprofit="false">
+        </LookAndFeel>
+    </CustomSearchEngine>
+
+    <Include type="Annotations" href="<?php echo $GLOBALS['root'];?>api/export_gcs.php?xml=1" />
+
+
+</GoogleCustomizations>
diff --git a/gsearch/index.php b/gsearch/index.php
new file mode 100644 (file)
index 0000000..d4f596d
--- /dev/null
@@ -0,0 +1,36 @@
+<?php require_once('../header.inc.php');
+
+if($GLOBALS['enableGoogleCustomSearch']==false) {
+    echo "Google Custom Search disabled. You can enable it into the config.inc.php file.";
+    die;
+}
+?>
+
+<html>
+<title><?php echo $GLOBALS['sitename'] ?></title>
+<body>
+<center>
+<br />
+
+<!-- Google CSE Search Box Begins  -->
+<form id="cref" action="http://www.google.com/cse">
+  <input type="hidden" name="cref" value="<?php echo $GLOBALS['root']?>gsearch/context.php" />
+  <input type="text" name="q" size="40" />
+  <input type="submit" name="sa" value="Search" />
+</form>
+<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cref"></script>
+<!-- Google CSE Search Box Ends -->
+<small>Based on <a href="http://www.google.com/coop/cse/">Google Custom Search</a> over this <a href="../api/export_gcs.php">list of websites</a> from <?php echo $GLOBALS['sitename'] ?>.</small>
+
+
+<!--
+To refresh manually Google Custom Search Engine, goes to: http://www.google.com/coop/cse/cref
+-->
+
+
+
+</center>
+</body>
+</html>
+
+
index 792c04c41d94067308fc5fe8ca39220d8b270a31..163fce79d4b4f4a987391b3b702e70e822837aca 100644 (file)
@@ -37,5 +37,7 @@
        $sizeSearchHistory = 10;
   - add sidebar block index line:
        $index_sidebar_blocks = array('search','menu','users','popular');
+  - add line:
+       $enableGoogleCustomSearch = true;