default_widgets.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * Default widgets landing page.
  4. *
  5. * @package Elgg.Core
  6. * @subpackage Administration.DefaultWidgets
  7. */
  8. $object = elgg_get_entities(array(
  9. 'type' => 'object',
  10. 'subtype' => 'moddefaultwidgets',
  11. 'distinct' => false,
  12. 'limit' => 1,
  13. ));
  14. if ($object) {
  15. echo elgg_view('output/url', array(
  16. 'text' => elgg_echo('upgrade'),
  17. 'href' => 'action/widgets/upgrade',
  18. 'is_action' => true,
  19. 'is_trusted' => true,
  20. 'class' => 'elgg_button elgg-button-submit',
  21. 'title' => 'Upgrade your default widgets to work on Elgg 1.8',
  22. ));
  23. }
  24. elgg_push_context('default_widgets');
  25. $widget_context = get_input('widget_context');
  26. $list = elgg_trigger_plugin_hook('get_list', 'default_widgets', null, array());
  27. // default to something if we can
  28. if (!$widget_context && $list) {
  29. $widget_context = $list[0]['widget_context'];
  30. }
  31. $current_info = null;
  32. $tabs = array();
  33. foreach ($list as $info) {
  34. $url = "admin/appearance/default_widgets?widget_context={$info['widget_context']}";
  35. $selected = false;
  36. if ($widget_context == $info['widget_context']) {
  37. $selected = true;
  38. $current_info = $info;
  39. }
  40. $tabs[] = array(
  41. 'title' => $info['name'],
  42. 'url' => $url,
  43. 'selected' => $selected
  44. );
  45. }
  46. $tabs_vars = array(
  47. 'tabs' => $tabs
  48. );
  49. echo elgg_view('navigation/tabs', $tabs_vars);
  50. echo elgg_view('output/longtext', array('value' => elgg_echo('admin:default_widgets:instructions')));
  51. if (!$current_info) {
  52. $content = elgg_echo('admin:default_widgets:unknown_type');
  53. } else {
  54. // default widgets are owned and saved to the site.
  55. elgg_set_page_owner_guid(elgg_get_config('site_guid'));
  56. elgg_push_context($current_info['widget_context']);
  57. $default_widgets_input = elgg_view('input/hidden', array(
  58. 'name' => 'default_widgets',
  59. 'value' => 1
  60. ));
  61. $params = array(
  62. 'content' => $default_widgets_input,
  63. 'num_columns' => $current_info['widget_columns'],
  64. );
  65. $content = elgg_view_layout('widgets', $params);
  66. elgg_pop_context();
  67. }
  68. elgg_pop_context();
  69. echo $content;