User:Hendrik Brummermann/TODO/CategoryBasedSearch
Appearance
This is a prototype not completely implemented yet.
<?php /** * Search engine class for MySQL4 supporting category based searches. * **************************************************************************************** * THIS IS A PROTOTYPE. EXSPECT MISSING FEATURES (BUGS) AND INCONVINIENT CONFIGURATION. * **************************************************************************************** * * Setup: * Add theses lines to LocalSettings.php after copying this file to extensions * $wgSearchType = 'SearchMySQL4Category'; * include_once($IP.'/extensions/SearchMySQL4Category.php'); * * * @version 0.0.0.1 * @package MediaWiki * @subpackage Search */ /* Suche nach $3 $9 <br /><br /> Nur diese Einordnungen berücksichtigen: <br /> <label><input type='checkbox' value="FSV-Doku" name="cat" />FSV-Doku</label> <label><input type='checkbox' value="LSF-Doku" name="cat" />LSF-Doku</label> <label><input type='checkbox' value="POS-Doku" name="cat" />POS-Doku</label> <label><input type='checkbox' value="SOS-Doku" name="cat" />SOS-Doku</label> <label><input type='checkbox' value="ZUL-Doku" name="cat" />ZUL-Doku</label> <br /> <label><input type='checkbox' value="QISPOS-Doku" name="cat" />QISPOS-Doku</label> <label><input type='checkbox' value="QISSOS-Doku" name="cat" />QISSOS-Doku</label> <label><input type='checkbox' value="QISZUL-Doku" name="cat" />QISZUL-Doku</label> <br /> <label><input type='checkbox' value="QIS-Entwickler-Doku" name="cat" />QIS-Entwickler-Doku</label> <br /> $2 Zeige auch REDIRECTs */ require_once( 'SearchMySQL4.php' ); /** @package MediaWiki */ class SearchMySQL4Category extends SearchMySQL4 { function queryMain( $filteredTerm, $fulltext ) { $match = $this->parseQuery( $filteredTerm, $fulltext ); $page = $this->db->tableName( 'page' ); $searchindex = $this->db->tableName( 'searchindex' ); # Category based search $fromsuffix = ""; $wheresuffix = ""; $categoriesSpecified = false; $wanted = "'SHOW_ALLWAYS'"; foreach($_REQUEST as $key => $value) { $pos = strpos ($key, "cat"); if ($pos === 0) { $wanted .= ", '" . mysql_escape_string($value) . "'"; $categoriesSpecified = true; } } if ( $categoriesSpecified ) { $fromsuffix .= ", categorylinks"; $wheresuffix .= " AND $page.page_id = categorylinks.cl_from AND categorylinks.cl_to IN (" . $wanted . ")"; } $temp = 'SELECT page_id, page_namespace, page_title ' . " FROM $page,$searchindex " . $fromsuffix. ' WHERE page_id=si_page AND ' . $match . $wheresuffix; echo $temp; return $temp; } } $wgExtensionCredits['other'][] = array( 'name' => 'CategoryBasedSearch', 'version' => '0.0.0.1', 'author' => 'Hendrik Brummermann', 'url' => 'http://meta.wikimedia.org/wiki/CategoryBasedSearch', 'description' => 'UNFINISHED PROTOTYPE for category-matching in power-search.' ); ?>
This is a prototype not completely implemented yet.