[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gforge-commits] gforge/www/search/include/renderers FrsHtmlSearchRender
From: |
gsmet |
Subject: |
[Gforge-commits] gforge/www/search/include/renderers FrsHtmlSearchRenderer.class, 1.1, 1.2 AdvancedSearchHtmlSearchRenderer.class, NONE, 1.1 ForumsHtmlSearchRenderer.class, 1.1, 1.2 TrackersHtmlSearchRenderer.class, 1.1, 1.2 DocsHtmlSearchRenderer.class, 1.1, 1.2 |
Date: |
Sun, 12 Dec 2004 13:25:11 -0600 |
Update of /cvsroot/gforge/gforge/www/search/include/renderers
In directory db.perdue.net:/tmp/cvs-serv16530/www/search/include/renderers
Modified Files:
FrsHtmlSearchRenderer.class ForumsHtmlSearchRenderer.class
TrackersHtmlSearchRenderer.class DocsHtmlSearchRenderer.class
Added Files:
AdvancedSearchHtmlSearchRenderer.class
Log Message:
finalized Grand Unified Search work based on Dominik Haas' patch [#833]
Index: FrsHtmlSearchRenderer.class
===================================================================
RCS file:
/cvsroot/gforge/gforge/www/search/include/renderers/FrsHtmlSearchRenderer.class,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- FrsHtmlSearchRenderer.class 16 Oct 2004 16:36:31 -0000 1.1
+++ FrsHtmlSearchRenderer.class 12 Dec 2004 19:25:08 -0000 1.2
@@ -80,7 +80,7 @@
function getSections($groupId) {
$userIsGroupMember = $this->isGroupMember($groupId);
- return FilesSearchQuery::getSections($groupId,
$userIsGroupMember);
+ return FrsSearchQuery::getSections($groupId,
$userIsGroupMember);
}
}
--- NEW FILE: AdvancedSearchHtmlSearchRenderer.class ---
<?php
/**
* GForge Search Engine
*
* Copyright 2004 (c) Dominik Haas, GForge Team
*
* http://gforge.org
*
* @version $Id: AdvancedSearchHtmlSearchRenderer.class,v 1.1 2004/12/12
19:25:08 gsmet Exp $
*/
require_once('pre.php');
require_once('www/search/include/renderers/HtmlGroupSearchRenderer.class');
class AdvancedSearchHtmlSearchRenderer extends HtmlGroupSearchRenderer {
/**
* group id
*
* @var int $groupId
*/
var $groupId;
/**
* the words to search for
*
* @var string $words
*/
var $words;
/**
* flag to define whether the result must contain all words or only one
of them
*
* @var boolean $isExact
*/
var $isExact;
/**
* selected parents sections
*
* @var array $selectedParentSections
*/
var $selectedParentSections = array();
/**
* Constructor
*
* @param string $words words we are searching for
* @param int $offset offset
* @param boolean $isExact if we want to search for all the words or if
only one matching the query is sufficient
* @param int $groupId group id
*
*/
function AdvancedSearchHtmlSearchRenderer($words, $offset, $isExact,
$groupId) {
$this->groupId = $groupId;
$this->words = $words;
$this->isExact = $isExact;
$this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_ADVANCED,
$words, $isExact, $searchQuery, $groupId);
}
/**
* flush - overwrites the flush method from htmlrenderer
*/
function flush() {
$this->writeHeader();
$this->writeBody();
$this->writeFooter();
}
/**
* writeHeader - write the header of the output
*/
function writeHeader() {
site_project_header(array('title' =>
$this->Language->getText('advanced_search', 'project_search'), 'group' =>
$this->groupId, 'pagename' => 'advanced search', ));
$sectionarray = $this->getSectionArray();
$this->handleTransferInformation($sectionarray);
$GLOBALS['HTML']->advancedSearchBox($sectionarray,
$this->groupId, $this->words, $this->isExact);
}
/**
* writeBody - write the Body of the output
*/
function writeBody() {
if (strlen($this->words) < 3) {
echo
'<br><h1>'.$this->Language->getText('advanced_search',
'error_search_minlength').'<h1><br>';
} else {
echo $this->getResult();
}
}
/**
* getResult - returns the Body of the output
*
* @return string result of all selected searches
*/
function getResult() {
$html = '';
if (in_array('short_forum', $this->selectedParentSections)) {
$renderer = new ForumsHtmlSearchRenderer($this->words,
$this->offset, $this->isExact, $this->groupId,
$this->getSelectedChildSections('short_forum'));
$html .= $this->getPartResult($renderer, 'short_forum');
}
if (in_array('short_tracker', $this->selectedParentSections)) {
$renderer = new
TrackersHtmlSearchRenderer($this->words, $this->offset, $this->isExact,
$this->groupId, $this->getSelectedChildSections('short_tracker'));
$html .= $this->getPartResult($renderer,
'short_tracker');
}
if (in_array('short_pm', $this->selectedParentSections)) {
$renderer = new TasksHtmlSearchRenderer($this->words,
$this->offset, $this->isExact, $this->groupId,
$this->getSelectedChildSections('short_pm'));
$html .= $this->getPartResult($renderer, 'short_pm');
}
if (in_array('short_docman', $this->selectedParentSections)) {
$renderer = new DocsHtmlSearchRenderer($this->words,
$this->offset, $this->isExact, $this->groupId,
$this->getSelectedChildSections('short_docman'));
$html .= $this->getPartResult($renderer,
'short_docman');
}
if (in_array('short_files', $this->selectedParentSections)) {
$renderer = new FilesHtmlSearchRenderer($this->words,
$this->offset, $this->isExact, $this->groupId,
$this->getSelectedChildSections('short_files'));
$html .= $this->getPartResult($renderer, 'short_files');
}
if (in_array('short_news', $this->selectedParentSections)) {
$renderer = new NewsHtmlSearchRenderer($this->words,
$this->offset, $this->isExact, $this->groupId);
$html .= $this->getPartResult($renderer, 'short_news');
}
return $html.'<br />';
}
/**
* getPartResult - returns the result of the given renderer
*
* @return string result of the renderer
*/
function getPartResult($renderer, $section) {
$result = '';
$renderer->searchQuery->executeQuery();
$result .= '<h3><a
name="'.$section.'"></a>'.$this->Language->getText('advanced_search',
'headline', array($this->Language->getText('group', $section))).'</h3>';
if ($renderer->searchQuery->getRowsCount() > 0) {
$result .=
$GLOBALS['HTML']->listTabletop($renderer->tableHeaders);
$result .= $renderer->getRows();
$result .= $GLOBALS['HTML']->listTableBottom();
} elseif(method_exists($renderer, 'getSections') &&
(count($renderer->getSections($this->groupId)) == 0)) {
$result .=
'<p>'.$this->Language->getText('advanced_search',
'no_matches_found_no_under_section',
array(htmlspecialchars($query['words']))).'</p>';
} else {
$result .=
'<p>'.$this->Language->getText('advanced_search', 'no_matches_found',
array(htmlspecialchars($query['words']))).'</p>';
}
return $result;
}
/**
* getSectionArray - creates an array of sections in which the user can
search
*
* @return array sections
*/
function getSectionArray() {
$sections = array();
$group =& group_get_object($this->groupId);
if ($group->usesForum()) {
require_once('ForumsHtmlSearchRenderer.class');
$undersections =
ForumsHtmlSearchRenderer::getSections($this->groupId);
if (count($undersections) > 0) {
$sections['short_forum'] = $undersections;
}
}
if ($group->usesTracker()) {
require_once('TrackersHtmlSearchRenderer.class');
$undersections =
TrackersHtmlSearchRenderer::getSections($this->groupId);
if (count($undersections) > 0) {
$sections['short_tracker'] = $undersections;
}
}
if ($group->usesPM()) {
require_once('TasksHtmlSearchRenderer.class');
$undersections =
TasksHtmlSearchRenderer::getSections($this->groupId);
if (count($undersections) > 0) {
$sections['short_pm'] = $undersections;
}
}
if ($group->usesDocman()) {
require_once('DocsHtmlSearchRenderer.class');
$undersections =
DocsHtmlSearchRenderer::getSections($this->groupId);
if (count($undersections) > 0) {
$sections['short_docman'] = $undersections;
}
}
if ($group->usesNews()) {
require_once('NewsHtmlSearchRenderer.class');
$sections['short_news'] = true;
}
if ($group->usesFRS()) {
require_once('FrsHtmlSearchRenderer.class');
$undersections =
FrsHtmlSearchRenderer::getSections($this->groupId);
if (count($undersections) > 0) {
$sections['short_files'] = $undersections;
}
}
return $sections;
}
/**
* handleTransferInformation - marks parentsections if child is marked
and processes cookie information
*
*/
function handleTransferInformation(&$sectionarray) {
//get through all sections
//if a childsection is marked to search in, mark the parent too
$postArray = _getPostArray();
foreach($sectionarray as $key => $section) {
if(is_array($section)) {
foreach ($postArray as $postkey => $postvalue) {
if (substr($postkey, 0, strlen($key))
== $key) {
$this->selectedParentSections[]
= $key;
break;
}
}
} elseif(isset($postArray[$key])) {
$this->selectedParentSections[] = $key;
}
}
}
/**
* getSelectedChildSections - gets all selected child sections from the
given parentsection
*
* @param string $parentsection the parentsection
*
* @return array all child sections from the parent section the user
wants to search in
*/
function getSelectedChildSections($parentsection) {
$sections = array();
$postArray = _getPostArray();
foreach($postArray as $key => $value) {
if (substr($key, 0, strlen($parentsection)) ==
$parentsection) {
if (strlen(substr($key, strlen($parentsection)
, strlen($key))) > 0) {
array_push($sections,
urldecode(substr($key, strlen($parentsection), strlen($key))));
}
}
}
return $sections;
}
}
?>
Index: ForumsHtmlSearchRenderer.class
===================================================================
RCS file:
/cvsroot/gforge/gforge/www/search/include/renderers/ForumsHtmlSearchRenderer.class,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ForumsHtmlSearchRenderer.class 16 Oct 2004 16:36:31 -0000 1.1
+++ ForumsHtmlSearchRenderer.class 12 Dec 2004 19:25:08 -0000 1.2
@@ -81,7 +81,7 @@
function getSections($groupId) {
$userIsGroupMember = $this->isGroupMember($groupId);
- return $this->searchQuery->getSections($groupId,
$userIsGroupMember);
+ return ForumsSearchQuery::getSections($groupId,
$userIsGroupMember);
}
}
Index: TrackersHtmlSearchRenderer.class
===================================================================
RCS file:
/cvsroot/gforge/gforge/www/search/include/renderers/TrackersHtmlSearchRenderer.class,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- TrackersHtmlSearchRenderer.class 16 Oct 2004 16:36:31 -0000 1.1
+++ TrackersHtmlSearchRenderer.class 12 Dec 2004 19:25:08 -0000 1.2
@@ -85,7 +85,7 @@
function getSections($groupId) {
$userIsGroupMember = $this->isGroupMember($groupId);
- return $this->searchQuery->getSections($groupId,
$userIsGroupMember);
+ return TrackersSearchQuery::getSections($groupId,
$userIsGroupMember);
}
}
Index: DocsHtmlSearchRenderer.class
===================================================================
RCS file:
/cvsroot/gforge/gforge/www/search/include/renderers/DocsHtmlSearchRenderer.class,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- DocsHtmlSearchRenderer.class 16 Oct 2004 16:36:31 -0000 1.1
+++ DocsHtmlSearchRenderer.class 12 Dec 2004 19:25:08 -0000 1.2
@@ -84,7 +84,7 @@
function getSections($groupId) {
$userIsGroupMember = $this->isGroupMember($groupId);
- return $this->searchQuery->getSections($groupId,
$userIsGroupMember);
+ return DocsSearchQuery::getSections($groupId,
$userIsGroupMember);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gforge-commits] gforge/www/search/include/renderers FrsHtmlSearchRenderer.class, 1.1, 1.2 AdvancedSearchHtmlSearchRenderer.class, NONE, 1.1 ForumsHtmlSearchRenderer.class, 1.1, 1.2 TrackersHtmlSearchRenderer.class, 1.1, 1.2 DocsHtmlSearchRenderer.class, 1.1, 1.2,
gsmet <=