Search Function does not find some important Content Parts:(

Use GitHub to post feature requests for phpwcms.
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

Search Function does not find some important Content Parts:(

Post by StudioZ »

I already submitted this issue, a good while ago,
to the now dead Mantis Bugs/Features site...
Would someone know of a quick way...
to make these types of content parts searchable: ?
- file list (I have about 300 PDFs files waiting to be searched)
- link & email (I have about 250 outside links waiting to be searched)

:?: :?: :?:

Thanks..
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
User avatar
pico
Posts: 2595
Joined: Wed 28. Jul 2004, 18:04
Location: Frankfurt/M Germany
Contact:

Post by pico »

Hi

the actual Search-Function only searches the Content - a advanced Version is in preperation AFAIK
Lieber Gott gib mir Geduld - ABER BEEIL DICH
Horst - find me at Musiker-Board
User avatar
StudioZ
Posts: 802
Joined: Fri 28. May 2004, 19:57
Location: Québec, Canada
Contact:

Post by StudioZ »

pico wrote:Hi

the actual Search-Function only searches the Content - a advanced Version is in preperation AFAIK
Hi Pico,
Heard that too :D :wink:
Cheers,
Image
PhpWCMS Evangelist, -- iRoutier.com Running phpWCMS 1.4.2, r354 -> Great Version!!!!
frold
Posts: 2151
Joined: Tue 25. Nov 2003, 22:42

Post by frold »

I guess it will come some day....
http://www.studmed.dk Portal for doctors and medical students in Denmark
sebby
Posts: 28
Joined: Thu 28. Apr 2005, 00:31

Post by sebby »

Hello all-

Here is a quick fix for searching files (1.1RC4). In include/inc_front/content/cnt13.article.inc.php, add the following code before the closing tag (strongly inspired from the backend search engine):

Code: Select all

///SEARCHING FILES///////

//Suche template
$content["main"] .= "<br><br><b>SEARCHING FILES...</b><hr size=1>";
			
if(intval($_POST["file_aktion"]) == 1) {
	$search_string	= $content["search_word"];	
	
	if(sizeof($search_string)) {
		foreach($search_string as $key => $value) {
			if(trim($value)) $search["key"][$key] = trim($value);
		}
		unset($search_string);
		if(sizeof($search["key"])) {					
			$search["andor"] = true; // Boolean search 'AND'
			$file_key = get_list_of_file_keywords(); //Auslesen der File Schlüsselwörter
			
			//Aufbau des eigentlichen Suchstrings
			// this search is limited to public pdf files (can specify whatever you want here)
			$sql = "SELECT * FROM ".DB_PREPEND."phpwcms_file WHERE f_aktiv=1 AND f_trash=0 AND f_kid=1 AND f_public=1 AND f_type='application/pdf' ";

			if($result = mysql_query($sql, $db) or die ("error while running search")) {
				while($row = mysql_fetch_array($result)) {
					$search["string"]  = $row["f_name"]." ".$row["f_shortinfo"]." ".$row["f_longinfo"];
					$search["string"]  = str_replace("\r\n", " ", $search["string"]);
					$search["string"]  = str_replace("\n", " ", $search["string"]);
					$search["string"] .= add_keywords_to_search ($file_key, $row["f_keywords"]); //fügt freie Keywords zum Suchstring hinzu
					
					foreach($search["key"] as $value) {
						if(preg_match("/".preg_quote($value,"/")."/i", $search["string"])) {
							if($search["andor"]) {
								if(!isset($search["result"][$row["f_id"]])) {; //AND clause
									$search["result"][$row["f_id"]] = 1;
								} else {
									$search["result"][$row["f_id"]]++;
								}
							} else {
								$search["result"][$row["f_id"]] = 1; //OR clause
							}
						}
					}
				}
				if(sizeof($search["result"]) && $search["andor"]) {
					//Prüfen, ob die AND bedingung erfüllt ist
					//gilt nur, wenn Anzahl Suchworte = Anzahl Funde im String
					$search["count_key"] = sizeof($search["key"]);
					foreach($search["result"] as $key => $value) {
						if($search["count_key"] != $value) unset($search["result"][$key]);
					}
				}	
			}													
		} else {
			$search["error"][1] = "error 1".$BL['be_fsearch_err1'];
		}
	} else {
		$search["error"][1] = "error 2".$BL['be_fsearch_err1'];
	}
}

if(isset($search["result"]) && !empty($search["result"])) { 
	//Beginn Tabelle für Dateilisting
	$content["main"] .= "<table width=\"538\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n";
	$content["main"] .= "<tr><td colspan=\"2\"><img src=\"img/leer.gif\" width=\"1\" height=\"1\"></td></tr>\n";

	$sl=0; $search["filelist"] = " ";
	foreach($search["result"] as $key => $value) {
		if($sl) $search["filelist"] .=" OR ";
		$search["filelist"] .= "f_id=".intval($key);
		$sl++;					
	}

	//Listing der gefundenen Dateien
	$file_sql = "SELECT * FROM ".DB_PREPEND."phpwcms_file WHERE (".
				( (trim($search["filelist"])) ? $search["filelist"] : 0 ).
				") AND f_kid=1 AND f_trash=0 ORDER BY f_name;";
	if($file_result = mysql_query($file_sql, $db) or die ("error while listing files")) {
		$file_durchlauf = 0;
		while($file_row = mysql_fetch_array($file_result)) {
			$filename = html_specialchars($file_row["f_name"]);
			if(!$file_durchlauf) { //Aufbau der Zeile zum Einfließen der Filelisten-Tavbelle
				$content["main"] .= "<tr bgcolor=\"#F5F8F9\"><td colspan=\"2\"><table width=\"538\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n"; 
			} else {
				$content["main"] .= "<tr bgcolor=\"#FFFFFF\"><td colspan=\"5\"><img src=\"img/sp1.gif\" height=\"1\" width=\"1\"></td></tr>\n";
			}
			$content["main"] .= "<tr>\n";
			$content["main"] .= "<td width=\"6\" class=\"msglist\"><img src=\"img/sp1.gif\" height=\"1\" width=\"6\" border=\"0\"></td>\n";
			$content["main"] .= "<td width=\"13\" class=\"msglist\">";
			$content["main"] .= "<img src=\"img/icons/small_".extimg($file_row["f_ext"])."\" border=\"0\"></td>\n";
			$content["main"] .= "<td width=\"504\" class=\"msglist\"><img src=\"img/sp1.gif\" height=\"1\" width=\"5\">";
			$content["main"] .= "<a href=\"download.php?id=".$file_row["f_size"].",".$file_row["f_id"].",".$file_row["f_uid"]."\" title=\"download file ".$filename."\" target=\"_blank\">";
			$content["main"] .= $filename."</a>";
			$content["main"] .= "</td>\n";
			$content["main"] .= "<td widht=\"15\" class=\"v10\" align=\"right\">&nbsp;&nbsp;&nbsp;";
			$content["main"] .= fsizelong($file_row["f_size"]);
			$content["main"] .= "</td></tr>\n";
			$content["main"] .= "<tr>";
			$content["main"] .= "<td width=\"6\" class=\"msglist\"><img src=\"img/sp1.gif\" height=\"1\" width=\"6\" border=\"0\"></td>\n";
			$content["main"] .= "<td width=\"13\" class=\"msglist\"><img src=\"img/sp1.gif\" height=\"1\" width=\"13\" border=\"0\"></td>\n";
			if (!empty($file_row["f_longinfo"])) $content["main"] .= "<td colspan=\"2\" class=\"v09\"><img src=\"img/sp1.gif\" height=\"1\" width=\"10\"><table border=0><tr><td class=\"v09\">".substr($file_row["f_longinfo"], 0, 200)."...<br />&nbsp;</td></tr></table></td></tr>\n";
			$file_durchlauf++;
		}
		if($file_durchlauf) { //Abschluss der Filelisten-Tabelle
			$content["main"] .= "</table>\n";
			$content["main"] .= "<tr bgcolor=\"#F5F8F9\"><td colspan=\"2\"><img src=\"img/sp1.gif\" height=\"1\" width=\"1\"></td></tr>\n"; //Abstand vor
		} else {
			$content["main"] .= "<tr><td colspan=\"2\">";
			$content["main"] .= "<img src=\"img/leer.gif\" width=\"1\" height=\"6\"><br /><span class=\"error\" style=\"font-weight: bold;\">";			
			$content["main"] .= "&nbsp;&nbsp;&nbsp;&nbsp;".$BL['be_fsearch_nonfound'];
			$content["main"] .= "</span><br /><img src=\"img/leer.gif\" width=\"1\" height=\"10\"></td></tr>\n";
		}
	} //Ende Liste Dateien
	
	$content["main"] .= "</table>\n"; //Ende Tabelle

} else {
	//kein gültiges Suchergebnis
	if(isset($search["string"])) {			
		$content["main"] .= "<img src=\"img/leer.gif\" width=\"1\" height=\"6\"><br /><span class=\"error\">";			
		$content["main"] .= "&nbsp;&nbsp;&nbsp;&nbsp;No matching files!";
		$content["main"] .= "</span><br /><img src=\"img/leer.gif\" width=\"1\" height=\"6\">";
	} else {
		$content["main"] .= "<img src=\"img/leer.gif\" width=\"1\" height=\"6\"><br /><font color=\"red\">";			
		$content["main"] .= "&nbsp;&nbsp;&nbsp;&nbsp;Invalid search criteria !";
		$content["main"] .= "</font><br /><img src=\"img/leer.gif\" width=\"1\" height=\"6\">";
	}
}
Note that you must add 'file_aktion = 1' as hidden var in your frontend search form.

Cheers !

Seb
Last edited by sebby on Sat 8. Apr 2006, 19:36, edited 1 time in total.
User avatar
wireless
Posts: 138
Joined: Sun 24. Oct 2004, 04:35
Location: Houston, Texas

Post by wireless »

Could you expand on this some more
sebby
Posts: 28
Joined: Thu 28. Apr 2005, 00:31

Post by sebby »

Wireless: what do you want to know?

Whereas the frontend search script was parsing only text/html like content parts, this mod allows you to search directly from the database all files that were uploaded to the portal . No content part searching per se.

NOTE:This reminds me: the code above was implemented for the latest Stable version 1.1 RC4...
User avatar
wireless
Posts: 138
Joined: Sun 24. Oct 2004, 04:35
Location: Houston, Texas

Post by wireless »

I added the code to the cnt.13... and it did not work.

then I added the "'file_aktion = 1' as hidden var in your frontend search form" to the form in the same file and all I get is an error now.
User avatar
wireless
Posts: 138
Joined: Sun 24. Oct 2004, 04:35
Location: Houston, Texas

Post by wireless »

opps, sorry fo rthe dbl post: I added the code to the cnt.13... and it did not work.

then I added the "'file_aktion = 1' as hidden var in your frontend search form" to the form in the same file and all I get is an error now.
sebby
Posts: 28
Joined: Thu 28. Apr 2005, 00:31

Post by sebby »

Wireless: Can't help much if you don't describe the error you're getting...

Are you using phpWCMS 1.1RC4?

I'll pm you my file tomorrow if you still have troubles.

Seb
User avatar
wireless
Posts: 138
Joined: Sun 24. Oct 2004, 04:35
Location: Houston, Texas

Post by wireless »

I am running 1.2.6 currently

Here is one error I get:

Parse error: parse error, unexpected ';', expecting ')' in /home/streetta/public_html/main/amazoop/config/categories.inc.php on line 32

another error I get is somplace around row 345 of the same file.
sebby
Posts: 28
Joined: Thu 28. Apr 2005, 00:31

Post by sebby »

My mod was built for 1.1RC4...

Can't help you for DEV versions.

Seb
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

wireless wrote:I added the code to the cnt.13... and it did not work.
At a minmum, you will need to replace every reference to

Code: Select all

$content["main"]
with

Code: Select all

$CNT_TMP 
(changed in newer releases).
wireless wrote:IParse error: parse error, unexpected ';', expecting ')' in /home/streetta/public_html/main/amazoop/config/categories.inc.php on line 32

another error I get is somplace around row 345 of the same file.
How did amazoop get in here? Is the search bringing up this error -or- is your install of amazoop mod *flawed* ?
User avatar
wireless
Posts: 138
Joined: Sun 24. Oct 2004, 04:35
Location: Houston, Texas

Post by wireless »

Should the amazoop folder not bee in the root of the phpwcms?
User avatar
DeXXus
Posts: 2168
Joined: Fri 28. Nov 2003, 06:20
Location: USA - Florida

Post by DeXXus »

wireless wrote:Should the amazoop folder not bee in the root of the phpwcms?
I guess I'm just confused.

This thread was about a Mod to search directly from the database, all files that were uploaded to the portal.

But, your Parse error: has to do with a different (unrelated) Mod about Amazoop, right? (or not?)

Pardon my confusion.
Locked