Html.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. require_once 'PhpGtkDoc/Search2.php';
  3. /**
  4. * PHP-Gtk2-Doc result formatter for HTML
  5. *
  6. * @author Christian Weiske <cweiske@php.net>
  7. */
  8. class PhpGtkDoc_Search2_Result_Html
  9. {
  10. /**
  11. * The result types are replaced with
  12. * this titles in the output
  13. *
  14. * @var array
  15. */
  16. protected static $arTypeTitles = array(
  17. 'class' => 'Classes',
  18. 'method' => 'Methods',
  19. 'property' => 'Properties',
  20. 'field' => 'Fields',
  21. 'signal' => 'Signals',
  22. 'enum' => 'Enums',
  23. 'constructor' => 'Constructors',
  24. 'tutorial' => 'Tutorials',
  25. 'unknown' => 'Unknown type'
  26. );
  27. /**
  28. * The levels have this titles
  29. *
  30. * @var array
  31. */
  32. protected static $arLevelTitles = array(
  33. 1 => 'Very relevant',
  34. 2 => 'Relevant',
  35. 3 => 'Not so relevant'
  36. );
  37. /**
  38. * Formats the result as html and returns it.
  39. *
  40. * @param array $arResult The result you get from PhpGtkDoc_Search2::find()
  41. * @param string $strPrefix The prefix to put before the file names
  42. * @param string $strFilter The type filter (pass e.g. "method" to find methods only)
  43. *
  44. * @return string Nicely formatted ascii output
  45. */
  46. public static function format($arResult, $strPrefix = '', $strFilter = '')
  47. {
  48. $strOutput = '';
  49. foreach ($arResult as $nLevel => $arLevel) {
  50. $strLevelOutput = '';
  51. foreach ($arLevel as $strType => $arFiles) {
  52. if ($strFilter != '' && $strType != $strFilter) { continue; }
  53. $strLevelOutput .= '<h4>' . self::$arTypeTitles[$strType] . "</h4>\r\n";
  54. $strLevelOutput .= '<ul>';
  55. foreach ($arFiles as $strFile) {
  56. $strLevelOutput .= '<li><a href="'
  57. . htmlspecialchars($strPrefix . $strFile)
  58. . '">'
  59. . htmlspecialchars(PhpGtkDoc_Search2::getFileTitle($strFile, $strType))
  60. . "</a></li>\r\n";
  61. }
  62. $strLevelOutput .= '</ul>';
  63. }
  64. if ($strLevelOutput != '') {
  65. $strOutput .= '<h3>' . self::$arLevelTitles[$nLevel] . "</h3>\r\n" . $strLevelOutput;
  66. }
  67. }
  68. return $strOutput;
  69. }//public static function format($arResult, $strPrefix = '', $strFilter = '')
  70. }//class PhpGtkDoc_Search2_Result_Html
  71. ?>