views.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. $data = elgg_extract("data", $vars);
  3. if (empty($data)) {
  4. return;
  5. }
  6. $views = $data['views'];
  7. $global_hooks = $data['global_hooks'];
  8. $filtered_views = $data['filtered_views'];
  9. $root = elgg_get_root_path();
  10. $strip = function ($file) use ($root) {
  11. return (0 === strpos($file, $root)) ? substr($file, strlen($root)) : $file;
  12. };
  13. $make_id = function ($view) {
  14. return "z" . md5($view);
  15. };
  16. $viewtype = elgg_extract("viewtype", $vars);
  17. $viewtypes = elgg_extract("viewtypes", $vars);
  18. foreach ($viewtypes as $type) {
  19. $href = "admin/develop_tools/inspect?inspect_type=Views";
  20. if ($type !== "default") {
  21. $href .= "&type={$type}";
  22. }
  23. elgg_register_menu_item('developers_inspect_viewtype', array(
  24. 'name' => $type,
  25. 'text' => $type,
  26. 'href' => $href,
  27. ));
  28. }
  29. echo elgg_view_menu('developers_inspect_viewtype', array(
  30. 'class' => 'elgg-tabs mbm',
  31. ));
  32. if ($global_hooks) {
  33. array_walk($global_hooks, function (&$hook) {
  34. $id = "z" . md5($hook);
  35. $hook = "<a href='?inspect_type=Plugin%20Hooks#$id'>$hook</a>";
  36. });
  37. echo "<p>" . elgg_echo("developers:inspect:views:all_filtered") . " ";
  38. echo implode(' | ', $global_hooks);
  39. echo "</p>";
  40. }
  41. echo "<table class='elgg-table-alt'>";
  42. echo "<tr>";
  43. echo "<th>" . elgg_echo('developers:inspect:views') . "</th>";
  44. echo "<th width='1%'>" . elgg_echo('developers:inspect:priority') . "</th>";
  45. echo "<th>" . elgg_echo('developers:inspect:file_location') . "</th>";
  46. echo "</tr>";
  47. $last_view = '';
  48. foreach ($views as $view => $components) {
  49. /* @var \Elgg\Debug\Inspector\ViewComponent[] $components */
  50. $view_id = $make_id($view);
  51. $rowspan = count($components);
  52. if (in_array($view, $filtered_views)) {
  53. $rowspan += 1;
  54. $id = "z" . md5("view,$view");
  55. $link = "<a href='?inspect_type=Plugin%20Hooks#$id'>view,$view</a>";
  56. $col2 = elgg_echo('developers:inspect:views:filtered', array($link));
  57. $extra_row = "<tr><td>&nbsp;</td><td>$col2</td></tr>";
  58. } else {
  59. $extra_row = "";
  60. }
  61. foreach ($components as $priority => $component) {
  62. $file = $strip($component->getFile());
  63. echo "<tr>";
  64. if ($view !== $last_view) {
  65. echo "<td id='$view_id' rowspan='$rowspan'>$view</td>";
  66. $last_view = $view;
  67. }
  68. if (0 === strpos($priority, "o:")) {
  69. echo "<td style='opacity:.6'>over</td>";
  70. echo "<td style='opacity:.6'><del>$file</del></td>";
  71. } elseif ($priority != 500) {
  72. $href = $make_id($component->view);
  73. echo "<td>$priority</td>";
  74. $link = elgg_view('admin/develop_tools/inspect/views/view_link', array(
  75. 'view' => $component->view,
  76. 'text' => $file,
  77. ));
  78. echo "<td style='opacity:.6'>$link</td>";
  79. } else {
  80. echo "<td>$priority</td>";
  81. echo "<td>$file</td>";
  82. }
  83. echo "</tr>";
  84. }
  85. echo $extra_row;
  86. }
  87. echo "</table>";