[ros-diffs] [frik85] 22584: RSDB: * add more options to the AJAX search script RosCMS: * add AJAX website content search script
frik85 at svn.reactos.org
frik85 at svn.reactos.org
Sat Jun 24 22:22:53 CEST 2006
Author: frik85
Date: Sun Jun 25 00:22:53 2006
New Revision: 22584
URL: http://svn.reactos.org/svn/reactos?rev=22584&view=rev
Log:
RSDB:
* add more options to the AJAX search script
RosCMS:
* add AJAX website content search script
Added:
trunk/web/reactos.org/htdocs/roscms/search.php
Modified:
trunk/web/reactos.org/htdocs/support/search.js
Added: trunk/web/reactos.org/htdocs/roscms/search.php
URL: http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/roscms/search.php?rev=22584&view=auto
==============================================================================
--- trunk/web/reactos.org/htdocs/roscms/search.php (added)
+++ trunk/web/reactos.org/htdocs/roscms/search.php Sun Jun 25 00:22:53 2006
@@ -1,0 +1,82 @@
+<?php
+ /*
+ RosCMS - Search Function
+ Copyright (C) 2005-2006 Klemens Friedl <frik85 at reactos.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., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+ require_once("connect.db.php");
+
+ $RSDB_SET_search=""; // Search string
+ $RSDB_SET_search_lang=""; // Search language
+ if (array_key_exists("search", $_GET)) $RSDB_SET_search=htmlspecialchars($_GET["search"]);
+ if (array_key_exists("searchlang", $_GET)) $RSDB_SET_search_lang=htmlspecialchars($_GET["searchlang"]);
+ if ($RSDB_SET_search_lang == "en") {
+ $RSDB_SET_search_lang = "all";
+ }
+
+ $query_count_groups=mysql_query("SELECT COUNT(content_id)
+ FROM `content`, `pages`
+ WHERE content_active = '1'
+ AND
+ ( content_name LIKE '%" . mysql_real_escape_string($RSDB_SET_search) . "%'
+ OR content_text LIKE '%" . mysql_real_escape_string($RSDB_SET_search) . "%'
+ )
+ AND content_name = page_name
+ AND page_active = '1'
+ AND content_lang = '". mysql_real_escape_string($RSDB_SET_search_lang) ."'
+ ORDER BY `page_name` ASC
+ LIMIT 0 , 20 ;");
+ $result_count_groups = mysql_fetch_row($query_count_groups);
+
+header( 'Content-type: text/xml' );
+echo '<?xml version="1.0" encoding="UTF-8"?>
+<root>
+';
+
+ if (!$result_count_groups[0]) {
+ echo " #none#\n";
+ }
+ else {
+ echo " ".$result_count_groups[0]."\n";
+ }
+
+if ($RSDB_SET_search != "" || strlen($RSDB_SET_search) > 1) {
+
+ $query_page = mysql_query("SELECT content.content_name, content.content_id, pages.page_title
+ FROM `content`, `pages`
+ WHERE content_active = '1'
+ AND
+ ( content_name LIKE '%" . mysql_real_escape_string($RSDB_SET_search) . "%'
+ OR content_text LIKE '%" . mysql_real_escape_string($RSDB_SET_search) . "%'
+ )
+ AND content_name = page_name
+ AND page_active = '1'
+ AND content_lang = '". mysql_real_escape_string($RSDB_SET_search_lang) ."'
+ GROUP BY page_name, content_name
+ ORDER BY `content_id` DESC
+ LIMIT 0 , 15 ;");
+ while($result_page = mysql_fetch_array($query_page)) { // Pages
+?>
+ <dbentry>
+ <content id="<?php echo $result_page['page_title']; ?>"><?php echo $result_page['content_name']; ?></content>
+ </dbentry>
+<?
+ }
+}
+?>
+</root>
Modified: trunk/web/reactos.org/htdocs/support/search.js
URL: http://svn.reactos.org/svn/reactos/trunk/web/reactos.org/htdocs/support/search.js?rev=22584&r1=22583&r2=22584&view=diff
==============================================================================
--- trunk/web/reactos.org/htdocs/support/search.js (original)
+++ trunk/web/reactos.org/htdocs/support/search.js Sun Jun 25 00:22:53 2006
@@ -11,8 +11,10 @@
var tWhere = "";
var tPicAnimation = "";
var tResults = "";
- var twebsite = "http://localhost/reactos.org/support/index.php";
- //var twebsite = "http://www.reactos.org/support/index.php";
+ //var twebsite = "http://localhost/reactos.org/support/index.php";
+ //var twebsite2 = "http://localhost/reactos.org/";
+ var twebsite = "http://www.reactos.org/support/index.php";
+ var twebsite2 = "http://www.reactos.org/";
function writeItemList_style_header() {
@@ -58,6 +60,12 @@
return tempb;
}
+ function write_rosweb_entry(itemname, itemid) {
+ var tempb = "";
+ tempb += "<a href=\""+twebsite2+"?page=" + itemid + "\">• " + itemname + "</a>\n";
+ return tempb;
+ }
+
function write_compsubmit_header() {
var tempa = "";
@@ -137,32 +145,37 @@
if (asearch.length > 1) {
document.getElementById(tResults).style.display = "block";
document.getElementById(tPicAnimation).style.display = "inline";
- if (asearch != "") {
- setCursor('wait');
- if (http_request && (http_request.readyState == 2 || http_request.readyState == 3)) {
- http_request.abort(); // stop running request
- }
-
- if (tWhere == "comp") {
- makeRequest(twebsite+'?page=dat&export=grplst&search='+asearch);
- }
- else if (tWhere == "vendor") {
- //alert("vendor");
- makeRequest(twebsite+'?page=dat&export=vdrlst&search='+asearch);
- }
- }
- }
- else {
+ if (asearch != "") {
+ setCursor('wait');
+ if (http_request && (http_request.readyState == 2 || http_request.readyState == 3)) {
+ http_request.abort(); // stop running request
+ }
+
+
+ if (tWhere == "comp") {
+ makeRequest(twebsite+'?page=dat&export=grplst&search='+asearch);
+ }
+ else if (tWhere == "vendor") {
+ //alert("vendor");
+ makeRequest(twebsite+'?page=dat&export=vdrlst&search='+asearch);
+ }
+ else if (tWhere.substr(0, 6) == "roscms") {
+ //alert("vendor");
+ makeRequest(twebsite2+'roscms/search.php?search='+asearch+'&searchlang='+tWhere.substr(7, 2));
+ }
+ }
+ }
+ else {
document.getElementById(tResults).style.display = "none";
document.getElementById(tPicAnimation).style.display = "none";
deleteItemList();
- }
+ }
}
function setCursor(mode) {
- var pageBody = document.getElementsByTagName("body")[0];
- pageBody.style.cursor = mode;
+ var pageBody = document.getElementsByTagName("body")[0];
+ pageBody.style.cursor = mode;
}
@@ -230,7 +243,10 @@
var vendo = http_request.responseXML.getElementsByTagName("vendor");
var vendurl = http_request.responseXML.getElementsByTagName("url");
}
-
+ else if (tWhere.substr(0, 6) == "roscms") {
+ var webcontent = http_request.responseXML.getElementsByTagName("content");
+ }
+
// Colors:
var colorcur="";
var color1="#E2E2E2";
@@ -245,7 +261,10 @@
else if (tWhere == "vendor") {
xmllength = vendo.length;
}
-
+ else if (tWhere.substr(0, 6) == "roscms") {
+ xmllength = webcontent.length;
+ }
+
// XML-Loop:
for (var i = 0; i < xmllength; i++) {
// Table colors:
@@ -271,6 +290,10 @@
else if (tView == "submit_vendor") {
lstData += write_vendorsubmit_entry(vendo[i].getAttributeNode("id").value, vendo[i].firstChild.data, vendurl[i].firstChild.data, colorcur);
}
+ else if (tView == "rosweb") {
+ lstData += write_rosweb_entry(webcontent[i].getAttributeNode("id").value, webcontent[i].firstChild.data);
+ }
+
}
// Table footer:
@@ -307,6 +330,9 @@
}
else if (tView == "submit_vendor") {
document.getElementById(tResults).innerHTML = "<p>Your search - " + tSearch + " - did not match any database entries.</p><p>Choose a vendor from the <b><a href=\"javascript://\" onclick=\"SelectVendor()\">vendor list</a></b> or <b><a href=\"javascript://\" onclick=\"AddVendor()\">submit a new vendor</a></b> to the database.</p>";
+ }
+ else if (tView == "rosweb") {
+ document.getElementById(tResults).innerHTML = "<center>no entries found</center>";
}
}
More information about the Ros-diffs
mailing list