PageRenderTime 43ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/gforge/www/search/include/renderers/FullProjectHtmlSearchRenderer.class.php

https://github.com/neymanna/fusionforge
PHP | 177 lines | 77 code | 28 blank | 72 comment | 23 complexity | 678378058493bce1602da922732d3aaf MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception
  1. <?php
  2. /**
  3. * GForge Search Engine
  4. *
  5. * Copyright 2004 (c) Dominik Haas, GForge Team
  6. *
  7. * http://gforge.org
  8. *
  9. * @version $Id$
  10. */
  11. require_once $gfwww.'include/pre.php';
  12. require_once $gfwww.'search/include/renderers/HtmlGroupSearchRenderer.class.php';
  13. require_once $gfwww.'search/include/renderers/ForumsHtmlSearchRenderer.class.php';
  14. require_once $gfwww.'search/include/renderers/TrackersHtmlSearchRenderer.class.php';
  15. require_once $gfwww.'search/include/renderers/TasksHtmlSearchRenderer.class.php';
  16. require_once $gfwww.'search/include/renderers/DocsHtmlSearchRenderer.class.php';
  17. require_once $gfwww.'search/include/renderers/FrsHtmlSearchRenderer.class.php';
  18. require_once $gfwww.'search/include/renderers/NewsHtmlSearchRenderer.class.php';
  19. class FullProjectHtmlSearchRenderer extends HtmlGroupSearchRenderer {
  20. /**
  21. * group id
  22. *
  23. * @var int $groupId
  24. */
  25. var $groupId;
  26. /**
  27. * the words to search for
  28. *
  29. * @var string $words
  30. */
  31. var $words;
  32. /**
  33. * flag to define whether the result must contain all words or only one of them
  34. *
  35. * @var boolean $isExact
  36. */
  37. var $isExact;
  38. /**
  39. * Constructor
  40. *
  41. * @param string $words words we are searching for
  42. * @param int $offset offset
  43. * @param boolean $isExact if we want to search for all the words or if only one matching the query is sufficient
  44. * @param int $groupId group id
  45. *
  46. */
  47. function FullProjectHtmlSearchRenderer($words, $offset, $isExact, $groupId) {
  48. $this->groupId = $groupId;
  49. $this->words = $words;
  50. $this->isExact = $isExact;
  51. $searchQuery =& $this->searchQuery;
  52. $this->HtmlGroupSearchRenderer(SEARCH__TYPE_IS_ADVANCED, $words, $isExact, $searchQuery, $groupId);
  53. }
  54. /**
  55. * flush - overwrites the flush method from htmlrenderer
  56. */
  57. function flush() {
  58. $this->writeBody();
  59. $this->writeFooter();
  60. }
  61. /**
  62. * writeBody - write the Body of the output
  63. */
  64. function writeBody() {
  65. site_project_header(array('title' => _('Advanced project search'), 'group' => $this->groupId, 'toptab'=>'none'));
  66. echo $this->getResult();
  67. }
  68. /**
  69. * getResult - returns the Body of the output
  70. *
  71. * @return string result of all selected searches
  72. */
  73. function getResult() {
  74. $html = '';
  75. $forumsRenderer = new ForumsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  76. $trackersRenderer = new TrackersHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  77. $tasksRenderer = new TasksHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  78. $docsRenderer = new DocsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  79. $frsRenderer = new FrsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  80. $newsRenderer = new NewsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  81. $validLength = (strlen($this->words) >= 3);
  82. if ($validLength || (is_numeric($this->words) && $trackersRenderer->searchQuery->implementsSearchById())) {
  83. $html .= $this->getPartResult($trackersRenderer, 'short_tracker', _('Tracker Search Results'));
  84. }
  85. if ($validLength || (is_numeric($this->words) && $forumsRenderer->searchQuery->implementsSearchById())) {
  86. $html .= $this->getPartResult($forumsRenderer, 'short_forum', _('Forum Search Results'));
  87. }
  88. if ($validLength || (is_numeric($this->words) && $tasksRenderer->searchQuery->implementsSearchById())) {
  89. $html .= $this->getPartResult($tasksRenderer, 'short_pm', _('Task Search Results'));
  90. }
  91. if ($validLength || (is_numeric($this->words) && $docsRenderer->searchQuery->implementsSearchById())) {
  92. $html .= $this->getPartResult($docsRenderer, 'short_docman', _('Documentation Search Results'));
  93. }
  94. if ($validLength || (is_numeric($this->words) && $frsRenderer->searchQuery->implementsSearchById())) {
  95. $html .= $this->getPartResult($newsRenderer, 'short_files', _('Files Search Results'));
  96. }
  97. if ($validLength || (is_numeric($this->words) && $newsRenderer->searchQuery->implementsSearchById())) {
  98. $html .= $this->getPartResult($newsRenderer, 'short_news', _('News Search Results'));
  99. }
  100. /*
  101. $renderer = new ForumsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  102. $html .= $this->getPartResult($renderer, 'short_forum', _('Forum Search Results'));
  103. $renderer = new TrackersHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  104. $html .= $this->getPartResult($renderer, 'short_tracker', _('Tracker Search Results'));
  105. $renderer = new TasksHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  106. $html .= $this->getPartResult($renderer, 'short_pm', _('Task Search Results'));
  107. $renderer = new DocsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  108. $html .= $this->getPartResult($renderer, 'short_docman', _('Documentation Search Results'));
  109. $renderer = new FrsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  110. $html .= $this->getPartResult($renderer, 'short_files', _('Files Search Results'));
  111. $renderer = new NewsHtmlSearchRenderer($this->words, $this->offset, $this->isExact, $this->groupId);
  112. $html .= $this->getPartResult($renderer, 'short_news', _('News Search Results'));
  113. */
  114. return $html.'<br />';
  115. }
  116. /**
  117. * getPartResult - returns the result of the given renderer
  118. *
  119. * @return string result of the renderer
  120. */
  121. function getPartResult($renderer, $section, $title='') {
  122. $result = '';
  123. $renderer->searchQuery->executeQuery();
  124. $query = NULL;
  125. if ($title === '')
  126. $title = $section;
  127. $result .= '<h3><a name="'.$section.'"></a>'.$title.'</h3>';
  128. if ($renderer->searchQuery->getRowsCount() > 0) {
  129. $result .= $GLOBALS['HTML']->listTabletop($renderer->tableHeaders);
  130. $result .= $renderer->getRows();
  131. $result .= $GLOBALS['HTML']->listTableBottom();
  132. } elseif(method_exists($renderer, 'getSections') && (count($renderer->getSections($this->groupId)) == 0)) {
  133. $result .= '<p>'.sprintf(_('No matches found - No sections available (check your permissions)'), htmlspecialchars($query['words'])).'</p>';
  134. } else {
  135. $result .= '<p>'.sprintf(_('No matches found'), htmlspecialchars($query['words'])).'</p>';
  136. }
  137. return $result;
  138. }
  139. }
  140. // Local Variables:
  141. // mode: php
  142. // c-file-style: "bsd"
  143. // End:
  144. ?>