]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Implement request #2874049: "Feeling lucky" button
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Mon, 2 Nov 2009 09:42:18 +0000 (09:42 +0000)
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>
Mon, 2 Nov 2009 09:42:18 +0000 (09:42 +0000)
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@506 b3834d28-1941-0410-a4f8-b48e95affb8f

doc/ChangeLog
doc/developers/TODO
www/search.php

index 13e3d65fa211c3bea6786521947fdc1d53424d3b..459ee8d823ab58594bf0033d7d5439a12a4cb7b8 100644 (file)
@@ -6,6 +6,8 @@ ChangeLog for SemantiScuttle
 - Implement request #2878169: Voting system
 - Fix bug #2881886: PHP notice when viewing tags
 - Configuration option to disable registration
+- Implement request #2874049: "Feeling lucky" button
+  just add "?lucky=1" as parameter to search page
 
 
 0.94 - 2009-10-02
index a827750e90937135f1904422380f9738909ed8c2..72ab582ba94af28ecae0fc0e880bcb72e5dd97c5 100644 (file)
@@ -107,5 +107,3 @@ Tracker items:
   So I'd define "freddy" as short url name in the bookmark, and anyone could
   access it e.g. via our-bookmarks.com/s/freddy and get redirected to the
   real url. Useful to get permanent URLs to moving targets.
-#2874049 - feeling lucky button
-  redirect to first search result
index c957b8077a276c1c83a4066a70a4cffe3530ff74..11c382caa05de2ff3ec9b77c25f74afb9b61faef 100644 (file)
@@ -113,10 +113,23 @@ if (is_null($terms)) {
 
     }
 }
-$bookmarks =& $bookmarkservice->getBookmarks($start, $perpage, $s_user, NULL, $terms, getSortOrder(), $s_watchlist, $s_start, $s_end);
+$bookmarks =& $bookmarkservice->getBookmarks(
+    $start, $perpage, $s_user, NULL, $terms, getSortOrder(),
+    $s_watchlist, $s_start, $s_end
+);
 
 // Save search
-$searchhistoryservice->addSearch($terms, $range, $bookmarks['total'], $currentUserId);
+$searchhistoryservice->addSearch(
+    $terms, $range, $bookmarks['total'], $currentUserId
+);
+
+if (isset($_GET['lucky']) && $_GET['lucky']
+    && isset($bookmarks['bookmarks'][0])
+) {
+    $url = $bookmarks['bookmarks'][0]['bAddress'];
+    header('Location: ' . $url);
+    exit();
+}
 
 if ($GLOBALS['enableGoogleCustomSearch']) {
     $tplVars['tipMsg'] = T_('Unsatisfied? You can also try our ')